[
  {
    "path": ".github/FUNDING.yml",
    "content": "github: [balupton]\npatreon: bevry\nopen_collective: bevry\nko_fi: balupton\nliberapay: bevry\ncustom: ['https://bevry.me/fund']\n"
  },
  {
    "path": ".gitignore",
    "content": ".build\n/node_modules\n/.idea\nnpm-debug.log\n"
  },
  {
    "path": "HISTORY.md",
    "content": "## History\n\n- v1.8b2 - June 22 2013\n    - Introduced uncompressed bundled files #287\n    - Copied component.json to bower.json #291 and used right tag #286\n    - Fixed wrong argument passed to History.getHash() #305, #297, #292 (@Izkata)\n\n- v1.8b1 - May 31 2013\n    - Fixed \"encoded string automatically unencoded on html5 browsers\" #282, #236, #272\n\n- v1.8a4 - February 13 2013\n    - Fixed coffee script warnings (ExtJS & Dojo adapter, IE 6 iFrame)\n    - Updated qUnit to release 1.11.0, jQuery to release 1.9.1\n\n- v1.8a3 - February 5 2013\n\t- Added tests for Dojo and ExtJS\n\t- Changed setting of title and url\n\t- Testing status\n\t\t- All HTML5 Native Adapter fail in all browsers on Test 10\n\t\t- All other HTML5 tests work fine\n\t\t- All other HTML4 tests fail in Test 4 (in IE)\n\n- v1.8a2 - January 21 2013\n\t- Fixed hashchange / statechange triggers: e.g. if a user in a HTML5 browser clicks a link, statechange is fired, in a HTML4 browser only hashchange, but state has also changed\n\t- UTF8 / url encoding / decoding tested and so resolved: #64, #107, #108, #162, #177, #187, #205, #207, #210, #228, #251\n\t- Fixed #244\n\n- v1.8a1 - January 19 2013\n\t- Pass options to `init()` as json is now supported\n\t- Added unicode demo\n\t- Introduced `getCurrentIndex()`, so you can get previous state by `History.getStateByIndex(getCurrentIndex()-1)`\n\t- Fixed HTML4 endless loop when url starts with a slash (e.g. /welcome/hello) #239, #232, #185\n\t- Bundled and compressed all scripts\n\t- Responsed (and therefore solved) or old issues from balupton repository: #250, #242, #238, #234, #224, #213, #206, #195, #183, #181, #180, #179, #175, #168\n\t- Fixed (or merged and therefore fixed) old issues from balupton repository: #248, #239, #236, #235, #229, #221, #220, #218, #215, #214, #212, #203, #191, #189, #172, #171, #166  \n\t- Feedback for UTF8 / url encode issues necessary, related problems (thanks to riyad)\n\t\t- #64, #107, #108, #162, #177, #187, #205, #207, #210, #228\n\n- v1.7.2 - January 18 2013\n\t- Updated project README\n\t- Integrated ExtJS Adapter (thanks to @seanadkinson!)\n\t- Merged from forks\n\t\t- added option to force no suid (@hrunting, @sbearcsiro)\n\t\t- provide a consistent URI-encoded document.location.href (@hrunting, @sbearcsiro)\n\t\t- Change History.getHash to return consistent hash, ala History.getLocationHref (@sbearcsiro)\n\t\t- Fix an issue where HTML4 replaceState wasn't firing when SUIDs were disabled and the url didn't change (@sbearcsiro)\n\t\t- Make extractId ignore the fragment if one is present (normally the hash is passed without an fragment) (@sbearcsiro)\n\t\t- Remove all encoding / decoding of URLs except when creating or extracting a fragment, based on the assumption that all inputs to replaceState / pushState are appropriately encoded (@sbearcsiro)\n\t\t- Change escapeHash/unescapeHash methods to use encodeURI/decodeURI instead of window.escape/unescape (@sbearcsiro)\n\t\t- Fixed issue #158 (@sbearcsiro)\n\t\t- isEmptyObject should use hasOwnProperty: prevents from always returning true if the Object.prototype is extended (@Alexander Johansson)\n\t\t- Add potential fix for IE8 not returning full hashed url from getLocationHref when hash contains encoded characters (@sbearcsiro)\n\t\t- Match current W3C popState event semantics for HTML4 (@STRML)\n\t\t- Added History.options.html4Mode for easier debugging (@gigafied)\n\t\t- Added History.options.delayInit (Boolean). (@gigafied)\n\t\t- Added error testing and quota relief for sessionStorage.setItem (@jamie-pate)\n\t\t- Fix IE 6 HTTPS warning (@Daniel15)\n\t\t- Fixed bug in html4 pushState function which left History in a busy state (@joelarson4)\n\t\t- Disable session storage if it's present but not working, thanks to @paulschreiber (@sbearcsiro)\n\t\t- Add Lakin Wecker's dojo adapter (@sbearcsiro)\n\t\t- Add dojo 1.8 tests (@sbearcsiro)\n\t\t- Change dojo adapter to not use dojo events, it seems to break other parts of dojo (@sbearcsiro)\n\t\t- Removes stray spaces so that the build script can run. (@billmag)\n\t\t- fixed an issue in Safari's Private Browsing mode where setItem throws an exception (@billmag)\n\t\t- Adds better error handling for the quota exceeded problem seen with the iPad. (@billmag)\n\t\t- Consolidated var in sessionStorage to the top of the function. Re-build compressed and bundled. (@billmag)\n\n- v1.7.1 - October 4 2011\n\t- Added a new native adapter which is framework agnostic (can be used with, or without any framework)\n\t- Provided bundled files\n\t- Added RightJS adapter\n\t- Updated supported browser listing\n\t- Added sessionStorage support in core instead of optional Amplify.js Store support\n\t- Fixed issue with state id generation growing slower over time\n\t- Closes #104, #95, #102, #92, #81, #90, #94, #93, #91, #67, #83, #54, #45\n\n- v1.7.0 - April 1 2011\n\t- Added `History.enabled` property (refer to usage section). This reflects whether or not History.js is enabled for our particular browser. For instance, if we have not included support for a HTML4 browser and we are accessing through a HTML4 browser then `History.enabled` will be `false`.\n\t- Added (optional but recommended) Data Persistance and Synchronisation Support thanks to [AppendTo's](http://appendto.com/) [Amplify.js](http://amplifyjs.com/) (refer to installation and compatibility sections for details)\n\t- Made HTML5 SUIDs more transparent - [Reported](https://github.com/balupton/history.js/issues#issue/34) by [azago](https://github.com/azago) and [Mark Jaquith](http://markjaquith.com/)\n\t- Fixed Session Storage Issue - Reported by a whole bunch of different people; [one](https://github.com/balupton/history.js/issues#issue/36), [two](https://github.com/balupton/history.js/issues#issue/37), [three](http://getsatisfaction.com/balupton/topics/history_js_1_6_losing_state_after_manual_page_reload)\n\t- Fixed URL Encoding Issue - [Reported](https://github.com/balupton/history.js/issues/#issue/33) by [Rob Madole](http://robmadole.com/)\n\t- Disabled support for IE6,7,8 when using the Prototype Adapter (there is nothing we can do about this, it is due to a bug in the prototype library) - [Reported](https://github.com/balupton/history.js/issues#issue/39) by [Sindre Wimberger](http://sindre.at/)\n\t- URLs in the State Hashes for HTML4 Browsers are now even shorter - [Discussion](https://github.com/balupton/history.js/issues#issue/28)\n\t- Fixed a issue with the MooTools Adapter and JSON with IE7 and IE8\n\n- v1.6.0 - March 22 2011\n\t- Added Zepto adapter thanks to [Matt Garrett](http://twitter.com/#!/matthewgarrett)\n\t- The readme now references the supported versions of the libraries we use\n\t- Updated vendors to the most recent versions. jQuery 1.5.1 and Mootools 1.3.1\n\t- Reverted versions of Safari iOS prior to version 4.3 to be HTML4 browsers, Safari iOS 4.3 is a HTML5 browser\n\t- Refined code in History.js and its adapters\n\t- Fixed issue with extra state being inserted on Safari 5 requiring an extra click on the back button to go home - [Reported](https://github.com/balupton/history.js/issues#issue/17) by [Rob Madole](http://robmadole.com/)\n\t- Fixed issue with Safari 5 and Safari iOS 4 sometimes failing to apply the state change under busy conditions - Solution conceived with [Matt Garrett](http://twitter.com/matthewgarrett)\n\t- Fixed issue with HTML4 browsers requiring a query-string in the urls of states - [Reported](https://github.com/balupton/history.js/issues#issue/26) by [azago](https://github.com/azago)\n\t- Fixed issue with HTML4 browsers requiring title in the states in order to use state data - [Reported](https://github.com/balupton/history.js/issues#issue/25) by [Jonathan McLaughlin](http://system-werks.com/)\n\t- Fixed issue with HTML4 browsers failing is a state is pushed/replaced twice in a row - [Reported](https://github.com/balupton/history.js/issues#issue/17) by [Joey Baker](http://byjoeybaker.com/)\n\t- **B/C BREAK:** The `statechange` event now only fires if the state has changed; it no longer fires on page initialisation. This is following the [Firefox 4 History API Changes](http://hacks.mozilla.org/2011/03/history-api-changes-in-firefox-4/) which we agree with - this breaks standard, but makes more sense.\n\n- v1.5.0 - February 12 2011\n\t- Moved to UglifyJS instead of Google Closure\n\t- Split HTML4 functionality from HTML5 functionality\n\t- Installation details have changed (the filenames are different)\n\n- v1.4.1 - February 10 2011\n\t- Added HTML History API Support for Safari 5 and Safari iOS 4.2.1\n\t- Cleaned code a bit (mostly with unit tests)\n\n- v1.4.0 - February 10 2011\n\t- Unit Testing now uses [QUnit](http://docs.jquery.com/Qunit)\n\t- Corrected Safari 5 Support\n\t- Now uses queues instead of timeouts\n\t\t- This means the API works exactly as expected, no more need to wrap calls in timeouts\n\t- Included a Subscribe Form in the Demo for Version Updates via Email\n\t- Small updates to Documentation\n\n- v1.3.1 - February 4 2011\n\t- Improved Documentation\n\n- v1.3.0 - January 31 2011\n\t- Support for cleaner HTML4 States\n\n- v1.2.1 - January 30 2011\n\t- Fixed History.log always being called - [reported by dlee](https://github.com/balupton/history.js/issues/#issue/2)\n\t- Re-Added `History.go(index)` support\n\n- v1.2.0 - January 25 2011\n\t- Support for HTML4 States in HTML5 Browsers (added test)\n\t- Updates of Documentation\n\n- v1.1.0 - January 24 2011\n\t- Developed a series of automated test cases\n\t- Fixed issue with traditional anchors\n\t- Fixed issue with differing replaceState functionality in HTML4 Browsers\n\t- Fixed issue with Google Chrome artefacts being carried over to the initial state\n\t- Provided `onstatechange` and `onanchorchange` events\n\n- v1.0.0 - January 22 2011\n\t- Supported `History.pushState` and `History.replaceState` degradation\n\t- Supported jQuery, MooTools and Prototype Frameworks\n\n"
  },
  {
    "path": "LICENSE.md",
    "content": "# License\n\nCopyright &copy; 2014+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me)\n<br/>Copyright &copy; 2011-2013 Benjamin Lupton <b@lupton.cc> (http://balupton.com)\n\n## The New BSD License\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n- Neither the name of Benjamin Arthur Lupton nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "README.md",
    "content": "Memo\n==================\nWhile there are some [legitimate bugs and differences in state handling even in modern browsers](https://github.com/browserstate/history.js/wiki/The-State-of-the-HTML5-History-API), they are relatively small enough now that you can just use the native HTML5 History API. If you intend to support legacy browsers, then History.js is your bet.\n\nThis notice is here as History.js does not receive enough funding to be maintained, so it exists only in legacy condition for legacy browsers. Perhaps it still works for modern browsers, but it could really do with maintenance. Maintenance is very difficult as the library requires manual testing in HTML5 and HTML4 modes, and for each adapter, and for each browser. So that means `2^(# of adapters)^(# of browsers and their versions)` tests that need to be run by a human. Tests need to be run by a human as certain failures require browser interactions, such as navigating from the test suite to a different domain and back again, or clicking the physical back buttons, or checking if the physical back buttons actually work. This takes a lot of time.\n\nDespite History.js being one of the most popular JavaScript libraries there is, and has been used by even multi-million-user companies in its time - the reality of economy and company practices seems to be that companies prefer to fork their own internal versions and fix locally with their own devs rather than fund open-source maintainers what they would pay their own devs to make things better for everyone, including themselves, which would be cheaper - but no, that would require too many tiers of company approval that don't understand the need.\n\nAs such, if you are an open-source developer, I'd recommend just working on open-source projects that are paid for by your own consulting work or your own company (e.g. every successful open-source project). As otherwise, when they become popular, you better hope they are easily maintainable and testable, otherwise the cost of maintenance is higher than the free time of the maintainers.\n\nSo with all that said, this repo still exists for archival purposes, legacy browsers, and a hub for anarachistic issue & fork maintenance.\n\nCheers,\nBenjamin Lupton, founder of Bevry, creator of History.js\n\n\nWelcome to History.js <br/> v1.8b2, June 22 2013\n==================\n\n<!-- BADGES/ -->\n\n<span class=\"badge-slackin\"><a href=\"https://slack.bevry.me\" title=\"Join this project's slack community\"><img src=\"https://slack.bevry.me/badge.svg\" alt=\"Slack community badge\" /></a></span>\n<span class=\"badge-patreon\"><a href=\"http://patreon.com/bevry\" title=\"Donate to this project using Patreon\"><img src=\"https://img.shields.io/badge/patreon-donate-yellow.svg\" alt=\"Patreon donate button\" /></a></span>\n<span class=\"badge-gratipay\"><a href=\"https://www.gratipay.com/bevry\" title=\"Donate weekly to this project using Gratipay\"><img src=\"https://img.shields.io/badge/gratipay-donate-yellow.svg\" alt=\"Gratipay donate button\" /></a></span>\n<span class=\"badge-flattr\"><a href=\"https://flattr.com/profile/balupton\" title=\"Donate to this project using Flattr\"><img src=\"https://img.shields.io/badge/flattr-donate-yellow.svg\" alt=\"Flattr donate button\" /></a></span>\n<span class=\"badge-paypal\"><a href=\"https://bevry.me/paypal\" title=\"Donate to this project using Paypal\"><img src=\"https://img.shields.io/badge/paypal-donate-yellow.svg\" alt=\"PayPal donate button\" /></a></span>\n<span class=\"badge-bitcoin\"><a href=\"https://bevry.me/bitcoin\" title=\"Donate once-off to this project using Bitcoin\"><img src=\"https://img.shields.io/badge/bitcoin-donate-yellow.svg\" alt=\"Bitcoin donate button\" /></a></span>\n<span class=\"badge-wishlist\"><a href=\"https://bevry.me/wishlist\" title=\"Buy an item on our wishlist for us\"><img src=\"https://img.shields.io/badge/wishlist-donate-yellow.svg\" alt=\"Wishlist browse button\" /></a></span>\n\n<!-- /BADGES -->\n\n\n\n## News\n- 22/06/2013: Beta 2 of v1.8 is released. Fixes and uncompressed bundled files.\n- 31/05/2013: Beta 1 of v1.8 is released. Fixes.\n- 14/02/2013: Alpha 4 of v1.8 is released. Fixes.\n- 05/02/2013: Alpha 3 of v1.8 is released. Tests updated.\n- 21/01/2013: Alpha 2 of v1.8 is released. Correct statechange behaviour.\n- 19/01/2013: Alpha 1 of v1.8 is released. Started to categorize old balupton's issues.\n\n\n### History\n[See the `HISTORY.md` file for a detailed list of features, changes, solved issues and bugs](https://github.com/browserstate/history.js/blob/master/HISTORY.md#files)\n\n\n### Involve\nPlease create an issue if something doesn't work or if there is a browser specific bug. I'll try to fix it as soon as possible. Please send me your Pull requests if you have a nice solution! I'm also going to review old issues in balupton's repository and try to solve them too.\n\n\n## Aims\n\n- Follow the [HTML5 History API](https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history) as much as possible\n- Provide a cross-compatible experience for all HTML5 Browsers (they all implement the HTML5 History API a little bit differently causing different behaviours and sometimes bugs - History.js fixes this ensuring the experience is as expected / the same / great throughout the HTML5 browsers)\n- Provide a backwards-compatible experience for all HTML4 Browsers using a hash-fallback (including continued support for the HTML5 History API's `data`, `title`, `pushState` and `replaceState`) with the option to [remove HTML4 support if it is not right for your application](https://github.com/browserstate/history.js/wiki/Intelligent-State-Handling)\n- Provide a forwards-compatible experience for HTML4 States to HTML5 States (so if a hash-fallbacked url is accessed by a HTML5 browser it is naturally transformed into its non-hashed url equivalent)\n- Provide support for as many javascript frameworks as possible via adapters; especially [Dojo](http://dojotoolkit.org/), [ExtJS](http://www.sencha.com/), [jQuery](http://jquery.com/), [MooTools](http://mootools.net/), [Right.js](http://rightjs.org/) and [Zepto](http://zeptojs.com/).\n\n\n## Quick Install\n\n### Via Ajaxify Script\nTo ajaxify your entire website with the HTML5 History API, History.js and jQuery the [Ajaxify script](https://github.com/browserstate/ajaxify) is all you need. It's that easy.\n\n### Via Ajaxify Extension\nIf you don't have access to your server, or just want to try out the Ajaxify script first, you can install the [History.js It! Google Chrome Extension](https://github.com/browserstate/historyjsit.crx) to try out History.js via Ajaxify on select websites without actually installing History.js/Ajaxify on your server.\n\n### Via Ruby On Rails Gem\nIf you are using Rails, then the easiest way for you to try History.js would be to use [Wiselinks](https://github.com/igor-alexandrov/wiselinks) gem. Wiselinks integrates  into Rails application and allows you to start using History.js with three lines of code.\n\n\n## Direct Install\n\n### Working with History.js directly\n\n``` javascript\n(function(window,undefined){\n\n\t// Bind to StateChange Event\n\tHistory.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate\n\t\tvar State = History.getState(); // Note: We are using History.getState() instead of event.state\n\t});\n\n\t// Change our States\n\tHistory.pushState({state:1}, \"State 1\", \"?state=1\"); // logs {state:1}, \"State 1\", \"?state=1\"\n\tHistory.pushState({state:2}, \"State 2\", \"?state=2\"); // logs {state:2}, \"State 2\", \"?state=2\"\n\tHistory.replaceState({state:3}, \"State 3\", \"?state=3\"); // logs {state:3}, \"State 3\", \"?state=3\"\n\tHistory.pushState(null, null, \"?state=4\"); // logs {}, '', \"?state=4\"\n\tHistory.back(); // logs {state:3}, \"State 3\", \"?state=3\"\n\tHistory.back(); // logs {state:1}, \"State 1\", \"?state=1\"\n\tHistory.back(); // logs {}, \"Home Page\", \"?\"\n\tHistory.go(2); // logs {state:3}, \"State 3\", \"?state=3\"\n\n})(window);\n```\n\n\n### How would the above operations look in a HTML5 Browser?\n\n1. www.mysite.com\n1. www.mysite.com/?state=1\n1. www.mysite.com/?state=2\n1. www.mysite.com/?state=3\n1. www.mysite.com/?state=4\n1. www.mysite.com/?state=3\n1. www.mysite.com/?state=1\n1. www.mysite.com\n1. www.mysite.com/?state=3\n\n> Note: These urls also work in HTML4 browsers and Search Engines. So no need for the hashbang (`#!`) fragment-identifier that google [\"recommends\"](https://github.com/browserstate/history.js/wiki/Intelligent-State-Handling).\n\n\n### How would they look in a HTML4 Browser?\n\n1. www.mysite.com\n1. www.mysite.com/#?state=1&_suid=1\n1. www.mysite.com/#?state=2&_suid=2\n1. www.mysite.com/#?state=3&_suid=3\n1. www.mysite.com/#?state=4\n1. www.mysite.com/#?state=3&_suid=3\n1. www.mysite.com/#?state=1&_suid=1\n1. www.mysite.com\n1. www.mysite.com/#?state=3&_suid=3\n\n> Note 1: These urls also work in HTML5 browsers - we use `replaceState` to transform these HTML4 states into their HTML5 equivalents so the user won't even notice :-)\n>\n> Note 2: These urls will be automatically url-encoded in IE6 to prevent certain browser-specific bugs.\n>\n> Note 3: Support for HTML4 browsers (this hash fallback) is optional [- why supporting HTML4 browsers could be either good or bad based on my app's use cases](https://github.com/browserstate/history.js/wiki/Intelligent-State-Handling)\n\n\n### What's the deal with the SUIDs used in the HTML4 States?\n\n- SUIDs (State Unique Identifiers) are used when we utilise a `title` and/or `data` in our state. Adding a SUID allows us to associate particular states with data and titles while keeping the urls as simple as possible (don't worry it's all tested, working and a lot smarter than I'm making it out to be).\n- If you aren't utilising `title` or `data` then we don't even include a SUID (as there is no need for it) - as seen by State 4 above :-)\n- We also shrink the urls to make sure that the smallest url will be used. For instance we will adjust `http://www.mysite.com/#http://www.mysite.com/projects/History.js` to become `http://www.mysite.com/#/projects/History.js` automatically. (again tested, working, and smarter).\n- It works with domains, subdomains, subdirectories, whatever - doesn't matter where you put it. It's smart.\n- Safari 5 will also have a SUID appended to the URL, it is entirely transparent but just a visible side-effect. It is required to fix a bug with Safari 5.\n\n\n### Is there a working demo?\n\n- Sure is, give it a download and navigate to the demo directory in your browser :-)\n- If you are after something a bit more adventurous than a end-user demo, open up the tests directory in your browser and editor - it'll rock your world and show all the vast use cases that History.js supports.\n\n\n## Download & Installation\n\n- Download History.js and upload it to your webserver. Download links: [tar.gz](https://github.com/browserstate/history.js/tarball/master) or [zip](https://github.com/browserstate/history.js/zipball/master)\n\n- Include History.js\n\n\t- For [Dojo](http://dojotoolkit.org/) v1.8+\n\n\t\t``` html\n\t\t<script src=\"http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/dojo.history.js\"></script>\n\t\t```\n\t\n\t- For [ExtJs](http://www.sencha.com/) v1.8+\n\n\t\t``` html\n\t\t<script src=\"http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/extjs.history.js\"></script>\n\t\t```\n\t\n\t- For [jQuery](http://jquery.com/) v1.3+\n\n\t\t``` html\n\t\t<script src=\"http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/jquery.history.js\"></script>\n\t\t```\n\n\t- For [Mootools](http://mootools.net/) v1.3+\n\n\t\t``` html\n\t\t<script src=\"http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/mootools.history.js\"></script>\n\t\t```\n\n\t- For [Right.js](http://rightjs.org/) v2.2+\n\n\t\t``` html\n\t\t<script src=\"http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/right.history.js\"></script>\n\t\t```\n\n\t- For [Zepto](http://zeptojs.com/) v0.5+\n\n\t\t``` html\n\t\t<script src=\"http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/zepto.history.js\"></script>\n\t\t```\n\n\t- For everything else\n\n\t\t``` html\n\t\t<script src=\"http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/native.history.js\"></script>\n\t\t```\n\n> Note: If you want to only support HTML5 Browsers and not HTML4 Browsers (so no hash fallback support) then just change the `/html4+html5/` part in the urls to just `/html5/`. See [Why supporting HTML4 browsers could be either good or bad based on my app's use cases](https://github.com/browserstate/history.js/wiki/Intelligent-State-Handling)\n\n\n## Get Updates\n\n- For Commit RSS/Atom Updates:\n\t- You can subscribe via the [GitHub Commit Atom Feed](http://feeds.feedburner.com/historyjs)\n- For GitHub News Feed Updates:\n\t- You can click the \"watch\" button up the top right of History.js's [GitHub Project Page](https://github.com/browserstate/history.js)\n\n\n## Get Support\n\n- History.js is maintained by people like you. If you find a bug, report it to the [GitHub Issue Tracker](https://github.com/browserstate/history.js/issues). If you've fixed a bug submit a [Pull Request](https://github.com/browserstate/history.js/pulls) and add your fork to the [Network Wiki Page](https://github.com/browserstate/history.js/wiki/Network).\n\n- If you would like paid support and trainings, or have job offers, then refer to the [Network Wiki Page](https://github.com/browserstate/history.js/wiki/Network). If you are qualified with History.js, then be sure to add your details to that page too.\n\n- If your company uses History.js on your projects, and would like to see it grow and prosper (better documentation, bugfixes, upgrades, maintenance, etc.) and would love to become a corporate sponsor then do email sponsor@bevry.me\n\n- If you would like free support for History.js, then [post your question](http://stackoverflow.com/questions/ask) on [Stackoverflow](http://stackoverflow.com/about) and be sure to use the `history.js` tag when asking your question.\n\n- If you've created a website that uses History.js, or know of one, be sure to add it to the [Showcase Wiki Page](https://github.com/browserstate/history.js/wiki/Showcase).\n\n- If you'd love to +1 or like this project, then be sure to tweet about it and click the \"watch\" button up the top of its [Project Page](https://github.com/browserstate/history.js).\n\n- For anything else, refer to the [History.js GitHub Wiki Site](https://github.com/browserstate/history.js/wiki).\n\nThanks! every bit of help really does make a difference!\n\n\n\n## Browsers: Tested and Working In\n\n### HTML5 Browsers\n\n- Firefox 4+\n- Chrome 8+\n- Opera 11.5+\n- Safari 5.0+\n- Safari iOS 4.3+\n\n\n### HTML4 Browsers\n\n- IE 6, 7, 8, 9, (10)\n- Firefox 3\n- Opera 10, 11.0\n- Safari 4\n- Safari iOS 4.2, 4.1, 4.0, 3.2\n\n\n\n## Exposed API\n\n### Functions\n\n#### States\n\n- `History.pushState(data,title,url)` <br/> Pushes a new state to the browser; `data` can be null or an object, `title` can be null or a string, `url` must be a string\n- `History.replaceState(data,title,url)` <br/> Replaces the existing state with a new state to the browser; `data` can be null or an object, `title` can be null or a string, `url` must be a string\n- `History.getState()` <br/> Gets the current state of the browser, returns an object with `data`, `title` and `url`\n- `History.getStateByIndex` <br/> Gets a state by the index\n- `History.getCurrentIndex` <br/> Gets the current index\n- `History.getHash()` <br/> Gets the current hash of the browser\n\n#### Adapter\n\n- `History.Adapter.bind(element,event,callback)` <br/> A framework independent event binder, you may either use this or your framework's native event binder.\n- `History.Adapter.trigger(element,event)` <br/> A framework independent event trigger, you may either use this or your framework's native event trigger.\n- `History.Adapter.onDomLoad(callback)` <br/> A framework independent onDomLoad binder, you may either use this or your framework's native onDomLoad binder.\n\n#### Navigation\n\n- `History.back()` <br/> Go back once through the history (same as hitting the browser's back button)\n- `History.forward()` <br/> Go forward once through the history (same as hitting the browser's forward button)\n- `History.go(X)` <br/> If X is negative go back through history X times, if X is positive go forwards through history X times\n\n#### Debug\n\n- `History.log(...)` <br/> Logs messages to the console, the log element, and fallbacks to alert if neither of those two exist\n- `History.debug(...)` <br/> Same as `History.log` but only runs if `History.options.debug === true`\n\n\n\n### Options\n\n- `History.options.hashChangeInterval` <br/> How long should the interval be before hashchange checks\n- `History.options.safariPollInterval` <br/> How long should the interval be before safari poll checks\n- `History.options.doubleCheckInterval` <br/> How long should the interval be before we perform a double check\n- `History.options.disableSuid` <br/> Force History not to append suid\n- `History.options.storeInterval` <br/> How long should we wait between store calls\n- `History.options.busyDelay` <br/> How long should we wait between busy events\n- `History.options.debug` <br/> If true will enable debug messages to be logged\n- `History.options.initialTitle` <br/> What is the title of the initial state\n- `History.options.html4Mode` <br/> If true, will force HTMl4 mode (hashtags)\n- `History.options.delayInit` <br/> Want to override default options and call init manually.\n\n\n### Events\n\n- `window.onstatechange` <br/> Fired when the state of the page changes (does not include hash changes)\n- `window.onanchorchange` <br/> Fired when the anchor of the page changes (does not include state hashes)\n\n\n## Known Issues\n- Opera 11 fails to create history entries when under stressful loads (events fire perfectly, just the history events fail) - there is nothing we can do about this\n- Mercury iOS fails to apply url changes (hashes and HTML5 History API states) - there is nothing we can do about this\n\n\n## Notes on Compatibility\n\n- History.js **solves** the following browser bugs:\n\t- HTML5 Browsers\n\t\t- Chrome 8 sometimes does not contain the correct state data when traversing back to the initial state\n\t\t- Safari 5, Safari iOS 4 and Firefox 3 and 4 do not fire the `onhashchange` event when the page is loaded with a hash\n\t\t- Safari 5 and Safari iOS 4 do not fire the `onpopstate` event when the hash has changed unlike the other browsers\n\t\t- Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call / [bug report](https://bugs.webkit.org/show_bug.cgi?id=56249)\n\t\t- Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions / [bug report](https://bugs.webkit.org/show_bug.cgi?id=42940)\n\t\t- Google Chrome 8,9,10 and Firefox 4 prior to the RC will always fire `onpopstate` once the page has loaded / [change recommendation](http://hacks.mozilla.org/2011/03/history-api-changes-in-firefox-4/)\n\t\t- Safari iOS 4.0, 4.1, 4.2 have a working HTML5 History API - although the actual back buttons of the browsers do not work, therefore we treat them as HTML4 browsers\n\t\t- None of the HTML5 browsers actually utilise the `title` argument to the `pushState` and `replaceState` calls\n\t- HTML4 Browsers\n\t\t- Old browsers like MSIE 6,7 and Firefox 2 do not have a `onhashchange` event\n\t\t- MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t- Non-Opera HTML4 browsers sometimes do not apply the hash when the hash is not `urlencoded`\n\t- All Browsers\n\t\t- State data and titles do not persist once the site is left and then returned (includes page refreshes)\n\t\t- State titles are never applied to the `document.title`\n- ReplaceState functionality is emulated in HTML4 browsers by discarding the replaced state, so when the discarded state is accessed it is skipped using the appropriate `History.back()` / `History.forward()` call\n- Data persistance and synchronisation works like so: Every second or so, the SUIDs and URLs of the states will synchronise between the store and the local session. When a new session opens a familiar state (via the SUID or the URL) and it is not found locally then it will attempt to load the last known stored state with that information.\n- URLs will be unescaped to the maximum, so for instance the URL `?key=a%20b%252c` will become `?key=a b c`. This is to ensure consistency between browser url encodings.\n- Changing the hash of the page causes `onpopstate` to fire (this is expected/standard functionality). To ensure correct compatibility between HTML5 and HTML4 browsers the following events have been created:\n\t- `window.onstatechange`: this is the same as the `onpopstate` event except it does not fire for traditional anchors\n\t- `window.onanchorchange`: this is the same as the `onhashchange` event except it does not fire for states\n\n\n\n## License\n\nLicensed under the [New BSD License](http://opensource.org/licenses/BSD-3-Clause)\n<br/>Copyright &copy;  2014+ [Bevry Pty Ltd](http://bevry.me) <us@bevry.me>\n<br/>Copyright &copy;  2011-2013 [Benjamin Arthur Lupton](http://balupton.com) <b@lupton.cc>\n\nFor support see the [Getting Support](#get-support) section.\n"
  },
  {
    "path": "bower.json",
    "content": "{\n  \"name\": \"history.js\",\n  \"version\": \"1.8.0\"\n}\n"
  },
  {
    "path": "buildr-uncompressed.coffee",
    "content": "# Requires\nbuildr = require 'buildr'\nutil = require 'util'\n\n# Options\noptions =\n\twatch: false\n\tcompress: false\n\n# Configs\nconfigs =\n\tstandard:\n\t\t# Options\n\t\tname: 'standard'\n\t\twatch: options.watch\n\n\t\t# Paths\n\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t# Checking\n\t\tcheckScripts: true\n\t\tjshintOptions:\n\t\t\tbrowser: true\n\t\t\tlaxbreak: true\n\t\t\tboss: true\n\t\t\tundef: true\n\t\t\tonevar: true\n\t\t\tstrict: true\n\t\t\tnoarg: true\n\n\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\tcompressScripts: options.compress # Array or true or false\n\t\n\tother: [\n\n\t\t# -----------------------------\n\t\t# Dojo Toolkit\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+dojo'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.dojo.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/dojo.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+dojo'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.dojo.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/dojo.history.js'\n\t\t}\n\t\t\n\t\t# -----------------------------\n\t\t# ExtJS\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+extjs'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.extjs.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/extjs.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+extjs'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.extjs.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/extjs.history.js'\n\t\t}\n\n\t\t# -----------------------------\n\t\t# JQUERY\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+jquery'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.jquery.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/jquery.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+jquery'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.jquery.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/jquery.history.js'\n\t\t}\n\n\n\t\t# -----------------------------\n\t\t# MOOTOOLS\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+mootools'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.mootools.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/mootools.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+mootools'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.mootools.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/mootools.history.js'\n\t\t}\n\n\n\t\t# -----------------------------\n\t\t# NATIVE\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+native'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.native.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/native.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+native'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.native.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/native.history.js'\n\t\t}\n\n\n\t\t# -----------------------------\n\t\t# RIGHT.JS\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+right'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.right.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/right.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+right'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.right.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/right.history.js'\n\t\t}\n\n\n\t\t# -----------------------------\n\t\t# ZEPTO\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+zepto'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.zepto.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/zepto.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+zepto'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.zepto.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/zepto.history.js'\n\t\t}\n\t]\n\n# Standard\nstandardConfig = configs.standard\nstandardConfig.successHandler = ->\n\tfor config in configs.other\n\t\tbuildrInstance = buildr.createInstance config\n\t\tbuildrInstance.process()\n\n# Process\nstandardBuildr = buildr.createInstance configs.standard\nstandardBuildr.process()\n"
  },
  {
    "path": "buildr.coffee",
    "content": "# Requires\nbuildr = require 'buildr'\nutil = require 'util'\n\n# Options\noptions =\n\twatch: false\n\tcompress: true\n\n# Configs\nconfigs =\n\tstandard:\n\t\t# Options\n\t\tname: 'standard'\n\t\twatch: options.watch\n\n\t\t# Paths\n\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\t\toutPath: __dirname+'/scripts/compressed'\n\n\t\t# Checking\n\t\tcheckScripts: true\n\t\tjshintOptions:\n\t\t\tbrowser: true\n\t\t\tlaxbreak: true\n\t\t\tboss: true\n\t\t\tundef: true\n\t\t\tonevar: true\n\t\t\tstrict: true\n\t\t\tnoarg: true\n\n\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\tcompressScripts: options.compress # Array or true or false\n\t\n\tother: [\n\n\t\t# -----------------------------\n\t\t# Dojo Toolkit\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+dojo'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.dojo.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html4+html5/dojo.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+dojo'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.dojo.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html5/dojo.history.js'\n\t\t}\n\t\t\n\t\t# -----------------------------\n\t\t# ExtJS\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+extjs'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.extjs.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html4+html5/extjs.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+extjs'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.extjs.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html5/extjs.history.js'\n\t\t}\n\n\t\t# -----------------------------\n\t\t# JQUERY\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+jquery'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.jquery.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html4+html5/jquery.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+jquery'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.jquery.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html5/jquery.history.js'\n\t\t}\n\n\n\t\t# -----------------------------\n\t\t# MOOTOOLS\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+mootools'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.mootools.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html4+html5/mootools.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+mootools'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.mootools.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html5/mootools.history.js'\n\t\t}\n\n\n\t\t# -----------------------------\n\t\t# NATIVE\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+native'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.native.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html4+html5/native.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+native'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.native.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html5/native.history.js'\n\t\t}\n\n\n\t\t# -----------------------------\n\t\t# RIGHT.JS\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+right'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.right.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html4+html5/right.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+right'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.right.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html5/right.history.js'\n\t\t}\n\n\n\t\t# -----------------------------\n\t\t# ZEPTO\n\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html4+html5+zepto'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'json2.js'\n\t\t\t\t'history.adapter.zepto.js'\n\t\t\t\t'history.html4.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html4+html5/zepto.history.js'\n\t\t}\n\t\t{\n\t\t\t# Options\n\t\t\tname: 'html5+zepto'\n\t\t\twatch: options.watch\n\n\t\t\t# Paths\n\t\t\tsrcPath: __dirname+'/scripts/uncompressed'\n\n\t\t\t# Compression (without outPath only the generated bundle files are compressed)\n\t\t\tcompressScripts: options.compress # Array or true or false\n\n\t\t\t# Order\n\t\t\tscriptsOrder: [\n\t\t\t\t'history.adapter.zepto.js'\n\t\t\t\t'history.js'\n\t\t\t]\n\n\t\t\t# Bundling\n\t\t\tbundleScriptPath: __dirname+'/scripts/bundled/html5/zepto.history.js'\n\t\t}\n\t]\n\n# Standard\nstandardConfig = configs.standard\nstandardConfig.successHandler = ->\n\tfor config in configs.other\n\t\tbuildrInstance = buildr.createInstance config\n\t\tbuildrInstance.process()\n\n# Process\nstandardBuildr = buildr.createInstance configs.standard\nstandardBuildr.process()\n"
  },
  {
    "path": "component.json",
    "content": "{\n  \"name\": \"history.js\",\n  \"version\": \"1.8.0\"\n}\n"
  },
  {
    "path": "demo/bcherry-orig.html",
    "content": "\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\" />\n\n  <title>WebKit is Dropping HTML5 \"popstate\" Events</title>\n\n  <link rel=\"stylesheet\" href=\"/static/lib/css/blueprint/blueprint.min.css\" media=\"screen, projection\" />\n  <link rel=\"stylesheet\" href=\"/static/lib/css/blueprint/print.min.css\" media=\"print\" />\n  <!--[if lt IE 8]>\n    <link rel=\"stylesheet\" href=\"/static/lib/css/blueprint/ie.min.css\" media=\"screen, projection\">\n  <![endif]-->\n  <link href=\"/static/lib/css/bcherry.css\" rel=\"stylesheet\" media=\"screen\" />\n  <style>\n    #n {\n      font-size: 48px;\n    }\n    p {\n      padding: 0 20px;\n    }\n  </style>\n\n  <script type=\"text/javascript\" src=\"../vendor/jquery.js\"></script>\n\t<script type=\"text/javascript\" src=\"../scripts/uncompressed/history.adapter.jquery.js\"></script>\n\t<script type=\"text/javascript\" src=\"../scripts/uncompressed/history.js\"></script>\n\n</head>\n<body>\n  <div id=\"n\"></div>\n  <p>There's a bug in the HTML5 \"popstate\" event, as implemented in WebKit (Safari and Chrome).  View this page in one of those browsers.  Your browser has had history entries added from #0 to #19 (you should start at #19).  Hitting back/forward will navigate through these.  On each URL, the large number above should reflect the hash value.  If you hit back/forward quickly, you'll notice that your number gets out of sync with the URL.  This is because WebKit is dropping popstate events (they are not firing).  It seems to happen when outbound network requests are in progress when the user navigates in their browser happens.  In this case, your browser is downloading an image that takes 1s to serve on every popstate, so you'll have to wait 1s between backs/forwards to have the feature work correctly.  You could also cause constant network traffic by putting an image download in a setInterval, in which case your popstate events will never fire. This implementation simulates an AJAX application that makes a network request when you navigate between URLs using pushState/popstate.  View the source for more info.</p>\n  <p>This was filed as <a href=\"https://bugs.webkit.org/show_bug.cgi?id=42940\">Bug 42940</a> with WebKit on July 24, 2010. The Firefox 4 beta does not have this bug, which is good news.</p>\n  <p>This is put together by <a href=\"http://www.adequatelygood.com\">Ben Cherry</a>.  Ben is a front-end engineer at <a href=\"http://twitter.com/\">Twitter</a>, and you can follow him at <a href=\"http://twitter.com/bcherry\">@bcherry</a>.</p>\n  <script>\n    // Bind to popstate\n    $(window).bind(\"popstate\", function(e) {\n    \tvar State = e.state;\n\n      // log that this event was fired, and the current URL\n      if (window.console && window.console.log) {\n        console.log(\"popstate\", State, window.location.href);\n      }\n      // update the page\n      $(\"#n\").text(typeof State.n !== 'undefined' ? State.n : document.location.href);\n\n      // Make an outbound image request that will take 1s. This request seems to be the cause of dropped popstates.\n      // Removing this, or replacing it with something else, avoids the issue.  Even if it's replaced with slow, blocking code (i.e. 1s of execution) events are not dropped.\n      (new Image()).src = \"http://www.bcherry.net/playground/pushstate.jpg\";\n    });\n\n    // Seed the browser history\n    for (var i = 0; i < 20; i++) {\n      window.history.pushState({n:i}, i, \"?\" + i);\n      $(\"#n\").text(i);\n    }\n  </script>\n</body>\n</html>\n"
  },
  {
    "path": "demo/bcherry.html",
    "content": "\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\" />\n\n  <title>WebKit is Dropping HTML5 \"popstate\" Events</title>\n\n  <link rel=\"stylesheet\" href=\"/static/lib/css/blueprint/blueprint.min.css\" media=\"screen, projection\" />\n  <link rel=\"stylesheet\" href=\"/static/lib/css/blueprint/print.min.css\" media=\"print\" />\n  <!--[if lt IE 8]>\n    <link rel=\"stylesheet\" href=\"/static/lib/css/blueprint/ie.min.css\" media=\"screen, projection\">\n  <![endif]-->\n  <link href=\"/static/lib/css/bcherry.css\" rel=\"stylesheet\" media=\"screen\" />\n  <style>\n    #n {\n      font-size: 48px;\n    }\n    p {\n      padding: 0 20px;\n    }\n  </style>\n\n  <script type=\"text/javascript\" src=\"../vendor/jquery.js\"></script>\n\t<script type=\"text/javascript\" src=\"../scripts/uncompressed/history.adapter.jquery.js\"></script>\n\t<script type=\"text/javascript\" src=\"../scripts/uncompressed/history.js\"></script>\n\n</head>\n<body>\n  <div id=\"n\"></div>\n  <p>There's a bug in the HTML5 \"popstate\" event, as implemented in WebKit (Safari and Chrome).  View this page in one of those browsers.  Your browser has had history entries added from #0 to #19 (you should start at #19).  Hitting back/forward will navigate through these.  On each URL, the large number above should reflect the hash value.  If you hit back/forward quickly, you'll notice that your number gets out of sync with the URL.  This is because WebKit is dropping popstate events (they are not firing).  It seems to happen when outbound network requests are in progress when the user navigates in their browser happens.  In this case, your browser is downloading an image that takes 1s to serve on every popstate, so you'll have to wait 1s between backs/forwards to have the feature work correctly.  You could also cause constant network traffic by putting an image download in a setInterval, in which case your popstate events will never fire. This implementation simulates an AJAX application that makes a network request when you navigate between URLs using pushState/popstate.  View the source for more info.</p>\n  <p>This was filed as <a href=\"https://bugs.webkit.org/show_bug.cgi?id=42940\">Bug 42940</a> with WebKit on July 24, 2010. The Firefox 4 beta does not have this bug, which is good news.</p>\n  <p>This is put together by <a href=\"http://www.adequatelygood.com\">Ben Cherry</a>.  Ben is a front-end engineer at <a href=\"http://twitter.com/\">Twitter</a>, and you can follow him at <a href=\"http://twitter.com/bcherry\">@bcherry</a>.</p>\n  <p>This bug was fixed in <a href=\"http://github.com/balupton/history.js\">History.js</a> by <a href=\"http://balupton.com\">Benjamin Lupton</a>. Benjamin is a freelance web 2.0 consultant, and you can follow him at <a href=\"http://twitter.com/balupton\">@balupton</a>.</p>\n  <script>\n  \t// Prepare\n\t\twindow.History.debug.enable = true;\n\n    // Bind to popstate\n    $(window).bind(\"statechange\", function(e) {\n    \tvar State = window.History.getState();\n\n      // log that this event was fired, and the current URL\n      if (window.console && window.console.log) {\n        console.log(\"popstate\", State, window.location.href);\n      }\n      // update the page\n      $(\"#n\").text(typeof State.data.n !== 'undefined' ? State.data.n : State.url);\n\n      // Make an outbound image request that will take 1s. This request seems to be the cause of dropped popstates.\n      // Removing this, or replacing it with something else, avoids the issue.  Even if it's replaced with slow, blocking code (i.e. 1s of execution) events are not dropped.\n      (new Image()).src = \"http://www.bcherry.net/playground/pushstate.jpg\";\n    });\n\n    // Seed the browser history\n    for (var i = 0; i < 20; i++) {\n      window.History.pushState({n:i}, i, \"?\" + i);\n      $(\"#n\").text(i);\n    }\n  </script>\n</body>\n</html>\n"
  },
  {
    "path": "demo/chrome.html",
    "content": "<html>\n<head>\n\t<title>Chrome History API Data Artifact</title>\n</head>\n<body>\n\t<p>This demo demonstrates an issue with Google Chrome versions 8-10 (possibly 11) where if you push a state with data, then do history.back to the initial state, the event.state will contain the pushed states data instead of being null.</p>\n\t<p>Note: The issue requires a clean history list, as such this should always be opened in a new tab/window where there are no prior history items.</p>\n\t<p>Reported by <a href=\"http://balupton.com\">Benjamin Lupton</a> author of <a href=\"http://github.com/balupton/history.js\">History.js</a></p>\n\t<button id=\"bug\">bug</button>\n\t<button id=\"reset\">reset</button>\n\t<textarea id=\"log\" style=\"width:100%;height:200px;margin-top:1em;\"></textarea>\n\t<script type=\"text/javascript\">\n\t\t(function(){\n\n\t\t\twindow.onpopstate = function(event) {\n\t\t\t\tvar message = (\"onpopstate: location: \" + document.location.href + \", data: \" + JSON.stringify(event.state));\n\t\t\t\tdocument.getElementById('log').innerHTML += message+\"\\n\\n\";\n\t\t\t};\n\n\t\t\tdocument.getElementById('bug').onclick = function(){\n\t\t\t\tsetTimeout(function(){\n\t\t\t\t\thistory.pushState({state:'new'},'New State','?new');\n\t\t\t\t},1e3);\n\n\t\t\t\tsetTimeout(function(){\n\t\t\t\t\thistory.back();\n\t\t\t\t},2e3);\n\t\t\t};\n\n\t\t\tdocument.getElementById('reset').onclick = function(){\n\t\t\t\tdocument.location.href = document.location.href.replace(/[\\#\\?].*/,\"\");\n\t\t\t};\n\n\t\t})();\n\t</script>\n</body>\n</html>\n"
  },
  {
    "path": "demo/index.html",
    "content": "<!DOCTYPE HTML>\n<html>\n<head>\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n\t<title>\n\t\tHistory.js\n\t</title>\n</head>\n<body style=\"padding-bottom:40px\">\n\t<!-- Scripts -->\n\t<script>if ( typeof window.JSON === 'undefined' ) { document.write('<script src=\"../scripts/uncompressed/json2.js\"><\\/script>'); }</script>\n\t<script src=\"../vendor/jquery.js\"></script>\n\t<script src=\"../scripts/bundled/html4+html5/jquery.history.js\"></script>\n\n\t<!-- HTML -->\n\t<div id=\"wrap\">\n\t\t<!-- Intro -->\n\t\t<h1>History.js</h1>\n\t\t<p>History.js gracefully supports the <a href=\"https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history\">HTML5 History/State APIs</a> (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports <a href=\"http://jquery.com/\">jQuery</a>, <a href=\"http://mootools.net\">MooTools</a> and <a href=\"http://prototypejs.org\">Prototype</a>. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.</p>\n\n\t\t<!-- Textarea for Logging -->\n\t\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t\t<!-- Note -->\n\t\t<p>Click through the buttons in order and you'll get the results demonstrated in the <a href=\"../README.md\">README.md</a> file.</p>\n\n\t\t<!-- Buttons -->\n\t\t<ul id=\"buttons\">\n\t\t</ul>\n\n\t\t<!-- Our Script -->\n\t\t<script>\n\t\t\t(function(window,undefined){\n\n\t\t\t\t// Check Location\n\t\t\t\tif ( document.location.protocol === 'file:' ) {\n\t\t\t\t\talert('The HTML5 History API (and thus History.js) do not work on files, please upload it to a server.');\n\t\t\t\t}\n\n\t\t\t\t// Establish Variables\n\t\t\t\tvar\n\t\t\t\t\tState = History.getState(),\n\t\t\t\t\t$log = $('#log');\n\n\t\t\t\t// Log Initial State\n\t\t\t\tHistory.log('initial:', State.data, State.title, State.url);\n\n\t\t\t\t// Bind to State Change\n\t\t\t\tHistory.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate\n\t\t\t\t\t// Log the State\n\t\t\t\t\tvar State = History.getState(); // Note: We are using History.getState() instead of event.state\n\t\t\t\t\tHistory.log('statechange:', State.data, State.title, State.url);\n\t\t\t\t});\n\n\t\t\t\t// Prepare Buttons\n\t\t\t\tvar\n\t\t\t\t\tbuttons = document.getElementById('buttons'),\n\t\t\t\t\tscripts = [\n\t\t\t\t\t\t'History.pushState({state:1,rand:Math.random()}, \"State 1\", \"?state=1\"); // logs {state:1,rand:\"some random value\"}, \"State 1\", \"?state=1\"',\n\t\t\t\t\t\t'History.pushState({state:2,rand:Math.random()}, \"State 2\", \"?state=2\"); // logs {state:2,rand:\"some random value\"}, \"State 2\", \"?state=2\"',\n\t\t\t\t\t\t'History.replaceState({state:3,rand:Math.random()}, \"State 3\", \"?state=3\"); // logs {state:3,rand:\"some random value\"}, \"State 3\", \"?state=3\"',\n\t\t\t\t\t\t'History.pushState(null, null, \"?state=4\"); // logs {}, \"\", \"?state=4\"',\n\t\t\t\t\t\t'History.back(); // logs {state:3}, \"State 3\", \"?state=3\"',\n\t\t\t\t\t\t'History.back(); // logs {state:1}, \"State 1\", \"?state=1\"',\n\t\t\t\t\t\t'History.back(); // logs {}, \"The page you started at\", \"?\"',\n\t\t\t\t\t\t'History.go(2); // logs {state:3}, \"State 3\", \"?state=3\"'\n\t\t\t\t\t],\n\t\t\t\t\tbuttonsHTML = ''\n\t\t\t\t\t;\n\n\t\t\t\t// Add Buttons\n\t\t\t\tfor ( var i=0,n=scripts.length; i<n; ++i ) {\n\t\t\t\t\tvar _script = scripts[i];\n\t\t\t\t\tbuttonsHTML +=\n\t\t\t\t\t\t'<li><button onclick=\\'javascript:'+_script+'\\'>'+_script+'</button></li>';\n\t\t\t\t}\n\t\t\t\tbuttons.innerHTML = buttonsHTML;\n\n\t\t\t})(window);\n\t\t</script>\n\t</div>\n</body>\n</html>\n"
  },
  {
    "path": "demo/native-auto.html",
    "content": "<html>\n<head>\n</head>\n<body>\n\t<script type=\"text/javascript\">\n\t\t(function(){\n\n\t\t\twindow.onpopstate = function(event) {\n\t\t\t\tconsole.log(\"onpopstate: location: \" + document.location.href + \", data: \" + JSON.stringify(event.state));\n\t\t\t};\n\t\t\twindow.onhashchange = function(event) {\n\t\t\t\tconsole.log(\"onhashchange: location: \" + document.location.href);\n\t\t\t};\n\n\t\t\tsetTimeout(function(){\n\t\t\t\thistory.pushState({page: 1}, \"title 1\", \"?page=1\");\n\t\t\t},1e3);\n\t\t\tsetTimeout(function(){\n\t\t\t\thistory.pushState({page: 2}, \"title 2\", \"?page=2\");\n\t\t\t},2e3);\n\t\t\tsetTimeout(function(){\n\t\t\t\thistory.replaceState({page: 3}, \"title 3\", \"?page=3\");\n\t\t\t},3e3);\n\t\t\tsetTimeout(function(){\n\t\t\t\tdocument.location.hash = 'asd';\n\t\t\t},4e3);\n\t\t\tsetTimeout(function(){\n\t\t\t\thistory.back(); // alerts \"location: http://example.com/example.html?page=3#asd, state: {\"page\":3}\"\n\t\t\t},5e3);\n\t\t\tsetTimeout(function(){\n\t\t\t\thistory.back(); // alerts \"location: http://example.com/example.html?page=1, state: {\"page\":1}\"\n\t\t\t},6e3);\n\t\t\tsetTimeout(function(){\n\t\t\t\thistory.back(); // alerts \"location: http://example.com/example.html, state: null\n\t\t\t},7e3);\n\t\t\tsetTimeout(function(){\n\t\t\t\thistory.go(2);  // alerts \"location: http://example.com/example.html?page=3, state: {\"page\":3}\n\t\t\t},8e3);\n\n\t\t})();\n\t</script>\n</body>\n</html>\n"
  },
  {
    "path": "demo/native.html",
    "content": "<html>\n<head>\n\t<title>HTML5 History API Demo</title>\n</head>\n<body>\n\t<textarea id=\"log\" style=\"width:100%;height:400px;margin:1em;\"></textarea>\n\t<div id=\"url\" style=\"border:1px black dotted;height:1em;margin:1em;\"></div>\n\t<div id=\"buttons\" style=\"margin:1em;\"></div>\n\t<script type=\"text/javascript\">\n\t\t\tvar $url = document.getElementById('url'), $log = document.getElementById('log');\n\n\t\t\twindow.onpopstate = function(event) {\n\t\t\t\tvar message =\n\t\t\t\t\t\"onpopstate: \"+\n\t\t\t\t\t\"location: \" + location.href + \", \" +\n\t\t\t\t\t\"data: \" + JSON.stringify(event.state) +\n\t\t\t\t\t\"\\n\\n\"\n\t\t\t\t\t;\n\n\t\t\t\t$url.innerHTML = location.href;\n\t\t\t\t$log.innerHTML += message;\n\t\t\t\tconsole.log(message);\n\t\t\t};\n\n\t\t\twindow.onhashchange = function(event) {\n\t\t\t\tvar message =\n\t\t\t\t\t\"onhashchange: \"+\n\t\t\t\t\t\"location: \" + location.href + \", \"+\n\t\t\t\t\t\"hash: \" + location.hash +\n\t\t\t\t\t\"\\n\\n\"\n\t\t\t\t\t;\n\n\t\t\t\t$url.innerHTML = location.href;\n\t\t\t\t$log.innerHTML += message;\n\t\t\t\tconsole.log(message);\n\t\t\t};\n\n\t\t\t// Prepare Buttons\n\t\t\tvar\n\t\t\t\tbuttons = document.getElementById('buttons'),\n\t\t\t\tscripts = [\n\t\t\t\t\t'history.pushState({state:1}, \"State 1\", \"?state=1\");',\n\t\t\t\t\t'history.pushState({state:2}, \"State 2\", \"?state=2\");',\n\t\t\t\t\t'history.replaceState({state:3}, \"State 3\", \"?state=3\");',\n\t\t\t\t\t'location.hash = Math.random();',\n\t\t\t\t\t'history.back();',\n\t\t\t\t\t'history.forward();',\n\t\t\t\t\t'document.location.href = document.location.href.replace(/[\\#\\?].*/,\"\");'\n\t\t\t\t],\n\t\t\t\tbuttonsHTML = ''\n\t\t\t\t;\n\n\t\t\t// Add Buttons\n\t\t\tfor ( var i=0,n=scripts.length; i<n; ++i ) {\n\t\t\t\tvar _script = scripts[i];\n\t\t\t\tbuttonsHTML +=\n\t\t\t\t\t'<li><button onclick=\\'javascript:'+_script+'\\'>'+_script+'</button></li>';\n\t\t\t}\n\t\t\tbuttons.innerHTML = buttonsHTML;\n\t</script>\n</body>\n</html>\n"
  },
  {
    "path": "demo/navigator.html",
    "content": "<!DOCTYPE HTML>\n<html>\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n\t<title>\n\t\tNavigator Output\n\t</title>\n\t<style>\n\t\tlabel { font-weight:bold; }\n\t\tlabel:after { content: \":\"; margin-right:5px; }\n\t</style>\n</head>\n<body>\n\t<div id=\"nav\"></div>\n\t<script>\n\t\tvar nav = document.getElementById('nav'), i,v;\n\t\tfor ( i in navigator ) {\n\t\t\tvar v = navigator[i];\n\t\t\tnav.innerHTML += '<div><label>'+i+'</label>'+v+'</div>';\n\t\t}\n\t</script>\n</body>\n</html>\n"
  },
  {
    "path": "demo/safari.html",
    "content": "<html>\n<head>\n\t<title>Safari Hash ReplaceState History Traversal Bug</title>\n</head>\n<body>\n\t<p>This demo demonstrates an issue with Safari 5.0.4 (6533.20.27) handing of hashes and replace state. When a hash is set, and then replaced using replaceState the history list are then broken, when traversing back the hash does not change.</p>\n\t<p>Note: The issue requires a clean history list, as such this should always be opened in a new tab/window where there are no prior history items.</p>\n\t<p>Reported by <a href=\"http://balupton.com\">Benjamin Lupton</a> author of <a href=\"http://github.com/balupton/history.js\">History.js</a></p>\n\t<button id=\"bug\">bug</button>\n\t<button id=\"workaround\">workaround</button>\n\t<button id=\"reset\">reset</button>\n\t<textarea id=\"log\" style=\"width:100%;height:200px;margin-top:1em;\"></textarea>\n\t<script type=\"text/javascript\">\n\t\t(function(){\n\n\t\t\twindow.onpopstate = function(event) {\n\t\t\t\tvar message = (\"onpopstate: location: \" + document.location.href);\n\t\t\t\tdocument.getElementById('log').innerHTML += message+\"\\n\\n\";\n\t\t\t};\n\n\t\t\twindow.onhashchange = function(event) {\n\t\t\t\tvar message = (\"onhashchange: location: \" + document.location.href);\n\t\t\t\tdocument.getElementById('log').innerHTML += message+\"\\n\\n\";\n\t\t\t};\n\n\t\t\tdocument.getElementById('bug').onclick = function(){\n\t\t\t\tsetTimeout(function(){\n\t\t\t\t\tdocument.location.hash = Math.random();\n\t\t\t\t},1e3);\n\n\t\t\t\tsetTimeout(function(){\n\t\t\t\t\thistory.replaceState(null,'','?blah');\n\t\t\t\t},2e3);\n\n\t\t\t\tsetTimeout(function(){\n\t\t\t\t\thistory.back(); // should take us to the initial page, it doesn't\n\t\t\t\t},3e3);\n\t\t\t};\n\n\t\t\tdocument.getElementById('workaround').onclick = function(){\n\t\t\t\tsetTimeout(function(){\n\t\t\t\t\thistory.pushState(null,'','#'+Math.random());\n\t\t\t\t},1e3);\n\n\t\t\t\tsetTimeout(function(){\n\t\t\t\t\thistory.replaceState(null,'','?blah');\n\t\t\t\t},2e3);\n\n\t\t\t\tsetTimeout(function(){\n\t\t\t\t\thistory.back(); // will take us to the initial page\n\t\t\t\t},3e3);\n\t\t\t};\n\n\t\t\tdocument.getElementById('reset').onclick = function(){\n\t\t\t\tdocument.location.href = document.location.href.replace(/[\\#\\?].*/,\"\");\n\t\t\t};\n\n\t\t})();\n\t</script>\n</body>\n</html>\n"
  },
  {
    "path": "demo/unicode.html",
    "content": "<!DOCTYPE HTML>\n<html>\n<head>\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n\t<title>\n\t\tHistory.js\n\t</title>\n</head>\n<body style=\"padding-bottom:40px\">\n\t<!-- Scripts -->\n\t<script>if ( typeof window.JSON === 'undefined' ) { document.write('<script src=\"../scripts/uncompressed/json2.js\"><\\/script>'); }</script>\n\t<script src=\"../vendor/jquery.js\"></script>\n\t<script src=\"../scripts/bundled/html4+html5/jquery.history.js\"></script>\n\n\t<!-- HTML -->\n\t<div id=\"wrap\">\n\t\t<!-- Intro -->\n\t\t<h1>History.js</h1>\n\t\t<p>History.js gracefully supports unicode.</p>\n\n\t\t<!-- Textarea for Logging -->\n\t\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t\t<!-- Buttons -->\n\t\t<ul id=\"buttons\">\n\t\t</ul>\n\n\t\t<!-- Our Script -->\n\t\t<script>\n\t\t\t(function(window,undefined){\n\n\t\t\t\t// Check Location\n\t\t\t\tif ( document.location.protocol === 'file:' ) {\n\t\t\t\t\talert('The HTML5 History API (and thus History.js) do not work on files, please upload it to a server.');\n\t\t\t\t}\n\n\t\t\t\t// Establish Variables\n\t\t\t\tvar\n\t\t\t\t\tState = History.getState(),\n\t\t\t\t\t$log = $('#log');\n\n\t\t\t\t// Log Initial State\n\t\t\t\tHistory.log('initial:', State.data, State.title, State.url);\n\n\t\t\t\t// Bind to State Change\n\t\t\t\tHistory.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate\n\t\t\t\t\t// Log the State\n\t\t\t\t\tvar State = History.getState(); // Note: We are using History.getState() instead of event.state\n\t\t\t\t\tHistory.log('statechange:', State.data, State.title, State.url);\n\t\t\t\t});\n\n\t\t\t\t// Prepare Buttons\n\t\t\t\tvar\n\t\t\t\t\tbuttons = document.getElementById('buttons'),\n\t\t\t\t\tscripts = [\n\t\t\t\t\t\t'History.pushState({state:1,rand:Math.random()}, \"State 1\", \"?läu=ßüs\"); // logs {state:1,rand:\"some random value\"}, \"State 1\", \"?l#äu=ßüs\"',\n\t\t\t\t\t\t'History.pushState({state:2,rand:Math.random()}, \"State 2\", \"?chinese=リオれ\"); // logs {state:2,rand:\"some random value\"}, \"State 2\", \"/chinese/2\"',\n\t\t\t\t\t\t'History.back(); // logs {state:3}, \"State 3\", \"?state=3\"',\n\t\t\t\t\t\t'History.back(); // logs {state:1}, \"State 1\", \"?state=1\"',\n\t\t\t\t\t\t'History.back(); // logs {}, \"The page you started at\", \"?\"',\n\t\t\t\t\t\t'History.go(2); // logs {state:3}, \"State 3\", \"?state=3\"'\n\t\t\t\t\t],\n\t\t\t\t\tbuttonsHTML = ''\n\t\t\t\t\t;\n\n\t\t\t\t// Add Buttons\n\t\t\t\tfor ( var i=0,n=scripts.length; i<n; ++i ) {\n\t\t\t\t\tvar _script = scripts[i];\n\t\t\t\t\tbuttonsHTML +=\n\t\t\t\t\t\t'<li><button onclick=\\'javascript:'+_script+'\\'>'+_script+'</button></li>';\n\t\t\t\t}\n\t\t\t\tbuttons.innerHTML = buttonsHTML;\n\n\t\t\t})(window);\n\t\t</script>\n\t</div>\n</body>\n</html>\n"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"history.js\",\n\t\"version\": \"1.8.0\",\n\t\"description\": \"History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype.  For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.\",\n\t\"homepage\": \"https://github.com/browserstate/history.js\",\n\t\"keywords\": [\n\t\t\"javascript\",\n\t\t\"html5 history api\",\n\t\t\"hashchange\",\n\t\t\"popstate\",\n\t\t\"pushstate\",\n\t\t\"replacestate\",\n\t\t\"hashes\",\n\t\t\"hashbang\"\n\t],\n\t\"author\": {\n\t\t\"name\": \"Benjamin Lupton\",\n\t\t\"email\": \"b@lupton.cc\",\n\t\t\"web\": \"http://balupton.com\"\n\t},\n\t\"maintainers\": [\n\t\t{\n\t\t\t\"name\": \"Benjamin Lupton\",\n\t\t\t\"email\": \"b@lupton.cc\",\n\t\t\t\"web\": \"http://balupton.com\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"Andreas Bernhard\",\n\t\t\t\"email\": \"andreas@bernhard.im\",\n\t\t\t\"web\": \"http://www.bs-infosys.com\"\n\t\t}\n\t],\n\t\"contributors\": [\n\t\t{\n\t\t\t\"name\": \"Benjamin Lupton\",\n\t\t\t\"email\": \"b@lupton.cc\",\n\t\t\t\"web\": \"http://balupton.com\"\n\t\t},\n\t\t{\n\t\t\t\"name\": \"Andreas Bernhard\",\n\t\t\t\"email\": \"andreas@bernhard.im\",\n\t\t\t\"web\": \"http://www.bs-infosys.com\"\n\t\t}\n\t],\n\t\"bugs\": {\n\t\t\"web\": \"https://github.com/browserstate/history.js/issues\"\n\t},\n\t\"licenses\": [\n\t\t{\n\t\t\t\"type\": \"New-BSD\",\n\t\t\t\"url\": \"http://creativecommons.org/licenses/BSD/\"\n\t\t}\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"http://github.com/browserstate/history.js.git\"\n\t},\n\t\"dependencies\": {\n\t\t\"buildr\": \"0.8.x\"\n\t},\n\t\"engines\": {\n\t},\n\t\"directories\": {\n\t\t\"out\": \"./scripts/compressed\",\n\t\t\"src\": \"./scripts/uncompressed\"\n\t}\n}"
  },
  {
    "path": "scripts/bundled/html4+html5/dojo.history.js",
    "content": "typeof JSON!=\"object\"&&(JSON={}),function(){\"use strict\";function f(e){return e<10?\"0\"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'\"'+e.replace(escapable,function(e){var t=meta[e];return typeof t==\"string\"?t:\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+e+'\"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a==\"object\"&&typeof a.toJSON==\"function\"&&(a=a.toJSON(e)),typeof rep==\"function\"&&(a=rep.call(t,e,a));switch(typeof a){case\"string\":return quote(a);case\"number\":return isFinite(a)?String(a):\"null\";case\"boolean\":case\"null\":return String(a);case\"object\":if(!a)return\"null\";gap+=indent,u=[];if(Object.prototype.toString.apply(a)===\"[object Array]\"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||\"null\";return i=u.length===0?\"[]\":gap?\"[\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"]\":\"[\"+u.join(\",\")+\"]\",gap=o,i}if(rep&&typeof rep==\"object\"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]==\"string\"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i));return i=u.length===0?\"{}\":gap?\"{\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"}\":\"{\"+u.join(\",\")+\"}\",gap=o,i}}typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(e,t,n){var r;gap=\"\",indent=\"\";if(typeof n==\"number\")for(r=0;r<n;r+=1)indent+=\" \";else typeof n==\"string\"&&(indent=n);rep=t;if(!t||typeof t==\"function\"||typeof t==\"object\"&&typeof t.length==\"number\")return str(\"\",{\"\":e});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i==\"object\")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\")))return j=eval(\"(\"+text+\")\"),typeof reviver==\"function\"?walk({\"\":j},\"\"):j;throw new SyntaxError(\"JSON.parse\")})}(),function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.require;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={handlers:{},_uid:1,uid:function(e){return e._uid||(e._uid=n.Adapter._uid++)},bind:function(e,t,r){var i=n.Adapter.uid(e);n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[],n.Adapter.handlers[i][t].push(r),e[\"on\"+t]=function(e,t){return function(r){n.Adapter.trigger(e,t,r)}}(e,t)},trigger:function(e,t,r){r=r||{};var i=n.Adapter.uid(e),s,o;n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[];for(s=0,o=n.Adapter.handlers[i][t].length;s<o;++s)n.Adapter.handlers[i][t][s].apply(this,[r])},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(e){r([\"dojo/ready\"],function(t){t(e)})}},typeof n.init!=\"undefined\"&&n.init()}(window),function(e,t){\"use strict\";var n=e.document,r=e.setTimeout||r,i=e.clearTimeout||i,s=e.setInterval||s,o=e.History=e.History||{};if(typeof o.initHtml4!=\"undefined\")throw new Error(\"History.js HTML4 Support has already been loaded...\");o.initHtml4=function(){if(typeof o.initHtml4.initialized!=\"undefined\")return!1;o.initHtml4.initialized=!0,o.enabled=!0,o.savedHashes=[],o.isLastHash=function(e){var t=o.getHashByIndex(),n;return n=e===t,n},o.isHashEqual=function(e,t){return e=encodeURIComponent(e).replace(/%25/g,\"%\"),t=encodeURIComponent(t).replace(/%25/g,\"%\"),e===t},o.saveHash=function(e){return o.isLastHash(e)?!1:(o.savedHashes.push(e),!0)},o.getHashByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=o.savedHashes[o.savedHashes.length-1]:e<0?t=o.savedHashes[o.savedHashes.length+e]:t=o.savedHashes[e],t},o.discardedHashes={},o.discardedStates={},o.discardState=function(e,t,n){var r=o.getHashByState(e),i;return i={discardedState:e,backState:n,forwardState:t},o.discardedStates[r]=i,!0},o.discardHash=function(e,t,n){var r={discardedHash:e,backState:n,forwardState:t};return o.discardedHashes[e]=r,!0},o.discardedState=function(e){var t=o.getHashByState(e),n;return n=o.discardedStates[t]||!1,n},o.discardedHash=function(e){var t=o.discardedHashes[e]||!1;return t},o.recycleState=function(e){var t=o.getHashByState(e);return o.discardedState(e)&&delete o.discardedStates[t],!0},o.emulated.hashChange&&(o.hashChangeInit=function(){o.checkerFunction=null;var t=\"\",r,i,u,a,f=Boolean(o.getHash());return o.isInternetExplorer()?(r=\"historyjs-iframe\",i=n.createElement(\"iframe\"),i.setAttribute(\"id\",r),i.setAttribute(\"src\",\"#\"),i.style.display=\"none\",n.body.appendChild(i),i.contentWindow.document.open(),i.contentWindow.document.close(),u=\"\",a=!1,o.checkerFunction=function(){if(a)return!1;a=!0;var n=o.getHash(),r=o.getHash(i.contentWindow.document);return n!==t?(t=n,r!==n&&(u=r=n,i.contentWindow.document.open(),i.contentWindow.document.close(),i.contentWindow.document.location.hash=o.escapeHash(n)),o.Adapter.trigger(e,\"hashchange\")):r!==u&&(u=r,f&&r===\"\"?o.back():o.setHash(r,!1)),a=!1,!0}):o.checkerFunction=function(){var n=o.getHash()||\"\";return n!==t&&(t=n,o.Adapter.trigger(e,\"hashchange\")),!0},o.intervalList.push(s(o.checkerFunction,o.options.hashChangeInterval)),!0},o.Adapter.onDomLoad(o.hashChangeInit)),o.emulated.pushState&&(o.onHashChange=function(t){var n=t&&t.newURL||o.getLocationHref(),r=o.getHashByUrl(n),i=null,s=null,u=null,a;return o.isLastHash(r)?(o.busy(!1),!1):(o.doubleCheckComplete(),o.saveHash(r),r&&o.isTraditionalAnchor(r)?(o.Adapter.trigger(e,\"anchorchange\"),o.busy(!1),!1):(i=o.extractState(o.getFullUrl(r||o.getLocationHref()),!0),o.isLastSavedState(i)?(o.busy(!1),!1):(s=o.getHashByState(i),a=o.discardedState(i),a?(o.getHashByIndex(-2)===o.getHashByState(a.forwardState)?o.back(!1):o.forward(!1),!1):(o.pushState(i.data,i.title,encodeURI(i.url),!1),!0))))},o.Adapter.bind(e,\"hashchange\",o.onHashChange),o.pushState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,\"statechange\"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)},o.replaceState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.replaceState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getStateByIndex(-2);return o.discardState(a,s,l),u===f?(o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),o.saveState(s),o.Adapter.trigger(e,\"statechange\"),o.busy(!1)):o.pushState(s.data,s.title,s.url,!1),!0}),o.emulated.pushState&&o.getHash()&&!o.emulated.hashChange&&o.Adapter.onDomLoad(function(){o.Adapter.trigger(e,\"hashchange\")})},typeof o.init!=\"undefined\"&&o.init()}(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html4+html5/extjs.history.js",
    "content": "typeof JSON!=\"object\"&&(JSON={}),function(){\"use strict\";function f(e){return e<10?\"0\"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'\"'+e.replace(escapable,function(e){var t=meta[e];return typeof t==\"string\"?t:\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+e+'\"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a==\"object\"&&typeof a.toJSON==\"function\"&&(a=a.toJSON(e)),typeof rep==\"function\"&&(a=rep.call(t,e,a));switch(typeof a){case\"string\":return quote(a);case\"number\":return isFinite(a)?String(a):\"null\";case\"boolean\":case\"null\":return String(a);case\"object\":if(!a)return\"null\";gap+=indent,u=[];if(Object.prototype.toString.apply(a)===\"[object Array]\"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||\"null\";return i=u.length===0?\"[]\":gap?\"[\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"]\":\"[\"+u.join(\",\")+\"]\",gap=o,i}if(rep&&typeof rep==\"object\"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]==\"string\"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i));return i=u.length===0?\"{}\":gap?\"{\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"}\":\"{\"+u.join(\",\")+\"}\",gap=o,i}}typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(e,t,n){var r;gap=\"\",indent=\"\";if(typeof n==\"number\")for(r=0;r<n;r+=1)indent+=\" \";else typeof n==\"string\"&&(indent=n);rep=t;if(!t||typeof t==\"function\"||typeof t==\"object\"&&typeof t.length==\"number\")return str(\"\",{\"\":e});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i==\"object\")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\")))return j=eval(\"(\"+text+\")\"),typeof reviver==\"function\"?walk({\"\":j},\"\"):j;throw new SyntaxError(\"JSON.parse\")})}(),function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.Ext;e.JSON={stringify:r.JSON.encode,parse:r.JSON.decode};if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={observables:{},bind:function(e,t,n,i){r.EventManager.addListener(e,t,n,i);var s=r.id(e,\"history-\"),o=this.observables[s];o||(o=r.create(\"Ext.util.Observable\"),this.observables[s]=o),o.on(t,n,i)},trigger:function(e,t,n){var i=r.id(e,\"history-\"),s=this.observables[i];s&&s.fireEvent(t,n)},extractEventData:function(e,n,r){var i=n&&n.browserEvent&&n.browserEvent[e]||r&&r[e]||t;return i},onDomLoad:function(e){r.onReady(e)}},typeof n.init!=\"undefined\"&&n.init()}(window),function(e,t){\"use strict\";var n=e.document,r=e.setTimeout||r,i=e.clearTimeout||i,s=e.setInterval||s,o=e.History=e.History||{};if(typeof o.initHtml4!=\"undefined\")throw new Error(\"History.js HTML4 Support has already been loaded...\");o.initHtml4=function(){if(typeof o.initHtml4.initialized!=\"undefined\")return!1;o.initHtml4.initialized=!0,o.enabled=!0,o.savedHashes=[],o.isLastHash=function(e){var t=o.getHashByIndex(),n;return n=e===t,n},o.isHashEqual=function(e,t){return e=encodeURIComponent(e).replace(/%25/g,\"%\"),t=encodeURIComponent(t).replace(/%25/g,\"%\"),e===t},o.saveHash=function(e){return o.isLastHash(e)?!1:(o.savedHashes.push(e),!0)},o.getHashByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=o.savedHashes[o.savedHashes.length-1]:e<0?t=o.savedHashes[o.savedHashes.length+e]:t=o.savedHashes[e],t},o.discardedHashes={},o.discardedStates={},o.discardState=function(e,t,n){var r=o.getHashByState(e),i;return i={discardedState:e,backState:n,forwardState:t},o.discardedStates[r]=i,!0},o.discardHash=function(e,t,n){var r={discardedHash:e,backState:n,forwardState:t};return o.discardedHashes[e]=r,!0},o.discardedState=function(e){var t=o.getHashByState(e),n;return n=o.discardedStates[t]||!1,n},o.discardedHash=function(e){var t=o.discardedHashes[e]||!1;return t},o.recycleState=function(e){var t=o.getHashByState(e);return o.discardedState(e)&&delete o.discardedStates[t],!0},o.emulated.hashChange&&(o.hashChangeInit=function(){o.checkerFunction=null;var t=\"\",r,i,u,a,f=Boolean(o.getHash());return o.isInternetExplorer()?(r=\"historyjs-iframe\",i=n.createElement(\"iframe\"),i.setAttribute(\"id\",r),i.setAttribute(\"src\",\"#\"),i.style.display=\"none\",n.body.appendChild(i),i.contentWindow.document.open(),i.contentWindow.document.close(),u=\"\",a=!1,o.checkerFunction=function(){if(a)return!1;a=!0;var n=o.getHash(),r=o.getHash(i.contentWindow.document);return n!==t?(t=n,r!==n&&(u=r=n,i.contentWindow.document.open(),i.contentWindow.document.close(),i.contentWindow.document.location.hash=o.escapeHash(n)),o.Adapter.trigger(e,\"hashchange\")):r!==u&&(u=r,f&&r===\"\"?o.back():o.setHash(r,!1)),a=!1,!0}):o.checkerFunction=function(){var n=o.getHash()||\"\";return n!==t&&(t=n,o.Adapter.trigger(e,\"hashchange\")),!0},o.intervalList.push(s(o.checkerFunction,o.options.hashChangeInterval)),!0},o.Adapter.onDomLoad(o.hashChangeInit)),o.emulated.pushState&&(o.onHashChange=function(t){var n=t&&t.newURL||o.getLocationHref(),r=o.getHashByUrl(n),i=null,s=null,u=null,a;return o.isLastHash(r)?(o.busy(!1),!1):(o.doubleCheckComplete(),o.saveHash(r),r&&o.isTraditionalAnchor(r)?(o.Adapter.trigger(e,\"anchorchange\"),o.busy(!1),!1):(i=o.extractState(o.getFullUrl(r||o.getLocationHref()),!0),o.isLastSavedState(i)?(o.busy(!1),!1):(s=o.getHashByState(i),a=o.discardedState(i),a?(o.getHashByIndex(-2)===o.getHashByState(a.forwardState)?o.back(!1):o.forward(!1),!1):(o.pushState(i.data,i.title,encodeURI(i.url),!1),!0))))},o.Adapter.bind(e,\"hashchange\",o.onHashChange),o.pushState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,\"statechange\"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)},o.replaceState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.replaceState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getStateByIndex(-2);return o.discardState(a,s,l),u===f?(o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),o.saveState(s),o.Adapter.trigger(e,\"statechange\"),o.busy(!1)):o.pushState(s.data,s.title,s.url,!1),!0}),o.emulated.pushState&&o.getHash()&&!o.emulated.hashChange&&o.Adapter.onDomLoad(function(){o.Adapter.trigger(e,\"hashchange\")})},typeof o.init!=\"undefined\"&&o.init()}(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html4+html5/jquery.history.js",
    "content": "typeof JSON!=\"object\"&&(JSON={}),function(){\"use strict\";function f(e){return e<10?\"0\"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'\"'+e.replace(escapable,function(e){var t=meta[e];return typeof t==\"string\"?t:\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+e+'\"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a==\"object\"&&typeof a.toJSON==\"function\"&&(a=a.toJSON(e)),typeof rep==\"function\"&&(a=rep.call(t,e,a));switch(typeof a){case\"string\":return quote(a);case\"number\":return isFinite(a)?String(a):\"null\";case\"boolean\":case\"null\":return String(a);case\"object\":if(!a)return\"null\";gap+=indent,u=[];if(Object.prototype.toString.apply(a)===\"[object Array]\"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||\"null\";return i=u.length===0?\"[]\":gap?\"[\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"]\":\"[\"+u.join(\",\")+\"]\",gap=o,i}if(rep&&typeof rep==\"object\"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]==\"string\"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i));return i=u.length===0?\"{}\":gap?\"{\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"}\":\"{\"+u.join(\",\")+\"}\",gap=o,i}}typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(e,t,n){var r;gap=\"\",indent=\"\";if(typeof n==\"number\")for(r=0;r<n;r+=1)indent+=\" \";else typeof n==\"string\"&&(indent=n);rep=t;if(!t||typeof t==\"function\"||typeof t==\"object\"&&typeof t.length==\"number\")return str(\"\",{\"\":e});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i==\"object\")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\")))return j=eval(\"(\"+text+\")\"),typeof reviver==\"function\"?walk({\"\":j},\"\"):j;throw new SyntaxError(\"JSON.parse\")})}(),function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.jQuery;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){r(e).bind(t,n)},trigger:function(e,t,n){r(e).trigger(t,n)},extractEventData:function(e,n,r){var i=n&&n.originalEvent&&n.originalEvent[e]||r&&r[e]||t;return i},onDomLoad:function(e){r(e)}},typeof n.init!=\"undefined\"&&n.init()}(window),function(e,t){\"use strict\";var n=e.document,r=e.setTimeout||r,i=e.clearTimeout||i,s=e.setInterval||s,o=e.History=e.History||{};if(typeof o.initHtml4!=\"undefined\")throw new Error(\"History.js HTML4 Support has already been loaded...\");o.initHtml4=function(){if(typeof o.initHtml4.initialized!=\"undefined\")return!1;o.initHtml4.initialized=!0,o.enabled=!0,o.savedHashes=[],o.isLastHash=function(e){var t=o.getHashByIndex(),n;return n=e===t,n},o.isHashEqual=function(e,t){return e=encodeURIComponent(e).replace(/%25/g,\"%\"),t=encodeURIComponent(t).replace(/%25/g,\"%\"),e===t},o.saveHash=function(e){return o.isLastHash(e)?!1:(o.savedHashes.push(e),!0)},o.getHashByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=o.savedHashes[o.savedHashes.length-1]:e<0?t=o.savedHashes[o.savedHashes.length+e]:t=o.savedHashes[e],t},o.discardedHashes={},o.discardedStates={},o.discardState=function(e,t,n){var r=o.getHashByState(e),i;return i={discardedState:e,backState:n,forwardState:t},o.discardedStates[r]=i,!0},o.discardHash=function(e,t,n){var r={discardedHash:e,backState:n,forwardState:t};return o.discardedHashes[e]=r,!0},o.discardedState=function(e){var t=o.getHashByState(e),n;return n=o.discardedStates[t]||!1,n},o.discardedHash=function(e){var t=o.discardedHashes[e]||!1;return t},o.recycleState=function(e){var t=o.getHashByState(e);return o.discardedState(e)&&delete o.discardedStates[t],!0},o.emulated.hashChange&&(o.hashChangeInit=function(){o.checkerFunction=null;var t=\"\",r,i,u,a,f=Boolean(o.getHash());return o.isInternetExplorer()?(r=\"historyjs-iframe\",i=n.createElement(\"iframe\"),i.setAttribute(\"id\",r),i.setAttribute(\"src\",\"#\"),i.style.display=\"none\",n.body.appendChild(i),i.contentWindow.document.open(),i.contentWindow.document.close(),u=\"\",a=!1,o.checkerFunction=function(){if(a)return!1;a=!0;var n=o.getHash(),r=o.getHash(i.contentWindow.document);return n!==t?(t=n,r!==n&&(u=r=n,i.contentWindow.document.open(),i.contentWindow.document.close(),i.contentWindow.document.location.hash=o.escapeHash(n)),o.Adapter.trigger(e,\"hashchange\")):r!==u&&(u=r,f&&r===\"\"?o.back():o.setHash(r,!1)),a=!1,!0}):o.checkerFunction=function(){var n=o.getHash()||\"\";return n!==t&&(t=n,o.Adapter.trigger(e,\"hashchange\")),!0},o.intervalList.push(s(o.checkerFunction,o.options.hashChangeInterval)),!0},o.Adapter.onDomLoad(o.hashChangeInit)),o.emulated.pushState&&(o.onHashChange=function(t){var n=t&&t.newURL||o.getLocationHref(),r=o.getHashByUrl(n),i=null,s=null,u=null,a;return o.isLastHash(r)?(o.busy(!1),!1):(o.doubleCheckComplete(),o.saveHash(r),r&&o.isTraditionalAnchor(r)?(o.Adapter.trigger(e,\"anchorchange\"),o.busy(!1),!1):(i=o.extractState(o.getFullUrl(r||o.getLocationHref()),!0),o.isLastSavedState(i)?(o.busy(!1),!1):(s=o.getHashByState(i),a=o.discardedState(i),a?(o.getHashByIndex(-2)===o.getHashByState(a.forwardState)?o.back(!1):o.forward(!1),!1):(o.pushState(i.data,i.title,encodeURI(i.url),!1),!0))))},o.Adapter.bind(e,\"hashchange\",o.onHashChange),o.pushState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,\"statechange\"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)},o.replaceState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.replaceState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getStateByIndex(-2);return o.discardState(a,s,l),u===f?(o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),o.saveState(s),o.Adapter.trigger(e,\"statechange\"),o.busy(!1)):o.pushState(s.data,s.title,s.url,!1),!0}),o.emulated.pushState&&o.getHash()&&!o.emulated.hashChange&&o.Adapter.onDomLoad(function(){o.Adapter.trigger(e,\"hashchange\")})},typeof o.init!=\"undefined\"&&o.init()}(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html4+html5/mootools.history.js",
    "content": "typeof JSON!=\"object\"&&(JSON={}),function(){\"use strict\";function f(e){return e<10?\"0\"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'\"'+e.replace(escapable,function(e){var t=meta[e];return typeof t==\"string\"?t:\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+e+'\"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a==\"object\"&&typeof a.toJSON==\"function\"&&(a=a.toJSON(e)),typeof rep==\"function\"&&(a=rep.call(t,e,a));switch(typeof a){case\"string\":return quote(a);case\"number\":return isFinite(a)?String(a):\"null\";case\"boolean\":case\"null\":return String(a);case\"object\":if(!a)return\"null\";gap+=indent,u=[];if(Object.prototype.toString.apply(a)===\"[object Array]\"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||\"null\";return i=u.length===0?\"[]\":gap?\"[\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"]\":\"[\"+u.join(\",\")+\"]\",gap=o,i}if(rep&&typeof rep==\"object\"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]==\"string\"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i));return i=u.length===0?\"{}\":gap?\"{\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"}\":\"{\"+u.join(\",\")+\"}\",gap=o,i}}typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(e,t,n){var r;gap=\"\",indent=\"\";if(typeof n==\"number\")for(r=0;r<n;r+=1)indent+=\" \";else typeof n==\"string\"&&(indent=n);rep=t;if(!t||typeof t==\"function\"||typeof t==\"object\"&&typeof t.length==\"number\")return str(\"\",{\"\":e});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i==\"object\")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\")))return j=eval(\"(\"+text+\")\"),typeof reviver==\"function\"?walk({\"\":j},\"\"):j;throw new SyntaxError(\"JSON.parse\")})}(),function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.MooTools,i=e.Element;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");Object.append(i.NativeEvents,{popstate:2,hashchange:2}),n.Adapter={bind:function(e,t,n){var r=typeof e==\"string\"?document.id(e):e;r.addEvent(t,n)},trigger:function(e,t,n){var r=typeof e==\"string\"?document.id(e):e;r.fireEvent(t,n)},extractEventData:function(e,n){var r=n&&n.event&&n.event[e]||n&&n[e]||t;return r},onDomLoad:function(t){e.addEvent(\"domready\",t)}},typeof n.init!=\"undefined\"&&n.init()}(window),function(e,t){\"use strict\";var n=e.document,r=e.setTimeout||r,i=e.clearTimeout||i,s=e.setInterval||s,o=e.History=e.History||{};if(typeof o.initHtml4!=\"undefined\")throw new Error(\"History.js HTML4 Support has already been loaded...\");o.initHtml4=function(){if(typeof o.initHtml4.initialized!=\"undefined\")return!1;o.initHtml4.initialized=!0,o.enabled=!0,o.savedHashes=[],o.isLastHash=function(e){var t=o.getHashByIndex(),n;return n=e===t,n},o.isHashEqual=function(e,t){return e=encodeURIComponent(e).replace(/%25/g,\"%\"),t=encodeURIComponent(t).replace(/%25/g,\"%\"),e===t},o.saveHash=function(e){return o.isLastHash(e)?!1:(o.savedHashes.push(e),!0)},o.getHashByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=o.savedHashes[o.savedHashes.length-1]:e<0?t=o.savedHashes[o.savedHashes.length+e]:t=o.savedHashes[e],t},o.discardedHashes={},o.discardedStates={},o.discardState=function(e,t,n){var r=o.getHashByState(e),i;return i={discardedState:e,backState:n,forwardState:t},o.discardedStates[r]=i,!0},o.discardHash=function(e,t,n){var r={discardedHash:e,backState:n,forwardState:t};return o.discardedHashes[e]=r,!0},o.discardedState=function(e){var t=o.getHashByState(e),n;return n=o.discardedStates[t]||!1,n},o.discardedHash=function(e){var t=o.discardedHashes[e]||!1;return t},o.recycleState=function(e){var t=o.getHashByState(e);return o.discardedState(e)&&delete o.discardedStates[t],!0},o.emulated.hashChange&&(o.hashChangeInit=function(){o.checkerFunction=null;var t=\"\",r,i,u,a,f=Boolean(o.getHash());return o.isInternetExplorer()?(r=\"historyjs-iframe\",i=n.createElement(\"iframe\"),i.setAttribute(\"id\",r),i.setAttribute(\"src\",\"#\"),i.style.display=\"none\",n.body.appendChild(i),i.contentWindow.document.open(),i.contentWindow.document.close(),u=\"\",a=!1,o.checkerFunction=function(){if(a)return!1;a=!0;var n=o.getHash(),r=o.getHash(i.contentWindow.document);return n!==t?(t=n,r!==n&&(u=r=n,i.contentWindow.document.open(),i.contentWindow.document.close(),i.contentWindow.document.location.hash=o.escapeHash(n)),o.Adapter.trigger(e,\"hashchange\")):r!==u&&(u=r,f&&r===\"\"?o.back():o.setHash(r,!1)),a=!1,!0}):o.checkerFunction=function(){var n=o.getHash()||\"\";return n!==t&&(t=n,o.Adapter.trigger(e,\"hashchange\")),!0},o.intervalList.push(s(o.checkerFunction,o.options.hashChangeInterval)),!0},o.Adapter.onDomLoad(o.hashChangeInit)),o.emulated.pushState&&(o.onHashChange=function(t){var n=t&&t.newURL||o.getLocationHref(),r=o.getHashByUrl(n),i=null,s=null,u=null,a;return o.isLastHash(r)?(o.busy(!1),!1):(o.doubleCheckComplete(),o.saveHash(r),r&&o.isTraditionalAnchor(r)?(o.Adapter.trigger(e,\"anchorchange\"),o.busy(!1),!1):(i=o.extractState(o.getFullUrl(r||o.getLocationHref()),!0),o.isLastSavedState(i)?(o.busy(!1),!1):(s=o.getHashByState(i),a=o.discardedState(i),a?(o.getHashByIndex(-2)===o.getHashByState(a.forwardState)?o.back(!1):o.forward(!1),!1):(o.pushState(i.data,i.title,encodeURI(i.url),!1),!0))))},o.Adapter.bind(e,\"hashchange\",o.onHashChange),o.pushState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,\"statechange\"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)},o.replaceState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.replaceState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getStateByIndex(-2);return o.discardState(a,s,l),u===f?(o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),o.saveState(s),o.Adapter.trigger(e,\"statechange\"),o.busy(!1)):o.pushState(s.data,s.title,s.url,!1),!0}),o.emulated.pushState&&o.getHash()&&!o.emulated.hashChange&&o.Adapter.onDomLoad(function(){o.Adapter.trigger(e,\"hashchange\")})},typeof o.init!=\"undefined\"&&o.init()}(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html4+html5/native.history.js",
    "content": "typeof JSON!=\"object\"&&(JSON={}),function(){\"use strict\";function f(e){return e<10?\"0\"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'\"'+e.replace(escapable,function(e){var t=meta[e];return typeof t==\"string\"?t:\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+e+'\"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a==\"object\"&&typeof a.toJSON==\"function\"&&(a=a.toJSON(e)),typeof rep==\"function\"&&(a=rep.call(t,e,a));switch(typeof a){case\"string\":return quote(a);case\"number\":return isFinite(a)?String(a):\"null\";case\"boolean\":case\"null\":return String(a);case\"object\":if(!a)return\"null\";gap+=indent,u=[];if(Object.prototype.toString.apply(a)===\"[object Array]\"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||\"null\";return i=u.length===0?\"[]\":gap?\"[\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"]\":\"[\"+u.join(\",\")+\"]\",gap=o,i}if(rep&&typeof rep==\"object\"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]==\"string\"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i));return i=u.length===0?\"{}\":gap?\"{\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"}\":\"{\"+u.join(\",\")+\"}\",gap=o,i}}typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(e,t,n){var r;gap=\"\",indent=\"\";if(typeof n==\"number\")for(r=0;r<n;r+=1)indent+=\" \";else typeof n==\"string\"&&(indent=n);rep=t;if(!t||typeof t==\"function\"||typeof t==\"object\"&&typeof t.length==\"number\")return str(\"\",{\"\":e});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i==\"object\")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\")))return j=eval(\"(\"+text+\")\"),typeof reviver==\"function\"?walk({\"\":j},\"\"):j;throw new SyntaxError(\"JSON.parse\")})}(),function(e,t){\"use strict\";var n=e.History=e.History||{};if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={handlers:{},_uid:1,uid:function(e){return e._uid||(e._uid=n.Adapter._uid++)},bind:function(e,t,r){var i=n.Adapter.uid(e);n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[],n.Adapter.handlers[i][t].push(r),e[\"on\"+t]=function(e,t){return function(r){n.Adapter.trigger(e,t,r)}}(e,t)},trigger:function(e,t,r){r=r||{};var i=n.Adapter.uid(e),s,o;n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[];for(s=0,o=n.Adapter.handlers[i][t].length;s<o;++s)n.Adapter.handlers[i][t][s].apply(this,[r])},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(t){var n=e.setTimeout(function(){t()},2e3);e.onload=function(){clearTimeout(n),t()}}},typeof n.init!=\"undefined\"&&n.init()}(window),function(e,t){\"use strict\";var n=e.document,r=e.setTimeout||r,i=e.clearTimeout||i,s=e.setInterval||s,o=e.History=e.History||{};if(typeof o.initHtml4!=\"undefined\")throw new Error(\"History.js HTML4 Support has already been loaded...\");o.initHtml4=function(){if(typeof o.initHtml4.initialized!=\"undefined\")return!1;o.initHtml4.initialized=!0,o.enabled=!0,o.savedHashes=[],o.isLastHash=function(e){var t=o.getHashByIndex(),n;return n=e===t,n},o.isHashEqual=function(e,t){return e=encodeURIComponent(e).replace(/%25/g,\"%\"),t=encodeURIComponent(t).replace(/%25/g,\"%\"),e===t},o.saveHash=function(e){return o.isLastHash(e)?!1:(o.savedHashes.push(e),!0)},o.getHashByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=o.savedHashes[o.savedHashes.length-1]:e<0?t=o.savedHashes[o.savedHashes.length+e]:t=o.savedHashes[e],t},o.discardedHashes={},o.discardedStates={},o.discardState=function(e,t,n){var r=o.getHashByState(e),i;return i={discardedState:e,backState:n,forwardState:t},o.discardedStates[r]=i,!0},o.discardHash=function(e,t,n){var r={discardedHash:e,backState:n,forwardState:t};return o.discardedHashes[e]=r,!0},o.discardedState=function(e){var t=o.getHashByState(e),n;return n=o.discardedStates[t]||!1,n},o.discardedHash=function(e){var t=o.discardedHashes[e]||!1;return t},o.recycleState=function(e){var t=o.getHashByState(e);return o.discardedState(e)&&delete o.discardedStates[t],!0},o.emulated.hashChange&&(o.hashChangeInit=function(){o.checkerFunction=null;var t=\"\",r,i,u,a,f=Boolean(o.getHash());return o.isInternetExplorer()?(r=\"historyjs-iframe\",i=n.createElement(\"iframe\"),i.setAttribute(\"id\",r),i.setAttribute(\"src\",\"#\"),i.style.display=\"none\",n.body.appendChild(i),i.contentWindow.document.open(),i.contentWindow.document.close(),u=\"\",a=!1,o.checkerFunction=function(){if(a)return!1;a=!0;var n=o.getHash(),r=o.getHash(i.contentWindow.document);return n!==t?(t=n,r!==n&&(u=r=n,i.contentWindow.document.open(),i.contentWindow.document.close(),i.contentWindow.document.location.hash=o.escapeHash(n)),o.Adapter.trigger(e,\"hashchange\")):r!==u&&(u=r,f&&r===\"\"?o.back():o.setHash(r,!1)),a=!1,!0}):o.checkerFunction=function(){var n=o.getHash()||\"\";return n!==t&&(t=n,o.Adapter.trigger(e,\"hashchange\")),!0},o.intervalList.push(s(o.checkerFunction,o.options.hashChangeInterval)),!0},o.Adapter.onDomLoad(o.hashChangeInit)),o.emulated.pushState&&(o.onHashChange=function(t){var n=t&&t.newURL||o.getLocationHref(),r=o.getHashByUrl(n),i=null,s=null,u=null,a;return o.isLastHash(r)?(o.busy(!1),!1):(o.doubleCheckComplete(),o.saveHash(r),r&&o.isTraditionalAnchor(r)?(o.Adapter.trigger(e,\"anchorchange\"),o.busy(!1),!1):(i=o.extractState(o.getFullUrl(r||o.getLocationHref()),!0),o.isLastSavedState(i)?(o.busy(!1),!1):(s=o.getHashByState(i),a=o.discardedState(i),a?(o.getHashByIndex(-2)===o.getHashByState(a.forwardState)?o.back(!1):o.forward(!1),!1):(o.pushState(i.data,i.title,encodeURI(i.url),!1),!0))))},o.Adapter.bind(e,\"hashchange\",o.onHashChange),o.pushState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,\"statechange\"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)},o.replaceState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.replaceState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getStateByIndex(-2);return o.discardState(a,s,l),u===f?(o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),o.saveState(s),o.Adapter.trigger(e,\"statechange\"),o.busy(!1)):o.pushState(s.data,s.title,s.url,!1),!0}),o.emulated.pushState&&o.getHash()&&!o.emulated.hashChange&&o.Adapter.onDomLoad(function(){o.Adapter.trigger(e,\"hashchange\")})},typeof o.init!=\"undefined\"&&o.init()}(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html4+html5/right.history.js",
    "content": "typeof JSON!=\"object\"&&(JSON={}),function(){\"use strict\";function f(e){return e<10?\"0\"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'\"'+e.replace(escapable,function(e){var t=meta[e];return typeof t==\"string\"?t:\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+e+'\"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a==\"object\"&&typeof a.toJSON==\"function\"&&(a=a.toJSON(e)),typeof rep==\"function\"&&(a=rep.call(t,e,a));switch(typeof a){case\"string\":return quote(a);case\"number\":return isFinite(a)?String(a):\"null\";case\"boolean\":case\"null\":return String(a);case\"object\":if(!a)return\"null\";gap+=indent,u=[];if(Object.prototype.toString.apply(a)===\"[object Array]\"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||\"null\";return i=u.length===0?\"[]\":gap?\"[\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"]\":\"[\"+u.join(\",\")+\"]\",gap=o,i}if(rep&&typeof rep==\"object\"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]==\"string\"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i));return i=u.length===0?\"{}\":gap?\"{\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"}\":\"{\"+u.join(\",\")+\"}\",gap=o,i}}typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(e,t,n){var r;gap=\"\",indent=\"\";if(typeof n==\"number\")for(r=0;r<n;r+=1)indent+=\" \";else typeof n==\"string\"&&(indent=n);rep=t;if(!t||typeof t==\"function\"||typeof t==\"object\"&&typeof t.length==\"number\")return str(\"\",{\"\":e});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i==\"object\")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\")))return j=eval(\"(\"+text+\")\"),typeof reviver==\"function\"?walk({\"\":j},\"\"):j;throw new SyntaxError(\"JSON.parse\")})}(),function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.document,i=e.RightJS,s=i.$;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){s(e).on(t,n)},trigger:function(e,t,n){s(e).fire(t,n)},extractEventData:function(e,n){var r=n&&n._&&n._[e]||t;return r},onDomLoad:function(e){s(r).onReady(e)}},typeof n.init!=\"undefined\"&&n.init()}(window),function(e,t){\"use strict\";var n=e.document,r=e.setTimeout||r,i=e.clearTimeout||i,s=e.setInterval||s,o=e.History=e.History||{};if(typeof o.initHtml4!=\"undefined\")throw new Error(\"History.js HTML4 Support has already been loaded...\");o.initHtml4=function(){if(typeof o.initHtml4.initialized!=\"undefined\")return!1;o.initHtml4.initialized=!0,o.enabled=!0,o.savedHashes=[],o.isLastHash=function(e){var t=o.getHashByIndex(),n;return n=e===t,n},o.isHashEqual=function(e,t){return e=encodeURIComponent(e).replace(/%25/g,\"%\"),t=encodeURIComponent(t).replace(/%25/g,\"%\"),e===t},o.saveHash=function(e){return o.isLastHash(e)?!1:(o.savedHashes.push(e),!0)},o.getHashByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=o.savedHashes[o.savedHashes.length-1]:e<0?t=o.savedHashes[o.savedHashes.length+e]:t=o.savedHashes[e],t},o.discardedHashes={},o.discardedStates={},o.discardState=function(e,t,n){var r=o.getHashByState(e),i;return i={discardedState:e,backState:n,forwardState:t},o.discardedStates[r]=i,!0},o.discardHash=function(e,t,n){var r={discardedHash:e,backState:n,forwardState:t};return o.discardedHashes[e]=r,!0},o.discardedState=function(e){var t=o.getHashByState(e),n;return n=o.discardedStates[t]||!1,n},o.discardedHash=function(e){var t=o.discardedHashes[e]||!1;return t},o.recycleState=function(e){var t=o.getHashByState(e);return o.discardedState(e)&&delete o.discardedStates[t],!0},o.emulated.hashChange&&(o.hashChangeInit=function(){o.checkerFunction=null;var t=\"\",r,i,u,a,f=Boolean(o.getHash());return o.isInternetExplorer()?(r=\"historyjs-iframe\",i=n.createElement(\"iframe\"),i.setAttribute(\"id\",r),i.setAttribute(\"src\",\"#\"),i.style.display=\"none\",n.body.appendChild(i),i.contentWindow.document.open(),i.contentWindow.document.close(),u=\"\",a=!1,o.checkerFunction=function(){if(a)return!1;a=!0;var n=o.getHash(),r=o.getHash(i.contentWindow.document);return n!==t?(t=n,r!==n&&(u=r=n,i.contentWindow.document.open(),i.contentWindow.document.close(),i.contentWindow.document.location.hash=o.escapeHash(n)),o.Adapter.trigger(e,\"hashchange\")):r!==u&&(u=r,f&&r===\"\"?o.back():o.setHash(r,!1)),a=!1,!0}):o.checkerFunction=function(){var n=o.getHash()||\"\";return n!==t&&(t=n,o.Adapter.trigger(e,\"hashchange\")),!0},o.intervalList.push(s(o.checkerFunction,o.options.hashChangeInterval)),!0},o.Adapter.onDomLoad(o.hashChangeInit)),o.emulated.pushState&&(o.onHashChange=function(t){var n=t&&t.newURL||o.getLocationHref(),r=o.getHashByUrl(n),i=null,s=null,u=null,a;return o.isLastHash(r)?(o.busy(!1),!1):(o.doubleCheckComplete(),o.saveHash(r),r&&o.isTraditionalAnchor(r)?(o.Adapter.trigger(e,\"anchorchange\"),o.busy(!1),!1):(i=o.extractState(o.getFullUrl(r||o.getLocationHref()),!0),o.isLastSavedState(i)?(o.busy(!1),!1):(s=o.getHashByState(i),a=o.discardedState(i),a?(o.getHashByIndex(-2)===o.getHashByState(a.forwardState)?o.back(!1):o.forward(!1),!1):(o.pushState(i.data,i.title,encodeURI(i.url),!1),!0))))},o.Adapter.bind(e,\"hashchange\",o.onHashChange),o.pushState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,\"statechange\"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)},o.replaceState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.replaceState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getStateByIndex(-2);return o.discardState(a,s,l),u===f?(o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),o.saveState(s),o.Adapter.trigger(e,\"statechange\"),o.busy(!1)):o.pushState(s.data,s.title,s.url,!1),!0}),o.emulated.pushState&&o.getHash()&&!o.emulated.hashChange&&o.Adapter.onDomLoad(function(){o.Adapter.trigger(e,\"hashchange\")})},typeof o.init!=\"undefined\"&&o.init()}(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html4+html5/zepto.history.js",
    "content": "typeof JSON!=\"object\"&&(JSON={}),function(){\"use strict\";function f(e){return e<10?\"0\"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'\"'+e.replace(escapable,function(e){var t=meta[e];return typeof t==\"string\"?t:\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+e+'\"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a==\"object\"&&typeof a.toJSON==\"function\"&&(a=a.toJSON(e)),typeof rep==\"function\"&&(a=rep.call(t,e,a));switch(typeof a){case\"string\":return quote(a);case\"number\":return isFinite(a)?String(a):\"null\";case\"boolean\":case\"null\":return String(a);case\"object\":if(!a)return\"null\";gap+=indent,u=[];if(Object.prototype.toString.apply(a)===\"[object Array]\"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||\"null\";return i=u.length===0?\"[]\":gap?\"[\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"]\":\"[\"+u.join(\",\")+\"]\",gap=o,i}if(rep&&typeof rep==\"object\"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]==\"string\"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i));return i=u.length===0?\"{}\":gap?\"{\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"}\":\"{\"+u.join(\",\")+\"}\",gap=o,i}}typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(e,t,n){var r;gap=\"\",indent=\"\";if(typeof n==\"number\")for(r=0;r<n;r+=1)indent+=\" \";else typeof n==\"string\"&&(indent=n);rep=t;if(!t||typeof t==\"function\"||typeof t==\"object\"&&typeof t.length==\"number\")return str(\"\",{\"\":e});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i==\"object\")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\")))return j=eval(\"(\"+text+\")\"),typeof reviver==\"function\"?walk({\"\":j},\"\"):j;throw new SyntaxError(\"JSON.parse\")})}(),function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.Zepto;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){(new r(e)).bind(t,n)},trigger:function(e,t){(new r(e)).trigger(t)},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(e){new r(e)}},typeof n.init!=\"undefined\"&&n.init()}(window),function(e,t){\"use strict\";var n=e.document,r=e.setTimeout||r,i=e.clearTimeout||i,s=e.setInterval||s,o=e.History=e.History||{};if(typeof o.initHtml4!=\"undefined\")throw new Error(\"History.js HTML4 Support has already been loaded...\");o.initHtml4=function(){if(typeof o.initHtml4.initialized!=\"undefined\")return!1;o.initHtml4.initialized=!0,o.enabled=!0,o.savedHashes=[],o.isLastHash=function(e){var t=o.getHashByIndex(),n;return n=e===t,n},o.isHashEqual=function(e,t){return e=encodeURIComponent(e).replace(/%25/g,\"%\"),t=encodeURIComponent(t).replace(/%25/g,\"%\"),e===t},o.saveHash=function(e){return o.isLastHash(e)?!1:(o.savedHashes.push(e),!0)},o.getHashByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=o.savedHashes[o.savedHashes.length-1]:e<0?t=o.savedHashes[o.savedHashes.length+e]:t=o.savedHashes[e],t},o.discardedHashes={},o.discardedStates={},o.discardState=function(e,t,n){var r=o.getHashByState(e),i;return i={discardedState:e,backState:n,forwardState:t},o.discardedStates[r]=i,!0},o.discardHash=function(e,t,n){var r={discardedHash:e,backState:n,forwardState:t};return o.discardedHashes[e]=r,!0},o.discardedState=function(e){var t=o.getHashByState(e),n;return n=o.discardedStates[t]||!1,n},o.discardedHash=function(e){var t=o.discardedHashes[e]||!1;return t},o.recycleState=function(e){var t=o.getHashByState(e);return o.discardedState(e)&&delete o.discardedStates[t],!0},o.emulated.hashChange&&(o.hashChangeInit=function(){o.checkerFunction=null;var t=\"\",r,i,u,a,f=Boolean(o.getHash());return o.isInternetExplorer()?(r=\"historyjs-iframe\",i=n.createElement(\"iframe\"),i.setAttribute(\"id\",r),i.setAttribute(\"src\",\"#\"),i.style.display=\"none\",n.body.appendChild(i),i.contentWindow.document.open(),i.contentWindow.document.close(),u=\"\",a=!1,o.checkerFunction=function(){if(a)return!1;a=!0;var n=o.getHash(),r=o.getHash(i.contentWindow.document);return n!==t?(t=n,r!==n&&(u=r=n,i.contentWindow.document.open(),i.contentWindow.document.close(),i.contentWindow.document.location.hash=o.escapeHash(n)),o.Adapter.trigger(e,\"hashchange\")):r!==u&&(u=r,f&&r===\"\"?o.back():o.setHash(r,!1)),a=!1,!0}):o.checkerFunction=function(){var n=o.getHash()||\"\";return n!==t&&(t=n,o.Adapter.trigger(e,\"hashchange\")),!0},o.intervalList.push(s(o.checkerFunction,o.options.hashChangeInterval)),!0},o.Adapter.onDomLoad(o.hashChangeInit)),o.emulated.pushState&&(o.onHashChange=function(t){var n=t&&t.newURL||o.getLocationHref(),r=o.getHashByUrl(n),i=null,s=null,u=null,a;return o.isLastHash(r)?(o.busy(!1),!1):(o.doubleCheckComplete(),o.saveHash(r),r&&o.isTraditionalAnchor(r)?(o.Adapter.trigger(e,\"anchorchange\"),o.busy(!1),!1):(i=o.extractState(o.getFullUrl(r||o.getLocationHref()),!0),o.isLastSavedState(i)?(o.busy(!1),!1):(s=o.getHashByState(i),a=o.discardedState(i),a?(o.getHashByIndex(-2)===o.getHashByState(a.forwardState)?o.back(!1):o.forward(!1),!1):(o.pushState(i.data,i.title,encodeURI(i.url),!1),!0))))},o.Adapter.bind(e,\"hashchange\",o.onHashChange),o.pushState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,\"statechange\"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)},o.replaceState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.replaceState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getStateByIndex(-2);return o.discardState(a,s,l),u===f?(o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),o.saveState(s),o.Adapter.trigger(e,\"statechange\"),o.busy(!1)):o.pushState(s.data,s.title,s.url,!1),!0}),o.emulated.pushState&&o.getHash()&&!o.emulated.hashChange&&o.Adapter.onDomLoad(function(){o.Adapter.trigger(e,\"hashchange\")})},typeof o.init!=\"undefined\"&&o.init()}(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html5/dojo.history.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.require;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={handlers:{},_uid:1,uid:function(e){return e._uid||(e._uid=n.Adapter._uid++)},bind:function(e,t,r){var i=n.Adapter.uid(e);n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[],n.Adapter.handlers[i][t].push(r),e[\"on\"+t]=function(e,t){return function(r){n.Adapter.trigger(e,t,r)}}(e,t)},trigger:function(e,t,r){r=r||{};var i=n.Adapter.uid(e),s,o;n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[];for(s=0,o=n.Adapter.handlers[i][t].length;s<o;++s)n.Adapter.handlers[i][t][s].apply(this,[r])},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(e){r([\"dojo/ready\"],function(t){t(e)})}},typeof n.init!=\"undefined\"&&n.init()})(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html5/extjs.history.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.Ext;e.JSON={stringify:r.JSON.encode,parse:r.JSON.decode};if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={observables:{},bind:function(e,t,n,i){r.EventManager.addListener(e,t,n,i);var s=r.id(e,\"history-\"),o=this.observables[s];o||(o=r.create(\"Ext.util.Observable\"),this.observables[s]=o),o.on(t,n,i)},trigger:function(e,t,n){var i=r.id(e,\"history-\"),s=this.observables[i];s&&s.fireEvent(t,n)},extractEventData:function(e,n,r){var i=n&&n.browserEvent&&n.browserEvent[e]||r&&r[e]||t;return i},onDomLoad:function(e){r.onReady(e)}},typeof n.init!=\"undefined\"&&n.init()})(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html5/jquery.history.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.jQuery;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){r(e).bind(t,n)},trigger:function(e,t,n){r(e).trigger(t,n)},extractEventData:function(e,n,r){var i=n&&n.originalEvent&&n.originalEvent[e]||r&&r[e]||t;return i},onDomLoad:function(e){r(e)}},typeof n.init!=\"undefined\"&&n.init()})(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html5/mootools.history.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.MooTools,i=e.Element;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");Object.append(i.NativeEvents,{popstate:2,hashchange:2}),n.Adapter={bind:function(e,t,n){var r=typeof e==\"string\"?document.id(e):e;r.addEvent(t,n)},trigger:function(e,t,n){var r=typeof e==\"string\"?document.id(e):e;r.fireEvent(t,n)},extractEventData:function(e,n){var r=n&&n.event&&n.event[e]||n&&n[e]||t;return r},onDomLoad:function(t){e.addEvent(\"domready\",t)}},typeof n.init!=\"undefined\"&&n.init()})(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html5/native.history.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{};if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={handlers:{},_uid:1,uid:function(e){return e._uid||(e._uid=n.Adapter._uid++)},bind:function(e,t,r){var i=n.Adapter.uid(e);n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[],n.Adapter.handlers[i][t].push(r),e[\"on\"+t]=function(e,t){return function(r){n.Adapter.trigger(e,t,r)}}(e,t)},trigger:function(e,t,r){r=r||{};var i=n.Adapter.uid(e),s,o;n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[];for(s=0,o=n.Adapter.handlers[i][t].length;s<o;++s)n.Adapter.handlers[i][t][s].apply(this,[r])},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(t){var n=e.setTimeout(function(){t()},2e3);e.onload=function(){clearTimeout(n),t()}}},typeof n.init!=\"undefined\"&&n.init()})(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html5/right.history.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.document,i=e.RightJS,s=i.$;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){s(e).on(t,n)},trigger:function(e,t,n){s(e).fire(t,n)},extractEventData:function(e,n){var r=n&&n._&&n._[e]||t;return r},onDomLoad:function(e){s(r).onReady(e)}},typeof n.init!=\"undefined\"&&n.init()})(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled/html5/zepto.history.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.Zepto;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){(new r(e)).bind(t,n)},trigger:function(e,t){(new r(e)).trigger(t)},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(e){new r(e)}},typeof n.init!=\"undefined\"&&n.init()})(window),function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()}(window)"
  },
  {
    "path": "scripts/bundled-uncompressed/html4+html5/dojo.history.js",
    "content": "/*\n    json2.js\n    2012-10-08\n\n    Public Domain.\n\n    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n    See http://www.JSON.org/js.html\n\n\n    This code should be minified before deployment.\n    See http://javascript.crockford.com/jsmin.html\n\n    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n    NOT CONTROL.\n\n\n    This file creates a global JSON object containing two methods: stringify\n    and parse.\n\n        JSON.stringify(value, replacer, space)\n            value       any JavaScript value, usually an object or array.\n\n            replacer    an optional parameter that determines how object\n                        values are stringified for objects. It can be a\n                        function or an array of strings.\n\n            space       an optional parameter that specifies the indentation\n                        of nested structures. If it is omitted, the text will\n                        be packed without extra whitespace. If it is a number,\n                        it will specify the number of spaces to indent at each\n                        level. If it is a string (such as '\\t' or '&nbsp;'),\n                        it contains the characters used to indent at each level.\n\n            This method produces a JSON text from a JavaScript value.\n\n            When an object value is found, if the object contains a toJSON\n            method, its toJSON method will be called and the result will be\n            stringified. A toJSON method does not serialize: it returns the\n            value represented by the name/value pair that should be serialized,\n            or undefined if nothing should be serialized. The toJSON method\n            will be passed the key associated with the value, and this will be\n            bound to the value\n\n            For example, this would serialize Dates as ISO strings.\n\n                Date.prototype.toJSON = function (key) {\n                    function f(n) {\n                        // Format integers to have at least two digits.\n                        return n < 10 ? '0' + n : n;\n                    }\n\n                    return this.getUTCFullYear()   + '-' +\n                         f(this.getUTCMonth() + 1) + '-' +\n                         f(this.getUTCDate())      + 'T' +\n                         f(this.getUTCHours())     + ':' +\n                         f(this.getUTCMinutes())   + ':' +\n                         f(this.getUTCSeconds())   + 'Z';\n                };\n\n            You can provide an optional replacer method. It will be passed the\n            key and value of each member, with this bound to the containing\n            object. The value that is returned from your method will be\n            serialized. If your method returns undefined, then the member will\n            be excluded from the serialization.\n\n            If the replacer parameter is an array of strings, then it will be\n            used to select the members to be serialized. It filters the results\n            such that only members with keys listed in the replacer array are\n            stringified.\n\n            Values that do not have JSON representations, such as undefined or\n            functions, will not be serialized. Such values in objects will be\n            dropped; in arrays they will be replaced with null. You can use\n            a replacer function to replace those with JSON values.\n            JSON.stringify(undefined) returns undefined.\n\n            The optional space parameter produces a stringification of the\n            value that is filled with line breaks and indentation to make it\n            easier to read.\n\n            If the space parameter is a non-empty string, then that string will\n            be used for indentation. If the space parameter is a number, then\n            the indentation will be that many spaces.\n\n            Example:\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}]);\n            // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n            // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n            text = JSON.stringify([new Date()], function (key, value) {\n                return this[key] instanceof Date ?\n                    'Date(' + this[key] + ')' : value;\n            });\n            // text is '[\"Date(---current time---)\"]'\n\n\n        JSON.parse(text, reviver)\n            This method parses a JSON text to produce an object or array.\n            It can throw a SyntaxError exception.\n\n            The optional reviver parameter is a function that can filter and\n            transform the results. It receives each of the keys and values,\n            and its return value is used instead of the original value.\n            If it returns what it received, then the structure is not modified.\n            If it returns undefined then the member is deleted.\n\n            Example:\n\n            // Parse the text. Values that look like ISO date strings will\n            // be converted to Date objects.\n\n            myData = JSON.parse(text, function (key, value) {\n                var a;\n                if (typeof value === 'string') {\n                    a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n                    if (a) {\n                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n                            +a[5], +a[6]));\n                    }\n                }\n                return value;\n            });\n\n            myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n                var d;\n                if (typeof value === 'string' &&\n                        value.slice(0, 5) === 'Date(' &&\n                        value.slice(-1) === ')') {\n                    d = new Date(value.slice(5, -1));\n                    if (d) {\n                        return d;\n                    }\n                }\n                return value;\n            });\n\n\n    This is a reference implementation. You are free to copy, modify, or\n    redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== 'object') {\n    JSON = {};\n}\n\n(function () {\n    'use strict';\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10 ? '0' + n : n;\n    }\n\n    if (typeof Date.prototype.toJSON !== 'function') {\n\n        Date.prototype.toJSON = function (key) {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear()     + '-' +\n                    f(this.getUTCMonth() + 1) + '-' +\n                    f(this.getUTCDate())      + 'T' +\n                    f(this.getUTCHours())     + ':' +\n                    f(this.getUTCMinutes())   + ':' +\n                    f(this.getUTCSeconds())   + 'Z'\n                : null;\n        };\n\n        String.prototype.toJSON      =\n            Number.prototype.toJSON  =\n            Boolean.prototype.toJSON = function (key) {\n                return this.valueOf();\n            };\n    }\n\n    var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        gap,\n        indent,\n        meta = {    // table of character substitutions\n            '\\b': '\\\\b',\n            '\\t': '\\\\t',\n            '\\n': '\\\\n',\n            '\\f': '\\\\f',\n            '\\r': '\\\\r',\n            '\"' : '\\\\\"',\n            '\\\\': '\\\\\\\\'\n        },\n        rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        escapable.lastIndex = 0;\n        return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n            var c = meta[a];\n            return typeof c === 'string'\n                ? c\n                : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"' : '\"' + string + '\"';\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i,          // The loop counter.\n            k,          // The member key.\n            v,          // The member value.\n            length,\n            mind = gap,\n            partial,\n            value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === 'object' &&\n                typeof value.toJSON === 'function') {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === 'function') {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case 'string':\n            return quote(value);\n\n        case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value) ? String(value) : 'null';\n\n        case 'boolean':\n        case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n        case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n            if (!value) {\n                return 'null';\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || 'null';\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? '[]'\n                    : gap\n                    ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n                    : '[' + partial.join(',') + ']';\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === 'object') {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === 'string') {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? '{}'\n                : gap\n                ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n                : '{' + partial.join(',') + '}';\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== 'function') {\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = '';\n            indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === 'number') {\n                for (i = 0; i < space; i += 1) {\n                    indent += ' ';\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === 'string') {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== 'function' &&\n                    (typeof replacer !== 'object' ||\n                    typeof replacer.length !== 'number')) {\n                throw new Error('JSON.stringify');\n            }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n            return str('', {'': value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== 'function') {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k, v, value = holder[key];\n                if (value && typeof value === 'object') {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            cx.lastIndex = 0;\n            if (cx.test(text)) {\n                text = text.replace(cx, function (a) {\n                    return '\\\\u' +\n                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n            if (/^[\\],:{}\\s]*$/\n                    .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n                        .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n                        .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return typeof reviver === 'function'\n                    ? walk({'': j}, '')\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError('JSON.parse');\n        };\n    }\n}());/**\n * History.js Dojo Adapter\n *\n * Essentially the same as the native adapter but uses dojo/ready for the dom load callback.\n *\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar History = window.History = window.History||{},\n        require = window.require;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.handlers[uid][eventName] = Array\n\t\t */\n\t\thandlers: {},\n\n\t\t/**\n\t\t * History.Adapter._uid\n\t\t * The current element unique identifier\n\t\t */\n\t\t_uid: 1,\n\n\t\t/**\n\t\t * History.Adapter.uid(element)\n\t\t * @param {Element} element\n\t\t * @return {String} uid\n\t\t */\n\t\tuid: function(element){\n\t\t\treturn element._uid || (element._uid = History.Adapter._uid++);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(element,eventName,callback){\n\t\t\t// Prepare\n\t\t\tvar uid = History.Adapter.uid(element);\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\t\t\tHistory.Adapter.handlers[uid][eventName].push(callback);\n\n\t\t\t// Bind Global Listener\n\t\t\telement['on'+eventName] = (function(element,eventName){\n\t\t\t\treturn function(event){\n\t\t\t\t\tHistory.Adapter.trigger(element,eventName,event);\n\t\t\t\t};\n\t\t\t})(element,eventName);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Object} event - a object of event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(element,eventName,event){\n\t\t\t// Prepare\n\t\t\tevent = event || {};\n\t\t\tvar uid = History.Adapter.uid(element),\n\t\t\t\ti,n;\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\n\t\t\t// Fire Listeners\n\t\t\tfor ( i=0,n=History.Adapter.handlers[uid][eventName].length; i<n; ++i ) {\n\t\t\t\tHistory.Adapter.handlers[uid][eventName][i].apply(this,[event]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\tvar result = (event && event[key]) || undefined;\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\trequire([\"dojo/ready\"], function(ready) {\n\t\t\t\tready(callback);\n\t\t\t});\n\t\t}\n\t};\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js HTML4 Support\n * Depends on the HTML5 Support\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tsetTimeout = window.setTimeout||setTimeout,\n\t\tclearTimeout = window.clearTimeout||clearTimeout,\n\t\tsetInterval = window.setInterval||setInterval,\n\t\tHistory = window.History = window.History||{}; // Public History Object\n\n\t// Check Existence\n\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\tthrow new Error('History.js HTML4 Support has already been loaded...');\n\t}\n\n\n\t// ========================================================================\n\t// Initialise HTML4 Support\n\n\t// Initialise HTML4 Support\n\tHistory.initHtml4 = function(){\n\t\t// Initialise\n\t\tif ( typeof History.initHtml4.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initHtml4.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Properties\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = true;\n\n\n\t\t// ====================================================================\n\t\t// Hash Storage\n\n\t\t/**\n\t\t * History.savedHashes\n\t\t * Store the hashes in an array\n\t\t */\n\t\tHistory.savedHashes = [];\n\n\t\t/**\n\t\t * History.isLastHash(newHash)\n\t\t * Checks if the hash is the last hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isLastHash = function(newHash){\n\t\t\t// Prepare\n\t\t\tvar oldHash = History.getHashByIndex(),\n\t\t\t\tisLast;\n\n\t\t\t// Check\n\t\t\tisLast = newHash === oldHash;\n\n\t\t\t// Return isLast\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.isHashEqual(newHash, oldHash)\n\t\t * Checks to see if two hashes are functionally equal\n\t\t * @param {string} newHash\n\t\t * @param {string} oldHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isHashEqual = function(newHash, oldHash){\n\t\t\tnewHash = encodeURIComponent(newHash).replace(/%25/g, \"%\");\n\t\t\toldHash = encodeURIComponent(oldHash).replace(/%25/g, \"%\");\n\t\t\treturn newHash === oldHash;\n\t\t};\n\n\t\t/**\n\t\t * History.saveHash(newHash)\n\t\t * Push a Hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.saveHash = function(newHash){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastHash(newHash) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the Hash\n\t\t\tHistory.savedHashes.push(newHash);\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByIndex()\n\t\t * Gets a hash by the index\n\t\t * @param {integer} index\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHashByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar hash = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\thash = History.savedHashes[History.savedHashes.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\thash = History.savedHashes[History.savedHashes.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\thash = History.savedHashes[index];\n\t\t\t}\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Discarded States\n\n\t\t/**\n\t\t * History.discardedHashes\n\t\t * A hashed array of discarded hashes\n\t\t */\n\t\tHistory.discardedHashes = {};\n\n\t\t/**\n\t\t * History.discardedStates\n\t\t * A hashed array of discarded states\n\t\t */\n\t\tHistory.discardedStates = {};\n\n\t\t/**\n\t\t * History.discardState(State)\n\t\t * Discards the state by ignoring it through History\n\t\t * @param {object} State\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardState = function(discardedState,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Prepare\n\t\t\tvar discardedStateHash = History.getHashByState(discardedState),\n\t\t\t\tdiscardObject;\n\n\t\t\t// Create Discard Object\n\t\t\tdiscardObject = {\n\t\t\t\t'discardedState': discardedState,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to DiscardedStates\n\t\t\tHistory.discardedStates[discardedStateHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardHash(hash)\n\t\t * Discards the hash by ignoring it through History\n\t\t * @param {string} hash\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardHash = function(discardedHash,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Create Discard Object\n\t\t\tvar discardObject = {\n\t\t\t\t'discardedHash': discardedHash,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to discardedHash\n\t\t\tHistory.discardedHashes[discardedHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedState(State)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {object} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedState = function(State){\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State),\n\t\t\t\tdiscarded;\n\n\t\t\t// Check\n\t\t\tdiscarded = History.discardedStates[StateHash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedHash(hash)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {string} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedHash = function(hash){\n\t\t\t// Check\n\t\t\tvar discarded = History.discardedHashes[hash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.recycleState(State)\n\t\t * Allows a discarded state to be used again\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {true}\n\t\t */\n\t\tHistory.recycleState = function(State){\n\t\t\t//History.debug('History.recycleState', arguments);\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State);\n\n\t\t\t// Remove from DiscardedStates\n\t\t\tif ( History.discardedState(State) ) {\n\t\t\t\tdelete History.discardedStates[StateHash];\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML4 HashChange Support\n\n\t\tif ( History.emulated.hashChange ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML4 HashChange Support by manually checking for hash changes\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.hashChangeInit()\n\t\t\t * Init the HashChange Emulation\n\t\t\t */\n\t\t\tHistory.hashChangeInit = function(){\n\t\t\t\t// Define our Checker Function\n\t\t\t\tHistory.checkerFunction = null;\n\n\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\tvar lastDocumentHash = '',\n\t\t\t\t\tiframeId, iframe,\n\t\t\t\t\tlastIframeHash, checkerRunning,\n\t\t\t\t\tstartedWithHash = Boolean(History.getHash());\n\n\t\t\t\t// Handle depending on the browser\n\t\t\t\tif ( History.isInternetExplorer() ) {\n\t\t\t\t\t// IE6 and IE7\n\t\t\t\t\t// We need to use an iframe to emulate the back and forward buttons\n\n\t\t\t\t\t// Create iFrame\n\t\t\t\t\tiframeId = 'historyjs-iframe';\n\t\t\t\t\tiframe = document.createElement('iframe');\n\n\t\t\t\t\t// Adjust iFarme\n\t\t\t\t\t// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a\n\t\t\t\t\t// \"This page contains both secure and nonsecure items\" warning.\n\t\t\t\t\tiframe.setAttribute('id', iframeId);\n\t\t\t\t\tiframe.setAttribute('src', '#');\n\t\t\t\t\tiframe.style.display = 'none';\n\n\t\t\t\t\t// Append iFrame\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\t// Create initial history entry\n\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\t\tlastIframeHash = '';\n\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Check Running\n\t\t\t\t\t\tif ( checkerRunning ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update Running\n\t\t\t\t\t\tcheckerRunning = true;\n\n\t\t\t\t\t\t// Fetch\n\t\t\t\t\t\tvar\n\t\t\t\t\t\t\tdocumentHash = History.getHash(),\n\t\t\t\t\t\t\tiframeHash = History.getHash(iframe.contentWindow.document);\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Create a history entry in the iframe\n\t\t\t\t\t\t\tif ( iframeHash !== documentHash ) {\n\t\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);\n\n\t\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\t\tlastIframeHash = iframeHash = documentHash;\n\n\t\t\t\t\t\t\t\t// Create History Entry\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t\t\t\t// Update the iframe's hash\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.location.hash = History.escapeHash(documentHash);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The iFrame Hash has changed (back button caused)\n\t\t\t\t\t\telse if ( iframeHash !== lastIframeHash ) {\n\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);\n\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastIframeHash = iframeHash;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// If there is no iframe hash that means we're at the original\n\t\t\t\t\t\t\t// iframe state.\n\t\t\t\t\t\t\t// And if there was a hash on the original request, the original\n\t\t\t\t\t\t\t// iframe state was replaced instantly, so skip this state and take\n\t\t\t\t\t\t\t// the user back to where they came from.\n\t\t\t\t\t\t\tif (startedWithHash && iframeHash === '') {\n\t\t\t\t\t\t\t\tHistory.back();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Update the Hash\n\t\t\t\t\t\t\t\tHistory.setHash(iframeHash,false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset Running\n\t\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// We are not IE\n\t\t\t\t\t// Firefox 1 or 2, Opera\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Prepare\n\t\t\t\t\t\tvar documentHash = History.getHash()||'';\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Apply the checker function\n\t\t\t\tHistory.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));\n\n\t\t\t\t// Done\n\t\t\t\treturn true;\n\t\t\t}; // History.hashChangeInit\n\n\t\t\t// Bind hashChangeInit\n\t\t\tHistory.Adapter.onDomLoad(History.hashChangeInit);\n\n\t\t} // History.emulated.hashChange\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML5 State Management by using HTML4 HashChange\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onHashChange(event)\n\t\t\t * Trigger HTML5's window.onpopstate via HTML4 HashChange Support\n\t\t\t */\n\t\t\tHistory.onHashChange = function(event){\n\t\t\t\t//History.debug('History.onHashChange', arguments);\n\n\t\t\t\t// Prepare\n\t\t\t\tvar currentUrl = ((event && event.newURL) || History.getLocationHref()),\n\t\t\t\t\tcurrentHash = History.getHashByUrl(currentUrl),\n\t\t\t\t\tcurrentState = null,\n\t\t\t\t\tcurrentStateHash = null,\n\t\t\t\t\tcurrentStateHashExits = null,\n\t\t\t\t\tdiscardObject;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastHash(currentHash) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Store our location for use in detecting back/forward direction\n\t\t\t\tHistory.saveHash(currentHash);\n\n\t\t\t\t// Expand Hash\n\t\t\t\tif ( currentHash && History.isTraditionalAnchor(currentHash) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: traditional anchor', currentHash);\n\t\t\t\t\t// Traditional Anchor Hash\n\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tcurrentState = History.extractState(History.getFullUrl(currentHash||History.getLocationHref()),true);\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(currentState) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create the state Hash\n\t\t\t\tcurrentStateHash = History.getHashByState(currentState);\n\n\t\t\t\t// Check if we are DiscardedState\n\t\t\t\tdiscardObject = History.discardedState(currentState);\n\t\t\t\tif ( discardObject ) {\n\t\t\t\t\t// Ignore this state as it has been discarded and go back to the state before it\n\t\t\t\t\tif ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {\n\t\t\t\t\t\t// We are going backwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go backwards');\n\t\t\t\t\t\tHistory.back(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We are going forwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go forwards');\n\t\t\t\t\t\tHistory.forward(false);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Push the new HTML5 State\n\t\t\t\t//History.debug('History.onHashChange: success hashchange');\n\t\t\t\tHistory.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);\n\n\t\t\t\t// End onHashChange closure\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'hashchange',History.onHashChange);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Object\n\t\t\t\tvar newState = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\thtml4Hash = History.getHash(),\n\t\t\t\t\twasExpected = History.expectedStateId == newState.id;\n\n\t\t\t\t// Store the newState\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t// Recycle the State\n\t\t\t\tHistory.recycleState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Check if we are the same State\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t//History.debug('History.pushState: no change', newStateHash);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Update HTML5 State\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Fire HTML5 Event\n\t\t\t\tif(!wasExpected)\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\n\t\t\t\t// Update HTML4 Hash\n\t\t\t\tif ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {\n\t\t\t\t\tHistory.setHash(newStateHash,false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Objects\n\t\t\t\tvar newState        = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState        = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\tpreviousState   = History.getStateByIndex(-2);\n\n\t\t\t\t// Discard Old State\n\t\t\t\tHistory.discardState(oldState,newState,previousState);\n\n\t\t\t\t// If the url hasn't changed, just store and save the state\n\t\t\t\t// and fire a statechange event to be consistent with the\n\t\t\t\t// html 5 api\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\t\n\t\t\t\t\t// Recycle the State\n\t\t\t\t\tHistory.recycleState(newState);\n\t\n\t\t\t\t\t// Force update of the title\n\t\t\t\t\tHistory.setTitle(newState);\n\t\t\t\t\t\n\t\t\t\t\t// Update HTML5 State\n\t\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\t//History.debug('History.pushState: trigger popstate');\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Alias to PushState\n\t\t\t\t\tHistory.pushState(newState.data,newState.title,newState.url,false);\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // History.emulated.pushState\n\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/**\n\t\t\t * Ensure initial state is handled correctly\n\t\t\t */\n\t\t\tif ( History.getHash() && !History.emulated.hashChange ) {\n\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t});\n\t\t\t}\n\n\t\t} // History.emulated.pushState\n\n\t}; // History.initHtml4\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html4+html5/extjs.history.js",
    "content": "/*\n    json2.js\n    2012-10-08\n\n    Public Domain.\n\n    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n    See http://www.JSON.org/js.html\n\n\n    This code should be minified before deployment.\n    See http://javascript.crockford.com/jsmin.html\n\n    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n    NOT CONTROL.\n\n\n    This file creates a global JSON object containing two methods: stringify\n    and parse.\n\n        JSON.stringify(value, replacer, space)\n            value       any JavaScript value, usually an object or array.\n\n            replacer    an optional parameter that determines how object\n                        values are stringified for objects. It can be a\n                        function or an array of strings.\n\n            space       an optional parameter that specifies the indentation\n                        of nested structures. If it is omitted, the text will\n                        be packed without extra whitespace. If it is a number,\n                        it will specify the number of spaces to indent at each\n                        level. If it is a string (such as '\\t' or '&nbsp;'),\n                        it contains the characters used to indent at each level.\n\n            This method produces a JSON text from a JavaScript value.\n\n            When an object value is found, if the object contains a toJSON\n            method, its toJSON method will be called and the result will be\n            stringified. A toJSON method does not serialize: it returns the\n            value represented by the name/value pair that should be serialized,\n            or undefined if nothing should be serialized. The toJSON method\n            will be passed the key associated with the value, and this will be\n            bound to the value\n\n            For example, this would serialize Dates as ISO strings.\n\n                Date.prototype.toJSON = function (key) {\n                    function f(n) {\n                        // Format integers to have at least two digits.\n                        return n < 10 ? '0' + n : n;\n                    }\n\n                    return this.getUTCFullYear()   + '-' +\n                         f(this.getUTCMonth() + 1) + '-' +\n                         f(this.getUTCDate())      + 'T' +\n                         f(this.getUTCHours())     + ':' +\n                         f(this.getUTCMinutes())   + ':' +\n                         f(this.getUTCSeconds())   + 'Z';\n                };\n\n            You can provide an optional replacer method. It will be passed the\n            key and value of each member, with this bound to the containing\n            object. The value that is returned from your method will be\n            serialized. If your method returns undefined, then the member will\n            be excluded from the serialization.\n\n            If the replacer parameter is an array of strings, then it will be\n            used to select the members to be serialized. It filters the results\n            such that only members with keys listed in the replacer array are\n            stringified.\n\n            Values that do not have JSON representations, such as undefined or\n            functions, will not be serialized. Such values in objects will be\n            dropped; in arrays they will be replaced with null. You can use\n            a replacer function to replace those with JSON values.\n            JSON.stringify(undefined) returns undefined.\n\n            The optional space parameter produces a stringification of the\n            value that is filled with line breaks and indentation to make it\n            easier to read.\n\n            If the space parameter is a non-empty string, then that string will\n            be used for indentation. If the space parameter is a number, then\n            the indentation will be that many spaces.\n\n            Example:\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}]);\n            // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n            // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n            text = JSON.stringify([new Date()], function (key, value) {\n                return this[key] instanceof Date ?\n                    'Date(' + this[key] + ')' : value;\n            });\n            // text is '[\"Date(---current time---)\"]'\n\n\n        JSON.parse(text, reviver)\n            This method parses a JSON text to produce an object or array.\n            It can throw a SyntaxError exception.\n\n            The optional reviver parameter is a function that can filter and\n            transform the results. It receives each of the keys and values,\n            and its return value is used instead of the original value.\n            If it returns what it received, then the structure is not modified.\n            If it returns undefined then the member is deleted.\n\n            Example:\n\n            // Parse the text. Values that look like ISO date strings will\n            // be converted to Date objects.\n\n            myData = JSON.parse(text, function (key, value) {\n                var a;\n                if (typeof value === 'string') {\n                    a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n                    if (a) {\n                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n                            +a[5], +a[6]));\n                    }\n                }\n                return value;\n            });\n\n            myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n                var d;\n                if (typeof value === 'string' &&\n                        value.slice(0, 5) === 'Date(' &&\n                        value.slice(-1) === ')') {\n                    d = new Date(value.slice(5, -1));\n                    if (d) {\n                        return d;\n                    }\n                }\n                return value;\n            });\n\n\n    This is a reference implementation. You are free to copy, modify, or\n    redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== 'object') {\n    JSON = {};\n}\n\n(function () {\n    'use strict';\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10 ? '0' + n : n;\n    }\n\n    if (typeof Date.prototype.toJSON !== 'function') {\n\n        Date.prototype.toJSON = function (key) {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear()     + '-' +\n                    f(this.getUTCMonth() + 1) + '-' +\n                    f(this.getUTCDate())      + 'T' +\n                    f(this.getUTCHours())     + ':' +\n                    f(this.getUTCMinutes())   + ':' +\n                    f(this.getUTCSeconds())   + 'Z'\n                : null;\n        };\n\n        String.prototype.toJSON      =\n            Number.prototype.toJSON  =\n            Boolean.prototype.toJSON = function (key) {\n                return this.valueOf();\n            };\n    }\n\n    var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        gap,\n        indent,\n        meta = {    // table of character substitutions\n            '\\b': '\\\\b',\n            '\\t': '\\\\t',\n            '\\n': '\\\\n',\n            '\\f': '\\\\f',\n            '\\r': '\\\\r',\n            '\"' : '\\\\\"',\n            '\\\\': '\\\\\\\\'\n        },\n        rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        escapable.lastIndex = 0;\n        return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n            var c = meta[a];\n            return typeof c === 'string'\n                ? c\n                : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"' : '\"' + string + '\"';\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i,          // The loop counter.\n            k,          // The member key.\n            v,          // The member value.\n            length,\n            mind = gap,\n            partial,\n            value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === 'object' &&\n                typeof value.toJSON === 'function') {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === 'function') {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case 'string':\n            return quote(value);\n\n        case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value) ? String(value) : 'null';\n\n        case 'boolean':\n        case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n        case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n            if (!value) {\n                return 'null';\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || 'null';\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? '[]'\n                    : gap\n                    ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n                    : '[' + partial.join(',') + ']';\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === 'object') {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === 'string') {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? '{}'\n                : gap\n                ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n                : '{' + partial.join(',') + '}';\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== 'function') {\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = '';\n            indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === 'number') {\n                for (i = 0; i < space; i += 1) {\n                    indent += ' ';\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === 'string') {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== 'function' &&\n                    (typeof replacer !== 'object' ||\n                    typeof replacer.length !== 'number')) {\n                throw new Error('JSON.stringify');\n            }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n            return str('', {'': value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== 'function') {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k, v, value = holder[key];\n                if (value && typeof value === 'object') {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            cx.lastIndex = 0;\n            if (cx.test(text)) {\n                text = text.replace(cx, function (a) {\n                    return '\\\\u' +\n                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n            if (/^[\\],:{}\\s]*$/\n                    .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n                        .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n                        .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return typeof reviver === 'function'\n                    ? walk({'': j}, '')\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError('JSON.parse');\n        };\n    }\n}());/**\n * History.js ExtJS Adapter\n * @author Sean Adkinson <sean.adkinson@gmail.com>\n * @copyright 2012 Sean Adkinson <sean.adkinson@gmail.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n    \"use strict\";\n\n    // Localise Globals\n    var\n        History = window.History = window.History||{},\n        Ext = window.Ext;\n\n    window.JSON = {\n        stringify: Ext.JSON.encode,\n        parse: Ext.JSON.decode\n    };\n    \n    // Check Existence\n    if ( typeof History.Adapter !== 'undefined' ) {\n        throw new Error('History.js Adapter has already been loaded...');\n    }\n\n    // Add the Adapter\n    History.Adapter = {\n        observables: {},\n        \n        /**\n         * History.Adapter.bind(el,event,callback)\n         * @param {Element|string} el\n         * @param {string} event - custom and standard events\n         * @param {function} callback\n         * @param {Object} scope\n         * @return {void}\n         */\n        bind: function(element,eventName,callback,scope){\n            Ext.EventManager.addListener(element, eventName, callback, scope);\n            \n            //bind an observable to the element that will let us \"trigger\" events on it\n            var id = Ext.id(element, 'history-'), observable = this.observables[id];\n            if (!observable) {\n                observable = Ext.create('Ext.util.Observable');\n                this.observables[id] = observable;\n            }\n            observable.on(eventName, callback, scope);\n        },\n\n        /**\n         * History.Adapter.trigger(el,event)\n         * @param {Element|string} el\n         * @param {string} event - custom and standard events\n         * @param {Object=} extra - a object of extra event data (optional)\n         * @return {void}\n         */\n        trigger: function(element,eventName,extra){\n            var id = Ext.id(element, 'history-'), observable = this.observables[id];\n            if (observable) {\n                observable.fireEvent(eventName, extra);\n            }\n        },\n\n        /**\n         * History.Adapter.extractEventData(key,event,extra)\n         * @param {string} key - key for the event data to extract\n         * @param {string} event - custom and standard events\n         * @param {Object=} extra - a object of extra event data (optional)\n         * @return {mixed}\n         */\n        extractEventData: function(key,event,extra){\n            var result = (event && event.browserEvent && event.browserEvent[key]) || (extra && extra[key]) || undefined;\n            return result;\n        },\n\n        /**\n         * History.Adapter.onDomLoad(callback)\n         * @param {function} callback\n         * @return {void}\n         */\n        onDomLoad: function(callback) {\n            Ext.onReady(callback);\n        }\n    };\n\n    // Try and Initialise History\n    if ( typeof History.init !== 'undefined' ) {\n        History.init();\n    }\n\n})(window);/**\n * History.js HTML4 Support\n * Depends on the HTML5 Support\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tsetTimeout = window.setTimeout||setTimeout,\n\t\tclearTimeout = window.clearTimeout||clearTimeout,\n\t\tsetInterval = window.setInterval||setInterval,\n\t\tHistory = window.History = window.History||{}; // Public History Object\n\n\t// Check Existence\n\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\tthrow new Error('History.js HTML4 Support has already been loaded...');\n\t}\n\n\n\t// ========================================================================\n\t// Initialise HTML4 Support\n\n\t// Initialise HTML4 Support\n\tHistory.initHtml4 = function(){\n\t\t// Initialise\n\t\tif ( typeof History.initHtml4.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initHtml4.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Properties\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = true;\n\n\n\t\t// ====================================================================\n\t\t// Hash Storage\n\n\t\t/**\n\t\t * History.savedHashes\n\t\t * Store the hashes in an array\n\t\t */\n\t\tHistory.savedHashes = [];\n\n\t\t/**\n\t\t * History.isLastHash(newHash)\n\t\t * Checks if the hash is the last hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isLastHash = function(newHash){\n\t\t\t// Prepare\n\t\t\tvar oldHash = History.getHashByIndex(),\n\t\t\t\tisLast;\n\n\t\t\t// Check\n\t\t\tisLast = newHash === oldHash;\n\n\t\t\t// Return isLast\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.isHashEqual(newHash, oldHash)\n\t\t * Checks to see if two hashes are functionally equal\n\t\t * @param {string} newHash\n\t\t * @param {string} oldHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isHashEqual = function(newHash, oldHash){\n\t\t\tnewHash = encodeURIComponent(newHash).replace(/%25/g, \"%\");\n\t\t\toldHash = encodeURIComponent(oldHash).replace(/%25/g, \"%\");\n\t\t\treturn newHash === oldHash;\n\t\t};\n\n\t\t/**\n\t\t * History.saveHash(newHash)\n\t\t * Push a Hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.saveHash = function(newHash){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastHash(newHash) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the Hash\n\t\t\tHistory.savedHashes.push(newHash);\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByIndex()\n\t\t * Gets a hash by the index\n\t\t * @param {integer} index\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHashByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar hash = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\thash = History.savedHashes[History.savedHashes.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\thash = History.savedHashes[History.savedHashes.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\thash = History.savedHashes[index];\n\t\t\t}\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Discarded States\n\n\t\t/**\n\t\t * History.discardedHashes\n\t\t * A hashed array of discarded hashes\n\t\t */\n\t\tHistory.discardedHashes = {};\n\n\t\t/**\n\t\t * History.discardedStates\n\t\t * A hashed array of discarded states\n\t\t */\n\t\tHistory.discardedStates = {};\n\n\t\t/**\n\t\t * History.discardState(State)\n\t\t * Discards the state by ignoring it through History\n\t\t * @param {object} State\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardState = function(discardedState,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Prepare\n\t\t\tvar discardedStateHash = History.getHashByState(discardedState),\n\t\t\t\tdiscardObject;\n\n\t\t\t// Create Discard Object\n\t\t\tdiscardObject = {\n\t\t\t\t'discardedState': discardedState,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to DiscardedStates\n\t\t\tHistory.discardedStates[discardedStateHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardHash(hash)\n\t\t * Discards the hash by ignoring it through History\n\t\t * @param {string} hash\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardHash = function(discardedHash,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Create Discard Object\n\t\t\tvar discardObject = {\n\t\t\t\t'discardedHash': discardedHash,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to discardedHash\n\t\t\tHistory.discardedHashes[discardedHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedState(State)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {object} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedState = function(State){\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State),\n\t\t\t\tdiscarded;\n\n\t\t\t// Check\n\t\t\tdiscarded = History.discardedStates[StateHash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedHash(hash)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {string} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedHash = function(hash){\n\t\t\t// Check\n\t\t\tvar discarded = History.discardedHashes[hash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.recycleState(State)\n\t\t * Allows a discarded state to be used again\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {true}\n\t\t */\n\t\tHistory.recycleState = function(State){\n\t\t\t//History.debug('History.recycleState', arguments);\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State);\n\n\t\t\t// Remove from DiscardedStates\n\t\t\tif ( History.discardedState(State) ) {\n\t\t\t\tdelete History.discardedStates[StateHash];\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML4 HashChange Support\n\n\t\tif ( History.emulated.hashChange ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML4 HashChange Support by manually checking for hash changes\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.hashChangeInit()\n\t\t\t * Init the HashChange Emulation\n\t\t\t */\n\t\t\tHistory.hashChangeInit = function(){\n\t\t\t\t// Define our Checker Function\n\t\t\t\tHistory.checkerFunction = null;\n\n\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\tvar lastDocumentHash = '',\n\t\t\t\t\tiframeId, iframe,\n\t\t\t\t\tlastIframeHash, checkerRunning,\n\t\t\t\t\tstartedWithHash = Boolean(History.getHash());\n\n\t\t\t\t// Handle depending on the browser\n\t\t\t\tif ( History.isInternetExplorer() ) {\n\t\t\t\t\t// IE6 and IE7\n\t\t\t\t\t// We need to use an iframe to emulate the back and forward buttons\n\n\t\t\t\t\t// Create iFrame\n\t\t\t\t\tiframeId = 'historyjs-iframe';\n\t\t\t\t\tiframe = document.createElement('iframe');\n\n\t\t\t\t\t// Adjust iFarme\n\t\t\t\t\t// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a\n\t\t\t\t\t// \"This page contains both secure and nonsecure items\" warning.\n\t\t\t\t\tiframe.setAttribute('id', iframeId);\n\t\t\t\t\tiframe.setAttribute('src', '#');\n\t\t\t\t\tiframe.style.display = 'none';\n\n\t\t\t\t\t// Append iFrame\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\t// Create initial history entry\n\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\t\tlastIframeHash = '';\n\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Check Running\n\t\t\t\t\t\tif ( checkerRunning ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update Running\n\t\t\t\t\t\tcheckerRunning = true;\n\n\t\t\t\t\t\t// Fetch\n\t\t\t\t\t\tvar\n\t\t\t\t\t\t\tdocumentHash = History.getHash(),\n\t\t\t\t\t\t\tiframeHash = History.getHash(iframe.contentWindow.document);\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Create a history entry in the iframe\n\t\t\t\t\t\t\tif ( iframeHash !== documentHash ) {\n\t\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);\n\n\t\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\t\tlastIframeHash = iframeHash = documentHash;\n\n\t\t\t\t\t\t\t\t// Create History Entry\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t\t\t\t// Update the iframe's hash\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.location.hash = History.escapeHash(documentHash);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The iFrame Hash has changed (back button caused)\n\t\t\t\t\t\telse if ( iframeHash !== lastIframeHash ) {\n\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);\n\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastIframeHash = iframeHash;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// If there is no iframe hash that means we're at the original\n\t\t\t\t\t\t\t// iframe state.\n\t\t\t\t\t\t\t// And if there was a hash on the original request, the original\n\t\t\t\t\t\t\t// iframe state was replaced instantly, so skip this state and take\n\t\t\t\t\t\t\t// the user back to where they came from.\n\t\t\t\t\t\t\tif (startedWithHash && iframeHash === '') {\n\t\t\t\t\t\t\t\tHistory.back();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Update the Hash\n\t\t\t\t\t\t\t\tHistory.setHash(iframeHash,false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset Running\n\t\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// We are not IE\n\t\t\t\t\t// Firefox 1 or 2, Opera\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Prepare\n\t\t\t\t\t\tvar documentHash = History.getHash()||'';\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Apply the checker function\n\t\t\t\tHistory.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));\n\n\t\t\t\t// Done\n\t\t\t\treturn true;\n\t\t\t}; // History.hashChangeInit\n\n\t\t\t// Bind hashChangeInit\n\t\t\tHistory.Adapter.onDomLoad(History.hashChangeInit);\n\n\t\t} // History.emulated.hashChange\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML5 State Management by using HTML4 HashChange\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onHashChange(event)\n\t\t\t * Trigger HTML5's window.onpopstate via HTML4 HashChange Support\n\t\t\t */\n\t\t\tHistory.onHashChange = function(event){\n\t\t\t\t//History.debug('History.onHashChange', arguments);\n\n\t\t\t\t// Prepare\n\t\t\t\tvar currentUrl = ((event && event.newURL) || History.getLocationHref()),\n\t\t\t\t\tcurrentHash = History.getHashByUrl(currentUrl),\n\t\t\t\t\tcurrentState = null,\n\t\t\t\t\tcurrentStateHash = null,\n\t\t\t\t\tcurrentStateHashExits = null,\n\t\t\t\t\tdiscardObject;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastHash(currentHash) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Store our location for use in detecting back/forward direction\n\t\t\t\tHistory.saveHash(currentHash);\n\n\t\t\t\t// Expand Hash\n\t\t\t\tif ( currentHash && History.isTraditionalAnchor(currentHash) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: traditional anchor', currentHash);\n\t\t\t\t\t// Traditional Anchor Hash\n\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tcurrentState = History.extractState(History.getFullUrl(currentHash||History.getLocationHref()),true);\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(currentState) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create the state Hash\n\t\t\t\tcurrentStateHash = History.getHashByState(currentState);\n\n\t\t\t\t// Check if we are DiscardedState\n\t\t\t\tdiscardObject = History.discardedState(currentState);\n\t\t\t\tif ( discardObject ) {\n\t\t\t\t\t// Ignore this state as it has been discarded and go back to the state before it\n\t\t\t\t\tif ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {\n\t\t\t\t\t\t// We are going backwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go backwards');\n\t\t\t\t\t\tHistory.back(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We are going forwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go forwards');\n\t\t\t\t\t\tHistory.forward(false);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Push the new HTML5 State\n\t\t\t\t//History.debug('History.onHashChange: success hashchange');\n\t\t\t\tHistory.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);\n\n\t\t\t\t// End onHashChange closure\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'hashchange',History.onHashChange);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Object\n\t\t\t\tvar newState = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\thtml4Hash = History.getHash(),\n\t\t\t\t\twasExpected = History.expectedStateId == newState.id;\n\n\t\t\t\t// Store the newState\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t// Recycle the State\n\t\t\t\tHistory.recycleState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Check if we are the same State\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t//History.debug('History.pushState: no change', newStateHash);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Update HTML5 State\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Fire HTML5 Event\n\t\t\t\tif(!wasExpected)\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\n\t\t\t\t// Update HTML4 Hash\n\t\t\t\tif ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {\n\t\t\t\t\tHistory.setHash(newStateHash,false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Objects\n\t\t\t\tvar newState        = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState        = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\tpreviousState   = History.getStateByIndex(-2);\n\n\t\t\t\t// Discard Old State\n\t\t\t\tHistory.discardState(oldState,newState,previousState);\n\n\t\t\t\t// If the url hasn't changed, just store and save the state\n\t\t\t\t// and fire a statechange event to be consistent with the\n\t\t\t\t// html 5 api\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\t\n\t\t\t\t\t// Recycle the State\n\t\t\t\t\tHistory.recycleState(newState);\n\t\n\t\t\t\t\t// Force update of the title\n\t\t\t\t\tHistory.setTitle(newState);\n\t\t\t\t\t\n\t\t\t\t\t// Update HTML5 State\n\t\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\t//History.debug('History.pushState: trigger popstate');\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Alias to PushState\n\t\t\t\t\tHistory.pushState(newState.data,newState.title,newState.url,false);\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // History.emulated.pushState\n\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/**\n\t\t\t * Ensure initial state is handled correctly\n\t\t\t */\n\t\t\tif ( History.getHash() && !History.emulated.hashChange ) {\n\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t});\n\t\t\t}\n\n\t\t} // History.emulated.pushState\n\n\t}; // History.initHtml4\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html4+html5/jquery.history.js",
    "content": "/*\n    json2.js\n    2012-10-08\n\n    Public Domain.\n\n    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n    See http://www.JSON.org/js.html\n\n\n    This code should be minified before deployment.\n    See http://javascript.crockford.com/jsmin.html\n\n    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n    NOT CONTROL.\n\n\n    This file creates a global JSON object containing two methods: stringify\n    and parse.\n\n        JSON.stringify(value, replacer, space)\n            value       any JavaScript value, usually an object or array.\n\n            replacer    an optional parameter that determines how object\n                        values are stringified for objects. It can be a\n                        function or an array of strings.\n\n            space       an optional parameter that specifies the indentation\n                        of nested structures. If it is omitted, the text will\n                        be packed without extra whitespace. If it is a number,\n                        it will specify the number of spaces to indent at each\n                        level. If it is a string (such as '\\t' or '&nbsp;'),\n                        it contains the characters used to indent at each level.\n\n            This method produces a JSON text from a JavaScript value.\n\n            When an object value is found, if the object contains a toJSON\n            method, its toJSON method will be called and the result will be\n            stringified. A toJSON method does not serialize: it returns the\n            value represented by the name/value pair that should be serialized,\n            or undefined if nothing should be serialized. The toJSON method\n            will be passed the key associated with the value, and this will be\n            bound to the value\n\n            For example, this would serialize Dates as ISO strings.\n\n                Date.prototype.toJSON = function (key) {\n                    function f(n) {\n                        // Format integers to have at least two digits.\n                        return n < 10 ? '0' + n : n;\n                    }\n\n                    return this.getUTCFullYear()   + '-' +\n                         f(this.getUTCMonth() + 1) + '-' +\n                         f(this.getUTCDate())      + 'T' +\n                         f(this.getUTCHours())     + ':' +\n                         f(this.getUTCMinutes())   + ':' +\n                         f(this.getUTCSeconds())   + 'Z';\n                };\n\n            You can provide an optional replacer method. It will be passed the\n            key and value of each member, with this bound to the containing\n            object. The value that is returned from your method will be\n            serialized. If your method returns undefined, then the member will\n            be excluded from the serialization.\n\n            If the replacer parameter is an array of strings, then it will be\n            used to select the members to be serialized. It filters the results\n            such that only members with keys listed in the replacer array are\n            stringified.\n\n            Values that do not have JSON representations, such as undefined or\n            functions, will not be serialized. Such values in objects will be\n            dropped; in arrays they will be replaced with null. You can use\n            a replacer function to replace those with JSON values.\n            JSON.stringify(undefined) returns undefined.\n\n            The optional space parameter produces a stringification of the\n            value that is filled with line breaks and indentation to make it\n            easier to read.\n\n            If the space parameter is a non-empty string, then that string will\n            be used for indentation. If the space parameter is a number, then\n            the indentation will be that many spaces.\n\n            Example:\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}]);\n            // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n            // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n            text = JSON.stringify([new Date()], function (key, value) {\n                return this[key] instanceof Date ?\n                    'Date(' + this[key] + ')' : value;\n            });\n            // text is '[\"Date(---current time---)\"]'\n\n\n        JSON.parse(text, reviver)\n            This method parses a JSON text to produce an object or array.\n            It can throw a SyntaxError exception.\n\n            The optional reviver parameter is a function that can filter and\n            transform the results. It receives each of the keys and values,\n            and its return value is used instead of the original value.\n            If it returns what it received, then the structure is not modified.\n            If it returns undefined then the member is deleted.\n\n            Example:\n\n            // Parse the text. Values that look like ISO date strings will\n            // be converted to Date objects.\n\n            myData = JSON.parse(text, function (key, value) {\n                var a;\n                if (typeof value === 'string') {\n                    a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n                    if (a) {\n                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n                            +a[5], +a[6]));\n                    }\n                }\n                return value;\n            });\n\n            myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n                var d;\n                if (typeof value === 'string' &&\n                        value.slice(0, 5) === 'Date(' &&\n                        value.slice(-1) === ')') {\n                    d = new Date(value.slice(5, -1));\n                    if (d) {\n                        return d;\n                    }\n                }\n                return value;\n            });\n\n\n    This is a reference implementation. You are free to copy, modify, or\n    redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== 'object') {\n    JSON = {};\n}\n\n(function () {\n    'use strict';\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10 ? '0' + n : n;\n    }\n\n    if (typeof Date.prototype.toJSON !== 'function') {\n\n        Date.prototype.toJSON = function (key) {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear()     + '-' +\n                    f(this.getUTCMonth() + 1) + '-' +\n                    f(this.getUTCDate())      + 'T' +\n                    f(this.getUTCHours())     + ':' +\n                    f(this.getUTCMinutes())   + ':' +\n                    f(this.getUTCSeconds())   + 'Z'\n                : null;\n        };\n\n        String.prototype.toJSON      =\n            Number.prototype.toJSON  =\n            Boolean.prototype.toJSON = function (key) {\n                return this.valueOf();\n            };\n    }\n\n    var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        gap,\n        indent,\n        meta = {    // table of character substitutions\n            '\\b': '\\\\b',\n            '\\t': '\\\\t',\n            '\\n': '\\\\n',\n            '\\f': '\\\\f',\n            '\\r': '\\\\r',\n            '\"' : '\\\\\"',\n            '\\\\': '\\\\\\\\'\n        },\n        rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        escapable.lastIndex = 0;\n        return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n            var c = meta[a];\n            return typeof c === 'string'\n                ? c\n                : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"' : '\"' + string + '\"';\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i,          // The loop counter.\n            k,          // The member key.\n            v,          // The member value.\n            length,\n            mind = gap,\n            partial,\n            value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === 'object' &&\n                typeof value.toJSON === 'function') {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === 'function') {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case 'string':\n            return quote(value);\n\n        case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value) ? String(value) : 'null';\n\n        case 'boolean':\n        case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n        case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n            if (!value) {\n                return 'null';\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || 'null';\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? '[]'\n                    : gap\n                    ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n                    : '[' + partial.join(',') + ']';\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === 'object') {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === 'string') {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? '{}'\n                : gap\n                ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n                : '{' + partial.join(',') + '}';\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== 'function') {\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = '';\n            indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === 'number') {\n                for (i = 0; i < space; i += 1) {\n                    indent += ' ';\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === 'string') {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== 'function' &&\n                    (typeof replacer !== 'object' ||\n                    typeof replacer.length !== 'number')) {\n                throw new Error('JSON.stringify');\n            }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n            return str('', {'': value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== 'function') {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k, v, value = holder[key];\n                if (value && typeof value === 'object') {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            cx.lastIndex = 0;\n            if (cx.test(text)) {\n                text = text.replace(cx, function (a) {\n                    return '\\\\u' +\n                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n            if (/^[\\],:{}\\s]*$/\n                    .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n                        .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n                        .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return typeof reviver === 'function'\n                    ? walk({'': j}, '')\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError('JSON.parse');\n        };\n    }\n}());/**\n * History.js jQuery Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tjQuery = window.jQuery;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tjQuery(el).bind(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return {void}\n\t\t */\n\t\ttrigger: function(el,event,extra){\n\t\t\tjQuery(el).trigger(event,extra);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event,extra){\n\t\t\t// jQuery Native then jQuery Custom\n\t\t\tvar result = (event && event.originalEvent && event.originalEvent[key]) || (extra && extra[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tjQuery(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n\n/**\n * History.js HTML4 Support\n * Depends on the HTML5 Support\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tsetTimeout = window.setTimeout||setTimeout,\n\t\tclearTimeout = window.clearTimeout||clearTimeout,\n\t\tsetInterval = window.setInterval||setInterval,\n\t\tHistory = window.History = window.History||{}; // Public History Object\n\n\t// Check Existence\n\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\tthrow new Error('History.js HTML4 Support has already been loaded...');\n\t}\n\n\n\t// ========================================================================\n\t// Initialise HTML4 Support\n\n\t// Initialise HTML4 Support\n\tHistory.initHtml4 = function(){\n\t\t// Initialise\n\t\tif ( typeof History.initHtml4.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initHtml4.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Properties\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = true;\n\n\n\t\t// ====================================================================\n\t\t// Hash Storage\n\n\t\t/**\n\t\t * History.savedHashes\n\t\t * Store the hashes in an array\n\t\t */\n\t\tHistory.savedHashes = [];\n\n\t\t/**\n\t\t * History.isLastHash(newHash)\n\t\t * Checks if the hash is the last hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isLastHash = function(newHash){\n\t\t\t// Prepare\n\t\t\tvar oldHash = History.getHashByIndex(),\n\t\t\t\tisLast;\n\n\t\t\t// Check\n\t\t\tisLast = newHash === oldHash;\n\n\t\t\t// Return isLast\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.isHashEqual(newHash, oldHash)\n\t\t * Checks to see if two hashes are functionally equal\n\t\t * @param {string} newHash\n\t\t * @param {string} oldHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isHashEqual = function(newHash, oldHash){\n\t\t\tnewHash = encodeURIComponent(newHash).replace(/%25/g, \"%\");\n\t\t\toldHash = encodeURIComponent(oldHash).replace(/%25/g, \"%\");\n\t\t\treturn newHash === oldHash;\n\t\t};\n\n\t\t/**\n\t\t * History.saveHash(newHash)\n\t\t * Push a Hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.saveHash = function(newHash){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastHash(newHash) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the Hash\n\t\t\tHistory.savedHashes.push(newHash);\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByIndex()\n\t\t * Gets a hash by the index\n\t\t * @param {integer} index\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHashByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar hash = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\thash = History.savedHashes[History.savedHashes.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\thash = History.savedHashes[History.savedHashes.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\thash = History.savedHashes[index];\n\t\t\t}\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Discarded States\n\n\t\t/**\n\t\t * History.discardedHashes\n\t\t * A hashed array of discarded hashes\n\t\t */\n\t\tHistory.discardedHashes = {};\n\n\t\t/**\n\t\t * History.discardedStates\n\t\t * A hashed array of discarded states\n\t\t */\n\t\tHistory.discardedStates = {};\n\n\t\t/**\n\t\t * History.discardState(State)\n\t\t * Discards the state by ignoring it through History\n\t\t * @param {object} State\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardState = function(discardedState,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Prepare\n\t\t\tvar discardedStateHash = History.getHashByState(discardedState),\n\t\t\t\tdiscardObject;\n\n\t\t\t// Create Discard Object\n\t\t\tdiscardObject = {\n\t\t\t\t'discardedState': discardedState,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to DiscardedStates\n\t\t\tHistory.discardedStates[discardedStateHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardHash(hash)\n\t\t * Discards the hash by ignoring it through History\n\t\t * @param {string} hash\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardHash = function(discardedHash,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Create Discard Object\n\t\t\tvar discardObject = {\n\t\t\t\t'discardedHash': discardedHash,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to discardedHash\n\t\t\tHistory.discardedHashes[discardedHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedState(State)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {object} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedState = function(State){\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State),\n\t\t\t\tdiscarded;\n\n\t\t\t// Check\n\t\t\tdiscarded = History.discardedStates[StateHash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedHash(hash)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {string} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedHash = function(hash){\n\t\t\t// Check\n\t\t\tvar discarded = History.discardedHashes[hash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.recycleState(State)\n\t\t * Allows a discarded state to be used again\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {true}\n\t\t */\n\t\tHistory.recycleState = function(State){\n\t\t\t//History.debug('History.recycleState', arguments);\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State);\n\n\t\t\t// Remove from DiscardedStates\n\t\t\tif ( History.discardedState(State) ) {\n\t\t\t\tdelete History.discardedStates[StateHash];\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML4 HashChange Support\n\n\t\tif ( History.emulated.hashChange ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML4 HashChange Support by manually checking for hash changes\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.hashChangeInit()\n\t\t\t * Init the HashChange Emulation\n\t\t\t */\n\t\t\tHistory.hashChangeInit = function(){\n\t\t\t\t// Define our Checker Function\n\t\t\t\tHistory.checkerFunction = null;\n\n\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\tvar lastDocumentHash = '',\n\t\t\t\t\tiframeId, iframe,\n\t\t\t\t\tlastIframeHash, checkerRunning,\n\t\t\t\t\tstartedWithHash = Boolean(History.getHash());\n\n\t\t\t\t// Handle depending on the browser\n\t\t\t\tif ( History.isInternetExplorer() ) {\n\t\t\t\t\t// IE6 and IE7\n\t\t\t\t\t// We need to use an iframe to emulate the back and forward buttons\n\n\t\t\t\t\t// Create iFrame\n\t\t\t\t\tiframeId = 'historyjs-iframe';\n\t\t\t\t\tiframe = document.createElement('iframe');\n\n\t\t\t\t\t// Adjust iFarme\n\t\t\t\t\t// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a\n\t\t\t\t\t// \"This page contains both secure and nonsecure items\" warning.\n\t\t\t\t\tiframe.setAttribute('id', iframeId);\n\t\t\t\t\tiframe.setAttribute('src', '#');\n\t\t\t\t\tiframe.style.display = 'none';\n\n\t\t\t\t\t// Append iFrame\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\t// Create initial history entry\n\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\t\tlastIframeHash = '';\n\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Check Running\n\t\t\t\t\t\tif ( checkerRunning ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update Running\n\t\t\t\t\t\tcheckerRunning = true;\n\n\t\t\t\t\t\t// Fetch\n\t\t\t\t\t\tvar\n\t\t\t\t\t\t\tdocumentHash = History.getHash(),\n\t\t\t\t\t\t\tiframeHash = History.getHash(iframe.contentWindow.document);\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Create a history entry in the iframe\n\t\t\t\t\t\t\tif ( iframeHash !== documentHash ) {\n\t\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);\n\n\t\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\t\tlastIframeHash = iframeHash = documentHash;\n\n\t\t\t\t\t\t\t\t// Create History Entry\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t\t\t\t// Update the iframe's hash\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.location.hash = History.escapeHash(documentHash);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The iFrame Hash has changed (back button caused)\n\t\t\t\t\t\telse if ( iframeHash !== lastIframeHash ) {\n\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);\n\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastIframeHash = iframeHash;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// If there is no iframe hash that means we're at the original\n\t\t\t\t\t\t\t// iframe state.\n\t\t\t\t\t\t\t// And if there was a hash on the original request, the original\n\t\t\t\t\t\t\t// iframe state was replaced instantly, so skip this state and take\n\t\t\t\t\t\t\t// the user back to where they came from.\n\t\t\t\t\t\t\tif (startedWithHash && iframeHash === '') {\n\t\t\t\t\t\t\t\tHistory.back();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Update the Hash\n\t\t\t\t\t\t\t\tHistory.setHash(iframeHash,false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset Running\n\t\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// We are not IE\n\t\t\t\t\t// Firefox 1 or 2, Opera\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Prepare\n\t\t\t\t\t\tvar documentHash = History.getHash()||'';\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Apply the checker function\n\t\t\t\tHistory.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));\n\n\t\t\t\t// Done\n\t\t\t\treturn true;\n\t\t\t}; // History.hashChangeInit\n\n\t\t\t// Bind hashChangeInit\n\t\t\tHistory.Adapter.onDomLoad(History.hashChangeInit);\n\n\t\t} // History.emulated.hashChange\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML5 State Management by using HTML4 HashChange\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onHashChange(event)\n\t\t\t * Trigger HTML5's window.onpopstate via HTML4 HashChange Support\n\t\t\t */\n\t\t\tHistory.onHashChange = function(event){\n\t\t\t\t//History.debug('History.onHashChange', arguments);\n\n\t\t\t\t// Prepare\n\t\t\t\tvar currentUrl = ((event && event.newURL) || History.getLocationHref()),\n\t\t\t\t\tcurrentHash = History.getHashByUrl(currentUrl),\n\t\t\t\t\tcurrentState = null,\n\t\t\t\t\tcurrentStateHash = null,\n\t\t\t\t\tcurrentStateHashExits = null,\n\t\t\t\t\tdiscardObject;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastHash(currentHash) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Store our location for use in detecting back/forward direction\n\t\t\t\tHistory.saveHash(currentHash);\n\n\t\t\t\t// Expand Hash\n\t\t\t\tif ( currentHash && History.isTraditionalAnchor(currentHash) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: traditional anchor', currentHash);\n\t\t\t\t\t// Traditional Anchor Hash\n\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tcurrentState = History.extractState(History.getFullUrl(currentHash||History.getLocationHref()),true);\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(currentState) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create the state Hash\n\t\t\t\tcurrentStateHash = History.getHashByState(currentState);\n\n\t\t\t\t// Check if we are DiscardedState\n\t\t\t\tdiscardObject = History.discardedState(currentState);\n\t\t\t\tif ( discardObject ) {\n\t\t\t\t\t// Ignore this state as it has been discarded and go back to the state before it\n\t\t\t\t\tif ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {\n\t\t\t\t\t\t// We are going backwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go backwards');\n\t\t\t\t\t\tHistory.back(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We are going forwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go forwards');\n\t\t\t\t\t\tHistory.forward(false);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Push the new HTML5 State\n\t\t\t\t//History.debug('History.onHashChange: success hashchange');\n\t\t\t\tHistory.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);\n\n\t\t\t\t// End onHashChange closure\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'hashchange',History.onHashChange);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Object\n\t\t\t\tvar newState = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\thtml4Hash = History.getHash(),\n\t\t\t\t\twasExpected = History.expectedStateId == newState.id;\n\n\t\t\t\t// Store the newState\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t// Recycle the State\n\t\t\t\tHistory.recycleState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Check if we are the same State\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t//History.debug('History.pushState: no change', newStateHash);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Update HTML5 State\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Fire HTML5 Event\n\t\t\t\tif(!wasExpected)\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\n\t\t\t\t// Update HTML4 Hash\n\t\t\t\tif ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {\n\t\t\t\t\tHistory.setHash(newStateHash,false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Objects\n\t\t\t\tvar newState        = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState        = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\tpreviousState   = History.getStateByIndex(-2);\n\n\t\t\t\t// Discard Old State\n\t\t\t\tHistory.discardState(oldState,newState,previousState);\n\n\t\t\t\t// If the url hasn't changed, just store and save the state\n\t\t\t\t// and fire a statechange event to be consistent with the\n\t\t\t\t// html 5 api\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\t\n\t\t\t\t\t// Recycle the State\n\t\t\t\t\tHistory.recycleState(newState);\n\t\n\t\t\t\t\t// Force update of the title\n\t\t\t\t\tHistory.setTitle(newState);\n\t\t\t\t\t\n\t\t\t\t\t// Update HTML5 State\n\t\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\t//History.debug('History.pushState: trigger popstate');\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Alias to PushState\n\t\t\t\t\tHistory.pushState(newState.data,newState.title,newState.url,false);\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // History.emulated.pushState\n\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/**\n\t\t\t * Ensure initial state is handled correctly\n\t\t\t */\n\t\t\tif ( History.getHash() && !History.emulated.hashChange ) {\n\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t});\n\t\t\t}\n\n\t\t} // History.emulated.pushState\n\n\t}; // History.initHtml4\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html4+html5/mootools.history.js",
    "content": "/*\n    json2.js\n    2012-10-08\n\n    Public Domain.\n\n    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n    See http://www.JSON.org/js.html\n\n\n    This code should be minified before deployment.\n    See http://javascript.crockford.com/jsmin.html\n\n    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n    NOT CONTROL.\n\n\n    This file creates a global JSON object containing two methods: stringify\n    and parse.\n\n        JSON.stringify(value, replacer, space)\n            value       any JavaScript value, usually an object or array.\n\n            replacer    an optional parameter that determines how object\n                        values are stringified for objects. It can be a\n                        function or an array of strings.\n\n            space       an optional parameter that specifies the indentation\n                        of nested structures. If it is omitted, the text will\n                        be packed without extra whitespace. If it is a number,\n                        it will specify the number of spaces to indent at each\n                        level. If it is a string (such as '\\t' or '&nbsp;'),\n                        it contains the characters used to indent at each level.\n\n            This method produces a JSON text from a JavaScript value.\n\n            When an object value is found, if the object contains a toJSON\n            method, its toJSON method will be called and the result will be\n            stringified. A toJSON method does not serialize: it returns the\n            value represented by the name/value pair that should be serialized,\n            or undefined if nothing should be serialized. The toJSON method\n            will be passed the key associated with the value, and this will be\n            bound to the value\n\n            For example, this would serialize Dates as ISO strings.\n\n                Date.prototype.toJSON = function (key) {\n                    function f(n) {\n                        // Format integers to have at least two digits.\n                        return n < 10 ? '0' + n : n;\n                    }\n\n                    return this.getUTCFullYear()   + '-' +\n                         f(this.getUTCMonth() + 1) + '-' +\n                         f(this.getUTCDate())      + 'T' +\n                         f(this.getUTCHours())     + ':' +\n                         f(this.getUTCMinutes())   + ':' +\n                         f(this.getUTCSeconds())   + 'Z';\n                };\n\n            You can provide an optional replacer method. It will be passed the\n            key and value of each member, with this bound to the containing\n            object. The value that is returned from your method will be\n            serialized. If your method returns undefined, then the member will\n            be excluded from the serialization.\n\n            If the replacer parameter is an array of strings, then it will be\n            used to select the members to be serialized. It filters the results\n            such that only members with keys listed in the replacer array are\n            stringified.\n\n            Values that do not have JSON representations, such as undefined or\n            functions, will not be serialized. Such values in objects will be\n            dropped; in arrays they will be replaced with null. You can use\n            a replacer function to replace those with JSON values.\n            JSON.stringify(undefined) returns undefined.\n\n            The optional space parameter produces a stringification of the\n            value that is filled with line breaks and indentation to make it\n            easier to read.\n\n            If the space parameter is a non-empty string, then that string will\n            be used for indentation. If the space parameter is a number, then\n            the indentation will be that many spaces.\n\n            Example:\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}]);\n            // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n            // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n            text = JSON.stringify([new Date()], function (key, value) {\n                return this[key] instanceof Date ?\n                    'Date(' + this[key] + ')' : value;\n            });\n            // text is '[\"Date(---current time---)\"]'\n\n\n        JSON.parse(text, reviver)\n            This method parses a JSON text to produce an object or array.\n            It can throw a SyntaxError exception.\n\n            The optional reviver parameter is a function that can filter and\n            transform the results. It receives each of the keys and values,\n            and its return value is used instead of the original value.\n            If it returns what it received, then the structure is not modified.\n            If it returns undefined then the member is deleted.\n\n            Example:\n\n            // Parse the text. Values that look like ISO date strings will\n            // be converted to Date objects.\n\n            myData = JSON.parse(text, function (key, value) {\n                var a;\n                if (typeof value === 'string') {\n                    a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n                    if (a) {\n                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n                            +a[5], +a[6]));\n                    }\n                }\n                return value;\n            });\n\n            myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n                var d;\n                if (typeof value === 'string' &&\n                        value.slice(0, 5) === 'Date(' &&\n                        value.slice(-1) === ')') {\n                    d = new Date(value.slice(5, -1));\n                    if (d) {\n                        return d;\n                    }\n                }\n                return value;\n            });\n\n\n    This is a reference implementation. You are free to copy, modify, or\n    redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== 'object') {\n    JSON = {};\n}\n\n(function () {\n    'use strict';\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10 ? '0' + n : n;\n    }\n\n    if (typeof Date.prototype.toJSON !== 'function') {\n\n        Date.prototype.toJSON = function (key) {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear()     + '-' +\n                    f(this.getUTCMonth() + 1) + '-' +\n                    f(this.getUTCDate())      + 'T' +\n                    f(this.getUTCHours())     + ':' +\n                    f(this.getUTCMinutes())   + ':' +\n                    f(this.getUTCSeconds())   + 'Z'\n                : null;\n        };\n\n        String.prototype.toJSON      =\n            Number.prototype.toJSON  =\n            Boolean.prototype.toJSON = function (key) {\n                return this.valueOf();\n            };\n    }\n\n    var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        gap,\n        indent,\n        meta = {    // table of character substitutions\n            '\\b': '\\\\b',\n            '\\t': '\\\\t',\n            '\\n': '\\\\n',\n            '\\f': '\\\\f',\n            '\\r': '\\\\r',\n            '\"' : '\\\\\"',\n            '\\\\': '\\\\\\\\'\n        },\n        rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        escapable.lastIndex = 0;\n        return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n            var c = meta[a];\n            return typeof c === 'string'\n                ? c\n                : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"' : '\"' + string + '\"';\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i,          // The loop counter.\n            k,          // The member key.\n            v,          // The member value.\n            length,\n            mind = gap,\n            partial,\n            value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === 'object' &&\n                typeof value.toJSON === 'function') {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === 'function') {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case 'string':\n            return quote(value);\n\n        case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value) ? String(value) : 'null';\n\n        case 'boolean':\n        case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n        case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n            if (!value) {\n                return 'null';\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || 'null';\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? '[]'\n                    : gap\n                    ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n                    : '[' + partial.join(',') + ']';\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === 'object') {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === 'string') {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? '{}'\n                : gap\n                ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n                : '{' + partial.join(',') + '}';\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== 'function') {\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = '';\n            indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === 'number') {\n                for (i = 0; i < space; i += 1) {\n                    indent += ' ';\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === 'string') {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== 'function' &&\n                    (typeof replacer !== 'object' ||\n                    typeof replacer.length !== 'number')) {\n                throw new Error('JSON.stringify');\n            }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n            return str('', {'': value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== 'function') {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k, v, value = holder[key];\n                if (value && typeof value === 'object') {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            cx.lastIndex = 0;\n            if (cx.test(text)) {\n                text = text.replace(cx, function (a) {\n                    return '\\\\u' +\n                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n            if (/^[\\],:{}\\s]*$/\n                    .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n                        .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n                        .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return typeof reviver === 'function'\n                    ? walk({'': j}, '')\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError('JSON.parse');\n        };\n    }\n}());/**\n * History.js MooTools Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tMooTools = window.MooTools,\n\t\tElement = window.Element;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Make MooTools aware of History.js Events\n\tObject.append(Element.NativeEvents,{\n\t\t'popstate':2,\n\t\t'hashchange':2\n\t});\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tvar El = typeof el === 'string' ? document.id(el) : el;\n\t\t\tEl.addEvent(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return void\n\t\t */\n\t\ttrigger: function(el,event,extra){\n\t\t\tvar El = typeof el === 'string' ? document.id(el) : el;\n\t\t\tEl.fireEvent(event,extra);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// MooTools Native then MooTools Custom\n\t\t\tvar result = (event && event.event && event.event[key]) || (event && event[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\twindow.addEvent('domready',callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js HTML4 Support\n * Depends on the HTML5 Support\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tsetTimeout = window.setTimeout||setTimeout,\n\t\tclearTimeout = window.clearTimeout||clearTimeout,\n\t\tsetInterval = window.setInterval||setInterval,\n\t\tHistory = window.History = window.History||{}; // Public History Object\n\n\t// Check Existence\n\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\tthrow new Error('History.js HTML4 Support has already been loaded...');\n\t}\n\n\n\t// ========================================================================\n\t// Initialise HTML4 Support\n\n\t// Initialise HTML4 Support\n\tHistory.initHtml4 = function(){\n\t\t// Initialise\n\t\tif ( typeof History.initHtml4.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initHtml4.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Properties\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = true;\n\n\n\t\t// ====================================================================\n\t\t// Hash Storage\n\n\t\t/**\n\t\t * History.savedHashes\n\t\t * Store the hashes in an array\n\t\t */\n\t\tHistory.savedHashes = [];\n\n\t\t/**\n\t\t * History.isLastHash(newHash)\n\t\t * Checks if the hash is the last hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isLastHash = function(newHash){\n\t\t\t// Prepare\n\t\t\tvar oldHash = History.getHashByIndex(),\n\t\t\t\tisLast;\n\n\t\t\t// Check\n\t\t\tisLast = newHash === oldHash;\n\n\t\t\t// Return isLast\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.isHashEqual(newHash, oldHash)\n\t\t * Checks to see if two hashes are functionally equal\n\t\t * @param {string} newHash\n\t\t * @param {string} oldHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isHashEqual = function(newHash, oldHash){\n\t\t\tnewHash = encodeURIComponent(newHash).replace(/%25/g, \"%\");\n\t\t\toldHash = encodeURIComponent(oldHash).replace(/%25/g, \"%\");\n\t\t\treturn newHash === oldHash;\n\t\t};\n\n\t\t/**\n\t\t * History.saveHash(newHash)\n\t\t * Push a Hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.saveHash = function(newHash){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastHash(newHash) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the Hash\n\t\t\tHistory.savedHashes.push(newHash);\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByIndex()\n\t\t * Gets a hash by the index\n\t\t * @param {integer} index\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHashByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar hash = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\thash = History.savedHashes[History.savedHashes.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\thash = History.savedHashes[History.savedHashes.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\thash = History.savedHashes[index];\n\t\t\t}\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Discarded States\n\n\t\t/**\n\t\t * History.discardedHashes\n\t\t * A hashed array of discarded hashes\n\t\t */\n\t\tHistory.discardedHashes = {};\n\n\t\t/**\n\t\t * History.discardedStates\n\t\t * A hashed array of discarded states\n\t\t */\n\t\tHistory.discardedStates = {};\n\n\t\t/**\n\t\t * History.discardState(State)\n\t\t * Discards the state by ignoring it through History\n\t\t * @param {object} State\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardState = function(discardedState,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Prepare\n\t\t\tvar discardedStateHash = History.getHashByState(discardedState),\n\t\t\t\tdiscardObject;\n\n\t\t\t// Create Discard Object\n\t\t\tdiscardObject = {\n\t\t\t\t'discardedState': discardedState,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to DiscardedStates\n\t\t\tHistory.discardedStates[discardedStateHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardHash(hash)\n\t\t * Discards the hash by ignoring it through History\n\t\t * @param {string} hash\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardHash = function(discardedHash,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Create Discard Object\n\t\t\tvar discardObject = {\n\t\t\t\t'discardedHash': discardedHash,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to discardedHash\n\t\t\tHistory.discardedHashes[discardedHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedState(State)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {object} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedState = function(State){\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State),\n\t\t\t\tdiscarded;\n\n\t\t\t// Check\n\t\t\tdiscarded = History.discardedStates[StateHash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedHash(hash)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {string} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedHash = function(hash){\n\t\t\t// Check\n\t\t\tvar discarded = History.discardedHashes[hash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.recycleState(State)\n\t\t * Allows a discarded state to be used again\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {true}\n\t\t */\n\t\tHistory.recycleState = function(State){\n\t\t\t//History.debug('History.recycleState', arguments);\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State);\n\n\t\t\t// Remove from DiscardedStates\n\t\t\tif ( History.discardedState(State) ) {\n\t\t\t\tdelete History.discardedStates[StateHash];\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML4 HashChange Support\n\n\t\tif ( History.emulated.hashChange ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML4 HashChange Support by manually checking for hash changes\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.hashChangeInit()\n\t\t\t * Init the HashChange Emulation\n\t\t\t */\n\t\t\tHistory.hashChangeInit = function(){\n\t\t\t\t// Define our Checker Function\n\t\t\t\tHistory.checkerFunction = null;\n\n\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\tvar lastDocumentHash = '',\n\t\t\t\t\tiframeId, iframe,\n\t\t\t\t\tlastIframeHash, checkerRunning,\n\t\t\t\t\tstartedWithHash = Boolean(History.getHash());\n\n\t\t\t\t// Handle depending on the browser\n\t\t\t\tif ( History.isInternetExplorer() ) {\n\t\t\t\t\t// IE6 and IE7\n\t\t\t\t\t// We need to use an iframe to emulate the back and forward buttons\n\n\t\t\t\t\t// Create iFrame\n\t\t\t\t\tiframeId = 'historyjs-iframe';\n\t\t\t\t\tiframe = document.createElement('iframe');\n\n\t\t\t\t\t// Adjust iFarme\n\t\t\t\t\t// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a\n\t\t\t\t\t// \"This page contains both secure and nonsecure items\" warning.\n\t\t\t\t\tiframe.setAttribute('id', iframeId);\n\t\t\t\t\tiframe.setAttribute('src', '#');\n\t\t\t\t\tiframe.style.display = 'none';\n\n\t\t\t\t\t// Append iFrame\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\t// Create initial history entry\n\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\t\tlastIframeHash = '';\n\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Check Running\n\t\t\t\t\t\tif ( checkerRunning ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update Running\n\t\t\t\t\t\tcheckerRunning = true;\n\n\t\t\t\t\t\t// Fetch\n\t\t\t\t\t\tvar\n\t\t\t\t\t\t\tdocumentHash = History.getHash(),\n\t\t\t\t\t\t\tiframeHash = History.getHash(iframe.contentWindow.document);\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Create a history entry in the iframe\n\t\t\t\t\t\t\tif ( iframeHash !== documentHash ) {\n\t\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);\n\n\t\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\t\tlastIframeHash = iframeHash = documentHash;\n\n\t\t\t\t\t\t\t\t// Create History Entry\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t\t\t\t// Update the iframe's hash\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.location.hash = History.escapeHash(documentHash);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The iFrame Hash has changed (back button caused)\n\t\t\t\t\t\telse if ( iframeHash !== lastIframeHash ) {\n\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);\n\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastIframeHash = iframeHash;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// If there is no iframe hash that means we're at the original\n\t\t\t\t\t\t\t// iframe state.\n\t\t\t\t\t\t\t// And if there was a hash on the original request, the original\n\t\t\t\t\t\t\t// iframe state was replaced instantly, so skip this state and take\n\t\t\t\t\t\t\t// the user back to where they came from.\n\t\t\t\t\t\t\tif (startedWithHash && iframeHash === '') {\n\t\t\t\t\t\t\t\tHistory.back();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Update the Hash\n\t\t\t\t\t\t\t\tHistory.setHash(iframeHash,false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset Running\n\t\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// We are not IE\n\t\t\t\t\t// Firefox 1 or 2, Opera\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Prepare\n\t\t\t\t\t\tvar documentHash = History.getHash()||'';\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Apply the checker function\n\t\t\t\tHistory.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));\n\n\t\t\t\t// Done\n\t\t\t\treturn true;\n\t\t\t}; // History.hashChangeInit\n\n\t\t\t// Bind hashChangeInit\n\t\t\tHistory.Adapter.onDomLoad(History.hashChangeInit);\n\n\t\t} // History.emulated.hashChange\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML5 State Management by using HTML4 HashChange\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onHashChange(event)\n\t\t\t * Trigger HTML5's window.onpopstate via HTML4 HashChange Support\n\t\t\t */\n\t\t\tHistory.onHashChange = function(event){\n\t\t\t\t//History.debug('History.onHashChange', arguments);\n\n\t\t\t\t// Prepare\n\t\t\t\tvar currentUrl = ((event && event.newURL) || History.getLocationHref()),\n\t\t\t\t\tcurrentHash = History.getHashByUrl(currentUrl),\n\t\t\t\t\tcurrentState = null,\n\t\t\t\t\tcurrentStateHash = null,\n\t\t\t\t\tcurrentStateHashExits = null,\n\t\t\t\t\tdiscardObject;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastHash(currentHash) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Store our location for use in detecting back/forward direction\n\t\t\t\tHistory.saveHash(currentHash);\n\n\t\t\t\t// Expand Hash\n\t\t\t\tif ( currentHash && History.isTraditionalAnchor(currentHash) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: traditional anchor', currentHash);\n\t\t\t\t\t// Traditional Anchor Hash\n\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tcurrentState = History.extractState(History.getFullUrl(currentHash||History.getLocationHref()),true);\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(currentState) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create the state Hash\n\t\t\t\tcurrentStateHash = History.getHashByState(currentState);\n\n\t\t\t\t// Check if we are DiscardedState\n\t\t\t\tdiscardObject = History.discardedState(currentState);\n\t\t\t\tif ( discardObject ) {\n\t\t\t\t\t// Ignore this state as it has been discarded and go back to the state before it\n\t\t\t\t\tif ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {\n\t\t\t\t\t\t// We are going backwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go backwards');\n\t\t\t\t\t\tHistory.back(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We are going forwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go forwards');\n\t\t\t\t\t\tHistory.forward(false);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Push the new HTML5 State\n\t\t\t\t//History.debug('History.onHashChange: success hashchange');\n\t\t\t\tHistory.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);\n\n\t\t\t\t// End onHashChange closure\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'hashchange',History.onHashChange);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Object\n\t\t\t\tvar newState = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\thtml4Hash = History.getHash(),\n\t\t\t\t\twasExpected = History.expectedStateId == newState.id;\n\n\t\t\t\t// Store the newState\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t// Recycle the State\n\t\t\t\tHistory.recycleState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Check if we are the same State\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t//History.debug('History.pushState: no change', newStateHash);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Update HTML5 State\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Fire HTML5 Event\n\t\t\t\tif(!wasExpected)\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\n\t\t\t\t// Update HTML4 Hash\n\t\t\t\tif ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {\n\t\t\t\t\tHistory.setHash(newStateHash,false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Objects\n\t\t\t\tvar newState        = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState        = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\tpreviousState   = History.getStateByIndex(-2);\n\n\t\t\t\t// Discard Old State\n\t\t\t\tHistory.discardState(oldState,newState,previousState);\n\n\t\t\t\t// If the url hasn't changed, just store and save the state\n\t\t\t\t// and fire a statechange event to be consistent with the\n\t\t\t\t// html 5 api\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\t\n\t\t\t\t\t// Recycle the State\n\t\t\t\t\tHistory.recycleState(newState);\n\t\n\t\t\t\t\t// Force update of the title\n\t\t\t\t\tHistory.setTitle(newState);\n\t\t\t\t\t\n\t\t\t\t\t// Update HTML5 State\n\t\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\t//History.debug('History.pushState: trigger popstate');\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Alias to PushState\n\t\t\t\t\tHistory.pushState(newState.data,newState.title,newState.url,false);\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // History.emulated.pushState\n\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/**\n\t\t\t * Ensure initial state is handled correctly\n\t\t\t */\n\t\t\tif ( History.getHash() && !History.emulated.hashChange ) {\n\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t});\n\t\t\t}\n\n\t\t} // History.emulated.pushState\n\n\t}; // History.initHtml4\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html4+html5/native.history.js",
    "content": "/*\n    json2.js\n    2012-10-08\n\n    Public Domain.\n\n    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n    See http://www.JSON.org/js.html\n\n\n    This code should be minified before deployment.\n    See http://javascript.crockford.com/jsmin.html\n\n    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n    NOT CONTROL.\n\n\n    This file creates a global JSON object containing two methods: stringify\n    and parse.\n\n        JSON.stringify(value, replacer, space)\n            value       any JavaScript value, usually an object or array.\n\n            replacer    an optional parameter that determines how object\n                        values are stringified for objects. It can be a\n                        function or an array of strings.\n\n            space       an optional parameter that specifies the indentation\n                        of nested structures. If it is omitted, the text will\n                        be packed without extra whitespace. If it is a number,\n                        it will specify the number of spaces to indent at each\n                        level. If it is a string (such as '\\t' or '&nbsp;'),\n                        it contains the characters used to indent at each level.\n\n            This method produces a JSON text from a JavaScript value.\n\n            When an object value is found, if the object contains a toJSON\n            method, its toJSON method will be called and the result will be\n            stringified. A toJSON method does not serialize: it returns the\n            value represented by the name/value pair that should be serialized,\n            or undefined if nothing should be serialized. The toJSON method\n            will be passed the key associated with the value, and this will be\n            bound to the value\n\n            For example, this would serialize Dates as ISO strings.\n\n                Date.prototype.toJSON = function (key) {\n                    function f(n) {\n                        // Format integers to have at least two digits.\n                        return n < 10 ? '0' + n : n;\n                    }\n\n                    return this.getUTCFullYear()   + '-' +\n                         f(this.getUTCMonth() + 1) + '-' +\n                         f(this.getUTCDate())      + 'T' +\n                         f(this.getUTCHours())     + ':' +\n                         f(this.getUTCMinutes())   + ':' +\n                         f(this.getUTCSeconds())   + 'Z';\n                };\n\n            You can provide an optional replacer method. It will be passed the\n            key and value of each member, with this bound to the containing\n            object. The value that is returned from your method will be\n            serialized. If your method returns undefined, then the member will\n            be excluded from the serialization.\n\n            If the replacer parameter is an array of strings, then it will be\n            used to select the members to be serialized. It filters the results\n            such that only members with keys listed in the replacer array are\n            stringified.\n\n            Values that do not have JSON representations, such as undefined or\n            functions, will not be serialized. Such values in objects will be\n            dropped; in arrays they will be replaced with null. You can use\n            a replacer function to replace those with JSON values.\n            JSON.stringify(undefined) returns undefined.\n\n            The optional space parameter produces a stringification of the\n            value that is filled with line breaks and indentation to make it\n            easier to read.\n\n            If the space parameter is a non-empty string, then that string will\n            be used for indentation. If the space parameter is a number, then\n            the indentation will be that many spaces.\n\n            Example:\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}]);\n            // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n            // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n            text = JSON.stringify([new Date()], function (key, value) {\n                return this[key] instanceof Date ?\n                    'Date(' + this[key] + ')' : value;\n            });\n            // text is '[\"Date(---current time---)\"]'\n\n\n        JSON.parse(text, reviver)\n            This method parses a JSON text to produce an object or array.\n            It can throw a SyntaxError exception.\n\n            The optional reviver parameter is a function that can filter and\n            transform the results. It receives each of the keys and values,\n            and its return value is used instead of the original value.\n            If it returns what it received, then the structure is not modified.\n            If it returns undefined then the member is deleted.\n\n            Example:\n\n            // Parse the text. Values that look like ISO date strings will\n            // be converted to Date objects.\n\n            myData = JSON.parse(text, function (key, value) {\n                var a;\n                if (typeof value === 'string') {\n                    a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n                    if (a) {\n                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n                            +a[5], +a[6]));\n                    }\n                }\n                return value;\n            });\n\n            myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n                var d;\n                if (typeof value === 'string' &&\n                        value.slice(0, 5) === 'Date(' &&\n                        value.slice(-1) === ')') {\n                    d = new Date(value.slice(5, -1));\n                    if (d) {\n                        return d;\n                    }\n                }\n                return value;\n            });\n\n\n    This is a reference implementation. You are free to copy, modify, or\n    redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== 'object') {\n    JSON = {};\n}\n\n(function () {\n    'use strict';\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10 ? '0' + n : n;\n    }\n\n    if (typeof Date.prototype.toJSON !== 'function') {\n\n        Date.prototype.toJSON = function (key) {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear()     + '-' +\n                    f(this.getUTCMonth() + 1) + '-' +\n                    f(this.getUTCDate())      + 'T' +\n                    f(this.getUTCHours())     + ':' +\n                    f(this.getUTCMinutes())   + ':' +\n                    f(this.getUTCSeconds())   + 'Z'\n                : null;\n        };\n\n        String.prototype.toJSON      =\n            Number.prototype.toJSON  =\n            Boolean.prototype.toJSON = function (key) {\n                return this.valueOf();\n            };\n    }\n\n    var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        gap,\n        indent,\n        meta = {    // table of character substitutions\n            '\\b': '\\\\b',\n            '\\t': '\\\\t',\n            '\\n': '\\\\n',\n            '\\f': '\\\\f',\n            '\\r': '\\\\r',\n            '\"' : '\\\\\"',\n            '\\\\': '\\\\\\\\'\n        },\n        rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        escapable.lastIndex = 0;\n        return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n            var c = meta[a];\n            return typeof c === 'string'\n                ? c\n                : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"' : '\"' + string + '\"';\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i,          // The loop counter.\n            k,          // The member key.\n            v,          // The member value.\n            length,\n            mind = gap,\n            partial,\n            value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === 'object' &&\n                typeof value.toJSON === 'function') {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === 'function') {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case 'string':\n            return quote(value);\n\n        case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value) ? String(value) : 'null';\n\n        case 'boolean':\n        case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n        case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n            if (!value) {\n                return 'null';\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || 'null';\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? '[]'\n                    : gap\n                    ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n                    : '[' + partial.join(',') + ']';\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === 'object') {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === 'string') {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? '{}'\n                : gap\n                ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n                : '{' + partial.join(',') + '}';\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== 'function') {\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = '';\n            indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === 'number') {\n                for (i = 0; i < space; i += 1) {\n                    indent += ' ';\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === 'string') {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== 'function' &&\n                    (typeof replacer !== 'object' ||\n                    typeof replacer.length !== 'number')) {\n                throw new Error('JSON.stringify');\n            }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n            return str('', {'': value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== 'function') {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k, v, value = holder[key];\n                if (value && typeof value === 'object') {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            cx.lastIndex = 0;\n            if (cx.test(text)) {\n                text = text.replace(cx, function (a) {\n                    return '\\\\u' +\n                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n            if (/^[\\],:{}\\s]*$/\n                    .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n                        .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n                        .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return typeof reviver === 'function'\n                    ? walk({'': j}, '')\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError('JSON.parse');\n        };\n    }\n}());/**\n * History.js Native Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar History = window.History = window.History||{};\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.handlers[uid][eventName] = Array\n\t\t */\n\t\thandlers: {},\n\n\t\t/**\n\t\t * History.Adapter._uid\n\t\t * The current element unique identifier\n\t\t */\n\t\t_uid: 1,\n\n\t\t/**\n\t\t * History.Adapter.uid(element)\n\t\t * @param {Element} element\n\t\t * @return {String} uid\n\t\t */\n\t\tuid: function(element){\n\t\t\treturn element._uid || (element._uid = History.Adapter._uid++);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(element,eventName,callback){\n\t\t\t// Prepare\n\t\t\tvar uid = History.Adapter.uid(element);\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\t\t\tHistory.Adapter.handlers[uid][eventName].push(callback);\n\n\t\t\t// Bind Global Listener\n\t\t\telement['on'+eventName] = (function(element,eventName){\n\t\t\t\treturn function(event){\n\t\t\t\t\tHistory.Adapter.trigger(element,eventName,event);\n\t\t\t\t};\n\t\t\t})(element,eventName);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Object} event - a object of event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(element,eventName,event){\n\t\t\t// Prepare\n\t\t\tevent = event || {};\n\t\t\tvar uid = History.Adapter.uid(element),\n\t\t\t\ti,n;\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\n\t\t\t// Fire Listeners\n\t\t\tfor ( i=0,n=History.Adapter.handlers[uid][eventName].length; i<n; ++i ) {\n\t\t\t\tHistory.Adapter.handlers[uid][eventName][i].apply(this,[event]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\tvar result = (event && event[key]) || undefined;\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tvar timeout = window.setTimeout(function(){\n\t\t\t\tcallback();\n\t\t\t},2000);\n\t\t\twindow.onload = function(){\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tcallback();\n\t\t\t};\n\t\t}\n\t};\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js HTML4 Support\n * Depends on the HTML5 Support\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tsetTimeout = window.setTimeout||setTimeout,\n\t\tclearTimeout = window.clearTimeout||clearTimeout,\n\t\tsetInterval = window.setInterval||setInterval,\n\t\tHistory = window.History = window.History||{}; // Public History Object\n\n\t// Check Existence\n\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\tthrow new Error('History.js HTML4 Support has already been loaded...');\n\t}\n\n\n\t// ========================================================================\n\t// Initialise HTML4 Support\n\n\t// Initialise HTML4 Support\n\tHistory.initHtml4 = function(){\n\t\t// Initialise\n\t\tif ( typeof History.initHtml4.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initHtml4.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Properties\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = true;\n\n\n\t\t// ====================================================================\n\t\t// Hash Storage\n\n\t\t/**\n\t\t * History.savedHashes\n\t\t * Store the hashes in an array\n\t\t */\n\t\tHistory.savedHashes = [];\n\n\t\t/**\n\t\t * History.isLastHash(newHash)\n\t\t * Checks if the hash is the last hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isLastHash = function(newHash){\n\t\t\t// Prepare\n\t\t\tvar oldHash = History.getHashByIndex(),\n\t\t\t\tisLast;\n\n\t\t\t// Check\n\t\t\tisLast = newHash === oldHash;\n\n\t\t\t// Return isLast\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.isHashEqual(newHash, oldHash)\n\t\t * Checks to see if two hashes are functionally equal\n\t\t * @param {string} newHash\n\t\t * @param {string} oldHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isHashEqual = function(newHash, oldHash){\n\t\t\tnewHash = encodeURIComponent(newHash).replace(/%25/g, \"%\");\n\t\t\toldHash = encodeURIComponent(oldHash).replace(/%25/g, \"%\");\n\t\t\treturn newHash === oldHash;\n\t\t};\n\n\t\t/**\n\t\t * History.saveHash(newHash)\n\t\t * Push a Hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.saveHash = function(newHash){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastHash(newHash) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the Hash\n\t\t\tHistory.savedHashes.push(newHash);\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByIndex()\n\t\t * Gets a hash by the index\n\t\t * @param {integer} index\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHashByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar hash = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\thash = History.savedHashes[History.savedHashes.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\thash = History.savedHashes[History.savedHashes.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\thash = History.savedHashes[index];\n\t\t\t}\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Discarded States\n\n\t\t/**\n\t\t * History.discardedHashes\n\t\t * A hashed array of discarded hashes\n\t\t */\n\t\tHistory.discardedHashes = {};\n\n\t\t/**\n\t\t * History.discardedStates\n\t\t * A hashed array of discarded states\n\t\t */\n\t\tHistory.discardedStates = {};\n\n\t\t/**\n\t\t * History.discardState(State)\n\t\t * Discards the state by ignoring it through History\n\t\t * @param {object} State\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardState = function(discardedState,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Prepare\n\t\t\tvar discardedStateHash = History.getHashByState(discardedState),\n\t\t\t\tdiscardObject;\n\n\t\t\t// Create Discard Object\n\t\t\tdiscardObject = {\n\t\t\t\t'discardedState': discardedState,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to DiscardedStates\n\t\t\tHistory.discardedStates[discardedStateHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardHash(hash)\n\t\t * Discards the hash by ignoring it through History\n\t\t * @param {string} hash\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardHash = function(discardedHash,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Create Discard Object\n\t\t\tvar discardObject = {\n\t\t\t\t'discardedHash': discardedHash,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to discardedHash\n\t\t\tHistory.discardedHashes[discardedHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedState(State)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {object} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedState = function(State){\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State),\n\t\t\t\tdiscarded;\n\n\t\t\t// Check\n\t\t\tdiscarded = History.discardedStates[StateHash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedHash(hash)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {string} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedHash = function(hash){\n\t\t\t// Check\n\t\t\tvar discarded = History.discardedHashes[hash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.recycleState(State)\n\t\t * Allows a discarded state to be used again\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {true}\n\t\t */\n\t\tHistory.recycleState = function(State){\n\t\t\t//History.debug('History.recycleState', arguments);\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State);\n\n\t\t\t// Remove from DiscardedStates\n\t\t\tif ( History.discardedState(State) ) {\n\t\t\t\tdelete History.discardedStates[StateHash];\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML4 HashChange Support\n\n\t\tif ( History.emulated.hashChange ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML4 HashChange Support by manually checking for hash changes\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.hashChangeInit()\n\t\t\t * Init the HashChange Emulation\n\t\t\t */\n\t\t\tHistory.hashChangeInit = function(){\n\t\t\t\t// Define our Checker Function\n\t\t\t\tHistory.checkerFunction = null;\n\n\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\tvar lastDocumentHash = '',\n\t\t\t\t\tiframeId, iframe,\n\t\t\t\t\tlastIframeHash, checkerRunning,\n\t\t\t\t\tstartedWithHash = Boolean(History.getHash());\n\n\t\t\t\t// Handle depending on the browser\n\t\t\t\tif ( History.isInternetExplorer() ) {\n\t\t\t\t\t// IE6 and IE7\n\t\t\t\t\t// We need to use an iframe to emulate the back and forward buttons\n\n\t\t\t\t\t// Create iFrame\n\t\t\t\t\tiframeId = 'historyjs-iframe';\n\t\t\t\t\tiframe = document.createElement('iframe');\n\n\t\t\t\t\t// Adjust iFarme\n\t\t\t\t\t// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a\n\t\t\t\t\t// \"This page contains both secure and nonsecure items\" warning.\n\t\t\t\t\tiframe.setAttribute('id', iframeId);\n\t\t\t\t\tiframe.setAttribute('src', '#');\n\t\t\t\t\tiframe.style.display = 'none';\n\n\t\t\t\t\t// Append iFrame\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\t// Create initial history entry\n\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\t\tlastIframeHash = '';\n\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Check Running\n\t\t\t\t\t\tif ( checkerRunning ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update Running\n\t\t\t\t\t\tcheckerRunning = true;\n\n\t\t\t\t\t\t// Fetch\n\t\t\t\t\t\tvar\n\t\t\t\t\t\t\tdocumentHash = History.getHash(),\n\t\t\t\t\t\t\tiframeHash = History.getHash(iframe.contentWindow.document);\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Create a history entry in the iframe\n\t\t\t\t\t\t\tif ( iframeHash !== documentHash ) {\n\t\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);\n\n\t\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\t\tlastIframeHash = iframeHash = documentHash;\n\n\t\t\t\t\t\t\t\t// Create History Entry\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t\t\t\t// Update the iframe's hash\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.location.hash = History.escapeHash(documentHash);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The iFrame Hash has changed (back button caused)\n\t\t\t\t\t\telse if ( iframeHash !== lastIframeHash ) {\n\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);\n\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastIframeHash = iframeHash;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// If there is no iframe hash that means we're at the original\n\t\t\t\t\t\t\t// iframe state.\n\t\t\t\t\t\t\t// And if there was a hash on the original request, the original\n\t\t\t\t\t\t\t// iframe state was replaced instantly, so skip this state and take\n\t\t\t\t\t\t\t// the user back to where they came from.\n\t\t\t\t\t\t\tif (startedWithHash && iframeHash === '') {\n\t\t\t\t\t\t\t\tHistory.back();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Update the Hash\n\t\t\t\t\t\t\t\tHistory.setHash(iframeHash,false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset Running\n\t\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// We are not IE\n\t\t\t\t\t// Firefox 1 or 2, Opera\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Prepare\n\t\t\t\t\t\tvar documentHash = History.getHash()||'';\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Apply the checker function\n\t\t\t\tHistory.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));\n\n\t\t\t\t// Done\n\t\t\t\treturn true;\n\t\t\t}; // History.hashChangeInit\n\n\t\t\t// Bind hashChangeInit\n\t\t\tHistory.Adapter.onDomLoad(History.hashChangeInit);\n\n\t\t} // History.emulated.hashChange\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML5 State Management by using HTML4 HashChange\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onHashChange(event)\n\t\t\t * Trigger HTML5's window.onpopstate via HTML4 HashChange Support\n\t\t\t */\n\t\t\tHistory.onHashChange = function(event){\n\t\t\t\t//History.debug('History.onHashChange', arguments);\n\n\t\t\t\t// Prepare\n\t\t\t\tvar currentUrl = ((event && event.newURL) || History.getLocationHref()),\n\t\t\t\t\tcurrentHash = History.getHashByUrl(currentUrl),\n\t\t\t\t\tcurrentState = null,\n\t\t\t\t\tcurrentStateHash = null,\n\t\t\t\t\tcurrentStateHashExits = null,\n\t\t\t\t\tdiscardObject;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastHash(currentHash) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Store our location for use in detecting back/forward direction\n\t\t\t\tHistory.saveHash(currentHash);\n\n\t\t\t\t// Expand Hash\n\t\t\t\tif ( currentHash && History.isTraditionalAnchor(currentHash) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: traditional anchor', currentHash);\n\t\t\t\t\t// Traditional Anchor Hash\n\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tcurrentState = History.extractState(History.getFullUrl(currentHash||History.getLocationHref()),true);\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(currentState) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create the state Hash\n\t\t\t\tcurrentStateHash = History.getHashByState(currentState);\n\n\t\t\t\t// Check if we are DiscardedState\n\t\t\t\tdiscardObject = History.discardedState(currentState);\n\t\t\t\tif ( discardObject ) {\n\t\t\t\t\t// Ignore this state as it has been discarded and go back to the state before it\n\t\t\t\t\tif ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {\n\t\t\t\t\t\t// We are going backwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go backwards');\n\t\t\t\t\t\tHistory.back(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We are going forwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go forwards');\n\t\t\t\t\t\tHistory.forward(false);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Push the new HTML5 State\n\t\t\t\t//History.debug('History.onHashChange: success hashchange');\n\t\t\t\tHistory.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);\n\n\t\t\t\t// End onHashChange closure\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'hashchange',History.onHashChange);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Object\n\t\t\t\tvar newState = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\thtml4Hash = History.getHash(),\n\t\t\t\t\twasExpected = History.expectedStateId == newState.id;\n\n\t\t\t\t// Store the newState\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t// Recycle the State\n\t\t\t\tHistory.recycleState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Check if we are the same State\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t//History.debug('History.pushState: no change', newStateHash);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Update HTML5 State\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Fire HTML5 Event\n\t\t\t\tif(!wasExpected)\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\n\t\t\t\t// Update HTML4 Hash\n\t\t\t\tif ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {\n\t\t\t\t\tHistory.setHash(newStateHash,false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Objects\n\t\t\t\tvar newState        = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState        = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\tpreviousState   = History.getStateByIndex(-2);\n\n\t\t\t\t// Discard Old State\n\t\t\t\tHistory.discardState(oldState,newState,previousState);\n\n\t\t\t\t// If the url hasn't changed, just store and save the state\n\t\t\t\t// and fire a statechange event to be consistent with the\n\t\t\t\t// html 5 api\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\t\n\t\t\t\t\t// Recycle the State\n\t\t\t\t\tHistory.recycleState(newState);\n\t\n\t\t\t\t\t// Force update of the title\n\t\t\t\t\tHistory.setTitle(newState);\n\t\t\t\t\t\n\t\t\t\t\t// Update HTML5 State\n\t\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\t//History.debug('History.pushState: trigger popstate');\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Alias to PushState\n\t\t\t\t\tHistory.pushState(newState.data,newState.title,newState.url,false);\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // History.emulated.pushState\n\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/**\n\t\t\t * Ensure initial state is handled correctly\n\t\t\t */\n\t\t\tif ( History.getHash() && !History.emulated.hashChange ) {\n\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t});\n\t\t\t}\n\n\t\t} // History.emulated.pushState\n\n\t}; // History.initHtml4\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html4+html5/right.history.js",
    "content": "/*\n    json2.js\n    2012-10-08\n\n    Public Domain.\n\n    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n    See http://www.JSON.org/js.html\n\n\n    This code should be minified before deployment.\n    See http://javascript.crockford.com/jsmin.html\n\n    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n    NOT CONTROL.\n\n\n    This file creates a global JSON object containing two methods: stringify\n    and parse.\n\n        JSON.stringify(value, replacer, space)\n            value       any JavaScript value, usually an object or array.\n\n            replacer    an optional parameter that determines how object\n                        values are stringified for objects. It can be a\n                        function or an array of strings.\n\n            space       an optional parameter that specifies the indentation\n                        of nested structures. If it is omitted, the text will\n                        be packed without extra whitespace. If it is a number,\n                        it will specify the number of spaces to indent at each\n                        level. If it is a string (such as '\\t' or '&nbsp;'),\n                        it contains the characters used to indent at each level.\n\n            This method produces a JSON text from a JavaScript value.\n\n            When an object value is found, if the object contains a toJSON\n            method, its toJSON method will be called and the result will be\n            stringified. A toJSON method does not serialize: it returns the\n            value represented by the name/value pair that should be serialized,\n            or undefined if nothing should be serialized. The toJSON method\n            will be passed the key associated with the value, and this will be\n            bound to the value\n\n            For example, this would serialize Dates as ISO strings.\n\n                Date.prototype.toJSON = function (key) {\n                    function f(n) {\n                        // Format integers to have at least two digits.\n                        return n < 10 ? '0' + n : n;\n                    }\n\n                    return this.getUTCFullYear()   + '-' +\n                         f(this.getUTCMonth() + 1) + '-' +\n                         f(this.getUTCDate())      + 'T' +\n                         f(this.getUTCHours())     + ':' +\n                         f(this.getUTCMinutes())   + ':' +\n                         f(this.getUTCSeconds())   + 'Z';\n                };\n\n            You can provide an optional replacer method. It will be passed the\n            key and value of each member, with this bound to the containing\n            object. The value that is returned from your method will be\n            serialized. If your method returns undefined, then the member will\n            be excluded from the serialization.\n\n            If the replacer parameter is an array of strings, then it will be\n            used to select the members to be serialized. It filters the results\n            such that only members with keys listed in the replacer array are\n            stringified.\n\n            Values that do not have JSON representations, such as undefined or\n            functions, will not be serialized. Such values in objects will be\n            dropped; in arrays they will be replaced with null. You can use\n            a replacer function to replace those with JSON values.\n            JSON.stringify(undefined) returns undefined.\n\n            The optional space parameter produces a stringification of the\n            value that is filled with line breaks and indentation to make it\n            easier to read.\n\n            If the space parameter is a non-empty string, then that string will\n            be used for indentation. If the space parameter is a number, then\n            the indentation will be that many spaces.\n\n            Example:\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}]);\n            // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n            // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n            text = JSON.stringify([new Date()], function (key, value) {\n                return this[key] instanceof Date ?\n                    'Date(' + this[key] + ')' : value;\n            });\n            // text is '[\"Date(---current time---)\"]'\n\n\n        JSON.parse(text, reviver)\n            This method parses a JSON text to produce an object or array.\n            It can throw a SyntaxError exception.\n\n            The optional reviver parameter is a function that can filter and\n            transform the results. It receives each of the keys and values,\n            and its return value is used instead of the original value.\n            If it returns what it received, then the structure is not modified.\n            If it returns undefined then the member is deleted.\n\n            Example:\n\n            // Parse the text. Values that look like ISO date strings will\n            // be converted to Date objects.\n\n            myData = JSON.parse(text, function (key, value) {\n                var a;\n                if (typeof value === 'string') {\n                    a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n                    if (a) {\n                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n                            +a[5], +a[6]));\n                    }\n                }\n                return value;\n            });\n\n            myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n                var d;\n                if (typeof value === 'string' &&\n                        value.slice(0, 5) === 'Date(' &&\n                        value.slice(-1) === ')') {\n                    d = new Date(value.slice(5, -1));\n                    if (d) {\n                        return d;\n                    }\n                }\n                return value;\n            });\n\n\n    This is a reference implementation. You are free to copy, modify, or\n    redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== 'object') {\n    JSON = {};\n}\n\n(function () {\n    'use strict';\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10 ? '0' + n : n;\n    }\n\n    if (typeof Date.prototype.toJSON !== 'function') {\n\n        Date.prototype.toJSON = function (key) {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear()     + '-' +\n                    f(this.getUTCMonth() + 1) + '-' +\n                    f(this.getUTCDate())      + 'T' +\n                    f(this.getUTCHours())     + ':' +\n                    f(this.getUTCMinutes())   + ':' +\n                    f(this.getUTCSeconds())   + 'Z'\n                : null;\n        };\n\n        String.prototype.toJSON      =\n            Number.prototype.toJSON  =\n            Boolean.prototype.toJSON = function (key) {\n                return this.valueOf();\n            };\n    }\n\n    var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        gap,\n        indent,\n        meta = {    // table of character substitutions\n            '\\b': '\\\\b',\n            '\\t': '\\\\t',\n            '\\n': '\\\\n',\n            '\\f': '\\\\f',\n            '\\r': '\\\\r',\n            '\"' : '\\\\\"',\n            '\\\\': '\\\\\\\\'\n        },\n        rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        escapable.lastIndex = 0;\n        return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n            var c = meta[a];\n            return typeof c === 'string'\n                ? c\n                : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"' : '\"' + string + '\"';\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i,          // The loop counter.\n            k,          // The member key.\n            v,          // The member value.\n            length,\n            mind = gap,\n            partial,\n            value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === 'object' &&\n                typeof value.toJSON === 'function') {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === 'function') {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case 'string':\n            return quote(value);\n\n        case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value) ? String(value) : 'null';\n\n        case 'boolean':\n        case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n        case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n            if (!value) {\n                return 'null';\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || 'null';\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? '[]'\n                    : gap\n                    ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n                    : '[' + partial.join(',') + ']';\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === 'object') {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === 'string') {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? '{}'\n                : gap\n                ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n                : '{' + partial.join(',') + '}';\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== 'function') {\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = '';\n            indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === 'number') {\n                for (i = 0; i < space; i += 1) {\n                    indent += ' ';\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === 'string') {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== 'function' &&\n                    (typeof replacer !== 'object' ||\n                    typeof replacer.length !== 'number')) {\n                throw new Error('JSON.stringify');\n            }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n            return str('', {'': value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== 'function') {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k, v, value = holder[key];\n                if (value && typeof value === 'object') {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            cx.lastIndex = 0;\n            if (cx.test(text)) {\n                text = text.replace(cx, function (a) {\n                    return '\\\\u' +\n                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n            if (/^[\\],:{}\\s]*$/\n                    .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n                        .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n                        .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return typeof reviver === 'function'\n                    ? walk({'': j}, '')\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError('JSON.parse');\n        };\n    }\n}());/**\n * History.js RightJS Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tdocument = window.document,\n\t\tRightJS = window.RightJS,\n\t\t$ = RightJS.$;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|Selector} el\n\t\t * @param {String} event - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\t$(el).on(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|Selector} el\n\t\t * @param {String} event - custom and standard events\n\t\t * @param {Object} extraEventData - a object of extra event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(el,event,extraEventData){\n\t\t\t$(el).fire(event,extraEventData);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// Right.js Native\n\t\t\t// Right.js Custom\n\t\t\tvar result = (event && event._ && event._[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\t$(document).onReady(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js HTML4 Support\n * Depends on the HTML5 Support\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tsetTimeout = window.setTimeout||setTimeout,\n\t\tclearTimeout = window.clearTimeout||clearTimeout,\n\t\tsetInterval = window.setInterval||setInterval,\n\t\tHistory = window.History = window.History||{}; // Public History Object\n\n\t// Check Existence\n\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\tthrow new Error('History.js HTML4 Support has already been loaded...');\n\t}\n\n\n\t// ========================================================================\n\t// Initialise HTML4 Support\n\n\t// Initialise HTML4 Support\n\tHistory.initHtml4 = function(){\n\t\t// Initialise\n\t\tif ( typeof History.initHtml4.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initHtml4.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Properties\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = true;\n\n\n\t\t// ====================================================================\n\t\t// Hash Storage\n\n\t\t/**\n\t\t * History.savedHashes\n\t\t * Store the hashes in an array\n\t\t */\n\t\tHistory.savedHashes = [];\n\n\t\t/**\n\t\t * History.isLastHash(newHash)\n\t\t * Checks if the hash is the last hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isLastHash = function(newHash){\n\t\t\t// Prepare\n\t\t\tvar oldHash = History.getHashByIndex(),\n\t\t\t\tisLast;\n\n\t\t\t// Check\n\t\t\tisLast = newHash === oldHash;\n\n\t\t\t// Return isLast\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.isHashEqual(newHash, oldHash)\n\t\t * Checks to see if two hashes are functionally equal\n\t\t * @param {string} newHash\n\t\t * @param {string} oldHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isHashEqual = function(newHash, oldHash){\n\t\t\tnewHash = encodeURIComponent(newHash).replace(/%25/g, \"%\");\n\t\t\toldHash = encodeURIComponent(oldHash).replace(/%25/g, \"%\");\n\t\t\treturn newHash === oldHash;\n\t\t};\n\n\t\t/**\n\t\t * History.saveHash(newHash)\n\t\t * Push a Hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.saveHash = function(newHash){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastHash(newHash) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the Hash\n\t\t\tHistory.savedHashes.push(newHash);\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByIndex()\n\t\t * Gets a hash by the index\n\t\t * @param {integer} index\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHashByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar hash = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\thash = History.savedHashes[History.savedHashes.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\thash = History.savedHashes[History.savedHashes.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\thash = History.savedHashes[index];\n\t\t\t}\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Discarded States\n\n\t\t/**\n\t\t * History.discardedHashes\n\t\t * A hashed array of discarded hashes\n\t\t */\n\t\tHistory.discardedHashes = {};\n\n\t\t/**\n\t\t * History.discardedStates\n\t\t * A hashed array of discarded states\n\t\t */\n\t\tHistory.discardedStates = {};\n\n\t\t/**\n\t\t * History.discardState(State)\n\t\t * Discards the state by ignoring it through History\n\t\t * @param {object} State\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardState = function(discardedState,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Prepare\n\t\t\tvar discardedStateHash = History.getHashByState(discardedState),\n\t\t\t\tdiscardObject;\n\n\t\t\t// Create Discard Object\n\t\t\tdiscardObject = {\n\t\t\t\t'discardedState': discardedState,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to DiscardedStates\n\t\t\tHistory.discardedStates[discardedStateHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardHash(hash)\n\t\t * Discards the hash by ignoring it through History\n\t\t * @param {string} hash\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardHash = function(discardedHash,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Create Discard Object\n\t\t\tvar discardObject = {\n\t\t\t\t'discardedHash': discardedHash,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to discardedHash\n\t\t\tHistory.discardedHashes[discardedHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedState(State)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {object} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedState = function(State){\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State),\n\t\t\t\tdiscarded;\n\n\t\t\t// Check\n\t\t\tdiscarded = History.discardedStates[StateHash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedHash(hash)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {string} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedHash = function(hash){\n\t\t\t// Check\n\t\t\tvar discarded = History.discardedHashes[hash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.recycleState(State)\n\t\t * Allows a discarded state to be used again\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {true}\n\t\t */\n\t\tHistory.recycleState = function(State){\n\t\t\t//History.debug('History.recycleState', arguments);\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State);\n\n\t\t\t// Remove from DiscardedStates\n\t\t\tif ( History.discardedState(State) ) {\n\t\t\t\tdelete History.discardedStates[StateHash];\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML4 HashChange Support\n\n\t\tif ( History.emulated.hashChange ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML4 HashChange Support by manually checking for hash changes\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.hashChangeInit()\n\t\t\t * Init the HashChange Emulation\n\t\t\t */\n\t\t\tHistory.hashChangeInit = function(){\n\t\t\t\t// Define our Checker Function\n\t\t\t\tHistory.checkerFunction = null;\n\n\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\tvar lastDocumentHash = '',\n\t\t\t\t\tiframeId, iframe,\n\t\t\t\t\tlastIframeHash, checkerRunning,\n\t\t\t\t\tstartedWithHash = Boolean(History.getHash());\n\n\t\t\t\t// Handle depending on the browser\n\t\t\t\tif ( History.isInternetExplorer() ) {\n\t\t\t\t\t// IE6 and IE7\n\t\t\t\t\t// We need to use an iframe to emulate the back and forward buttons\n\n\t\t\t\t\t// Create iFrame\n\t\t\t\t\tiframeId = 'historyjs-iframe';\n\t\t\t\t\tiframe = document.createElement('iframe');\n\n\t\t\t\t\t// Adjust iFarme\n\t\t\t\t\t// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a\n\t\t\t\t\t// \"This page contains both secure and nonsecure items\" warning.\n\t\t\t\t\tiframe.setAttribute('id', iframeId);\n\t\t\t\t\tiframe.setAttribute('src', '#');\n\t\t\t\t\tiframe.style.display = 'none';\n\n\t\t\t\t\t// Append iFrame\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\t// Create initial history entry\n\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\t\tlastIframeHash = '';\n\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Check Running\n\t\t\t\t\t\tif ( checkerRunning ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update Running\n\t\t\t\t\t\tcheckerRunning = true;\n\n\t\t\t\t\t\t// Fetch\n\t\t\t\t\t\tvar\n\t\t\t\t\t\t\tdocumentHash = History.getHash(),\n\t\t\t\t\t\t\tiframeHash = History.getHash(iframe.contentWindow.document);\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Create a history entry in the iframe\n\t\t\t\t\t\t\tif ( iframeHash !== documentHash ) {\n\t\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);\n\n\t\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\t\tlastIframeHash = iframeHash = documentHash;\n\n\t\t\t\t\t\t\t\t// Create History Entry\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t\t\t\t// Update the iframe's hash\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.location.hash = History.escapeHash(documentHash);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The iFrame Hash has changed (back button caused)\n\t\t\t\t\t\telse if ( iframeHash !== lastIframeHash ) {\n\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);\n\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastIframeHash = iframeHash;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// If there is no iframe hash that means we're at the original\n\t\t\t\t\t\t\t// iframe state.\n\t\t\t\t\t\t\t// And if there was a hash on the original request, the original\n\t\t\t\t\t\t\t// iframe state was replaced instantly, so skip this state and take\n\t\t\t\t\t\t\t// the user back to where they came from.\n\t\t\t\t\t\t\tif (startedWithHash && iframeHash === '') {\n\t\t\t\t\t\t\t\tHistory.back();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Update the Hash\n\t\t\t\t\t\t\t\tHistory.setHash(iframeHash,false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset Running\n\t\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// We are not IE\n\t\t\t\t\t// Firefox 1 or 2, Opera\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Prepare\n\t\t\t\t\t\tvar documentHash = History.getHash()||'';\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Apply the checker function\n\t\t\t\tHistory.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));\n\n\t\t\t\t// Done\n\t\t\t\treturn true;\n\t\t\t}; // History.hashChangeInit\n\n\t\t\t// Bind hashChangeInit\n\t\t\tHistory.Adapter.onDomLoad(History.hashChangeInit);\n\n\t\t} // History.emulated.hashChange\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML5 State Management by using HTML4 HashChange\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onHashChange(event)\n\t\t\t * Trigger HTML5's window.onpopstate via HTML4 HashChange Support\n\t\t\t */\n\t\t\tHistory.onHashChange = function(event){\n\t\t\t\t//History.debug('History.onHashChange', arguments);\n\n\t\t\t\t// Prepare\n\t\t\t\tvar currentUrl = ((event && event.newURL) || History.getLocationHref()),\n\t\t\t\t\tcurrentHash = History.getHashByUrl(currentUrl),\n\t\t\t\t\tcurrentState = null,\n\t\t\t\t\tcurrentStateHash = null,\n\t\t\t\t\tcurrentStateHashExits = null,\n\t\t\t\t\tdiscardObject;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastHash(currentHash) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Store our location for use in detecting back/forward direction\n\t\t\t\tHistory.saveHash(currentHash);\n\n\t\t\t\t// Expand Hash\n\t\t\t\tif ( currentHash && History.isTraditionalAnchor(currentHash) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: traditional anchor', currentHash);\n\t\t\t\t\t// Traditional Anchor Hash\n\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tcurrentState = History.extractState(History.getFullUrl(currentHash||History.getLocationHref()),true);\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(currentState) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create the state Hash\n\t\t\t\tcurrentStateHash = History.getHashByState(currentState);\n\n\t\t\t\t// Check if we are DiscardedState\n\t\t\t\tdiscardObject = History.discardedState(currentState);\n\t\t\t\tif ( discardObject ) {\n\t\t\t\t\t// Ignore this state as it has been discarded and go back to the state before it\n\t\t\t\t\tif ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {\n\t\t\t\t\t\t// We are going backwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go backwards');\n\t\t\t\t\t\tHistory.back(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We are going forwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go forwards');\n\t\t\t\t\t\tHistory.forward(false);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Push the new HTML5 State\n\t\t\t\t//History.debug('History.onHashChange: success hashchange');\n\t\t\t\tHistory.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);\n\n\t\t\t\t// End onHashChange closure\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'hashchange',History.onHashChange);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Object\n\t\t\t\tvar newState = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\thtml4Hash = History.getHash(),\n\t\t\t\t\twasExpected = History.expectedStateId == newState.id;\n\n\t\t\t\t// Store the newState\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t// Recycle the State\n\t\t\t\tHistory.recycleState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Check if we are the same State\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t//History.debug('History.pushState: no change', newStateHash);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Update HTML5 State\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Fire HTML5 Event\n\t\t\t\tif(!wasExpected)\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\n\t\t\t\t// Update HTML4 Hash\n\t\t\t\tif ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {\n\t\t\t\t\tHistory.setHash(newStateHash,false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Objects\n\t\t\t\tvar newState        = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState        = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\tpreviousState   = History.getStateByIndex(-2);\n\n\t\t\t\t// Discard Old State\n\t\t\t\tHistory.discardState(oldState,newState,previousState);\n\n\t\t\t\t// If the url hasn't changed, just store and save the state\n\t\t\t\t// and fire a statechange event to be consistent with the\n\t\t\t\t// html 5 api\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\t\n\t\t\t\t\t// Recycle the State\n\t\t\t\t\tHistory.recycleState(newState);\n\t\n\t\t\t\t\t// Force update of the title\n\t\t\t\t\tHistory.setTitle(newState);\n\t\t\t\t\t\n\t\t\t\t\t// Update HTML5 State\n\t\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\t//History.debug('History.pushState: trigger popstate');\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Alias to PushState\n\t\t\t\t\tHistory.pushState(newState.data,newState.title,newState.url,false);\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // History.emulated.pushState\n\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/**\n\t\t\t * Ensure initial state is handled correctly\n\t\t\t */\n\t\t\tif ( History.getHash() && !History.emulated.hashChange ) {\n\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t});\n\t\t\t}\n\n\t\t} // History.emulated.pushState\n\n\t}; // History.initHtml4\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html4+html5/zepto.history.js",
    "content": "/*\n    json2.js\n    2012-10-08\n\n    Public Domain.\n\n    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n    See http://www.JSON.org/js.html\n\n\n    This code should be minified before deployment.\n    See http://javascript.crockford.com/jsmin.html\n\n    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n    NOT CONTROL.\n\n\n    This file creates a global JSON object containing two methods: stringify\n    and parse.\n\n        JSON.stringify(value, replacer, space)\n            value       any JavaScript value, usually an object or array.\n\n            replacer    an optional parameter that determines how object\n                        values are stringified for objects. It can be a\n                        function or an array of strings.\n\n            space       an optional parameter that specifies the indentation\n                        of nested structures. If it is omitted, the text will\n                        be packed without extra whitespace. If it is a number,\n                        it will specify the number of spaces to indent at each\n                        level. If it is a string (such as '\\t' or '&nbsp;'),\n                        it contains the characters used to indent at each level.\n\n            This method produces a JSON text from a JavaScript value.\n\n            When an object value is found, if the object contains a toJSON\n            method, its toJSON method will be called and the result will be\n            stringified. A toJSON method does not serialize: it returns the\n            value represented by the name/value pair that should be serialized,\n            or undefined if nothing should be serialized. The toJSON method\n            will be passed the key associated with the value, and this will be\n            bound to the value\n\n            For example, this would serialize Dates as ISO strings.\n\n                Date.prototype.toJSON = function (key) {\n                    function f(n) {\n                        // Format integers to have at least two digits.\n                        return n < 10 ? '0' + n : n;\n                    }\n\n                    return this.getUTCFullYear()   + '-' +\n                         f(this.getUTCMonth() + 1) + '-' +\n                         f(this.getUTCDate())      + 'T' +\n                         f(this.getUTCHours())     + ':' +\n                         f(this.getUTCMinutes())   + ':' +\n                         f(this.getUTCSeconds())   + 'Z';\n                };\n\n            You can provide an optional replacer method. It will be passed the\n            key and value of each member, with this bound to the containing\n            object. The value that is returned from your method will be\n            serialized. If your method returns undefined, then the member will\n            be excluded from the serialization.\n\n            If the replacer parameter is an array of strings, then it will be\n            used to select the members to be serialized. It filters the results\n            such that only members with keys listed in the replacer array are\n            stringified.\n\n            Values that do not have JSON representations, such as undefined or\n            functions, will not be serialized. Such values in objects will be\n            dropped; in arrays they will be replaced with null. You can use\n            a replacer function to replace those with JSON values.\n            JSON.stringify(undefined) returns undefined.\n\n            The optional space parameter produces a stringification of the\n            value that is filled with line breaks and indentation to make it\n            easier to read.\n\n            If the space parameter is a non-empty string, then that string will\n            be used for indentation. If the space parameter is a number, then\n            the indentation will be that many spaces.\n\n            Example:\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}]);\n            // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n            // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n            text = JSON.stringify([new Date()], function (key, value) {\n                return this[key] instanceof Date ?\n                    'Date(' + this[key] + ')' : value;\n            });\n            // text is '[\"Date(---current time---)\"]'\n\n\n        JSON.parse(text, reviver)\n            This method parses a JSON text to produce an object or array.\n            It can throw a SyntaxError exception.\n\n            The optional reviver parameter is a function that can filter and\n            transform the results. It receives each of the keys and values,\n            and its return value is used instead of the original value.\n            If it returns what it received, then the structure is not modified.\n            If it returns undefined then the member is deleted.\n\n            Example:\n\n            // Parse the text. Values that look like ISO date strings will\n            // be converted to Date objects.\n\n            myData = JSON.parse(text, function (key, value) {\n                var a;\n                if (typeof value === 'string') {\n                    a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n                    if (a) {\n                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n                            +a[5], +a[6]));\n                    }\n                }\n                return value;\n            });\n\n            myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n                var d;\n                if (typeof value === 'string' &&\n                        value.slice(0, 5) === 'Date(' &&\n                        value.slice(-1) === ')') {\n                    d = new Date(value.slice(5, -1));\n                    if (d) {\n                        return d;\n                    }\n                }\n                return value;\n            });\n\n\n    This is a reference implementation. You are free to copy, modify, or\n    redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== 'object') {\n    JSON = {};\n}\n\n(function () {\n    'use strict';\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10 ? '0' + n : n;\n    }\n\n    if (typeof Date.prototype.toJSON !== 'function') {\n\n        Date.prototype.toJSON = function (key) {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear()     + '-' +\n                    f(this.getUTCMonth() + 1) + '-' +\n                    f(this.getUTCDate())      + 'T' +\n                    f(this.getUTCHours())     + ':' +\n                    f(this.getUTCMinutes())   + ':' +\n                    f(this.getUTCSeconds())   + 'Z'\n                : null;\n        };\n\n        String.prototype.toJSON      =\n            Number.prototype.toJSON  =\n            Boolean.prototype.toJSON = function (key) {\n                return this.valueOf();\n            };\n    }\n\n    var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        gap,\n        indent,\n        meta = {    // table of character substitutions\n            '\\b': '\\\\b',\n            '\\t': '\\\\t',\n            '\\n': '\\\\n',\n            '\\f': '\\\\f',\n            '\\r': '\\\\r',\n            '\"' : '\\\\\"',\n            '\\\\': '\\\\\\\\'\n        },\n        rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        escapable.lastIndex = 0;\n        return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n            var c = meta[a];\n            return typeof c === 'string'\n                ? c\n                : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"' : '\"' + string + '\"';\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i,          // The loop counter.\n            k,          // The member key.\n            v,          // The member value.\n            length,\n            mind = gap,\n            partial,\n            value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === 'object' &&\n                typeof value.toJSON === 'function') {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === 'function') {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case 'string':\n            return quote(value);\n\n        case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value) ? String(value) : 'null';\n\n        case 'boolean':\n        case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n        case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n            if (!value) {\n                return 'null';\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || 'null';\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? '[]'\n                    : gap\n                    ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n                    : '[' + partial.join(',') + ']';\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === 'object') {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === 'string') {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? '{}'\n                : gap\n                ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n                : '{' + partial.join(',') + '}';\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== 'function') {\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = '';\n            indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === 'number') {\n                for (i = 0; i < space; i += 1) {\n                    indent += ' ';\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === 'string') {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== 'function' &&\n                    (typeof replacer !== 'object' ||\n                    typeof replacer.length !== 'number')) {\n                throw new Error('JSON.stringify');\n            }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n            return str('', {'': value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== 'function') {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k, v, value = holder[key];\n                if (value && typeof value === 'object') {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            cx.lastIndex = 0;\n            if (cx.test(text)) {\n                text = text.replace(cx, function (a) {\n                    return '\\\\u' +\n                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n            if (/^[\\],:{}\\s]*$/\n                    .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n                        .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n                        .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return typeof reviver === 'function'\n                    ? walk({'': j}, '')\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError('JSON.parse');\n        };\n    }\n}());/**\n * History.js Zepto Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tZepto = window.Zepto;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tnew Zepto(el).bind(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {void}\n\t\t */\n\t\ttrigger: function(el,event){\n\t\t\tnew Zepto(el).trigger(event);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// Zepto Native\n\t\t\tvar result = (event && event[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tnew Zepto(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js HTML4 Support\n * Depends on the HTML5 Support\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tsetTimeout = window.setTimeout||setTimeout,\n\t\tclearTimeout = window.clearTimeout||clearTimeout,\n\t\tsetInterval = window.setInterval||setInterval,\n\t\tHistory = window.History = window.History||{}; // Public History Object\n\n\t// Check Existence\n\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\tthrow new Error('History.js HTML4 Support has already been loaded...');\n\t}\n\n\n\t// ========================================================================\n\t// Initialise HTML4 Support\n\n\t// Initialise HTML4 Support\n\tHistory.initHtml4 = function(){\n\t\t// Initialise\n\t\tif ( typeof History.initHtml4.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initHtml4.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Properties\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = true;\n\n\n\t\t// ====================================================================\n\t\t// Hash Storage\n\n\t\t/**\n\t\t * History.savedHashes\n\t\t * Store the hashes in an array\n\t\t */\n\t\tHistory.savedHashes = [];\n\n\t\t/**\n\t\t * History.isLastHash(newHash)\n\t\t * Checks if the hash is the last hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isLastHash = function(newHash){\n\t\t\t// Prepare\n\t\t\tvar oldHash = History.getHashByIndex(),\n\t\t\t\tisLast;\n\n\t\t\t// Check\n\t\t\tisLast = newHash === oldHash;\n\n\t\t\t// Return isLast\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.isHashEqual(newHash, oldHash)\n\t\t * Checks to see if two hashes are functionally equal\n\t\t * @param {string} newHash\n\t\t * @param {string} oldHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isHashEqual = function(newHash, oldHash){\n\t\t\tnewHash = encodeURIComponent(newHash).replace(/%25/g, \"%\");\n\t\t\toldHash = encodeURIComponent(oldHash).replace(/%25/g, \"%\");\n\t\t\treturn newHash === oldHash;\n\t\t};\n\n\t\t/**\n\t\t * History.saveHash(newHash)\n\t\t * Push a Hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.saveHash = function(newHash){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastHash(newHash) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the Hash\n\t\t\tHistory.savedHashes.push(newHash);\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByIndex()\n\t\t * Gets a hash by the index\n\t\t * @param {integer} index\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHashByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar hash = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\thash = History.savedHashes[History.savedHashes.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\thash = History.savedHashes[History.savedHashes.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\thash = History.savedHashes[index];\n\t\t\t}\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Discarded States\n\n\t\t/**\n\t\t * History.discardedHashes\n\t\t * A hashed array of discarded hashes\n\t\t */\n\t\tHistory.discardedHashes = {};\n\n\t\t/**\n\t\t * History.discardedStates\n\t\t * A hashed array of discarded states\n\t\t */\n\t\tHistory.discardedStates = {};\n\n\t\t/**\n\t\t * History.discardState(State)\n\t\t * Discards the state by ignoring it through History\n\t\t * @param {object} State\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardState = function(discardedState,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Prepare\n\t\t\tvar discardedStateHash = History.getHashByState(discardedState),\n\t\t\t\tdiscardObject;\n\n\t\t\t// Create Discard Object\n\t\t\tdiscardObject = {\n\t\t\t\t'discardedState': discardedState,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to DiscardedStates\n\t\t\tHistory.discardedStates[discardedStateHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardHash(hash)\n\t\t * Discards the hash by ignoring it through History\n\t\t * @param {string} hash\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardHash = function(discardedHash,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Create Discard Object\n\t\t\tvar discardObject = {\n\t\t\t\t'discardedHash': discardedHash,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to discardedHash\n\t\t\tHistory.discardedHashes[discardedHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedState(State)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {object} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedState = function(State){\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State),\n\t\t\t\tdiscarded;\n\n\t\t\t// Check\n\t\t\tdiscarded = History.discardedStates[StateHash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedHash(hash)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {string} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedHash = function(hash){\n\t\t\t// Check\n\t\t\tvar discarded = History.discardedHashes[hash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.recycleState(State)\n\t\t * Allows a discarded state to be used again\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {true}\n\t\t */\n\t\tHistory.recycleState = function(State){\n\t\t\t//History.debug('History.recycleState', arguments);\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State);\n\n\t\t\t// Remove from DiscardedStates\n\t\t\tif ( History.discardedState(State) ) {\n\t\t\t\tdelete History.discardedStates[StateHash];\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML4 HashChange Support\n\n\t\tif ( History.emulated.hashChange ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML4 HashChange Support by manually checking for hash changes\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.hashChangeInit()\n\t\t\t * Init the HashChange Emulation\n\t\t\t */\n\t\t\tHistory.hashChangeInit = function(){\n\t\t\t\t// Define our Checker Function\n\t\t\t\tHistory.checkerFunction = null;\n\n\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\tvar lastDocumentHash = '',\n\t\t\t\t\tiframeId, iframe,\n\t\t\t\t\tlastIframeHash, checkerRunning,\n\t\t\t\t\tstartedWithHash = Boolean(History.getHash());\n\n\t\t\t\t// Handle depending on the browser\n\t\t\t\tif ( History.isInternetExplorer() ) {\n\t\t\t\t\t// IE6 and IE7\n\t\t\t\t\t// We need to use an iframe to emulate the back and forward buttons\n\n\t\t\t\t\t// Create iFrame\n\t\t\t\t\tiframeId = 'historyjs-iframe';\n\t\t\t\t\tiframe = document.createElement('iframe');\n\n\t\t\t\t\t// Adjust iFarme\n\t\t\t\t\t// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a\n\t\t\t\t\t// \"This page contains both secure and nonsecure items\" warning.\n\t\t\t\t\tiframe.setAttribute('id', iframeId);\n\t\t\t\t\tiframe.setAttribute('src', '#');\n\t\t\t\t\tiframe.style.display = 'none';\n\n\t\t\t\t\t// Append iFrame\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\t// Create initial history entry\n\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\t\tlastIframeHash = '';\n\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Check Running\n\t\t\t\t\t\tif ( checkerRunning ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update Running\n\t\t\t\t\t\tcheckerRunning = true;\n\n\t\t\t\t\t\t// Fetch\n\t\t\t\t\t\tvar\n\t\t\t\t\t\t\tdocumentHash = History.getHash(),\n\t\t\t\t\t\t\tiframeHash = History.getHash(iframe.contentWindow.document);\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Create a history entry in the iframe\n\t\t\t\t\t\t\tif ( iframeHash !== documentHash ) {\n\t\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);\n\n\t\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\t\tlastIframeHash = iframeHash = documentHash;\n\n\t\t\t\t\t\t\t\t// Create History Entry\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t\t\t\t// Update the iframe's hash\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.location.hash = History.escapeHash(documentHash);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The iFrame Hash has changed (back button caused)\n\t\t\t\t\t\telse if ( iframeHash !== lastIframeHash ) {\n\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);\n\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastIframeHash = iframeHash;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// If there is no iframe hash that means we're at the original\n\t\t\t\t\t\t\t// iframe state.\n\t\t\t\t\t\t\t// And if there was a hash on the original request, the original\n\t\t\t\t\t\t\t// iframe state was replaced instantly, so skip this state and take\n\t\t\t\t\t\t\t// the user back to where they came from.\n\t\t\t\t\t\t\tif (startedWithHash && iframeHash === '') {\n\t\t\t\t\t\t\t\tHistory.back();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Update the Hash\n\t\t\t\t\t\t\t\tHistory.setHash(iframeHash,false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset Running\n\t\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// We are not IE\n\t\t\t\t\t// Firefox 1 or 2, Opera\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Prepare\n\t\t\t\t\t\tvar documentHash = History.getHash()||'';\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Apply the checker function\n\t\t\t\tHistory.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));\n\n\t\t\t\t// Done\n\t\t\t\treturn true;\n\t\t\t}; // History.hashChangeInit\n\n\t\t\t// Bind hashChangeInit\n\t\t\tHistory.Adapter.onDomLoad(History.hashChangeInit);\n\n\t\t} // History.emulated.hashChange\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML5 State Management by using HTML4 HashChange\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onHashChange(event)\n\t\t\t * Trigger HTML5's window.onpopstate via HTML4 HashChange Support\n\t\t\t */\n\t\t\tHistory.onHashChange = function(event){\n\t\t\t\t//History.debug('History.onHashChange', arguments);\n\n\t\t\t\t// Prepare\n\t\t\t\tvar currentUrl = ((event && event.newURL) || History.getLocationHref()),\n\t\t\t\t\tcurrentHash = History.getHashByUrl(currentUrl),\n\t\t\t\t\tcurrentState = null,\n\t\t\t\t\tcurrentStateHash = null,\n\t\t\t\t\tcurrentStateHashExits = null,\n\t\t\t\t\tdiscardObject;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastHash(currentHash) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Store our location for use in detecting back/forward direction\n\t\t\t\tHistory.saveHash(currentHash);\n\n\t\t\t\t// Expand Hash\n\t\t\t\tif ( currentHash && History.isTraditionalAnchor(currentHash) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: traditional anchor', currentHash);\n\t\t\t\t\t// Traditional Anchor Hash\n\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tcurrentState = History.extractState(History.getFullUrl(currentHash||History.getLocationHref()),true);\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(currentState) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create the state Hash\n\t\t\t\tcurrentStateHash = History.getHashByState(currentState);\n\n\t\t\t\t// Check if we are DiscardedState\n\t\t\t\tdiscardObject = History.discardedState(currentState);\n\t\t\t\tif ( discardObject ) {\n\t\t\t\t\t// Ignore this state as it has been discarded and go back to the state before it\n\t\t\t\t\tif ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {\n\t\t\t\t\t\t// We are going backwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go backwards');\n\t\t\t\t\t\tHistory.back(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We are going forwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go forwards');\n\t\t\t\t\t\tHistory.forward(false);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Push the new HTML5 State\n\t\t\t\t//History.debug('History.onHashChange: success hashchange');\n\t\t\t\tHistory.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);\n\n\t\t\t\t// End onHashChange closure\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'hashchange',History.onHashChange);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Object\n\t\t\t\tvar newState = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\thtml4Hash = History.getHash(),\n\t\t\t\t\twasExpected = History.expectedStateId == newState.id;\n\n\t\t\t\t// Store the newState\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t// Recycle the State\n\t\t\t\tHistory.recycleState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Check if we are the same State\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t//History.debug('History.pushState: no change', newStateHash);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Update HTML5 State\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Fire HTML5 Event\n\t\t\t\tif(!wasExpected)\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\n\t\t\t\t// Update HTML4 Hash\n\t\t\t\tif ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {\n\t\t\t\t\tHistory.setHash(newStateHash,false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Objects\n\t\t\t\tvar newState        = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState        = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\tpreviousState   = History.getStateByIndex(-2);\n\n\t\t\t\t// Discard Old State\n\t\t\t\tHistory.discardState(oldState,newState,previousState);\n\n\t\t\t\t// If the url hasn't changed, just store and save the state\n\t\t\t\t// and fire a statechange event to be consistent with the\n\t\t\t\t// html 5 api\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\t\n\t\t\t\t\t// Recycle the State\n\t\t\t\t\tHistory.recycleState(newState);\n\t\n\t\t\t\t\t// Force update of the title\n\t\t\t\t\tHistory.setTitle(newState);\n\t\t\t\t\t\n\t\t\t\t\t// Update HTML5 State\n\t\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\t//History.debug('History.pushState: trigger popstate');\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Alias to PushState\n\t\t\t\t\tHistory.pushState(newState.data,newState.title,newState.url,false);\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // History.emulated.pushState\n\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/**\n\t\t\t * Ensure initial state is handled correctly\n\t\t\t */\n\t\t\tif ( History.getHash() && !History.emulated.hashChange ) {\n\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t});\n\t\t\t}\n\n\t\t} // History.emulated.pushState\n\n\t}; // History.initHtml4\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html5/dojo.history.js",
    "content": "/**\n * History.js Dojo Adapter\n *\n * Essentially the same as the native adapter but uses dojo/ready for the dom load callback.\n *\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar History = window.History = window.History||{},\n        require = window.require;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.handlers[uid][eventName] = Array\n\t\t */\n\t\thandlers: {},\n\n\t\t/**\n\t\t * History.Adapter._uid\n\t\t * The current element unique identifier\n\t\t */\n\t\t_uid: 1,\n\n\t\t/**\n\t\t * History.Adapter.uid(element)\n\t\t * @param {Element} element\n\t\t * @return {String} uid\n\t\t */\n\t\tuid: function(element){\n\t\t\treturn element._uid || (element._uid = History.Adapter._uid++);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(element,eventName,callback){\n\t\t\t// Prepare\n\t\t\tvar uid = History.Adapter.uid(element);\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\t\t\tHistory.Adapter.handlers[uid][eventName].push(callback);\n\n\t\t\t// Bind Global Listener\n\t\t\telement['on'+eventName] = (function(element,eventName){\n\t\t\t\treturn function(event){\n\t\t\t\t\tHistory.Adapter.trigger(element,eventName,event);\n\t\t\t\t};\n\t\t\t})(element,eventName);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Object} event - a object of event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(element,eventName,event){\n\t\t\t// Prepare\n\t\t\tevent = event || {};\n\t\t\tvar uid = History.Adapter.uid(element),\n\t\t\t\ti,n;\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\n\t\t\t// Fire Listeners\n\t\t\tfor ( i=0,n=History.Adapter.handlers[uid][eventName].length; i<n; ++i ) {\n\t\t\t\tHistory.Adapter.handlers[uid][eventName][i].apply(this,[event]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\tvar result = (event && event[key]) || undefined;\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\trequire([\"dojo/ready\"], function(ready) {\n\t\t\t\tready(callback);\n\t\t\t});\n\t\t}\n\t};\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html5/extjs.history.js",
    "content": "/**\n * History.js ExtJS Adapter\n * @author Sean Adkinson <sean.adkinson@gmail.com>\n * @copyright 2012 Sean Adkinson <sean.adkinson@gmail.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n    \"use strict\";\n\n    // Localise Globals\n    var\n        History = window.History = window.History||{},\n        Ext = window.Ext;\n\n    window.JSON = {\n        stringify: Ext.JSON.encode,\n        parse: Ext.JSON.decode\n    };\n    \n    // Check Existence\n    if ( typeof History.Adapter !== 'undefined' ) {\n        throw new Error('History.js Adapter has already been loaded...');\n    }\n\n    // Add the Adapter\n    History.Adapter = {\n        observables: {},\n        \n        /**\n         * History.Adapter.bind(el,event,callback)\n         * @param {Element|string} el\n         * @param {string} event - custom and standard events\n         * @param {function} callback\n         * @param {Object} scope\n         * @return {void}\n         */\n        bind: function(element,eventName,callback,scope){\n            Ext.EventManager.addListener(element, eventName, callback, scope);\n            \n            //bind an observable to the element that will let us \"trigger\" events on it\n            var id = Ext.id(element, 'history-'), observable = this.observables[id];\n            if (!observable) {\n                observable = Ext.create('Ext.util.Observable');\n                this.observables[id] = observable;\n            }\n            observable.on(eventName, callback, scope);\n        },\n\n        /**\n         * History.Adapter.trigger(el,event)\n         * @param {Element|string} el\n         * @param {string} event - custom and standard events\n         * @param {Object=} extra - a object of extra event data (optional)\n         * @return {void}\n         */\n        trigger: function(element,eventName,extra){\n            var id = Ext.id(element, 'history-'), observable = this.observables[id];\n            if (observable) {\n                observable.fireEvent(eventName, extra);\n            }\n        },\n\n        /**\n         * History.Adapter.extractEventData(key,event,extra)\n         * @param {string} key - key for the event data to extract\n         * @param {string} event - custom and standard events\n         * @param {Object=} extra - a object of extra event data (optional)\n         * @return {mixed}\n         */\n        extractEventData: function(key,event,extra){\n            var result = (event && event.browserEvent && event.browserEvent[key]) || (extra && extra[key]) || undefined;\n            return result;\n        },\n\n        /**\n         * History.Adapter.onDomLoad(callback)\n         * @param {function} callback\n         * @return {void}\n         */\n        onDomLoad: function(callback) {\n            Ext.onReady(callback);\n        }\n    };\n\n    // Try and Initialise History\n    if ( typeof History.init !== 'undefined' ) {\n        History.init();\n    }\n\n})(window);/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html5/jquery.history.js",
    "content": "/**\n * History.js jQuery Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tjQuery = window.jQuery;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tjQuery(el).bind(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return {void}\n\t\t */\n\t\ttrigger: function(el,event,extra){\n\t\t\tjQuery(el).trigger(event,extra);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event,extra){\n\t\t\t// jQuery Native then jQuery Custom\n\t\t\tvar result = (event && event.originalEvent && event.originalEvent[key]) || (extra && extra[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tjQuery(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html5/mootools.history.js",
    "content": "/**\n * History.js MooTools Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tMooTools = window.MooTools,\n\t\tElement = window.Element;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Make MooTools aware of History.js Events\n\tObject.append(Element.NativeEvents,{\n\t\t'popstate':2,\n\t\t'hashchange':2\n\t});\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tvar El = typeof el === 'string' ? document.id(el) : el;\n\t\t\tEl.addEvent(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return void\n\t\t */\n\t\ttrigger: function(el,event,extra){\n\t\t\tvar El = typeof el === 'string' ? document.id(el) : el;\n\t\t\tEl.fireEvent(event,extra);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// MooTools Native then MooTools Custom\n\t\t\tvar result = (event && event.event && event.event[key]) || (event && event[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\twindow.addEvent('domready',callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html5/native.history.js",
    "content": "/**\n * History.js Native Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar History = window.History = window.History||{};\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.handlers[uid][eventName] = Array\n\t\t */\n\t\thandlers: {},\n\n\t\t/**\n\t\t * History.Adapter._uid\n\t\t * The current element unique identifier\n\t\t */\n\t\t_uid: 1,\n\n\t\t/**\n\t\t * History.Adapter.uid(element)\n\t\t * @param {Element} element\n\t\t * @return {String} uid\n\t\t */\n\t\tuid: function(element){\n\t\t\treturn element._uid || (element._uid = History.Adapter._uid++);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(element,eventName,callback){\n\t\t\t// Prepare\n\t\t\tvar uid = History.Adapter.uid(element);\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\t\t\tHistory.Adapter.handlers[uid][eventName].push(callback);\n\n\t\t\t// Bind Global Listener\n\t\t\telement['on'+eventName] = (function(element,eventName){\n\t\t\t\treturn function(event){\n\t\t\t\t\tHistory.Adapter.trigger(element,eventName,event);\n\t\t\t\t};\n\t\t\t})(element,eventName);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Object} event - a object of event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(element,eventName,event){\n\t\t\t// Prepare\n\t\t\tevent = event || {};\n\t\t\tvar uid = History.Adapter.uid(element),\n\t\t\t\ti,n;\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\n\t\t\t// Fire Listeners\n\t\t\tfor ( i=0,n=History.Adapter.handlers[uid][eventName].length; i<n; ++i ) {\n\t\t\t\tHistory.Adapter.handlers[uid][eventName][i].apply(this,[event]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\tvar result = (event && event[key]) || undefined;\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tvar timeout = window.setTimeout(function(){\n\t\t\t\tcallback();\n\t\t\t},2000);\n\t\t\twindow.onload = function(){\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tcallback();\n\t\t\t};\n\t\t}\n\t};\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html5/right.history.js",
    "content": "/**\n * History.js RightJS Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tdocument = window.document,\n\t\tRightJS = window.RightJS,\n\t\t$ = RightJS.$;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|Selector} el\n\t\t * @param {String} event - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\t$(el).on(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|Selector} el\n\t\t * @param {String} event - custom and standard events\n\t\t * @param {Object} extraEventData - a object of extra event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(el,event,extraEventData){\n\t\t\t$(el).fire(event,extraEventData);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// Right.js Native\n\t\t\t// Right.js Custom\n\t\t\tvar result = (event && event._ && event._[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\t$(document).onReady(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/bundled-uncompressed/html5/zepto.history.js",
    "content": "/**\n * History.js Zepto Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tZepto = window.Zepto;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tnew Zepto(el).bind(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {void}\n\t\t */\n\t\ttrigger: function(el,event){\n\t\t\tnew Zepto(el).trigger(event);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// Zepto Native\n\t\t\tvar result = (event && event[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tnew Zepto(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/compressed/history.adapter.dojo.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.require;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={handlers:{},_uid:1,uid:function(e){return e._uid||(e._uid=n.Adapter._uid++)},bind:function(e,t,r){var i=n.Adapter.uid(e);n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[],n.Adapter.handlers[i][t].push(r),e[\"on\"+t]=function(e,t){return function(r){n.Adapter.trigger(e,t,r)}}(e,t)},trigger:function(e,t,r){r=r||{};var i=n.Adapter.uid(e),s,o;n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[];for(s=0,o=n.Adapter.handlers[i][t].length;s<o;++s)n.Adapter.handlers[i][t][s].apply(this,[r])},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(e){r([\"dojo/ready\"],function(t){t(e)})}},typeof n.init!=\"undefined\"&&n.init()})(window)"
  },
  {
    "path": "scripts/compressed/history.adapter.extjs.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.Ext;e.JSON={stringify:r.JSON.encode,parse:r.JSON.decode};if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={observables:{},bind:function(e,t,n,i){r.EventManager.addListener(e,t,n,i);var s=r.id(e,\"history-\"),o=this.observables[s];o||(o=r.create(\"Ext.util.Observable\"),this.observables[s]=o),o.on(t,n,i)},trigger:function(e,t,n){var i=r.id(e,\"history-\"),s=this.observables[i];s&&s.fireEvent(t,n)},extractEventData:function(e,n,r){var i=n&&n.browserEvent&&n.browserEvent[e]||r&&r[e]||t;return i},onDomLoad:function(e){r.onReady(e)}},typeof n.init!=\"undefined\"&&n.init()})(window)"
  },
  {
    "path": "scripts/compressed/history.adapter.jquery.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.jQuery;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){r(e).bind(t,n)},trigger:function(e,t,n){r(e).trigger(t,n)},extractEventData:function(e,n,r){var i=n&&n.originalEvent&&n.originalEvent[e]||r&&r[e]||t;return i},onDomLoad:function(e){r(e)}},typeof n.init!=\"undefined\"&&n.init()})(window)"
  },
  {
    "path": "scripts/compressed/history.adapter.mootools.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.MooTools,i=e.Element;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");Object.append(i.NativeEvents,{popstate:2,hashchange:2}),n.Adapter={bind:function(e,t,n){var r=typeof e==\"string\"?document.id(e):e;r.addEvent(t,n)},trigger:function(e,t,n){var r=typeof e==\"string\"?document.id(e):e;r.fireEvent(t,n)},extractEventData:function(e,n){var r=n&&n.event&&n.event[e]||n&&n[e]||t;return r},onDomLoad:function(t){e.addEvent(\"domready\",t)}},typeof n.init!=\"undefined\"&&n.init()})(window)"
  },
  {
    "path": "scripts/compressed/history.adapter.native.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{};if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={handlers:{},_uid:1,uid:function(e){return e._uid||(e._uid=n.Adapter._uid++)},bind:function(e,t,r){var i=n.Adapter.uid(e);n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[],n.Adapter.handlers[i][t].push(r),e[\"on\"+t]=function(e,t){return function(r){n.Adapter.trigger(e,t,r)}}(e,t)},trigger:function(e,t,r){r=r||{};var i=n.Adapter.uid(e),s,o;n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[];for(s=0,o=n.Adapter.handlers[i][t].length;s<o;++s)n.Adapter.handlers[i][t][s].apply(this,[r])},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(t){var n=e.setTimeout(function(){t()},2e3);e.onload=function(){clearTimeout(n),t()}}},typeof n.init!=\"undefined\"&&n.init()})(window)"
  },
  {
    "path": "scripts/compressed/history.adapter.right.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.document,i=e.RightJS,s=i.$;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){s(e).on(t,n)},trigger:function(e,t,n){s(e).fire(t,n)},extractEventData:function(e,n){var r=n&&n._&&n._[e]||t;return r},onDomLoad:function(e){s(r).onReady(e)}},typeof n.init!=\"undefined\"&&n.init()})(window)"
  },
  {
    "path": "scripts/compressed/history.adapter.zepto.js",
    "content": "(function(e,t){\"use strict\";var n=e.History=e.History||{},r=e.Zepto;if(typeof n.Adapter!=\"undefined\")throw new Error(\"History.js Adapter has already been loaded...\");n.Adapter={bind:function(e,t,n){(new r(e)).bind(t,n)},trigger:function(e,t){(new r(e)).trigger(t)},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(e){new r(e)}},typeof n.init!=\"undefined\"&&n.init()})(window)"
  },
  {
    "path": "scripts/compressed/history.html4.js",
    "content": "(function(e,t){\"use strict\";var n=e.document,r=e.setTimeout||r,i=e.clearTimeout||i,s=e.setInterval||s,o=e.History=e.History||{};if(typeof o.initHtml4!=\"undefined\")throw new Error(\"History.js HTML4 Support has already been loaded...\");o.initHtml4=function(){if(typeof o.initHtml4.initialized!=\"undefined\")return!1;o.initHtml4.initialized=!0,o.enabled=!0,o.savedHashes=[],o.isLastHash=function(e){var t=o.getHashByIndex(),n;return n=e===t,n},o.isHashEqual=function(e,t){return e=encodeURIComponent(e).replace(/%25/g,\"%\"),t=encodeURIComponent(t).replace(/%25/g,\"%\"),e===t},o.saveHash=function(e){return o.isLastHash(e)?!1:(o.savedHashes.push(e),!0)},o.getHashByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=o.savedHashes[o.savedHashes.length-1]:e<0?t=o.savedHashes[o.savedHashes.length+e]:t=o.savedHashes[e],t},o.discardedHashes={},o.discardedStates={},o.discardState=function(e,t,n){var r=o.getHashByState(e),i;return i={discardedState:e,backState:n,forwardState:t},o.discardedStates[r]=i,!0},o.discardHash=function(e,t,n){var r={discardedHash:e,backState:n,forwardState:t};return o.discardedHashes[e]=r,!0},o.discardedState=function(e){var t=o.getHashByState(e),n;return n=o.discardedStates[t]||!1,n},o.discardedHash=function(e){var t=o.discardedHashes[e]||!1;return t},o.recycleState=function(e){var t=o.getHashByState(e);return o.discardedState(e)&&delete o.discardedStates[t],!0},o.emulated.hashChange&&(o.hashChangeInit=function(){o.checkerFunction=null;var t=\"\",r,i,u,a,f=Boolean(o.getHash());return o.isInternetExplorer()?(r=\"historyjs-iframe\",i=n.createElement(\"iframe\"),i.setAttribute(\"id\",r),i.setAttribute(\"src\",\"#\"),i.style.display=\"none\",n.body.appendChild(i),i.contentWindow.document.open(),i.contentWindow.document.close(),u=\"\",a=!1,o.checkerFunction=function(){if(a)return!1;a=!0;var n=o.getHash(),r=o.getHash(i.contentWindow.document);return n!==t?(t=n,r!==n&&(u=r=n,i.contentWindow.document.open(),i.contentWindow.document.close(),i.contentWindow.document.location.hash=o.escapeHash(n)),o.Adapter.trigger(e,\"hashchange\")):r!==u&&(u=r,f&&r===\"\"?o.back():o.setHash(r,!1)),a=!1,!0}):o.checkerFunction=function(){var n=o.getHash()||\"\";return n!==t&&(t=n,o.Adapter.trigger(e,\"hashchange\")),!0},o.intervalList.push(s(o.checkerFunction,o.options.hashChangeInterval)),!0},o.Adapter.onDomLoad(o.hashChangeInit)),o.emulated.pushState&&(o.onHashChange=function(t){var n=t&&t.newURL||o.getLocationHref(),r=o.getHashByUrl(n),i=null,s=null,u=null,a;return o.isLastHash(r)?(o.busy(!1),!1):(o.doubleCheckComplete(),o.saveHash(r),r&&o.isTraditionalAnchor(r)?(o.Adapter.trigger(e,\"anchorchange\"),o.busy(!1),!1):(i=o.extractState(o.getFullUrl(r||o.getLocationHref()),!0),o.isLastSavedState(i)?(o.busy(!1),!1):(s=o.getHashByState(i),a=o.discardedState(i),a?(o.getHashByIndex(-2)===o.getHashByState(a.forwardState)?o.back(!1):o.forward(!1),!1):(o.pushState(i.data,i.title,encodeURI(i.url),!1),!0))))},o.Adapter.bind(e,\"hashchange\",o.onHashChange),o.pushState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.pushState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getHash(),c=o.expectedStateId==s.id;return o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),u===f?(o.busy(!1),!1):(o.saveState(s),c||o.Adapter.trigger(e,\"statechange\"),!o.isHashEqual(u,l)&&!o.isHashEqual(u,o.getShortUrl(o.getLocationHref()))&&o.setHash(u,!1),o.busy(!1),!0)},o.replaceState=function(t,n,r,i){r=encodeURI(r).replace(/%25/g,\"%\");if(o.getHashByUrl(r))throw new Error(\"History.js does not support states with fragment-identifiers (hashes/anchors).\");if(i!==!1&&o.busy())return o.pushQueue({scope:o,callback:o.replaceState,args:arguments,queue:i}),!1;o.busy(!0);var s=o.createStateObject(t,n,r),u=o.getHashByState(s),a=o.getState(!1),f=o.getHashByState(a),l=o.getStateByIndex(-2);return o.discardState(a,s,l),u===f?(o.storeState(s),o.expectedStateId=s.id,o.recycleState(s),o.setTitle(s),o.saveState(s),o.Adapter.trigger(e,\"statechange\"),o.busy(!1)):o.pushState(s.data,s.title,s.url,!1),!0}),o.emulated.pushState&&o.getHash()&&!o.emulated.hashChange&&o.Adapter.onDomLoad(function(){o.Adapter.trigger(e,\"hashchange\")})},typeof o.init!=\"undefined\"&&o.init()})(window)"
  },
  {
    "path": "scripts/compressed/history.js",
    "content": "(function(e,t){\"use strict\";var n=e.console||t,r=e.document,i=e.navigator,s=!1,o=e.setTimeout,u=e.clearTimeout,a=e.setInterval,f=e.clearInterval,l=e.JSON,c=e.alert,h=e.History=e.History||{},p=e.history;try{s=e.sessionStorage,s.setItem(\"TEST\",\"1\"),s.removeItem(\"TEST\")}catch(d){s=!1}l.stringify=l.stringify||l.encode,l.parse=l.parse||l.decode;if(typeof h.init!=\"undefined\")throw new Error(\"History.js Core has already been loaded...\");h.init=function(e){return typeof h.Adapter==\"undefined\"?!1:(typeof h.initCore!=\"undefined\"&&h.initCore(),typeof h.initHtml4!=\"undefined\"&&h.initHtml4(),!0)},h.initCore=function(d){if(typeof h.initCore.initialized!=\"undefined\")return!1;h.initCore.initialized=!0,h.options=h.options||{},h.options.hashChangeInterval=h.options.hashChangeInterval||100,h.options.safariPollInterval=h.options.safariPollInterval||500,h.options.doubleCheckInterval=h.options.doubleCheckInterval||500,h.options.disableSuid=h.options.disableSuid||!1,h.options.storeInterval=h.options.storeInterval||1e3,h.options.busyDelay=h.options.busyDelay||250,h.options.debug=h.options.debug||!1,h.options.initialTitle=h.options.initialTitle||r.title,h.options.html4Mode=h.options.html4Mode||!1,h.options.delayInit=h.options.delayInit||!1,h.intervalList=[],h.clearAllIntervals=function(){var e,t=h.intervalList;if(typeof t!=\"undefined\"&&t!==null){for(e=0;e<t.length;e++)f(t[e]);h.intervalList=null}},h.debug=function(){(h.options.debug||!1)&&h.log.apply(h,arguments)},h.log=function(){var e=typeof n!=\"undefined\"&&typeof n.log!=\"undefined\"&&typeof n.log.apply!=\"undefined\",t=r.getElementById(\"log\"),i,s,o,u,a;e?(u=Array.prototype.slice.call(arguments),i=u.shift(),typeof n.debug!=\"undefined\"?n.debug.apply(n,[i,u]):n.log.apply(n,[i,u])):i=\"\\n\"+arguments[0]+\"\\n\";for(s=1,o=arguments.length;s<o;++s){a=arguments[s];if(typeof a==\"object\"&&typeof l!=\"undefined\")try{a=l.stringify(a)}catch(f){}i+=\"\\n\"+a+\"\\n\"}return t?(t.value+=i+\"\\n-----\\n\",t.scrollTop=t.scrollHeight-t.clientHeight):e||c(i),!0},h.getInternetExplorerMajorVersion=function(){var e=h.getInternetExplorerMajorVersion.cached=typeof h.getInternetExplorerMajorVersion.cached!=\"undefined\"?h.getInternetExplorerMajorVersion.cached:function(){var e=3,t=r.createElement(\"div\"),n=t.getElementsByTagName(\"i\");while((t.innerHTML=\"<!--[if gt IE \"+ ++e+\"]><i></i><![endif]-->\")&&n[0]);return e>4?e:!1}();return e},h.isInternetExplorer=function(){var e=h.isInternetExplorer.cached=typeof h.isInternetExplorer.cached!=\"undefined\"?h.isInternetExplorer.cached:Boolean(h.getInternetExplorerMajorVersion());return e},h.options.html4Mode?h.emulated={pushState:!0,hashChange:!0}:h.emulated={pushState:!Boolean(e.history&&e.history.pushState&&e.history.replaceState&&!/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(i.userAgent)&&!/AppleWebKit\\/5([0-2]|3[0-2])/i.test(i.userAgent)),hashChange:Boolean(!(\"onhashchange\"in e||\"onhashchange\"in r)||h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8)},h.enabled=!h.emulated.pushState,h.bugs={setHash:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),safariPoll:Boolean(!h.emulated.pushState&&i.vendor===\"Apple Computer, Inc.\"&&/AppleWebKit\\/5([0-2]|3[0-3])/.test(i.userAgent)),ieDoubleCheck:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(h.isInternetExplorer()&&h.getInternetExplorerMajorVersion()<7)},h.isEmptyObject=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.cloneObject=function(e){var t,n;return e?(t=l.stringify(e),n=l.parse(t)):n={},n},h.getRootUrl=function(){var e=r.location.protocol+\"//\"+(r.location.hostname||r.location.host);if(r.location.port||!1)e+=\":\"+r.location.port;return e+=\"/\",e},h.getBaseHref=function(){var e=r.getElementsByTagName(\"base\"),t=null,n=\"\";return e.length===1&&(t=e[0],n=t.href.replace(/[^\\/]+$/,\"\")),n=n.replace(/\\/+$/,\"\"),n&&(n+=\"/\"),n},h.getBaseUrl=function(){var e=h.getBaseHref()||h.getBasePageUrl()||h.getRootUrl();return e},h.getPageUrl=function(){var e=h.getState(!1,!1),t=(e||{}).url||h.getLocationHref(),n;return n=t.replace(/\\/+$/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/\\./.test(e)?e:e+\"/\"}),n},h.getBasePageUrl=function(){var e=h.getLocationHref().replace(/[#\\?].*/,\"\").replace(/[^\\/]+$/,function(e,t,n){return/[^\\/]$/.test(e)?\"\":e}).replace(/\\/+$/,\"\")+\"/\";return e},h.getFullUrl=function(e,t){var n=e,r=e.substring(0,1);return t=typeof t==\"undefined\"?!0:t,/[a-z]+\\:\\/\\//.test(e)||(r===\"/\"?n=h.getRootUrl()+e.replace(/^\\/+/,\"\"):r===\"#\"?n=h.getPageUrl().replace(/#.*/,\"\")+e:r===\"?\"?n=h.getPageUrl().replace(/[\\?#].*/,\"\")+e:t?n=h.getBaseUrl()+e.replace(/^(\\.\\/)+/,\"\"):n=h.getBasePageUrl()+e.replace(/^(\\.\\/)+/,\"\")),n.replace(/\\#$/,\"\")},h.getShortUrl=function(e){var t=e,n=h.getBaseUrl(),r=h.getRootUrl();return h.emulated.pushState&&(t=t.replace(n,\"\")),t=t.replace(r,\"/\"),h.isTraditionalAnchor(t)&&(t=\"./\"+t),t=t.replace(/^(\\.\\/)+/g,\"./\").replace(/\\#$/,\"\"),t},h.getLocationHref=function(e){return e=e||r,e.URL===e.location.href?e.location.href:e.location.href===decodeURIComponent(e.URL)?e.URL:e.location.hash&&decodeURIComponent(e.location.href.replace(/^[^#]+/,\"\"))===e.location.hash?e.location.href:e.URL.indexOf(\"#\")==-1&&e.location.href.indexOf(\"#\")!=-1?e.location.href:e.URL||e.location.href},h.store={},h.idToState=h.idToState||{},h.stateToId=h.stateToId||{},h.urlToId=h.urlToId||{},h.storedStates=h.storedStates||[],h.savedStates=h.savedStates||[],h.normalizeStore=function(){h.store.idToState=h.store.idToState||{},h.store.urlToId=h.store.urlToId||{},h.store.stateToId=h.store.stateToId||{}},h.getState=function(e,t){typeof e==\"undefined\"&&(e=!0),typeof t==\"undefined\"&&(t=!0);var n=h.getLastSavedState();return!n&&t&&(n=h.createStateObject()),e&&(n=h.cloneObject(n),n.url=n.cleanUrl||n.url),n},h.getIdByState=function(e){var t=h.extractId(e.url),n;if(!t){n=h.getStateString(e);if(typeof h.stateToId[n]!=\"undefined\")t=h.stateToId[n];else if(typeof h.store.stateToId[n]!=\"undefined\")t=h.store.stateToId[n];else{for(;;){t=(new Date).getTime()+String(Math.random()).replace(/\\D/g,\"\");if(typeof h.idToState[t]==\"undefined\"&&typeof h.store.idToState[t]==\"undefined\")break}h.stateToId[n]=t,h.idToState[t]=e}}return t},h.normalizeState=function(e){var t,n;if(!e||typeof e!=\"object\")e={};if(typeof e.normalized!=\"undefined\")return e;if(!e.data||typeof e.data!=\"object\")e.data={};return t={},t.normalized=!0,t.title=e.title||\"\",t.url=h.getFullUrl(e.url?e.url:h.getLocationHref()),t.hash=h.getShortUrl(t.url),t.data=h.cloneObject(e.data),t.id=h.getIdByState(t),t.cleanUrl=t.url.replace(/\\??\\&_suid.*/,\"\"),t.url=t.cleanUrl,n=!h.isEmptyObject(t.data),(t.title||n)&&h.options.disableSuid!==!0&&(t.hash=h.getShortUrl(t.url).replace(/\\??\\&_suid.*/,\"\"),/\\?/.test(t.hash)||(t.hash+=\"?\"),t.hash+=\"&_suid=\"+t.id),t.hashedUrl=h.getFullUrl(t.hash),(h.emulated.pushState||h.bugs.safariPoll)&&h.hasUrlDuplicate(t)&&(t.url=t.hashedUrl),t},h.createStateObject=function(e,t,n){var r={data:e,title:t,url:n};return r=h.normalizeState(r),r},h.getStateById=function(e){e=String(e);var n=h.idToState[e]||h.store.idToState[e]||t;return n},h.getStateString=function(e){var t,n,r;return t=h.normalizeState(e),n={data:t.data,title:e.title,url:e.url},r=l.stringify(n),r},h.getStateId=function(e){var t,n;return t=h.normalizeState(e),n=t.id,n},h.getHashByState=function(e){var t,n;return t=h.normalizeState(e),n=t.hash,n},h.extractId=function(e){var t,n,r,i;return e.indexOf(\"#\")!=-1?i=e.split(\"#\")[0]:i=e,n=/(.*)\\&_suid=([0-9]+)$/.exec(i),r=n?n[1]||e:e,t=n?String(n[2]||\"\"):\"\",t||!1},h.isTraditionalAnchor=function(e){var t=!/[\\/\\?\\.]/.test(e);return t},h.extractState=function(e,t){var n=null,r,i;return t=t||!1,r=h.extractId(e),r&&(n=h.getStateById(r)),n||(i=h.getFullUrl(e),r=h.getIdByUrl(i)||!1,r&&(n=h.getStateById(r)),!n&&t&&!h.isTraditionalAnchor(e)&&(n=h.createStateObject(null,null,i))),n},h.getIdByUrl=function(e){var n=h.urlToId[e]||h.store.urlToId[e]||t;return n},h.getLastSavedState=function(){return h.savedStates[h.savedStates.length-1]||t},h.getLastStoredState=function(){return h.storedStates[h.storedStates.length-1]||t},h.hasUrlDuplicate=function(e){var t=!1,n;return n=h.extractState(e.url),t=n&&n.id!==e.id,t},h.storeState=function(e){return h.urlToId[e.url]=e.id,h.storedStates.push(h.cloneObject(e)),e},h.isLastSavedState=function(e){var t=!1,n,r,i;return h.savedStates.length&&(n=e.id,r=h.getLastSavedState(),i=r.id,t=n===i),t},h.saveState=function(e){return h.isLastSavedState(e)?!1:(h.savedStates.push(h.cloneObject(e)),!0)},h.getStateByIndex=function(e){var t=null;return typeof e==\"undefined\"?t=h.savedStates[h.savedStates.length-1]:e<0?t=h.savedStates[h.savedStates.length+e]:t=h.savedStates[e],t},h.getCurrentIndex=function(){var e=null;return h.savedStates.length<1?e=0:e=h.savedStates.length-1,e},h.getHash=function(e){var t=h.getLocationHref(e),n;return n=h.getHashByUrl(t),n},h.unescapeHash=function(e){var t=h.normalizeHash(e);return t=decodeURIComponent(t),t},h.normalizeHash=function(e){var t=e.replace(/[^#]*#/,\"\").replace(/#.*/,\"\");return t},h.setHash=function(e,t){var n,i;return t!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.setHash,args:arguments,queue:t}),!1):(h.busy(!0),n=h.extractState(e,!0),n&&!h.emulated.pushState?h.pushState(n.data,n.title,n.url,!1):h.getHash()!==e&&(h.bugs.setHash?(i=h.getPageUrl(),h.pushState(null,null,i+\"#\"+e,!1)):r.location.hash=e),h)},h.escapeHash=function(t){var n=h.normalizeHash(t);return n=e.encodeURIComponent(n),h.bugs.hashEscape||(n=n.replace(/\\%21/g,\"!\").replace(/\\%26/g,\"&\").replace(/\\%3D/g,\"=\").replace(/\\%3F/g,\"?\")),n},h.getHashByUrl=function(e){var t=String(e).replace(/([^#]*)#?([^#]*)#?(.*)/,\"$2\");return t=h.unescapeHash(t),t},h.setTitle=function(e){var t=e.title,n;t||(n=h.getStateByIndex(0),n&&n.url===e.url&&(t=n.title||h.options.initialTitle));try{r.getElementsByTagName(\"title\")[0].innerHTML=t.replace(\"<\",\"&lt;\").replace(\">\",\"&gt;\").replace(\" & \",\" &amp; \")}catch(i){}return r.title=t,h},h.queues=[],h.busy=function(e){typeof e!=\"undefined\"?h.busy.flag=e:typeof h.busy.flag==\"undefined\"&&(h.busy.flag=!1);if(!h.busy.flag){u(h.busy.timeout);var t=function(){var e,n,r;if(h.busy.flag)return;for(e=h.queues.length-1;e>=0;--e){n=h.queues[e];if(n.length===0)continue;r=n.shift(),h.fireQueueItem(r),h.busy.timeout=o(t,h.options.busyDelay)}};h.busy.timeout=o(t,h.options.busyDelay)}return h.busy.flag},h.busy.flag=!1,h.fireQueueItem=function(e){return e.callback.apply(e.scope||h,e.args||[])},h.pushQueue=function(e){return h.queues[e.queue||0]=h.queues[e.queue||0]||[],h.queues[e.queue||0].push(e),h},h.queue=function(e,t){return typeof e==\"function\"&&(e={callback:e}),typeof t!=\"undefined\"&&(e.queue=t),h.busy()?h.pushQueue(e):h.fireQueueItem(e),h},h.clearQueue=function(){return h.busy.flag=!1,h.queues=[],h},h.stateChanged=!1,h.doubleChecker=!1,h.doubleCheckComplete=function(){return h.stateChanged=!0,h.doubleCheckClear(),h},h.doubleCheckClear=function(){return h.doubleChecker&&(u(h.doubleChecker),h.doubleChecker=!1),h},h.doubleCheck=function(e){return h.stateChanged=!1,h.doubleCheckClear(),h.bugs.ieDoubleCheck&&(h.doubleChecker=o(function(){return h.doubleCheckClear(),h.stateChanged||e(),!0},h.options.doubleCheckInterval)),h},h.safariStatePoll=function(){var t=h.extractState(h.getLocationHref()),n;if(!h.isLastSavedState(t))return n=t,n||(n=h.createStateObject()),h.Adapter.trigger(e,\"popstate\"),h;return},h.back=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.back,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.back(!1)}),p.go(-1),!0)},h.forward=function(e){return e!==!1&&h.busy()?(h.pushQueue({scope:h,callback:h.forward,args:arguments,queue:e}),!1):(h.busy(!0),h.doubleCheck(function(){h.forward(!1)}),p.go(1),!0)},h.go=function(e,t){var n;if(e>0)for(n=1;n<=e;++n)h.forward(t);else{if(!(e<0))throw new Error(\"History.go: History.go requires a positive or negative integer passed.\");for(n=-1;n>=e;--n)h.back(t)}return h};if(h.emulated.pushState){var v=function(){};h.pushState=h.pushState||v,h.replaceState=h.replaceState||v}else h.onPopState=function(t,n){var r=!1,i=!1,s,o;return h.doubleCheckComplete(),s=h.getHash(),s?(o=h.extractState(s||h.getLocationHref(),!0),o?h.replaceState(o.data,o.title,o.url,!1):(h.Adapter.trigger(e,\"anchorchange\"),h.busy(!1)),h.expectedStateId=!1,!1):(r=h.Adapter.extractEventData(\"state\",t,n)||!1,r?i=h.getStateById(r):h.expectedStateId?i=h.getStateById(h.expectedStateId):i=h.extractState(h.getLocationHref()),i||(i=h.createStateObject(null,null,h.getLocationHref())),h.expectedStateId=!1,h.isLastSavedState(i)?(h.busy(!1),!1):(h.storeState(i),h.saveState(i),h.setTitle(i),h.Adapter.trigger(e,\"statechange\"),h.busy(!1),!0))},h.Adapter.bind(e,\"popstate\",h.onPopState),h.pushState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.pushState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.pushState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0},h.replaceState=function(t,n,r,i){if(h.getHashByUrl(r)&&h.emulated.pushState)throw new Error(\"History.js does not support states with fragement-identifiers (hashes/anchors).\");if(i!==!1&&h.busy())return h.pushQueue({scope:h,callback:h.replaceState,args:arguments,queue:i}),!1;h.busy(!0);var s=h.createStateObject(t,n,r);return h.isLastSavedState(s)?h.busy(!1):(h.storeState(s),h.expectedStateId=s.id,p.replaceState(s.id,s.title,s.url),h.Adapter.trigger(e,\"popstate\")),!0};if(s){try{h.store=l.parse(s.getItem(\"History.store\"))||{}}catch(m){h.store={}}h.normalizeStore()}else h.store={},h.normalizeStore();h.Adapter.bind(e,\"unload\",h.clearAllIntervals),h.saveState(h.storeState(h.extractState(h.getLocationHref(),!0))),s&&(h.onUnload=function(){var e,t,n;try{e=l.parse(s.getItem(\"History.store\"))||{}}catch(r){e={}}e.idToState=e.idToState||{},e.urlToId=e.urlToId||{},e.stateToId=e.stateToId||{};for(t in h.idToState){if(!h.idToState.hasOwnProperty(t))continue;e.idToState[t]=h.idToState[t]}for(t in h.urlToId){if(!h.urlToId.hasOwnProperty(t))continue;e.urlToId[t]=h.urlToId[t]}for(t in h.stateToId){if(!h.stateToId.hasOwnProperty(t))continue;e.stateToId[t]=h.stateToId[t]}h.store=e,h.normalizeStore(),n=l.stringify(e);try{s.setItem(\"History.store\",n)}catch(i){if(i.code!==DOMException.QUOTA_EXCEEDED_ERR)throw i;s.length&&(s.removeItem(\"History.store\"),s.setItem(\"History.store\",n))}},h.intervalList.push(a(h.onUnload,h.options.storeInterval)),h.Adapter.bind(e,\"beforeunload\",h.onUnload),h.Adapter.bind(e,\"unload\",h.onUnload));if(!h.emulated.pushState){h.bugs.safariPoll&&h.intervalList.push(a(h.safariStatePoll,h.options.safariPollInterval));if(i.vendor===\"Apple Computer, Inc.\"||(i.appCodeName||\"\")===\"Mozilla\")h.Adapter.bind(e,\"hashchange\",function(){h.Adapter.trigger(e,\"popstate\")}),h.getHash()&&h.Adapter.onDomLoad(function(){h.Adapter.trigger(e,\"hashchange\")})}},(!h.options||!h.options.delayInit)&&h.init()})(window)"
  },
  {
    "path": "scripts/compressed/json2.js",
    "content": "typeof JSON!=\"object\"&&(JSON={}),function(){\"use strict\";function f(e){return e<10?\"0\"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'\"'+e.replace(escapable,function(e){var t=meta[e];return typeof t==\"string\"?t:\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+e+'\"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a==\"object\"&&typeof a.toJSON==\"function\"&&(a=a.toJSON(e)),typeof rep==\"function\"&&(a=rep.call(t,e,a));switch(typeof a){case\"string\":return quote(a);case\"number\":return isFinite(a)?String(a):\"null\";case\"boolean\":case\"null\":return String(a);case\"object\":if(!a)return\"null\";gap+=indent,u=[];if(Object.prototype.toString.apply(a)===\"[object Array]\"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||\"null\";return i=u.length===0?\"[]\":gap?\"[\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"]\":\"[\"+u.join(\",\")+\"]\",gap=o,i}if(rep&&typeof rep==\"object\"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]==\"string\"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?\": \":\":\")+i));return i=u.length===0?\"{}\":gap?\"{\\n\"+gap+u.join(\",\\n\"+gap)+\"\\n\"+o+\"}\":\"{\"+u.join(\",\")+\"}\",gap=o,i}}typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(e,t,n){var r;gap=\"\",indent=\"\";if(typeof n==\"number\")for(r=0;r<n;r+=1)indent+=\" \";else typeof n==\"string\"&&(indent=n);rep=t;if(!t||typeof t==\"function\"||typeof t==\"object\"&&typeof t.length==\"number\")return str(\"\",{\"\":e});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i==\"object\")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return\"\\\\u\"+(\"0000\"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\")))return j=eval(\"(\"+text+\")\"),typeof reviver==\"function\"?walk({\"\":j},\"\"):j;throw new SyntaxError(\"JSON.parse\")})}()"
  },
  {
    "path": "scripts/uncompressed/history.adapter.dojo.js",
    "content": "/**\n * History.js Dojo Adapter\n *\n * Essentially the same as the native adapter but uses dojo/ready for the dom load callback.\n *\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar History = window.History = window.History||{},\n        require = window.require;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.handlers[uid][eventName] = Array\n\t\t */\n\t\thandlers: {},\n\n\t\t/**\n\t\t * History.Adapter._uid\n\t\t * The current element unique identifier\n\t\t */\n\t\t_uid: 1,\n\n\t\t/**\n\t\t * History.Adapter.uid(element)\n\t\t * @param {Element} element\n\t\t * @return {String} uid\n\t\t */\n\t\tuid: function(element){\n\t\t\treturn element._uid || (element._uid = History.Adapter._uid++);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(element,eventName,callback){\n\t\t\t// Prepare\n\t\t\tvar uid = History.Adapter.uid(element);\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\t\t\tHistory.Adapter.handlers[uid][eventName].push(callback);\n\n\t\t\t// Bind Global Listener\n\t\t\telement['on'+eventName] = (function(element,eventName){\n\t\t\t\treturn function(event){\n\t\t\t\t\tHistory.Adapter.trigger(element,eventName,event);\n\t\t\t\t};\n\t\t\t})(element,eventName);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Object} event - a object of event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(element,eventName,event){\n\t\t\t// Prepare\n\t\t\tevent = event || {};\n\t\t\tvar uid = History.Adapter.uid(element),\n\t\t\t\ti,n;\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\n\t\t\t// Fire Listeners\n\t\t\tfor ( i=0,n=History.Adapter.handlers[uid][eventName].length; i<n; ++i ) {\n\t\t\t\tHistory.Adapter.handlers[uid][eventName][i].apply(this,[event]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\tvar result = (event && event[key]) || undefined;\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\trequire([\"dojo/ready\"], function(ready) {\n\t\t\t\tready(callback);\n\t\t\t});\n\t\t}\n\t};\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/uncompressed/history.adapter.extjs.js",
    "content": "/**\n * History.js ExtJS Adapter\n * @author Sean Adkinson <sean.adkinson@gmail.com>\n * @copyright 2012 Sean Adkinson <sean.adkinson@gmail.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n    \"use strict\";\n\n    // Localise Globals\n    var\n        History = window.History = window.History||{},\n        Ext = window.Ext;\n\n    window.JSON = {\n        stringify: Ext.JSON.encode,\n        parse: Ext.JSON.decode\n    };\n    \n    // Check Existence\n    if ( typeof History.Adapter !== 'undefined' ) {\n        throw new Error('History.js Adapter has already been loaded...');\n    }\n\n    // Add the Adapter\n    History.Adapter = {\n        observables: {},\n        \n        /**\n         * History.Adapter.bind(el,event,callback)\n         * @param {Element|string} el\n         * @param {string} event - custom and standard events\n         * @param {function} callback\n         * @param {Object} scope\n         * @return {void}\n         */\n        bind: function(element,eventName,callback,scope){\n            Ext.EventManager.addListener(element, eventName, callback, scope);\n            \n            //bind an observable to the element that will let us \"trigger\" events on it\n            var id = Ext.id(element, 'history-'), observable = this.observables[id];\n            if (!observable) {\n                observable = Ext.create('Ext.util.Observable');\n                this.observables[id] = observable;\n            }\n            observable.on(eventName, callback, scope);\n        },\n\n        /**\n         * History.Adapter.trigger(el,event)\n         * @param {Element|string} el\n         * @param {string} event - custom and standard events\n         * @param {Object=} extra - a object of extra event data (optional)\n         * @return {void}\n         */\n        trigger: function(element,eventName,extra){\n            var id = Ext.id(element, 'history-'), observable = this.observables[id];\n            if (observable) {\n                observable.fireEvent(eventName, extra);\n            }\n        },\n\n        /**\n         * History.Adapter.extractEventData(key,event,extra)\n         * @param {string} key - key for the event data to extract\n         * @param {string} event - custom and standard events\n         * @param {Object=} extra - a object of extra event data (optional)\n         * @return {mixed}\n         */\n        extractEventData: function(key,event,extra){\n            var result = (event && event.browserEvent && event.browserEvent[key]) || (extra && extra[key]) || undefined;\n            return result;\n        },\n\n        /**\n         * History.Adapter.onDomLoad(callback)\n         * @param {function} callback\n         * @return {void}\n         */\n        onDomLoad: function(callback) {\n            Ext.onReady(callback);\n        }\n    };\n\n    // Try and Initialise History\n    if ( typeof History.init !== 'undefined' ) {\n        History.init();\n    }\n\n})(window);"
  },
  {
    "path": "scripts/uncompressed/history.adapter.jquery.js",
    "content": "/**\n * History.js jQuery Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tjQuery = window.jQuery;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tjQuery(el).bind(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return {void}\n\t\t */\n\t\ttrigger: function(el,event,extra){\n\t\t\tjQuery(el).trigger(event,extra);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event,extra){\n\t\t\t// jQuery Native then jQuery Custom\n\t\t\tvar result = (event && event.originalEvent && event.originalEvent[key]) || (extra && extra[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tjQuery(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n\n"
  },
  {
    "path": "scripts/uncompressed/history.adapter.mootools.js",
    "content": "/**\n * History.js MooTools Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tMooTools = window.MooTools,\n\t\tElement = window.Element;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Make MooTools aware of History.js Events\n\tObject.append(Element.NativeEvents,{\n\t\t'popstate':2,\n\t\t'hashchange':2\n\t});\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tvar El = typeof el === 'string' ? document.id(el) : el;\n\t\t\tEl.addEvent(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {Object=} extra - a object of extra event data (optional)\n\t\t * @return void\n\t\t */\n\t\ttrigger: function(el,event,extra){\n\t\t\tvar El = typeof el === 'string' ? document.id(el) : el;\n\t\t\tEl.fireEvent(event,extra);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// MooTools Native then MooTools Custom\n\t\t\tvar result = (event && event.event && event.event[key]) || (event && event[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\twindow.addEvent('domready',callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/uncompressed/history.adapter.native.js",
    "content": "/**\n * History.js Native Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar History = window.History = window.History||{};\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.handlers[uid][eventName] = Array\n\t\t */\n\t\thandlers: {},\n\n\t\t/**\n\t\t * History.Adapter._uid\n\t\t * The current element unique identifier\n\t\t */\n\t\t_uid: 1,\n\n\t\t/**\n\t\t * History.Adapter.uid(element)\n\t\t * @param {Element} element\n\t\t * @return {String} uid\n\t\t */\n\t\tuid: function(element){\n\t\t\treturn element._uid || (element._uid = History.Adapter._uid++);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(element,eventName,callback){\n\t\t\t// Prepare\n\t\t\tvar uid = History.Adapter.uid(element);\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\t\t\tHistory.Adapter.handlers[uid][eventName].push(callback);\n\n\t\t\t// Bind Global Listener\n\t\t\telement['on'+eventName] = (function(element,eventName){\n\t\t\t\treturn function(event){\n\t\t\t\t\tHistory.Adapter.trigger(element,eventName,event);\n\t\t\t\t};\n\t\t\t})(element,eventName);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element} element\n\t\t * @param {String} eventName - custom and standard events\n\t\t * @param {Object} event - a object of event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(element,eventName,event){\n\t\t\t// Prepare\n\t\t\tevent = event || {};\n\t\t\tvar uid = History.Adapter.uid(element),\n\t\t\t\ti,n;\n\n\t\t\t// Apply Listener\n\t\t\tHistory.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};\n\t\t\tHistory.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];\n\n\t\t\t// Fire Listeners\n\t\t\tfor ( i=0,n=History.Adapter.handlers[uid][eventName].length; i<n; ++i ) {\n\t\t\t\tHistory.Adapter.handlers[uid][eventName][i].apply(this,[event]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\tvar result = (event && event[key]) || undefined;\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tvar timeout = window.setTimeout(function(){\n\t\t\t\tcallback();\n\t\t\t},2000);\n\t\t\twindow.onload = function(){\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tcallback();\n\t\t\t};\n\t\t}\n\t};\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/uncompressed/history.adapter.right.js",
    "content": "/**\n * History.js RightJS Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tdocument = window.document,\n\t\tRightJS = window.RightJS,\n\t\t$ = RightJS.$;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|Selector} el\n\t\t * @param {String} event - custom and standard events\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\t$(el).on(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|Selector} el\n\t\t * @param {String} event - custom and standard events\n\t\t * @param {Object} extraEventData - a object of extra event data\n\t\t * @return\n\t\t */\n\t\ttrigger: function(el,event,extraEventData){\n\t\t\t$(el).fire(event,extraEventData);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {String} key - key for the event data to extract\n\t\t * @param {String} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// Right.js Native\n\t\t\t// Right.js Custom\n\t\t\tvar result = (event && event._ && event._[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {Function} callback\n\t\t * @return\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\t$(document).onReady(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/uncompressed/history.adapter.zepto.js",
    "content": "/**\n * History.js Zepto Adapter\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n// Closure\n(function(window,undefined){\n\t\"use strict\";\n\n\t// Localise Globals\n\tvar\n\t\tHistory = window.History = window.History||{},\n\t\tZepto = window.Zepto;\n\n\t// Check Existence\n\tif ( typeof History.Adapter !== 'undefined' ) {\n\t\tthrow new Error('History.js Adapter has already been loaded...');\n\t}\n\n\t// Add the Adapter\n\tHistory.Adapter = {\n\t\t/**\n\t\t * History.Adapter.bind(el,event,callback)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tbind: function(el,event,callback){\n\t\t\tnew Zepto(el).bind(event,callback);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.trigger(el,event)\n\t\t * @param {Element|string} el\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {void}\n\t\t */\n\t\ttrigger: function(el,event){\n\t\t\tnew Zepto(el).trigger(event);\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.extractEventData(key,event,extra)\n\t\t * @param {string} key - key for the event data to extract\n\t\t * @param {string} event - custom and standard events\n\t\t * @return {mixed}\n\t\t */\n\t\textractEventData: function(key,event){\n\t\t\t// Zepto Native\n\t\t\tvar result = (event && event[key]) || undefined;\n\n\t\t\t// Return\n\t\t\treturn result;\n\t\t},\n\n\t\t/**\n\t\t * History.Adapter.onDomLoad(callback)\n\t\t * @param {function} callback\n\t\t * @return {void}\n\t\t */\n\t\tonDomLoad: function(callback) {\n\t\t\tnew Zepto(callback);\n\t\t}\n\t};\n\n\t// Try and Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/uncompressed/history.html4.js",
    "content": "/**\n * History.js HTML4 Support\n * Depends on the HTML5 Support\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tsetTimeout = window.setTimeout||setTimeout,\n\t\tclearTimeout = window.clearTimeout||clearTimeout,\n\t\tsetInterval = window.setInterval||setInterval,\n\t\tHistory = window.History = window.History||{}; // Public History Object\n\n\t// Check Existence\n\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\tthrow new Error('History.js HTML4 Support has already been loaded...');\n\t}\n\n\n\t// ========================================================================\n\t// Initialise HTML4 Support\n\n\t// Initialise HTML4 Support\n\tHistory.initHtml4 = function(){\n\t\t// Initialise\n\t\tif ( typeof History.initHtml4.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initHtml4.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Properties\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = true;\n\n\n\t\t// ====================================================================\n\t\t// Hash Storage\n\n\t\t/**\n\t\t * History.savedHashes\n\t\t * Store the hashes in an array\n\t\t */\n\t\tHistory.savedHashes = [];\n\n\t\t/**\n\t\t * History.isLastHash(newHash)\n\t\t * Checks if the hash is the last hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isLastHash = function(newHash){\n\t\t\t// Prepare\n\t\t\tvar oldHash = History.getHashByIndex(),\n\t\t\t\tisLast;\n\n\t\t\t// Check\n\t\t\tisLast = newHash === oldHash;\n\n\t\t\t// Return isLast\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.isHashEqual(newHash, oldHash)\n\t\t * Checks to see if two hashes are functionally equal\n\t\t * @param {string} newHash\n\t\t * @param {string} oldHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.isHashEqual = function(newHash, oldHash){\n\t\t\tnewHash = encodeURIComponent(newHash).replace(/%25/g, \"%\");\n\t\t\toldHash = encodeURIComponent(oldHash).replace(/%25/g, \"%\");\n\t\t\treturn newHash === oldHash;\n\t\t};\n\n\t\t/**\n\t\t * History.saveHash(newHash)\n\t\t * Push a Hash\n\t\t * @param {string} newHash\n\t\t * @return {boolean} true\n\t\t */\n\t\tHistory.saveHash = function(newHash){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastHash(newHash) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the Hash\n\t\t\tHistory.savedHashes.push(newHash);\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByIndex()\n\t\t * Gets a hash by the index\n\t\t * @param {integer} index\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHashByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar hash = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\thash = History.savedHashes[History.savedHashes.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\thash = History.savedHashes[History.savedHashes.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\thash = History.savedHashes[index];\n\t\t\t}\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Discarded States\n\n\t\t/**\n\t\t * History.discardedHashes\n\t\t * A hashed array of discarded hashes\n\t\t */\n\t\tHistory.discardedHashes = {};\n\n\t\t/**\n\t\t * History.discardedStates\n\t\t * A hashed array of discarded states\n\t\t */\n\t\tHistory.discardedStates = {};\n\n\t\t/**\n\t\t * History.discardState(State)\n\t\t * Discards the state by ignoring it through History\n\t\t * @param {object} State\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardState = function(discardedState,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Prepare\n\t\t\tvar discardedStateHash = History.getHashByState(discardedState),\n\t\t\t\tdiscardObject;\n\n\t\t\t// Create Discard Object\n\t\t\tdiscardObject = {\n\t\t\t\t'discardedState': discardedState,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to DiscardedStates\n\t\t\tHistory.discardedStates[discardedStateHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardHash(hash)\n\t\t * Discards the hash by ignoring it through History\n\t\t * @param {string} hash\n\t\t * @return {true}\n\t\t */\n\t\tHistory.discardHash = function(discardedHash,forwardState,backState){\n\t\t\t//History.debug('History.discardState', arguments);\n\t\t\t// Create Discard Object\n\t\t\tvar discardObject = {\n\t\t\t\t'discardedHash': discardedHash,\n\t\t\t\t'backState': backState,\n\t\t\t\t'forwardState': forwardState\n\t\t\t};\n\n\t\t\t// Add to discardedHash\n\t\t\tHistory.discardedHashes[discardedHash] = discardObject;\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedState(State)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {object} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedState = function(State){\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State),\n\t\t\t\tdiscarded;\n\n\t\t\t// Check\n\t\t\tdiscarded = History.discardedStates[StateHash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.discardedHash(hash)\n\t\t * Checks to see if the state is discarded\n\t\t * @param {string} State\n\t\t * @return {bool}\n\t\t */\n\t\tHistory.discardedHash = function(hash){\n\t\t\t// Check\n\t\t\tvar discarded = History.discardedHashes[hash]||false;\n\n\t\t\t// Return true\n\t\t\treturn discarded;\n\t\t};\n\n\t\t/**\n\t\t * History.recycleState(State)\n\t\t * Allows a discarded state to be used again\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {true}\n\t\t */\n\t\tHistory.recycleState = function(State){\n\t\t\t//History.debug('History.recycleState', arguments);\n\t\t\t// Prepare\n\t\t\tvar StateHash = History.getHashByState(State);\n\n\t\t\t// Remove from DiscardedStates\n\t\t\tif ( History.discardedState(State) ) {\n\t\t\t\tdelete History.discardedStates[StateHash];\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML4 HashChange Support\n\n\t\tif ( History.emulated.hashChange ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML4 HashChange Support by manually checking for hash changes\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.hashChangeInit()\n\t\t\t * Init the HashChange Emulation\n\t\t\t */\n\t\t\tHistory.hashChangeInit = function(){\n\t\t\t\t// Define our Checker Function\n\t\t\t\tHistory.checkerFunction = null;\n\n\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\tvar lastDocumentHash = '',\n\t\t\t\t\tiframeId, iframe,\n\t\t\t\t\tlastIframeHash, checkerRunning,\n\t\t\t\t\tstartedWithHash = Boolean(History.getHash());\n\n\t\t\t\t// Handle depending on the browser\n\t\t\t\tif ( History.isInternetExplorer() ) {\n\t\t\t\t\t// IE6 and IE7\n\t\t\t\t\t// We need to use an iframe to emulate the back and forward buttons\n\n\t\t\t\t\t// Create iFrame\n\t\t\t\t\tiframeId = 'historyjs-iframe';\n\t\t\t\t\tiframe = document.createElement('iframe');\n\n\t\t\t\t\t// Adjust iFarme\n\t\t\t\t\t// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a\n\t\t\t\t\t// \"This page contains both secure and nonsecure items\" warning.\n\t\t\t\t\tiframe.setAttribute('id', iframeId);\n\t\t\t\t\tiframe.setAttribute('src', '#');\n\t\t\t\t\tiframe.style.display = 'none';\n\n\t\t\t\t\t// Append iFrame\n\t\t\t\t\tdocument.body.appendChild(iframe);\n\n\t\t\t\t\t// Create initial history entry\n\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t// Define some variables that will help in our checker function\n\t\t\t\t\tlastIframeHash = '';\n\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Check Running\n\t\t\t\t\t\tif ( checkerRunning ) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Update Running\n\t\t\t\t\t\tcheckerRunning = true;\n\n\t\t\t\t\t\t// Fetch\n\t\t\t\t\t\tvar\n\t\t\t\t\t\t\tdocumentHash = History.getHash(),\n\t\t\t\t\t\t\tiframeHash = History.getHash(iframe.contentWindow.document);\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Create a history entry in the iframe\n\t\t\t\t\t\t\tif ( iframeHash !== documentHash ) {\n\t\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);\n\n\t\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\t\tlastIframeHash = iframeHash = documentHash;\n\n\t\t\t\t\t\t\t\t// Create History Entry\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.open();\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.close();\n\n\t\t\t\t\t\t\t\t// Update the iframe's hash\n\t\t\t\t\t\t\t\tiframe.contentWindow.document.location.hash = History.escapeHash(documentHash);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// The iFrame Hash has changed (back button caused)\n\t\t\t\t\t\telse if ( iframeHash !== lastIframeHash ) {\n\t\t\t\t\t\t\t//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);\n\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastIframeHash = iframeHash;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// If there is no iframe hash that means we're at the original\n\t\t\t\t\t\t\t// iframe state.\n\t\t\t\t\t\t\t// And if there was a hash on the original request, the original\n\t\t\t\t\t\t\t// iframe state was replaced instantly, so skip this state and take\n\t\t\t\t\t\t\t// the user back to where they came from.\n\t\t\t\t\t\t\tif (startedWithHash && iframeHash === '') {\n\t\t\t\t\t\t\t\tHistory.back();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// Update the Hash\n\t\t\t\t\t\t\t\tHistory.setHash(iframeHash,false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset Running\n\t\t\t\t\t\tcheckerRunning = false;\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// We are not IE\n\t\t\t\t\t// Firefox 1 or 2, Opera\n\n\t\t\t\t\t// Define the checker function\n\t\t\t\t\tHistory.checkerFunction = function(){\n\t\t\t\t\t\t// Prepare\n\t\t\t\t\t\tvar documentHash = History.getHash()||'';\n\n\t\t\t\t\t\t// The Document Hash has changed (application caused)\n\t\t\t\t\t\tif ( documentHash !== lastDocumentHash ) {\n\t\t\t\t\t\t\t// Equalise\n\t\t\t\t\t\t\tlastDocumentHash = documentHash;\n\n\t\t\t\t\t\t\t// Trigger Hashchange Event\n\t\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Return true\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Apply the checker function\n\t\t\t\tHistory.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));\n\n\t\t\t\t// Done\n\t\t\t\treturn true;\n\t\t\t}; // History.hashChangeInit\n\n\t\t\t// Bind hashChangeInit\n\t\t\tHistory.Adapter.onDomLoad(History.hashChangeInit);\n\n\t\t} // History.emulated.hashChange\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * We must emulate the HTML5 State Management by using HTML4 HashChange\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onHashChange(event)\n\t\t\t * Trigger HTML5's window.onpopstate via HTML4 HashChange Support\n\t\t\t */\n\t\t\tHistory.onHashChange = function(event){\n\t\t\t\t//History.debug('History.onHashChange', arguments);\n\n\t\t\t\t// Prepare\n\t\t\t\tvar currentUrl = ((event && event.newURL) || History.getLocationHref()),\n\t\t\t\t\tcurrentHash = History.getHashByUrl(currentUrl),\n\t\t\t\t\tcurrentState = null,\n\t\t\t\t\tcurrentStateHash = null,\n\t\t\t\t\tcurrentStateHashExits = null,\n\t\t\t\t\tdiscardObject;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastHash(currentHash) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Store our location for use in detecting back/forward direction\n\t\t\t\tHistory.saveHash(currentHash);\n\n\t\t\t\t// Expand Hash\n\t\t\t\tif ( currentHash && History.isTraditionalAnchor(currentHash) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: traditional anchor', currentHash);\n\t\t\t\t\t// Traditional Anchor Hash\n\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tcurrentState = History.extractState(History.getFullUrl(currentHash||History.getLocationHref()),true);\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(currentState) ) {\n\t\t\t\t\t//History.debug('History.onHashChange: no change');\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Create the state Hash\n\t\t\t\tcurrentStateHash = History.getHashByState(currentState);\n\n\t\t\t\t// Check if we are DiscardedState\n\t\t\t\tdiscardObject = History.discardedState(currentState);\n\t\t\t\tif ( discardObject ) {\n\t\t\t\t\t// Ignore this state as it has been discarded and go back to the state before it\n\t\t\t\t\tif ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {\n\t\t\t\t\t\t// We are going backwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go backwards');\n\t\t\t\t\t\tHistory.back(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We are going forwards\n\t\t\t\t\t\t//History.debug('History.onHashChange: go forwards');\n\t\t\t\t\t\tHistory.forward(false);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Push the new HTML5 State\n\t\t\t\t//History.debug('History.onHashChange: success hashchange');\n\t\t\t\tHistory.pushState(currentState.data,currentState.title,encodeURI(currentState.url),false);\n\n\t\t\t\t// End onHashChange closure\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'hashchange',History.onHashChange);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Object\n\t\t\t\tvar newState = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\thtml4Hash = History.getHash(),\n\t\t\t\t\twasExpected = History.expectedStateId == newState.id;\n\n\t\t\t\t// Store the newState\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t// Recycle the State\n\t\t\t\tHistory.recycleState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Check if we are the same State\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t//History.debug('History.pushState: no change', newStateHash);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Update HTML5 State\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Fire HTML5 Event\n\t\t\t\tif(!wasExpected)\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\n\t\t\t\t// Update HTML4 Hash\n\t\t\t\tif ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {\n\t\t\t\t\tHistory.setHash(newStateHash,false);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// We assume that the URL passed in is URI-encoded, but this makes\n\t\t\t\t// sure that it's fully URI encoded; any '%'s that are encoded are\n\t\t\t\t// converted back into '%'s\n\t\t\t\turl = encodeURI(url).replace(/%25/g, \"%\");\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragment-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Fetch the State Objects\n\t\t\t\tvar newState        = History.createStateObject(data,title,url),\n\t\t\t\t\tnewStateHash = History.getHashByState(newState),\n\t\t\t\t\toldState        = History.getState(false),\n\t\t\t\t\toldStateHash = History.getHashByState(oldState),\n\t\t\t\t\tpreviousState   = History.getStateByIndex(-2);\n\n\t\t\t\t// Discard Old State\n\t\t\t\tHistory.discardState(oldState,newState,previousState);\n\n\t\t\t\t// If the url hasn't changed, just store and save the state\n\t\t\t\t// and fire a statechange event to be consistent with the\n\t\t\t\t// html 5 api\n\t\t\t\tif ( newStateHash === oldStateHash ) {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\t\n\t\t\t\t\t// Recycle the State\n\t\t\t\t\tHistory.recycleState(newState);\n\t\n\t\t\t\t\t// Force update of the title\n\t\t\t\t\tHistory.setTitle(newState);\n\t\t\t\t\t\n\t\t\t\t\t// Update HTML5 State\n\t\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\t//History.debug('History.pushState: trigger popstate');\n\t\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Alias to PushState\n\t\t\t\t\tHistory.pushState(newState.data,newState.title,newState.url,false);\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // History.emulated.pushState\n\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/**\n\t\t\t * Ensure initial state is handled correctly\n\t\t\t */\n\t\t\tif ( History.getHash() && !History.emulated.hashChange ) {\n\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t});\n\t\t\t}\n\n\t\t} // History.emulated.pushState\n\n\t}; // History.initHtml4\n\n\t// Try to Initialise History\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/uncompressed/history.js",
    "content": "/**\n * History.js Core\n * @author Benjamin Arthur Lupton <contact@balupton.com>\n * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>\n * @license New BSD License <http://creativecommons.org/licenses/BSD/>\n */\n\n(function(window,undefined){\n\t\"use strict\";\n\n\t// ========================================================================\n\t// Initialise\n\n\t// Localise Globals\n\tvar\n\t\tconsole = window.console||undefined, // Prevent a JSLint complain\n\t\tdocument = window.document, // Make sure we are using the correct document\n\t\tnavigator = window.navigator, // Make sure we are using the correct navigator\n\t\tsessionStorage = false, // sessionStorage\n\t\tsetTimeout = window.setTimeout,\n\t\tclearTimeout = window.clearTimeout,\n\t\tsetInterval = window.setInterval,\n\t\tclearInterval = window.clearInterval,\n\t\tJSON = window.JSON,\n\t\talert = window.alert,\n\t\tHistory = window.History = window.History||{}, // Public History Object\n\t\thistory = window.history; // Old History Object\n\n\ttry {\n\t\tsessionStorage = window.sessionStorage; // This will throw an exception in some browsers when cookies/localStorage are explicitly disabled (i.e. Chrome)\n\t\tsessionStorage.setItem('TEST', '1');\n\t\tsessionStorage.removeItem('TEST');\n\t} catch(e) {\n\t\tsessionStorage = false;\n\t}\n\n\t// MooTools Compatibility\n\tJSON.stringify = JSON.stringify||JSON.encode;\n\tJSON.parse = JSON.parse||JSON.decode;\n\n\t// Check Existence\n\tif ( typeof History.init !== 'undefined' ) {\n\t\tthrow new Error('History.js Core has already been loaded...');\n\t}\n\n\t// Initialise History\n\tHistory.init = function(options){\n\t\t// Check Load Status of Adapter\n\t\tif ( typeof History.Adapter === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check Load Status of Core\n\t\tif ( typeof History.initCore !== 'undefined' ) {\n\t\t\tHistory.initCore();\n\t\t}\n\n\t\t// Check Load Status of HTML4 Support\n\t\tif ( typeof History.initHtml4 !== 'undefined' ) {\n\t\t\tHistory.initHtml4();\n\t\t}\n\n\t\t// Return true\n\t\treturn true;\n\t};\n\n\n\t// ========================================================================\n\t// Initialise Core\n\n\t// Initialise Core\n\tHistory.initCore = function(options){\n\t\t// Initialise\n\t\tif ( typeof History.initCore.initialized !== 'undefined' ) {\n\t\t\t// Already Loaded\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\tHistory.initCore.initialized = true;\n\t\t}\n\n\n\t\t// ====================================================================\n\t\t// Options\n\n\t\t/**\n\t\t * History.options\n\t\t * Configurable options\n\t\t */\n\t\tHistory.options = History.options||{};\n\n\t\t/**\n\t\t * History.options.hashChangeInterval\n\t\t * How long should the interval be before hashchange checks\n\t\t */\n\t\tHistory.options.hashChangeInterval = History.options.hashChangeInterval || 100;\n\n\t\t/**\n\t\t * History.options.safariPollInterval\n\t\t * How long should the interval be before safari poll checks\n\t\t */\n\t\tHistory.options.safariPollInterval = History.options.safariPollInterval || 500;\n\n\t\t/**\n\t\t * History.options.doubleCheckInterval\n\t\t * How long should the interval be before we perform a double check\n\t\t */\n\t\tHistory.options.doubleCheckInterval = History.options.doubleCheckInterval || 500;\n\n\t\t/**\n\t\t * History.options.disableSuid\n\t\t * Force History not to append suid\n\t\t */\n\t\tHistory.options.disableSuid = History.options.disableSuid || false;\n\n\t\t/**\n\t\t * History.options.storeInterval\n\t\t * How long should we wait between store calls\n\t\t */\n\t\tHistory.options.storeInterval = History.options.storeInterval || 1000;\n\n\t\t/**\n\t\t * History.options.busyDelay\n\t\t * How long should we wait between busy events\n\t\t */\n\t\tHistory.options.busyDelay = History.options.busyDelay || 250;\n\n\t\t/**\n\t\t * History.options.debug\n\t\t * If true will enable debug messages to be logged\n\t\t */\n\t\tHistory.options.debug = History.options.debug || false;\n\n\t\t/**\n\t\t * History.options.initialTitle\n\t\t * What is the title of the initial state\n\t\t */\n\t\tHistory.options.initialTitle = History.options.initialTitle || document.title;\n\n\t\t/**\n\t\t * History.options.html4Mode\n\t\t * If true, will force HTMl4 mode (hashtags)\n\t\t */\n\t\tHistory.options.html4Mode = History.options.html4Mode || false;\n\n\t\t/**\n\t\t * History.options.delayInit\n\t\t * Want to override default options and call init manually.\n\t\t */\n\t\tHistory.options.delayInit = History.options.delayInit || false;\n\n\n\t\t// ====================================================================\n\t\t// Interval record\n\n\t\t/**\n\t\t * History.intervalList\n\t\t * List of intervals set, to be cleared when document is unloaded.\n\t\t */\n\t\tHistory.intervalList = [];\n\n\t\t/**\n\t\t * History.clearAllIntervals\n\t\t * Clears all setInterval instances.\n\t\t */\n\t\tHistory.clearAllIntervals = function(){\n\t\t\tvar i, il = History.intervalList;\n\t\t\tif (typeof il !== \"undefined\" && il !== null) {\n\t\t\t\tfor (i = 0; i < il.length; i++) {\n\t\t\t\t\tclearInterval(il[i]);\n\t\t\t\t}\n\t\t\t\tHistory.intervalList = null;\n\t\t\t}\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Debug\n\n\t\t/**\n\t\t * History.debug(message,...)\n\t\t * Logs the passed arguments if debug enabled\n\t\t */\n\t\tHistory.debug = function(){\n\t\t\tif ( (History.options.debug||false) ) {\n\t\t\t\tHistory.log.apply(History,arguments);\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * History.log(message,...)\n\t\t * Logs the passed arguments\n\t\t */\n\t\tHistory.log = function(){\n\t\t\t// Prepare\n\t\t\tvar\n\t\t\t\tconsoleExists = !(typeof console === 'undefined' || typeof console.log === 'undefined' || typeof console.log.apply === 'undefined'),\n\t\t\t\ttextarea = document.getElementById('log'),\n\t\t\t\tmessage,\n\t\t\t\ti,n,\n\t\t\t\targs,arg\n\t\t\t\t;\n\n\t\t\t// Write to Console\n\t\t\tif ( consoleExists ) {\n\t\t\t\targs = Array.prototype.slice.call(arguments);\n\t\t\t\tmessage = args.shift();\n\t\t\t\tif ( typeof console.debug !== 'undefined' ) {\n\t\t\t\t\tconsole.debug.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconsole.log.apply(console,[message,args]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmessage = (\"\\n\"+arguments[0]+\"\\n\");\n\t\t\t}\n\n\t\t\t// Write to log\n\t\t\tfor ( i=1,n=arguments.length; i<n; ++i ) {\n\t\t\t\targ = arguments[i];\n\t\t\t\tif ( typeof arg === 'object' && typeof JSON !== 'undefined' ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\targ = JSON.stringify(arg);\n\t\t\t\t\t}\n\t\t\t\t\tcatch ( Exception ) {\n\t\t\t\t\t\t// Recursive Object\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmessage += \"\\n\"+arg+\"\\n\";\n\t\t\t}\n\n\t\t\t// Textarea\n\t\t\tif ( textarea ) {\n\t\t\t\ttextarea.value += message+\"\\n-----\\n\";\n\t\t\t\ttextarea.scrollTop = textarea.scrollHeight - textarea.clientHeight;\n\t\t\t}\n\t\t\t// No Textarea, No Console\n\t\t\telse if ( !consoleExists ) {\n\t\t\t\talert(message);\n\t\t\t}\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Emulated Status\n\n\t\t/**\n\t\t * History.getInternetExplorerMajorVersion()\n\t\t * Get's the major version of Internet Explorer\n\t\t * @return {integer}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t * @author James Padolsey <https://gist.github.com/527683>\n\t\t */\n\t\tHistory.getInternetExplorerMajorVersion = function(){\n\t\t\tvar result = History.getInternetExplorerMajorVersion.cached =\n\t\t\t\t\t(typeof History.getInternetExplorerMajorVersion.cached !== 'undefined')\n\t\t\t\t?\tHistory.getInternetExplorerMajorVersion.cached\n\t\t\t\t:\t(function(){\n\t\t\t\t\t\tvar v = 3,\n\t\t\t\t\t\t\t\tdiv = document.createElement('div'),\n\t\t\t\t\t\t\t\tall = div.getElementsByTagName('i');\n\t\t\t\t\t\twhile ( (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->') && all[0] ) {}\n\t\t\t\t\t\treturn (v > 4) ? v : false;\n\t\t\t\t\t})()\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.isInternetExplorer()\n\t\t * Are we using Internet Explorer?\n\t\t * @return {boolean}\n\t\t * @license Public Domain\n\t\t * @author Benjamin Arthur Lupton <contact@balupton.com>\n\t\t */\n\t\tHistory.isInternetExplorer = function(){\n\t\t\tvar result =\n\t\t\t\tHistory.isInternetExplorer.cached =\n\t\t\t\t(typeof History.isInternetExplorer.cached !== 'undefined')\n\t\t\t\t\t?\tHistory.isInternetExplorer.cached\n\t\t\t\t\t:\tBoolean(History.getInternetExplorerMajorVersion())\n\t\t\t\t;\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.emulated\n\t\t * Which features require emulating?\n\t\t */\n\n\t\tif (History.options.html4Mode) {\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState : true,\n\t\t\t\thashChange: true\n\t\t\t};\n\t\t}\n\n\t\telse {\n\n\t\t\tHistory.emulated = {\n\t\t\t\tpushState: !Boolean(\n\t\t\t\t\twindow.history && window.history.pushState && window.history.replaceState\n\t\t\t\t\t&& !(\n\t\t\t\t\t\t(/ Mobile\\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */\n\t\t\t\t\t\t|| (/AppleWebKit\\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\thashChange: Boolean(\n\t\t\t\t\t!(('onhashchange' in window) || ('onhashchange' in document))\n\t\t\t\t\t||\n\t\t\t\t\t(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)\n\t\t\t\t)\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * History.enabled\n\t\t * Is History enabled?\n\t\t */\n\t\tHistory.enabled = !History.emulated.pushState;\n\n\t\t/**\n\t\t * History.bugs\n\t\t * Which bugs are present\n\t\t */\n\t\tHistory.bugs = {\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=56249\n\t\t\t */\n\t\t\tsetHash: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions\n\t\t\t * https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\t */\n\t\t\tsafariPoll: Boolean(!History.emulated.pushState && navigator.vendor === 'Apple Computer, Inc.' && /AppleWebKit\\/5([0-2]|3[0-3])/.test(navigator.userAgent)),\n\n\t\t\t/**\n\t\t\t * MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)\n\t\t\t */\n\t\t\tieDoubleCheck: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8),\n\n\t\t\t/**\n\t\t\t * MSIE 6 requires the entire hash to be encoded for the hashes to trigger the onHashChange event\n\t\t\t */\n\t\t\thashEscape: Boolean(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 7)\n\t\t};\n\n\t\t/**\n\t\t * History.isEmptyObject(obj)\n\t\t * Checks to see if the Object is Empty\n\t\t * @param {Object} obj\n\t\t * @return {boolean}\n\t\t */\n\t\tHistory.isEmptyObject = function(obj) {\n\t\t\tfor ( var name in obj ) {\n\t\t\t\tif ( obj.hasOwnProperty(name) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.cloneObject(obj)\n\t\t * Clones a object and eliminate all references to the original contexts\n\t\t * @param {Object} obj\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.cloneObject = function(obj) {\n\t\t\tvar hash,newObj;\n\t\t\tif ( obj ) {\n\t\t\t\thash = JSON.stringify(obj);\n\t\t\t\tnewObj = JSON.parse(hash);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnewObj = {};\n\t\t\t}\n\t\t\treturn newObj;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// URL Helpers\n\n\t\t/**\n\t\t * History.getRootUrl()\n\t\t * Turns \"http://mysite.com/dir/page.html?asd\" into \"http://mysite.com\"\n\t\t * @return {String} rootUrl\n\t\t */\n\t\tHistory.getRootUrl = function(){\n\t\t\t// Create\n\t\t\tvar rootUrl = document.location.protocol+'//'+(document.location.hostname||document.location.host);\n\t\t\tif ( document.location.port||false ) {\n\t\t\t\trootUrl += ':'+document.location.port;\n\t\t\t}\n\t\t\trootUrl += '/';\n\n\t\t\t// Return\n\t\t\treturn rootUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseHref()\n\t\t * Fetches the `href` attribute of the `<base href=\"...\">` element if it exists\n\t\t * @return {String} baseHref\n\t\t */\n\t\tHistory.getBaseHref = function(){\n\t\t\t// Create\n\t\t\tvar\n\t\t\t\tbaseElements = document.getElementsByTagName('base'),\n\t\t\t\tbaseElement = null,\n\t\t\t\tbaseHref = '';\n\n\t\t\t// Test for Base Element\n\t\t\tif ( baseElements.length === 1 ) {\n\t\t\t\t// Prepare for Base Element\n\t\t\t\tbaseElement = baseElements[0];\n\t\t\t\tbaseHref = baseElement.href.replace(/[^\\/]+$/,'');\n\t\t\t}\n\n\t\t\t// Adjust trailing slash\n\t\t\tbaseHref = baseHref.replace(/\\/+$/,'');\n\t\t\tif ( baseHref ) baseHref += '/';\n\n\t\t\t// Return\n\t\t\treturn baseHref;\n\t\t};\n\n\t\t/**\n\t\t * History.getBaseUrl()\n\t\t * Fetches the baseHref or basePageUrl or rootUrl (whichever one exists first)\n\t\t * @return {String} baseUrl\n\t\t */\n\t\tHistory.getBaseUrl = function(){\n\t\t\t// Create\n\t\t\tvar baseUrl = History.getBaseHref()||History.getBasePageUrl()||History.getRootUrl();\n\n\t\t\t// Return\n\t\t\treturn baseUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getPageUrl()\n\t\t * Fetches the URL of the current page\n\t\t * @return {String} pageUrl\n\t\t */\n\t\tHistory.getPageUrl = function(){\n\t\t\t// Fetch\n\t\t\tvar\n\t\t\t\tState = History.getState(false,false),\n\t\t\t\tstateUrl = (State||{}).url||History.getLocationHref(),\n\t\t\t\tpageUrl;\n\n\t\t\t// Create\n\t\t\tpageUrl = stateUrl.replace(/\\/+$/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/\\./).test(part) ? part : part+'/';\n\t\t\t});\n\n\t\t\t// Return\n\t\t\treturn pageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getBasePageUrl()\n\t\t * Fetches the Url of the directory of the current page\n\t\t * @return {String} basePageUrl\n\t\t */\n\t\tHistory.getBasePageUrl = function(){\n\t\t\t// Create\n\t\t\tvar basePageUrl = (History.getLocationHref()).replace(/[#\\?].*/,'').replace(/[^\\/]+$/,function(part,index,string){\n\t\t\t\treturn (/[^\\/]$/).test(part) ? '' : part;\n\t\t\t}).replace(/\\/+$/,'')+'/';\n\n\t\t\t// Return\n\t\t\treturn basePageUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getFullUrl(url)\n\t\t * Ensures that we have an absolute URL and not a relative URL\n\t\t * @param {string} url\n\t\t * @param {Boolean} allowBaseHref\n\t\t * @return {string} fullUrl\n\t\t */\n\t\tHistory.getFullUrl = function(url,allowBaseHref){\n\t\t\t// Prepare\n\t\t\tvar fullUrl = url, firstChar = url.substring(0,1);\n\t\t\tallowBaseHref = (typeof allowBaseHref === 'undefined') ? true : allowBaseHref;\n\n\t\t\t// Check\n\t\t\tif ( /[a-z]+\\:\\/\\//.test(url) ) {\n\t\t\t\t// Full URL\n\t\t\t}\n\t\t\telse if ( firstChar === '/' ) {\n\t\t\t\t// Root URL\n\t\t\t\tfullUrl = History.getRootUrl()+url.replace(/^\\/+/,'');\n\t\t\t}\n\t\t\telse if ( firstChar === '#' ) {\n\t\t\t\t// Anchor URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/#.*/,'')+url;\n\t\t\t}\n\t\t\telse if ( firstChar === '?' ) {\n\t\t\t\t// Query URL\n\t\t\t\tfullUrl = History.getPageUrl().replace(/[\\?#].*/,'')+url;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative URL\n\t\t\t\tif ( allowBaseHref ) {\n\t\t\t\t\tfullUrl = History.getBaseUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t} else {\n\t\t\t\t\tfullUrl = History.getBasePageUrl()+url.replace(/^(\\.\\/)+/,'');\n\t\t\t\t}\n\t\t\t\t// We have an if condition above as we do not want hashes\n\t\t\t\t// which are relative to the baseHref in our URLs\n\t\t\t\t// as if the baseHref changes, then all our bookmarks\n\t\t\t\t// would now point to different locations\n\t\t\t\t// whereas the basePageUrl will always stay the same\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn fullUrl.replace(/\\#$/,'');\n\t\t};\n\n\t\t/**\n\t\t * History.getShortUrl(url)\n\t\t * Ensures that we have a relative URL and not a absolute URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getShortUrl = function(url){\n\t\t\t// Prepare\n\t\t\tvar shortUrl = url, baseUrl = History.getBaseUrl(), rootUrl = History.getRootUrl();\n\n\t\t\t// Trim baseUrl\n\t\t\tif ( History.emulated.pushState ) {\n\t\t\t\t// We are in a if statement as when pushState is not emulated\n\t\t\t\t// The actual url these short urls are relative to can change\n\t\t\t\t// So within the same session, we the url may end up somewhere different\n\t\t\t\tshortUrl = shortUrl.replace(baseUrl,'');\n\t\t\t}\n\n\t\t\t// Trim rootUrl\n\t\t\tshortUrl = shortUrl.replace(rootUrl,'/');\n\n\t\t\t// Ensure we can still detect it as a state\n\t\t\tif ( History.isTraditionalAnchor(shortUrl) ) {\n\t\t\t\tshortUrl = './'+shortUrl;\n\t\t\t}\n\n\t\t\t// Clean It\n\t\t\tshortUrl = shortUrl.replace(/^(\\.\\/)+/g,'./').replace(/\\#$/,'');\n\n\t\t\t// Return\n\t\t\treturn shortUrl;\n\t\t};\n\n\t\t/**\n\t\t * History.getLocationHref(document)\n\t\t * Returns a normalized version of document.location.href\n\t\t * accounting for browser inconsistencies, etc.\n\t\t *\n\t\t * This URL will be URI-encoded and will include the hash\n\t\t *\n\t\t * @param {object} document\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getLocationHref = function(doc) {\n\t\t\tdoc = doc || document;\n\n\t\t\t// most of the time, this will be true\n\t\t\tif (doc.URL === doc.location.href)\n\t\t\t\treturn doc.location.href;\n\n\t\t\t// some versions of webkit URI-decode document.location.href\n\t\t\t// but they leave document.URL in an encoded state\n\t\t\tif (doc.location.href === decodeURIComponent(doc.URL))\n\t\t\t\treturn doc.URL;\n\n\t\t\t// FF 3.6 only updates document.URL when a page is reloaded\n\t\t\t// document.location.href is updated correctly\n\t\t\tif (doc.location.hash && decodeURIComponent(doc.location.href.replace(/^[^#]+/, \"\")) === doc.location.hash)\n\t\t\t\treturn doc.location.href;\n\n\t\t\tif (doc.URL.indexOf('#') == -1 && doc.location.href.indexOf('#') != -1)\n\t\t\t\treturn doc.location.href;\n\t\t\t\n\t\t\treturn doc.URL || doc.location.href;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Storage\n\n\t\t/**\n\t\t * History.store\n\t\t * The store for all session specific data\n\t\t */\n\t\tHistory.store = {};\n\n\t\t/**\n\t\t * History.idToState\n\t\t * 1-1: State ID to State Object\n\t\t */\n\t\tHistory.idToState = History.idToState||{};\n\n\t\t/**\n\t\t * History.stateToId\n\t\t * 1-1: State String to State ID\n\t\t */\n\t\tHistory.stateToId = History.stateToId||{};\n\n\t\t/**\n\t\t * History.urlToId\n\t\t * 1-1: State URL to State ID\n\t\t */\n\t\tHistory.urlToId = History.urlToId||{};\n\n\t\t/**\n\t\t * History.storedStates\n\t\t * Store the states in an array\n\t\t */\n\t\tHistory.storedStates = History.storedStates||[];\n\n\t\t/**\n\t\t * History.savedStates\n\t\t * Saved the states in an array\n\t\t */\n\t\tHistory.savedStates = History.savedStates||[];\n\n\t\t/**\n\t\t * History.noramlizeStore()\n\t\t * Noramlize the store by adding necessary values\n\t\t */\n\t\tHistory.normalizeStore = function(){\n\t\t\tHistory.store.idToState = History.store.idToState||{};\n\t\t\tHistory.store.urlToId = History.store.urlToId||{};\n\t\t\tHistory.store.stateToId = History.store.stateToId||{};\n\t\t};\n\n\t\t/**\n\t\t * History.getState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @param {Boolean} friendly\n\t\t * @param {Boolean} create\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getState = function(friendly,create){\n\t\t\t// Prepare\n\t\t\tif ( typeof friendly === 'undefined' ) { friendly = true; }\n\t\t\tif ( typeof create === 'undefined' ) { create = true; }\n\n\t\t\t// Fetch\n\t\t\tvar State = History.getLastSavedState();\n\n\t\t\t// Create\n\t\t\tif ( !State && create ) {\n\t\t\t\tState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( friendly ) {\n\t\t\t\tState = History.cloneObject(State);\n\t\t\t\tState.url = State.cleanUrl||State.url;\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByState(State)\n\t\t * Gets a ID for a State\n\t\t * @param {State} newState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getIdByState = function(newState){\n\n\t\t\t// Fetch ID\n\t\t\tvar id = History.extractId(newState.url),\n\t\t\t\tstr;\n\n\t\t\tif ( !id ) {\n\t\t\t\t// Find ID via State String\n\t\t\t\tstr = History.getStateString(newState);\n\t\t\t\tif ( typeof History.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse if ( typeof History.store.stateToId[str] !== 'undefined' ) {\n\t\t\t\t\tid = History.store.stateToId[str];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Generate a new ID\n\t\t\t\t\twhile ( true ) {\n\t\t\t\t\t\tid = (new Date()).getTime() + String(Math.random()).replace(/\\D/g,'');\n\t\t\t\t\t\tif ( typeof History.idToState[id] === 'undefined' && typeof History.store.idToState[id] === 'undefined' ) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply the new State to the ID\n\t\t\t\t\tHistory.stateToId[str] = id;\n\t\t\t\t\tHistory.idToState[id] = newState;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return ID\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeState(State)\n\t\t * Expands a State Object\n\t\t * @param {object} State\n\t\t * @return {object}\n\t\t */\n\t\tHistory.normalizeState = function(oldState){\n\t\t\t// Variables\n\t\t\tvar newState, dataNotEmpty;\n\n\t\t\t// Prepare\n\t\t\tif ( !oldState || (typeof oldState !== 'object') ) {\n\t\t\t\toldState = {};\n\t\t\t}\n\n\t\t\t// Check\n\t\t\tif ( typeof oldState.normalized !== 'undefined' ) {\n\t\t\t\treturn oldState;\n\t\t\t}\n\n\t\t\t// Adjust\n\t\t\tif ( !oldState.data || (typeof oldState.data !== 'object') ) {\n\t\t\t\toldState.data = {};\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Create\n\t\t\tnewState = {};\n\t\t\tnewState.normalized = true;\n\t\t\tnewState.title = oldState.title||'';\n\t\t\tnewState.url = History.getFullUrl(oldState.url?oldState.url:(History.getLocationHref()));\n\t\t\tnewState.hash = History.getShortUrl(newState.url);\n\t\t\tnewState.data = History.cloneObject(oldState.data);\n\n\t\t\t// Fetch ID\n\t\t\tnewState.id = History.getIdByState(newState);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Clean the URL\n\t\t\tnewState.cleanUrl = newState.url.replace(/\\??\\&_suid.*/,'');\n\t\t\tnewState.url = newState.cleanUrl;\n\n\t\t\t// Check to see if we have more than just a url\n\t\t\tdataNotEmpty = !History.isEmptyObject(newState.data);\n\n\t\t\t// Apply\n\t\t\tif ( (newState.title || dataNotEmpty) && History.options.disableSuid !== true ) {\n\t\t\t\t// Add ID to Hash\n\t\t\t\tnewState.hash = History.getShortUrl(newState.url).replace(/\\??\\&_suid.*/,'');\n\t\t\t\tif ( !/\\?/.test(newState.hash) ) {\n\t\t\t\t\tnewState.hash += '?';\n\t\t\t\t}\n\t\t\t\tnewState.hash += '&_suid='+newState.id;\n\t\t\t}\n\n\t\t\t// Create the Hashed URL\n\t\t\tnewState.hashedUrl = History.getFullUrl(newState.hash);\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Update the URL if we have a duplicate\n\t\t\tif ( (History.emulated.pushState || History.bugs.safariPoll) && History.hasUrlDuplicate(newState) ) {\n\t\t\t\tnewState.url = newState.hashedUrl;\n\t\t\t}\n\n\t\t\t// ----------------------------------------------------------------\n\n\t\t\t// Return\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.createStateObject(data,title,url)\n\t\t * Creates a object based on the data, title and url state params\n\t\t * @param {object} data\n\t\t * @param {string} title\n\t\t * @param {string} url\n\t\t * @return {object}\n\t\t */\n\t\tHistory.createStateObject = function(data,title,url){\n\t\t\t// Hashify\n\t\t\tvar State = {\n\t\t\t\t'data': data,\n\t\t\t\t'title': title,\n\t\t\t\t'url': url\n\t\t\t};\n\n\t\t\t// Expand the State\n\t\t\tState = History.normalizeState(State);\n\n\t\t\t// Return object\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateById(id)\n\t\t * Get a state by it's UID\n\t\t * @param {String} id\n\t\t */\n\t\tHistory.getStateById = function(id){\n\t\t\t// Prepare\n\t\t\tid = String(id);\n\n\t\t\t// Retrieve\n\t\t\tvar State = History.idToState[id] || History.store.idToState[id] || undefined;\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's String\n\t\t * @param {State} passedState\n\t\t */\n\t\tHistory.getStateString = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, cleanedState, str;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Clean\n\t\t\tcleanedState = {\n\t\t\t\tdata: State.data,\n\t\t\t\ttitle: passedState.title,\n\t\t\t\turl: passedState.url\n\t\t\t};\n\n\t\t\t// Fetch\n\t\t\tstr = JSON.stringify(cleanedState);\n\n\t\t\t// Return\n\t\t\treturn str;\n\t\t};\n\n\t\t/**\n\t\t * Get a State's ID\n\t\t * @param {State} passedState\n\t\t * @return {String} id\n\t\t */\n\t\tHistory.getStateId = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, id;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Fetch\n\t\t\tid = State.id;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByState(State)\n\t\t * Creates a Hash for the State Object\n\t\t * @param {State} passedState\n\t\t * @return {String} hash\n\t\t */\n\t\tHistory.getHashByState = function(passedState){\n\t\t\t// Prepare\n\t\t\tvar State, hash;\n\n\t\t\t// Fetch\n\t\t\tState = History.normalizeState(passedState);\n\n\t\t\t// Hash\n\t\t\thash = State.hash;\n\n\t\t\t// Return\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.extractId(url_or_hash)\n\t\t * Get a State ID by it's URL or Hash\n\t\t * @param {string} url_or_hash\n\t\t * @return {string} id\n\t\t */\n\t\tHistory.extractId = function ( url_or_hash ) {\n\t\t\t// Prepare\n\t\t\tvar id,parts,url, tmp;\n\n\t\t\t// Extract\n\t\t\t\n\t\t\t// If the URL has a #, use the id from before the #\n\t\t\tif (url_or_hash.indexOf('#') != -1)\n\t\t\t{\n\t\t\t\ttmp = url_or_hash.split(\"#\")[0];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttmp = url_or_hash;\n\t\t\t}\n\t\t\t\n\t\t\tparts = /(.*)\\&_suid=([0-9]+)$/.exec(tmp);\n\t\t\turl = parts ? (parts[1]||url_or_hash) : url_or_hash;\n\t\t\tid = parts ? String(parts[2]||'') : '';\n\n\t\t\t// Return\n\t\t\treturn id||false;\n\t\t};\n\n\t\t/**\n\t\t * History.isTraditionalAnchor\n\t\t * Checks to see if the url is a traditional anchor or not\n\t\t * @param {String} url_or_hash\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.isTraditionalAnchor = function(url_or_hash){\n\t\t\t// Check\n\t\t\tvar isTraditional = !(/[\\/\\?\\.]/.test(url_or_hash));\n\n\t\t\t// Return\n\t\t\treturn isTraditional;\n\t\t};\n\n\t\t/**\n\t\t * History.extractState\n\t\t * Get a State by it's URL or Hash\n\t\t * @param {String} url_or_hash\n\t\t * @return {State|null}\n\t\t */\n\t\tHistory.extractState = function(url_or_hash,create){\n\t\t\t// Prepare\n\t\t\tvar State = null, id, url;\n\t\t\tcreate = create||false;\n\n\t\t\t// Fetch SUID\n\t\t\tid = History.extractId(url_or_hash);\n\t\t\tif ( id ) {\n\t\t\t\tState = History.getStateById(id);\n\t\t\t}\n\n\t\t\t// Fetch SUID returned no State\n\t\t\tif ( !State ) {\n\t\t\t\t// Fetch URL\n\t\t\t\turl = History.getFullUrl(url_or_hash);\n\n\t\t\t\t// Check URL\n\t\t\t\tid = History.getIdByUrl(url)||false;\n\t\t\t\tif ( id ) {\n\t\t\t\t\tState = History.getStateById(id);\n\t\t\t\t}\n\n\t\t\t\t// Create State\n\t\t\t\tif ( !State && create && !History.isTraditionalAnchor(url_or_hash) ) {\n\t\t\t\t\tState = History.createStateObject(null,null,url);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn State;\n\t\t};\n\n\t\t/**\n\t\t * History.getIdByUrl()\n\t\t * Get a State ID by a State URL\n\t\t */\n\t\tHistory.getIdByUrl = function(url){\n\t\t\t// Fetch\n\t\t\tvar id = History.urlToId[url] || History.store.urlToId[url] || undefined;\n\n\t\t\t// Return\n\t\t\treturn id;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastSavedState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastSavedState = function(){\n\t\t\treturn History.savedStates[History.savedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.getLastStoredState()\n\t\t * Get an object containing the data, title and url of the current state\n\t\t * @return {Object} State\n\t\t */\n\t\tHistory.getLastStoredState = function(){\n\t\t\treturn History.storedStates[History.storedStates.length-1]||undefined;\n\t\t};\n\n\t\t/**\n\t\t * History.hasUrlDuplicate\n\t\t * Checks if a Url will have a url conflict\n\t\t * @param {Object} newState\n\t\t * @return {Boolean} hasDuplicate\n\t\t */\n\t\tHistory.hasUrlDuplicate = function(newState) {\n\t\t\t// Prepare\n\t\t\tvar hasDuplicate = false,\n\t\t\t\toldState;\n\n\t\t\t// Fetch\n\t\t\toldState = History.extractState(newState.url);\n\n\t\t\t// Check\n\t\t\thasDuplicate = oldState && oldState.id !== newState.id;\n\n\t\t\t// Return\n\t\t\treturn hasDuplicate;\n\t\t};\n\n\t\t/**\n\t\t * History.storeState\n\t\t * Store a State\n\t\t * @param {Object} newState\n\t\t * @return {Object} newState\n\t\t */\n\t\tHistory.storeState = function(newState){\n\t\t\t// Store the State\n\t\t\tHistory.urlToId[newState.url] = newState.id;\n\n\t\t\t// Push the State\n\t\t\tHistory.storedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return newState\n\t\t\treturn newState;\n\t\t};\n\n\t\t/**\n\t\t * History.isLastSavedState(newState)\n\t\t * Tests to see if the state is the last state\n\t\t * @param {Object} newState\n\t\t * @return {boolean} isLast\n\t\t */\n\t\tHistory.isLastSavedState = function(newState){\n\t\t\t// Prepare\n\t\t\tvar isLast = false,\n\t\t\t\tnewId, oldState, oldId;\n\n\t\t\t// Check\n\t\t\tif ( History.savedStates.length ) {\n\t\t\t\tnewId = newState.id;\n\t\t\t\toldState = History.getLastSavedState();\n\t\t\t\toldId = oldState.id;\n\n\t\t\t\t// Check\n\t\t\t\tisLast = (newId === oldId);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn isLast;\n\t\t};\n\n\t\t/**\n\t\t * History.saveState\n\t\t * Push a State\n\t\t * @param {Object} newState\n\t\t * @return {boolean} changed\n\t\t */\n\t\tHistory.saveState = function(newState){\n\t\t\t// Check Hash\n\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Push the State\n\t\t\tHistory.savedStates.push(History.cloneObject(newState));\n\n\t\t\t// Return true\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.getStateByIndex()\n\t\t * Gets a state by the index\n\t\t * @param {integer} index\n\t\t * @return {Object}\n\t\t */\n\t\tHistory.getStateByIndex = function(index){\n\t\t\t// Prepare\n\t\t\tvar State = null;\n\n\t\t\t// Handle\n\t\t\tif ( typeof index === 'undefined' ) {\n\t\t\t\t// Get the last inserted\n\t\t\t\tState = History.savedStates[History.savedStates.length-1];\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Get from the end\n\t\t\t\tState = History.savedStates[History.savedStates.length+index];\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Get from the beginning\n\t\t\t\tState = History.savedStates[index];\n\t\t\t}\n\n\t\t\t// Return State\n\t\t\treturn State;\n\t\t};\n\t\t\n\t\t/**\n\t\t * History.getCurrentIndex()\n\t\t * Gets the current index\n\t\t * @return (integer)\n\t\t*/\n\t\tHistory.getCurrentIndex = function(){\n\t\t\t// Prepare\n\t\t\tvar index = null;\n\t\t\t\n\t\t\t// No states saved\n\t\t\tif(History.savedStates.length < 1) {\n\t\t\t\tindex = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tindex = History.savedStates.length-1;\n\t\t\t}\n\t\t\treturn index;\n\t\t};\n\n\t\t// ====================================================================\n\t\t// Hash Helpers\n\n\t\t/**\n\t\t * History.getHash()\n\t\t * @param {Location=} location\n\t\t * Gets the current document hash\n\t\t * Note: unlike location.hash, this is guaranteed to return the escaped hash in all browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.getHash = function(doc){\n\t\t\tvar url = History.getLocationHref(doc),\n\t\t\t\thash;\n\t\t\thash = History.getHashByUrl(url);\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.unescapeHash()\n\t\t * normalize and Unescape a Hash\n\t\t * @param {String} hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.unescapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Unescape hash\n\t\t\tresult = decodeURIComponent(result);\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.normalizeHash()\n\t\t * normalize a hash across browsers\n\t\t * @return {string}\n\t\t */\n\t\tHistory.normalizeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = hash.replace(/[^#]*#/,'').replace(/#.*/, '');\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.setHash(hash)\n\t\t * Sets the document hash\n\t\t * @param {string} hash\n\t\t * @return {History}\n\t\t */\n\t\tHistory.setHash = function(hash,queue){\n\t\t\t// Prepare\n\t\t\tvar State, pageUrl;\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.setHash: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.setHash,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Log\n\t\t\t//History.debug('History.setHash: called',hash);\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Check if hash is a state\n\t\t\tState = History.extractState(hash,true);\n\t\t\tif ( State && !History.emulated.pushState ) {\n\t\t\t\t// Hash is a state so skip the setHash\n\t\t\t\t//History.debug('History.setHash: Hash is a state so skipping the hash set with a direct pushState call',arguments);\n\n\t\t\t\t// PushState\n\t\t\t\tHistory.pushState(State.data,State.title,State.url,false);\n\t\t\t}\n\t\t\telse if ( History.getHash() !== hash ) {\n\t\t\t\t// Hash is a proper hash, so apply it\n\n\t\t\t\t// Handle browser bugs\n\t\t\t\tif ( History.bugs.setHash ) {\n\t\t\t\t\t// Fix Safari Bug https://bugs.webkit.org/show_bug.cgi?id=56249\n\n\t\t\t\t\t// Fetch the base page\n\t\t\t\t\tpageUrl = History.getPageUrl();\n\n\t\t\t\t\t// Safari hash apply\n\t\t\t\t\tHistory.pushState(null,null,pageUrl+'#'+hash,false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Normal hash apply\n\t\t\t\t\tdocument.location.hash = hash;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.escape()\n\t\t * normalize and Escape a Hash\n\t\t * @return {string}\n\t\t */\n\t\tHistory.escapeHash = function(hash){\n\t\t\t// Prepare\n\t\t\tvar result = History.normalizeHash(hash);\n\n\t\t\t// Escape hash\n\t\t\tresult = window.encodeURIComponent(result);\n\n\t\t\t// IE6 Escape Bug\n\t\t\tif ( !History.bugs.hashEscape ) {\n\t\t\t\t// Restore common parts\n\t\t\t\tresult = result\n\t\t\t\t\t.replace(/\\%21/g,'!')\n\t\t\t\t\t.replace(/\\%26/g,'&')\n\t\t\t\t\t.replace(/\\%3D/g,'=')\n\t\t\t\t\t.replace(/\\%3F/g,'?');\n\t\t\t}\n\n\t\t\t// Return result\n\t\t\treturn result;\n\t\t};\n\n\t\t/**\n\t\t * History.getHashByUrl(url)\n\t\t * Extracts the Hash from a URL\n\t\t * @param {string} url\n\t\t * @return {string} url\n\t\t */\n\t\tHistory.getHashByUrl = function(url){\n\t\t\t// Extract the hash\n\t\t\tvar hash = String(url)\n\t\t\t\t.replace(/([^#]*)#?([^#]*)#?(.*)/, '$2')\n\t\t\t\t;\n\n\t\t\t// Unescape hash\n\t\t\thash = History.unescapeHash(hash);\n\n\t\t\t// Return hash\n\t\t\treturn hash;\n\t\t};\n\n\t\t/**\n\t\t * History.setTitle(title)\n\t\t * Applies the title to the document\n\t\t * @param {State} newState\n\t\t * @return {Boolean}\n\t\t */\n\t\tHistory.setTitle = function(newState){\n\t\t\t// Prepare\n\t\t\tvar title = newState.title,\n\t\t\t\tfirstState;\n\n\t\t\t// Initial\n\t\t\tif ( !title ) {\n\t\t\t\tfirstState = History.getStateByIndex(0);\n\t\t\t\tif ( firstState && firstState.url === newState.url ) {\n\t\t\t\t\ttitle = firstState.title||History.options.initialTitle;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply\n\t\t\ttry {\n\t\t\t\tdocument.getElementsByTagName('title')[0].innerHTML = title.replace('<','&lt;').replace('>','&gt;').replace(' & ',' &amp; ');\n\t\t\t}\n\t\t\tcatch ( Exception ) { }\n\t\t\tdocument.title = title;\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Queueing\n\n\t\t/**\n\t\t * History.queues\n\t\t * The list of queues to use\n\t\t * First In, First Out\n\t\t */\n\t\tHistory.queues = [];\n\n\t\t/**\n\t\t * History.busy(value)\n\t\t * @param {boolean} value [optional]\n\t\t * @return {boolean} busy\n\t\t */\n\t\tHistory.busy = function(value){\n\t\t\t// Apply\n\t\t\tif ( typeof value !== 'undefined' ) {\n\t\t\t\t//History.debug('History.busy: changing ['+(History.busy.flag||false)+'] to ['+(value||false)+']', History.queues.length);\n\t\t\t\tHistory.busy.flag = value;\n\t\t\t}\n\t\t\t// Default\n\t\t\telse if ( typeof History.busy.flag === 'undefined' ) {\n\t\t\t\tHistory.busy.flag = false;\n\t\t\t}\n\n\t\t\t// Queue\n\t\t\tif ( !History.busy.flag ) {\n\t\t\t\t// Execute the next item in the queue\n\t\t\t\tclearTimeout(History.busy.timeout);\n\t\t\t\tvar fireNext = function(){\n\t\t\t\t\tvar i, queue, item;\n\t\t\t\t\tif ( History.busy.flag ) return;\n\t\t\t\t\tfor ( i=History.queues.length-1; i >= 0; --i ) {\n\t\t\t\t\t\tqueue = History.queues[i];\n\t\t\t\t\t\tif ( queue.length === 0 ) continue;\n\t\t\t\t\t\titem = queue.shift();\n\t\t\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tHistory.busy.timeout = setTimeout(fireNext,History.options.busyDelay);\n\t\t\t}\n\n\t\t\t// Return\n\t\t\treturn History.busy.flag;\n\t\t};\n\n\t\t/**\n\t\t * History.busy.flag\n\t\t */\n\t\tHistory.busy.flag = false;\n\n\t\t/**\n\t\t * History.fireQueueItem(item)\n\t\t * Fire a Queue Item\n\t\t * @param {Object} item\n\t\t * @return {Mixed} result\n\t\t */\n\t\tHistory.fireQueueItem = function(item){\n\t\t\treturn item.callback.apply(item.scope||History,item.args||[]);\n\t\t};\n\n\t\t/**\n\t\t * History.pushQueue(callback,args)\n\t\t * Add an item to the queue\n\t\t * @param {Object} item [scope,callback,args,queue]\n\t\t */\n\t\tHistory.pushQueue = function(item){\n\t\t\t// Prepare the queue\n\t\t\tHistory.queues[item.queue||0] = History.queues[item.queue||0]||[];\n\n\t\t\t// Add to the queue\n\t\t\tHistory.queues[item.queue||0].push(item);\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.queue (item,queue), (func,queue), (func), (item)\n\t\t * Either firs the item now if not busy, or adds it to the queue\n\t\t */\n\t\tHistory.queue = function(item,queue){\n\t\t\t// Prepare\n\t\t\tif ( typeof item === 'function' ) {\n\t\t\t\titem = {\n\t\t\t\t\tcallback: item\n\t\t\t\t};\n\t\t\t}\n\t\t\tif ( typeof queue !== 'undefined' ) {\n\t\t\t\titem.queue = queue;\n\t\t\t}\n\n\t\t\t// Handle\n\t\t\tif ( History.busy() ) {\n\t\t\t\tHistory.pushQueue(item);\n\t\t\t} else {\n\t\t\t\tHistory.fireQueueItem(item);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.clearQueue()\n\t\t * Clears the Queue\n\t\t */\n\t\tHistory.clearQueue = function(){\n\t\t\tHistory.busy.flag = false;\n\t\t\tHistory.queues = [];\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// IE Bug Fix\n\n\t\t/**\n\t\t * History.stateChanged\n\t\t * States whether or not the state has changed since the last double check was initialised\n\t\t */\n\t\tHistory.stateChanged = false;\n\n\t\t/**\n\t\t * History.doubleChecker\n\t\t * Contains the timeout used for the double checks\n\t\t */\n\t\tHistory.doubleChecker = false;\n\n\t\t/**\n\t\t * History.doubleCheckComplete()\n\t\t * Complete a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckComplete = function(){\n\t\t\t// Update\n\t\t\tHistory.stateChanged = true;\n\n\t\t\t// Clear\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheckClear()\n\t\t * Clear a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheckClear = function(){\n\t\t\t// Clear\n\t\t\tif ( History.doubleChecker ) {\n\t\t\t\tclearTimeout(History.doubleChecker);\n\t\t\t\tHistory.doubleChecker = false;\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\t\t/**\n\t\t * History.doubleCheck()\n\t\t * Create a double check\n\t\t * @return {History}\n\t\t */\n\t\tHistory.doubleCheck = function(tryAgain){\n\t\t\t// Reset\n\t\t\tHistory.stateChanged = false;\n\t\t\tHistory.doubleCheckClear();\n\n\t\t\t// Fix IE6,IE7 bug where calling history.back or history.forward does not actually change the hash (whereas doing it manually does)\n\t\t\t// Fix Safari 5 bug where sometimes the state does not change: https://bugs.webkit.org/show_bug.cgi?id=42940\n\t\t\tif ( History.bugs.ieDoubleCheck ) {\n\t\t\t\t// Apply Check\n\t\t\t\tHistory.doubleChecker = setTimeout(\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tHistory.doubleCheckClear();\n\t\t\t\t\t\tif ( !History.stateChanged ) {\n\t\t\t\t\t\t\t//History.debug('History.doubleCheck: State has not yet changed, trying again', arguments);\n\t\t\t\t\t\t\t// Re-Attempt\n\t\t\t\t\t\t\ttryAgain();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tHistory.options.doubleCheckInterval\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// Safari Bug Fix\n\n\t\t/**\n\t\t * History.safariStatePoll()\n\t\t * Poll the current state\n\t\t * @return {History}\n\t\t */\n\t\tHistory.safariStatePoll = function(){\n\t\t\t// Poll the URL\n\n\t\t\t// Get the Last State which has the new URL\n\t\t\tvar\n\t\t\t\turlState = History.extractState(History.getLocationHref()),\n\t\t\t\tnewState;\n\n\t\t\t// Check for a difference\n\t\t\tif ( !History.isLastSavedState(urlState) ) {\n\t\t\t\tnewState = urlState;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Check if we have a state with that url\n\t\t\t// If not create it\n\t\t\tif ( !newState ) {\n\t\t\t\t//History.debug('History.safariStatePoll: new');\n\t\t\t\tnewState = History.createStateObject();\n\t\t\t}\n\n\t\t\t// Apply the New State\n\t\t\t//History.debug('History.safariStatePoll: trigger');\n\t\t\tHistory.Adapter.trigger(window,'popstate');\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// State Aliases\n\n\t\t/**\n\t\t * History.back(queue)\n\t\t * Send the browser history back one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.back = function(queue){\n\t\t\t//History.debug('History.back: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.back: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.back,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.back(false);\n\t\t\t});\n\n\t\t\t// Go back\n\t\t\thistory.go(-1);\n\n\t\t\t// End back closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.forward(queue)\n\t\t * Send the browser history forward one item\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.forward = function(queue){\n\t\t\t//History.debug('History.forward: called', arguments);\n\n\t\t\t// Handle Queueing\n\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t// Wait + Push to Queue\n\t\t\t\t//History.debug('History.forward: we must wait', arguments);\n\t\t\t\tHistory.pushQueue({\n\t\t\t\t\tscope: History,\n\t\t\t\t\tcallback: History.forward,\n\t\t\t\t\targs: arguments,\n\t\t\t\t\tqueue: queue\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Make Busy + Continue\n\t\t\tHistory.busy(true);\n\n\t\t\t// Fix certain browser bugs that prevent the state from changing\n\t\t\tHistory.doubleCheck(function(){\n\t\t\t\tHistory.forward(false);\n\t\t\t});\n\n\t\t\t// Go forward\n\t\t\thistory.go(1);\n\n\t\t\t// End forward closure\n\t\t\treturn true;\n\t\t};\n\n\t\t/**\n\t\t * History.go(index,queue)\n\t\t * Send the browser history back or forward index times\n\t\t * @param {Integer} queue [optional]\n\t\t */\n\t\tHistory.go = function(index,queue){\n\t\t\t//History.debug('History.go: called', arguments);\n\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};\n\t\t\tHistory.pushState = History.pushState||emptyFunction;\n\t\t\tHistory.replaceState = History.replaceState||emptyFunction;\n\t\t} // History.emulated.pushState\n\n\t\t// Native pushState Implementation\n\t\telse {\n\t\t\t/*\n\t\t\t * Use native HTML5 History API Implementation\n\t\t\t */\n\n\t\t\t/**\n\t\t\t * History.onPopState(event,extra)\n\t\t\t * Refresh the Current State\n\t\t\t */\n\t\t\tHistory.onPopState = function(event,extra){\n\t\t\t\t// Prepare\n\t\t\t\tvar stateId = false, newState = false, currentHash, currentState;\n\n\t\t\t\t// Reset the double check\n\t\t\t\tHistory.doubleCheckComplete();\n\n\t\t\t\t// Check for a Hash, and handle apporiatly\n\t\t\t\tcurrentHash = History.getHash();\n\t\t\t\tif ( currentHash ) {\n\t\t\t\t\t// Expand Hash\n\t\t\t\t\tcurrentState = History.extractState(currentHash||History.getLocationHref(),true);\n\t\t\t\t\tif ( currentState ) {\n\t\t\t\t\t\t// We were able to parse it, it must be a State!\n\t\t\t\t\t\t// Let's forward to replaceState\n\t\t\t\t\t\t//History.debug('History.onPopState: state anchor', currentHash, currentState);\n\t\t\t\t\t\tHistory.replaceState(currentState.data, currentState.title, currentState.url, false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Traditional Anchor\n\t\t\t\t\t\t//History.debug('History.onPopState: traditional anchor', currentHash);\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'anchorchange');\n\t\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\t}\n\n\t\t\t\t\t// We don't care for hashes\n\t\t\t\t\tHistory.expectedStateId = false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tstateId = History.Adapter.extractEventData('state',event,extra) || false;\n\n\t\t\t\t// Fetch State\n\t\t\t\tif ( stateId ) {\n\t\t\t\t\t// Vanilla: Back/forward button was used\n\t\t\t\t\tnewState = History.getStateById(stateId);\n\t\t\t\t}\n\t\t\t\telse if ( History.expectedStateId ) {\n\t\t\t\t\t// Vanilla: A new state was pushed, and popstate was called manually\n\t\t\t\t\tnewState = History.getStateById(History.expectedStateId);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Initial State\n\t\t\t\t\tnewState = History.extractState(History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// The State did not exist in our store\n\t\t\t\tif ( !newState ) {\n\t\t\t\t\t// Regenerate the State\n\t\t\t\t\tnewState = History.createStateObject(null,null,History.getLocationHref());\n\t\t\t\t}\n\n\t\t\t\t// Clean\n\t\t\t\tHistory.expectedStateId = false;\n\n\t\t\t\t// Check if we are the same state\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// There has been no change (just the page's hash has finally propagated)\n\t\t\t\t\t//History.debug('History.onPopState: no change', newState, History.savedStates);\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Store the State\n\t\t\t\tHistory.storeState(newState);\n\t\t\t\tHistory.saveState(newState);\n\n\t\t\t\t// Force update of the title\n\t\t\t\tHistory.setTitle(newState);\n\n\t\t\t\t// Fire Our Event\n\t\t\t\tHistory.Adapter.trigger(window,'statechange');\n\t\t\t\tHistory.busy(false);\n\n\t\t\t\t// Return true\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tHistory.Adapter.bind(window,'popstate',History.onPopState);\n\n\t\t\t/**\n\t\t\t * History.pushState(data,title,url)\n\t\t\t * Add a new State to the history object, become it, and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.pushState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.pushState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.pushState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.pushState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.pushState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End pushState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * History.replaceState(data,title,url)\n\t\t\t * Replace the State and trigger onpopstate\n\t\t\t * We have to trigger for HTML4 compatibility\n\t\t\t * @param {object} data\n\t\t\t * @param {string} title\n\t\t\t * @param {string} url\n\t\t\t * @return {true}\n\t\t\t */\n\t\t\tHistory.replaceState = function(data,title,url,queue){\n\t\t\t\t//History.debug('History.replaceState: called', arguments);\n\n\t\t\t\t// Check the State\n\t\t\t\tif ( History.getHashByUrl(url) && History.emulated.pushState ) {\n\t\t\t\t\tthrow new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');\n\t\t\t\t}\n\n\t\t\t\t// Handle Queueing\n\t\t\t\tif ( queue !== false && History.busy() ) {\n\t\t\t\t\t// Wait + Push to Queue\n\t\t\t\t\t//History.debug('History.replaceState: we must wait', arguments);\n\t\t\t\t\tHistory.pushQueue({\n\t\t\t\t\t\tscope: History,\n\t\t\t\t\t\tcallback: History.replaceState,\n\t\t\t\t\t\targs: arguments,\n\t\t\t\t\t\tqueue: queue\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t// Make Busy + Continue\n\t\t\t\tHistory.busy(true);\n\n\t\t\t\t// Create the newState\n\t\t\t\tvar newState = History.createStateObject(data,title,url);\n\n\t\t\t\t// Check it\n\t\t\t\tif ( History.isLastSavedState(newState) ) {\n\t\t\t\t\t// Won't be a change\n\t\t\t\t\tHistory.busy(false);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// Store the newState\n\t\t\t\t\tHistory.storeState(newState);\n\t\t\t\t\tHistory.expectedStateId = newState.id;\n\n\t\t\t\t\t// Push the newState\n\t\t\t\t\thistory.replaceState(newState.id,newState.title,newState.url);\n\n\t\t\t\t\t// Fire HTML5 Event\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t}\n\n\t\t\t\t// End replaceState closure\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t} // !History.emulated.pushState\n\n\n\t\t// ====================================================================\n\t\t// Initialise\n\n\t\t/**\n\t\t * Load the Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// Fetch\n\t\t\ttry {\n\t\t\t\tHistory.store = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t}\n\t\t\tcatch ( err ) {\n\t\t\t\tHistory.store = {};\n\t\t\t}\n\n\t\t\t// Normalize\n\t\t\tHistory.normalizeStore();\n\t\t}\n\t\telse {\n\t\t\t// Default Load\n\t\t\tHistory.store = {};\n\t\t\tHistory.normalizeStore();\n\t\t}\n\n\t\t/**\n\t\t * Clear Intervals on exit to prevent memory leaks\n\t\t */\n\t\tHistory.Adapter.bind(window,\"unload\",History.clearAllIntervals);\n\n\t\t/**\n\t\t * Create the initial State\n\t\t */\n\t\tHistory.saveState(History.storeState(History.extractState(History.getLocationHref(),true)));\n\n\t\t/**\n\t\t * Bind for Saving Store\n\t\t */\n\t\tif ( sessionStorage ) {\n\t\t\t// When the page is closed\n\t\t\tHistory.onUnload = function(){\n\t\t\t\t// Prepare\n\t\t\t\tvar\tcurrentStore, item, currentStoreString;\n\n\t\t\t\t// Fetch\n\t\t\t\ttry {\n\t\t\t\t\tcurrentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};\n\t\t\t\t}\n\t\t\t\tcatch ( err ) {\n\t\t\t\t\tcurrentStore = {};\n\t\t\t\t}\n\n\t\t\t\t// Ensure\n\t\t\t\tcurrentStore.idToState = currentStore.idToState || {};\n\t\t\t\tcurrentStore.urlToId = currentStore.urlToId || {};\n\t\t\t\tcurrentStore.stateToId = currentStore.stateToId || {};\n\n\t\t\t\t// Sync\n\t\t\t\tfor ( item in History.idToState ) {\n\t\t\t\t\tif ( !History.idToState.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.idToState[item] = History.idToState[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.urlToId ) {\n\t\t\t\t\tif ( !History.urlToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.urlToId[item] = History.urlToId[item];\n\t\t\t\t}\n\t\t\t\tfor ( item in History.stateToId ) {\n\t\t\t\t\tif ( !History.stateToId.hasOwnProperty(item) ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tcurrentStore.stateToId[item] = History.stateToId[item];\n\t\t\t\t}\n\n\t\t\t\t// Update\n\t\t\t\tHistory.store = currentStore;\n\t\t\t\tHistory.normalizeStore();\n\n\t\t\t\t// In Safari, going into Private Browsing mode causes the\n\t\t\t\t// Session Storage object to still exist but if you try and use\n\t\t\t\t// or set any property/function of it it throws the exception\n\t\t\t\t// \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to\n\t\t\t\t// add something to storage that exceeded the quota.\" infinitely\n\t\t\t\t// every second.\n\t\t\t\tcurrentStoreString = JSON.stringify(currentStore);\n\t\t\t\ttry {\n\t\t\t\t\t// Store\n\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tif (e.code === DOMException.QUOTA_EXCEEDED_ERR) {\n\t\t\t\t\t\tif (sessionStorage.length) {\n\t\t\t\t\t\t\t// Workaround for a bug seen on iPads. Sometimes the quota exceeded error comes up and simply\n\t\t\t\t\t\t\t// removing/resetting the storage can work.\n\t\t\t\t\t\t\tsessionStorage.removeItem('History.store');\n\t\t\t\t\t\t\tsessionStorage.setItem('History.store', currentStoreString);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Otherwise, we're probably private browsing in Safari, so we'll ignore the exception.\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// For Internet Explorer\n\t\t\tHistory.intervalList.push(setInterval(History.onUnload,History.options.storeInterval));\n\n\t\t\t// For Other Browsers\n\t\t\tHistory.Adapter.bind(window,'beforeunload',History.onUnload);\n\t\t\tHistory.Adapter.bind(window,'unload',History.onUnload);\n\n\t\t\t// Both are enabled for consistency\n\t\t}\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( !History.emulated.pushState ) {\n\t\t\t// Be aware, the following is only for native pushState implementations\n\t\t\t// If you are wanting to include something for all browsers\n\t\t\t// Then include it above this if block\n\n\t\t\t/**\n\t\t\t * Setup Safari Fix\n\t\t\t */\n\t\t\tif ( History.bugs.safariPoll ) {\n\t\t\t\tHistory.intervalList.push(setInterval(History.safariStatePoll, History.options.safariPollInterval));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Ensure Cross Browser Compatibility\n\t\t\t */\n\t\t\tif ( navigator.vendor === 'Apple Computer, Inc.' || (navigator.appCodeName||'') === 'Mozilla' ) {\n\t\t\t\t/**\n\t\t\t\t * Fix Safari HashChange Issue\n\t\t\t\t */\n\n\t\t\t\t// Setup Alias\n\t\t\t\tHistory.Adapter.bind(window,'hashchange',function(){\n\t\t\t\t\tHistory.Adapter.trigger(window,'popstate');\n\t\t\t\t});\n\n\t\t\t\t// Initialise Alias\n\t\t\t\tif ( History.getHash() ) {\n\t\t\t\t\tHistory.Adapter.onDomLoad(function(){\n\t\t\t\t\t\tHistory.Adapter.trigger(window,'hashchange');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t} // !History.emulated.pushState\n\n\n\t}; // History.initCore\n\n\t// Try to Initialise History\n\tif (!History.options || !History.options.delayInit) {\n\t\tHistory.init();\n\t}\n\n})(window);\n"
  },
  {
    "path": "scripts/uncompressed/json2.js",
    "content": "/*\n    json2.js\n    2012-10-08\n\n    Public Domain.\n\n    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n    See http://www.JSON.org/js.html\n\n\n    This code should be minified before deployment.\n    See http://javascript.crockford.com/jsmin.html\n\n    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n    NOT CONTROL.\n\n\n    This file creates a global JSON object containing two methods: stringify\n    and parse.\n\n        JSON.stringify(value, replacer, space)\n            value       any JavaScript value, usually an object or array.\n\n            replacer    an optional parameter that determines how object\n                        values are stringified for objects. It can be a\n                        function or an array of strings.\n\n            space       an optional parameter that specifies the indentation\n                        of nested structures. If it is omitted, the text will\n                        be packed without extra whitespace. If it is a number,\n                        it will specify the number of spaces to indent at each\n                        level. If it is a string (such as '\\t' or '&nbsp;'),\n                        it contains the characters used to indent at each level.\n\n            This method produces a JSON text from a JavaScript value.\n\n            When an object value is found, if the object contains a toJSON\n            method, its toJSON method will be called and the result will be\n            stringified. A toJSON method does not serialize: it returns the\n            value represented by the name/value pair that should be serialized,\n            or undefined if nothing should be serialized. The toJSON method\n            will be passed the key associated with the value, and this will be\n            bound to the value\n\n            For example, this would serialize Dates as ISO strings.\n\n                Date.prototype.toJSON = function (key) {\n                    function f(n) {\n                        // Format integers to have at least two digits.\n                        return n < 10 ? '0' + n : n;\n                    }\n\n                    return this.getUTCFullYear()   + '-' +\n                         f(this.getUTCMonth() + 1) + '-' +\n                         f(this.getUTCDate())      + 'T' +\n                         f(this.getUTCHours())     + ':' +\n                         f(this.getUTCMinutes())   + ':' +\n                         f(this.getUTCSeconds())   + 'Z';\n                };\n\n            You can provide an optional replacer method. It will be passed the\n            key and value of each member, with this bound to the containing\n            object. The value that is returned from your method will be\n            serialized. If your method returns undefined, then the member will\n            be excluded from the serialization.\n\n            If the replacer parameter is an array of strings, then it will be\n            used to select the members to be serialized. It filters the results\n            such that only members with keys listed in the replacer array are\n            stringified.\n\n            Values that do not have JSON representations, such as undefined or\n            functions, will not be serialized. Such values in objects will be\n            dropped; in arrays they will be replaced with null. You can use\n            a replacer function to replace those with JSON values.\n            JSON.stringify(undefined) returns undefined.\n\n            The optional space parameter produces a stringification of the\n            value that is filled with line breaks and indentation to make it\n            easier to read.\n\n            If the space parameter is a non-empty string, then that string will\n            be used for indentation. If the space parameter is a number, then\n            the indentation will be that many spaces.\n\n            Example:\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}]);\n            // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n            // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n            text = JSON.stringify([new Date()], function (key, value) {\n                return this[key] instanceof Date ?\n                    'Date(' + this[key] + ')' : value;\n            });\n            // text is '[\"Date(---current time---)\"]'\n\n\n        JSON.parse(text, reviver)\n            This method parses a JSON text to produce an object or array.\n            It can throw a SyntaxError exception.\n\n            The optional reviver parameter is a function that can filter and\n            transform the results. It receives each of the keys and values,\n            and its return value is used instead of the original value.\n            If it returns what it received, then the structure is not modified.\n            If it returns undefined then the member is deleted.\n\n            Example:\n\n            // Parse the text. Values that look like ISO date strings will\n            // be converted to Date objects.\n\n            myData = JSON.parse(text, function (key, value) {\n                var a;\n                if (typeof value === 'string') {\n                    a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n                    if (a) {\n                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n                            +a[5], +a[6]));\n                    }\n                }\n                return value;\n            });\n\n            myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n                var d;\n                if (typeof value === 'string' &&\n                        value.slice(0, 5) === 'Date(' &&\n                        value.slice(-1) === ')') {\n                    d = new Date(value.slice(5, -1));\n                    if (d) {\n                        return d;\n                    }\n                }\n                return value;\n            });\n\n\n    This is a reference implementation. You are free to copy, modify, or\n    redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n    lastIndex, length, parse, prototype, push, replace, slice, stringify,\n    test, toJSON, toString, valueOf\n*/\n\n\n// Create a JSON object only if one does not already exist. We create the\n// methods in a closure to avoid creating global variables.\n\nif (typeof JSON !== 'object') {\n    JSON = {};\n}\n\n(function () {\n    'use strict';\n\n    function f(n) {\n        // Format integers to have at least two digits.\n        return n < 10 ? '0' + n : n;\n    }\n\n    if (typeof Date.prototype.toJSON !== 'function') {\n\n        Date.prototype.toJSON = function (key) {\n\n            return isFinite(this.valueOf())\n                ? this.getUTCFullYear()     + '-' +\n                    f(this.getUTCMonth() + 1) + '-' +\n                    f(this.getUTCDate())      + 'T' +\n                    f(this.getUTCHours())     + ':' +\n                    f(this.getUTCMinutes())   + ':' +\n                    f(this.getUTCSeconds())   + 'Z'\n                : null;\n        };\n\n        String.prototype.toJSON      =\n            Number.prototype.toJSON  =\n            Boolean.prototype.toJSON = function (key) {\n                return this.valueOf();\n            };\n    }\n\n    var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n        gap,\n        indent,\n        meta = {    // table of character substitutions\n            '\\b': '\\\\b',\n            '\\t': '\\\\t',\n            '\\n': '\\\\n',\n            '\\f': '\\\\f',\n            '\\r': '\\\\r',\n            '\"' : '\\\\\"',\n            '\\\\': '\\\\\\\\'\n        },\n        rep;\n\n\n    function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n        escapable.lastIndex = 0;\n        return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n            var c = meta[a];\n            return typeof c === 'string'\n                ? c\n                : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"' : '\"' + string + '\"';\n    }\n\n\n    function str(key, holder) {\n\n// Produce a string from holder[key].\n\n        var i,          // The loop counter.\n            k,          // The member key.\n            v,          // The member value.\n            length,\n            mind = gap,\n            partial,\n            value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n        if (value && typeof value === 'object' &&\n                typeof value.toJSON === 'function') {\n            value = value.toJSON(key);\n        }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n        if (typeof rep === 'function') {\n            value = rep.call(holder, key, value);\n        }\n\n// What happens next depends on the value's type.\n\n        switch (typeof value) {\n        case 'string':\n            return quote(value);\n\n        case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n            return isFinite(value) ? String(value) : 'null';\n\n        case 'boolean':\n        case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n            return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n        case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n            if (!value) {\n                return 'null';\n            }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n            gap += indent;\n            partial = [];\n\n// Is the value an array?\n\n            if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n                length = value.length;\n                for (i = 0; i < length; i += 1) {\n                    partial[i] = str(i, value) || 'null';\n                }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n                v = partial.length === 0\n                    ? '[]'\n                    : gap\n                    ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n                    : '[' + partial.join(',') + ']';\n                gap = mind;\n                return v;\n            }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n            if (rep && typeof rep === 'object') {\n                length = rep.length;\n                for (i = 0; i < length; i += 1) {\n                    if (typeof rep[i] === 'string') {\n                        k = rep[i];\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n                for (k in value) {\n                    if (Object.prototype.hasOwnProperty.call(value, k)) {\n                        v = str(k, value);\n                        if (v) {\n                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\n                        }\n                    }\n                }\n            }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n            v = partial.length === 0\n                ? '{}'\n                : gap\n                ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n                : '{' + partial.join(',') + '}';\n            gap = mind;\n            return v;\n        }\n    }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n    if (typeof JSON.stringify !== 'function') {\n        JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n            var i;\n            gap = '';\n            indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n            if (typeof space === 'number') {\n                for (i = 0; i < space; i += 1) {\n                    indent += ' ';\n                }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n            } else if (typeof space === 'string') {\n                indent = space;\n            }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n            rep = replacer;\n            if (replacer && typeof replacer !== 'function' &&\n                    (typeof replacer !== 'object' ||\n                    typeof replacer.length !== 'number')) {\n                throw new Error('JSON.stringify');\n            }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n            return str('', {'': value});\n        };\n    }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n    if (typeof JSON.parse !== 'function') {\n        JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n            var j;\n\n            function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n                var k, v, value = holder[key];\n                if (value && typeof value === 'object') {\n                    for (k in value) {\n                        if (Object.prototype.hasOwnProperty.call(value, k)) {\n                            v = walk(value, k);\n                            if (v !== undefined) {\n                                value[k] = v;\n                            } else {\n                                delete value[k];\n                            }\n                        }\n                    }\n                }\n                return reviver.call(holder, key, value);\n            }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n            text = String(text);\n            cx.lastIndex = 0;\n            if (cx.test(text)) {\n                text = text.replace(cx, function (a) {\n                    return '\\\\u' +\n                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n                });\n            }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n            if (/^[\\],:{}\\s]*$/\n                    .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n                        .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n                        .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n                j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n                return typeof reviver === 'function'\n                    ? walk({'': j}, '')\n                    : j;\n            }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n            throw new SyntaxError('JSON.parse');\n        };\n    }\n}());"
  },
  {
    "path": "tests/.htaccess",
    "content": "Options +FollowSymlinks\nRewriteEngine On\n\n# Clean Adapter\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule ([^\\.]+)$ $1.html [NC,L,QSA]\n\n# Can someone smarter than me make it so:\n# http://localhost/history.js/tests/uncompressed-html5-persistant-jquery\n# Does not redirect to:\n# http://localhost/history.js/tests/uncompressed-html5-persistant-jquery.html\n# But still accesses that url\n"
  },
  {
    "path": "tests/html4+html5.dojo.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML4+HTML5 Dojo Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/dojo.js\"></script>\n\n\t<!-- QUnit -->\n    <!--\n    -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML4+HTML5 Dojo Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\n\t<script src=\"../scripts/uncompressed/json2.js\"></script>\n\t<script src=\"../scripts/uncompressed/history.adapter.dojo.js\"></script>\n\t<script src=\"../scripts/uncompressed/history.html4.js\"></script>\n\t<script src=\"../scripts/uncompressed/history.js\"></script>\n\n<!--\n    <script src=\"../scripts/bundled/html4+html5/dojo.history.js\"></script>\n-->\n\t<!-- Tests -->\n    <!--\n    -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>\n\n"
  },
  {
    "path": "tests/html4+html5.extjs.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML4+HTML5 ExtJS Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/extjs.js\"></script>\n\n\t<!-- QUnit -->\n    <!--\n    -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML4+HTML5 ExtJS Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\n\t<script src=\"../scripts/uncompressed/json2.js\"></script>\n\t<script src=\"../scripts/uncompressed/history.adapter.extjs.js\"></script>\n\t<script src=\"../scripts/uncompressed/history.html4.js\"></script>\n\t<script src=\"../scripts/uncompressed/history.js\"></script>\n\n<!--\n    <script src=\"../scripts/bundled/html4+html5/extjs.history.js\"></script>\n-->\n\t<!-- Tests -->\n    <!--\n    -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>\n\n"
  },
  {
    "path": "tests/html4+html5.jquery.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML4+HTML5 Jquery Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/jquery.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML4+HTML5 Jquery Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html4+html5/jquery.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html4+html5.mootools.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML4+HTML5 Mootools Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/mootools.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML4+HTML5 Mootools Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html4+html5/mootools.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html4+html5.native.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML4+HTML5 Native Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/native.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML4+HTML5 Native Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html4+html5/native.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html4+html5.right.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML4+HTML5 Right Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/right.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML4+HTML5 Right Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html4+html5/right.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html4+html5.zepto.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML4+HTML5 Zepto Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/zepto.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML4+HTML5 Zepto Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html4+html5/zepto.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html5.dojo.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML5 Dojo Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/dojo.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML5 Dojo Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html5/dojo.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "tests/html5.extjs.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML5 ExtJS Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/extjs.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML5 ExtJS Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html5/extjs.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "tests/html5.jquery.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML5 Jquery Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/jquery.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML5 Jquery Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html5/jquery.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html5.mootools.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML5 Mootools Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/mootools.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML5 Mootools Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html5/mootools.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html5.native.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML5 Native Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/native.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML5 Native Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html5/native.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html5.right.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML5 Right Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/right.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML5 Right Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html5/right.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/html5.zepto.html",
    "content": "<!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title>History.js HTML5 Zepto Test Suite</title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/zepto.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\">History.js HTML5 Zepto Test Suite</h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/html5/zepto.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests/image.php",
    "content": "<?php\nheader('Content-type: image/jpeg');\nsleep(10);\n"
  },
  {
    "path": "tests/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<title>History.js Test Suite</title>\n\t\t<style type=\"text/css\">\n\t\t\tbody,html,iframe {\n\t\t\t\tpadding:0;\n\t\t\t\tmargin:0;\n\t\t\t\toutline:none;\n\t\t\t\tborder:none;\n\t\t\t}\n\t\t\t.browser {\n\t\t\t\tpadding-bottom:1em;\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-right: 5em;\n\t\t\t}\n\t\t\t.adapter {\n\t\t\t\tpadding-bottom:1em;\n\t\t\t}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<h1>History.js Test Suite</h1>\n\t\t<p>HTML5 Browsers must pass the HTML4+HTML5 tests, HTML4 Browsers must pass the HTML4 tests and should fail the HTML5 tests.</p>\n\t\t\n\t\t<div class=\"browser\">\n\t\t\t<h2>HTML 4+5</h2>\n\t\t\t<div class=\"adapter\"><a href=\"html4+HTML5.dojo.html\">Dojo Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"html4+HTML5.extjs.html\">ExtJS Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML4+HTML5.jquery.html\">jQuery Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML4+HTML5.mootools.html\">Mootools Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML4+HTML5.native.html\">Native Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML4+HTML5.right.html\">Right Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML4+HTML5.zepto.html\">Zepto Test Suite</a> (Zepto doesn't support IE)</div>\n\t\t</div>\n\t\t<div class=\"browser\">\n\t\t\t<h2>HTML 5</h2>\n\t\t\t<div class=\"adapter\"><a href=\"HTML5.dojo.html\">Dojo Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML5.extjs.html\">ExtJS Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML5.jquery.html\">jQuery Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML5.mootools.html\">Mootools Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML5.native.html\">Native Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML5.right.html\">Right Test Suite</a></div>\n\t\t\t<div class=\"adapter\"><a href=\"HTML5.zepto.html\">Zepto Test Suite</a> (Zepto doesn't support IE)</div>\n\t\t</div>\n\t</body>\n</html>\n"
  },
  {
    "path": "tests/tests.js",
    "content": "(function(){\n\nvar\n\tHistory = window.History,\n\tdocument = window.document,\n\ttest = window.test,\n    deepEqual = window.deepEqual;\n\n// Check\nif ( !History.enabled ) {\n\tthrow new Error('History.js is disabled');\n}\n\n// Prepare\nHistory.options.debug = false;\n\n// Variables\nvar\n\tStates = {\n\t\t// Home\n\t\t0: {\n\t\t\t'url': document.location.href.replace(/#.*$/,''),\n\t\t\t'title': ''\n\t\t},\n\t\t// One\n\t\t1: {\n\t\t\t'data': {\n\t\t\t\t'state': 1,\n\t\t\t\t'rand': Math.random()\n\t\t\t},\n\t\t\t'title': 'State 1',\n\t\t\t'url': '?state=1'\n\t\t},\n\t\t// Two\n\t\t2: {\n\t\t\t'data': {\n\t\t\t\t'state': 2,\n\t\t\t\t'rand': Math.random()\n\t\t\t},\n\t\t\t'title': 'State 2',\n\t\t\t'url': '?state=2&asd=%20asd%2520asd'\n\t\t},\n\t\t// Three\n\t\t3: {\n\t\t\t'url': '?state=3'\n\t\t},\n\t\t// Four\n\t\t4: {\n\t\t\t'data': {\n\t\t\t\t'state': 4,\n\t\t\t\t'trick': true,\n\t\t\t\t'rand': Math.random()\n\t\t\t},\n\t\t\t'title': 'State 4',\n\t\t\t'url': '?state=3'\n\t\t},\n\t\t// Log\n\t\t5: {\n\t\t\t'url': '?state=1#log'\n\t\t},\n\t\t// Six\n\t\t6: {\n\t\t\t'data': {\n\t\t\t\t'state': 6,\n\t\t\t\t'rand': Math.random()\n\t\t\t},\n\t\t\t'url': 'six.html'\n\t\t},\n\t\t// Seven\n\t\t7: {\n\t\t\t'url': 'seven'\n\t\t},\n\t\t// Eight\n\t\t8: {\n\t\t\t'url': '/eight'\n\t\t}\n\t},\n\tstateOrder = [0,1,2,3,4,3,1,0,1,3,4,3,1,0,6,7,8,1,8,7,6,0],\n\tcurrentTest = 0;\n\n// Original Title\nvar title = document.title;\n\nvar banner;\n\nvar checkStatus = function(){\n\tbanner = banner || document.getElementById('qunit-banner');\n\tvar status = banner.className !== 'qunit-fail';\n\treturn status;\n};\n\n// Check State\nvar checkState = function(){\n\tif ( !checkStatus() ) {\n\t\tthrow new Error('A test has failed');\n\t}\n\n\tvar\n\t\tstateIndex = stateOrder[currentTest],\n\t\texpectedState = History.normalizeState(States[stateIndex]),\n\t\tactualState = History.getState(false);\n\n\t++currentTest;\n\n\tdocument.title = title+': '+actualState.url;\n\n\tvar\n\t\ttestName = 'Test '+currentTest,\n\t\tstateName = 'State '+stateIndex;\n\n\ttest(testName,function(){\n\t\tHistory.log('Completed: '+testName +' / '+ stateName);\n        deepEqual(actualState,expectedState,stateName);\n\t});\n\n\t// Image Load to Stress Test Safari and Opera\n\t(new Image()).src = \"image.php\";\n};\n\n// Check the Initial State\ncheckState();\n\n// State Change\nHistory.Adapter.bind(window,'statechange',checkState);\n\n// Log\nvar addLog = function(){\n\tvar args = arguments;\n\tHistory.queue(function(){\n\t\tHistory.log.apply(History,args);\n\t});\n};\n\n// Dom Load\nHistory.Adapter.onDomLoad(function(){\n\tsetTimeout(function(){\n\n\t// ----------------------------------------------------------------------\n\t// Test State Functionality: Adding\n\n\t// Test 2 / State 1 (0 -> 1)\n\t// Tests HTML4 -> HTML5 Graceful Upgrade\n\taddLog('Test 2',History.queues.length,History.busy.flag);\n\tHistory.setHash(History.getHashByState(States[1]));\n\n\t// Test 3 / State 2 (1 -> 2)\n\taddLog('Test 3',History.queues.length,History.busy.flag);\n\tHistory.pushState(States[2].data, States[2].title, States[2].url);\n\n\t// Test 3-2 / State 2 (2 -> 2) / No Change\n\taddLog('Test 3-2',History.queues.length,History.busy.flag);\n\tHistory.pushState(States[2].data, States[2].title, States[2].url);\n\n\t// Test 3-3 / State 2 (2 -> 2) / No Change\n\taddLog('Test 3-3',History.queues.length,History.busy.flag);\n\tHistory.replaceState(States[2].data, States[2].title, States[2].url);\n\n\t// Test 4 / State 3 (2 -> 3)\n\taddLog('Test 4',History.queues.length,History.busy.flag);\n\tHistory.replaceState(States[3].data, States[3].title, States[3].url);\n\n\t// Test 5 / State 4 (3 -> 4)\n\taddLog('Test 5',History.queues.length,History.busy.flag);\n\tHistory.pushState(States[4].data, States[4].title, States[4].url);\n\n\t// ----------------------------------------------------------------------\n\t// Test State Functionality: Traversing\n\n\t// Test 6 / State 3 (4 -> 3)\n\t// Test 7 / State 1 (3 -> 2 -> 1)\n\taddLog('Test 6,7',History.queues.length,History.busy.flag);\n\tHistory.go(-2);\n\n\t// Test 8 / State 0 (1 -> 0)\n\t// Tests Default State\n\taddLog('Test 8',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t// Test 9 / State 1 (0 -> 1)\n\t// Test 10 / State 3 (1 -> 2 -> 3)\n\taddLog('Test 9,10',History.queues.length,History.busy.flag);\n\tHistory.go(2);\n\n\t// Test 11 / State 4 (3 -> 4)\n\taddLog('Test 11',History.queues.length,History.busy.flag);\n\tHistory.forward();\n\n\t// Test 12 / State 3 (4 -> 3)\n\taddLog('Test 12',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t// Test 13 / State 1 (3 -> 2 -> 1)\n\taddLog('Test 13',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t// ----------------------------------------------------------------------\n\t// Test State Functionality: Traditional Anchors\n\n\t// Test 13-2 / State 1 (1 -> #log) / No Change\n\taddLog('Test 13-2',History.queues.length,History.busy.flag);\n\tHistory.setHash('log');\n\n\t// Test 13-3 / State 1 (#log -> 1) / No Change\n\taddLog('Test 13-3',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t// Test 14 / State 0 (1 -> 0)\n\taddLog('Test 14',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t// ----------------------------------------------------------------------\n\t// Test URL Handling: Adding\n\n\t// Test 15 / State 6 (1 -> 6)\n\t// Also tests data with no title\n\taddLog('Test 15',History.queues.length,History.busy.flag);\n\tHistory.pushState(States[6].data, States[6].title, States[6].url);\n\n\t// Test 16 / State 7 (6 -> 7)\n\taddLog('Test 16',History.queues.length,History.busy.flag);\n\tHistory.pushState(States[7].data, States[7].title, States[7].url);\n\n\t// Test 17 / State 7 (7 -> 8)\n\taddLog('Test 17',History.queues.length,History.busy.flag);\n\tHistory.pushState(States[8].data, States[8].title, States[8].url);\n\n\t// Test 18 / State 1 (8 -> 1)\n\t// Should be /eight?state=1\n\taddLog('Test 18',History.queues.length,History.busy.flag);\n\tHistory.pushState(States[1].data, States[1].title, States[1].url);\n\n\t// ----------------------------------------------------------------------\n\t// Test URL Handling: Traversing\n\n\t// Test 19 / State 8 (1 -> 8)\n\taddLog('Test 19',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t// Test 20 / State 7 (8 -> 7)\n\taddLog('Test 20',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t// Test 21 / State 6 (7 -> 6)\n\taddLog('Test 21',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t// Test 22 / State 0 (6 -> 0)\n\taddLog('Test 22',History.queues.length,History.busy.flag);\n\tHistory.back();\n\n\t},1000); // wait for test one to complete\n});\n\n})();\n"
  },
  {
    "path": "tests.src/_header.php",
    "content": "<?php\n\t# Locations\n\t$dir = dirname(__FILE__);\n\t$out = \"$dir/../tests\";\n\n\t# Base URL\n\t$base_url = '/';\n\t$tests_url = $base_url.'tests';\n\n\t# Data\n\t$browsers = array(\n\t\t'html4+html5',\n\t\t'html5'\n\t);\n\t$adapters = array(\n\t\t'jquery',\n\t\t'mootools',\n\t\t'native',\n\t\t'right',\n\t\t'zepto'\n\t);\n\n"
  },
  {
    "path": "tests.src/all.php",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\t<title>History.js Test Suite</title>\n\t<style type=\"text/css\">\n\t\tbody,html,iframe {\n\t\t\tpadding:0;\n\t\t\tmargin:0;\n\t\t\toutline:none;\n\t\t\tborder:none;\n\t\t}\n\t\t.browser {\n\t\t\tpadding-top:1em;\n\t\t}\n\t\t.adapter {\n\t\t\tpadding-top:1em;\n\t\t}\n\t</style>\n</head>\n<body>\n\t<h1>History.js Test Suite</h1>\n\t<p>HTML5 Browsers must pass the HTML4+HTML5 tests</p>\n\t<p>HTML4 Browsers must pass the HTML4 tests and should fail the HTML5 tests</p>\n\t<?php\n\tforeach ( $browsers as $browser ) :\n\t\techo '<div class=\"browser\">';\n\t\tforeach ( $adapters as $adapter ) :\n\t\t\techo '<div class=\"adapter\">';\n\t\t\t# Url\n\t\t\t$url = \"${browser}.${adapter}.html\";\n\n\t\t\t# Title\n\t\t\t$Browser = ucwords($browser);\n\t\t\t$Adapter = ucwords($adapter);\n\t\t\t$title = \"History.js ${Browser} ${Adapter} Test Suite\";\n\n\t\t\t# Render\n\t\t\t?><a href=\"<?=$url?>\"><?=$title?></a><?php\n\t\t\techo '</div>';\n\t\tendforeach;\n\t\techo '</div>';\n\tendforeach;\n\t?>\n</body>\n</html>\n"
  },
  {
    "path": "tests.src/each.php",
    "content": "<?php\n\t# Url\n\t$url = \"${browser}.${adapter}.html\";\n\n\t# Titles\n\t$Browser = strtoupper($browser);\n\t$Adapter = ucwords($adapter);\n\t$title = \"History.js ${Browser} ${Adapter} Test Suite\";\n?><!DOCTYPE html>\n<html debug=\"true\">\n<head>\n\t<meta http-equiv=\"Expires\" CONTENT=\"Mon, 06 Jan 1990 00:00:01 GMT\" />\n\t<meta http-equiv=\"PRAGMA\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\" />\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n\t<title><?=$title?></title>\n\n\t<!-- Check -->\n\t<script>\n\t\tvar href = window.document.location.href,\n\t\t\ttest_url = href.replace(/(history\\.js\\/tests\\/[^\\/\\?\\#]+).*/,'$1');\n\t\tif ( test_url !== href ) {\n\t\t\twindow.document.location.href = test_url;\n\t\t}\n\t</script>\n\n\t<!-- Framework -->\n\t<script src=\"../vendor/<?=$adapter?>.js\"></script>\n\n\t<!-- QUnit -->\n\t<link rel=\"stylesheet\" href=\"../vendor/qunit/qunit/qunit.css\" type=\"text/css\" media=\"screen\">\n\t<script src=\"../vendor/qunit/qunit/qunit.js\"></script>\n</head>\n<body>\n\t<!-- Elements -->\n\t<h1 id=\"qunit-header\"><?=$title?></h1>\n\t<h2 id=\"qunit-banner\"></h2>\n\t<div id=\"qunit-testrunner-toolbar\"></div>\n\t<h2 id=\"qunit-userAgent\"></h2>\n\t<ol id=\"qunit-tests\"></ol>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<button onclick=\"history.back()\">back</button><button onclick=\"history.forward()\">forward</button>\n\t<textarea id=\"log\" style=\"width:100%;height:400px\"></textarea>\n\n\t<!-- History.js -->\n\t<script src=\"../scripts/bundled/<?=$browser?>/<?=$adapter?>.history.js\"></script>\n\n\t<!-- Tests -->\n\t<script src=\"tests.js\"></script>\n</body>\n</html>"
  },
  {
    "path": "tests.src/index.php",
    "content": "<?php\n\t# Header\n\trequire_once(dirname(__FILE__).'/_header.php');\n\n\t# Index\n\tob_start();\n\trequire($dir.'/all.php');\n\t$contents = ob_get_contents();\n\tob_end_clean();\n\tfile_put_contents($out.'/index.html', $contents);\n\n\t# Each\n\tforeach ( $browsers as $browser )\n\tforeach ( $adapters as $adapter ) {\n\t\tob_start();\n\t\trequire($dir.'/each.php');\n\t\t$contents = ob_get_contents();\n\t\tob_end_clean();\n\t\tfile_put_contents($out.\"/${url}\", $contents);\n\t}\n\n\t# Done\n?><html><body><a href=\"../tests\">Tests</a></body></html>\n"
  },
  {
    "path": "vendor/dojo.js",
    "content": "/*\n\tCopyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.\n\tAvailable via Academic Free License >= 2.1 OR the modified BSD license.\n\tsee: http://dojotoolkit.org/license for details\n*/\n\n/*\n\tThis is an optimized version of Dojo, built for deployment and not for\n\tdevelopment. To get sources and documentation, please visit:\n\n\t\thttp://dojotoolkit.org\n*/\n\n(function(\n\tuserConfig,\n\tdefaultConfig\n){\n\t// summary:\n\t//\t\tThis is the \"source loader\" and is the entry point for Dojo during development. You may also load Dojo with\n\t//\t\tany AMD-compliant loader via the package main module dojo/main.\n\t// description:\n\t//\t\tThis is the \"source loader\" for Dojo. It provides an AMD-compliant loader that can be configured\n\t//\t\tto operate in either synchronous or asynchronous modes. After the loader is defined, dojo is loaded\n\t//\t\tIAW the package main module dojo/main. In the event you wish to use a foreign loader, you may load dojo as a package\n\t//\t\tvia the package main module dojo/main and this loader is not required; see dojo/package.json for details.\n\t//\n\t//\t\tIn order to keep compatibility with the v1.x line, this loader includes additional machinery that enables\n\t//\t\tthe dojo.provide, dojo.require et al API. This machinery is loaded by default, but may be dynamically removed\n\t//\t\tvia the has.js API and statically removed via the build system.\n\t//\n\t//\t\tThis loader includes sniffing machinery to determine the environment; the following environments are supported:\n\t//\n\t//\t\t- browser\n\t//\t\t- node.js\n\t//\t\t- rhino\n\t//\n\t//\t\tThis is the so-called \"source loader\". As such, it includes many optional features that may be discadred by\n\t//\t\tbuilding a customized verion with the build system.\n\n\t// Design and Implementation Notes\n\t//\n\t// This is a dojo-specific adaption of bdLoad, donated to the dojo foundation by Altoviso LLC.\n\t//\n\t// This function defines an AMD-compliant (http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition)\n\t// loader that can be configured to operate in either synchronous or asynchronous modes.\n\t//\n\t// Since this machinery implements a loader, it does not have the luxury of using a load system and/or\n\t// leveraging a utility library. This results in an unpleasantly long file; here is a road map of the contents:\n\t//\n\t//\t 1. Small library for use implementing the loader.\n\t//\t 2. Define the has.js API; this is used throughout the loader to bracket features.\n\t//\t 3. Define the node.js and rhino sniffs and sniff.\n\t//\t 4. Define the loader's data.\n\t//\t 5. Define the configuration machinery.\n\t//\t 6. Define the script element sniffing machinery and sniff for configuration data.\n\t//\t 7. Configure the loader IAW the provided user, default, and sniffing data.\n\t//\t 8. Define the global require function.\n\t//\t 9. Define the module resolution machinery.\n\t//\t10. Define the module and plugin module definition machinery\n\t//\t11. Define the script injection machinery.\n\t//\t12. Define the window load detection.\n\t//\t13. Define the logging API.\n\t//\t14. Define the tracing API.\n\t//\t16. Define the AMD define function.\n\t//\t17. Define the dojo v1.x provide/require machinery--so called \"legacy\" modes.\n\t//\t18. Publish global variables.\n\t//\n\t// Language and Acronyms and Idioms\n\t//\n\t// moduleId: a CJS module identifier, (used for public APIs)\n\t// mid: moduleId (used internally)\n\t// packageId: a package identifier (used for public APIs)\n\t// pid: packageId (used internally); the implied system or default package has pid===\"\"\n\t// pack: package is used internally to reference a package object (since javascript has reserved words including \"package\")\n\t// prid: plugin resource identifier\n\t// The integer constant 1 is used in place of true and 0 in place of false.\n\n\t// define a minimal library to help build the loader\n\tvar\tnoop = function(){\n\t\t},\n\n\t\tisEmpty = function(it){\n\t\t\tfor(var p in it){\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn 1;\n\t\t},\n\n\t\ttoString = {}.toString,\n\n\t\tisFunction = function(it){\n\t\t\treturn toString.call(it) == \"[object Function]\";\n\t\t},\n\n\t\tisString = function(it){\n\t\t\treturn toString.call(it) == \"[object String]\";\n\t\t},\n\n\t\tisArray = function(it){\n\t\t\treturn toString.call(it) == \"[object Array]\";\n\t\t},\n\n\t\tforEach = function(vector, callback){\n\t\t\tif(vector){\n\t\t\t\tfor(var i = 0; i < vector.length;){\n\t\t\t\t\tcallback(vector[i++]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tmix = function(dest, src){\n\t\t\tfor(var p in src){\n\t\t\t\tdest[p] = src[p];\n\t\t\t}\n\t\t\treturn dest;\n\t\t},\n\n\t\tmakeError = function(error, info){\n\t\t\treturn mix(new Error(error), {src:\"dojoLoader\", info:info});\n\t\t},\n\n\t\tuidSeed = 1,\n\n\t\tuid = function(){\n\t\t\t// Returns a unique indentifier (within the lifetime of the document) of the form /_d+/.\n\t\t\treturn \"_\" + uidSeed++;\n\t\t},\n\n\t\t// FIXME: how to doc window.require() api\n\n\t\t// this will be the global require function; define it immediately so we can start hanging things off of it\n\t\treq = function(\n\t\t\tconfig,\t\t  //(object, optional) hash of configuration properties\n\t\t\tdependencies, //(array of commonjs.moduleId, optional) list of modules to be loaded before applying callback\n\t\t\tcallback\t  //(function, optional) lamda expression to apply to module values implied by dependencies\n\t\t){\n\t\t\treturn contextRequire(config, dependencies, callback, 0, req);\n\t\t},\n\n\t\t// the loader uses the has.js API to control feature inclusion/exclusion; define then use throughout\n\t\tglobal = this,\n\n\t\tdoc = global.document,\n\n\t\telement = doc && doc.createElement(\"DiV\"),\n\n\t\thas = req.has = function(name){\n\t\t\treturn isFunction(hasCache[name]) ? (hasCache[name] = hasCache[name](global, doc, element)) : hasCache[name];\n\t\t},\n\n\t\thasCache = has.cache = defaultConfig.hasCache;\n\n\thas.add = function(name, test, now, force){\n\t\t(hasCache[name]===undefined || force) && (hasCache[name] = test);\n\t\treturn now && has(name);\n\t};\n\n\t 0 && has.add(\"host-node\", userConfig.has && \"host-node\" in userConfig.has ?\n\t\tuserConfig.has[\"host-node\"] :\n\t\t(typeof process == \"object\" && process.versions && process.versions.node && process.versions.v8));\n\tif( 0 ){\n\t\t// fixup the default config for node.js environment\n\t\trequire(\"./_base/configNode.js\").config(defaultConfig);\n\t\t// remember node's require (with respect to baseUrl==dojo's root)\n\t\tdefaultConfig.loaderPatch.nodeRequire = require;\n\t}\n\n\t 0 && has.add(\"host-rhino\", userConfig.has && \"host-rhino\" in userConfig.has ?\n\t\tuserConfig.has[\"host-rhino\"] :\n\t\t(typeof load == \"function\" && (typeof Packages == \"function\" || typeof Packages == \"object\")));\n\tif( 0 ){\n\t\t// owing to rhino's lame feature that hides the source of the script, give the user a way to specify the baseUrl...\n\t\tfor(var baseUrl = userConfig.baseUrl || \".\", arg, rhinoArgs = this.arguments, i = 0; i < rhinoArgs.length;){\n\t\t\targ = (rhinoArgs[i++] + \"\").split(\"=\");\n\t\t\tif(arg[0] == \"baseUrl\"){\n\t\t\t\tbaseUrl = arg[1];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tload(baseUrl + \"/_base/configRhino.js\");\n\t\trhinoDojoConfig(defaultConfig, baseUrl, rhinoArgs);\n\t}\n\n\t// userConfig has tests override defaultConfig has tests; do this after the environment detection because\n\t// the environment detection usually sets some has feature values in the hasCache.\n\tfor(var p in userConfig.has){\n\t\thas.add(p, userConfig.has[p], 0, 1);\n\t}\n\n\t//\n\t// define the loader data\n\t//\n\n\t// the loader will use these like symbols if the loader has the traceApi; otherwise\n\t// define magic numbers so that modules can be provided as part of defaultConfig\n\tvar\trequested = 1,\n\t\tarrived = 2,\n\t\tnonmodule = 3,\n\t\texecuting = 4,\n\t\texecuted = 5;\n\n\tif( 0 ){\n\t\t// these make debugging nice; but using strings for symbols is a gross rookie error; don't do it for production code\n\t\trequested = \"requested\";\n\t\tarrived = \"arrived\";\n\t\tnonmodule = \"not-a-module\";\n\t\texecuting = \"executing\";\n\t\texecuted = \"executed\";\n\t}\n\n\tvar legacyMode = 0,\n\t\tsync = \"sync\",\n\t\txd = \"xd\",\n\t\tsyncExecStack = [],\n\t\tdojoRequirePlugin = 0,\n\t\tcheckDojoRequirePlugin = noop,\n\t\ttransformToAmd = noop,\n\t\tgetXhr;\n\tif( 1 ){\n\t\treq.isXdUrl = noop;\n\n\t\treq.initSyncLoader = function(dojoRequirePlugin_, checkDojoRequirePlugin_, transformToAmd_){\n\t\t\t// the first dojo/_base/loader loaded gets to define these variables; they are designed to work\n\t\t\t// in the presense of zero to many mapped dojo/_base/loaders\n\t\t\tif(!dojoRequirePlugin){\n\t\t\t\tdojoRequirePlugin = dojoRequirePlugin_;\n\t\t\t\tcheckDojoRequirePlugin = checkDojoRequirePlugin_;\n\t\t\t\ttransformToAmd = transformToAmd_;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsync:sync,\n\t\t\t\trequested:requested,\n\t\t\t\tarrived:arrived,\n\t\t\t\tnonmodule:nonmodule,\n\t\t\t\texecuting:executing,\n\t\t\t\texecuted:executed,\n\t\t\t\tsyncExecStack:syncExecStack,\n\t\t\t\tmodules:modules,\n\t\t\t\texecQ:execQ,\n\t\t\t\tgetModule:getModule,\n\t\t\t\tinjectModule:injectModule,\n\t\t\t\tsetArrived:setArrived,\n\t\t\t\tsignal:signal,\n\t\t\t\tfinishExec:finishExec,\n\t\t\t\texecModule:execModule,\n\t\t\t\tdojoRequirePlugin:dojoRequirePlugin,\n\t\t\t\tgetLegacyMode:function(){return legacyMode;},\n\t\t\t\tguardCheckComplete:guardCheckComplete\n\t\t\t};\n\t\t};\n\n\t\tif( 1 ){\n\t\t\t// in legacy sync mode, the loader needs a minimal XHR library\n\n\t\t\tvar locationProtocol = location.protocol,\n\t\t\t\tlocationHost = location.host;\n\t\t\treq.isXdUrl = function(url){\n\t\t\t\tif(/^\\./.test(url)){\n\t\t\t\t\t// begins with a dot is always relative to page URL; therefore not xdomain\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif(/^\\/\\//.test(url)){\n\t\t\t\t\t// for v1.6- backcompat, url starting with // indicates xdomain\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// get protocol and host\n\t\t\t\t// \\/+ takes care of the typical file protocol that looks like file:///drive/path/to/file\n\t\t\t\t// locationHost is falsy if file protocol => if locationProtocol matches and is \"file:\", || will return false\n\t\t\t\tvar match = url.match(/^([^\\/\\:]+\\:)\\/+([^\\/]+)/);\n\t\t\t\treturn match && (match[1] != locationProtocol || (locationHost && match[2] != locationHost));\n\t\t\t};\n\n\n\t\t\t// note: to get the file:// protocol to work in FF, you must set security.fileuri.strict_origin_policy to false in about:config\n\t\t\t 1 || has.add(\"dojo-xhr-factory\", 1);\n\t\t\thas.add(\"dojo-force-activex-xhr\",  1  && !doc.addEventListener && window.location.protocol == \"file:\");\n\t\t\thas.add(\"native-xhr\", typeof XMLHttpRequest != \"undefined\");\n\t\t\tif(has(\"native-xhr\") && !has(\"dojo-force-activex-xhr\")){\n\t\t\t\tgetXhr = function(){\n\t\t\t\t\treturn new XMLHttpRequest();\n\t\t\t\t};\n\t\t\t}else{\n\t\t\t\t// if in the browser an old IE; find an xhr\n\t\t\t\tfor(var XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'], progid, i = 0; i < 3;){\n\t\t\t\t\ttry{\n\t\t\t\t\t\tprogid = XMLHTTP_PROGIDS[i++];\n\t\t\t\t\t\tif(new ActiveXObject(progid)){\n\t\t\t\t\t\t\t// this progid works; therefore, use it from now on\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}catch(e){\n\t\t\t\t\t\t// squelch; we're just trying to find a good ActiveX progid\n\t\t\t\t\t\t// if they all fail, then progid ends up as the last attempt and that will signal the error\n\t\t\t\t\t\t// the first time the client actually tries to exec an xhr\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgetXhr = function(){\n\t\t\t\t\treturn new ActiveXObject(progid);\n\t\t\t\t};\n\t\t\t}\n\t\t\treq.getXhr = getXhr;\n\n\t\t\thas.add(\"dojo-gettext-api\", 1);\n\t\t\treq.getText = function(url, async, onLoad){\n\t\t\t\tvar xhr = getXhr();\n\t\t\t\txhr.open('GET', fixupUrl(url), false);\n\t\t\t\txhr.send(null);\n\t\t\t\tif(xhr.status == 200 || (!location.host && !xhr.status)){\n\t\t\t\t\tif(onLoad){\n\t\t\t\t\t\tonLoad(xhr.responseText, async);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tthrow makeError(\"xhrFailed\", xhr.status);\n\t\t\t\t}\n\t\t\t\treturn xhr.responseText;\n\t\t\t};\n\t\t}\n\t}else{\n\t\treq.async = 1;\n\t}\n\n\t//\n\t// loader eval\n\t//\n\tvar eval_ =\n\t\t// use the function constructor so our eval is scoped close to (but not in) in the global space with minimal pollution\n\t\tnew Function('return eval(arguments[0]);');\n\n\treq.eval =\n\t\tfunction(text, hint){\n\t\t\treturn eval_(text + \"\\r\\n////@ sourceURL=\" + hint);\n\t\t};\n\n\t//\n\t// loader micro events API\n\t//\n\tvar listenerQueues = {},\n\t\terror = \"error\",\n\t\tsignal = req.signal = function(type, args){\n\t\t\tvar queue = listenerQueues[type];\n\t\t\t// notice we run a copy of the queue; this allows listeners to add/remove\n\t\t\t// other listeners without affecting this particular signal\n\t\t\tforEach(queue && queue.slice(0), function(listener){\n\t\t\t\tlistener.apply(null, isArray(args) ? args : [args]);\n\t\t\t});\n\t\t},\n\t\ton = req.on = function(type, listener){\n\t\t\t// notice a queue is not created until a client actually connects\n\t\t\tvar queue = listenerQueues[type] || (listenerQueues[type] = []);\n\t\t\tqueue.push(listener);\n\t\t\treturn {\n\t\t\t\tremove:function(){\n\t\t\t\t\tfor(var i = 0; i<queue.length; i++){\n\t\t\t\t\t\tif(queue[i]===listener){\n\t\t\t\t\t\t\tqueue.splice(i, 1);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t};\n\n\t// configuration machinery; with an optimized/built defaultConfig, all configuration machinery can be discarded\n\t// lexical variables hold key loader data structures to help with minification; these may be completely,\n\t// one-time initialized by defaultConfig for optimized/built versions\n\tvar\n\t\taliases\n\t\t\t// a vector of pairs of [regexs or string, replacement] => (alias, actual)\n\t\t\t= [],\n\n\t\tpaths\n\t\t\t// CommonJS paths\n\t\t\t= {},\n\n\t\tpathsMapProg\n\t\t\t// list of (from-path, to-path, regex, length) derived from paths;\n\t\t\t// a \"program\" to apply paths; see computeMapProg\n\t\t\t= [],\n\n\t\tpacks\n\t\t\t// a map from packageId to package configuration object; see fixupPackageInfo\n\t\t\t= {},\n\n\t\tmap = req.map\n\t\t\t// AMD map config variable; dojo/_base/kernel needs req.map to figure out the scope map\n\t\t\t= {},\n\n\t\tmapProgs\n\t\t\t// vector of quads as described by computeMapProg; map-key is AMD map key, map-value is AMD map value\n\t\t\t= [],\n\n\t\tmodules\n\t\t\t// A hash:(mid) --> (module-object) the module namespace\n\t\t\t//\n\t\t\t// pid: the package identifier to which the module belongs (e.g., \"dojo\"); \"\" indicates the system or default package\n\t\t\t// mid: the fully-resolved (i.e., mappings have been applied) module identifier without the package identifier (e.g., \"dojo/io/script\")\n\t\t\t// url: the URL from which the module was retrieved\n\t\t\t// pack: the package object of the package to which the module belongs\n\t\t\t// executed: 0 => not executed; executing => in the process of tranversing deps and running factory; executed => factory has been executed\n\t\t\t// deps: the dependency vector for this module (vector of modules objects)\n\t\t\t// def: the factory for this module\n\t\t\t// result: the result of the running the factory for this module\n\t\t\t// injected: (0 | requested | arrived) the status of the module; nonmodule means the resource did not call define\n\t\t\t// load: plugin load function; applicable only for plugins\n\t\t\t//\n\t\t\t// Modules go through several phases in creation:\n\t\t\t//\n\t\t\t// 1. Requested: some other module's definition or a require application contained the requested module in\n\t\t\t//\t  its dependency vector or executing code explicitly demands a module via req.require.\n\t\t\t//\n\t\t\t// 2. Injected: a script element has been appended to the insert-point element demanding the resource implied by the URL\n\t\t\t//\n\t\t\t// 3. Loaded: the resource injected in [2] has been evalated.\n\t\t\t//\n\t\t\t// 4. Defined: the resource contained a define statement that advised the loader about the module. Notice that some\n\t\t\t//\t  resources may just contain a bundle of code and never formally define a module via define\n\t\t\t//\n\t\t\t// 5. Evaluated: the module was defined via define and the loader has evaluated the factory and computed a result.\n\t\t\t= {},\n\n\t\tcacheBust\n\t\t\t// query string to append to module URLs to bust browser cache\n\t\t\t= \"\",\n\n\t\tcache\n\t\t\t// hash:(mid | url)-->(function | string)\n\t\t\t//\n\t\t\t// A cache of resources. The resources arrive via a config.cache object, which is a hash from either mid --> function or\n\t\t\t// url --> string. The url key is distinguished from the mid key by always containing the prefix \"url:\". url keys as provided\n\t\t\t// by config.cache always have a string value that represents the contents of the resource at the given url. mid keys as provided\n\t\t\t// by configl.cache always have a function value that causes the same code to execute as if the module was script injected.\n\t\t\t//\n\t\t\t// Both kinds of key-value pairs are entered into cache via the function consumePendingCache, which may relocate keys as given\n\t\t\t// by any mappings *iff* the config.cache was received as part of a module resource request.\n\t\t\t//\n\t\t\t// Further, for mid keys, the implied url is computed and the value is entered into that key as well. This allows mapped modules\n\t\t\t// to retrieve cached items that may have arrived consequent to another namespace.\n\t\t\t//\n\t\t\t = {},\n\n\t\turlKeyPrefix\n\t\t\t// the prefix to prepend to a URL key in the cache.\n\t\t\t= \"url:\",\n\n\t\tpendingCacheInsert\n\t\t\t// hash:(mid)-->(function)\n\t\t\t//\n\t\t\t// Gives a set of cache modules pending entry into cache. When cached modules are published to the loader, they are\n\t\t\t// entered into pendingCacheInsert; modules are then pressed into cache upon (1) AMD define or (2) upon receiving another\n\t\t\t// independent set of cached modules. (1) is the usual case, and this case allows normalizing mids given in the pending\n\t\t\t// cache for the local configuration, possibly relocating modules.\n\t\t\t = {},\n\n\t\tdojoSniffConfig\n\t\t\t// map of configuration variables\n\t\t\t// give the data-dojo-config as sniffed from the document (if any)\n\t\t\t= {};\n\n\tif( 1 ){\n\t\tvar consumePendingCacheInsert = function(referenceModule){\n\t\t\t\tvar p, item, match, now, m;\n\t\t\t\tfor(p in pendingCacheInsert){\n\t\t\t\t\titem = pendingCacheInsert[p];\n\t\t\t\t\tmatch = p.match(/^url\\:(.+)/);\n\t\t\t\t\tif(match){\n\t\t\t\t\t\tcache[urlKeyPrefix + toUrl(match[1], referenceModule)] =  item;\n\t\t\t\t\t}else if(p==\"*now\"){\n\t\t\t\t\t\tnow = item;\n\t\t\t\t\t}else if(p!=\"*noref\"){\n\t\t\t\t\t\tm = getModuleInfo(p, referenceModule);\n\t\t\t\t\t\tcache[m.mid] = cache[urlKeyPrefix + m.url] = item;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(now){\n\t\t\t\t\tnow(createRequire(referenceModule));\n\t\t\t\t}\n\t\t\t\tpendingCacheInsert = {};\n\t\t\t},\n\n\t\t\tescapeString = function(s){\n\t\t\t\treturn s.replace(/([\\.$?*|{}\\(\\)\\[\\]\\\\\\/\\+^])/g, function(c){ return \"\\\\\" + c; });\n\t\t\t},\n\n\t\t\tcomputeMapProg = function(map, dest){\n\t\t\t\t// This routine takes a map as represented by a JavaScript object and initializes dest, a vector of\n\t\t\t\t// quads of (map-key, map-value, refex-for-map-key, length-of-map-key), sorted decreasing by length-\n\t\t\t\t// of-map-key. The regex looks for the map-key followed by either \"/\" or end-of-string at the beginning\n\t\t\t\t// of a the search source. Notice the map-value is irrelevent to the algorithm\n\t\t\t\tdest.splice(0, dest.length);\n\t\t\t\tfor(var p in map){\n\t\t\t\t\tdest.push([\n\t\t\t\t\t\tp,\n\t\t\t\t\t\tmap[p],\n\t\t\t\t\t\tnew RegExp(\"^\" + escapeString(p) + \"(\\/|$)\"),\n\t\t\t\t\t\tp.length]);\n\t\t\t\t}\n\t\t\t\tdest.sort(function(lhs, rhs){ return rhs[3] - lhs[3]; });\n\t\t\t\treturn dest;\n\t\t\t},\n\n\t\t\tfixupPackageInfo = function(packageInfo){\n\t\t\t\t// calculate the precise (name, location, main, mappings) for a package\n\t\t\t\tvar name = packageInfo.name;\n\t\t\t\tif(!name){\n\t\t\t\t\t// packageInfo must be a string that gives the name\n\t\t\t\t\tname = packageInfo;\n\t\t\t\t\tpackageInfo = {name:name};\n\t\t\t\t}\n\t\t\t\tpackageInfo = mix({main:\"main\"}, packageInfo);\n\t\t\t\tpackageInfo.location = packageInfo.location ? packageInfo.location : name;\n\n\t\t\t\t// packageMap is depricated in favor of AMD map\n\t\t\t\tif(packageInfo.packageMap){\n\t\t\t\t\tmap[name] = packageInfo.packageMap;\n\t\t\t\t}\n\n\t\t\t\tif(!packageInfo.main.indexOf(\"./\")){\n\t\t\t\t\tpackageInfo.main = packageInfo.main.substring(2);\n\t\t\t\t}\n\n\t\t\t\t// now that we've got a fully-resolved package object, push it into the configuration\n\t\t\t\tpacks[name] = packageInfo;\n\t\t\t},\n\n\t\t\tdelayedModuleConfig\n\t\t\t\t// module config cannot be consummed until the loader is completely initialized; therefore, all\n\t\t\t\t// module config detected during booting is memorized and applied at the end of loader initialization\n\t\t\t\t// TODO: this is a bit of a kludge; all config should be moved to end of loader initialization, but\n\t\t\t\t// we'll delay this chore and do it with a final loader 1.x cleanup after the 2.x loader prototyping is complete\n\t\t\t\t= [],\n\n\n\t\t\tconfig = function(config, booting, referenceModule){\n\t\t\t\tfor(var p in config){\n\t\t\t\t\tif(p==\"waitSeconds\"){\n\t\t\t\t\t\treq.waitms = (config[p] || 0) * 1000;\n\t\t\t\t\t}\n\t\t\t\t\tif(p==\"cacheBust\"){\n\t\t\t\t\t\tcacheBust = config[p] ? (isString(config[p]) ? config[p] : (new Date()).getTime() + \"\") : \"\";\n\t\t\t\t\t}\n\t\t\t\t\tif(p==\"baseUrl\" || p==\"combo\"){\n\t\t\t\t\t\treq[p] = config[p];\n\t\t\t\t\t}\n\t\t\t\t\tif( 1  && p==\"async\"){\n\t\t\t\t\t\t// falsy or \"sync\" => legacy sync loader\n\t\t\t\t\t\t// \"xd\" => sync but loading xdomain tree and therefore loading asynchronously (not configurable, set automatically by the loader)\n\t\t\t\t\t\t// \"legacyAsync\" => permanently in \"xd\" by choice\n\t\t\t\t\t\t// \"debugAtAllCosts\" => trying to load everything via script injection (not implemented)\n\t\t\t\t\t\t// otherwise, must be truthy => AMD\n\t\t\t\t\t\t// legacyMode: sync | legacyAsync | xd | false\n\t\t\t\t\t\tvar mode = config[p];\n\t\t\t\t\t\treq.legacyMode = legacyMode = (isString(mode) && /sync|legacyAsync/.test(mode) ? mode : (!mode ? sync : false));\n\t\t\t\t\t\treq.async = !legacyMode;\n\t\t\t\t\t}\n\t\t\t\t\tif(config[p]!==hasCache){\n\t\t\t\t\t\t// accumulate raw config info for client apps which can use this to pass their own config\n\t\t\t\t\t\treq.rawConfig[p] = config[p];\n\t\t\t\t\t\tp!=\"has\" && has.add(\"config-\"+p, config[p], 0, booting);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// make sure baseUrl exists\n\t\t\t\tif(!req.baseUrl){\n\t\t\t\t\treq.baseUrl = \"./\";\n\t\t\t\t}\n\t\t\t\t// make sure baseUrl ends with a slash\n\t\t\t\tif(!/\\/$/.test(req.baseUrl)){\n\t\t\t\t\treq.baseUrl += \"/\";\n\t\t\t\t}\n\n\t\t\t\t// now do the special work for has, packages, packagePaths, paths, aliases, and cache\n\n\t\t\t\tfor(p in config.has){\n\t\t\t\t\thas.add(p, config.has[p], 0, booting);\n\t\t\t\t}\n\n\t\t\t\t// for each package found in any packages config item, augment the packs map owned by the loader\n\t\t\t\tforEach(config.packages, fixupPackageInfo);\n\n\t\t\t\t// for each packagePath found in any packagePaths config item, augment the packageConfig\n\t\t\t\t// packagePaths is depricated; remove in 2.0\n\t\t\t\tfor(baseUrl in config.packagePaths){\n\t\t\t\t\tforEach(config.packagePaths[baseUrl], function(packageInfo){\n\t\t\t\t\t\tvar location = baseUrl + \"/\" + packageInfo;\n\t\t\t\t\t\tif(isString(packageInfo)){\n\t\t\t\t\t\t\tpackageInfo = {name:packageInfo};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpackageInfo.location = location;\n\t\t\t\t\t\tfixupPackageInfo(packageInfo);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// notice that computeMapProg treats the dest as a reference; therefore, if/when that variable\n\t\t\t\t// is published (see dojo-publish-privates), the published variable will always hold a valid value.\n\n\t\t\t\t// this must come after all package processing since package processing may mutate map\n\t\t\t\tcomputeMapProg(mix(map, config.map), mapProgs);\n\t\t\t\tforEach(mapProgs, function(item){\n\t\t\t\t\titem[1] = computeMapProg(item[1], []);\n\t\t\t\t\tif(item[0]==\"*\"){\n\t\t\t\t\t\tmapProgs.star = item[1];\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// push in any paths and recompute the internal pathmap\n\t\t\t\tcomputeMapProg(mix(paths, config.paths), pathsMapProg);\n\n\t\t\t\t// aliases\n\t\t\t\tforEach(config.aliases, function(pair){\n\t\t\t\t\tif(isString(pair[0])){\n\t\t\t\t\t\tpair[0] = new RegExp(\"^\" + escapeString(pair[0]) + \"$\");\n\t\t\t\t\t}\n\t\t\t\t\taliases.push(pair);\n\t\t\t\t});\n\n\t\t\t\tif(booting){\n\t\t\t\t\tdelayedModuleConfig.push({config:config.config});\n\t\t\t\t}else{\n\t\t\t\t\tfor(p in config.config){\n\t\t\t\t\t\tvar module = getModule(p, referenceModule);\n\t\t\t\t\t\tmodule.config = mix(module.config || {}, config.config[p]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// push in any new cache values\n\t\t\t\tif(config.cache){\n\t\t\t\t\tconsumePendingCacheInsert();\n\t\t\t\t\tpendingCacheInsert = config.cache;\n\t\t\t\t\tif(config.cache[\"*noref\"]){\n\t\t\t\t\t\tconsumePendingCacheInsert();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tsignal(\"config\", [config, req.rawConfig]);\n\t\t\t};\n\n\t\t//\n\t\t// execute the various sniffs; userConfig can override and value\n\t\t//\n\n\t\tif(has(\"dojo-cdn\") ||  1 ){\n\t\t\t// the sniff regex looks for a src attribute ending in dojo.js, optionally preceeded with a path.\n\t\t\t// match[3] returns the path to dojo.js (if any) without the trailing slash. This is used for the\n\t\t\t// dojo location on CDN deployments and baseUrl when either/both of these are not provided\n\t\t\t// explicitly in the config data; this is the 1.6- behavior.\n\n\t\t\tvar scripts = doc.getElementsByTagName(\"script\"),\n\t\t\t\ti = 0,\n\t\t\t\tscript, dojoDir, src, match;\n\t\t\twhile(i < scripts.length){\n\t\t\t\tscript = scripts[i++];\n\t\t\t\tif((src = script.getAttribute(\"src\")) && (match = src.match(/(((.*)\\/)|^)dojo\\.js(\\W|$)/i))){\n\t\t\t\t\t// sniff dojoDir and baseUrl\n\t\t\t\t\tdojoDir = match[3] || \"\";\n\t\t\t\t\tdefaultConfig.baseUrl = defaultConfig.baseUrl || dojoDir;\n\n\t\t\t\t\t// sniff configuration on attribute in script element\n\t\t\t\t\tsrc = (script.getAttribute(\"data-dojo-config\") || script.getAttribute(\"djConfig\"));\n\t\t\t\t\tif(src){\n\t\t\t\t\t\tdojoSniffConfig = req.eval(\"({ \" + src + \" })\", \"data-dojo-config\");\n\t\t\t\t\t}\n\n\t\t\t\t\t// sniff requirejs attribute\n\t\t\t\t\tif( 0 ){\n\t\t\t\t\t\tvar dataMain = script.getAttribute(\"data-main\");\n\t\t\t\t\t\tif(dataMain){\n\t\t\t\t\t\t\tdojoSniffConfig.deps = dojoSniffConfig.deps || [dataMain];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif( 0 ){\n\t\t\t// pass down doh.testConfig from parent as if it were a data-dojo-config\n\t\t\ttry{\n\t\t\t\tif(window.parent != window && window.parent.require){\n\t\t\t\t\tvar doh = window.parent.require(\"doh\");\n\t\t\t\t\tdoh && mix(dojoSniffConfig, doh.testConfig);\n\t\t\t\t}\n\t\t\t}catch(e){}\n\t\t}\n\n\t\t// configure the loader; let the user override defaults\n\t\treq.rawConfig = {};\n\t\tconfig(defaultConfig, 1);\n\n\t\t// do this before setting userConfig/sniffConfig to allow userConfig/sniff overrides\n\t\tif(has(\"dojo-cdn\")){\n\t\t\tpacks.dojo.location = dojoDir;\n\t\t\tif(dojoDir){\n\t\t\t\tdojoDir += \"/\";\n\t\t\t}\n\t\t\tpacks.dijit.location = dojoDir + \"../dijit/\";\n\t\t\tpacks.dojox.location = dojoDir + \"../dojox/\";\n\t\t}\n\n\t\tconfig(userConfig, 1);\n\t\tconfig(dojoSniffConfig, 1);\n\n\t}else{\n\t\t// no config API, assume defaultConfig has everything the loader needs...for the entire lifetime of the application\n\t\tpaths = defaultConfig.paths;\n\t\tpathsMapProg = defaultConfig.pathsMapProg;\n\t\tpacks = defaultConfig.packs;\n\t\taliases = defaultConfig.aliases;\n\t\tmapProgs = defaultConfig.mapProgs;\n\t\tmodules = defaultConfig.modules;\n\t\tcache = defaultConfig.cache;\n\t\tcacheBust = defaultConfig.cacheBust;\n\n\t\t// remember the default config for other processes (e.g., dojo/config)\n\t\treq.rawConfig = defaultConfig;\n\t}\n\n\n\tif( 0 ){\n\t\treq.combo = req.combo || {add:noop};\n\t\tvar\tcomboPending = 0,\n\t\t\tcombosPending = [],\n\t\t\tcomboPendingTimer = null;\n\t}\n\n\n\t// build the loader machinery iaw configuration, including has feature tests\n\tvar\tinjectDependencies = function(module){\n\t\t\t// checkComplete!=0 holds the idle signal; we're not idle if we're injecting dependencies\n\t\t\tguardCheckComplete(function(){\n\t\t\t\tforEach(module.deps, injectModule);\n\t\t\t\tif( 0  && comboPending && !comboPendingTimer){\n\t\t\t\t\tcomboPendingTimer = setTimeout(function() {\n\t\t\t\t\t\tcomboPending = 0;\n\t\t\t\t\t\tcomboPendingTimer = null;\n\t\t\t\t\t\treq.combo.done(function(mids, url) {\n\t\t\t\t\t\t\tvar onLoadCallback= function(){\n\t\t\t\t\t\t\t\t// defQ is a vector of module definitions 1-to-1, onto mids\n\t\t\t\t\t\t\t\trunDefQ(0, mids);\n\t\t\t\t\t\t\t\tcheckComplete();\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tcombosPending.push(mids);\n\t\t\t\t\t\t\tinjectingModule = mids;\n\t\t\t\t\t\t\treq.injectUrl(url, onLoadCallback, mids);\n\t\t\t\t\t\t\tinjectingModule = 0;\n\t\t\t\t\t\t}, req);\n\t\t\t\t\t}, 0);\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tcontextRequire = function(a1, a2, a3, referenceModule, contextRequire){\n\t\t\tvar module, syntheticMid;\n\t\t\tif(isString(a1)){\n\t\t\t\t// signature is (moduleId)\n\t\t\t\tmodule = getModule(a1, referenceModule, true);\n\t\t\t\tif(module && module.executed){\n\t\t\t\t\treturn module.result;\n\t\t\t\t}\n\t\t\t\tthrow makeError(\"undefinedModule\", a1);\n\t\t\t}\n\t\t\tif(!isArray(a1)){\n\t\t\t\t// a1 is a configuration\n\t\t\t\tconfig(a1, 0, referenceModule);\n\n\t\t\t\t// juggle args; (a2, a3) may be (dependencies, callback)\n\t\t\t\ta1 = a2;\n\t\t\t\ta2 = a3;\n\t\t\t}\n\t\t\tif(isArray(a1)){\n\t\t\t\t// signature is (requestList [,callback])\n\t\t\t\tif(!a1.length){\n\t\t\t\t\ta2 && a2();\n\t\t\t\t}else{\n\t\t\t\t\tsyntheticMid = \"require*\" + uid();\n\n\t\t\t\t\t// resolve the request list with respect to the reference module\n\t\t\t\t\tfor(var mid, deps = [], i = 0; i < a1.length;){\n\t\t\t\t\t\tmid = a1[i++];\n\t\t\t\t\t\tdeps.push(getModule(mid, referenceModule));\n\t\t\t\t\t}\n\n\t\t\t\t\t// construct a synthetic module to control execution of the requestList, and, optionally, callback\n\t\t\t\t\tmodule = mix(makeModuleInfo(\"\", syntheticMid, 0, \"\"), {\n\t\t\t\t\t\tinjected: arrived,\n\t\t\t\t\t\tdeps: deps,\n\t\t\t\t\t\tdef: a2 || noop,\n\t\t\t\t\t\trequire: referenceModule ? referenceModule.require : req,\n\t\t\t\t\t\tgc: 1 //garbage collect\n\t\t\t\t\t});\n\t\t\t\t\tmodules[module.mid] = module;\n\n\t\t\t\t\t// checkComplete!=0 holds the idle signal; we're not idle if we're injecting dependencies\n\t\t\t\t\tinjectDependencies(module);\n\n\t\t\t\t\t// try to immediately execute\n\t\t\t\t\t// if already traversing a factory tree, then strict causes circular dependency to abort the execution; maybe\n\t\t\t\t\t// it's possible to execute this require later after the current traversal completes and avoid the circular dependency.\n\t\t\t\t\t// ...but *always* insist on immediate in synch mode\n\t\t\t\t\tvar strict = checkCompleteGuard && legacyMode!=sync;\n\t\t\t\t\tguardCheckComplete(function(){\n\t\t\t\t\t\texecModule(module, strict);\n\t\t\t\t\t});\n\t\t\t\t\tif(!module.executed){\n\t\t\t\t\t\t// some deps weren't on board or circular dependency detected and strict; therefore, push into the execQ\n\t\t\t\t\t\texecQ.push(module);\n\t\t\t\t\t}\n\t\t\t\t\tcheckComplete();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn contextRequire;\n\t\t},\n\n\t\tcreateRequire = function(module){\n\t\t\tif(!module){\n\t\t\t\treturn req;\n\t\t\t}\n\t\t\tvar result = module.require;\n\t\t\tif(!result){\n\t\t\t\tresult = function(a1, a2, a3){\n\t\t\t\t\treturn contextRequire(a1, a2, a3, module, result);\n\t\t\t\t};\n\t\t\t\tmodule.require = mix(result, req);\n\t\t\t\tresult.module = module;\n\t\t\t\tresult.toUrl = function(name){\n\t\t\t\t\treturn toUrl(name, module);\n\t\t\t\t};\n\t\t\t\tresult.toAbsMid = function(mid){\n\t\t\t\t\treturn toAbsMid(mid, module);\n\t\t\t\t};\n\t\t\t\tif( 0 ){\n\t\t\t\t\tresult.undef = function(mid){\n\t\t\t\t\t\treq.undef(mid, module);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif( 1 ){\n\t\t\t\t\tresult.syncLoadNls = function(mid){\n\t\t\t\t\t\tvar nlsModuleInfo = getModuleInfo(mid, module),\n\t\t\t\t\t\t\tnlsModule = modules[nlsModuleInfo.mid];\n\t\t\t\t\t\tif(!nlsModule || !nlsModule.executed){\n\t\t\t\t\t\t\tcached = cache[nlsModuleInfo.mid] || cache[urlKeyPrefix + nlsModuleInfo.url];\n\t\t\t\t\t\t\tif(cached){\n\t\t\t\t\t\t\t\tevalModuleText(cached);\n\t\t\t\t\t\t\t\tnlsModule = modules[nlsModuleInfo.mid];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn nlsModule && nlsModule.executed && nlsModule.result;\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\n\t\texecQ =\n\t\t\t// The list of modules that need to be evaluated.\n\t\t\t[],\n\n\t\tdefQ =\n\t\t\t// The queue of define arguments sent to loader.\n\t\t\t[],\n\n\t\twaiting =\n\t\t\t// The set of modules upon which the loader is waiting for definition to arrive\n\t\t\t{},\n\n\t\tsetRequested = function(module){\n\t\t\tmodule.injected = requested;\n\t\t\twaiting[module.mid] = 1;\n\t\t\tif(module.url){\n\t\t\t\twaiting[module.url] = module.pack || 1;\n\t\t\t}\n\t\t\tstartTimer();\n\t\t},\n\n\t\tsetArrived = function(module){\n\t\t\tmodule.injected = arrived;\n\t\t\tdelete waiting[module.mid];\n\t\t\tif(module.url){\n\t\t\t\tdelete waiting[module.url];\n\t\t\t}\n\t\t\tif(isEmpty(waiting)){\n\t\t\t\tclearTimer();\n\t\t\t\t 1  && legacyMode==xd && (legacyMode = sync);\n\t\t\t}\n\t\t},\n\n\t\texecComplete = req.idle =\n\t\t\t// says the loader has completed (or not) its work\n\t\t\tfunction(){\n\t\t\t\treturn !defQ.length && isEmpty(waiting) && !execQ.length && !checkCompleteGuard;\n\t\t\t},\n\n\t\trunMapProg = function(targetMid, map){\n\t\t\t// search for targetMid in map; return the map item if found; falsy otherwise\n\t\t\tif(map){\n\t\t\tfor(var i = 0; i < map.length; i++){\n\t\t\t\tif(map[i][2].test(targetMid)){\n\t\t\t\t\treturn map[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\t},\n\n\t\tcompactPath = function(path){\n\t\t\tvar result = [],\n\t\t\t\tsegment, lastSegment;\n\t\t\tpath = path.replace(/\\\\/g, '/').split('/');\n\t\t\twhile(path.length){\n\t\t\t\tsegment = path.shift();\n\t\t\t\tif(segment==\"..\" && result.length && lastSegment!=\"..\"){\n\t\t\t\t\tresult.pop();\n\t\t\t\t\tlastSegment = result[result.length - 1];\n\t\t\t\t}else if(segment!=\".\"){\n\t\t\t\t\tresult.push(lastSegment= segment);\n\t\t\t\t} // else ignore \".\"\n\t\t\t}\n\t\t\treturn result.join(\"/\");\n\t\t},\n\n\t\tmakeModuleInfo = function(pid, mid, pack, url){\n\t\t\tif( 1 ){\n\t\t\t\tvar xd= req.isXdUrl(url);\n\t\t\t\treturn {pid:pid, mid:mid, pack:pack, url:url, executed:0, def:0, isXd:xd, isAmd:!!(xd || (packs[pid] && packs[pid].isAmd))};\n\t\t\t}else{\n\t\t\t\treturn {pid:pid, mid:mid, pack:pack, url:url, executed:0, def:0};\n\t\t\t}\n\t\t},\n\n\t\tgetModuleInfo_ = function(mid, referenceModule, packs, modules, baseUrl, mapProgs, pathsMapProg, alwaysCreate){\n\t\t\t// arguments are passed instead of using lexical variables so that this function my be used independent of the loader (e.g., the builder)\n\t\t\t// alwaysCreate is useful in this case so that getModuleInfo never returns references to real modules owned by the loader\n\t\t\tvar pid, pack, midInPackage, mapProg, mapItem, url, result, isRelative, requestedMid;\n\t\t\trequestedMid = mid;\n\t\t\tisRelative = /^\\./.test(mid);\n\t\t\tif(/(^\\/)|(\\:)|(\\.js$)/.test(mid) || (isRelative && !referenceModule)){\n\t\t\t\t// absolute path or protocol of .js filetype, or relative path but no reference module and therefore relative to page\n\t\t\t\t// whatever it is, it's not a module but just a URL of some sort\n\t\t\t\t// note: pid===0 indicates the routine is returning an unmodified mid\n\n\t\t\t\treturn makeModuleInfo(0, mid, 0, mid);\n\t\t\t}else{\n\t\t\t\t// relative module ids are relative to the referenceModule; get rid of any dots\n\t\t\t\tmid = compactPath(isRelative ? (referenceModule.mid + \"/../\" + mid) : mid);\n\t\t\t\tif(/^\\./.test(mid)){\n\t\t\t\t\tthrow makeError(\"irrationalPath\", mid);\n\t\t\t\t}\n\t\t\t\t// at this point, mid is an absolute mid\n\n\t\t\t\t// map the mid\n\t\t\t\tif(referenceModule){\n\t\t\t\t\tmapItem = runMapProg(referenceModule.mid, mapProgs);\n\t\t\t\t}\n\t\t\t\tmapItem = mapItem || mapProgs.star;\n\t\t\t\tmapItem = mapItem && runMapProg(mid, mapItem[1]);\n\n\t\t\t\tif(mapItem){\n\t\t\t\t\tmid = mapItem[1] + mid.substring(mapItem[3]);\n\t\t\t\t\t}\n\n\t\t\t\tmatch = mid.match(/^([^\\/]+)(\\/(.+))?$/);\n\t\t\t\tpid = match ? match[1] : \"\";\n\t\t\t\tif((pack = packs[pid])){\n\t\t\t\t\tmid = pid + \"/\" + (midInPackage = (match[3] || pack.main));\n\t\t\t\t}else{\n\t\t\t\t\tpid = \"\";\n\t\t\t\t}\n\n\t\t\t\t// search aliases\n\t\t\t\tvar candidateLength = 0,\n\t\t\t\t\tcandidate = 0;\n\t\t\t\tforEach(aliases, function(pair){\n\t\t\t\t\tvar match = mid.match(pair[0]);\n\t\t\t\t\tif(match && match.length>candidateLength){\n\t\t\t\t\t\tcandidate = isFunction(pair[1]) ? mid.replace(pair[0], pair[1]) : pair[1];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif(candidate){\n\t\t\t\t\treturn getModuleInfo_(candidate, 0, packs, modules, baseUrl, mapProgs, pathsMapProg, alwaysCreate);\n\t\t\t\t}\n\n\t\t\t\tresult = modules[mid];\n\t\t\t\tif(result){\n\t\t\t\t\treturn alwaysCreate ? makeModuleInfo(result.pid, result.mid, result.pack, result.url) : modules[mid];\n\t\t\t\t}\n\t\t\t}\n\t\t\t// get here iff the sought-after module does not yet exist; therefore, we need to compute the URL given the\n\t\t\t// fully resolved (i.e., all relative indicators and package mapping resolved) module id\n\n\t\t\t// note: pid!==0 indicates the routine is returning a url that has .js appended unmodified mid\n\t\t\tmapItem = runMapProg(mid, pathsMapProg);\n\t\t\tif(mapItem){\n\t\t\t\turl = mapItem[1] + mid.substring(mapItem[3]);\n\t\t\t}else if(pid){\n\t\t\t\turl = pack.location + \"/\" + midInPackage;\n\t\t\t}else if(has(\"config-tlmSiblingOfDojo\")){\n\t\t\t\turl = \"../\" + mid;\n\t\t\t}else{\n\t\t\t\turl = mid;\n\t\t\t}\n\t\t\t// if result is not absolute, add baseUrl\n\t\t\tif(!(/(^\\/)|(\\:)/.test(url))){\n\t\t\t\turl = baseUrl + url;\n\t\t\t}\n\t\t\turl += \".js\";\n\t\t\treturn makeModuleInfo(pid, mid, pack, compactPath(url));\n\t\t},\n\n\t\tgetModuleInfo = function(mid, referenceModule){\n\t\t\treturn getModuleInfo_(mid, referenceModule, packs, modules, req.baseUrl, mapProgs, pathsMapProg);\n\t\t},\n\n\t\tresolvePluginResourceId = function(plugin, prid, referenceModule){\n\t\t\treturn plugin.normalize ? plugin.normalize(prid, function(mid){return toAbsMid(mid, referenceModule);}) : toAbsMid(prid, referenceModule);\n\t\t},\n\n\t\tdynamicPluginUidGenerator = 0,\n\n\t\tgetModule = function(mid, referenceModule, immediate){\n\t\t\t// compute and optionally construct (if necessary) the module implied by the mid with respect to referenceModule\n\t\t\tvar match, plugin, prid, result;\n\t\t\tmatch = mid.match(/^(.+?)\\!(.*)$/);\n\t\t\tif(match){\n\t\t\t\t// name was <plugin-module>!<plugin-resource-id>\n\t\t\t\tplugin = getModule(match[1], referenceModule, immediate);\n\n\t\t\t\tif( 1  && legacyMode == sync && !plugin.executed){\n\t\t\t\t\tinjectModule(plugin);\n\t\t\t\t\tif(plugin.injected===arrived && !plugin.executed){\n\t\t\t\t\t\tguardCheckComplete(function(){\n\t\t\t\t\t\t\texecModule(plugin);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif(plugin.executed){\n\t\t\t\t\t\tpromoteModuleToPlugin(plugin);\n\t\t\t\t\t}else{\n\t\t\t\t\t\t// we are in xdomain mode for some reason\n\t\t\t\t\t\texecQ.unshift(plugin);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\t\t\t\tif(plugin.executed === executed && !plugin.load){\n\t\t\t\t\t// executed the module not knowing it was a plugin\n\t\t\t\t\tpromoteModuleToPlugin(plugin);\n\t\t\t\t}\n\n\t\t\t\t// if the plugin has not been loaded, then can't resolve the prid and  must assume this plugin is dynamic until we find out otherwise\n\t\t\t\tif(plugin.load){\n\t\t\t\t\tprid = resolvePluginResourceId(plugin, match[2], referenceModule);\n\t\t\t\t\tmid = (plugin.mid + \"!\" + (plugin.dynamic ? ++dynamicPluginUidGenerator + \"!\" : \"\") + prid);\n\t\t\t\t}else{\n\t\t\t\t\tprid = match[2];\n\t\t\t\t\tmid = plugin.mid + \"!\" + (++dynamicPluginUidGenerator) + \"!waitingForPlugin\";\n\t\t\t\t}\n\t\t\t\tresult = {plugin:plugin, mid:mid, req:createRequire(referenceModule), prid:prid};\n\t\t\t}else{\n\t\t\t\tresult = getModuleInfo(mid, referenceModule);\n\t\t\t}\n\t\t\treturn modules[result.mid] || (!immediate && (modules[result.mid] = result));\n\t\t},\n\n\t\ttoAbsMid = req.toAbsMid = function(mid, referenceModule){\n\t\t\treturn getModuleInfo(mid, referenceModule).mid;\n\t\t},\n\n\t\ttoUrl = req.toUrl = function(name, referenceModule){\n\t\t\tvar moduleInfo = getModuleInfo(name+\"/x\", referenceModule),\n\t\t\t\turl= moduleInfo.url;\n\t\t\treturn fixupUrl(moduleInfo.pid===0 ?\n\t\t\t\t// if pid===0, then name had a protocol or absolute path; either way, toUrl is the identify function in such cases\n\t\t\t\tname :\n\t\t\t\t// \"/x.js\" since getModuleInfo automatically appends \".js\" and we appended \"/x\" to make name look likde a module id\n\t\t\t\turl.substring(0, url.length-5)\n\t\t\t);\n\t\t},\n\n\t\tnonModuleProps = {\n\t\t\tinjected: arrived,\n\t\t\texecuted: executed,\n\t\t\tdef: nonmodule,\n\t\t\tresult: nonmodule\n\t\t},\n\n\t\tmakeCjs = function(mid){\n\t\t\treturn modules[mid] = mix({mid:mid}, nonModuleProps);\n\t\t},\n\n\t\tcjsRequireModule = makeCjs(\"require\"),\n\t\tcjsExportsModule = makeCjs(\"exports\"),\n\t\tcjsModuleModule = makeCjs(\"module\"),\n\n\t\trunFactory = function(module, args){\n\t\t\treq.trace(\"loader-run-factory\", [module.mid]);\n\t\t\tvar factory = module.def,\n\t\t\t\tresult;\n\t\t\t 1  && syncExecStack.unshift(module);\n\t\t\tif(has(\"config-dojo-loader-catches\")){\n\t\t\t\ttry{\n\t\t\t\t\tresult= isFunction(factory) ? factory.apply(null, args) : factory;\n\t\t\t\t}catch(e){\n\t\t\t\t\tsignal(error, module.result = makeError(\"factoryThrew\", [module, e]));\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tresult= isFunction(factory) ? factory.apply(null, args) : factory;\n\t\t\t}\n\t\t\tmodule.result = result===undefined && module.cjs ? module.cjs.exports : result;\n\t\t\t 1  && syncExecStack.shift(module);\n\t\t},\n\n\t\tabortExec = {},\n\n\t\tdefOrder = 0,\n\n\t\tpromoteModuleToPlugin = function(pluginModule){\n\t\t\tvar plugin = pluginModule.result;\n\t\t\tpluginModule.dynamic = plugin.dynamic;\n\t\t\tpluginModule.normalize = plugin.normalize;\n\t\t\tpluginModule.load = plugin.load;\n\t\t\treturn pluginModule;\n\t\t},\n\n\t\tresolvePluginLoadQ = function(plugin){\n\t\t\t// plugins is a newly executed module that has a loadQ waiting to run\n\n\t\t\t// step 1: traverse the loadQ and fixup the mid and prid; remember the map from original mid to new mid\n\t\t\t// recall the original mid was created before the plugin was on board and therefore it was impossible to\n\t\t\t// compute the final mid; accordingly, prid may or may not change, but the mid will definitely change\n\t\t\tvar map = {};\n\t\t\tforEach(plugin.loadQ, function(pseudoPluginResource){\n\t\t\t\t// manufacture and insert the real module in modules\n\t\t\t\tvar prid = resolvePluginResourceId(plugin, pseudoPluginResource.prid, pseudoPluginResource.req.module),\n\t\t\t\t\tmid = plugin.dynamic ? pseudoPluginResource.mid.replace(/waitingForPlugin$/, prid) : (plugin.mid + \"!\" + prid),\n\t\t\t\t\tpluginResource = mix(mix({}, pseudoPluginResource), {mid:mid, prid:prid, injected:0});\n\t\t\t\tif(!modules[mid]){\n\t\t\t\t\t// create a new (the real) plugin resource and inject it normally now that the plugin is on board\n\t\t\t\t\tinjectPlugin(modules[mid] = pluginResource);\n\t\t\t\t} // else this was a duplicate request for the same (plugin, rid) for a nondynamic plugin\n\n\t\t\t\t// pluginResource is really just a placeholder with the wrong mid (because we couldn't calculate it until the plugin was on board)\n\t\t\t\t// mark is as arrived and delete it from modules; the real module was requested above\n\t\t\t\tmap[pseudoPluginResource.mid] = modules[mid];\n\t\t\t\tsetArrived(pseudoPluginResource);\n\t\t\t\tdelete modules[pseudoPluginResource.mid];\n\t\t\t});\n\t\t\tplugin.loadQ = 0;\n\n\t\t\t// step2: replace all references to any placeholder modules with real modules\n\t\t\tvar substituteModules = function(module){\n\t\t\t\tfor(var replacement, deps = module.deps || [], i = 0; i<deps.length; i++){\n\t\t\t\t\treplacement = map[deps[i].mid];\n\t\t\t\t\tif(replacement){\n\t\t\t\t\t\tdeps[i] = replacement;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\tfor(var p in modules){\n\t\t\t\tsubstituteModules(modules[p]);\n\t\t\t}\n\t\t\tforEach(execQ, substituteModules);\n\t\t},\n\n\t\tfinishExec = function(module){\n\t\t\treq.trace(\"loader-finish-exec\", [module.mid]);\n\t\t\tmodule.executed = executed;\n\t\t\tmodule.defOrder = defOrder++;\n\t\t\t 1  && forEach(module.provides, function(cb){ cb(); });\n\t\t\tif(module.loadQ){\n\t\t\t\t// the module was a plugin\n\t\t\t\tpromoteModuleToPlugin(module);\n\t\t\t\tresolvePluginLoadQ(module);\n\t\t\t}\n\t\t\t// remove all occurences of this module from the execQ\n\t\t\tfor(i = 0; i < execQ.length;){\n\t\t\t\tif(execQ[i] === module){\n\t\t\t\t\texecQ.splice(i, 1);\n\t\t\t\t}else{\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// delete references to synthetic modules\n\t\t\tif (/^require\\*/.test(module.mid)) {\n\t\t\t\tdelete modules[module.mid];\n\t\t\t}\n\t\t},\n\n\t\tcircleTrace = [],\n\n\t\texecModule = function(module, strict){\n\t\t\t// run the dependency vector, then run the factory for module\n\t\t\tif(module.executed === executing){\n\t\t\t\treq.trace(\"loader-circular-dependency\", [circleTrace.concat(module.mid).join(\"->\")]);\n\t\t\t\treturn (!module.def || strict) ? abortExec :  (module.cjs && module.cjs.exports);\n\t\t\t}\n\t\t\t// at this point the module is either not executed or fully executed\n\n\n\t\t\tif(!module.executed){\n\t\t\t\tif(!module.def){\n\t\t\t\t\treturn abortExec;\n\t\t\t\t}\n\t\t\t\tvar mid = module.mid,\n\t\t\t\t\tdeps = module.deps || [],\n\t\t\t\t\targ, argResult,\n\t\t\t\t\targs = [],\n\t\t\t\t\ti = 0;\n\n\t\t\t\tif( 0 ){\n\t\t\t\t\tcircleTrace.push(mid);\n\t\t\t\t\treq.trace(\"loader-exec-module\", [\"exec\", circleTrace.length, mid]);\n\t\t\t\t}\n\n\t\t\t\t// for circular dependencies, assume the first module encountered was executed OK\n\t\t\t\t// modules that circularly depend on a module that has not run its factory will get\n\t\t\t\t// the premade cjs.exports===module.result. They can take a reference to this object and/or\n\t\t\t\t// add properties to it. When the module finally runs its factory, the factory can\n\t\t\t\t// read/write/replace this object. Notice that so long as the object isn't replaced, any\n\t\t\t\t// reference taken earlier while walking the deps list is still valid.\n\t\t\t\tmodule.executed = executing;\n\t\t\t\twhile(i < deps.length){\n\t\t\t\t\targ = deps[i++];\n\t\t\t\t\targResult = ((arg === cjsRequireModule) ? createRequire(module) :\n\t\t\t\t\t\t\t\t\t((arg === cjsExportsModule) ? module.cjs.exports :\n\t\t\t\t\t\t\t\t\t\t((arg === cjsModuleModule) ? module.cjs :\n\t\t\t\t\t\t\t\t\t\t\texecModule(arg, strict))));\n\t\t\t\t\tif(argResult === abortExec){\n\t\t\t\t\t\tmodule.executed = 0;\n\t\t\t\t\t\treq.trace(\"loader-exec-module\", [\"abort\", mid]);\n\t\t\t\t\t\t 0  && circleTrace.pop();\n\t\t\t\t\t\treturn abortExec;\n\t\t\t\t\t}\n\t\t\t\t\targs.push(argResult);\n\t\t\t\t}\n\t\t\t\trunFactory(module, args);\n\t\t\t\tfinishExec(module);\n\t\t\t\t 0  && circleTrace.pop();\n\t\t\t}\n\t\t\t// at this point the module is guaranteed fully executed\n\n\t\t\treturn module.result;\n\t\t},\n\n\n\t\tcheckCompleteGuard = 0,\n\n\t\tguardCheckComplete = function(proc){\n\t\t\ttry{\n\t\t\t\tcheckCompleteGuard++;\n\t\t\t\tproc();\n\t\t\t}finally{\n\t\t\t\tcheckCompleteGuard--;\n\t\t\t}\n\t\t\tif(execComplete()){\n\t\t\t\tsignal(\"idle\", []);\n\t\t\t}\n\t\t},\n\n\t\tcheckComplete = function(){\n\t\t\t// keep going through the execQ as long as at least one factory is executed\n\t\t\t// plugins, recursion, cached modules all make for many execution path possibilities\n\t\t\tif(checkCompleteGuard){\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tguardCheckComplete(function(){\n\t\t\t\tcheckDojoRequirePlugin();\n\t\t\t\tfor(var currentDefOrder, module, i = 0; i < execQ.length;){\n\t\t\t\t\tcurrentDefOrder = defOrder;\n\t\t\t\t\tmodule = execQ[i];\n\t\t\t\t\texecModule(module);\n\t\t\t\t\tif(currentDefOrder!=defOrder){\n\t\t\t\t\t\t// defOrder was bumped one or more times indicating something was executed (note, this indicates\n\t\t\t\t\t\t// the execQ was modified, maybe a lot (for example a later module causes an earlier module to execute)\n\t\t\t\t\t\tcheckDojoRequirePlugin();\n\t\t\t\t\t\ti = 0;\n\t\t\t\t\t}else{\n\t\t\t\t\t\t// nothing happened; check the next module in the exec queue\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\n\tif( 0 ){\n\t\treq.undef = function(moduleId, referenceModule){\n\t\t\t// In order to reload a module, it must be undefined (this routine) and then re-requested.\n\t\t\t// This is useful for testing frameworks (at least).\n\t\t\tvar module = getModule(moduleId, referenceModule);\n\t\t\tsetArrived(module);\n\t\t\tdelete modules[module.mid];\n\t\t};\n\t}\n\n\tif( 1 ){\n\t\tif(has(\"dojo-loader-eval-hint-url\")===undefined){\n\t\t\thas.add(\"dojo-loader-eval-hint-url\", 1);\n\t\t}\n\n\t\tvar fixupUrl= function(url){\n\t\t\t\turl += \"\"; // make sure url is a Javascript string (some paths may be a Java string)\n\t\t\t\treturn url + (cacheBust ? ((/\\?/.test(url) ? \"&\" : \"?\") + cacheBust) : \"\");\n\t\t\t},\n\n\t\t\tinjectPlugin = function(\n\t\t\t\tmodule\n\t\t\t){\n\t\t\t\t// injects the plugin module given by module; may have to inject the plugin itself\n\t\t\t\tvar plugin = module.plugin;\n\n\t\t\t\tif(plugin.executed === executed && !plugin.load){\n\t\t\t\t\t// executed the module not knowing it was a plugin\n\t\t\t\t\tpromoteModuleToPlugin(plugin);\n\t\t\t\t}\n\n\t\t\t\tvar onLoad = function(def){\n\t\t\t\t\t\tmodule.result = def;\n\t\t\t\t\t\tsetArrived(module);\n\t\t\t\t\t\tfinishExec(module);\n\t\t\t\t\t\tcheckComplete();\n\t\t\t\t\t};\n\n\t\t\t\tif(plugin.load){\n\t\t\t\t\tplugin.load(module.prid, module.req, onLoad);\n\t\t\t\t}else if(plugin.loadQ){\n\t\t\t\t\tplugin.loadQ.push(module);\n\t\t\t\t}else{\n\t\t\t\t\t// the unshift instead of push is important: we don't want plugins to execute as\n\t\t\t\t\t// dependencies of some other module because this may cause circles when the plugin\n\t\t\t\t\t// loadQ is run; also, generally, we want plugins to run early since they may load\n\t\t\t\t\t// several other modules and therefore can potentially unblock many modules\n\t\t\t\t\tplugin.loadQ = [module];\n\t\t\t\t\texecQ.unshift(plugin);\n\t\t\t\t\tinjectModule(plugin);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// for IE, injecting a module may result in a recursive execution if the module is in the cache\n\n\t\t\tcached = 0,\n\n\t\t\tinjectingModule = 0,\n\n\t\t\tinjectingCachedModule = 0,\n\n\t\t\tevalModuleText = function(text, module){\n\t\t\t\t// see def() for the injectingCachedModule bracket; it simply causes a short, safe curcuit\n\t\t\t\tif(has(\"config-stripStrict\")){\n\t\t\t\t\ttext = text.replace(/\"use strict\"/g, '');\n\t\t\t\t}\n\t\t\t\tinjectingCachedModule = 1;\n\t\t\t\tif(has(\"config-dojo-loader-catches\")){\n\t\t\t\t\ttry{\n\t\t\t\t\t\tif(text===cached){\n\t\t\t\t\t\t\tcached.call(null);\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\treq.eval(text, has(\"dojo-loader-eval-hint-url\") ? module.url : module.mid);\n\t\t\t\t\t\t}\n\t\t\t\t\t}catch(e){\n\t\t\t\t\t\tsignal(error, makeError(\"evalModuleThrew\", module));\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tif(text===cached){\n\t\t\t\t\t\tcached.call(null);\n\t\t\t\t\t}else{\n\t\t\t\t\t\treq.eval(text, has(\"dojo-loader-eval-hint-url\") ? module.url : module.mid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tinjectingCachedModule = 0;\n\t\t\t},\n\n\t\t\tinjectModule = function(module){\n\t\t\t\t// Inject the module. In the browser environment, this means appending a script element into\n\t\t\t\t// the document; in other environments, it means loading a file.\n\t\t\t\t//\n\t\t\t\t// If in synchronous mode, then get the module synchronously if it's not xdomainLoading.\n\n\t\t\t\tvar mid = module.mid,\n\t\t\t\t\turl = module.url;\n\t\t\t\tif(module.executed || module.injected || waiting[mid] || (module.url && ((module.pack && waiting[module.url]===module.pack) || waiting[module.url]==1))){\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetRequested(module);\n\n\t\t\t\tif( 0 ){\n\t\t\t\t\tvar viaCombo = 0;\n\t\t\t\t\tif(module.plugin && module.plugin.isCombo){\n\t\t\t\t\t\t// a combo plugin; therefore, must be handled by combo service\n\t\t\t\t\t\t// the prid should have already been converted to a URL (if required by the plugin) during\n\t\t\t\t\t\t// the normalze process; in any event, there is no way for the loader to know how to\n\t\t\t\t\t\t// to the conversion; therefore the third argument is zero\n\t\t\t\t\t\treq.combo.add(module.plugin.mid, module.prid, 0, req);\n\t\t\t\t\t\tviaCombo = 1;\n\t\t\t\t\t}else if(!module.plugin){\n\t\t\t\t\t\tviaCombo = req.combo.add(0, module.mid, module.url, req);\n\t\t\t\t\t}\n\t\t\t\t\tif(viaCombo){\n\t\t\t\t\t\tcomboPending= 1;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif(module.plugin){\n\t\t\t\t\tinjectPlugin(module);\n\t\t\t\t\treturn;\n\t\t\t\t} // else a normal module (not a plugin)\n\n\n\t\t\t\tvar onLoadCallback = function(){\n\t\t\t\t\trunDefQ(module);\n\t\t\t\t\tif(module.injected !== arrived){\n\t\t\t\t\t\t// the script that contained the module arrived and has been executed yet\n\t\t\t\t\t\t// nothing was added to the defQ (so it wasn't an AMD module) and the module\n\t\t\t\t\t\t// wasn't marked as arrived by dojo.provide (so it wasn't a v1.6- module);\n\t\t\t\t\t\t// therefore, it must not have been a module; adjust state accordingly\n\t\t\t\t\t\tsetArrived(module);\n\t\t\t\t\t\tmix(module, nonModuleProps);\n\t\t\t\t\t\treq.trace(\"loader-define-nonmodule\", [module.url]);\n\t\t\t\t\t}\n\n\t\t\t\t\tif( 1  && legacyMode){\n\t\t\t\t\t\t// must call checkComplete even in for sync loader because we may be in xdomainLoading mode;\n\t\t\t\t\t\t// but, if xd loading, then don't call checkComplete until out of the current sync traversal\n\t\t\t\t\t\t// in order to preserve order of execution of the dojo.required modules\n\t\t\t\t\t\t!syncExecStack.length && checkComplete();\n\t\t\t\t\t}else{\n\t\t\t\t\t\tcheckComplete();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tcached = cache[mid] || cache[urlKeyPrefix + module.url];\n\t\t\t\tif(cached){\n\t\t\t\t\treq.trace(\"loader-inject\", [\"cache\", module.mid, url]);\n\t\t\t\t\tevalModuleText(cached, module);\n\t\t\t\t\tonLoadCallback();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif( 1  && legacyMode){\n\t\t\t\t\tif(module.isXd){\n\t\t\t\t\t\t// switch to async mode temporarily; if current legacyMode!=sync, then is must be one of {legacyAsync, xd, false}\n\t\t\t\t\t\tlegacyMode==sync && (legacyMode = xd);\n\t\t\t\t\t\t// fall through and load via script injection\n\t\t\t\t\t}else if(module.isAmd && legacyMode!=sync){\n\t\t\t\t\t\t// fall through and load via script injection\n\t\t\t\t\t}else{\n\t\t\t\t\t\t// mode may be sync, xd/legacyAsync, or async; module may be AMD or legacy; but module is always located on the same domain\n\t\t\t\t\t\tvar xhrCallback = function(text){\n\t\t\t\t\t\t\tif(legacyMode==sync){\n\t\t\t\t\t\t\t\t// the top of syncExecStack gives the current synchronously executing module; the loader needs\n\t\t\t\t\t\t\t\t// to know this if it has to switch to async loading in the middle of evaluating a legacy module\n\t\t\t\t\t\t\t\t// this happens when a modules dojo.require's a module that must be loaded async because it's xdomain\n\t\t\t\t\t\t\t\t// (using unshift/shift because there is no back() methods for Javascript arrays)\n\t\t\t\t\t\t\t\tsyncExecStack.unshift(module);\n\t\t\t\t\t\t\t\tevalModuleText(text, module);\n\t\t\t\t\t\t\t\tsyncExecStack.shift();\n\n\t\t\t\t\t\t\t\t// maybe the module was an AMD module\n\t\t\t\t\t\t\t\trunDefQ(module);\n\n\t\t\t\t\t\t\t\t// legacy modules never get to defineModule() => cjs and injected never set; also evaluation implies executing\n\t\t\t\t\t\t\t\tif(!module.cjs){\n\t\t\t\t\t\t\t\t\tsetArrived(module);\n\t\t\t\t\t\t\t\t\tfinishExec(module);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif(module.finish){\n\t\t\t\t\t\t\t\t\t// while synchronously evaluating this module, dojo.require was applied referencing a module\n\t\t\t\t\t\t\t\t\t// that had to be loaded async; therefore, the loader stopped answering all dojo.require\n\t\t\t\t\t\t\t\t\t// requests so they could be answered completely in the correct sequence; module.finish gives\n\t\t\t\t\t\t\t\t\t// the list of dojo.requires that must be re-applied once all target modules are available;\n\t\t\t\t\t\t\t\t\t// make a synthetic module to execute the dojo.require's in the correct order\n\n\t\t\t\t\t\t\t\t\t// compute a guarnateed-unique mid for the synthetic finish module; remember the finish vector; remove it from the reference module\n\t\t\t\t\t\t\t\t\t// TODO: can we just leave the module.finish...what's it hurting?\n\t\t\t\t\t\t\t\t\tvar finishMid = mid + \"*finish\",\n\t\t\t\t\t\t\t\t\t\tfinish = module.finish;\n\t\t\t\t\t\t\t\t\tdelete module.finish;\n\n\t\t\t\t\t\t\t\t\tdef(finishMid, [\"dojo\", (\"dojo/require!\" + finish.join(\",\")).replace(/\\./g, \"/\")], function(dojo){\n\t\t\t\t\t\t\t\t\t\tforEach(finish, function(mid){ dojo.require(mid); });\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t// unshift, not push, which causes the current traversal to be reattempted from the top\n\t\t\t\t\t\t\t\t\texecQ.unshift(getModule(finishMid));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonLoadCallback();\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\ttext = transformToAmd(module, text);\n\t\t\t\t\t\t\t\tif(text){\n\t\t\t\t\t\t\t\t\tevalModuleText(text, module);\n\t\t\t\t\t\t\t\t\tonLoadCallback();\n\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t// if transformToAmd returned falsy, then the module was already AMD and it can be script-injected\n\t\t\t\t\t\t\t\t\t// do so to improve debugability(even though it means another download...which probably won't happen with a good browser cache)\n\t\t\t\t\t\t\t\t\tinjectingModule = module;\n\t\t\t\t\t\t\t\t\treq.injectUrl(fixupUrl(url), onLoadCallback, module);\n\t\t\t\t\t\t\t\t\tinjectingModule = 0;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\treq.trace(\"loader-inject\", [\"xhr\", module.mid, url, legacyMode!=sync]);\n\t\t\t\t\t\tif(has(\"config-dojo-loader-catches\")){\n\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\treq.getText(url, legacyMode!=sync, xhrCallback);\n\t\t\t\t\t\t\t}catch(e){\n\t\t\t\t\t\t\t\tsignal(error, makeError(\"xhrInjectFailed\", [module, e]));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\treq.getText(url, legacyMode!=sync, xhrCallback);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} // else async mode or fell through in xdomain loading mode; either way, load by script injection\n\t\t\t\treq.trace(\"loader-inject\", [\"script\", module.mid, url]);\n\t\t\t\tinjectingModule = module;\n\t\t\t\treq.injectUrl(fixupUrl(url), onLoadCallback, module);\n\t\t\t\tinjectingModule = 0;\n\t\t\t},\n\n\t\t\tdefineModule = function(module, deps, def){\n\t\t\t\treq.trace(\"loader-define-module\", [module.mid, deps]);\n\n\t\t\t\tif( 0  && module.plugin && module.plugin.isCombo){\n\t\t\t\t\t// the module is a plugin resource loaded by the combo service\n\t\t\t\t\t// note: check for module.plugin should be enough since normal plugin resources should\n\t\t\t\t\t// not follow this path; module.plugin.isCombo is future-proofing belt and suspenders\n\t\t\t\t\tmodule.result = isFunction(def) ? def() : def;\n\t\t\t\t\tsetArrived(module);\n\t\t\t\t\tfinishExec(module);\n\t\t\t\t\treturn module;\n\t\t\t\t};\n\n\t\t\t\tvar mid = module.mid;\n\t\t\t\tif(module.injected === arrived){\n\t\t\t\t\tsignal(error, makeError(\"multipleDefine\", module));\n\t\t\t\t\treturn module;\n\t\t\t\t}\n\t\t\t\tmix(module, {\n\t\t\t\t\tdeps: deps,\n\t\t\t\t\tdef: def,\n\t\t\t\t\tcjs: {\n\t\t\t\t\t\tid: module.mid,\n\t\t\t\t\t\turi: module.url,\n\t\t\t\t\t\texports: (module.result = {}),\n\t\t\t\t\t\tsetExports: function(exports){\n\t\t\t\t\t\t\tmodule.cjs.exports = exports;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tconfig:function(){\n\t\t\t\t\t\t\treturn module.config;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\t// resolve deps with respect to this module\n\t\t\t\tfor(var i = 0; i < deps.length; i++){\n\t\t\t\t\tdeps[i] = getModule(deps[i], module);\n\t\t\t\t}\n\n\t\t\t\tif( 1  && legacyMode && !waiting[mid]){\n\t\t\t\t\t// the module showed up without being asked for; it was probably in a <script> element\n\t\t\t\t\tinjectDependencies(module);\n\t\t\t\t\texecQ.push(module);\n\t\t\t\t\tcheckComplete();\n\t\t\t\t}\n\t\t\t\tsetArrived(module);\n\n\t\t\t\tif(!isFunction(def) && !deps.length){\n\t\t\t\t\tmodule.result = def;\n\t\t\t\t\tfinishExec(module);\n\t\t\t\t}\n\n\t\t\t\treturn module;\n\t\t\t},\n\n\t\t\trunDefQ = function(referenceModule, mids){\n\t\t\t\t// defQ is an array of [id, dependencies, factory]\n\t\t\t\t// mids (if any) is a vector of mids given by a combo service\n\t\t\t\tvar definedModules = [],\n\t\t\t\t\tmodule, args;\n\t\t\t\twhile(defQ.length){\n\t\t\t\t\targs = defQ.shift();\n\t\t\t\t\tmids && (args[0]= mids.shift());\n\t\t\t\t\t// explicit define indicates possible multiple modules in a single file; delay injecting dependencies until defQ fully\n\t\t\t\t\t// processed since modules earlier in the queue depend on already-arrived modules that are later in the queue\n\t\t\t\t\t// TODO: what if no args[0] and no referenceModule\n\t\t\t\t\tmodule = (args[0] && getModule(args[0])) || referenceModule;\n\t\t\t\t\tdefinedModules.push([module, args[1], args[2]]);\n\t\t\t\t}\n\t\t\t\tconsumePendingCacheInsert(referenceModule);\n\t\t\t\tforEach(definedModules, function(args){\n\t\t\t\t\tinjectDependencies(defineModule.apply(null, args));\n\t\t\t\t});\n\t\t\t};\n\t}\n\n\tvar timerId = 0,\n\t\tclearTimer = noop,\n\t\tstartTimer = noop;\n\tif( 1 ){\n\t\t// Timer machinery that monitors how long the loader is waiting and signals an error when the timer runs out.\n\t\tclearTimer = function(){\n\t\t\ttimerId && clearTimeout(timerId);\n\t\t\ttimerId = 0;\n\t\t},\n\n\t\tstartTimer = function(){\n\t\t\tclearTimer();\n\t\t\tif(req.waitms){\n\t\t\t\ttimerId = window.setTimeout(function(){\n\t\t\t\t\tclearTimer();\n\t\t\t\t\tsignal(error, makeError(\"timeout\", waiting));\n\t\t\t\t}, req.waitms);\n\t\t\t}\n\t\t};\n\t}\n\n\tif( 1 ){\n\t\t// the typically unnecessary !! in front of doc.attachEvent is due to an opera bug; see\t#15096\n\t\thas.add(\"ie-event-behavior\", !!doc.attachEvent && (typeof opera === \"undefined\" || opera.toString() != \"[object Opera]\"));\n\t}\n\n\tif( 1  && ( 1  ||  1 )){\n\t\tvar domOn = function(node, eventName, ieEventName, handler){\n\t\t\t\t// Add an event listener to a DOM node using the API appropriate for the current browser;\n\t\t\t\t// return a function that will disconnect the listener.\n\t\t\t\tif(!has(\"ie-event-behavior\")){\n\t\t\t\t\tnode.addEventListener(eventName, handler, false);\n\t\t\t\t\treturn function(){\n\t\t\t\t\t\tnode.removeEventListener(eventName, handler, false);\n\t\t\t\t\t};\n\t\t\t\t}else{\n\t\t\t\t\tnode.attachEvent(ieEventName, handler);\n\t\t\t\t\treturn function(){\n\t\t\t\t\t\tnode.detachEvent(ieEventName, handler);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\t\t\twindowOnLoadListener = domOn(window, \"load\", \"onload\", function(){\n\t\t\t\treq.pageLoaded = 1;\n\t\t\t\tdoc.readyState!=\"complete\" && (doc.readyState = \"complete\");\n\t\t\t\twindowOnLoadListener();\n\t\t\t});\n\n\t\tif( 1 ){\n\t\t\t// if the loader is on the page, there must be at least one script element\n\t\t\t// getting its parent and then doing insertBefore solves the \"Operation Aborted\"\n\t\t\t// error in IE from appending to a node that isn't properly closed; see\n\t\t\t// dojo/tests/_base/loader/requirejs/simple-badbase.html for an example\n\t\t\tvar sibling = doc.getElementsByTagName(\"script\")[0],\n\t\t\t\tinsertPoint= sibling.parentNode;\n\t\t\treq.injectUrl = function(url, callback, owner){\n\t\t\t\t// insert a script element to the insert-point element with src=url;\n\t\t\t\t// apply callback upon detecting the script has loaded.\n\n\t\t\t\tvar node = owner.node = doc.createElement(\"script\"),\n\t\t\t\t\tonLoad = function(e){\n\t\t\t\t\t\te = e || window.event;\n\t\t\t\t\t\tvar node = e.target || e.srcElement;\n\t\t\t\t\t\tif(e.type === \"load\" || /complete|loaded/.test(node.readyState)){\n\t\t\t\t\t\t\tloadDisconnector();\n\t\t\t\t\t\t\terrorDisconnector();\n\t\t\t\t\t\t\tcallback && callback();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tloadDisconnector = domOn(node, \"load\", \"onreadystatechange\", onLoad),\n\t\t\t\t\terrorDisconnector = domOn(node, \"error\", \"onerror\", function(e){\n\t\t\t\t\t\tloadDisconnector();\n\t\t\t\t\t\terrorDisconnector();\n\t\t\t\t\t\tsignal(error, makeError(\"scriptError\", [url, e]));\n\t\t\t\t\t});\n\n\t\t\t\tnode.type = \"text/javascript\";\n\t\t\t\tnode.charset = \"utf-8\";\n\t\t\t\tnode.src = url;\n\t\t\t\tinsertPoint.insertBefore(node, sibling);\n\t\t\t\treturn node;\n\t\t\t};\n\t\t}\n\t}\n\n\tif( 1 ){\n\t\treq.log = function(){\n\t\t\ttry{\n\t\t\t\tfor(var i = 0; i < arguments.length; i++){\n\t\t\t\t\tconsole.log(arguments[i]);\n\t\t\t\t}\n\t\t\t}catch(e){}\n\t\t};\n\t}else{\n\t\treq.log = noop;\n\t}\n\n\tif( 0 ){\n\t\tvar trace = req.trace = function(\n\t\t\tgroup,\t// the trace group to which this application belongs\n\t\t\targs\t// the contents of the trace\n\t\t){\n\t\t\t///\n\t\t\t// Tracing interface by group.\n\t\t\t//\n\t\t\t// Sends the contents of args to the console iff (req.trace.on && req.trace[group])\n\n\t\t\tif(trace.on && trace.group[group]){\n\t\t\t\tsignal(\"trace\", [group, args]);\n\t\t\t\tfor(var arg, dump = [], text= \"trace:\" + group + (args.length ? (\":\" + args[0]) : \"\"), i= 1; i<args.length;){\n\t\t\t\t\targ = args[i++];\n\t\t\t\t\tif(isString(arg)){\n\t\t\t\t\t\ttext += \", \" + arg;\n\t\t\t\t\t}else{\n\t\t\t\t\t\tdump.push(arg);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treq.log(text);\n\t\t\t\tdump.length && dump.push(\".\");\n\t\t\t\treq.log.apply(req, dump);\n\t\t\t}\n\t\t};\n\t\tmix(trace, {\n\t\t\ton:1,\n\t\t\tgroup:{},\n\t\t\tset:function(group, value){\n\t\t\t\tif(isString(group)){\n\t\t\t\t\ttrace.group[group]= value;\n\t\t\t\t}else{\n\t\t\t\t\tmix(trace.group, group);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\ttrace.set(mix(mix(mix({}, defaultConfig.trace), userConfig.trace), dojoSniffConfig.trace));\n\t\ton(\"config\", function(config){\n\t\t\tconfig.trace && trace.set(config.trace);\n\t\t});\n\t}else{\n\t\treq.trace = noop;\n\t}\n\n\tvar def = function(\n\t\tmid,\t\t  //(commonjs.moduleId, optional) list of modules to be loaded before running factory\n\t\tdependencies, //(array of commonjs.moduleId, optional)\n\t\tfactory\t\t  //(any)\n\t){\n\t\t///\n\t\t// Advises the loader of a module factory. //Implements http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition.\n\t\t///\n\t\t//note\n\t\t// CommonJS factory scan courtesy of http://requirejs.org\n\n\t\tvar arity = arguments.length,\n\t\t\tdefaultDeps = [\"require\", \"exports\", \"module\"],\n\t\t\t// the predominate signature...\n\t\t\targs = [0, mid, dependencies];\n\t\tif(arity==1){\n\t\t\targs = [0, (isFunction(mid) ? defaultDeps : []), mid];\n\t\t}else if(arity==2 && isString(mid)){\n\t\t\targs = [mid, (isFunction(dependencies) ? defaultDeps : []), dependencies];\n\t\t}else if(arity==3){\n\t\t\targs = [mid, dependencies, factory];\n\t\t}\n\n\t\tif( 0  && args[1]===defaultDeps){\n\t\t\targs[2].toString()\n\t\t\t\t.replace(/(\\/\\*([\\s\\S]*?)\\*\\/|\\/\\/(.*)$)/mg, \"\")\n\t\t\t\t.replace(/require\\([\"']([\\w\\!\\-_\\.\\/]+)[\"']\\)/g, function(match, dep){\n\t\t\t\targs[1].push(dep);\n\t\t\t});\n\t\t}\n\n\t\treq.trace(\"loader-define\", args.slice(0, 2));\n\t\tvar targetModule = args[0] && getModule(args[0]),\n\t\t\tmodule;\n\t\tif(targetModule && !waiting[targetModule.mid]){\n\t\t\t// given a mid that hasn't been requested; therefore, defined through means other than injecting\n\t\t\t// consequent to a require() or define() application; examples include defining modules on-the-fly\n\t\t\t// due to some code path or including a module in a script element. In any case,\n\t\t\t// there is no callback waiting to finish processing and nothing to trigger the defQ and the\n\t\t\t// dependencies are never requested; therefore, do it here.\n\t\t\tinjectDependencies(defineModule(targetModule, args[1], args[2]));\n\t\t}else if(!has(\"ie-event-behavior\") || ! 1  || injectingCachedModule){\n\t\t\t// not IE path: anonymous module and therefore must have been injected; therefore, onLoad will fire immediately\n\t\t\t// after script finishes being evaluated and the defQ can be run from that callback to detect the module id\n\t\t\tdefQ.push(args);\n\t\t}else{\n\t\t\t// IE path: possibly anonymous module and therefore injected; therefore, cannot depend on 1-to-1,\n\t\t\t// in-order exec of onLoad with script eval (since it's IE) and must manually detect here\n\t\t\ttargetModule = targetModule || injectingModule;\n\t\t\tif(!targetModule){\n\t\t\t\tfor(mid in waiting){\n\t\t\t\t\tmodule = modules[mid];\n\t\t\t\t\tif(module && module.node && module.node.readyState === 'interactive'){\n\t\t\t\t\t\ttargetModule = module;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif( 0  && !targetModule){\n\t\t\t\t\tfor(var i = 0; i<combosPending.length; i++){\n\t\t\t\t\t\ttargetModule = combosPending[i];\n\t\t\t\t\t\tif(targetModule.node && targetModule.node.readyState === 'interactive'){\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttargetModule= 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif( 0  && isArray(targetModule)){\n\t\t\t\tinjectDependencies(defineModule(getModule(targetModule.shift()), args[1], args[2]));\n\t\t\t\tif(!targetModule.length){\n\t\t\t\t\tcombosPending.splice(i, 1);\n\t\t\t\t}\n\t\t\t}else if(targetModule){\n\t\t\t\tconsumePendingCacheInsert(targetModule);\n\t\t\t\tinjectDependencies(defineModule(targetModule, args[1], args[2]));\n\t\t\t}else{\n\t\t\t\tsignal(error, makeError(\"ieDefineFailed\", args[0]));\n\t\t\t}\n\t\t\tcheckComplete();\n\t\t}\n\t};\n\tdef.amd = {\n\t\tvendor:\"dojotoolkit.org\"\n\t};\n\n\tif( 0 ){\n\t\treq.def = def;\n\t}\n\n\t// allow config to override default implemention of named functions; this is useful for\n\t// non-browser environments, e.g., overriding injectUrl, getText, log, etc. in node.js, Rhino, etc.\n\t// also useful for testing and monkey patching loader\n\tmix(mix(req, defaultConfig.loaderPatch), userConfig.loaderPatch);\n\n\t// now that req is fully initialized and won't change, we can hook it up to the error signal\n\ton(error, function(arg){\n\t\ttry{\n\t\t\tconsole.error(arg);\n\t\t\tif(arg instanceof Error){\n\t\t\t\tfor(var p in arg){\n\t\t\t\t\tconsole.log(p + \":\", arg[p]);\n\t\t\t\t}\n\t\t\t\tconsole.log(\".\");\n\t\t\t}\n\t\t}catch(e){}\n\t});\n\n\t// always publish these\n\tmix(req, {\n\t\tuid:uid,\n\t\tcache:cache,\n\t\tpacks:packs\n\t});\n\n\n\tif( 0 ){\n\t\tmix(req, {\n\t\t\t// these may be interesting to look at when debugging\n\t\t\tpaths:paths,\n\t\t\taliases:aliases,\n\t\t\tmodules:modules,\n\t\t\tlegacyMode:legacyMode,\n\t\t\texecQ:execQ,\n\t\t\tdefQ:defQ,\n\t\t\twaiting:waiting,\n\n\t\t\t// these are used for testing\n\t\t\t// TODO: move testing infrastructure to a different has feature\n\t\t\tpacks:packs,\n\t\t\tmapProgs:mapProgs,\n\t\t\tpathsMapProg:pathsMapProg,\n\t\t\tlistenerQueues:listenerQueues,\n\n\t\t\t// these are used by the builder (at least)\n\t\t\tcomputeMapProg:computeMapProg,\n\t\t\trunMapProg:runMapProg,\n\t\t\tcompactPath:compactPath,\n\t\t\tgetModuleInfo:getModuleInfo_\n\t\t});\n\t}\n\n\t// the loader can be defined exactly once; look for global define which is the symbol AMD loaders are\n\t// *required* to define (as opposed to require, which is optional)\n\tif(global.define){\n\t\tif( 1 ){\n\t\t\tsignal(error, makeError(\"defineAlreadyDefined\", 0));\n\t\t}\n\t\treturn;\n\t}else{\n\t\tglobal.define = def;\n\t\tglobal.require = req;\n\t\tif( 0 ){\n\t\t\trequire= req;\n\t\t}\n\t}\n\n\tif( 0  && req.combo && req.combo.plugins){\n\t\tvar plugins = req.combo.plugins,\n\t\t\tpluginName;\n\t\tfor(pluginName in plugins){\n\t\t\tmix(mix(getModule(pluginName), plugins[pluginName]), {isCombo:1, executed:\"executed\", load:1});\n\t\t}\n\t}\n\n\tif( 1 ){\n\t\tforEach(delayedModuleConfig, function(c){ config(c); });\n\t\tvar bootDeps = dojoSniffConfig.deps ||\tuserConfig.deps || defaultConfig.deps,\n\t\t\tbootCallback = dojoSniffConfig.callback || userConfig.callback || defaultConfig.callback;\n\t\treq.boot = (bootDeps || bootCallback) ? [bootDeps || [], bootCallback] : 0;\n\t}\n\tif(! 1 ){\n\t\t!req.async && req([\"dojo\"]);\n\t\treq.boot && req.apply(null, req.boot);\n\t}\n})\n(this.dojoConfig || this.djConfig || this.require || {}, {\n\t\tasync:0,\n\t\thasCache:{\n\t\t\t\t'config-selectorEngine':\"acme\",\n\t\t\t\t'config-tlmSiblingOfDojo':1,\n\t\t\t\t'dojo-built':1,\n\t\t\t\t'dojo-loader':1,\n\t\t\t\tdom:1,\n\t\t\t\t'host-browser':1\n\t\t},\n\t\tpackages:[\n\t\t\t\t{\n\t\t\t\t\t location:\"../dijit\",\n\t\t\t\t\t name:\"dijit\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t location:\"../dojox\",\n\t\t\t\t\t name:\"dojox\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t location:\".\",\n\t\t\t\t\t name:\"dojo\"\n\t\t\t\t}\n\t\t]\n});require({cache:{\n'dojo/_base/fx':function(){\ndefine([\"./kernel\", \"./config\", /*===== \"./declare\", =====*/ \"./lang\", \"../Evented\", \"./Color\", \"./connect\", \"./sniff\", \"../dom\", \"../dom-style\"],\n\tfunction(dojo, config, /*===== declare, =====*/ lang, Evented, Color, connect, has, dom, style){\n\t// module:\n\t//\t\tdojo/_base/fx\n\t// notes:\n\t//\t\tAnimation loosely package based on Dan Pupius' work, contributed under CLA; see\n\t//\t\thttp://pupius.co.uk/js/Toolkit.Drawing.js\n\n\tvar _mixin = lang.mixin;\n\n\t// Module export\n\tvar basefx = {\n\t\t// summary:\n\t\t//\t\tThis module defines the base dojo/_base/fx implementation.\n\t};\n\n\tvar _Line = basefx._Line = function(/*int*/ start, /*int*/ end){\n\t\t// summary:\n\t\t//\t\tObject used to generate values from a start value to an end value\n\t\t// start: int\n\t\t//\t\tBeginning value for range\n\t\t// end: int\n\t\t//\t\tEnding value for range\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t};\n\n\t_Line.prototype.getValue = function(/*float*/ n){\n\t\t// summary:\n\t\t//\t\tReturns the point on the line\n\t\t// n:\n\t\t//\t\ta floating point number greater than 0 and less than 1\n\t\treturn ((this.end - this.start) * n) + this.start; // Decimal\n\t};\n\n\tvar Animation = basefx.Animation = function(args){\n\t\t// summary:\n\t\t//\t\tA generic animation class that fires callbacks into its handlers\n\t\t//\t\tobject at various states.\n\t\t// description:\n\t\t//\t\tA generic animation class that fires callbacks into its handlers\n\t\t//\t\tobject at various states. Nearly all dojo animation functions\n\t\t//\t\treturn an instance of this method, usually without calling the\n\t\t//\t\t.play() method beforehand. Therefore, you will likely need to\n\t\t//\t\tcall .play() on instances of `Animation` when one is\n\t\t//\t\treturned.\n\t\t// args: Object\n\t\t//\t\tThe 'magic argument', mixing all the properties into this\n\t\t//\t\tanimation instance.\n\n\t\t_mixin(this, args);\n\t\tif(lang.isArray(this.curve)){\n\t\t\tthis.curve = new _Line(this.curve[0], this.curve[1]);\n\t\t}\n\n\t};\n\tAnimation.prototype = new Evented();\n\n\tlang.extend(Animation, {\n\t\t// duration: Integer\n\t\t//\t\tThe time in milliseconds the animation will take to run\n\t\tduration: 350,\n\n\t/*=====\n\t\t// curve: _Line|Array\n\t\t//\t\tA two element array of start and end values, or a `_Line` instance to be\n\t\t//\t\tused in the Animation.\n\t\tcurve: null,\n\n\t\t// easing: Function?\n\t\t//\t\tA Function to adjust the acceleration (or deceleration) of the progress\n\t\t//\t\tacross a _Line\n\t\teasing: null,\n\t=====*/\n\n\t\t// repeat: Integer?\n\t\t//\t\tThe number of times to loop the animation\n\t\trepeat: 0,\n\n\t\t// rate: Integer?\n\t\t//\t\tthe time in milliseconds to wait before advancing to next frame\n\t\t//\t\t(used as a fps timer: 1000/rate = fps)\n\t\trate: 20 /* 50 fps */,\n\n\t/*=====\n\t\t// delay: Integer?\n\t\t//\t\tThe time in milliseconds to wait before starting animation after it\n\t\t//\t\thas been .play()'ed\n\t\tdelay: null,\n\n\t\t// beforeBegin: Event?\n\t\t//\t\tSynthetic event fired before a Animation begins playing (synchronous)\n\t\tbeforeBegin: null,\n\n\t\t// onBegin: Event?\n\t\t//\t\tSynthetic event fired as a Animation begins playing (useful?)\n\t\tonBegin: null,\n\n\t\t// onAnimate: Event?\n\t\t//\t\tSynthetic event fired at each interval of the Animation\n\t\tonAnimate: null,\n\n\t\t// onEnd: Event?\n\t\t//\t\tSynthetic event fired after the final frame of the Animation\n\t\tonEnd: null,\n\n\t\t// onPlay: Event?\n\t\t//\t\tSynthetic event fired any time the Animation is play()'ed\n\t\tonPlay: null,\n\n\t\t// onPause: Event?\n\t\t//\t\tSynthetic event fired when the Animation is paused\n\t\tonPause: null,\n\n\t\t// onStop: Event\n\t\t//\t\tSynthetic event fires when the Animation is stopped\n\t\tonStop: null,\n\n\t=====*/\n\n\t\t_percent: 0,\n\t\t_startRepeatCount: 0,\n\n\t\t_getStep: function(){\n\t\t\tvar _p = this._percent,\n\t\t\t\t_e = this.easing\n\t\t\t;\n\t\t\treturn _e ? _e(_p) : _p;\n\t\t},\n\t\t_fire: function(/*Event*/ evt, /*Array?*/ args){\n\t\t\t// summary:\n\t\t\t//\t\tConvenience function.  Fire event \"evt\" and pass it the\n\t\t\t//\t\targuments specified in \"args\".\n\t\t\t// description:\n\t\t\t//\t\tConvenience function.  Fire event \"evt\" and pass it the\n\t\t\t//\t\targuments specified in \"args\".\n\t\t\t//\t\tFires the callback in the scope of this Animation\n\t\t\t//\t\tinstance.\n\t\t\t// evt:\n\t\t\t//\t\tThe event to fire.\n\t\t\t// args:\n\t\t\t//\t\tThe arguments to pass to the event.\n\t\t\tvar a = args||[];\n\t\t\tif(this[evt]){\n\t\t\t\tif(config.debugAtAllCosts){\n\t\t\t\t\tthis[evt].apply(this, a);\n\t\t\t\t}else{\n\t\t\t\t\ttry{\n\t\t\t\t\t\tthis[evt].apply(this, a);\n\t\t\t\t\t}catch(e){\n\t\t\t\t\t\t// squelch and log because we shouldn't allow exceptions in\n\t\t\t\t\t\t// synthetic event handlers to cause the internal timer to run\n\t\t\t\t\t\t// amuck, potentially pegging the CPU. I'm not a fan of this\n\t\t\t\t\t\t// squelch, but hopefully logging will make it clear what's\n\t\t\t\t\t\t// going on\n\t\t\t\t\t\tconsole.error(\"exception in animation handler for:\", evt);\n\t\t\t\t\t\tconsole.error(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this; // Animation\n\t\t},\n\n\t\tplay: function(/*int?*/ delay, /*Boolean?*/ gotoStart){\n\t\t\t// summary:\n\t\t\t//\t\tStart the animation.\n\t\t\t// delay:\n\t\t\t//\t\tHow many milliseconds to delay before starting.\n\t\t\t// gotoStart:\n\t\t\t//\t\tIf true, starts the animation from the beginning; otherwise,\n\t\t\t//\t\tstarts it from its current position.\n\t\t\t// returns: Animation\n\t\t\t//\t\tThe instance to allow chaining.\n\n\t\t\tvar _t = this;\n\t\t\tif(_t._delayTimer){ _t._clearTimer(); }\n\t\t\tif(gotoStart){\n\t\t\t\t_t._stopTimer();\n\t\t\t\t_t._active = _t._paused = false;\n\t\t\t\t_t._percent = 0;\n\t\t\t}else if(_t._active && !_t._paused){\n\t\t\t\treturn _t;\n\t\t\t}\n\n\t\t\t_t._fire(\"beforeBegin\", [_t.node]);\n\n\t\t\tvar de = delay || _t.delay,\n\t\t\t\t_p = lang.hitch(_t, \"_play\", gotoStart);\n\n\t\t\tif(de > 0){\n\t\t\t\t_t._delayTimer = setTimeout(_p, de);\n\t\t\t\treturn _t;\n\t\t\t}\n\t\t\t_p();\n\t\t\treturn _t;\t// Animation\n\t\t},\n\n\t\t_play: function(gotoStart){\n\t\t\tvar _t = this;\n\t\t\tif(_t._delayTimer){ _t._clearTimer(); }\n\t\t\t_t._startTime = new Date().valueOf();\n\t\t\tif(_t._paused){\n\t\t\t\t_t._startTime -= _t.duration * _t._percent;\n\t\t\t}\n\n\t\t\t_t._active = true;\n\t\t\t_t._paused = false;\n\t\t\tvar value = _t.curve.getValue(_t._getStep());\n\t\t\tif(!_t._percent){\n\t\t\t\tif(!_t._startRepeatCount){\n\t\t\t\t\t_t._startRepeatCount = _t.repeat;\n\t\t\t\t}\n\t\t\t\t_t._fire(\"onBegin\", [value]);\n\t\t\t}\n\n\t\t\t_t._fire(\"onPlay\", [value]);\n\n\t\t\t_t._cycle();\n\t\t\treturn _t; // Animation\n\t\t},\n\n\t\tpause: function(){\n\t\t\t// summary:\n\t\t\t//\t\tPauses a running animation.\n\t\t\tvar _t = this;\n\t\t\tif(_t._delayTimer){ _t._clearTimer(); }\n\t\t\t_t._stopTimer();\n\t\t\tif(!_t._active){ return _t; /*Animation*/ }\n\t\t\t_t._paused = true;\n\t\t\t_t._fire(\"onPause\", [_t.curve.getValue(_t._getStep())]);\n\t\t\treturn _t; // Animation\n\t\t},\n\n\t\tgotoPercent: function(/*Decimal*/ percent, /*Boolean?*/ andPlay){\n\t\t\t// summary:\n\t\t\t//\t\tSets the progress of the animation.\n\t\t\t// percent:\n\t\t\t//\t\tA percentage in decimal notation (between and including 0.0 and 1.0).\n\t\t\t// andPlay:\n\t\t\t//\t\tIf true, play the animation after setting the progress.\n\t\t\tvar _t = this;\n\t\t\t_t._stopTimer();\n\t\t\t_t._active = _t._paused = true;\n\t\t\t_t._percent = percent;\n\t\t\tif(andPlay){ _t.play(); }\n\t\t\treturn _t; // Animation\n\t\t},\n\n\t\tstop: function(/*boolean?*/ gotoEnd){\n\t\t\t// summary:\n\t\t\t//\t\tStops a running animation.\n\t\t\t// gotoEnd:\n\t\t\t//\t\tIf true, the animation will end.\n\t\t\tvar _t = this;\n\t\t\tif(_t._delayTimer){ _t._clearTimer(); }\n\t\t\tif(!_t._timer){ return _t; /* Animation */ }\n\t\t\t_t._stopTimer();\n\t\t\tif(gotoEnd){\n\t\t\t\t_t._percent = 1;\n\t\t\t}\n\t\t\t_t._fire(\"onStop\", [_t.curve.getValue(_t._getStep())]);\n\t\t\t_t._active = _t._paused = false;\n\t\t\treturn _t; // Animation\n\t\t},\n\n\t\tstatus: function(){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a string token representation of the status of\n\t\t\t//\t\tthe animation, one of: \"paused\", \"playing\", \"stopped\"\n\t\t\tif(this._active){\n\t\t\t\treturn this._paused ? \"paused\" : \"playing\"; // String\n\t\t\t}\n\t\t\treturn \"stopped\"; // String\n\t\t},\n\n\t\t_cycle: function(){\n\t\t\tvar _t = this;\n\t\t\tif(_t._active){\n\t\t\t\tvar curr = new Date().valueOf();\n\t\t\t\t// Allow durations of 0 (instant) by setting step to 1 - see #13798\n\t\t\t\tvar step = _t.duration === 0 ? 1 : (curr - _t._startTime) / (_t.duration);\n\n\t\t\t\tif(step >= 1){\n\t\t\t\t\tstep = 1;\n\t\t\t\t}\n\t\t\t\t_t._percent = step;\n\n\t\t\t\t// Perform easing\n\t\t\t\tif(_t.easing){\n\t\t\t\t\tstep = _t.easing(step);\n\t\t\t\t}\n\n\t\t\t\t_t._fire(\"onAnimate\", [_t.curve.getValue(step)]);\n\n\t\t\t\tif(_t._percent < 1){\n\t\t\t\t\t_t._startTimer();\n\t\t\t\t}else{\n\t\t\t\t\t_t._active = false;\n\n\t\t\t\t\tif(_t.repeat > 0){\n\t\t\t\t\t\t_t.repeat--;\n\t\t\t\t\t\t_t.play(null, true);\n\t\t\t\t\t}else if(_t.repeat == -1){\n\t\t\t\t\t\t_t.play(null, true);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tif(_t._startRepeatCount){\n\t\t\t\t\t\t\t_t.repeat = _t._startRepeatCount;\n\t\t\t\t\t\t\t_t._startRepeatCount = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t_t._percent = 0;\n\t\t\t\t\t_t._fire(\"onEnd\", [_t.node]);\n\t\t\t\t\t!_t.repeat && _t._stopTimer();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn _t; // Animation\n\t\t},\n\n\t\t_clearTimer: function(){\n\t\t\t// summary:\n\t\t\t//\t\tClear the play delay timer\n\t\t\tclearTimeout(this._delayTimer);\n\t\t\tdelete this._delayTimer;\n\t\t}\n\n\t});\n\n\t// the local timer, stubbed into all Animation instances\n\tvar ctr = 0,\n\t\ttimer = null,\n\t\trunner = {\n\t\t\trun: function(){}\n\t\t};\n\n\tlang.extend(Animation, {\n\n\t\t_startTimer: function(){\n\t\t\tif(!this._timer){\n\t\t\t\tthis._timer = connect.connect(runner, \"run\", this, \"_cycle\");\n\t\t\t\tctr++;\n\t\t\t}\n\t\t\tif(!timer){\n\t\t\t\ttimer = setInterval(lang.hitch(runner, \"run\"), this.rate);\n\t\t\t}\n\t\t},\n\n\t\t_stopTimer: function(){\n\t\t\tif(this._timer){\n\t\t\t\tconnect.disconnect(this._timer);\n\t\t\t\tthis._timer = null;\n\t\t\t\tctr--;\n\t\t\t}\n\t\t\tif(ctr <= 0){\n\t\t\t\tclearInterval(timer);\n\t\t\t\ttimer = null;\n\t\t\t\tctr = 0;\n\t\t\t}\n\t\t}\n\n\t});\n\n\tvar _makeFadeable =\n\t\thas(\"ie\") ? function(node){\n\t\t\t// only set the zoom if the \"tickle\" value would be the same as the\n\t\t\t// default\n\t\t\tvar ns = node.style;\n\t\t\t// don't set the width to auto if it didn't already cascade that way.\n\t\t\t// We don't want to f anyones designs\n\t\t\tif(!ns.width.length && style.get(node, \"width\") == \"auto\"){\n\t\t\t\tns.width = \"auto\";\n\t\t\t}\n\t\t} :\n\t\tfunction(){};\n\n\tbasefx._fade = function(/*Object*/ args){\n\t\t// summary:\n\t\t//\t\tReturns an animation that will fade the node defined by\n\t\t//\t\targs.node from the start to end values passed (args.start\n\t\t//\t\targs.end) (end is mandatory, start is optional)\n\n\t\targs.node = dom.byId(args.node);\n\t\tvar fArgs = _mixin({ properties: {} }, args),\n\t\t\tprops = (fArgs.properties.opacity = {});\n\n\t\tprops.start = !(\"start\" in fArgs) ?\n\t\t\tfunction(){\n\t\t\t\treturn +style.get(fArgs.node, \"opacity\")||0;\n\t\t\t} : fArgs.start;\n\t\tprops.end = fArgs.end;\n\n\t\tvar anim = basefx.animateProperty(fArgs);\n\t\tconnect.connect(anim, \"beforeBegin\", lang.partial(_makeFadeable, fArgs.node));\n\n\t\treturn anim; // Animation\n\t};\n\n\t/*=====\n\tvar __FadeArgs = declare(null, {\n\t\t// node: DOMNode|String\n\t\t//\t\tThe node referenced in the animation\n\t\t// duration: Integer?\n\t\t//\t\tDuration of the animation in milliseconds.\n\t\t// easing: Function?\n\t\t//\t\tAn easing function.\n\t});\n\t=====*/\n\n\tbasefx.fadeIn = function(/*__FadeArgs*/ args){\n\t\t// summary:\n\t\t//\t\tReturns an animation that will fade node defined in 'args' from\n\t\t//\t\tits current opacity to fully opaque.\n\t\treturn basefx._fade(_mixin({ end: 1 }, args)); // Animation\n\t};\n\n\tbasefx.fadeOut = function(/*__FadeArgs*/ args){\n\t\t// summary:\n\t\t//\t\tReturns an animation that will fade node defined in 'args'\n\t\t//\t\tfrom its current opacity to fully transparent.\n\t\treturn basefx._fade(_mixin({ end: 0 }, args)); // Animation\n\t};\n\n\tbasefx._defaultEasing = function(/*Decimal?*/ n){\n\t\t// summary:\n\t\t//\t\tThe default easing function for Animation(s)\n\t\treturn 0.5 + ((Math.sin((n + 1.5) * Math.PI)) / 2);\t// Decimal\n\t};\n\n\tvar PropLine = function(properties){\n\t\t// PropLine is an internal class which is used to model the values of\n\t\t// an a group of CSS properties across an animation lifecycle. In\n\t\t// particular, the \"getValue\" function handles getting interpolated\n\t\t// values between start and end for a particular CSS value.\n\t\tthis._properties = properties;\n\t\tfor(var p in properties){\n\t\t\tvar prop = properties[p];\n\t\t\tif(prop.start instanceof Color){\n\t\t\t\t// create a reusable temp color object to keep intermediate results\n\t\t\t\tprop.tempColor = new Color();\n\t\t\t}\n\t\t}\n\t};\n\n\tPropLine.prototype.getValue = function(r){\n\t\tvar ret = {};\n\t\tfor(var p in this._properties){\n\t\t\tvar prop = this._properties[p],\n\t\t\t\tstart = prop.start;\n\t\t\tif(start instanceof Color){\n\t\t\t\tret[p] = Color.blendColors(start, prop.end, r, prop.tempColor).toCss();\n\t\t\t}else if(!lang.isArray(start)){\n\t\t\t\tret[p] = ((prop.end - start) * r) + start + (p != \"opacity\" ? prop.units || \"px\" : 0);\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t/*=====\n\tvar __AnimArgs = declare(__FadeArgs, {\n\t\t// properties: Object?\n\t\t//\t\tA hash map of style properties to Objects describing the transition,\n\t\t//\t\tsuch as the properties of _Line with an additional 'units' property\n\t\tproperties: {}\n\n\t\t//TODOC: add event callbacks\n\t});\n\t=====*/\n\n\tbasefx.animateProperty = function(/*__AnimArgs*/ args){\n\t\t// summary:\n\t\t//\t\tReturns an animation that will transition the properties of\n\t\t//\t\tnode defined in `args` depending how they are defined in\n\t\t//\t\t`args.properties`\n\t\t//\n\t\t// description:\n\t\t//\t\tFoundation of most `dojo/_base/fx`\n\t\t//\t\tanimations. It takes an object of \"properties\" corresponding to\n\t\t//\t\tstyle properties, and animates them in parallel over a set\n\t\t//\t\tduration.\n\t\t//\n\t\t// example:\n\t\t//\t\tA simple animation that changes the width of the specified node.\n\t\t//\t|\tbasefx.animateProperty({\n\t\t//\t|\t\tnode: \"nodeId\",\n\t\t//\t|\t\tproperties: { width: 400 },\n\t\t//\t|\t}).play();\n\t\t//\t\tDojo figures out the start value for the width and converts the\n\t\t//\t\tinteger specified for the width to the more expressive but\n\t\t//\t\tverbose form `{ width: { end: '400', units: 'px' } }` which you\n\t\t//\t\tcan also specify directly. Defaults to 'px' if omitted.\n\t\t//\n\t\t// example:\n\t\t//\t\tAnimate width, height, and padding over 2 seconds... the\n\t\t//\t\tpedantic way:\n\t\t//\t|\tbasefx.animateProperty({ node: node, duration:2000,\n\t\t//\t|\t\tproperties: {\n\t\t//\t|\t\t\twidth: { start: '200', end: '400', units:\"px\" },\n\t\t//\t|\t\t\theight: { start:'200', end: '400', units:\"px\" },\n\t\t//\t|\t\t\tpaddingTop: { start:'5', end:'50', units:\"px\" }\n\t\t//\t|\t\t}\n\t\t//\t|\t}).play();\n\t\t//\t\tNote 'paddingTop' is used over 'padding-top'. Multi-name CSS properties\n\t\t//\t\tare written using \"mixed case\", as the hyphen is illegal as an object key.\n\t\t//\n\t\t// example:\n\t\t//\t\tPlug in a different easing function and register a callback for\n\t\t//\t\twhen the animation ends. Easing functions accept values between\n\t\t//\t\tzero and one and return a value on that basis. In this case, an\n\t\t//\t\texponential-in curve.\n\t\t//\t|\tbasefx.animateProperty({\n\t\t//\t|\t\tnode: \"nodeId\",\n\t\t//\t|\t\t// dojo figures out the start value\n\t\t//\t|\t\tproperties: { width: { end: 400 } },\n\t\t//\t|\t\teasing: function(n){\n\t\t//\t|\t\t\treturn (n==0) ? 0 : Math.pow(2, 10 * (n - 1));\n\t\t//\t|\t\t},\n\t\t//\t|\t\tonEnd: function(node){\n\t\t//\t|\t\t\t// called when the animation finishes. The animation\n\t\t//\t|\t\t\t// target is passed to this function\n\t\t//\t|\t\t}\n\t\t//\t|\t}).play(500); // delay playing half a second\n\t\t//\n\t\t// example:\n\t\t//\t\tLike all `Animation`s, animateProperty returns a handle to the\n\t\t//\t\tAnimation instance, which fires the events common to Dojo FX. Use `aspect.after`\n\t\t//\t\tto access these events outside of the Animation definition:\n\t\t//\t|\tvar anim = basefx.animateProperty({\n\t\t//\t|\t\tnode:\"someId\",\n\t\t//\t|\t\tproperties:{\n\t\t//\t|\t\t\twidth:400, height:500\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\taspect.after(anim, \"onEnd\", function(){\n\t\t//\t|\t\tconsole.log(\"animation ended\");\n\t\t//\t|\t}, true);\n\t\t//\t|\t// play the animation now:\n\t\t//\t|\tanim.play();\n\t\t//\n\t\t// example:\n\t\t//\t\tEach property can be a function whose return value is substituted along.\n\t\t//\t\tAdditionally, each measurement (eg: start, end) can be a function. The node\n\t\t//\t\treference is passed directly to callbacks.\n\t\t//\t|\tbasefx.animateProperty({\n\t\t//\t|\t\tnode:\"mine\",\n\t\t//\t|\t\tproperties:{\n\t\t//\t|\t\t\theight:function(node){\n\t\t//\t|\t\t\t\t// shrink this node by 50%\n\t\t//\t|\t\t\t\treturn domGeom.position(node).h / 2\n\t\t//\t|\t\t\t},\n\t\t//\t|\t\t\twidth:{\n\t\t//\t|\t\t\t\tstart:function(node){ return 100; },\n\t\t//\t|\t\t\t\tend:function(node){ return 200; }\n\t\t//\t|\t\t\t}\n\t\t//\t|\t\t}\n\t\t//\t|\t}).play();\n\t\t//\n\n\t\tvar n = args.node = dom.byId(args.node);\n\t\tif(!args.easing){ args.easing = dojo._defaultEasing; }\n\n\t\tvar anim = new Animation(args);\n\t\tconnect.connect(anim, \"beforeBegin\", anim, function(){\n\t\t\tvar pm = {};\n\t\t\tfor(var p in this.properties){\n\t\t\t\t// Make shallow copy of properties into pm because we overwrite\n\t\t\t\t// some values below. In particular if start/end are functions\n\t\t\t\t// we don't want to overwrite them or the functions won't be\n\t\t\t\t// called if the animation is reused.\n\t\t\t\tif(p == \"width\" || p == \"height\"){\n\t\t\t\t\tthis.node.display = \"block\";\n\t\t\t\t}\n\t\t\t\tvar prop = this.properties[p];\n\t\t\t\tif(lang.isFunction(prop)){\n\t\t\t\t\tprop = prop(n);\n\t\t\t\t}\n\t\t\t\tprop = pm[p] = _mixin({}, (lang.isObject(prop) ? prop: { end: prop }));\n\n\t\t\t\tif(lang.isFunction(prop.start)){\n\t\t\t\t\tprop.start = prop.start(n);\n\t\t\t\t}\n\t\t\t\tif(lang.isFunction(prop.end)){\n\t\t\t\t\tprop.end = prop.end(n);\n\t\t\t\t}\n\t\t\t\tvar isColor = (p.toLowerCase().indexOf(\"color\") >= 0);\n\t\t\t\tfunction getStyle(node, p){\n\t\t\t\t\t// domStyle.get(node, \"height\") can return \"auto\" or \"\" on IE; this is more reliable:\n\t\t\t\t\tvar v = { height: node.offsetHeight, width: node.offsetWidth }[p];\n\t\t\t\t\tif(v !== undefined){ return v; }\n\t\t\t\t\tv = style.get(node, p);\n\t\t\t\t\treturn (p == \"opacity\") ? +v : (isColor ? v : parseFloat(v));\n\t\t\t\t}\n\t\t\t\tif(!(\"end\" in prop)){\n\t\t\t\t\tprop.end = getStyle(n, p);\n\t\t\t\t}else if(!(\"start\" in prop)){\n\t\t\t\t\tprop.start = getStyle(n, p);\n\t\t\t\t}\n\n\t\t\t\tif(isColor){\n\t\t\t\t\tprop.start = new Color(prop.start);\n\t\t\t\t\tprop.end = new Color(prop.end);\n\t\t\t\t}else{\n\t\t\t\t\tprop.start = (p == \"opacity\") ? +prop.start : parseFloat(prop.start);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.curve = new PropLine(pm);\n\t\t});\n\t\tconnect.connect(anim, \"onAnimate\", lang.hitch(style, \"set\", anim.node));\n\t\treturn anim; // Animation\n\t};\n\n\tbasefx.anim = function(\t/*DOMNode|String*/\tnode,\n\t\t\t\t\t\t\t/*Object*/\t\t\tproperties,\n\t\t\t\t\t\t\t/*Integer?*/\t\tduration,\n\t\t\t\t\t\t\t/*Function?*/\t\teasing,\n\t\t\t\t\t\t\t/*Function?*/\t\tonEnd,\n\t\t\t\t\t\t\t/*Integer?*/\t\tdelay){\n\t\t// summary:\n\t\t//\t\tA simpler interface to `animateProperty()`, also returns\n\t\t//\t\tan instance of `Animation` but begins the animation\n\t\t//\t\timmediately, unlike nearly every other Dojo animation API.\n\t\t// description:\n\t\t//\t\tSimpler (but somewhat less powerful) version\n\t\t//\t\tof `animateProperty`.  It uses defaults for many basic properties\n\t\t//\t\tand allows for positional parameters to be used in place of the\n\t\t//\t\tpacked \"property bag\" which is used for other Dojo animation\n\t\t//\t\tmethods.\n\t\t//\n\t\t//\t\tThe `Animation` object returned will be already playing, so\n\t\t//\t\tcalling play() on it again is (usually) a no-op.\n\t\t// node:\n\t\t//\t\ta DOM node or the id of a node to animate CSS properties on\n\t\t// duration:\n\t\t//\t\tThe number of milliseconds over which the animation\n\t\t//\t\tshould run. Defaults to the global animation default duration\n\t\t//\t\t(350ms).\n\t\t// easing:\n\t\t//\t\tAn easing function over which to calculate acceleration\n\t\t//\t\tand deceleration of the animation through its duration.\n\t\t//\t\tA default easing algorithm is provided, but you may\n\t\t//\t\tplug in any you wish. A large selection of easing algorithms\n\t\t//\t\tare available in `dojo/fx/easing`.\n\t\t// onEnd:\n\t\t//\t\tA function to be called when the animation finishes\n\t\t//\t\trunning.\n\t\t// delay:\n\t\t//\t\tThe number of milliseconds to delay beginning the\n\t\t//\t\tanimation by. The default is 0.\n\t\t// example:\n\t\t//\t\tFade out a node\n\t\t//\t|\tbasefx.anim(\"id\", { opacity: 0 });\n\t\t// example:\n\t\t//\t\tFade out a node over a full second\n\t\t//\t|\tbasefx.anim(\"id\", { opacity: 0 }, 1000);\n\t\treturn basefx.animateProperty({ // Animation\n\t\t\tnode: node,\n\t\t\tduration: duration || Animation.prototype.duration,\n\t\t\tproperties: properties,\n\t\t\teasing: easing,\n\t\t\tonEnd: onEnd\n\t\t}).play(delay || 0);\n\t};\n\n\n\tif( 1 ){\n\t\t_mixin(dojo, basefx);\n\t\t// Alias to drop come 2.0:\n\t\tdojo._Animation = Animation;\n\t}\n\n\treturn basefx;\n});\n\n},\n'dojo/dom-form':function(){\ndefine([\"./_base/lang\", \"./dom\", \"./io-query\", \"./json\"], function(lang, dom, ioq, json){\n\t// module:\n\t//\t\tdojo/dom-form\n\n    function setValue(/*Object*/ obj, /*String*/ name, /*String*/ value){\n        // summary:\n        //\t\tFor the named property in object, set the value. If a value\n        //\t\talready exists and it is a string, convert the value to be an\n        //\t\tarray of values.\n\n        // Skip it if there is no value\n        if(value === null){\n            return;\n        }\n\n        var val = obj[name];\n        if(typeof val == \"string\"){ // inline'd type check\n            obj[name] = [val, value];\n        }else if(lang.isArray(val)){\n            val.push(value);\n        }else{\n            obj[name] = value;\n        }\n    }\n\n\tvar exclude = \"file|submit|image|reset|button\";\n\n\tvar form = {\n\t\t// summary:\n\t\t//\t\tThis module defines form-processing functions.\n\n\t\tfieldToObject: function fieldToObject(/*DOMNode|String*/ inputNode){\n\t\t\t// summary:\n\t\t\t//\t\tSerialize a form field to a JavaScript object.\n\t\t\t// description:\n\t\t\t//\t\tReturns the value encoded in a form field as\n\t\t\t//\t\tas a string or an array of strings. Disabled form elements\n\t\t\t//\t\tand unchecked radio and checkboxes are skipped.\tMulti-select\n\t\t\t//\t\telements are returned as an array of string values.\n\t\t\t// inputNode: DOMNode|String\n\t\t\t// returns: Object\n\n\t\t\tvar ret = null;\n\t\t\tinputNode = dom.byId(inputNode);\n\t\t\tif(inputNode){\n\t\t\t\tvar _in = inputNode.name, type = (inputNode.type || \"\").toLowerCase();\n\t\t\t\tif(_in && type && !inputNode.disabled){\n\t\t\t\t\tif(type == \"radio\" || type == \"checkbox\"){\n\t\t\t\t\t\tif(inputNode.checked){\n\t\t\t\t\t\t\tret = inputNode.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(inputNode.multiple){\n\t\t\t\t\t\tret = [];\n\t\t\t\t\t\tvar nodes = [inputNode.firstChild];\n\t\t\t\t\t\twhile(nodes.length){\n\t\t\t\t\t\t\tfor(var node = nodes.pop(); node; node = node.nextSibling){\n\t\t\t\t\t\t\t\tif(node.nodeType == 1 && node.tagName.toLowerCase() == \"option\"){\n\t\t\t\t\t\t\t\t\tif(node.selected){\n\t\t\t\t\t\t\t\t\t\tret.push(node.value);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\tif(node.nextSibling){\n\t\t\t\t\t\t\t\t\t\tnodes.push(node.nextSibling);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif(node.firstChild){\n\t\t\t\t\t\t\t\t\t\tnodes.push(node.firstChild);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tret = inputNode.value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret; // Object\n\t\t},\n\n\t\ttoObject: function formToObject(/*DOMNode|String*/ formNode){\n\t\t\t// summary:\n\t\t\t//\t\tSerialize a form node to a JavaScript object.\n\t\t\t// description:\n\t\t\t//\t\tReturns the values encoded in an HTML form as\n\t\t\t//\t\tstring properties in an object which it then returns. Disabled form\n\t\t\t//\t\telements, buttons, and other non-value form elements are skipped.\n\t\t\t//\t\tMulti-select elements are returned as an array of string values.\n\t\t\t// formNode: DOMNode|String\n\t\t\t// example:\n\t\t\t//\t\tThis form:\n\t\t\t//\t\t|\t<form id=\"test_form\">\n\t\t\t//\t\t|\t\t<input type=\"text\" name=\"blah\" value=\"blah\">\n\t\t\t//\t\t|\t\t<input type=\"text\" name=\"no_value\" value=\"blah\" disabled>\n\t\t\t//\t\t|\t\t<input type=\"button\" name=\"no_value2\" value=\"blah\">\n\t\t\t//\t\t|\t\t<select type=\"select\" multiple name=\"multi\" size=\"5\">\n\t\t\t//\t\t|\t\t\t<option value=\"blah\">blah</option>\n\t\t\t//\t\t|\t\t\t<option value=\"thud\" selected>thud</option>\n\t\t\t//\t\t|\t\t\t<option value=\"thonk\" selected>thonk</option>\n\t\t\t//\t\t|\t\t</select>\n\t\t\t//\t\t|\t</form>\n\t\t\t//\n\t\t\t//\t\tyields this object structure as the result of a call to\n\t\t\t//\t\tformToObject():\n\t\t\t//\n\t\t\t//\t\t|\t{\n\t\t\t//\t\t|\t\tblah: \"blah\",\n\t\t\t//\t\t|\t\tmulti: [\n\t\t\t//\t\t|\t\t\t\"thud\",\n\t\t\t//\t\t|\t\t\t\"thonk\"\n\t\t\t//\t\t|\t\t]\n\t\t\t//\t\t|\t};\n\n\t\t\tvar ret = {}, elems = dom.byId(formNode).elements;\n\t\t\tfor(var i = 0, l = elems.length; i < l; ++i){\n\t\t\t\tvar item = elems[i], _in = item.name, type = (item.type || \"\").toLowerCase();\n\t\t\t\tif(_in && type && exclude.indexOf(type) < 0 && !item.disabled){\n\t\t\t\t\tsetValue(ret, _in, form.fieldToObject(item));\n\t\t\t\t\tif(type == \"image\"){\n\t\t\t\t\t\tret[_in + \".x\"] = ret[_in + \".y\"] = ret[_in].x = ret[_in].y = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret; // Object\n\t\t},\n\n\t\ttoQuery: function formToQuery(/*DOMNode|String*/ formNode){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a URL-encoded string representing the form passed as either a\n\t\t\t//\t\tnode or string ID identifying the form to serialize\n\t\t\t// formNode: DOMNode|String\n\t\t\t// returns: String\n\n\t\t\treturn ioq.objectToQuery(form.toObject(formNode)); // String\n\t\t},\n\n\t\ttoJson: function formToJson(/*DOMNode|String*/ formNode, /*Boolean?*/ prettyPrint){\n\t\t\t// summary:\n\t\t\t//\t\tCreate a serialized JSON string from a form node or string\n\t\t\t//\t\tID identifying the form to serialize\n\t\t\t// formNode: DOMNode|String\n\t\t\t// prettyPrint: Boolean?\n\t\t\t// returns: String\n\n\t\t\treturn json.stringify(form.toObject(formNode), null, prettyPrint ? 4 : 0); // String\n\t\t}\n\t};\n\n    return form;\n});\n\n},\n'dojo/i18n':function(){\ndefine([\"./_base/kernel\", \"require\", \"./has\", \"./_base/array\", \"./_base/config\", \"./_base/lang\", \"./_base/xhr\", \"./json\", \"module\"],\n\tfunction(dojo, require, has, array, config, lang, xhr, json, module){\n\n\t// module:\n\t//\t\tdojo/i18n\n\n\thas.add(\"dojo-preload-i18n-Api\",\n\t\t// if true, define the preload localizations machinery\n\t\t1\n\t);\n\n\t 1 || has.add(\"dojo-v1x-i18n-Api\",\n\t\t// if true, define the v1.x i18n functions\n\t\t1\n\t);\n\n\tvar\n\t\tthisModule = dojo.i18n =\n\t\t\t{\n\t\t\t\t// summary:\n\t\t\t\t//\t\tThis module implements the dojo/i18n! plugin and the v1.6- i18n API\n\t\t\t\t// description:\n\t\t\t\t//\t\tWe choose to include our own plugin to leverage functionality already contained in dojo\n\t\t\t\t//\t\tand thereby reduce the size of the plugin compared to various loader implementations. Also, this\n\t\t\t\t//\t\tallows foreign AMD loaders to be used without their plugins.\n\t\t\t},\n\n\t\tnlsRe =\n\t\t\t// regexp for reconstructing the master bundle name from parts of the regexp match\n\t\t\t// nlsRe.exec(\"foo/bar/baz/nls/en-ca/foo\") gives:\n\t\t\t// [\"foo/bar/baz/nls/en-ca/foo\", \"foo/bar/baz/nls/\", \"/\", \"/\", \"en-ca\", \"foo\"]\n\t\t\t// nlsRe.exec(\"foo/bar/baz/nls/foo\") gives:\n\t\t\t// [\"foo/bar/baz/nls/foo\", \"foo/bar/baz/nls/\", \"/\", \"/\", \"foo\", \"\"]\n\t\t\t// so, if match[5] is blank, it means this is the top bundle definition.\n\t\t\t// courtesy of http://requirejs.org\n\t\t\t/(^.*(^|\\/)nls)(\\/|$)([^\\/]*)\\/?([^\\/]*)/,\n\n\t\tgetAvailableLocales = function(\n\t\t\troot,\n\t\t\tlocale,\n\t\t\tbundlePath,\n\t\t\tbundleName\n\t\t){\n\t\t\t// summary:\n\t\t\t//\t\treturn a vector of module ids containing all available locales with respect to the target locale\n\t\t\t//\t\tFor example, assuming:\n\t\t\t//\n\t\t\t//\t\t- the root bundle indicates specific bundles for \"fr\" and \"fr-ca\",\n\t\t\t//\t\t-  bundlePath is \"myPackage/nls\"\n\t\t\t//\t\t- bundleName is \"myBundle\"\n\t\t\t//\n\t\t\t//\t\tThen a locale argument of \"fr-ca\" would return\n\t\t\t//\n\t\t\t//\t\t\t[\"myPackage/nls/myBundle\", \"myPackage/nls/fr/myBundle\", \"myPackage/nls/fr-ca/myBundle\"]\n\t\t\t//\n\t\t\t//\t\tNotice that bundles are returned least-specific to most-specific, starting with the root.\n\t\t\t//\n\t\t\t//\t\tIf root===false indicates we're working with a pre-AMD i18n bundle that doesn't tell about the available locales;\n\t\t\t//\t\ttherefore, assume everything is available and get 404 errors that indicate a particular localization is not available\n\n\t\t\tfor(var result = [bundlePath + bundleName], localeParts = locale.split(\"-\"), current = \"\", i = 0; i<localeParts.length; i++){\n\t\t\t\tcurrent += (current ? \"-\" : \"\") + localeParts[i];\n\t\t\t\tif(!root || root[current]){\n\t\t\t\t\tresult.push(bundlePath + current + \"/\" + bundleName);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\n\t\tcache = {},\n\n\t\tgetBundleName = function(moduleName, bundleName, locale){\n\t\t\tlocale = locale ? locale.toLowerCase() : dojo.locale;\n\t\t\tmoduleName = moduleName.replace(/\\./g, \"/\");\n\t\t\tbundleName = bundleName.replace(/\\./g, \"/\");\n\t\t\treturn (/root/i.test(locale)) ?\n\t\t\t\t(moduleName + \"/nls/\" + bundleName) :\n\t\t\t\t(moduleName + \"/nls/\" + locale + \"/\" + bundleName);\n\t\t},\n\n\t\tgetL10nName = dojo.getL10nName = function(moduleName, bundleName, locale){\n\t\t\treturn moduleName = module.id + \"!\" + getBundleName(moduleName, bundleName, locale);\n\t\t},\n\n\t\tdoLoad = function(require, bundlePathAndName, bundlePath, bundleName, locale, load){\n\t\t\t// summary:\n\t\t\t//\t\tget the root bundle which instructs which other bundles are required to construct the localized bundle\n\t\t\trequire([bundlePathAndName], function(root){\n\t\t\t\tvar current = lang.clone(root.root),\n\t\t\t\t\tavailableLocales = getAvailableLocales(!root._v1x && root, locale, bundlePath, bundleName);\n\t\t\t\trequire(availableLocales, function(){\n\t\t\t\t\tfor (var i = 1; i<availableLocales.length; i++){\n\t\t\t\t\t\tcurrent = lang.mixin(lang.clone(current), arguments[i]);\n\t\t\t\t\t}\n\t\t\t\t\t// target may not have been resolve (e.g., maybe only \"fr\" exists when \"fr-ca\" was requested)\n\t\t\t\t\tvar target = bundlePathAndName + \"/\" + locale;\n\t\t\t\t\tcache[target] = current;\n\t\t\t\t\tload();\n\t\t\t\t});\n\t\t\t});\n\t\t},\n\n\t\tnormalize = function(id, toAbsMid){\n\t\t\t// summary:\n\t\t\t//\t\tid may be relative.\n\t\t\t//\t\tpreload has form `*preload*<path>/nls/<module>*<flattened locales>` and\n\t\t\t//\t\ttherefore never looks like a relative\n\t\t\treturn /^\\./.test(id) ? toAbsMid(id) : id;\n\t\t},\n\n\t\tgetLocalesToLoad = function(targetLocale){\n\t\t\tvar list = config.extraLocale || [];\n\t\t\tlist = lang.isArray(list) ? list : [list];\n\t\t\tlist.push(targetLocale);\n\t\t\treturn list;\n\t\t},\n\n\t\tload = function(id, require, load){\n\t\t\t// summary:\n\t\t\t//\t\tid is in one of the following formats\n\t\t\t//\n\t\t\t//\t\t1. <path>/nls/<bundle>\n\t\t\t//\t\t\t=> load the bundle, localized to config.locale; load all bundles localized to\n\t\t\t//\t\t\tconfig.extraLocale (if any); return the loaded bundle localized to config.locale.\n\t\t\t//\n\t\t\t//\t\t2. <path>/nls/<locale>/<bundle>\n\t\t\t//\t\t\t=> load then return the bundle localized to <locale>\n\t\t\t//\n\t\t\t//\t\t3. *preload*<path>/nls/<module>*<JSON array of available locales>\n\t\t\t//\t\t\t=> for config.locale and all config.extraLocale, load all bundles found\n\t\t\t//\t\t\tin the best-matching bundle rollup. A value of 1 is returned, which\n\t\t\t//\t\t\tis meaningless other than to say the plugin is executing the requested\n\t\t\t//\t\t\tpreloads\n\t\t\t//\n\t\t\t//\t\tIn cases 1 and 2, <path> is always normalized to an absolute module id upon entry; see\n\t\t\t//\t\tnormalize. In case 3, it <path> is assumed to be absolute; this is arranged by the builder.\n\t\t\t//\n\t\t\t//\t\tTo load a bundle means to insert the bundle into the plugin's cache and publish the bundle\n\t\t\t//\t\tvalue to the loader. Given <path>, <bundle>, and a particular <locale>, the cache key\n\t\t\t//\n\t\t\t//\t\t\t<path>/nls/<bundle>/<locale>\n\t\t\t//\n\t\t\t//\t\twill hold the value. Similarly, then plugin will publish this value to the loader by\n\t\t\t//\n\t\t\t//\t\t\tdefine(\"<path>/nls/<bundle>/<locale>\", <bundle-value>);\n\t\t\t//\n\t\t\t//\t\tGiven this algorithm, other machinery can provide fast load paths be preplacing\n\t\t\t//\t\tvalues in the plugin's cache, which is public. When a load is demanded the\n\t\t\t//\t\tcache is inspected before starting any loading. Explicitly placing values in the plugin\n\t\t\t//\t\tcache is an advanced/experimental feature that should not be needed; use at your own risk.\n\t\t\t//\n\t\t\t//\t\tFor the normal AMD algorithm, the root bundle is loaded first, which instructs the\n\t\t\t//\t\tplugin what additional localized bundles are required for a particular locale. These\n\t\t\t//\t\tadditional locales are loaded and a mix of the root and each progressively-specific\n\t\t\t//\t\tlocale is returned. For example:\n\t\t\t//\n\t\t\t//\t\t1. The client demands \"dojo/i18n!some/path/nls/someBundle\n\t\t\t//\n\t\t\t//\t\t2. The loader demands load(some/path/nls/someBundle)\n\t\t\t//\n\t\t\t//\t\t3. This plugin require's \"some/path/nls/someBundle\", which is the root bundle.\n\t\t\t//\n\t\t\t//\t\t4. Assuming config.locale is \"ab-cd-ef\" and the root bundle indicates that localizations\n\t\t\t//\t\tare available for \"ab\" and \"ab-cd-ef\" (note the missing \"ab-cd\", then the plugin\n\t\t\t//\t\trequires \"some/path/nls/ab/someBundle\" and \"some/path/nls/ab-cd-ef/someBundle\"\n\t\t\t//\n\t\t\t//\t\t5. Upon receiving all required bundles, the plugin constructs the value of the bundle\n\t\t\t//\t\tab-cd-ef as...\n\t\t\t//\n\t\t\t//\t\t\t\tmixin(mixin(mixin({}, require(\"some/path/nls/someBundle\"),\n\t\t\t//\t\t  \t\t\trequire(\"some/path/nls/ab/someBundle\")),\n\t\t\t//\t\t\t\t\trequire(\"some/path/nls/ab-cd-ef/someBundle\"));\n\t\t\t//\n\t\t\t//\t\tThis value is inserted into the cache and published to the loader at the\n\t\t\t//\t\tkey/module-id some/path/nls/someBundle/ab-cd-ef.\n\t\t\t//\n\t\t\t//\t\tThe special preload signature (case 3) instructs the plugin to stop servicing all normal requests\n\t\t\t//\t\t(further preload requests will be serviced) until all ongoing preloading has completed.\n\t\t\t//\n\t\t\t//\t\tThe preload signature instructs the plugin that a special rollup module is available that contains\n\t\t\t//\t\tone or more flattened, localized bundles. The JSON array of available locales indicates which locales\n\t\t\t//\t\tare available. Here is an example:\n\t\t\t//\n\t\t\t//\t\t\t*preload*some/path/nls/someModule*[\"root\", \"ab\", \"ab-cd-ef\"]\n\t\t\t//\n\t\t\t//\t\tThis indicates the following rollup modules are available:\n\t\t\t//\n\t\t\t//\t\t\tsome/path/nls/someModule_ROOT\n\t\t\t//\t\t\tsome/path/nls/someModule_ab\n\t\t\t//\t\t\tsome/path/nls/someModule_ab-cd-ef\n\t\t\t//\n\t\t\t//\t\tEach of these modules is a normal AMD module that contains one or more flattened bundles in a hash.\n\t\t\t//\t\tFor example, assume someModule contained the bundles some/bundle/path/someBundle and\n\t\t\t//\t\tsome/bundle/path/someOtherBundle, then some/path/nls/someModule_ab would be expressed as follows:\n\t\t\t//\n\t\t\t//\t\t\tdefine({\n\t\t\t//\t\t\t\tsome/bundle/path/someBundle:<value of someBundle, flattened with respect to locale ab>,\n\t\t\t//\t\t\t\tsome/bundle/path/someOtherBundle:<value of someOtherBundle, flattened with respect to locale ab>,\n\t\t\t//\t\t\t});\n\t\t\t//\n\t\t\t//\t\tE.g., given this design, preloading for locale==\"ab\" can execute the following algorithm:\n\t\t\t//\n\t\t\t//\t\t\trequire([\"some/path/nls/someModule_ab\"], function(rollup){\n\t\t\t//\t\t\t\tfor(var p in rollup){\n\t\t\t//\t\t\t\t\tvar id = p + \"/ab\",\n\t\t\t//\t\t\t\t\tcache[id] = rollup[p];\n\t\t\t//\t\t\t\t\tdefine(id, rollup[p]);\n\t\t\t//\t\t\t\t}\n\t\t\t//\t\t\t});\n\t\t\t//\n\t\t\t//\t\tSimilarly, if \"ab-cd\" is requested, the algorithm can determine that \"ab\" is the best available and\n\t\t\t//\t\tload accordingly.\n\t\t\t//\n\t\t\t//\t\tThe builder will write such rollups for every layer if a non-empty localeList  profile property is\n\t\t\t//\t\tprovided. Further, the builder will include the following cache entry in the cache associated with\n\t\t\t//\t\tany layer.\n\t\t\t//\n\t\t\t//\t\t\t\"*now\":function(r){r(['dojo/i18n!*preload*<path>/nls/<module>*<JSON array of available locales>']);}\n\t\t\t//\n\t\t\t//\t\tThe *now special cache module instructs the loader to apply the provided function to context-require\n\t\t\t//\t\twith respect to the particular layer being defined. This causes the plugin to hold all normal service\n\t\t\t//\t\trequests until all preloading is complete.\n\t\t\t//\n\t\t\t//\t\tNotice that this algorithm is rarely better than the standard AMD load algorithm. Consider the normal case\n\t\t\t//\t\twhere the target locale has a single segment and a layer depends on a single bundle:\n\t\t\t//\n\t\t\t//\t\tWithout Preloads:\n\t\t\t//\n\t\t\t//\t\t1. Layer loads root bundle.\n\t\t\t//\t\t2. bundle is demanded; plugin loads single localized bundle.\n\t\t\t//\n\t\t\t//\t\tWith Preloads:\n\t\t\t//\n\t\t\t//\t\t1. Layer causes preloading of target bundle.\n\t\t\t//\t\t2. bundle is demanded; service is delayed until preloading complete; bundle is returned.\n\t\t\t//\n\t\t\t//\t\tIn each case a single transaction is required to load the target bundle. In cases where multiple bundles\n\t\t\t//\t\tare required and/or the locale has multiple segments, preloads still requires a single transaction whereas\n\t\t\t//\t\tthe normal path requires an additional transaction for each additional bundle/locale-segment. However all\n\t\t\t//\t\tof these additional transactions can be done concurrently. Owing to this analysis, the entire preloading\n\t\t\t//\t\talgorithm can be discard during a build by setting the has feature dojo-preload-i18n-Api to false.\n\n\t\t\tif(has(\"dojo-preload-i18n-Api\")){\n\t\t\t\tvar split = id.split(\"*\"),\n\t\t\t\t\tpreloadDemand = split[1] == \"preload\";\n\t\t\t\tif(preloadDemand){\n\t\t\t\t\tif(!cache[id]){\n\t\t\t\t\t\t// use cache[id] to prevent multiple preloads of the same preload; this shouldn't happen, but\n\t\t\t\t\t\t// who knows what over-aggressive human optimizers may attempt\n\t\t\t\t\t\tcache[id] = 1;\n\t\t\t\t\t\tpreloadL10n(split[2], json.parse(split[3]), 1, require);\n\t\t\t\t\t}\n\t\t\t\t\t// don't stall the loader!\n\t\t\t\t\tload(1);\n\t\t\t\t}\n\t\t\t\tif(preloadDemand || waitForPreloads(id, require, load)){\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar match = nlsRe.exec(id),\n\t\t\t\tbundlePath = match[1] + \"/\",\n\t\t\t\tbundleName = match[5] || match[4],\n\t\t\t\tbundlePathAndName = bundlePath + bundleName,\n\t\t\t\tlocaleSpecified = (match[5] && match[4]),\n\t\t\t\ttargetLocale =\tlocaleSpecified || dojo.locale,\n\t\t\t\tloadTarget = bundlePathAndName + \"/\" + targetLocale,\n\t\t\t\tloadList = localeSpecified ? [targetLocale] : getLocalesToLoad(targetLocale),\n\t\t\t\tremaining = loadList.length,\n\t\t\t\tfinish = function(){\n\t\t\t\t\tif(!--remaining){\n\t\t\t\t\t\tload(lang.delegate(cache[loadTarget]));\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\tarray.forEach(loadList, function(locale){\n\t\t\t\tvar target = bundlePathAndName + \"/\" + locale;\n\t\t\t\tif(has(\"dojo-preload-i18n-Api\")){\n\t\t\t\t\tcheckForLegacyModules(target);\n\t\t\t\t}\n\t\t\t\tif(!cache[target]){\n\t\t\t\t\tdoLoad(require, bundlePathAndName, bundlePath, bundleName, locale, finish);\n\t\t\t\t}else{\n\t\t\t\t\tfinish();\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\tif(has(\"dojo-unit-tests\")){\n\t\tvar unitTests = thisModule.unitTests = [];\n\t}\n\n\tif(has(\"dojo-preload-i18n-Api\") ||  1 ){\n\t\tvar normalizeLocale = thisModule.normalizeLocale = function(locale){\n\t\t\t\tvar result = locale ? locale.toLowerCase() : dojo.locale;\n\t\t\t\treturn result == \"root\" ? \"ROOT\" : result;\n\t\t\t},\n\n\t\t\tisXd = function(mid, contextRequire){\n\t\t\t\treturn ( 1  &&  1 ) ?\n\t\t\t\t\tcontextRequire.isXdUrl(require.toUrl(mid + \".js\")) :\n\t\t\t\t\ttrue;\n\t\t\t},\n\n\t\t\tpreloading = 0,\n\n\t\t\tpreloadWaitQueue = [],\n\n\t\t\tpreloadL10n = thisModule._preloadLocalizations = function(/*String*/bundlePrefix, /*Array*/localesGenerated, /*boolean?*/ guaranteedAmdFormat, /*function?*/ contextRequire){\n\t\t\t\t// summary:\n\t\t\t\t//\t\tLoad available flattened resource bundles associated with a particular module for dojo/locale and all dojo/config.extraLocale (if any)\n\t\t\t\t// description:\n\t\t\t\t//\t\tOnly called by built layer files. The entire locale hierarchy is loaded. For example,\n\t\t\t\t//\t\tif locale==\"ab-cd\", then ROOT, \"ab\", and \"ab-cd\" are loaded. This is different than v1.6-\n\t\t\t\t//\t\tin that the v1.6- would only load ab-cd...which was *always* flattened.\n\t\t\t\t//\n\t\t\t\t//\t\tIf guaranteedAmdFormat is true, then the module can be loaded with require thereby circumventing the detection algorithm\n\t\t\t\t//\t\tand the extra possible extra transaction.\n\n\t\t\t\t// If this function is called from legacy code, then guaranteedAmdFormat and contextRequire will be undefined. Since the function\n\t\t\t\t// needs a require in order to resolve module ids, fall back to the context-require associated with this dojo/i18n module, which\n\t\t\t\t// itself may have been mapped.\n\t\t\t\tcontextRequire = contextRequire || require;\n\n\t\t\t\tfunction doRequire(mid, callback){\n\t\t\t\t\tif(isXd(mid, contextRequire) || guaranteedAmdFormat){\n\t\t\t\t\t\tcontextRequire([mid], callback);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tsyncRequire([mid], callback, contextRequire);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfunction forEachLocale(locale, func){\n\t\t\t\t\t// given locale= \"ab-cd-ef\", calls func on \"ab-cd-ef\", \"ab-cd\", \"ab\", \"ROOT\"; stops calling the first time func returns truthy\n\t\t\t\t\tvar parts = locale.split(\"-\");\n\t\t\t\t\twhile(parts.length){\n\t\t\t\t\t\tif(func(parts.join(\"-\"))){\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparts.pop();\n\t\t\t\t\t}\n\t\t\t\t\tfunc(\"ROOT\");\n\t\t\t\t}\n\n\t\t\t\tfunction preload(locale){\n\t\t\t\t\tlocale = normalizeLocale(locale);\n\t\t\t\t\tforEachLocale(locale, function(loc){\n\t\t\t\t\t\tif(array.indexOf(localesGenerated, loc)>=0){\n\t\t\t\t\t\t\tvar mid = bundlePrefix.replace(/\\./g, \"/\")+\"_\"+loc;\n\t\t\t\t\t\t\tpreloading++;\n\t\t\t\t\t\t\tdoRequire(mid, function(rollup){\n\t\t\t\t\t\t\t\tfor(var p in rollup){\n\t\t\t\t\t\t\t\t\tcache[require.toAbsMid(p) + \"/\" + loc] = rollup[p];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t--preloading;\n\t\t\t\t\t\t\t\twhile(!preloading && preloadWaitQueue.length){\n\t\t\t\t\t\t\t\t\tload.apply(null, preloadWaitQueue.shift());\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tpreload();\n\t\t\t\tarray.forEach(dojo.config.extraLocale, preload);\n\t\t\t},\n\n\t\t\twaitForPreloads = function(id, require, load){\n\t\t\t\tif(preloading){\n\t\t\t\t\tpreloadWaitQueue.push([id, require, load]);\n\t\t\t\t}\n\t\t\t\treturn preloading;\n\t\t\t},\n\n\t\t\tcheckForLegacyModules = function()\n\t\t\t\t{};\n\t}\n\n\tif( 1 ){\n\t\t// this code path assumes the dojo loader and won't work with a standard AMD loader\n\t\tvar amdValue = {},\n\t\t\tevalBundle =\n\t\t\t\t// use the function ctor to keep the minifiers away (also come close to global scope, but this is secondary)\n\t\t\t\tnew Function(\n\t\t\t\t\t\"__bundle\",\t\t\t\t   // the bundle to evalutate\n\t\t\t\t\t\"__checkForLegacyModules\", // a function that checks if __bundle defined __mid in the global space\n\t\t\t\t\t\"__mid\",\t\t\t\t   // the mid that __bundle is intended to define\n\t\t\t\t\t\"__amdValue\",\n\n\t\t\t\t\t// returns one of:\n\t\t\t\t\t//\t\t1 => the bundle was an AMD bundle\n\t\t\t\t\t//\t\ta legacy bundle object that is the value of __mid\n\t\t\t\t\t//\t\tinstance of Error => could not figure out how to evaluate bundle\n\n\t\t\t\t\t  // used to detect when __bundle calls define\n\t\t\t\t\t  \"var define = function(mid, factory){define.called = 1; __amdValue.result = factory || mid;},\"\n\t\t\t\t\t+ \"\t   require = function(){define.called = 1;};\"\n\n\t\t\t\t\t+ \"try{\"\n\t\t\t\t\t+\t\t\"define.called = 0;\"\n\t\t\t\t\t+\t\t\"eval(__bundle);\"\n\t\t\t\t\t+\t\t\"if(define.called==1)\"\n\t\t\t\t\t\t\t\t// bundle called define; therefore signal it's an AMD bundle\n\t\t\t\t\t+\t\t\t\"return __amdValue;\"\n\n\t\t\t\t\t+\t\t\"if((__checkForLegacyModules = __checkForLegacyModules(__mid)))\"\n\t\t\t\t\t\t\t\t// bundle was probably a v1.6- built NLS flattened NLS bundle that defined __mid in the global space\n\t\t\t\t\t+\t\t\t\"return __checkForLegacyModules;\"\n\n\t\t\t\t\t+ \"}catch(e){}\"\n\t\t\t\t\t// evaulating the bundle was *neither* an AMD *nor* a legacy flattened bundle\n\t\t\t\t\t// either way, re-eval *after* surrounding with parentheses\n\n\t\t\t\t\t+ \"try{\"\n\t\t\t\t\t+\t\t\"return eval('('+__bundle+')');\"\n\t\t\t\t\t+ \"}catch(e){\"\n\t\t\t\t\t+\t\t\"return e;\"\n\t\t\t\t\t+ \"}\"\n\t\t\t\t),\n\n\t\t\tsyncRequire = function(deps, callback, require){\n\t\t\t\tvar results = [];\n\t\t\t\tarray.forEach(deps, function(mid){\n\t\t\t\t\tvar url = require.toUrl(mid + \".js\");\n\n\t\t\t\t\tfunction load(text){\n\t\t\t\t\t\tvar result = evalBundle(text, checkForLegacyModules, mid, amdValue);\n\t\t\t\t\t\tif(result===amdValue){\n\t\t\t\t\t\t\t// the bundle was an AMD module; re-inject it through the normal AMD path\n\t\t\t\t\t\t\t// we gotta do this since it could be an anonymous module and simply evaluating\n\t\t\t\t\t\t\t// the text here won't provide the loader with the context to know what\n\t\t\t\t\t\t\t// module is being defined()'d. With browser caching, this should be free; further\n\t\t\t\t\t\t\t// this entire code path can be circumvented by using the AMD format to begin with\n\t\t\t\t\t\t\tresults.push(cache[url] = amdValue.result);\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tif(result instanceof Error){\n\t\t\t\t\t\t\t\tconsole.error(\"failed to evaluate i18n bundle; url=\" + url, result);\n\t\t\t\t\t\t\t\tresult = {};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// nls/<locale>/<bundle-name> indicates not the root.\n\t\t\t\t\t\t\tresults.push(cache[url] = (/nls\\/[^\\/]+\\/[^\\/]+$/.test(url) ? result : {root:result, _v1x:1}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif(cache[url]){\n\t\t\t\t\t\tresults.push(cache[url]);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tvar bundle = require.syncLoadNls(mid);\n\t\t\t\t\t\t// don't need to check for legacy since syncLoadNls returns a module if the module\n\t\t\t\t\t\t// (1) was already loaded, or (2) was in the cache. In case 1, if syncRequire is called\n\t\t\t\t\t\t// from getLocalization --> load, then load will have called checkForLegacyModules() before\n\t\t\t\t\t\t// calling syncRequire; if syncRequire is called from preloadLocalizations, then we\n\t\t\t\t\t\t// don't care about checkForLegacyModules() because that will be done when a particular\n\t\t\t\t\t\t// bundle is actually demanded. In case 2, checkForLegacyModules() is never relevant\n\t\t\t\t\t\t// because cached modules are always v1.7+ built modules.\n\t\t\t\t\t\tif(bundle){\n\t\t\t\t\t\t\tresults.push(bundle);\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tif(!xhr){\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\trequire.getText(url, true, load);\n\t\t\t\t\t\t\t\t}catch(e){\n\t\t\t\t\t\t\t\t\tresults.push(cache[url] = {});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\txhr.get({\n\t\t\t\t\t\t\t\t\turl:url,\n\t\t\t\t\t\t\t\t\tsync:true,\n\t\t\t\t\t\t\t\t\tload:load,\n\t\t\t\t\t\t\t\t\terror:function(){\n\t\t\t\t\t\t\t\t\t\tresults.push(cache[url] = {});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tcallback && callback.apply(null, results);\n\t\t\t};\n\n\t\tcheckForLegacyModules = function(target){\n\t\t\t// legacy code may have already loaded [e.g] the raw bundle x/y/z at x.y.z; when true, push into the cache\n\t\t\tfor(var result, names = target.split(\"/\"), object = dojo.global[names[0]], i = 1; object && i<names.length-1; object = object[names[i++]]){}\n\t\t\tif(object){\n\t\t\t\tresult = object[names[i]];\n\t\t\t\tif(!result){\n\t\t\t\t\t// fallback for incorrect bundle build of 1.6\n\t\t\t\t\tresult = object[names[i].replace(/-/g,\"_\")];\n\t\t\t\t}\n\t\t\t\tif(result){\n\t\t\t\t\tcache[target] = result;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\tthisModule.getLocalization = function(moduleName, bundleName, locale){\n\t\t\tvar result,\n\t\t\t\tl10nName = getBundleName(moduleName, bundleName, locale);\n\t\t\tload(\n\t\t\t\tl10nName,\n\n\t\t\t\t// isXd() and syncRequire() need a context-require in order to resolve the mid with respect to a reference module.\n\t\t\t\t// Since this legacy function does not have the concept of a reference module, resolve with respect to this\n\t\t\t\t// dojo/i18n module, which, itself may have been mapped.\n\t\t\t\t(!isXd(l10nName, require) ? function(deps, callback){ syncRequire(deps, callback, require); } : require),\n\n\t\t\t\tfunction(result_){ result = result_; }\n\t\t\t);\n\t\t\treturn result;\n\t\t};\n\n\t\tif(has(\"dojo-unit-tests\")){\n\t\t\tunitTests.push(function(doh){\n\t\t\t\tdoh.register(\"tests.i18n.unit\", function(t){\n\t\t\t\t\tvar check;\n\n\t\t\t\t\tcheck = evalBundle(\"{prop:1}\", checkForLegacyModules, \"nonsense\", amdValue);\n\t\t\t\t\tt.is({prop:1}, check); t.is(undefined, check[1]);\n\n\t\t\t\t\tcheck = evalBundle(\"({prop:1})\", checkForLegacyModules, \"nonsense\", amdValue);\n\t\t\t\t\tt.is({prop:1}, check); t.is(undefined, check[1]);\n\n\t\t\t\t\tcheck = evalBundle(\"{'prop-x':1}\", checkForLegacyModules, \"nonsense\", amdValue);\n\t\t\t\t\tt.is({'prop-x':1}, check); t.is(undefined, check[1]);\n\n\t\t\t\t\tcheck = evalBundle(\"({'prop-x':1})\", checkForLegacyModules, \"nonsense\", amdValue);\n\t\t\t\t\tt.is({'prop-x':1}, check); t.is(undefined, check[1]);\n\n\t\t\t\t\tcheck = evalBundle(\"define({'prop-x':1})\", checkForLegacyModules, \"nonsense\", amdValue);\n\t\t\t\t\tt.is(amdValue, check); t.is({'prop-x':1}, amdValue.result);\n\n\t\t\t\t\tcheck = evalBundle(\"define('some/module', {'prop-x':1})\", checkForLegacyModules, \"nonsense\", amdValue);\n\t\t\t\t\tt.is(amdValue, check); t.is({'prop-x':1}, amdValue.result);\n\n\t\t\t\t\tcheck = evalBundle(\"this is total nonsense and should throw an error\", checkForLegacyModules, \"nonsense\", amdValue);\n\t\t\t\t\tt.is(check instanceof Error, true);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t}\n\n\treturn lang.mixin(thisModule, {\n\t\tdynamic:true,\n\t\tnormalize:normalize,\n\t\tload:load,\n\t\tcache:cache\n\t});\n});\n\n},\n'dojo/promise/tracer':function(){\ndefine([\n\t\"../_base/lang\",\n\t\"./Promise\",\n\t\"../Evented\"\n], function(lang, Promise, Evented){\n\t\"use strict\";\n\n\t// module:\n\t//\t\tdojo/promise/tracer\n\n\t/*=====\n\treturn {\n\t\t// summary:\n\t\t//\t\tTrace promise fulfillment.\n\t\t// description:\n\t\t//\t\tTrace promise fulfillment. Calling `.trace()` or `.traceError()` on a\n\t\t//\t\tpromise enables tracing. Will emit `resolved`, `rejected` or `progress`\n\t\t//\t\tevents.\n\n\t\ton: function(type, listener){\n\t\t\t// summary:\n\t\t\t//\t\tSubscribe to traces.\n\t\t\t// description:\n\t\t\t//\t\tSee `dojo/Evented#on()`.\n\t\t\t// type: String\n\t\t\t//\t\t`resolved`, `rejected`, or `progress`\n\t\t\t// listener: Function\n\t\t\t//\t\tThe listener is passed the traced value and any arguments\n\t\t\t//\t\tthat were used with the `.trace()` call.\n\t\t}\n\t};\n\t=====*/\n\n\tvar evented = new Evented;\n\tvar emit = evented.emit;\n\tevented.emit = null;\n\t// Emit events asynchronously since they should not change the promise state.\n\tfunction emitAsync(args){\n\t\tsetTimeout(function(){\n\t\t\temit.apply(evented, args);\n\t\t}, 0);\n\t}\n\n\tPromise.prototype.trace = function(){\n\t\t// summary:\n\t\t//\t\tTrace the promise.\n\t\t// description:\n\t\t//\t\tTracing allows you to transparently log progress,\n\t\t//\t\tresolution and rejection of promises, without affecting the\n\t\t//\t\tpromise itself. Any arguments passed to `trace()` are\n\t\t//\t\temitted in trace events. See `dojo/promise/tracer` on how\n\t\t//\t\tto handle traces.\n\t\t// returns: dojo/promise/Promise\n\t\t//\t\tThe promise instance `trace()` is called on.\n\n\t\tvar args = lang._toArray(arguments);\n\t\tthis.then(\n\t\t\tfunction(value){ emitAsync([\"resolved\", value].concat(args)); },\n\t\t\tfunction(error){ emitAsync([\"rejected\", error].concat(args)); },\n\t\t\tfunction(update){ emitAsync([\"progress\", update].concat(args)); }\n\t\t);\n\t\treturn this;\n\t};\n\n\tPromise.prototype.traceRejected = function(){\n\t\t// summary:\n\t\t//\t\tTrace rejection of the promise.\n\t\t// description:\n\t\t//\t\tTracing allows you to transparently log progress,\n\t\t//\t\tresolution and rejection of promises, without affecting the\n\t\t//\t\tpromise itself. Any arguments passed to `trace()` are\n\t\t//\t\temitted in trace events. See `dojo/promise/tracer` on how\n\t\t//\t\tto handle traces.\n\t\t// returns: dojo/promise/Promise\n\t\t//\t\tThe promise instance `traceRejected()` is called on.\n\n\t\tvar args = lang._toArray(arguments);\n\t\tthis.otherwise(function(error){\n\t\t\temitAsync([\"rejected\", error].concat(args));\n\t\t});\n\t\treturn this;\n\t};\n\n\treturn evented;\n});\n\n},\n'dojo/errors/RequestError':function(){\ndefine(['./create'], function(create){\n\t// module:\n\t//\t\tdojo/errors/RequestError\n\n\t/*=====\n\t return function(){\n\t\t // summary:\n\t\t //\t\tTODOC\n\t };\n\t =====*/\n\n\treturn create(\"RequestError\", function(message, response){\n\t\tthis.response = response;\n\t});\n});\n\n},\n'dojo/_base/html':function(){\ndefine(\"dojo/_base/html\", [\"./kernel\", \"../dom\", \"../dom-style\", \"../dom-attr\", \"../dom-prop\", \"../dom-class\", \"../dom-construct\", \"../dom-geometry\"], function(dojo, dom, style, attr, prop, cls, ctr, geom){\n\t// module:\n\t//\t\tdojo/dom\n\n\t/*=====\n\treturn {\n\t\t// summary:\n\t\t//\t\tThis module is a stub for the core dojo DOM API.\n\t};\n\t=====*/\n\n\t// mix-in dom\n\tdojo.byId = dom.byId;\n\tdojo.isDescendant = dom.isDescendant;\n\tdojo.setSelectable = dom.setSelectable;\n\n\t// mix-in dom-attr\n\tdojo.getAttr = attr.get;\n\tdojo.setAttr = attr.set;\n\tdojo.hasAttr = attr.has;\n\tdojo.removeAttr = attr.remove;\n\tdojo.getNodeProp = attr.getNodeProp;\n\n\tdojo.attr = function(node, name, value){\n\t\t// summary:\n\t\t//\t\tGets or sets an attribute on an HTML element.\n\t\t// description:\n\t\t//\t\tHandles normalized getting and setting of attributes on DOM\n\t\t//\t\tNodes. If 2 arguments are passed, and a the second argument is a\n\t\t//\t\tstring, acts as a getter.\n\t\t//\n\t\t//\t\tIf a third argument is passed, or if the second argument is a\n\t\t//\t\tmap of attributes, acts as a setter.\n\t\t//\n\t\t//\t\tWhen passing functions as values, note that they will not be\n\t\t//\t\tdirectly assigned to slots on the node, but rather the default\n\t\t//\t\tbehavior will be removed and the new behavior will be added\n\t\t//\t\tusing `dojo.connect()`, meaning that event handler properties\n\t\t//\t\twill be normalized and that some caveats with regards to\n\t\t//\t\tnon-standard behaviors for onsubmit apply. Namely that you\n\t\t//\t\tshould cancel form submission using `dojo.stopEvent()` on the\n\t\t//\t\tpassed event object instead of returning a boolean value from\n\t\t//\t\tthe handler itself.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to the element to get or set the attribute on\n\t\t// name: String|Object\n\t\t//\t\tthe name of the attribute to get or set.\n\t\t// value: String?\n\t\t//\t\tThe value to set for the attribute\n\t\t// returns:\n\t\t//\t\twhen used as a getter, the value of the requested attribute\n\t\t//\t\tor null if that attribute does not have a specified or\n\t\t//\t\tdefault value;\n\t\t//\n\t\t//\t\twhen used as a setter, the DOM node\n\t\t//\n\t\t// example:\n\t\t//\t|\t// get the current value of the \"foo\" attribute on a node\n\t\t//\t|\tdojo.attr(dojo.byId(\"nodeId\"), \"foo\");\n\t\t//\t|\t// or we can just pass the id:\n\t\t//\t|\tdojo.attr(\"nodeId\", \"foo\");\n\t\t//\n\t\t// example:\n\t\t//\t|\t// use attr() to set the tab index\n\t\t//\t|\tdojo.attr(\"nodeId\", \"tabIndex\", 3);\n\t\t//\t|\n\t\t//\n\t\t// example:\n\t\t//\tSet multiple values at once, including event handlers:\n\t\t//\t|\tdojo.attr(\"formId\", {\n\t\t//\t|\t\t\"foo\": \"bar\",\n\t\t//\t|\t\t\"tabIndex\": -1,\n\t\t//\t|\t\t\"method\": \"POST\",\n\t\t//\t|\t\t\"onsubmit\": function(e){\n\t\t//\t|\t\t\t// stop submitting the form. Note that the IE behavior\n\t\t//\t|\t\t\t// of returning true or false will have no effect here\n\t\t//\t|\t\t\t// since our handler is connect()ed to the built-in\n\t\t//\t|\t\t\t// onsubmit behavior and so we need to use\n\t\t//\t|\t\t\t// dojo.stopEvent() to ensure that the submission\n\t\t//\t|\t\t\t// doesn't proceed.\n\t\t//\t|\t\t\tdojo.stopEvent(e);\n\t\t//\t|\n\t\t//\t|\t\t\t// submit the form with Ajax\n\t\t//\t|\t\t\tdojo.xhrPost({ form: \"formId\" });\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tStyle is s special case: Only set with an object hash of styles\n\t\t//\t|\tdojo.attr(\"someNode\",{\n\t\t//\t|\t\tid:\"bar\",\n\t\t//\t|\t\tstyle:{\n\t\t//\t|\t\t\twidth:\"200px\", height:\"100px\", color:\"#000\"\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tAgain, only set style as an object hash of styles:\n\t\t//\t|\tvar obj = { color:\"#fff\", backgroundColor:\"#000\" };\n\t\t//\t|\tdojo.attr(\"someNode\", \"style\", obj);\n\t\t//\t|\n\t\t//\t|\t// though shorter to use `dojo.style()` in this case:\n\t\t//\t|\tdojo.style(\"someNode\", obj);\n\n\t\tif(arguments.length == 2){\n\t\t\treturn attr[typeof name == \"string\" ? \"get\" : \"set\"](node, name);\n\t\t}\n\t\treturn attr.set(node, name, value);\n\t};\n\n\t// mix-in dom-class\n\tdojo.hasClass = cls.contains;\n\tdojo.addClass = cls.add;\n\tdojo.removeClass = cls.remove;\n\tdojo.toggleClass = cls.toggle;\n\tdojo.replaceClass = cls.replace;\n\n\t// mix-in dom-construct\n\tdojo._toDom = dojo.toDom = ctr.toDom;\n\tdojo.place = ctr.place;\n\tdojo.create = ctr.create;\n\tdojo.empty = function(node){ ctr.empty(node); };\n\tdojo._destroyElement = dojo.destroy = function(node){ ctr.destroy(node); };\n\n\t// mix-in dom-geometry\n\tdojo._getPadExtents = dojo.getPadExtents = geom.getPadExtents;\n\tdojo._getBorderExtents = dojo.getBorderExtents = geom.getBorderExtents;\n\tdojo._getPadBorderExtents = dojo.getPadBorderExtents = geom.getPadBorderExtents;\n\tdojo._getMarginExtents = dojo.getMarginExtents = geom.getMarginExtents;\n\tdojo._getMarginSize = dojo.getMarginSize = geom.getMarginSize;\n\tdojo._getMarginBox = dojo.getMarginBox = geom.getMarginBox;\n\tdojo.setMarginBox = geom.setMarginBox;\n\tdojo._getContentBox = dojo.getContentBox = geom.getContentBox;\n\tdojo.setContentSize = geom.setContentSize;\n\tdojo._isBodyLtr = dojo.isBodyLtr = geom.isBodyLtr;\n\tdojo._docScroll = dojo.docScroll = geom.docScroll;\n\tdojo._getIeDocumentElementOffset = dojo.getIeDocumentElementOffset = geom.getIeDocumentElementOffset;\n\tdojo._fixIeBiDiScrollLeft = dojo.fixIeBiDiScrollLeft = geom.fixIeBiDiScrollLeft;\n\tdojo.position = geom.position;\n\n\tdojo.marginBox = function marginBox(/*DomNode|String*/node, /*Object?*/box){\n\t\t// summary:\n\t\t//\t\tGetter/setter for the margin-box of node.\n\t\t// description:\n\t\t//\t\tGetter/setter for the margin-box of node.\n\t\t//\t\tReturns an object in the expected format of box (regardless\n\t\t//\t\tif box is passed). The object might look like:\n\t\t//\t\t`{ l: 50, t: 200, w: 300: h: 150 }`\n\t\t//\t\tfor a node offset from its parent 50px to the left, 200px from\n\t\t//\t\tthe top with a margin width of 300px and a margin-height of\n\t\t//\t\t150px.\n\t\t// node:\n\t\t//\t\tid or reference to DOM Node to get/set box for\n\t\t// box:\n\t\t//\t\tIf passed, denotes that dojo.marginBox() should\n\t\t//\t\tupdate/set the margin box for node. Box is an object in the\n\t\t//\t\tabove format. All properties are optional if passed.\n\t\t// example:\n\t\t//\t\tRetrieve the margin box of a passed node\n\t\t//\t|\tvar box = dojo.marginBox(\"someNodeId\");\n\t\t//\t|\tconsole.dir(box);\n\t\t//\n\t\t// example:\n\t\t//\t\tSet a node's margin box to the size of another node\n\t\t//\t|\tvar box = dojo.marginBox(\"someNodeId\");\n\t\t//\t|\tdojo.marginBox(\"someOtherNode\", box);\n\t\treturn box ? geom.setMarginBox(node, box) : geom.getMarginBox(node); // Object\n\t};\n\n\tdojo.contentBox = function contentBox(/*DomNode|String*/node, /*Object?*/box){\n\t\t// summary:\n\t\t//\t\tGetter/setter for the content-box of node.\n\t\t// description:\n\t\t//\t\tReturns an object in the expected format of box (regardless if box is passed).\n\t\t//\t\tThe object might look like:\n\t\t//\t\t`{ l: 50, t: 200, w: 300: h: 150 }`\n\t\t//\t\tfor a node offset from its parent 50px to the left, 200px from\n\t\t//\t\tthe top with a content width of 300px and a content-height of\n\t\t//\t\t150px. Note that the content box may have a much larger border\n\t\t//\t\tor margin box, depending on the box model currently in use and\n\t\t//\t\tCSS values set/inherited for node.\n\t\t//\t\tWhile the getter will return top and left values, the\n\t\t//\t\tsetter only accepts setting the width and height.\n\t\t// node:\n\t\t//\t\tid or reference to DOM Node to get/set box for\n\t\t// box:\n\t\t//\t\tIf passed, denotes that dojo.contentBox() should\n\t\t//\t\tupdate/set the content box for node. Box is an object in the\n\t\t//\t\tabove format, but only w (width) and h (height) are supported.\n\t\t//\t\tAll properties are optional if passed.\n\t\treturn box ? geom.setContentSize(node, box) : geom.getContentBox(node); // Object\n\t};\n\n\tdojo.coords = function(/*DomNode|String*/node, /*Boolean?*/includeScroll){\n\t\t// summary:\n\t\t//\t\tDeprecated: Use position() for border-box x/y/w/h\n\t\t//\t\tor marginBox() for margin-box w/h/l/t.\n\t\t//\n\t\t//\t\tReturns an object that measures margin-box (w)idth/(h)eight\n\t\t//\t\tand absolute position x/y of the border-box. Also returned\n\t\t//\t\tis computed (l)eft and (t)op values in pixels from the\n\t\t//\t\tnode's offsetParent as returned from marginBox().\n\t\t//\t\tReturn value will be in the form:\n\t\t//|\t\t\t{ l: 50, t: 200, w: 300: h: 150, x: 100, y: 300 }\n\t\t//\t\tDoes not act as a setter. If includeScroll is passed, the x and\n\t\t//\t\ty params are affected as one would expect in dojo.position().\n\t\tdojo.deprecated(\"dojo.coords()\", \"Use dojo.position() or dojo.marginBox().\");\n\t\tnode = dom.byId(node);\n\t\tvar s = style.getComputedStyle(node), mb = geom.getMarginBox(node, s);\n\t\tvar abs = geom.position(node, includeScroll);\n\t\tmb.x = abs.x;\n\t\tmb.y = abs.y;\n\t\treturn mb;\t// Object\n\t};\n\n\t// mix-in dom-prop\n\tdojo.getProp = prop.get;\n\tdojo.setProp = prop.set;\n\n\tdojo.prop = function(/*DomNode|String*/node, /*String|Object*/name, /*String?*/value){\n\t\t// summary:\n\t\t//\t\tGets or sets a property on an HTML element.\n\t\t// description:\n\t\t//\t\tHandles normalized getting and setting of properties on DOM\n\t\t//\t\tNodes. If 2 arguments are passed, and a the second argument is a\n\t\t//\t\tstring, acts as a getter.\n\t\t//\n\t\t//\t\tIf a third argument is passed, or if the second argument is a\n\t\t//\t\tmap of attributes, acts as a setter.\n\t\t//\n\t\t//\t\tWhen passing functions as values, note that they will not be\n\t\t//\t\tdirectly assigned to slots on the node, but rather the default\n\t\t//\t\tbehavior will be removed and the new behavior will be added\n\t\t//\t\tusing `dojo.connect()`, meaning that event handler properties\n\t\t//\t\twill be normalized and that some caveats with regards to\n\t\t//\t\tnon-standard behaviors for onsubmit apply. Namely that you\n\t\t//\t\tshould cancel form submission using `dojo.stopEvent()` on the\n\t\t//\t\tpassed event object instead of returning a boolean value from\n\t\t//\t\tthe handler itself.\n\t\t// node:\n\t\t//\t\tid or reference to the element to get or set the property on\n\t\t// name:\n\t\t//\t\tthe name of the property to get or set.\n\t\t// value:\n\t\t//\t\tThe value to set for the property\n\t\t// returns:\n\t\t//\t\twhen used as a getter, the value of the requested property\n\t\t//\t\tor null if that attribute does not have a specified or\n\t\t//\t\tdefault value;\n\t\t//\n\t\t//\t\twhen used as a setter, the DOM node\n\t\t//\n\t\t// example:\n\t\t//\t|\t// get the current value of the \"foo\" property on a node\n\t\t//\t|\tdojo.prop(dojo.byId(\"nodeId\"), \"foo\");\n\t\t//\t|\t// or we can just pass the id:\n\t\t//\t|\tdojo.prop(\"nodeId\", \"foo\");\n\t\t//\n\t\t// example:\n\t\t//\t|\t// use prop() to set the tab index\n\t\t//\t|\tdojo.prop(\"nodeId\", \"tabIndex\", 3);\n\t\t//\t|\n\t\t//\n\t\t// example:\n\t\t//\tSet multiple values at once, including event handlers:\n\t\t//\t|\tdojo.prop(\"formId\", {\n\t\t//\t|\t\t\"foo\": \"bar\",\n\t\t//\t|\t\t\"tabIndex\": -1,\n\t\t//\t|\t\t\"method\": \"POST\",\n\t\t//\t|\t\t\"onsubmit\": function(e){\n\t\t//\t|\t\t\t// stop submitting the form. Note that the IE behavior\n\t\t//\t|\t\t\t// of returning true or false will have no effect here\n\t\t//\t|\t\t\t// since our handler is connect()ed to the built-in\n\t\t//\t|\t\t\t// onsubmit behavior and so we need to use\n\t\t//\t|\t\t\t// dojo.stopEvent() to ensure that the submission\n\t\t//\t|\t\t\t// doesn't proceed.\n\t\t//\t|\t\t\tdojo.stopEvent(e);\n\t\t//\t|\n\t\t//\t|\t\t\t// submit the form with Ajax\n\t\t//\t|\t\t\tdojo.xhrPost({ form: \"formId\" });\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t\tStyle is s special case: Only set with an object hash of styles\n\t\t//\t|\tdojo.prop(\"someNode\",{\n\t\t//\t|\t\tid:\"bar\",\n\t\t//\t|\t\tstyle:{\n\t\t//\t|\t\t\twidth:\"200px\", height:\"100px\", color:\"#000\"\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t\tAgain, only set style as an object hash of styles:\n\t\t//\t|\tvar obj = { color:\"#fff\", backgroundColor:\"#000\" };\n\t\t//\t|\tdojo.prop(\"someNode\", \"style\", obj);\n\t\t//\t|\n\t\t//\t|\t// though shorter to use `dojo.style()` in this case:\n\t\t//\t|\tdojo.style(\"someNode\", obj);\n\n\t\tif(arguments.length == 2){\n\t\t\treturn prop[typeof name == \"string\" ? \"get\" : \"set\"](node, name);\n\t\t}\n\t\t// setter\n\t\treturn prop.set(node, name, value);\n\t};\n\n\t// mix-in dom-style\n\tdojo.getStyle = style.get;\n\tdojo.setStyle = style.set;\n\tdojo.getComputedStyle = style.getComputedStyle;\n\tdojo.__toPixelValue = dojo.toPixelValue = style.toPixelValue;\n\n\tdojo.style = function(node, name, value){\n\t\t// summary:\n\t\t//\t\tAccesses styles on a node. If 2 arguments are\n\t\t//\t\tpassed, acts as a getter. If 3 arguments are passed, acts\n\t\t//\t\tas a setter.\n\t\t// description:\n\t\t//\t\tGetting the style value uses the computed style for the node, so the value\n\t\t//\t\twill be a calculated value, not just the immediate node.style value.\n\t\t//\t\tAlso when getting values, use specific style names,\n\t\t//\t\tlike \"borderBottomWidth\" instead of \"border\" since compound values like\n\t\t//\t\t\"border\" are not necessarily reflected as expected.\n\t\t//\t\tIf you want to get node dimensions, use `dojo.marginBox()`,\n\t\t//\t\t`dojo.contentBox()` or `dojo.position()`.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to node to get/set style for\n\t\t// name: String|Object?\n\t\t//\t\tthe style property to set in DOM-accessor format\n\t\t//\t\t(\"borderWidth\", not \"border-width\") or an object with key/value\n\t\t//\t\tpairs suitable for setting each property.\n\t\t// value: String?\n\t\t//\t\tIf passed, sets value on the node for style, handling\n\t\t//\t\tcross-browser concerns.  When setting a pixel value,\n\t\t//\t\tbe sure to include \"px\" in the value. For instance, top: \"200px\".\n\t\t//\t\tOtherwise, in some cases, some browsers will not apply the style.\n\t\t// returns:\n\t\t//\t\twhen used as a getter, return the computed style of the node if passing in an ID or node,\n\t\t//\t\tor return the normalized, computed value for the property when passing in a node and a style property\n\t\t// example:\n\t\t//\t\tPassing only an ID or node returns the computed style object of\n\t\t//\t\tthe node:\n\t\t//\t|\tdojo.style(\"thinger\");\n\t\t// example:\n\t\t//\t\tPassing a node and a style property returns the current\n\t\t//\t\tnormalized, computed value for that property:\n\t\t//\t|\tdojo.style(\"thinger\", \"opacity\"); // 1 by default\n\t\t//\n\t\t// example:\n\t\t//\t\tPassing a node, a style property, and a value changes the\n\t\t//\t\tcurrent display of the node and returns the new computed value\n\t\t//\t|\tdojo.style(\"thinger\", \"opacity\", 0.5); // == 0.5\n\t\t//\n\t\t// example:\n\t\t//\t\tPassing a node, an object-style style property sets each of the values in turn and returns the computed style object of the node:\n\t\t//\t|\tdojo.style(\"thinger\", {\n\t\t//\t|\t\t\"opacity\": 0.5,\n\t\t//\t|\t\t\"border\": \"3px solid black\",\n\t\t//\t|\t\t\"height\": \"300px\"\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t\tWhen the CSS style property is hyphenated, the JavaScript property is camelCased.\n\t\t//\t\tfont-size becomes fontSize, and so on.\n\t\t//\t|\tdojo.style(\"thinger\",{\n\t\t//\t|\t\tfontSize:\"14pt\",\n\t\t//\t|\t\tletterSpacing:\"1.2em\"\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t\tdojo/NodeList implements .style() using the same syntax, omitting the \"node\" parameter, calling\n\t\t//\t\tdojo.style() on every element of the list. See: `dojo/query` and `dojo/NodeList`\n\t\t//\t|\tdojo.query(\".someClassName\").style(\"visibility\",\"hidden\");\n\t\t//\t|\t// or\n\t\t//\t|\tdojo.query(\"#baz > div\").style({\n\t\t//\t|\t\topacity:0.75,\n\t\t//\t|\t\tfontSize:\"13pt\"\n\t\t//\t|\t});\n\n\t\tswitch(arguments.length){\n\t\t\tcase 1:\n\t\t\t\treturn style.get(node);\n\t\t\tcase 2:\n\t\t\t\treturn style[typeof name == \"string\" ? \"get\" : \"set\"](node, name);\n\t\t}\n\t\t// setter\n\t\treturn style.set(node, name, value);\n\t};\n\n\treturn dojo;\n});\n\n},\n'dojo/_base/kernel':function(){\ndefine([\"../has\", \"./config\", \"require\", \"module\"], function(has, config, require, module){\n\t// module:\n\t//\t\tdojo/_base/kernel\n\n\t// This module is the foundational module of the dojo boot sequence; it defines the dojo object.\n\n\tvar\n\t\t// loop variables for this module\n\t\ti, p,\n\n\t\t// create dojo, dijit, and dojox\n\t\t// FIXME: in 2.0 remove dijit, dojox being created by dojo\n\t\tdijit = {},\n\t\tdojox = {},\n\t\tdojo = {\n\t\t\t// summary:\n\t\t\t//\t\tThis module is the foundational module of the dojo boot sequence; it defines the dojo object.\n\n\t\t\t// notice dojo takes ownership of the value of the config module\n\t\t\tconfig:config,\n\t\t\tglobal:this,\n\t\t\tdijit:dijit,\n\t\t\tdojox:dojox\n\t\t};\n\n\n\t// Configure the scope map. For a 100% AMD application, the scope map is not needed other than to provide\n\t// a _scopeName property for the dojo, dijit, and dojox root object so those packages can create\n\t// unique names in the global space.\n\t//\n\t// Built, legacy modules use the scope map to allow those modules to be expressed as if dojo, dijit, and dojox,\n\t// where global when in fact they are either global under different names or not global at all. In v1.6-, the\n\t// config variable \"scopeMap\" was used to map names as used within a module to global names. This has been\n\t// subsumed by the AMD map configuration variable which can relocate packages to different names. For backcompat,\n\t// only the \"*\" mapping is supported. See http://livedocs.dojotoolkit.org/developer/design/loader#legacy-cross-domain-mode for details.\n\t//\n\t// The following computations contort the packageMap for this dojo instance into a scopeMap.\n\tvar scopeMap =\n\t\t\t// a map from a name used in a legacy module to the (global variable name, object addressed by that name)\n\t\t\t// always map dojo, dijit, and dojox\n\t\t\t{\n\t\t\t\tdojo:[\"dojo\", dojo],\n\t\t\t\tdijit:[\"dijit\", dijit],\n\t\t\t\tdojox:[\"dojox\", dojox]\n\t\t\t},\n\n\t\tpackageMap =\n\t\t\t// the package map for this dojo instance; note, a foreign loader or no pacakgeMap results in the above default config\n\t\t\t(require.map && require.map[module.id.match(/[^\\/]+/)[0]]),\n\n\t\titem;\n\n\n\t// process all mapped top-level names for this instance of dojo\n\tfor(p in packageMap){\n\t\tif(scopeMap[p]){\n\t\t\t// mapped dojo, dijit, or dojox\n\t\t\tscopeMap[p][0] = packageMap[p];\n\t\t}else{\n\t\t\t// some other top-level name\n\t\t\tscopeMap[p] = [packageMap[p], {}];\n\t\t}\n\t}\n\n\t// publish those names to _scopeName and, optionally, the global namespace\n\tfor(p in scopeMap){\n\t\titem = scopeMap[p];\n\t\titem[1]._scopeName = item[0];\n\t\tif(!config.noGlobals){\n\t\t\tthis[item[0]] = item[1];\n\t\t}\n\t}\n\tdojo.scopeMap = scopeMap;\n\n\t/*===== dojo.__docParserConfigureScopeMap(scopeMap); =====*/\n\n\t// FIXME: dojo.baseUrl and dojo.config.baseUrl should be deprecated\n\tdojo.baseUrl = dojo.config.baseUrl = require.baseUrl;\n\tdojo.isAsync = ! 1  || require.async;\n\tdojo.locale = config.locale;\n\n\tvar rev = \"$Rev: 29801 $\".match(/\\d+/);\n\tdojo.version = {\n\t\t// summary:\n\t\t//\t\tVersion number of the Dojo Toolkit\n\t\t// description:\n\t\t//\t\tHash about the version, including\n\t\t//\n\t\t//\t\t- major: Integer: Major version. If total version is \"1.2.0beta1\", will be 1\n\t\t//\t\t- minor: Integer: Minor version. If total version is \"1.2.0beta1\", will be 2\n\t\t//\t\t- patch: Integer: Patch version. If total version is \"1.2.0beta1\", will be 0\n\t\t//\t\t- flag: String: Descriptor flag. If total version is \"1.2.0beta1\", will be \"beta1\"\n\t\t//\t\t- revision: Number: The SVN rev from which dojo was pulled\n\n\t\tmajor: 1, minor: 8, patch: 1, flag: \"\",\n\t\trevision: rev ? +rev[0] : NaN,\n\t\ttoString: function(){\n\t\t\tvar v = dojo.version;\n\t\t\treturn v.major + \".\" + v.minor + \".\" + v.patch + v.flag + \" (\" + v.revision + \")\";\t// String\n\t\t}\n\t};\n\n\t// If  1  is truthy, then as a dojo module is defined it should push it's definitions\n\t// into the dojo object, and conversely. In 2.0, it will likely be unusual to augment another object\n\t// as a result of defining a module. This has feature gives a way to force 2.0 behavior as the code\n\t// is migrated. Absent specific advice otherwise, set extend-dojo to truthy.\n\t 1 || has.add(\"extend-dojo\", 1);\n\n\n\t(Function(\"d\", \"d.eval = function(){return d.global.eval ? d.global.eval(arguments[0]) : eval(arguments[0]);}\"))(dojo);\n\t/*=====\n\tdojo.eval = function(scriptText){\n\t\t// summary:\n\t\t//\t\tA legacy method created for use exclusively by internal Dojo methods. Do not use this method\n\t\t//\t\tdirectly unless you understand its possibly-different implications on the platforms your are targeting.\n\t\t// description:\n\t\t//\t\tMakes an attempt to evaluate scriptText in the global scope. The function works correctly for browsers\n\t\t//\t\tthat support indirect eval.\n\t\t//\n\t\t//\t\tAs usual, IE does not. On IE, the only way to implement global eval is to\n\t\t//\t\tuse execScript. Unfortunately, execScript does not return a value and breaks some current usages of dojo.eval.\n\t\t//\t\tThis implementation uses the technique of executing eval in the scope of a function that is a single scope\n\t\t//\t\tframe below the global scope; thereby coming close to the global scope. Note carefully that\n\t\t//\n\t\t//\t\tdojo.eval(\"var pi = 3.14;\");\n\t\t//\n\t\t//\t\twill define global pi in non-IE environments, but define pi only in a temporary local scope for IE. If you want\n\t\t//\t\tto define a global variable using dojo.eval, write something like\n\t\t//\n\t\t//\t\tdojo.eval(\"window.pi = 3.14;\")\n\t\t// scriptText:\n\t\t//\t\tThe text to evaluation.\n\t\t// returns:\n\t\t//\t\tThe result of the evaluation. Often `undefined`\n\t};\n\t=====*/\n\n\n\tif( 0 ){\n\t\tdojo.exit = function(exitcode){\n\t\t\tquit(exitcode);\n\t\t};\n\t}else{\n\t\tdojo.exit = function(){\n\t\t};\n\t}\n\n\t 1 || has.add(\"dojo-guarantee-console\",\n\t\t// ensure that console.log, console.warn, etc. are defined\n\t\t1\n\t);\n\tif( 1 ){\n\t\ttypeof console != \"undefined\" || (console = {});\n\t\t//\tBe careful to leave 'log' always at the end\n\t\tvar cn = [\n\t\t\t\"assert\", \"count\", \"debug\", \"dir\", \"dirxml\", \"error\", \"group\",\n\t\t\t\"groupEnd\", \"info\", \"profile\", \"profileEnd\", \"time\", \"timeEnd\",\n\t\t\t\"trace\", \"warn\", \"log\"\n\t\t];\n\t\tvar tn;\n\t\ti = 0;\n\t\twhile((tn = cn[i++])){\n\t\t\tif(!console[tn]){\n\t\t\t\t(function(){\n\t\t\t\t\tvar tcn = tn + \"\";\n\t\t\t\t\tconsole[tcn] = ('log' in console) ? function(){\n\t\t\t\t\t\tvar a = Array.apply({}, arguments);\n\t\t\t\t\t\ta.unshift(tcn + \":\");\n\t\t\t\t\t\tconsole[\"log\"](a.join(\" \"));\n\t\t\t\t\t} : function(){};\n\t\t\t\t\tconsole[tcn]._fake = true;\n\t\t\t\t})();\n\t\t\t}\n\t\t}\n\t}\n\n\thas.add(\"dojo-debug-messages\",\n\t\t// include dojo.deprecated/dojo.experimental implementations\n\t\t!!config.isDebug\n\t);\n\tdojo.deprecated = dojo.experimental =  function(){};\n\tif(has(\"dojo-debug-messages\")){\n\t\tdojo.deprecated = function(/*String*/ behaviour, /*String?*/ extra, /*String?*/ removal){\n\t\t\t// summary:\n\t\t\t//\t\tLog a debug message to indicate that a behavior has been\n\t\t\t//\t\tdeprecated.\n\t\t\t// behaviour: String\n\t\t\t//\t\tThe API or behavior being deprecated. Usually in the form\n\t\t\t//\t\tof \"myApp.someFunction()\".\n\t\t\t// extra: String?\n\t\t\t//\t\tText to append to the message. Often provides advice on a\n\t\t\t//\t\tnew function or facility to achieve the same goal during\n\t\t\t//\t\tthe deprecation period.\n\t\t\t// removal: String?\n\t\t\t//\t\tText to indicate when in the future the behavior will be\n\t\t\t//\t\tremoved. Usually a version number.\n\t\t\t// example:\n\t\t\t//\t| dojo.deprecated(\"myApp.getTemp()\", \"use myApp.getLocaleTemp() instead\", \"1.0\");\n\n\t\t\tvar message = \"DEPRECATED: \" + behaviour;\n\t\t\tif(extra){ message += \" \" + extra; }\n\t\t\tif(removal){ message += \" -- will be removed in version: \" + removal; }\n\t\t\tconsole.warn(message);\n\t\t};\n\n\t\tdojo.experimental = function(/* String */ moduleName, /* String? */ extra){\n\t\t\t// summary:\n\t\t\t//\t\tMarks code as experimental.\n\t\t\t// description:\n\t\t\t//\t\tThis can be used to mark a function, file, or module as\n\t\t\t//\t\texperimental.\t Experimental code is not ready to be used, and the\n\t\t\t//\t\tAPIs are subject to change without notice.\tExperimental code may be\n\t\t\t//\t\tcompleted deleted without going through the normal deprecation\n\t\t\t//\t\tprocess.\n\t\t\t// moduleName: String\n\t\t\t//\t\tThe name of a module, or the name of a module file or a specific\n\t\t\t//\t\tfunction\n\t\t\t// extra: String?\n\t\t\t//\t\tsome additional message for the user\n\t\t\t// example:\n\t\t\t//\t| dojo.experimental(\"dojo.data.Result\");\n\t\t\t// example:\n\t\t\t//\t| dojo.experimental(\"dojo.weather.toKelvin()\", \"PENDING approval from NOAA\");\n\n\t\t\tvar message = \"EXPERIMENTAL: \" + moduleName + \" -- APIs subject to change without notice.\";\n\t\t\tif(extra){ message += \" \" + extra; }\n\t\t\tconsole.warn(message);\n\t\t};\n\t}\n\n\t 1 || has.add(\"dojo-modulePaths\",\n\t\t// consume dojo.modulePaths processing\n\t\t1\n\t);\n\tif( 1 ){\n\t\t// notice that modulePaths won't be applied to any require's before the dojo/_base/kernel factory is run;\n\t\t// this is the v1.6- behavior.\n\t\tif(config.modulePaths){\n\t\t\tdojo.deprecated(\"dojo.modulePaths\", \"use paths configuration\");\n\t\t\tvar paths = {};\n\t\t\tfor(p in config.modulePaths){\n\t\t\t\tpaths[p.replace(/\\./g, \"/\")] = config.modulePaths[p];\n\t\t\t}\n\t\t\trequire({paths:paths});\n\t\t}\n\t}\n\n\t 1 || has.add(\"dojo-moduleUrl\",\n\t\t// include dojo.moduleUrl\n\t\t1\n\t);\n\tif( 1 ){\n\t\tdojo.moduleUrl = function(/*String*/module, /*String?*/url){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a URL relative to a module.\n\t\t\t// example:\n\t\t\t//\t|\tvar pngPath = dojo.moduleUrl(\"acme\",\"images/small.png\");\n\t\t\t//\t|\tconsole.dir(pngPath); // list the object properties\n\t\t\t//\t|\t// create an image and set it's source to pngPath's value:\n\t\t\t//\t|\tvar img = document.createElement(\"img\");\n\t\t\t//\t|\timg.src = pngPath;\n\t\t\t//\t|\t// add our image to the document\n\t\t\t//\t|\tdojo.body().appendChild(img);\n\t\t\t// example:\n\t\t\t//\t\tyou may de-reference as far as you like down the package\n\t\t\t//\t\thierarchy.  This is sometimes handy to avoid lenghty relative\n\t\t\t//\t\turls or for building portable sub-packages. In this example,\n\t\t\t//\t\tthe `acme.widget` and `acme.util` directories may be located\n\t\t\t//\t\tunder different roots (see `dojo.registerModulePath`) but the\n\t\t\t//\t\tthe modules which reference them can be unaware of their\n\t\t\t//\t\trelative locations on the filesystem:\n\t\t\t//\t|\t// somewhere in a configuration block\n\t\t\t//\t|\tdojo.registerModulePath(\"acme.widget\", \"../../acme/widget\");\n\t\t\t//\t|\tdojo.registerModulePath(\"acme.util\", \"../../util\");\n\t\t\t//\t|\n\t\t\t//\t|\t// ...\n\t\t\t//\t|\n\t\t\t//\t|\t// code in a module using acme resources\n\t\t\t//\t|\tvar tmpltPath = dojo.moduleUrl(\"acme.widget\",\"templates/template.html\");\n\t\t\t//\t|\tvar dataPath = dojo.moduleUrl(\"acme.util\",\"resources/data.json\");\n\n\t\t\tdojo.deprecated(\"dojo.moduleUrl()\", \"use require.toUrl\", \"2.0\");\n\n\t\t\t// require.toUrl requires a filetype; therefore, just append the suffix \"/*.*\" to guarantee a filetype, then\n\t\t\t// remove the suffix from the result. This way clients can request a url w/out a filetype. This should be\n\t\t\t// rare, but it maintains backcompat for the v1.x line (note: dojo.moduleUrl will be removed in v2.0).\n\t\t\t// Notice * is an illegal filename so it won't conflict with any real path map that may exist the paths config.\n\t\t\tvar result = null;\n\t\t\tif(module){\n\t\t\t\tresult = require.toUrl(module.replace(/\\./g, \"/\") + (url ? (\"/\" + url) : \"\") + \"/*.*\").replace(/\\/\\*\\.\\*/, \"\") + (url ? \"\" : \"/\");\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tdojo._hasResource = {}; // for backward compatibility with layers built with 1.6 tooling\n\n\treturn dojo;\n});\n\n},\n'dojo/io-query':function(){\ndefine([\"./_base/lang\"], function(lang){\n\n// module:\n//\t\tdojo/io-query\n\nvar backstop = {};\n\nreturn {\n// summary:\n//\t\tThis module defines query string processing functions.\n\n\tobjectToQuery: function objectToQuery(/*Object*/ map){\n\t\t// summary:\n        //\t\ttakes a name/value mapping object and returns a string representing\n        //\t\ta URL-encoded version of that object.\n        // example:\n        //\t\tthis object:\n        //\n        //\t|\t{\n        //\t|\t\tblah: \"blah\",\n        //\t|\t\tmulti: [\n        //\t|\t\t\t\"thud\",\n        //\t|\t\t\t\"thonk\"\n        //\t|\t\t]\n        //\t|\t};\n        //\n        //\t\tyields the following query string:\n        //\n        //\t|\t\"blah=blah&multi=thud&multi=thonk\"\n\n        // FIXME: need to implement encodeAscii!!\n        var enc = encodeURIComponent, pairs = [];\n        for(var name in map){\n            var value = map[name];\n            if(value != backstop[name]){\n                var assign = enc(name) + \"=\";\n                if(lang.isArray(value)){\n                    for(var i = 0, l = value.length; i < l; ++i){\n                        pairs.push(assign + enc(value[i]));\n                    }\n                }else{\n                    pairs.push(assign + enc(value));\n                }\n            }\n        }\n        return pairs.join(\"&\"); // String\n    },\n\n\tqueryToObject: function queryToObject(/*String*/ str){\n        // summary:\n        //\t\tCreate an object representing a de-serialized query section of a\n        //\t\tURL. Query keys with multiple values are returned in an array.\n        //\n        // example:\n        //\t\tThis string:\n        //\n        //\t|\t\t\"foo=bar&foo=baz&thinger=%20spaces%20=blah&zonk=blarg&\"\n        //\n        //\t\tresults in this object structure:\n        //\n        //\t|\t\t{\n        //\t|\t\t\tfoo: [ \"bar\", \"baz\" ],\n        //\t|\t\t\tthinger: \" spaces =blah\",\n        //\t|\t\t\tzonk: \"blarg\"\n        //\t|\t\t}\n        //\n        //\t\tNote that spaces and other urlencoded entities are correctly\n        //\t\thandled.\n\n        // FIXME: should we grab the URL string if we're not passed one?\n        var dec = decodeURIComponent, qp = str.split(\"&\"), ret = {}, name, val;\n        for(var i = 0, l = qp.length, item; i < l; ++i){\n            item = qp[i];\n            if(item.length){\n                var s = item.indexOf(\"=\");\n                if(s < 0){\n                    name = dec(item);\n                    val = \"\";\n                }else{\n                    name = dec(item.slice(0, s));\n                    val  = dec(item.slice(s + 1));\n                }\n                if(typeof ret[name] == \"string\"){ // inline'd type check\n                    ret[name] = [ret[name]];\n                }\n\n                if(lang.isArray(ret[name])){\n                    ret[name].push(val);\n                }else{\n                    ret[name] = val;\n                }\n            }\n        }\n        return ret; // Object\n    }\n};\n});\n},\n'dojo/_base/Deferred':function(){\ndefine([\n\t\"./kernel\",\n\t\"../Deferred\",\n\t\"../promise/Promise\",\n\t\"../errors/CancelError\",\n\t\"../has\",\n\t\"./lang\",\n\t\"../when\"\n], function(dojo, NewDeferred, Promise, CancelError, has, lang, when){\n\t// module:\n\t//\t\tdojo/_base/Deferred\n\n\tvar mutator = function(){};\n\tvar freeze = Object.freeze || function(){};\n\t// A deferred provides an API for creating and resolving a promise.\n\tvar Deferred = dojo.Deferred = function(/*Function?*/ canceller){\n\t\t// summary:\n\t\t//\t\tDeprecated.   This module defines the legacy dojo/_base/Deferred API.\n\t\t//\t\tNew code should use dojo/Deferred instead.\n\t\t// description:\n\t\t//\t\tThe Deferred API is based on the concept of promises that provide a\n\t\t//\t\tgeneric interface into the eventual completion of an asynchronous action.\n\t\t//\t\tThe motivation for promises fundamentally is about creating a\n\t\t//\t\tseparation of concerns that allows one to achieve the same type of\n\t\t//\t\tcall patterns and logical data flow in asynchronous code as can be\n\t\t//\t\tachieved in synchronous code. Promises allows one\n\t\t//\t\tto be able to call a function purely with arguments needed for\n\t\t//\t\texecution, without conflating the call with concerns of whether it is\n\t\t//\t\tsync or async. One shouldn't need to alter a call's arguments if the\n\t\t//\t\timplementation switches from sync to async (or vice versa). By having\n\t\t//\t\tasync functions return promises, the concerns of making the call are\n\t\t//\t\tseparated from the concerns of asynchronous interaction (which are\n\t\t//\t\thandled by the promise).\n\t\t//\n\t\t//\t\tThe Deferred is a type of promise that provides methods for fulfilling the\n\t\t//\t\tpromise with a successful result or an error. The most important method for\n\t\t//\t\tworking with Dojo's promises is the then() method, which follows the\n\t\t//\t\tCommonJS proposed promise API. An example of using a Dojo promise:\n\t\t//\n\t\t//\t\t|\tvar resultingPromise = someAsyncOperation.then(function(result){\n\t\t//\t\t|\t\t... handle result ...\n\t\t//\t\t|\t},\n\t\t//\t\t|\tfunction(error){\n\t\t//\t\t|\t\t... handle error ...\n\t\t//\t\t|\t});\n\t\t//\n\t\t//\t\tThe .then() call returns a new promise that represents the result of the\n\t\t//\t\texecution of the callback. The callbacks will never affect the original promises value.\n\t\t//\n\t\t//\t\tThe Deferred instances also provide the following functions for backwards compatibility:\n\t\t//\n\t\t//\t\t- addCallback(handler)\n\t\t//\t\t- addErrback(handler)\n\t\t//\t\t- callback(result)\n\t\t//\t\t- errback(result)\n\t\t//\n\t\t//\t\tCallbacks are allowed to return promises themselves, so\n\t\t//\t\tyou can build complicated sequences of events with ease.\n\t\t//\n\t\t//\t\tThe creator of the Deferred may specify a canceller.  The canceller\n\t\t//\t\tis a function that will be called if Deferred.cancel is called\n\t\t//\t\tbefore the Deferred fires. You can use this to implement clean\n\t\t//\t\taborting of an XMLHttpRequest, etc. Note that cancel will fire the\n\t\t//\t\tdeferred with a CancelledError (unless your canceller returns\n\t\t//\t\tanother kind of error), so the errbacks should be prepared to\n\t\t//\t\thandle that error for cancellable Deferreds.\n\t\t// example:\n\t\t//\t|\tvar deferred = new Deferred();\n\t\t//\t|\tsetTimeout(function(){ deferred.callback({success: true}); }, 1000);\n\t\t//\t|\treturn deferred;\n\t\t// example:\n\t\t//\t\tDeferred objects are often used when making code asynchronous. It\n\t\t//\t\tmay be easiest to write functions in a synchronous manner and then\n\t\t//\t\tsplit code using a deferred to trigger a response to a long-lived\n\t\t//\t\toperation. For example, instead of register a callback function to\n\t\t//\t\tdenote when a rendering operation completes, the function can\n\t\t//\t\tsimply return a deferred:\n\t\t//\n\t\t//\t\t|\t// callback style:\n\t\t//\t\t|\tfunction renderLotsOfData(data, callback){\n\t\t//\t\t|\t\tvar success = false\n\t\t//\t\t|\t\ttry{\n\t\t//\t\t|\t\t\tfor(var x in data){\n\t\t//\t\t|\t\t\t\trenderDataitem(data[x]);\n\t\t//\t\t|\t\t\t}\n\t\t//\t\t|\t\t\tsuccess = true;\n\t\t//\t\t|\t\t}catch(e){ }\n\t\t//\t\t|\t\tif(callback){\n\t\t//\t\t|\t\t\tcallback(success);\n\t\t//\t\t|\t\t}\n\t\t//\t\t|\t}\n\t\t//\n\t\t//\t\t|\t// using callback style\n\t\t//\t\t|\trenderLotsOfData(someDataObj, function(success){\n\t\t//\t\t|\t\t// handles success or failure\n\t\t//\t\t|\t\tif(!success){\n\t\t//\t\t|\t\t\tpromptUserToRecover();\n\t\t//\t\t|\t\t}\n\t\t//\t\t|\t});\n\t\t//\t\t|\t// NOTE: no way to add another callback here!!\n\t\t// example:\n\t\t//\t\tUsing a Deferred doesn't simplify the sending code any, but it\n\t\t//\t\tprovides a standard interface for callers and senders alike,\n\t\t//\t\tproviding both with a simple way to service multiple callbacks for\n\t\t//\t\tan operation and freeing both sides from worrying about details\n\t\t//\t\tsuch as \"did this get called already?\". With Deferreds, new\n\t\t//\t\tcallbacks can be added at any time.\n\t\t//\n\t\t//\t\t|\t// Deferred style:\n\t\t//\t\t|\tfunction renderLotsOfData(data){\n\t\t//\t\t|\t\tvar d = new Deferred();\n\t\t//\t\t|\t\ttry{\n\t\t//\t\t|\t\t\tfor(var x in data){\n\t\t//\t\t|\t\t\t\trenderDataitem(data[x]);\n\t\t//\t\t|\t\t\t}\n\t\t//\t\t|\t\t\td.callback(true);\n\t\t//\t\t|\t\t}catch(e){\n\t\t//\t\t|\t\t\td.errback(new Error(\"rendering failed\"));\n\t\t//\t\t|\t\t}\n\t\t//\t\t|\t\treturn d;\n\t\t//\t\t|\t}\n\t\t//\n\t\t//\t\t|\t// using Deferred style\n\t\t//\t\t|\trenderLotsOfData(someDataObj).then(null, function(){\n\t\t//\t\t|\t\tpromptUserToRecover();\n\t\t//\t\t|\t});\n\t\t//\t\t|\t// NOTE: addErrback and addCallback both return the Deferred\n\t\t//\t\t|\t// again, so we could chain adding callbacks or save the\n\t\t//\t\t|\t// deferred for later should we need to be notified again.\n\t\t// example:\n\t\t//\t\tIn this example, renderLotsOfData is synchronous and so both\n\t\t//\t\tversions are pretty artificial. Putting the data display on a\n\t\t//\t\ttimeout helps show why Deferreds rock:\n\t\t//\n\t\t//\t\t|\t// Deferred style and async func\n\t\t//\t\t|\tfunction renderLotsOfData(data){\n\t\t//\t\t|\t\tvar d = new Deferred();\n\t\t//\t\t|\t\tsetTimeout(function(){\n\t\t//\t\t|\t\t\ttry{\n\t\t//\t\t|\t\t\t\tfor(var x in data){\n\t\t//\t\t|\t\t\t\t\trenderDataitem(data[x]);\n\t\t//\t\t|\t\t\t\t}\n\t\t//\t\t|\t\t\t\td.callback(true);\n\t\t//\t\t|\t\t\t}catch(e){\n\t\t//\t\t|\t\t\t\td.errback(new Error(\"rendering failed\"));\n\t\t//\t\t|\t\t\t}\n\t\t//\t\t|\t\t}, 100);\n\t\t//\t\t|\t\treturn d;\n\t\t//\t\t|\t}\n\t\t//\n\t\t//\t\t|\t// using Deferred style\n\t\t//\t\t|\trenderLotsOfData(someDataObj).then(null, function(){\n\t\t//\t\t|\t\tpromptUserToRecover();\n\t\t//\t\t|\t});\n\t\t//\n\t\t//\t\tNote that the caller doesn't have to change his code at all to\n\t\t//\t\thandle the asynchronous case.\n\n\t\tvar result, finished, isError, head, nextListener;\n\t\tvar promise = (this.promise = new Promise());\n\n\t\tfunction complete(value){\n\t\t\tif(finished){\n\t\t\t\tthrow new Error(\"This deferred has already been resolved\");\n\t\t\t}\n\t\t\tresult = value;\n\t\t\tfinished = true;\n\t\t\tnotify();\n\t\t}\n\t\tfunction notify(){\n\t\t\tvar mutated;\n\t\t\twhile(!mutated && nextListener){\n\t\t\t\tvar listener = nextListener;\n\t\t\t\tnextListener = nextListener.next;\n\t\t\t\tif((mutated = (listener.progress == mutator))){ // assignment and check\n\t\t\t\t\tfinished = false;\n\t\t\t\t}\n\n\t\t\t\tvar func = (isError ? listener.error : listener.resolved);\n\t\t\t\tif(has(\"config-useDeferredInstrumentation\")){\n\t\t\t\t\tif(isError && NewDeferred.instrumentRejected){\n\t\t\t\t\t\tNewDeferred.instrumentRejected(result, !!func);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(func){\n\t\t\t\t\ttry{\n\t\t\t\t\t\tvar newResult = func(result);\n\t\t\t\t\t\tif (newResult && typeof newResult.then === \"function\"){\n\t\t\t\t\t\t\tnewResult.then(lang.hitch(listener.deferred, \"resolve\"), lang.hitch(listener.deferred, \"reject\"), lang.hitch(listener.deferred, \"progress\"));\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar unchanged = mutated && newResult === undefined;\n\t\t\t\t\t\tif(mutated && !unchanged){\n\t\t\t\t\t\t\tisError = newResult instanceof Error;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlistener.deferred[unchanged && isError ? \"reject\" : \"resolve\"](unchanged ? result : newResult);\n\t\t\t\t\t}catch(e){\n\t\t\t\t\t\tlistener.deferred.reject(e);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tif(isError){\n\t\t\t\t\t\tlistener.deferred.reject(result);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tlistener.deferred.resolve(result);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// calling resolve will resolve the promise\n\t\tthis.resolve = this.callback = function(value){\n\t\t\t// summary:\n\t\t\t//\t\tFulfills the Deferred instance successfully with the provide value\n\t\t\tthis.fired = 0;\n\t\t\tthis.results = [value, null];\n\t\t\tcomplete(value);\n\t\t};\n\n\n\t\t// calling error will indicate that the promise failed\n\t\tthis.reject = this.errback = function(error){\n\t\t\t// summary:\n\t\t\t//\t\tFulfills the Deferred instance as an error with the provided error\n\t\t\tisError = true;\n\t\t\tthis.fired = 1;\n\t\t\tif(has(\"config-useDeferredInstrumentation\")){\n\t\t\t\tif(NewDeferred.instrumentRejected){\n\t\t\t\t\tNewDeferred.instrumentRejected(error, !!nextListener);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcomplete(error);\n\t\t\tthis.results = [null, error];\n\t\t};\n\t\t// call progress to provide updates on the progress on the completion of the promise\n\t\tthis.progress = function(update){\n\t\t\t// summary:\n\t\t\t//\t\tSend progress events to all listeners\n\t\t\tvar listener = nextListener;\n\t\t\twhile(listener){\n\t\t\t\tvar progress = listener.progress;\n\t\t\t\tprogress && progress(update);\n\t\t\t\tlistener = listener.next;\n\t\t\t}\n\t\t};\n\t\tthis.addCallbacks = function(callback, errback){\n\t\t\t// summary:\n\t\t\t//\t\tAdds callback and error callback for this deferred instance.\n\t\t\t// callback: Function?\n\t\t\t//\t\tThe callback attached to this deferred object.\n\t\t\t// errback: Function?\n\t\t\t//\t\tThe error callback attached to this deferred object.\n\t\t\t// returns:\n\t\t\t//\t\tReturns this deferred object.\n\t\t\tthis.then(callback, errback, mutator);\n\t\t\treturn this;\t// Deferred\n\t\t};\n\t\t// provide the implementation of the promise\n\t\tpromise.then = this.then = function(/*Function?*/resolvedCallback, /*Function?*/errorCallback, /*Function?*/progressCallback){\n\t\t\t// summary:\n\t\t\t//\t\tAdds a fulfilledHandler, errorHandler, and progressHandler to be called for\n\t\t\t//\t\tcompletion of a promise. The fulfilledHandler is called when the promise\n\t\t\t//\t\tis fulfilled. The errorHandler is called when a promise fails. The\n\t\t\t//\t\tprogressHandler is called for progress events. All arguments are optional\n\t\t\t//\t\tand non-function values are ignored. The progressHandler is not only an\n\t\t\t//\t\toptional argument, but progress events are purely optional. Promise\n\t\t\t//\t\tproviders are not required to ever create progress events.\n\t\t\t//\n\t\t\t//\t\tThis function will return a new promise that is fulfilled when the given\n\t\t\t//\t\tfulfilledHandler or errorHandler callback is finished. This allows promise\n\t\t\t//\t\toperations to be chained together. The value returned from the callback\n\t\t\t//\t\thandler is the fulfillment value for the returned promise. If the callback\n\t\t\t//\t\tthrows an error, the returned promise will be moved to failed state.\n\t\t\t//\n\t\t\t// returns:\n\t\t\t//\t\tReturns a new promise that represents the result of the\n\t\t\t//\t\texecution of the callback. The callbacks will never affect the original promises value.\n\t\t\t// example:\n\t\t\t//\t\tAn example of using a CommonJS compliant promise:\n\t\t\t//\t\t|\tasyncComputeTheAnswerToEverything().\n\t\t\t//\t\t|\t\tthen(addTwo).\n\t\t\t//\t\t|\t\tthen(printResult, onError);\n\t\t\t//\t\t|\t>44\n\t\t\t//\n\t\t\tvar returnDeferred = progressCallback == mutator ? this : new Deferred(promise.cancel);\n\t\t\tvar listener = {\n\t\t\t\tresolved: resolvedCallback,\n\t\t\t\terror: errorCallback,\n\t\t\t\tprogress: progressCallback,\n\t\t\t\tdeferred: returnDeferred\n\t\t\t};\n\t\t\tif(nextListener){\n\t\t\t\thead = head.next = listener;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tnextListener = head = listener;\n\t\t\t}\n\t\t\tif(finished){\n\t\t\t\tnotify();\n\t\t\t}\n\t\t\treturn returnDeferred.promise; // Promise\n\t\t};\n\t\tvar deferred = this;\n\t\tpromise.cancel = this.cancel = function(){\n\t\t\t// summary:\n\t\t\t//\t\tCancels the asynchronous operation\n\t\t\tif(!finished){\n\t\t\t\tvar error = canceller && canceller(deferred);\n\t\t\t\tif(!finished){\n\t\t\t\t\tif (!(error instanceof Error)){\n\t\t\t\t\t\terror = new CancelError(error);\n\t\t\t\t\t}\n\t\t\t\t\terror.log = false;\n\t\t\t\t\tdeferred.reject(error);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tfreeze(promise);\n\t};\n\tlang.extend(Deferred, {\n\t\taddCallback: function(/*Function*/ callback){\n\t\t\t// summary:\n\t\t\t//\t\tAdds successful callback for this deferred instance.\n\t\t\t// returns:\n\t\t\t//\t\tReturns this deferred object.\n\t\t\treturn this.addCallbacks(lang.hitch.apply(dojo, arguments));\t// Deferred\n\t\t},\n\n\t\taddErrback: function(/*Function*/ errback){\n\t\t\t// summary:\n\t\t\t//\t\tAdds error callback for this deferred instance.\n\t\t\t// returns:\n\t\t\t//\t\tReturns this deferred object.\n\t\t\treturn this.addCallbacks(null, lang.hitch.apply(dojo, arguments));\t// Deferred\n\t\t},\n\n\t\taddBoth: function(/*Function*/ callback){\n\t\t\t// summary:\n\t\t\t//\t\tAdd handler as both successful callback and error callback for this deferred instance.\n\t\t\t// returns:\n\t\t\t//\t\tReturns this deferred object.\n\t\t\tvar enclosed = lang.hitch.apply(dojo, arguments);\n\t\t\treturn this.addCallbacks(enclosed, enclosed);\t// Deferred\n\t\t},\n\t\tfired: -1\n\t});\n\n\tDeferred.when = dojo.when = when;\n\n\treturn Deferred;\n});\n\n},\n'dojo/NodeList-dom':function(){\ndefine([\"./_base/kernel\", \"./query\", \"./_base/array\", \"./_base/lang\", \"./dom-class\", \"./dom-construct\", \"./dom-geometry\", \"./dom-attr\", \"./dom-style\"], function(dojo, query, array, lang, domCls, domCtr, domGeom, domAttr, domStyle){\n\n\t// module:\n\t//\t\tdojo/NodeList-dom.js\n\n\t/*=====\n\t return function(){\n\t\t // summary:\n\t\t //\t\tAdds DOM related methods to NodeList, and returns NodeList constructor.\n\t };\n\t =====*/\n\n\tvar magicGuard = function(a){\n\t\t// summary:\n\t\t//\t\tthe guard function for dojo.attr() and dojo.style()\n\t\treturn a.length == 1 && (typeof a[0] == \"string\"); // inline'd type check\n\t};\n\n\tvar orphan = function(node){\n\t\t// summary:\n\t\t//\t\tfunction to orphan nodes\n\t\tvar p = node.parentNode;\n\t\tif(p){\n\t\t\tp.removeChild(node);\n\t\t}\n\t};\n\t// FIXME: should we move orphan() to dojo.html?\n\n\tvar NodeList = query.NodeList,\n\t\tawc = NodeList._adaptWithCondition,\n\t\taafe = NodeList._adaptAsForEach,\n\t\taam = NodeList._adaptAsMap;\n\n\tfunction getSet(module){\n\t\treturn function(node, name, value){\n\t\t\tif(arguments.length == 2){\n\t\t\t\treturn module[typeof name == \"string\" ? \"get\" : \"set\"](node, name);\n\t\t\t}\n\t\t\t// setter\n\t\t\treturn module.set(node, name, value);\n\t\t};\n\t}\n\n\tlang.extend(NodeList, {\n\t\t_normalize: function(/*String||Element||Object||NodeList*/content, /*DOMNode?*/refNode){\n\t\t\t// summary:\n\t\t\t//\t\tnormalizes data to an array of items to insert.\n\t\t\t// description:\n\t\t\t//\t\tIf content is an object, it can have special properties \"template\" and\n\t\t\t//\t\t\"parse\". If \"template\" is defined, then the template value is run through\n\t\t\t//\t\tdojo.string.substitute (if dojo/string.substitute() has been dojo.required elsewhere),\n\t\t\t//\t\tor if templateFunc is a function on the content, that function will be used to\n\t\t\t//\t\ttransform the template into a final string to be used for for passing to dojo/dom-construct.toDom().\n\t\t\t//\t\tIf content.parse is true, then it is remembered for later, for when the content\n\t\t\t//\t\tnodes are inserted into the DOM. At that point, the nodes will be parsed for widgets\n\t\t\t//\t\t(if dojo.parser has been dojo.required elsewhere).\n\n\t\t\t//Wanted to just use a DocumentFragment, but for the array/NodeList\n\t\t\t//case that meant using cloneNode, but we may not want that.\n\t\t\t//Cloning should only happen if the node operations span\n\t\t\t//multiple refNodes. Also, need a real array, not a NodeList from the\n\t\t\t//DOM since the node movements could change those NodeLists.\n\n\t\t\tvar parse = content.parse === true;\n\n\t\t\t//Do we have an object that needs to be run through a template?\n\t\t\tif(typeof content.template == \"string\"){\n\t\t\t\tvar templateFunc = content.templateFunc || (dojo.string && dojo.string.substitute);\n\t\t\t\tcontent = templateFunc ? templateFunc(content.template, content) : content;\n\t\t\t}\n\n\t\t\tvar type = (typeof content);\n\t\t\tif(type == \"string\" || type == \"number\"){\n\t\t\t\tcontent = domCtr.toDom(content, (refNode && refNode.ownerDocument));\n\t\t\t\tif(content.nodeType == 11){\n\t\t\t\t\t//DocumentFragment. It cannot handle cloneNode calls, so pull out the children.\n\t\t\t\t\tcontent = lang._toArray(content.childNodes);\n\t\t\t\t}else{\n\t\t\t\t\tcontent = [content];\n\t\t\t\t}\n\t\t\t}else if(!lang.isArrayLike(content)){\n\t\t\t\tcontent = [content];\n\t\t\t}else if(!lang.isArray(content)){\n\t\t\t\t//To get to this point, content is array-like, but\n\t\t\t\t//not an array, which likely means a DOM NodeList. Convert it now.\n\t\t\t\tcontent = lang._toArray(content);\n\t\t\t}\n\n\t\t\t//Pass around the parse info\n\t\t\tif(parse){\n\t\t\t\tcontent._runParse = true;\n\t\t\t}\n\t\t\treturn content; //Array\n\t\t},\n\n\t\t_cloneNode: function(/*DOMNode*/ node){\n\t\t\t// summary:\n\t\t\t//\t\tprivate utility to clone a node. Not very interesting in the vanilla\n\t\t\t//\t\tdojo/NodeList case, but delegates could do interesting things like\n\t\t\t//\t\tclone event handlers if that is derivable from the node.\n\t\t\treturn node.cloneNode(true);\n\t\t},\n\n\t\t_place: function(/*Array*/ary, /*DOMNode*/refNode, /*String*/position, /*Boolean*/useClone){\n\t\t\t// summary:\n\t\t\t//\t\tprivate utility to handle placing an array of nodes relative to another node.\n\t\t\t// description:\n\t\t\t//\t\tAllows for cloning the nodes in the array, and for\n\t\t\t//\t\toptionally parsing widgets, if ary._runParse is true.\n\n\t\t\t//Avoid a disallowed operation if trying to do an innerHTML on a non-element node.\n\t\t\tif(refNode.nodeType != 1 && position == \"only\"){\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar rNode = refNode, tempNode;\n\n\t\t\t//Always cycle backwards in case the array is really a\n\t\t\t//DOM NodeList and the DOM operations take it out of the live collection.\n\t\t\tvar length = ary.length;\n\t\t\tfor(var i = length - 1; i >= 0; i--){\n\t\t\t\tvar node = (useClone ? this._cloneNode(ary[i]) : ary[i]);\n\n\t\t\t\t//If need widget parsing, use a temp node, instead of waiting after inserting into\n\t\t\t\t//real DOM because we need to start widget parsing at one node up from current node,\n\t\t\t\t//which could cause some already parsed widgets to be parsed again.\n\t\t\t\tif(ary._runParse && dojo.parser && dojo.parser.parse){\n\t\t\t\t\tif(!tempNode){\n\t\t\t\t\t\ttempNode = rNode.ownerDocument.createElement(\"div\");\n\t\t\t\t\t}\n\t\t\t\t\ttempNode.appendChild(node);\n\t\t\t\t\tdojo.parser.parse(tempNode);\n\t\t\t\t\tnode = tempNode.firstChild;\n\t\t\t\t\twhile(tempNode.firstChild){\n\t\t\t\t\t\ttempNode.removeChild(tempNode.firstChild);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif(i == length - 1){\n\t\t\t\t\tdomCtr.place(node, rNode, position);\n\t\t\t\t}else{\n\t\t\t\t\trNode.parentNode.insertBefore(node, rNode);\n\t\t\t\t}\n\t\t\t\trNode = node;\n\t\t\t}\n\t\t},\n\n\n\t\tposition: aam(domGeom.position),\n\t\t/*=====\n\t\tposition: function(){\n\t\t\t// summary:\n\t\t\t//\t\tReturns border-box objects (x/y/w/h) of all elements in a node list\n\t\t\t//\t\tas an Array (*not* a NodeList). Acts like `dojo.position`, though\n\t\t\t//\t\tassumes the node passed is each node in this list.\n\n\t\t\treturn dojo.map(this, dojo.position); // Array\n\t\t},\n\t\t=====*/\n\n\t\tattr: awc(getSet(domAttr), magicGuard),\n\t\t/*=====\n\t\tattr: function(property, value){\n\t\t\t// summary:\n\t\t\t//\t\tgets or sets the DOM attribute for every element in the\n\t\t\t//\t\tNodeList. See also `dojo.attr`\n\t\t\t// property: String\n\t\t\t//\t\tthe attribute to get/set\n\t\t\t// value: String?\n\t\t\t//\t\toptional. The value to set the property to\n\t\t\t// returns:\n\t\t\t//\t\tif no value is passed, the result is an array of attribute values\n\t\t\t//\t\tIf a value is passed, the return is this NodeList\n\t\t\t// example:\n\t\t\t//\t\tMake all nodes with a particular class focusable:\n\t\t\t//\t|\tdojo.query(\".focusable\").attr(\"tabIndex\", -1);\n\t\t\t// example:\n\t\t\t//\t\tDisable a group of buttons:\n\t\t\t//\t|\tdojo.query(\"button.group\").attr(\"disabled\", true);\n\t\t\t// example:\n\t\t\t//\t\tinnerHTML can be assigned or retrieved as well:\n\t\t\t//\t|\t// get the innerHTML (as an array) for each list item\n\t\t\t//\t|\tvar ih = dojo.query(\"li.replaceable\").attr(\"innerHTML\");\n\t\t\treturn; // dojo/NodeList|Array\n\t\t},\n\t\t=====*/\n\n\t\tstyle: awc(getSet(domStyle), magicGuard),\n\t\t/*=====\n\t\tstyle: function(property, value){\n\t\t\t// summary:\n\t\t\t//\t\tgets or sets the CSS property for every element in the NodeList\n\t\t\t// property: String\n\t\t\t//\t\tthe CSS property to get/set, in JavaScript notation\n\t\t\t//\t\t(\"lineHieght\" instead of \"line-height\")\n\t\t\t// value: String?\n\t\t\t//\t\toptional. The value to set the property to\n\t\t\t// returns:\n\t\t\t//\t\tif no value is passed, the result is an array of strings.\n\t\t\t//\t\tIf a value is passed, the return is this NodeList\n\t\t\treturn; // dojo/NodeList\n\t\t\treturn; // Array\n\t\t},\n\t\t=====*/\n\n\t\taddClass: aafe(domCls.add),\n\t\t/*=====\n\t\taddClass: function(className){\n\t\t\t// summary:\n\t\t\t//\t\tadds the specified class to every node in the list\n\t\t\t// className: String|Array\n\t\t\t//\t\tA String class name to add, or several space-separated class names,\n\t\t\t//\t\tor an array of class names.\n\t\t\treturn; // dojo/NodeList\n\t\t},\n\t\t=====*/\n\n\t\tremoveClass: aafe(domCls.remove),\n\t\t/*=====\n\t\tremoveClass: function(className){\n\t\t\t// summary:\n\t\t\t//\t\tremoves the specified class from every node in the list\n\t\t\t// className: String|Array?\n\t\t\t//\t\tAn optional String class name to remove, or several space-separated\n\t\t\t//\t\tclass names, or an array of class names. If omitted, all class names\n\t\t\t//\t\twill be deleted.\n\t\t\t// returns:\n\t\t\t//\t\tthis list\n\t\t\treturn; // dojo/NodeList\n\t\t},\n\t\t=====*/\n\n\t\ttoggleClass: aafe(domCls.toggle),\n\t\t/*=====\n\t\ttoggleClass: function(className, condition){\n\t\t\t// summary:\n\t\t\t//\t\tAdds a class to node if not present, or removes if present.\n\t\t\t//\t\tPass a boolean condition if you want to explicitly add or remove.\n\t\t\t// condition: Boolean?\n\t\t\t//\t\tIf passed, true means to add the class, false means to remove.\n\t\t\t// className: String\n\t\t\t//\t\tthe CSS class to add\n\t\t\treturn; // dojo/NodeList\n\t\t},\n\t\t=====*/\n\n\t\treplaceClass: aafe(domCls.replace),\n\t\t/*=====\n\t\treplaceClass: function(addClassStr, removeClassStr){\n\t\t\t// summary:\n\t\t\t//\t\tReplaces one or more classes on a node if not present.\n\t\t\t//\t\tOperates more quickly than calling `removeClass()` and `addClass()`\n\t\t\t// addClassStr: String|Array\n\t\t\t//\t\tA String class name to add, or several space-separated class names,\n\t\t\t//\t\tor an array of class names.\n\t\t\t// removeClassStr: String|Array?\n\t\t\t//\t\tA String class name to remove, or several space-separated class names,\n\t\t\t//\t\tor an array of class names.\n\t\t\treturn; // dojo/NodeList\n\t\t },\n\t\t =====*/\n\n\t\tempty: aafe(domCtr.empty),\n\t\t/*=====\n\t\tempty: function(){\n\t\t\t// summary:\n\t\t\t//\t\tclears all content from each node in the list. Effectively\n\t\t\t//\t\tequivalent to removing all child nodes from every item in\n\t\t\t//\t\tthe list.\n\t\t\treturn this.forEach(\"item.innerHTML='';\"); // dojo/NodeList\n\t\t\t// FIXME: should we be checking for and/or disposing of widgets below these nodes?\n\t\t},\n\t\t=====*/\n\n\t\tremoveAttr: aafe(domAttr.remove),\n\t\t/*=====\n\t\t removeAttr: function(name){\n\t\t\t// summary:\n\t\t\t//\t\tRemoves an attribute from each node in the list.\n\t\t\t// name: String\n\t\t\t//\t\tthe name of the attribute to remove\n\t\t\treturn;\t\t// dojo/NodeList\n\t\t},\n\t\t=====*/\n\n\t\tmarginBox: aam(domGeom.getMarginBox),\n\t\t/*=====\n\t\tmarginBox: function(){\n\t\t\t// summary:\n\t\t\t//\t\tReturns margin-box size of nodes\n\t\t \treturn; // dojo/NodeList\n\t\t },\n\t\t =====*/\n\n\t\t// FIXME: connectPublisher()? connectRunOnce()?\n\n\t\t/*\n\t\tdestroy: function(){\n\t\t\t// summary:\n\t\t\t//\t\tdestroys every item in the list.\n\t\t\tthis.forEach(d.destroy);\n\t\t\t// FIXME: should we be checking for and/or disposing of widgets below these nodes?\n\t\t},\n\t\t*/\n\n\t\tplace: function(/*String||Node*/ queryOrNode, /*String*/ position){\n\t\t\t// summary:\n\t\t\t//\t\tplaces elements of this node list relative to the first element matched\n\t\t\t//\t\tby queryOrNode. Returns the original NodeList. See: `dojo.place`\n\t\t\t// queryOrNode:\n\t\t\t//\t\tmay be a string representing any valid CSS3 selector or a DOM node.\n\t\t\t//\t\tIn the selector case, only the first matching element will be used\n\t\t\t//\t\tfor relative positioning.\n\t\t\t// position:\n\t\t\t//\t\tcan be one of:\n\t\t\t//\n\t\t\t//\t\t-\t\"last\" (default)\n\t\t\t//\t\t-\t\"first\"\n\t\t\t//\t\t-\t\"before\"\n\t\t\t//\t\t-\t\"after\"\n\t\t\t//\t\t-\t\"only\"\n\t\t\t//\t\t-\t\"replace\"\n\t\t\t//\n\t\t\t//\t\tor an offset in the childNodes property\n\t\t\tvar item = query(queryOrNode)[0];\n\t\t\treturn this.forEach(function(node){ domCtr.place(node, item, position); }); // dojo/NodeList\n\t\t},\n\n\t\torphan: function(/*String?*/ filter){\n\t\t\t// summary:\n\t\t\t//\t\tremoves elements in this list that match the filter\n\t\t\t//\t\tfrom their parents and returns them as a new NodeList.\n\t\t\t// filter:\n\t\t\t//\t\tCSS selector like \".foo\" or \"div > span\"\n\t\t\t// returns:\n\t\t\t//\t\tNodeList containing the orphaned elements\n\t\t\treturn (filter ? query._filterResult(this, filter) : this).forEach(orphan); // dojo/NodeList\n\t\t},\n\n\t\tadopt: function(/*String||Array||DomNode*/ queryOrListOrNode, /*String?*/ position){\n\t\t\t// summary:\n\t\t\t//\t\tplaces any/all elements in queryOrListOrNode at a\n\t\t\t//\t\tposition relative to the first element in this list.\n\t\t\t//\t\tReturns a dojo/NodeList of the adopted elements.\n\t\t\t// queryOrListOrNode:\n\t\t\t//\t\ta DOM node or a query string or a query result.\n\t\t\t//\t\tRepresents the nodes to be adopted relative to the\n\t\t\t//\t\tfirst element of this NodeList.\n\t\t\t// position:\n\t\t\t//\t\tcan be one of:\n\t\t\t//\n\t\t\t//\t\t-\t\"last\" (default)\n\t\t\t//\t\t-\t\"first\"\n\t\t\t//\t\t-\t\"before\"\n\t\t\t//\t\t-\t\"after\"\n\t\t\t//\t\t-\t\"only\"\n\t\t\t//\t\t-\t\"replace\"\n\t\t\t//\n\t\t\t//\t\tor an offset in the childNodes property\n\t\t\treturn query(queryOrListOrNode).place(this[0], position)._stash(this);\t// dojo/NodeList\n\t\t},\n\n\t\t// FIXME: do we need this?\n\t\tquery: function(/*String*/ queryStr){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a new list whose members match the passed query,\n\t\t\t//\t\tassuming elements of the current NodeList as the root for\n\t\t\t//\t\teach search.\n\t\t\t// example:\n\t\t\t//\t\tassume a DOM created by this markup:\n\t\t\t//\t|\t<div id=\"foo\">\n\t\t\t//\t|\t\t<p>\n\t\t\t//\t|\t\t\tbacon is tasty, <span>dontcha think?</span>\n\t\t\t//\t|\t\t</p>\n\t\t\t//\t|\t</div>\n\t\t\t//\t|\t<div id=\"bar\">\n\t\t\t//\t|\t\t<p>great comedians may not be funny <span>in person</span></p>\n\t\t\t//\t|\t</div>\n\t\t\t//\t\tIf we are presented with the following definition for a NodeList:\n\t\t\t//\t|\tvar l = new NodeList(dojo.byId(\"foo\"), dojo.byId(\"bar\"));\n\t\t\t//\t\tit's possible to find all span elements under paragraphs\n\t\t\t//\t\tcontained by these elements with this sub-query:\n\t\t\t//\t|\tvar spans = l.query(\"p span\");\n\n\t\t\t// FIXME: probably slow\n\t\t\tif(!queryStr){ return this; }\n\t\t\tvar ret = new NodeList;\n\t\t\tthis.map(function(node){\n\t\t\t\t// FIXME: why would we ever get undefined here?\n\t\t\t\tquery(queryStr, node).forEach(function(subNode){\n\t\t\t\t\tif(subNode !== undefined){\n\t\t\t\t\t\tret.push(subNode);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t\treturn ret._stash(this);\t// dojo/NodeList\n\t\t},\n\n\t\tfilter: function(/*String|Function*/ filter){\n\t\t\t// summary:\n\t\t\t//\t\t\"masks\" the built-in javascript filter() method (supported\n\t\t\t//\t\tin Dojo via `dojo.filter`) to support passing a simple\n\t\t\t//\t\tstring filter in addition to supporting filtering function\n\t\t\t//\t\tobjects.\n\t\t\t// filter:\n\t\t\t//\t\tIf a string, a CSS rule like \".thinger\" or \"div > span\".\n\t\t\t// example:\n\t\t\t//\t\t\"regular\" JS filter syntax as exposed in dojo.filter:\n\t\t\t//\t\t|\tdojo.query(\"*\").filter(function(item){\n\t\t\t//\t\t|\t\t// highlight every paragraph\n\t\t\t//\t\t|\t\treturn (item.nodeName == \"p\");\n\t\t\t//\t\t|\t}).style(\"backgroundColor\", \"yellow\");\n\t\t\t// example:\n\t\t\t//\t\tthe same filtering using a CSS selector\n\t\t\t//\t\t|\tdojo.query(\"*\").filter(\"p\").styles(\"backgroundColor\", \"yellow\");\n\n\t\t\tvar a = arguments, items = this, start = 0;\n\t\t\tif(typeof filter == \"string\"){ // inline'd type check\n\t\t\t\titems = query._filterResult(this, a[0]);\n\t\t\t\tif(a.length == 1){\n\t\t\t\t\t// if we only got a string query, pass back the filtered results\n\t\t\t\t\treturn items._stash(this); // dojo/NodeList\n\t\t\t\t}\n\t\t\t\t// if we got a callback, run it over the filtered items\n\t\t\t\tstart = 1;\n\t\t\t}\n\t\t\treturn this._wrap(array.filter(items, a[start], a[start + 1]), this);\t// dojo/NodeList\n\t\t},\n\n\t\t/*\n\t\t// FIXME: should this be \"copyTo\" and include parenting info?\n\t\tclone: function(){\n\t\t\t// summary:\n\t\t\t//\t\tcreates node clones of each element of this list\n\t\t\t//\t\tand returns a new list containing the clones\n\t\t},\n\t\t*/\n\n\t\taddContent: function(/*String||DomNode||Object||dojo/NodeList*/ content, /*String||Integer?*/ position){\n\t\t\t// summary:\n\t\t\t//\t\tadd a node, NodeList or some HTML as a string to every item in the\n\t\t\t//\t\tlist.  Returns the original list.\n\t\t\t// description:\n\t\t\t//\t\ta copy of the HTML content is added to each item in the\n\t\t\t//\t\tlist, with an optional position argument. If no position\n\t\t\t//\t\targument is provided, the content is appended to the end of\n\t\t\t//\t\teach item.\n\t\t\t// content:\n\t\t\t//\t\tDOM node, HTML in string format, a NodeList or an Object. If a DOM node or\n\t\t\t//\t\tNodeList, the content will be cloned if the current NodeList has more than one\n\t\t\t//\t\telement. Only the DOM nodes are cloned, no event handlers. If it is an Object,\n\t\t\t//\t\tit should be an object with at \"template\" String property that has the HTML string\n\t\t\t//\t\tto insert. If dojo.string has already been dojo.required, then dojo.string.substitute\n\t\t\t//\t\twill be used on the \"template\" to generate the final HTML string. Other allowed\n\t\t\t//\t\tproperties on the object are: \"parse\" if the HTML\n\t\t\t//\t\tstring should be parsed for widgets (dojo.require(\"dojo.parser\") to get that\n\t\t\t//\t\toption to work), and \"templateFunc\" if a template function besides dojo.string.substitute\n\t\t\t//\t\tshould be used to transform the \"template\".\n\t\t\t// position:\n\t\t\t//\t\tcan be one of:\n\t\t\t//\n\t\t\t//\t\t-\t\"last\"||\"end\" (default)\n\t\t\t//\t\t-\t\"first||\"start\"\n\t\t\t//\t\t-\t\"before\"\n\t\t\t//\t\t-\t\"after\"\n\t\t\t//\t\t-\t\"replace\" (replaces nodes in this NodeList with new content)\n\t\t\t//\t\t-\t\"only\" (removes other children of the nodes so new content is the only child)\n\t\t\t//\n\t\t\t//\t\tor an offset in the childNodes property\n\t\t\t// example:\n\t\t\t//\t\tappends content to the end if the position is omitted\n\t\t\t//\t|\tdojo.query(\"h3 > p\").addContent(\"hey there!\");\n\t\t\t// example:\n\t\t\t//\t\tadd something to the front of each element that has a\n\t\t\t//\t\t\"thinger\" property:\n\t\t\t//\t|\tdojo.query(\"[thinger]\").addContent(\"...\", \"first\");\n\t\t\t// example:\n\t\t\t//\t\tadds a header before each element of the list\n\t\t\t//\t|\tdojo.query(\".note\").addContent(\"<h4>NOTE:</h4>\", \"before\");\n\t\t\t// example:\n\t\t\t//\t\tadd a clone of a DOM node to the end of every element in\n\t\t\t//\t\tthe list, removing it from its existing parent.\n\t\t\t//\t|\tdojo.query(\".note\").addContent(dojo.byId(\"foo\"));\n\t\t\t// example:\n\t\t\t//\t\tAppend nodes from a templatized string.\n\t\t\t// |\tdojo.require(\"dojo.string\");\n\t\t\t// |\tdojo.query(\".note\").addContent({\n\t\t\t// |\t\ttemplate: '<b>${id}: </b><span>${name}</span>',\n\t\t\t// |\t\tid: \"user332\",\n\t\t\t// |\t\tname: \"Mr. Anderson\"\n\t\t\t// |\t});\n\t\t\t// example:\n\t\t\t//\t\tAppend nodes from a templatized string that also has widgets parsed.\n\t\t\t// |\tdojo.require(\"dojo.string\");\n\t\t\t// |\tdojo.require(\"dojo.parser\");\n\t\t\t// |\tvar notes = dojo.query(\".note\").addContent({\n\t\t\t// |\t\ttemplate: '<button dojoType=\"dijit/form/Button\">${text}</button>',\n\t\t\t// |\t\tparse: true,\n\t\t\t// |\t\ttext: \"Send\"\n\t\t\t// |\t});\n\t\t\tcontent = this._normalize(content, this[0]);\n\t\t\tfor(var i = 0, node; (node = this[i]); i++){\n\t\t\t\tthis._place(content, node, position, i > 0);\n\t\t\t}\n\t\t\treturn this; // dojo/NodeList\n\t\t}\n\t});\n\n\treturn NodeList;\n});\n\n},\n'dojo/query':function(){\ndefine([\"./_base/kernel\", \"./has\", \"./dom\", \"./on\", \"./_base/array\", \"./_base/lang\", \"./selector/_loader\", \"./selector/_loader!default\"],\n\tfunction(dojo, has, dom, on, array, lang, loader, defaultEngine){\n\n\t\"use strict\";\n\n\thas.add(\"array-extensible\", function(){\n\t\t// test to see if we can extend an array (not supported in old IE)\n\t\treturn lang.delegate([], {length: 1}).length == 1 && !has(\"bug-for-in-skips-shadowed\");\n\t});\n\t\n\tvar ap = Array.prototype, aps = ap.slice, apc = ap.concat, forEach = array.forEach;\n\n\tvar tnl = function(/*Array*/ a, /*dojo/NodeList?*/ parent, /*Function?*/ NodeListCtor){\n\t\t// summary:\n\t\t//\t\tdecorate an array to make it look like a `dojo/NodeList`.\n\t\t// a:\n\t\t//\t\tArray of nodes to decorate.\n\t\t// parent:\n\t\t//\t\tAn optional parent NodeList that generated the current\n\t\t//\t\tlist of nodes. Used to call _stash() so the parent NodeList\n\t\t//\t\tcan be accessed via end() later.\n\t\t// NodeListCtor:\n\t\t//\t\tAn optional constructor function to use for any\n\t\t//\t\tnew NodeList calls. This allows a certain chain of\n\t\t//\t\tNodeList calls to use a different object than dojo/NodeList.\n\t\tvar nodeList = new (NodeListCtor || this._NodeListCtor || nl)(a);\n\t\treturn parent ? nodeList._stash(parent) : nodeList;\n\t};\n\n\tvar loopBody = function(f, a, o){\n\t\ta = [0].concat(aps.call(a, 0));\n\t\to = o || dojo.global;\n\t\treturn function(node){\n\t\t\ta[0] = node;\n\t\t\treturn f.apply(o, a);\n\t\t};\n\t};\n\n\t// adapters\n\n\tvar adaptAsForEach = function(f, o){\n\t\t// summary:\n\t\t//\t\tadapts a single node function to be used in the forEach-type\n\t\t//\t\tactions. The initial object is returned from the specialized\n\t\t//\t\tfunction.\n\t\t// f: Function\n\t\t//\t\ta function to adapt\n\t\t// o: Object?\n\t\t//\t\tan optional context for f\n\t\treturn function(){\n\t\t\tthis.forEach(loopBody(f, arguments, o));\n\t\t\treturn this;\t// Object\n\t\t};\n\t};\n\n\tvar adaptAsMap = function(f, o){\n\t\t// summary:\n\t\t//\t\tadapts a single node function to be used in the map-type\n\t\t//\t\tactions. The return is a new array of values, as via `dojo.map`\n\t\t// f: Function\n\t\t//\t\ta function to adapt\n\t\t// o: Object?\n\t\t//\t\tan optional context for f\n\t\treturn function(){\n\t\t\treturn this.map(loopBody(f, arguments, o));\n\t\t};\n\t};\n\n\tvar adaptAsFilter = function(f, o){\n\t\t// summary:\n\t\t//\t\tadapts a single node function to be used in the filter-type actions\n\t\t// f: Function\n\t\t//\t\ta function to adapt\n\t\t// o: Object?\n\t\t//\t\tan optional context for f\n\t\treturn function(){\n\t\t\treturn this.filter(loopBody(f, arguments, o));\n\t\t};\n\t};\n\n\tvar adaptWithCondition = function(f, g, o){\n\t\t// summary:\n\t\t//\t\tadapts a single node function to be used in the map-type\n\t\t//\t\tactions, behaves like forEach() or map() depending on arguments\n\t\t// f: Function\n\t\t//\t\ta function to adapt\n\t\t// g: Function\n\t\t//\t\ta condition function, if true runs as map(), otherwise runs as forEach()\n\t\t// o: Object?\n\t\t//\t\tan optional context for f and g\n\t\treturn function(){\n\t\t\tvar a = arguments, body = loopBody(f, a, o);\n\t\t\tif(g.call(o || dojo.global, a)){\n\t\t\t\treturn this.map(body);\t// self\n\t\t\t}\n\t\t\tthis.forEach(body);\n\t\t\treturn this;\t// self\n\t\t};\n\t};\n\n\tvar NodeList = function(array){\n\t\t// summary:\n\t\t//\t\tArray-like object which adds syntactic\n\t\t//\t\tsugar for chaining, common iteration operations, animation, and\n\t\t//\t\tnode manipulation. NodeLists are most often returned as the\n\t\t//\t\tresult of dojo.query() calls.\n\t\t// description:\n\t\t//\t\tNodeList instances provide many utilities that reflect\n\t\t//\t\tcore Dojo APIs for Array iteration and manipulation, DOM\n\t\t//\t\tmanipulation, and event handling. Instead of needing to dig up\n\t\t//\t\tfunctions in the dojo.* namespace, NodeLists generally make the\n\t\t//\t\tfull power of Dojo available for DOM manipulation tasks in a\n\t\t//\t\tsimple, chainable way.\n\t\t// example:\n\t\t//\t\tcreate a node list from a node\n\t\t//\t\t|\tnew query.NodeList(dojo.byId(\"foo\"));\n\t\t// example:\n\t\t//\t\tget a NodeList from a CSS query and iterate on it\n\t\t//\t\t|\tvar l = dojo.query(\".thinger\");\n\t\t//\t\t|\tl.forEach(function(node, index, nodeList){\n\t\t//\t\t|\t\tconsole.log(index, node.innerHTML);\n\t\t//\t\t|\t});\n\t\t// example:\n\t\t//\t\tuse native and Dojo-provided array methods to manipulate a\n\t\t//\t\tNodeList without needing to use dojo.* functions explicitly:\n\t\t//\t\t|\tvar l = dojo.query(\".thinger\");\n\t\t//\t\t|\t// since NodeLists are real arrays, they have a length\n\t\t//\t\t|\t// property that is both readable and writable and\n\t\t//\t\t|\t// push/pop/shift/unshift methods\n\t\t//\t\t|\tconsole.log(l.length);\n\t\t//\t\t|\tl.push(dojo.create(\"span\"));\n\t\t//\t\t|\n\t\t//\t\t|\t// dojo's normalized array methods work too:\n\t\t//\t\t|\tconsole.log( l.indexOf(dojo.byId(\"foo\")) );\n\t\t//\t\t|\t// ...including the special \"function as string\" shorthand\n\t\t//\t\t|\tconsole.log( l.every(\"item.nodeType == 1\") );\n\t\t//\t\t|\n\t\t//\t\t|\t// NodeLists can be [..] indexed, or you can use the at()\n\t\t//\t\t|\t// function to get specific items wrapped in a new NodeList:\n\t\t//\t\t|\tvar node = l[3]; // the 4th element\n\t\t//\t\t|\tvar newList = l.at(1, 3); // the 2nd and 4th elements\n\t\t// example:\n\t\t//\t\tthe style functions you expect are all there too:\n\t\t//\t\t|\t// style() as a getter...\n\t\t//\t\t|\tvar borders = dojo.query(\".thinger\").style(\"border\");\n\t\t//\t\t|\t// ...and as a setter:\n\t\t//\t\t|\tdojo.query(\".thinger\").style(\"border\", \"1px solid black\");\n\t\t//\t\t|\t// class manipulation\n\t\t//\t\t|\tdojo.query(\"li:nth-child(even)\").addClass(\"even\");\n\t\t//\t\t|\t// even getting the coordinates of all the items\n\t\t//\t\t|\tvar coords = dojo.query(\".thinger\").coords();\n\t\t// example:\n\t\t//\t\tDOM manipulation functions from the dojo.* namespace area also available:\n\t\t//\t\t|\t// remove all of the elements in the list from their\n\t\t//\t\t|\t// parents (akin to \"deleting\" them from the document)\n\t\t//\t\t|\tdojo.query(\".thinger\").orphan();\n\t\t//\t\t|\t// place all elements in the list at the front of #foo\n\t\t//\t\t|\tdojo.query(\".thinger\").place(\"foo\", \"first\");\n\t\t// example:\n\t\t//\t\tEvent handling couldn't be easier. `dojo.connect` is mapped in,\n\t\t//\t\tand shortcut handlers are provided for most DOM events:\n\t\t//\t\t|\t// like dojo.connect(), but with implicit scope\n\t\t//\t\t|\tdojo.query(\"li\").connect(\"onclick\", console, \"log\");\n\t\t//\t\t|\n\t\t//\t\t|\t// many common event handlers are already available directly:\n\t\t//\t\t|\tdojo.query(\"li\").onclick(console, \"log\");\n\t\t//\t\t|\tvar toggleHovered = dojo.hitch(dojo, \"toggleClass\", \"hovered\");\n\t\t//\t\t|\tdojo.query(\"p\")\n\t\t//\t\t|\t\t.onmouseenter(toggleHovered)\n\t\t//\t\t|\t\t.onmouseleave(toggleHovered);\n\t\t// example:\n\t\t//\t\tchainability is a key advantage of NodeLists:\n\t\t//\t\t|\tdojo.query(\".thinger\")\n\t\t//\t\t|\t\t.onclick(function(e){ /* ... */ })\n\t\t//\t\t|\t\t.at(1, 3, 8) // get a subset\n\t\t//\t\t|\t\t\t.style(\"padding\", \"5px\")\n\t\t//\t\t|\t\t\t.forEach(console.log);\n\t\tvar isNew = this instanceof nl && has(\"array-extensible\");\n\t\tif(typeof array == \"number\"){\n\t\t\tarray = Array(array);\n\t\t}\n\t\tvar nodeArray = (array && \"length\" in array) ? array : arguments;\n\t\tif(isNew || !nodeArray.sort){\n\t\t\t// make sure it's a real array before we pass it on to be wrapped \n\t\t\tvar target = isNew ? this : [],\n\t\t\t\tl = target.length = nodeArray.length;\n\t\t\tfor(var i = 0; i < l; i++){\n\t\t\t\ttarget[i] = nodeArray[i];\n\t\t\t}\n\t\t\tif(isNew){\n\t\t\t\t// called with new operator, this means we are going to use this instance and push\n\t\t\t\t// the nodes on to it. This is usually much faster since the NodeList properties\n\t\t\t\t//\tdon't need to be copied (unless the list of nodes is extremely large).\n\t\t\t\treturn target;\n\t\t\t}\n\t\t\tnodeArray = target;\n\t\t}\n\t\t// called without new operator, use a real array and copy prototype properties,\n\t\t// this is slower and exists for back-compat. Should be removed in 2.0.\n\t\tlang._mixin(nodeArray, nlp);\n\t\tnodeArray._NodeListCtor = function(array){\n\t\t\t// call without new operator to preserve back-compat behavior\n\t\t\treturn nl(array);\n\t\t};\n\t\treturn nodeArray;\n\t};\n\t\n\tvar nl = NodeList, nlp = nl.prototype = \n\t\thas(\"array-extensible\") ? [] : {};// extend an array if it is extensible\n\n\t// expose adapters and the wrapper as private functions\n\n\tnl._wrap = nlp._wrap = tnl;\n\tnl._adaptAsMap = adaptAsMap;\n\tnl._adaptAsForEach = adaptAsForEach;\n\tnl._adaptAsFilter  = adaptAsFilter;\n\tnl._adaptWithCondition = adaptWithCondition;\n\n\t// mass assignment\n\n\t// add array redirectors\n\tforEach([\"slice\", \"splice\"], function(name){\n\t\tvar f = ap[name];\n\t\t//Use a copy of the this array via this.slice() to allow .end() to work right in the splice case.\n\t\t// CANNOT apply ._stash()/end() to splice since it currently modifies\n\t\t// the existing this array -- it would break backward compatibility if we copy the array before\n\t\t// the splice so that we can use .end(). So only doing the stash option to this._wrap for slice.\n\t\tnlp[name] = function(){ return this._wrap(f.apply(this, arguments), name == \"slice\" ? this : null); };\n\t});\n\t// concat should be here but some browsers with native NodeList have problems with it\n\n\t// add array.js redirectors\n\tforEach([\"indexOf\", \"lastIndexOf\", \"every\", \"some\"], function(name){\n\t\tvar f = array[name];\n\t\tnlp[name] = function(){ return f.apply(dojo, [this].concat(aps.call(arguments, 0))); };\n\t});\n\n\tlang.extend(NodeList, {\n\t\t// copy the constructors\n\t\tconstructor: nl,\n\t\t_NodeListCtor: nl,\n\t\ttoString: function(){\n\t\t\t// Array.prototype.toString can't be applied to objects, so we use join\n\t\t\treturn this.join(\",\");\n\t\t},\n\t\t_stash: function(parent){\n\t\t\t// summary:\n\t\t\t//\t\tprivate function to hold to a parent NodeList. end() to return the parent NodeList.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tHow to make a `dojo/NodeList` method that only returns the third node in\n\t\t\t//\t\tthe dojo/NodeList but allows access to the original NodeList by using this._stash:\n\t\t\t//\t|\tdojo.extend(NodeList, {\n\t\t\t//\t|\t\tthird: function(){\n\t\t\t//\t|\t\t\tvar newNodeList = NodeList(this[2]);\n\t\t\t//\t|\t\t\treturn newNodeList._stash(this);\n\t\t\t//\t|\t\t}\n\t\t\t//\t|\t});\n\t\t\t//\t|\t// then see how _stash applies a sub-list, to be .end()'ed out of\n\t\t\t//\t|\tdojo.query(\".foo\")\n\t\t\t//\t|\t\t.third()\n\t\t\t//\t|\t\t\t.addClass(\"thirdFoo\")\n\t\t\t//\t|\t\t.end()\n\t\t\t//\t|\t\t// access to the orig .foo list\n\t\t\t//\t|\t\t.removeClass(\"foo\")\n\t\t\t//\t|\n\t\t\t//\n\t\t\tthis._parent = parent;\n\t\t\treturn this; // dojo/NodeList\n\t\t},\n\n\t\ton: function(eventName, listener){\n\t\t\t// summary:\n\t\t\t//\t\tListen for events on the nodes in the NodeList. Basic usage is:\n\t\t\t//\t\t| query(\".my-class\").on(\"click\", listener);\n\t\t\t//\t\tThis supports event delegation by using selectors as the first argument with the event names as\n\t\t\t//\t\tpseudo selectors. For example:\n\t\t\t//\t\t| dojo.query(\"#my-list\").on(\"li:click\", listener);\n\t\t\t//\t\tThis will listen for click events within `<li>` elements that are inside the `#my-list` element.\n\t\t\t//\t\tBecause on supports CSS selector syntax, we can use comma-delimited events as well:\n\t\t\t//\t\t| dojo.query(\"#my-list\").on(\"li button:mouseover, li:click\", listener);\n\t\t\tvar handles = this.map(function(node){\n\t\t\t\treturn on(node, eventName, listener); // TODO: apply to the NodeList so the same selector engine is used for matches\n\t\t\t});\n\t\t\thandles.remove = function(){\n\t\t\t\tfor(var i = 0; i < handles.length; i++){\n\t\t\t\t\thandles[i].remove();\n\t\t\t\t}\n\t\t\t};\n\t\t\treturn handles;\n\t\t},\n\n\t\tend: function(){\n\t\t\t// summary:\n\t\t\t//\t\tEnds use of the current `NodeList` by returning the previous NodeList\n\t\t\t//\t\tthat generated the current NodeList.\n\t\t\t// description:\n\t\t\t//\t\tReturns the `NodeList` that generated the current `NodeList`. If there\n\t\t\t//\t\tis no parent NodeList, an empty NodeList is returned.\n\t\t\t// example:\n\t\t\t//\t|\tdojo.query(\"a\")\n\t\t\t//\t|\t\t.filter(\".disabled\")\n\t\t\t//\t|\t\t\t// operate on the anchors that only have a disabled class\n\t\t\t//\t|\t\t\t.style(\"color\", \"grey\")\n\t\t\t//\t|\t\t.end()\n\t\t\t//\t|\t\t// jump back to the list of anchors\n\t\t\t//\t|\t\t.style(...)\n\t\t\t//\n\t\t\tif(this._parent){\n\t\t\t\treturn this._parent;\n\t\t\t}else{\n\t\t\t\t//Just return empty list.\n\t\t\t\treturn new this._NodeListCtor(0);\n\t\t\t}\n\t\t},\n\n\t\t// http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array#Methods\n\n\t\t// FIXME: handle return values for #3244\n\t\t//\t\thttp://trac.dojotoolkit.org/ticket/3244\n\n\t\t// FIXME:\n\t\t//\t\tneed to wrap or implement:\n\t\t//\t\t\tjoin (perhaps w/ innerHTML/outerHTML overload for toString() of items?)\n\t\t//\t\t\treduce\n\t\t//\t\t\treduceRight\n\n\t\t/*=====\n\t\tslice: function(begin, end){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a new NodeList, maintaining this one in place\n\t\t\t// description:\n\t\t\t//\t\tThis method behaves exactly like the Array.slice method\n\t\t\t//\t\twith the caveat that it returns a dojo/NodeList and not a\n\t\t\t//\t\traw Array. For more details, see Mozilla's [slice\n\t\t\t//\t\tdocumentation](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/slice)\n\t\t\t// begin: Integer\n\t\t\t//\t\tCan be a positive or negative integer, with positive\n\t\t\t//\t\tintegers noting the offset to begin at, and negative\n\t\t\t//\t\tintegers denoting an offset from the end (i.e., to the left\n\t\t\t//\t\tof the end)\n\t\t\t// end: Integer?\n\t\t\t//\t\tOptional parameter to describe what position relative to\n\t\t\t//\t\tthe NodeList's zero index to end the slice at. Like begin,\n\t\t\t//\t\tcan be positive or negative.\n\t\t\treturn this._wrap(a.slice.apply(this, arguments));\n\t\t},\n\n\t\tsplice: function(index, howmany, item){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a new NodeList, manipulating this NodeList based on\n\t\t\t//\t\tthe arguments passed, potentially splicing in new elements\n\t\t\t//\t\tat an offset, optionally deleting elements\n\t\t\t// description:\n\t\t\t//\t\tThis method behaves exactly like the Array.splice method\n\t\t\t//\t\twith the caveat that it returns a dojo/NodeList and not a\n\t\t\t//\t\traw Array. For more details, see Mozilla's [splice\n\t\t\t//\t\tdocumentation](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/splice)\n\t\t\t//\t\tFor backwards compatibility, calling .end() on the spliced NodeList\n\t\t\t//\t\tdoes not return the original NodeList -- splice alters the NodeList in place.\n\t\t\t// index: Integer\n\t\t\t//\t\tbegin can be a positive or negative integer, with positive\n\t\t\t//\t\tintegers noting the offset to begin at, and negative\n\t\t\t//\t\tintegers denoting an offset from the end (i.e., to the left\n\t\t\t//\t\tof the end)\n\t\t\t// howmany: Integer?\n\t\t\t//\t\tOptional parameter to describe what position relative to\n\t\t\t//\t\tthe NodeList's zero index to end the slice at. Like begin,\n\t\t\t//\t\tcan be positive or negative.\n\t\t\t// item: Object...?\n\t\t\t//\t\tAny number of optional parameters may be passed in to be\n\t\t\t//\t\tspliced into the NodeList\n\t\t\treturn this._wrap(a.splice.apply(this, arguments));\t// dojo/NodeList\n\t\t},\n\n\t\tindexOf: function(value, fromIndex){\n\t\t\t// summary:\n\t\t\t//\t\tsee dojo.indexOf(). The primary difference is that the acted-on\n\t\t\t//\t\tarray is implicitly this NodeList\n\t\t\t// value: Object\n\t\t\t//\t\tThe value to search for.\n\t\t\t// fromIndex: Integer?\n\t\t\t//\t\tThe location to start searching from. Optional. Defaults to 0.\n\t\t\t// description:\n\t\t\t//\t\tFor more details on the behavior of indexOf, see Mozilla's\n\t\t\t//\t\t[indexOf\n\t\t\t//\t\tdocs](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf)\n\t\t\t// returns:\n\t\t\t//\t\tPositive Integer or 0 for a match, -1 of not found.\n\t\t\treturn d.indexOf(this, value, fromIndex); // Integer\n\t\t},\n\n\t\tlastIndexOf: function(value, fromIndex){\n\t\t\t// summary:\n\t\t\t//\t\tsee dojo.lastIndexOf(). The primary difference is that the\n\t\t\t//\t\tacted-on array is implicitly this NodeList\n\t\t\t// description:\n\t\t\t//\t\tFor more details on the behavior of lastIndexOf, see\n\t\t\t//\t\tMozilla's [lastIndexOf\n\t\t\t//\t\tdocs](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf)\n\t\t\t// value: Object\n\t\t\t//\t\tThe value to search for.\n\t\t\t// fromIndex: Integer?\n\t\t\t//\t\tThe location to start searching from. Optional. Defaults to 0.\n\t\t\t// returns:\n\t\t\t//\t\tPositive Integer or 0 for a match, -1 of not found.\n\t\t\treturn d.lastIndexOf(this, value, fromIndex); // Integer\n\t\t},\n\n\t\tevery: function(callback, thisObject){\n\t\t\t// summary:\n\t\t\t//\t\tsee `dojo.every()` and the [Array.every\n\t\t\t//\t\tdocs](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every).\n\t\t\t//\t\tTakes the same structure of arguments and returns as\n\t\t\t//\t\tdojo.every() with the caveat that the passed array is\n\t\t\t//\t\timplicitly this NodeList\n\t\t\t// callback: Function\n\t\t\t//\t\tthe callback\n\t\t\t// thisObject: Object?\n\t\t\t//\t\tthe context\n\t\t\treturn d.every(this, callback, thisObject); // Boolean\n\t\t},\n\n\t\tsome: function(callback, thisObject){\n\t\t\t// summary:\n\t\t\t//\t\tTakes the same structure of arguments and returns as\n\t\t\t//\t\t`dojo.some()` with the caveat that the passed array is\n\t\t\t//\t\timplicitly this NodeList.  See `dojo.some()` and Mozilla's\n\t\t\t//\t\t[Array.some\n\t\t\t//\t\tdocumentation](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some).\n\t\t\t// callback: Function\n\t\t\t//\t\tthe callback\n\t\t\t// thisObject: Object?\n\t\t\t//\t\tthe context\n\t\t\treturn d.some(this, callback, thisObject); // Boolean\n\t\t},\n\t\t=====*/\n\n\t\tconcat: function(item){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a new NodeList comprised of items in this NodeList\n\t\t\t//\t\tas well as items passed in as parameters\n\t\t\t// description:\n\t\t\t//\t\tThis method behaves exactly like the Array.concat method\n\t\t\t//\t\twith the caveat that it returns a `NodeList` and not a\n\t\t\t//\t\traw Array. For more details, see the [Array.concat\n\t\t\t//\t\tdocs](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/concat)\n\t\t\t// item: Object?\n\t\t\t//\t\tAny number of optional parameters may be passed in to be\n\t\t\t//\t\tspliced into the NodeList\n\n\t\t\t//return this._wrap(apc.apply(this, arguments));\n\t\t\t// the line above won't work for the native NodeList, or for Dojo NodeLists either :-(\n\n\t\t\t// implementation notes:\n\t\t\t// Array.concat() doesn't recognize native NodeLists or Dojo NodeLists\n\t\t\t// as arrays, and so does not inline them into a unioned array, but\n\t\t\t// appends them as single entities. Both the original NodeList and the\n\t\t\t// items passed in as parameters must be converted to raw Arrays\n\t\t\t// and then the concatenation result may be re-_wrap()ed as a Dojo NodeList.\n\n\t\t\tvar t = aps.call(this, 0),\n\t\t\t\tm = array.map(arguments, function(a){\n\t\t\t\t\treturn aps.call(a, 0);\n\t\t\t\t});\n\t\t\treturn this._wrap(apc.apply(t, m), this);\t// dojo/NodeList\n\t\t},\n\n\t\tmap: function(/*Function*/ func, /*Function?*/ obj){\n\t\t\t// summary:\n\t\t\t//\t\tsee dojo.map(). The primary difference is that the acted-on\n\t\t\t//\t\tarray is implicitly this NodeList and the return is a\n\t\t\t//\t\tNodeList (a subclass of Array)\n\t\t\treturn this._wrap(array.map(this, func, obj), this); // dojo/NodeList\n\t\t},\n\n\t\tforEach: function(callback, thisObj){\n\t\t\t// summary:\n\t\t\t//\t\tsee `dojo.forEach()`. The primary difference is that the acted-on\n\t\t\t//\t\tarray is implicitly this NodeList. If you want the option to break out\n\t\t\t//\t\tof the forEach loop, use every() or some() instead.\n\t\t\tforEach(this, callback, thisObj);\n\t\t\t// non-standard return to allow easier chaining\n\t\t\treturn this; // dojo/NodeList\n\t\t},\n\t\tfilter: function(/*String|Function*/ filter){\n\t\t\t// summary:\n\t\t\t//\t\t\"masks\" the built-in javascript filter() method (supported\n\t\t\t//\t\tin Dojo via `dojo.filter`) to support passing a simple\n\t\t\t//\t\tstring filter in addition to supporting filtering function\n\t\t\t//\t\tobjects.\n\t\t\t// filter:\n\t\t\t//\t\tIf a string, a CSS rule like \".thinger\" or \"div > span\".\n\t\t\t// example:\n\t\t\t//\t\t\"regular\" JS filter syntax as exposed in dojo.filter:\n\t\t\t//\t\t|\tdojo.query(\"*\").filter(function(item){\n\t\t\t//\t\t|\t\t// highlight every paragraph\n\t\t\t//\t\t|\t\treturn (item.nodeName == \"p\");\n\t\t\t//\t\t|\t}).style(\"backgroundColor\", \"yellow\");\n\t\t\t// example:\n\t\t\t//\t\tthe same filtering using a CSS selector\n\t\t\t//\t\t|\tdojo.query(\"*\").filter(\"p\").styles(\"backgroundColor\", \"yellow\");\n\n\t\t\tvar a = arguments, items = this, start = 0;\n\t\t\tif(typeof filter == \"string\"){ // inline'd type check\n\t\t\t\titems = query._filterResult(this, a[0]);\n\t\t\t\tif(a.length == 1){\n\t\t\t\t\t// if we only got a string query, pass back the filtered results\n\t\t\t\t\treturn items._stash(this); // dojo/NodeList\n\t\t\t\t}\n\t\t\t\t// if we got a callback, run it over the filtered items\n\t\t\t\tstart = 1;\n\t\t\t}\n\t\t\treturn this._wrap(array.filter(items, a[start], a[start + 1]), this);\t// dojo/NodeList\n\t\t},\n\t\tinstantiate: function(/*String|Object*/ declaredClass, /*Object?*/ properties){\n\t\t\t// summary:\n\t\t\t//\t\tCreate a new instance of a specified class, using the\n\t\t\t//\t\tspecified properties and each node in the NodeList as a\n\t\t\t//\t\tsrcNodeRef.\n\t\t\t// example:\n\t\t\t//\t\tGrabs all buttons in the page and converts them to dijit/form/Button's.\n\t\t\t//\t|\tvar buttons = query(\"button\").instantiate(Button, {showLabel: true});\n\t\t\tvar c = lang.isFunction(declaredClass) ? declaredClass : lang.getObject(declaredClass);\n\t\t\tproperties = properties || {};\n\t\t\treturn this.forEach(function(node){\n\t\t\t\tnew c(properties, node);\n\t\t\t});\t// dojo/NodeList\n\t\t},\n\t\tat: function(/*===== index =====*/){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a new NodeList comprised of items in this NodeList\n\t\t\t//\t\tat the given index or indices.\n\t\t\t//\n\t\t\t// index: Integer...\n\t\t\t//\t\tOne or more 0-based indices of items in the current\n\t\t\t//\t\tNodeList. A negative index will start at the end of the\n\t\t\t//\t\tlist and go backwards.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\tShorten the list to the first, second, and third elements\n\t\t\t//\t|\tquery(\"a\").at(0, 1, 2).forEach(fn);\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\tRetrieve the first and last elements of a unordered list:\n\t\t\t//\t|\tquery(\"ul > li\").at(0, -1).forEach(cb);\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\tDo something for the first element only, but end() out back to\n\t\t\t//\tthe original list and continue chaining:\n\t\t\t//\t|\tquery(\"a\").at(0).onclick(fn).end().forEach(function(n){\n\t\t\t//\t|\t\tconsole.log(n); // all anchors on the page.\n\t\t\t//\t|\t})\n\n\t\t\tvar t = new this._NodeListCtor(0);\n\t\t\tforEach(arguments, function(i){\n\t\t\t\tif(i < 0){ i = this.length + i; }\n\t\t\t\tif(this[i]){ t.push(this[i]); }\n\t\t\t}, this);\n\t\t\treturn t._stash(this); // dojo/NodeList\n\t\t}\n\t});\n\n\tfunction queryForEngine(engine, NodeList){\n\t\tvar query = function(/*String*/ query, /*String|DOMNode?*/ root){\n\t\t\t// summary:\n\t\t\t//\t\tReturns nodes which match the given CSS selector, searching the\n\t\t\t//\t\tentire document by default but optionally taking a node to scope\n\t\t\t//\t\tthe search by. Returns an instance of NodeList.\n\t\t\tif(typeof root == \"string\"){\n\t\t\t\troot = dom.byId(root);\n\t\t\t\tif(!root){\n\t\t\t\t\treturn new NodeList([]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar results = typeof query == \"string\" ? engine(query, root) : query ? query.orphan ? query : [query] : [];\n\t\t\tif(results.orphan){\n\t\t\t\t// already wrapped\n\t\t\t\treturn results;\n\t\t\t}\n\t\t\treturn new NodeList(results);\n\t\t};\n\t\tquery.matches = engine.match || function(node, selector, root){\n\t\t\t// summary:\n\t\t\t//\t\tTest to see if a node matches a selector\n\t\t\treturn query.filter([node], selector, root).length > 0;\n\t\t};\n\t\t// the engine provides a filtering function, use it to for matching\n\t\tquery.filter = engine.filter || function(nodes, selector, root){\n\t\t\t// summary:\n\t\t\t//\t\tFilters an array of nodes. Note that this does not guarantee to return a NodeList, just an array.\n\t\t\treturn query(selector, root).filter(function(node){\n\t\t\t\treturn array.indexOf(nodes, node) > -1;\n\t\t\t});\n\t\t};\n\t\tif(typeof engine != \"function\"){\n\t\t\tvar search = engine.search;\n\t\t\tengine = function(selector, root){\n\t\t\t\t// Slick does it backwards (or everyone else does it backwards, probably the latter)\n\t\t\t\treturn search(root || document, selector);\n\t\t\t};\n\t\t}\n\t\treturn query;\n\t}\n\tvar query = queryForEngine(defaultEngine, NodeList);\n\t/*=====\n\tquery = function(selector, context){\n\t\t// summary:\n\t\t//\t\tThis modules provides DOM querying functionality. The module export is a function\n\t\t//\t\tthat can be used to query for DOM nodes by CSS selector and returns a NodeList\n\t\t//\t\trepresenting the matching nodes.\n\t\t// selector: String\n\t\t//\t\tA CSS selector to search for.\n\t\t// context: String|DomNode?\n\t\t//\t\tAn optional context to limit the searching scope. Only nodes under `context` will be\n\t\t//\t\tscanned.\n\t\t// example:\n\t\t//\t\tadd an onclick handler to every submit button in the document\n\t\t//\t\twhich causes the form to be sent via Ajax instead:\n\t\t//\t|\trequire([\"dojo/query\"], function(query){\n\t\t//\t|\t\tquery(\"input[type='submit']\").on(\"click\", function(e){\n\t\t//\t|\t\t\tdojo.stopEvent(e); // prevent sending the form\n\t\t//\t|\t\t\tvar btn = e.target;\n\t\t//\t|\t\t\tdojo.xhrPost({\n\t\t//\t|\t\t\t\tform: btn.form,\n\t\t//\t|\t\t\t\tload: function(data){\n\t\t//\t|\t\t\t\t\t// replace the form with the response\n\t\t//\t|\t\t\t\t\tvar div = dojo.doc.createElement(\"div\");\n\t\t//\t|\t\t\t\t\tdojo.place(div, btn.form, \"after\");\n\t\t//\t|\t\t\t\t\tdiv.innerHTML = data;\n\t\t//\t|\t\t\t\t\tdojo.style(btn.form, \"display\", \"none\");\n\t\t//\t|\t\t\t\t}\n\t\t//\t|\t\t\t});\n\t\t//\t|\t\t});\n\t\t// |\t});\n\t\t//\n\t\t// description:\n\t\t//\t\tdojo/query is responsible for loading the appropriate query engine and wrapping\n\t\t//\t\tits results with a `NodeList`. You can use dojo/query with a specific selector engine\n\t\t//\t\tby using it as a plugin. For example, if you installed the sizzle package, you could\n\t\t//\t\tuse it as the selector engine with:\n\t\t//\t\t|\trequire([\"dojo/query!sizzle\"], function(query){\n\t\t//\t\t|\t\tquery(\"div\")...\n\t\t//\n\t\t//\t\tThe id after the ! can be a module id of the selector engine or one of the following values:\n\t\t//\n\t\t//\t\t- acme: This is the default engine used by Dojo base, and will ensure that the full\n\t\t//\t\tAcme engine is always loaded.\n\t\t//\n\t\t//\t\t- css2: If the browser has a native selector engine, this will be used, otherwise a\n\t\t//\t\tvery minimal lightweight selector engine will be loaded that can do simple CSS2 selectors\n\t\t//\t\t(by #id, .class, tag, and [name=value] attributes, with standard child or descendant (>)\n\t\t//\t\toperators) and nothing more.\n\t\t//\n\t\t//\t\t- css2.1: If the browser has a native selector engine, this will be used, otherwise the\n\t\t//\t\tfull Acme engine will be loaded.\n\t\t//\n\t\t//\t\t- css3: If the browser has a native selector engine with support for CSS3 pseudo\n\t\t//\t\tselectors (most modern browsers except IE8), this will be used, otherwise the\n\t\t//\t\tfull Acme engine will be loaded.\n\t\t//\n\t\t//\t\t- Or the module id of a selector engine can be used to explicitly choose the selector engine\n\t\t//\n\t\t//\t\tFor example, if you are using CSS3 pseudo selectors in module, you can specify that\n\t\t//\t\tyou will need support them with:\n\t\t//\t\t|\trequire([\"dojo/query!css3\"], function(query){\n\t\t//\t\t|\t\tquery('#t > h3:nth-child(odd)')...\n\t\t//\n\t\t//\t\tYou can also choose the selector engine/load configuration by setting the query-selector:\n\t\t//\t\tFor example:\n\t\t//\t\t|\t<script data-dojo-config=\"query-selector:'css3'\" src=\"dojo.js\"></script>\n\t\t//\n\t\treturn new NodeList(); // dojo/NodeList\n\t };\n\t =====*/\n\n\t// the query that is returned from this module is slightly different than dojo.query,\n\t// because dojo.query has to maintain backwards compatibility with returning a\n\t// true array which has performance problems. The query returned from the module\n\t// does not use true arrays, but rather inherits from Array, making it much faster to\n\t// instantiate.\n\tdojo.query = queryForEngine(defaultEngine, function(array){\n\t\t// call it without the new operator to invoke the back-compat behavior that returns a true array\n\t\treturn NodeList(array);\t// dojo/NodeList\n\t});\n\n\tquery.load = function(id, parentRequire, loaded){\n\t\t// summary:\n\t\t//\t\tcan be used as AMD plugin to conditionally load new query engine\n\t\t// example:\n\t\t//\t|\trequire([\"dojo/query!custom\"], function(qsa){\n\t\t//\t|\t\t// loaded selector/custom.js as engine\n\t\t//\t|\t\tqsa(\"#foobar\").forEach(...);\n\t\t//\t|\t});\n\t\tloader.load(id, parentRequire, function(engine){\n\t\t\tloaded(queryForEngine(engine, NodeList));\n\t\t});\n\t};\n\n\tdojo._filterQueryResult = query._filterResult = function(nodes, selector, root){\n\t\treturn new NodeList(query.filter(nodes, selector, root));\n\t};\n\tdojo.NodeList = query.NodeList = NodeList;\n\treturn query;\n});\n\n},\n'dojo/has':function(){\ndefine([\"require\", \"module\"], function(require, module){\n\t// module:\n\t//\t\tdojo/has\n\t// summary:\n\t//\t\tDefines the has.js API and several feature tests used by dojo.\n\t// description:\n\t//\t\tThis module defines the has API as described by the project has.js with the following additional features:\n\t//\n\t//\t\t- the has test cache is exposed at has.cache.\n\t//\t\t- the method has.add includes a forth parameter that controls whether or not existing tests are replaced\n\t//\t\t- the loader's has cache may be optionally copied into this module's has cahce.\n\t//\n\t//\t\tThis module adopted from https://github.com/phiggins42/has.js; thanks has.js team!\n\n\t// try to pull the has implementation from the loader; both the dojo loader and bdLoad provide one\n\t// if using a foreign loader, then the has cache may be initialized via the config object for this module\n\t// WARNING: if a foreign loader defines require.has to be something other than the has.js API, then this implementation fail\n\tvar has = require.has || function(){};\n\tif(! 1 ){\n\t\tvar\n\t\t\tisBrowser =\n\t\t\t\t// the most fundamental decision: are we in the browser?\n\t\t\t\ttypeof window != \"undefined\" &&\n\t\t\t\ttypeof location != \"undefined\" &&\n\t\t\t\ttypeof document != \"undefined\" &&\n\t\t\t\twindow.location == location && window.document == document,\n\n\t\t\t// has API variables\n\t\t\tglobal = this,\n\t\t\tdoc = isBrowser && document,\n\t\t\telement = doc && doc.createElement(\"DiV\"),\n\t\t\tcache = (module.config && module.config()) || {};\n\n\t\thas = function(name){\n\t\t\t// summary:\n\t\t\t//\t\tReturn the current value of the named feature.\n\t\t\t//\n\t\t\t// name: String|Integer\n\t\t\t//\t\tThe name (if a string) or identifier (if an integer) of the feature to test.\n\t\t\t//\n\t\t\t// description:\n\t\t\t//\t\tReturns the value of the feature named by name. The feature must have been\n\t\t\t//\t\tpreviously added to the cache by has.add.\n\n\t\t\treturn typeof cache[name] == \"function\" ? (cache[name] = cache[name](global, doc, element)) : cache[name]; // Boolean\n\t\t};\n\n\t\thas.cache = cache;\n\n\t\thas.add = function(name, test, now, force){\n\t\t\t// summary:\n\t\t\t//\t \tRegister a new feature test for some named feature.\n\t\t\t// name: String|Integer\n\t\t\t//\t \tThe name (if a string) or identifier (if an integer) of the feature to test.\n\t\t\t// test: Function\n\t\t\t//\t\t A test function to register. If a function, queued for testing until actually\n\t\t\t//\t\t needed. The test function should return a boolean indicating\n\t\t\t//\t \tthe presence of a feature or bug.\n\t\t\t// now: Boolean?\n\t\t\t//\t\t Optional. Omit if `test` is not a function. Provides a way to immediately\n\t\t\t//\t\t run the test and cache the result.\n\t\t\t// force: Boolean?\n\t\t\t//\t \tOptional. If the test already exists and force is truthy, then the existing\n\t\t\t//\t \ttest will be replaced; otherwise, add does not replace an existing test (that\n\t\t\t//\t \tis, by default, the first test advice wins).\n\t\t\t// example:\n\t\t\t//\t\tA redundant test, testFn with immediate execution:\n\t\t\t//\t|\thas.add(\"javascript\", function(){ return true; }, true);\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tAgain with the redundantness. You can do this in your tests, but we should\n\t\t\t//\t\tnot be doing this in any internal has.js tests\n\t\t\t//\t|\thas.add(\"javascript\", true);\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tThree things are passed to the testFunction. `global`, `document`, and a generic element\n\t\t\t//\t\tfrom which to work your test should the need arise.\n\t\t\t//\t|\thas.add(\"bug-byid\", function(g, d, el){\n\t\t\t//\t|\t\t// g\t== global, typically window, yadda yadda\n\t\t\t//\t|\t\t// d\t== document object\n\t\t\t//\t|\t\t// el == the generic element. a `has` element.\n\t\t\t//\t|\t\treturn false; // fake test, byid-when-form-has-name-matching-an-id is slightly longer\n\t\t\t//\t|\t});\n\n\t\t\t(typeof cache[name]==\"undefined\" || force) && (cache[name]= test);\n\t\t\treturn now && has(name);\n\t\t};\n\n\t\t// since we're operating under a loader that doesn't provide a has API, we must explicitly initialize\n\t\t// has as it would have otherwise been initialized by the dojo loader; use has.add to the builder\n\t\t// can optimize these away iff desired\n\t\t 1 || has.add(\"host-browser\", isBrowser);\n\t\t 1 || has.add(\"dom\", isBrowser);\n\t\t 1 || has.add(\"dojo-dom-ready-api\", 1);\n\t\t 1 || has.add(\"dojo-sniff\", 1);\n\t}\n\n\tif( 1 ){\n\t\t// Common application level tests\n\t\thas.add(\"dom-addeventlistener\", !!document.addEventListener);\n\t\thas.add(\"touch\", \"ontouchstart\" in document);\n\t\t// I don't know if any of these tests are really correct, just a rough guess\n\t\thas.add(\"device-width\", screen.availWidth || innerWidth);\n\n\t\t// Tests for DOMNode.attributes[] behavior:\n\t\t//\t - dom-attributes-explicit - attributes[] only lists explicitly user specified attributes\n\t\t//\t - dom-attributes-specified-flag (IE8) - need to check attr.specified flag to skip attributes user didn't specify\n\t\t//\t - Otherwise, in IE6-7. attributes[] will list hundreds of values, so need to do outerHTML to get attrs instead.\n\t\tvar form = document.createElement(\"form\");\n\t\thas.add(\"dom-attributes-explicit\", form.attributes.length == 0); // W3C\n\t\thas.add(\"dom-attributes-specified-flag\", form.attributes.length > 0 && form.attributes.length < 40);\t// IE8\n\t}\n\n\thas.clearElement = function(element){\n\t\t// summary:\n\t\t//\t Deletes the contents of the element passed to test functions.\n\t\telement.innerHTML= \"\";\n\t\treturn element;\n\t};\n\n\thas.normalize = function(id, toAbsMid){\n\t\t// summary:\n\t\t//\t Resolves id into a module id based on possibly-nested tenary expression that branches on has feature test value(s).\n\t\t//\n\t\t// toAbsMid: Function\n\t\t//\t Resolves a relative module id into an absolute module id\n\t\tvar\n\t\t\ttokens = id.match(/[\\?:]|[^:\\?]*/g), i = 0,\n\t\t\tget = function(skip){\n\t\t\t\tvar term = tokens[i++];\n\t\t\t\tif(term == \":\"){\n\t\t\t\t\t// empty string module name, resolves to 0\n\t\t\t\t\treturn 0;\n\t\t\t\t}else{\n\t\t\t\t\t// postfixed with a ? means it is a feature to branch on, the term is the name of the feature\n\t\t\t\t\tif(tokens[i++] == \"?\"){\n\t\t\t\t\t\tif(!skip && has(term)){\n\t\t\t\t\t\t\t// matched the feature, get the first value from the options\n\t\t\t\t\t\t\treturn get();\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t// did not match, get the second value, passing over the first\n\t\t\t\t\t\t\tget(true);\n\t\t\t\t\t\t\treturn get(skip);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// a module\n\t\t\t\t\treturn term || 0;\n\t\t\t\t}\n\t\t\t};\n\t\tid = get();\n\t\treturn id && toAbsMid(id);\n\t};\n\n\thas.load = function(id, parentRequire, loaded){\n\t\t// summary:\n\t\t//\t\tConditional loading of AMD modules based on a has feature test value.\n\t\t// id: String\n\t\t//\t\tGives the resolved module id to load.\n\t\t// parentRequire: Function\n\t\t//\t\tThe loader require function with respect to the module that contained the plugin resource in it's\n\t\t//\t\tdependency list.\n\t\t// loaded: Function\n\t\t//\t Callback to loader that consumes result of plugin demand.\n\n\t\tif(id){\n\t\t\tparentRequire([id], loaded);\n\t\t}else{\n\t\t\tloaded();\n\t\t}\n\t};\n\n\treturn has;\n});\n\n},\n'dojo/_base/loader':function(){\ndefine([\"./kernel\", \"../has\", \"require\", \"module\", \"./json\", \"./lang\", \"./array\"], function(dojo, has, require, thisModule, json, lang, array) {\n\t// module:\n\t//\t\tdojo/_base/loader\n\n\t//\t\tThis module defines the v1.x synchronous loader API.\n\n\t// signal the loader in sync mode...\n\t//>>pure-amd\n\n\tif (! 1 ){\n\t\tconsole.error(\"cannot load the Dojo v1.x loader with a foreign loader\");\n\t\treturn 0;\n\t}\n\n\t 1 || has.add(\"dojo-fast-sync-require\", 1);\n\n\n\tvar makeErrorToken = function(id){\n\t\t\treturn {src:thisModule.id, id:id};\n\t\t},\n\n\t\tslashName = function(name){\n\t\t\treturn name.replace(/\\./g, \"/\");\n\t\t},\n\n\t\tbuildDetectRe = /\\/\\/>>built/,\n\n\t\tdojoRequireCallbacks = [],\n\t\tdojoRequireModuleStack = [],\n\n\t\tdojoRequirePlugin = function(mid, require, loaded){\n\t\t\tdojoRequireCallbacks.push(loaded);\n\t\t\tarray.forEach(mid.split(\",\"), function(mid){\n\t\t\t\tvar module = getModule(mid, require.module);\n\t\t\t\tdojoRequireModuleStack.push(module);\n\t\t\t\tinjectModule(module);\n\t\t\t});\n\t\t\tcheckDojoRequirePlugin();\n\t\t},\n\n\t\tcheckDojoRequirePlugin = ( 1  ?\n\t\t\t// This version of checkDojoRequirePlugin makes the observation that all dojoRequireCallbacks can be released\n\t\t\t// when all *non-dojo/require!, dojo/loadInit!* modules are either executed, not requested, or arrived. This is\n\t\t\t// the case since there are no more modules the loader is waiting for, therefore, dojo/require! must have\n\t\t\t// everything it needs on board.\n\t\t\t//\n\t\t\t// The potential weakness of this algorithm is that dojo/require will not execute callbacks until *all* dependency\n\t\t\t// trees are ready. It is possible that some trees may be ready earlier than others, and this extra wait is non-optimal.\n\t\t\t// Still, for big projects, this seems better than the original algorithm below that proved slow in some cases.\n\t\t\t// Note, however, the original algorithm had the potential to execute partial trees,  but that potential was never enabled.\n\t\t\t// There are also other optimization available with the original algorithm that have not been explored.\n\t\t\tfunction(){\n\t\t\t\tvar module, mid;\n\t\t\t\tfor(mid in modules){\n\t\t\t\t\tmodule = modules[mid];\n\t\t\t\t\tif(module.noReqPluginCheck===undefined){\n\t\t\t\t\t\t// tag the module as either a loadInit or require plugin or not for future reference\n\t\t\t\t\t\tmodule.noReqPluginCheck = /loadInit\\!/.test(mid) || /require\\!/.test(mid) ? 1 : 0;\n\t\t\t\t\t}\n\t\t\t\t\tif(!module.executed && !module.noReqPluginCheck && module.injected==requested){\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tguardCheckComplete(function(){\n\t\t\t\t\tvar oldCallbacks = dojoRequireCallbacks;\n\t\t\t\t\tdojoRequireCallbacks = [];\n\t\t\t\t\tarray.forEach(oldCallbacks, function(cb){cb(1);});\n\t\t\t\t});\n\t\t} : (function(){\n\t\t\t// Note: this is the original checkDojoRequirePlugin that is much slower than the algorithm above. However, we know it\n\t\t\t// works, so we leave it here in case the algorithm above fails in some corner case.\n\t\t\t//\n\t\t\t// checkDojoRequirePlugin inspects all of the modules demanded by a dojo/require!<module-list> dependency\n\t\t\t// to see if they have arrived. The loader does not release *any* of these modules to be instantiated\n\t\t\t// until *all* of these modules are on board, thereby preventing the evaluation of a module with dojo.require's\n\t\t\t// that reference modules that are not available.\n\t\t\t//\n\t\t\t// The algorithm works by traversing the dependency graphs (remember, there can be cycles so they are not trees)\n\t\t\t// of each module in the dojoRequireModuleStack array (which contains the list of modules demanded by dojo/require!).\n\t\t\t// The moment a single module is discovered that is missing, the algorithm gives up and indicates that not all\n\t\t\t// modules are on board. dojo/loadInit! and dojo/require! are ignored because there dependencies are inserted\n\t\t\t// directly in dojoRequireModuleStack. For example, if \"your/module\" module depends on \"dojo/require!my/module\", then\n\t\t\t// *both* \"dojo/require!my/module\" and \"my/module\" will be in dojoRequireModuleStack. Obviously, if \"my/module\"\n\t\t\t// is on board, then \"dojo/require!my/module\" is also satisfied, so the algorithm doesn't check for \"dojo/require!my/module\".\n\t\t\t//\n\t\t\t// Note: inserting a dojo/require!<some-module-list> dependency in the dojoRequireModuleStack achieves nothing\n\t\t\t// with the current algorithm; however, having such modules present makes it possible to optimize the algorithm\n\t\t\t//\n\t\t\t// Note: prior versions of this algorithm had an optimization that signaled loaded on dojo/require! dependencies\n\t\t\t// individually (rather than waiting for them all to be resolved). The implementation proved problematic with cycles\n\t\t\t// and plugins. However, it is possible to reattach that strategy in the future.\n\n\t\t\t// a set from module-id to {undefined | 1 | 0}, where...\n\t\t\t//\t undefined => the module has not been inspected\n\t\t\t//\t 0 => the module or at least one of its dependencies has not arrived\n\t\t\t//\t 1 => the module is a loadInit! or require! plugin resource, or is currently being traversed (therefore, assume\n\t\t\t//\t\t  OK until proven otherwise), or has been completely traversed and all dependencies have arrived\n\n\t\t\tvar touched,\n\t\t\ttraverse = function(m){\n\t\t\t\ttouched[m.mid] = 1;\n\t\t\t\tfor(var t, module, deps = m.deps || [], i= 0; i<deps.length; i++){\n\t\t\t\t\tmodule = deps[i];\n\t\t\t\t\tif(!(t = touched[module.mid])){\n\t\t\t\t\t\tif(t===0 || !traverse(module)){\n\t\t\t\t\t\t\ttouched[m.mid] = 0;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t};\n\n\t\t\treturn function(){\n\t\t\t\t// initialize the touched hash with easy-to-compute values that help short circuit recursive algorithm;\n\t\t\t\t// recall loadInit/require plugin modules are dependencies of modules in dojoRequireModuleStack...\n\t\t\t\t// which would cause a circular dependency chain that would never be resolved if checked here\n\t\t\t\t// notice all dependencies of any particular loadInit/require plugin module will already\n\t\t\t\t// be checked since those are pushed into dojoRequireModuleStack explicitly by the\n\t\t\t\t// plugin...so if a particular loadInitPlugin module's dependencies are not really\n\t\t\t\t// on board, that *will* be detected elsewhere in the traversal.\n\t\t\t\tvar module, mid;\n\t\t\t\ttouched = {};\n\t\t\t\tfor(mid in modules){\n\t\t\t\t\tmodule = modules[mid];\n\t\t\t\t\tif(module.executed || module.noReqPluginCheck){\n\t\t\t\t\t\ttouched[mid] = 1;\n\t\t\t\t\t}else{\n\t\t\t\t\t\tif(module.noReqPluginCheck!==0){\n\t\t\t\t\t\t\t// tag the module as either a loadInit or require plugin or not for future reference\n\t\t\t\t\t\t\tmodule.noReqPluginCheck = /loadInit\\!/.test(mid) || /require\\!/.test(mid) ? 1 : 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(module.noReqPluginCheck){\n\t\t\t\t\t\t\ttouched[mid] = 1;\n\t\t\t\t\t\t}else if(module.injected!==arrived){\n\t\t\t\t\t\t\t// not executed, has not arrived, and is not a loadInit or require plugin resource\n\t\t\t\t\t\t\ttouched[mid] = 0;\n\t\t\t\t\t\t}// else, leave undefined and we'll traverse the dependencies\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(var t, i = 0, end = dojoRequireModuleStack.length; i<end; i++){\n\t\t\t\t\tmodule = dojoRequireModuleStack[i];\n\t\t\t\t\tif(!(t = touched[module.mid])){\n\t\t\t\t\t\tif(t===0 || !traverse(module)){\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tguardCheckComplete(function(){\n\t\t\t\t\tvar oldCallbacks = dojoRequireCallbacks;\n\t\t\t\t\tdojoRequireCallbacks = [];\n\t\t\t\t\tarray.forEach(oldCallbacks, function(cb){cb(1);});\n\t\t\t\t});\n\t\t\t};\n\t\t})()),\n\n\t\tdojoLoadInitPlugin = function(mid, require, loaded){\n\t\t\t// mid names a module that defines a \"dojo load init\" bundle, an object with two properties:\n\t\t\t//\n\t\t\t//\t * names: a vector of module ids that give top-level names to define in the lexical scope of def\n\t\t\t//\t * def: a function that contains some some legacy loader API applications\n\t\t\t//\n\t\t\t// The point of def is to possibly cause some modules to be loaded (but not executed) by dojo/require! where the module\n\t\t\t// ids are possibly-determined at runtime. For example, here is dojox.gfx from v1.6 expressed as an AMD module using the dojo/loadInit\n\t\t\t// and dojo/require plugins.\n\t\t\t//\n\t\t\t// // dojox/gfx:\n\t\t\t//\n\t\t\t//\t define(\"*loadInit_12, {\n\t\t\t//\t   names:[\"dojo\", \"dijit\", \"dojox\"],\n\t\t\t//\t   def: function(){\n\t\t\t//\t\t dojo.loadInit(function(){\n\t\t\t//\t\t   var gfx = lang.getObject(\"dojox.gfx\", true);\n\t\t\t//\n\t\t\t//\t\t   //\n\t\t\t//\t\t   // code required to set gfx properties ommitted...\n\t\t\t//\t\t   //\n\t\t\t//\n\t\t\t//\t\t   // now use the calculations to include the runtime-dependent module\n\t\t\t//\t\t   dojo.require(\"dojox.gfx.\" + gfx.renderer);\n\t\t\t//\t\t });\n\t\t\t//\t   }\n\t\t\t//\t });\n\t\t\t//\n\t\t\t//\t define([\"dojo\", \"dojo/loadInit!\" + id].concat(\"dojo/require!dojox/gfx/matric,dojox/gfx/_base\"), function(dojo){\n\t\t\t//\t   // when this AMD factory function is executed, the following modules are guaranteed downloaded but not executed:\n\t\t\t//\t   //\t\"dojox.gfx.\" + gfx.renderer\n\t\t\t//\t   //\tdojox.gfx.matrix\n\t\t\t//\t   //\tdojox.gfx._base\n\t\t\t//\t   dojo.provide(\"dojo.gfx\");\n\t\t\t//\t   dojo.require(\"dojox.gfx.matrix\");\n\t\t\t//\t   dojo.require(\"dojox.gfx._base\");\n\t\t\t//\t   dojo.require(\"dojox.gfx.\" + gfx.renderer);\n\t\t\t//\t   return lang.getObject(\"dojo.gfx\");\n\t\t\t//\t });\n\t\t\t//\t})();\n\t\t\t//\n\t\t\t// The idea is to run the legacy loader API with global variables shadowed, which allows these variables to\n\t\t\t// be relocated. For example, dojox and dojo could be relocated to different names by giving a map and the code above will\n\t\t\t// execute properly (because the plugin below resolves the load init bundle.names module with respect to the module that demanded\n\t\t\t// the plugin resource).\n\t\t\t//\n\t\t\t// Note that the relocation is specified in the runtime configuration; relocated names need not be set at build-time.\n\t\t\t//\n\t\t\t// Warning: this is not the best way to express dojox.gfx as and AMD module. In fact, the module has been properly converted in\n\t\t\t// v1.7. However, this technique allows the builder to convert legacy modules into AMD modules and guarantee the codepath is the\n\t\t\t// same in the converted AMD module.\n\t\t\trequire([mid], function(bundle){\n\t\t\t\t// notice how names is resolved with respect to the module that demanded the plugin resource\n\t\t\t\trequire(bundle.names, function(){\n\t\t\t\t\t// bring the bundle names into scope\n\t\t\t\t\tfor(var scopeText = \"\", args= [], i = 0; i<arguments.length; i++){\n\t\t\t\t\t\tscopeText+= \"var \" + bundle.names[i] + \"= arguments[\" + i + \"]; \";\n\t\t\t\t\t\targs.push(arguments[i]);\n\t\t\t\t\t}\n\t\t\t\t\teval(scopeText);\n\n\t\t\t\t\tvar callingModule = require.module,\n\t\t\t\t\t\t// the list of modules that need to be downloaded but not executed before the callingModule can be executed\n\t\t\t\t\t\trequireList = [],\n\n\t\t\t\t\t\t// the list of i18n bundles that are xdomain; undefined if none\n\t\t\t\t\t\ti18nDeps,\n\n\t\t\t\t\t\tsyncLoaderApi = {\n\t\t\t\t\t\t\tprovide:function(moduleName){\n\t\t\t\t\t\t\t\t// mark modules that arrive consequent to multiple provides in this module as arrived since they can't be injected\n\t\t\t\t\t\t\t\tmoduleName = slashName(moduleName);\n\t\t\t\t\t\t\t\tvar providedModule = getModule(moduleName, callingModule);\n\t\t\t\t\t\t\t\tif(providedModule!==callingModule){\n\t\t\t\t\t\t\t\t\tsetArrived(providedModule);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trequire:function(moduleName, omitModuleCheck){\n\t\t\t\t\t\t\t\tmoduleName = slashName(moduleName);\n\t\t\t\t\t\t\t\tomitModuleCheck && (getModule(moduleName, callingModule).result = nonmodule);\n\t\t\t\t\t\t\t\trequireList.push(moduleName);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\trequireLocalization:function(moduleName, bundleName, locale){\n\t\t\t\t\t\t\t\t// since we're going to need dojo/i8n, add it to i18nDeps if not already there\n\t\t\t\t\t\t\t\tif(!i18nDeps){\n\t\t\t\t\t\t\t\t\t// don't have to map since that will occur when the dependency is resolved\n\t\t\t\t\t\t\t\t\ti18nDeps = [\"dojo/i18n\"];\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// figure out if the bundle is xdomain; if so, add it to the i18nDepsSet\n\t\t\t\t\t\t\t\tlocale = (locale || dojo.locale).toLowerCase();\n\t\t\t\t\t\t\t\tmoduleName = slashName(moduleName) + \"/nls/\" + (/root/i.test(locale) ? \"\" : locale + \"/\") + slashName(bundleName);\n\t\t\t\t\t\t\t\tif(getModule(moduleName, callingModule).isXd){\n\t\t\t\t\t\t\t\t\t// don't have to map since that will occur when the dependency is resolved\n\t\t\t\t\t\t\t\t\ti18nDeps.push(\"dojo/i18n!\" + moduleName);\n\t\t\t\t\t\t\t\t}// else the bundle will be loaded synchronously when the module is evaluated\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tloadInit:function(f){\n\t\t\t\t\t\t\t\tf();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\thold = {},\n\t\t\t\t\t\tp;\n\n\t\t\t\t\t// hijack the correct dojo and apply bundle.def\n\t\t\t\t\ttry{\n\t\t\t\t\t\tfor(p in syncLoaderApi){\n\t\t\t\t\t\t\thold[p] = dojo[p];\n\t\t\t\t\t\t\tdojo[p] = syncLoaderApi[p];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbundle.def.apply(null, args);\n\t\t\t\t\t}catch(e){\n\t\t\t\t\t\tsignal(\"error\", [makeErrorToken(\"failedDojoLoadInit\"), e]);\n\t\t\t\t\t}finally{\n\t\t\t\t\t\tfor(p in syncLoaderApi){\n\t\t\t\t\t\t\tdojo[p] = hold[p];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif(i18nDeps){\n\t\t\t\t\t\trequireList = requireList.concat(i18nDeps);\n\t\t\t\t\t}\n\n\t\t\t\t\tif(requireList.length){\n\t\t\t\t\t\tdojoRequirePlugin(requireList.join(\",\"), require, loaded);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tloaded();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t},\n\n\t\textractApplication = function(\n\t\t\ttext,\t\t\t  // the text to search\n\t\t\tstartSearch,\t  // the position in text to start looking for the closing paren\n\t\t\tstartApplication  // the position in text where the function application expression starts\n\t\t){\n\t\t\t// find end of the call by finding the matching end paren\n\t\t\t// Warning: as usual, this will fail in the presense of unmatched right parans contained in strings, regexs, or unremoved comments\n\t\t\tvar parenRe = /\\(|\\)/g,\n\t\t\t\tmatchCount = 1,\n\t\t\t\tmatch;\n\t\t\tparenRe.lastIndex = startSearch;\n\t\t\twhile((match = parenRe.exec(text))){\n\t\t\t\tif(match[0] == \")\"){\n\t\t\t\t\tmatchCount -= 1;\n\t\t\t\t}else{\n\t\t\t\t\tmatchCount += 1;\n\t\t\t\t}\n\t\t\t\tif(matchCount == 0){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(matchCount != 0){\n\t\t\t\tthrow \"unmatched paren around character \" + parenRe.lastIndex + \" in: \" + text;\n\t\t\t}\n\n\t\t\t//Put the master matching string in the results.\n\t\t\treturn [dojo.trim(text.substring(startApplication, parenRe.lastIndex))+\";\\n\", parenRe.lastIndex];\n\t\t},\n\n\t\t// the following regex is taken from 1.6. It is a very poor technique to remove comments and\n\t\t// will fail in some cases; for example, consider the code...\n\t\t//\n\t\t//\t  var message = \"Category-1 */* Category-2\";\n\t\t//\n\t\t// The regex that follows will see a /* comment and trash the code accordingly. In fact, there are all\n\t\t// kinds of cases like this with strings and regexs that will cause this design to fail miserably.\n\t\t//\n\t\t// Alternative regex designs exist that will result in less-likely failures, but will still fail in many cases.\n\t\t// The only solution guaranteed 100% correct is to parse the code and that seems overkill for this\n\t\t// backcompat/unbuilt-xdomain layer. In the end, since it's been this way for a while, we won't change it.\n\t\t// See the opening paragraphs of Chapter 7 or ECME-262 which describes the lexical abiguity further.\n\t\tremoveCommentRe = /(\\/\\*([\\s\\S]*?)\\*\\/|\\/\\/(.*)$)/mg,\n\n\t\tsyncLoaderApiRe = /(^|\\s)dojo\\.(loadInit|require|provide|requireLocalization|requireIf|requireAfterIf|platformRequire)\\s*\\(/mg,\n\n\t\tamdLoaderApiRe = /(^|\\s)(require|define)\\s*\\(/m,\n\n\t\textractLegacyApiApplications = function(text, noCommentText){\n\t\t\t// scan the noCommentText for any legacy loader API applications. Copy such applications into result (this is\n\t\t\t// used by the builder). Move dojo.loadInit applications to loadInitApplications string. Copy all other applications\n\t\t\t// to otherApplications string. If no applications were found, return 0, signalling an AMD module. Otherwise, return\n\t\t\t// loadInitApplications + otherApplications. Fixup text by replacing\n\t\t\t//\n\t\t\t//\t dojo.loadInit(// etc...\n\t\t\t//\n\t\t\t// with\n\t\t\t//\n\t\t\t//\t \\n 0 && dojo.loadInit(// etc...\n\t\t\t//\n\t\t\t// Which results in the dojo.loadInit from *not* being applied. This design goes a long way towards protecting the\n\t\t\t// code from an over-agressive removeCommentRe. However...\n\t\t\t//\n\t\t\t// WARNING: the removeCommentRe will cause an error if a detected comment removes all or part of a legacy-loader application\n\t\t\t// that is not in a comment.\n\n\t\t\tvar match, startSearch, startApplication, application,\n\t\t\t\tloadInitApplications = [],\n\t\t\t\totherApplications = [],\n\t\t\t\tallApplications = [];\n\n\t\t\t// noCommentText may be provided by a build app with comments extracted by a better method than regex (hopefully)\n\t\t\tnoCommentText = noCommentText || text.replace(removeCommentRe, function(match){\n\t\t\t\t// remove iff the detected comment has text that looks like a sync loader API application; this helps by\n\t\t\t\t// removing as little as possible, minimizing the changes the janky regex will kill the module\n\t\t\t\tsyncLoaderApiRe.lastIndex = amdLoaderApiRe.lastIndex = 0;\n\t\t\t\treturn (syncLoaderApiRe.test(match) || amdLoaderApiRe.test(match)) ? \"\" : match;\n\t\t\t});\n\n\t\t\t// find and extract all dojo.loadInit applications\n\t\t\twhile((match = syncLoaderApiRe.exec(noCommentText))){\n\t\t\t\tstartSearch = syncLoaderApiRe.lastIndex;\n\t\t\t\tstartApplication = startSearch\t- match[0].length;\n\t\t\t\tapplication = extractApplication(noCommentText, startSearch, startApplication);\n\t\t\t\tif(match[2]==\"loadInit\"){\n\t\t\t\t\tloadInitApplications.push(application[0]);\n\t\t\t\t}else{\n\t\t\t\t\totherApplications.push(application[0]);\n\t\t\t\t}\n\t\t\t\tsyncLoaderApiRe.lastIndex = application[1];\n\t\t\t}\n\t\t\tallApplications = loadInitApplications.concat(otherApplications);\n\t\t\tif(allApplications.length || !amdLoaderApiRe.test(noCommentText)){\n\t\t\t\t// either there were some legacy loader API applications or there were no AMD API applications\n\t\t\t\treturn [text.replace(/(^|\\s)dojo\\.loadInit\\s*\\(/g, \"\\n0 && dojo.loadInit(\"), allApplications.join(\"\"), allApplications];\n\t\t\t}else{\n\t\t\t\t// legacy loader API *was not* detected and AMD API *was* detected; therefore, assume it's an AMD module\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t},\n\n\t\ttransformToAmd = function(module, text){\n\t\t\t// This is roughly the equivalent of dojo._xdCreateResource in 1.6-; however, it expresses a v1.6- dojo\n\t\t\t// module in terms of AMD define instead of creating the dojo proprietary xdomain module expression.\n\t\t\t// The module could have originated from several sources:\n\t\t\t//\n\t\t\t//\t * amd require() a module, e.g., require([\"my/module\"])\n\t\t\t//\t * amd require() a nonmodule, e.g., require([\"my/resource.js\"')\n\t\t\t//\t * amd define() deps vector (always a module)\n\t\t\t//\t * dojo.require() a module, e.g. dojo.require(\"my.module\")\n\t\t\t//\t * dojo.require() a nonmodule, e.g., dojo.require(\"my.module\", true)\n\t\t\t//\t * dojo.requireIf/requireAfterIf/platformRequire a module\n\t\t\t//\n\t\t\t// The module is scanned for legacy loader API applications; if none are found, then assume the module is an\n\t\t\t// AMD module and return 0. Otherwise, a synthetic dojo/loadInit plugin resource is created and the module text\n\t\t\t// is rewritten as an AMD module with the single dependency of this synthetic resource. When the dojo/loadInit\n\t\t\t// plugin loaded the synthetic resource, it will cause all dojo.loadInit's to be executed, find all dojo.require's\n\t\t\t// (either directly consequent to dojo.require or indirectly consequent to dojo.require[After]If or\n\t\t\t// dojo.platformRequire, and finally cause loading of all dojo.required modules with the dojo/require plugin. Thus,\n\t\t\t// when the dojo/loadInit plugin reports it has been loaded, all modules required by the given module are guaranteed\n\t\t\t// loaded (but not executed). This then allows the module to execute it's code path without interupts, thereby\n\t\t\t// following the synchronous code path.\n\t\t\t//\n\t\t\t// Notice that this function behaves the same whether or not it happens to be in a mapped dojo/loader module.\n\n\t\t\tvar extractResult, id, names = [], namesAsStrings = [];\n\t\t\tif(buildDetectRe.test(text) || !(extractResult = extractLegacyApiApplications(text))){\n\t\t\t\t// buildDetectRe.test(text) => a built module, always AMD\n\t\t\t\t// extractResult==0 => no sync API\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// manufacture a synthetic module id that can never be a real mdule id (just like require does)\n\t\t\tid = module.mid + \"-*loadInit\";\n\n\t\t\t// construct the dojo/loadInit names vector which causes any relocated names to be defined as lexical variables under their not-relocated name\n\t\t\t// the dojo/loadInit plugin assumes the first name in names is \"dojo\"\n\n\t\t\tfor(var p in getModule(\"dojo\", module).result.scopeMap){\n\t\t\t\tnames.push(p);\n\t\t\t\tnamesAsStrings.push('\"' + p + '\"');\n\t\t\t}\n\n\t\t\t// rewrite the module as a synthetic dojo/loadInit plugin resource + the module expressed as an AMD module that depends on this synthetic resource\n\t\t\t// don't have to map dojo/init since that will occur when the dependency is resolved\n\t\t\treturn \"// xdomain rewrite of \" + module.mid + \"\\n\" +\n\t\t\t\t\"define('\" + id + \"',{\\n\" +\n\t\t\t\t\"\\tnames:\" + dojo.toJson(names) + \",\\n\" +\n\t\t\t\t\"\\tdef:function(\" + names.join(\",\") + \"){\" + extractResult[1] + \"}\" +\n\t\t\t\t\"});\\n\\n\" +\n\t\t\t\t\"define(\" + dojo.toJson(names.concat([\"dojo/loadInit!\"+id])) + \", function(\" + names.join(\",\") + \"){\\n\" + extractResult[0] + \"});\";\n\t\t},\n\n\t\tloaderVars = require.initSyncLoader(dojoRequirePlugin, checkDojoRequirePlugin, transformToAmd),\n\n\t\tsync =\n\t\t\tloaderVars.sync,\n\n\t\trequested =\n\t\t\tloaderVars.requested,\n\n\t\tarrived =\n\t\t\tloaderVars.arrived,\n\n\t\tnonmodule =\n\t\t\tloaderVars.nonmodule,\n\n\t\texecuting =\n\t\t\tloaderVars.executing,\n\n\t\texecuted =\n\t\t\tloaderVars.executed,\n\n\t\tsyncExecStack =\n\t\t\tloaderVars.syncExecStack,\n\n\t\tmodules =\n\t\t\tloaderVars.modules,\n\n\t\texecQ =\n\t\t\tloaderVars.execQ,\n\n\t\tgetModule =\n\t\t\tloaderVars.getModule,\n\n\t\tinjectModule =\n\t\t\tloaderVars.injectModule,\n\n\t\tsetArrived =\n\t\t\tloaderVars.setArrived,\n\n\t\tsignal =\n\t\t\tloaderVars.signal,\n\n\t\tfinishExec =\n\t\t\tloaderVars.finishExec,\n\n\t\texecModule =\n\t\t\tloaderVars.execModule,\n\n\t\tgetLegacyMode =\n\t\t\tloaderVars.getLegacyMode,\n\n\t\tguardCheckComplete =\n\t\t\tloaderVars.guardCheckComplete;\n\n\t// there is exactly one dojoRequirePlugin among possibly-many dojo/_base/loader's (owing to mapping)\n\tdojoRequirePlugin = loaderVars.dojoRequirePlugin;\n\n\tdojo.provide = function(mid){\n\t\tvar executingModule = syncExecStack[0],\n\t\t\tmodule = lang.mixin(getModule(slashName(mid), require.module), {\n\t\t\t\texecuted:executing,\n\t\t\t\tresult:lang.getObject(mid, true)\n\t\t\t});\n\t\tsetArrived(module);\n\t\tif(executingModule){\n\t\t\t(executingModule.provides || (executingModule.provides = [])).push(function(){\n\t\t\t\tmodule.result = lang.getObject(mid);\n\t\t\t\tdelete module.provides;\n\t\t\t\tmodule.executed!==executed && finishExec(module);\n\t\t\t});\n\t\t}// else dojo.provide called not consequent to loading; therefore, give up trying to publish module value to loader namespace\n\t\treturn module.result;\n\t};\n\n\thas.add(\"config-publishRequireResult\", 1, 0, 0);\n\n\tdojo.require = function(moduleName, omitModuleCheck) {\n\t\t// summary:\n\t\t//\t\tloads a Javascript module from the appropriate URI\n\t\t//\n\t\t// moduleName: String\n\t\t//\t\tmodule name to load, using periods for separators,\n\t\t//\t\t e.g. \"dojo.date.locale\".  Module paths are de-referenced by dojo's\n\t\t//\t\tinternal mapping of locations to names and are disambiguated by\n\t\t//\t\tlongest prefix. See `dojo.registerModulePath()` for details on\n\t\t//\t\tregistering new modules.\n\t\t//\n\t\t// omitModuleCheck: Boolean?\n\t\t//\t\tif `true`, omitModuleCheck skips the step of ensuring that the\n\t\t//\t\tloaded file actually defines the symbol it is referenced by.\n\t\t//\t\tFor example if it called as `dojo.require(\"a.b.c\")` and the\n\t\t//\t\tfile located at `a/b/c.js` does not define an object `a.b.c`,\n\t\t//\t\tand exception will be throws whereas no exception is raised\n\t\t//\t\twhen called as `dojo.require(\"a.b.c\", true)`\n\t\t//\n\t\t// description:\n\t\t//\t\tModules are loaded via dojo.require by using one of two loaders: the normal loader\n\t\t//\t\tand the xdomain loader. The xdomain loader is used when dojo was built with a\n\t\t//\t\tcustom build that specified loader=xdomain and the module lives on a modulePath\n\t\t//\t\tthat is a whole URL, with protocol and a domain. The versions of Dojo that are on\n\t\t//\t\tthe Google and AOL CDNs use the xdomain loader.\n\t\t//\n\t\t//\t\tIf the module is loaded via the xdomain loader, it is an asynchronous load, since\n\t\t//\t\tthe module is added via a dynamically created script tag. This\n\t\t//\t\tmeans that dojo.require() can return before the module has loaded. However, this\n\t\t//\t\tshould only happen in the case where you do dojo.require calls in the top-level\n\t\t//\t\tHTML page, or if you purposely avoid the loader checking for dojo.require\n\t\t//\t\tdependencies in your module by using a syntax like dojo[\"require\"] to load the module.\n\t\t//\n\t\t//\t\tSometimes it is useful to not have the loader detect the dojo.require calls in the\n\t\t//\t\tmodule so that you can dynamically load the modules as a result of an action on the\n\t\t//\t\tpage, instead of right at module load time.\n\t\t//\n\t\t//\t\tAlso, for script blocks in an HTML page, the loader does not pre-process them, so\n\t\t//\t\tit does not know to download the modules before the dojo.require calls occur.\n\t\t//\n\t\t//\t\tSo, in those two cases, when you want on-the-fly module loading or for script blocks\n\t\t//\t\tin the HTML page, special care must be taken if the dojo.required code is loaded\n\t\t//\t\tasynchronously. To make sure you can execute code that depends on the dojo.required\n\t\t//\t\tmodules, be sure to add the code that depends on the modules in a dojo.addOnLoad()\n\t\t//\t\tcallback. dojo.addOnLoad waits for all outstanding modules to finish loading before\n\t\t//\t\texecuting.\n\t\t//\n\t\t//\t\tThis type of syntax works with both xdomain and normal loaders, so it is good\n\t\t//\t\tpractice to always use this idiom for on-the-fly code loading and in HTML script\n\t\t//\t\tblocks. If at some point you change loaders and where the code is loaded from,\n\t\t//\t\tit will all still work.\n\t\t//\n\t\t//\t\tMore on how dojo.require\n\t\t//\t\t`dojo.require(\"A.B\")` first checks to see if symbol A.B is\n\t\t//\t\tdefined. If it is, it is simply returned (nothing to do).\n\t\t//\n\t\t//\t\tIf it is not defined, it will look for `A/B.js` in the script root\n\t\t//\t\tdirectory.\n\t\t//\n\t\t//\t\t`dojo.require` throws an exception if it cannot find a file\n\t\t//\t\tto load, or if the symbol `A.B` is not defined after loading.\n\t\t//\n\t\t//\t\tIt returns the object `A.B`, but note the caveats above about on-the-fly loading and\n\t\t//\t\tHTML script blocks when the xdomain loader is loading a module.\n\t\t//\n\t\t//\t\t`dojo.require()` does nothing about importing symbols into\n\t\t//\t\tthe current namespace.\tIt is presumed that the caller will\n\t\t//\t\ttake care of that.\n\t\t//\n\t\t// example:\n\t\t//\t\tTo use dojo.require in conjunction with dojo.ready:\n\t\t//\n\t\t//\t\t|\tdojo.require(\"foo\");\n\t\t//\t\t|\tdojo.require(\"bar\");\n\t\t//\t\t|\tdojo.addOnLoad(function(){\n\t\t//\t\t|\t\t//you can now safely do something with foo and bar\n\t\t//\t\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t\tFor example, to import all symbols into a local block, you might write:\n\t\t//\n\t\t//\t\t|\twith (dojo.require(\"A.B\")) {\n\t\t//\t\t|\t\t...\n\t\t//\t\t|\t}\n\t\t//\n\t\t//\t\tAnd to import just the leaf symbol to a local variable:\n\t\t//\n\t\t//\t\t|\tvar B = dojo.require(\"A.B\");\n\t\t//\t\t|\t...\n\t\t//\n\t\t// returns:\n\t\t//\t\tthe required namespace object\n\t\tfunction doRequire(mid, omitModuleCheck){\n\t\t\tvar module = getModule(slashName(mid), require.module);\n\t\t\tif(syncExecStack.length && syncExecStack[0].finish){\n\t\t\t\t// switched to async loading in the middle of evaluating a legacy module; stop\n\t\t\t\t// applying dojo.require so the remaining dojo.requires are applied in order\n\t\t\t\tsyncExecStack[0].finish.push(mid);\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// recall module.executed has values {0, executing, executed}; therefore, truthy indicates executing or executed\n\t\t\tif(module.executed){\n\t\t\t\treturn module.result;\n\t\t\t}\n\t\t\tomitModuleCheck && (module.result = nonmodule);\n\n\t\t\t// rcg...why here and in two lines??\n\t\t\tvar currentMode = getLegacyMode();\n\n\t\t\t// recall, in sync mode to inject is to *eval* the module text\n\t\t\t// if the module is a legacy module, this is the same as executing\n\t\t\t// but if the module is an AMD module, this means defining, not executing\n\t\t\tinjectModule(module);\n\t\t\t// the inject may have changed the mode\n\t\t\tcurrentMode = getLegacyMode();\n\n\t\t\t// in sync mode to dojo.require is to execute\n\t\t\tif(module.executed!==executed && module.injected===arrived){\n\t\t\t\t// the module was already here before injectModule was called probably finishing up a xdomain\n\t\t\t\t// load, but maybe a module given to the loader directly rather than having the loader retrieve it\n\n\t\t\t\tloaderVars.guardCheckComplete(function(){\n\t\t\t\t\texecModule(module);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif(module.executed){\n\t\t\t\treturn module.result;\n\t\t\t}\n\n\t\t\tif(currentMode==sync){\n\t\t\t\t// the only way to get here is in sync mode and dojo.required a module that\n\t\t\t\t//\t * was loaded async in the injectModule application a few lines up\n\t\t\t\t//\t * was an AMD module that had deps that are being loaded async and therefore couldn't execute\n\t\t\t\tif(module.cjs){\n\t\t\t\t\t// the module was an AMD module; unshift, not push, which causes the current traversal to be reattempted from the top\n\t\t\t\t\texecQ.unshift(module);\n\t\t\t\t}else{\n\t\t\t\t\t// the module was a legacy module\n\t\t\t\t\tsyncExecStack.length && (syncExecStack[0].finish= [mid]);\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\t// the loader wasn't in sync mode on entry; probably async mode; therefore, no expectation of getting\n\t\t\t\t// the module value synchronously; make sure it gets executed though\n\t\t\t\texecQ.push(module);\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t}\n\n\t\tvar result = doRequire(moduleName, omitModuleCheck);\n\t\tif(has(\"config-publishRequireResult\") && !lang.exists(moduleName) && result!==undefined){\n\t\t\tlang.setObject(moduleName, result);\n\t\t}\n\t\treturn result;\n\t};\n\n\tdojo.loadInit = function(f) {\n\t\tf();\n\t};\n\n\tdojo.registerModulePath = function(/*String*/moduleName, /*String*/prefix){\n\t\t// summary:\n\t\t//\t\tMaps a module name to a path\n\t\t// description:\n\t\t//\t\tAn unregistered module is given the default path of ../[module],\n\t\t//\t\trelative to Dojo root. For example, module acme is mapped to\n\t\t//\t\t../acme.  If you want to use a different module name, use\n\t\t//\t\tdojo.registerModulePath.\n\t\t// example:\n\t\t//\t\tIf your dojo.js is located at this location in the web root:\n\t\t//\t|\t/myapp/js/dojo/dojo/dojo.js\n\t\t//\t\tand your modules are located at:\n\t\t//\t|\t/myapp/js/foo/bar.js\n\t\t//\t|\t/myapp/js/foo/baz.js\n\t\t//\t|\t/myapp/js/foo/thud/xyzzy.js\n\t\t//\t\tYour application can tell Dojo to locate the \"foo\" namespace by calling:\n\t\t//\t|\tdojo.registerModulePath(\"foo\", \"../../foo\");\n\t\t//\t\tAt which point you can then use dojo.require() to load the\n\t\t//\t\tmodules (assuming they provide() the same things which are\n\t\t//\t\trequired). The full code might be:\n\t\t//\t|\t<script type=\"text/javascript\"\n\t\t//\t|\t\tsrc=\"/myapp/js/dojo/dojo/dojo.js\"></script>\n\t\t//\t|\t<script type=\"text/javascript\">\n\t\t//\t|\t\tdojo.registerModulePath(\"foo\", \"../../foo\");\n\t\t//\t|\t\tdojo.require(\"foo.bar\");\n\t\t//\t|\t\tdojo.require(\"foo.baz\");\n\t\t//\t|\t\tdojo.require(\"foo.thud.xyzzy\");\n\t\t//\t|\t</script>\n\n\t\tvar paths = {};\n\t\tpaths[moduleName.replace(/\\./g, \"/\")] = prefix;\n\t\trequire({paths:paths});\n\t};\n\n\tdojo.platformRequire = function(/*Object*/modMap){\n\t\t// summary:\n\t\t//\t\trequire one or more modules based on which host environment\n\t\t//\t\tDojo is currently operating in\n\t\t// description:\n\t\t//\t\tThis method takes a \"map\" of arrays which one can use to\n\t\t//\t\toptionally load dojo modules. The map is indexed by the\n\t\t//\t\tpossible dojo.name_ values, with two additional values:\n\t\t//\t\t\"default\" and \"common\". The items in the \"default\" array will\n\t\t//\t\tbe loaded if none of the other items have been choosen based on\n\t\t//\t\tdojo.name_, set by your host environment. The items in the\n\t\t//\t\t\"common\" array will *always* be loaded, regardless of which\n\t\t//\t\tlist is chosen.\n\t\t// example:\n\t\t//\t\t|\tdojo.platformRequire({\n\t\t//\t\t|\t\tbrowser: [\n\t\t//\t\t|\t\t\t\"foo.sample\", // simple module\n\t\t//\t\t|\t\t\t\"foo.test\",\n\t\t//\t\t|\t\t\t[\"foo.bar.baz\", true] // skip object check in _loadModule (dojo.require)\n\t\t//\t\t|\t\t],\n\t\t//\t\t|\t\tdefault: [ \"foo.sample._base\" ],\n\t\t//\t\t|\t\tcommon: [ \"important.module.common\" ]\n\t\t//\t\t|\t});\n\n\t\tvar result = (modMap.common || []).concat(modMap[dojo._name] || modMap[\"default\"] || []),\n\t\t\ttemp;\n\t\twhile(result.length){\n\t\t\tif(lang.isArray(temp = result.shift())){\n\t\t\t\tdojo.require.apply(dojo, temp);\n\t\t\t}else{\n\t\t\t\tdojo.require(temp);\n\t\t\t}\n\t\t}\n\t};\n\n\tdojo.requireIf = dojo.requireAfterIf = function(/*Boolean*/ condition, /*String*/ moduleName, /*Boolean?*/omitModuleCheck){\n\t\t// summary:\n\t\t//\t\tIf the condition is true then call `dojo.require()` for the specified\n\t\t//\t\tresource\n\t\t//\n\t\t// example:\n\t\t//\t|\tdojo.requireIf(dojo.isBrowser, \"my.special.Module\");\n\n\t\tif(condition){\n\t\t\tdojo.require(moduleName, omitModuleCheck);\n\t\t}\n\t};\n\n\tdojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale){\n\t\trequire([\"../i18n\"], function(i18n){\n\t\t\ti18n.getLocalization(moduleName, bundleName, locale);\n\t\t});\n\t};\n\n\treturn {\n\t\t// summary:\n\t\t//\t\tThis module defines the v1.x synchronous loader API.\n\n\t\textractLegacyApiApplications:extractLegacyApiApplications,\n\t\trequire:dojoRequirePlugin,\n\t\tloadInit:dojoLoadInitPlugin\n\t};\n});\n\n},\n'dojo/json':function(){\ndefine([\"./has\"], function(has){\n\t\"use strict\";\n\tvar hasJSON = typeof JSON != \"undefined\";\n\thas.add(\"json-parse\", hasJSON); // all the parsers work fine\n\t\t// Firefox 3.5/Gecko 1.9 fails to use replacer in stringify properly https://bugzilla.mozilla.org/show_bug.cgi?id=509184\n\thas.add(\"json-stringify\", hasJSON && JSON.stringify({a:0}, function(k,v){return v||1;}) == '{\"a\":1}');\n\n\t/*=====\n\treturn {\n\t\t// summary:\n\t\t//\t\tFunctions to parse and serialize JSON\n\n\t\tparse: function(str, strict){\n\t\t\t// summary:\n\t\t\t//\t\tParses a [JSON](http://json.org) string to return a JavaScript object.\n\t\t\t// description:\n\t\t\t//\t\tThis function follows [native JSON API](https://developer.mozilla.org/en/JSON)\n\t\t\t//\t\tThrows for invalid JSON strings. This delegates to eval() if native JSON\n\t\t\t//\t\tsupport is not available. By default this will evaluate any valid JS expression.\n\t\t\t//\t\tWith the strict parameter set to true, the parser will ensure that only\n\t\t\t//\t\tvalid JSON strings are parsed (otherwise throwing an error). Without the strict\n\t\t\t//\t\tparameter, the content passed to this method must come\n\t\t\t//\t\tfrom a trusted source.\n\t\t\t// str:\n\t\t\t//\t\ta string literal of a JSON item, for instance:\n\t\t\t//\t\t`'{ \"foo\": [ \"bar\", 1, { \"baz\": \"thud\" } ] }'`\n\t\t\t// strict:\n\t\t\t//\t\tWhen set to true, this will ensure that only valid, secure JSON is ever parsed.\n\t\t\t//\t\tMake sure this is set to true for untrusted content. Note that on browsers/engines\n\t\t\t//\t\twithout native JSON support, setting this to true will run slower.\n\t\t},\n\t\tstringify: function(value, replacer, spacer){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a [JSON](http://json.org) serialization of an object.\n\t\t\t// description:\n\t\t\t//\t\tReturns a [JSON](http://json.org) serialization of an object.\n\t\t\t//\t\tThis function follows [native JSON API](https://developer.mozilla.org/en/JSON)\n\t\t\t//\t\tNote that this doesn't check for infinite recursion, so don't do that!\n\t\t\t// value:\n\t\t\t//\t\tA value to be serialized.\n\t\t\t// replacer:\n\t\t\t//\t\tA replacer function that is called for each value and can return a replacement\n\t\t\t// spacer:\n\t\t\t//\t\tA spacer string to be used for pretty printing of JSON\n\t\t\t// example:\n\t\t\t//\t\tsimple serialization of a trivial object\n\t\t\t//\t|\tdefine([\"dojo/json\"], function(JSON){\n\t\t\t// \t|\t\tvar jsonStr = JSON.stringify({ howdy: \"stranger!\", isStrange: true });\n\t\t\t//\t|\t\tdoh.is('{\"howdy\":\"stranger!\",\"isStrange\":true}', jsonStr);\n\t\t}\n\t};\n\t=====*/\n\n\tif(has(\"json-stringify\")){\n\t\treturn JSON;\n\t}else{\n\t\tvar escapeString = function(/*String*/str){\n\t\t\t// summary:\n\t\t\t//\t\tAdds escape sequences for non-visual characters, double quote and\n\t\t\t//\t\tbackslash and surrounds with double quotes to form a valid string\n\t\t\t//\t\tliteral.\n\t\t\treturn ('\"' + str.replace(/([\"\\\\])/g, '\\\\$1') + '\"').\n\t\t\t\treplace(/[\\f]/g, \"\\\\f\").replace(/[\\b]/g, \"\\\\b\").replace(/[\\n]/g, \"\\\\n\").\n\t\t\t\treplace(/[\\t]/g, \"\\\\t\").replace(/[\\r]/g, \"\\\\r\"); // string\n\t\t};\n\t\treturn {\n\t\t\tparse: has(\"json-parse\") ? JSON.parse : function(str, strict){\n\t\t\t\tif(strict && !/^([\\s\\[\\{]*(?:\"(?:\\\\.|[^\"])+\"|-?\\d[\\d\\.]*(?:[Ee][+-]?\\d+)?|null|true|false|)[\\s\\]\\}]*(?:,|:|$))+$/.test(str)){\n\t\t\t\t\tthrow new SyntaxError(\"Invalid characters in JSON\");\n\t\t\t\t}\n\t\t\t\treturn eval('(' + str + ')');\n\t\t\t},\n\t\t\tstringify: function(value, replacer, spacer){\n\t\t\t\tvar undef;\n\t\t\t\tif(typeof replacer == \"string\"){\n\t\t\t\t\tspacer = replacer;\n\t\t\t\t\treplacer = null;\n\t\t\t\t}\n\t\t\t\tfunction stringify(it, indent, key){\n\t\t\t\t\tif(replacer){\n\t\t\t\t\t\tit = replacer(key, it);\n\t\t\t\t\t}\n\t\t\t\t\tvar val, objtype = typeof it;\n\t\t\t\t\tif(objtype == \"number\"){\n\t\t\t\t\t\treturn isFinite(it) ? it + \"\" : \"null\";\n\t\t\t\t\t}\n\t\t\t\t\tif(objtype == \"boolean\"){\n\t\t\t\t\t\treturn it + \"\";\n\t\t\t\t\t}\n\t\t\t\t\tif(it === null){\n\t\t\t\t\t\treturn \"null\";\n\t\t\t\t\t}\n\t\t\t\t\tif(typeof it == \"string\"){\n\t\t\t\t\t\treturn escapeString(it);\n\t\t\t\t\t}\n\t\t\t\t\tif(objtype == \"function\" || objtype == \"undefined\"){\n\t\t\t\t\t\treturn undef; // undefined\n\t\t\t\t\t}\n\t\t\t\t\t// short-circuit for objects that support \"json\" serialization\n\t\t\t\t\t// if they return \"self\" then just pass-through...\n\t\t\t\t\tif(typeof it.toJSON == \"function\"){\n\t\t\t\t\t\treturn stringify(it.toJSON(key), indent, key);\n\t\t\t\t\t}\n\t\t\t\t\tif(it instanceof Date){\n\t\t\t\t\t\treturn '\"{FullYear}-{Month+}-{Date}T{Hours}:{Minutes}:{Seconds}Z\"'.replace(/\\{(\\w+)(\\+)?\\}/g, function(t, prop, plus){\n\t\t\t\t\t\t\tvar num = it[\"getUTC\" + prop]() + (plus ? 1 : 0);\n\t\t\t\t\t\t\treturn num < 10 ? \"0\" + num : num;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif(it.valueOf() !== it){\n\t\t\t\t\t\t// primitive wrapper, try again unwrapped:\n\t\t\t\t\t\treturn stringify(it.valueOf(), indent, key);\n\t\t\t\t\t}\n\t\t\t\t\tvar nextIndent= spacer ? (indent + spacer) : \"\";\n\t\t\t\t\t/* we used to test for DOM nodes and throw, but FF serializes them as {}, so cross-browser consistency is probably not efficiently attainable */ \n\t\t\t\t\n\t\t\t\t\tvar sep = spacer ? \" \" : \"\";\n\t\t\t\t\tvar newLine = spacer ? \"\\n\" : \"\";\n\t\t\t\t\n\t\t\t\t\t// array\n\t\t\t\t\tif(it instanceof Array){\n\t\t\t\t\t\tvar itl = it.length, res = [];\n\t\t\t\t\t\tfor(key = 0; key < itl; key++){\n\t\t\t\t\t\t\tvar obj = it[key];\n\t\t\t\t\t\t\tval = stringify(obj, nextIndent, key);\n\t\t\t\t\t\t\tif(typeof val != \"string\"){\n\t\t\t\t\t\t\t\tval = \"null\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tres.push(newLine + nextIndent + val);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn \"[\" + res.join(\",\") + newLine + indent + \"]\";\n\t\t\t\t\t}\n\t\t\t\t\t// generic object code path\n\t\t\t\t\tvar output = [];\n\t\t\t\t\tfor(key in it){\n\t\t\t\t\t\tvar keyStr;\n\t\t\t\t\t\tif(it.hasOwnProperty(key)){\n\t\t\t\t\t\t\tif(typeof key == \"number\"){\n\t\t\t\t\t\t\t\tkeyStr = '\"' + key + '\"';\n\t\t\t\t\t\t\t}else if(typeof key == \"string\"){\n\t\t\t\t\t\t\t\tkeyStr = escapeString(key);\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t// skip non-string or number keys\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tval = stringify(it[key], nextIndent, key);\n\t\t\t\t\t\t\tif(typeof val != \"string\"){\n\t\t\t\t\t\t\t\t// skip non-serializable values\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// At this point, the most non-IE browsers don't get in this branch \n\t\t\t\t\t\t\t// (they have native JSON), so push is definitely the way to\n\t\t\t\t\t\t\toutput.push(newLine + nextIndent + keyStr + \":\" + sep + val);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn \"{\" + output.join(\",\") + newLine + indent + \"}\"; // String\n\t\t\t\t}\n\t\t\t\treturn stringify(value, \"\", \"\");\n\t\t\t}\n\t\t};\n\t}\n});\n\n},\n'dojo/_base/declare':function(){\ndefine([\"./kernel\", \"../has\", \"./lang\"], function(dojo, has, lang){\n\t// module:\n\t//\t\tdojo/_base/declare\n\n\tvar mix = lang.mixin, op = Object.prototype, opts = op.toString,\n\t\txtor = new Function, counter = 0, cname = \"constructor\";\n\n\tfunction err(msg, cls){ throw new Error(\"declare\" + (cls ? \" \" + cls : \"\") + \": \" + msg); }\n\n\t// C3 Method Resolution Order (see http://www.python.org/download/releases/2.3/mro/)\n\tfunction c3mro(bases, className){\n\t\tvar result = [], roots = [{cls: 0, refs: []}], nameMap = {}, clsCount = 1,\n\t\t\tl = bases.length, i = 0, j, lin, base, top, proto, rec, name, refs;\n\n\t\t// build a list of bases naming them if needed\n\t\tfor(; i < l; ++i){\n\t\t\tbase = bases[i];\n\t\t\tif(!base){\n\t\t\t\terr(\"mixin #\" + i + \" is unknown. Did you use dojo.require to pull it in?\", className);\n\t\t\t}else if(opts.call(base) != \"[object Function]\"){\n\t\t\t\terr(\"mixin #\" + i + \" is not a callable constructor.\", className);\n\t\t\t}\n\t\t\tlin = base._meta ? base._meta.bases : [base];\n\t\t\ttop = 0;\n\t\t\t// add bases to the name map\n\t\t\tfor(j = lin.length - 1; j >= 0; --j){\n\t\t\t\tproto = lin[j].prototype;\n\t\t\t\tif(!proto.hasOwnProperty(\"declaredClass\")){\n\t\t\t\t\tproto.declaredClass = \"uniqName_\" + (counter++);\n\t\t\t\t}\n\t\t\t\tname = proto.declaredClass;\n\t\t\t\tif(!nameMap.hasOwnProperty(name)){\n\t\t\t\t\tnameMap[name] = {count: 0, refs: [], cls: lin[j]};\n\t\t\t\t\t++clsCount;\n\t\t\t\t}\n\t\t\t\trec = nameMap[name];\n\t\t\t\tif(top && top !== rec){\n\t\t\t\t\trec.refs.push(top);\n\t\t\t\t\t++top.count;\n\t\t\t\t}\n\t\t\t\ttop = rec;\n\t\t\t}\n\t\t\t++top.count;\n\t\t\troots[0].refs.push(top);\n\t\t}\n\n\t\t// remove classes without external references recursively\n\t\twhile(roots.length){\n\t\t\ttop = roots.pop();\n\t\t\tresult.push(top.cls);\n\t\t\t--clsCount;\n\t\t\t// optimization: follow a single-linked chain\n\t\t\twhile(refs = top.refs, refs.length == 1){\n\t\t\t\ttop = refs[0];\n\t\t\t\tif(!top || --top.count){\n\t\t\t\t\t// branch or end of chain => do not end to roots\n\t\t\t\t\ttop = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tresult.push(top.cls);\n\t\t\t\t--clsCount;\n\t\t\t}\n\t\t\tif(top){\n\t\t\t\t// branch\n\t\t\t\tfor(i = 0, l = refs.length; i < l; ++i){\n\t\t\t\t\ttop = refs[i];\n\t\t\t\t\tif(!--top.count){\n\t\t\t\t\t\troots.push(top);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(clsCount){\n\t\t\terr(\"can't build consistent linearization\", className);\n\t\t}\n\n\t\t// calculate the superclass offset\n\t\tbase = bases[0];\n\t\tresult[0] = base ?\n\t\t\tbase._meta && base === result[result.length - base._meta.bases.length] ?\n\t\t\t\tbase._meta.bases.length : 1 : 0;\n\n\t\treturn result;\n\t}\n\n\tfunction inherited(args, a, f){\n\t\tvar name, chains, bases, caller, meta, base, proto, opf, pos,\n\t\t\tcache = this._inherited = this._inherited || {};\n\n\t\t// crack arguments\n\t\tif(typeof args == \"string\"){\n\t\t\tname = args;\n\t\t\targs = a;\n\t\t\ta = f;\n\t\t}\n\t\tf = 0;\n\n\t\tcaller = args.callee;\n\t\tname = name || caller.nom;\n\t\tif(!name){\n\t\t\terr(\"can't deduce a name to call inherited()\", this.declaredClass);\n\t\t}\n\n\t\tmeta = this.constructor._meta;\n\t\tbases = meta.bases;\n\n\t\tpos = cache.p;\n\t\tif(name != cname){\n\t\t\t// method\n\t\t\tif(cache.c !== caller){\n\t\t\t\t// cache bust\n\t\t\t\tpos = 0;\n\t\t\t\tbase = bases[0];\n\t\t\t\tmeta = base._meta;\n\t\t\t\tif(meta.hidden[name] !== caller){\n\t\t\t\t\t// error detection\n\t\t\t\t\tchains = meta.chains;\n\t\t\t\t\tif(chains && typeof chains[name] == \"string\"){\n\t\t\t\t\t\terr(\"calling chained method with inherited: \" + name, this.declaredClass);\n\t\t\t\t\t}\n\t\t\t\t\t// find caller\n\t\t\t\t\tdo{\n\t\t\t\t\t\tmeta = base._meta;\n\t\t\t\t\t\tproto = base.prototype;\n\t\t\t\t\t\tif(meta && (proto[name] === caller && proto.hasOwnProperty(name) || meta.hidden[name] === caller)){\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}while(base = bases[++pos]); // intentional assignment\n\t\t\t\t\tpos = base ? pos : -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// find next\n\t\t\tbase = bases[++pos];\n\t\t\tif(base){\n\t\t\t\tproto = base.prototype;\n\t\t\t\tif(base._meta && proto.hasOwnProperty(name)){\n\t\t\t\t\tf = proto[name];\n\t\t\t\t}else{\n\t\t\t\t\topf = op[name];\n\t\t\t\t\tdo{\n\t\t\t\t\t\tproto = base.prototype;\n\t\t\t\t\t\tf = proto[name];\n\t\t\t\t\t\tif(f && (base._meta ? proto.hasOwnProperty(name) : f !== opf)){\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}while(base = bases[++pos]); // intentional assignment\n\t\t\t\t}\n\t\t\t}\n\t\t\tf = base && f || op[name];\n\t\t}else{\n\t\t\t// constructor\n\t\t\tif(cache.c !== caller){\n\t\t\t\t// cache bust\n\t\t\t\tpos = 0;\n\t\t\t\tmeta = bases[0]._meta;\n\t\t\t\tif(meta && meta.ctor !== caller){\n\t\t\t\t\t// error detection\n\t\t\t\t\tchains = meta.chains;\n\t\t\t\t\tif(!chains || chains.constructor !== \"manual\"){\n\t\t\t\t\t\terr(\"calling chained constructor with inherited\", this.declaredClass);\n\t\t\t\t\t}\n\t\t\t\t\t// find caller\n\t\t\t\t\twhile(base = bases[++pos]){ // intentional assignment\n\t\t\t\t\t\tmeta = base._meta;\n\t\t\t\t\t\tif(meta && meta.ctor === caller){\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpos = base ? pos : -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// find next\n\t\t\twhile(base = bases[++pos]){\t// intentional assignment\n\t\t\t\tmeta = base._meta;\n\t\t\t\tf = meta ? meta.ctor : base;\n\t\t\t\tif(f){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tf = base && f;\n\t\t}\n\n\t\t// cache the found super method\n\t\tcache.c = f;\n\t\tcache.p = pos;\n\n\t\t// now we have the result\n\t\tif(f){\n\t\t\treturn a === true ? f : f.apply(this, a || args);\n\t\t}\n\t\t// intentionally no return if a super method was not found\n\t}\n\n\tfunction getInherited(name, args){\n\t\tif(typeof name == \"string\"){\n\t\t\treturn this.__inherited(name, args, true);\n\t\t}\n\t\treturn this.__inherited(name, true);\n\t}\n\n\tfunction inherited__debug(args, a1, a2){\n\t\tvar f = this.getInherited(args, a1);\n\t\tif(f){ return f.apply(this, a2 || a1 || args); }\n\t\t// intentionally no return if a super method was not found\n\t}\n\n\tvar inheritedImpl = dojo.config.isDebug ? inherited__debug : inherited;\n\n\t// emulation of \"instanceof\"\n\tfunction isInstanceOf(cls){\n\t\tvar bases = this.constructor._meta.bases;\n\t\tfor(var i = 0, l = bases.length; i < l; ++i){\n\t\t\tif(bases[i] === cls){\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn this instanceof cls;\n\t}\n\n\tfunction mixOwn(target, source){\n\t\t// add props adding metadata for incoming functions skipping a constructor\n\t\tfor(var name in source){\n\t\t\tif(name != cname && source.hasOwnProperty(name)){\n\t\t\t\ttarget[name] = source[name];\n\t\t\t}\n\t\t}\n\t\tif(has(\"bug-for-in-skips-shadowed\")){\n\t\t\tfor(var extraNames= lang._extraNames, i= extraNames.length; i;){\n\t\t\t\tname = extraNames[--i];\n\t\t\t\tif(name != cname && source.hasOwnProperty(name)){\n\t\t\t\t\t  target[name] = source[name];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// implementation of safe mixin function\n\tfunction safeMixin(target, source){\n\t\t// summary:\n\t\t//\t\tMix in properties skipping a constructor and decorating functions\n\t\t//\t\tlike it is done by declare().\n\t\t// target: Object\n\t\t//\t\tTarget object to accept new properties.\n\t\t// source: Object\n\t\t//\t\tSource object for new properties.\n\t\t// description:\n\t\t//\t\tThis function is used to mix in properties like lang.mixin does,\n\t\t//\t\tbut it skips a constructor property and decorates functions like\n\t\t//\t\tdeclare() does.\n\t\t//\n\t\t//\t\tIt is meant to be used with classes and objects produced with\n\t\t//\t\tdeclare. Functions mixed in with dojo.safeMixin can use\n\t\t//\t\tthis.inherited() like normal methods.\n\t\t//\n\t\t//\t\tThis function is used to implement extend() method of a constructor\n\t\t//\t\tproduced with declare().\n\t\t//\n\t\t// example:\n\t\t//\t|\tvar A = declare(null, {\n\t\t//\t|\t\tm1: function(){\n\t\t//\t|\t\t\tconsole.log(\"A.m1\");\n\t\t//\t|\t\t},\n\t\t//\t|\t\tm2: function(){\n\t\t//\t|\t\t\tconsole.log(\"A.m2\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tvar B = declare(A, {\n\t\t//\t|\t\tm1: function(){\n\t\t//\t|\t\t\tthis.inherited(arguments);\n\t\t//\t|\t\t\tconsole.log(\"B.m1\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tB.extend({\n\t\t//\t|\t\tm2: function(){\n\t\t//\t|\t\t\tthis.inherited(arguments);\n\t\t//\t|\t\t\tconsole.log(\"B.m2\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tvar x = new B();\n\t\t//\t|\tdojo.safeMixin(x, {\n\t\t//\t|\t\tm1: function(){\n\t\t//\t|\t\t\tthis.inherited(arguments);\n\t\t//\t|\t\t\tconsole.log(\"X.m1\");\n\t\t//\t|\t\t},\n\t\t//\t|\t\tm2: function(){\n\t\t//\t|\t\t\tthis.inherited(arguments);\n\t\t//\t|\t\t\tconsole.log(\"X.m2\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tx.m2();\n\t\t//\t|\t// prints:\n\t\t//\t|\t// A.m1\n\t\t//\t|\t// B.m1\n\t\t//\t|\t// X.m1\n\n\t\tvar name, t;\n\t\t// add props adding metadata for incoming functions skipping a constructor\n\t\tfor(name in source){\n\t\t\tt = source[name];\n\t\t\tif((t !== op[name] || !(name in op)) && name != cname){\n\t\t\t\tif(opts.call(t) == \"[object Function]\"){\n\t\t\t\t\t// non-trivial function method => attach its name\n\t\t\t\t\tt.nom = name;\n\t\t\t\t}\n\t\t\t\ttarget[name] = t;\n\t\t\t}\n\t\t}\n\t\tif(has(\"bug-for-in-skips-shadowed\")){\n\t\t\tfor(var extraNames= lang._extraNames, i= extraNames.length; i;){\n\t\t\t\tname = extraNames[--i];\n\t\t\t\tt = source[name];\n\t\t\t\tif((t !== op[name] || !(name in op)) && name != cname){\n\t\t\t\t\tif(opts.call(t) == \"[object Function]\"){\n\t\t\t\t\t\t// non-trivial function method => attach its name\n\t\t\t\t\t\t  t.nom = name;\n\t\t\t\t\t}\n\t\t\t\t\ttarget[name] = t;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn target;\n\t}\n\n\tfunction extend(source){\n\t\tdeclare.safeMixin(this.prototype, source);\n\t\treturn this;\n\t}\n\n\tfunction createSubclass(mixins){\n\t\treturn declare([this].concat(mixins));\n\t}\n\n\t// chained constructor compatible with the legacy declare()\n\tfunction chainedConstructor(bases, ctorSpecial){\n\t\treturn function(){\n\t\t\tvar a = arguments, args = a, a0 = a[0], f, i, m,\n\t\t\t\tl = bases.length, preArgs;\n\n\t\t\tif(!(this instanceof a.callee)){\n\t\t\t\t// not called via new, so force it\n\t\t\t\treturn applyNew(a);\n\t\t\t}\n\n\t\t\t//this._inherited = {};\n\t\t\t// perform the shaman's rituals of the original declare()\n\t\t\t// 1) call two types of the preamble\n\t\t\tif(ctorSpecial && (a0 && a0.preamble || this.preamble)){\n\t\t\t\t// full blown ritual\n\t\t\t\tpreArgs = new Array(bases.length);\n\t\t\t\t// prepare parameters\n\t\t\t\tpreArgs[0] = a;\n\t\t\t\tfor(i = 0;;){\n\t\t\t\t\t// process the preamble of the 1st argument\n\t\t\t\t\ta0 = a[0];\n\t\t\t\t\tif(a0){\n\t\t\t\t\t\tf = a0.preamble;\n\t\t\t\t\t\tif(f){\n\t\t\t\t\t\t\ta = f.apply(this, a) || a;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// process the preamble of this class\n\t\t\t\t\tf = bases[i].prototype;\n\t\t\t\t\tf = f.hasOwnProperty(\"preamble\") && f.preamble;\n\t\t\t\t\tif(f){\n\t\t\t\t\t\ta = f.apply(this, a) || a;\n\t\t\t\t\t}\n\t\t\t\t\t// one peculiarity of the preamble:\n\t\t\t\t\t// it is called if it is not needed,\n\t\t\t\t\t// e.g., there is no constructor to call\n\t\t\t\t\t// let's watch for the last constructor\n\t\t\t\t\t// (see ticket #9795)\n\t\t\t\t\tif(++i == l){\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tpreArgs[i] = a;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 2) call all non-trivial constructors using prepared arguments\n\t\t\tfor(i = l - 1; i >= 0; --i){\n\t\t\t\tf = bases[i];\n\t\t\t\tm = f._meta;\n\t\t\t\tf = m ? m.ctor : f;\n\t\t\t\tif(f){\n\t\t\t\t\tf.apply(this, preArgs ? preArgs[i] : a);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 3) continue the original ritual: call the postscript\n\t\t\tf = this.postscript;\n\t\t\tif(f){\n\t\t\t\tf.apply(this, args);\n\t\t\t}\n\t\t};\n\t}\n\n\n\t// chained constructor compatible with the legacy declare()\n\tfunction singleConstructor(ctor, ctorSpecial){\n\t\treturn function(){\n\t\t\tvar a = arguments, t = a, a0 = a[0], f;\n\n\t\t\tif(!(this instanceof a.callee)){\n\t\t\t\t// not called via new, so force it\n\t\t\t\treturn applyNew(a);\n\t\t\t}\n\n\t\t\t//this._inherited = {};\n\t\t\t// perform the shaman's rituals of the original declare()\n\t\t\t// 1) call two types of the preamble\n\t\t\tif(ctorSpecial){\n\t\t\t\t// full blown ritual\n\t\t\t\tif(a0){\n\t\t\t\t\t// process the preamble of the 1st argument\n\t\t\t\t\tf = a0.preamble;\n\t\t\t\t\tif(f){\n\t\t\t\t\t\tt = f.apply(this, t) || t;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tf = this.preamble;\n\t\t\t\tif(f){\n\t\t\t\t\t// process the preamble of this class\n\t\t\t\t\tf.apply(this, t);\n\t\t\t\t\t// one peculiarity of the preamble:\n\t\t\t\t\t// it is called even if it is not needed,\n\t\t\t\t\t// e.g., there is no constructor to call\n\t\t\t\t\t// let's watch for the last constructor\n\t\t\t\t\t// (see ticket #9795)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 2) call a constructor\n\t\t\tif(ctor){\n\t\t\t\tctor.apply(this, a);\n\t\t\t}\n\t\t\t// 3) continue the original ritual: call the postscript\n\t\t\tf = this.postscript;\n\t\t\tif(f){\n\t\t\t\tf.apply(this, a);\n\t\t\t}\n\t\t};\n\t}\n\n\t// plain vanilla constructor (can use inherited() to call its base constructor)\n\tfunction simpleConstructor(bases){\n\t\treturn function(){\n\t\t\tvar a = arguments, i = 0, f, m;\n\n\t\t\tif(!(this instanceof a.callee)){\n\t\t\t\t// not called via new, so force it\n\t\t\t\treturn applyNew(a);\n\t\t\t}\n\n\t\t\t//this._inherited = {};\n\t\t\t// perform the shaman's rituals of the original declare()\n\t\t\t// 1) do not call the preamble\n\t\t\t// 2) call the top constructor (it can use this.inherited())\n\t\t\tfor(; f = bases[i]; ++i){ // intentional assignment\n\t\t\t\tm = f._meta;\n\t\t\t\tf = m ? m.ctor : f;\n\t\t\t\tif(f){\n\t\t\t\t\tf.apply(this, a);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 3) call the postscript\n\t\t\tf = this.postscript;\n\t\t\tif(f){\n\t\t\t\tf.apply(this, a);\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction chain(name, bases, reversed){\n\t\treturn function(){\n\t\t\tvar b, m, f, i = 0, step = 1;\n\t\t\tif(reversed){\n\t\t\t\ti = bases.length - 1;\n\t\t\t\tstep = -1;\n\t\t\t}\n\t\t\tfor(; b = bases[i]; i += step){ // intentional assignment\n\t\t\t\tm = b._meta;\n\t\t\t\tf = (m ? m.hidden : b.prototype)[name];\n\t\t\t\tif(f){\n\t\t\t\t\tf.apply(this, arguments);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\t// forceNew(ctor)\n\t// return a new object that inherits from ctor.prototype but\n\t// without actually running ctor on the object.\n\tfunction forceNew(ctor){\n\t\t// create object with correct prototype using a do-nothing\n\t\t// constructor\n\t\txtor.prototype = ctor.prototype;\n\t\tvar t = new xtor;\n\t\txtor.prototype = null;\t// clean up\n\t\treturn t;\n\t}\n\n\t// applyNew(args)\n\t// just like 'new ctor()' except that the constructor and its arguments come\n\t// from args, which must be an array or an arguments object\n\tfunction applyNew(args){\n\t\t// create an object with ctor's prototype but without\n\t\t// calling ctor on it.\n\t\tvar ctor = args.callee, t = forceNew(ctor);\n\t\t// execute the real constructor on the new object\n\t\tctor.apply(t, args);\n\t\treturn t;\n\t}\n\n\tfunction declare(className, superclass, props){\n\t\t// summary:\n\t\t//\t\tCreate a feature-rich constructor from compact notation.\n\t\t// className: String?\n\t\t//\t\tThe optional name of the constructor (loosely, a \"class\")\n\t\t//\t\tstored in the \"declaredClass\" property in the created prototype.\n\t\t//\t\tIt will be used as a global name for a created constructor.\n\t\t// superclass: Function|Function[]\n\t\t//\t\tMay be null, a Function, or an Array of Functions. This argument\n\t\t//\t\tspecifies a list of bases (the left-most one is the most deepest\n\t\t//\t\tbase).\n\t\t// props: Object\n\t\t//\t\tAn object whose properties are copied to the created prototype.\n\t\t//\t\tAdd an instance-initialization function by making it a property\n\t\t//\t\tnamed \"constructor\".\n\t\t// returns: dojo/_base/declare.__DeclareCreatedObject\n\t\t//\t\tNew constructor function.\n\t\t// description:\n\t\t//\t\tCreate a constructor using a compact notation for inheritance and\n\t\t//\t\tprototype extension.\n\t\t//\n\t\t//\t\tMixin ancestors provide a type of multiple inheritance.\n\t\t//\t\tPrototypes of mixin ancestors are copied to the new class:\n\t\t//\t\tchanges to mixin prototypes will not affect classes to which\n\t\t//\t\tthey have been mixed in.\n\t\t//\n\t\t//\t\tAncestors can be compound classes created by this version of\n\t\t//\t\tdeclare(). In complex cases all base classes are going to be\n\t\t//\t\tlinearized according to C3 MRO algorithm\n\t\t//\t\t(see http://www.python.org/download/releases/2.3/mro/ for more\n\t\t//\t\tdetails).\n\t\t//\n\t\t//\t\t\"className\" is cached in \"declaredClass\" property of the new class,\n\t\t//\t\tif it was supplied. The immediate super class will be cached in\n\t\t//\t\t\"superclass\" property of the new class.\n\t\t//\n\t\t//\t\tMethods in \"props\" will be copied and modified: \"nom\" property\n\t\t//\t\t(the declared name of the method) will be added to all copied\n\t\t//\t\tfunctions to help identify them for the internal machinery. Be\n\t\t//\t\tvery careful, while reusing methods: if you use the same\n\t\t//\t\tfunction under different names, it can produce errors in some\n\t\t//\t\tcases.\n\t\t//\n\t\t//\t\tIt is possible to use constructors created \"manually\" (without\n\t\t//\t\tdeclare()) as bases. They will be called as usual during the\n\t\t//\t\tcreation of an instance, their methods will be chained, and even\n\t\t//\t\tcalled by \"this.inherited()\".\n\t\t//\n\t\t//\t\tSpecial property \"-chains-\" governs how to chain methods. It is\n\t\t//\t\ta dictionary, which uses method names as keys, and hint strings\n\t\t//\t\tas values. If a hint string is \"after\", this method will be\n\t\t//\t\tcalled after methods of its base classes. If a hint string is\n\t\t//\t\t\"before\", this method will be called before methods of its base\n\t\t//\t\tclasses.\n\t\t//\n\t\t//\t\tIf \"constructor\" is not mentioned in \"-chains-\" property, it will\n\t\t//\t\tbe chained using the legacy mode: using \"after\" chaining,\n\t\t//\t\tcalling preamble() method before each constructor, if available,\n\t\t//\t\tand calling postscript() after all constructors were executed.\n\t\t//\t\tIf the hint is \"after\", it is chained as a regular method, but\n\t\t//\t\tpostscript() will be called after the chain of constructors.\n\t\t//\t\t\"constructor\" cannot be chained \"before\", but it allows\n\t\t//\t\ta special hint string: \"manual\", which means that constructors\n\t\t//\t\tare not going to be chained in any way, and programmer will call\n\t\t//\t\tthem manually using this.inherited(). In the latter case\n\t\t//\t\tpostscript() will be called after the construction.\n\t\t//\n\t\t//\t\tAll chaining hints are \"inherited\" from base classes and\n\t\t//\t\tpotentially can be overridden. Be very careful when overriding\n\t\t//\t\thints! Make sure that all chained methods can work in a proposed\n\t\t//\t\tmanner of chaining.\n\t\t//\n\t\t//\t\tOnce a method was chained, it is impossible to unchain it. The\n\t\t//\t\tonly exception is \"constructor\". You don't need to define a\n\t\t//\t\tmethod in order to supply a chaining hint.\n\t\t//\n\t\t//\t\tIf a method is chained, it cannot use this.inherited() because\n\t\t//\t\tall other methods in the hierarchy will be called automatically.\n\t\t//\n\t\t//\t\tUsually constructors and initializers of any kind are chained\n\t\t//\t\tusing \"after\" and destructors of any kind are chained as\n\t\t//\t\t\"before\". Note that chaining assumes that chained methods do not\n\t\t//\t\treturn any value: any returned value will be discarded.\n\t\t//\n\t\t// example:\n\t\t//\t|\tdeclare(\"my.classes.bar\", my.classes.foo, {\n\t\t//\t|\t\t// properties to be added to the class prototype\n\t\t//\t|\t\tsomeValue: 2,\n\t\t//\t|\t\t// initialization function\n\t\t//\t|\t\tconstructor: function(){\n\t\t//\t|\t\t\tthis.myComplicatedObject = new ReallyComplicatedObject();\n\t\t//\t|\t\t},\n\t\t//\t|\t\t// other functions\n\t\t//\t|\t\tsomeMethod: function(){\n\t\t//\t|\t\t\tdoStuff();\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t|\tvar MyBase = declare(null, {\n\t\t//\t|\t\t// constructor, properties, and methods go here\n\t\t//\t|\t\t// ...\n\t\t//\t|\t});\n\t\t//\t|\tvar MyClass1 = declare(MyBase, {\n\t\t//\t|\t\t// constructor, properties, and methods go here\n\t\t//\t|\t\t// ...\n\t\t//\t|\t});\n\t\t//\t|\tvar MyClass2 = declare(MyBase, {\n\t\t//\t|\t\t// constructor, properties, and methods go here\n\t\t//\t|\t\t// ...\n\t\t//\t|\t});\n\t\t//\t|\tvar MyDiamond = declare([MyClass1, MyClass2], {\n\t\t//\t|\t\t// constructor, properties, and methods go here\n\t\t//\t|\t\t// ...\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t|\tvar F = function(){ console.log(\"raw constructor\"); };\n\t\t//\t|\tF.prototype.method = function(){\n\t\t//\t|\t\tconsole.log(\"raw method\");\n\t\t//\t|\t};\n\t\t//\t|\tvar A = declare(F, {\n\t\t//\t|\t\tconstructor: function(){\n\t\t//\t|\t\t\tconsole.log(\"A.constructor\");\n\t\t//\t|\t\t},\n\t\t//\t|\t\tmethod: function(){\n\t\t//\t|\t\t\tconsole.log(\"before calling F.method...\");\n\t\t//\t|\t\t\tthis.inherited(arguments);\n\t\t//\t|\t\t\tconsole.log(\"...back in A\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tnew A().method();\n\t\t//\t|\t// will print:\n\t\t//\t|\t// raw constructor\n\t\t//\t|\t// A.constructor\n\t\t//\t|\t// before calling F.method...\n\t\t//\t|\t// raw method\n\t\t//\t|\t// ...back in A\n\t\t//\n\t\t// example:\n\t\t//\t|\tvar A = declare(null, {\n\t\t//\t|\t\t\"-chains-\": {\n\t\t//\t|\t\t\tdestroy: \"before\"\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tvar B = declare(A, {\n\t\t//\t|\t\tconstructor: function(){\n\t\t//\t|\t\t\tconsole.log(\"B.constructor\");\n\t\t//\t|\t\t},\n\t\t//\t|\t\tdestroy: function(){\n\t\t//\t|\t\t\tconsole.log(\"B.destroy\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tvar C = declare(B, {\n\t\t//\t|\t\tconstructor: function(){\n\t\t//\t|\t\t\tconsole.log(\"C.constructor\");\n\t\t//\t|\t\t},\n\t\t//\t|\t\tdestroy: function(){\n\t\t//\t|\t\t\tconsole.log(\"C.destroy\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tnew C().destroy();\n\t\t//\t|\t// prints:\n\t\t//\t|\t// B.constructor\n\t\t//\t|\t// C.constructor\n\t\t//\t|\t// C.destroy\n\t\t//\t|\t// B.destroy\n\t\t//\n\t\t// example:\n\t\t//\t|\tvar A = declare(null, {\n\t\t//\t|\t\t\"-chains-\": {\n\t\t//\t|\t\t\tconstructor: \"manual\"\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tvar B = declare(A, {\n\t\t//\t|\t\tconstructor: function(){\n\t\t//\t|\t\t\t// ...\n\t\t//\t|\t\t\t// call the base constructor with new parameters\n\t\t//\t|\t\t\tthis.inherited(arguments, [1, 2, 3]);\n\t\t//\t|\t\t\t// ...\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t|\tvar A = declare(null, {\n\t\t//\t|\t\t\"-chains-\": {\n\t\t//\t|\t\t\tm1: \"before\"\n\t\t//\t|\t\t},\n\t\t//\t|\t\tm1: function(){\n\t\t//\t|\t\t\tconsole.log(\"A.m1\");\n\t\t//\t|\t\t},\n\t\t//\t|\t\tm2: function(){\n\t\t//\t|\t\t\tconsole.log(\"A.m2\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tvar B = declare(A, {\n\t\t//\t|\t\t\"-chains-\": {\n\t\t//\t|\t\t\tm2: \"after\"\n\t\t//\t|\t\t},\n\t\t//\t|\t\tm1: function(){\n\t\t//\t|\t\t\tconsole.log(\"B.m1\");\n\t\t//\t|\t\t},\n\t\t//\t|\t\tm2: function(){\n\t\t//\t|\t\t\tconsole.log(\"B.m2\");\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\t|\tvar x = new B();\n\t\t//\t|\tx.m1();\n\t\t//\t|\t// prints:\n\t\t//\t|\t// B.m1\n\t\t//\t|\t// A.m1\n\t\t//\t|\tx.m2();\n\t\t//\t|\t// prints:\n\t\t//\t|\t// A.m2\n\t\t//\t|\t// B.m2\n\n\t\t// crack parameters\n\t\tif(typeof className != \"string\"){\n\t\t\tprops = superclass;\n\t\t\tsuperclass = className;\n\t\t\tclassName = \"\";\n\t\t}\n\t\tprops = props || {};\n\n\t\tvar proto, i, t, ctor, name, bases, chains, mixins = 1, parents = superclass;\n\n\t\t// build a prototype\n\t\tif(opts.call(superclass) == \"[object Array]\"){\n\t\t\t// C3 MRO\n\t\t\tbases = c3mro(superclass, className);\n\t\t\tt = bases[0];\n\t\t\tmixins = bases.length - t;\n\t\t\tsuperclass = bases[mixins];\n\t\t}else{\n\t\t\tbases = [0];\n\t\t\tif(superclass){\n\t\t\t\tif(opts.call(superclass) == \"[object Function]\"){\n\t\t\t\t\tt = superclass._meta;\n\t\t\t\t\tbases = bases.concat(t ? t.bases : superclass);\n\t\t\t\t}else{\n\t\t\t\t\terr(\"base class is not a callable constructor.\", className);\n\t\t\t\t}\n\t\t\t}else if(superclass !== null){\n\t\t\t\terr(\"unknown base class. Did you use dojo.require to pull it in?\", className);\n\t\t\t}\n\t\t}\n\t\tif(superclass){\n\t\t\tfor(i = mixins - 1;; --i){\n\t\t\t\tproto = forceNew(superclass);\n\t\t\t\tif(!i){\n\t\t\t\t\t// stop if nothing to add (the last base)\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// mix in properties\n\t\t\t\tt = bases[i];\n\t\t\t\t(t._meta ? mixOwn : mix)(proto, t.prototype);\n\t\t\t\t// chain in new constructor\n\t\t\t\tctor = new Function;\n\t\t\t\tctor.superclass = superclass;\n\t\t\t\tctor.prototype = proto;\n\t\t\t\tsuperclass = proto.constructor = ctor;\n\t\t\t}\n\t\t}else{\n\t\t\tproto = {};\n\t\t}\n\t\t// add all properties\n\t\tdeclare.safeMixin(proto, props);\n\t\t// add constructor\n\t\tt = props.constructor;\n\t\tif(t !== op.constructor){\n\t\t\tt.nom = cname;\n\t\t\tproto.constructor = t;\n\t\t}\n\n\t\t// collect chains and flags\n\t\tfor(i = mixins - 1; i; --i){ // intentional assignment\n\t\t\tt = bases[i]._meta;\n\t\t\tif(t && t.chains){\n\t\t\t\tchains = mix(chains || {}, t.chains);\n\t\t\t}\n\t\t}\n\t\tif(proto[\"-chains-\"]){\n\t\t\tchains = mix(chains || {}, proto[\"-chains-\"]);\n\t\t}\n\n\t\t// build ctor\n\t\tt = !chains || !chains.hasOwnProperty(cname);\n\t\tbases[0] = ctor = (chains && chains.constructor === \"manual\") ? simpleConstructor(bases) :\n\t\t\t(bases.length == 1 ? singleConstructor(props.constructor, t) : chainedConstructor(bases, t));\n\n\t\t// add meta information to the constructor\n\t\tctor._meta  = {bases: bases, hidden: props, chains: chains,\n\t\t\tparents: parents, ctor: props.constructor};\n\t\tctor.superclass = superclass && superclass.prototype;\n\t\tctor.extend = extend;\n\t\tctor.createSubclass = createSubclass;\n\t\tctor.prototype = proto;\n\t\tproto.constructor = ctor;\n\n\t\t// add \"standard\" methods to the prototype\n\t\tproto.getInherited = getInherited;\n\t\tproto.isInstanceOf = isInstanceOf;\n\t\tproto.inherited    = inheritedImpl;\n\t\tproto.__inherited  = inherited;\n\n\t\t// add name if specified\n\t\tif(className){\n\t\t\tproto.declaredClass = className;\n\t\t\tlang.setObject(className, ctor);\n\t\t}\n\n\t\t// build chains and add them to the prototype\n\t\tif(chains){\n\t\t\tfor(name in chains){\n\t\t\t\tif(proto[name] && typeof chains[name] == \"string\" && name != cname){\n\t\t\t\t\tt = proto[name] = chain(name, bases, chains[name] === \"after\");\n\t\t\t\t\tt.nom = name;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// chained methods do not return values\n\t\t// no need to chain \"invisible\" functions\n\n\t\treturn ctor;\t// Function\n\t}\n\n\t/*=====\n\tdeclare.__DeclareCreatedObject = {\n\t\t// summary:\n\t\t//\t\tdojo/_base/declare() returns a constructor `C`.   `new C()` returns an Object with the following\n\t\t//\t\tmethods, in addition to the methods and properties specified via the arguments passed to declare().\n\n\t\tinherited: function(name, args, newArgs){\n\t\t\t// summary:\n\t\t\t//\t\tCalls a super method.\n\t\t\t// name: String?\n\t\t\t//\t\tThe optional method name. Should be the same as the caller's\n\t\t\t//\t\tname. Usually \"name\" is specified in complex dynamic cases, when\n\t\t\t//\t\tthe calling method was dynamically added, undecorated by\n\t\t\t//\t\tdeclare(), and it cannot be determined.\n\t\t\t// args: Arguments\n\t\t\t//\t\tThe caller supply this argument, which should be the original\n\t\t\t//\t\t\"arguments\".\n\t\t\t// newArgs: Object?\n\t\t\t//\t\tIf \"true\", the found function will be returned without\n\t\t\t//\t\texecuting it.\n\t\t\t//\t\tIf Array, it will be used to call a super method. Otherwise\n\t\t\t//\t\t\"args\" will be used.\n\t\t\t// returns:\n\t\t\t//\t\tWhatever is returned by a super method, or a super method itself,\n\t\t\t//\t\tif \"true\" was specified as newArgs.\n\t\t\t// description:\n\t\t\t//\t\tThis method is used inside method of classes produced with\n\t\t\t//\t\tdeclare() to call a super method (next in the chain). It is\n\t\t\t//\t\tused for manually controlled chaining. Consider using the regular\n\t\t\t//\t\tchaining, because it is faster. Use \"this.inherited()\" only in\n\t\t\t//\t\tcomplex cases.\n\t\t\t//\n\t\t\t//\t\tThis method cannot me called from automatically chained\n\t\t\t//\t\tconstructors including the case of a special (legacy)\n\t\t\t//\t\tconstructor chaining. It cannot be called from chained methods.\n\t\t\t//\n\t\t\t//\t\tIf \"this.inherited()\" cannot find the next-in-chain method, it\n\t\t\t//\t\tdoes nothing and returns \"undefined\". The last method in chain\n\t\t\t//\t\tcan be a default method implemented in Object, which will be\n\t\t\t//\t\tcalled last.\n\t\t\t//\n\t\t\t//\t\tIf \"name\" is specified, it is assumed that the method that\n\t\t\t//\t\treceived \"args\" is the parent method for this call. It is looked\n\t\t\t//\t\tup in the chain list and if it is found the next-in-chain method\n\t\t\t//\t\tis called. If it is not found, the first-in-chain method is\n\t\t\t//\t\tcalled.\n\t\t\t//\n\t\t\t//\t\tIf \"name\" is not specified, it will be derived from the calling\n\t\t\t//\t\tmethod (using a methoid property \"nom\").\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t|\tvar B = declare(A, {\n\t\t\t//\t|\t\tmethod1: function(a, b, c){\n\t\t\t//\t|\t\t\tthis.inherited(arguments);\n\t\t\t//\t|\t\t},\n\t\t\t//\t|\t\tmethod2: function(a, b){\n\t\t\t//\t|\t\t\treturn this.inherited(arguments, [a + b]);\n\t\t\t//\t|\t\t}\n\t\t\t//\t|\t});\n\t\t\t//\t|\t// next method is not in the chain list because it is added\n\t\t\t//\t|\t// manually after the class was created.\n\t\t\t//\t|\tB.prototype.method3 = function(){\n\t\t\t//\t|\t\tconsole.log(\"This is a dynamically-added method.\");\n\t\t\t//\t|\t\tthis.inherited(\"method3\", arguments);\n\t\t\t//\t|\t};\n\t\t\t// example:\n\t\t\t//\t|\tvar B = declare(A, {\n\t\t\t//\t|\t\tmethod: function(a, b){\n\t\t\t//\t|\t\t\tvar super = this.inherited(arguments, true);\n\t\t\t//\t|\t\t\t// ...\n\t\t\t//\t|\t\t\tif(!super){\n\t\t\t//\t|\t\t\t\tconsole.log(\"there is no super method\");\n\t\t\t//\t|\t\t\t\treturn 0;\n\t\t\t//\t|\t\t\t}\n\t\t\t//\t|\t\t\treturn super.apply(this, arguments);\n\t\t\t//\t|\t\t}\n\t\t\t//\t|\t});\n\t\t\treturn\t{};\t// Object\n\t\t},\n\n\t\tgetInherited: function(name, args){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a super method.\n\t\t\t// name: String?\n\t\t\t//\t\tThe optional method name. Should be the same as the caller's\n\t\t\t//\t\tname. Usually \"name\" is specified in complex dynamic cases, when\n\t\t\t//\t\tthe calling method was dynamically added, undecorated by\n\t\t\t//\t\tdeclare(), and it cannot be determined.\n\t\t\t// args: Arguments\n\t\t\t//\t\tThe caller supply this argument, which should be the original\n\t\t\t//\t\t\"arguments\".\n\t\t\t// returns:\n\t\t\t//\t\tReturns a super method (Function) or \"undefined\".\n\t\t\t// description:\n\t\t\t//\t\tThis method is a convenience method for \"this.inherited()\".\n\t\t\t//\t\tIt uses the same algorithm but instead of executing a super\n\t\t\t//\t\tmethod, it returns it, or \"undefined\" if not found.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t|\tvar B = declare(A, {\n\t\t\t//\t|\t\tmethod: function(a, b){\n\t\t\t//\t|\t\t\tvar super = this.getInherited(arguments);\n\t\t\t//\t|\t\t\t// ...\n\t\t\t//\t|\t\t\tif(!super){\n\t\t\t//\t|\t\t\t\tconsole.log(\"there is no super method\");\n\t\t\t//\t|\t\t\t\treturn 0;\n\t\t\t//\t|\t\t\t}\n\t\t\t//\t|\t\t\treturn super.apply(this, arguments);\n\t\t\t//\t|\t\t}\n\t\t\t//\t|\t});\n\t\t\treturn\t{};\t// Object\n\t\t},\n\n\t\tisInstanceOf: function(cls){\n\t\t\t// summary:\n\t\t\t//\t\tChecks the inheritance chain to see if it is inherited from this\n\t\t\t//\t\tclass.\n\t\t\t// cls: Function\n\t\t\t//\t\tClass constructor.\n\t\t\t// returns:\n\t\t\t//\t\t\"true\", if this object is inherited from this class, \"false\"\n\t\t\t//\t\totherwise.\n\t\t\t// description:\n\t\t\t//\t\tThis method is used with instances of classes produced with\n\t\t\t//\t\tdeclare() to determine of they support a certain interface or\n\t\t\t//\t\tnot. It models \"instanceof\" operator.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t|\tvar A = declare(null, {\n\t\t\t//\t|\t\t// constructor, properties, and methods go here\n\t\t\t//\t|\t\t// ...\n\t\t\t//\t|\t});\n\t\t\t//\t|\tvar B = declare(null, {\n\t\t\t//\t|\t\t// constructor, properties, and methods go here\n\t\t\t//\t|\t\t// ...\n\t\t\t//\t|\t});\n\t\t\t//\t|\tvar C = declare([A, B], {\n\t\t\t//\t|\t\t// constructor, properties, and methods go here\n\t\t\t//\t|\t\t// ...\n\t\t\t//\t|\t});\n\t\t\t//\t|\tvar D = declare(A, {\n\t\t\t//\t|\t\t// constructor, properties, and methods go here\n\t\t\t//\t|\t\t// ...\n\t\t\t//\t|\t});\n\t\t\t//\t|\n\t\t\t//\t|\tvar a = new A(), b = new B(), c = new C(), d = new D();\n\t\t\t//\t|\n\t\t\t//\t|\tconsole.log(a.isInstanceOf(A)); // true\n\t\t\t//\t|\tconsole.log(b.isInstanceOf(A)); // false\n\t\t\t//\t|\tconsole.log(c.isInstanceOf(A)); // true\n\t\t\t//\t|\tconsole.log(d.isInstanceOf(A)); // true\n\t\t\t//\t|\n\t\t\t//\t|\tconsole.log(a.isInstanceOf(B)); // false\n\t\t\t//\t|\tconsole.log(b.isInstanceOf(B)); // true\n\t\t\t//\t|\tconsole.log(c.isInstanceOf(B)); // true\n\t\t\t//\t|\tconsole.log(d.isInstanceOf(B)); // false\n\t\t\t//\t|\n\t\t\t//\t|\tconsole.log(a.isInstanceOf(C)); // false\n\t\t\t//\t|\tconsole.log(b.isInstanceOf(C)); // false\n\t\t\t//\t|\tconsole.log(c.isInstanceOf(C)); // true\n\t\t\t//\t|\tconsole.log(d.isInstanceOf(C)); // false\n\t\t\t//\t|\n\t\t\t//\t|\tconsole.log(a.isInstanceOf(D)); // false\n\t\t\t//\t|\tconsole.log(b.isInstanceOf(D)); // false\n\t\t\t//\t|\tconsole.log(c.isInstanceOf(D)); // false\n\t\t\t//\t|\tconsole.log(d.isInstanceOf(D)); // true\n\t\t\treturn\t{};\t// Object\n\t\t},\n\n\t\textend: function(source){\n\t\t\t// summary:\n\t\t\t//\t\tAdds all properties and methods of source to constructor's\n\t\t\t//\t\tprototype, making them available to all instances created with\n\t\t\t//\t\tconstructor. This method is specific to constructors created with\n\t\t\t//\t\tdeclare().\n\t\t\t// source: Object\n\t\t\t//\t\tSource object which properties are going to be copied to the\n\t\t\t//\t\tconstructor's prototype.\n\t\t\t// description:\n\t\t\t//\t\tAdds source properties to the constructor's prototype. It can\n\t\t\t//\t\toverride existing properties.\n\t\t\t//\n\t\t\t//\t\tThis method is similar to dojo.extend function, but it is specific\n\t\t\t//\t\tto constructors produced by declare(). It is implemented\n\t\t\t//\t\tusing dojo.safeMixin, and it skips a constructor property,\n\t\t\t//\t\tand properly decorates copied functions.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t|\tvar A = declare(null, {\n\t\t\t//\t|\t\tm1: function(){},\n\t\t\t//\t|\t\ts1: \"Popokatepetl\"\n\t\t\t//\t|\t});\n\t\t\t//\t|\tA.extend({\n\t\t\t//\t|\t\tm1: function(){},\n\t\t\t//\t|\t\tm2: function(){},\n\t\t\t//\t|\t\tf1: true,\n\t\t\t//\t|\t\td1: 42\n\t\t\t//\t|\t});\n\t\t}\n\t};\n\t=====*/\n\n\t// For back-compat, remove for 2.0\n\tdojo.safeMixin = declare.safeMixin = safeMixin;\n\tdojo.declare = declare;\n\n\treturn declare;\n});\n\n},\n'dojo/dom':function(){\ndefine([\"./sniff\", \"./_base/lang\", \"./_base/window\"],\n\t\tfunction(has, lang, win){\n\t// module:\n\t//\t\tdojo/dom\n\n\t// FIXME: need to add unit tests for all the semi-public methods\n\n\tif(has(\"ie\") <= 7){\n\t\ttry{\n\t\t\tdocument.execCommand(\"BackgroundImageCache\", false, true);\n\t\t}catch(e){\n\t\t\t// sane browsers don't have cache \"issues\"\n\t\t}\n\t}\n\n\t// =============================\n\t// DOM Functions\n\t// =============================\n\n\t// the result object\n\tvar dom = {\n\t\t// summary:\n\t\t//\t\tThis module defines the core dojo DOM API.\n\t};\n\n\tif(has(\"ie\")){\n\t\tdom.byId = function(id, doc){\n\t\t\tif(typeof id != \"string\"){\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\tvar _d = doc || win.doc, te = id && _d.getElementById(id);\n\t\t\t// attributes.id.value is better than just id in case the\n\t\t\t// user has a name=id inside a form\n\t\t\tif(te && (te.attributes.id.value == id || te.id == id)){\n\t\t\t\treturn te;\n\t\t\t}else{\n\t\t\t\tvar eles = _d.all[id];\n\t\t\t\tif(!eles || eles.nodeName){\n\t\t\t\t\teles = [eles];\n\t\t\t\t}\n\t\t\t\t// if more than 1, choose first with the correct id\n\t\t\t\tvar i = 0;\n\t\t\t\twhile((te = eles[i++])){\n\t\t\t\t\tif((te.attributes && te.attributes.id && te.attributes.id.value == id) || te.id == id){\n\t\t\t\t\t\treturn te;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}else{\n\t\tdom.byId = function(id, doc){\n\t\t\t// inline'd type check.\n\t\t\t// be sure to return null per documentation, to match IE branch.\n\t\t\treturn ((typeof id == \"string\") ? (doc || win.doc).getElementById(id) : id) || null; // DOMNode\n\t\t};\n\t}\n\t/*=====\n\t dom.byId = function(id, doc){\n\t\t // summary:\n\t\t //\t\tReturns DOM node with matching `id` attribute or falsy value (ex: null or undefined)\n\t\t //\t\tif not found.  If `id` is a DomNode, this function is a no-op.\n\t\t //\n\t\t // id: String|DOMNode\n\t\t //\t\tA string to match an HTML id attribute or a reference to a DOM Node\n\t\t //\n\t\t // doc: Document?\n\t\t //\t\tDocument to work in. Defaults to the current value of\n\t\t //\t\tdojo.doc.  Can be used to retrieve\n\t\t //\t\tnode references from other documents.\n\t\t //\n\t\t // example:\n\t\t //\t\tLook up a node by ID:\n\t\t //\t|\tvar n = dojo.byId(\"foo\");\n\t\t //\n\t\t // example:\n\t\t //\t\tCheck if a node exists, and use it.\n\t\t //\t|\tvar n = dojo.byId(\"bar\");\n\t\t //\t|\tif(n){ doStuff() ... }\n\t\t //\n\t\t // example:\n\t\t //\t\tAllow string or DomNode references to be passed to a custom function:\n\t\t //\t|\tvar foo = function(nodeOrId){\n\t\t //\t|\t\tnodeOrId = dojo.byId(nodeOrId);\n\t\t //\t|\t\t// ... more stuff\n\t\t //\t|\t}\n\t };\n\t =====*/\n\n\tdom.isDescendant = function(/*DOMNode|String*/ node, /*DOMNode|String*/ ancestor){\n\t\t// summary:\n\t\t//\t\tReturns true if node is a descendant of ancestor\n\t\t// node: DOMNode|String\n\t\t//\t\tstring id or node reference to test\n\t\t// ancestor: DOMNode|String\n\t\t//\t\tstring id or node reference of potential parent to test against\n\t\t//\n\t\t// example:\n\t\t//\t\tTest is node id=\"bar\" is a descendant of node id=\"foo\"\n\t\t//\t|\tif(dojo.isDescendant(\"bar\", \"foo\")){ ... }\n\n\t\ttry{\n\t\t\tnode = dom.byId(node);\n\t\t\tancestor = dom.byId(ancestor);\n\t\t\twhile(node){\n\t\t\t\tif(node == ancestor){\n\t\t\t\t\treturn true; // Boolean\n\t\t\t\t}\n\t\t\t\tnode = node.parentNode;\n\t\t\t}\n\t\t}catch(e){ /* squelch, return false */ }\n\t\treturn false; // Boolean\n\t};\n\n\n\t\t\t// TODO: do we need this function in the base?\n\n\tdom.setSelectable = function(/*DOMNode|String*/ node, /*Boolean*/ selectable){\n\t\t// summary:\n\t\t//\t\tEnable or disable selection on a node\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to node\n\t\t// selectable: Boolean\n\t\t//\t\tstate to put the node in. false indicates unselectable, true\n\t\t//\t\tallows selection.\n\t\t// example:\n\t\t//\t\tMake the node id=\"bar\" unselectable\n\t\t//\t|\tdojo.setSelectable(\"bar\");\n\t\t// example:\n\t\t//\t\tMake the node id=\"bar\" selectable\n\t\t//\t|\tdojo.setSelectable(\"bar\", true);\n\n\t\tnode = dom.byId(node);\n\t\tif(has(\"mozilla\")){\n\t\t\tnode.style.MozUserSelect = selectable ? \"\" : \"none\";\n\t\t}else if(has(\"khtml\") || has(\"webkit\")){\n\t\t\tnode.style.KhtmlUserSelect = selectable ? \"auto\" : \"none\";\n\t\t}else if(has(\"ie\")){\n\t\t\tvar v = (node.unselectable = selectable ? \"\" : \"on\"),\n\t\t\t\tcs = node.getElementsByTagName(\"*\"), i = 0, l = cs.length;\n\t\t\tfor(; i < l; ++i){\n\t\t\t\tcs.item(i).unselectable = v;\n\t\t\t}\n\t\t}\n\t\t//FIXME: else?  Opera?\n\t};\n\n\treturn dom;\n});\n\n},\n'dojo/_base/browser':function(){\nif(require.has){\n\trequire.has.add(\"config-selectorEngine\", \"acme\");\n}\ndefine([\n\t\"../ready\",\n\t\"./kernel\",\n\t\"./connect\", // until we decide if connect is going back into non-browser environments\n\t\"./unload\",\n\t\"./window\",\n\t\"./event\",\n\t\"./html\",\n\t\"./NodeList\",\n\t\"../query\",\n\t\"./xhr\",\n\t\"./fx\"], function(dojo){\n\n\t// module:\n\t//\t\tdojo/_base/browser\n\n\t/*=====\n\treturn {\n\t\t// summary:\n\t\t//\t\tThis module causes the browser-only base modules to be loaded.\n\t};\n\t=====*/\n\n\treturn dojo;\n});\n\n},\n'dojo/selector/acme':function(){\ndefine([\n\t\"../dom\", \"../sniff\", \"../_base/array\", \"../_base/lang\", \"../_base/window\"\n], function(dom, has, array, lang, win){\n\n\t// module:\n\t//\t\tdojo/selector/acme\n\n/*\n\tacme architectural overview:\n\n\t\tacme is a relatively full-featured CSS3 query library. It is\n\t\tdesigned to take any valid CSS3 selector and return the nodes matching\n\t\tthe selector. To do this quickly, it processes queries in several\n\t\tsteps, applying caching where profitable.\n\n\t\tThe steps (roughly in reverse order of the way they appear in the code):\n\t\t\t1.) check to see if we already have a \"query dispatcher\"\n\t\t\t\t- if so, use that with the given parameterization. Skip to step 4.\n\t\t\t2.) attempt to determine which branch to dispatch the query to:\n\t\t\t\t- JS (optimized DOM iteration)\n\t\t\t\t- native (FF3.1+, Safari 3.1+, IE 8+)\n\t\t\t3.) tokenize and convert to executable \"query dispatcher\"\n\t\t\t\t- this is where the lion's share of the complexity in the\n\t\t\t\t\tsystem lies. In the DOM version, the query dispatcher is\n\t\t\t\t\tassembled as a chain of \"yes/no\" test functions pertaining to\n\t\t\t\t\ta section of a simple query statement (\".blah:nth-child(odd)\"\n\t\t\t\t\tbut not \"div div\", which is 2 simple statements). Individual\n\t\t\t\t\tstatement dispatchers are cached (to prevent re-definition)\n\t\t\t\t\tas are entire dispatch chains (to make re-execution of the\n\t\t\t\t\tsame query fast)\n\t\t\t4.) the resulting query dispatcher is called in the passed scope\n\t\t\t\t\t(by default the top-level document)\n\t\t\t\t- for DOM queries, this results in a recursive, top-down\n\t\t\t\t\tevaluation of nodes based on each simple query section\n\t\t\t\t- for native implementations, this may mean working around spec\n\t\t\t\t\tbugs. So be it.\n\t\t\t5.) matched nodes are pruned to ensure they are unique (if necessary)\n*/\n\n\n\t////////////////////////////////////////////////////////////////////////\n\t// Toolkit aliases\n\t////////////////////////////////////////////////////////////////////////\n\n\t// if you are extracting acme for use in your own system, you will\n\t// need to provide these methods and properties. No other porting should be\n\t// necessary, save for configuring the system to use a class other than\n\t// dojo/NodeList as the return instance instantiator\n\tvar trim = \t\t\tlang.trim;\n\tvar each = \t\t\tarray.forEach;\n\n\tvar getDoc = function(){ return win.doc; };\n\t// NOTE(alex): the spec is idiotic. CSS queries should ALWAYS be case-sensitive, but nooooooo\n\tvar cssCaseBug = (getDoc().compatMode) == \"BackCompat\";\n\n\t////////////////////////////////////////////////////////////////////////\n\t// Global utilities\n\t////////////////////////////////////////////////////////////////////////\n\n\n\tvar specials = \">~+\";\n\n\t// global thunk to determine whether we should treat the current query as\n\t// case sensitive or not. This switch is flipped by the query evaluator\n\t// based on the document passed as the context to search.\n\tvar caseSensitive = false;\n\n\t// how high?\n\tvar yesman = function(){ return true; };\n\n\t////////////////////////////////////////////////////////////////////////\n\t// Tokenizer\n\t////////////////////////////////////////////////////////////////////////\n\n\tvar getQueryParts = function(query){\n\t\t// summary:\n\t\t//\t\tstate machine for query tokenization\n\t\t// description:\n\t\t//\t\tinstead of using a brittle and slow regex-based CSS parser,\n\t\t//\t\tacme implements an AST-style query representation. This\n\t\t//\t\trepresentation is only generated once per query. For example,\n\t\t//\t\tthe same query run multiple times or under different root nodes\n\t\t//\t\tdoes not re-parse the selector expression but instead uses the\n\t\t//\t\tcached data structure. The state machine implemented here\n\t\t//\t\tterminates on the last \" \" (space) character and returns an\n\t\t//\t\tordered array of query component structures (or \"parts\"). Each\n\t\t//\t\tpart represents an operator or a simple CSS filtering\n\t\t//\t\texpression. The structure for parts is documented in the code\n\t\t//\t\tbelow.\n\n\n\t\t// NOTE:\n\t\t//\t\tthis code is designed to run fast and compress well. Sacrifices\n\t\t//\t\tto readability and maintainability have been made.  Your best\n\t\t//\t\tbet when hacking the tokenizer is to put The Donnas on *really*\n\t\t//\t\tloud (may we recommend their \"Spend The Night\" release?) and\n\t\t//\t\tjust assume you're gonna make mistakes. Keep the unit tests\n\t\t//\t\topen and run them frequently. Knowing is half the battle ;-)\n\t\tif(specials.indexOf(query.slice(-1)) >= 0){\n\t\t\t// if we end with a \">\", \"+\", or \"~\", that means we're implicitly\n\t\t\t// searching all children, so make it explicit\n\t\t\tquery += \" * \";\n\t\t}else{\n\t\t\t// if you have not provided a terminator, one will be provided for\n\t\t\t// you...\n\t\t\tquery += \" \";\n\t\t}\n\n\t\tvar ts = function(/*Integer*/ s, /*Integer*/ e){\n\t\t\t// trim and slice.\n\n\t\t\t// take an index to start a string slice from and an end position\n\t\t\t// and return a trimmed copy of that sub-string\n\t\t\treturn trim(query.slice(s, e));\n\t\t};\n\n\t\t// the overall data graph of the full query, as represented by queryPart objects\n\t\tvar queryParts = [];\n\n\n\t\t// state keeping vars\n\t\tvar inBrackets = -1, inParens = -1, inMatchFor = -1,\n\t\t\tinPseudo = -1, inClass = -1, inId = -1, inTag = -1, currentQuoteChar,\n\t\t\tlc = \"\", cc = \"\", pStart;\n\n\t\t// iteration vars\n\t\tvar x = 0, // index in the query\n\t\t\tql = query.length,\n\t\t\tcurrentPart = null, // data structure representing the entire clause\n\t\t\t_cp = null; // the current pseudo or attr matcher\n\n\t\t// several temporary variables are assigned to this structure during a\n\t\t// potential sub-expression match:\n\t\t//\t\tattr:\n\t\t//\t\t\ta string representing the current full attribute match in a\n\t\t//\t\t\tbracket expression\n\t\t//\t\ttype:\n\t\t//\t\t\tif there's an operator in a bracket expression, this is\n\t\t//\t\t\tused to keep track of it\n\t\t//\t\tvalue:\n\t\t//\t\t\tthe internals of parenthetical expression for a pseudo. for\n\t\t//\t\t\t:nth-child(2n+1), value might be \"2n+1\"\n\n\t\tvar endTag = function(){\n\t\t\t// called when the tokenizer hits the end of a particular tag name.\n\t\t\t// Re-sets state variables for tag matching and sets up the matcher\n\t\t\t// to handle the next type of token (tag or operator).\n\t\t\tif(inTag >= 0){\n\t\t\t\tvar tv = (inTag == x) ? null : ts(inTag, x); // .toLowerCase();\n\t\t\t\tcurrentPart[ (specials.indexOf(tv) < 0) ? \"tag\" : \"oper\" ] = tv;\n\t\t\t\tinTag = -1;\n\t\t\t}\n\t\t};\n\n\t\tvar endId = function(){\n\t\t\t// called when the tokenizer might be at the end of an ID portion of a match\n\t\t\tif(inId >= 0){\n\t\t\t\tcurrentPart.id = ts(inId, x).replace(/\\\\/g, \"\");\n\t\t\t\tinId = -1;\n\t\t\t}\n\t\t};\n\n\t\tvar endClass = function(){\n\t\t\t// called when the tokenizer might be at the end of a class name\n\t\t\t// match. CSS allows for multiple classes, so we augment the\n\t\t\t// current item with another class in its list\n\t\t\tif(inClass >= 0){\n\t\t\t\tcurrentPart.classes.push(ts(inClass + 1, x).replace(/\\\\/g, \"\"));\n\t\t\t\tinClass = -1;\n\t\t\t}\n\t\t};\n\n\t\tvar endAll = function(){\n\t\t\t// at the end of a simple fragment, so wall off the matches\n\t\t\tendId();\n\t\t\tendTag();\n\t\t\tendClass();\n\t\t};\n\n\t\tvar endPart = function(){\n\t\t\tendAll();\n\t\t\tif(inPseudo >= 0){\n\t\t\t\tcurrentPart.pseudos.push({ name: ts(inPseudo + 1, x) });\n\t\t\t}\n\t\t\t// hint to the selector engine to tell it whether or not it\n\t\t\t// needs to do any iteration. Many simple selectors don't, and\n\t\t\t// we can avoid significant construction-time work by advising\n\t\t\t// the system to skip them\n\t\t\tcurrentPart.loops = (\n\t\t\t\t\tcurrentPart.pseudos.length ||\n\t\t\t\t\tcurrentPart.attrs.length ||\n\t\t\t\t\tcurrentPart.classes.length\t);\n\n\t\t\tcurrentPart.oquery = currentPart.query = ts(pStart, x); // save the full expression as a string\n\n\n\t\t\t// otag/tag are hints to suggest to the system whether or not\n\t\t\t// it's an operator or a tag. We save a copy of otag since the\n\t\t\t// tag name is cast to upper-case in regular HTML matches. The\n\t\t\t// system has a global switch to figure out if the current\n\t\t\t// expression needs to be case sensitive or not and it will use\n\t\t\t// otag or tag accordingly\n\t\t\tcurrentPart.otag = currentPart.tag = (currentPart[\"oper\"]) ? null : (currentPart.tag || \"*\");\n\n\t\t\tif(currentPart.tag){\n\t\t\t\t// if we're in a case-insensitive HTML doc, we likely want\n\t\t\t\t// the toUpperCase when matching on element.tagName. If we\n\t\t\t\t// do it here, we can skip the string op per node\n\t\t\t\t// comparison\n\t\t\t\tcurrentPart.tag = currentPart.tag.toUpperCase();\n\t\t\t}\n\n\t\t\t// add the part to the list\n\t\t\tif(queryParts.length && (queryParts[queryParts.length-1].oper)){\n\t\t\t\t// operators are always infix, so we remove them from the\n\t\t\t\t// list and attach them to the next match. The evaluator is\n\t\t\t\t// responsible for sorting out how to handle them.\n\t\t\t\tcurrentPart.infixOper = queryParts.pop();\n\t\t\t\tcurrentPart.query = currentPart.infixOper.query + \" \" + currentPart.query;\n\t\t\t\t/*\n\t\t\t\tconsole.debug(\t\"swapping out the infix\",\n\t\t\t\t\t\t\t\tcurrentPart.infixOper,\n\t\t\t\t\t\t\t\t\"and attaching it to\",\n\t\t\t\t\t\t\t\tcurrentPart);\n\t\t\t\t*/\n\t\t\t}\n\t\t\tqueryParts.push(currentPart);\n\n\t\t\tcurrentPart = null;\n\t\t};\n\n\t\t// iterate over the query, character by character, building up a\n\t\t// list of query part objects\n\t\tfor(; lc=cc, cc=query.charAt(x), x < ql; x++){\n\t\t\t//\t\tcc: the current character in the match\n\t\t\t//\t\tlc: the last character (if any)\n\n\t\t\t// someone is trying to escape something, so don't try to match any\n\t\t\t// fragments. We assume we're inside a literal.\n\t\t\tif(lc == \"\\\\\"){ continue; }\n\t\t\tif(!currentPart){ // a part was just ended or none has yet been created\n\t\t\t\t// NOTE: I hate all this alloc, but it's shorter than writing tons of if's\n\t\t\t\tpStart = x;\n\t\t\t\t//\trules describe full CSS sub-expressions, like:\n\t\t\t\t//\t\t#someId\n\t\t\t\t//\t\t.className:first-child\n\t\t\t\t//\tbut not:\n\t\t\t\t//\t\tthinger > div.howdy[type=thinger]\n\t\t\t\t//\tthe indidual components of the previous query would be\n\t\t\t\t//\tsplit into 3 parts that would be represented a structure like:\n\t\t\t\t//\t\t[\n\t\t\t\t//\t\t\t{\n\t\t\t\t//\t\t\t\tquery: \"thinger\",\n\t\t\t\t//\t\t\t\ttag: \"thinger\",\n\t\t\t\t//\t\t\t},\n\t\t\t\t//\t\t\t{\n\t\t\t\t//\t\t\t\tquery: \"div.howdy[type=thinger]\",\n\t\t\t\t//\t\t\t\tclasses: [\"howdy\"],\n\t\t\t\t//\t\t\t\tinfixOper: {\n\t\t\t\t//\t\t\t\t\tquery: \">\",\n\t\t\t\t//\t\t\t\t\toper: \">\",\n\t\t\t\t//\t\t\t\t}\n\t\t\t\t//\t\t\t},\n\t\t\t\t//\t\t]\n\t\t\t\tcurrentPart = {\n\t\t\t\t\tquery: null, // the full text of the part's rule\n\t\t\t\t\tpseudos: [], // CSS supports multiple pseud-class matches in a single rule\n\t\t\t\t\tattrs: [],\t// CSS supports multi-attribute match, so we need an array\n\t\t\t\t\tclasses: [], // class matches may be additive, e.g.: .thinger.blah.howdy\n\t\t\t\t\ttag: null,\t// only one tag...\n\t\t\t\t\toper: null, // ...or operator per component. Note that these wind up being exclusive.\n\t\t\t\t\tid: null,\t// the id component of a rule\n\t\t\t\t\tgetTag: function(){\n\t\t\t\t\t\treturn caseSensitive ? this.otag : this.tag;\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t// if we don't have a part, we assume we're going to start at\n\t\t\t\t// the beginning of a match, which should be a tag name. This\n\t\t\t\t// might fault a little later on, but we detect that and this\n\t\t\t\t// iteration will still be fine.\n\t\t\t\tinTag = x;\n\t\t\t}\n\n\t\t\t// Skip processing all quoted characters.\n\t\t\t// If we are inside quoted text then currentQuoteChar stores the character that began the quote,\n\t\t\t// thus that character that will end it.\n\t\t\tif(currentQuoteChar){\n\t\t\t\tif(cc == currentQuoteChar){\n\t\t\t\t\tcurrentQuoteChar = null;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}else if (cc == \"'\" || cc == '\"'){\n\t\t\t\tcurrentQuoteChar = cc;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif(inBrackets >= 0){\n\t\t\t\t// look for a the close first\n\t\t\t\tif(cc == \"]\"){ // if we're in a [...] clause and we end, do assignment\n\t\t\t\t\tif(!_cp.attr){\n\t\t\t\t\t\t// no attribute match was previously begun, so we\n\t\t\t\t\t\t// assume this is an attribute existence match in the\n\t\t\t\t\t\t// form of [someAttributeName]\n\t\t\t\t\t\t_cp.attr = ts(inBrackets+1, x);\n\t\t\t\t\t}else{\n\t\t\t\t\t\t// we had an attribute already, so we know that we're\n\t\t\t\t\t\t// matching some sort of value, as in [attrName=howdy]\n\t\t\t\t\t\t_cp.matchFor = ts((inMatchFor||inBrackets+1), x);\n\t\t\t\t\t}\n\t\t\t\t\tvar cmf = _cp.matchFor;\n\t\t\t\t\tif(cmf){\n\t\t\t\t\t\t// try to strip quotes from the matchFor value. We want\n\t\t\t\t\t\t// [attrName=howdy] to match the same\n\t\t\t\t\t\t//\tas [attrName = 'howdy' ]\n\t\t\t\t\t\tif(\t(cmf.charAt(0) == '\"') || (cmf.charAt(0) == \"'\") ){\n\t\t\t\t\t\t\t_cp.matchFor = cmf.slice(1, -1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// remove backslash escapes from an attribute match, since DOM\n\t\t\t\t\t// querying will get attribute values without backslashes\n\t\t\t\t\tif(_cp.matchFor){\n\t\t\t\t\t\t_cp.matchFor = _cp.matchFor.replace(/\\\\/g, \"\");\n\t\t\t\t\t}\n\n\t\t\t\t\t// end the attribute by adding it to the list of attributes.\n\t\t\t\t\tcurrentPart.attrs.push(_cp);\n\t\t\t\t\t_cp = null; // necessary?\n\t\t\t\t\tinBrackets = inMatchFor = -1;\n\t\t\t\t}else if(cc == \"=\"){\n\t\t\t\t\t// if the last char was an operator prefix, make sure we\n\t\t\t\t\t// record it along with the \"=\" operator.\n\t\t\t\t\tvar addToCc = (\"|~^$*\".indexOf(lc) >=0 ) ? lc : \"\";\n\t\t\t\t\t_cp.type = addToCc+cc;\n\t\t\t\t\t_cp.attr = ts(inBrackets+1, x-addToCc.length);\n\t\t\t\t\tinMatchFor = x+1;\n\t\t\t\t}\n\t\t\t\t// now look for other clause parts\n\t\t\t}else if(inParens >= 0){\n\t\t\t\t// if we're in a parenthetical expression, we need to figure\n\t\t\t\t// out if it's attached to a pseudo-selector rule like\n\t\t\t\t// :nth-child(1)\n\t\t\t\tif(cc == \")\"){\n\t\t\t\t\tif(inPseudo >= 0){\n\t\t\t\t\t\t_cp.value = ts(inParens+1, x);\n\t\t\t\t\t}\n\t\t\t\t\tinPseudo = inParens = -1;\n\t\t\t\t}\n\t\t\t}else if(cc == \"#\"){\n\t\t\t\t// start of an ID match\n\t\t\t\tendAll();\n\t\t\t\tinId = x+1;\n\t\t\t}else if(cc == \".\"){\n\t\t\t\t// start of a class match\n\t\t\t\tendAll();\n\t\t\t\tinClass = x;\n\t\t\t}else if(cc == \":\"){\n\t\t\t\t// start of a pseudo-selector match\n\t\t\t\tendAll();\n\t\t\t\tinPseudo = x;\n\t\t\t}else if(cc == \"[\"){\n\t\t\t\t// start of an attribute match.\n\t\t\t\tendAll();\n\t\t\t\tinBrackets = x;\n\t\t\t\t// provide a new structure for the attribute match to fill-in\n\t\t\t\t_cp = {\n\t\t\t\t\t/*=====\n\t\t\t\t\tattr: null, type: null, matchFor: null\n\t\t\t\t\t=====*/\n\t\t\t\t};\n\t\t\t}else if(cc == \"(\"){\n\t\t\t\t// we really only care if we've entered a parenthetical\n\t\t\t\t// expression if we're already inside a pseudo-selector match\n\t\t\t\tif(inPseudo >= 0){\n\t\t\t\t\t// provide a new structure for the pseudo match to fill-in\n\t\t\t\t\t_cp = {\n\t\t\t\t\t\tname: ts(inPseudo+1, x),\n\t\t\t\t\t\tvalue: null\n\t\t\t\t\t};\n\t\t\t\t\tcurrentPart.pseudos.push(_cp);\n\t\t\t\t}\n\t\t\t\tinParens = x;\n\t\t\t}else if(\n\t\t\t\t(cc == \" \") &&\n\t\t\t\t// if it's a space char and the last char is too, consume the\n\t\t\t\t// current one without doing more work\n\t\t\t\t(lc != cc)\n\t\t\t){\n\t\t\t\tendPart();\n\t\t\t}\n\t\t}\n\t\treturn queryParts;\n\t};\n\n\n\t////////////////////////////////////////////////////////////////////////\n\t// DOM query infrastructure\n\t////////////////////////////////////////////////////////////////////////\n\n\tvar agree = function(first, second){\n\t\t// the basic building block of the yes/no chaining system. agree(f1,\n\t\t// f2) generates a new function which returns the boolean results of\n\t\t// both of the passed functions to a single logical-anded result. If\n\t\t// either are not passed, the other is used exclusively.\n\t\tif(!first){ return second; }\n\t\tif(!second){ return first; }\n\n\t\treturn function(){\n\t\t\treturn first.apply(window, arguments) && second.apply(window, arguments);\n\t\t};\n\t};\n\n\tvar getArr = function(i, arr){\n\t\t// helps us avoid array alloc when we don't need it\n\t\tvar r = arr||[]; // FIXME: should this be 'new d._NodeListCtor()' ?\n\t\tif(i){ r.push(i); }\n\t\treturn r;\n\t};\n\n\tvar _isElement = function(n){ return (1 == n.nodeType); };\n\n\t// FIXME: need to coalesce _getAttr with defaultGetter\n\tvar blank = \"\";\n\tvar _getAttr = function(elem, attr){\n\t\tif(!elem){ return blank; }\n\t\tif(attr == \"class\"){\n\t\t\treturn elem.className || blank;\n\t\t}\n\t\tif(attr == \"for\"){\n\t\t\treturn elem.htmlFor || blank;\n\t\t}\n\t\tif(attr == \"style\"){\n\t\t\treturn elem.style.cssText || blank;\n\t\t}\n\t\treturn (caseSensitive ? elem.getAttribute(attr) : elem.getAttribute(attr, 2)) || blank;\n\t};\n\n\tvar attrs = {\n\t\t\"*=\": function(attr, value){\n\t\t\treturn function(elem){\n\t\t\t\t// E[foo*=\"bar\"]\n\t\t\t\t//\t\tan E element whose \"foo\" attribute value contains\n\t\t\t\t//\t\tthe substring \"bar\"\n\t\t\t\treturn (_getAttr(elem, attr).indexOf(value)>=0);\n\t\t\t};\n\t\t},\n\t\t\"^=\": function(attr, value){\n\t\t\t// E[foo^=\"bar\"]\n\t\t\t//\t\tan E element whose \"foo\" attribute value begins exactly\n\t\t\t//\t\twith the string \"bar\"\n\t\t\treturn function(elem){\n\t\t\t\treturn (_getAttr(elem, attr).indexOf(value)==0);\n\t\t\t};\n\t\t},\n\t\t\"$=\": function(attr, value){\n\t\t\t// E[foo$=\"bar\"]\n\t\t\t//\t\tan E element whose \"foo\" attribute value ends exactly\n\t\t\t//\t\twith the string \"bar\"\n\t\t\treturn function(elem){\n\t\t\t\tvar ea = \" \"+_getAttr(elem, attr);\n\t\t\t\tvar lastIndex = ea.lastIndexOf(value);\n\t\t\t\treturn lastIndex > -1 && (lastIndex==(ea.length-value.length));\n\t\t\t};\n\t\t},\n\t\t\"~=\": function(attr, value){\n\t\t\t// E[foo~=\"bar\"]\n\t\t\t//\t\tan E element whose \"foo\" attribute value is a list of\n\t\t\t//\t\tspace-separated values, one of which is exactly equal\n\t\t\t//\t\tto \"bar\"\n\n\t\t\t// return \"[contains(concat(' ',@\"+attr+\",' '), ' \"+ value +\" ')]\";\n\t\t\tvar tval = \" \"+value+\" \";\n\t\t\treturn function(elem){\n\t\t\t\tvar ea = \" \"+_getAttr(elem, attr)+\" \";\n\t\t\t\treturn (ea.indexOf(tval)>=0);\n\t\t\t};\n\t\t},\n\t\t\"|=\": function(attr, value){\n\t\t\t// E[hreflang|=\"en\"]\n\t\t\t//\t\tan E element whose \"hreflang\" attribute has a\n\t\t\t//\t\thyphen-separated list of values beginning (from the\n\t\t\t//\t\tleft) with \"en\"\n\t\t\tvar valueDash = value+\"-\";\n\t\t\treturn function(elem){\n\t\t\t\tvar ea = _getAttr(elem, attr);\n\t\t\t\treturn (\n\t\t\t\t\t(ea == value) ||\n\t\t\t\t\t(ea.indexOf(valueDash)==0)\n\t\t\t\t);\n\t\t\t};\n\t\t},\n\t\t\"=\": function(attr, value){\n\t\t\treturn function(elem){\n\t\t\t\treturn (_getAttr(elem, attr) == value);\n\t\t\t};\n\t\t}\n\t};\n\n\t// avoid testing for node type if we can. Defining this in the negative\n\t// here to avoid negation in the fast path.\n\tvar _noNES = (typeof getDoc().firstChild.nextElementSibling == \"undefined\");\n\tvar _ns = !_noNES ? \"nextElementSibling\" : \"nextSibling\";\n\tvar _ps = !_noNES ? \"previousElementSibling\" : \"previousSibling\";\n\tvar _simpleNodeTest = (_noNES ? _isElement : yesman);\n\n\tvar _lookLeft = function(node){\n\t\t// look left\n\t\twhile(node = node[_ps]){\n\t\t\tif(_simpleNodeTest(node)){ return false; }\n\t\t}\n\t\treturn true;\n\t};\n\n\tvar _lookRight = function(node){\n\t\t// look right\n\t\twhile(node = node[_ns]){\n\t\t\tif(_simpleNodeTest(node)){ return false; }\n\t\t}\n\t\treturn true;\n\t};\n\n\tvar getNodeIndex = function(node){\n\t\tvar root = node.parentNode;\n\t\troot = root.nodeType != 7 ? root : root.nextSibling; // PROCESSING_INSTRUCTION_NODE\n\t\tvar i = 0,\n\t\t\ttret = root.children || root.childNodes,\n\t\t\tci = (node[\"_i\"]||node.getAttribute(\"_i\")||-1),\n\t\t\tcl = (root[\"_l\"]|| (typeof root.getAttribute !== \"undefined\" ? root.getAttribute(\"_l\") : -1));\n\n\t\tif(!tret){ return -1; }\n\t\tvar l = tret.length;\n\n\t\t// we calculate the parent length as a cheap way to invalidate the\n\t\t// cache. It's not 100% accurate, but it's much more honest than what\n\t\t// other libraries do\n\t\tif( cl == l && ci >= 0 && cl >= 0 ){\n\t\t\t// if it's legit, tag and release\n\t\t\treturn ci;\n\t\t}\n\n\t\t// else re-key things\n\t\tif(has(\"ie\") && typeof root.setAttribute !== \"undefined\"){\n\t\t\troot.setAttribute(\"_l\", l);\n\t\t}else{\n\t\t\troot[\"_l\"] = l;\n\t\t}\n\t\tci = -1;\n\t\tfor(var te = root[\"firstElementChild\"]||root[\"firstChild\"]; te; te = te[_ns]){\n\t\t\tif(_simpleNodeTest(te)){\n\t\t\t\tif(has(\"ie\")){\n\t\t\t\t\tte.setAttribute(\"_i\", ++i);\n\t\t\t\t}else{\n\t\t\t\t\tte[\"_i\"] = ++i;\n\t\t\t\t}\n\t\t\t\tif(node === te){\n\t\t\t\t\t// NOTE:\n\t\t\t\t\t//\tshortcutting the return at this step in indexing works\n\t\t\t\t\t//\tvery well for benchmarking but we avoid it here since\n\t\t\t\t\t//\tit leads to potential O(n^2) behavior in sequential\n\t\t\t\t\t//\tgetNodexIndex operations on a previously un-indexed\n\t\t\t\t\t//\tparent. We may revisit this at a later time, but for\n\t\t\t\t\t//\tnow we just want to get the right answer more often\n\t\t\t\t\t//\tthan not.\n\t\t\t\t\tci = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ci;\n\t};\n\n\tvar isEven = function(elem){\n\t\treturn !((getNodeIndex(elem)) % 2);\n\t};\n\n\tvar isOdd = function(elem){\n\t\treturn ((getNodeIndex(elem)) % 2);\n\t};\n\n\tvar pseudos = {\n\t\t\"checked\": function(name, condition){\n\t\t\treturn function(elem){\n\t\t\t\treturn !!(\"checked\" in elem ? elem.checked : elem.selected);\n\t\t\t};\n\t\t},\n\t\t\"disabled\": function(name, condition){\n\t\t\treturn function(elem){\n\t\t\t\treturn elem.disabled;\n\t\t\t};\n\t\t},\n\t\t\"enabled\": function(name, condition){\n\t\t\treturn function(elem){\n\t\t\t\treturn !elem.disabled;\n\t\t\t};\n\t\t},\n\t\t\"first-child\": function(){ return _lookLeft; },\n\t\t\"last-child\": function(){ return _lookRight; },\n\t\t\"only-child\": function(name, condition){\n\t\t\treturn function(node){\n\t\t\t\treturn _lookLeft(node) && _lookRight(node);\n\t\t\t};\n\t\t},\n\t\t\"empty\": function(name, condition){\n\t\t\treturn function(elem){\n\t\t\t\t// DomQuery and jQuery get this wrong, oddly enough.\n\t\t\t\t// The CSS 3 selectors spec is pretty explicit about it, too.\n\t\t\t\tvar cn = elem.childNodes;\n\t\t\t\tvar cnl = elem.childNodes.length;\n\t\t\t\t// if(!cnl){ return true; }\n\t\t\t\tfor(var x=cnl-1; x >= 0; x--){\n\t\t\t\t\tvar nt = cn[x].nodeType;\n\t\t\t\t\tif((nt === 1)||(nt == 3)){ return false; }\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t};\n\t\t},\n\t\t\"contains\": function(name, condition){\n\t\t\tvar cz = condition.charAt(0);\n\t\t\tif( cz == '\"' || cz == \"'\" ){ //remove quote\n\t\t\t\tcondition = condition.slice(1, -1);\n\t\t\t}\n\t\t\treturn function(elem){\n\t\t\t\treturn (elem.innerHTML.indexOf(condition) >= 0);\n\t\t\t};\n\t\t},\n\t\t\"not\": function(name, condition){\n\t\t\tvar p = getQueryParts(condition)[0];\n\t\t\tvar ignores = { el: 1 };\n\t\t\tif(p.tag != \"*\"){\n\t\t\t\tignores.tag = 1;\n\t\t\t}\n\t\t\tif(!p.classes.length){\n\t\t\t\tignores.classes = 1;\n\t\t\t}\n\t\t\tvar ntf = getSimpleFilterFunc(p, ignores);\n\t\t\treturn function(elem){\n\t\t\t\treturn (!ntf(elem));\n\t\t\t};\n\t\t},\n\t\t\"nth-child\": function(name, condition){\n\t\t\tvar pi = parseInt;\n\t\t\t// avoid re-defining function objects if we can\n\t\t\tif(condition == \"odd\"){\n\t\t\t\treturn isOdd;\n\t\t\t}else if(condition == \"even\"){\n\t\t\t\treturn isEven;\n\t\t\t}\n\t\t\t// FIXME: can we shorten this?\n\t\t\tif(condition.indexOf(\"n\") != -1){\n\t\t\t\tvar tparts = condition.split(\"n\", 2);\n\t\t\t\tvar pred = tparts[0] ? ((tparts[0] == '-') ? -1 : pi(tparts[0])) : 1;\n\t\t\t\tvar idx = tparts[1] ? pi(tparts[1]) : 0;\n\t\t\t\tvar lb = 0, ub = -1;\n\t\t\t\tif(pred > 0){\n\t\t\t\t\tif(idx < 0){\n\t\t\t\t\t\tidx = (idx % pred) && (pred + (idx % pred));\n\t\t\t\t\t}else if(idx>0){\n\t\t\t\t\t\tif(idx >= pred){\n\t\t\t\t\t\t\tlb = idx - idx % pred;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tidx = idx % pred;\n\t\t\t\t\t}\n\t\t\t\t}else if(pred<0){\n\t\t\t\t\tpred *= -1;\n\t\t\t\t\t// idx has to be greater than 0 when pred is negative;\n\t\t\t\t\t// shall we throw an error here?\n\t\t\t\t\tif(idx > 0){\n\t\t\t\t\t\tub = idx;\n\t\t\t\t\t\tidx = idx % pred;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(pred > 0){\n\t\t\t\t\treturn function(elem){\n\t\t\t\t\t\tvar i = getNodeIndex(elem);\n\t\t\t\t\t\treturn (i>=lb) && (ub<0 || i<=ub) && ((i % pred) == idx);\n\t\t\t\t\t};\n\t\t\t\t}else{\n\t\t\t\t\tcondition = idx;\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar ncount = pi(condition);\n\t\t\treturn function(elem){\n\t\t\t\treturn (getNodeIndex(elem) == ncount);\n\t\t\t};\n\t\t}\n\t};\n\n\tvar defaultGetter = (has(\"ie\") && (has(\"ie\") < 9 || has(\"quirks\"))) ? function(cond){\n\t\tvar clc = cond.toLowerCase();\n\t\tif(clc == \"class\"){ cond = \"className\"; }\n\t\treturn function(elem){\n\t\t\treturn (caseSensitive ? elem.getAttribute(cond) : elem[cond]||elem[clc]);\n\t\t};\n\t} : function(cond){\n\t\treturn function(elem){\n\t\t\treturn (elem && elem.getAttribute && elem.hasAttribute(cond));\n\t\t};\n\t};\n\n\tvar getSimpleFilterFunc = function(query, ignores){\n\t\t// generates a node tester function based on the passed query part. The\n\t\t// query part is one of the structures generated by the query parser\n\t\t// when it creates the query AST. The \"ignores\" object specifies which\n\t\t// (if any) tests to skip, allowing the system to avoid duplicating\n\t\t// work where it may have already been taken into account by other\n\t\t// factors such as how the nodes to test were fetched in the first\n\t\t// place\n\t\tif(!query){ return yesman; }\n\t\tignores = ignores||{};\n\n\t\tvar ff = null;\n\n\t\tif(!(\"el\" in ignores)){\n\t\t\tff = agree(ff, _isElement);\n\t\t}\n\n\t\tif(!(\"tag\" in ignores)){\n\t\t\tif(query.tag != \"*\"){\n\t\t\t\tff = agree(ff, function(elem){\n\t\t\t\t\treturn (elem && ((caseSensitive ? elem.tagName : elem.tagName.toUpperCase()) == query.getTag()));\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif(!(\"classes\" in ignores)){\n\t\t\teach(query.classes, function(cname, idx, arr){\n\t\t\t\t// get the class name\n\t\t\t\t/*\n\t\t\t\tvar isWildcard = cname.charAt(cname.length-1) == \"*\";\n\t\t\t\tif(isWildcard){\n\t\t\t\t\tcname = cname.substr(0, cname.length-1);\n\t\t\t\t}\n\t\t\t\t// I dislike the regex thing, even if memoized in a cache, but it's VERY short\n\t\t\t\tvar re = new RegExp(\"(?:^|\\\\s)\" + cname + (isWildcard ? \".*\" : \"\") + \"(?:\\\\s|$)\");\n\t\t\t\t*/\n\t\t\t\tvar re = new RegExp(\"(?:^|\\\\s)\" + cname + \"(?:\\\\s|$)\");\n\t\t\t\tff = agree(ff, function(elem){\n\t\t\t\t\treturn re.test(elem.className);\n\t\t\t\t});\n\t\t\t\tff.count = idx;\n\t\t\t});\n\t\t}\n\n\t\tif(!(\"pseudos\" in ignores)){\n\t\t\teach(query.pseudos, function(pseudo){\n\t\t\t\tvar pn = pseudo.name;\n\t\t\t\tif(pseudos[pn]){\n\t\t\t\t\tff = agree(ff, pseudos[pn](pn, pseudo.value));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif(!(\"attrs\" in ignores)){\n\t\t\teach(query.attrs, function(attr){\n\t\t\t\tvar matcher;\n\t\t\t\tvar a = attr.attr;\n\t\t\t\t// type, attr, matchFor\n\t\t\t\tif(attr.type && attrs[attr.type]){\n\t\t\t\t\tmatcher = attrs[attr.type](a, attr.matchFor);\n\t\t\t\t}else if(a.length){\n\t\t\t\t\tmatcher = defaultGetter(a);\n\t\t\t\t}\n\t\t\t\tif(matcher){\n\t\t\t\t\tff = agree(ff, matcher);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif(!(\"id\" in ignores)){\n\t\t\tif(query.id){\n\t\t\t\tff = agree(ff, function(elem){\n\t\t\t\t\treturn (!!elem && (elem.id == query.id));\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif(!ff){\n\t\t\tif(!(\"default\" in ignores)){\n\t\t\t\tff = yesman;\n\t\t\t}\n\t\t}\n\t\treturn ff;\n\t};\n\n\tvar _nextSibling = function(filterFunc){\n\t\treturn function(node, ret, bag){\n\t\t\twhile(node = node[_ns]){\n\t\t\t\tif(_noNES && (!_isElement(node))){ continue; }\n\t\t\t\tif(\n\t\t\t\t\t(!bag || _isUnique(node, bag)) &&\n\t\t\t\t\tfilterFunc(node)\n\t\t\t\t){\n\t\t\t\t\tret.push(node);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn ret;\n\t\t};\n\t};\n\n\tvar _nextSiblings = function(filterFunc){\n\t\treturn function(root, ret, bag){\n\t\t\tvar te = root[_ns];\n\t\t\twhile(te){\n\t\t\t\tif(_simpleNodeTest(te)){\n\t\t\t\t\tif(bag && !_isUnique(te, bag)){\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif(filterFunc(te)){\n\t\t\t\t\t\tret.push(te);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tte = te[_ns];\n\t\t\t}\n\t\t\treturn ret;\n\t\t};\n\t};\n\n\t// get an array of child *elements*, skipping text and comment nodes\n\tvar _childElements = function(filterFunc){\n\t\tfilterFunc = filterFunc||yesman;\n\t\treturn function(root, ret, bag){\n\t\t\t// get an array of child elements, skipping text and comment nodes\n\t\t\tvar te, x = 0, tret = root.children || root.childNodes;\n\t\t\twhile(te = tret[x++]){\n\t\t\t\tif(\n\t\t\t\t\t_simpleNodeTest(te) &&\n\t\t\t\t\t(!bag || _isUnique(te, bag)) &&\n\t\t\t\t\t(filterFunc(te, x))\n\t\t\t\t){\n\t\t\t\t\tret.push(te);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ret;\n\t\t};\n\t};\n\n\t// test to see if node is below root\n\tvar _isDescendant = function(node, root){\n\t\tvar pn = node.parentNode;\n\t\twhile(pn){\n\t\t\tif(pn == root){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpn = pn.parentNode;\n\t\t}\n\t\treturn !!pn;\n\t};\n\n\tvar _getElementsFuncCache = {};\n\n\tvar getElementsFunc = function(query){\n\t\tvar retFunc = _getElementsFuncCache[query.query];\n\t\t// if we've got a cached dispatcher, just use that\n\t\tif(retFunc){ return retFunc; }\n\t\t// else, generate a new on\n\n\t\t// NOTE:\n\t\t//\t\tthis function returns a function that searches for nodes and\n\t\t//\t\tfilters them.  The search may be specialized by infix operators\n\t\t//\t\t(\">\", \"~\", or \"+\") else it will default to searching all\n\t\t//\t\tdescendants (the \" \" selector). Once a group of children is\n\t\t//\t\tfound, a test function is applied to weed out the ones we\n\t\t//\t\tdon't want. Many common cases can be fast-pathed. We spend a\n\t\t//\t\tlot of cycles to create a dispatcher that doesn't do more work\n\t\t//\t\tthan necessary at any point since, unlike this function, the\n\t\t//\t\tdispatchers will be called every time. The logic of generating\n\t\t//\t\tefficient dispatchers looks like this in pseudo code:\n\t\t//\n\t\t//\t\t# if it's a purely descendant query (no \">\", \"+\", or \"~\" modifiers)\n\t\t//\t\tif infixOperator == \" \":\n\t\t//\t\t\tif only(id):\n\t\t//\t\t\t\treturn def(root):\n\t\t//\t\t\t\t\treturn d.byId(id, root);\n\t\t//\n\t\t//\t\t\telif id:\n\t\t//\t\t\t\treturn def(root):\n\t\t//\t\t\t\t\treturn filter(d.byId(id, root));\n\t\t//\n\t\t//\t\t\telif cssClass && getElementsByClassName:\n\t\t//\t\t\t\treturn def(root):\n\t\t//\t\t\t\t\treturn filter(root.getElementsByClassName(cssClass));\n\t\t//\n\t\t//\t\t\telif only(tag):\n\t\t//\t\t\t\treturn def(root):\n\t\t//\t\t\t\t\treturn root.getElementsByTagName(tagName);\n\t\t//\n\t\t//\t\t\telse:\n\t\t//\t\t\t\t# search by tag name, then filter\n\t\t//\t\t\t\treturn def(root):\n\t\t//\t\t\t\t\treturn filter(root.getElementsByTagName(tagName||\"*\"));\n\t\t//\n\t\t//\t\telif infixOperator == \">\":\n\t\t//\t\t\t# search direct children\n\t\t//\t\t\treturn def(root):\n\t\t//\t\t\t\treturn filter(root.children);\n\t\t//\n\t\t//\t\telif infixOperator == \"+\":\n\t\t//\t\t\t# search next sibling\n\t\t//\t\t\treturn def(root):\n\t\t//\t\t\t\treturn filter(root.nextElementSibling);\n\t\t//\n\t\t//\t\telif infixOperator == \"~\":\n\t\t//\t\t\t# search rightward siblings\n\t\t//\t\t\treturn def(root):\n\t\t//\t\t\t\treturn filter(nextSiblings(root));\n\n\t\tvar io = query.infixOper;\n\t\tvar oper = (io ? io.oper : \"\");\n\t\t// the default filter func which tests for all conditions in the query\n\t\t// part. This is potentially inefficient, so some optimized paths may\n\t\t// re-define it to test fewer things.\n\t\tvar filterFunc = getSimpleFilterFunc(query, { el: 1 });\n\t\tvar qt = query.tag;\n\t\tvar wildcardTag = (\"*\" == qt);\n\t\tvar ecs = getDoc()[\"getElementsByClassName\"];\n\n\t\tif(!oper){\n\t\t\t// if there's no infix operator, then it's a descendant query. ID\n\t\t\t// and \"elements by class name\" variants can be accelerated so we\n\t\t\t// call them out explicitly:\n\t\t\tif(query.id){\n\t\t\t\t// testing shows that the overhead of yesman() is acceptable\n\t\t\t\t// and can save us some bytes vs. re-defining the function\n\t\t\t\t// everywhere.\n\t\t\t\tfilterFunc = (!query.loops && wildcardTag) ?\n\t\t\t\t\tyesman :\n\t\t\t\t\tgetSimpleFilterFunc(query, { el: 1, id: 1 });\n\n\t\t\t\tretFunc = function(root, arr){\n\t\t\t\t\tvar te = dom.byId(query.id, (root.ownerDocument||root));\n\t\t\t\t\tif(!te || !filterFunc(te)){ return; }\n\t\t\t\t\tif(9 == root.nodeType){ // if root's a doc, we just return directly\n\t\t\t\t\t\treturn getArr(te, arr);\n\t\t\t\t\t}else{ // otherwise check ancestry\n\t\t\t\t\t\tif(_isDescendant(te, root)){\n\t\t\t\t\t\t\treturn getArr(te, arr);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}else if(\n\t\t\t\tecs &&\n\t\t\t\t// isAlien check. Workaround for Prototype.js being totally evil/dumb.\n\t\t\t\t/\\{\\s*\\[native code\\]\\s*\\}/.test(String(ecs)) &&\n\t\t\t\tquery.classes.length &&\n\t\t\t\t!cssCaseBug\n\t\t\t){\n\t\t\t\t// it's a class-based query and we've got a fast way to run it.\n\n\t\t\t\t// ignore class and ID filters since we will have handled both\n\t\t\t\tfilterFunc = getSimpleFilterFunc(query, { el: 1, classes: 1, id: 1 });\n\t\t\t\tvar classesString = query.classes.join(\" \");\n\t\t\t\tretFunc = function(root, arr, bag){\n\t\t\t\t\tvar ret = getArr(0, arr), te, x=0;\n\t\t\t\t\tvar tret = root.getElementsByClassName(classesString);\n\t\t\t\t\twhile((te = tret[x++])){\n\t\t\t\t\t\tif(filterFunc(te, root) && _isUnique(te, bag)){\n\t\t\t\t\t\t\tret.push(te);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn ret;\n\t\t\t\t};\n\n\t\t\t}else if(!wildcardTag && !query.loops){\n\t\t\t\t// it's tag only. Fast-path it.\n\t\t\t\tretFunc = function(root, arr, bag){\n\t\t\t\t\tvar ret = getArr(0, arr), te, x=0;\n\t\t\t\t\tvar tag = query.getTag(),\n\t\t\t\t\t\ttret = tag ? root.getElementsByTagName(tag) : [];\n\t\t\t\t\twhile((te = tret[x++])){\n\t\t\t\t\t\tif(_isUnique(te, bag)){\n\t\t\t\t\t\t\tret.push(te);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn ret;\n\t\t\t\t};\n\t\t\t}else{\n\t\t\t\t// the common case:\n\t\t\t\t//\t\ta descendant selector without a fast path. By now it's got\n\t\t\t\t//\t\tto have a tag selector, even if it's just \"*\" so we query\n\t\t\t\t//\t\tby that and filter\n\t\t\t\tfilterFunc = getSimpleFilterFunc(query, { el: 1, tag: 1, id: 1 });\n\t\t\t\tretFunc = function(root, arr, bag){\n\t\t\t\t\tvar ret = getArr(0, arr), te, x=0;\n\t\t\t\t\t// we use getTag() to avoid case sensitivity issues\n\t\t\t\t\tvar tag = query.getTag(),\n\t\t\t\t\t\ttret = tag ? root.getElementsByTagName(tag) : [];\n\t\t\t\t\twhile((te = tret[x++])){\n\t\t\t\t\t\tif(filterFunc(te, root) && _isUnique(te, bag)){\n\t\t\t\t\t\t\tret.push(te);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn ret;\n\t\t\t\t};\n\t\t\t}\n\t\t}else{\n\t\t\t// the query is scoped in some way. Instead of querying by tag we\n\t\t\t// use some other collection to find candidate nodes\n\t\t\tvar skipFilters = { el: 1 };\n\t\t\tif(wildcardTag){\n\t\t\t\tskipFilters.tag = 1;\n\t\t\t}\n\t\t\tfilterFunc = getSimpleFilterFunc(query, skipFilters);\n\t\t\tif(\"+\" == oper){\n\t\t\t\tretFunc = _nextSibling(filterFunc);\n\t\t\t}else if(\"~\" == oper){\n\t\t\t\tretFunc = _nextSiblings(filterFunc);\n\t\t\t}else if(\">\" == oper){\n\t\t\t\tretFunc = _childElements(filterFunc);\n\t\t\t}\n\t\t}\n\t\t// cache it and return\n\t\treturn _getElementsFuncCache[query.query] = retFunc;\n\t};\n\n\tvar filterDown = function(root, queryParts){\n\t\t// NOTE:\n\t\t//\t\tthis is the guts of the DOM query system. It takes a list of\n\t\t//\t\tparsed query parts and a root and finds children which match\n\t\t//\t\tthe selector represented by the parts\n\t\tvar candidates = getArr(root), qp, x, te, qpl = queryParts.length, bag, ret;\n\n\t\tfor(var i = 0; i < qpl; i++){\n\t\t\tret = [];\n\t\t\tqp = queryParts[i];\n\t\t\tx = candidates.length - 1;\n\t\t\tif(x > 0){\n\t\t\t\t// if we have more than one root at this level, provide a new\n\t\t\t\t// hash to use for checking group membership but tell the\n\t\t\t\t// system not to post-filter us since we will already have been\n\t\t\t\t// guaranteed to be unique\n\t\t\t\tbag = {};\n\t\t\t\tret.nozip = true;\n\t\t\t}\n\t\t\tvar gef = getElementsFunc(qp);\n\t\t\tfor(var j = 0; (te = candidates[j]); j++){\n\t\t\t\t// for every root, get the elements that match the descendant\n\t\t\t\t// selector, adding them to the \"ret\" array and filtering them\n\t\t\t\t// via membership in this level's bag. If there are more query\n\t\t\t\t// parts, then this level's return will be used as the next\n\t\t\t\t// level's candidates\n\t\t\t\tgef(te, ret, bag);\n\t\t\t}\n\t\t\tif(!ret.length){ break; }\n\t\t\tcandidates = ret;\n\t\t}\n\t\treturn ret;\n\t};\n\n\t////////////////////////////////////////////////////////////////////////\n\t// the query runner\n\t////////////////////////////////////////////////////////////////////////\n\n\t// these are the primary caches for full-query results. The query\n\t// dispatcher functions are generated then stored here for hash lookup in\n\t// the future\n\tvar _queryFuncCacheDOM = {},\n\t\t_queryFuncCacheQSA = {};\n\n\t// this is the second level of splitting, from full-length queries (e.g.,\n\t// \"div.foo .bar\") into simple query expressions (e.g., [\"div.foo\",\n\t// \".bar\"])\n\tvar getStepQueryFunc = function(query){\n\t\tvar qparts = getQueryParts(trim(query));\n\n\t\t// if it's trivial, avoid iteration and zipping costs\n\t\tif(qparts.length == 1){\n\t\t\t// we optimize this case here to prevent dispatch further down the\n\t\t\t// chain, potentially slowing things down. We could more elegantly\n\t\t\t// handle this in filterDown(), but it's slower for simple things\n\t\t\t// that need to be fast (e.g., \"#someId\").\n\t\t\tvar tef = getElementsFunc(qparts[0]);\n\t\t\treturn function(root){\n\t\t\t\tvar r = tef(root, []);\n\t\t\t\tif(r){ r.nozip = true; }\n\t\t\t\treturn r;\n\t\t\t};\n\t\t}\n\n\t\t// otherwise, break it up and return a runner that iterates over the parts recursively\n\t\treturn function(root){\n\t\t\treturn filterDown(root, qparts);\n\t\t};\n\t};\n\n\t// NOTES:\n\t//\t* we can't trust QSA for anything but document-rooted queries, so\n\t//\t  caching is split into DOM query evaluators and QSA query evaluators\n\t//\t* caching query results is dirty and leak-prone (or, at a minimum,\n\t//\t  prone to unbounded growth). Other toolkits may go this route, but\n\t//\t  they totally destroy their own ability to manage their memory\n\t//\t  footprint. If we implement it, it should only ever be with a fixed\n\t//\t  total element reference # limit and an LRU-style algorithm since JS\n\t//\t  has no weakref support. Caching compiled query evaluators is also\n\t//\t  potentially problematic, but even on large documents the size of the\n\t//\t  query evaluators is often < 100 function objects per evaluator (and\n\t//\t  LRU can be applied if it's ever shown to be an issue).\n\t//\t* since IE's QSA support is currently only for HTML documents and even\n\t//\t  then only in IE 8's \"standards mode\", we have to detect our dispatch\n\t//\t  route at query time and keep 2 separate caches. Ugg.\n\n\t// we need to determine if we think we can run a given query via\n\t// querySelectorAll or if we'll need to fall back on DOM queries to get\n\t// there. We need a lot of information about the environment and the query\n\t// to make the determination (e.g. does it support QSA, does the query in\n\t// question work in the native QSA impl, etc.).\n\n\t// IE QSA queries may incorrectly include comment nodes, so we throw the\n\t// zipping function into \"remove\" comments mode instead of the normal \"skip\n\t// it\" which every other QSA-clued browser enjoys\n\tvar noZip = has(\"ie\") ? \"commentStrip\" : \"nozip\";\n\n\tvar qsa = \"querySelectorAll\";\n\tvar qsaAvail = !!getDoc()[qsa];\n\n\t//Don't bother with n+3 type of matches, IE complains if we modify those.\n\tvar infixSpaceRe = /\\\\[>~+]|n\\+\\d|([^ \\\\])?([>~+])([^ =])?/g;\n\tvar infixSpaceFunc = function(match, pre, ch, post){\n\t\treturn ch ? (pre ? pre + \" \" : \"\") + ch + (post ? \" \" + post : \"\") : /*n+3*/ match;\n\t};\n\t\n\t//Don't apply the infixSpaceRe to attribute value selectors\n\tvar attRe = /([^[]*)([^\\]]*])?/g;\n\tvar attFunc = function(match, nonAtt, att){\n\t\treturn nonAtt.replace(infixSpaceRe, infixSpaceFunc) + (att||\"\");\n\t};\n\tvar getQueryFunc = function(query, forceDOM){\n\t\t//Normalize query. The CSS3 selectors spec allows for omitting spaces around\n\t\t//infix operators, >, ~ and +\n\t\t//Do the work here since detection for spaces is used as a simple \"not use QSA\"\n\t\t//test below.\n\t\tquery = query.replace(attRe, attFunc);\n\n\t\tif(qsaAvail){\n\t\t\t// if we've got a cached variant and we think we can do it, run it!\n\t\t\tvar qsaCached = _queryFuncCacheQSA[query];\n\t\t\tif(qsaCached && !forceDOM){ return qsaCached; }\n\t\t}\n\n\t\t// else if we've got a DOM cached variant, assume that we already know\n\t\t// all we need to and use it\n\t\tvar domCached = _queryFuncCacheDOM[query];\n\t\tif(domCached){ return domCached; }\n\n\t\t// TODO:\n\t\t//\t\ttoday we're caching DOM and QSA branches separately so we\n\t\t//\t\trecalc useQSA every time. If we had a way to tag root+query\n\t\t//\t\tefficiently, we'd be in good shape to do a global cache.\n\n\t\tvar qcz = query.charAt(0);\n\t\tvar nospace = (-1 == query.indexOf(\" \"));\n\n\t\t// byId searches are wicked fast compared to QSA, even when filtering\n\t\t// is required\n\t\tif( (query.indexOf(\"#\") >= 0) && (nospace) ){\n\t\t\tforceDOM = true;\n\t\t}\n\n\t\tvar useQSA = (\n\t\t\tqsaAvail && (!forceDOM) &&\n\t\t\t// as per CSS 3, we can't currently start w/ combinator:\n\t\t\t//\t\thttp://www.w3.org/TR/css3-selectors/#w3cselgrammar\n\t\t\t(specials.indexOf(qcz) == -1) &&\n\t\t\t// IE's QSA impl sucks on pseudos\n\t\t\t(!has(\"ie\") || (query.indexOf(\":\") == -1)) &&\n\n\t\t\t(!(cssCaseBug && (query.indexOf(\".\") >= 0))) &&\n\n\t\t\t// FIXME:\n\t\t\t//\t\tneed to tighten up browser rules on \":contains\" and \"|=\" to\n\t\t\t//\t\tfigure out which aren't good\n\t\t\t//\t\tLatest webkit (around 531.21.8) does not seem to do well with :checked on option\n\t\t\t//\t\telements, even though according to spec, selected options should\n\t\t\t//\t\tmatch :checked. So go nonQSA for it:\n\t\t\t//\t\thttp://bugs.dojotoolkit.org/ticket/5179\n\t\t\t(query.indexOf(\":contains\") == -1) && (query.indexOf(\":checked\") == -1) &&\n\t\t\t(query.indexOf(\"|=\") == -1) // some browsers don't grok it\n\t\t);\n\n\t\t// TODO:\n\t\t//\t\tif we've got a descendant query (e.g., \"> .thinger\" instead of\n\t\t//\t\tjust \".thinger\") in a QSA-able doc, but are passed a child as a\n\t\t//\t\troot, it should be possible to give the item a synthetic ID and\n\t\t//\t\ttrivially rewrite the query to the form \"#synid > .thinger\" to\n\t\t//\t\tuse the QSA branch\n\n\n\t\tif(useQSA){\n\t\t\tvar tq = (specials.indexOf(query.charAt(query.length-1)) >= 0) ?\n\t\t\t\t\t\t(query + \" *\") : query;\n\t\t\treturn _queryFuncCacheQSA[query] = function(root){\n\t\t\t\ttry{\n\t\t\t\t\t// the QSA system contains an egregious spec bug which\n\t\t\t\t\t// limits us, effectively, to only running QSA queries over\n\t\t\t\t\t// entire documents.  See:\n\t\t\t\t\t//\t\thttp://ejohn.org/blog/thoughts-on-queryselectorall/\n\t\t\t\t\t//\tdespite this, we can also handle QSA runs on simple\n\t\t\t\t\t//\tselectors, but we don't want detection to be expensive\n\t\t\t\t\t//\tso we're just checking for the presence of a space char\n\t\t\t\t\t//\tright now. Not elegant, but it's cheaper than running\n\t\t\t\t\t//\tthe query parser when we might not need to\n\t\t\t\t\tif(!((9 == root.nodeType) || nospace)){ throw \"\"; }\n\t\t\t\t\tvar r = root[qsa](tq);\n\t\t\t\t\t// skip expensive duplication checks and just wrap in a NodeList\n\t\t\t\t\tr[noZip] = true;\n\t\t\t\t\treturn r;\n\t\t\t\t}catch(e){\n\t\t\t\t\t// else run the DOM branch on this query, ensuring that we\n\t\t\t\t\t// default that way in the future\n\t\t\t\t\treturn getQueryFunc(query, true)(root);\n\t\t\t\t}\n\t\t\t};\n\t\t}else{\n\t\t\t// DOM branch\n\t\t\tvar parts = query.match(/([^\\s,](?:\"(?:\\\\.|[^\"])+\"|'(?:\\\\.|[^'])+'|[^,])*)/g);\n\t\t\treturn _queryFuncCacheDOM[query] = ((parts.length < 2) ?\n\t\t\t\t// if not a compound query (e.g., \".foo, .bar\"), cache and return a dispatcher\n\t\t\t\tgetStepQueryFunc(query) :\n\t\t\t\t// if it *is* a complex query, break it up into its\n\t\t\t\t// constituent parts and return a dispatcher that will\n\t\t\t\t// merge the parts when run\n\t\t\t\tfunction(root){\n\t\t\t\t\tvar pindex = 0, // avoid array alloc for every invocation\n\t\t\t\t\t\tret = [],\n\t\t\t\t\t\ttp;\n\t\t\t\t\twhile((tp = parts[pindex++])){\n\t\t\t\t\t\tret = ret.concat(getStepQueryFunc(tp)(root));\n\t\t\t\t\t}\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n\tvar _zipIdx = 0;\n\n\t// NOTE:\n\t//\t\tthis function is Moo inspired, but our own impl to deal correctly\n\t//\t\twith XML in IE\n\tvar _nodeUID = has(\"ie\") ? function(node){\n\t\tif(caseSensitive){\n\t\t\t// XML docs don't have uniqueID on their nodes\n\t\t\treturn (node.getAttribute(\"_uid\") || node.setAttribute(\"_uid\", ++_zipIdx) || _zipIdx);\n\n\t\t}else{\n\t\t\treturn node.uniqueID;\n\t\t}\n\t} :\n\tfunction(node){\n\t\treturn (node._uid || (node._uid = ++_zipIdx));\n\t};\n\n\t// determine if a node in is unique in a \"bag\". In this case we don't want\n\t// to flatten a list of unique items, but rather just tell if the item in\n\t// question is already in the bag. Normally we'd just use hash lookup to do\n\t// this for us but IE's DOM is busted so we can't really count on that. On\n\t// the upside, it gives us a built in unique ID function.\n\tvar _isUnique = function(node, bag){\n\t\tif(!bag){ return 1; }\n\t\tvar id = _nodeUID(node);\n\t\tif(!bag[id]){ return bag[id] = 1; }\n\t\treturn 0;\n\t};\n\n\t// attempt to efficiently determine if an item in a list is a dupe,\n\t// returning a list of \"uniques\", hopefully in document order\n\tvar _zipIdxName = \"_zipIdx\";\n\tvar _zip = function(arr){\n\t\tif(arr && arr.nozip){\n\t\t\treturn arr;\n\t\t}\n\t\tvar ret = [];\n\t\tif(!arr || !arr.length){ return ret; }\n\t\tif(arr[0]){\n\t\t\tret.push(arr[0]);\n\t\t}\n\t\tif(arr.length < 2){ return ret; }\n\n\t\t_zipIdx++;\n\n\t\t// we have to fork here for IE and XML docs because we can't set\n\t\t// expandos on their nodes (apparently). *sigh*\n\t\tvar x, te;\n\t\tif(has(\"ie\") && caseSensitive){\n\t\t\tvar szidx = _zipIdx+\"\";\n\t\t\tarr[0].setAttribute(_zipIdxName, szidx);\n\t\t\tfor(x = 1; te = arr[x]; x++){\n\t\t\t\tif(arr[x].getAttribute(_zipIdxName) != szidx){\n\t\t\t\t\tret.push(te);\n\t\t\t\t}\n\t\t\t\tte.setAttribute(_zipIdxName, szidx);\n\t\t\t}\n\t\t}else if(has(\"ie\") && arr.commentStrip){\n\t\t\ttry{\n\t\t\t\tfor(x = 1; te = arr[x]; x++){\n\t\t\t\t\tif(_isElement(te)){\n\t\t\t\t\t\tret.push(te);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}catch(e){ /* squelch */ }\n\t\t}else{\n\t\t\tif(arr[0]){ arr[0][_zipIdxName] = _zipIdx; }\n\t\t\tfor(x = 1; te = arr[x]; x++){\n\t\t\t\tif(arr[x][_zipIdxName] != _zipIdx){\n\t\t\t\t\tret.push(te);\n\t\t\t\t}\n\t\t\t\tte[_zipIdxName] = _zipIdx;\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t};\n\n\t// the main executor\n\tvar query = function(/*String*/ query, /*String|DOMNode?*/ root){\n\t\t// summary:\n\t\t//\t\tReturns nodes which match the given CSS3 selector, searching the\n\t\t//\t\tentire document by default but optionally taking a node to scope\n\t\t//\t\tthe search by. Returns an array.\n\t\t// description:\n\t\t//\t\tdojo.query() is the swiss army knife of DOM node manipulation in\n\t\t//\t\tDojo. Much like Prototype's \"$$\" (bling-bling) function or JQuery's\n\t\t//\t\t\"$\" function, dojo.query provides robust, high-performance\n\t\t//\t\tCSS-based node selector support with the option of scoping searches\n\t\t//\t\tto a particular sub-tree of a document.\n\t\t//\n\t\t//\t\tSupported Selectors:\n\t\t//\t\t--------------------\n\t\t//\n\t\t//\t\tacme supports a rich set of CSS3 selectors, including:\n\t\t//\n\t\t//\t\t- class selectors (e.g., `.foo`)\n\t\t//\t\t- node type selectors like `span`\n\t\t//\t\t- ` ` descendant selectors\n\t\t//\t\t- `>` child element selectors\n\t\t//\t\t- `#foo` style ID selectors\n\t\t//\t\t- `*` universal selector\n\t\t//\t\t- `~`, the preceded-by sibling selector\n\t\t//\t\t- `+`, the immediately preceded-by sibling selector\n\t\t//\t\t- attribute queries:\n\t\t//\t\t\t- `[foo]` attribute presence selector\n\t\t//\t\t\t- `[foo='bar']` attribute value exact match\n\t\t//\t\t\t- `[foo~='bar']` attribute value list item match\n\t\t//\t\t\t- `[foo^='bar']` attribute start match\n\t\t//\t\t\t- `[foo$='bar']` attribute end match\n\t\t//\t\t\t- `[foo*='bar']` attribute substring match\n\t\t//\t\t- `:first-child`, `:last-child`, and `:only-child` positional selectors\n\t\t//\t\t- `:empty` content emtpy selector\n\t\t//\t\t- `:checked` pseudo selector\n\t\t//\t\t- `:nth-child(n)`, `:nth-child(2n+1)` style positional calculations\n\t\t//\t\t- `:nth-child(even)`, `:nth-child(odd)` positional selectors\n\t\t//\t\t- `:not(...)` negation pseudo selectors\n\t\t//\n\t\t//\t\tAny legal combination of these selectors will work with\n\t\t//\t\t`dojo.query()`, including compound selectors (\",\" delimited).\n\t\t//\t\tVery complex and useful searches can be constructed with this\n\t\t//\t\tpalette of selectors and when combined with functions for\n\t\t//\t\tmanipulation presented by dojo/NodeList, many types of DOM\n\t\t//\t\tmanipulation operations become very straightforward.\n\t\t//\n\t\t//\t\tUnsupported Selectors:\n\t\t//\t\t----------------------\n\t\t//\n\t\t//\t\tWhile dojo.query handles many CSS3 selectors, some fall outside of\n\t\t//\t\twhat's reasonable for a programmatic node querying engine to\n\t\t//\t\thandle. Currently unsupported selectors include:\n\t\t//\n\t\t//\t\t- namespace-differentiated selectors of any form\n\t\t//\t\t- all `::` pseduo-element selectors\n\t\t//\t\t- certain pseudo-selectors which don't get a lot of day-to-day use:\n\t\t//\t\t\t- `:root`, `:lang()`, `:target`, `:focus`\n\t\t//\t\t- all visual and state selectors:\n\t\t//\t\t\t- `:root`, `:active`, `:hover`, `:visited`, `:link`,\n\t\t//\t\t\t\t  `:enabled`, `:disabled`\n\t\t//\t\t\t- `:*-of-type` pseudo selectors\n\t\t//\n\t\t//\t\tdojo.query and XML Documents:\n\t\t//\t\t-----------------------------\n\t\t//\n\t\t//\t\t`dojo.query` (as of dojo 1.2) supports searching XML documents\n\t\t//\t\tin a case-sensitive manner. If an HTML document is served with\n\t\t//\t\ta doctype that forces case-sensitivity (e.g., XHTML 1.1\n\t\t//\t\tStrict), dojo.query() will detect this and \"do the right\n\t\t//\t\tthing\". Case sensitivity is dependent upon the document being\n\t\t//\t\tsearched and not the query used. It is therefore possible to\n\t\t//\t\tuse case-sensitive queries on strict sub-documents (iframes,\n\t\t//\t\tetc.) or XML documents while still assuming case-insensitivity\n\t\t//\t\tfor a host/root document.\n\t\t//\n\t\t//\t\tNon-selector Queries:\n\t\t//\t\t---------------------\n\t\t//\n\t\t//\t\tIf something other than a String is passed for the query,\n\t\t//\t\t`dojo.query` will return a new `dojo/NodeList` instance\n\t\t//\t\tconstructed from that parameter alone and all further\n\t\t//\t\tprocessing will stop. This means that if you have a reference\n\t\t//\t\tto a node or NodeList, you can quickly construct a new NodeList\n\t\t//\t\tfrom the original by calling `dojo.query(node)` or\n\t\t//\t\t`dojo.query(list)`.\n\t\t//\n\t\t// query:\n\t\t//\t\tThe CSS3 expression to match against. For details on the syntax of\n\t\t//\t\tCSS3 selectors, see <http://www.w3.org/TR/css3-selectors/#selectors>\n\t\t// root:\n\t\t//\t\tA DOMNode (or node id) to scope the search from. Optional.\n\t\t// returns: Array\n\t\t// example:\n\t\t//\t\tsearch the entire document for elements with the class \"foo\":\n\t\t//\t|\tdojo.query(\".foo\");\n\t\t//\t\tthese elements will match:\n\t\t//\t|\t<span class=\"foo\"></span>\n\t\t//\t|\t<span class=\"foo bar\"></span>\n\t\t//\t|\t<p class=\"thud foo\"></p>\n\t\t// example:\n\t\t//\t\tsearch the entire document for elements with the classes \"foo\" *and* \"bar\":\n\t\t//\t|\tdojo.query(\".foo.bar\");\n\t\t//\t\tthese elements will match:\n\t\t//\t|\t<span class=\"foo bar\"></span>\n\t\t//\t\twhile these will not:\n\t\t//\t|\t<span class=\"foo\"></span>\n\t\t//\t|\t<p class=\"thud foo\"></p>\n\t\t// example:\n\t\t//\t\tfind `<span>` elements which are descendants of paragraphs and\n\t\t//\t\twhich have a \"highlighted\" class:\n\t\t//\t|\tdojo.query(\"p span.highlighted\");\n\t\t//\t\tthe innermost span in this fragment matches:\n\t\t//\t|\t<p class=\"foo\">\n\t\t//\t|\t\t<span>...\n\t\t//\t|\t\t\t<span class=\"highlighted foo bar\">...</span>\n\t\t//\t|\t\t</span>\n\t\t//\t|\t</p>\n\t\t// example:\n\t\t//\t\tset an \"odd\" class on all odd table rows inside of the table\n\t\t//\t\t`#tabular_data`, using the `>` (direct child) selector to avoid\n\t\t//\t\taffecting any nested tables:\n\t\t//\t|\tdojo.query(\"#tabular_data > tbody > tr:nth-child(odd)\").addClass(\"odd\");\n\t\t// example:\n\t\t//\t\tremove all elements with the class \"error\" from the document\n\t\t//\t\tand store them in a list:\n\t\t//\t|\tvar errors = dojo.query(\".error\").orphan();\n\t\t// example:\n\t\t//\t\tadd an onclick handler to every submit button in the document\n\t\t//\t\twhich causes the form to be sent via Ajax instead:\n\t\t//\t|\tdojo.query(\"input[type='submit']\").onclick(function(e){\n\t\t//\t|\t\tdojo.stopEvent(e); // prevent sending the form\n\t\t//\t|\t\tvar btn = e.target;\n\t\t//\t|\t\tdojo.xhrPost({\n\t\t//\t|\t\t\tform: btn.form,\n\t\t//\t|\t\t\tload: function(data){\n\t\t//\t|\t\t\t\t// replace the form with the response\n\t\t//\t|\t\t\t\tvar div = dojo.doc.createElement(\"div\");\n\t\t//\t|\t\t\t\tdojo.place(div, btn.form, \"after\");\n\t\t//\t|\t\t\t\tdiv.innerHTML = data;\n\t\t//\t|\t\t\t\tdojo.style(btn.form, \"display\", \"none\");\n\t\t//\t|\t\t\t}\n\t\t//\t|\t\t});\n\t\t//\t|\t});\n\n\t\troot = root || getDoc();\n\n\t\t// throw the big case sensitivity switch\n\t\tvar od = root.ownerDocument || root;\t// root is either Document or a node inside the document\n\t\tcaseSensitive = (od.createElement(\"div\").tagName === \"div\");\n\n\t\t// NOTE:\n\t\t//\t\tadding \"true\" as the 2nd argument to getQueryFunc is useful for\n\t\t//\t\ttesting the DOM branch without worrying about the\n\t\t//\t\tbehavior/performance of the QSA branch.\n\t\tvar r = getQueryFunc(query)(root);\n\n\t\t// FIXME:\n\t\t//\t\tneed to investigate this branch WRT #8074 and #8075\n\t\tif(r && r.nozip){\n\t\t\treturn r;\n\t\t}\n\t\treturn _zip(r); // dojo/NodeList\n\t};\n\tquery.filter = function(/*Node[]*/ nodeList, /*String*/ filter, /*String|DOMNode?*/ root){\n\t\t// summary:\n\t\t//\t\tfunction for filtering a NodeList based on a selector, optimized for simple selectors\n\t\tvar tmpNodeList = [],\n\t\t\tparts = getQueryParts(filter),\n\t\t\tfilterFunc =\n\t\t\t\t(parts.length == 1 && !/[^\\w#\\.]/.test(filter)) ?\n\t\t\t\tgetSimpleFilterFunc(parts[0]) :\n\t\t\t\tfunction(node){\n\t\t\t\t\treturn array.indexOf(query(filter, dom.byId(root)), node) != -1;\n\t\t\t\t};\n\t\tfor(var x = 0, te; te = nodeList[x]; x++){\n\t\t\tif(filterFunc(te)){ tmpNodeList.push(te); }\n\t\t}\n\t\treturn tmpNodeList;\n\t};\n\treturn query;\n});\n\n},\n'dojo/errors/RequestTimeoutError':function(){\ndefine(\"dojo/errors/RequestTimeoutError\", ['./create', './RequestError'], function(create, RequestError){\n\t// module:\n\t//\t\tdojo/errors/RequestTimeoutError\n\n\t/*=====\n\t return function(){\n\t\t // summary:\n\t\t //\t\tTODOC\n\t };\n\t =====*/\n\n\treturn create(\"RequestTimeoutError\", null, RequestError, {\n\t\tdojoType: \"timeout\"\n\t});\n});\n\n},\n'dojo/dom-style':function(){\ndefine(\"dojo/dom-style\", [\"./sniff\", \"./dom\"], function(has, dom){\n\t// module:\n\t//\t\tdojo/dom-style\n\n\t// =============================\n\t// Style Functions\n\t// =============================\n\n\t// getComputedStyle drives most of the style code.\n\t// Wherever possible, reuse the returned object.\n\t//\n\t// API functions below that need to access computed styles accept an\n\t// optional computedStyle parameter.\n\t// If this parameter is omitted, the functions will call getComputedStyle themselves.\n\t// This way, calling code can access computedStyle once, and then pass the reference to\n\t// multiple API functions.\n\n\t// Although we normally eschew argument validation at this\n\t// level, here we test argument 'node' for (duck)type,\n\t// by testing nodeType, ecause 'document' is the 'parentNode' of 'body'\n\t// it is frequently sent to this function even\n\t// though it is not Element.\n\tvar getComputedStyle, style = {\n\t\t// summary:\n\t\t//\t\tThis module defines the core dojo DOM style API.\n\t};\n\tif(has(\"webkit\")){\n\t\tgetComputedStyle = function(/*DomNode*/ node){\n\t\t\tvar s;\n\t\t\tif(node.nodeType == 1){\n\t\t\t\tvar dv = node.ownerDocument.defaultView;\n\t\t\t\ts = dv.getComputedStyle(node, null);\n\t\t\t\tif(!s && node.style){\n\t\t\t\t\tnode.style.display = \"\";\n\t\t\t\t\ts = dv.getComputedStyle(node, null);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn s || {};\n\t\t};\n\t}else if(has(\"ie\") && (has(\"ie\") < 9 || has(\"quirks\"))){\n\t\tgetComputedStyle = function(node){\n\t\t\t// IE (as of 7) doesn't expose Element like sane browsers\n\t\t\t// currentStyle can be null on IE8!\n\t\t\treturn node.nodeType == 1 /* ELEMENT_NODE*/ && node.currentStyle ? node.currentStyle : {};\n\t\t};\n\t}else{\n\t\tgetComputedStyle = function(node){\n\t\t\treturn node.nodeType == 1 /* ELEMENT_NODE*/ ?\n\t\t\t\tnode.ownerDocument.defaultView.getComputedStyle(node, null) : {};\n\t\t};\n\t}\n\tstyle.getComputedStyle = getComputedStyle;\n\t/*=====\n\tstyle.getComputedStyle = function(node){\n\t\t// summary:\n\t\t//\t\tReturns a \"computed style\" object.\n\t\t//\n\t\t// description:\n\t\t//\t\tGets a \"computed style\" object which can be used to gather\n\t\t//\t\tinformation about the current state of the rendered node.\n\t\t//\n\t\t//\t\tNote that this may behave differently on different browsers.\n\t\t//\t\tValues may have different formats and value encodings across\n\t\t//\t\tbrowsers.\n\t\t//\n\t\t//\t\tNote also that this method is expensive.  Wherever possible,\n\t\t//\t\treuse the returned object.\n\t\t//\n\t\t//\t\tUse the dojo.style() method for more consistent (pixelized)\n\t\t//\t\treturn values.\n\t\t//\n\t\t// node: DOMNode\n\t\t//\t\tA reference to a DOM node. Does NOT support taking an\n\t\t//\t\tID string for speed reasons.\n\t\t// example:\n\t\t//\t|\tdojo.getComputedStyle(dojo.byId('foo')).borderWidth;\n\t\t//\n\t\t// example:\n\t\t//\t\tReusing the returned object, avoiding multiple lookups:\n\t\t//\t|\tvar cs = dojo.getComputedStyle(dojo.byId(\"someNode\"));\n\t\t//\t|\tvar w = cs.width, h = cs.height;\n\t\treturn; // CSS2Properties\n\t};\n\t=====*/\n\n\tvar toPixel;\n\tif(!has(\"ie\")){\n\t\ttoPixel = function(element, value){\n\t\t\t// style values can be floats, client code may want\n\t\t\t// to round for integer pixels.\n\t\t\treturn parseFloat(value) || 0;\n\t\t};\n\t}else{\n\t\ttoPixel = function(element, avalue){\n\t\t\tif(!avalue){ return 0; }\n\t\t\t// on IE7, medium is usually 4 pixels\n\t\t\tif(avalue == \"medium\"){ return 4; }\n\t\t\t// style values can be floats, client code may\n\t\t\t// want to round this value for integer pixels.\n\t\t\tif(avalue.slice && avalue.slice(-2) == 'px'){ return parseFloat(avalue); }\n\t\t\tvar s = element.style, rs = element.runtimeStyle, cs = element.currentStyle,\n\t\t\t\tsLeft = s.left, rsLeft = rs.left;\n\t\t\trs.left = cs.left;\n\t\t\ttry{\n\t\t\t\t// 'avalue' may be incompatible with style.left, which can cause IE to throw\n\t\t\t\t// this has been observed for border widths using \"thin\", \"medium\", \"thick\" constants\n\t\t\t\t// those particular constants could be trapped by a lookup\n\t\t\t\t// but perhaps there are more\n\t\t\t\ts.left = avalue;\n\t\t\t\tavalue = s.pixelLeft;\n\t\t\t}catch(e){\n\t\t\t\tavalue = 0;\n\t\t\t}\n\t\t\ts.left = sLeft;\n\t\t\trs.left = rsLeft;\n\t\t\treturn avalue;\n\t\t};\n\t}\n\tstyle.toPixelValue = toPixel;\n\t/*=====\n\tstyle.toPixelValue = function(node, value){\n\t\t// summary:\n\t\t//\t\tconverts style value to pixels on IE or return a numeric value.\n\t\t// node: DOMNode\n\t\t// value: String\n\t\t// returns: Number\n\t};\n\t=====*/\n\n\t// FIXME: there opacity quirks on FF that we haven't ported over. Hrm.\n\n\tvar astr = \"DXImageTransform.Microsoft.Alpha\";\n\tvar af = function(n, f){\n\t\ttry{\n\t\t\treturn n.filters.item(astr);\n\t\t}catch(e){\n\t\t\treturn f ? {} : null;\n\t\t}\n\t};\n\n\tvar _getOpacity =\n\t\thas(\"ie\") < 9 || (has(\"ie\") && has(\"quirks\")) ? function(node){\n\t\t\ttry{\n\t\t\t\treturn af(node).Opacity / 100; // Number\n\t\t\t}catch(e){\n\t\t\t\treturn 1; // Number\n\t\t\t}\n\t\t} :\n\t\tfunction(node){\n\t\t\treturn getComputedStyle(node).opacity;\n\t\t};\n\n\tvar _setOpacity =\n\t\thas(\"ie\") < 9 || (has(\"ie\") && has(\"quirks\")) ? function(/*DomNode*/ node, /*Number*/ opacity){\n\t\t\tvar ov = opacity * 100, opaque = opacity == 1;\n\t\t\tnode.style.zoom = opaque ? \"\" : 1;\n\n\t\t\tif(!af(node)){\n\t\t\t\tif(opaque){\n\t\t\t\t\treturn opacity;\n\t\t\t\t}\n\t\t\t\tnode.style.filter += \" progid:\" + astr + \"(Opacity=\" + ov + \")\";\n\t\t\t}else{\n\t\t\t\taf(node, 1).Opacity = ov;\n\t\t\t}\n\n\t\t\t// on IE7 Alpha(Filter opacity=100) makes text look fuzzy so disable it altogether (bug #2661),\n\t\t\t//but still update the opacity value so we can get a correct reading if it is read later.\n\t\t\taf(node, 1).Enabled = !opaque;\n\n\t\t\tif(node.tagName.toLowerCase() == \"tr\"){\n\t\t\t\tfor(var td = node.firstChild; td; td = td.nextSibling){\n\t\t\t\t\tif(td.tagName.toLowerCase() == \"td\"){\n\t\t\t\t\t\t_setOpacity(td, opacity);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn opacity;\n\t\t} :\n\t\tfunction(node, opacity){\n\t\t\treturn node.style.opacity = opacity;\n\t\t};\n\n\tvar _pixelNamesCache = {\n\t\tleft: true, top: true\n\t};\n\tvar _pixelRegExp = /margin|padding|width|height|max|min|offset/; // |border\n\tfunction _toStyleValue(node, type, value){\n\t\t//TODO: should we really be doing string case conversion here? Should we cache it? Need to profile!\n\t\ttype = type.toLowerCase();\n\t\tif(has(\"ie\")){\n\t\t\tif(value == \"auto\"){\n\t\t\t\tif(type == \"height\"){ return node.offsetHeight; }\n\t\t\t\tif(type == \"width\"){ return node.offsetWidth; }\n\t\t\t}\n\t\t\tif(type == \"fontweight\"){\n\t\t\t\tswitch(value){\n\t\t\t\t\tcase 700: return \"bold\";\n\t\t\t\t\tcase 400:\n\t\t\t\t\tdefault: return \"normal\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(!(type in _pixelNamesCache)){\n\t\t\t_pixelNamesCache[type] = _pixelRegExp.test(type);\n\t\t}\n\t\treturn _pixelNamesCache[type] ? toPixel(node, value) : value;\n\t}\n\n\tvar _floatStyle = has(\"ie\") ? \"styleFloat\" : \"cssFloat\",\n\t\t_floatAliases = {\"cssFloat\": _floatStyle, \"styleFloat\": _floatStyle, \"float\": _floatStyle};\n\n\t// public API\n\n\tstyle.get = function getStyle(/*DOMNode|String*/ node, /*String?*/ name){\n\t\t// summary:\n\t\t//\t\tAccesses styles on a node.\n\t\t// description:\n\t\t//\t\tGetting the style value uses the computed style for the node, so the value\n\t\t//\t\twill be a calculated value, not just the immediate node.style value.\n\t\t//\t\tAlso when getting values, use specific style names,\n\t\t//\t\tlike \"borderBottomWidth\" instead of \"border\" since compound values like\n\t\t//\t\t\"border\" are not necessarily reflected as expected.\n\t\t//\t\tIf you want to get node dimensions, use `dojo.marginBox()`,\n\t\t//\t\t`dojo.contentBox()` or `dojo.position()`.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to node to get style for\n\t\t// name: String?\n\t\t//\t\tthe style property to get\n\t\t// example:\n\t\t//\t\tPassing only an ID or node returns the computed style object of\n\t\t//\t\tthe node:\n\t\t//\t|\tdojo.getStyle(\"thinger\");\n\t\t// example:\n\t\t//\t\tPassing a node and a style property returns the current\n\t\t//\t\tnormalized, computed value for that property:\n\t\t//\t|\tdojo.getStyle(\"thinger\", \"opacity\"); // 1 by default\n\n\t\tvar n = dom.byId(node), l = arguments.length, op = (name == \"opacity\");\n\t\tif(l == 2 && op){\n\t\t\treturn _getOpacity(n);\n\t\t}\n\t\tname = _floatAliases[name] || name;\n\t\tvar s = style.getComputedStyle(n);\n\t\treturn (l == 1) ? s : _toStyleValue(n, name, s[name] || n.style[name]); /* CSS2Properties||String||Number */\n\t};\n\n\tstyle.set = function setStyle(/*DOMNode|String*/ node, /*String|Object*/ name, /*String?*/ value){\n\t\t// summary:\n\t\t//\t\tSets styles on a node.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to node to set style for\n\t\t// name: String|Object\n\t\t//\t\tthe style property to set in DOM-accessor format\n\t\t//\t\t(\"borderWidth\", not \"border-width\") or an object with key/value\n\t\t//\t\tpairs suitable for setting each property.\n\t\t// value: String?\n\t\t//\t\tIf passed, sets value on the node for style, handling\n\t\t//\t\tcross-browser concerns.  When setting a pixel value,\n\t\t//\t\tbe sure to include \"px\" in the value. For instance, top: \"200px\".\n\t\t//\t\tOtherwise, in some cases, some browsers will not apply the style.\n\t\t//\n\t\t// example:\n\t\t//\t\tPassing a node, a style property, and a value changes the\n\t\t//\t\tcurrent display of the node and returns the new computed value\n\t\t//\t|\tdojo.setStyle(\"thinger\", \"opacity\", 0.5); // == 0.5\n\t\t//\n\t\t// example:\n\t\t//\t\tPassing a node, an object-style style property sets each of the values in turn and returns the computed style object of the node:\n\t\t//\t|\tdojo.setStyle(\"thinger\", {\n\t\t//\t|\t\t\"opacity\": 0.5,\n\t\t//\t|\t\t\"border\": \"3px solid black\",\n\t\t//\t|\t\t\"height\": \"300px\"\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t\tWhen the CSS style property is hyphenated, the JavaScript property is camelCased.\n\t\t//\t\tfont-size becomes fontSize, and so on.\n\t\t//\t|\tdojo.setStyle(\"thinger\",{\n\t\t//\t|\t\tfontSize:\"14pt\",\n\t\t//\t|\t\tletterSpacing:\"1.2em\"\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t\tdojo/NodeList implements .style() using the same syntax, omitting the \"node\" parameter, calling\n\t\t//\t\tdojo.style() on every element of the list. See: `dojo.query()` and `dojo/NodeList`\n\t\t//\t|\tdojo.query(\".someClassName\").style(\"visibility\",\"hidden\");\n\t\t//\t|\t// or\n\t\t//\t|\tdojo.query(\"#baz > div\").style({\n\t\t//\t|\t\topacity:0.75,\n\t\t//\t|\t\tfontSize:\"13pt\"\n\t\t//\t|\t});\n\n\t\tvar n = dom.byId(node), l = arguments.length, op = (name == \"opacity\");\n\t\tname = _floatAliases[name] || name;\n\t\tif(l == 3){\n\t\t\treturn op ? _setOpacity(n, value) : n.style[name] = value; // Number\n\t\t}\n\t\tfor(var x in name){\n\t\t\tstyle.set(node, x, name[x]);\n\t\t}\n\t\treturn style.getComputedStyle(n);\n\t};\n\n\treturn style;\n});\n\n},\n'dojo/dom-geometry':function(){\ndefine([\"./sniff\", \"./_base/window\",\"./dom\", \"./dom-style\"],\n\t\tfunction(has, win, dom, style){\n\t// module:\n\t//\t\tdojo/dom-geometry\n\n\t// the result object\n\tvar geom = {\n\t\t// summary:\n\t\t//\t\tThis module defines the core dojo DOM geometry API.\n\t};\n\n\t// Box functions will assume this model.\n\t// On IE/Opera, BORDER_BOX will be set if the primary document is in quirks mode.\n\t// Can be set to change behavior of box setters.\n\n\t// can be either:\n\t//\t\"border-box\"\n\t//\t\"content-box\" (default)\n\tgeom.boxModel = \"content-box\";\n\n\t// We punt per-node box mode testing completely.\n\t// If anybody cares, we can provide an additional (optional) unit\n\t// that overrides existing code to include per-node box sensitivity.\n\n\t// Opera documentation claims that Opera 9 uses border-box in BackCompat mode.\n\t// but experiments (Opera 9.10.8679 on Windows Vista) indicate that it actually continues to use content-box.\n\t// IIRC, earlier versions of Opera did in fact use border-box.\n\t// Opera guys, this is really confusing. Opera being broken in quirks mode is not our fault.\n\n\tif(has(\"ie\") /*|| has(\"opera\")*/){\n\t\t// client code may have to adjust if compatMode varies across iframes\n\t\tgeom.boxModel = document.compatMode == \"BackCompat\" ? \"border-box\" : \"content-box\";\n\t}\n\n\tgeom.getPadExtents = function getPadExtents(/*DomNode*/ node, /*Object*/ computedStyle){\n\t\t// summary:\n\t\t//\t\tReturns object with special values specifically useful for node\n\t\t//\t\tfitting.\n\t\t// description:\n\t\t//\t\tReturns an object with `w`, `h`, `l`, `t` properties:\n\t\t//\t|\t\tl/t/r/b = left/top/right/bottom padding (respectively)\n\t\t//\t|\t\tw = the total of the left and right padding\n\t\t//\t|\t\th = the total of the top and bottom padding\n\t\t//\t\tIf 'node' has position, l/t forms the origin for child nodes.\n\t\t//\t\tThe w/h are used for calculating boxes.\n\t\t//\t\tNormally application code will not need to invoke this\n\t\t//\t\tdirectly, and will use the ...box... functions instead.\n\t\t// node: DOMNode\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\tnode = dom.byId(node);\n\t\tvar s = computedStyle || style.getComputedStyle(node), px = style.toPixelValue,\n\t\t\tl = px(node, s.paddingLeft), t = px(node, s.paddingTop), r = px(node, s.paddingRight), b = px(node, s.paddingBottom);\n\t\treturn {l: l, t: t, r: r, b: b, w: l + r, h: t + b};\n\t};\n\n\tvar none = \"none\";\n\n\tgeom.getBorderExtents = function getBorderExtents(/*DomNode*/ node, /*Object*/ computedStyle){\n\t\t// summary:\n\t\t//\t\treturns an object with properties useful for noting the border\n\t\t//\t\tdimensions.\n\t\t// description:\n\t\t//\t\t- l/t/r/b = the sum of left/top/right/bottom border (respectively)\n\t\t//\t\t- w = the sum of the left and right border\n\t\t//\t\t- h = the sum of the top and bottom border\n\t\t//\n\t\t//\t\tThe w/h are used for calculating boxes.\n\t\t//\t\tNormally application code will not need to invoke this\n\t\t//\t\tdirectly, and will use the ...box... functions instead.\n\t\t// node: DOMNode\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\tnode = dom.byId(node);\n\t\tvar px = style.toPixelValue, s = computedStyle || style.getComputedStyle(node),\n\t\t\tl = s.borderLeftStyle != none ? px(node, s.borderLeftWidth) : 0,\n\t\t\tt = s.borderTopStyle != none ? px(node, s.borderTopWidth) : 0,\n\t\t\tr = s.borderRightStyle != none ? px(node, s.borderRightWidth) : 0,\n\t\t\tb = s.borderBottomStyle != none ? px(node, s.borderBottomWidth) : 0;\n\t\treturn {l: l, t: t, r: r, b: b, w: l + r, h: t + b};\n\t};\n\n\tgeom.getPadBorderExtents = function getPadBorderExtents(/*DomNode*/ node, /*Object*/ computedStyle){\n\t\t// summary:\n\t\t//\t\tReturns object with properties useful for box fitting with\n\t\t//\t\tregards to padding.\n\t\t// description:\n\t\t//\t\t- l/t/r/b = the sum of left/top/right/bottom padding and left/top/right/bottom border (respectively)\n\t\t//\t\t- w = the sum of the left and right padding and border\n\t\t//\t\t- h = the sum of the top and bottom padding and border\n\t\t//\n\t\t//\t\tThe w/h are used for calculating boxes.\n\t\t//\t\tNormally application code will not need to invoke this\n\t\t//\t\tdirectly, and will use the ...box... functions instead.\n\t\t// node: DOMNode\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\tnode = dom.byId(node);\n\t\tvar s = computedStyle || style.getComputedStyle(node),\n\t\t\tp = geom.getPadExtents(node, s),\n\t\t\tb = geom.getBorderExtents(node, s);\n\t\treturn {\n\t\t\tl: p.l + b.l,\n\t\t\tt: p.t + b.t,\n\t\t\tr: p.r + b.r,\n\t\t\tb: p.b + b.b,\n\t\t\tw: p.w + b.w,\n\t\t\th: p.h + b.h\n\t\t};\n\t};\n\n\tgeom.getMarginExtents = function getMarginExtents(node, computedStyle){\n\t\t// summary:\n\t\t//\t\treturns object with properties useful for box fitting with\n\t\t//\t\tregards to box margins (i.e., the outer-box).\n\t\t//\n\t\t//\t\t- l/t = marginLeft, marginTop, respectively\n\t\t//\t\t- w = total width, margin inclusive\n\t\t//\t\t- h = total height, margin inclusive\n\t\t//\n\t\t//\t\tThe w/h are used for calculating boxes.\n\t\t//\t\tNormally application code will not need to invoke this\n\t\t//\t\tdirectly, and will use the ...box... functions instead.\n\t\t// node: DOMNode\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\tnode = dom.byId(node);\n\t\tvar s = computedStyle || style.getComputedStyle(node), px = style.toPixelValue,\n\t\t\tl = px(node, s.marginLeft), t = px(node, s.marginTop), r = px(node, s.marginRight), b = px(node, s.marginBottom);\n\t\treturn {l: l, t: t, r: r, b: b, w: l + r, h: t + b};\n\t};\n\n\t// Box getters work in any box context because offsetWidth/clientWidth\n\t// are invariant wrt box context\n\t//\n\t// They do *not* work for display: inline objects that have padding styles\n\t// because the user agent ignores padding (it's bogus styling in any case)\n\t//\n\t// Be careful with IMGs because they are inline or block depending on\n\t// browser and browser mode.\n\n\t// Although it would be easier to read, there are not separate versions of\n\t// _getMarginBox for each browser because:\n\t// 1. the branching is not expensive\n\t// 2. factoring the shared code wastes cycles (function call overhead)\n\t// 3. duplicating the shared code wastes bytes\n\n\tgeom.getMarginBox = function getMarginBox(/*DomNode*/ node, /*Object*/ computedStyle){\n\t\t// summary:\n\t\t//\t\treturns an object that encodes the width, height, left and top\n\t\t//\t\tpositions of the node's margin box.\n\t\t// node: DOMNode\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\tnode = dom.byId(node);\n\t\tvar s = computedStyle || style.getComputedStyle(node), me = geom.getMarginExtents(node, s),\n\t\t\tl = node.offsetLeft - me.l, t = node.offsetTop - me.t, p = node.parentNode, px = style.toPixelValue, pcs;\n\t\tif(has(\"mozilla\")){\n\t\t\t// Mozilla:\n\t\t\t// If offsetParent has a computed overflow != visible, the offsetLeft is decreased\n\t\t\t// by the parent's border.\n\t\t\t// We don't want to compute the parent's style, so instead we examine node's\n\t\t\t// computed left/top which is more stable.\n\t\t\tvar sl = parseFloat(s.left), st = parseFloat(s.top);\n\t\t\tif(!isNaN(sl) && !isNaN(st)){\n\t\t\t\tl = sl;\n\t\t\t\tt = st;\n\t\t\t}else{\n\t\t\t\t// If child's computed left/top are not parseable as a number (e.g. \"auto\"), we\n\t\t\t\t// have no choice but to examine the parent's computed style.\n\t\t\t\tif(p && p.style){\n\t\t\t\t\tpcs = style.getComputedStyle(p);\n\t\t\t\t\tif(pcs.overflow != \"visible\"){\n\t\t\t\t\t\tl += pcs.borderLeftStyle != none ? px(node, pcs.borderLeftWidth) : 0;\n\t\t\t\t\t\tt += pcs.borderTopStyle != none ? px(node, pcs.borderTopWidth) : 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}else if(has(\"opera\") || (has(\"ie\") == 8 && !has(\"quirks\"))){\n\t\t\t// On Opera and IE 8, offsetLeft/Top includes the parent's border\n\t\t\tif(p){\n\t\t\t\tpcs = style.getComputedStyle(p);\n\t\t\t\tl -= pcs.borderLeftStyle != none ? px(node, pcs.borderLeftWidth) : 0;\n\t\t\t\tt -= pcs.borderTopStyle != none ? px(node, pcs.borderTopWidth) : 0;\n\t\t\t}\n\t\t}\n\t\treturn {l: l, t: t, w: node.offsetWidth + me.w, h: node.offsetHeight + me.h};\n\t};\n\n\tgeom.getContentBox = function getContentBox(node, computedStyle){\n\t\t// summary:\n\t\t//\t\tReturns an object that encodes the width, height, left and top\n\t\t//\t\tpositions of the node's content box, irrespective of the\n\t\t//\t\tcurrent box model.\n\t\t// node: DOMNode\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\t// clientWidth/Height are important since the automatically account for scrollbars\n\t\t// fallback to offsetWidth/Height for special cases (see #3378)\n\t\tnode = dom.byId(node);\n\t\tvar s = computedStyle || style.getComputedStyle(node), w = node.clientWidth, h,\n\t\t\tpe = geom.getPadExtents(node, s), be = geom.getBorderExtents(node, s);\n\t\tif(!w){\n\t\t\tw = node.offsetWidth;\n\t\t\th = node.offsetHeight;\n\t\t}else{\n\t\t\th = node.clientHeight;\n\t\t\tbe.w = be.h = 0;\n\t\t}\n\t\t// On Opera, offsetLeft includes the parent's border\n\t\tif(has(\"opera\")){\n\t\t\tpe.l += be.l;\n\t\t\tpe.t += be.t;\n\t\t}\n\t\treturn {l: pe.l, t: pe.t, w: w - pe.w - be.w, h: h - pe.h - be.h};\n\t};\n\n\t// Box setters depend on box context because interpretation of width/height styles\n\t// vary wrt box context.\n\t//\n\t// The value of boxModel is used to determine box context.\n\t// boxModel can be set directly to change behavior.\n\t//\n\t// Beware of display: inline objects that have padding styles\n\t// because the user agent ignores padding (it's a bogus setup anyway)\n\t//\n\t// Be careful with IMGs because they are inline or block depending on\n\t// browser and browser mode.\n\t//\n\t// Elements other than DIV may have special quirks, like built-in\n\t// margins or padding, or values not detectable via computedStyle.\n\t// In particular, margins on TABLE do not seems to appear\n\t// at all in computedStyle on Mozilla.\n\n\tfunction setBox(/*DomNode*/ node, /*Number?*/ l, /*Number?*/ t, /*Number?*/ w, /*Number?*/ h, /*String?*/ u){\n\t\t// summary:\n\t\t//\t\tsets width/height/left/top in the current (native) box-model\n\t\t//\t\tdimensions. Uses the unit passed in u.\n\t\t// node:\n\t\t//\t\tDOM Node reference. Id string not supported for performance\n\t\t//\t\treasons.\n\t\t// l:\n\t\t//\t\tleft offset from parent.\n\t\t// t:\n\t\t//\t\ttop offset from parent.\n\t\t// w:\n\t\t//\t\twidth in current box model.\n\t\t// h:\n\t\t//\t\twidth in current box model.\n\t\t// u:\n\t\t//\t\tunit measure to use for other measures. Defaults to \"px\".\n\t\tu = u || \"px\";\n\t\tvar s = node.style;\n\t\tif(!isNaN(l)){\n\t\t\ts.left = l + u;\n\t\t}\n\t\tif(!isNaN(t)){\n\t\t\ts.top = t + u;\n\t\t}\n\t\tif(w >= 0){\n\t\t\ts.width = w + u;\n\t\t}\n\t\tif(h >= 0){\n\t\t\ts.height = h + u;\n\t\t}\n\t}\n\n\tfunction isButtonTag(/*DomNode*/ node){\n\t\t// summary:\n\t\t//\t\tTrue if the node is BUTTON or INPUT.type=\"button\".\n\t\treturn node.tagName.toLowerCase() == \"button\" ||\n\t\t\tnode.tagName.toLowerCase() == \"input\" && (node.getAttribute(\"type\") || \"\").toLowerCase() == \"button\"; // boolean\n\t}\n\n\tfunction usesBorderBox(/*DomNode*/ node){\n\t\t// summary:\n\t\t//\t\tTrue if the node uses border-box layout.\n\n\t\t// We could test the computed style of node to see if a particular box\n\t\t// has been specified, but there are details and we choose not to bother.\n\n\t\t// TABLE and BUTTON (and INPUT type=button) are always border-box by default.\n\t\t// If you have assigned a different box to either one via CSS then\n\t\t// box functions will break.\n\n\t\treturn geom.boxModel == \"border-box\" || node.tagName.toLowerCase() == \"table\" || isButtonTag(node); // boolean\n\t}\n\n\tgeom.setContentSize = function setContentSize(/*DomNode*/ node, /*Object*/ box, /*Object*/ computedStyle){\n\t\t// summary:\n\t\t//\t\tSets the size of the node's contents, irrespective of margins,\n\t\t//\t\tpadding, or borders.\n\t\t// node: DOMNode\n\t\t// box: Object\n\t\t//\t\thash with optional \"w\", and \"h\" properties for \"width\", and \"height\"\n\t\t//\t\trespectively. All specified properties should have numeric values in whole pixels.\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\tnode = dom.byId(node);\n\t\tvar w = box.w, h = box.h;\n\t\tif(usesBorderBox(node)){\n\t\t\tvar pb = geom.getPadBorderExtents(node, computedStyle);\n\t\t\tif(w >= 0){\n\t\t\t\tw += pb.w;\n\t\t\t}\n\t\t\tif(h >= 0){\n\t\t\t\th += pb.h;\n\t\t\t}\n\t\t}\n\t\tsetBox(node, NaN, NaN, w, h);\n\t};\n\n\tvar nilExtents = {l: 0, t: 0, w: 0, h: 0};\n\n\tgeom.setMarginBox = function setMarginBox(/*DomNode*/ node, /*Object*/ box, /*Object*/ computedStyle){\n\t\t// summary:\n\t\t//\t\tsets the size of the node's margin box and placement\n\t\t//\t\t(left/top), irrespective of box model. Think of it as a\n\t\t//\t\tpassthrough to setBox that handles box-model vagaries for\n\t\t//\t\tyou.\n\t\t// node: DOMNode\n\t\t// box: Object\n\t\t//\t\thash with optional \"l\", \"t\", \"w\", and \"h\" properties for \"left\", \"right\", \"width\", and \"height\"\n\t\t//\t\trespectively. All specified properties should have numeric values in whole pixels.\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\tnode = dom.byId(node);\n\t\tvar s = computedStyle || style.getComputedStyle(node), w = box.w, h = box.h,\n\t\t// Some elements have special padding, margin, and box-model settings.\n\t\t// To use box functions you may need to set padding, margin explicitly.\n\t\t// Controlling box-model is harder, in a pinch you might set dojo/dom-geometry.boxModel.\n\t\t\tpb = usesBorderBox(node) ? nilExtents : geom.getPadBorderExtents(node, s),\n\t\t\tmb = geom.getMarginExtents(node, s);\n\t\tif(has(\"webkit\")){\n\t\t\t// on Safari (3.1.2), button nodes with no explicit size have a default margin\n\t\t\t// setting an explicit size eliminates the margin.\n\t\t\t// We have to swizzle the width to get correct margin reading.\n\t\t\tif(isButtonTag(node)){\n\t\t\t\tvar ns = node.style;\n\t\t\t\tif(w >= 0 && !ns.width){\n\t\t\t\t\tns.width = \"4px\";\n\t\t\t\t}\n\t\t\t\tif(h >= 0 && !ns.height){\n\t\t\t\t\tns.height = \"4px\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(w >= 0){\n\t\t\tw = Math.max(w - pb.w - mb.w, 0);\n\t\t}\n\t\tif(h >= 0){\n\t\t\th = Math.max(h - pb.h - mb.h, 0);\n\t\t}\n\t\tsetBox(node, box.l, box.t, w, h);\n\t};\n\n\t// =============================\n\t// Positioning\n\t// =============================\n\n\tgeom.isBodyLtr = function isBodyLtr(/*Document?*/ doc){\n\t\t// summary:\n\t\t//\t\tReturns true if the current language is left-to-right, and false otherwise.\n\t\t// doc: Document?\n\t\t//\t\tOptional document to query.   If unspecified, use win.doc.\n\t\t// returns: Boolean\n\n\t\tdoc = doc || win.doc;\n\t\treturn (win.body(doc).dir || doc.documentElement.dir || \"ltr\").toLowerCase() == \"ltr\"; // Boolean\n\t};\n\n\tgeom.docScroll = function docScroll(/*Document?*/ doc){\n\t\t// summary:\n\t\t//\t\tReturns an object with {node, x, y} with corresponding offsets.\n\t\t// doc: Document?\n\t\t//\t\tOptional document to query.   If unspecified, use win.doc.\n\t\t// returns: Object\n\n\t\tdoc = doc || win.doc;\n\t\tvar node = win.doc.parentWindow || win.doc.defaultView;   // use UI window, not dojo.global window.   TODO: use dojo/window::get() except for circular dependency problem\n\t\treturn \"pageXOffset\" in node ? {x: node.pageXOffset, y: node.pageYOffset } :\n\t\t\t(node = has(\"quirks\") ? win.body(doc) : doc.documentElement) &&\n\t\t\t\t{x: geom.fixIeBiDiScrollLeft(node.scrollLeft || 0, doc), y: node.scrollTop || 0 };\n\t};\n\n\tif(has(\"ie\")){\n\t\tgeom.getIeDocumentElementOffset = function getIeDocumentElementOffset(/*Document?*/ doc){\n\t\t\t// summary:\n\t\t\t//\t\treturns the offset in x and y from the document body to the\n\t\t\t//\t\tvisual edge of the page for IE\n\t\t\t// doc: Document?\n\t\t\t//\t\tOptional document to query.   If unspecified, use win.doc.\n\t\t\t// description:\n\t\t\t//\t\tThe following values in IE contain an offset:\n\t\t\t//\t|\t\tevent.clientX\n\t\t\t//\t|\t\tevent.clientY\n\t\t\t//\t|\t\tnode.getBoundingClientRect().left\n\t\t\t//\t|\t\tnode.getBoundingClientRect().top\n\t\t\t//\t\tBut other position related values do not contain this offset,\n\t\t\t//\t\tsuch as node.offsetLeft, node.offsetTop, node.style.left and\n\t\t\t//\t\tnode.style.top. The offset is always (2, 2) in LTR direction.\n\t\t\t//\t\tWhen the body is in RTL direction, the offset counts the width\n\t\t\t//\t\tof left scroll bar's width.  This function computes the actual\n\t\t\t//\t\toffset.\n\n\t\t\t//NOTE: assumes we're being called in an IE browser\n\n\t\t\tdoc = doc || win.doc;\n\t\t\tvar de = doc.documentElement; // only deal with HTML element here, position() handles body/quirks\n\n\t\t\tif(has(\"ie\") < 8){\n\t\t\t\tvar r = de.getBoundingClientRect(), // works well for IE6+\n\t\t\t\t\tl = r.left, t = r.top;\n\t\t\t\tif(has(\"ie\") < 7){\n\t\t\t\t\tl += de.clientLeft;\t// scrollbar size in strict/RTL, or,\n\t\t\t\t\tt += de.clientTop;\t// HTML border size in strict\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tx: l < 0 ? 0 : l, // FRAME element border size can lead to inaccurate negative values\n\t\t\t\t\ty: t < 0 ? 0 : t\n\t\t\t\t};\n\t\t\t}else{\n\t\t\t\treturn {\n\t\t\t\t\tx: 0,\n\t\t\t\t\ty: 0\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t}\n\n\tgeom.fixIeBiDiScrollLeft = function fixIeBiDiScrollLeft(/*Integer*/ scrollLeft, /*Document?*/ doc){\n\t\t// summary:\n\t\t//\t\tIn RTL direction, scrollLeft should be a negative value, but IE\n\t\t//\t\treturns a positive one. All codes using documentElement.scrollLeft\n\t\t//\t\tmust call this function to fix this error, otherwise the position\n\t\t//\t\twill offset to right when there is a horizontal scrollbar.\n\t\t// scrollLeft: Number\n\t\t// doc: Document?\n\t\t//\t\tOptional document to query.   If unspecified, use win.doc.\n\t\t// returns: Number\n\n\t\t// In RTL direction, scrollLeft should be a negative value, but IE\n\t\t// returns a positive one. All codes using documentElement.scrollLeft\n\t\t// must call this function to fix this error, otherwise the position\n\t\t// will offset to right when there is a horizontal scrollbar.\n\n\t\tdoc = doc || win.doc;\n\t\tvar ie = has(\"ie\");\n\t\tif(ie && !geom.isBodyLtr(doc)){\n\t\t\tvar qk = has(\"quirks\"),\n\t\t\t\tde = qk ? win.body(doc) : doc.documentElement,\n\t\t\t\tpwin = win.global;\t// TODO: use winUtils.get(doc) after resolving circular dependency b/w dom-geometry.js and dojo/window.js\n\t\t\tif(ie == 6 && !qk && pwin.frameElement && de.scrollHeight > de.clientHeight){\n\t\t\t\tscrollLeft += de.clientLeft; // workaround ie6+strict+rtl+iframe+vertical-scrollbar bug where clientWidth is too small by clientLeft pixels\n\t\t\t}\n\t\t\treturn (ie < 8 || qk) ? (scrollLeft + de.clientWidth - de.scrollWidth) : -scrollLeft; // Integer\n\t\t}\n\t\treturn scrollLeft; // Integer\n\t};\n\n\tgeom.position = function(/*DomNode*/ node, /*Boolean?*/ includeScroll){\n\t\t// summary:\n\t\t//\t\tGets the position and size of the passed element relative to\n\t\t//\t\tthe viewport (if includeScroll==false), or relative to the\n\t\t//\t\tdocument root (if includeScroll==true).\n\t\t//\n\t\t// description:\n\t\t//\t\tReturns an object of the form:\n\t\t//\t\t`{ x: 100, y: 300, w: 20, h: 15 }`.\n\t\t//\t\tIf includeScroll==true, the x and y values will include any\n\t\t//\t\tdocument offsets that may affect the position relative to the\n\t\t//\t\tviewport.\n\t\t//\t\tUses the border-box model (inclusive of border and padding but\n\t\t//\t\tnot margin).  Does not act as a setter.\n\t\t// node: DOMNode|String\n\t\t// includeScroll: Boolean?\n\t\t// returns: Object\n\n\t\tnode = dom.byId(node);\n\t\tvar\tdb = win.body(node.ownerDocument),\n\t\t\tret = node.getBoundingClientRect();\n\t\tret = {x: ret.left, y: ret.top, w: ret.right - ret.left, h: ret.bottom - ret.top};\n\n\t\tif(has(\"ie\")){\n\t\t\t// On IE there's a 2px offset that we need to adjust for, see dojo.getIeDocumentElementOffset()\n\t\t\tvar offset = geom.getIeDocumentElementOffset(node.ownerDocument);\n\n\t\t\t// fixes the position in IE, quirks mode\n\t\t\tret.x -= offset.x + (has(\"quirks\") ? db.clientLeft + db.offsetLeft : 0);\n\t\t\tret.y -= offset.y + (has(\"quirks\") ? db.clientTop + db.offsetTop : 0);\n\t\t}\n\n\t\t// account for document scrolling\n\t\t// if offsetParent is used, ret value already includes scroll position\n\t\t// so we may have to actually remove that value if !includeScroll\n\t\tif(includeScroll){\n\t\t\tvar scroll = geom.docScroll(node.ownerDocument);\n\t\t\tret.x += scroll.x;\n\t\t\tret.y += scroll.y;\n\t\t}\n\n\t\treturn ret; // Object\n\t};\n\n\t// random \"private\" functions wildly used throughout the toolkit\n\n\tgeom.getMarginSize = function getMarginSize(/*DomNode*/ node, /*Object*/ computedStyle){\n\t\t// summary:\n\t\t//\t\treturns an object that encodes the width and height of\n\t\t//\t\tthe node's margin box\n\t\t// node: DOMNode|String\n\t\t// computedStyle: Object?\n\t\t//\t\tThis parameter accepts computed styles object.\n\t\t//\t\tIf this parameter is omitted, the functions will call\n\t\t//\t\tdojo.getComputedStyle to get one. It is a better way, calling\n\t\t//\t\tdojo.computedStyle once, and then pass the reference to this\n\t\t//\t\tcomputedStyle parameter. Wherever possible, reuse the returned\n\t\t//\t\tobject of dojo/dom-style.getComputedStyle().\n\n\t\tnode = dom.byId(node);\n\t\tvar me = geom.getMarginExtents(node, computedStyle || style.getComputedStyle(node));\n\t\tvar size = node.getBoundingClientRect();\n\t\treturn {\n\t\t\tw: (size.right - size.left) + me.w,\n\t\t\th: (size.bottom - size.top) + me.h\n\t\t};\n\t};\n\n\tgeom.normalizeEvent = function(event){\n\t\t// summary:\n\t\t//\t\tNormalizes the geometry of a DOM event, normalizing the pageX, pageY,\n\t\t//\t\toffsetX, offsetY, layerX, and layerX properties\n\t\t// event: Object\n\t\tif(!(\"layerX\" in event)){\n\t\t\tevent.layerX = event.offsetX;\n\t\t\tevent.layerY = event.offsetY;\n\t\t}\n\t\tif(!has(\"dom-addeventlistener\")){\n\t\t\t// old IE version\n\t\t\t// FIXME: scroll position query is duped from dojo.html to\n\t\t\t// avoid dependency on that entire module. Now that HTML is in\n\t\t\t// Base, we should convert back to something similar there.\n\t\t\tvar se = event.target;\n\t\t\tvar doc = (se && se.ownerDocument) || document;\n\t\t\t// DO NOT replace the following to use dojo.body(), in IE, document.documentElement should be used\n\t\t\t// here rather than document.body\n\t\t\tvar docBody = has(\"quirks\") ? doc.body : doc.documentElement;\n\t\t\tvar offset = geom.getIeDocumentElementOffset(doc);\n\t\t\tevent.pageX = event.clientX + geom.fixIeBiDiScrollLeft(docBody.scrollLeft || 0, doc) - offset.x;\n\t\t\tevent.pageY = event.clientY + (docBody.scrollTop || 0) - offset.y;\n\t\t}\n\t};\n\n\t// TODO: evaluate separate getters/setters for position and sizes?\n\n\treturn geom;\n});\n\n},\n'dojo/dom-prop':function(){\ndefine([\"exports\", \"./_base/kernel\", \"./sniff\", \"./_base/lang\", \"./dom\", \"./dom-style\", \"./dom-construct\", \"./_base/connect\"],\n\t\tfunction(exports, dojo, has, lang, dom, style, ctr, conn){\n\t// module:\n\t//\t\tdojo/dom-prop\n\t// summary:\n\t//\t\tThis module defines the core dojo DOM properties API.\n\t//\t\tIndirectly depends on dojo.empty() and dojo.toDom().\n\n\t// TODOC: summary not showing up in output, see https://github.com/csnover/js-doc-parse/issues/42\n\n\t// =============================\n\t// Element properties Functions\n\t// =============================\n\n\t// helper to connect events\n\tvar _evtHdlrMap = {}, _ctr = 0, _attrId = dojo._scopeName + \"attrid\";\n\n\texports.names = {\n\t\t// properties renamed to avoid clashes with reserved words\n\t\t\"class\": \"className\",\n\t\t\"for\": \"htmlFor\",\n\t\t// properties written as camelCase\n\t\ttabindex: \"tabIndex\",\n\t\treadonly: \"readOnly\",\n\t\tcolspan: \"colSpan\",\n\t\tframeborder: \"frameBorder\",\n\t\trowspan: \"rowSpan\",\n\t\tvaluetype: \"valueType\"\n\t};\n\n\texports.get = function getProp(/*DOMNode|String*/ node, /*String*/ name){\n\t\t// summary:\n\t\t//\t\tGets a property on an HTML element.\n\t\t// description:\n\t\t//\t\tHandles normalized getting of properties on DOM nodes.\n\t\t//\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to the element to get the property on\n\t\t// name: String\n\t\t//\t\tthe name of the property to get.\n\t\t// returns:\n\t\t//\t\tthe value of the requested property or its default value\n\t\t//\n\t\t// example:\n\t\t//\t|\t// get the current value of the \"foo\" property on a node\n\t\t//\t|\tdojo.getProp(dojo.byId(\"nodeId\"), \"foo\");\n\t\t//\t|\t// or we can just pass the id:\n\t\t//\t|\tdojo.getProp(\"nodeId\", \"foo\");\n\n\t\tnode = dom.byId(node);\n\t\tvar lc = name.toLowerCase(), propName = exports.names[lc] || name;\n\t\treturn node[propName];\t// Anything\n\t};\n\n\texports.set = function setProp(/*DOMNode|String*/ node, /*String|Object*/ name, /*String?*/ value){\n\t\t// summary:\n\t\t//\t\tSets a property on an HTML element.\n\t\t// description:\n\t\t//\t\tHandles normalized setting of properties on DOM nodes.\n\t\t//\n\t\t//\t\tWhen passing functions as values, note that they will not be\n\t\t//\t\tdirectly assigned to slots on the node, but rather the default\n\t\t//\t\tbehavior will be removed and the new behavior will be added\n\t\t//\t\tusing `dojo.connect()`, meaning that event handler properties\n\t\t//\t\twill be normalized and that some caveats with regards to\n\t\t//\t\tnon-standard behaviors for onsubmit apply. Namely that you\n\t\t//\t\tshould cancel form submission using `dojo.stopEvent()` on the\n\t\t//\t\tpassed event object instead of returning a boolean value from\n\t\t//\t\tthe handler itself.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to the element to set the property on\n\t\t// name: String|Object\n\t\t//\t\tthe name of the property to set, or a hash object to set\n\t\t//\t\tmultiple properties at once.\n\t\t// value: String?\n\t\t//\t\tThe value to set for the property\n\t\t// returns:\n\t\t//\t\tthe DOM node\n\t\t//\n\t\t// example:\n\t\t//\t|\t// use prop() to set the tab index\n\t\t//\t|\tdojo.setProp(\"nodeId\", \"tabIndex\", 3);\n\t\t//\t|\n\t\t//\n\t\t// example:\n\t\t//\tSet multiple values at once, including event handlers:\n\t\t//\t|\tdojo.setProp(\"formId\", {\n\t\t//\t|\t\t\"foo\": \"bar\",\n\t\t//\t|\t\t\"tabIndex\": -1,\n\t\t//\t|\t\t\"method\": \"POST\",\n\t\t//\t|\t\t\"onsubmit\": function(e){\n\t\t//\t|\t\t\t// stop submitting the form. Note that the IE behavior\n\t\t//\t|\t\t\t// of returning true or false will have no effect here\n\t\t//\t|\t\t\t// since our handler is connect()ed to the built-in\n\t\t//\t|\t\t\t// onsubmit behavior and so we need to use\n\t\t//\t|\t\t\t// dojo.stopEvent() to ensure that the submission\n\t\t//\t|\t\t\t// doesn't proceed.\n\t\t//\t|\t\t\tdojo.stopEvent(e);\n\t\t//\t|\n\t\t//\t|\t\t\t// submit the form with Ajax\n\t\t//\t|\t\t\tdojo.xhrPost({ form: \"formId\" });\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tStyle is s special case: Only set with an object hash of styles\n\t\t//\t|\tdojo.setProp(\"someNode\",{\n\t\t//\t|\t\tid:\"bar\",\n\t\t//\t|\t\tstyle:{\n\t\t//\t|\t\t\twidth:\"200px\", height:\"100px\", color:\"#000\"\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tAgain, only set style as an object hash of styles:\n\t\t//\t|\tvar obj = { color:\"#fff\", backgroundColor:\"#000\" };\n\t\t//\t|\tdojo.setProp(\"someNode\", \"style\", obj);\n\t\t//\t|\n\t\t//\t|\t// though shorter to use `dojo.style()` in this case:\n\t\t//\t|\tdojo.style(\"someNode\", obj);\n\n\t\tnode = dom.byId(node);\n\t\tvar l = arguments.length;\n\t\tif(l == 2 && typeof name != \"string\"){ // inline'd type check\n\t\t\t// the object form of setter: the 2nd argument is a dictionary\n\t\t\tfor(var x in name){\n\t\t\t\texports.set(node, x, name[x]);\n\t\t\t}\n\t\t\treturn node; // DomNode\n\t\t}\n\t\tvar lc = name.toLowerCase(), propName = exports.names[lc] || name;\n\t\tif(propName == \"style\" && typeof value != \"string\"){ // inline'd type check\n\t\t\t// special case: setting a style\n\t\t\tstyle.set(node, value);\n\t\t\treturn node; // DomNode\n\t\t}\n\t\tif(propName == \"innerHTML\"){\n\t\t\t// special case: assigning HTML\n\t\t\t// the hash lists elements with read-only innerHTML on IE\n\t\t\tif(has(\"ie\") && node.tagName.toLowerCase() in {col: 1, colgroup: 1,\n\t\t\t\t\t\ttable: 1, tbody: 1, tfoot: 1, thead: 1, tr: 1, title: 1}){\n\t\t\t\tctr.empty(node);\n\t\t\t\tnode.appendChild(ctr.toDom(value, node.ownerDocument));\n\t\t\t}else{\n\t\t\t\tnode[propName] = value;\n\t\t\t}\n\t\t\treturn node; // DomNode\n\t\t}\n\t\tif(lang.isFunction(value)){\n\t\t\t// special case: assigning an event handler\n\t\t\t// clobber if we can\n\t\t\tvar attrId = node[_attrId];\n\t\t\tif(!attrId){\n\t\t\t\tattrId = _ctr++;\n\t\t\t\tnode[_attrId] = attrId;\n\t\t\t}\n\t\t\tif(!_evtHdlrMap[attrId]){\n\t\t\t\t_evtHdlrMap[attrId] = {};\n\t\t\t}\n\t\t\tvar h = _evtHdlrMap[attrId][propName];\n\t\t\tif(h){\n\t\t\t\t//h.remove();\n\t\t\t\tconn.disconnect(h);\n\t\t\t}else{\n\t\t\t\ttry{\n\t\t\t\t\tdelete node[propName];\n\t\t\t\t}catch(e){}\n\t\t\t}\n\t\t\t// ensure that event objects are normalized, etc.\n\t\t\tif(value){\n\t\t\t\t//_evtHdlrMap[attrId][propName] = on(node, propName, value);\n\t\t\t\t_evtHdlrMap[attrId][propName] = conn.connect(node, propName, value);\n\t\t\t}else{\n\t\t\t\tnode[propName] = null;\n\t\t\t}\n\t\t\treturn node; // DomNode\n\t\t}\n\t\tnode[propName] = value;\n\t\treturn node;\t// DomNode\n\t};\n});\n\n},\n'dojo/when':function(){\ndefine([\n\t\"./Deferred\",\n\t\"./promise/Promise\"\n], function(Deferred, Promise){\n\t\"use strict\";\n\n\t// module:\n\t//\t\tdojo/when\n\n\treturn function when(valueOrPromise, callback, errback, progback){\n\t\t// summary:\n\t\t//\t\tTransparently applies callbacks to values and/or promises.\n\t\t// description:\n\t\t//\t\tAccepts promises but also transparently handles non-promises. If no\n\t\t//\t\tcallbacks are provided returns a promise, regardless of the initial\n\t\t//\t\tvalue. Foreign promises are converted.\n\t\t//\n\t\t//\t\tIf callbacks are provided and the initial value is not a promise,\n\t\t//\t\tthe callback is executed immediately with no error handling. Returns\n\t\t//\t\ta promise if the initial value is a promise, or the result of the\n\t\t//\t\tcallback otherwise.\n\t\t// valueOrPromise:\n\t\t//\t\tEither a regular value or an object with a `then()` method that\n\t\t//\t\tfollows the Promises/A specification.\n\t\t// callback: Function?\n\t\t//\t\tCallback to be invoked when the promise is resolved, or a non-promise\n\t\t//\t\tis received.\n\t\t// errback: Function?\n\t\t//\t\tCallback to be invoked when the promise is rejected.\n\t\t// progback: Function?\n\t\t//\t\tCallback to be invoked when the promise emits a progress update.\n\t\t// returns: dojo/promise/Promise\n\t\t//\t\tPromise, or if a callback is provided, the result of the callback.\n\n\t\tvar receivedPromise = valueOrPromise && typeof valueOrPromise.then === \"function\";\n\t\tvar nativePromise = receivedPromise && valueOrPromise instanceof Promise;\n\n\t\tif(!receivedPromise){\n\t\t\tif(callback){\n\t\t\t\treturn callback(valueOrPromise);\n\t\t\t}else{\n\t\t\t\treturn new Deferred().resolve(valueOrPromise);\n\t\t\t}\n\t\t}else if(!nativePromise){\n\t\t\tvar deferred = new Deferred(valueOrPromise.cancel);\n\t\t\tvalueOrPromise.then(deferred.resolve, deferred.reject, deferred.progress);\n\t\t\tvalueOrPromise = deferred.promise;\n\t\t}\n\n\t\tif(callback || errback || progback){\n\t\t\treturn valueOrPromise.then(callback, errback, progback);\n\t\t}\n\t\treturn valueOrPromise;\n\t};\n});\n\n},\n'dojo/dom-attr':function(){\ndefine([\"exports\", \"./sniff\", \"./_base/lang\", \"./dom\", \"./dom-style\", \"./dom-prop\"],\n\t\tfunction(exports, has, lang, dom, style, prop){\n\t// module:\n\t//\t\tdojo/dom-attr\n\t// summary:\n\t//\t\tThis module defines the core dojo DOM attributes API.\n\n\t// TODOC: summary not showing up in output see https://github.com/csnover/js-doc-parse/issues/42\n\n\t// =============================\n\t// Element attribute Functions\n\t// =============================\n\n\t// This module will be obsolete soon. Use dojo/prop instead.\n\n\t// dojo.attr() should conform to http://www.w3.org/TR/DOM-Level-2-Core/\n\n\t// attribute-related functions (to be obsolete soon)\n\n\tvar forcePropNames = {\n\t\t\tinnerHTML:\t1,\n\t\t\tclassName:\t1,\n\t\t\thtmlFor:\thas(\"ie\"),\n\t\t\tvalue:\t\t1\n\t\t},\n\t\tattrNames = {\n\t\t\t// original attribute names\n\t\t\tclassname: \"class\",\n\t\t\thtmlfor: \"for\",\n\t\t\t// for IE\n\t\t\ttabindex: \"tabIndex\",\n\t\t\treadonly: \"readOnly\"\n\t\t};\n\n\tfunction _hasAttr(node, name){\n\t\tvar attr = node.getAttributeNode && node.getAttributeNode(name);\n\t\treturn attr && attr.specified; // Boolean\n\t}\n\n\t// There is a difference in the presence of certain properties and their default values\n\t// between browsers. For example, on IE \"disabled\" is present on all elements,\n\t// but it is value is \"false\"; \"tabIndex\" of <div> returns 0 by default on IE, yet other browsers\n\t// can return -1.\n\n\texports.has = function hasAttr(/*DOMNode|String*/ node, /*String*/ name){\n\t\t// summary:\n\t\t//\t\tReturns true if the requested attribute is specified on the\n\t\t//\t\tgiven element, and false otherwise.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to the element to check\n\t\t// name: String\n\t\t//\t\tthe name of the attribute\n\t\t// returns: Boolean\n\t\t//\t\ttrue if the requested attribute is specified on the\n\t\t//\t\tgiven element, and false otherwise\n\n\t\tvar lc = name.toLowerCase();\n\t\treturn forcePropNames[prop.names[lc] || name] || _hasAttr(dom.byId(node), attrNames[lc] || name);\t// Boolean\n\t};\n\n\texports.get = function getAttr(/*DOMNode|String*/ node, /*String*/ name){\n\t\t// summary:\n\t\t//\t\tGets an attribute on an HTML element.\n\t\t// description:\n\t\t//\t\tHandles normalized getting of attributes on DOM Nodes.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to the element to get the attribute on\n\t\t// name: String\n\t\t//\t\tthe name of the attribute to get.\n\t\t// returns:\n\t\t//\t\tthe value of the requested attribute or null if that attribute does not have a specified or\n\t\t//\t\tdefault value;\n\t\t//\n\t\t// example:\n\t\t//\t|\t// get the current value of the \"foo\" attribute on a node\n\t\t//\t|\tdojo.getAttr(dojo.byId(\"nodeId\"), \"foo\");\n\t\t//\t|\t// or we can just pass the id:\n\t\t//\t|\tdojo.getAttr(\"nodeId\", \"foo\");\n\n\t\tnode = dom.byId(node);\n\t\tvar lc = name.toLowerCase(),\n\t\t\tpropName = prop.names[lc] || name,\n\t\t\tforceProp = forcePropNames[propName],\n\t\t\tvalue = node[propName];\t\t// should we access this attribute via a property or via getAttribute()?\n\n\t\tif(forceProp && typeof value != \"undefined\"){\n\t\t\t// node's property\n\t\t\treturn value;\t// Anything\n\t\t}\n\t\tif(propName != \"href\" && (typeof value == \"boolean\" || lang.isFunction(value))){\n\t\t\t// node's property\n\t\t\treturn value;\t// Anything\n\t\t}\n\t\t// node's attribute\n\t\t// we need _hasAttr() here to guard against IE returning a default value\n\t\tvar attrName = attrNames[lc] || name;\n\t\treturn _hasAttr(node, attrName) ? node.getAttribute(attrName) : null; // Anything\n\t};\n\n\texports.set = function setAttr(/*DOMNode|String*/ node, /*String|Object*/ name, /*String?*/ value){\n\t\t// summary:\n\t\t//\t\tSets an attribute on an HTML element.\n\t\t// description:\n\t\t//\t\tHandles normalized setting of attributes on DOM Nodes.\n\t\t//\n\t\t//\t\tWhen passing functions as values, note that they will not be\n\t\t//\t\tdirectly assigned to slots on the node, but rather the default\n\t\t//\t\tbehavior will be removed and the new behavior will be added\n\t\t//\t\tusing `dojo.connect()`, meaning that event handler properties\n\t\t//\t\twill be normalized and that some caveats with regards to\n\t\t//\t\tnon-standard behaviors for onsubmit apply. Namely that you\n\t\t//\t\tshould cancel form submission using `dojo.stopEvent()` on the\n\t\t//\t\tpassed event object instead of returning a boolean value from\n\t\t//\t\tthe handler itself.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to the element to set the attribute on\n\t\t// name: String|Object\n\t\t//\t\tthe name of the attribute to set, or a hash of key-value pairs to set.\n\t\t// value: String?\n\t\t//\t\tthe value to set for the attribute, if the name is a string.\n\t\t// returns:\n\t\t//\t\tthe DOM node\n\t\t//\n\t\t// example:\n\t\t//\t|\t// use attr() to set the tab index\n\t\t//\t|\tdojo.setAttr(\"nodeId\", \"tabIndex\", 3);\n\t\t//\n\t\t// example:\n\t\t//\tSet multiple values at once, including event handlers:\n\t\t//\t|\tdojo.setAttr(\"formId\", {\n\t\t//\t|\t\t\"foo\": \"bar\",\n\t\t//\t|\t\t\"tabIndex\": -1,\n\t\t//\t|\t\t\"method\": \"POST\",\n\t\t//\t|\t\t\"onsubmit\": function(e){\n\t\t//\t|\t\t\t// stop submitting the form. Note that the IE behavior\n\t\t//\t|\t\t\t// of returning true or false will have no effect here\n\t\t//\t|\t\t\t// since our handler is connect()ed to the built-in\n\t\t//\t|\t\t\t// onsubmit behavior and so we need to use\n\t\t//\t|\t\t\t// dojo.stopEvent() to ensure that the submission\n\t\t//\t|\t\t\t// doesn't proceed.\n\t\t//\t|\t\t\tdojo.stopEvent(e);\n\t\t//\t|\n\t\t//\t|\t\t\t// submit the form with Ajax\n\t\t//\t|\t\t\tdojo.xhrPost({ form: \"formId\" });\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tStyle is s special case: Only set with an object hash of styles\n\t\t//\t|\tdojo.setAttr(\"someNode\",{\n\t\t//\t|\t\tid:\"bar\",\n\t\t//\t|\t\tstyle:{\n\t\t//\t|\t\t\twidth:\"200px\", height:\"100px\", color:\"#000\"\n\t\t//\t|\t\t}\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tAgain, only set style as an object hash of styles:\n\t\t//\t|\tvar obj = { color:\"#fff\", backgroundColor:\"#000\" };\n\t\t//\t|\tdojo.setAttr(\"someNode\", \"style\", obj);\n\t\t//\t|\n\t\t//\t|\t// though shorter to use `dojo.style()` in this case:\n\t\t//\t|\tdojo.setStyle(\"someNode\", obj);\n\n\t\tnode = dom.byId(node);\n\t\tif(arguments.length == 2){ // inline'd type check\n\t\t\t// the object form of setter: the 2nd argument is a dictionary\n\t\t\tfor(var x in name){\n\t\t\t\texports.set(node, x, name[x]);\n\t\t\t}\n\t\t\treturn node; // DomNode\n\t\t}\n\t\tvar lc = name.toLowerCase(),\n\t\t\tpropName = prop.names[lc] || name,\n\t\t\tforceProp = forcePropNames[propName];\n\t\tif(propName == \"style\" && typeof value != \"string\"){ // inline'd type check\n\t\t\t// special case: setting a style\n\t\t\tstyle.set(node, value);\n\t\t\treturn node; // DomNode\n\t\t}\n\t\tif(forceProp || typeof value == \"boolean\" || lang.isFunction(value)){\n\t\t\treturn prop.set(node, name, value);\n\t\t}\n\t\t// node's attribute\n\t\tnode.setAttribute(attrNames[lc] || name, value);\n\t\treturn node; // DomNode\n\t};\n\n\texports.remove = function removeAttr(/*DOMNode|String*/ node, /*String*/ name){\n\t\t// summary:\n\t\t//\t\tRemoves an attribute from an HTML element.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to the element to remove the attribute from\n\t\t// name: String\n\t\t//\t\tthe name of the attribute to remove\n\n\t\tdom.byId(node).removeAttribute(attrNames[name.toLowerCase()] || name);\n\t};\n\n\texports.getNodeProp = function getNodeProp(/*DomNode|String*/ node, /*String*/ name){\n\t\t// summary:\n\t\t//\t\tReturns an effective value of a property or an attribute.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or reference to the element to remove the attribute from\n\t\t// name: String\n\t\t//\t\tthe name of the attribute\n\t\t// returns:\n\t\t//\t\tthe value of the attribute\n\n\t\tnode = dom.byId(node);\n\t\tvar lc = name.toLowerCase(), propName = prop.names[lc] || name;\n\t\tif((propName in node) && propName != \"href\"){\n\t\t\t// node's property\n\t\t\treturn node[propName];\t// Anything\n\t\t}\n\t\t// node's attribute\n\t\tvar attrName = attrNames[lc] || name;\n\t\treturn _hasAttr(node, attrName) ? node.getAttribute(attrName) : null; // Anything\n\t};\n});\n\n},\n'dojo/dom-construct':function(){\ndefine([\"exports\", \"./_base/kernel\", \"./sniff\", \"./_base/window\", \"./dom\", \"./dom-attr\", \"./on\"],\n\t\tfunction(exports, dojo, has, win, dom, attr, on){\n\t// module:\n\t//\t\tdojo/dom-construct\n\t// summary:\n\t//\t\tThis module defines the core dojo DOM construction API.\n\n\t// TODOC: summary not showing up in output, see https://github.com/csnover/js-doc-parse/issues/42\n\n\t// support stuff for toDom()\n\tvar tagWrap = {\n\t\t\toption: [\"select\"],\n\t\t\ttbody: [\"table\"],\n\t\t\tthead: [\"table\"],\n\t\t\ttfoot: [\"table\"],\n\t\t\ttr: [\"table\", \"tbody\"],\n\t\t\ttd: [\"table\", \"tbody\", \"tr\"],\n\t\t\tth: [\"table\", \"thead\", \"tr\"],\n\t\t\tlegend: [\"fieldset\"],\n\t\t\tcaption: [\"table\"],\n\t\t\tcolgroup: [\"table\"],\n\t\t\tcol: [\"table\", \"colgroup\"],\n\t\t\tli: [\"ul\"]\n\t\t},\n\t\treTag = /<\\s*([\\w\\:]+)/,\n\t\tmasterNode = {}, masterNum = 0,\n\t\tmasterName = \"__\" + dojo._scopeName + \"ToDomId\";\n\n\t// generate start/end tag strings to use\n\t// for the injection for each special tag wrap case.\n\tfor(var param in tagWrap){\n\t\tif(tagWrap.hasOwnProperty(param)){\n\t\t\tvar tw = tagWrap[param];\n\t\t\ttw.pre = param == \"option\" ? '<select multiple=\"multiple\">' : \"<\" + tw.join(\"><\") + \">\";\n\t\t\ttw.post = \"</\" + tw.reverse().join(\"></\") + \">\";\n\t\t\t// the last line is destructive: it reverses the array,\n\t\t\t// but we don't care at this point\n\t\t}\n\t}\n\n\tfunction _insertBefore(/*DomNode*/ node, /*DomNode*/ ref){\n\t\tvar parent = ref.parentNode;\n\t\tif(parent){\n\t\t\tparent.insertBefore(node, ref);\n\t\t}\n\t}\n\n\tfunction _insertAfter(/*DomNode*/ node, /*DomNode*/ ref){\n\t\t// summary:\n\t\t//\t\tTry to insert node after ref\n\t\tvar parent = ref.parentNode;\n\t\tif(parent){\n\t\t\tif(parent.lastChild == ref){\n\t\t\t\tparent.appendChild(node);\n\t\t\t}else{\n\t\t\t\tparent.insertBefore(node, ref.nextSibling);\n\t\t\t}\n\t\t}\n\t}\n\n\tvar _destroyContainer = null,\n\t\t_destroyDoc;\n\ton(window, \"unload\", function(){\n\t\t_destroyContainer = null; //prevent IE leak\n\t});\n\n\texports.toDom = function toDom(frag, doc){\n\t\t// summary:\n\t\t//\t\tinstantiates an HTML fragment returning the corresponding DOM.\n\t\t// frag: String\n\t\t//\t\tthe HTML fragment\n\t\t// doc: DocumentNode?\n\t\t//\t\toptional document to use when creating DOM nodes, defaults to\n\t\t//\t\tdojo.doc if not specified.\n\t\t// returns:\n\t\t//\t\tDocument fragment, unless it's a single node in which case it returns the node itself\n\t\t// example:\n\t\t//\t\tCreate a table row:\n\t\t//\t|\tvar tr = dojo.toDom(\"<tr><td>First!</td></tr>\");\n\n\t\tdoc = doc || win.doc;\n\t\tvar masterId = doc[masterName];\n\t\tif(!masterId){\n\t\t\tdoc[masterName] = masterId = ++masterNum + \"\";\n\t\t\tmasterNode[masterId] = doc.createElement(\"div\");\n\t\t}\n\n\t\t// make sure the frag is a string.\n\t\tfrag += \"\";\n\n\t\t// find the starting tag, and get node wrapper\n\t\tvar match = frag.match(reTag),\n\t\t\ttag = match ? match[1].toLowerCase() : \"\",\n\t\t\tmaster = masterNode[masterId],\n\t\t\twrap, i, fc, df;\n\t\tif(match && tagWrap[tag]){\n\t\t\twrap = tagWrap[tag];\n\t\t\tmaster.innerHTML = wrap.pre + frag + wrap.post;\n\t\t\tfor(i = wrap.length; i; --i){\n\t\t\t\tmaster = master.firstChild;\n\t\t\t}\n\t\t}else{\n\t\t\tmaster.innerHTML = frag;\n\t\t}\n\n\t\t// one node shortcut => return the node itself\n\t\tif(master.childNodes.length == 1){\n\t\t\treturn master.removeChild(master.firstChild); // DOMNode\n\t\t}\n\n\t\t// return multiple nodes as a document fragment\n\t\tdf = doc.createDocumentFragment();\n\t\twhile(fc = master.firstChild){ // intentional assignment\n\t\t\tdf.appendChild(fc);\n\t\t}\n\t\treturn df; // DocumentFragment\n\t};\n\n\texports.place = function place(/*DOMNode|String*/ node, /*DOMNode|String*/ refNode, /*String|Number?*/ position){\n\t\t// summary:\n\t\t//\t\tAttempt to insert node into the DOM, choosing from various positioning options.\n\t\t//\t\tReturns the first argument resolved to a DOM node.\n\t\t// node: DOMNode|String\n\t\t//\t\tid or node reference, or HTML fragment starting with \"<\" to place relative to refNode\n\t\t// refNode: DOMNode|String\n\t\t//\t\tid or node reference to use as basis for placement\n\t\t// position: String|Number?\n\t\t//\t\tstring noting the position of node relative to refNode or a\n\t\t//\t\tnumber indicating the location in the childNodes collection of refNode.\n\t\t//\t\tAccepted string values are:\n\t\t//\n\t\t//\t\t- before\n\t\t//\t\t- after\n\t\t//\t\t- replace\n\t\t//\t\t- only\n\t\t//\t\t- first\n\t\t//\t\t- last\n\t\t//\n\t\t//\t\t\"first\" and \"last\" indicate positions as children of refNode, \"replace\" replaces refNode,\n\t\t//\t\t\"only\" replaces all children.  position defaults to \"last\" if not specified\n\t\t// returns: DOMNode\n\t\t//\t\tReturned values is the first argument resolved to a DOM node.\n\t\t//\n\t\t//\t\t.place() is also a method of `dojo/NodeList`, allowing `dojo.query` node lookups.\n\t\t// example:\n\t\t//\t\tPlace a node by string id as the last child of another node by string id:\n\t\t//\t|\tdojo.place(\"someNode\", \"anotherNode\");\n\t\t// example:\n\t\t//\t\tPlace a node by string id before another node by string id\n\t\t//\t|\tdojo.place(\"someNode\", \"anotherNode\", \"before\");\n\t\t// example:\n\t\t//\t\tCreate a Node, and place it in the body element (last child):\n\t\t//\t|\tdojo.place(\"<div></div>\", dojo.body());\n\t\t// example:\n\t\t//\t\tPut a new LI as the first child of a list by id:\n\t\t//\t|\tdojo.place(\"<li></li>\", \"someUl\", \"first\");\n\n\t\trefNode = dom.byId(refNode);\n\t\tif(typeof node == \"string\"){ // inline'd type check\n\t\t\tnode = /^\\s*</.test(node) ? exports.toDom(node, refNode.ownerDocument) : dom.byId(node);\n\t\t}\n\t\tif(typeof position == \"number\"){ // inline'd type check\n\t\t\tvar cn = refNode.childNodes;\n\t\t\tif(!cn.length || cn.length <= position){\n\t\t\t\trefNode.appendChild(node);\n\t\t\t}else{\n\t\t\t\t_insertBefore(node, cn[position < 0 ? 0 : position]);\n\t\t\t}\n\t\t}else{\n\t\t\tswitch(position){\n\t\t\t\tcase \"before\":\n\t\t\t\t\t_insertBefore(node, refNode);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"after\":\n\t\t\t\t\t_insertAfter(node, refNode);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"replace\":\n\t\t\t\t\trefNode.parentNode.replaceChild(node, refNode);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"only\":\n\t\t\t\t\texports.empty(refNode);\n\t\t\t\t\trefNode.appendChild(node);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"first\":\n\t\t\t\t\tif(refNode.firstChild){\n\t\t\t\t\t\t_insertBefore(node, refNode.firstChild);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t// else fallthrough...\n\t\t\t\tdefault: // aka: last\n\t\t\t\t\trefNode.appendChild(node);\n\t\t\t}\n\t\t}\n\t\treturn node; // DomNode\n\t};\n\n\texports.create = function create(/*DOMNode|String*/ tag, /*Object*/ attrs, /*DOMNode|String?*/ refNode, /*String?*/ pos){\n\t\t// summary:\n\t\t//\t\tCreate an element, allowing for optional attribute decoration\n\t\t//\t\tand placement.\n\t\t// description:\n\t\t//\t\tA DOM Element creation function. A shorthand method for creating a node or\n\t\t//\t\ta fragment, and allowing for a convenient optional attribute setting step,\n\t\t//\t\tas well as an optional DOM placement reference.\n\t\t//\n\t\t//\t\tAttributes are set by passing the optional object through `dojo.setAttr`.\n\t\t//\t\tSee `dojo.setAttr` for noted caveats and nuances, and API if applicable.\n\t\t//\n\t\t//\t\tPlacement is done via `dojo.place`, assuming the new node to be the action\n\t\t//\t\tnode, passing along the optional reference node and position.\n\t\t// tag: DOMNode|String\n\t\t//\t\tA string of the element to create (eg: \"div\", \"a\", \"p\", \"li\", \"script\", \"br\"),\n\t\t//\t\tor an existing DOM node to process.\n\t\t// attrs: Object\n\t\t//\t\tAn object-hash of attributes to set on the newly created node.\n\t\t//\t\tCan be null, if you don't want to set any attributes/styles.\n\t\t//\t\tSee: `dojo.setAttr` for a description of available attributes.\n\t\t// refNode: DOMNode|String?\n\t\t//\t\tOptional reference node. Used by `dojo.place` to place the newly created\n\t\t//\t\tnode somewhere in the dom relative to refNode. Can be a DomNode reference\n\t\t//\t\tor String ID of a node.\n\t\t// pos: String?\n\t\t//\t\tOptional positional reference. Defaults to \"last\" by way of `dojo.place`,\n\t\t//\t\tthough can be set to \"first\",\"after\",\"before\",\"last\", \"replace\" or \"only\"\n\t\t//\t\tto further control the placement of the new node relative to the refNode.\n\t\t//\t\t'refNode' is required if a 'pos' is specified.\n\t\t// example:\n\t\t//\t\tCreate a DIV:\n\t\t//\t|\tvar n = dojo.create(\"div\");\n\t\t//\n\t\t// example:\n\t\t//\t\tCreate a DIV with content:\n\t\t//\t|\tvar n = dojo.create(\"div\", { innerHTML:\"<p>hi</p>\" });\n\t\t//\n\t\t// example:\n\t\t//\t\tPlace a new DIV in the BODY, with no attributes set\n\t\t//\t|\tvar n = dojo.create(\"div\", null, dojo.body());\n\t\t//\n\t\t// example:\n\t\t//\t\tCreate an UL, and populate it with LI's. Place the list as the first-child of a\n\t\t//\t\tnode with id=\"someId\":\n\t\t//\t|\tvar ul = dojo.create(\"ul\", null, \"someId\", \"first\");\n\t\t//\t|\tvar items = [\"one\", \"two\", \"three\", \"four\"];\n\t\t//\t|\tdojo.forEach(items, function(data){\n\t\t//\t|\t\tdojo.create(\"li\", { innerHTML: data }, ul);\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\t\tCreate an anchor, with an href. Place in BODY:\n\t\t//\t|\tdojo.create(\"a\", { href:\"foo.html\", title:\"Goto FOO!\" }, dojo.body());\n\t\t//\n\t\t// example:\n\t\t//\t\tCreate a `dojo/NodeList()` from a new element (for syntactic sugar):\n\t\t//\t|\tdojo.query(dojo.create('div'))\n\t\t//\t|\t\t.addClass(\"newDiv\")\n\t\t//\t|\t\t.onclick(function(e){ console.log('clicked', e.target) })\n\t\t//\t|\t\t.place(\"#someNode\"); // redundant, but cleaner.\n\n\t\tvar doc = win.doc;\n\t\tif(refNode){\n\t\t\trefNode = dom.byId(refNode);\n\t\t\tdoc = refNode.ownerDocument;\n\t\t}\n\t\tif(typeof tag == \"string\"){ // inline'd type check\n\t\t\ttag = doc.createElement(tag);\n\t\t}\n\t\tif(attrs){ attr.set(tag, attrs); }\n\t\tif(refNode){ exports.place(tag, refNode, pos); }\n\t\treturn tag; // DomNode\n\t};\n\n\texports.empty =\n\t\thas(\"ie\") ? function(node){\n\t\t\tnode = dom.byId(node);\n\t\t\tfor(var c; c = node.lastChild;){ // intentional assignment\n\t\t\t\texports.destroy(c);\n\t\t\t}\n\t\t} :\n\t\tfunction(node){\n\t\t\tdom.byId(node).innerHTML = \"\";\n\t\t};\n\t/*=====\n\t exports.empty = function(node){\n\t\t // summary:\n\t\t //\t\tsafely removes all children of the node.\n\t\t // node: DOMNode|String\n\t\t //\t\ta reference to a DOM node or an id.\n\t\t // example:\n\t\t //\t\tDestroy node's children byId:\n\t\t //\t|\tdojo.empty(\"someId\");\n\t\t //\n\t\t // example:\n\t\t //\t\tDestroy all nodes' children in a list by reference:\n\t\t //\t|\tdojo.query(\".someNode\").forEach(dojo.empty);\n\t };\n\t =====*/\n\n\texports.destroy = function destroy(/*DOMNode|String*/ node){\n\t\t// summary:\n\t\t//\t\tRemoves a node from its parent, clobbering it and all of its\n\t\t//\t\tchildren.\n\t\t//\n\t\t// description:\n\t\t//\t\tRemoves a node from its parent, clobbering it and all of its\n\t\t//\t\tchildren. Function only works with DomNodes, and returns nothing.\n\t\t//\n\t\t// node: DOMNode|String\n\t\t//\t\tA String ID or DomNode reference of the element to be destroyed\n\t\t//\n\t\t// example:\n\t\t//\t\tDestroy a node byId:\n\t\t//\t|\tdojo.destroy(\"someId\");\n\t\t//\n\t\t// example:\n\t\t//\t\tDestroy all nodes in a list by reference:\n\t\t//\t|\tdojo.query(\".someNode\").forEach(dojo.destroy);\n\n\t\tnode = dom.byId(node);\n\t\ttry{\n\t\t\tvar doc = node.ownerDocument;\n\t\t\t// cannot use _destroyContainer.ownerDocument since this can throw an exception on IE\n\t\t\tif(!_destroyContainer || _destroyDoc != doc){\n\t\t\t\t_destroyContainer = doc.createElement(\"div\");\n\t\t\t\t_destroyDoc = doc;\n\t\t\t}\n\t\t\t_destroyContainer.appendChild(node.parentNode ? node.parentNode.removeChild(node) : node);\n\t\t\t// NOTE: see http://trac.dojotoolkit.org/ticket/2931. This may be a bug and not a feature\n\t\t\t_destroyContainer.innerHTML = \"\";\n\t\t}catch(e){\n\t\t\t/* squelch */\n\t\t}\n\t};\n});\n\n},\n'dojo/request/xhr':function(){\ndefine(\"dojo/request/xhr\", [\n\t'../errors/RequestError',\n\t'./watch',\n\t'./handlers',\n\t'./util',\n\t'../has'/*=====,\n\t'../request',\n\t'../_base/declare' =====*/\n], function(RequestError, watch, handlers, util, has/*=====, request, declare =====*/){\n\thas.add('native-xhr', function(){\n\t\t// if true, the environment has a native XHR implementation\n\t\treturn typeof XMLHttpRequest !== 'undefined';\n\t});\n\thas.add('dojo-force-activex-xhr', function(){\n\t\treturn has('activex') && !document.addEventListener && window.location.protocol === 'file:';\n\t});\n\n\thas.add('native-xhr2', function(){\n\t\tif(!has('native-xhr')){ return; }\n\t\tvar x = new XMLHttpRequest();\n\t\treturn typeof x['addEventListener'] !== 'undefined' &&\n\t\t\t(typeof opera === 'undefined' || typeof x['upload'] !== 'undefined');\n\t});\n\n\thas.add('native-formdata', function(){\n\t\t// if true, the environment has a native FormData implementation\n\t\treturn typeof FormData === 'function';\n\t});\n\n\tfunction handleResponse(response, error){\n\t\tvar _xhr = response.xhr;\n\t\tresponse.status = response.xhr.status;\n\t\tresponse.text = _xhr.responseText;\n\n\t\tif(response.options.handleAs === 'xml'){\n\t\t\tresponse.data = _xhr.responseXML;\n\t\t}\n\n\t\tif(!error){\n\t\t\ttry{\n\t\t\t\thandlers(response);\n\t\t\t}catch(e){\n\t\t\t\terror = e;\n\t\t\t}\n\t\t}\n\n\t\tif(error){\n\t\t\tthis.reject(error);\n\t\t}else if(util.checkStatus(_xhr.status)){\n\t\t\tthis.resolve(response);\n\t\t}else{\n\t\t\terror = new RequestError('Unable to load ' + response.url + ' status: ' + _xhr.status, response);\n\n\t\t\tthis.reject(error);\n\t\t}\n\t}\n\n\tvar isValid, isReady, addListeners, cancel;\n\tif(has('native-xhr2')){\n\t\t// Any platform with XHR2 will only use the watch mechanism for timeout.\n\n\t\tisValid = function(response){\n\t\t\t// summary:\n\t\t\t//\t\tCheck to see if the request should be taken out of the watch queue\n\t\t\treturn !this.isFulfilled();\n\t\t};\n\t\tcancel = function(dfd, response){\n\t\t\t// summary:\n\t\t\t//\t\tCanceler for deferred\n\t\t\tresponse.xhr.abort();\n\t\t};\n\t\taddListeners = function(_xhr, dfd, response){\n\t\t\t// summary:\n\t\t\t//\t\tAdds event listeners to the XMLHttpRequest object\n\t\t\tfunction onLoad(evt){\n\t\t\t\tdfd.handleResponse(response);\n\t\t\t}\n\t\t\tfunction onError(evt){\n\t\t\t\tvar _xhr = evt.target;\n\t\t\t\tvar error = new RequestError('Unable to load ' + response.url + ' status: ' + _xhr.status, response); \n\t\t\t\tdfd.handleResponse(response, error);\n\t\t\t}\n\n\t\t\tfunction onProgress(evt){\n\t\t\t\tif(evt.lengthComputable){\n\t\t\t\t\tresponse.loaded = evt.loaded;\n\t\t\t\t\tresponse.total = evt.total;\n\t\t\t\t\tdfd.progress(response);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_xhr.addEventListener('load', onLoad, false);\n\t\t\t_xhr.addEventListener('error', onError, false);\n\t\t\t_xhr.addEventListener('progress', onProgress, false);\n\n\t\t\treturn function(){\n\t\t\t\t_xhr.removeEventListener('load', onLoad, false);\n\t\t\t\t_xhr.removeEventListener('error', onError, false);\n\t\t\t\t_xhr.removeEventListener('progress', onProgress, false);\n\t\t\t};\n\t\t};\n\t}else{\n\t\tisValid = function(response){\n\t\t\treturn response.xhr.readyState; //boolean\n\t\t};\n\t\tisReady = function(response){\n\t\t\treturn 4 === response.xhr.readyState; //boolean\n\t\t};\n\t\tcancel = function(dfd, response){\n\t\t\t// summary:\n\t\t\t//\t\tcanceller function for util.deferred call.\n\t\t\tvar xhr = response.xhr;\n\t\t\tvar _at = typeof xhr.abort;\n\t\t\tif(_at === 'function' || _at === 'object' || _at === 'unknown'){\n\t\t\t\txhr.abort();\n\t\t\t}\n\t\t};\n\t}\n\n\tvar undefined,\n\t\tdefaultOptions = {\n\t\t\tdata: null,\n\t\t\tquery: null,\n\t\t\tsync: false,\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t}\n\t\t};\n\tfunction xhr(url, options, returnDeferred){\n\t\tvar response = util.parseArgs(\n\t\t\turl,\n\t\t\tutil.deepCreate(defaultOptions, options),\n\t\t\thas('native-formdata') && options && options.data && options.data instanceof FormData\n\t\t);\n\t\turl = response.url;\n\t\toptions = response.options;\n\n\t\tvar remover,\n\t\t\tlast = function(){\n\t\t\t\tremover && remover();\n\t\t\t};\n\n\t\t//Make the Deferred object for this xhr request.\n\t\tvar dfd = util.deferred(\n\t\t\tresponse,\n\t\t\tcancel,\n\t\t\tisValid,\n\t\t\tisReady,\n\t\t\thandleResponse,\n\t\t\tlast\n\t\t);\n\t\tvar _xhr = response.xhr = xhr._create();\n\n\t\tif(!_xhr){\n\t\t\t// If XHR factory somehow returns nothings,\n\t\t\t// cancel the deferred.\n\t\t\tdfd.cancel(new RequestError('XHR was not created'));\n\t\t\treturn returnDeferred ? dfd : dfd.promise;\n\t\t}\n\n\t\tresponse.getHeader = function(headerName){\n\t\t\treturn this.xhr.getResponseHeader(headerName);\n\t\t};\n\n\t\tif(addListeners){\n\t\t\tremover = addListeners(_xhr, dfd, response);\n\t\t}\n\n\t\tvar data = options.data,\n\t\t\tasync = !options.sync,\n\t\t\tmethod = options.method;\n\n\t\ttry{\n\t\t\t// IE6 won't let you call apply() on the native function.\n\t\t\t_xhr.open(method, url, async, options.user || undefined, options.password || undefined);\n\n\t\t\tif(options.withCredentials){\n\t\t\t\t_xhr.withCredentials = options.withCredentials;\n\t\t\t}\n\n\t\t\tvar headers = options.headers,\n\t\t\t\tcontentType;\n\t\t\tif(headers){\n\t\t\t\tfor(var hdr in headers){\n\t\t\t\t\tif(hdr.toLowerCase() === 'content-type'){\n\t\t\t\t\t\tcontentType = headers[hdr];\n\t\t\t\t\t}else if(headers[hdr]){\n\t\t\t\t\t\t//Only add header if it has a value. This allows for instance, skipping\n\t\t\t\t\t\t//insertion of X-Requested-With by specifying empty value.\n\t\t\t\t\t\t_xhr.setRequestHeader(hdr, headers[hdr]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(contentType && contentType !== false){\n\t\t\t\t_xhr.setRequestHeader('Content-Type', contentType);\n\t\t\t}\n\t\t\tif(!headers || !('X-Requested-With' in headers)){\n\t\t\t\t_xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');\n\t\t\t}\n\n\t\t\tif(util.notify){\n\t\t\t\tutil.notify.emit('send', response, dfd.promise.cancel);\n\t\t\t}\n\t\t\t_xhr.send(data);\n\t\t}catch(e){\n\t\t\tdfd.reject(e);\n\t\t}\n\n\t\twatch(dfd);\n\t\t_xhr = null;\n\n\t\treturn returnDeferred ? dfd : dfd.promise;\n\t}\n\n\t/*=====\n\txhr = function(url, options){\n\t\t// summary:\n\t\t//\t\tSends a request using XMLHttpRequest with the given URL and options.\n\t\t// url: String\n\t\t//\t\tURL to request\n\t\t// options: dojo/request/xhr.__Options?\n\t\t//\t\tOptions for the request.\n\t\t// returns: dojo/request.__Promise\n\t};\n\txhr.__BaseOptions = declare(request.__BaseOptions, {\n\t\t// sync: Boolean?\n\t\t//\t\tWhether to make a synchronous request or not. Default\n\t\t//\t\tis `false` (asynchronous).\n\t\t// data: String|Object|FormData?\n\t\t//\t\tData to transfer. This is ignored for GET and DELETE\n\t\t//\t\trequests.\n\t\t// headers: Object?\n\t\t//\t\tHeaders to use for the request.\n\t\t// user: String?\n\t\t//\t\tUsername to use during the request.\n\t\t// password: String?\n\t\t//\t\tPassword to use during the request.\n\t\t// withCredentials: Boolean?\n\t\t//\t\tFor cross-site requests, whether to send credentials\n\t\t//\t\tor not.\n\t});\n\txhr.__MethodOptions = declare(null, {\n\t\t// method: String?\n\t\t//\t\tThe HTTP method to use to make the request. Must be\n\t\t//\t\tuppercase. Default is `\"GET\"`.\n\t});\n\txhr.__Options = declare([xhr.__BaseOptions, xhr.__MethodOptions]);\n\n\txhr.get = function(url, options){\n\t\t// summary:\n\t\t//\t\tSend an HTTP GET request using XMLHttpRequest with the given URL and options.\n\t\t// url: String\n\t\t//\t\tURL to request\n\t\t// options: dojo/request/xhr.__BaseOptions?\n\t\t//\t\tOptions for the request.\n\t\t// returns: dojo/request.__Promise\n\t};\n\txhr.post = function(url, options){\n\t\t// summary:\n\t\t//\t\tSend an HTTP POST request using XMLHttpRequest with the given URL and options.\n\t\t// url: String\n\t\t//\t\tURL to request\n\t\t// options: dojo/request/xhr.__BaseOptions?\n\t\t//\t\tOptions for the request.\n\t\t// returns: dojo/request.__Promise\n\t};\n\txhr.put = function(url, options){\n\t\t// summary:\n\t\t//\t\tSend an HTTP PUT request using XMLHttpRequest with the given URL and options.\n\t\t// url: String\n\t\t//\t\tURL to request\n\t\t// options: dojo/request/xhr.__BaseOptions?\n\t\t//\t\tOptions for the request.\n\t\t// returns: dojo/request.__Promise\n\t};\n\txhr.del = function(url, options){\n\t\t// summary:\n\t\t//\t\tSend an HTTP DELETE request using XMLHttpRequest with the given URL and options.\n\t\t// url: String\n\t\t//\t\tURL to request\n\t\t// options: dojo/request/xhr.__BaseOptions?\n\t\t//\t\tOptions for the request.\n\t\t// returns: dojo/request.__Promise\n\t};\n\t=====*/\n\txhr._create = function(){\n\t\t// summary:\n\t\t//\t\tdoes the work of portably generating a new XMLHTTPRequest object.\n\t\tthrow new Error('XMLHTTP not available');\n\t};\n\tif(has('native-xhr') && !has('dojo-force-activex-xhr')){\n\t\txhr._create = function(){\n\t\t\treturn new XMLHttpRequest();\n\t\t};\n\t}else if(has('activex')){\n\t\ttry{\n\t\t\tnew ActiveXObject('Msxml2.XMLHTTP');\n\t\t\txhr._create = function(){\n\t\t\t\treturn new ActiveXObject('Msxml2.XMLHTTP');\n\t\t\t};\n\t\t}catch(e){\n\t\t\ttry{\n\t\t\t\tnew ActiveXObject('Microsoft.XMLHTTP');\n\t\t\t\txhr._create = function(){\n\t\t\t\t\treturn new ActiveXObject('Microsoft.XMLHTTP');\n\t\t\t\t};\n\t\t\t}catch(e){}\n\t\t}\n\t}\n\n\tutil.addCommonMethods(xhr);\n\n\treturn xhr;\n});\n\n},\n'dojo/text':function(){\ndefine([\"./_base/kernel\", \"require\", \"./has\", \"./_base/xhr\"], function(dojo, require, has, xhr){\n\t// module:\n\t//\t\tdojo/text\n\n\tvar getText;\n\tif( 1 ){\n\t\tgetText= function(url, sync, load){\n\t\t\txhr(\"GET\", {url: url, sync:!!sync, load: load, headers: dojo.config.textPluginHeaders || {}});\n\t\t};\n\t}else{\n\t\t// TODOC: only works for dojo AMD loader\n\t\tif(require.getText){\n\t\t\tgetText= require.getText;\n\t\t}else{\n\t\t\tconsole.error(\"dojo/text plugin failed to load because loader does not support getText\");\n\t\t}\n\t}\n\n\tvar\n\t\ttheCache = {},\n\n\t\tstrip= function(text){\n\t\t\t//Strips <?xml ...?> declarations so that external SVG and XML\n\t\t\t//documents can be added to a document without worry. Also, if the string\n\t\t\t//is an HTML document, only the part inside the body tag is returned.\n\t\t\tif(text){\n\t\t\t\ttext= text.replace(/^\\s*<\\?xml(\\s)+version=[\\'\\\"](\\d)*.(\\d)*[\\'\\\"](\\s)*\\?>/im, \"\");\n\t\t\t\tvar matches= text.match(/<body[^>]*>\\s*([\\s\\S]+)\\s*<\\/body>/im);\n\t\t\t\tif(matches){\n\t\t\t\t\ttext= matches[1];\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\ttext = \"\";\n\t\t\t}\n\t\t\treturn text;\n\t\t},\n\n\t\tnotFound = {},\n\n\t\tpending = {};\n\n\tdojo.cache = function(/*String||Object*/module, /*String*/url, /*String||Object?*/value){\n\t\t// summary:\n\t\t//\t\tA getter and setter for storing the string content associated with the\n\t\t//\t\tmodule and url arguments.\n\t\t// description:\n\t\t//\t\tIf module is a string that contains slashes, then it is interpretted as a fully\n\t\t//\t\tresolved path (typically a result returned by require.toUrl), and url should not be\n\t\t//\t\tprovided. This is the preferred signature. If module is a string that does not\n\t\t//\t\tcontain slashes, then url must also be provided and module and url are used to\n\t\t//\t\tcall `dojo.moduleUrl()` to generate a module URL. This signature is deprecated.\n\t\t//\t\tIf value is specified, the cache value for the moduleUrl will be set to\n\t\t//\t\tthat value. Otherwise, dojo.cache will fetch the moduleUrl and store it\n\t\t//\t\tin its internal cache and return that cached value for the URL. To clear\n\t\t//\t\ta cache value pass null for value. Since XMLHttpRequest (XHR) is used to fetch the\n\t\t//\t\tthe URL contents, only modules on the same domain of the page can use this capability.\n\t\t//\t\tThe build system can inline the cache values though, to allow for xdomain hosting.\n\t\t// module: String||Object\n\t\t//\t\tIf a String with slashes, a fully resolved path; if a String without slashes, the\n\t\t//\t\tmodule name to use for the base part of the URL, similar to module argument\n\t\t//\t\tto `dojo.moduleUrl`. If an Object, something that has a .toString() method that\n\t\t//\t\tgenerates a valid path for the cache item. For example, a dojo._Url object.\n\t\t// url: String\n\t\t//\t\tThe rest of the path to append to the path derived from the module argument. If\n\t\t//\t\tmodule is an object, then this second argument should be the \"value\" argument instead.\n\t\t// value: String||Object?\n\t\t//\t\tIf a String, the value to use in the cache for the module/url combination.\n\t\t//\t\tIf an Object, it can have two properties: value and sanitize. The value property\n\t\t//\t\tshould be the value to use in the cache, and sanitize can be set to true or false,\n\t\t//\t\tto indicate if XML declarations should be removed from the value and if the HTML\n\t\t//\t\tinside a body tag in the value should be extracted as the real value. The value argument\n\t\t//\t\tor the value property on the value argument are usually only used by the build system\n\t\t//\t\tas it inlines cache content.\n\t\t// example:\n\t\t//\t\tTo ask dojo.cache to fetch content and store it in the cache (the dojo[\"cache\"] style\n\t\t//\t\tof call is used to avoid an issue with the build system erroneously trying to intern\n\t\t//\t\tthis example. To get the build system to intern your dojo.cache calls, use the\n\t\t//\t\t\"dojo.cache\" style of call):\n\t\t//\t\t| //If template.html contains \"<h1>Hello</h1>\" that will be\n\t\t//\t\t| //the value for the text variable.\n\t\t//\t\t| var text = dojo[\"cache\"](\"my.module\", \"template.html\");\n\t\t// example:\n\t\t//\t\tTo ask dojo.cache to fetch content and store it in the cache, and sanitize the input\n\t\t//\t\t (the dojo[\"cache\"] style of call is used to avoid an issue with the build system\n\t\t//\t\terroneously trying to intern this example. To get the build system to intern your\n\t\t//\t\tdojo.cache calls, use the \"dojo.cache\" style of call):\n\t\t//\t\t| //If template.html contains \"<html><body><h1>Hello</h1></body></html>\", the\n\t\t//\t\t| //text variable will contain just \"<h1>Hello</h1>\".\n\t\t//\t\t| var text = dojo[\"cache\"](\"my.module\", \"template.html\", {sanitize: true});\n\t\t// example:\n\t\t//\t\tSame example as previous, but demonstrates how an object can be passed in as\n\t\t//\t\tthe first argument, then the value argument can then be the second argument.\n\t\t//\t\t| //If template.html contains \"<html><body><h1>Hello</h1></body></html>\", the\n\t\t//\t\t| //text variable will contain just \"<h1>Hello</h1>\".\n\t\t//\t\t| var text = dojo[\"cache\"](new dojo._Url(\"my/module/template.html\"), {sanitize: true});\n\n\t\t//\t * (string string [value]) => (module, url, value)\n\t\t//\t * (object [value])        => (module, value), url defaults to \"\"\n\t\t//\n\t\t//\t * if module is an object, then it must be convertable to a string\n\t\t//\t * (module, url) module + (url ? (\"/\" + url) : \"\") must be a legal argument to require.toUrl\n\t\t//\t * value may be a string or an object; if an object then may have the properties \"value\" and/or \"sanitize\"\n\t\tvar key;\n\t\tif(typeof module==\"string\"){\n\t\t\tif(/\\//.test(module)){\n\t\t\t\t// module is a version 1.7+ resolved path\n\t\t\t\tkey = module;\n\t\t\t\tvalue = url;\n\t\t\t}else{\n\t\t\t\t// module is a version 1.6- argument to dojo.moduleUrl\n\t\t\t\tkey = require.toUrl(module.replace(/\\./g, \"/\") + (url ? (\"/\" + url) : \"\"));\n\t\t\t}\n\t\t}else{\n\t\t\tkey = module + \"\";\n\t\t\tvalue = url;\n\t\t}\n\t\tvar\n\t\t\tval = (value != undefined && typeof value != \"string\") ? value.value : value,\n\t\t\tsanitize = value && value.sanitize;\n\n\t\tif(typeof val == \"string\"){\n\t\t\t//We have a string, set cache value\n\t\t\ttheCache[key] = val;\n\t\t\treturn sanitize ? strip(val) : val;\n\t\t}else if(val === null){\n\t\t\t//Remove cached value\n\t\t\tdelete theCache[key];\n\t\t\treturn null;\n\t\t}else{\n\t\t\t//Allow cache values to be empty strings. If key property does\n\t\t\t//not exist, fetch it.\n\t\t\tif(!(key in theCache)){\n\t\t\t\tgetText(key, true, function(text){\n\t\t\t\t\ttheCache[key]= text;\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn sanitize ? strip(theCache[key]) : theCache[key];\n\t\t}\n\t};\n\n\treturn {\n\t\t// summary:\n\t\t//\t\tThis module implements the dojo/text! plugin and the dojo.cache API.\n\t\t// description:\n\t\t//\t\tWe choose to include our own plugin to leverage functionality already contained in dojo\n\t\t//\t\tand thereby reduce the size of the plugin compared to various foreign loader implementations.\n\t\t//\t\tAlso, this allows foreign AMD loaders to be used without their plugins.\n\t\t//\n\t\t//\t\tCAUTION: this module is designed to optionally function synchronously to support the dojo v1.x synchronous\n\t\t//\t\tloader. This feature is outside the scope of the CommonJS plugins specification.\n\n\t\t// the dojo/text caches it's own resources because of dojo.cache\n\t\tdynamic: true,\n\n\t\tnormalize: function(id, toAbsMid){\n\t\t\t// id is something like (path may be relative):\n\t\t\t//\n\t\t\t//\t \"path/to/text.html\"\n\t\t\t//\t \"path/to/text.html!strip\"\n\t\t\tvar parts= id.split(\"!\"),\n\t\t\t\turl= parts[0];\n\t\t\treturn (/^\\./.test(url) ? toAbsMid(url) : url) + (parts[1] ? \"!\" + parts[1] : \"\");\n\t\t},\n\n\t\tload: function(id, require, load){\n\t\t\t// id: String\n\t\t\t//\t\tPath to the resource.\n\t\t\t// require: Function\n\t\t\t//\t\tObject that include the function toUrl with given id returns a valid URL from which to load the text.\n\t\t\t// load: Function\n\t\t\t//\t\tCallback function which will be called, when the loading finished.\n\n\t\t\t// id is something like (path is always absolute):\n\t\t\t//\n\t\t\t//\t \"path/to/text.html\"\n\t\t\t//\t \"path/to/text.html!strip\"\n\t\t\tvar\n\t\t\t\tparts= id.split(\"!\"),\n\t\t\t\tstripFlag= parts.length>1,\n\t\t\t\tabsMid= parts[0],\n\t\t\t\turl = require.toUrl(parts[0]),\n\t\t\t\trequireCacheUrl = \"url:\" + url,\n\t\t\t\ttext = notFound,\n\t\t\t\tfinish = function(text){\n\t\t\t\t\tload(stripFlag ? strip(text) : text);\n\t\t\t\t};\n\t\t\tif(absMid in theCache){\n\t\t\t\ttext = theCache[absMid];\n\t\t\t}else if(requireCacheUrl in require.cache){\n\t\t\t\ttext = require.cache[requireCacheUrl];\n\t\t\t}else if(url in theCache){\n\t\t\t\ttext = theCache[url];\n\t\t\t}\n\t\t\tif(text===notFound){\n\t\t\t\tif(pending[url]){\n\t\t\t\t\tpending[url].push(finish);\n\t\t\t\t}else{\n\t\t\t\t\tvar pendingList = pending[url] = [finish];\n\t\t\t\t\tgetText(url, !require.async, function(text){\n\t\t\t\t\t\ttheCache[absMid]= theCache[url]= text;\n\t\t\t\t\t\tfor(var i = 0; i<pendingList.length;){\n\t\t\t\t\t\t\tpendingList[i++](text);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdelete pending[url];\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tfinish(text);\n\t\t\t}\n\t\t}\n\t};\n\n});\n\n\n},\n'dojo/keys':function(){\ndefine(\"dojo/keys\", [\"./_base/kernel\", \"./sniff\"], function(dojo, has){\n\n\t// module:\n\t//\t\tdojo/keys\n\n\treturn dojo.keys = {\n\t\t// summary:\n\t\t//\t\tDefinitions for common key values.  Client code should test keyCode against these named constants,\n\t\t//\t\tas the actual codes can vary by browser.\n\n\t\tBACKSPACE: 8,\n\t\tTAB: 9,\n\t\tCLEAR: 12,\n\t\tENTER: 13,\n\t\tSHIFT: 16,\n\t\tCTRL: 17,\n\t\tALT: 18,\n\t\tMETA: has(\"webkit\") ? 91 : 224,\t\t// the apple key on macs\n\t\tPAUSE: 19,\n\t\tCAPS_LOCK: 20,\n\t\tESCAPE: 27,\n\t\tSPACE: 32,\n\t\tPAGE_UP: 33,\n\t\tPAGE_DOWN: 34,\n\t\tEND: 35,\n\t\tHOME: 36,\n\t\tLEFT_ARROW: 37,\n\t\tUP_ARROW: 38,\n\t\tRIGHT_ARROW: 39,\n\t\tDOWN_ARROW: 40,\n\t\tINSERT: 45,\n\t\tDELETE: 46,\n\t\tHELP: 47,\n\t\tLEFT_WINDOW: 91,\n\t\tRIGHT_WINDOW: 92,\n\t\tSELECT: 93,\n\t\tNUMPAD_0: 96,\n\t\tNUMPAD_1: 97,\n\t\tNUMPAD_2: 98,\n\t\tNUMPAD_3: 99,\n\t\tNUMPAD_4: 100,\n\t\tNUMPAD_5: 101,\n\t\tNUMPAD_6: 102,\n\t\tNUMPAD_7: 103,\n\t\tNUMPAD_8: 104,\n\t\tNUMPAD_9: 105,\n\t\tNUMPAD_MULTIPLY: 106,\n\t\tNUMPAD_PLUS: 107,\n\t\tNUMPAD_ENTER: 108,\n\t\tNUMPAD_MINUS: 109,\n\t\tNUMPAD_PERIOD: 110,\n\t\tNUMPAD_DIVIDE: 111,\n\t\tF1: 112,\n\t\tF2: 113,\n\t\tF3: 114,\n\t\tF4: 115,\n\t\tF5: 116,\n\t\tF6: 117,\n\t\tF7: 118,\n\t\tF8: 119,\n\t\tF9: 120,\n\t\tF10: 121,\n\t\tF11: 122,\n\t\tF12: 123,\n\t\tF13: 124,\n\t\tF14: 125,\n\t\tF15: 126,\n\t\tNUM_LOCK: 144,\n\t\tSCROLL_LOCK: 145,\n\t\tUP_DPAD: 175,\n\t\tDOWN_DPAD: 176,\n\t\tLEFT_DPAD: 177,\n\t\tRIGHT_DPAD: 178,\n\t\t// virtual key mapping\n\t\tcopyKey: has(\"mac\") && !has(\"air\") ? (has(\"safari\") ? 91 : 224 ) : 17\n\t};\n});\n\n},\n'dojo/domReady':function(){\ndefine(['./has'], function(has){\n\tvar global = this,\n\t\tdoc = document,\n\t\treadyStates = { 'loaded': 1, 'complete': 1 },\n\t\tfixReadyState = typeof doc.readyState != \"string\",\n\t\tready = !!readyStates[doc.readyState];\n\n\t// For FF <= 3.5\n\tif(fixReadyState){ doc.readyState = \"loading\"; }\n\n\tif(!ready){\n\t\tvar readyQ = [], tests = [],\n\t\t\tdetectReady = function(evt){\n\t\t\t\tevt = evt || global.event;\n\t\t\t\tif(ready || (evt.type == \"readystatechange\" && !readyStates[doc.readyState])){ return; }\n\t\t\t\tready = 1;\n\n\t\t\t\t// For FF <= 3.5\n\t\t\t\tif(fixReadyState){ doc.readyState = \"complete\"; }\n\n\t\t\t\twhile(readyQ.length){\n\t\t\t\t\t(readyQ.shift())(doc);\n\t\t\t\t}\n\t\t\t},\n\t\t\ton = function(node, event){\n\t\t\t\tnode.addEventListener(event, detectReady, false);\n\t\t\t\treadyQ.push(function(){ node.removeEventListener(event, detectReady, false); });\n\t\t\t};\n\n\t\tif(!has(\"dom-addeventlistener\")){\n\t\t\ton = function(node, event){\n\t\t\t\tevent = \"on\" + event;\n\t\t\t\tnode.attachEvent(event, detectReady);\n\t\t\t\treadyQ.push(function(){ node.detachEvent(event, detectReady); });\n\t\t\t};\n\n\t\t\tvar div = doc.createElement(\"div\");\n\t\t\ttry{\n\t\t\t\tif(div.doScroll && global.frameElement === null){\n\t\t\t\t\t// the doScroll test is only useful if we're in the top-most frame\n\t\t\t\t\ttests.push(function(){\n\t\t\t\t\t\t// Derived with permission from Diego Perini's IEContentLoaded\n\t\t\t\t\t\t// http://javascript.nwbox.com/IEContentLoaded/\n\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\tdiv.doScroll(\"left\");\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t}catch(e){}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}catch(e){}\n\t\t}\n\n\t\ton(doc, \"DOMContentLoaded\");\n\t\ton(global, \"load\");\n\n\t\tif(\"onreadystatechange\" in doc){\n\t\t\ton(doc, \"readystatechange\");\n\t\t}else if(!fixReadyState){\n\t\t\t// if the ready state property exists and there's\n\t\t\t// no readystatechange event, poll for the state\n\t\t\t// to change\n\t\t\ttests.push(function(){\n\t\t\t\treturn readyStates[doc.readyState];\n\t\t\t});\n\t\t}\n\n\t\tif(tests.length){\n\t\t\tvar poller = function(){\n\t\t\t\tif(ready){ return; }\n\t\t\t\tvar i = tests.length;\n\t\t\t\twhile(i--){\n\t\t\t\t\tif(tests[i]()){\n\t\t\t\t\t\tdetectReady(\"poller\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsetTimeout(poller, 30);\n\t\t\t};\n\t\t\tpoller();\n\t\t}\n\t}\n\n\tfunction domReady(callback){\n\t\t// summary:\n\t\t//\t\tPlugin to delay require()/define() callback from firing until the DOM has finished loading.\n\t\tif(ready){\n\t\t\tcallback(doc);\n\t\t}else{\n\t\t\treadyQ.push(callback);\n\t\t}\n\t}\n\tdomReady.load = function(id, req, load){\n\t\tdomReady(load);\n\t};\n\n\treturn domReady;\n});\n\n},\n'dojo/_base/lang':function(){\ndefine(\"dojo/_base/lang\", [\"./kernel\", \"../has\", \"../sniff\"], function(dojo, has){\n\t// module:\n\t//\t\tdojo/_base/lang\n\n\thas.add(\"bug-for-in-skips-shadowed\", function(){\n\t\t// if true, the for-in iterator skips object properties that exist in Object's prototype (IE 6 - ?)\n\t\tfor(var i in {toString: 1}){\n\t\t\treturn 0;\n\t\t}\n\t\treturn 1;\n\t});\n\n\t// Helper methods\n\tvar _extraNames =\n\t\t\thas(\"bug-for-in-skips-shadowed\") ?\n\t\t\t\t\"hasOwnProperty.valueOf.isPrototypeOf.propertyIsEnumerable.toLocaleString.toString.constructor\".split(\".\") : [],\n\n\t\t_extraLen = _extraNames.length,\n\n\t\tgetProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){\n\t\t\tvar p, i = 0, dojoGlobal = dojo.global;\n\t\t\tif(!context){\n\t\t\t\tif(!parts.length){\n\t\t\t\t\treturn dojoGlobal;\n\t\t\t\t}else{\n\t\t\t\t\tp = parts[i++];\n\t\t\t\t\ttry{\n\t\t\t\t\t\tcontext = dojo.scopeMap[p] && dojo.scopeMap[p][1];\n\t\t\t\t\t}catch(e){}\n\t\t\t\t\tcontext = context || (p in dojoGlobal ? dojoGlobal[p] : (create ? dojoGlobal[p] = {} : undefined));\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile(context && (p = parts[i++])){\n\t\t\t\tcontext = (p in context ? context[p] : (create ? context[p] = {} : undefined));\n\t\t\t}\n\t\t\treturn context; // mixed\n\t\t},\n\n\t\topts = Object.prototype.toString,\n\n\t\tefficient = function(obj, offset, startWith){\n\t\t\treturn (startWith||[]).concat(Array.prototype.slice.call(obj, offset||0));\n\t\t},\n\n\t\t_pattern = /\\{([^\\}]+)\\}/g;\n\n\t// Module export\n\tvar lang = {\n\t\t// summary:\n\t\t//\t\tThis module defines Javascript language extensions.\n\n\t\t// _extraNames: String[]\n\t\t//\t\tLists property names that must be explicitly processed during for-in iteration\n\t\t//\t\tin environments that have has(\"bug-for-in-skips-shadowed\") true.\n\t\t_extraNames:_extraNames,\n\n\t\t_mixin: function(dest, source, copyFunc){\n\t\t\t// summary:\n\t\t\t//\t\tCopies/adds all properties of source to dest; returns dest.\n\t\t\t// dest: Object\n\t\t\t//\t\tThe object to which to copy/add all properties contained in source.\n\t\t\t// source: Object\n\t\t\t//\t\tThe object from which to draw all properties to copy into dest.\n\t\t\t// copyFunc: Function?\n\t\t\t//\t\tThe process used to copy/add a property in source; defaults to the Javascript assignment operator.\n\t\t\t// returns:\n\t\t\t//\t\tdest, as modified\n\t\t\t// description:\n\t\t\t//\t\tAll properties, including functions (sometimes termed \"methods\"), excluding any non-standard extensions\n\t\t\t//\t\tfound in Object.prototype, are copied/added to dest. Copying/adding each particular property is\n\t\t\t//\t\tdelegated to copyFunc (if any); copyFunc defaults to the Javascript assignment operator if not provided.\n\t\t\t//\t\tNotice that by default, _mixin executes a so-called \"shallow copy\" and aggregate types are copied/added by reference.\n\t\t\tvar name, s, i, empty = {};\n\t\t\tfor(name in source){\n\t\t\t\t// the (!(name in empty) || empty[name] !== s) condition avoids copying properties in \"source\"\n\t\t\t\t// inherited from Object.prototype.\t For example, if dest has a custom toString() method,\n\t\t\t\t// don't overwrite it with the toString() method that source inherited from Object.prototype\n\t\t\t\ts = source[name];\n\t\t\t\tif(!(name in dest) || (dest[name] !== s && (!(name in empty) || empty[name] !== s))){\n\t\t\t\t\tdest[name] = copyFunc ? copyFunc(s) : s;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(has(\"bug-for-in-skips-shadowed\")){\n\t\t\t\tif(source){\n\t\t\t\t\tfor(i = 0; i < _extraLen; ++i){\n\t\t\t\t\t\tname = _extraNames[i];\n\t\t\t\t\t\ts = source[name];\n\t\t\t\t\t\tif(!(name in dest) || (dest[name] !== s && (!(name in empty) || empty[name] !== s))){\n\t\t\t\t\t\t\tdest[name] = copyFunc ? copyFunc(s) : s;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn dest; // Object\n\t\t},\n\n\t\tmixin: function(dest, sources){\n\t\t\t// summary:\n\t\t\t//\t\tCopies/adds all properties of one or more sources to dest; returns dest.\n\t\t\t// dest: Object\n\t\t\t//\t\tThe object to which to copy/add all properties contained in source. If dest is falsy, then\n\t\t\t//\t\ta new object is manufactured before copying/adding properties begins.\n\t\t\t// sources: Object...\n\t\t\t//\t\tOne of more objects from which to draw all properties to copy into dest. sources are processed\n\t\t\t//\t\tleft-to-right and if more than one of these objects contain the same property name, the right-most\n\t\t\t//\t\tvalue \"wins\".\n\t\t\t// returns: Object\n\t\t\t//\t\tdest, as modified\n\t\t\t// description:\n\t\t\t//\t\tAll properties, including functions (sometimes termed \"methods\"), excluding any non-standard extensions\n\t\t\t//\t\tfound in Object.prototype, are copied/added from sources to dest. sources are processed left to right.\n\t\t\t//\t\tThe Javascript assignment operator is used to copy/add each property; therefore, by default, mixin\n\t\t\t//\t\texecutes a so-called \"shallow copy\" and aggregate types are copied/added by reference.\n\t\t\t// example:\n\t\t\t//\t\tmake a shallow copy of an object\n\t\t\t//\t|\tvar copy = lang.mixin({}, source);\n\t\t\t// example:\n\t\t\t//\t\tmany class constructors often take an object which specifies\n\t\t\t//\t\tvalues to be configured on the object. In this case, it is\n\t\t\t//\t\toften simplest to call `lang.mixin` on the `this` object:\n\t\t\t//\t|\tdeclare(\"acme.Base\", null, {\n\t\t\t//\t|\t\tconstructor: function(properties){\n\t\t\t//\t|\t\t\t// property configuration:\n\t\t\t//\t|\t\t\tlang.mixin(this, properties);\n\t\t\t//\t|\n\t\t\t//\t|\t\t\tconsole.log(this.quip);\n\t\t\t//\t|\t\t\t//\t...\n\t\t\t//\t|\t\t},\n\t\t\t//\t|\t\tquip: \"I wasn't born yesterday, you know - I've seen movies.\",\n\t\t\t//\t|\t\t// ...\n\t\t\t//\t|\t});\n\t\t\t//\t|\n\t\t\t//\t|\t// create an instance of the class and configure it\n\t\t\t//\t|\tvar b = new acme.Base({quip: \"That's what it does!\" });\n\t\t\t// example:\n\t\t\t//\t\tcopy in properties from multiple objects\n\t\t\t//\t|\tvar flattened = lang.mixin(\n\t\t\t//\t|\t\t{\n\t\t\t//\t|\t\t\tname: \"Frylock\",\n\t\t\t//\t|\t\t\tbraces: true\n\t\t\t//\t|\t\t},\n\t\t\t//\t|\t\t{\n\t\t\t//\t|\t\t\tname: \"Carl Brutanananadilewski\"\n\t\t\t//\t|\t\t}\n\t\t\t//\t|\t);\n\t\t\t//\t|\n\t\t\t//\t|\t// will print \"Carl Brutanananadilewski\"\n\t\t\t//\t|\tconsole.log(flattened.name);\n\t\t\t//\t|\t// will print \"true\"\n\t\t\t//\t|\tconsole.log(flattened.braces);\n\n\t\t\tif(!dest){ dest = {}; }\n\t\t\tfor(var i = 1, l = arguments.length; i < l; i++){\n\t\t\t\tlang._mixin(dest, arguments[i]);\n\t\t\t}\n\t\t\treturn dest; // Object\n\t\t},\n\n\t\tsetObject: function(name, value, context){\n\t\t\t// summary:\n\t\t\t//\t\tSet a property from a dot-separated string, such as \"A.B.C\"\n\t\t\t// description:\n\t\t\t//\t\tUseful for longer api chains where you have to test each object in\n\t\t\t//\t\tthe chain, or when you have an object reference in string format.\n\t\t\t//\t\tObjects are created as needed along `path`. Returns the passed\n\t\t\t//\t\tvalue if setting is successful or `undefined` if not.\n\t\t\t// name: String\n\t\t\t//\t\tPath to a property, in the form \"A.B.C\".\n\t\t\t// value: anything\n\t\t\t//\t\tvalue or object to place at location given by name\n\t\t\t// context: Object?\n\t\t\t//\t\tOptional. Object to use as root of path. Defaults to\n\t\t\t//\t\t`dojo.global`.\n\t\t\t// example:\n\t\t\t//\t\tset the value of `foo.bar.baz`, regardless of whether\n\t\t\t//\t\tintermediate objects already exist:\n\t\t\t//\t| lang.setObject(\"foo.bar.baz\", value);\n\t\t\t// example:\n\t\t\t//\t\twithout `lang.setObject`, we often see code like this:\n\t\t\t//\t| // ensure that intermediate objects are available\n\t\t\t//\t| if(!obj[\"parent\"]){ obj.parent = {}; }\n\t\t\t//\t| if(!obj.parent[\"child\"]){ obj.parent.child = {}; }\n\t\t\t//\t| // now we can safely set the property\n\t\t\t//\t| obj.parent.child.prop = \"some value\";\n\t\t\t//\t\twhereas with `lang.setObject`, we can shorten that to:\n\t\t\t//\t| lang.setObject(\"parent.child.prop\", \"some value\", obj);\n\n\t\t\tvar parts = name.split(\".\"), p = parts.pop(), obj = getProp(parts, true, context);\n\t\t\treturn obj && p ? (obj[p] = value) : undefined; // Object\n\t\t},\n\n\t\tgetObject: function(name, create, context){\n\t\t\t// summary:\n\t\t\t//\t\tGet a property from a dot-separated string, such as \"A.B.C\"\n\t\t\t// description:\n\t\t\t//\t\tUseful for longer api chains where you have to test each object in\n\t\t\t//\t\tthe chain, or when you have an object reference in string format.\n\t\t\t// name: String\n\t\t\t//\t\tPath to an property, in the form \"A.B.C\".\n\t\t\t// create: Boolean?\n\t\t\t//\t\tOptional. Defaults to `false`. If `true`, Objects will be\n\t\t\t//\t\tcreated at any point along the 'path' that is undefined.\n\t\t\t// context: Object?\n\t\t\t//\t\tOptional. Object to use as root of path. Defaults to\n\t\t\t//\t\t'dojo.global'. Null may be passed.\n\t\t\treturn getProp(name.split(\".\"), create, context); // Object\n\t\t},\n\n\t\texists: function(name, obj){\n\t\t\t// summary:\n\t\t\t//\t\tdetermine if an object supports a given method\n\t\t\t// description:\n\t\t\t//\t\tuseful for longer api chains where you have to test each object in\n\t\t\t//\t\tthe chain. Useful for object and method detection.\n\t\t\t// name: String\n\t\t\t//\t\tPath to an object, in the form \"A.B.C\".\n\t\t\t// obj: Object?\n\t\t\t//\t\tObject to use as root of path. Defaults to\n\t\t\t//\t\t'dojo.global'. Null may be passed.\n\t\t\t// example:\n\t\t\t//\t| // define an object\n\t\t\t//\t| var foo = {\n\t\t\t//\t|\t\tbar: { }\n\t\t\t//\t| };\n\t\t\t//\t|\n\t\t\t//\t| // search the global scope\n\t\t\t//\t| lang.exists(\"foo.bar\"); // true\n\t\t\t//\t| lang.exists(\"foo.bar.baz\"); // false\n\t\t\t//\t|\n\t\t\t//\t| // search from a particular scope\n\t\t\t//\t| lang.exists(\"bar\", foo); // true\n\t\t\t//\t| lang.exists(\"bar.baz\", foo); // false\n\t\t\treturn lang.getObject(name, false, obj) !== undefined; // Boolean\n\t\t},\n\n\t\t// Crockford (ish) functions\n\n\t\tisString: function(it){\n\t\t\t// summary:\n\t\t\t//\t\tReturn true if it is a String\n\t\t\t// it: anything\n\t\t\t//\t\tItem to test.\n\t\t\treturn (typeof it == \"string\" || it instanceof String); // Boolean\n\t\t},\n\n\t\tisArray: function(it){\n\t\t\t// summary:\n\t\t\t//\t\tReturn true if it is an Array.\n\t\t\t//\t\tDoes not work on Arrays created in other windows.\n\t\t\t// it: anything\n\t\t\t//\t\tItem to test.\n\t\t\treturn it && (it instanceof Array || typeof it == \"array\"); // Boolean\n\t\t},\n\n\t\tisFunction: function(it){\n\t\t\t// summary:\n\t\t\t//\t\tReturn true if it is a Function\n\t\t\t// it: anything\n\t\t\t//\t\tItem to test.\n\t\t\treturn opts.call(it) === \"[object Function]\";\n\t\t},\n\n\t\tisObject: function(it){\n\t\t\t// summary:\n\t\t\t//\t\tReturns true if it is a JavaScript object (or an Array, a Function\n\t\t\t//\t\tor null)\n\t\t\t// it: anything\n\t\t\t//\t\tItem to test.\n\t\t\treturn it !== undefined &&\n\t\t\t\t(it === null || typeof it == \"object\" || lang.isArray(it) || lang.isFunction(it)); // Boolean\n\t\t},\n\n\t\tisArrayLike: function(it){\n\t\t\t// summary:\n\t\t\t//\t\tsimilar to isArray() but more permissive\n\t\t\t// it: anything\n\t\t\t//\t\tItem to test.\n\t\t\t// returns:\n\t\t\t//\t\tIf it walks like a duck and quacks like a duck, return `true`\n\t\t\t// description:\n\t\t\t//\t\tDoesn't strongly test for \"arrayness\".  Instead, settles for \"isn't\n\t\t\t//\t\ta string or number and has a length property\". Arguments objects\n\t\t\t//\t\tand DOM collections will return true when passed to\n\t\t\t//\t\tisArrayLike(), but will return false when passed to\n\t\t\t//\t\tisArray().\n\t\t\treturn it && it !== undefined && // Boolean\n\t\t\t\t// keep out built-in constructors (Number, String, ...) which have length\n\t\t\t\t// properties\n\t\t\t\t!lang.isString(it) && !lang.isFunction(it) &&\n\t\t\t\t!(it.tagName && it.tagName.toLowerCase() == 'form') &&\n\t\t\t\t(lang.isArray(it) || isFinite(it.length));\n\t\t},\n\n\t\tisAlien: function(it){\n\t\t\t// summary:\n\t\t\t//\t\tReturns true if it is a built-in function or some other kind of\n\t\t\t//\t\toddball that *should* report as a function but doesn't\n\t\t\treturn it && !lang.isFunction(it) && /\\{\\s*\\[native code\\]\\s*\\}/.test(String(it)); // Boolean\n\t\t},\n\n\t\textend: function(ctor, props){\n\t\t\t// summary:\n\t\t\t//\t\tAdds all properties and methods of props to constructor's\n\t\t\t//\t\tprototype, making them available to all instances created with\n\t\t\t//\t\tconstructor.\n\t\t\t// ctor: Object\n\t\t\t//\t\tTarget constructor to extend.\n\t\t\t// props: Object\n\t\t\t//\t\tOne or more objects to mix into ctor.prototype\n\t\t\tfor(var i=1, l=arguments.length; i<l; i++){\n\t\t\t\tlang._mixin(ctor.prototype, arguments[i]);\n\t\t\t}\n\t\t\treturn ctor; // Object\n\t\t},\n\n\t\t_hitchArgs: function(scope, method){\n\t\t\tvar pre = lang._toArray(arguments, 2);\n\t\t\tvar named = lang.isString(method);\n\t\t\treturn function(){\n\t\t\t\t// arrayify arguments\n\t\t\t\tvar args = lang._toArray(arguments);\n\t\t\t\t// locate our method\n\t\t\t\tvar f = named ? (scope||dojo.global)[method] : method;\n\t\t\t\t// invoke with collected args\n\t\t\t\treturn f && f.apply(scope || this, pre.concat(args)); // mixed\n\t\t\t}; // Function\n\t\t},\n\n\t\thitch: function(scope, method){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a function that will only ever execute in the a given scope.\n\t\t\t//\t\tThis allows for easy use of object member functions\n\t\t\t//\t\tin callbacks and other places in which the \"this\" keyword may\n\t\t\t//\t\totherwise not reference the expected scope.\n\t\t\t//\t\tAny number of default positional arguments may be passed as parameters\n\t\t\t//\t\tbeyond \"method\".\n\t\t\t//\t\tEach of these values will be used to \"placehold\" (similar to curry)\n\t\t\t//\t\tfor the hitched function.\n\t\t\t// scope: Object\n\t\t\t//\t\tThe scope to use when method executes. If method is a string,\n\t\t\t//\t\tscope is also the object containing method.\n\t\t\t// method: Function|String...\n\t\t\t//\t\tA function to be hitched to scope, or the name of the method in\n\t\t\t//\t\tscope to be hitched.\n\t\t\t// example:\n\t\t\t//\t|\tlang.hitch(foo, \"bar\")();\n\t\t\t//\t\truns foo.bar() in the scope of foo\n\t\t\t// example:\n\t\t\t//\t|\tlang.hitch(foo, myFunction);\n\t\t\t//\t\treturns a function that runs myFunction in the scope of foo\n\t\t\t// example:\n\t\t\t//\t\tExpansion on the default positional arguments passed along from\n\t\t\t//\t\thitch. Passed args are mixed first, additional args after.\n\t\t\t//\t|\tvar foo = { bar: function(a, b, c){ console.log(a, b, c); } };\n\t\t\t//\t|\tvar fn = lang.hitch(foo, \"bar\", 1, 2);\n\t\t\t//\t|\tfn(3); // logs \"1, 2, 3\"\n\t\t\t// example:\n\t\t\t//\t|\tvar foo = { bar: 2 };\n\t\t\t//\t|\tlang.hitch(foo, function(){ this.bar = 10; })();\n\t\t\t//\t\texecute an anonymous function in scope of foo\n\t\t\tif(arguments.length > 2){\n\t\t\t\treturn lang._hitchArgs.apply(dojo, arguments); // Function\n\t\t\t}\n\t\t\tif(!method){\n\t\t\t\tmethod = scope;\n\t\t\t\tscope = null;\n\t\t\t}\n\t\t\tif(lang.isString(method)){\n\t\t\t\tscope = scope || dojo.global;\n\t\t\t\tif(!scope[method]){ throw(['lang.hitch: scope[\"', method, '\"] is null (scope=\"', scope, '\")'].join('')); }\n\t\t\t\treturn function(){ return scope[method].apply(scope, arguments || []); }; // Function\n\t\t\t}\n\t\t\treturn !scope ? method : function(){ return method.apply(scope, arguments || []); }; // Function\n\t\t},\n\n\t\tdelegate: (function(){\n\t\t\t// boodman/crockford delegation w/ cornford optimization\n\t\t\tfunction TMP(){}\n\t\t\treturn function(obj, props){\n\t\t\t\tTMP.prototype = obj;\n\t\t\t\tvar tmp = new TMP();\n\t\t\t\tTMP.prototype = null;\n\t\t\t\tif(props){\n\t\t\t\t\tlang._mixin(tmp, props);\n\t\t\t\t}\n\t\t\t\treturn tmp; // Object\n\t\t\t};\n\t\t})(),\n\t\t/*=====\n\t\tdelegate: function(obj, props){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a new object which \"looks\" to obj for properties which it\n\t\t\t//\t\tdoes not have a value for. Optionally takes a bag of properties to\n\t\t\t//\t\tseed the returned object with initially.\n\t\t\t// description:\n\t\t\t//\t\tThis is a small implementation of the Boodman/Crockford delegation\n\t\t\t//\t\tpattern in JavaScript. An intermediate object constructor mediates\n\t\t\t//\t\tthe prototype chain for the returned object, using it to delegate\n\t\t\t//\t\tdown to obj for property lookup when object-local lookup fails.\n\t\t\t//\t\tThis can be thought of similarly to ES4's \"wrap\", save that it does\n\t\t\t//\t\tnot act on types but rather on pure objects.\n\t\t\t// obj: Object\n\t\t\t//\t\tThe object to delegate to for properties not found directly on the\n\t\t\t//\t\treturn object or in props.\n\t\t\t// props: Object...\n\t\t\t//\t\tan object containing properties to assign to the returned object\n\t\t\t// returns:\n\t\t\t//\t\tan Object of anonymous type\n\t\t\t// example:\n\t\t\t//\t|\tvar foo = { bar: \"baz\" };\n\t\t\t//\t|\tvar thinger = lang.delegate(foo, { thud: \"xyzzy\"});\n\t\t\t//\t|\tthinger.bar == \"baz\"; // delegated to foo\n\t\t\t//\t|\tfoo.thud == undefined; // by definition\n\t\t\t//\t|\tthinger.thud == \"xyzzy\"; // mixed in from props\n\t\t\t//\t|\tfoo.bar = \"thonk\";\n\t\t\t//\t|\tthinger.bar == \"thonk\"; // still delegated to foo's bar\n\t\t},\n\t\t=====*/\n\n\t\t_toArray: has(\"ie\") ?\n\t\t\t(function(){\n\t\t\t\tfunction slow(obj, offset, startWith){\n\t\t\t\t\tvar arr = startWith||[];\n\t\t\t\t\tfor(var x = offset || 0; x < obj.length; x++){\n\t\t\t\t\t\tarr.push(obj[x]);\n\t\t\t\t\t}\n\t\t\t\t\treturn arr;\n\t\t\t\t}\n\t\t\t\treturn function(obj){\n\t\t\t\t\treturn ((obj.item) ? slow : efficient).apply(this, arguments);\n\t\t\t\t};\n\t\t\t})() : efficient,\n\t\t/*=====\n\t\t _toArray: function(obj, offset, startWith){\n\t\t\t // summary:\n\t\t\t //\t\tConverts an array-like object (i.e. arguments, DOMCollection) to an\n\t\t\t //\t\tarray. Returns a new Array with the elements of obj.\n\t\t\t // obj: Object\n\t\t\t //\t\tthe object to \"arrayify\". We expect the object to have, at a\n\t\t\t //\t\tminimum, a length property which corresponds to integer-indexed\n\t\t\t //\t\tproperties.\n\t\t\t // offset: Number?\n\t\t\t //\t\tthe location in obj to start iterating from. Defaults to 0.\n\t\t\t //\t\tOptional.\n\t\t\t // startWith: Array?\n\t\t\t //\t\tAn array to pack with the properties of obj. If provided,\n\t\t\t //\t\tproperties in obj are appended at the end of startWith and\n\t\t\t //\t\tstartWith is the returned array.\n\t\t },\n\t\t =====*/\n\n\t\tpartial: function(/*Function|String*/ method /*, ...*/){\n\t\t\t// summary:\n\t\t\t//\t\tsimilar to hitch() except that the scope object is left to be\n\t\t\t//\t\twhatever the execution context eventually becomes.\n\t\t\t// description:\n\t\t\t//\t\tCalling lang.partial is the functional equivalent of calling:\n\t\t\t//\t\t|\tlang.hitch(null, funcName, ...);\n\t\t\t// method:\n\t\t\t//\t\tThe function to \"wrap\"\n\t\t\tvar arr = [ null ];\n\t\t\treturn lang.hitch.apply(dojo, arr.concat(lang._toArray(arguments))); // Function\n\t\t},\n\n\t\tclone: function(/*anything*/ src){\n\t\t\t// summary:\n\t\t\t//\t\tClones objects (including DOM nodes) and all children.\n\t\t\t//\t\tWarning: do not clone cyclic structures.\n\t\t\t// src:\n\t\t\t//\t\tThe object to clone\n\t\t\tif(!src || typeof src != \"object\" || lang.isFunction(src)){\n\t\t\t\t// null, undefined, any non-object, or function\n\t\t\t\treturn src;\t// anything\n\t\t\t}\n\t\t\tif(src.nodeType && \"cloneNode\" in src){\n\t\t\t\t// DOM Node\n\t\t\t\treturn src.cloneNode(true); // Node\n\t\t\t}\n\t\t\tif(src instanceof Date){\n\t\t\t\t// Date\n\t\t\t\treturn new Date(src.getTime());\t// Date\n\t\t\t}\n\t\t\tif(src instanceof RegExp){\n\t\t\t\t// RegExp\n\t\t\t\treturn new RegExp(src);   // RegExp\n\t\t\t}\n\t\t\tvar r, i, l;\n\t\t\tif(lang.isArray(src)){\n\t\t\t\t// array\n\t\t\t\tr = [];\n\t\t\t\tfor(i = 0, l = src.length; i < l; ++i){\n\t\t\t\t\tif(i in src){\n\t\t\t\t\t\tr.push(lang.clone(src[i]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// we don't clone functions for performance reasons\n\t\t\t\t//\t\t}else if(d.isFunction(src)){\n\t\t\t\t//\t\t\t// function\n\t\t\t\t//\t\t\tr = function(){ return src.apply(this, arguments); };\n\t\t\t}else{\n\t\t\t\t// generic objects\n\t\t\t\tr = src.constructor ? new src.constructor() : {};\n\t\t\t}\n\t\t\treturn lang._mixin(r, src, lang.clone);\n\t\t},\n\n\n\t\ttrim: String.prototype.trim ?\n\t\t\tfunction(str){ return str.trim(); } :\n\t\t\tfunction(str){ return str.replace(/^\\s\\s*/, '').replace(/\\s\\s*$/, ''); },\n\t\t/*=====\n\t\t trim: function(str){\n\t\t\t // summary:\n\t\t\t //\t\tTrims whitespace from both sides of the string\n\t\t\t // str: String\n\t\t\t //\t\tString to be trimmed\n\t\t\t // returns: String\n\t\t\t //\t\tReturns the trimmed string\n\t\t\t // description:\n\t\t\t //\t\tThis version of trim() was selected for inclusion into the base due\n\t\t\t //\t\tto its compact size and relatively good performance\n\t\t\t //\t\t(see [Steven Levithan's blog](http://blog.stevenlevithan.com/archives/faster-trim-javascript)\n\t\t\t //\t\tUses String.prototype.trim instead, if available.\n\t\t\t //\t\tThe fastest but longest version of this function is located at\n\t\t\t //\t\tlang.string.trim()\n\t\t },\n\t\t =====*/\n\n\t\treplace: function(tmpl, map, pattern){\n\t\t\t// summary:\n\t\t\t//\t\tPerforms parameterized substitutions on a string. Throws an\n\t\t\t//\t\texception if any parameter is unmatched.\n\t\t\t// tmpl: String\n\t\t\t//\t\tString to be used as a template.\n\t\t\t// map: Object|Function\n\t\t\t//\t\tIf an object, it is used as a dictionary to look up substitutions.\n\t\t\t//\t\tIf a function, it is called for every substitution with following parameters:\n\t\t\t//\t\ta whole match, a name, an offset, and the whole template\n\t\t\t//\t\tstring (see https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/replace\n\t\t\t//\t\tfor more details).\n\t\t\t// pattern: RegEx?\n\t\t\t//\t\tOptional regular expression objects that overrides the default pattern.\n\t\t\t//\t\tMust be global and match one item. The default is: /\\{([^\\}]+)\\}/g,\n\t\t\t//\t\twhich matches patterns like that: \"{xxx}\", where \"xxx\" is any sequence\n\t\t\t//\t\tof characters, which doesn't include \"}\".\n\t\t\t// returns: String\n\t\t\t//\t\tReturns the substituted string.\n\t\t\t// example:\n\t\t\t//\t|\t// uses a dictionary for substitutions:\n\t\t\t//\t|\tlang.replace(\"Hello, {name.first} {name.last} AKA {nick}!\",\n\t\t\t//\t|\t\t{\n\t\t\t//\t|\t\t\tnick: \"Bob\",\n\t\t\t//\t|\t\t\tname: {\n\t\t\t//\t|\t\t\t\tfirst:\t\"Robert\",\n\t\t\t//\t|\t\t\t\tmiddle: \"X\",\n\t\t\t//\t|\t\t\t\tlast:\t\t\"Cringely\"\n\t\t\t//\t|\t\t\t}\n\t\t\t//\t|\t\t});\n\t\t\t//\t|\t// returns: Hello, Robert Cringely AKA Bob!\n\t\t\t// example:\n\t\t\t//\t|\t// uses an array for substitutions:\n\t\t\t//\t|\tlang.replace(\"Hello, {0} {2}!\",\n\t\t\t//\t|\t\t[\"Robert\", \"X\", \"Cringely\"]);\n\t\t\t//\t|\t// returns: Hello, Robert Cringely!\n\t\t\t// example:\n\t\t\t//\t|\t// uses a function for substitutions:\n\t\t\t//\t|\tfunction sum(a){\n\t\t\t//\t|\t\tvar t = 0;\n\t\t\t//\t|\t\tarrayforEach(a, function(x){ t += x; });\n\t\t\t//\t|\t\treturn t;\n\t\t\t//\t|\t}\n\t\t\t//\t|\tlang.replace(\n\t\t\t//\t|\t\t\"{count} payments averaging {avg} USD per payment.\",\n\t\t\t//\t|\t\tlang.hitch(\n\t\t\t//\t|\t\t\t{ payments: [11, 16, 12] },\n\t\t\t//\t|\t\t\tfunction(_, key){\n\t\t\t//\t|\t\t\t\tswitch(key){\n\t\t\t//\t|\t\t\t\t\tcase \"count\": return this.payments.length;\n\t\t\t//\t|\t\t\t\t\tcase \"min\":\t\treturn Math.min.apply(Math, this.payments);\n\t\t\t//\t|\t\t\t\t\tcase \"max\":\t\treturn Math.max.apply(Math, this.payments);\n\t\t\t//\t|\t\t\t\t\tcase \"sum\":\t\treturn sum(this.payments);\n\t\t\t//\t|\t\t\t\t\tcase \"avg\":\t\treturn sum(this.payments) / this.payments.length;\n\t\t\t//\t|\t\t\t\t}\n\t\t\t//\t|\t\t\t}\n\t\t\t//\t|\t\t)\n\t\t\t//\t|\t);\n\t\t\t//\t|\t// prints: 3 payments averaging 13 USD per payment.\n\t\t\t// example:\n\t\t\t//\t|\t// uses an alternative PHP-like pattern for substitutions:\n\t\t\t//\t|\tlang.replace(\"Hello, ${0} ${2}!\",\n\t\t\t//\t|\t\t[\"Robert\", \"X\", \"Cringely\"], /\\$\\{([^\\}]+)\\}/g);\n\t\t\t//\t|\t// returns: Hello, Robert Cringely!\n\n\t\t\treturn tmpl.replace(pattern || _pattern, lang.isFunction(map) ?\n\t\t\t\tmap : function(_, k){ return lang.getObject(k, false, map); });\n\t\t}\n\t};\n\n\t 1  && lang.mixin(dojo, lang);\n\n\treturn lang;\n});\n\n\n},\n'dojo/request/util':function(){\ndefine(\"dojo/request/util\", [\n\t'exports',\n\t'../errors/RequestError',\n\t'../errors/CancelError',\n\t'../Deferred',\n\t'../io-query',\n\t'../_base/array',\n\t'../_base/lang'\n], function(exports, RequestError, CancelError, Deferred, ioQuery, array, lang){\n\texports.deepCopy = function deepCopy(target, source){\n\t\tfor(var name in source){\n\t\t\tvar tval = target[name],\n\t\t\t\tsval = source[name];\n\t\t\tif(tval !== sval){\n\t\t\t\tif(tval && typeof tval === 'object' && sval && typeof sval === 'object'){\n\t\t\t\t\texports.deepCopy(tval, sval);\n\t\t\t\t}else{\n\t\t\t\t\ttarget[name] = sval;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn target;\n\t};\n\n\texports.deepCreate = function deepCreate(source, properties){\n\t\tproperties = properties || {};\n\t\tvar target = lang.delegate(source),\n\t\t\tname, value;\n\n\t\tfor(name in source){\n\t\t\tvalue = source[name];\n\n\t\t\tif(value && typeof value === 'object'){\n\t\t\t\ttarget[name] = exports.deepCreate(value, properties[name]);\n\t\t\t}\n\t\t}\n\t\treturn exports.deepCopy(target, properties);\n\t};\n\n\tvar freeze = Object.freeze || function(obj){ return obj; };\n\tfunction okHandler(response){\n\t\treturn freeze(response);\n\t}\n\n\texports.deferred = function deferred(response, cancel, isValid, isReady, handleResponse, last){\n\t\tvar def = new Deferred(function(reason){\n\t\t\tcancel && cancel(def, response);\n\n\t\t\tif(!reason || !(reason instanceof RequestError) && !(reason instanceof CancelError)){\n\t\t\t\treturn new CancelError('Request canceled', response);\n\t\t\t}\n\t\t\treturn reason;\n\t\t});\n\n\t\tdef.response = response;\n\t\tdef.isValid = isValid;\n\t\tdef.isReady = isReady;\n\t\tdef.handleResponse = handleResponse;\n\n\t\tfunction errHandler(error){\n\t\t\terror.response = response;\n\t\t\tthrow error;\n\t\t}\n\t\tvar responsePromise = def.then(okHandler).otherwise(errHandler);\n\n\t\tif(exports.notify){\n\t\t\tresponsePromise.then(\n\t\t\t\tlang.hitch(exports.notify, 'emit', 'load'),\n\t\t\t\tlang.hitch(exports.notify, 'emit', 'error')\n\t\t\t);\n\t\t}\n\n\t\tvar dataPromise = responsePromise.then(function(response){\n\t\t\t\treturn response.data || response.text;\n\t\t\t});\n\n\t\tvar promise = freeze(lang.delegate(dataPromise, {\n\t\t\tresponse: responsePromise\n\t\t}));\n\n\n\t\tif(last){\n\t\t\tdef.then(function(response){\n\t\t\t\tlast.call(def, response);\n\t\t\t}, function(error){\n\t\t\t\tlast.call(def, response, error);\n\t\t\t});\n\t\t}\n\n\t\tdef.promise = promise;\n\t\tdef.then = promise.then;\n\n\t\treturn def;\n\t};\n\n\texports.addCommonMethods = function addCommonMethods(provider, methods){\n\t\tarray.forEach(methods||['GET', 'POST', 'PUT', 'DELETE'], function(method){\n\t\t\tprovider[(method === 'DELETE' ? 'DEL' : method).toLowerCase()] = function(url, options){\n\t\t\t\toptions = lang.delegate(options||{});\n\t\t\t\toptions.method = method;\n\t\t\t\treturn provider(url, options);\n\t\t\t};\n\t\t});\n\t};\n\n\texports.parseArgs = function parseArgs(url, options, skipData){\n\t\tvar data = options.data,\n\t\t\tquery = options.query;\n\t\t\n\t\tif(data && !skipData){\n\t\t\tif(typeof data === 'object'){\n\t\t\t\toptions.data = ioQuery.objectToQuery(data);\n\t\t\t}\n\t\t}\n\n\t\tif(query){\n\t\t\tif(typeof query === 'object'){\n\t\t\t\tquery = ioQuery.objectToQuery(query);\n\t\t\t}\n\t\t\tif(options.preventCache){\n\t\t\t\tquery += (query ? '&' : '') + 'request.preventCache=' + (+(new Date));\n\t\t\t}\n\t\t}else if(options.preventCache){\n\t\t\tquery = 'request.preventCache=' + (+(new Date));\n\t\t}\n\n\t\tif(url && query){\n\t\t\turl += (~url.indexOf('?') ? '&' : '?') + query;\n\t\t}\n\n\t\treturn {\n\t\t\turl: url,\n\t\t\toptions: options,\n\t\t\tgetHeader: function(headerName){ return null; }\n\t\t};\n\t};\n\n\texports.checkStatus = function(stat){\n\t\tstat = stat || 0;\n\t\treturn (stat >= 200 && stat < 300) || // allow any 2XX response code\n\t\t\tstat === 304 ||                 // or, get it out of the cache\n\t\t\tstat === 1223 ||                // or, Internet Explorer mangled the status code\n\t\t\t!stat;                         // or, we're Titanium/browser chrome/chrome extension requesting a local file\n\t};\n});\n\n},\n'dojo/Evented':function(){\ndefine(\"dojo/Evented\", [\"./aspect\", \"./on\"], function(aspect, on){\n\t// module:\n\t//\t\tdojo/Evented\n\n \t\"use strict\";\n \tvar after = aspect.after;\n\tfunction Evented(){\n\t\t// summary:\n\t\t//\t\tA class that can be used as a mixin or base class,\n\t\t//\t\tto add on() and emit() methods to a class\n\t\t//\t\tfor listening for events and emitting events:\n\t\t//\n\t\t//\t\t|\tdefine([\"dojo/Evented\"], function(Evented){\n\t\t//\t\t|\t\tvar EventedWidget = dojo.declare([Evented, dijit._Widget], {...});\n\t\t//\t\t|\t\twidget = new EventedWidget();\n\t\t//\t\t|\t\twidget.on(\"open\", function(event){\n\t\t//\t\t|\t\t... do something with event\n\t\t//\t\t|\t });\n\t\t//\t\t|\n\t\t//\t\t|\twidget.emit(\"open\", {name:\"some event\", ...});\n\t}\n\tEvented.prototype = {\n\t\ton: function(type, listener){\n\t\t\treturn on.parse(this, type, listener, function(target, type){\n\t\t\t\treturn after(target, 'on' + type, listener, true);\n\t\t\t});\n\t\t},\n\t\temit: function(type, event){\n\t\t\tvar args = [this];\n\t\t\targs.push.apply(args, arguments);\n\t\t\treturn on.emit.apply(on, args);\n\t\t}\n\t};\n\treturn Evented;\n});\n\n},\n'dojo/mouse':function(){\ndefine(\"dojo/mouse\", [\"./_base/kernel\", \"./on\", \"./has\", \"./dom\", \"./_base/window\"], function(dojo, on, has, dom, win){\n\n\t// module:\n\t//\t\tdojo/mouse\n\n    has.add(\"dom-quirks\", win.doc && win.doc.compatMode == \"BackCompat\");\n\thas.add(\"events-mouseenter\", win.doc && \"onmouseenter\" in win.doc.createElement(\"div\"));\n\thas.add(\"events-mousewheel\", win.doc && 'onmousewheel' in win.doc);\n\n\tvar mouseButtons;\n\tif((has(\"dom-quirks\") && has(\"ie\")) || !has(\"dom-addeventlistener\")){\n\t\tmouseButtons = {\n\t\t\tLEFT:   1,\n\t\t\tMIDDLE: 4,\n\t\t\tRIGHT:  2,\n\t\t\t// helper functions\n\t\t\tisButton: function(e, button){ return e.button & button; },\n\t\t\tisLeft:   function(e){ return e.button & 1; },\n\t\t\tisMiddle: function(e){ return e.button & 4; },\n\t\t\tisRight:  function(e){ return e.button & 2; }\n\t\t};\n\t}else{\n\t\tmouseButtons = {\n\t\t\tLEFT:   0,\n\t\t\tMIDDLE: 1,\n\t\t\tRIGHT:  2,\n\t\t\t// helper functions\n\t\t\tisButton: function(e, button){ return e.button == button; },\n\t\t\tisLeft:   function(e){ return e.button == 0; },\n\t\t\tisMiddle: function(e){ return e.button == 1; },\n\t\t\tisRight:  function(e){ return e.button == 2; }\n\t\t};\n\t}\n\tdojo.mouseButtons = mouseButtons;\n\n/*=====\n\tdojo.mouseButtons = {\n\t\t// LEFT: Number\n\t\t//\t\tNumeric value of the left mouse button for the platform.\n\t\tLEFT:   0,\n\t\t// MIDDLE: Number\n\t\t//\t\tNumeric value of the middle mouse button for the platform.\n\t\tMIDDLE: 1,\n\t\t// RIGHT: Number\n\t\t//\t\tNumeric value of the right mouse button for the platform.\n\t\tRIGHT:  2,\n\n\t\tisButton: function(e, button){\n\t\t\t// summary:\n\t\t\t//\t\tChecks an event object for a pressed button\n\t\t\t// e: Event\n\t\t\t//\t\tEvent object to examine\n\t\t\t// button: Number\n\t\t\t//\t\tThe button value (example: dojo.mouseButton.LEFT)\n\t\t\treturn e.button == button; // Boolean\n\t\t},\n\t\tisLeft: function(e){\n\t\t\t// summary:\n\t\t\t//\t\tChecks an event object for the pressed left button\n\t\t\t// e: Event\n\t\t\t//\t\tEvent object to examine\n\t\t\treturn e.button == 0; // Boolean\n\t\t},\n\t\tisMiddle: function(e){\n\t\t\t// summary:\n\t\t\t//\t\tChecks an event object for the pressed middle button\n\t\t\t// e: Event\n\t\t\t//\t\tEvent object to examine\n\t\t\treturn e.button == 1; // Boolean\n\t\t},\n\t\tisRight: function(e){\n\t\t\t// summary:\n\t\t\t//\t\tChecks an event object for the pressed right button\n\t\t\t// e: Event\n\t\t\t//\t\tEvent object to examine\n\t\t\treturn e.button == 2; // Boolean\n\t\t}\n\t};\n=====*/\n\n\tfunction eventHandler(type, selectHandler){\n\t\t// emulation of mouseenter/leave with mouseover/out using descendant checking\n\t\tvar handler = function(node, listener){\n\t\t\treturn on(node, type, function(evt){\n\t\t\t\tif(selectHandler){\n\t\t\t\t\treturn selectHandler(evt, listener);\n\t\t\t\t}\n\t\t\t\tif(!dom.isDescendant(evt.relatedTarget, node)){\n\t\t\t\t\treturn listener.call(this, evt);\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t\thandler.bubble = function(select){\n\t\t\treturn eventHandler(type, function(evt, listener){\n\t\t\t\t// using a selector, use the select function to determine if the mouse moved inside the selector and was previously outside the selector\n\t\t\t\tvar target = select(evt.target);\n\t\t\t\tvar relatedTarget = evt.relatedTarget;\n\t\t\t\tif(target && (target != (relatedTarget && relatedTarget.nodeType == 1 && select(relatedTarget)))){\n\t\t\t\t\treturn listener.call(target, evt);\n\t\t\t\t} \n\t\t\t});\n\t\t};\n\t\treturn handler;\n\t}\n\tvar wheel;\n\tif(has(\"events-mousewheel\")){\n\t\twheel = 'mousewheel';\n\t}else{ //firefox\n\t\twheel = function(node, listener){\n\t\t\treturn on(node, 'DOMMouseScroll', function(evt){\n\t\t\t\tevt.wheelDelta = -evt.detail;\n\t\t\t\tlistener.call(this, evt);\n\t\t\t});\n\t\t};\n\t}\n\treturn {\n\t\t// summary:\n\t\t//\t\tThis module provide mouse event handling utility functions and exports\n\t\t//\t\tmouseenter and mouseleave event emulation.\n\t\t// example:\n\t\t//\t\tTo use these events, you register a mouseenter like this:\n\t\t//\t\t|\tdefine([\"dojo/on\", dojo/mouse\"], function(on, mouse){\n\t\t//\t\t|\t\ton(targetNode, mouse.enter, function(event){\n\t\t//\t\t|\t\t\tdojo.addClass(targetNode, \"highlighted\");\n\t\t//\t\t|\t\t});\n\t\t//\t\t|\t\ton(targetNode, mouse.leave, function(event){\n\t\t//\t\t|\t\t\tdojo.removeClass(targetNode, \"highlighted\");\n\t\t//\t\t|\t\t});\n\n\t\t_eventHandler: eventHandler,\t\t// for dojo/touch\n\n\t\t// enter: Synthetic Event\n\t\t//\t\tThis is an extension event for the mouseenter that IE provides, emulating the\n\t\t//\t\tbehavior on other browsers.\n\t\tenter: eventHandler(\"mouseover\"),\n\n\t\t// leave: Synthetic Event\n\t\t//\t\tThis is an extension event for the mouseleave that IE provides, emulating the\n\t\t//\t\tbehavior on other browsers.\n\t\tleave: eventHandler(\"mouseout\"),\n\n\t\t// wheel: Normalized Mouse Wheel Event\n\t\t//\t\tThis is an extension event for the mousewheel that non-Mozilla browsers provide,\n\t\t//\t\temulating the behavior on Mozilla based browsers.\n\t\twheel: wheel,\n\n\t\tisLeft: mouseButtons.isLeft,\n\t\t/*=====\n\t\tisLeft: function(){\n\t\t\t// summary:\n\t\t\t//\t\tTest an event object (from a mousedown event) to see if the left button was pressed.\n\t\t},\n\t\t=====*/\n\n\t\tisMiddle: mouseButtons.isMiddle,\n\t\t/*=====\n\t\t isMiddle: function(){\n\t\t\t // summary:\n\t\t\t //\t\tTest an event object (from a mousedown event) to see if the middle button was pressed.\n\t\t },\n\t\t =====*/\n\n\t\tisRight: mouseButtons.isRight\n\t\t/*=====\n\t\t , isRight: function(){\n\t\t\t // summary:\n\t\t\t //\t\tTest an event object (from a mousedown event) to see if the right button was pressed.\n\t\t }\n\t\t =====*/\n\t};\n});\n\n},\n'dojo/topic':function(){\ndefine(\"dojo/topic\", [\"./Evented\"], function(Evented){\n\n\t// module:\n\t//\t\tdojo/topic\n\n\tvar hub = new Evented;\n\treturn {\n\t\t// summary:\n\t\t//\t\tPubsub hub.\n\t\t// example:\n\t\t//\t\t| \ttopic.subscribe(\"some/topic\", function(event){\n\t\t//\t\t|\t... do something with event\n\t\t//\t\t|\t});\n\t\t//\t\t|\ttopic.publish(\"some/topic\", {name:\"some event\", ...});\n\n\t\tpublish: function(topic, event){\n\t\t\t// summary:\n\t\t\t//\t\tPublishes a message to a topic on the pub/sub hub. All arguments after\n\t\t\t//\t\tthe first will be passed to the subscribers, so any number of arguments\n\t\t\t//\t\tcan be provided (not just event).\n\t\t\t// topic: String\n\t\t\t//\t\tThe name of the topic to publish to\n\t\t\t// event: Object\n\t\t\t//\t\tAn event to distribute to the topic listeners\n\t\t\treturn hub.emit.apply(hub, arguments);\n\t\t},\n\n\t\tsubscribe: function(topic, listener){\n\t\t\t// summary:\n\t\t\t//\t\tSubscribes to a topic on the pub/sub hub\n\t\t\t// topic: String\n\t\t\t//\t\tThe topic to subscribe to\n\t\t\t// listener: Function\n\t\t\t//\t\tA function to call when a message is published to the given topic\n\t\t\treturn hub.on.apply(hub, arguments);\n\t\t}\n\t};\n});\n\n},\n'dojo/_base/xhr':function(){\ndefine(\"dojo/_base/xhr\", [\n\t\"./kernel\",\n\t\"./sniff\",\n\t\"require\",\n\t\"../io-query\",\n\t/*===== \"./declare\", =====*/\n\t\"../dom\",\n\t\"../dom-form\",\n\t\"./Deferred\",\n\t\"./config\",\n\t\"./json\",\n\t\"./lang\",\n\t\"./array\",\n\t\"../on\",\n\t\"../aspect\",\n\t\"../request/watch\",\n\t\"../request/xhr\",\n\t\"../request/util\"\n], function(dojo, has, require, ioq, /*===== declare, =====*/ dom, domForm, Deferred, config, json, lang, array, on, aspect, watch, _xhr, util){\n\t// module:\n\t//\t\tdojo/_base/xhr\n\n\t/*=====\n\tdojo._xhrObj = function(){\n\t\t// summary:\n\t\t//\t\tdoes the work of portably generating a new XMLHTTPRequest object.\n\t};\n\t=====*/\n\tdojo._xhrObj = _xhr._create;\n\n\tvar cfg = dojo.config;\n\n\t// mix in io-query and dom-form\n\tdojo.objectToQuery = ioq.objectToQuery;\n\tdojo.queryToObject = ioq.queryToObject;\n\tdojo.fieldToObject = domForm.fieldToObject;\n\tdojo.formToObject = domForm.toObject;\n\tdojo.formToQuery = domForm.toQuery;\n\tdojo.formToJson = domForm.toJson;\n\n\t// need to block async callbacks from snatching this thread as the result\n\t// of an async callback might call another sync XHR, this hangs khtml forever\n\t// must checked by watchInFlight()\n\n\tdojo._blockAsync = false;\n\n\t// MOW: remove dojo._contentHandlers alias in 2.0\n\tvar handlers = dojo._contentHandlers = dojo.contentHandlers = {\n\t\t// summary:\n\t\t//\t\tA map of available XHR transport handle types. Name matches the\n\t\t//\t\t`handleAs` attribute passed to XHR calls.\n\t\t// description:\n\t\t//\t\tA map of available XHR transport handle types. Name matches the\n\t\t//\t\t`handleAs` attribute passed to XHR calls. Each contentHandler is\n\t\t//\t\tcalled, passing the xhr object for manipulation. The return value\n\t\t//\t\tfrom the contentHandler will be passed to the `load` or `handle`\n\t\t//\t\tfunctions defined in the original xhr call.\n\t\t// example:\n\t\t//\t\tCreating a custom content-handler:\n\t\t//\t|\txhr.contentHandlers.makeCaps = function(xhr){\n\t\t//\t|\t\treturn xhr.responseText.toUpperCase();\n\t\t//\t|\t}\n\t\t//\t|\t// and later:\n\t\t//\t|\tdojo.xhrGet({\n\t\t//\t|\t\turl:\"foo.txt\",\n\t\t//\t|\t\thandleAs:\"makeCaps\",\n\t\t//\t|\t\tload: function(data){ /* data is a toUpper version of foo.txt */ }\n\t\t//\t|\t});\n\n\t\t\"text\": function(xhr){\n\t\t\t// summary:\n\t\t\t//\t\tA contentHandler which simply returns the plaintext response data\n\t\t\treturn xhr.responseText;\n\t\t},\n\t\t\"json\": function(xhr){\n\t\t\t// summary:\n\t\t\t//\t\tA contentHandler which returns a JavaScript object created from the response data\n\t\t\treturn json.fromJson(xhr.responseText || null);\n\t\t},\n\t\t\"json-comment-filtered\": function(xhr){\n\t\t\t// summary:\n\t\t\t//\t\tA contentHandler which expects comment-filtered JSON.\n\t\t\t// description:\n\t\t\t//\t\tA contentHandler which expects comment-filtered JSON.\n\t\t\t//\t\tthe json-comment-filtered option was implemented to prevent\n\t\t\t//\t\t\"JavaScript Hijacking\", but it is less secure than standard JSON. Use\n\t\t\t//\t\tstandard JSON instead. JSON prefixing can be used to subvert hijacking.\n\t\t\t//\n\t\t\t//\t\tWill throw a notice suggesting to use application/json mimetype, as\n\t\t\t//\t\tjson-commenting can introduce security issues. To decrease the chances of hijacking,\n\t\t\t//\t\tuse the standard `json` contentHandler, and prefix your \"JSON\" with: {}&&\n\t\t\t//\n\t\t\t//\t\tuse djConfig.useCommentedJson = true to turn off the notice\n\t\t\tif(!config.useCommentedJson){\n\t\t\t\tconsole.warn(\"Consider using the standard mimetype:application/json.\"\n\t\t\t\t\t+ \" json-commenting can introduce security issues. To\"\n\t\t\t\t\t+ \" decrease the chances of hijacking, use the standard the 'json' handler and\"\n\t\t\t\t\t+ \" prefix your json with: {}&&\\n\"\n\t\t\t\t\t+ \"Use djConfig.useCommentedJson=true to turn off this message.\");\n\t\t\t}\n\n\t\t\tvar value = xhr.responseText;\n\t\t\tvar cStartIdx = value.indexOf(\"\\/*\");\n\t\t\tvar cEndIdx = value.lastIndexOf(\"*\\/\");\n\t\t\tif(cStartIdx == -1 || cEndIdx == -1){\n\t\t\t\tthrow new Error(\"JSON was not comment filtered\");\n\t\t\t}\n\t\t\treturn json.fromJson(value.substring(cStartIdx+2, cEndIdx));\n\t\t},\n\t\t\"javascript\": function(xhr){\n\t\t\t// summary:\n\t\t\t//\t\tA contentHandler which evaluates the response data, expecting it to be valid JavaScript\n\n\t\t\t// FIXME: try Moz and IE specific eval variants?\n\t\t\treturn dojo.eval(xhr.responseText);\n\t\t},\n\t\t\"xml\": function(xhr){\n\t\t\t// summary:\n\t\t\t//\t\tA contentHandler returning an XML Document parsed from the response data\n\t\t\tvar result = xhr.responseXML;\n\n\t\t\tif(has(\"ie\")){\n\t\t\t\tif((!result || !result.documentElement)){\n\t\t\t\t\t//WARNING: this branch used by the xml handling in dojo.io.iframe,\n\t\t\t\t\t//so be sure to test dojo.io.iframe if making changes below.\n\t\t\t\t\tvar ms = function(n){ return \"MSXML\" + n + \".DOMDocument\"; };\n\t\t\t\t\tvar dp = [\"Microsoft.XMLDOM\", ms(6), ms(4), ms(3), ms(2)];\n\t\t\t\t\tarray.some(dp, function(p){\n\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\tvar dom = new ActiveXObject(p);\n\t\t\t\t\t\t\tdom.async = false;\n\t\t\t\t\t\t\tdom.loadXML(xhr.responseText);\n\t\t\t\t\t\t\tresult = dom;\n\t\t\t\t\t\t}catch(e){ return false; }\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result; // DOMDocument\n\t\t},\n\t\t\"json-comment-optional\": function(xhr){\n\t\t\t// summary:\n\t\t\t//\t\tA contentHandler which checks the presence of comment-filtered JSON and\n\t\t\t//\t\talternates between the `json` and `json-comment-filtered` contentHandlers.\n\t\t\tif(xhr.responseText && /^[^{\\[]*\\/\\*/.test(xhr.responseText)){\n\t\t\t\treturn handlers[\"json-comment-filtered\"](xhr);\n\t\t\t}else{\n\t\t\t\treturn handlers[\"json\"](xhr);\n\t\t\t}\n\t\t}\n\t};\n\n\t/*=====\n\n\t// kwargs function parameter definitions.   Assigning to dojo namespace rather than making them local variables\n\t// because they are used by dojo/io modules too\n\n\tdojo.__IoArgs = declare(null, {\n\t\t// url: String\n\t\t//\t\tURL to server endpoint.\n\t\t// content: Object?\n\t\t//\t\tContains properties with string values. These\n\t\t//\t\tproperties will be serialized as name1=value2 and\n\t\t//\t\tpassed in the request.\n\t\t// timeout: Integer?\n\t\t//\t\tMilliseconds to wait for the response. If this time\n\t\t//\t\tpasses, the then error callbacks are called.\n\t\t// form: DOMNode?\n\t\t//\t\tDOM node for a form. Used to extract the form values\n\t\t//\t\tand send to the server.\n\t\t// preventCache: Boolean?\n\t\t//\t\tDefault is false. If true, then a\n\t\t//\t\t\"dojo.preventCache\" parameter is sent in the request\n\t\t//\t\twith a value that changes with each request\n\t\t//\t\t(timestamp). Useful only with GET-type requests.\n\t\t// handleAs: String?\n\t\t//\t\tAcceptable values depend on the type of IO\n\t\t//\t\ttransport (see specific IO calls for more information).\n\t\t// rawBody: String?\n\t\t//\t\tSets the raw body for an HTTP request. If this is used, then the content\n\t\t//\t\tproperty is ignored. This is mostly useful for HTTP methods that have\n\t\t//\t\ta body to their requests, like PUT or POST. This property can be used instead\n\t\t//\t\tof postData and putData for dojo/_base/xhr.rawXhrPost and dojo/_base/xhr.rawXhrPut respectively.\n\t\t// ioPublish: Boolean?\n\t\t//\t\tSet this explicitly to false to prevent publishing of topics related to\n\t\t//\t\tIO operations. Otherwise, if djConfig.ioPublish is set to true, topics\n\t\t//\t\twill be published via dojo/topic.publish() for different phases of an IO operation.\n\t\t//\t\tSee dojo/main.__IoPublish for a list of topics that are published.\n\n\t\tload: function(response, ioArgs){\n\t\t\t// summary:\n\t\t\t//\t\tThis function will be\n\t\t\t//\t\tcalled on a successful HTTP response code.\n\t \t\t// ioArgs: dojo/main.__IoCallbackArgs\n\t\t\t//\t\tProvides additional information about the request.\n\t\t\t// response: Object\n\t\t\t//\t\tThe response in the format as defined with handleAs.\n\t\t},\n\n\t\terror: function(response, ioArgs){\n\t\t\t// summary:\n\t\t\t//\t\tThis function will\n\t\t\t//\t\tbe called when the request fails due to a network or server error, the url\n\t\t\t//\t\tis invalid, etc. It will also be called if the load or handle callback throws an\n\t\t\t//\t\texception, unless djConfig.debugAtAllCosts is true.\t This allows deployed applications\n\t\t\t//\t\tto continue to run even when a logic error happens in the callback, while making\n\t\t\t//\t\tit easier to troubleshoot while in debug mode.\n\t\t\t// ioArgs: dojo/main.__IoCallbackArgs\n\t\t\t//\t\tProvides additional information about the request.\n\t\t\t// response: Object\n\t\t\t//\t\tThe response in the format as defined with handleAs.\n\t\t},\n\n\t\thandle: function(loadOrError, response, ioArgs){\n\t\t\t// summary:\n\t \t\t//\t\tThis function will\n\t \t\t//\t\tbe called at the end of every request, whether or not an error occurs.\n\t\t\t// loadOrError: String\n\t\t\t//\t\tProvides a string that tells you whether this function\n\t\t\t//\t\twas called because of success (load) or failure (error).\n\t\t\t// response: Object\n\t\t\t//\t\tThe response in the format as defined with handleAs.\n\t\t\t// ioArgs: dojo/main.__IoCallbackArgs\n\t\t\t//\t\tProvides additional information about the request.\n\t\t}\n\t});\n\n\tdojo.__IoCallbackArgs = declare(null, {\n\t\t// args: Object\n\t\t//\t\tthe original object argument to the IO call.\n\t\t// xhr: XMLHttpRequest\n\t\t//\t\tFor XMLHttpRequest calls only, the\n\t\t//\t\tXMLHttpRequest object that was used for the\n\t\t//\t\trequest.\n\t\t// url: String\n\t\t//\t\tThe final URL used for the call. Many times it\n\t\t//\t\twill be different than the original args.url\n\t\t//\t\tvalue.\n\t\t// query: String\n\t\t//\t\tFor non-GET requests, the\n\t\t//\t\tname1=value1&name2=value2 parameters sent up in\n\t\t//\t\tthe request.\n\t\t// handleAs: String\n\t\t//\t\tThe final indicator on how the response will be\n\t\t//\t\thandled.\n\t\t// id: String\n\t\t//\t\tFor dojo/io/script calls only, the internal\n\t\t//\t\tscript ID used for the request.\n\t\t// canDelete: Boolean\n\t\t//\t\tFor dojo/io/script calls only, indicates\n\t\t//\t\twhether the script tag that represents the\n\t\t//\t\trequest can be deleted after callbacks have\n\t\t//\t\tbeen called. Used internally to know when\n\t\t//\t\tcleanup can happen on JSONP-type requests.\n\t\t// json: Object\n\t\t//\t\tFor dojo/io/script calls only: holds the JSON\n\t\t//\t\tresponse for JSONP-type requests. Used\n\t\t//\t\tinternally to hold on to the JSON responses.\n\t\t//\t\tYou should not need to access it directly --\n\t\t//\t\tthe same object should be passed to the success\n\t\t//\t\tcallbacks directly.\n\t});\n\n\tdojo.__IoPublish = declare(null, {\n\t\t// summary:\n\t\t//\t\tThis is a list of IO topics that can be published\n\t\t//\t\tif djConfig.ioPublish is set to true. IO topics can be\n\t\t//\t\tpublished for any Input/Output, network operation. So,\n\t\t//\t\tdojo.xhr, dojo.io.script and dojo.io.iframe can all\n\t\t//\t\ttrigger these topics to be published.\n\t\t// start: String\n\t\t//\t\t\"/dojo/io/start\" is sent when there are no outstanding IO\n\t\t//\t\trequests, and a new IO request is started. No arguments\n\t\t//\t\tare passed with this topic.\n\t\t// send: String\n\t\t//\t\t\"/dojo/io/send\" is sent whenever a new IO request is started.\n\t\t//\t\tIt passes the dojo.Deferred for the request with the topic.\n\t\t// load: String\n\t\t//\t\t\"/dojo/io/load\" is sent whenever an IO request has loaded\n\t\t//\t\tsuccessfully. It passes the response and the dojo.Deferred\n\t\t//\t\tfor the request with the topic.\n\t\t// error: String\n\t\t//\t\t\"/dojo/io/error\" is sent whenever an IO request has errored.\n\t\t//\t\tIt passes the error and the dojo.Deferred\n\t\t//\t\tfor the request with the topic.\n\t\t// done: String\n\t\t//\t\t\"/dojo/io/done\" is sent whenever an IO request has completed,\n\t\t//\t\teither by loading or by erroring. It passes the error and\n\t\t//\t\tthe dojo.Deferred for the request with the topic.\n\t\t// stop: String\n\t\t//\t\t\"/dojo/io/stop\" is sent when all outstanding IO requests have\n\t\t//\t\tfinished. No arguments are passed with this topic.\n\t});\n\t=====*/\n\n\n\tdojo._ioSetArgs = function(/*dojo/main.__IoArgs*/args,\n\t\t\t/*Function*/canceller,\n\t\t\t/*Function*/okHandler,\n\t\t\t/*Function*/errHandler){\n\t\t// summary:\n\t\t//\t\tsets up the Deferred and ioArgs property on the Deferred so it\n\t\t//\t\tcan be used in an io call.\n\t\t// args:\n\t\t//\t\tThe args object passed into the public io call. Recognized properties on\n\t\t//\t\tthe args object are:\n\t\t// canceller:\n\t\t//\t\tThe canceller function used for the Deferred object. The function\n\t\t//\t\twill receive one argument, the Deferred object that is related to the\n\t\t//\t\tcanceller.\n\t\t// okHandler:\n\t\t//\t\tThe first OK callback to be registered with Deferred. It has the opportunity\n\t\t//\t\tto transform the OK response. It will receive one argument -- the Deferred\n\t\t//\t\tobject returned from this function.\n\t\t// errHandler:\n\t\t//\t\tThe first error callback to be registered with Deferred. It has the opportunity\n\t\t//\t\tto do cleanup on an error. It will receive two arguments: error (the\n\t\t//\t\tError object) and dfd, the Deferred object returned from this function.\n\n\t\tvar ioArgs = {args: args, url: args.url};\n\n\t\t//Get values from form if requested.\n\t\tvar formObject = null;\n\t\tif(args.form){\n\t\t\tvar form = dom.byId(args.form);\n\t\t\t//IE requires going through getAttributeNode instead of just getAttribute in some form cases,\n\t\t\t//so use it for all. See #2844\n\t\t\tvar actnNode = form.getAttributeNode(\"action\");\n\t\t\tioArgs.url = ioArgs.url || (actnNode ? actnNode.value : null);\n\t\t\tformObject = domForm.toObject(form);\n\t\t}\n\n\t\t// set up the query params\n\t\tvar miArgs = [{}];\n\n\t\tif(formObject){\n\t\t\t// potentially over-ride url-provided params w/ form values\n\t\t\tmiArgs.push(formObject);\n\t\t}\n\t\tif(args.content){\n\t\t\t// stuff in content over-rides what's set by form\n\t\t\tmiArgs.push(args.content);\n\t\t}\n\t\tif(args.preventCache){\n\t\t\tmiArgs.push({\"dojo.preventCache\": new Date().valueOf()});\n\t\t}\n\t\tioArgs.query = ioq.objectToQuery(lang.mixin.apply(null, miArgs));\n\n\t\t// .. and the real work of getting the deferred in order, etc.\n\t\tioArgs.handleAs = args.handleAs || \"text\";\n\t\tvar d = new Deferred(function(dfd){\n\t\t\tdfd.canceled = true;\n\t\t\tcanceller && canceller(dfd);\n\n\t\t\tvar err = dfd.ioArgs.error;\n\t\t\tif(!err){\n\t\t\t\terr = new Error(\"request cancelled\");\n\t\t\t\terr.dojoType=\"cancel\";\n\t\t\t\tdfd.ioArgs.error = err;\n\t\t\t}\n\t\t\treturn err;\n\t\t});\n\t\td.addCallback(okHandler);\n\n\t\t//Support specifying load, error and handle callback functions from the args.\n\t\t//For those callbacks, the \"this\" object will be the args object.\n\t\t//The callbacks will get the deferred result value as the\n\t\t//first argument and the ioArgs object as the second argument.\n\t\tvar ld = args.load;\n\t\tif(ld && lang.isFunction(ld)){\n\t\t\td.addCallback(function(value){\n\t\t\t\treturn ld.call(args, value, ioArgs);\n\t\t\t});\n\t\t}\n\t\tvar err = args.error;\n\t\tif(err && lang.isFunction(err)){\n\t\t\td.addErrback(function(value){\n\t\t\t\treturn err.call(args, value, ioArgs);\n\t\t\t});\n\t\t}\n\t\tvar handle = args.handle;\n\t\tif(handle && lang.isFunction(handle)){\n\t\t\td.addBoth(function(value){\n\t\t\t\treturn handle.call(args, value, ioArgs);\n\t\t\t});\n\t\t}\n\n\t\t// Attach error handler last (not including topic publishing)\n\t\t// to catch any errors that may have been generated from load\n\t\t// or handle functions.\n\t\td.addErrback(function(error){\n\t\t\treturn errHandler(error, d);\n\t\t});\n\n\t\t//Plug in topic publishing, if dojo.publish is loaded.\n\t\tif(cfg.ioPublish && dojo.publish && ioArgs.args.ioPublish !== false){\n\t\t\td.addCallbacks(\n\t\t\t\tfunction(res){\n\t\t\t\t\tdojo.publish(\"/dojo/io/load\", [d, res]);\n\t\t\t\t\treturn res;\n\t\t\t\t},\n\t\t\t\tfunction(res){\n\t\t\t\t\tdojo.publish(\"/dojo/io/error\", [d, res]);\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t);\n\t\t\td.addBoth(function(res){\n\t\t\t\tdojo.publish(\"/dojo/io/done\", [d, res]);\n\t\t\t\treturn res;\n\t\t\t});\n\t\t}\n\n\t\td.ioArgs = ioArgs;\n\n\t\t// FIXME: need to wire up the xhr object's abort method to something\n\t\t// analogous in the Deferred\n\t\treturn d;\n\t};\n\n\tvar _deferredOk = function(/*Deferred*/dfd){\n\t\t// summary:\n\t\t//\t\tokHandler function for dojo._ioSetArgs call.\n\n\t\tvar ret = handlers[dfd.ioArgs.handleAs](dfd.ioArgs.xhr);\n\t\treturn ret === undefined ? null : ret;\n\t};\n\tvar _deferError = function(/*Error*/error, /*Deferred*/dfd){\n\t\t// summary:\n\t\t//\t\terrHandler function for dojo._ioSetArgs call.\n\n\t\tif(!dfd.ioArgs.args.failOk){\n\t\t\tconsole.error(error);\n\t\t}\n\t\treturn error;\n\t};\n\n\t//Use a separate count for knowing if we are starting/stopping io calls.\n\tvar _checkPubCount = function(dfd){\n\t\tif(_pubCount <= 0){\n\t\t\t_pubCount = 0;\n\t\t\tif(cfg.ioPublish && dojo.publish && (!dfd || dfd && dfd.ioArgs.args.ioPublish !== false)){\n\t\t\t\tdojo.publish(\"/dojo/io/stop\");\n\t\t\t}\n\t\t}\n\t};\n\n\tvar _pubCount = 0;\n\taspect.after(watch, \"_onAction\", function(){\n\t\t_pubCount -= 1;\n\t});\n\taspect.after(watch, \"_onInFlight\", _checkPubCount);\n\n\tdojo._ioCancelAll = watch.cancelAll;\n\t/*=====\n\tdojo._ioCancelAll = function(){\n\t\t// summary:\n\t\t//\t\tCancels all pending IO requests, regardless of IO type\n\t\t//\t\t(xhr, script, iframe).\n\t};\n\t=====*/\n\n\tdojo._ioNotifyStart = function(/*Deferred*/dfd){\n\t\t// summary:\n\t\t//\t\tIf dojo.publish is available, publish topics\n\t\t//\t\tabout the start of a request queue and/or the\n\t\t//\t\tthe beginning of request.\n\t\t//\n\t\t//\t\tUsed by IO transports. An IO transport should\n\t\t//\t\tcall this method before making the network connection.\n\t\tif(cfg.ioPublish && dojo.publish && dfd.ioArgs.args.ioPublish !== false){\n\t\t\tif(!_pubCount){\n\t\t\t\tdojo.publish(\"/dojo/io/start\");\n\t\t\t}\n\t\t\t_pubCount += 1;\n\t\t\tdojo.publish(\"/dojo/io/send\", [dfd]);\n\t\t}\n\t};\n\n\tdojo._ioWatch = function(dfd, validCheck, ioCheck, resHandle){\n\t\t// summary:\n\t\t//\t\tWatches the io request represented by dfd to see if it completes.\n\t\t// dfd: Deferred\n\t\t//\t\tThe Deferred object to watch.\n\t\t// validCheck: Function\n\t\t//\t\tFunction used to check if the IO request is still valid. Gets the dfd\n\t\t//\t\tobject as its only argument.\n\t\t// ioCheck: Function\n\t\t//\t\tFunction used to check if basic IO call worked. Gets the dfd\n\t\t//\t\tobject as its only argument.\n\t\t// resHandle: Function\n\t\t//\t\tFunction used to process response. Gets the dfd\n\t\t//\t\tobject as its only argument.\n\n\t\tvar args = dfd.ioArgs.options = dfd.ioArgs.args;\n\t\tlang.mixin(dfd, {\n\t\t\tresponse: dfd.ioArgs,\n\t\t\tisValid: function(response){\n\t\t\t\treturn validCheck(dfd);\n\t\t\t},\n\t\t\tisReady: function(response){\n\t\t\t\treturn ioCheck(dfd);\n\t\t\t},\n\t\t\thandleResponse: function(response){\n\t\t\t\treturn resHandle(dfd);\n\t\t\t}\n\t\t});\n\t\twatch(dfd);\n\n\t\t_checkPubCount(dfd);\n\t};\n\n\tvar _defaultContentType = \"application/x-www-form-urlencoded\";\n\n\tdojo._ioAddQueryToUrl = function(/*dojo.__IoCallbackArgs*/ioArgs){\n\t\t// summary:\n\t\t//\t\tAdds query params discovered by the io deferred construction to the URL.\n\t\t//\t\tOnly use this for operations which are fundamentally GET-type operations.\n\t\tif(ioArgs.query.length){\n\t\t\tioArgs.url += (ioArgs.url.indexOf(\"?\") == -1 ? \"?\" : \"&\") + ioArgs.query;\n\t\t\tioArgs.query = null;\n\t\t}\n\t};\n\n\t/*=====\n\tdojo.__XhrArgs = declare(dojo.__IoArgs, {\n\t\t// summary:\n\t\t//\t\tIn addition to the properties listed for the dojo._IoArgs type,\n\t\t//\t\tthe following properties are allowed for dojo.xhr* methods.\n\t\t// handleAs: String?\n\t\t//\t\tAcceptable values are: text (default), json, json-comment-optional,\n\t\t//\t\tjson-comment-filtered, javascript, xml. See `dojo/_base/xhr.contentHandlers`\n\t \t// sync: Boolean?\n\t\t//\t\tfalse is default. Indicates whether the request should\n\t\t//\t\tbe a synchronous (blocking) request.\n\t\t// headers: Object?\n\t\t//\t\tAdditional HTTP headers to send in the request.\n\t\t// failOk: Boolean?\n\t\t//\t\tfalse is default. Indicates whether a request should be\n\t\t//\t\tallowed to fail (and therefore no console error message in\n\t\t//\t\tthe event of a failure)\n\t\t// contentType: String|Boolean\n\t\t//\t\t\"application/x-www-form-urlencoded\" is default. Set to false to\n\t\t//\t\tprevent a Content-Type header from being sent, or to a string\n\t\t//\t\tto send a different Content-Type.\n\t });\n\t=====*/\n\n\tdojo.xhr = function(/*String*/ method, /*dojo.__XhrArgs*/ args, /*Boolean?*/ hasBody){\n\t\t// summary:\n\t\t//\t\tDeprecated.   Use dojo/request instead.\n\t\t// description:\n\t\t//\t\tSends an HTTP request with the given method.\n\t\t//\t\tSee also dojo.xhrGet(), xhrPost(), xhrPut() and dojo.xhrDelete() for shortcuts\n\t\t//\t\tfor those HTTP methods. There are also methods for \"raw\" PUT and POST methods\n\t\t//\t\tvia dojo.rawXhrPut() and dojo.rawXhrPost() respectively.\n\t\t// method:\n\t\t//\t\tHTTP method to be used, such as GET, POST, PUT, DELETE. Should be uppercase.\n\t\t// hasBody:\n\t\t//\t\tIf the request has an HTTP body, then pass true for hasBody.\n\n\t\tvar rDfd;\n\t\t//Make the Deferred object for this xhr request.\n\t\tvar dfd = dojo._ioSetArgs(args, function(dfd){\n\t\t\trDfd && rDfd.cancel();\n\t\t}, _deferredOk, _deferError);\n\t\tvar ioArgs = dfd.ioArgs;\n\n\t\t//Allow for specifying the HTTP body completely.\n\t\tif(\"postData\" in args){\n\t\t\tioArgs.query = args.postData;\n\t\t}else if(\"putData\" in args){\n\t\t\tioArgs.query = args.putData;\n\t\t}else if(\"rawBody\" in args){\n\t\t\tioArgs.query = args.rawBody;\n\t\t}else if((arguments.length > 2 && !hasBody) || \"POST|PUT\".indexOf(method.toUpperCase()) === -1){\n\t\t\t//Check for hasBody being passed. If no hasBody,\n\t\t\t//then only append query string if not a POST or PUT request.\n\t\t\tdojo._ioAddQueryToUrl(ioArgs);\n\t\t}\n\n\t\tvar options = {\n\t\t\tmethod: method,\n\t\t\thandleAs: \"text\",\n\t\t\ttimeout: args.timeout,\n\t\t\twithCredentials: args.withCredentials,\n\t\t\tioArgs: ioArgs\n\t\t};\n\n\t\tif(typeof args.headers !== 'undefined'){\n\t\t\toptions.headers = args.headers;\n\t\t}\n\t\tif(typeof args.contentType !== 'undefined'){\n\t\t\tif(!options.headers){\n\t\t\t\toptions.headers = {};\n\t\t\t}\n\t\t\toptions.headers['Content-Type'] = args.contentType;\n\t\t}\n\t\tif(typeof ioArgs.query !== 'undefined'){\n\t\t\toptions.data = ioArgs.query;\n\t\t}\n\t\tif(typeof args.sync !== 'undefined'){\n\t\t\toptions.sync = args.sync;\n\t\t}\n\n\t\tdojo._ioNotifyStart(dfd);\n\t\ttry{\n\t\t\trDfd = _xhr(ioArgs.url, options, true);\n\t\t}catch(e){\n\t\t\t// If XHR creation fails, dojo/request/xhr throws\n\t\t\t// When this happens, cancel the deferred\n\t\t\tdfd.cancel();\n\t\t\treturn dfd;\n\t\t}\n\n\t\t// sync ioArgs\n\t\tdfd.ioArgs.xhr = rDfd.response.xhr;\n\n\t\trDfd.then(function(){\n\t\t\tdfd.resolve(dfd);\n\t\t}).otherwise(function(error){\n\t\t\tioArgs.error = error;\n\t\t\tif(error.response){\n\t\t\t\terror.status = error.response.status;\n\t\t\t\terror.responseText = error.response.text;\n\t\t\t\terror.xhr = error.response.xhr;\n\t\t\t}\n\t\t\tdfd.reject(error);\n\t\t});\n\t\treturn dfd; // dojo/_base/Deferred\n\t};\n\n\tdojo.xhrGet = function(/*dojo.__XhrArgs*/ args){\n\t\t// summary:\n\t\t//\t\tSends an HTTP GET request to the server.\n\t\treturn dojo.xhr(\"GET\", args); // dojo/_base/Deferred\n\t};\n\n\tdojo.rawXhrPost = dojo.xhrPost = function(/*dojo.__XhrArgs*/ args){\n\t\t// summary:\n\t\t//\t\tSends an HTTP POST request to the server. In addition to the properties\n\t\t//\t\tlisted for the dojo.__XhrArgs type, the following property is allowed:\n\t\t// postData:\n\t\t//\t\tString. Send raw data in the body of the POST request.\n\t\treturn dojo.xhr(\"POST\", args, true); // dojo/_base/Deferred\n\t};\n\n\tdojo.rawXhrPut = dojo.xhrPut = function(/*dojo.__XhrArgs*/ args){\n\t\t// summary:\n\t\t//\t\tSends an HTTP PUT request to the server. In addition to the properties\n\t\t//\t\tlisted for the dojo.__XhrArgs type, the following property is allowed:\n\t\t// putData:\n\t\t//\t\tString. Send raw data in the body of the PUT request.\n\t\treturn dojo.xhr(\"PUT\", args, true); // dojo/_base/Deferred\n\t};\n\n\tdojo.xhrDelete = function(/*dojo.__XhrArgs*/ args){\n\t\t// summary:\n\t\t//\t\tSends an HTTP DELETE request to the server.\n\t\treturn dojo.xhr(\"DELETE\", args); // dojo/_base/Deferred\n\t};\n\n\t/*\n\tdojo.wrapForm = function(formNode){\n\t\t// summary:\n\t\t//\t\tA replacement for FormBind, but not implemented yet.\n\n\t\t// FIXME: need to think harder about what extensions to this we might\n\t\t// want. What should we allow folks to do w/ this? What events to\n\t\t// set/send?\n\t\tthrow new Error(\"dojo.wrapForm not yet implemented\");\n\t}\n\t*/\n\n\tdojo._isDocumentOk = function(x){\n\t\treturn util.checkStatus(x.status);\n\t};\n\n\tdojo._getText = function(url){\n\t\tvar result;\n\t\tdojo.xhrGet({url:url, sync:true, load:function(text){\n\t\t\tresult = text;\n\t\t}});\n\t\treturn result;\n\t};\n\n\t// Add aliases for static functions to dojo.xhr since dojo.xhr is what's returned from this module\n\tlang.mixin(dojo.xhr, {\n\t\t_xhrObj: dojo._xhrObj,\n\t\tfieldToObject: domForm.fieldToObject,\n\t\tformToObject: domForm.toObject,\n\t\tobjectToQuery: ioq.objectToQuery,\n\t\tformToQuery: domForm.toQuery,\n\t\tformToJson: domForm.toJson,\n\t\tqueryToObject: ioq.queryToObject,\n\t\tcontentHandlers: handlers,\n\t\t_ioSetArgs: dojo._ioSetArgs,\n\t\t_ioCancelAll: dojo._ioCancelAll,\n\t\t_ioNotifyStart: dojo._ioNotifyStart,\n\t\t_ioWatch: dojo._ioWatch,\n\t\t_ioAddQueryToUrl: dojo._ioAddQueryToUrl,\n\t\t_isDocumentOk: dojo._isDocumentOk,\n\t\t_getText: dojo._getText,\n\t\tget: dojo.xhrGet,\n\t\tpost: dojo.xhrPost,\n\t\tput: dojo.xhrPut,\n\t\tdel: dojo.xhrDelete\t// because \"delete\" is a reserved word\n\t});\n\n\treturn dojo.xhr;\n});\n\n},\n'dojo/loadInit':function(){\ndefine(\"dojo/loadInit\", [\"./_base/loader\"], function(loader){\n\treturn {\n\t\tdynamic:0,\n\t\tnormalize:function(id){return id;},\n\t\tload:loader.loadInit\n\t};\n});\n\n},\n'dojo/_base/unload':function(){\ndefine([\"./kernel\", \"./lang\", \"../on\"], function(dojo, lang, on){\n\n// module:\n//\t\tdojo/unload\n\nvar win = window;\n\nvar unload = {\n\t// summary:\n\t//\t\tThis module contains the document and window unload detection API.\n\n\taddOnWindowUnload: function(/*Object|Function?*/ obj, /*String|Function?*/ functionName){\n\t\t// summary:\n\t\t//\t\tregisters a function to be triggered when window.onunload\n\t\t//\t\tfires.\n\t\t// description:\n\t\t//\t\tThe first time that addOnWindowUnload is called Dojo\n\t\t//\t\twill register a page listener to trigger your unload\n\t\t//\t\thandler with. Note that registering these handlers may\n\t\t//\t\tdestroy \"fastback\" page caching in browsers that support\n\t\t//\t\tit. Be careful trying to modify the DOM or access\n\t\t//\t\tJavaScript properties during this phase of page unloading:\n\t\t//\t\tthey may not always be available. Consider\n\t\t//\t\taddOnUnload() if you need to modify the DOM or do\n\t\t//\t\theavy JavaScript work since it fires at the equivalent of\n\t\t//\t\tthe page's \"onbeforeunload\" event.\n\t\t// example:\n\t\t//\t|\tunload.addOnWindowUnload(functionPointer)\n\t\t//\t|\tunload.addOnWindowUnload(object, \"functionName\");\n\t\t//\t|\tunload.addOnWindowUnload(object, function(){ /* ... */});\n\n\t\tif (!dojo.windowUnloaded){\n\t\t\ton(win, \"unload\", (dojo.windowUnloaded = function(){\n\t\t\t\t// summary:\n\t\t\t\t//\t\tsignal fired by impending window destruction. You may use\n\t\t\t\t//\t\tdojo.addOnWindowUnload() to register a listener for this\n\t\t\t\t//\t\tevent. NOTE: if you wish to dojo.connect() to this method\n\t\t\t\t//\t\tto perform page/application cleanup, be aware that this\n\t\t\t\t//\t\tevent WILL NOT fire if no handler has been registered with\n\t\t\t\t//\t\taddOnWindowUnload(). This behavior started in Dojo 1.3.\n\t\t\t\t//\t\tPrevious versions always triggered windowUnloaded(). See\n\t\t\t\t//\t\taddOnWindowUnload for more info.\n\t\t\t}));\n\t\t}\n\t\ton(win, \"unload\", lang.hitch(obj, functionName));\n\t},\n\n\taddOnUnload: function(/*Object?|Function?*/ obj, /*String|Function?*/ functionName){\n\t\t// summary:\n\t\t//\t\tregisters a function to be triggered when the page unloads.\n\t\t// description:\n\t\t//\t\tThe first time that addOnUnload is called Dojo will\n\t\t//\t\tregister a page listener to trigger your unload handler\n\t\t//\t\twith.\n\t\t//\n\t\t//\t\tIn a browser environment, the functions will be triggered\n\t\t//\t\tduring the window.onbeforeunload event. Be careful of doing\n\t\t//\t\ttoo much work in an unload handler. onbeforeunload can be\n\t\t//\t\ttriggered if a link to download a file is clicked, or if\n\t\t//\t\tthe link is a javascript: link. In these cases, the\n\t\t//\t\tonbeforeunload event fires, but the document is not\n\t\t//\t\tactually destroyed. So be careful about doing destructive\n\t\t//\t\toperations in a dojo.addOnUnload callback.\n\t\t//\n\t\t//\t\tFurther note that calling dojo.addOnUnload will prevent\n\t\t//\t\tbrowsers from using a \"fast back\" cache to make page\n\t\t//\t\tloading via back button instantaneous.\n\t\t// example:\n\t\t//\t|\tdojo.addOnUnload(functionPointer)\n\t\t//\t|\tdojo.addOnUnload(object, \"functionName\")\n\t\t//\t|\tdojo.addOnUnload(object, function(){ /* ... */});\n\n\t\ton(win, \"beforeunload\", lang.hitch(obj, functionName));\n\t}\n};\n\ndojo.addOnWindowUnload = unload.addOnWindowUnload;\ndojo.addOnUnload = unload.addOnUnload;\n\nreturn unload;\n\n});\n\n},\n'dojo/Deferred':function(){\ndefine([\n\t\"./has\",\n\t\"./_base/lang\",\n\t\"./errors/CancelError\",\n\t\"./promise/Promise\",\n\t\"./promise/instrumentation\"\n], function(has, lang, CancelError, Promise, instrumentation){\n\t\"use strict\";\n\n\t// module:\n\t//\t\tdojo/Deferred\n\n\tvar PROGRESS = 0,\n\t\t\tRESOLVED = 1,\n\t\t\tREJECTED = 2;\n\tvar FULFILLED_ERROR_MESSAGE = \"This deferred has already been fulfilled.\";\n\n\tvar freezeObject = Object.freeze || function(){};\n\n\tvar signalWaiting = function(waiting, type, result, rejection, deferred){\n\t\tif( 1 ){\n\t\t\tif(type === REJECTED && Deferred.instrumentRejected && waiting.length === 0){\n\t\t\t\tDeferred.instrumentRejected(result, false, rejection, deferred);\n\t\t\t}\n\t\t}\n\n\t\tfor(var i = 0; i < waiting.length; i++){\n\t\t\tsignalListener(waiting[i], type, result, rejection);\n\t\t}\n\t};\n\n\tvar signalListener = function(listener, type, result, rejection){\n\t\tvar func = listener[type];\n\t\tvar deferred = listener.deferred;\n\t\tif(func){\n\t\t\ttry{\n\t\t\t\tvar newResult = func(result);\n\t\t\t\tif(type === PROGRESS){\n\t\t\t\t\tif(typeof newResult !== \"undefined\"){\n\t\t\t\t\t\tsignalDeferred(deferred, type, newResult);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tif(newResult && typeof newResult.then === \"function\"){\n\t\t\t\t\t\tlistener.cancel = newResult.cancel;\n\t\t\t\t\t\tnewResult.then(\n\t\t\t\t\t\t\t\t// Only make resolvers if they're actually going to be used\n\t\t\t\t\t\t\t\tmakeDeferredSignaler(deferred, RESOLVED),\n\t\t\t\t\t\t\t\tmakeDeferredSignaler(deferred, REJECTED),\n\t\t\t\t\t\t\t\tmakeDeferredSignaler(deferred, PROGRESS));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsignalDeferred(deferred, RESOLVED, newResult);\n\t\t\t\t}\n\t\t\t}catch(error){\n\t\t\t\tsignalDeferred(deferred, REJECTED, error);\n\t\t\t}\n\t\t}else{\n\t\t\tsignalDeferred(deferred, type, result);\n\t\t}\n\n\t\tif( 1 ){\n\t\t\tif(type === REJECTED && Deferred.instrumentRejected){\n\t\t\t\tDeferred.instrumentRejected(result, !!func, rejection, deferred.promise);\n\t\t\t}\n\t\t}\n\t};\n\n\tvar makeDeferredSignaler = function(deferred, type){\n\t\treturn function(value){\n\t\t\tsignalDeferred(deferred, type, value);\n\t\t};\n\t};\n\n\tvar signalDeferred = function(deferred, type, result){\n\t\tif(!deferred.isCanceled()){\n\t\t\tswitch(type){\n\t\t\t\tcase PROGRESS:\n\t\t\t\t\tdeferred.progress(result);\n\t\t\t\t\tbreak;\n\t\t\t\tcase RESOLVED:\n\t\t\t\t\tdeferred.resolve(result);\n\t\t\t\t\tbreak;\n\t\t\t\tcase REJECTED:\n\t\t\t\t\tdeferred.reject(result);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\tvar Deferred = function(canceler){\n\t\t// summary:\n\t\t//\t\tCreates a new deferred. This API is preferred over\n\t\t//\t\t`dojo/_base/Deferred`.\n\t\t// description:\n\t\t//\t\tCreates a new deferred, as an abstraction over (primarily)\n\t\t//\t\tasynchronous operations. The deferred is the private interface\n\t\t//\t\tthat should not be returned to calling code. That's what the\n\t\t//\t\t`promise` is for. See `dojo/promise/Promise`.\n\t\t// canceler: Function?\n\t\t//\t\tWill be invoked if the deferred is canceled. The canceler\n\t\t//\t\treceives the reason the deferred was canceled as its argument.\n\t\t//\t\tThe deferred is rejected with its return value, or a new\n\t\t//\t\t`dojo/errors/CancelError` instance.\n\n\t\t// promise: dojo/promise/Promise\n\t\t//\t\tThe public promise object that clients can add callbacks to. \n\t\tvar promise = this.promise = new Promise();\n\n\t\tvar deferred = this;\n\t\tvar fulfilled, result, rejection;\n\t\tvar canceled = false;\n\t\tvar waiting = [];\n\n\t\tif( 1  && Error.captureStackTrace){\n\t\t\tError.captureStackTrace(deferred, Deferred);\n\t\t\tError.captureStackTrace(promise, Deferred);\n\t\t}\n\n\t\tthis.isResolved = promise.isResolved = function(){\n\t\t\t// summary:\n\t\t\t//\t\tChecks whether the deferred has been resolved.\n\t\t\t// returns: Boolean\n\n\t\t\treturn fulfilled === RESOLVED;\n\t\t};\n\n\t\tthis.isRejected = promise.isRejected = function(){\n\t\t\t// summary:\n\t\t\t//\t\tChecks whether the deferred has been rejected.\n\t\t\t// returns: Boolean\n\n\t\t\treturn fulfilled === REJECTED;\n\t\t};\n\n\t\tthis.isFulfilled = promise.isFulfilled = function(){\n\t\t\t// summary:\n\t\t\t//\t\tChecks whether the deferred has been resolved or rejected.\n\t\t\t// returns: Boolean\n\n\t\t\treturn !!fulfilled;\n\t\t};\n\n\t\tthis.isCanceled = promise.isCanceled = function(){\n\t\t\t// summary:\n\t\t\t//\t\tChecks whether the deferred has been canceled.\n\t\t\t// returns: Boolean\n\n\t\t\treturn canceled;\n\t\t};\n\n\t\tthis.progress = function(update, strict){\n\t\t\t// summary:\n\t\t\t//\t\tEmit a progress update on the deferred.\n\t\t\t// description:\n\t\t\t//\t\tEmit a progress update on the deferred. Progress updates\n\t\t\t//\t\tcan be used to communicate updates about the asynchronous\n\t\t\t//\t\toperation before it has finished.\n\t\t\t// update: any\n\t\t\t//\t\tThe progress update. Passed to progbacks.\n\t\t\t// strict: Boolean?\n\t\t\t//\t\tIf strict, will throw an error if the deferred has already\n\t\t\t//\t\tbeen fulfilled and consequently no progress can be emitted.\n\t\t\t// returns: dojo/promise/Promise\n\t\t\t//\t\tReturns the original promise for the deferred.\n\n\t\t\tif(!fulfilled){\n\t\t\t\tsignalWaiting(waiting, PROGRESS, update, null, deferred);\n\t\t\t\treturn promise;\n\t\t\t}else if(strict === true){\n\t\t\t\tthrow new Error(FULFILLED_ERROR_MESSAGE);\n\t\t\t}else{\n\t\t\t\treturn promise;\n\t\t\t}\n\t\t};\n\n\t\tthis.resolve = function(value, strict){\n\t\t\t// summary:\n\t\t\t//\t\tResolve the deferred.\n\t\t\t// description:\n\t\t\t//\t\tResolve the deferred, putting it in a success state.\n\t\t\t// value: any\n\t\t\t//\t\tThe result of the deferred. Passed to callbacks.\n\t\t\t// strict: Boolean?\n\t\t\t//\t\tIf strict, will throw an error if the deferred has already\n\t\t\t//\t\tbeen fulfilled and consequently cannot be resolved.\n\t\t\t// returns: dojo/promise/Promise\n\t\t\t//\t\tReturns the original promise for the deferred.\n\n\t\t\tif(!fulfilled){\n\t\t\t\t// Set fulfilled, store value. After signaling waiting listeners unset\n\t\t\t\t// waiting.\n\t\t\t\tsignalWaiting(waiting, fulfilled = RESOLVED, result = value, null, deferred);\n\t\t\t\twaiting = null;\n\t\t\t\treturn promise;\n\t\t\t}else if(strict === true){\n\t\t\t\tthrow new Error(FULFILLED_ERROR_MESSAGE);\n\t\t\t}else{\n\t\t\t\treturn promise;\n\t\t\t}\n\t\t};\n\n\t\tvar reject = this.reject = function(error, strict){\n\t\t\t// summary:\n\t\t\t//\t\tReject the deferred.\n\t\t\t// description:\n\t\t\t//\t\tReject the deferred, putting it in an error state.\n\t\t\t// error: any\n\t\t\t//\t\tThe error result of the deferred. Passed to errbacks.\n\t\t\t// strict: Boolean?\n\t\t\t//\t\tIf strict, will throw an error if the deferred has already\n\t\t\t//\t\tbeen fulfilled and consequently cannot be rejected.\n\t\t\t// returns: dojo/promise/Promise\n\t\t\t//\t\tReturns the original promise for the deferred.\n\n\t\t\tif(!fulfilled){\n\t\t\t\tif( 1  && Error.captureStackTrace){\n\t\t\t\t\tError.captureStackTrace(rejection = {}, reject);\n\t\t\t\t}\n\t\t\t\tsignalWaiting(waiting, fulfilled = REJECTED, result = error, rejection, deferred);\n\t\t\t\twaiting = null;\n\t\t\t\treturn promise;\n\t\t\t}else if(strict === true){\n\t\t\t\tthrow new Error(FULFILLED_ERROR_MESSAGE);\n\t\t\t}else{\n\t\t\t\treturn promise;\n\t\t\t}\n\t\t};\n\n\t\tthis.then = promise.then = function(callback, errback, progback){\n\t\t\t// summary:\n\t\t\t//\t\tAdd new callbacks to the deferred.\n\t\t\t// description:\n\t\t\t//\t\tAdd new callbacks to the deferred. Callbacks can be added\n\t\t\t//\t\tbefore or after the deferred is fulfilled.\n\t\t\t// callback: Function?\n\t\t\t//\t\tCallback to be invoked when the promise is resolved.\n\t\t\t//\t\tReceives the resolution value.\n\t\t\t// errback: Function?\n\t\t\t//\t\tCallback to be invoked when the promise is rejected.\n\t\t\t//\t\tReceives the rejection error.\n\t\t\t// progback: Function?\n\t\t\t//\t\tCallback to be invoked when the promise emits a progress\n\t\t\t//\t\tupdate. Receives the progress update.\n\t\t\t// returns: dojo/promise/Promise\n\t\t\t//\t\tReturns a new promise for the result of the callback(s).\n\t\t\t//\t\tThis can be used for chaining many asynchronous operations.\n\n\t\t\tvar listener = [progback, callback, errback];\n\t\t\t// Ensure we cancel the promise we're waiting for, or if callback/errback\n\t\t\t// have returned a promise, cancel that one.\n\t\t\tlistener.cancel = promise.cancel;\n\t\t\tlistener.deferred = new Deferred(function(reason){\n\t\t\t\t// Check whether cancel is really available, returned promises are not\n\t\t\t\t// required to expose `cancel`\n\t\t\t\treturn listener.cancel && listener.cancel(reason);\n\t\t\t});\n\t\t\tif(fulfilled && !waiting){\n\t\t\t\tsignalListener(listener, fulfilled, result, rejection);\n\t\t\t}else{\n\t\t\t\twaiting.push(listener);\n\t\t\t}\n\t\t\treturn listener.deferred.promise;\n\t\t};\n\n\t\tthis.cancel = promise.cancel = function(reason, strict){\n\t\t\t// summary:\n\t\t\t//\t\tInform the deferred it may cancel its asynchronous operation.\n\t\t\t// description:\n\t\t\t//\t\tInform the deferred it may cancel its asynchronous operation.\n\t\t\t//\t\tThe deferred's (optional) canceler is invoked and the\n\t\t\t//\t\tdeferred will be left in a rejected state. Can affect other\n\t\t\t//\t\tpromises that originate with the same deferred.\n\t\t\t// reason: any\n\t\t\t//\t\tA message that may be sent to the deferred's canceler,\n\t\t\t//\t\texplaining why it's being canceled.\n\t\t\t// strict: Boolean?\n\t\t\t//\t\tIf strict, will throw an error if the deferred has already\n\t\t\t//\t\tbeen fulfilled and consequently cannot be canceled.\n\t\t\t// returns: any\n\t\t\t//\t\tReturns the rejection reason if the deferred was canceled\n\t\t\t//\t\tnormally.\n\n\t\t\tif(!fulfilled){\n\t\t\t\t// Cancel can be called even after the deferred is fulfilled\n\t\t\t\tif(canceler){\n\t\t\t\t\tvar returnedReason = canceler(reason);\n\t\t\t\t\treason = typeof returnedReason === \"undefined\" ? reason : returnedReason;\n\t\t\t\t}\n\t\t\t\tcanceled = true;\n\t\t\t\tif(!fulfilled){\n\t\t\t\t\t// Allow canceler to provide its own reason, but fall back to a CancelError\n\t\t\t\t\tif(typeof reason === \"undefined\"){\n\t\t\t\t\t\treason = new CancelError();\n\t\t\t\t\t}\n\t\t\t\t\treject(reason);\n\t\t\t\t\treturn reason;\n\t\t\t\t}else if(fulfilled === REJECTED && result === reason){\n\t\t\t\t\treturn reason;\n\t\t\t\t}\n\t\t\t}else if(strict === true){\n\t\t\t\tthrow new Error(FULFILLED_ERROR_MESSAGE);\n\t\t\t}\n\t\t};\n\n\t\tfreezeObject(promise);\n\t};\n\n\tDeferred.prototype.toString = function(){\n\t\t// returns: String\n\t\t//\t\tReturns `[object Deferred]`.\n\n\t\treturn \"[object Deferred]\";\n\t};\n\n\tif(instrumentation){\n\t\tinstrumentation(Deferred);\n\t}\n\n\treturn Deferred;\n});\n\n},\n'dojo/_base/NodeList':function(){\ndefine(\"dojo/_base/NodeList\", [\"./kernel\", \"../query\", \"./array\", \"./html\", \"../NodeList-dom\"], function(dojo, query, array){\n\t// module:\n\t//\t\tdojo/_base/NodeList\n\n\t/*=====\n\treturn {\n\t\t// summary:\n\t\t//\t\tThis module extends dojo/NodeList with the legacy connect(), coords(),\n\t\t//\t\tblur(), focus(), change(), click(), error(), keydown(), keypress(),\n\t\t//\t\tkeyup(), load(), mousedown(), mouseenter(), mouseleave(), mousemove(),\n\t\t//\t\tmouseout(), mouseover(), mouseup(), and submit() methods.\n\t};\n\t=====*/\n \n\tvar NodeList = query.NodeList,\n\t\tnlp = NodeList.prototype;\n\n\tnlp.connect = NodeList._adaptAsForEach(function(){\n\t\t// don't bind early to dojo.connect since we no longer explicitly depend on it\n\t\treturn dojo.connect.apply(this, arguments);\n\t});\n\t/*=====\n\tnlp.connect = function(methodName, objOrFunc, funcName){\n\t\t// summary:\n\t\t//\t\tAttach event handlers to every item of the NodeList. Uses dojo.connect()\n\t\t//\t\tso event properties are normalized.\n\t\t//\n\t\t//\t\tApplication must manually require() \"dojo/_base/connect\" before using this method.\n\t\t// methodName: String\n\t\t//\t\tthe name of the method to attach to. For DOM events, this should be\n\t\t//\t\tthe lower-case name of the event\n\t\t// objOrFunc: Object|Function|String\n\t\t//\t\tif 2 arguments are passed (methodName, objOrFunc), objOrFunc should\n\t\t//\t\treference a function or be the name of the function in the global\n\t\t//\t\tnamespace to attach. If 3 arguments are provided\n\t\t//\t\t(methodName, objOrFunc, funcName), objOrFunc must be the scope to\n\t\t//\t\tlocate the bound function in\n\t\t// funcName: String?\n\t\t//\t\toptional. A string naming the function in objOrFunc to bind to the\n\t\t//\t\tevent. May also be a function reference.\n\t\t// example:\n\t\t//\t\tadd an onclick handler to every button on the page\n\t\t//\t\t|\tquery(\"div:nth-child(odd)\").connect(\"onclick\", function(e){\n\t\t//\t\t|\t\tconsole.log(\"clicked!\");\n\t\t//\t\t|\t});\n\t\t// example:\n\t\t//\t\tattach foo.bar() to every odd div's onmouseover\n\t\t//\t\t|\tquery(\"div:nth-child(odd)\").connect(\"onmouseover\", foo, \"bar\");\n\n\t\treturn null;\t// NodeList\n\t};\n\t=====*/\n\n\tnlp.coords = NodeList._adaptAsMap(dojo.coords);\n\t/*=====\n\tnlp.coords = function(){\n\t\t// summary:\n\t\t//\t\tDeprecated: Use position() for border-box x/y/w/h\n\t\t//\t\tor marginBox() for margin-box w/h/l/t.\n\t\t//\t\tReturns the box objects of all elements in a node list as\n\t\t//\t\tan Array (*not* a NodeList). Acts like `domGeom.coords`, though assumes\n\t\t//\t\tthe node passed is each node in this list.\n\n\t\treturn []; // Array\n\t};\n\t=====*/\n\n\tNodeList.events = [\n\t\t// summary:\n\t\t//\t\tlist of all DOM events used in NodeList\n\t\t\"blur\", \"focus\", \"change\", \"click\", \"error\", \"keydown\", \"keypress\",\n\t\t\"keyup\", \"load\", \"mousedown\", \"mouseenter\", \"mouseleave\", \"mousemove\",\n\t\t\"mouseout\", \"mouseover\", \"mouseup\", \"submit\"\n\t];\n\n\t// FIXME: pseudo-doc the above automatically generated on-event functions\n\n\t// syntactic sugar for DOM events\n\tarray.forEach(NodeList.events, function(evt){\n\t\t\tvar _oe = \"on\" + evt;\n\t\t\tnlp[_oe] = function(a, b){\n\t\t\t\treturn this.connect(_oe, a, b);\n\t\t\t};\n\t\t\t\t// FIXME: should these events trigger publishes?\n\t\t\t\t/*\n\t\t\t\treturn (a ? this.connect(_oe, a, b) :\n\t\t\t\t\t\t\tthis.forEach(function(n){\n\t\t\t\t\t\t\t\t// FIXME:\n\t\t\t\t\t\t\t\t//\t\tlisteners get buried by\n\t\t\t\t\t\t\t\t//\t\taddEventListener and can't be dug back\n\t\t\t\t\t\t\t\t//\t\tout to be triggered externally.\n\t\t\t\t\t\t\t\t// see:\n\t\t\t\t\t\t\t\t//\t\thttp://developer.mozilla.org/en/docs/DOM:element\n\n\t\t\t\t\t\t\t\tconsole.log(n, evt, _oe);\n\n\t\t\t\t\t\t\t\t// FIXME: need synthetic event support!\n\t\t\t\t\t\t\t\tvar _e = { target: n, faux: true, type: evt };\n\t\t\t\t\t\t\t\t// dojo._event_listener._synthesizeEvent({}, { target: n, faux: true, type: evt });\n\t\t\t\t\t\t\t\ttry{ n[evt](_e); }catch(e){ console.log(e); }\n\t\t\t\t\t\t\t\ttry{ n[_oe](_e); }catch(e){ console.log(e); }\n\t\t\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\t*/\n\t\t}\n\t);\n\n\tdojo.NodeList = NodeList;\n\treturn NodeList;\n});\n\n},\n'dojo/_base/Color':function(){\ndefine([\"./kernel\", \"./lang\", \"./array\", \"./config\"], function(dojo, lang, ArrayUtil, config){\n\n\tvar Color = dojo.Color = function(/*Array|String|Object*/ color){\n\t\t// summary:\n\t\t//\t\tTakes a named string, hex string, array of rgb or rgba values,\n\t\t//\t\tan object with r, g, b, and a properties, or another `Color` object\n\t\t//\t\tand creates a new Color instance to work from.\n\t\t//\n\t\t// example:\n\t\t//\t\tWork with a Color instance:\n\t\t//\t | var c = new Color();\n\t\t//\t | c.setColor([0,0,0]); // black\n\t\t//\t | var hex = c.toHex(); // #000000\n\t\t//\n\t\t// example:\n\t\t//\t\tWork with a node's color:\n\t\t//\t | var color = dojo.style(\"someNode\", \"backgroundColor\");\n\t\t//\t | var n = new Color(color);\n\t\t//\t | // adjust the color some\n\t\t//\t | n.r *= .5;\n\t\t//\t | console.log(n.toString()); // rgb(128, 255, 255);\n\t\tif(color){ this.setColor(color); }\n\t};\n\n\t// FIXME:\n\t// there's got to be a more space-efficient way to encode or discover\n\t// these!! Use hex?\n\tColor.named = {\n\t\t// summary:\n\t\t//\t\tDictionary list of all CSS named colors, by name. Values are 3-item arrays with corresponding RG and B values.\n\t\t\"black\":  [0,0,0],\n\t\t\"silver\": [192,192,192],\n\t\t\"gray\":\t  [128,128,128],\n\t\t\"white\":  [255,255,255],\n\t\t\"maroon\": [128,0,0],\n\t\t\"red\":\t  [255,0,0],\n\t\t\"purple\": [128,0,128],\n\t\t\"fuchsia\":[255,0,255],\n\t\t\"green\":  [0,128,0],\n\t\t\"lime\":\t  [0,255,0],\n\t\t\"olive\":  [128,128,0],\n\t\t\"yellow\": [255,255,0],\n\t\t\"navy\":\t  [0,0,128],\n\t\t\"blue\":\t  [0,0,255],\n\t\t\"teal\":\t  [0,128,128],\n\t\t\"aqua\":\t  [0,255,255],\n\t\t\"transparent\": config.transparentColor || [0,0,0,0]\n\t};\n\n\tlang.extend(Color, {\n\t\tr: 255, g: 255, b: 255, a: 1,\n\t\t_set: function(r, g, b, a){\n\t\t\tvar t = this; t.r = r; t.g = g; t.b = b; t.a = a;\n\t\t},\n\t\tsetColor: function(/*Array|String|Object*/ color){\n\t\t\t// summary:\n\t\t\t//\t\tTakes a named string, hex string, array of rgb or rgba values,\n\t\t\t//\t\tan object with r, g, b, and a properties, or another `Color` object\n\t\t\t//\t\tand sets this color instance to that value.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t|\tvar c = new Color(); // no color\n\t\t\t//\t|\tc.setColor(\"#ededed\"); // greyish\n\t\t\tif(lang.isString(color)){\n\t\t\t\tColor.fromString(color, this);\n\t\t\t}else if(lang.isArray(color)){\n\t\t\t\tColor.fromArray(color, this);\n\t\t\t}else{\n\t\t\t\tthis._set(color.r, color.g, color.b, color.a);\n\t\t\t\tif(!(color instanceof Color)){ this.sanitize(); }\n\t\t\t}\n\t\t\treturn this;\t// Color\n\t\t},\n\t\tsanitize: function(){\n\t\t\t// summary:\n\t\t\t//\t\tEnsures the object has correct attributes\n\t\t\t// description:\n\t\t\t//\t\tthe default implementation does nothing, include dojo.colors to\n\t\t\t//\t\taugment it with real checks\n\t\t\treturn this;\t// Color\n\t\t},\n\t\ttoRgb: function(){\n\t\t\t// summary:\n\t\t\t//\t\tReturns 3 component array of rgb values\n\t\t\t// example:\n\t\t\t//\t|\tvar c = new Color(\"#000000\");\n\t\t\t//\t|\tconsole.log(c.toRgb()); // [0,0,0]\n\t\t\tvar t = this;\n\t\t\treturn [t.r, t.g, t.b]; // Array\n\t\t},\n\t\ttoRgba: function(){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a 4 component array of rgba values from the color\n\t\t\t//\t\trepresented by this object.\n\t\t\tvar t = this;\n\t\t\treturn [t.r, t.g, t.b, t.a];\t// Array\n\t\t},\n\t\ttoHex: function(){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a CSS color string in hexadecimal representation\n\t\t\t// example:\n\t\t\t//\t|\tconsole.log(new Color([0,0,0]).toHex()); // #000000\n\t\t\tvar arr = ArrayUtil.map([\"r\", \"g\", \"b\"], function(x){\n\t\t\t\tvar s = this[x].toString(16);\n\t\t\t\treturn s.length < 2 ? \"0\" + s : s;\n\t\t\t}, this);\n\t\t\treturn \"#\" + arr.join(\"\");\t// String\n\t\t},\n\t\ttoCss: function(/*Boolean?*/ includeAlpha){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a css color string in rgb(a) representation\n\t\t\t// example:\n\t\t\t//\t|\tvar c = new Color(\"#FFF\").toCss();\n\t\t\t//\t|\tconsole.log(c); // rgb('255','255','255')\n\t\t\tvar t = this, rgb = t.r + \", \" + t.g + \", \" + t.b;\n\t\t\treturn (includeAlpha ? \"rgba(\" + rgb + \", \" + t.a : \"rgb(\" + rgb) + \")\";\t// String\n\t\t},\n\t\ttoString: function(){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a visual representation of the color\n\t\t\treturn this.toCss(true); // String\n\t\t}\n\t});\n\n\tColor.blendColors = dojo.blendColors = function(\n\t\t/*Color*/ start,\n\t\t/*Color*/ end,\n\t\t/*Number*/ weight,\n\t\t/*Color?*/ obj\n\t){\n\t\t// summary:\n\t\t//\t\tBlend colors end and start with weight from 0 to 1, 0.5 being a 50/50 blend,\n\t\t//\t\tcan reuse a previously allocated Color object for the result\n\t\tvar t = obj || new Color();\n\t\tArrayUtil.forEach([\"r\", \"g\", \"b\", \"a\"], function(x){\n\t\t\tt[x] = start[x] + (end[x] - start[x]) * weight;\n\t\t\tif(x != \"a\"){ t[x] = Math.round(t[x]); }\n\t\t});\n\t\treturn t.sanitize();\t// Color\n\t};\n\n\tColor.fromRgb = dojo.colorFromRgb = function(/*String*/ color, /*Color?*/ obj){\n\t\t// summary:\n\t\t//\t\tReturns a `Color` instance from a string of the form\n\t\t//\t\t\"rgb(...)\" or \"rgba(...)\". Optionally accepts a `Color`\n\t\t//\t\tobject to update with the parsed value and return instead of\n\t\t//\t\tcreating a new object.\n\t\t// returns:\n\t\t//\t\tA Color object. If obj is passed, it will be the return value.\n\t\tvar m = color.toLowerCase().match(/^rgba?\\(([\\s\\.,0-9]+)\\)/);\n\t\treturn m && Color.fromArray(m[1].split(/\\s*,\\s*/), obj);\t// Color\n\t};\n\n\tColor.fromHex = dojo.colorFromHex = function(/*String*/ color, /*Color?*/ obj){\n\t\t// summary:\n\t\t//\t\tConverts a hex string with a '#' prefix to a color object.\n\t\t//\t\tSupports 12-bit #rgb shorthand. Optionally accepts a\n\t\t//\t\t`Color` object to update with the parsed value.\n\t\t//\n\t\t// returns:\n\t\t//\t\tA Color object. If obj is passed, it will be the return value.\n\t\t//\n\t\t// example:\n\t\t//\t | var thing = dojo.colorFromHex(\"#ededed\"); // grey, longhand\n\t\t//\n\t\t// example:\n\t\t//\t| var thing = dojo.colorFromHex(\"#000\"); // black, shorthand\n\t\tvar t = obj || new Color(),\n\t\t\tbits = (color.length == 4) ? 4 : 8,\n\t\t\tmask = (1 << bits) - 1;\n\t\tcolor = Number(\"0x\" + color.substr(1));\n\t\tif(isNaN(color)){\n\t\t\treturn null; // Color\n\t\t}\n\t\tArrayUtil.forEach([\"b\", \"g\", \"r\"], function(x){\n\t\t\tvar c = color & mask;\n\t\t\tcolor >>= bits;\n\t\t\tt[x] = bits == 4 ? 17 * c : c;\n\t\t});\n\t\tt.a = 1;\n\t\treturn t;\t// Color\n\t};\n\n\tColor.fromArray = dojo.colorFromArray = function(/*Array*/ a, /*Color?*/ obj){\n\t\t// summary:\n\t\t//\t\tBuilds a `Color` from a 3 or 4 element array, mapping each\n\t\t//\t\telement in sequence to the rgb(a) values of the color.\n\t\t// example:\n\t\t//\t\t| var myColor = dojo.colorFromArray([237,237,237,0.5]); // grey, 50% alpha\n\t\t// returns:\n\t\t//\t\tA Color object. If obj is passed, it will be the return value.\n\t\tvar t = obj || new Color();\n\t\tt._set(Number(a[0]), Number(a[1]), Number(a[2]), Number(a[3]));\n\t\tif(isNaN(t.a)){ t.a = 1; }\n\t\treturn t.sanitize();\t// Color\n\t};\n\n\tColor.fromString = dojo.colorFromString = function(/*String*/ str, /*Color?*/ obj){\n\t\t// summary:\n\t\t//\t\tParses `str` for a color value. Accepts hex, rgb, and rgba\n\t\t//\t\tstyle color values.\n\t\t// description:\n\t\t//\t\tAcceptable input values for str may include arrays of any form\n\t\t//\t\taccepted by dojo.colorFromArray, hex strings such as \"#aaaaaa\", or\n\t\t//\t\trgb or rgba strings such as \"rgb(133, 200, 16)\" or \"rgba(10, 10,\n\t\t//\t\t10, 50)\"\n\t\t// returns:\n\t\t//\t\tA Color object. If obj is passed, it will be the return value.\n\t\tvar a = Color.named[str];\n\t\treturn a && Color.fromArray(a, obj) || Color.fromRgb(str, obj) || Color.fromHex(str, obj);\t// Color\n\t};\n\n\treturn Color;\n});\n\n},\n'dojo/promise/instrumentation':function(){\ndefine([\n\t\"./tracer\",\n\t\"../has\",\n\t\"../_base/lang\",\n\t\"../_base/array\"\n], function(tracer, has, lang, arrayUtil){\n\tfunction logError(error, rejection, deferred){\n\t\tvar stack = \"\";\n\t\tif(error && error.stack){\n\t\t\tstack += error.stack;\n\t\t}\n\t\tif(rejection && rejection.stack){\n\t\t\tstack += \"\\n    ----------------------------------------\\n    rejected\" + rejection.stack.split(\"\\n\").slice(1).join(\"\\n\").replace(/^\\s+/, \" \");\n\t\t}\n\t\tif(deferred && deferred.stack){\n\t\t\tstack += \"\\n    ----------------------------------------\\n\" + deferred.stack;\n\t\t}\n\t\tconsole.error(error, stack);\n\t}\n\n\tfunction reportRejections(error, handled, rejection, deferred){\n\t\tif(!handled){\n\t\t\tlogError(error, rejection, deferred);\n\t\t}\n\t}\n\n\tvar errors = [];\n\tvar activeTimeout = false;\n\tvar unhandledWait = 1000;\n\tfunction trackUnhandledRejections(error, handled, rejection, deferred){\n\t\tif(handled){\n\t\t\tarrayUtil.some(errors, function(obj, ix){\n\t\t\t\tif(obj.error === error){\n\t\t\t\t\terrors.splice(ix, 1);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t});\n\t\t}else if(!arrayUtil.some(errors, function(obj){ return obj.error === error; })){\n\t\t\terrors.push({\n\t\t\t\terror: error,\n\t\t\t\trejection: rejection,\n\t\t\t\tdeferred: deferred,\n\t\t\t\ttimestamp: new Date().getTime()\n\t\t\t});\n\t\t}\n\n\t\tif(!activeTimeout){\n\t\t\tactiveTimeout = setTimeout(logRejected, unhandledWait);\n\t\t}\n\t}\n\n\tfunction logRejected(){\n\t\tvar now = new Date().getTime();\n\t\tvar reportBefore = now - unhandledWait;\n\t\terrors = arrayUtil.filter(errors, function(obj){\n\t\t\tif(obj.timestamp < reportBefore){\n\t\t\t\tlogError(obj.error, obj.rejection, obj.deferred);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\n\t\tif(errors.length){\n\t\t\tactiveTimeout = setTimeout(logRejected, errors[0].timestamp + unhandledWait - now);\n\t\t}\n\t}\n\n\treturn function(Deferred){\n\t\t// summary:\n\t\t//\t\tInitialize instrumentation for the Deferred class.\n\t\t// description:\n\t\t//\t\tInitialize instrumentation for the Deferred class.\n\t\t//\t\tDone automatically by `dojo/Deferred` if the\n\t\t//\t\t`deferredInstrumentation` and `useDeferredInstrumentation`\n\t\t//\t\tconfig options are set.\n\t\t//\n\t\t//\t\tSets up `dojo/promise/tracer` to log to the console.\n\t\t//\n\t\t//\t\tSets up instrumentation of rejected deferreds so unhandled\n\t\t//\t\terrors are logged to the console.\n\n\t\tvar usage = has(\"config-useDeferredInstrumentation\");\n\t\tif(usage){\n\t\t\ttracer.on(\"resolved\", lang.hitch(console, \"log\", \"resolved\"));\n\t\t\ttracer.on(\"rejected\", lang.hitch(console, \"log\", \"rejected\"));\n\t\t\ttracer.on(\"progress\", lang.hitch(console, \"log\", \"progress\"));\n\n\t\t\tvar args = [];\n\t\t\tif(typeof usage === \"string\"){\n\t\t\t\targs = usage.split(\",\");\n\t\t\t\tusage = args.shift();\n\t\t\t}\n\t\t\tif(usage === \"report-rejections\"){\n\t\t\t\tDeferred.instrumentRejected = reportRejections;\n\t\t\t}else if(usage === \"report-unhandled-rejections\" || usage === true || usage === 1){\n\t\t\t\tDeferred.instrumentRejected = trackUnhandledRejections;\n\t\t\t\tunhandledWait = parseInt(args[0], 10) || unhandledWait;\n\t\t\t}else{\n\t\t\t\tthrow new Error(\"Unsupported instrumentation usage <\" + usage + \">\");\n\t\t\t}\n\t\t}\n\t};\n});\n\n},\n'dojo/selector/_loader':function(){\ndefine([\"../has\", \"require\"],\n\t\tfunction(has, require){\n\n\"use strict\";\nvar testDiv = document.createElement(\"div\");\nhas.add(\"dom-qsa2.1\", !!testDiv.querySelectorAll);\nhas.add(\"dom-qsa3\", function(){\n\t\t\t// test to see if we have a reasonable native selector engine available\n\t\t\ttry{\n\t\t\t\ttestDiv.innerHTML = \"<p class='TEST'></p>\"; // test kind of from sizzle\n\t\t\t\t// Safari can't handle uppercase or unicode characters when\n\t\t\t\t// in quirks mode, IE8 can't handle pseudos like :empty\n\t\t\t\treturn testDiv.querySelectorAll(\".TEST:empty\").length == 1;\n\t\t\t}catch(e){}\n\t\t});\nvar fullEngine;\nvar acme = \"./acme\", lite = \"./lite\";\nreturn {\n\t// summary:\n\t//\t\tThis module handles loading the appropriate selector engine for the given browser\n\n\tload: function(id, parentRequire, loaded, config){\n\t\tvar req = require;\n\t\t// here we implement the default logic for choosing a selector engine\n\t\tid = id == \"default\" ? has(\"config-selectorEngine\") || \"css3\" : id;\n\t\tid = id == \"css2\" || id == \"lite\" ? lite :\n\t\t\t\tid == \"css2.1\" ? has(\"dom-qsa2.1\") ? lite : acme :\n\t\t\t\tid == \"css3\" ? has(\"dom-qsa3\") ? lite : acme :\n\t\t\t\tid == \"acme\" ? acme : (req = parentRequire) && id;\n\t\tif(id.charAt(id.length-1) == '?'){\n\t\t\tid = id.substring(0,id.length - 1);\n\t\t\tvar optionalLoad = true;\n\t\t}\n\t\t// the query engine is optional, only load it if a native one is not available or existing one has not been loaded\n\t\tif(optionalLoad && (has(\"dom-compliant-qsa\") || fullEngine)){\n\t\t\treturn loaded(fullEngine);\n\t\t}\n\t\t// load the referenced selector engine\n\t\treq([id], function(engine){\n\t\t\tif(id != \"./lite\"){\n\t\t\t\tfullEngine = engine;\n\t\t\t}\n\t\t\tloaded(engine);\n\t\t});\n\t}\n};\n});\n\n},\n'dojo/promise/Promise':function(){\ndefine([\n\t\"../_base/lang\"\n], function(lang){\n\t\"use strict\";\n\n\t// module:\n\t//\t\tdojo/promise/Promise\n\n\tfunction throwAbstract(){\n\t\tthrow new TypeError(\"abstract\");\n\t}\n\n\treturn lang.extend(function Promise(){\n\t\t// summary:\n\t\t//\t\tThe public interface to a deferred.\n\t\t// description:\n\t\t//\t\tThe public interface to a deferred. All promises in Dojo are\n\t\t//\t\tinstances of this class.\n\t}, {\n\t\tthen: function(callback, errback, progback){\n\t\t\t// summary:\n\t\t\t//\t\tAdd new callbacks to the promise.\n\t\t\t// description:\n\t\t\t//\t\tAdd new callbacks to the deferred. Callbacks can be added\n\t\t\t//\t\tbefore or after the deferred is fulfilled.\n\t\t\t// callback: Function?\n\t\t\t//\t\tCallback to be invoked when the promise is resolved.\n\t\t\t//\t\tReceives the resolution value.\n\t\t\t// errback: Function?\n\t\t\t//\t\tCallback to be invoked when the promise is rejected.\n\t\t\t//\t\tReceives the rejection error.\n\t\t\t// progback: Function?\n\t\t\t//\t\tCallback to be invoked when the promise emits a progress\n\t\t\t//\t\tupdate. Receives the progress update.\n\t\t\t// returns: dojo/promise/Promise\n\t\t\t//\t\tReturns a new promise for the result of the callback(s).\n\t\t\t//\t\tThis can be used for chaining many asynchronous operations.\n\n\t\t\tthrowAbstract();\n\t\t},\n\n\t\tcancel: function(reason, strict){\n\t\t\t// summary:\n\t\t\t//\t\tInform the deferred it may cancel its asynchronous operation.\n\t\t\t// description:\n\t\t\t//\t\tInform the deferred it may cancel its asynchronous operation.\n\t\t\t//\t\tThe deferred's (optional) canceler is invoked and the\n\t\t\t//\t\tdeferred will be left in a rejected state. Can affect other\n\t\t\t//\t\tpromises that originate with the same deferred.\n\t\t\t// reason: any\n\t\t\t//\t\tA message that may be sent to the deferred's canceler,\n\t\t\t//\t\texplaining why it's being canceled.\n\t\t\t// strict: Boolean?\n\t\t\t//\t\tIf strict, will throw an error if the deferred has already\n\t\t\t//\t\tbeen fulfilled and consequently cannot be canceled.\n\t\t\t// returns: any\n\t\t\t//\t\tReturns the rejection reason if the deferred was canceled\n\t\t\t//\t\tnormally.\n\n\t\t\tthrowAbstract();\n\t\t},\n\n\t\tisResolved: function(){\n\t\t\t// summary:\n\t\t\t//\t\tChecks whether the promise has been resolved.\n\t\t\t// returns: Boolean\n\n\t\t\tthrowAbstract();\n\t\t},\n\n\t\tisRejected: function(){\n\t\t\t// summary:\n\t\t\t//\t\tChecks whether the promise has been rejected.\n\t\t\t// returns: Boolean\n\n\t\t\tthrowAbstract();\n\t\t},\n\n\t\tisFulfilled: function(){\n\t\t\t// summary:\n\t\t\t//\t\tChecks whether the promise has been resolved or rejected.\n\t\t\t// returns: Boolean\n\n\t\t\tthrowAbstract();\n\t\t},\n\n\t\tisCanceled: function(){\n\t\t\t// summary:\n\t\t\t//\t\tChecks whether the promise has been canceled.\n\t\t\t// returns: Boolean\n\n\t\t\tthrowAbstract();\n\t\t},\n\n\t\talways: function(callbackOrErrback){\n\t\t\t// summary:\n\t\t\t//\t\tAdd a callback to be invoked when the promise is resolved\n\t\t\t//\t\tor rejected.\n\t\t\t// callbackOrErrback: Function?\n\t\t\t//\t\tA function that is used both as a callback and errback.\n\t\t\t// returns: dojo/promise/Promise\n\t\t\t//\t\tReturns a new promise for the result of the callback/errback.\n\n\t\t\treturn this.then(callbackOrErrback, callbackOrErrback);\n\t\t},\n\n\t\totherwise: function(errback){\n\t\t\t// summary:\n\t\t\t//\t\tAdd new errbacks to the promise.\n\t\t\t// errback: Function?\n\t\t\t//\t\tCallback to be invoked when the promise is rejected.\n\t\t\t// returns: dojo/promise/Promise\n\t\t\t//\t\tReturns a new promise for the result of the errback.\n\n\t\t\treturn this.then(null, errback);\n\t\t},\n\n\t\ttrace: function(){\n\t\t\treturn this;\n\t\t},\n\n\t\ttraceRejected: function(){\n\t\t\treturn this;\n\t\t},\n\n\t\ttoString: function(){\n\t\t\t// returns: string\n\t\t\t//\t\tReturns `[object Promise]`.\n\n\t\t\treturn \"[object Promise]\";\n\t\t}\n\t});\n});\n\n},\n'dojo/request/watch':function(){\ndefine([\n\t'./util',\n\t'../errors/RequestTimeoutError',\n\t'../errors/CancelError',\n\t'../_base/array',\n\t'../_base/window',\n\t'../has!host-browser?dom-addeventlistener?:../on:'\n], function(util, RequestTimeoutError, CancelError, array, win, on){\n\t// avoid setting a timer per request. It degrades performance on IE\n\t// something fierece if we don't use unified loops.\n\tvar _inFlightIntvl = null,\n\t\t_inFlight = [];\n\n\tfunction watchInFlight(){\n\t\t// summary:\n\t\t//\t\tinternal method that checks each inflight XMLHttpRequest to see\n\t\t//\t\tif it has completed or if the timeout situation applies.\n\n\t\tvar now = +(new Date);\n\n\t\t// we need manual loop because we often modify _inFlight (and therefore 'i') while iterating\n\t\tfor(var i = 0, dfd; i < _inFlight.length && (dfd = _inFlight[i]); i++){\n\t\t\tvar response = dfd.response,\n\t\t\t\toptions = response.options;\n\t\t\tif((dfd.isCanceled && dfd.isCanceled()) || (dfd.isValid && !dfd.isValid(response))){\n\t\t\t\t_inFlight.splice(i--, 1);\n\t\t\t\twatch._onAction && watch._onAction();\n\t\t\t}else if(dfd.isReady && dfd.isReady(response)){\n\t\t\t\t_inFlight.splice(i--, 1);\n\t\t\t\tdfd.handleResponse(response);\n\t\t\t\twatch._onAction && watch._onAction();\n\t\t\t}else if(dfd.startTime){\n\t\t\t\t// did we timeout?\n\t\t\t\tif(dfd.startTime + (options.timeout || 0) < now){\n\t\t\t\t\t_inFlight.splice(i--, 1);\n\t\t\t\t\t// Cancel the request so the io module can do appropriate cleanup.\n\t\t\t\t\tdfd.cancel(new RequestTimeoutError('Timeout exceeded', response));\n\t\t\t\t\twatch._onAction && watch._onAction();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\twatch._onInFlight && watch._onInFlight(dfd);\n\n\t\tif(!_inFlight.length){\n\t\t\tclearInterval(_inFlightIntvl);\n\t\t\t_inFlightIntvl = null;\n\t\t}\n\t}\n\n\tfunction watch(dfd){\n\t\t// summary:\n\t\t//\t\tWatches the io request represented by dfd to see if it completes.\n\t\t// dfd: Deferred\n\t\t//\t\tThe Deferred object to watch.\n\t\t// response: Object\n\t\t//\t\tThe object used as the value of the request promise.\n\t\t// validCheck: Function\n\t\t//\t\tFunction used to check if the IO request is still valid. Gets the dfd\n\t\t//\t\tobject as its only argument.\n\t\t// ioCheck: Function\n\t\t//\t\tFunction used to check if basic IO call worked. Gets the dfd\n\t\t//\t\tobject as its only argument.\n\t\t// resHandle: Function\n\t\t//\t\tFunction used to process response. Gets the dfd\n\t\t//\t\tobject as its only argument.\n\t\tif(dfd.response.options.timeout){\n\t\t\tdfd.startTime = +(new Date);\n\t\t}\n\n\t\tif(dfd.isFulfilled()){\n\t\t\t// bail out if the deferred is already fulfilled\n\t\t\treturn;\n\t\t}\n\n\t\t_inFlight.push(dfd);\n\t\tif(!_inFlightIntvl){\n\t\t\t_inFlightIntvl = setInterval(watchInFlight, 50);\n\t\t}\n\n\t\t// handle sync requests separately from async:\n\t\t// http://bugs.dojotoolkit.org/ticket/8467\n\t\tif(dfd.response.options.sync){\n\t\t\twatchInFlight();\n\t\t}\n\t}\n\n\twatch.cancelAll = function cancelAll(){\n\t\t// summary:\n\t\t//\t\tCancels all pending IO requests, regardless of IO type\n\t\ttry{\n\t\t\tarray.forEach(_inFlight, function(dfd){\n\t\t\t\ttry{\n\t\t\t\t\tdfd.cancel(new CancelError('All requests canceled.'));\n\t\t\t\t}catch(e){}\n\t\t\t});\n\t\t}catch(e){}\n\t};\n\n\tif(win && on && win.doc.attachEvent){\n\t\t// Automatically call cancel all io calls on unload in IE\n\t\t// http://bugs.dojotoolkit.org/ticket/2357\n\t\ton(win.global, 'unload', function(){\n\t\t\twatch.cancelAll();\n\t\t});\n\t}\n\n\treturn watch;\n});\n\n},\n'dojo/on':function(){\ndefine([\"./has!dom-addeventlistener?:./aspect\", \"./_base/kernel\", \"./has\"], function(aspect, dojo, has){\n\n\t\"use strict\";\n\tif( 1 ){ // check to make sure we are in a browser, this module should work anywhere\n\t\tvar major = window.ScriptEngineMajorVersion;\n\t\thas.add(\"jscript\", major && (major() + ScriptEngineMinorVersion() / 10));\n\t\thas.add(\"event-orientationchange\", has(\"touch\") && !has(\"android\")); // TODO: how do we detect this?\n\t\thas.add(\"event-stopimmediatepropagation\", window.Event && !!window.Event.prototype && !!window.Event.prototype.stopImmediatePropagation);\n\t}\n\tvar on = function(target, type, listener, dontFix){\n\t\t// summary:\n\t\t//\t\tA function that provides core event listening functionality. With this function\n\t\t//\t\tyou can provide a target, event type, and listener to be notified of\n\t\t//\t\tfuture matching events that are fired.\n\t\t// target: Element|Object\n\t\t//\t\tThis is the target object or DOM element that to receive events from\n\t\t// type: String|Function\n\t\t//\t\tThis is the name of the event to listen for or an extension event type.\n\t\t// listener: Function\n\t\t//\t\tThis is the function that should be called when the event fires.\n\t\t// returns: Object\n\t\t//\t\tAn object with a remove() method that can be used to stop listening for this\n\t\t//\t\tevent.\n\t\t// description:\n\t\t//\t\tTo listen for \"click\" events on a button node, we can do:\n\t\t//\t\t|\tdefine([\"dojo/on\"], function(listen){\n\t\t//\t\t|\t\ton(button, \"click\", clickHandler);\n\t\t//\t\t|\t\t...\n\t\t//\t\tEvented JavaScript objects can also have their own events.\n\t\t//\t\t|\tvar obj = new Evented;\n\t\t//\t\t|\ton(obj, \"foo\", fooHandler);\n\t\t//\t\tAnd then we could publish a \"foo\" event:\n\t\t//\t\t|\ton.emit(obj, \"foo\", {key: \"value\"});\n\t\t//\t\tWe can use extension events as well. For example, you could listen for a tap gesture:\n\t\t//\t\t|\tdefine([\"dojo/on\", \"dojo/gesture/tap\", function(listen, tap){\n\t\t//\t\t|\t\ton(button, tap, tapHandler);\n\t\t//\t\t|\t\t...\n\t\t//\t\twhich would trigger fooHandler. Note that for a simple object this is equivalent to calling:\n\t\t//\t\t|\tobj.onfoo({key:\"value\"});\n\t\t//\t\tIf you use on.emit on a DOM node, it will use native event dispatching when possible.\n\n\t\tif(typeof target.on == \"function\" && typeof type != \"function\"){\n\t\t\t// delegate to the target's on() method, so it can handle it's own listening if it wants\n\t\t\treturn target.on(type, listener);\n\t\t}\n\t\t// delegate to main listener code\n\t\treturn on.parse(target, type, listener, addListener, dontFix, this);\n\t};\n\ton.pausable =  function(target, type, listener, dontFix){\n\t\t// summary:\n\t\t//\t\tThis function acts the same as on(), but with pausable functionality. The\n\t\t//\t\treturned signal object has pause() and resume() functions. Calling the\n\t\t//\t\tpause() method will cause the listener to not be called for future events. Calling the\n\t\t//\t\tresume() method will cause the listener to again be called for future events.\n\t\tvar paused;\n\t\tvar signal = on(target, type, function(){\n\t\t\tif(!paused){\n\t\t\t\treturn listener.apply(this, arguments);\n\t\t\t}\n\t\t}, dontFix);\n\t\tsignal.pause = function(){\n\t\t\tpaused = true;\n\t\t};\n\t\tsignal.resume = function(){\n\t\t\tpaused = false;\n\t\t};\n\t\treturn signal;\n\t};\n\ton.once = function(target, type, listener, dontFix){\n\t\t// summary:\n\t\t//\t\tThis function acts the same as on(), but will only call the listener once. The \n\t\t//\t\tlistener will be called for the first\n\t\t//\t\tevent that takes place and then listener will automatically be removed.\n\t\tvar signal = on(target, type, function(){\n\t\t\t// remove this listener\n\t\t\tsignal.remove();\n\t\t\t// proceed to call the listener\n\t\t\treturn listener.apply(this, arguments);\n\t\t});\n\t\treturn signal;\n\t};\n\ton.parse = function(target, type, listener, addListener, dontFix, matchesTarget){\n\t\tif(type.call){\n\t\t\t// event handler function\n\t\t\t// on(node, touch.press, touchListener);\n\t\t\treturn type.call(matchesTarget, target, listener);\n\t\t}\n\n\t\tif(type.indexOf(\",\") > -1){\n\t\t\t// we allow comma delimited event names, so you can register for multiple events at once\n\t\t\tvar events = type.split(/\\s*,\\s*/);\n\t\t\tvar handles = [];\n\t\t\tvar i = 0;\n\t\t\tvar eventName;\n\t\t\twhile(eventName = events[i++]){\n\t\t\t\thandles.push(addListener(target, eventName, listener, dontFix, matchesTarget));\n\t\t\t}\n\t\t\thandles.remove = function(){\n\t\t\t\tfor(var i = 0; i < handles.length; i++){\n\t\t\t\t\thandles[i].remove();\n\t\t\t\t}\n\t\t\t};\n\t\t\treturn handles;\n\t\t}\n\t\treturn addListener(target, type, listener, dontFix, matchesTarget);\n\t};\n\tvar touchEvents = /^touch/;\n\tfunction addListener(target, type, listener, dontFix, matchesTarget){\n\t\t// event delegation:\n\t\tvar selector = type.match(/(.*):(.*)/);\n\t\t// if we have a selector:event, the last one is interpreted as an event, and we use event delegation\n\t\tif(selector){\n\t\t\ttype = selector[2];\n\t\t\tselector = selector[1];\n\t\t\t// create the extension event for selectors and directly call it\n\t\t\treturn on.selector(selector, type).call(matchesTarget, target, listener);\n\t\t}\n\t\t// test to see if it a touch event right now, so we don't have to do it every time it fires\n\t\tif(has(\"touch\")){\n\t\t\tif(touchEvents.test(type)){\n\t\t\t\t// touch event, fix it\n\t\t\t\tlistener = fixTouchListener(listener);\n\t\t\t}\n\t\t\tif(!has(\"event-orientationchange\") && (type == \"orientationchange\")){\n\t\t\t\t//\"orientationchange\" not supported <= Android 2.1, \n\t\t\t\t//but works through \"resize\" on window\n\t\t\t\ttype = \"resize\"; \n\t\t\t\ttarget = window;\n\t\t\t\tlistener = fixTouchListener(listener);\n\t\t\t} \n\t\t}\n\t\tif(addStopImmediate){\n\t\t\t// add stopImmediatePropagation if it doesn't exist\n\t\t\tlistener = addStopImmediate(listener);\n\t\t}\n\t\t// normal path, the target is |this|\n\t\tif(target.addEventListener){\n\t\t\t// the target has addEventListener, which should be used if available (might or might not be a node, non-nodes can implement this method as well)\n\t\t\t// check for capture conversions\n\t\t\tvar capture = type in captures,\n\t\t\t\tadjustedType = capture ? captures[type] : type;\n\t\t\ttarget.addEventListener(adjustedType, listener, capture);\n\t\t\t// create and return the signal\n\t\t\treturn {\n\t\t\t\tremove: function(){\n\t\t\t\t\ttarget.removeEventListener(adjustedType, listener, capture);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\ttype = \"on\" + type;\n\t\tif(fixAttach && target.attachEvent){\n\t\t\treturn fixAttach(target, type, listener);\n\t\t}\n\t\tthrow new Error(\"Target must be an event emitter\");\n\t}\n\n\ton.selector = function(selector, eventType, children){\n\t\t// summary:\n\t\t//\t\tCreates a new extension event with event delegation. This is based on\n\t\t//\t\tthe provided event type (can be extension event) that\n\t\t//\t\tonly calls the listener when the CSS selector matches the target of the event.\n\t\t//\n\t\t//\t\tThe application must require() an appropriate level of dojo/query to handle the selector.\n\t\t// selector:\n\t\t//\t\tThe CSS selector to use for filter events and determine the |this| of the event listener.\n\t\t// eventType:\n\t\t//\t\tThe event to listen for\n\t\t// children:\n\t\t//\t\tIndicates if children elements of the selector should be allowed. This defaults to \n\t\t//\t\ttrue\n\t\t// example:\n\t\t// |\trequire([\"dojo/on\", \"dojo/mouse\", \"dojo/query!css2\"], function(listen, mouse){\n\t\t// |\t\ton(node, on.selector(\".my-class\", mouse.enter), handlerForMyHover);\n\t\treturn function(target, listener){\n\t\t\t// if the selector is function, use it to select the node, otherwise use the matches method\n\t\t\tvar matchesTarget = typeof selector == \"function\" ? {matches: selector} : this,\n\t\t\t\tbubble = eventType.bubble;\n\t\t\tfunction select(eventTarget){\n\t\t\t\t// see if we have a valid matchesTarget or default to dojo.query\n\t\t\t\tmatchesTarget = matchesTarget && matchesTarget.matches ? matchesTarget : dojo.query;\n\t\t\t\t// there is a selector, so make sure it matches\n\t\t\t\twhile(!matchesTarget.matches(eventTarget, selector, target)){\n\t\t\t\t\tif(eventTarget == target || children === false || !(eventTarget = eventTarget.parentNode) || eventTarget.nodeType != 1){ // intentional assignment\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn eventTarget;\n\t\t\t}\n\t\t\tif(bubble){\n\t\t\t\t// the event type doesn't naturally bubble, but has a bubbling form, use that, and give it the selector so it can perform the select itself\n\t\t\t\treturn on(target, bubble(select), listener);\n\t\t\t}\n\t\t\t// standard event delegation\n\t\t\treturn on(target, eventType, function(event){\n\t\t\t\t// call select to see if we match\n\t\t\t\tvar eventTarget = select(event.target);\n\t\t\t\t// if it matches we call the listener\n\t\t\t\treturn eventTarget && listener.call(eventTarget, event);\n\t\t\t});\n\t\t};\n\t};\n\n\tfunction syntheticPreventDefault(){\n\t\tthis.cancelable = false;\n\t}\n\tfunction syntheticStopPropagation(){\n\t\tthis.bubbles = false;\n\t}\n\tvar slice = [].slice,\n\t\tsyntheticDispatch = on.emit = function(target, type, event){\n\t\t// summary:\n\t\t//\t\tFires an event on the target object.\n\t\t// target:\n\t\t//\t\tThe target object to fire the event on. This can be a DOM element or a plain \n\t\t//\t\tJS object. If the target is a DOM element, native event emiting mechanisms\n\t\t//\t\tare used when possible.\n\t\t// type:\n\t\t//\t\tThe event type name. You can emulate standard native events like \"click\" and \n\t\t//\t\t\"mouseover\" or create custom events like \"open\" or \"finish\".\n\t\t// event:\n\t\t//\t\tAn object that provides the properties for the event. See https://developer.mozilla.org/en/DOM/event.initEvent \n\t\t//\t\tfor some of the properties. These properties are copied to the event object.\n\t\t//\t\tOf particular importance are the cancelable and bubbles properties. The\n\t\t//\t\tcancelable property indicates whether or not the event has a default action\n\t\t//\t\tthat can be cancelled. The event is cancelled by calling preventDefault() on\n\t\t//\t\tthe event object. The bubbles property indicates whether or not the\n\t\t//\t\tevent will bubble up the DOM tree. If bubbles is true, the event will be called\n\t\t//\t\ton the target and then each parent successively until the top of the tree\n\t\t//\t\tis reached or stopPropagation() is called. Both bubbles and cancelable \n\t\t//\t\tdefault to false.\n\t\t// returns:\n\t\t//\t\tIf the event is cancelable and the event is not cancelled,\n\t\t//\t\temit will return true. If the event is cancelable and the event is cancelled,\n\t\t//\t\temit will return false.\n\t\t// details:\n\t\t//\t\tNote that this is designed to emit events for listeners registered through\n\t\t//\t\tdojo/on. It should actually work with any event listener except those\n\t\t//\t\tadded through IE's attachEvent (IE8 and below's non-W3C event emiting\n\t\t//\t\tdoesn't support custom event types). It should work with all events registered\n\t\t//\t\tthrough dojo/on. Also note that the emit method does do any default\n\t\t//\t\taction, it only returns a value to indicate if the default action should take\n\t\t//\t\tplace. For example, emiting a keypress event would not cause a character\n\t\t//\t\tto appear in a textbox.\n\t\t// example:\n\t\t//\t\tTo fire our own click event\n\t\t//\t|\ton.emit(dojo.byId(\"button\"), \"click\", {\n\t\t//\t|\t\tcancelable: true,\n\t\t//\t|\t\tbubbles: true,\n\t\t//\t|\t\tscreenX: 33,\n\t\t//\t|\t\tscreenY: 44\n\t\t//\t|\t});\n\t\t//\t\tWe can also fire our own custom events:\n\t\t//\t|\ton.emit(dojo.byId(\"slider\"), \"slide\", {\n\t\t//\t|\t\tcancelable: true,\n\t\t//\t|\t\tbubbles: true,\n\t\t//\t|\t\tdirection: \"left-to-right\"\n\t\t//\t|\t});\n\t\tvar args = slice.call(arguments, 2);\n\t\tvar method = \"on\" + type;\n\t\tif(\"parentNode\" in target){\n\t\t\t// node (or node-like), create event controller methods\n\t\t\tvar newEvent = args[0] = {};\n\t\t\tfor(var i in event){\n\t\t\t\tnewEvent[i] = event[i];\n\t\t\t}\n\t\t\tnewEvent.preventDefault = syntheticPreventDefault;\n\t\t\tnewEvent.stopPropagation = syntheticStopPropagation;\n\t\t\tnewEvent.target = target;\n\t\t\tnewEvent.type = type;\n\t\t\tevent = newEvent;\n\t\t}\n\t\tdo{\n\t\t\t// call any node which has a handler (note that ideally we would try/catch to simulate normal event propagation but that causes too much pain for debugging)\n\t\t\ttarget[method] && target[method].apply(target, args);\n\t\t\t// and then continue up the parent node chain if it is still bubbling (if started as bubbles and stopPropagation hasn't been called)\n\t\t}while(event && event.bubbles && (target = target.parentNode));\n\t\treturn event && event.cancelable && event; // if it is still true (was cancelable and was cancelled), return the event to indicate default action should happen\n\t};\n\tvar captures = {};\n\tif(!has(\"event-stopimmediatepropagation\")){\n\t\tvar stopImmediatePropagation =function(){\n\t\t\tthis.immediatelyStopped = true;\n\t\t\tthis.modified = true; // mark it as modified so the event will be cached in IE\n\t\t};\n\t\tvar addStopImmediate = function(listener){\n\t\t\treturn function(event){\n\t\t\t\tif(!event.immediatelyStopped){// check to make sure it hasn't been stopped immediately\n\t\t\t\t\tevent.stopImmediatePropagation = stopImmediatePropagation;\n\t\t\t\t\treturn listener.apply(this, arguments);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t} \n\tif(has(\"dom-addeventlistener\")){\n\t\t// normalize focusin and focusout\n\t\tcaptures = {\n\t\t\tfocusin: \"focus\",\n\t\t\tfocusout: \"blur\"\n\t\t};\n\t\tif(has(\"opera\")){\n\t\t\tcaptures.keydown = \"keypress\"; // this one needs to be transformed because Opera doesn't support repeating keys on keydown (and keypress works because it incorrectly fires on all keydown events)\n\t\t}\n\n\t\t// emiter that works with native event handling\n\t\ton.emit = function(target, type, event){\n\t\t\tif(target.dispatchEvent && document.createEvent){\n\t\t\t\t// use the native event emiting mechanism if it is available on the target object\n\t\t\t\t// create a generic event\t\t\t\t\n\t\t\t\t// we could create branch into the different types of event constructors, but \n\t\t\t\t// that would be a lot of extra code, with little benefit that I can see, seems \n\t\t\t\t// best to use the generic constructor and copy properties over, making it \n\t\t\t\t// easy to have events look like the ones created with specific initializers\n\t\t\t\tvar nativeEvent = target.ownerDocument.createEvent(\"HTMLEvents\");\n\t\t\t\tnativeEvent.initEvent(type, !!event.bubbles, !!event.cancelable);\n\t\t\t\t// and copy all our properties over\n\t\t\t\tfor(var i in event){\n\t\t\t\t\tvar value = event[i];\n\t\t\t\t\tif(!(i in nativeEvent)){\n\t\t\t\t\t\tnativeEvent[i] = event[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target.dispatchEvent(nativeEvent) && nativeEvent;\n\t\t\t}\n\t\t\treturn syntheticDispatch.apply(on, arguments); // emit for a non-node\n\t\t};\n\t}else{\n\t\t// no addEventListener, basically old IE event normalization\n\t\ton._fixEvent = function(evt, sender){\n\t\t\t// summary:\n\t\t\t//\t\tnormalizes properties on the event object including event\n\t\t\t//\t\tbubbling methods, keystroke normalization, and x/y positions\n\t\t\t// evt:\n\t\t\t//\t\tnative event object\n\t\t\t// sender:\n\t\t\t//\t\tnode to treat as \"currentTarget\"\n\t\t\tif(!evt){\n\t\t\t\tvar w = sender && (sender.ownerDocument || sender.document || sender).parentWindow || window;\n\t\t\t\tevt = w.event;\n\t\t\t}\n\t\t\tif(!evt){return evt;}\n\t\t\tif(lastEvent && evt.type == lastEvent.type){\n\t\t\t\t// should be same event, reuse event object (so it can be augmented)\n\t\t\t\tevt = lastEvent;\n\t\t\t}\n\t\t\tif(!evt.target){ // check to see if it has been fixed yet\n\t\t\t\tevt.target = evt.srcElement;\n\t\t\t\tevt.currentTarget = (sender || evt.srcElement);\n\t\t\t\tif(evt.type == \"mouseover\"){\n\t\t\t\t\tevt.relatedTarget = evt.fromElement;\n\t\t\t\t}\n\t\t\t\tif(evt.type == \"mouseout\"){\n\t\t\t\t\tevt.relatedTarget = evt.toElement;\n\t\t\t\t}\n\t\t\t\tif(!evt.stopPropagation){\n\t\t\t\t\tevt.stopPropagation = stopPropagation;\n\t\t\t\t\tevt.preventDefault = preventDefault;\n\t\t\t\t}\n\t\t\t\tswitch(evt.type){\n\t\t\t\t\tcase \"keypress\":\n\t\t\t\t\t\tvar c = (\"charCode\" in evt ? evt.charCode : evt.keyCode);\n\t\t\t\t\t\tif (c==10){\n\t\t\t\t\t\t\t// CTRL-ENTER is CTRL-ASCII(10) on IE, but CTRL-ENTER on Mozilla\n\t\t\t\t\t\t\tc=0;\n\t\t\t\t\t\t\tevt.keyCode = 13;\n\t\t\t\t\t\t}else if(c==13||c==27){\n\t\t\t\t\t\t\tc=0; // Mozilla considers ENTER and ESC non-printable\n\t\t\t\t\t\t}else if(c==3){\n\t\t\t\t\t\t\tc=99; // Mozilla maps CTRL-BREAK to CTRL-c\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Mozilla sets keyCode to 0 when there is a charCode\n\t\t\t\t\t\t// but that stops the event on IE.\n\t\t\t\t\t\tevt.charCode = c;\n\t\t\t\t\t\t_setKeyChar(evt);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn evt;\n\t\t};\n\t\tvar lastEvent, IESignal = function(handle){\n\t\t\tthis.handle = handle;\n\t\t};\n\t\tIESignal.prototype.remove = function(){\n\t\t\tdelete _dojoIEListeners_[this.handle];\n\t\t};\n\t\tvar fixListener = function(listener){\n\t\t\t// this is a minimal function for closing on the previous listener with as few as variables as possible\n\t\t\treturn function(evt){\n\t\t\t\tevt = on._fixEvent(evt, this);\n\t\t\t\tvar result = listener.call(this, evt);\n\t\t\t\tif(evt.modified){\n\t\t\t\t\t// cache the last event and reuse it if we can\n\t\t\t\t\tif(!lastEvent){\n\t\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\tlastEvent = null;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tlastEvent = evt;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t};\n\t\t};\n\t\tvar fixAttach = function(target, type, listener){\n\t\t\tlistener = fixListener(listener);\n\t\t\tif(((target.ownerDocument ? target.ownerDocument.parentWindow : target.parentWindow || target.window || window) != top || \n\t\t\t\t\t\thas(\"jscript\") < 5.8) && \n\t\t\t\t\t!has(\"config-_allow_leaks\")){\n\t\t\t\t// IE will leak memory on certain handlers in frames (IE8 and earlier) and in unattached DOM nodes for JScript 5.7 and below.\n\t\t\t\t// Here we use global redirection to solve the memory leaks\n\t\t\t\tif(typeof _dojoIEListeners_ == \"undefined\"){\n\t\t\t\t\t_dojoIEListeners_ = [];\n\t\t\t\t}\n\t\t\t\tvar emiter = target[type];\n\t\t\t\tif(!emiter || !emiter.listeners){\n\t\t\t\t\tvar oldListener = emiter;\n\t\t\t\t\temiter = Function('event', 'var callee = arguments.callee; for(var i = 0; i<callee.listeners.length; i++){var listener = _dojoIEListeners_[callee.listeners[i]]; if(listener){listener.call(this,event);}}');\n\t\t\t\t\temiter.listeners = [];\n\t\t\t\t\ttarget[type] = emiter;\n\t\t\t\t\temiter.global = this;\n\t\t\t\t\tif(oldListener){\n\t\t\t\t\t\temiter.listeners.push(_dojoIEListeners_.push(oldListener) - 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tvar handle;\n\t\t\t\temiter.listeners.push(handle = (emiter.global._dojoIEListeners_.push(listener) - 1));\n\t\t\t\treturn new IESignal(handle);\n\t\t\t}\n\t\t\treturn aspect.after(target, type, listener, true);\n\t\t};\n\n\t\tvar _setKeyChar = function(evt){\n\t\t\tevt.keyChar = evt.charCode ? String.fromCharCode(evt.charCode) : '';\n\t\t\tevt.charOrCode = evt.keyChar || evt.keyCode;\n\t\t};\n\t\t// Called in Event scope\n\t\tvar stopPropagation = function(){\n\t\t\tthis.cancelBubble = true;\n\t\t};\n\t\tvar preventDefault = on._preventDefault = function(){\n\t\t\t// Setting keyCode to 0 is the only way to prevent certain keypresses (namely\n\t\t\t// ctrl-combinations that correspond to menu accelerator keys).\n\t\t\t// Otoh, it prevents upstream listeners from getting this information\n\t\t\t// Try to split the difference here by clobbering keyCode only for ctrl\n\t\t\t// combinations. If you still need to access the key upstream, bubbledKeyCode is\n\t\t\t// provided as a workaround.\n\t\t\tthis.bubbledKeyCode = this.keyCode;\n\t\t\tif(this.ctrlKey){\n\t\t\t\ttry{\n\t\t\t\t\t// squelch errors when keyCode is read-only\n\t\t\t\t\t// (e.g. if keyCode is ctrl or shift)\n\t\t\t\t\tthis.keyCode = 0;\n\t\t\t\t}catch(e){\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.defaultPrevented = true;\n\t\t\tthis.returnValue = false;\n\t\t};\n\t}\n\tif(has(\"touch\")){ \n\t\tvar Event = function(){};\n\t\tvar windowOrientation = window.orientation; \n\t\tvar fixTouchListener = function(listener){ \n\t\t\treturn function(originalEvent){ \n\t\t\t\t//Event normalization(for ontouchxxx and resize): \n\t\t\t\t//1.incorrect e.pageX|pageY in iOS \n\t\t\t\t//2.there are no \"e.rotation\", \"e.scale\" and \"onorientationchange\" in Andriod\n\t\t\t\t//3.More TBD e.g. force | screenX | screenX | clientX | clientY | radiusX | radiusY\n\n\t\t\t\t// see if it has already been corrected\n\t\t\t\tvar event = originalEvent.corrected;\n\t\t\t\tif(!event){\n\t\t\t\t\tvar type = originalEvent.type;\n\t\t\t\t\ttry{\n\t\t\t\t\t\tdelete originalEvent.type; // on some JS engines (android), deleting properties make them mutable\n\t\t\t\t\t}catch(e){} \n\t\t\t\t\tif(originalEvent.type){\n\t\t\t\t\t\t// deleting properties doesn't work (older iOS), have to use delegation\n\t\t\t\t\t\tEvent.prototype = originalEvent;\n\t\t\t\t\t\tvar event = new Event;\n\t\t\t\t\t\t// have to delegate methods to make them work\n\t\t\t\t\t\tevent.preventDefault = function(){\n\t\t\t\t\t\t\toriginalEvent.preventDefault();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tevent.stopPropagation = function(){\n\t\t\t\t\t\t\toriginalEvent.stopPropagation();\n\t\t\t\t\t\t};\n\t\t\t\t\t}else{\n\t\t\t\t\t\t// deletion worked, use property as is\n\t\t\t\t\t\tevent = originalEvent;\n\t\t\t\t\t\tevent.type = type;\n\t\t\t\t\t}\n\t\t\t\t\toriginalEvent.corrected = event;\n\t\t\t\t\tif(type == 'resize'){\n\t\t\t\t\t\tif(windowOrientation == window.orientation){ \n\t\t\t\t\t\t\treturn null;//double tap causes an unexpected 'resize' in Andriod \n\t\t\t\t\t\t} \n\t\t\t\t\t\twindowOrientation = window.orientation;\n\t\t\t\t\t\tevent.type = \"orientationchange\"; \n\t\t\t\t\t\treturn listener.call(this, event);\n\t\t\t\t\t}\n\t\t\t\t\t// We use the original event and augment, rather than doing an expensive mixin operation\n\t\t\t\t\tif(!(\"rotation\" in event)){ // test to see if it has rotation\n\t\t\t\t\t\tevent.rotation = 0; \n\t\t\t\t\t\tevent.scale = 1;\n\t\t\t\t\t}\n\t\t\t\t\t//use event.changedTouches[0].pageX|pageY|screenX|screenY|clientX|clientY|target\n\t\t\t\t\tvar firstChangeTouch = event.changedTouches[0];\n\t\t\t\t\tfor(var i in firstChangeTouch){ // use for-in, we don't need to have dependency on dojo/_base/lang here\n\t\t\t\t\t\tdelete event[i]; // delete it first to make it mutable\n\t\t\t\t\t\tevent[i] = firstChangeTouch[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn listener.call(this, event); \n\t\t\t}; \n\t\t}; \n\t}\n\treturn on;\n});\n\n},\n'dojo/_base/sniff':function(){\ndefine([\"./kernel\", \"./lang\", \"../sniff\"], function(dojo, lang, has){\n\t// module:\n\t//\t\tdojo/_base/sniff\n\n\t/*=====\n\treturn {\n\t\t// summary:\n\t\t//\t\tDeprecated.   New code should use dojo/sniff.\n\t\t//\t\tThis module populates the dojo browser version sniffing properties like dojo.isIE.\n\t};\n\t=====*/\n\n\tif(! 1 ){\n\t\treturn has;\n\t}\n\n\t// no idea what this is for, or if it's used\n\tdojo._name = \"browser\";\n\n\tlang.mixin(dojo, {\n\t\t// isBrowser: Boolean\n\t\t//\t\tTrue if the client is a web-browser\n\t\tisBrowser: true,\n\n\t\t// isFF: Number|undefined\n\t\t//\t\tVersion as a Number if client is FireFox. undefined otherwise. Corresponds to\n\t\t//\t\tmajor detected FireFox version (1.5, 2, 3, etc.)\n\t\tisFF: has(\"ff\"),\n\n\t\t// isIE: Number|undefined\n\t\t//\t\tVersion as a Number if client is MSIE(PC). undefined otherwise. Corresponds to\n\t\t//\t\tmajor detected IE version (6, 7, 8, etc.)\n\t\tisIE: has(\"ie\"),\n\n\t\t// isKhtml: Number|undefined\n\t\t//\t\tVersion as a Number if client is a KHTML browser. undefined otherwise. Corresponds to major\n\t\t//\t\tdetected version.\n\t\tisKhtml: has(\"khtml\"),\n\n\t\t// isWebKit: Number|undefined\n\t\t//\t\tVersion as a Number if client is a WebKit-derived browser (Konqueror,\n\t\t//\t\tSafari, Chrome, etc.). undefined otherwise.\n\t\tisWebKit: has(\"webkit\"),\n\n\t\t// isMozilla: Number|undefined\n\t\t//\t\tVersion as a Number if client is a Mozilla-based browser (Firefox,\n\t\t//\t\tSeaMonkey). undefined otherwise. Corresponds to major detected version.\n\t\tisMozilla: has(\"mozilla\"),\n\t\t// isMoz: Number|undefined\n\t\t//\t\tVersion as a Number if client is a Mozilla-based browser (Firefox,\n\t\t//\t\tSeaMonkey). undefined otherwise. Corresponds to major detected version.\n\t\tisMoz: has(\"mozilla\"),\n\n\t\t// isOpera: Number|undefined\n\t\t//\t\tVersion as a Number if client is Opera. undefined otherwise. Corresponds to\n\t\t//\t\tmajor detected version.\n\t\tisOpera: has(\"opera\"),\n\n\t\t// isSafari: Number|undefined\n\t\t//\t\tVersion as a Number if client is Safari or iPhone. undefined otherwise.\n\t\tisSafari: has(\"safari\"),\n\n\t\t// isChrome: Number|undefined\n\t\t//\t\tVersion as a Number if client is Chrome browser. undefined otherwise.\n\t\tisChrome: has(\"chrome\"),\n\n\t\t// isMac: Boolean\n\t\t//\t\tTrue if the client runs on Mac\n\t\tisMac: has(\"mac\"),\n\n\t\t// isIos: Boolean\n\t\t//\t\tTrue if client is iPhone, iPod, or iPad\n\t\tisIos: has(\"ios\"),\n\n\t\t// isAndroid: Number|undefined\n\t\t//\t\tVersion as a Number if client is android browser. undefined otherwise.\n\t\tisAndroid: has(\"android\"),\n\n\t\t// isWii: Boolean\n\t\t//\t\tTrue if client is Wii\n\t\tisWii: has(\"wii\"),\n\n\t\t// isQuirks: Boolean\n\t\t//\t\tPage is in quirks mode.\n\t\tisQuirks: has(\"quirks\"),\n\n\t\t// isAir: Boolean\n\t\t//\t\tTrue if client is Adobe Air\n\t\tisAir: has(\"air\")\n\t});\n\n\n\tdojo.locale = dojo.locale || (has(\"ie\") ? navigator.userLanguage : navigator.language).toLowerCase();\n\n\treturn has;\n});\n\n},\n'dojo/errors/create':function(){\ndefine([\"../_base/lang\"], function(lang){\n\treturn function(name, ctor, base, props){\n\t\tbase = base || Error;\n\n\t\tvar ErrorCtor = function(message){\n\t\t\tif(base === Error){\n\t\t\t\tif(Error.captureStackTrace){\n\t\t\t\t\tError.captureStackTrace(this, ErrorCtor);\n\t\t\t\t}\n\n\t\t\t\t// Error.call() operates on the returned error\n\t\t\t\t// object rather than operating on |this|\n\t\t\t\tvar err = Error.call(this, message),\n\t\t\t\t\tprop;\n\n\t\t\t\t// Copy own properties from err to |this|\n\t\t\t\tfor(prop in err){\n\t\t\t\t\tif(err.hasOwnProperty(prop)){\n\t\t\t\t\t\tthis[prop] = err[prop];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// messsage is non-enumerable in ES5\n\t\t\t\tthis.message = message;\n\t\t\t\t// stack is non-enumerable in at least Firefox\n\t\t\t\tthis.stack = err.stack;\n\t\t\t}else{\n\t\t\t\tbase.apply(this, arguments);\n\t\t\t}\n\t\t\tif(ctor){\n\t\t\t\tctor.apply(this, arguments);\n\t\t\t}\n\t\t};\n\n\t\tErrorCtor.prototype = lang.delegate(base.prototype, props);\n\t\tErrorCtor.prototype.name = name;\n\t\tErrorCtor.prototype.constructor = ErrorCtor;\n\n\t\treturn ErrorCtor;\n\t};\n});\n\n},\n'dojo/_base/array':function(){\ndefine([\"./kernel\", \"../has\", \"./lang\"], function(dojo, has, lang){\n\t// module:\n\t//\t\tdojo/_base/array\n\n\t// our old simple function builder stuff\n\tvar cache = {}, u;\n\n\tfunction buildFn(fn){\n\t\treturn cache[fn] = new Function(\"item\", \"index\", \"array\", fn); // Function\n\t}\n\t// magic snippet: if(typeof fn == \"string\") fn = cache[fn] || buildFn(fn);\n\n\t// every & some\n\n\tfunction everyOrSome(some){\n\t\tvar every = !some;\n\t\treturn function(a, fn, o){\n\t\t\tvar i = 0, l = a && a.length || 0, result;\n\t\t\tif(l && typeof a == \"string\") a = a.split(\"\");\n\t\t\tif(typeof fn == \"string\") fn = cache[fn] || buildFn(fn);\n\t\t\tif(o){\n\t\t\t\tfor(; i < l; ++i){\n\t\t\t\t\tresult = !fn.call(o, a[i], i, a);\n\t\t\t\t\tif(some ^ result){\n\t\t\t\t\t\treturn !result;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tfor(; i < l; ++i){\n\t\t\t\t\tresult = !fn(a[i], i, a);\n\t\t\t\t\tif(some ^ result){\n\t\t\t\t\t\treturn !result;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn every; // Boolean\n\t\t};\n\t}\n\n\t// indexOf, lastIndexOf\n\n\tfunction index(up){\n\t\tvar delta = 1, lOver = 0, uOver = 0;\n\t\tif(!up){\n\t\t\tdelta = lOver = uOver = -1;\n\t\t}\n\t\treturn function(a, x, from, last){\n\t\t\tif(last && delta > 0){\n\t\t\t\t// TODO: why do we use a non-standard signature? why do we need \"last\"?\n\t\t\t\treturn array.lastIndexOf(a, x, from);\n\t\t\t}\n\t\t\tvar l = a && a.length || 0, end = up ? l + uOver : lOver, i;\n\t\t\tif(from === u){\n\t\t\t\ti = up ? lOver : l + uOver;\n\t\t\t}else{\n\t\t\t\tif(from < 0){\n\t\t\t\t\ti = l + from;\n\t\t\t\t\tif(i < 0){\n\t\t\t\t\t\ti = lOver;\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\ti = from >= l ? l + uOver : from;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(l && typeof a == \"string\") a = a.split(\"\");\n\t\t\tfor(; i != end; i += delta){\n\t\t\t\tif(a[i] == x){\n\t\t\t\t\treturn i; // Number\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn -1; // Number\n\t\t};\n\t}\n\n\tvar array = {\n\t\t// summary:\n\t\t//\t\tThe Javascript v1.6 array extensions.\n\n\t\tevery: everyOrSome(false),\n\t\t/*=====\n\t\t every: function(arr, callback, thisObject){\n\t\t\t // summary:\n\t\t\t //\t\tDetermines whether or not every item in arr satisfies the\n\t\t\t //\t\tcondition implemented by callback.\n\t\t\t // arr: Array|String\n\t\t\t //\t\tthe array to iterate on. If a string, operates on individual characters.\n\t\t\t // callback: Function|String\n\t\t\t //\t\ta function is invoked with three arguments: item, index,\n\t\t\t //\t\tand array and returns true if the condition is met.\n\t\t\t // thisObject: Object?\n\t\t\t //\t\tmay be used to scope the call to callback\n\t\t\t // returns: Boolean\n\t\t\t // description:\n\t\t\t //\t\tThis function corresponds to the JavaScript 1.6 Array.every() method, with one difference: when\n\t\t\t //\t\trun over sparse arrays, this implementation passes the \"holes\" in the sparse array to\n\t\t\t //\t\tthe callback function with a value of undefined. JavaScript 1.6's every skips the holes in the sparse array.\n\t\t\t //\t\tFor more details, see:\n\t\t\t //\t\thttps://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/every\n\t\t\t // example:\n\t\t\t //\t|\t// returns false\n\t\t\t //\t|\tarray.every([1, 2, 3, 4], function(item){ return item>1; });\n\t\t\t // example:\n\t\t\t //\t|\t// returns true\n\t\t\t //\t|\tarray.every([1, 2, 3, 4], function(item){ return item>0; });\n\t\t },\n\t\t =====*/\n\n\t\tsome: everyOrSome(true),\n\t\t/*=====\n\t\tsome: function(arr, callback, thisObject){\n\t\t\t// summary:\n\t\t\t//\t\tDetermines whether or not any item in arr satisfies the\n\t\t\t//\t\tcondition implemented by callback.\n\t\t\t// arr: Array|String\n\t\t\t//\t\tthe array to iterate over. If a string, operates on individual characters.\n\t\t\t// callback: Function|String\n\t\t\t//\t\ta function is invoked with three arguments: item, index,\n\t\t\t//\t\tand array and returns true if the condition is met.\n\t\t\t// thisObject: Object?\n\t\t\t//\t\tmay be used to scope the call to callback\n\t\t\t// returns: Boolean\n\t\t\t// description:\n\t\t\t//\t\tThis function corresponds to the JavaScript 1.6 Array.some() method, with one difference: when\n\t\t\t//\t\trun over sparse arrays, this implementation passes the \"holes\" in the sparse array to\n\t\t\t//\t\tthe callback function with a value of undefined. JavaScript 1.6's some skips the holes in the sparse array.\n\t\t\t//\t\tFor more details, see:\n\t\t\t//\t\thttps://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/some\n\t\t\t// example:\n\t\t\t//\t| // is true\n\t\t\t//\t| array.some([1, 2, 3, 4], function(item){ return item>1; });\n\t\t\t// example:\n\t\t\t//\t| // is false\n\t\t\t//\t| array.some([1, 2, 3, 4], function(item){ return item<1; });\n\t\t},\n\t\t=====*/\n\n\t\tindexOf: index(true),\n\t\t/*=====\n\t\tindexOf: function(arr, value, fromIndex, findLast){\n\t\t\t// summary:\n\t\t\t//\t\tlocates the first index of the provided value in the\n\t\t\t//\t\tpassed array. If the value is not found, -1 is returned.\n\t\t\t// description:\n\t\t\t//\t\tThis method corresponds to the JavaScript 1.6 Array.indexOf method, with one difference: when\n\t\t\t//\t\trun over sparse arrays, the Dojo function invokes the callback for every index whereas JavaScript\n\t\t\t//\t\t1.6's indexOf skips the holes in the sparse array.\n\t\t\t//\t\tFor details on this method, see:\n\t\t\t//\t\thttps://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/indexOf\n\t\t\t// arr: Array\n\t\t\t// value: Object\n\t\t\t// fromIndex: Integer?\n\t\t\t// findLast: Boolean?\n\t\t\t// returns: Number\n\t\t},\n\t\t=====*/\n\n\t\tlastIndexOf: index(false),\n\t\t/*=====\n\t\tlastIndexOf: function(arr, value, fromIndex){\n\t\t\t// summary:\n\t\t\t//\t\tlocates the last index of the provided value in the passed\n\t\t\t//\t\tarray. If the value is not found, -1 is returned.\n\t\t\t// description:\n\t\t\t//\t\tThis method corresponds to the JavaScript 1.6 Array.lastIndexOf method, with one difference: when\n\t\t\t//\t\trun over sparse arrays, the Dojo function invokes the callback for every index whereas JavaScript\n\t\t\t//\t\t1.6's lastIndexOf skips the holes in the sparse array.\n\t\t\t//\t\tFor details on this method, see:\n\t\t\t//\t\thttps://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/lastIndexOf\n\t\t\t// arr: Array,\n\t\t\t// value: Object,\n\t\t\t// fromIndex: Integer?\n\t\t\t// returns: Number\n\t\t},\n\t\t=====*/\n\n\t\tforEach: function(arr, callback, thisObject){\n\t\t\t// summary:\n\t\t\t//\t\tfor every item in arr, callback is invoked. Return values are ignored.\n\t\t\t//\t\tIf you want to break out of the loop, consider using array.every() or array.some().\n\t\t\t//\t\tforEach does not allow breaking out of the loop over the items in arr.\n\t\t\t// arr:\n\t\t\t//\t\tthe array to iterate over. If a string, operates on individual characters.\n\t\t\t// callback:\n\t\t\t//\t\ta function is invoked with three arguments: item, index, and array\n\t\t\t// thisObject:\n\t\t\t//\t\tmay be used to scope the call to callback\n\t\t\t// description:\n\t\t\t//\t\tThis function corresponds to the JavaScript 1.6 Array.forEach() method, with one difference: when\n\t\t\t//\t\trun over sparse arrays, this implementation passes the \"holes\" in the sparse array to\n\t\t\t//\t\tthe callback function with a value of undefined. JavaScript 1.6's forEach skips the holes in the sparse array.\n\t\t\t//\t\tFor more details, see:\n\t\t\t//\t\thttps://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/forEach\n\t\t\t// example:\n\t\t\t//\t| // log out all members of the array:\n\t\t\t//\t| array.forEach(\n\t\t\t//\t|\t\t[ \"thinger\", \"blah\", \"howdy\", 10 ],\n\t\t\t//\t|\t\tfunction(item){\n\t\t\t//\t|\t\t\tconsole.log(item);\n\t\t\t//\t|\t\t}\n\t\t\t//\t| );\n\t\t\t// example:\n\t\t\t//\t| // log out the members and their indexes\n\t\t\t//\t| array.forEach(\n\t\t\t//\t|\t\t[ \"thinger\", \"blah\", \"howdy\", 10 ],\n\t\t\t//\t|\t\tfunction(item, idx, arr){\n\t\t\t//\t|\t\t\tconsole.log(item, \"at index:\", idx);\n\t\t\t//\t|\t\t}\n\t\t\t//\t| );\n\t\t\t// example:\n\t\t\t//\t| // use a scoped object member as the callback\n\t\t\t//\t|\n\t\t\t//\t| var obj = {\n\t\t\t//\t|\t\tprefix: \"logged via obj.callback:\",\n\t\t\t//\t|\t\tcallback: function(item){\n\t\t\t//\t|\t\t\tconsole.log(this.prefix, item);\n\t\t\t//\t|\t\t}\n\t\t\t//\t| };\n\t\t\t//\t|\n\t\t\t//\t| // specifying the scope function executes the callback in that scope\n\t\t\t//\t| array.forEach(\n\t\t\t//\t|\t\t[ \"thinger\", \"blah\", \"howdy\", 10 ],\n\t\t\t//\t|\t\tobj.callback,\n\t\t\t//\t|\t\tobj\n\t\t\t//\t| );\n\t\t\t//\t|\n\t\t\t//\t| // alternately, we can accomplish the same thing with lang.hitch()\n\t\t\t//\t| array.forEach(\n\t\t\t//\t|\t\t[ \"thinger\", \"blah\", \"howdy\", 10 ],\n\t\t\t//\t|\t\tlang.hitch(obj, \"callback\")\n\t\t\t//\t| );\n\t\t\t// arr: Array|String\n\t\t\t// callback: Function|String\n\t\t\t// thisObject: Object?\n\n\t\t\tvar i = 0, l = arr && arr.length || 0;\n\t\t\tif(l && typeof arr == \"string\") arr = arr.split(\"\");\n\t\t\tif(typeof callback == \"string\") callback = cache[callback] || buildFn(callback);\n\t\t\tif(thisObject){\n\t\t\t\tfor(; i < l; ++i){\n\t\t\t\t\tcallback.call(thisObject, arr[i], i, arr);\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tfor(; i < l; ++i){\n\t\t\t\t\tcallback(arr[i], i, arr);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tmap: function(arr, callback, thisObject, Ctr){\n\t\t\t// summary:\n\t\t\t//\t\tapplies callback to each element of arr and returns\n\t\t\t//\t\tan Array with the results\n\t\t\t// arr: Array|String\n\t\t\t//\t\tthe array to iterate on. If a string, operates on\n\t\t\t//\t\tindividual characters.\n\t\t\t// callback: Function|String\n\t\t\t//\t\ta function is invoked with three arguments, (item, index,\n\t\t\t//\t\tarray),\t and returns a value\n\t\t\t// thisObject: Object?\n\t\t\t//\t\tmay be used to scope the call to callback\n\t\t\t// returns: Array\n\t\t\t// description:\n\t\t\t//\t\tThis function corresponds to the JavaScript 1.6 Array.map() method, with one difference: when\n\t\t\t//\t\trun over sparse arrays, this implementation passes the \"holes\" in the sparse array to\n\t\t\t//\t\tthe callback function with a value of undefined. JavaScript 1.6's map skips the holes in the sparse array.\n\t\t\t//\t\tFor more details, see:\n\t\t\t//\t\thttps://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map\n\t\t\t// example:\n\t\t\t//\t| // returns [2, 3, 4, 5]\n\t\t\t//\t| array.map([1, 2, 3, 4], function(item){ return item+1 });\n\n\t\t\t// TODO: why do we have a non-standard signature here? do we need \"Ctr\"?\n\t\t\tvar i = 0, l = arr && arr.length || 0, out = new (Ctr || Array)(l);\n\t\t\tif(l && typeof arr == \"string\") arr = arr.split(\"\");\n\t\t\tif(typeof callback == \"string\") callback = cache[callback] || buildFn(callback);\n\t\t\tif(thisObject){\n\t\t\t\tfor(; i < l; ++i){\n\t\t\t\t\tout[i] = callback.call(thisObject, arr[i], i, arr);\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tfor(; i < l; ++i){\n\t\t\t\t\tout[i] = callback(arr[i], i, arr);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out; // Array\n\t\t},\n\n\t\tfilter: function(arr, callback, thisObject){\n\t\t\t// summary:\n\t\t\t//\t\tReturns a new Array with those items from arr that match the\n\t\t\t//\t\tcondition implemented by callback.\n\t\t\t// arr: Array\n\t\t\t//\t\tthe array to iterate over.\n\t\t\t// callback: Function|String\n\t\t\t//\t\ta function that is invoked with three arguments (item,\n\t\t\t//\t\tindex, array). The return of this function is expected to\n\t\t\t//\t\tbe a boolean which determines whether the passed-in item\n\t\t\t//\t\twill be included in the returned array.\n\t\t\t// thisObject: Object?\n\t\t\t//\t\tmay be used to scope the call to callback\n\t\t\t// returns: Array\n\t\t\t// description:\n\t\t\t//\t\tThis function corresponds to the JavaScript 1.6 Array.filter() method, with one difference: when\n\t\t\t//\t\trun over sparse arrays, this implementation passes the \"holes\" in the sparse array to\n\t\t\t//\t\tthe callback function with a value of undefined. JavaScript 1.6's filter skips the holes in the sparse array.\n\t\t\t//\t\tFor more details, see:\n\t\t\t//\t\thttps://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter\n\t\t\t// example:\n\t\t\t//\t| // returns [2, 3, 4]\n\t\t\t//\t| array.filter([1, 2, 3, 4], function(item){ return item>1; });\n\n\t\t\t// TODO: do we need \"Ctr\" here like in map()?\n\t\t\tvar i = 0, l = arr && arr.length || 0, out = [], value;\n\t\t\tif(l && typeof arr == \"string\") arr = arr.split(\"\");\n\t\t\tif(typeof callback == \"string\") callback = cache[callback] || buildFn(callback);\n\t\t\tif(thisObject){\n\t\t\t\tfor(; i < l; ++i){\n\t\t\t\t\tvalue = arr[i];\n\t\t\t\t\tif(callback.call(thisObject, value, i, arr)){\n\t\t\t\t\t\tout.push(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tfor(; i < l; ++i){\n\t\t\t\t\tvalue = arr[i];\n\t\t\t\t\tif(callback(value, i, arr)){\n\t\t\t\t\t\tout.push(value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out; // Array\n\t\t},\n\n\t\tclearCache: function(){\n\t\t\tcache = {};\n\t\t}\n\t};\n\n\n\t 1  && lang.mixin(dojo, array);\n\n\treturn array;\n});\n\n},\n'dojo/_base/json':function(){\ndefine([\"./kernel\", \"../json\"], function(dojo, json){\n\n// module:\n//\t\tdojo/_base/json\n\n/*=====\nreturn {\n\t// summary:\n\t//\t\tThis module defines the dojo JSON API.\n};\n=====*/\n\ndojo.fromJson = function(/*String*/ js){\n\t// summary:\n\t//\t\tParses a JavaScript expression and returns a JavaScript value.\n\t// description:\n\t//\t\tThrows for invalid JavaScript expressions. It does not use a strict JSON parser. It\n\t//\t\talways delegates to eval(). The content passed to this method must therefore come\n\t//\t\tfrom a trusted source.\n\t//\t\tIt is recommend that you use dojo/json's parse function for an\n\t//\t\timplementation uses the (faster) native JSON parse when available.\n\t// js:\n\t//\t\ta string literal of a JavaScript expression, for instance:\n\t//\t\t`'{ \"foo\": [ \"bar\", 1, { \"baz\": \"thud\" } ] }'`\n\n\treturn eval(\"(\" + js + \")\"); // Object\n};\n\n/*=====\ndojo._escapeString = function(){\n\t// summary:\n\t//\t\tAdds escape sequences for non-visual characters, double quote and\n\t//\t\tbackslash and surrounds with double quotes to form a valid string\n\t//\t\tliteral.\n};\n=====*/\ndojo._escapeString = json.stringify; // just delegate to json.stringify\n\ndojo.toJsonIndentStr = \"\\t\";\ndojo.toJson = function(/*Object*/ it, /*Boolean?*/ prettyPrint){\n\t// summary:\n\t//\t\tReturns a [JSON](http://json.org) serialization of an object.\n\t// description:\n\t//\t\tReturns a [JSON](http://json.org) serialization of an object.\n\t//\t\tNote that this doesn't check for infinite recursion, so don't do that!\n\t//\t\tIt is recommend that you use dojo/json's stringify function for an lighter\n\t//\t\tand faster implementation that matches the native JSON API and uses the\n\t//\t\tnative JSON serializer when available.\n\t// it:\n\t//\t\tan object to be serialized. Objects may define their own\n\t//\t\tserialization via a special \"__json__\" or \"json\" function\n\t//\t\tproperty. If a specialized serializer has been defined, it will\n\t//\t\tbe used as a fallback.\n\t//\t\tNote that in 1.6, toJson would serialize undefined, but this no longer supported\n\t//\t\tsince it is not supported by native JSON serializer.\n\t// prettyPrint:\n\t//\t\tif true, we indent objects and arrays to make the output prettier.\n\t//\t\tThe variable `dojo.toJsonIndentStr` is used as the indent string --\n\t//\t\tto use something other than the default (tab), change that variable\n\t//\t\tbefore calling dojo.toJson().\n\t//\t\tNote that if native JSON support is available, it will be used for serialization,\n\t//\t\tand native implementations vary on the exact spacing used in pretty printing.\n\t// returns:\n\t//\t\tA JSON string serialization of the passed-in object.\n\t// example:\n\t//\t\tsimple serialization of a trivial object\n\t//\t\t|\tvar jsonStr = dojo.toJson({ howdy: \"stranger!\", isStrange: true });\n\t//\t\t|\tdoh.is('{\"howdy\":\"stranger!\",\"isStrange\":true}', jsonStr);\n\t// example:\n\t//\t\ta custom serializer for an objects of a particular class:\n\t//\t\t|\tdojo.declare(\"Furby\", null, {\n\t//\t\t|\t\tfurbies: \"are strange\",\n\t//\t\t|\t\tfurbyCount: 10,\n\t//\t\t|\t\t__json__: function(){\n\t//\t\t|\t\t},\n\t//\t\t|\t});\n\n\t// use dojo/json\n\treturn json.stringify(it, function(key, value){\n\t\tif(value){\n\t\t\tvar tf = value.__json__||value.json;\n\t\t\tif(typeof tf == \"function\"){\n\t\t\t\treturn tf.call(value);\n\t\t\t}\n\t\t}\n\t\treturn value;\n\t}, prettyPrint && dojo.toJsonIndentStr);\t// String\n};\n\nreturn dojo;\n});\n\n},\n'dojo/_base/window':function(){\ndefine(\"dojo/_base/window\", [\"./kernel\", \"./lang\", \"../sniff\"], function(dojo, lang, has){\n// module:\n//\t\tdojo/_base/window\n\nvar ret = {\n\t// summary:\n\t//\t\tAPI to save/set/restore the global/document scope.\n\n\tglobal: dojo.global,\n\t/*=====\n\t global: {\n\t\t // summary:\n\t\t //\t\tAlias for the current window. 'global' can be modified\n\t\t //\t\tfor temporary context shifting. See also withGlobal().\n\t\t // description:\n\t\t //\t\tUse this rather than referring to 'window' to ensure your code runs\n\t\t //\t\tcorrectly in managed contexts.\n\t },\n\t =====*/\n\n\tdoc: this[\"document\"] || null,\n\t/*=====\n\tdoc: {\n\t\t// summary:\n\t\t//\t\tAlias for the current document. 'doc' can be modified\n\t\t//\t\tfor temporary context shifting. See also withDoc().\n\t\t// description:\n\t\t//\t\tUse this rather than referring to 'window.document' to ensure your code runs\n\t\t//\t\tcorrectly in managed contexts.\n\t\t// example:\n\t\t//\t|\tn.appendChild(dojo.doc.createElement('div'));\n\t},\n\t=====*/\n\n\tbody: function(/*Document?*/ doc){\n\t\t// summary:\n\t\t//\t\tReturn the body element of the specified document or of dojo/_base/window::doc.\n\t\t// example:\n\t\t//\t|\twin.body().appendChild(dojo.doc.createElement('div'));\n\n\t\t// Note: document.body is not defined for a strict xhtml document\n\t\t// Would like to memoize this, but dojo.doc can change vi dojo.withDoc().\n\t\tdoc = doc || dojo.doc;\n\t\treturn doc.body || doc.getElementsByTagName(\"body\")[0]; // Node\n\t},\n\n\tsetContext: function(/*Object*/ globalObject, /*DocumentElement*/ globalDocument){\n\t\t// summary:\n\t\t//\t\tchanges the behavior of many core Dojo functions that deal with\n\t\t//\t\tnamespace and DOM lookup, changing them to work in a new global\n\t\t//\t\tcontext (e.g., an iframe). The varibles dojo.global and dojo.doc\n\t\t//\t\tare modified as a result of calling this function and the result of\n\t\t//\t\t`dojo.body()` likewise differs.\n\t\tdojo.global = ret.global = globalObject;\n\t\tdojo.doc = ret.doc = globalDocument;\n\t},\n\n\twithGlobal: function(\t/*Object*/ globalObject,\n\t\t\t\t\t\t\t/*Function*/ callback,\n\t\t\t\t\t\t\t/*Object?*/ thisObject,\n\t\t\t\t\t\t\t/*Array?*/ cbArguments){\n\t\t// summary:\n\t\t//\t\tInvoke callback with globalObject as dojo.global and\n\t\t//\t\tglobalObject.document as dojo.doc.\n\t\t// description:\n\t\t//\t\tInvoke callback with globalObject as dojo.global and\n\t\t//\t\tglobalObject.document as dojo.doc. If provided, globalObject\n\t\t//\t\twill be executed in the context of object thisObject\n\t\t//\t\tWhen callback() returns or throws an error, the dojo.global\n\t\t//\t\tand dojo.doc will be restored to its previous state.\n\n\t\tvar oldGlob = dojo.global;\n\t\ttry{\n\t\t\tdojo.global = ret.global = globalObject;\n\t\t\treturn ret.withDoc.call(null, globalObject.document, callback, thisObject, cbArguments);\n\t\t}finally{\n\t\t\tdojo.global = ret.global = oldGlob;\n\t\t}\n\t},\n\n\twithDoc: function(\t/*DocumentElement*/ documentObject,\n\t\t\t\t\t\t/*Function*/ callback,\n\t\t\t\t\t\t/*Object?*/ thisObject,\n\t\t\t\t\t\t/*Array?*/ cbArguments){\n\t\t// summary:\n\t\t//\t\tInvoke callback with documentObject as dojo/_base/window::doc.\n\t\t// description:\n\t\t//\t\tInvoke callback with documentObject as dojo/_base/window::doc. If provided,\n\t\t//\t\tcallback will be executed in the context of object thisObject\n\t\t//\t\tWhen callback() returns or throws an error, the dojo/_base/window::doc will\n\t\t//\t\tbe restored to its previous state.\n\n\t\tvar oldDoc = ret.doc,\n\t\t\toldQ = has(\"quirks\"),\n\t\t\toldIE = has(\"ie\"), isIE, mode, pwin;\n\n\t\ttry{\n\t\t\tdojo.doc = ret.doc = documentObject;\n\t\t\t// update dojo.isQuirks and the value of the has feature \"quirks\".\n\t\t\t// remove setting dojo.isQuirks and dojo.isIE for 2.0\n\t\t\tdojo.isQuirks = has.add(\"quirks\", dojo.doc.compatMode == \"BackCompat\", true, true); // no need to check for QuirksMode which was Opera 7 only\n\n\t\t\tif(has(\"ie\")){\n\t\t\t\tif((pwin = documentObject.parentWindow) && pwin.navigator){\n\t\t\t\t\t// re-run IE detection logic and update dojo.isIE / has(\"ie\")\n\t\t\t\t\t// (the only time parentWindow/navigator wouldn't exist is if we were not\n\t\t\t\t\t// passed an actual legitimate document object)\n\t\t\t\t\tisIE = parseFloat(pwin.navigator.appVersion.split(\"MSIE \")[1]) || undefined;\n\t\t\t\t\tmode = documentObject.documentMode;\n\t\t\t\t\tif(mode && mode != 5 && Math.floor(isIE) != mode){\n\t\t\t\t\t\tisIE = mode;\n\t\t\t\t\t}\n\t\t\t\t\tdojo.isIE = has.add(\"ie\", isIE, true, true);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(thisObject && typeof callback == \"string\"){\n\t\t\t\tcallback = thisObject[callback];\n\t\t\t}\n\n\t\t\treturn callback.apply(thisObject, cbArguments || []);\n\t\t}finally{\n\t\t\tdojo.doc = ret.doc = oldDoc;\n\t\t\tdojo.isQuirks = has.add(\"quirks\", oldQ, true, true);\n\t\t\tdojo.isIE = has.add(\"ie\", oldIE, true, true);\n\t\t}\n\t}\n};\n\n 1  && lang.mixin(dojo, ret);\n\nreturn ret;\n\n});\n\n},\n'dojo/dom-class':function(){\ndefine([\"./_base/lang\", \"./_base/array\", \"./dom\"], function(lang, array, dom){\n\t// module:\n\t//\t\tdojo/dom-class\n\n\tvar className = \"className\";\n\n\t/* Part I of classList-based implementation is preserved here for posterity\n\tvar classList = \"classList\";\n\thas.add(\"dom-classList\", function(){\n\t\treturn classList in document.createElement(\"p\");\n\t});\n\t*/\n\n\t// =============================\n\t// (CSS) Class Functions\n\t// =============================\n\n\tvar cls, // exports object\n\t\tspaces = /\\s+/, a1 = [\"\"];\n\n\tfunction str2array(s){\n\t\tif(typeof s == \"string\" || s instanceof String){\n\t\t\tif(s && !spaces.test(s)){\n\t\t\t\ta1[0] = s;\n\t\t\t\treturn a1;\n\t\t\t}\n\t\t\tvar a = s.split(spaces);\n\t\t\tif(a.length && !a[0]){\n\t\t\t\ta.shift();\n\t\t\t}\n\t\t\tif(a.length && !a[a.length - 1]){\n\t\t\t\ta.pop();\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\t\t// assumed to be an array\n\t\tif(!s){\n\t\t\treturn [];\n\t\t}\n\t\treturn array.filter(s, function(x){ return x; });\n\t}\n\n\t/* Part II of classList-based implementation is preserved here for posterity\n\tif(has(\"dom-classList\")){\n\t\t// new classList version\n\t\tcls = {\n\t\t\tcontains: function containsClass(node, classStr){\n\t\t\t\tvar clslst = classStr && dom.byId(node)[classList];\n\t\t\t\treturn clslst && clslst.contains(classStr); // Boolean\n\t\t\t},\n\n\t\t\tadd: function addClass(node, classStr){\n\t\t\t\tnode = dom.byId(node);\n\t\t\t\tclassStr = str2array(classStr);\n\t\t\t\tfor(var i = 0, len = classStr.length; i < len; ++i){\n\t\t\t\t\tnode[classList].add(classStr[i]);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tremove: function removeClass(node, classStr){\n\t\t\t\tnode = dom.byId(node);\n\t\t\t\tif(classStr === undefined){\n\t\t\t\t\tnode[className] = \"\";\n\t\t\t\t}else{\n\t\t\t\t\tclassStr = str2array(classStr);\n\t\t\t\t\tfor(var i = 0, len = classStr.length; i < len; ++i){\n\t\t\t\t\t\tnode[classList].remove(classStr[i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\n\t\t\treplace: function replaceClass(node, addClassStr, removeClassStr){\n\t\t\t\tnode = dom.byId(node);\n\t\t\t\tif(removeClassStr === undefined){\n\t\t\t\t\tnode[className] = \"\";\n\t\t\t\t}else{\n\t\t\t\t\tremoveClassStr = str2array(removeClassStr);\n\t\t\t\t\tfor(var i = 0, len = removeClassStr.length; i < len; ++i){\n\t\t\t\t\t\tnode[classList].remove(removeClassStr[i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\taddClassStr = str2array(addClassStr);\n\t\t\t\tfor(i = 0, len = addClassStr.length; i < len; ++i){\n\t\t\t\t\tnode[classList].add(addClassStr[i]);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\ttoggle: function toggleClass(node, classStr, condition){\n\t\t\t\tnode = dom.byId(node);\n\t\t\t\tif(condition === undefined){\n\t\t\t\t\tclassStr = str2array(classStr);\n\t\t\t\t\tfor(var i = 0, len = classStr.length; i < len; ++i){\n\t\t\t\t\t\tnode[classList].toggle(classStr[i]);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tcls[condition ? \"add\" : \"remove\"](node, classStr);\n\t\t\t\t}\n\t\t\t\treturn condition;   // Boolean\n\t\t\t}\n\t\t}\n\t}\n\t*/\n\n\t// regular DOM version\n\tvar fakeNode = {};  // for effective replacement\n\tcls = {\n\t\t// summary:\n\t\t//\t\tThis module defines the core dojo DOM class API.\n\n\t\tcontains: function containsClass(/*DomNode|String*/ node, /*String*/ classStr){\n\t\t\t// summary:\n\t\t\t//\t\tReturns whether or not the specified classes are a portion of the\n\t\t\t//\t\tclass list currently applied to the node.\n\t\t\t// node: String|DOMNode\n\t\t\t//\t\tString ID or DomNode reference to check the class for.\n\t\t\t// classStr: String\n\t\t\t//\t\tA string class name to look for.\n\t\t\t// example:\n\t\t\t//\t\tDo something if a node with id=\"someNode\" has class=\"aSillyClassName\" present\n\t\t\t//\t|\tif(dojo.hasClass(\"someNode\",\"aSillyClassName\")){ ... }\n\n\t\t\treturn ((\" \" + dom.byId(node)[className] + \" \").indexOf(\" \" + classStr + \" \") >= 0); // Boolean\n\t\t},\n\n\t\tadd: function addClass(/*DomNode|String*/ node, /*String|Array*/ classStr){\n\t\t\t// summary:\n\t\t\t//\t\tAdds the specified classes to the end of the class list on the\n\t\t\t//\t\tpassed node. Will not re-apply duplicate classes.\n\t\t\t//\n\t\t\t// node: String|DOMNode\n\t\t\t//\t\tString ID or DomNode reference to add a class string too\n\t\t\t//\n\t\t\t// classStr: String|Array\n\t\t\t//\t\tA String class name to add, or several space-separated class names,\n\t\t\t//\t\tor an array of class names.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tAdd a class to some node:\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.add(\"someNode\", \"anewClass\");\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tAdd two classes at once:\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.add(\"someNode\", \"firstClass secondClass\");\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tAdd two classes at once (using array):\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.add(\"someNode\", [\"firstClass\", \"secondClass\"]);\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tAvailable in `dojo/NodeList` for multiple additions\n\t\t\t//\t|\trequire([\"dojo/query\"], function(query){\n\t\t\t//\t|\t\tquery(\"ul > li\").addClass(\"firstLevel\");\n\t\t\t//\t|\t});\n\n\t\t\tnode = dom.byId(node);\n\t\t\tclassStr = str2array(classStr);\n\t\t\tvar cls = node[className], oldLen;\n\t\t\tcls = cls ? \" \" + cls + \" \" : \" \";\n\t\t\toldLen = cls.length;\n\t\t\tfor(var i = 0, len = classStr.length, c; i < len; ++i){\n\t\t\t\tc = classStr[i];\n\t\t\t\tif(c && cls.indexOf(\" \" + c + \" \") < 0){\n\t\t\t\t\tcls += c + \" \";\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(oldLen < cls.length){\n\t\t\t\tnode[className] = cls.substr(1, cls.length - 2);\n\t\t\t}\n\t\t},\n\n\t\tremove: function removeClass(/*DomNode|String*/ node, /*String|Array?*/ classStr){\n\t\t\t// summary:\n\t\t\t//\t\tRemoves the specified classes from node. No `contains()`\n\t\t\t//\t\tcheck is required.\n\t\t\t//\n\t\t\t// node: String|DOMNode\n\t\t\t//\t\tString ID or DomNode reference to remove the class from.\n\t\t\t//\n\t\t\t// classStr: String|Array\n\t\t\t//\t\tAn optional String class name to remove, or several space-separated\n\t\t\t//\t\tclass names, or an array of class names. If omitted, all class names\n\t\t\t//\t\twill be deleted.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tRemove a class from some node:\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.remove(\"someNode\", \"firstClass\");\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tRemove two classes from some node:\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.remove(\"someNode\", \"firstClass secondClass\");\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tRemove two classes from some node (using array):\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.remove(\"someNode\", [\"firstClass\", \"secondClass\"]);\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tRemove all classes from some node:\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.remove(\"someNode\");\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tAvailable in `dojo/NodeList` for multiple removal\n\t\t\t//\t|\trequire([\"dojo/query\"], function(query){\n\t\t\t//\t|\t\tquery(\"ul > li\").removeClass(\"foo\");\n\t\t\t//\t|\t});\n\n\t\t\tnode = dom.byId(node);\n\t\t\tvar cls;\n\t\t\tif(classStr !== undefined){\n\t\t\t\tclassStr = str2array(classStr);\n\t\t\t\tcls = \" \" + node[className] + \" \";\n\t\t\t\tfor(var i = 0, len = classStr.length; i < len; ++i){\n\t\t\t\t\tcls = cls.replace(\" \" + classStr[i] + \" \", \" \");\n\t\t\t\t}\n\t\t\t\tcls = lang.trim(cls);\n\t\t\t}else{\n\t\t\t\tcls = \"\";\n\t\t\t}\n\t\t\tif(node[className] != cls){ node[className] = cls; }\n\t\t},\n\n\t\treplace: function replaceClass(/*DomNode|String*/ node, /*String|Array*/ addClassStr, /*String|Array?*/ removeClassStr){\n\t\t\t// summary:\n\t\t\t//\t\tReplaces one or more classes on a node if not present.\n\t\t\t//\t\tOperates more quickly than calling dojo.removeClass and dojo.addClass\n\t\t\t//\n\t\t\t// node: String|DOMNode\n\t\t\t//\t\tString ID or DomNode reference to remove the class from.\n\t\t\t//\n\t\t\t// addClassStr: String|Array\n\t\t\t//\t\tA String class name to add, or several space-separated class names,\n\t\t\t//\t\tor an array of class names.\n\t\t\t//\n\t\t\t// removeClassStr: String|Array?\n\t\t\t//\t\tA String class name to remove, or several space-separated class names,\n\t\t\t//\t\tor an array of class names.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.replace(\"someNode\", \"add1 add2\", \"remove1 remove2\");\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\tReplace all classes with addMe\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.replace(\"someNode\", \"addMe\");\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\tAvailable in `dojo/NodeList` for multiple toggles\n\t\t\t//\t|\trequire([\"dojo/query\"], function(query){\n\t\t\t//\t|\t\tquery(\".findMe\").replaceClass(\"addMe\", \"removeMe\");\n\t\t\t//\t|\t});\n\n\t\t\tnode = dom.byId(node);\n\t\t\tfakeNode[className] = node[className];\n\t\t\tcls.remove(fakeNode, removeClassStr);\n\t\t\tcls.add(fakeNode, addClassStr);\n\t\t\tif(node[className] !== fakeNode[className]){\n\t\t\t\tnode[className] = fakeNode[className];\n\t\t\t}\n\t\t},\n\n\t\ttoggle: function toggleClass(/*DomNode|String*/ node, /*String|Array*/ classStr, /*Boolean?*/ condition){\n\t\t\t// summary:\n\t\t\t//\t\tAdds a class to node if not present, or removes if present.\n\t\t\t//\t\tPass a boolean condition if you want to explicitly add or remove.\n\t\t\t//\t\tReturns the condition that was specified directly or indirectly.\n\t\t\t//\n\t\t\t// node: String|DOMNode\n\t\t\t//\t\tString ID or DomNode reference to toggle a class string\n\t\t\t//\n\t\t\t// classStr: String|Array\n\t\t\t//\t\tA String class name to toggle, or several space-separated class names,\n\t\t\t//\t\tor an array of class names.\n\t\t\t//\n\t\t\t// condition:\n\t\t\t//\t\tIf passed, true means to add the class, false means to remove.\n\t\t\t//\t\tOtherwise dojo.hasClass(node, classStr) is used to detect the class presence.\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.toggle(\"someNode\", \"hovered\");\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tForcefully add a class\n\t\t\t//\t|\trequire([\"dojo/dom-class\"], function(domClass){\n\t\t\t//\t|\t\tdomClass.toggle(\"someNode\", \"hovered\", true);\n\t\t\t//\t|\t});\n\t\t\t//\n\t\t\t// example:\n\t\t\t//\t\tAvailable in `dojo/NodeList` for multiple toggles\n\t\t\t//\t|\trequire([\"dojo/query\"], function(query){\n\t\t\t//\t|\t\tquery(\".toggleMe\").toggleClass(\"toggleMe\");\n\t\t\t//\t|\t});\n\n\t\t\tnode = dom.byId(node);\n\t\t\tif(condition === undefined){\n\t\t\t\tclassStr = str2array(classStr);\n\t\t\t\tfor(var i = 0, len = classStr.length, c; i < len; ++i){\n\t\t\t\t\tc = classStr[i];\n\t\t\t\t\tcls[cls.contains(node, c) ? \"remove\" : \"add\"](node, c);\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tcls[condition ? \"add\" : \"remove\"](node, classStr);\n\t\t\t}\n\t\t\treturn condition;   // Boolean\n\t\t}\n\t};\n\n\treturn cls;\n});\n\n},\n'dojo/_base/config':function(){\ndefine([\"../has\", \"require\"], function(has, require){\n\t// module:\n\t//\t\tdojo/_base/config\n\n/*=====\nreturn {\n\t// summary:\n\t//\t\tThis module defines the user configuration during bootstrap.\n\t// description:\n\t//\t\tBy defining user configuration as a module value, an entire configuration can be specified in a build,\n\t//\t\tthereby eliminating the need for sniffing and or explicitly setting in the global variable dojoConfig.\n\t//\t\tAlso, when multiple instances of dojo exist in a single application, each will necessarily be located\n\t//\t\tat an unique absolute module identifier as given by the package configuration. Implementing configuration\n\t//\t\tas a module allows for specifying unique, per-instance configurations.\n\t// example:\n\t//\t\tCreate a second instance of dojo with a different, instance-unique configuration (assume the loader and\n\t//\t\tdojo.js are already loaded).\n\t//\t\t|\t// specify a configuration that creates a new instance of dojo at the absolute module identifier \"myDojo\"\n\t//\t\t|\trequire({\n\t//\t\t|\t\tpackages:[{\n\t//\t\t|\t\t\tname:\"myDojo\",\n\t//\t\t|\t\t\tlocation:\".\", //assume baseUrl points to dojo.js\n\t//\t\t|\t\t}]\n\t//\t\t|\t});\n\t//\t\t|\n\t//\t\t|\t// specify a configuration for the myDojo instance\n\t//\t\t|\tdefine(\"myDojo/config\", {\n\t//\t\t|\t\t// normal configuration variables go here, e.g.,\n\t//\t\t|\t\tlocale:\"fr-ca\"\n\t//\t\t|\t});\n\t//\t\t|\n\t//\t\t|\t// load and use the new instance of dojo\n\t//\t\t|\trequire([\"myDojo\"], function(dojo){\n\t//\t\t|\t\t// dojo is the new instance of dojo\n\t//\t\t|\t\t// use as required\n\t//\t\t|\t});\n\n\t// isDebug: Boolean\n\t//\t\tDefaults to `false`. If set to `true`, ensures that Dojo provides\n\t//\t\textended debugging feedback via Firebug. If Firebug is not available\n\t//\t\ton your platform, setting `isDebug` to `true` will force Dojo to\n\t//\t\tpull in (and display) the version of Firebug Lite which is\n\t//\t\tintegrated into the Dojo distribution, thereby always providing a\n\t//\t\tdebugging/logging console when `isDebug` is enabled. Note that\n\t//\t\tFirebug's `console.*` methods are ALWAYS defined by Dojo. If\n\t//\t\t`isDebug` is false and you are on a platform without Firebug, these\n\t//\t\tmethods will be defined as no-ops.\n\tisDebug: false,\n\n\t// locale: String\n\t//\t\tThe locale to assume for loading localized resources in this page,\n\t//\t\tspecified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt).\n\t//\t\tMust be specified entirely in lowercase, e.g. `en-us` and `zh-cn`.\n\t//\t\tSee the documentation for `dojo.i18n` and `dojo.requireLocalization`\n\t//\t\tfor details on loading localized resources. If no locale is specified,\n\t//\t\tDojo assumes the locale of the user agent, according to `navigator.userLanguage`\n\t//\t\tor `navigator.language` properties.\n\tlocale: undefined,\n\n\t// extraLocale: Array\n\t//\t\tNo default value. Specifies additional locales whose\n\t//\t\tresources should also be loaded alongside the default locale when\n\t//\t\tcalls to `dojo.requireLocalization()` are processed.\n\textraLocale: undefined,\n\n\t// baseUrl: String\n\t//\t\tThe directory in which `dojo.js` is located. Under normal\n\t//\t\tconditions, Dojo auto-detects the correct location from which it\n\t//\t\twas loaded. You may need to manually configure `baseUrl` in cases\n\t//\t\twhere you have renamed `dojo.js` or in which `<base>` tags confuse\n\t//\t\tsome browsers (e.g. IE 6). The variable `dojo.baseUrl` is assigned\n\t//\t\teither the value of `djConfig.baseUrl` if one is provided or the\n\t//\t\tauto-detected root if not. Other modules are located relative to\n\t//\t\tthis path. The path should end in a slash.\n\tbaseUrl: undefined,\n\n\t// modulePaths: [deprecated] Object\n\t//\t\tA map of module names to paths relative to `dojo.baseUrl`. The\n\t//\t\tkey/value pairs correspond directly to the arguments which\n\t//\t\t`dojo.registerModulePath` accepts. Specifying\n\t//\t\t`djConfig.modulePaths = { \"foo\": \"../../bar\" }` is the equivalent\n\t//\t\tof calling `dojo.registerModulePath(\"foo\", \"../../bar\");`. Multiple\n\t//\t\tmodules may be configured via `djConfig.modulePaths`.\n\tmodulePaths: {},\n\n\t// addOnLoad: Function|Array\n\t//\t\tAdds a callback via dojo/ready. Useful when Dojo is added after\n\t//\t\tthe page loads and djConfig.afterOnLoad is true. Supports the same\n\t//\t\targuments as dojo/ready. When using a function reference, use\n\t//\t\t`djConfig.addOnLoad = function(){};`. For object with function name use\n\t//\t\t`djConfig.addOnLoad = [myObject, \"functionName\"];` and for object with\n\t//\t\tfunction reference use\n\t//\t\t`djConfig.addOnLoad = [myObject, function(){}];`\n\taddOnLoad: null,\n\n\t// parseOnLoad: Boolean\n\t//\t\tRun the parser after the page is loaded\n\tparseOnLoad: false,\n\n\t// require: String[]\n\t//\t\tAn array of module names to be loaded immediately after dojo.js has been included\n\t//\t\tin a page.\n\trequire: [],\n\n\t// defaultDuration: Number\n\t//\t\tDefault duration, in milliseconds, for wipe and fade animations within dijits.\n\t//\t\tAssigned to dijit.defaultDuration.\n\tdefaultDuration: 200,\n\n\t// dojoBlankHtmlUrl: String\n\t//\t\tUsed by some modules to configure an empty iframe. Used by dojo/io/iframe and\n\t//\t\tdojo/back, and dijit/popup support in IE where an iframe is needed to make sure native\n\t//\t\tcontrols do not bleed through the popups. Normally this configuration variable\n\t//\t\tdoes not need to be set, except when using cross-domain/CDN Dojo builds.\n\t//\t\tSave dojo/resources/blank.html to your domain and set `djConfig.dojoBlankHtmlUrl`\n\t//\t\tto the path on your domain your copy of blank.html.\n\tdojoBlankHtmlUrl: undefined,\n\n\t// ioPublish: Boolean?\n\t//\t\tSet this to true to enable publishing of topics for the different phases of\n\t//\t\tIO operations. Publishing is done via dojo/topic.publish(). See dojo/main.__IoPublish for a list\n\t//\t\tof topics that are published.\n\tioPublish: false,\n\n\t// useCustomLogger: Anything?\n\t//\t\tIf set to a value that evaluates to true such as a string or array and\n\t//\t\tisDebug is true and Firebug is not available or running, then it bypasses\n\t//\t\tthe creation of Firebug Lite allowing you to define your own console object.\n\tuseCustomLogger: undefined,\n\n\t// transparentColor: Array\n\t//\t\tArray containing the r, g, b components used as transparent color in dojo.Color;\n\t//\t\tif undefined, [255,255,255] (white) will be used.\n\ttransparentColor: undefined,\n\t\n\t// deps: Function|Array\n\t//\t\tDefines dependencies to be used before the loader has been loaded.\n\t//\t\tWhen provided, they cause the loader to execute require(deps, callback) \n\t//\t\tonce it has finished loading. Should be used with callback.\n\tdeps: undefined,\n\t\n\t// callback: Function|Array\n\t//\t\tDefines a callback to be used when dependencies are defined before \n\t//\t\tthe loader has been loaded. When provided, they cause the loader to \n\t//\t\texecute require(deps, callback) once it has finished loading. \n\t//\t\tShould be used with deps.\n\tcallback: undefined,\n\t\n\t// deferredInstrumentation: Boolean\n\t//\t\tWhether deferred instrumentation should be loaded or included\n\t//\t\tin builds.\n\tdeferredInstrumentation: true,\n\n\t// useDeferredInstrumentation: Boolean|String\n\t//\t\tWhether the deferred instrumentation should be used.\n\t//\n\t//\t\t* `\"report-rejections\"`: report each rejection as it occurs.\n\t//\t\t* `true` or `1` or `\"report-unhandled-rejections\"`: wait 1 second\n\t//\t\t\tin an attempt to detect unhandled rejections.\n\tuseDeferredInstrumentation: \"report-unhandled-rejections\"\n};\n=====*/\n\n\tvar result = {};\n\tif( 1 ){\n\t\t// must be the dojo loader; take a shallow copy of require.rawConfig\n\t\tvar src = require.rawConfig, p;\n\t\tfor(p in src){\n\t\t\tresult[p] = src[p];\n\t\t}\n\t}else{\n\t\tvar adviseHas = function(featureSet, prefix, booting){\n\t\t\tfor(p in featureSet){\n\t\t\t\tp!=\"has\" && has.add(prefix + p, featureSet[p], 0, booting);\n\t\t\t}\n\t\t};\n\t\tresult =  1  ?\n\t\t\t// must be a built version of the dojo loader; all config stuffed in require.rawConfig\n\t\t\trequire.rawConfig :\n\t\t\t// a foreign loader\n\t\t\tthis.dojoConfig || this.djConfig || {};\n\t\tadviseHas(result, \"config\", 1);\n\t\tadviseHas(result.has, \"\", 1);\n\t}\n\treturn result;\n});\n\n\n},\n'dojo/main':function(){\ndefine([\n\t\"./_base/kernel\",\t// kernel.isAsync\n\t\"./has\",\n\t\"require\",\n\t\"./sniff\",\n\t\"./_base/lang\",\n\t\"./_base/array\",\n\t\"./_base/config\",\n\t\"./ready\",\n\t\"./_base/declare\",\n\t\"./_base/connect\",\n\t\"./_base/Deferred\",\n\t\"./_base/json\",\n\t\"./_base/Color\",\n\t\"./has!dojo-firebug?./_firebug/firebug\",\n\t\"./_base/browser\",\n\t\"./_base/loader\"\n], function(kernel, has, require, sniff, lang, array, config, ready){\n\t// module:\n\t//\t\tdojo/main\n\t// summary:\n\t//\t\tThis is the package main module for the dojo package; it loads dojo base appropriate for the execution environment.\n\n\t// the preferred way to load the dojo firebug console is by setting has(\"dojo-firebug\") true in dojoConfig\n\t// the isDebug config switch is for backcompat and will work fine in sync loading mode; it works in\n\t// async mode too, but there's no guarantee when the module is loaded; therefore, if you need a firebug\n\t// console guaranteed at a particular spot in an app, either set config.has[\"dojo-firebug\"] true before\n\t// loading dojo.js or explicitly include dojo/_firebug/firebug in a dependency list.\n\tif(config.isDebug){\n\t\trequire([\"./_firebug/firebug\"]);\n\t}\n\n\t// dojoConfig.require is deprecated; use the loader configuration property deps\n\t 1 || has.add(\"dojo-config-require\", 1);\n\tif( 1 ){\n\t\tvar deps= config.require;\n\t\tif(deps){\n\t\t\t// config.require may be dot notation\n\t\t\tdeps= array.map(lang.isArray(deps) ? deps : [deps], function(item){ return item.replace(/\\./g, \"/\"); });\n\t\t\tif(kernel.isAsync){\n\t\t\t\trequire(deps);\n\t\t\t}else{\n\t\t\t\t// this is a bit janky; in 1.6- dojo is defined before these requires are applied; but in 1.7+\n\t\t\t\t// dojo isn't defined until returning from this module; this is only a problem in sync mode\n\t\t\t\t// since we're in sync mode, we know we've got our loader with its priority ready queue\n\t\t\t\tready(1, function(){require(deps);});\n\t\t\t}\n\t\t}\n\t}\n\n\treturn kernel;\n});\n\n},\n'dojo/_base/event':function(){\ndefine(\"dojo/_base/event\", [\"./kernel\", \"../on\", \"../has\", \"../dom-geometry\"], function(dojo, on, has, dom){\n\t// module:\n\t//\t\tdojo/_base/event\n\n\tif(on._fixEvent){\n\t\tvar fixEvent = on._fixEvent;\n\t\ton._fixEvent = function(evt, se){\n\t\t\t// add some additional normalization for back-compat, this isn't in on.js because it is somewhat more expensive\n\t\t\tevt = fixEvent(evt, se);\n\t\t\tif(evt){\n\t\t\t\tdom.normalizeEvent(evt);\n\t\t\t}\n\t\t\treturn evt;\n\t\t};\t\t\n\t}\n\t\n\tvar ret = {\n\t\t// summary:\n\t\t//\t\tThis module defines dojo DOM event API.   Usually you should use dojo/on, and evt.stopPropagation() +\n\t\t//\t\tevt.preventDefault(), rather than this module.\n\n\t\tfix: function(/*Event*/ evt, /*DOMNode*/ sender){\n\t\t\t// summary:\n\t\t\t//\t\tnormalizes properties on the event object including event\n\t\t\t//\t\tbubbling methods, keystroke normalization, and x/y positions\n\t\t\t// evt: Event\n\t\t\t//\t\tnative event object\n\t\t\t// sender: DOMNode\n\t\t\t//\t\tnode to treat as \"currentTarget\"\n\t\t\tif(on._fixEvent){\n\t\t\t\treturn on._fixEvent(evt, sender);\n\t\t\t}\n\t\t\treturn evt;\t// Event\n\t\t},\n\t\n\t\tstop: function(/*Event*/ evt){\n\t\t\t// summary:\n\t\t\t//\t\tprevents propagation and clobbers the default action of the\n\t\t\t//\t\tpassed event\n\t\t\t// evt: Event\n\t\t\t//\t\tThe event object. If omitted, window.event is used on IE.\n\t\t\tif(has(\"dom-addeventlistener\") || (evt && evt.preventDefault)){\n\t\t\t\tevt.preventDefault();\n\t\t\t\tevt.stopPropagation();\n\t\t\t}else{\n\t\t\t\tevt = evt || window.event;\n\t\t\t\tevt.cancelBubble = true;\n\t\t\t\ton._preventDefault.call(evt);\n\t\t\t}\n\t\t}\n\t};\n\n\tif( 1 ){\n\t\tdojo.fixEvent = ret.fix;\n\t\tdojo.stopEvent = ret.stop;\n\t}\n\n\treturn ret;\n});\n\n},\n'dojo/sniff':function(){\ndefine([\"./has\"], function(has){\n\t// module:\n\t//\t\tdojo/sniff\n\n\t/*=====\n\treturn function(){\n\t\t// summary:\n\t\t//\t\tThis module sets has() flags based on the current browser.\n\t\t//\t\tIt returns the has() function.\n\t};\n\t=====*/\n\n\tif( 1 ){\n\t\tvar n = navigator,\n\t\t\tdua = n.userAgent,\n\t\t\tdav = n.appVersion,\n\t\t\ttv = parseFloat(dav);\n\n\t\thas.add(\"air\", dua.indexOf(\"AdobeAIR\") >= 0),\n\t\thas.add(\"khtml\", dav.indexOf(\"Konqueror\") >= 0 ? tv : undefined);\n\t\thas.add(\"webkit\", parseFloat(dua.split(\"WebKit/\")[1]) || undefined);\n\t\thas.add(\"chrome\", parseFloat(dua.split(\"Chrome/\")[1]) || undefined);\n\t\thas.add(\"safari\", dav.indexOf(\"Safari\")>=0 && !has(\"chrome\") ? parseFloat(dav.split(\"Version/\")[1]) : undefined);\n\t\thas.add(\"mac\", dav.indexOf(\"Macintosh\") >= 0);\n\t\thas.add(\"quirks\", document.compatMode == \"BackCompat\");\n\t\thas.add(\"ios\", /iPhone|iPod|iPad/.test(dua));\n\t\thas.add(\"android\", parseFloat(dua.split(\"Android \")[1]) || undefined);\n\n\t\tif(!has(\"webkit\")){\n\t\t\t// Opera\n\t\t\tif(dua.indexOf(\"Opera\") >= 0){\n\t\t\t\t// see http://dev.opera.com/articles/view/opera-ua-string-changes and http://www.useragentstring.com/pages/Opera/\n\t\t\t\t// 9.8 has both styles; <9.8, 9.9 only old style\n\t\t\t\thas.add(\"opera\", tv >= 9.8 ? parseFloat(dua.split(\"Version/\")[1]) || tv : tv);\n\t\t\t}\n\n\t\t\t// Mozilla and firefox\n\t\t\tif(dua.indexOf(\"Gecko\") >= 0 && !has(\"khtml\") && !has(\"webkit\")){\n\t\t\t\thas.add(\"mozilla\", tv);\n\t\t\t}\n\t\t\tif(has(\"mozilla\")){\n\t\t\t\t//We really need to get away from this. Consider a sane isGecko approach for the future.\n\t\t\t\thas.add(\"ff\", parseFloat(dua.split(\"Firefox/\")[1] || dua.split(\"Minefield/\")[1]) || undefined);\n\t\t\t}\n\n\t\t\t// IE\n\t\t\tif(document.all && !has(\"opera\")){\n\t\t\t\tvar isIE = parseFloat(dav.split(\"MSIE \")[1]) || undefined;\n\n\t\t\t\t//In cases where the page has an HTTP header or META tag with\n\t\t\t\t//X-UA-Compatible, then it is in emulation mode.\n\t\t\t\t//Make sure isIE reflects the desired version.\n\t\t\t\t//document.documentMode of 5 means quirks mode.\n\t\t\t\t//Only switch the value if documentMode's major version\n\t\t\t\t//is different from isIE's major version.\n\t\t\t\tvar mode = document.documentMode;\n\t\t\t\tif(mode && mode != 5 && Math.floor(isIE) != mode){\n\t\t\t\t\tisIE = mode;\n\t\t\t\t}\n\n\t\t\t\thas.add(\"ie\", isIE);\n\t\t\t}\n\n\t\t\t// Wii\n\t\t\thas.add(\"wii\", typeof opera != \"undefined\" && opera.wiiremote);\n\t\t}\n\t}\n\n\treturn has;\n});\n\n},\n'dojo/request/handlers':function(){\ndefine([\n\t'../json',\n\t'../_base/kernel',\n\t'../_base/array',\n\t'../has'\n], function(JSON, kernel, array, has){\n\thas.add('activex', typeof ActiveXObject !== 'undefined');\n\n\tvar handleXML;\n\tif(has('activex')){\n\t\t// GUIDs obtained from http://msdn.microsoft.com/en-us/library/ms757837(VS.85).aspx\n\t\tvar dp = [\n\t\t\t'Msxml2.DOMDocument.6.0',\n\t\t\t'Msxml2.DOMDocument.4.0',\n\t\t\t'MSXML2.DOMDocument.3.0',\n\t\t\t'MSXML.DOMDocument' // 2.0\n\t\t];\n\n\t\thandleXML = function(response){\n\t\t\tvar result = response.data;\n\n\t\t\tif(!result || !result.documentElement){\n\t\t\t\tvar text = response.text;\n\t\t\t\tarray.some(dp, function(p){\n\t\t\t\t\ttry{\n\t\t\t\t\t\tvar dom = new ActiveXObject(p);\n\t\t\t\t\t\tdom.async = false;\n\t\t\t\t\t\tdom.loadXML(text);\n\t\t\t\t\t\tresult = dom;\n\t\t\t\t\t}catch(e){ return false; }\n\t\t\t\t\treturn true;\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\t}\n\n\tvar handlers = {\n\t\t'javascript': function(response){\n\t\t\treturn kernel.eval(response.text || '');\n\t\t},\n\t\t'json': function(response){\n\t\t\treturn JSON.parse(response.text || null);\n\t\t},\n\t\t'xml': handleXML\n\t};\n\n\tfunction handle(response){\n\t\tvar handler = handlers[response.options.handleAs];\n\n\t\tresponse.data = handler ? handler(response) : (response.data || response.text);\n\n\t\treturn response;\n\t}\n\n\thandle.register = function(name, handler){\n\t\thandlers[name] = handler;\n\t};\n\n\treturn handle;\n});\n\n},\n'dojo/aspect':function(){\ndefine(\"dojo/aspect\", [], function(){\n\n\t// module:\n\t//\t\tdojo/aspect\n\n\t\"use strict\";\n\tvar undefined, nextId = 0;\n\tfunction advise(dispatcher, type, advice, receiveArguments){\n\t\tvar previous = dispatcher[type];\n\t\tvar around = type == \"around\";\n\t\tvar signal;\n\t\tif(around){\n\t\t\tvar advised = advice(function(){\n\t\t\t\treturn previous.advice(this, arguments);\n\t\t\t});\n\t\t\tsignal = {\n\t\t\t\tremove: function(){\n\t\t\t\t\tsignal.cancelled = true;\n\t\t\t\t},\n\t\t\t\tadvice: function(target, args){\n\t\t\t\t\treturn signal.cancelled ?\n\t\t\t\t\t\tprevious.advice(target, args) : // cancelled, skip to next one\n\t\t\t\t\t\tadvised.apply(target, args);\t// called the advised function\n\t\t\t\t}\n\t\t\t};\n\t\t}else{\n\t\t\t// create the remove handler\n\t\t\tsignal = {\n\t\t\t\tremove: function(){\n\t\t\t\t\tvar previous = signal.previous;\n\t\t\t\t\tvar next = signal.next;\n\t\t\t\t\tif(!next && !previous){\n\t\t\t\t\t\tdelete dispatcher[type];\n\t\t\t\t\t}else{\n\t\t\t\t\t\tif(previous){\n\t\t\t\t\t\t\tprevious.next = next;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tdispatcher[type] = next;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(next){\n\t\t\t\t\t\t\tnext.previous = previous;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tid: nextId++,\n\t\t\t\tadvice: advice,\n\t\t\t\treceiveArguments: receiveArguments\n\t\t\t};\n\t\t}\n\t\tif(previous && !around){\n\t\t\tif(type == \"after\"){\n\t\t\t\t// add the listener to the end of the list\n\t\t\t\tvar next = previous;\n\t\t\t\twhile(next){\n\t\t\t\t\tprevious = next;\n\t\t\t\t\tnext = next.next;\n\t\t\t\t}\n\t\t\t\tprevious.next = signal;\n\t\t\t\tsignal.previous = previous;\n\t\t\t}else if(type == \"before\"){\n\t\t\t\t// add to beginning\n\t\t\t\tdispatcher[type] = signal;\n\t\t\t\tsignal.next = previous;\n\t\t\t\tprevious.previous = signal;\n\t\t\t}\n\t\t}else{\n\t\t\t// around or first one just replaces\n\t\t\tdispatcher[type] = signal;\n\t\t}\n\t\treturn signal;\n\t}\n\tfunction aspect(type){\n\t\treturn function(target, methodName, advice, receiveArguments){\n\t\t\tvar existing = target[methodName], dispatcher;\n\t\t\tif(!existing || existing.target != target){\n\t\t\t\t// no dispatcher in place\n\t\t\t\ttarget[methodName] = dispatcher = function(){\n\t\t\t\t\tvar executionId = nextId;\n\t\t\t\t\t// before advice\n\t\t\t\t\tvar args = arguments;\n\t\t\t\t\tvar before = dispatcher.before;\n\t\t\t\t\twhile(before){\n\t\t\t\t\t\targs = before.advice.apply(this, args) || args;\n\t\t\t\t\t\tbefore = before.next;\n\t\t\t\t\t}\n\t\t\t\t\t// around advice\n\t\t\t\t\tif(dispatcher.around){\n\t\t\t\t\t\tvar results = dispatcher.around.advice(this, args);\n\t\t\t\t\t}\n\t\t\t\t\t// after advice\n\t\t\t\t\tvar after = dispatcher.after;\n\t\t\t\t\twhile(after && after.id < executionId){\n\t\t\t\t\t\tif(after.receiveArguments){\n\t\t\t\t\t\t\tvar newResults = after.advice.apply(this, args);\n\t\t\t\t\t\t\t// change the return value only if a new value was returned\n\t\t\t\t\t\t\tresults = newResults === undefined ? results : newResults;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tresults = after.advice.call(this, results, args);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tafter = after.next;\n\t\t\t\t\t}\n\t\t\t\t\treturn results;\n\t\t\t\t};\n\t\t\t\tif(existing){\n\t\t\t\t\tdispatcher.around = {advice: function(target, args){\n\t\t\t\t\t\treturn existing.apply(target, args);\n\t\t\t\t\t}};\n\t\t\t\t}\n\t\t\t\tdispatcher.target = target;\n\t\t\t}\n\t\t\tvar results = advise((dispatcher || existing), type, advice, receiveArguments);\n\t\t\tadvice = null;\n\t\t\treturn results;\n\t\t};\n\t}\n\n\t// TODOC: after/before/around return object\n\n\tvar after = aspect(\"after\");\n\t/*=====\n\tafter = function(target, methodName, advice, receiveArguments){\n\t\t// summary:\n\t\t//\t\tThe \"after\" export of the aspect module is a function that can be used to attach\n\t\t//\t\t\"after\" advice to a method. This function will be executed after the original method\n\t\t//\t\tis executed. By default the function will be called with a single argument, the return\n\t\t//\t\tvalue of the original method, or the the return value of the last executed advice (if a previous one exists).\n\t\t//\t\tThe fourth (optional) argument can be set to true to so the function receives the original\n\t\t//\t\targuments (from when the original method was called) rather than the return value.\n\t\t//\t\tIf there are multiple \"after\" advisors, they are executed in the order they were registered.\n\t\t// target: Object\n\t\t//\t\tThis is the target object\n\t\t// methodName: String\n\t\t//\t\tThis is the name of the method to attach to.\n\t\t// advice: Function\n\t\t//\t\tThis is function to be called after the original method\n\t\t// receiveArguments: Boolean?\n\t\t//\t\tIf this is set to true, the advice function receives the original arguments (from when the original mehtod\n\t\t//\t\twas called) rather than the return value of the original/previous method.\n\t\t// returns:\n\t\t//\t\tA signal object that can be used to cancel the advice. If remove() is called on this signal object, it will\n\t\t//\t\tstop the advice function from being executed.\n\t};\n\t=====*/\n\n\tvar before = aspect(\"before\");\n\t/*=====\n\tbefore = function(target, methodName, advice){\n\t\t// summary:\n\t\t//\t\tThe \"before\" export of the aspect module is a function that can be used to attach\n\t\t//\t\t\"before\" advice to a method. This function will be executed before the original method\n\t\t//\t\tis executed. This function will be called with the arguments used to call the method.\n\t\t//\t\tThis function may optionally return an array as the new arguments to use to call\n\t\t//\t\tthe original method (or the previous, next-to-execute before advice, if one exists).\n\t\t//\t\tIf the before method doesn't return anything (returns undefined) the original arguments\n\t\t//\t\twill be preserved.\n\t\t//\t\tIf there are multiple \"before\" advisors, they are executed in the reverse order they were registered.\n\t\t// target: Object\n\t\t//\t\tThis is the target object\n\t\t// methodName: String\n\t\t//\t\tThis is the name of the method to attach to.\n\t\t// advice: Function\n\t\t//\t\tThis is function to be called before the original method\n\t};\n\t=====*/\n\n\tvar around = aspect(\"around\");\n\t/*=====\n\t around = function(target, methodName, advice){\n\t\t// summary:\n\t\t//\t\tThe \"around\" export of the aspect module is a function that can be used to attach\n\t\t//\t\t\"around\" advice to a method. The advisor function is immediately executed when\n\t\t//\t\tthe around() is called, is passed a single argument that is a function that can be\n\t\t//\t\tcalled to continue execution of the original method (or the next around advisor).\n\t\t//\t\tThe advisor function should return a function, and this function will be called whenever\n\t\t//\t\tthe method is called. It will be called with the arguments used to call the method.\n\t\t//\t\tWhatever this function returns will be returned as the result of the method call (unless after advise changes it).\n\t\t// example:\n\t\t//\t\tIf there are multiple \"around\" advisors, the most recent one is executed first,\n\t\t//\t\twhich can then delegate to the next one and so on. For example:\n\t\t//\t\t|\taround(obj, \"foo\", function(originalFoo){\n\t\t//\t\t|\t\treturn function(){\n\t\t//\t\t|\t\t\tvar start = new Date().getTime();\n\t\t//\t\t|\t\t\tvar results = originalFoo.apply(this, arguments); // call the original\n\t\t//\t\t|\t\t\tvar end = new Date().getTime();\n\t\t//\t\t|\t\t\tconsole.log(\"foo execution took \" + (end - start) + \" ms\");\n\t\t//\t\t|\t\t\treturn results;\n\t\t//\t\t|\t\t};\n\t\t//\t\t|\t});\n\t\t// target: Object\n\t\t//\t\tThis is the target object\n\t\t// methodName: String\n\t\t//\t\tThis is the name of the method to attach to.\n\t\t// advice: Function\n\t\t//\t\tThis is function to be called around the original method\n\t};\n\t=====*/\n\n\treturn {\n\t\t// summary:\n\t\t//\t\tprovides aspect oriented programming functionality, allowing for\n\t\t//\t\tone to add before, around, or after advice on existing methods.\n\t\t// example:\n\t\t//\t|\tdefine([\"dojo/aspect\"], function(aspect){\n\t\t//\t|\t\tvar signal = aspect.after(targetObject, \"methodName\", function(someArgument){\n\t\t//\t|\t\t\tthis will be called when targetObject.methodName() is called, after the original function is called\n\t\t//\t|\t\t});\n\t\t//\n\t\t// example:\n\t\t//\tThe returned signal object can be used to cancel the advice.\n\t\t//\t|\tsignal.remove(); // this will stop the advice from being executed anymore\n\t\t//\t|\taspect.before(targetObject, \"methodName\", function(someArgument){\n\t\t//\t|\t\t// this will be called when targetObject.methodName() is called, before the original function is called\n\t\t//\t|\t });\n\n\t\tbefore: before,\n\t\taround: around,\n\t\tafter: after\n\t};\n});\n\n},\n'dojo/ready':function(){\ndefine(\"dojo/ready\", [\"./_base/kernel\", \"./has\", \"require\", \"./domReady\", \"./_base/lang\"], function(dojo, has, require, domReady, lang){\n\t// module:\n\t//\t\tdojo/ready\n\t// note:\n\t//\t\tThis module should be unnecessary in dojo 2.0\n\n\tvar\n\t\t// truthy if DOMContentLoaded or better (e.g., window.onload fired) has been achieved\n\t\tisDomReady = 0,\n\n\t\t// a function to call to cause onLoad to be called when all requested modules have been loaded\n\t\trequestCompleteSignal,\n\n\t\t// The queue of functions waiting to execute as soon as dojo.ready conditions satisfied\n\t\tloadQ = [],\n\n\t\t// prevent recursion in onLoad\n\t\tonLoadRecursiveGuard = 0,\n\n\t\thandleDomReady = function(){\n\t\t\tisDomReady = 1;\n\t\t\tdojo._postLoad = dojo.config.afterOnLoad = true;\n\t\t\tif(loadQ.length){\n\t\t\t\trequestCompleteSignal(onLoad);\n\t\t\t}\n\t\t},\n\n\t\t// run the next function queued with dojo.ready\n\t\tonLoad = function(){\n\t\t\tif(isDomReady && !onLoadRecursiveGuard && loadQ.length){\n\t\t\t\t//guard against recursions into this function\n\t\t\t\tonLoadRecursiveGuard = 1;\n\t\t\t\tvar f = loadQ.shift();\n\t\t\t\t\ttry{\n\t\t\t\t\t\tf();\n\t\t\t\t\t}\n\t\t\t\t\t\t// FIXME: signal the error via require.on\n\t\t\t\t\tfinally{\n\t\t\t\t\t\tonLoadRecursiveGuard = 0;\n\t\t\t\t\t}\n\t\t\t\tonLoadRecursiveGuard = 0;\n\t\t\t\tif(loadQ.length){\n\t\t\t\t\trequestCompleteSignal(onLoad);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\trequire.on(\"idle\", onLoad);\n\trequestCompleteSignal = function(){\n\t\tif(require.idle()){\n\t\t\tonLoad();\n\t\t} // else do nothing, onLoad will be called with the next idle signal\n\t};\n\n\tvar ready = dojo.ready = dojo.addOnLoad = function(priority, context, callback){\n\t\t// summary:\n\t\t//\t\tAdd a function to execute on DOM content loaded and all requested modules have arrived and been evaluated.\n\t\t//\t\tIn most cases, the `domReady` plug-in should suffice and this method should not be needed.\n\t\t// priority: Integer?\n\t\t//\t\tThe order in which to exec this callback relative to other callbacks, defaults to 1000\n\t\t// context: Object?|Function\n\t\t//\t\tThe context in which to run execute callback, or a callback if not using context\n\t\t// callback: Function?\n\t\t//\t\tThe function to execute.\n\t\t//\n\t\t// example:\n\t\t//\tSimple DOM and Modules ready syntax\n\t\t//\t|\trequire([\"dojo/ready\"], function(ready){\n\t\t//\t|\t\tready(function(){ alert(\"Dom ready!\"); });\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tUsing a priority\n\t\t//\t|\trequire([\"dojo/ready\"], function(ready){\n\t\t//\t|\t\tready(2, function(){ alert(\"low priority ready!\"); })\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tUsing context\n\t\t//\t|\trequire([\"dojo/ready\"], function(ready){\n\t\t//\t|\t\tready(foo, function(){\n\t\t//\t|\t\t\t// in here, this == foo\n\t\t//\t|\t\t});\n\t\t//\t|\t});\n\t\t//\n\t\t// example:\n\t\t//\tUsing dojo/hitch style args:\n\t\t//\t|\trequire([\"dojo/ready\"], function(ready){\n\t\t//\t|\t\tvar foo = { dojoReady: function(){ console.warn(this, \"dojo dom and modules ready.\"); } };\n\t\t//\t|\t\tready(foo, \"dojoReady\");\n\t\t//\t|\t});\n\n\t\tvar hitchArgs = lang._toArray(arguments);\n\t\tif(typeof priority != \"number\"){\n\t\t\tcallback = context;\n\t\t\tcontext = priority;\n\t\t\tpriority = 1000;\n\t\t}else{\n\t\t\thitchArgs.shift();\n\t\t}\n\t\tcallback = callback ?\n\t\t\tlang.hitch.apply(dojo, hitchArgs) :\n\t\t\tfunction(){\n\t\t\t\tcontext();\n\t\t\t};\n\t\tcallback.priority = priority;\n\t\tfor(var i = 0; i < loadQ.length && priority >= loadQ[i].priority; i++){}\n\t\tloadQ.splice(i, 0, callback);\n\t\trequestCompleteSignal();\n\t};\n\n\t 1 || has.add(\"dojo-config-addOnLoad\", 1);\n\tif( 1 ){\n\t\tvar dca = dojo.config.addOnLoad;\n\t\tif(dca){\n\t\t\tready[(lang.isArray(dca) ? \"apply\" : \"call\")](dojo, dca);\n\t\t}\n\t}\n\n\tif( 1  && dojo.config.parseOnLoad && !dojo.isAsync){\n\t\tready(99, function(){\n\t\t\tif(!dojo.parser){\n\t\t\t\tdojo.deprecated(\"Add explicit require(['dojo/parser']);\", \"\", \"2.0\");\n\t\t\t\trequire([\"dojo/parser\"]);\n\t\t\t}\n\t\t});\n\t}\n\n\tif( 1 ){\n\t\tdomReady(handleDomReady);\n\t}else{\n\t\thandleDomReady();\n\t}\n\n\treturn ready;\n});\n\n},\n'dojo/_base/connect':function(){\ndefine([\"./kernel\", \"../on\", \"../topic\", \"../aspect\", \"./event\", \"../mouse\", \"./sniff\", \"./lang\", \"../keys\"], function(dojo, on, hub, aspect, eventModule, mouse, has, lang){\n// module:\n//\t\tdojo/_base/connect\n\nhas.add(\"events-keypress-typed\", function(){ // keypresses should only occur a printable character is hit\n\tvar testKeyEvent = {charCode: 0};\n\ttry{\n\t\ttestKeyEvent = document.createEvent(\"KeyboardEvent\");\n\t\t(testKeyEvent.initKeyboardEvent || testKeyEvent.initKeyEvent).call(testKeyEvent, \"keypress\", true, true, null, false, false, false, false, 9, 3);\n\t}catch(e){}\n\treturn testKeyEvent.charCode == 0 && !has(\"opera\");\n});\n\nfunction connect_(obj, event, context, method, dontFix){\n\tmethod = lang.hitch(context, method);\n\tif(!obj || !(obj.addEventListener || obj.attachEvent)){\n\t\t// it is a not a DOM node and we are using the dojo.connect style of treating a\n\t\t// method like an event, must go right to aspect\n\t\treturn aspect.after(obj || dojo.global, event, method, true);\n\t}\n\tif(typeof event == \"string\" && event.substring(0, 2) == \"on\"){\n\t\tevent = event.substring(2);\n\t}\n\tif(!obj){\n\t\tobj = dojo.global;\n\t}\n\tif(!dontFix){\n\t\tswitch(event){\n\t\t\t// dojo.connect has special handling for these event types\n\t\t\tcase \"keypress\":\n\t\t\t\tevent = keypress;\n\t\t\t\tbreak;\n\t\t\tcase \"mouseenter\":\n\t\t\t\tevent = mouse.enter;\n\t\t\t\tbreak;\n\t\t\tcase \"mouseleave\":\n\t\t\t\tevent = mouse.leave;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn on(obj, event, method, dontFix);\n}\n\nvar _punctMap = {\n\t106:42,\n\t111:47,\n\t186:59,\n\t187:43,\n\t188:44,\n\t189:45,\n\t190:46,\n\t191:47,\n\t192:96,\n\t219:91,\n\t220:92,\n\t221:93,\n\t222:39,\n\t229:113\n};\nvar evtCopyKey = has(\"mac\") ? \"metaKey\" : \"ctrlKey\";\n\n\nvar _synthesizeEvent = function(evt, props){\n\tvar faux = lang.mixin({}, evt, props);\n\tsetKeyChar(faux);\n\t// FIXME: would prefer to use lang.hitch: lang.hitch(evt, evt.preventDefault);\n\t// but it throws an error when preventDefault is invoked on Safari\n\t// does Event.preventDefault not support \"apply\" on Safari?\n\tfaux.preventDefault = function(){ evt.preventDefault(); };\n\tfaux.stopPropagation = function(){ evt.stopPropagation(); };\n\treturn faux;\n};\nfunction setKeyChar(evt){\n\tevt.keyChar = evt.charCode ? String.fromCharCode(evt.charCode) : '';\n\tevt.charOrCode = evt.keyChar || evt.keyCode;\n}\nvar keypress;\nif(has(\"events-keypress-typed\")){\n\t// this emulates Firefox's keypress behavior where every keydown can correspond to a keypress\n\tvar _trySetKeyCode = function(e, code){\n\t\ttry{\n\t\t\t// squelch errors when keyCode is read-only\n\t\t\t// (e.g. if keyCode is ctrl or shift)\n\t\t\treturn (e.keyCode = code);\n\t\t}catch(e){\n\t\t\treturn 0;\n\t\t}\n\t};\n\tkeypress = function(object, listener){\n\t\tvar keydownSignal = on(object, \"keydown\", function(evt){\n\t\t\t// munge key/charCode\n\t\t\tvar k=evt.keyCode;\n\t\t\t// These are Windows Virtual Key Codes\n\t\t\t// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp\n\t\t\tvar unprintable = (k!=13) && k!=32 && (k!=27||!has(\"ie\")) && (k<48||k>90) && (k<96||k>111) && (k<186||k>192) && (k<219||k>222) && k!=229;\n\t\t\t// synthesize keypress for most unprintables and CTRL-keys\n\t\t\tif(unprintable||evt.ctrlKey){\n\t\t\t\tvar c = unprintable ? 0 : k;\n\t\t\t\tif(evt.ctrlKey){\n\t\t\t\t\tif(k==3 || k==13){\n\t\t\t\t\t\treturn listener.call(evt.currentTarget, evt); // IE will post CTRL-BREAK, CTRL-ENTER as keypress natively\n\t\t\t\t\t}else if(c>95 && c<106){\n\t\t\t\t\t\tc -= 48; // map CTRL-[numpad 0-9] to ASCII\n\t\t\t\t\t}else if((!evt.shiftKey)&&(c>=65&&c<=90)){\n\t\t\t\t\t\tc += 32; // map CTRL-[A-Z] to lowercase\n\t\t\t\t\t}else{\n\t\t\t\t\t\tc = _punctMap[c] || c; // map other problematic CTRL combinations to ASCII\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// simulate a keypress event\n\t\t\t\tvar faux = _synthesizeEvent(evt, {type: 'keypress', faux: true, charCode: c});\n\t\t\t\tlistener.call(evt.currentTarget, faux);\n\t\t\t\tif(has(\"ie\")){\n\t\t\t\t\t_trySetKeyCode(evt, faux.keyCode);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tvar keypressSignal = on(object, \"keypress\", function(evt){\n\t\t\tvar c = evt.charCode;\n\t\t\tc = c>=32 ? c : 0;\n\t\t\tevt = _synthesizeEvent(evt, {charCode: c, faux: true});\n\t\t\treturn listener.call(this, evt);\n\t\t});\n\t\treturn {\n\t\t\tremove: function(){\n\t\t\t\tkeydownSignal.remove();\n\t\t\t\tkeypressSignal.remove();\n\t\t\t}\n\t\t};\n\t};\n}else{\n\tif(has(\"opera\")){\n\t\tkeypress = function(object, listener){\n\t\t\treturn on(object, \"keypress\", function(evt){\n\t\t\t\tvar c = evt.which;\n\t\t\t\tif(c==3){\n\t\t\t\t\tc=99; // Mozilla maps CTRL-BREAK to CTRL-c\n\t\t\t\t}\n\t\t\t\t// can't trap some keys at all, like INSERT and DELETE\n\t\t\t\t// there is no differentiating info between DELETE and \".\", or INSERT and \"-\"\n\t\t\t\tc = c<32 && !evt.shiftKey ? 0 : c;\n\t\t\t\tif(evt.ctrlKey && !evt.shiftKey && c>=65 && c<=90){\n\t\t\t\t\t// lowercase CTRL-[A-Z] keys\n\t\t\t\t\tc += 32;\n\t\t\t\t}\n\t\t\t\treturn listener.call(this, _synthesizeEvent(evt, { charCode: c }));\n\t\t\t});\n\t\t};\n\t}else{\n\t\tkeypress = function(object, listener){\n\t\t\treturn on(object, \"keypress\", function(evt){\n\t\t\t\tsetKeyChar(evt);\n\t\t\t\treturn listener.call(this, evt);\n\t\t\t});\n\t\t};\n\t}\n}\n\nvar connect = {\n\t// summary:\n\t//\t\tThis module defines the dojo.connect API.\n\t//\t\tThis modules also provides keyboard event handling helpers.\n\t//\t\tThis module exports an extension event for emulating Firefox's keypress handling.\n\t//\t\tHowever, this extension event exists primarily for backwards compatibility and\n\t//\t\tis not recommended. WebKit and IE uses an alternate keypress handling (only\n\t//\t\tfiring for printable characters, to distinguish from keydown events), and most\n\t//\t\tconsider the WebKit/IE behavior more desirable.\n\n\t_keypress:keypress,\n\n\tconnect:function(obj, event, context, method, dontFix){\n\t\t// summary:\n\t\t//\t\t`dojo.connect` is a deprecated event handling and delegation method in\n\t\t//\t\tDojo. It allows one function to \"listen in\" on the execution of\n\t\t//\t\tany other, triggering the second whenever the first is called. Many\n\t\t//\t\tlisteners may be attached to a function, and source functions may\n\t\t//\t\tbe either regular function calls or DOM events.\n\t\t//\n\t\t// description:\n\t\t//\t\tConnects listeners to actions, so that after event fires, a\n\t\t//\t\tlistener is called with the same arguments passed to the original\n\t\t//\t\tfunction.\n\t\t//\n\t\t//\t\tSince `dojo.connect` allows the source of events to be either a\n\t\t//\t\t\"regular\" JavaScript function or a DOM event, it provides a uniform\n\t\t//\t\tinterface for listening to all the types of events that an\n\t\t//\t\tapplication is likely to deal with though a single, unified\n\t\t//\t\tinterface. DOM programmers may want to think of it as\n\t\t//\t\t\"addEventListener for everything and anything\".\n\t\t//\n\t\t//\t\tWhen setting up a connection, the `event` parameter must be a\n\t\t//\t\tstring that is the name of the method/event to be listened for. If\n\t\t//\t\t`obj` is null, `kernel.global` is assumed, meaning that connections\n\t\t//\t\tto global methods are supported but also that you may inadvertently\n\t\t//\t\tconnect to a global by passing an incorrect object name or invalid\n\t\t//\t\treference.\n\t\t//\n\t\t//\t\t`dojo.connect` generally is forgiving. If you pass the name of a\n\t\t//\t\tfunction or method that does not yet exist on `obj`, connect will\n\t\t//\t\tnot fail, but will instead set up a stub method. Similarly, null\n\t\t//\t\targuments may simply be omitted such that fewer than 4 arguments\n\t\t//\t\tmay be required to set up a connection See the examples for details.\n\t\t//\n\t\t//\t\tThe return value is a handle that is needed to\n\t\t//\t\tremove this connection with `dojo.disconnect`.\n\t\t//\n\t\t// obj: Object?\n\t\t//\t\tThe source object for the event function.\n\t\t//\t\tDefaults to `kernel.global` if null.\n\t\t//\t\tIf obj is a DOM node, the connection is delegated\n\t\t//\t\tto the DOM event manager (unless dontFix is true).\n\t\t//\n\t\t// event: String\n\t\t//\t\tString name of the event function in obj.\n\t\t//\t\tI.e. identifies a property `obj[event]`.\n\t\t//\n\t\t// context: Object|null\n\t\t//\t\tThe object that method will receive as \"this\".\n\t\t//\n\t\t//\t\tIf context is null and method is a function, then method\n\t\t//\t\tinherits the context of event.\n\t\t//\n\t\t//\t\tIf method is a string then context must be the source\n\t\t//\t\tobject object for method (context[method]). If context is null,\n\t\t//\t\tkernel.global is used.\n\t\t//\n\t\t// method: String|Function\n\t\t//\t\tA function reference, or name of a function in context.\n\t\t//\t\tThe function identified by method fires after event does.\n\t\t//\t\tmethod receives the same arguments as the event.\n\t\t//\t\tSee context argument comments for information on method's scope.\n\t\t//\n\t\t// dontFix: Boolean?\n\t\t//\t\tIf obj is a DOM node, set dontFix to true to prevent delegation\n\t\t//\t\tof this connection to the DOM event manager.\n\t\t//\n\t\t// example:\n\t\t//\t\tWhen obj.onchange(), do ui.update():\n\t\t//\t|\tdojo.connect(obj, \"onchange\", ui, \"update\");\n\t\t//\t|\tdojo.connect(obj, \"onchange\", ui, ui.update); // same\n\t\t//\n\t\t// example:\n\t\t//\t\tUsing return value for disconnect:\n\t\t//\t|\tvar link = dojo.connect(obj, \"onchange\", ui, \"update\");\n\t\t//\t|\t...\n\t\t//\t|\tdojo.disconnect(link);\n\t\t//\n\t\t// example:\n\t\t//\t\tWhen onglobalevent executes, watcher.handler is invoked:\n\t\t//\t|\tdojo.connect(null, \"onglobalevent\", watcher, \"handler\");\n\t\t//\n\t\t// example:\n\t\t//\t\tWhen ob.onCustomEvent executes, customEventHandler is invoked:\n\t\t//\t|\tdojo.connect(ob, \"onCustomEvent\", null, \"customEventHandler\");\n\t\t//\t|\tdojo.connect(ob, \"onCustomEvent\", \"customEventHandler\"); // same\n\t\t//\n\t\t// example:\n\t\t//\t\tWhen ob.onCustomEvent executes, customEventHandler is invoked\n\t\t//\t\twith the same scope (this):\n\t\t//\t|\tdojo.connect(ob, \"onCustomEvent\", null, customEventHandler);\n\t\t//\t|\tdojo.connect(ob, \"onCustomEvent\", customEventHandler); // same\n\t\t//\n\t\t// example:\n\t\t//\t\tWhen globalEvent executes, globalHandler is invoked\n\t\t//\t\twith the same scope (this):\n\t\t//\t|\tdojo.connect(null, \"globalEvent\", null, globalHandler);\n\t\t//\t|\tdojo.connect(\"globalEvent\", globalHandler); // same\n\n\t\t// normalize arguments\n\t\tvar a=arguments, args=[], i=0;\n\t\t// if a[0] is a String, obj was omitted\n\t\targs.push(typeof a[0] == \"string\" ? null : a[i++], a[i++]);\n\t\t// if the arg-after-next is a String or Function, context was NOT omitted\n\t\tvar a1 = a[i+1];\n\t\targs.push(typeof a1 == \"string\" || typeof a1 == \"function\" ? a[i++] : null, a[i++]);\n\t\t// absorb any additional arguments\n\t\tfor(var l=a.length; i<l; i++){\targs.push(a[i]); }\n\t\treturn connect_.apply(this, args);\n\t},\n\n\tdisconnect:function(handle){\n\t\t// summary:\n\t\t//\t\tRemove a link created by dojo.connect.\n\t\t// description:\n\t\t//\t\tRemoves the connection between event and the method referenced by handle.\n\t\t// handle: Handle\n\t\t//\t\tthe return value of the dojo.connect call that created the connection.\n\n\t\tif(handle){\n\t\t\thandle.remove();\n\t\t}\n\t},\n\n\tsubscribe:function(topic, context, method){\n\t\t// summary:\n\t\t//\t\tAttach a listener to a named topic. The listener function is invoked whenever the\n\t\t//\t\tnamed topic is published (see: dojo.publish).\n\t\t//\t\tReturns a handle which is needed to unsubscribe this listener.\n\t\t// topic: String\n\t\t//\t\tThe topic to which to subscribe.\n\t\t// context: Object?\n\t\t//\t\tScope in which method will be invoked, or null for default scope.\n\t\t// method: String|Function\n\t\t//\t\tThe name of a function in context, or a function reference. This is the function that\n\t\t//\t\tis invoked when topic is published.\n\t\t// example:\n\t\t//\t|\tdojo.subscribe(\"alerts\", null, function(caption, message){ alert(caption + \"\\n\" + message); });\n\t\t//\t|\tdojo.publish(\"alerts\", [ \"read this\", \"hello world\" ]);\n\t\treturn hub.subscribe(topic, lang.hitch(context, method));\n\t},\n\n\tpublish:function(topic, args){\n\t\t// summary:\n\t\t//\t\tInvoke all listener method subscribed to topic.\n\t\t// topic: String\n\t\t//\t\tThe name of the topic to publish.\n\t\t// args: Array?\n\t\t//\t\tAn array of arguments. The arguments will be applied\n\t\t//\t\tto each topic subscriber (as first class parameters, via apply).\n\t\t// example:\n\t\t//\t|\tdojo.subscribe(\"alerts\", null, function(caption, message){ alert(caption + \"\\n\" + message); };\n\t\t//\t|\tdojo.publish(\"alerts\", [ \"read this\", \"hello world\" ]);\n\t\treturn hub.publish.apply(hub, [topic].concat(args));\n\t},\n\n\tconnectPublisher:function(topic, obj, event){\n\t\t// summary:\n\t\t//\t\tEnsure that every time obj.event() is called, a message is published\n\t\t//\t\ton the topic. Returns a handle which can be passed to\n\t\t//\t\tdojo.disconnect() to disable subsequent automatic publication on\n\t\t//\t\tthe topic.\n\t\t// topic: String\n\t\t//\t\tThe name of the topic to publish.\n\t\t// obj: Object?\n\t\t//\t\tThe source object for the event function. Defaults to kernel.global\n\t\t//\t\tif null.\n\t\t// event: String\n\t\t//\t\tThe name of the event function in obj.\n\t\t//\t\tI.e. identifies a property obj[event].\n\t\t// example:\n\t\t//\t|\tdojo.connectPublisher(\"/ajax/start\", dojo, \"xhrGet\");\n\t\tvar pf = function(){ connect.publish(topic, arguments); };\n\t\treturn event ? connect.connect(obj, event, pf) : connect.connect(obj, pf); //Handle\n\t},\n\n\tisCopyKey: function(e){\n\t\t// summary:\n\t\t//\t\tChecks an event for the copy key (meta on Mac, and ctrl anywhere else)\n\t\t// e: Event\n\t\t//\t\tEvent object to examine\n\t\treturn e[evtCopyKey];\t// Boolean\n\t}\n};\n\nconnect.unsubscribe = connect.disconnect;\n/*=====\n connect.unsubscribe = function(handle){\n\t // summary:\n\t //\t\tRemove a topic listener.\n\t // handle: Handle\n\t //\t\tThe handle returned from a call to subscribe.\n\t // example:\n\t //\t|\tvar alerter = dojo.subscribe(\"alerts\", null, function(caption, message){ alert(caption + \"\\n\" + message); };\n\t //\t|\t...\n\t //\t|\tdojo.unsubscribe(alerter);\n };\n =====*/\n\n 1  && lang.mixin(dojo, connect);\nreturn connect;\n\n});\n\n\n\n},\n'dojo/errors/CancelError':function(){\ndefine([\"./create\"], function(create){\n\t// module:\n\t//\t\tdojo/errors/CancelError\n\n\t/*=====\n\treturn function(){\n\t\t// summary:\n\t\t//\t\tDefault error if a promise is canceled without a reason.\n\t};\n\t=====*/\n\n\treturn create(\"CancelError\", null, null, { dojoType: \"cancel\" });\n});\n\n}}});\n(function(){\n\t// must use this.require to make this work in node.js\n\tvar require = this.require;\n\t// consume the cached dojo layer\n\trequire({cache:{}});\n\t!require.async && require([\"dojo\"]);\n\trequire.boot && require.apply(null, require.boot);\n})();\n\n"
  },
  {
    "path": "vendor/extjs.js",
    "content": "/*\nExt JS 4.1 - JavaScript Library\nCopyright (c) 2006-2012, Sencha Inc.\nAll rights reserved.\nlicensing@sencha.com\n\nhttp://www.sencha.com/license\n\nOpen Source License\n------------------------------------------------------------------------------------------\nThis version of Ext JS is licensed under the terms of the Open Source GPL 3.0 license. \n\nhttp://www.gnu.org/licenses/gpl.html\n\nThere are several FLOSS exceptions available for use with this release for\nopen source applications that are distributed under a license other than GPL.\n\n* Open Source License Exception for Applications\n\n  http://www.sencha.com/products/floss-exception.php\n\n* Open Source License Exception for Development\n\n  http://www.sencha.com/products/ux-exception.php\n\n\nAlternate Licensing\n------------------------------------------------------------------------------------------\nCommercial and OEM Licenses are available for an alternate download of Ext JS.\nThis is the appropriate option if you are creating proprietary applications and you are \nnot prepared to distribute and share the source code of your application under the \nGPL v3 license. Please visit http://www.sencha.com/license for more details.\n\n--\n\nThis library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF THIRD-PARTY INTELLECTUAL PROPERTY RIGHTS.  See the GNU General Public License for more details.\n*/\n//@tag foundation,core\n/**\n * @class Ext\n * @singleton\n */\nvar Ext = Ext || {};\nExt._startTime = new Date().getTime();\n(function() {\n    var global = this,\n        objectPrototype = Object.prototype,\n        toString = objectPrototype.toString,\n        enumerables = true,\n        enumerablesTest = { toString: 1 },\n        emptyFn = function () {},\n        // This is the \"$previous\" method of a hook function on an instance. When called, it\n        // calls through the class prototype by the name of the called method.\n        callOverrideParent = function () {\n            var method = callOverrideParent.caller.caller; // skip callParent (our caller)\n            return method.$owner.prototype[method.$name].apply(this, arguments);\n        },\n        i;\n\n    Ext.global = global;\n\n    for (i in enumerablesTest) {\n        enumerables = null;\n    }\n\n    if (enumerables) {\n        enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable',\n                       'toLocaleString', 'toString', 'constructor'];\n    }\n\n    /**\n     * An array containing extra enumerables for old browsers\n     * @property {String[]}\n     */\n    Ext.enumerables = enumerables;\n\n    /**\n     * Copies all the properties of config to the specified object.\n     * Note that if recursive merging and cloning without referencing the original objects / arrays is needed, use\n     * {@link Ext.Object#merge} instead.\n     * @param {Object} object The receiver of the properties\n     * @param {Object} config The source of the properties\n     * @param {Object} [defaults] A different object that will also be applied for default values\n     * @return {Object} returns obj\n     */\n    Ext.apply = function(object, config, defaults) {\n        if (defaults) {\n            Ext.apply(object, defaults);\n        }\n\n        if (object && config && typeof config === 'object') {\n            var i, j, k;\n\n            for (i in config) {\n                object[i] = config[i];\n            }\n\n            if (enumerables) {\n                for (j = enumerables.length; j--;) {\n                    k = enumerables[j];\n                    if (config.hasOwnProperty(k)) {\n                        object[k] = config[k];\n                    }\n                }\n            }\n        }\n\n        return object;\n    };\n\n    Ext.buildSettings = Ext.apply({\n        baseCSSPrefix: 'x-',\n        scopeResetCSS: false\n    }, Ext.buildSettings || {});\n\n    Ext.apply(Ext, {\n\n        /**\n         * @property {String} [name='Ext']\n         * <p>The name of the property in the global namespace (The <code>window</code> in browser environments) which refers to the current instance of Ext.</p>\n         * <p>This is usually <code>\"Ext\"</code>, but if a sandboxed build of ExtJS is being used, this will be an alternative name.</p>\n         * <p>If code is being generated for use by <code>eval</code> or to create a <code>new Function</code>, and the global instance\n         * of Ext must be referenced, this is the name that should be built into the code.</p>\n         */\n        name: Ext.sandboxName || 'Ext',\n\n        /**\n         * A reusable empty function\n         */\n        emptyFn: emptyFn,\n\n        /**\n         * A zero length string which will pass a truth test. Useful for passing to methods\n         * which use a truth test to reject <i>falsy</i> values where a string value must be cleared.\n         */\n        emptyString: new String(),\n\n        baseCSSPrefix: Ext.buildSettings.baseCSSPrefix,\n\n        /**\n         * Copies all the properties of config to object if they don't already exist.\n         * @param {Object} object The receiver of the properties\n         * @param {Object} config The source of the properties\n         * @return {Object} returns obj\n         */\n        applyIf: function(object, config) {\n            var property;\n\n            if (object) {\n                for (property in config) {\n                    if (object[property] === undefined) {\n                        object[property] = config[property];\n                    }\n                }\n            }\n\n            return object;\n        },\n\n        /**\n         * Iterates either an array or an object. This method delegates to\n         * {@link Ext.Array#each Ext.Array.each} if the given value is iterable, and {@link Ext.Object#each Ext.Object.each} otherwise.\n         *\n         * @param {Object/Array} object The object or array to be iterated.\n         * @param {Function} fn The function to be called for each iteration. See and {@link Ext.Array#each Ext.Array.each} and\n         * {@link Ext.Object#each Ext.Object.each} for detailed lists of arguments passed to this function depending on the given object\n         * type that is being iterated.\n         * @param {Object} scope (Optional) The scope (`this` reference) in which the specified function is executed.\n         * Defaults to the object being iterated itself.\n         * @markdown\n         */\n        iterate: function(object, fn, scope) {\n            if (Ext.isEmpty(object)) {\n                return;\n            }\n\n            if (scope === undefined) {\n                scope = object;\n            }\n\n            if (Ext.isIterable(object)) {\n                Ext.Array.each.call(Ext.Array, object, fn, scope);\n            }\n            else {\n                Ext.Object.each.call(Ext.Object, object, fn, scope);\n            }\n        }\n    });\n\n    Ext.apply(Ext, {\n\n        /**\n         * This method deprecated. Use {@link Ext#define Ext.define} instead.\n         * @method\n         * @param {Function} superclass\n         * @param {Object} overrides\n         * @return {Function} The subclass constructor from the <tt>overrides</tt> parameter, or a generated one if not provided.\n         * @deprecated 4.0.0 Use {@link Ext#define Ext.define} instead\n         */\n        extend: (function() {\n            // inline overrides\n            var objectConstructor = objectPrototype.constructor,\n                inlineOverrides = function(o) {\n                for (var m in o) {\n                    if (!o.hasOwnProperty(m)) {\n                        continue;\n                    }\n                    this[m] = o[m];\n                }\n            };\n\n            return function(subclass, superclass, overrides) {\n                // First we check if the user passed in just the superClass with overrides\n                if (Ext.isObject(superclass)) {\n                    overrides = superclass;\n                    superclass = subclass;\n                    subclass = overrides.constructor !== objectConstructor ? overrides.constructor : function() {\n                        superclass.apply(this, arguments);\n                    };\n                }\n\n                if (!superclass) {\n                    Ext.Error.raise({\n                        sourceClass: 'Ext',\n                        sourceMethod: 'extend',\n                        msg: 'Attempting to extend from a class which has not been loaded on the page.'\n                    });\n                }\n\n                // We create a new temporary class\n                var F = function() {},\n                    subclassProto, superclassProto = superclass.prototype;\n\n                F.prototype = superclassProto;\n                subclassProto = subclass.prototype = new F();\n                subclassProto.constructor = subclass;\n                subclass.superclass = superclassProto;\n\n                if (superclassProto.constructor === objectConstructor) {\n                    superclassProto.constructor = superclass;\n                }\n\n                subclass.override = function(overrides) {\n                    Ext.override(subclass, overrides);\n                };\n\n                subclassProto.override = inlineOverrides;\n                subclassProto.proto = subclassProto;\n\n                subclass.override(overrides);\n                subclass.extend = function(o) {\n                    return Ext.extend(subclass, o);\n                };\n\n                return subclass;\n            };\n        }()),\n\n        /**\n         * Overrides members of the specified `target` with the given values.\n         * \n         * If the `target` is a class declared using {@link Ext#define Ext.define}, the\n         * `override` method of that class is called (see {@link Ext.Base#override}) given\n         * the `overrides`.\n         *\n         * If the `target` is a function, it is assumed to be a constructor and the contents\n         * of `overrides` are applied to its `prototype` using {@link Ext#apply Ext.apply}.\n         * \n         * If the `target` is an instance of a class declared using {@link Ext#define Ext.define},\n         * the `overrides` are applied to only that instance. In this case, methods are\n         * specially processed to allow them to use {@link Ext.Base#callParent}.\n         * \n         *      var panel = new Ext.Panel({ ... });\n         *      \n         *      Ext.override(panel, {\n         *          initComponent: function () {\n         *              // extra processing...\n         *              \n         *              this.callParent();\n         *          }\n         *      });\n         *\n         * If the `target` is none of these, the `overrides` are applied to the `target`\n         * using {@link Ext#apply Ext.apply}.\n         *\n         * Please refer to {@link Ext#define Ext.define} and {@link Ext.Base#override} for\n         * further details.\n         *\n         * @param {Object} target The target to override.\n         * @param {Object} overrides The properties to add or replace on `target`. \n         * @method override\n         */\n        override: function (target, overrides) {\n            if (target.$isClass) {\n                target.override(overrides);\n            } else if (typeof target == 'function') {\n                Ext.apply(target.prototype, overrides);\n            } else {\n                var owner = target.self,\n                    name, value;\n\n                if (owner && owner.$isClass) { // if (instance of Ext.define'd class)\n                    for (name in overrides) {\n                        if (overrides.hasOwnProperty(name)) {\n                            value = overrides[name];\n\n                            if (typeof value == 'function') {\n                                if (owner.$className) {\n                                    value.displayName = owner.$className + '#' + name;\n                                }\n\n                                value.$name = name;\n                                value.$owner = owner;\n                                value.$previous = target.hasOwnProperty(name)\n                                    ? target[name] // already hooked, so call previous hook\n                                    : callOverrideParent; // calls by name on prototype\n                            }\n\n                            target[name] = value;\n                        }\n                    }\n                } else {\n                    Ext.apply(target, overrides);\n                }\n            }\n\n            return target;\n        }\n    });\n\n    // A full set of static methods to do type checking\n    Ext.apply(Ext, {\n\n        /**\n         * Returns the given value itself if it's not empty, as described in {@link Ext#isEmpty}; returns the default\n         * value (second argument) otherwise.\n         *\n         * @param {Object} value The value to test\n         * @param {Object} defaultValue The value to return if the original value is empty\n         * @param {Boolean} allowBlank (optional) true to allow zero length strings to qualify as non-empty (defaults to false)\n         * @return {Object} value, if non-empty, else defaultValue\n         */\n        valueFrom: function(value, defaultValue, allowBlank){\n            return Ext.isEmpty(value, allowBlank) ? defaultValue : value;\n        },\n\n        /**\n         * Returns the type of the given variable in string format. List of possible values are:\n         *\n         * - `undefined`: If the given value is `undefined`\n         * - `null`: If the given value is `null`\n         * - `string`: If the given value is a string\n         * - `number`: If the given value is a number\n         * - `boolean`: If the given value is a boolean value\n         * - `date`: If the given value is a `Date` object\n         * - `function`: If the given value is a function reference\n         * - `object`: If the given value is an object\n         * - `array`: If the given value is an array\n         * - `regexp`: If the given value is a regular expression\n         * - `element`: If the given value is a DOM Element\n         * - `textnode`: If the given value is a DOM text node and contains something other than whitespace\n         * - `whitespace`: If the given value is a DOM text node and contains only whitespace\n         *\n         * @param {Object} value\n         * @return {String}\n         * @markdown\n         */\n        typeOf: function(value) {\n            var type,\n                typeToString;\n            \n            if (value === null) {\n                return 'null';\n            }\n\n            type = typeof value;\n\n            if (type === 'undefined' || type === 'string' || type === 'number' || type === 'boolean') {\n                return type;\n            }\n\n            typeToString = toString.call(value);\n\n            switch(typeToString) {\n                case '[object Array]':\n                    return 'array';\n                case '[object Date]':\n                    return 'date';\n                case '[object Boolean]':\n                    return 'boolean';\n                case '[object Number]':\n                    return 'number';\n                case '[object RegExp]':\n                    return 'regexp';\n            }\n\n            if (type === 'function') {\n                return 'function';\n            }\n\n            if (type === 'object') {\n                if (value.nodeType !== undefined) {\n                    if (value.nodeType === 3) {\n                        return (/\\S/).test(value.nodeValue) ? 'textnode' : 'whitespace';\n                    }\n                    else {\n                        return 'element';\n                    }\n                }\n\n                return 'object';\n            }\n\n            Ext.Error.raise({\n                sourceClass: 'Ext',\n                sourceMethod: 'typeOf',\n                msg: 'Failed to determine the type of the specified value \"' + value + '\". This is most likely a bug.'\n            });\n        },\n\n        /**\n         * Returns true if the passed value is empty, false otherwise. The value is deemed to be empty if it is either:\n         *\n         * - `null`\n         * - `undefined`\n         * - a zero-length array\n         * - a zero-length string (Unless the `allowEmptyString` parameter is set to `true`)\n         *\n         * @param {Object} value The value to test\n         * @param {Boolean} allowEmptyString (optional) true to allow empty strings (defaults to false)\n         * @return {Boolean}\n         * @markdown\n         */\n        isEmpty: function(value, allowEmptyString) {\n            return (value === null) || (value === undefined) || (!allowEmptyString ? value === '' : false) || (Ext.isArray(value) && value.length === 0);\n        },\n\n        /**\n         * Returns true if the passed value is a JavaScript Array, false otherwise.\n         *\n         * @param {Object} target The target to test\n         * @return {Boolean}\n         * @method\n         */\n        isArray: ('isArray' in Array) ? Array.isArray : function(value) {\n            return toString.call(value) === '[object Array]';\n        },\n\n        /**\n         * Returns true if the passed value is a JavaScript Date object, false otherwise.\n         * @param {Object} object The object to test\n         * @return {Boolean}\n         */\n        isDate: function(value) {\n            return toString.call(value) === '[object Date]';\n        },\n\n        /**\n         * Returns true if the passed value is a JavaScript Object, false otherwise.\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         * @method\n         */\n        isObject: (toString.call(null) === '[object Object]') ?\n        function(value) {\n            // check ownerDocument here as well to exclude DOM nodes\n            return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined;\n        } :\n        function(value) {\n            return toString.call(value) === '[object Object]';\n        },\n\n        /**\n         * @private\n         */\n        isSimpleObject: function(value) {\n            return value instanceof Object && value.constructor === Object;\n        },\n        /**\n         * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         */\n        isPrimitive: function(value) {\n            var type = typeof value;\n\n            return type === 'string' || type === 'number' || type === 'boolean';\n        },\n\n        /**\n         * Returns true if the passed value is a JavaScript Function, false otherwise.\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         * @method\n         */\n        isFunction:\n        // Safari 3.x and 4.x returns 'function' for typeof <NodeList>, hence we need to fall back to using\n        // Object.prototype.toString (slower)\n        (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') ? function(value) {\n            return toString.call(value) === '[object Function]';\n        } : function(value) {\n            return typeof value === 'function';\n        },\n\n        /**\n         * Returns true if the passed value is a number. Returns false for non-finite numbers.\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         */\n        isNumber: function(value) {\n            return typeof value === 'number' && isFinite(value);\n        },\n\n        /**\n         * Validates that a value is numeric.\n         * @param {Object} value Examples: 1, '1', '2.34'\n         * @return {Boolean} True if numeric, false otherwise\n         */\n        isNumeric: function(value) {\n            return !isNaN(parseFloat(value)) && isFinite(value);\n        },\n\n        /**\n         * Returns true if the passed value is a string.\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         */\n        isString: function(value) {\n            return typeof value === 'string';\n        },\n\n        /**\n         * Returns true if the passed value is a boolean.\n         *\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         */\n        isBoolean: function(value) {\n            return typeof value === 'boolean';\n        },\n\n        /**\n         * Returns true if the passed value is an HTMLElement\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         */\n        isElement: function(value) {\n            return value ? value.nodeType === 1 : false;\n        },\n\n        /**\n         * Returns true if the passed value is a TextNode\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         */\n        isTextNode: function(value) {\n            return value ? value.nodeName === \"#text\" : false;\n        },\n\n        /**\n         * Returns true if the passed value is defined.\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         */\n        isDefined: function(value) {\n            return typeof value !== 'undefined';\n        },\n\n        /**\n         * Returns true if the passed value is iterable, false otherwise\n         * @param {Object} value The value to test\n         * @return {Boolean}\n         */\n        isIterable: function(value) {\n            var type = typeof value,\n                checkLength = false;\n            if (value && type != 'string') {\n                // Functions have a length property, so we need to filter them out\n                if (type == 'function') {\n                    // In Safari, NodeList/HTMLCollection both return \"function\" when using typeof, so we need\n                    // to explicitly check them here.\n                    if (Ext.isSafari) {\n                        checkLength = value instanceof NodeList || value instanceof HTMLCollection;\n                    }\n                } else {\n                    checkLength = true;\n                }\n            }\n            return checkLength ? value.length !== undefined : false;\n        }\n    });\n\n    Ext.apply(Ext, {\n\n        /**\n         * Clone simple variables including array, {}-like objects, DOM nodes and Date without keeping the old reference.\n         * A reference for the object itself is returned if it's not a direct decendant of Object. For model cloning,\n         * see {@link Ext.data.Model#copy Model.copy}.\n         * \n         * @param {Object} item The variable to clone\n         * @return {Object} clone\n         */\n        clone: function(item) {\n            var type,\n                i,\n                j,\n                k,\n                clone,\n                key;\n            \n            if (item === null || item === undefined) {\n                return item;\n            }\n\n            // DOM nodes\n            // TODO proxy this to Ext.Element.clone to handle automatic id attribute changing\n            // recursively\n            if (item.nodeType && item.cloneNode) {\n                return item.cloneNode(true);\n            }\n\n            type = toString.call(item);\n\n            // Date\n            if (type === '[object Date]') {\n                return new Date(item.getTime());\n            }\n\n\n            // Array\n            if (type === '[object Array]') {\n                i = item.length;\n\n                clone = [];\n\n                while (i--) {\n                    clone[i] = Ext.clone(item[i]);\n                }\n            }\n            // Object\n            else if (type === '[object Object]' && item.constructor === Object) {\n                clone = {};\n\n                for (key in item) {\n                    clone[key] = Ext.clone(item[key]);\n                }\n\n                if (enumerables) {\n                    for (j = enumerables.length; j--;) {\n                        k = enumerables[j];\n                        clone[k] = item[k];\n                    }\n                }\n            }\n\n            return clone || item;\n        },\n\n        /**\n         * @private\n         * Generate a unique reference of Ext in the global scope, useful for sandboxing\n         */\n        getUniqueGlobalNamespace: function() {\n            var uniqueGlobalNamespace = this.uniqueGlobalNamespace,\n                i;\n\n            if (uniqueGlobalNamespace === undefined) {\n                i = 0;\n\n                do {\n                    uniqueGlobalNamespace = 'ExtBox' + (++i);\n                } while (Ext.global[uniqueGlobalNamespace] !== undefined);\n\n                Ext.global[uniqueGlobalNamespace] = Ext;\n                this.uniqueGlobalNamespace = uniqueGlobalNamespace;\n            }\n\n            return uniqueGlobalNamespace;\n        },\n        \n        /**\n         * @private\n         */\n        functionFactoryCache: {},\n        \n        cacheableFunctionFactory: function() {\n            var me = this,\n                args = Array.prototype.slice.call(arguments),\n                cache = me.functionFactoryCache,\n                idx, fn, ln;\n                \n             if (Ext.isSandboxed) {\n                ln = args.length;\n                if (ln > 0) {\n                    ln--;\n                    args[ln] = 'var Ext=window.' + Ext.name + ';' + args[ln];\n                }\n            }\n            idx = args.join('');\n            fn = cache[idx];\n            if (!fn) {\n                fn = Function.prototype.constructor.apply(Function.prototype, args);\n                \n                cache[idx] = fn;\n            }\n            return fn;\n        },\n        \n        functionFactory: function() {\n            var me = this,\n                args = Array.prototype.slice.call(arguments),\n                ln;\n                \n            if (Ext.isSandboxed) {\n                ln = args.length;\n                if (ln > 0) {\n                    ln--;\n                    args[ln] = 'var Ext=window.' + Ext.name + ';' + args[ln];\n                }\n            }\n     \n            return Function.prototype.constructor.apply(Function.prototype, args);\n        },\n\n        /**\n         * @private\n         * @property\n         */\n        Logger: {\n            verbose: emptyFn,\n            log: emptyFn,\n            info: emptyFn,\n            warn: emptyFn,\n            error: function(message) {\n                throw new Error(message);\n            },\n            deprecate: emptyFn\n        }\n    });\n\n    /**\n     * Old alias to {@link Ext#typeOf}\n     * @deprecated 4.0.0 Use {@link Ext#typeOf} instead\n     * @method\n     * @inheritdoc Ext#typeOf\n     */\n    Ext.type = Ext.typeOf;\n\n}());\n\n/*\n * This method evaluates the given code free of any local variable. In some browsers this\n * will be at global scope, in others it will be in a function.\n * @parma {String} code The code to evaluate.\n * @private\n * @method\n */\nExt.globalEval = Ext.global.execScript\n    ? function(code) {\n        execScript(code);\n    }\n    : function($$code) {\n        // IMPORTANT: because we use eval we cannot place this in the above function or it\n        // will break the compressor's ability to rename local variables...\n        (function(){\n            eval($$code);\n        }());\n    };\n\n//@tag foundation,core\n//@require ../Ext.js\n\n/**\n * @author Jacky Nguyen <jacky@sencha.com>\n * @docauthor Jacky Nguyen <jacky@sencha.com>\n * @class Ext.Version\n *\n * A utility class that wrap around a string version number and provide convenient\n * method to perform comparison. See also: {@link Ext.Version#compare compare}. Example:\n *\n *     var version = new Ext.Version('1.0.2beta');\n *     console.log(\"Version is \" + version); // Version is 1.0.2beta\n *\n *     console.log(version.getMajor()); // 1\n *     console.log(version.getMinor()); // 0\n *     console.log(version.getPatch()); // 2\n *     console.log(version.getBuild()); // 0\n *     console.log(version.getRelease()); // beta\n *\n *     console.log(version.isGreaterThan('1.0.1')); // True\n *     console.log(version.isGreaterThan('1.0.2alpha')); // True\n *     console.log(version.isGreaterThan('1.0.2RC')); // False\n *     console.log(version.isGreaterThan('1.0.2')); // False\n *     console.log(version.isLessThan('1.0.2')); // True\n *\n *     console.log(version.match(1.0)); // True\n *     console.log(version.match('1.0.2')); // True\n *\n */\n(function() {\n\n// Current core version\nvar version = '4.1.1.1', Version;\n    Ext.Version = Version = Ext.extend(Object, {\n\n        /**\n         * @param {String/Number} version The version number in the following standard format:\n         *\n         *     major[.minor[.patch[.build[release]]]]\n         *\n         * Examples:\n         *\n         *     1.0\n         *     1.2.3beta\n         *     1.2.3.4RC\n         *\n         * @return {Ext.Version} this\n         */\n        constructor: function(version) {\n            var parts, releaseStartIndex;\n\n            if (version instanceof Version) {\n                return version;\n            }\n\n            this.version = this.shortVersion = String(version).toLowerCase().replace(/_/g, '.').replace(/[\\-+]/g, '');\n\n            releaseStartIndex = this.version.search(/([^\\d\\.])/);\n\n            if (releaseStartIndex !== -1) {\n                this.release = this.version.substr(releaseStartIndex, version.length);\n                this.shortVersion = this.version.substr(0, releaseStartIndex);\n            }\n\n            this.shortVersion = this.shortVersion.replace(/[^\\d]/g, '');\n\n            parts = this.version.split('.');\n\n            this.major = parseInt(parts.shift() || 0, 10);\n            this.minor = parseInt(parts.shift() || 0, 10);\n            this.patch = parseInt(parts.shift() || 0, 10);\n            this.build = parseInt(parts.shift() || 0, 10);\n\n            return this;\n        },\n\n        /**\n         * Override the native toString method\n         * @private\n         * @return {String} version\n         */\n        toString: function() {\n            return this.version;\n        },\n\n        /**\n         * Override the native valueOf method\n         * @private\n         * @return {String} version\n         */\n        valueOf: function() {\n            return this.version;\n        },\n\n        /**\n         * Returns the major component value\n         * @return {Number} major\n         */\n        getMajor: function() {\n            return this.major || 0;\n        },\n\n        /**\n         * Returns the minor component value\n         * @return {Number} minor\n         */\n        getMinor: function() {\n            return this.minor || 0;\n        },\n\n        /**\n         * Returns the patch component value\n         * @return {Number} patch\n         */\n        getPatch: function() {\n            return this.patch || 0;\n        },\n\n        /**\n         * Returns the build component value\n         * @return {Number} build\n         */\n        getBuild: function() {\n            return this.build || 0;\n        },\n\n        /**\n         * Returns the release component value\n         * @return {Number} release\n         */\n        getRelease: function() {\n            return this.release || '';\n        },\n\n        /**\n         * Returns whether this version if greater than the supplied argument\n         * @param {String/Number} target The version to compare with\n         * @return {Boolean} True if this version if greater than the target, false otherwise\n         */\n        isGreaterThan: function(target) {\n            return Version.compare(this.version, target) === 1;\n        },\n\n        /**\n         * Returns whether this version if greater than or equal to the supplied argument\n         * @param {String/Number} target The version to compare with\n         * @return {Boolean} True if this version if greater than or equal to the target, false otherwise\n         */\n        isGreaterThanOrEqual: function(target) {\n            return Version.compare(this.version, target) >= 0;\n        },\n\n        /**\n         * Returns whether this version if smaller than the supplied argument\n         * @param {String/Number} target The version to compare with\n         * @return {Boolean} True if this version if smaller than the target, false otherwise\n         */\n        isLessThan: function(target) {\n            return Version.compare(this.version, target) === -1;\n        },\n\n        /**\n         * Returns whether this version if less than or equal to the supplied argument\n         * @param {String/Number} target The version to compare with\n         * @return {Boolean} True if this version if less than or equal to the target, false otherwise\n         */\n        isLessThanOrEqual: function(target) {\n            return Version.compare(this.version, target) <= 0;\n        },\n\n        /**\n         * Returns whether this version equals to the supplied argument\n         * @param {String/Number} target The version to compare with\n         * @return {Boolean} True if this version equals to the target, false otherwise\n         */\n        equals: function(target) {\n            return Version.compare(this.version, target) === 0;\n        },\n\n        /**\n         * Returns whether this version matches the supplied argument. Example:\n         *\n         *     var version = new Ext.Version('1.0.2beta');\n         *     console.log(version.match(1)); // True\n         *     console.log(version.match(1.0)); // True\n         *     console.log(version.match('1.0.2')); // True\n         *     console.log(version.match('1.0.2RC')); // False\n         *\n         * @param {String/Number} target The version to compare with\n         * @return {Boolean} True if this version matches the target, false otherwise\n         */\n        match: function(target) {\n            target = String(target);\n            return this.version.substr(0, target.length) === target;\n        },\n\n        /**\n         * Returns this format: [major, minor, patch, build, release]. Useful for comparison\n         * @return {Number[]}\n         */\n        toArray: function() {\n            return [this.getMajor(), this.getMinor(), this.getPatch(), this.getBuild(), this.getRelease()];\n        },\n\n        /**\n         * Returns shortVersion version without dots and release\n         * @return {String}\n         */\n        getShortVersion: function() {\n            return this.shortVersion;\n        },\n\n        /**\n         * Convenient alias to {@link Ext.Version#isGreaterThan isGreaterThan}\n         * @param {String/Number} target\n         * @return {Boolean}\n         */\n        gt: function() {\n            return this.isGreaterThan.apply(this, arguments);\n        },\n\n        /**\n         * Convenient alias to {@link Ext.Version#isLessThan isLessThan}\n         * @param {String/Number} target\n         * @return {Boolean}\n         */\n        lt: function() {\n            return this.isLessThan.apply(this, arguments);\n        },\n\n        /**\n         * Convenient alias to {@link Ext.Version#isGreaterThanOrEqual isGreaterThanOrEqual}\n         * @param {String/Number} target\n         * @return {Boolean}\n         */\n        gtEq: function() {\n            return this.isGreaterThanOrEqual.apply(this, arguments);\n        },\n\n        /**\n         * Convenient alias to {@link Ext.Version#isLessThanOrEqual isLessThanOrEqual}\n         * @param {String/Number} target\n         * @return {Boolean}\n         */\n        ltEq: function() {\n            return this.isLessThanOrEqual.apply(this, arguments);\n        }\n    });\n\n    Ext.apply(Version, {\n        // @private\n        releaseValueMap: {\n            'dev': -6,\n            'alpha': -5,\n            'a': -5,\n            'beta': -4,\n            'b': -4,\n            'rc': -3,\n            '#': -2,\n            'p': -1,\n            'pl': -1\n        },\n\n        /**\n         * Converts a version component to a comparable value\n         *\n         * @static\n         * @param {Object} value The value to convert\n         * @return {Object}\n         */\n        getComponentValue: function(value) {\n            return !value ? 0 : (isNaN(value) ? this.releaseValueMap[value] || value : parseInt(value, 10));\n        },\n\n        /**\n         * Compare 2 specified versions, starting from left to right. If a part contains special version strings,\n         * they are handled in the following order:\n         * 'dev' < 'alpha' = 'a' < 'beta' = 'b' < 'RC' = 'rc' < '#' < 'pl' = 'p' < 'anything else'\n         *\n         * @static\n         * @param {String} current The current version to compare to\n         * @param {String} target The target version to compare to\n         * @return {Number} Returns -1 if the current version is smaller than the target version, 1 if greater, and 0 if they're equivalent\n         */\n        compare: function(current, target) {\n            var currentValue, targetValue, i;\n\n            current = new Version(current).toArray();\n            target = new Version(target).toArray();\n\n            for (i = 0; i < Math.max(current.length, target.length); i++) {\n                currentValue = this.getComponentValue(current[i]);\n                targetValue = this.getComponentValue(target[i]);\n\n                if (currentValue < targetValue) {\n                    return -1;\n                } else if (currentValue > targetValue) {\n                    return 1;\n                }\n            }\n\n            return 0;\n        }\n    });\n\n    /**\n     * @class Ext\n     */\n    Ext.apply(Ext, {\n        /**\n         * @private\n         */\n        versions: {},\n\n        /**\n         * @private\n         */\n        lastRegisteredVersion: null,\n\n        /**\n         * Set version number for the given package name.\n         *\n         * @param {String} packageName The package name, for example: 'core', 'touch', 'extjs'\n         * @param {String/Ext.Version} version The version, for example: '1.2.3alpha', '2.4.0-dev'\n         * @return {Ext}\n         */\n        setVersion: function(packageName, version) {\n            Ext.versions[packageName] = new Version(version);\n            Ext.lastRegisteredVersion = Ext.versions[packageName];\n\n            return this;\n        },\n\n        /**\n         * Get the version number of the supplied package name; will return the last registered version\n         * (last Ext.setVersion call) if there's no package name given.\n         *\n         * @param {String} packageName (Optional) The package name, for example: 'core', 'touch', 'extjs'\n         * @return {Ext.Version} The version\n         */\n        getVersion: function(packageName) {\n            if (packageName === undefined) {\n                return Ext.lastRegisteredVersion;\n            }\n\n            return Ext.versions[packageName];\n        },\n\n        /**\n         * Create a closure for deprecated code.\n         *\n         *     // This means Ext.oldMethod is only supported in 4.0.0beta and older.\n         *     // If Ext.getVersion('extjs') returns a version that is later than '4.0.0beta', for example '4.0.0RC',\n         *     // the closure will not be invoked\n         *     Ext.deprecate('extjs', '4.0.0beta', function() {\n         *         Ext.oldMethod = Ext.newMethod;\n         *\n         *         ...\n         *     });\n         *\n         * @param {String} packageName The package name\n         * @param {String} since The last version before it's deprecated\n         * @param {Function} closure The callback function to be executed with the specified version is less than the current version\n         * @param {Object} scope The execution scope (`this`) if the closure\n         */\n        deprecate: function(packageName, since, closure, scope) {\n            if (Version.compare(Ext.getVersion(packageName), since) < 1) {\n                closure.call(scope);\n            }\n        }\n    }); // End Versioning\n\n    Ext.setVersion('core', version);\n\n}());\n\n//@tag foundation,core\n//@require ../version/Version.js\n\n/**\n * @class Ext.String\n *\n * A collection of useful static methods to deal with strings\n * @singleton\n */\n\nExt.String = (function() {\n    var trimRegex     = /^[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+|[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+$/g,\n        escapeRe      = /('|\\\\)/g,\n        formatRe      = /\\{(\\d+)\\}/g,\n        escapeRegexRe = /([-.*+?\\^${}()|\\[\\]\\/\\\\])/g,\n        basicTrimRe   = /^\\s+|\\s+$/g,\n        whitespaceRe  = /\\s+/,\n        varReplace    = /(^[^a-z]*|[^\\w])/gi,\n        charToEntity,\n        entityToChar,\n        charToEntityRegex,\n        entityToCharRegex,\n        htmlEncodeReplaceFn = function(match, capture) {\n            return charToEntity[capture];\n        },\n        htmlDecodeReplaceFn = function(match, capture) {\n            return (capture in entityToChar) ? entityToChar[capture] : String.fromCharCode(parseInt(capture.substr(2), 10));\n        };\n\n    return {\n\n        /**\n         * Converts a string of characters into a legal, parseable Javascript `var` name as long as the passed\n         * string contains at least one alphabetic character. Non alphanumeric characters, and *leading* non alphabetic\n         * characters will be removed.\n         * @param {String} s A string to be converted into a `var` name.\n         * @return {String} A legal Javascript `var` name.\n         */\n        createVarName: function(s) {\n            return s.replace(varReplace, '');\n        },\n\n        /**\n         * Convert certain characters (&, <, >, ', and \") to their HTML character equivalents for literal display in web pages.\n         * @param {String} value The string to encode\n         * @return {String} The encoded text\n         * @method\n         */\n        htmlEncode: function(value) {\n            return (!value) ? value : String(value).replace(charToEntityRegex, htmlEncodeReplaceFn);\n        },\n\n        /**\n         * Convert certain characters (&, <, >, ', and \") from their HTML character equivalents.\n         * @param {String} value The string to decode\n         * @return {String} The decoded text\n         * @method\n         */\n        htmlDecode: function(value) {\n            return (!value) ? value : String(value).replace(entityToCharRegex, htmlDecodeReplaceFn);\n        },\n\n        /**\n         * Adds a set of character entity definitions to the set used by\n         * {@link Ext.String#htmlEncode} and {@link Ext.String#htmlDecode}.\n         *\n         * This object should be keyed by the entity name sequence,\n         * with the value being the textual representation of the entity.\n         *\n         *      Ext.String.addCharacterEntities({\n         *          '&amp;Uuml;':'Ü',\n         *          '&amp;ccedil;':'ç',\n         *          '&amp;ntilde;':'ñ',\n         *          '&amp;egrave;':'è'\n         *      });\n         *      var s = Ext.String.htmlEncode(\"A string with entities: èÜçñ\");\n         *\n         * Note: the values of the character entites defined on this object are expected\n         * to be single character values.  As such, the actual values represented by the\n         * characters are sensitive to the character encoding of the javascript source\n         * file when defined in string literal form. Script tasgs referencing server\n         * resources with character entities must ensure that the 'charset' attribute\n         * of the script node is consistent with the actual character encoding of the\n         * server resource.\n         *\n         * The set of character entities may be reset back to the default state by using\n         * the {@link Ext.String#resetCharacterEntities} method\n         *\n         * @param {Object} entities The set of character entities to add to the current\n         * definitions.\n         */\n        addCharacterEntities: function(newEntities) {\n            var charKeys = [],\n                entityKeys = [],\n                key, echar;\n            for (key in newEntities) {\n                echar = newEntities[key];\n                entityToChar[key] = echar;\n                charToEntity[echar] = key;\n                charKeys.push(echar);\n                entityKeys.push(key);\n            }\n            charToEntityRegex = new RegExp('(' + charKeys.join('|') + ')', 'g');\n            entityToCharRegex = new RegExp('(' + entityKeys.join('|') + '|&#[0-9]{1,5};' + ')', 'g');\n        },\n\n        /**\n         * Resets the set of character entity definitions used by\n         * {@link Ext.String#htmlEncode} and {@link Ext.String#htmlDecode} back to the\n         * default state.\n         */\n        resetCharacterEntities: function() {\n            charToEntity = {};\n            entityToChar = {};\n            // add the default set\n            this.addCharacterEntities({\n                '&amp;'     :   '&',\n                '&gt;'      :   '>',\n                '&lt;'      :   '<',\n                '&quot;'    :   '\"',\n                '&#39;'     :   \"'\"\n            });\n        },\n\n        /**\n         * Appends content to the query string of a URL, handling logic for whether to place\n         * a question mark or ampersand.\n         * @param {String} url The URL to append to.\n         * @param {String} string The content to append to the URL.\n         * @return {String} The resulting URL\n         */\n        urlAppend : function(url, string) {\n            if (!Ext.isEmpty(string)) {\n                return url + (url.indexOf('?') === -1 ? '?' : '&') + string;\n            }\n\n            return url;\n        },\n\n        /**\n         * Trims whitespace from either end of a string, leaving spaces within the string intact.  Example:\n         * @example\n    var s = '  foo bar  ';\n    alert('-' + s + '-');         //alerts \"- foo bar -\"\n    alert('-' + Ext.String.trim(s) + '-');  //alerts \"-foo bar-\"\n\n         * @param {String} string The string to escape\n         * @return {String} The trimmed string\n         */\n        trim: function(string) {\n            return string.replace(trimRegex, \"\");\n        },\n\n        /**\n         * Capitalize the given string\n         * @param {String} string\n         * @return {String}\n         */\n        capitalize: function(string) {\n            return string.charAt(0).toUpperCase() + string.substr(1);\n        },\n\n        /**\n         * Uncapitalize the given string\n         * @param {String} string\n         * @return {String}\n         */\n        uncapitalize: function(string) {\n            return string.charAt(0).toLowerCase() + string.substr(1);\n        },\n\n        /**\n         * Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length\n         * @param {String} value The string to truncate\n         * @param {Number} length The maximum length to allow before truncating\n         * @param {Boolean} word True to try to find a common word break\n         * @return {String} The converted text\n         */\n        ellipsis: function(value, len, word) {\n            if (value && value.length > len) {\n                if (word) {\n                    var vs = value.substr(0, len - 2),\n                    index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));\n                    if (index !== -1 && index >= (len - 15)) {\n                        return vs.substr(0, index) + \"...\";\n                    }\n                }\n                return value.substr(0, len - 3) + \"...\";\n            }\n            return value;\n        },\n\n        /**\n         * Escapes the passed string for use in a regular expression\n         * @param {String} string\n         * @return {String}\n         */\n        escapeRegex: function(string) {\n            return string.replace(escapeRegexRe, \"\\\\$1\");\n        },\n\n        /**\n         * Escapes the passed string for ' and \\\n         * @param {String} string The string to escape\n         * @return {String} The escaped string\n         */\n        escape: function(string) {\n            return string.replace(escapeRe, \"\\\\$1\");\n        },\n\n        /**\n         * Utility function that allows you to easily switch a string between two alternating values.  The passed value\n         * is compared to the current string, and if they are equal, the other value that was passed in is returned.  If\n         * they are already different, the first value passed in is returned.  Note that this method returns the new value\n         * but does not change the current string.\n         * <pre><code>\n        // alternate sort directions\n        sort = Ext.String.toggle(sort, 'ASC', 'DESC');\n\n        // instead of conditional logic:\n        sort = (sort == 'ASC' ? 'DESC' : 'ASC');\n           </code></pre>\n         * @param {String} string The current string\n         * @param {String} value The value to compare to the current string\n         * @param {String} other The new value to use if the string already equals the first value passed in\n         * @return {String} The new value\n         */\n        toggle: function(string, value, other) {\n            return string === value ? other : value;\n        },\n\n        /**\n         * Pads the left side of a string with a specified character.  This is especially useful\n         * for normalizing number and date strings.  Example usage:\n         *\n         * <pre><code>\n    var s = Ext.String.leftPad('123', 5, '0');\n    // s now contains the string: '00123'\n           </code></pre>\n         * @param {String} string The original string\n         * @param {Number} size The total length of the output string\n         * @param {String} character (optional) The character with which to pad the original string (defaults to empty string \" \")\n         * @return {String} The padded string\n         */\n        leftPad: function(string, size, character) {\n            var result = String(string);\n            character = character || \" \";\n            while (result.length < size) {\n                result = character + result;\n            }\n            return result;\n        },\n\n        /**\n         * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.  Each\n         * token must be unique, and must increment in the format {0}, {1}, etc.  Example usage:\n         * <pre><code>\n    var cls = 'my-class', text = 'Some text';\n    var s = Ext.String.format('&lt;div class=\"{0}\">{1}&lt;/div>', cls, text);\n    // s now contains the string: '&lt;div class=\"my-class\">Some text&lt;/div>'\n           </code></pre>\n         * @param {String} string The tokenized string to be formatted\n         * @param {String} value1 The value to replace token {0}\n         * @param {String} value2 Etc...\n         * @return {String} The formatted string\n         */\n        format: function(format) {\n            var args = Ext.Array.toArray(arguments, 1);\n            return format.replace(formatRe, function(m, i) {\n                return args[i];\n            });\n        },\n\n        /**\n         * Returns a string with a specified number of repititions a given string pattern.\n         * The pattern be separated by a different string.\n         *\n         *      var s = Ext.String.repeat('---', 4); // = '------------'\n         *      var t = Ext.String.repeat('--', 3, '/'); // = '--/--/--'\n         *\n         * @param {String} pattern The pattern to repeat.\n         * @param {Number} count The number of times to repeat the pattern (may be 0).\n         * @param {String} sep An option string to separate each pattern.\n         */\n        repeat: function(pattern, count, sep) {\n            for (var buf = [], i = count; i--; ) {\n                buf.push(pattern);\n            }\n            return buf.join(sep || '');\n        },\n\n        /**\n         * Splits a string of space separated words into an array, trimming as needed. If the\n         * words are already an array, it is returned.\n         *\n         * @param {String/Array} words\n         */\n        splitWords: function (words) {\n            if (words && typeof words == 'string') {\n                return words.replace(basicTrimRe, '').split(whitespaceRe);\n            }\n            return words || [];\n        }\n    };\n}());\n\n// initialize the default encode / decode entities\nExt.String.resetCharacterEntities();\n\n/**\n * Old alias to {@link Ext.String#htmlEncode}\n * @deprecated Use {@link Ext.String#htmlEncode} instead\n * @method\n * @member Ext\n * @inheritdoc Ext.String#htmlEncode\n */\nExt.htmlEncode = Ext.String.htmlEncode;\n\n\n/**\n * Old alias to {@link Ext.String#htmlDecode}\n * @deprecated Use {@link Ext.String#htmlDecode} instead\n * @method\n * @member Ext\n * @inheritdoc Ext.String#htmlDecode\n */\nExt.htmlDecode = Ext.String.htmlDecode;\n\n/**\n * Old alias to {@link Ext.String#urlAppend}\n * @deprecated Use {@link Ext.String#urlAppend} instead\n * @method\n * @member Ext\n * @inheritdoc Ext.String#urlAppend\n */\nExt.urlAppend = Ext.String.urlAppend;\n\n//@tag foundation,core\n//@require String.js\n//@define Ext.Number\n\n/**\n * @class Ext.Number\n *\n * A collection of useful static methods to deal with numbers\n * @singleton\n */\n\nExt.Number = new function() {\n\n    var me = this,\n        isToFixedBroken = (0.9).toFixed() !== '1',\n        math = Math;\n\n    Ext.apply(this, {\n        /**\n         * Checks whether or not the passed number is within a desired range.  If the number is already within the\n         * range it is returned, otherwise the min or max value is returned depending on which side of the range is\n         * exceeded. Note that this method returns the constrained value but does not change the current number.\n         * @param {Number} number The number to check\n         * @param {Number} min The minimum number in the range\n         * @param {Number} max The maximum number in the range\n         * @return {Number} The constrained value if outside the range, otherwise the current value\n         */\n        constrain: function(number, min, max) {\n            var x = parseFloat(number);\n\n            // Watch out for NaN in Chrome 18\n            // V8bug: http://code.google.com/p/v8/issues/detail?id=2056\n\n            // Operators are faster than Math.min/max. See http://jsperf.com/number-constrain\n            // ... and (x < Nan) || (x < undefined) == false\n            // ... same for (x > NaN) || (x > undefined)\n            // so if min or max are undefined or NaN, we never return them... sadly, this\n            // is not true of null (but even Math.max(-1,null)==0 and isNaN(null)==false)\n            return (x < min) ? min : ((x > max) ? max : x);\n        },\n\n        /**\n         * Snaps the passed number between stopping points based upon a passed increment value.\n         *\n         * The difference between this and {@link #snapInRange} is that {@link #snapInRange} uses the minValue\n         * when calculating snap points:\n         *\n         *     r = Ext.Number.snap(56, 2, 55, 65);        // Returns 56 - snap points are zero based\n         *\n         *     r = Ext.Number.snapInRange(56, 2, 55, 65); // Returns 57 - snap points are based from minValue\n         *\n         * @param {Number} value The unsnapped value.\n         * @param {Number} increment The increment by which the value must move.\n         * @param {Number} minValue The minimum value to which the returned value must be constrained. Overrides the increment.\n         * @param {Number} maxValue The maximum value to which the returned value must be constrained. Overrides the increment.\n         * @return {Number} The value of the nearest snap target.\n         */\n        snap : function(value, increment, minValue, maxValue) {\n            var m;\n\n            // If no value passed, or minValue was passed and value is less than minValue (anything < undefined is false)\n            // Then use the minValue (or zero if the value was undefined)\n            if (value === undefined || value < minValue) {\n                return minValue || 0;\n            }\n\n            if (increment) {\n                m = value % increment;\n                if (m !== 0) {\n                    value -= m;\n                    if (m * 2 >= increment) {\n                        value += increment;\n                    } else if (m * 2 < -increment) {\n                        value -= increment;\n                    }\n                }\n            }\n            return me.constrain(value, minValue,  maxValue);\n        },\n\n        /**\n         * Snaps the passed number between stopping points based upon a passed increment value.\n         *\n         * The difference between this and {@link #snap} is that {@link #snap} does not use the minValue\n         * when calculating snap points:\n         *\n         *     r = Ext.Number.snap(56, 2, 55, 65);        // Returns 56 - snap points are zero based\n         *\n         *     r = Ext.Number.snapInRange(56, 2, 55, 65); // Returns 57 - snap points are based from minValue\n         *\n         * @param {Number} value The unsnapped value.\n         * @param {Number} increment The increment by which the value must move.\n         * @param {Number} [minValue=0] The minimum value to which the returned value must be constrained.\n         * @param {Number} [maxValue=Infinity] The maximum value to which the returned value must be constrained.\n         * @return {Number} The value of the nearest snap target.\n         */\n        snapInRange : function(value, increment, minValue, maxValue) {\n            var tween;\n\n            // default minValue to zero\n            minValue = (minValue || 0);\n\n            // If value is undefined, or less than minValue, use minValue\n            if (value === undefined || value < minValue) {\n                return minValue;\n            }\n\n            // Calculate how many snap points from the minValue the passed value is.\n            if (increment && (tween = ((value - minValue) % increment))) {\n                value -= tween;\n                tween *= 2;\n                if (tween >= increment) {\n                    value += increment;\n                }\n            }\n\n            // If constraining within a maximum, ensure the maximum is on a snap point\n            if (maxValue !== undefined) {\n                if (value > (maxValue = me.snapInRange(maxValue, increment, minValue))) {\n                    value = maxValue;\n                }\n            }\n\n            return value;\n        },\n\n        /**\n         * Formats a number using fixed-point notation\n         * @param {Number} value The number to format\n         * @param {Number} precision The number of digits to show after the decimal point\n         */\n        toFixed: isToFixedBroken ? function(value, precision) {\n            precision = precision || 0;\n            var pow = math.pow(10, precision);\n            return (math.round(value * pow) / pow).toFixed(precision);\n        } : function(value, precision) {\n            return value.toFixed(precision);\n        },\n\n        /**\n         * Validate that a value is numeric and convert it to a number if necessary. Returns the specified default value if\n         * it is not.\n\n    Ext.Number.from('1.23', 1); // returns 1.23\n    Ext.Number.from('abc', 1); // returns 1\n\n         * @param {Object} value\n         * @param {Number} defaultValue The value to return if the original value is non-numeric\n         * @return {Number} value, if numeric, defaultValue otherwise\n         */\n        from: function(value, defaultValue) {\n            if (isFinite(value)) {\n                value = parseFloat(value);\n            }\n\n            return !isNaN(value) ? value : defaultValue;\n        },\n\n        /**\n         * Returns a random integer between the specified range (inclusive)\n         * @param {Number} from Lowest value to return.\n         * @param {Number} to Highst value to return.\n         * @return {Number} A random integer within the specified range.\n         */\n        randomInt: function (from, to) {\n           return math.floor(math.random() * (to - from + 1) + from);\n        }\n    });\n\n    /**\n     * @deprecated 4.0.0 Please use {@link Ext.Number#from} instead.\n     * @member Ext\n     * @method num\n     * @inheritdoc Ext.Number#from\n     */\n    Ext.num = function() {\n        return me.from.apply(this, arguments);\n    };\n};\n\n//@tag foundation,core\n//@require Number.js\n\n/**\n * @class Ext.Array\n * @singleton\n * @author Jacky Nguyen <jacky@sencha.com>\n * @docauthor Jacky Nguyen <jacky@sencha.com>\n *\n * A set of useful static methods to deal with arrays; provide missing methods for older browsers.\n */\n(function() {\n\n    var arrayPrototype = Array.prototype,\n        slice = arrayPrototype.slice,\n        supportsSplice = (function () {\n            var array = [],\n                lengthBefore,\n                j = 20;\n\n            if (!array.splice) {\n                return false;\n            }\n\n            // This detects a bug in IE8 splice method:\n            // see http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/6e946d03-e09f-4b22-a4dd-cd5e276bf05a/\n\n            while (j--) {\n                array.push(\"A\");\n            }\n\n            array.splice(15, 0, \"F\", \"F\", \"F\", \"F\", \"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\",\"F\");\n\n            lengthBefore = array.length; //41\n            array.splice(13, 0, \"XXX\"); // add one element\n\n            if (lengthBefore+1 != array.length) {\n                return false;\n            }\n            // end IE8 bug\n\n            return true;\n        }()),\n        supportsForEach = 'forEach' in arrayPrototype,\n        supportsMap = 'map' in arrayPrototype,\n        supportsIndexOf = 'indexOf' in arrayPrototype,\n        supportsEvery = 'every' in arrayPrototype,\n        supportsSome = 'some' in arrayPrototype,\n        supportsFilter = 'filter' in arrayPrototype,\n        supportsSort = (function() {\n            var a = [1,2,3,4,5].sort(function(){ return 0; });\n            return a[0] === 1 && a[1] === 2 && a[2] === 3 && a[3] === 4 && a[4] === 5;\n        }()),\n        supportsSliceOnNodeList = true,\n        ExtArray,\n        erase,\n        replace,\n        splice;\n\n    try {\n        // IE 6 - 8 will throw an error when using Array.prototype.slice on NodeList\n        if (typeof document !== 'undefined') {\n            slice.call(document.getElementsByTagName('body'));\n        }\n    } catch (e) {\n        supportsSliceOnNodeList = false;\n    }\n\n    function fixArrayIndex (array, index) {\n        return (index < 0) ? Math.max(0, array.length + index)\n                           : Math.min(array.length, index);\n    }\n\n    /*\n    Does the same work as splice, but with a slightly more convenient signature. The splice\n    method has bugs in IE8, so this is the implementation we use on that platform.\n\n    The rippling of items in the array can be tricky. Consider two use cases:\n\n                  index=2\n                  removeCount=2\n                 /=====\\\n        +---+---+---+---+---+---+---+---+\n        | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |\n        +---+---+---+---+---+---+---+---+\n                         /  \\/  \\/  \\/  \\\n                        /   /\\  /\\  /\\   \\\n                       /   /  \\/  \\/  \\   +--------------------------+\n                      /   /   /\\  /\\   +--------------------------+   \\\n                     /   /   /  \\/  +--------------------------+   \\   \\\n                    /   /   /   /+--------------------------+   \\   \\   \\\n                   /   /   /   /                             \\   \\   \\   \\\n                  v   v   v   v                               v   v   v   v\n        +---+---+---+---+---+---+       +---+---+---+---+---+---+---+---+---+\n        | 0 | 1 | 4 | 5 | 6 | 7 |       | 0 | 1 | a | b | c | 4 | 5 | 6 | 7 |\n        +---+---+---+---+---+---+       +---+---+---+---+---+---+---+---+---+\n        A                               B        \\=========/\n                                                 insert=[a,b,c]\n\n    In case A, it is obvious that copying of [4,5,6,7] must be left-to-right so\n    that we don't end up with [0,1,6,7,6,7]. In case B, we have the opposite; we\n    must go right-to-left or else we would end up with [0,1,a,b,c,4,4,4,4].\n    */\n    function replaceSim (array, index, removeCount, insert) {\n        var add = insert ? insert.length : 0,\n            length = array.length,\n            pos = fixArrayIndex(array, index),\n            remove,\n            tailOldPos,\n            tailNewPos,\n            tailCount,\n            lengthAfterRemove,\n            i;\n\n        // we try to use Array.push when we can for efficiency...\n        if (pos === length) {\n            if (add) {\n                array.push.apply(array, insert);\n            }\n        } else {\n            remove = Math.min(removeCount, length - pos);\n            tailOldPos = pos + remove;\n            tailNewPos = tailOldPos + add - remove;\n            tailCount = length - tailOldPos;\n            lengthAfterRemove = length - remove;\n\n            if (tailNewPos < tailOldPos) { // case A\n                for (i = 0; i < tailCount; ++i) {\n                    array[tailNewPos+i] = array[tailOldPos+i];\n                }\n            } else if (tailNewPos > tailOldPos) { // case B\n                for (i = tailCount; i--; ) {\n                    array[tailNewPos+i] = array[tailOldPos+i];\n                }\n            } // else, add == remove (nothing to do)\n\n            if (add && pos === lengthAfterRemove) {\n                array.length = lengthAfterRemove; // truncate array\n                array.push.apply(array, insert);\n            } else {\n                array.length = lengthAfterRemove + add; // reserves space\n                for (i = 0; i < add; ++i) {\n                    array[pos+i] = insert[i];\n                }\n            }\n        }\n\n        return array;\n    }\n\n    function replaceNative (array, index, removeCount, insert) {\n        if (insert && insert.length) {\n            if (index < array.length) {\n                array.splice.apply(array, [index, removeCount].concat(insert));\n            } else {\n                array.push.apply(array, insert);\n            }\n        } else {\n            array.splice(index, removeCount);\n        }\n        return array;\n    }\n\n    function eraseSim (array, index, removeCount) {\n        return replaceSim(array, index, removeCount);\n    }\n\n    function eraseNative (array, index, removeCount) {\n        array.splice(index, removeCount);\n        return array;\n    }\n\n    function spliceSim (array, index, removeCount) {\n        var pos = fixArrayIndex(array, index),\n            removed = array.slice(index, fixArrayIndex(array, pos+removeCount));\n\n        if (arguments.length < 4) {\n            replaceSim(array, pos, removeCount);\n        } else {\n            replaceSim(array, pos, removeCount, slice.call(arguments, 3));\n        }\n\n        return removed;\n    }\n\n    function spliceNative (array) {\n        return array.splice.apply(array, slice.call(arguments, 1));\n    }\n\n    erase = supportsSplice ? eraseNative : eraseSim;\n    replace = supportsSplice ? replaceNative : replaceSim;\n    splice = supportsSplice ? spliceNative : spliceSim;\n\n    // NOTE: from here on, use erase, replace or splice (not native methods)...\n\n    ExtArray = Ext.Array = {\n        /**\n         * Iterates an array or an iterable value and invoke the given callback function for each item.\n         *\n         *     var countries = ['Vietnam', 'Singapore', 'United States', 'Russia'];\n         *\n         *     Ext.Array.each(countries, function(name, index, countriesItSelf) {\n         *         console.log(name);\n         *     });\n         *\n         *     var sum = function() {\n         *         var sum = 0;\n         *\n         *         Ext.Array.each(arguments, function(value) {\n         *             sum += value;\n         *         });\n         *\n         *         return sum;\n         *     };\n         *\n         *     sum(1, 2, 3); // returns 6\n         *\n         * The iteration can be stopped by returning false in the function callback.\n         *\n         *     Ext.Array.each(countries, function(name, index, countriesItSelf) {\n         *         if (name === 'Singapore') {\n         *             return false; // break here\n         *         }\n         *     });\n         *\n         * {@link Ext#each Ext.each} is alias for {@link Ext.Array#each Ext.Array.each}\n         *\n         * @param {Array/NodeList/Object} iterable The value to be iterated. If this\n         * argument is not iterable, the callback function is called once.\n         * @param {Function} fn The callback function. If it returns false, the iteration stops and this method returns\n         * the current `index`.\n         * @param {Object} fn.item The item at the current `index` in the passed `array`\n         * @param {Number} fn.index The current `index` within the `array`\n         * @param {Array} fn.allItems The `array` itself which was passed as the first argument\n         * @param {Boolean} fn.return Return false to stop iteration.\n         * @param {Object} scope (Optional) The scope (`this` reference) in which the specified function is executed.\n         * @param {Boolean} reverse (Optional) Reverse the iteration order (loop from the end to the beginning)\n         * Defaults false\n         * @return {Boolean} See description for the `fn` parameter.\n         */\n        each: function(array, fn, scope, reverse) {\n            array = ExtArray.from(array);\n\n            var i,\n                ln = array.length;\n\n            if (reverse !== true) {\n                for (i = 0; i < ln; i++) {\n                    if (fn.call(scope || array[i], array[i], i, array) === false) {\n                        return i;\n                    }\n                }\n            }\n            else {\n                for (i = ln - 1; i > -1; i--) {\n                    if (fn.call(scope || array[i], array[i], i, array) === false) {\n                        return i;\n                    }\n                }\n            }\n\n            return true;\n        },\n\n        /**\n         * Iterates an array and invoke the given callback function for each item. Note that this will simply\n         * delegate to the native Array.prototype.forEach method if supported. It doesn't support stopping the\n         * iteration by returning false in the callback function like {@link Ext.Array#each}. However, performance\n         * could be much better in modern browsers comparing with {@link Ext.Array#each}\n         *\n         * @param {Array} array The array to iterate\n         * @param {Function} fn The callback function.\n         * @param {Object} fn.item The item at the current `index` in the passed `array`\n         * @param {Number} fn.index The current `index` within the `array`\n         * @param {Array}  fn.allItems The `array` itself which was passed as the first argument\n         * @param {Object} scope (Optional) The execution scope (`this`) in which the specified function is executed.\n         */\n        forEach: supportsForEach ? function(array, fn, scope) {\n            return array.forEach(fn, scope);\n        } : function(array, fn, scope) {\n            var i = 0,\n                ln = array.length;\n\n            for (; i < ln; i++) {\n                fn.call(scope, array[i], i, array);\n            }\n        },\n\n        /**\n         * Get the index of the provided `item` in the given `array`, a supplement for the\n         * missing arrayPrototype.indexOf in Internet Explorer.\n         *\n         * @param {Array} array The array to check\n         * @param {Object} item The item to look for\n         * @param {Number} from (Optional) The index at which to begin the search\n         * @return {Number} The index of item in the array (or -1 if it is not found)\n         */\n        indexOf: supportsIndexOf ? function(array, item, from) {\n            return array.indexOf(item, from);\n         } : function(array, item, from) {\n            var i, length = array.length;\n\n            for (i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++) {\n                if (array[i] === item) {\n                    return i;\n                }\n            }\n\n            return -1;\n        },\n\n        /**\n         * Checks whether or not the given `array` contains the specified `item`\n         *\n         * @param {Array} array The array to check\n         * @param {Object} item The item to look for\n         * @return {Boolean} True if the array contains the item, false otherwise\n         */\n        contains: supportsIndexOf ? function(array, item) {\n            return array.indexOf(item) !== -1;\n        } : function(array, item) {\n            var i, ln;\n\n            for (i = 0, ln = array.length; i < ln; i++) {\n                if (array[i] === item) {\n                    return true;\n                }\n            }\n\n            return false;\n        },\n\n        /**\n         * Converts any iterable (numeric indices and a length property) into a true array.\n         *\n         *     function test() {\n         *         var args = Ext.Array.toArray(arguments),\n         *             fromSecondToLastArgs = Ext.Array.toArray(arguments, 1);\n         *\n         *         alert(args.join(' '));\n         *         alert(fromSecondToLastArgs.join(' '));\n         *     }\n         *\n         *     test('just', 'testing', 'here'); // alerts 'just testing here';\n         *                                      // alerts 'testing here';\n         *\n         *     Ext.Array.toArray(document.getElementsByTagName('div')); // will convert the NodeList into an array\n         *     Ext.Array.toArray('splitted'); // returns ['s', 'p', 'l', 'i', 't', 't', 'e', 'd']\n         *     Ext.Array.toArray('splitted', 0, 3); // returns ['s', 'p', 'l']\n         *\n         * {@link Ext#toArray Ext.toArray} is alias for {@link Ext.Array#toArray Ext.Array.toArray}\n         *\n         * @param {Object} iterable the iterable object to be turned into a true Array.\n         * @param {Number} start (Optional) a zero-based index that specifies the start of extraction. Defaults to 0\n         * @param {Number} end (Optional) a 1-based index that specifies the end of extraction. Defaults to the last\n         * index of the iterable value\n         * @return {Array} array\n         */\n        toArray: function(iterable, start, end){\n            if (!iterable || !iterable.length) {\n                return [];\n            }\n\n            if (typeof iterable === 'string') {\n                iterable = iterable.split('');\n            }\n\n            if (supportsSliceOnNodeList) {\n                return slice.call(iterable, start || 0, end || iterable.length);\n            }\n\n            var array = [],\n                i;\n\n            start = start || 0;\n            end = end ? ((end < 0) ? iterable.length + end : end) : iterable.length;\n\n            for (i = start; i < end; i++) {\n                array.push(iterable[i]);\n            }\n\n            return array;\n        },\n\n        /**\n         * Plucks the value of a property from each item in the Array. Example:\n         *\n         *     Ext.Array.pluck(Ext.query(\"p\"), \"className\"); // [el1.className, el2.className, ..., elN.className]\n         *\n         * @param {Array/NodeList} array The Array of items to pluck the value from.\n         * @param {String} propertyName The property name to pluck from each element.\n         * @return {Array} The value from each item in the Array.\n         */\n        pluck: function(array, propertyName) {\n            var ret = [],\n                i, ln, item;\n\n            for (i = 0, ln = array.length; i < ln; i++) {\n                item = array[i];\n\n                ret.push(item[propertyName]);\n            }\n\n            return ret;\n        },\n\n        /**\n         * Creates a new array with the results of calling a provided function on every element in this array.\n         *\n         * @param {Array} array\n         * @param {Function} fn Callback function for each item\n         * @param {Object} scope Callback function scope\n         * @return {Array} results\n         */\n        map: supportsMap ? function(array, fn, scope) {\n            if (!fn) {\n                Ext.Error.raise('Ext.Array.map must have a callback function passed as second argument.');\n            }\n            return array.map(fn, scope);\n        } : function(array, fn, scope) {\n            if (!fn) {\n                Ext.Error.raise('Ext.Array.map must have a callback function passed as second argument.');\n            }\n            var results = [],\n                i = 0,\n                len = array.length;\n\n            for (; i < len; i++) {\n                results[i] = fn.call(scope, array[i], i, array);\n            }\n\n            return results;\n        },\n\n        /**\n         * Executes the specified function for each array element until the function returns a falsy value.\n         * If such an item is found, the function will return false immediately.\n         * Otherwise, it will return true.\n         *\n         * @param {Array} array\n         * @param {Function} fn Callback function for each item\n         * @param {Object} scope Callback function scope\n         * @return {Boolean} True if no false value is returned by the callback function.\n         */\n        every: supportsEvery ? function(array, fn, scope) {\n            if (!fn) {\n                Ext.Error.raise('Ext.Array.every must have a callback function passed as second argument.');\n            }\n            return array.every(fn, scope);\n        } : function(array, fn, scope) {\n            if (!fn) {\n                Ext.Error.raise('Ext.Array.every must have a callback function passed as second argument.');\n            }\n            var i = 0,\n                ln = array.length;\n\n            for (; i < ln; ++i) {\n                if (!fn.call(scope, array[i], i, array)) {\n                    return false;\n                }\n            }\n\n            return true;\n        },\n\n        /**\n         * Executes the specified function for each array element until the function returns a truthy value.\n         * If such an item is found, the function will return true immediately. Otherwise, it will return false.\n         *\n         * @param {Array} array\n         * @param {Function} fn Callback function for each item\n         * @param {Object} scope Callback function scope\n         * @return {Boolean} True if the callback function returns a truthy value.\n         */\n        some: supportsSome ? function(array, fn, scope) {\n            if (!fn) {\n                Ext.Error.raise('Ext.Array.some must have a callback function passed as second argument.');\n            }\n            return array.some(fn, scope);\n        } : function(array, fn, scope) {\n            if (!fn) {\n                Ext.Error.raise('Ext.Array.some must have a callback function passed as second argument.');\n            }\n            var i = 0,\n                ln = array.length;\n\n            for (; i < ln; ++i) {\n                if (fn.call(scope, array[i], i, array)) {\n                    return true;\n                }\n            }\n\n            return false;\n        },\n\n        /**\n         * Filter through an array and remove empty item as defined in {@link Ext#isEmpty Ext.isEmpty}\n         *\n         * See {@link Ext.Array#filter}\n         *\n         * @param {Array} array\n         * @return {Array} results\n         */\n        clean: function(array) {\n            var results = [],\n                i = 0,\n                ln = array.length,\n                item;\n\n            for (; i < ln; i++) {\n                item = array[i];\n\n                if (!Ext.isEmpty(item)) {\n                    results.push(item);\n                }\n            }\n\n            return results;\n        },\n\n        /**\n         * Returns a new array with unique items\n         *\n         * @param {Array} array\n         * @return {Array} results\n         */\n        unique: function(array) {\n            var clone = [],\n                i = 0,\n                ln = array.length,\n                item;\n\n            for (; i < ln; i++) {\n                item = array[i];\n\n                if (ExtArray.indexOf(clone, item) === -1) {\n                    clone.push(item);\n                }\n            }\n\n            return clone;\n        },\n\n        /**\n         * Creates a new array with all of the elements of this array for which\n         * the provided filtering function returns true.\n         *\n         * @param {Array} array\n         * @param {Function} fn Callback function for each item\n         * @param {Object} scope Callback function scope\n         * @return {Array} results\n         */\n        filter: supportsFilter ? function(array, fn, scope) {\n            if (!fn) {\n                Ext.Error.raise('Ext.Array.filter must have a callback function passed as second argument.');\n            }\n            return array.filter(fn, scope);\n        } : function(array, fn, scope) {\n            if (!fn) {\n                Ext.Error.raise('Ext.Array.filter must have a callback function passed as second argument.');\n            }\n            var results = [],\n                i = 0,\n                ln = array.length;\n\n            for (; i < ln; i++) {\n                if (fn.call(scope, array[i], i, array)) {\n                    results.push(array[i]);\n                }\n            }\n\n            return results;\n        },\n\n        /**\n         * Converts a value to an array if it's not already an array; returns:\n         *\n         * - An empty array if given value is `undefined` or `null`\n         * - Itself if given value is already an array\n         * - An array copy if given value is {@link Ext#isIterable iterable} (arguments, NodeList and alike)\n         * - An array with one item which is the given value, otherwise\n         *\n         * @param {Object} value The value to convert to an array if it's not already is an array\n         * @param {Boolean} newReference (Optional) True to clone the given array and return a new reference if necessary,\n         * defaults to false\n         * @return {Array} array\n         */\n        from: function(value, newReference) {\n            if (value === undefined || value === null) {\n                return [];\n            }\n\n            if (Ext.isArray(value)) {\n                return (newReference) ? slice.call(value) : value;\n            }\n\n            var type = typeof value;\n            // Both strings and functions will have a length property. In phantomJS, NodeList\n            // instances report typeof=='function' but don't have an apply method...\n            if (value && value.length !== undefined && type !== 'string' && (type !== 'function' || !value.apply)) {\n                return ExtArray.toArray(value);\n            }\n\n            return [value];\n        },\n\n        /**\n         * Removes the specified item from the array if it exists\n         *\n         * @param {Array} array The array\n         * @param {Object} item The item to remove\n         * @return {Array} The passed array itself\n         */\n        remove: function(array, item) {\n            var index = ExtArray.indexOf(array, item);\n\n            if (index !== -1) {\n                erase(array, index, 1);\n            }\n\n            return array;\n        },\n\n        /**\n         * Push an item into the array only if the array doesn't contain it yet\n         *\n         * @param {Array} array The array\n         * @param {Object} item The item to include\n         */\n        include: function(array, item) {\n            if (!ExtArray.contains(array, item)) {\n                array.push(item);\n            }\n        },\n\n        /**\n         * Clone a flat array without referencing the previous one. Note that this is different\n         * from Ext.clone since it doesn't handle recursive cloning. It's simply a convenient, easy-to-remember method\n         * for Array.prototype.slice.call(array)\n         *\n         * @param {Array} array The array\n         * @return {Array} The clone array\n         */\n        clone: function(array) {\n            return slice.call(array);\n        },\n\n        /**\n         * Merge multiple arrays into one with unique items.\n         *\n         * {@link Ext.Array#union} is alias for {@link Ext.Array#merge}\n         *\n         * @param {Array} array1\n         * @param {Array} array2\n         * @param {Array} etc\n         * @return {Array} merged\n         */\n        merge: function() {\n            var args = slice.call(arguments),\n                array = [],\n                i, ln;\n\n            for (i = 0, ln = args.length; i < ln; i++) {\n                array = array.concat(args[i]);\n            }\n\n            return ExtArray.unique(array);\n        },\n\n        /**\n         * Merge multiple arrays into one with unique items that exist in all of the arrays.\n         *\n         * @param {Array} array1\n         * @param {Array} array2\n         * @param {Array} etc\n         * @return {Array} intersect\n         */\n        intersect: function() {\n            var intersection = [],\n                arrays = slice.call(arguments),\n                arraysLength,\n                array,\n                arrayLength,\n                minArray,\n                minArrayIndex,\n                minArrayCandidate,\n                minArrayLength,\n                element,\n                elementCandidate,\n                elementCount,\n                i, j, k;\n\n            if (!arrays.length) {\n                return intersection;\n            }\n\n            // Find the smallest array\n            arraysLength = arrays.length;\n            for (i = minArrayIndex = 0; i < arraysLength; i++) {\n                minArrayCandidate = arrays[i];\n                if (!minArray || minArrayCandidate.length < minArray.length) {\n                    minArray = minArrayCandidate;\n                    minArrayIndex = i;\n                }\n            }\n\n            minArray = ExtArray.unique(minArray);\n            erase(arrays, minArrayIndex, 1);\n\n            // Use the smallest unique'd array as the anchor loop. If the other array(s) do contain\n            // an item in the small array, we're likely to find it before reaching the end\n            // of the inner loop and can terminate the search early.\n            minArrayLength = minArray.length;\n            arraysLength = arrays.length;\n            for (i = 0; i < minArrayLength; i++) {\n                element = minArray[i];\n                elementCount = 0;\n\n                for (j = 0; j < arraysLength; j++) {\n                    array = arrays[j];\n                    arrayLength = array.length;\n                    for (k = 0; k < arrayLength; k++) {\n                        elementCandidate = array[k];\n                        if (element === elementCandidate) {\n                            elementCount++;\n                            break;\n                        }\n                    }\n                }\n\n                if (elementCount === arraysLength) {\n                    intersection.push(element);\n                }\n            }\n\n            return intersection;\n        },\n\n        /**\n         * Perform a set difference A-B by subtracting all items in array B from array A.\n         *\n         * @param {Array} arrayA\n         * @param {Array} arrayB\n         * @return {Array} difference\n         */\n        difference: function(arrayA, arrayB) {\n            var clone = slice.call(arrayA),\n                ln = clone.length,\n                i, j, lnB;\n\n            for (i = 0,lnB = arrayB.length; i < lnB; i++) {\n                for (j = 0; j < ln; j++) {\n                    if (clone[j] === arrayB[i]) {\n                        erase(clone, j, 1);\n                        j--;\n                        ln--;\n                    }\n                }\n            }\n\n            return clone;\n        },\n\n        /**\n         * Returns a shallow copy of a part of an array. This is equivalent to the native\n         * call \"Array.prototype.slice.call(array, begin, end)\". This is often used when \"array\"\n         * is \"arguments\" since the arguments object does not supply a slice method but can\n         * be the context object to Array.prototype.slice.\n         *\n         * @param {Array} array The array (or arguments object).\n         * @param {Number} begin The index at which to begin. Negative values are offsets from\n         * the end of the array.\n         * @param {Number} end The index at which to end. The copied items do not include\n         * end. Negative values are offsets from the end of the array. If end is omitted,\n         * all items up to the end of the array are copied.\n         * @return {Array} The copied piece of the array.\n         * @method slice\n         */\n        // Note: IE6 will return [] on slice.call(x, undefined).\n        slice: ([1,2].slice(1, undefined).length ?\n            function (array, begin, end) {\n                return slice.call(array, begin, end);\n            } :\n            // at least IE6 uses arguments.length for variadic signature\n            function (array, begin, end) {\n                // After tested for IE 6, the one below is of the best performance\n                // see http://jsperf.com/slice-fix\n                if (typeof begin === 'undefined') {\n                    return slice.call(array);\n                }\n                if (typeof end === 'undefined') {\n                    return slice.call(array, begin);\n                }\n                return slice.call(array, begin, end);\n            }\n        ),\n\n        /**\n         * Sorts the elements of an Array.\n         * By default, this method sorts the elements alphabetically and ascending.\n         *\n         * @param {Array} array The array to sort.\n         * @param {Function} sortFn (optional) The comparison function.\n         * @return {Array} The sorted array.\n         */\n        sort: supportsSort ? function(array, sortFn) {\n            if (sortFn) {\n                return array.sort(sortFn);\n            } else {\n                return array.sort();\n            }\n         } : function(array, sortFn) {\n            var length = array.length,\n                i = 0,\n                comparison,\n                j, min, tmp;\n\n            for (; i < length; i++) {\n                min = i;\n                for (j = i + 1; j < length; j++) {\n                    if (sortFn) {\n                        comparison = sortFn(array[j], array[min]);\n                        if (comparison < 0) {\n                            min = j;\n                        }\n                    } else if (array[j] < array[min]) {\n                        min = j;\n                    }\n                }\n                if (min !== i) {\n                    tmp = array[i];\n                    array[i] = array[min];\n                    array[min] = tmp;\n                }\n            }\n\n            return array;\n        },\n\n        /**\n         * Recursively flattens into 1-d Array. Injects Arrays inline.\n         *\n         * @param {Array} array The array to flatten\n         * @return {Array} The 1-d array.\n         */\n        flatten: function(array) {\n            var worker = [];\n\n            function rFlatten(a) {\n                var i, ln, v;\n\n                for (i = 0, ln = a.length; i < ln; i++) {\n                    v = a[i];\n\n                    if (Ext.isArray(v)) {\n                        rFlatten(v);\n                    } else {\n                        worker.push(v);\n                    }\n                }\n\n                return worker;\n            }\n\n            return rFlatten(array);\n        },\n\n        /**\n         * Returns the minimum value in the Array.\n         *\n         * @param {Array/NodeList} array The Array from which to select the minimum value.\n         * @param {Function} comparisonFn (optional) a function to perform the comparision which determines minimization.\n         * If omitted the \"<\" operator will be used. Note: gt = 1; eq = 0; lt = -1\n         * @return {Object} minValue The minimum value\n         */\n        min: function(array, comparisonFn) {\n            var min = array[0],\n                i, ln, item;\n\n            for (i = 0, ln = array.length; i < ln; i++) {\n                item = array[i];\n\n                if (comparisonFn) {\n                    if (comparisonFn(min, item) === 1) {\n                        min = item;\n                    }\n                }\n                else {\n                    if (item < min) {\n                        min = item;\n                    }\n                }\n            }\n\n            return min;\n        },\n\n        /**\n         * Returns the maximum value in the Array.\n         *\n         * @param {Array/NodeList} array The Array from which to select the maximum value.\n         * @param {Function} comparisonFn (optional) a function to perform the comparision which determines maximization.\n         * If omitted the \">\" operator will be used. Note: gt = 1; eq = 0; lt = -1\n         * @return {Object} maxValue The maximum value\n         */\n        max: function(array, comparisonFn) {\n            var max = array[0],\n                i, ln, item;\n\n            for (i = 0, ln = array.length; i < ln; i++) {\n                item = array[i];\n\n                if (comparisonFn) {\n                    if (comparisonFn(max, item) === -1) {\n                        max = item;\n                    }\n                }\n                else {\n                    if (item > max) {\n                        max = item;\n                    }\n                }\n            }\n\n            return max;\n        },\n\n        /**\n         * Calculates the mean of all items in the array.\n         *\n         * @param {Array} array The Array to calculate the mean value of.\n         * @return {Number} The mean.\n         */\n        mean: function(array) {\n            return array.length > 0 ? ExtArray.sum(array) / array.length : undefined;\n        },\n\n        /**\n         * Calculates the sum of all items in the given array.\n         *\n         * @param {Array} array The Array to calculate the sum value of.\n         * @return {Number} The sum.\n         */\n        sum: function(array) {\n            var sum = 0,\n                i, ln, item;\n\n            for (i = 0,ln = array.length; i < ln; i++) {\n                item = array[i];\n\n                sum += item;\n            }\n\n            return sum;\n        },\n\n        /**\n         * Creates a map (object) keyed by the elements of the given array. The values in\n         * the map are the index+1 of the array element. For example:\n         * \n         *      var map = Ext.Array.toMap(['a','b','c']);\n         *\n         *      // map = { a: 1, b: 2, c: 3 };\n         * \n         * Or a key property can be specified:\n         * \n         *      var map = Ext.Array.toMap([\n         *              { name: 'a' },\n         *              { name: 'b' },\n         *              { name: 'c' }\n         *          ], 'name');\n         *\n         *      // map = { a: 1, b: 2, c: 3 };\n         * \n         * Lastly, a key extractor can be provided:\n         * \n         *      var map = Ext.Array.toMap([\n         *              { name: 'a' },\n         *              { name: 'b' },\n         *              { name: 'c' }\n         *          ], function (obj) { return obj.name.toUpperCase(); });\n         *\n         *      // map = { A: 1, B: 2, C: 3 };\n         */\n        toMap: function(array, getKey, scope) {\n            var map = {},\n                i = array.length;\n\n            if (!getKey) {\n                while (i--) {\n                    map[array[i]] = i+1;\n                }\n            } else if (typeof getKey == 'string') {\n                while (i--) {\n                    map[array[i][getKey]] = i+1;\n                }\n            } else {\n                while (i--) {\n                    map[getKey.call(scope, array[i])] = i+1;\n                }\n            }\n\n            return map;\n        },\n\n        _replaceSim: replaceSim, // for unit testing\n        _spliceSim: spliceSim,\n\n        /**\n         * Removes items from an array. This is functionally equivalent to the splice method\n         * of Array, but works around bugs in IE8's splice method and does not copy the\n         * removed elements in order to return them (because very often they are ignored).\n         *\n         * @param {Array} array The Array on which to replace.\n         * @param {Number} index The index in the array at which to operate.\n         * @param {Number} removeCount The number of items to remove at index.\n         * @return {Array} The array passed.\n         * @method\n         */\n        erase: erase,\n\n        /**\n         * Inserts items in to an array.\n         *\n         * @param {Array} array The Array in which to insert.\n         * @param {Number} index The index in the array at which to operate.\n         * @param {Array} items The array of items to insert at index.\n         * @return {Array} The array passed.\n         */\n        insert: function (array, index, items) {\n            return replace(array, index, 0, items);\n        },\n\n        /**\n         * Replaces items in an array. This is functionally equivalent to the splice method\n         * of Array, but works around bugs in IE8's splice method and is often more convenient\n         * to call because it accepts an array of items to insert rather than use a variadic\n         * argument list.\n         *\n         * @param {Array} array The Array on which to replace.\n         * @param {Number} index The index in the array at which to operate.\n         * @param {Number} removeCount The number of items to remove at index (can be 0).\n         * @param {Array} insert (optional) An array of items to insert at index.\n         * @return {Array} The array passed.\n         * @method\n         */\n        replace: replace,\n\n        /**\n         * Replaces items in an array. This is equivalent to the splice method of Array, but\n         * works around bugs in IE8's splice method. The signature is exactly the same as the\n         * splice method except that the array is the first argument. All arguments following\n         * removeCount are inserted in the array at index.\n         *\n         * @param {Array} array The Array on which to replace.\n         * @param {Number} index The index in the array at which to operate.\n         * @param {Number} removeCount The number of items to remove at index (can be 0).\n         * @param {Object...} elements The elements to add to the array. If you don't specify\n         * any elements, splice simply removes elements from the array.\n         * @return {Array} An array containing the removed items.\n         * @method\n         */\n        splice: splice,\n\n        /**\n         * Pushes new items onto the end of an Array.\n         *\n         * Passed parameters may be single items, or arrays of items. If an Array is found in the argument list, all its\n         * elements are pushed into the end of the target Array.\n         *\n         * @param {Array} target The Array onto which to push new items\n         * @param {Object...} elements The elements to add to the array. Each parameter may\n         * be an Array, in which case all the elements of that Array will be pushed into the end of the\n         * destination Array.\n         * @return {Array} An array containing all the new items push onto the end.\n         *\n         */\n        push: function(array) {\n            var len = arguments.length,\n                i = 1,\n                newItem;\n\n            if (array === undefined) {\n                array = [];\n            } else if (!Ext.isArray(array)) {\n                array = [array];\n            }\n            for (; i < len; i++) {\n                newItem = arguments[i];\n                Array.prototype.push[Ext.isArray(newItem) ? 'apply' : 'call'](array, newItem);\n            }\n            return array;\n        }\n    };\n\n    /**\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#each\n     */\n    Ext.each = ExtArray.each;\n\n    /**\n     * @method\n     * @member Ext.Array\n     * @inheritdoc Ext.Array#merge\n     */\n    ExtArray.union = ExtArray.merge;\n\n    /**\n     * Old alias to {@link Ext.Array#min}\n     * @deprecated 4.0.0 Use {@link Ext.Array#min} instead\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#min\n     */\n    Ext.min = ExtArray.min;\n\n    /**\n     * Old alias to {@link Ext.Array#max}\n     * @deprecated 4.0.0 Use {@link Ext.Array#max} instead\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#max\n     */\n    Ext.max = ExtArray.max;\n\n    /**\n     * Old alias to {@link Ext.Array#sum}\n     * @deprecated 4.0.0 Use {@link Ext.Array#sum} instead\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#sum\n     */\n    Ext.sum = ExtArray.sum;\n\n    /**\n     * Old alias to {@link Ext.Array#mean}\n     * @deprecated 4.0.0 Use {@link Ext.Array#mean} instead\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#mean\n     */\n    Ext.mean = ExtArray.mean;\n\n    /**\n     * Old alias to {@link Ext.Array#flatten}\n     * @deprecated 4.0.0 Use {@link Ext.Array#flatten} instead\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#flatten\n     */\n    Ext.flatten = ExtArray.flatten;\n\n    /**\n     * Old alias to {@link Ext.Array#clean}\n     * @deprecated 4.0.0 Use {@link Ext.Array#clean} instead\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#clean\n     */\n    Ext.clean = ExtArray.clean;\n\n    /**\n     * Old alias to {@link Ext.Array#unique}\n     * @deprecated 4.0.0 Use {@link Ext.Array#unique} instead\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#unique\n     */\n    Ext.unique = ExtArray.unique;\n\n    /**\n     * Old alias to {@link Ext.Array#pluck Ext.Array.pluck}\n     * @deprecated 4.0.0 Use {@link Ext.Array#pluck Ext.Array.pluck} instead\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#pluck\n     */\n    Ext.pluck = ExtArray.pluck;\n\n    /**\n     * @method\n     * @member Ext\n     * @inheritdoc Ext.Array#toArray\n     */\n    Ext.toArray = function() {\n        return ExtArray.toArray.apply(ExtArray, arguments);\n    };\n}());\n\n//@tag foundation,core\n//@require Array.js\n\n/**\n * @class Ext.Function\n *\n * A collection of useful static methods to deal with function callbacks\n * @singleton\n * @alternateClassName Ext.util.Functions\n */\nExt.Function = {\n\n    /**\n     * A very commonly used method throughout the framework. It acts as a wrapper around another method\n     * which originally accepts 2 arguments for `name` and `value`.\n     * The wrapped function then allows \"flexible\" value setting of either:\n     *\n     * - `name` and `value` as 2 arguments\n     * - one single object argument with multiple key - value pairs\n     *\n     * For example:\n     *\n     *     var setValue = Ext.Function.flexSetter(function(name, value) {\n     *         this[name] = value;\n     *     });\n     *\n     *     // Afterwards\n     *     // Setting a single name - value\n     *     setValue('name1', 'value1');\n     *\n     *     // Settings multiple name - value pairs\n     *     setValue({\n     *         name1: 'value1',\n     *         name2: 'value2',\n     *         name3: 'value3'\n     *     });\n     *\n     * @param {Function} setter\n     * @returns {Function} flexSetter\n     */\n    flexSetter: function(fn) {\n        return function(a, b) {\n            var k, i;\n\n            if (a === null) {\n                return this;\n            }\n\n            if (typeof a !== 'string') {\n                for (k in a) {\n                    if (a.hasOwnProperty(k)) {\n                        fn.call(this, k, a[k]);\n                    }\n                }\n\n                if (Ext.enumerables) {\n                    for (i = Ext.enumerables.length; i--;) {\n                        k = Ext.enumerables[i];\n                        if (a.hasOwnProperty(k)) {\n                            fn.call(this, k, a[k]);\n                        }\n                    }\n                }\n            } else {\n                fn.call(this, a, b);\n            }\n\n            return this;\n        };\n    },\n\n    /**\n     * Create a new function from the provided `fn`, change `this` to the provided scope, optionally\n     * overrides arguments for the call. (Defaults to the arguments passed by the caller)\n     *\n     * {@link Ext#bind Ext.bind} is alias for {@link Ext.Function#bind Ext.Function.bind}\n     *\n     * @param {Function} fn The function to delegate.\n     * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.\n     * **If omitted, defaults to the default global environment object (usually the browser window).**\n     * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)\n     * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,\n     * if a number the args are inserted at the specified position\n     * @return {Function} The new function\n     */\n    bind: function(fn, scope, args, appendArgs) {\n        if (arguments.length === 2) {\n            return function() {\n                return fn.apply(scope, arguments);\n            };\n        }\n\n        var method = fn,\n            slice = Array.prototype.slice;\n\n        return function() {\n            var callArgs = args || arguments;\n\n            if (appendArgs === true) {\n                callArgs = slice.call(arguments, 0);\n                callArgs = callArgs.concat(args);\n            }\n            else if (typeof appendArgs == 'number') {\n                callArgs = slice.call(arguments, 0); // copy arguments first\n                Ext.Array.insert(callArgs, appendArgs, args);\n            }\n\n            return method.apply(scope || Ext.global, callArgs);\n        };\n    },\n\n    /**\n     * Create a new function from the provided `fn`, the arguments of which are pre-set to `args`.\n     * New arguments passed to the newly created callback when it's invoked are appended after the pre-set ones.\n     * This is especially useful when creating callbacks.\n     *\n     * For example:\n     *\n     *     var originalFunction = function(){\n     *         alert(Ext.Array.from(arguments).join(' '));\n     *     };\n     *\n     *     var callback = Ext.Function.pass(originalFunction, ['Hello', 'World']);\n     *\n     *     callback(); // alerts 'Hello World'\n     *     callback('by Me'); // alerts 'Hello World by Me'\n     *\n     * {@link Ext#pass Ext.pass} is alias for {@link Ext.Function#pass Ext.Function.pass}\n     *\n     * @param {Function} fn The original function\n     * @param {Array} args The arguments to pass to new callback\n     * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.\n     * @return {Function} The new callback function\n     */\n    pass: function(fn, args, scope) {\n        if (!Ext.isArray(args)) {\n            if (Ext.isIterable(args)) {\n                args = Ext.Array.clone(args);\n            } else {\n                args = args !== undefined ? [args] : [];\n            }\n        }\n\n        return function() {\n            var fnArgs = [].concat(args);\n            fnArgs.push.apply(fnArgs, arguments);\n            return fn.apply(scope || this, fnArgs);\n        };\n    },\n\n    /**\n     * Create an alias to the provided method property with name `methodName` of `object`.\n     * Note that the execution scope will still be bound to the provided `object` itself.\n     *\n     * @param {Object/Function} object\n     * @param {String} methodName\n     * @return {Function} aliasFn\n     */\n    alias: function(object, methodName) {\n        return function() {\n            return object[methodName].apply(object, arguments);\n        };\n    },\n\n    /**\n     * Create a \"clone\" of the provided method. The returned method will call the given\n     * method passing along all arguments and the \"this\" pointer and return its result.\n     *\n     * @param {Function} method\n     * @return {Function} cloneFn\n     */\n    clone: function(method) {\n        return function() {\n            return method.apply(this, arguments);\n        };\n    },\n\n    /**\n     * Creates an interceptor function. The passed function is called before the original one. If it returns false,\n     * the original one is not called. The resulting function returns the results of the original function.\n     * The passed function is called with the parameters of the original function. Example usage:\n     *\n     *     var sayHi = function(name){\n     *         alert('Hi, ' + name);\n     *     }\n     *\n     *     sayHi('Fred'); // alerts \"Hi, Fred\"\n     *\n     *     // create a new function that validates input without\n     *     // directly modifying the original function:\n     *     var sayHiToFriend = Ext.Function.createInterceptor(sayHi, function(name){\n     *         return name == 'Brian';\n     *     });\n     *\n     *     sayHiToFriend('Fred');  // no alert\n     *     sayHiToFriend('Brian'); // alerts \"Hi, Brian\"\n     *\n     * @param {Function} origFn The original function.\n     * @param {Function} newFn The function to call before the original\n     * @param {Object} scope (optional) The scope (`this` reference) in which the passed function is executed.\n     * **If omitted, defaults to the scope in which the original function is called or the browser window.**\n     * @param {Object} returnValue (optional) The value to return if the passed function return false (defaults to null).\n     * @return {Function} The new function\n     */\n    createInterceptor: function(origFn, newFn, scope, returnValue) {\n        var method = origFn;\n        if (!Ext.isFunction(newFn)) {\n            return origFn;\n        }\n        else {\n            return function() {\n                var me = this,\n                    args = arguments;\n                newFn.target = me;\n                newFn.method = origFn;\n                return (newFn.apply(scope || me || Ext.global, args) !== false) ? origFn.apply(me || Ext.global, args) : returnValue || null;\n            };\n        }\n    },\n\n    /**\n     * Creates a delegate (callback) which, when called, executes after a specific delay.\n     *\n     * @param {Function} fn The function which will be called on a delay when the returned function is called.\n     * Optionally, a replacement (or additional) argument list may be specified.\n     * @param {Number} delay The number of milliseconds to defer execution by whenever called.\n     * @param {Object} scope (optional) The scope (`this` reference) used by the function at execution time.\n     * @param {Array} args (optional) Override arguments for the call. (Defaults to the arguments passed by the caller)\n     * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,\n     * if a number the args are inserted at the specified position.\n     * @return {Function} A function which, when called, executes the original function after the specified delay.\n     */\n    createDelayed: function(fn, delay, scope, args, appendArgs) {\n        if (scope || args) {\n            fn = Ext.Function.bind(fn, scope, args, appendArgs);\n        }\n\n        return function() {\n            var me = this,\n                args = Array.prototype.slice.call(arguments);\n\n            setTimeout(function() {\n                fn.apply(me, args);\n            }, delay);\n        };\n    },\n\n    /**\n     * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:\n     *\n     *     var sayHi = function(name){\n     *         alert('Hi, ' + name);\n     *     }\n     *\n     *     // executes immediately:\n     *     sayHi('Fred');\n     *\n     *     // executes after 2 seconds:\n     *     Ext.Function.defer(sayHi, 2000, this, ['Fred']);\n     *\n     *     // this syntax is sometimes useful for deferring\n     *     // execution of an anonymous function:\n     *     Ext.Function.defer(function(){\n     *         alert('Anonymous');\n     *     }, 100);\n     *\n     * {@link Ext#defer Ext.defer} is alias for {@link Ext.Function#defer Ext.Function.defer}\n     *\n     * @param {Function} fn The function to defer.\n     * @param {Number} millis The number of milliseconds for the setTimeout call\n     * (if less than or equal to 0 the function is executed immediately)\n     * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.\n     * **If omitted, defaults to the browser window.**\n     * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)\n     * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,\n     * if a number the args are inserted at the specified position\n     * @return {Number} The timeout id that can be used with clearTimeout\n     */\n    defer: function(fn, millis, scope, args, appendArgs) {\n        fn = Ext.Function.bind(fn, scope, args, appendArgs);\n        if (millis > 0) {\n            return setTimeout(Ext.supports.TimeoutActualLateness ? function () {\n                fn();\n            } : fn, millis);\n        }\n        fn();\n        return 0;\n    },\n\n    /**\n     * Create a combined function call sequence of the original function + the passed function.\n     * The resulting function returns the results of the original function.\n     * The passed function is called with the parameters of the original function. Example usage:\n     *\n     *     var sayHi = function(name){\n     *         alert('Hi, ' + name);\n     *     }\n     *\n     *     sayHi('Fred'); // alerts \"Hi, Fred\"\n     *\n     *     var sayGoodbye = Ext.Function.createSequence(sayHi, function(name){\n     *         alert('Bye, ' + name);\n     *     });\n     *\n     *     sayGoodbye('Fred'); // both alerts show\n     *\n     * @param {Function} originalFn The original function.\n     * @param {Function} newFn The function to sequence\n     * @param {Object} scope (optional) The scope (`this` reference) in which the passed function is executed.\n     * If omitted, defaults to the scope in which the original function is called or the default global environment object (usually the browser window).\n     * @return {Function} The new function\n     */\n    createSequence: function(originalFn, newFn, scope) {\n        if (!newFn) {\n            return originalFn;\n        }\n        else {\n            return function() {\n                var result = originalFn.apply(this, arguments);\n                newFn.apply(scope || this, arguments);\n                return result;\n            };\n        }\n    },\n\n    /**\n     * Creates a delegate function, optionally with a bound scope which, when called, buffers\n     * the execution of the passed function for the configured number of milliseconds.\n     * If called again within that period, the impending invocation will be canceled, and the\n     * timeout period will begin again.\n     *\n     * @param {Function} fn The function to invoke on a buffered timer.\n     * @param {Number} buffer The number of milliseconds by which to buffer the invocation of the\n     * function.\n     * @param {Object} scope (optional) The scope (`this` reference) in which\n     * the passed function is executed. If omitted, defaults to the scope specified by the caller.\n     * @param {Array} args (optional) Override arguments for the call. Defaults to the arguments\n     * passed by the caller.\n     * @return {Function} A function which invokes the passed function after buffering for the specified time.\n     */\n    createBuffered: function(fn, buffer, scope, args) {\n        var timerId;\n\n        return function() {\n            var callArgs = args || Array.prototype.slice.call(arguments, 0),\n                me = scope || this;\n\n            if (timerId) {\n                clearTimeout(timerId);\n            }\n\n            timerId = setTimeout(function(){\n                fn.apply(me, callArgs);\n            }, buffer);\n        };\n    },\n\n    /**\n     * Creates a throttled version of the passed function which, when called repeatedly and\n     * rapidly, invokes the passed function only after a certain interval has elapsed since the\n     * previous invocation.\n     *\n     * This is useful for wrapping functions which may be called repeatedly, such as\n     * a handler of a mouse move event when the processing is expensive.\n     *\n     * @param {Function} fn The function to execute at a regular time interval.\n     * @param {Number} interval The interval **in milliseconds** on which the passed function is executed.\n     * @param {Object} scope (optional) The scope (`this` reference) in which\n     * the passed function is executed. If omitted, defaults to the scope specified by the caller.\n     * @returns {Function} A function which invokes the passed function at the specified interval.\n     */\n    createThrottled: function(fn, interval, scope) {\n        var lastCallTime, elapsed, lastArgs, timer, execute = function() {\n            fn.apply(scope || this, lastArgs);\n            lastCallTime = new Date().getTime();\n        };\n\n        return function() {\n            elapsed = new Date().getTime() - lastCallTime;\n            lastArgs = arguments;\n\n            clearTimeout(timer);\n            if (!lastCallTime || (elapsed >= interval)) {\n                execute();\n            } else {\n                timer = setTimeout(execute, interval - elapsed);\n            }\n        };\n    },\n\n\n    /**\n     * Adds behavior to an existing method that is executed before the\n     * original behavior of the function.  For example:\n     * \n     *     var soup = {\n     *         contents: [],\n     *         add: function(ingredient) {\n     *             this.contents.push(ingredient);\n     *         }\n     *     };\n     *     Ext.Function.interceptBefore(soup, \"add\", function(ingredient){\n     *         if (!this.contents.length && ingredient !== \"water\") {\n     *             // Always add water to start with\n     *             this.contents.push(\"water\");\n     *         }\n     *     });\n     *     soup.add(\"onions\");\n     *     soup.add(\"salt\");\n     *     soup.contents; // will contain: water, onions, salt\n     * \n     * @param {Object} object The target object\n     * @param {String} methodName Name of the method to override\n     * @param {Function} fn Function with the new behavior.  It will\n     * be called with the same arguments as the original method.  The\n     * return value of this function will be the return value of the\n     * new method.\n     * @param {Object} [scope] The scope to execute the interceptor function. Defaults to the object.\n     * @return {Function} The new function just created.\n     */\n    interceptBefore: function(object, methodName, fn, scope) {\n        var method = object[methodName] || Ext.emptyFn;\n\n        return (object[methodName] = function() {\n            var ret = fn.apply(scope || this, arguments);\n            method.apply(this, arguments);\n\n            return ret;\n        });\n    },\n\n    /**\n     * Adds behavior to an existing method that is executed after the\n     * original behavior of the function.  For example:\n     * \n     *     var soup = {\n     *         contents: [],\n     *         add: function(ingredient) {\n     *             this.contents.push(ingredient);\n     *         }\n     *     };\n     *     Ext.Function.interceptAfter(soup, \"add\", function(ingredient){\n     *         // Always add a bit of extra salt\n     *         this.contents.push(\"salt\");\n     *     });\n     *     soup.add(\"water\");\n     *     soup.add(\"onions\");\n     *     soup.contents; // will contain: water, salt, onions, salt\n     * \n     * @param {Object} object The target object\n     * @param {String} methodName Name of the method to override\n     * @param {Function} fn Function with the new behavior.  It will\n     * be called with the same arguments as the original method.  The\n     * return value of this function will be the return value of the\n     * new method.\n     * @param {Object} [scope] The scope to execute the interceptor function. Defaults to the object.\n     * @return {Function} The new function just created.\n     */\n    interceptAfter: function(object, methodName, fn, scope) {\n        var method = object[methodName] || Ext.emptyFn;\n\n        return (object[methodName] = function() {\n            method.apply(this, arguments);\n            return fn.apply(scope || this, arguments);\n        });\n    }\n};\n\n/**\n * @method\n * @member Ext\n * @inheritdoc Ext.Function#defer\n */\nExt.defer = Ext.Function.alias(Ext.Function, 'defer');\n\n/**\n * @method\n * @member Ext\n * @inheritdoc Ext.Function#pass\n */\nExt.pass = Ext.Function.alias(Ext.Function, 'pass');\n\n/**\n * @method\n * @member Ext\n * @inheritdoc Ext.Function#bind\n */\nExt.bind = Ext.Function.alias(Ext.Function, 'bind');\n\n//@tag foundation,core\n//@require Function.js\n\n/**\n * @author Jacky Nguyen <jacky@sencha.com>\n * @docauthor Jacky Nguyen <jacky@sencha.com>\n * @class Ext.Object\n *\n * A collection of useful static methods to deal with objects.\n *\n * @singleton\n */\n\n(function() {\n\n// The \"constructor\" for chain:\nvar TemplateClass = function(){},\n    ExtObject = Ext.Object = {\n\n    /**\n     * Returns a new object with the given object as the prototype chain.\n     * @param {Object} object The prototype chain for the new object.\n     */\n    chain: function (object) {\n        TemplateClass.prototype = object;\n        var result = new TemplateClass();\n        TemplateClass.prototype = null;\n        return result;\n    },\n\n    /**\n     * Converts a `name` - `value` pair to an array of objects with support for nested structures. Useful to construct\n     * query strings. For example:\n     *\n     *     var objects = Ext.Object.toQueryObjects('hobbies', ['reading', 'cooking', 'swimming']);\n     *\n     *     // objects then equals:\n     *     [\n     *         { name: 'hobbies', value: 'reading' },\n     *         { name: 'hobbies', value: 'cooking' },\n     *         { name: 'hobbies', value: 'swimming' },\n     *     ];\n     *\n     *     var objects = Ext.Object.toQueryObjects('dateOfBirth', {\n     *         day: 3,\n     *         month: 8,\n     *         year: 1987,\n     *         extra: {\n     *             hour: 4\n     *             minute: 30\n     *         }\n     *     }, true); // Recursive\n     *\n     *     // objects then equals:\n     *     [\n     *         { name: 'dateOfBirth[day]', value: 3 },\n     *         { name: 'dateOfBirth[month]', value: 8 },\n     *         { name: 'dateOfBirth[year]', value: 1987 },\n     *         { name: 'dateOfBirth[extra][hour]', value: 4 },\n     *         { name: 'dateOfBirth[extra][minute]', value: 30 },\n     *     ];\n     *\n     * @param {String} name\n     * @param {Object/Array} value\n     * @param {Boolean} [recursive=false] True to traverse object recursively\n     * @return {Array}\n     */\n    toQueryObjects: function(name, value, recursive) {\n        var self = ExtObject.toQueryObjects,\n            objects = [],\n            i, ln;\n\n        if (Ext.isArray(value)) {\n            for (i = 0, ln = value.length; i < ln; i++) {\n                if (recursive) {\n                    objects = objects.concat(self(name + '[' + i + ']', value[i], true));\n                }\n                else {\n                    objects.push({\n                        name: name,\n                        value: value[i]\n                    });\n                }\n            }\n        }\n        else if (Ext.isObject(value)) {\n            for (i in value) {\n                if (value.hasOwnProperty(i)) {\n                    if (recursive) {\n                        objects = objects.concat(self(name + '[' + i + ']', value[i], true));\n                    }\n                    else {\n                        objects.push({\n                            name: name,\n                            value: value[i]\n                        });\n                    }\n                }\n            }\n        }\n        else {\n            objects.push({\n                name: name,\n                value: value\n            });\n        }\n\n        return objects;\n    },\n\n    /**\n     * Takes an object and converts it to an encoded query string.\n     *\n     * Non-recursive:\n     *\n     *     Ext.Object.toQueryString({foo: 1, bar: 2}); // returns \"foo=1&bar=2\"\n     *     Ext.Object.toQueryString({foo: null, bar: 2}); // returns \"foo=&bar=2\"\n     *     Ext.Object.toQueryString({'some price': '$300'}); // returns \"some%20price=%24300\"\n     *     Ext.Object.toQueryString({date: new Date(2011, 0, 1)}); // returns \"date=%222011-01-01T00%3A00%3A00%22\"\n     *     Ext.Object.toQueryString({colors: ['red', 'green', 'blue']}); // returns \"colors=red&colors=green&colors=blue\"\n     *\n     * Recursive:\n     *\n     *     Ext.Object.toQueryString({\n     *         username: 'Jacky',\n     *         dateOfBirth: {\n     *             day: 1,\n     *             month: 2,\n     *             year: 1911\n     *         },\n     *         hobbies: ['coding', 'eating', 'sleeping', ['nested', 'stuff']]\n     *     }, true); // returns the following string (broken down and url-decoded for ease of reading purpose):\n     *     // username=Jacky\n     *     //    &dateOfBirth[day]=1&dateOfBirth[month]=2&dateOfBirth[year]=1911\n     *     //    &hobbies[0]=coding&hobbies[1]=eating&hobbies[2]=sleeping&hobbies[3][0]=nested&hobbies[3][1]=stuff\n     *\n     * @param {Object} object The object to encode\n     * @param {Boolean} [recursive=false] Whether or not to interpret the object in recursive format.\n     * (PHP / Ruby on Rails servers and similar).\n     * @return {String} queryString\n     */\n    toQueryString: function(object, recursive) {\n        var paramObjects = [],\n            params = [],\n            i, j, ln, paramObject, value;\n\n        for (i in object) {\n            if (object.hasOwnProperty(i)) {\n                paramObjects = paramObjects.concat(ExtObject.toQueryObjects(i, object[i], recursive));\n            }\n        }\n\n        for (j = 0, ln = paramObjects.length; j < ln; j++) {\n            paramObject = paramObjects[j];\n            value = paramObject.value;\n\n            if (Ext.isEmpty(value)) {\n                value = '';\n            }\n            else if (Ext.isDate(value)) {\n                value = Ext.Date.toString(value);\n            }\n\n            params.push(encodeURIComponent(paramObject.name) + '=' + encodeURIComponent(String(value)));\n        }\n\n        return params.join('&');\n    },\n\n    /**\n     * Converts a query string back into an object.\n     *\n     * Non-recursive:\n     *\n     *     Ext.Object.fromQueryString(\"foo=1&bar=2\"); // returns {foo: 1, bar: 2}\n     *     Ext.Object.fromQueryString(\"foo=&bar=2\"); // returns {foo: null, bar: 2}\n     *     Ext.Object.fromQueryString(\"some%20price=%24300\"); // returns {'some price': '$300'}\n     *     Ext.Object.fromQueryString(\"colors=red&colors=green&colors=blue\"); // returns {colors: ['red', 'green', 'blue']}\n     *\n     * Recursive:\n     *\n     *     Ext.Object.fromQueryString(\n     *         \"username=Jacky&\"+\n     *         \"dateOfBirth[day]=1&dateOfBirth[month]=2&dateOfBirth[year]=1911&\"+\n     *         \"hobbies[0]=coding&hobbies[1]=eating&hobbies[2]=sleeping&\"+\n     *         \"hobbies[3][0]=nested&hobbies[3][1]=stuff\", true);\n     *\n     *     // returns\n     *     {\n     *         username: 'Jacky',\n     *         dateOfBirth: {\n     *             day: '1',\n     *             month: '2',\n     *             year: '1911'\n     *         },\n     *         hobbies: ['coding', 'eating', 'sleeping', ['nested', 'stuff']]\n     *     }\n     *\n     * @param {String} queryString The query string to decode\n     * @param {Boolean} [recursive=false] Whether or not to recursively decode the string. This format is supported by\n     * PHP / Ruby on Rails servers and similar.\n     * @return {Object}\n     */\n    fromQueryString: function(queryString, recursive) {\n        var parts = queryString.replace(/^\\?/, '').split('&'),\n            object = {},\n            temp, components, name, value, i, ln,\n            part, j, subLn, matchedKeys, matchedName,\n            keys, key, nextKey;\n\n        for (i = 0, ln = parts.length; i < ln; i++) {\n            part = parts[i];\n\n            if (part.length > 0) {\n                components = part.split('=');\n                name = decodeURIComponent(components[0]);\n                value = (components[1] !== undefined) ? decodeURIComponent(components[1]) : '';\n\n                if (!recursive) {\n                    if (object.hasOwnProperty(name)) {\n                        if (!Ext.isArray(object[name])) {\n                            object[name] = [object[name]];\n                        }\n\n                        object[name].push(value);\n                    }\n                    else {\n                        object[name] = value;\n                    }\n                }\n                else {\n                    matchedKeys = name.match(/(\\[):?([^\\]]*)\\]/g);\n                    matchedName = name.match(/^([^\\[]+)/);\n\n                    if (!matchedName) {\n                        throw new Error('[Ext.Object.fromQueryString] Malformed query string given, failed parsing name from \"' + part + '\"');\n                    }\n\n                    name = matchedName[0];\n                    keys = [];\n\n                    if (matchedKeys === null) {\n                        object[name] = value;\n                        continue;\n                    }\n\n                    for (j = 0, subLn = matchedKeys.length; j < subLn; j++) {\n                        key = matchedKeys[j];\n                        key = (key.length === 2) ? '' : key.substring(1, key.length - 1);\n                        keys.push(key);\n                    }\n\n                    keys.unshift(name);\n\n                    temp = object;\n\n                    for (j = 0, subLn = keys.length; j < subLn; j++) {\n                        key = keys[j];\n\n                        if (j === subLn - 1) {\n                            if (Ext.isArray(temp) && key === '') {\n                                temp.push(value);\n                            }\n                            else {\n                                temp[key] = value;\n                            }\n                        }\n                        else {\n                            if (temp[key] === undefined || typeof temp[key] === 'string') {\n                                nextKey = keys[j+1];\n\n                                temp[key] = (Ext.isNumeric(nextKey) || nextKey === '') ? [] : {};\n                            }\n\n                            temp = temp[key];\n                        }\n                    }\n                }\n            }\n        }\n\n        return object;\n    },\n\n    /**\n     * Iterates through an object and invokes the given callback function for each iteration.\n     * The iteration can be stopped by returning `false` in the callback function. For example:\n     *\n     *     var person = {\n     *         name: 'Jacky'\n     *         hairColor: 'black'\n     *         loves: ['food', 'sleeping', 'wife']\n     *     };\n     *\n     *     Ext.Object.each(person, function(key, value, myself) {\n     *         console.log(key + \":\" + value);\n     *\n     *         if (key === 'hairColor') {\n     *             return false; // stop the iteration\n     *         }\n     *     });\n     *\n     * @param {Object} object The object to iterate\n     * @param {Function} fn The callback function.\n     * @param {String} fn.key\n     * @param {Object} fn.value\n     * @param {Object} fn.object The object itself\n     * @param {Object} [scope] The execution scope (`this`) of the callback function\n     */\n    each: function(object, fn, scope) {\n        for (var property in object) {\n            if (object.hasOwnProperty(property)) {\n                if (fn.call(scope || object, property, object[property], object) === false) {\n                    return;\n                }\n            }\n        }\n    },\n\n    /**\n     * Merges any number of objects recursively without referencing them or their children.\n     *\n     *     var extjs = {\n     *         companyName: 'Ext JS',\n     *         products: ['Ext JS', 'Ext GWT', 'Ext Designer'],\n     *         isSuperCool: true,\n     *         office: {\n     *             size: 2000,\n     *             location: 'Palo Alto',\n     *             isFun: true\n     *         }\n     *     };\n     *\n     *     var newStuff = {\n     *         companyName: 'Sencha Inc.',\n     *         products: ['Ext JS', 'Ext GWT', 'Ext Designer', 'Sencha Touch', 'Sencha Animator'],\n     *         office: {\n     *             size: 40000,\n     *             location: 'Redwood City'\n     *         }\n     *     };\n     *\n     *     var sencha = Ext.Object.merge(extjs, newStuff);\n     *\n     *     // extjs and sencha then equals to\n     *     {\n     *         companyName: 'Sencha Inc.',\n     *         products: ['Ext JS', 'Ext GWT', 'Ext Designer', 'Sencha Touch', 'Sencha Animator'],\n     *         isSuperCool: true,\n     *         office: {\n     *             size: 40000,\n     *             location: 'Redwood City',\n     *             isFun: true\n     *         }\n     *     }\n     *\n     * @param {Object} destination The object into which all subsequent objects are merged.\n     * @param {Object...} object Any number of objects to merge into the destination.\n     * @return {Object} merged The destination object with all passed objects merged in.\n     */\n    merge: function(destination) {\n        var i = 1,\n            ln = arguments.length,\n            mergeFn = ExtObject.merge,\n            cloneFn = Ext.clone,\n            object, key, value, sourceKey;\n\n        for (; i < ln; i++) {\n            object = arguments[i];\n\n            for (key in object) {\n                value = object[key];\n                if (value && value.constructor === Object) {\n                    sourceKey = destination[key];\n                    if (sourceKey && sourceKey.constructor === Object) {\n                        mergeFn(sourceKey, value);\n                    }\n                    else {\n                        destination[key] = cloneFn(value);\n                    }\n                }\n                else {\n                    destination[key] = value;\n                }\n            }\n        }\n\n        return destination;\n    },\n\n    /**\n     * @private\n     * @param destination\n     */\n    mergeIf: function(destination) {\n        var i = 1,\n            ln = arguments.length,\n            cloneFn = Ext.clone,\n            object, key, value;\n\n        for (; i < ln; i++) {\n            object = arguments[i];\n\n            for (key in object) {\n                if (!(key in destination)) {\n                    value = object[key];\n\n                    if (value && value.constructor === Object) {\n                        destination[key] = cloneFn(value);\n                    }\n                    else {\n                        destination[key] = value;\n                    }\n                }\n            }\n        }\n\n        return destination;\n    },\n\n    /**\n     * Returns the first matching key corresponding to the given value.\n     * If no matching value is found, null is returned.\n     *\n     *     var person = {\n     *         name: 'Jacky',\n     *         loves: 'food'\n     *     };\n     *\n     *     alert(Ext.Object.getKey(person, 'food')); // alerts 'loves'\n     *\n     * @param {Object} object\n     * @param {Object} value The value to find\n     */\n    getKey: function(object, value) {\n        for (var property in object) {\n            if (object.hasOwnProperty(property) && object[property] === value) {\n                return property;\n            }\n        }\n\n        return null;\n    },\n\n    /**\n     * Gets all values of the given object as an array.\n     *\n     *     var values = Ext.Object.getValues({\n     *         name: 'Jacky',\n     *         loves: 'food'\n     *     }); // ['Jacky', 'food']\n     *\n     * @param {Object} object\n     * @return {Array} An array of values from the object\n     */\n    getValues: function(object) {\n        var values = [],\n            property;\n\n        for (property in object) {\n            if (object.hasOwnProperty(property)) {\n                values.push(object[property]);\n            }\n        }\n\n        return values;\n    },\n\n    /**\n     * Gets all keys of the given object as an array.\n     *\n     *     var values = Ext.Object.getKeys({\n     *         name: 'Jacky',\n     *         loves: 'food'\n     *     }); // ['name', 'loves']\n     *\n     * @param {Object} object\n     * @return {String[]} An array of keys from the object\n     * @method\n     */\n    getKeys: (typeof Object.keys == 'function')\n        ? function(object){\n            if (!object) {\n                return [];\n            }\n            return Object.keys(object);\n        }\n        : function(object) {\n            var keys = [],\n                property;\n\n            for (property in object) {\n                if (object.hasOwnProperty(property)) {\n                    keys.push(property);\n                }\n            }\n\n            return keys;\n        },\n\n    /**\n     * Gets the total number of this object's own properties\n     *\n     *     var size = Ext.Object.getSize({\n     *         name: 'Jacky',\n     *         loves: 'food'\n     *     }); // size equals 2\n     *\n     * @param {Object} object\n     * @return {Number} size\n     */\n    getSize: function(object) {\n        var size = 0,\n            property;\n\n        for (property in object) {\n            if (object.hasOwnProperty(property)) {\n                size++;\n            }\n        }\n\n        return size;\n    },\n\n    /**\n     * @private\n     */\n    classify: function(object) {\n        var prototype = object,\n            objectProperties = [],\n            propertyClassesMap = {},\n            objectClass = function() {\n                var i = 0,\n                    ln = objectProperties.length,\n                    property;\n\n                for (; i < ln; i++) {\n                    property = objectProperties[i];\n                    this[property] = new propertyClassesMap[property]();\n                }\n            },\n            key, value;\n\n        for (key in object) {\n            if (object.hasOwnProperty(key)) {\n                value = object[key];\n\n                if (value && value.constructor === Object) {\n                    objectProperties.push(key);\n                    propertyClassesMap[key] = ExtObject.classify(value);\n                }\n            }\n        }\n\n        objectClass.prototype = prototype;\n\n        return objectClass;\n    }\n};\n\n/**\n * A convenient alias method for {@link Ext.Object#merge}.\n *\n * @member Ext\n * @method merge\n * @inheritdoc Ext.Object#merge\n */\nExt.merge = Ext.Object.merge;\n\n/**\n * @private\n * @member Ext\n */\nExt.mergeIf = Ext.Object.mergeIf;\n\n/**\n *\n * @member Ext\n * @method urlEncode\n * @inheritdoc Ext.Object#toQueryString\n * @deprecated 4.0.0 Use {@link Ext.Object#toQueryString} instead\n */\nExt.urlEncode = function() {\n    var args = Ext.Array.from(arguments),\n        prefix = '';\n\n    // Support for the old `pre` argument\n    if ((typeof args[1] === 'string')) {\n        prefix = args[1] + '&';\n        args[1] = false;\n    }\n\n    return prefix + ExtObject.toQueryString.apply(ExtObject, args);\n};\n\n/**\n * Alias for {@link Ext.Object#fromQueryString}.\n *\n * @member Ext\n * @method urlDecode\n * @inheritdoc Ext.Object#fromQueryString\n * @deprecated 4.0.0 Use {@link Ext.Object#fromQueryString} instead\n */\nExt.urlDecode = function() {\n    return ExtObject.fromQueryString.apply(ExtObject, arguments);\n};\n\n}());\n\n//@tag foundation,core\n//@require Object.js\n//@define Ext.Date\n\n/**\n * @class Ext.Date\n * A set of useful static methods to deal with date\n * Note that if Ext.Date is required and loaded, it will copy all methods / properties to\n * this object for convenience\n *\n * The date parsing and formatting syntax contains a subset of\n * <a href=\"http://www.php.net/date\">PHP's date() function</a>, and the formats that are\n * supported will provide results equivalent to their PHP versions.\n *\n * The following is a list of all currently supported formats:\n * <pre class=\"\">\nFormat  Description                                                               Example returned values\n------  -----------------------------------------------------------------------   -----------------------\n  d     Day of the month, 2 digits with leading zeros                             01 to 31\n  D     A short textual representation of the day of the week                     Mon to Sun\n  j     Day of the month without leading zeros                                    1 to 31\n  l     A full textual representation of the day of the week                      Sunday to Saturday\n  N     ISO-8601 numeric representation of the day of the week                    1 (for Monday) through 7 (for Sunday)\n  S     English ordinal suffix for the day of the month, 2 characters             st, nd, rd or th. Works well with j\n  w     Numeric representation of the day of the week                             0 (for Sunday) to 6 (for Saturday)\n  z     The day of the year (starting from 0)                                     0 to 364 (365 in leap years)\n  W     ISO-8601 week number of year, weeks starting on Monday                    01 to 53\n  F     A full textual representation of a month, such as January or March        January to December\n  m     Numeric representation of a month, with leading zeros                     01 to 12\n  M     A short textual representation of a month                                 Jan to Dec\n  n     Numeric representation of a month, without leading zeros                  1 to 12\n  t     Number of days in the given month                                         28 to 31\n  L     Whether it&#39;s a leap year                                                  1 if it is a leap year, 0 otherwise.\n  o     ISO-8601 year number (identical to (Y), but if the ISO week number (W)    Examples: 1998 or 2004\n        belongs to the previous or next year, that year is used instead)\n  Y     A full numeric representation of a year, 4 digits                         Examples: 1999 or 2003\n  y     A two digit representation of a year                                      Examples: 99 or 03\n  a     Lowercase Ante meridiem and Post meridiem                                 am or pm\n  A     Uppercase Ante meridiem and Post meridiem                                 AM or PM\n  g     12-hour format of an hour without leading zeros                           1 to 12\n  G     24-hour format of an hour without leading zeros                           0 to 23\n  h     12-hour format of an hour with leading zeros                              01 to 12\n  H     24-hour format of an hour with leading zeros                              00 to 23\n  i     Minutes, with leading zeros                                               00 to 59\n  s     Seconds, with leading zeros                                               00 to 59\n  u     Decimal fraction of a second                                              Examples:\n        (minimum 1 digit, arbitrary number of digits allowed)                     001 (i.e. 0.001s) or\n                                                                                  100 (i.e. 0.100s) or\n                                                                                  999 (i.e. 0.999s) or\n                                                                                  999876543210 (i.e. 0.999876543210s)\n  O     Difference to Greenwich time (GMT) in hours and minutes                   Example: +1030\n  P     Difference to Greenwich time (GMT) with colon between hours and minutes   Example: -08:00\n  T     Timezone abbreviation of the machine running the code                     Examples: EST, MDT, PDT ...\n  Z     Timezone offset in seconds (negative if west of UTC, positive if east)    -43200 to 50400\n  c     ISO 8601 date\n        Notes:                                                                    Examples:\n        1) If unspecified, the month / day defaults to the current month / day,   1991 or\n           the time defaults to midnight, while the timezone defaults to the      1992-10 or\n           browser's timezone. If a time is specified, it must include both hours 1993-09-20 or\n           and minutes. The \"T\" delimiter, seconds, milliseconds and timezone     1994-08-19T16:20+01:00 or\n           are optional.                                                          1995-07-18T17:21:28-02:00 or\n        2) The decimal fraction of a second, if specified, must contain at        1996-06-17T18:22:29.98765+03:00 or\n           least 1 digit (there is no limit to the maximum number                 1997-05-16T19:23:30,12345-0400 or\n           of digits allowed), and may be delimited by either a '.' or a ','      1998-04-15T20:24:31.2468Z or\n        Refer to the examples on the right for the various levels of              1999-03-14T20:24:32Z or\n        date-time granularity which are supported, or see                         2000-02-13T21:25:33\n        http://www.w3.org/TR/NOTE-datetime for more info.                         2001-01-12 22:26:34\n  U     Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)                1193432466 or -2138434463\n  MS    Microsoft AJAX serialized dates                                           \\/Date(1238606590509)\\/ (i.e. UTC milliseconds since epoch) or\n                                                                                  \\/Date(1238606590509+0800)\\/\n</pre>\n *\n * Example usage (note that you must escape format specifiers with '\\\\' to render them as character literals):\n * <pre><code>\n// Sample date:\n// 'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'\n\nvar dt = new Date('1/10/2007 03:05:01 PM GMT-0600');\nconsole.log(Ext.Date.format(dt, 'Y-m-d'));                          // 2007-01-10\nconsole.log(Ext.Date.format(dt, 'F j, Y, g:i a'));                  // January 10, 2007, 3:05 pm\nconsole.log(Ext.Date.format(dt, 'l, \\\\t\\\\he jS \\\\of F Y h:i:s A')); // Wednesday, the 10th of January 2007 03:05:01 PM\n</code></pre>\n *\n * Here are some standard date/time patterns that you might find helpful.  They\n * are not part of the source of Ext.Date, but to use them you can simply copy this\n * block of code into any script that is included after Ext.Date and they will also become\n * globally available on the Date object.  Feel free to add or remove patterns as needed in your code.\n * <pre><code>\nExt.Date.patterns = {\n    ISO8601Long:\"Y-m-d H:i:s\",\n    ISO8601Short:\"Y-m-d\",\n    ShortDate: \"n/j/Y\",\n    LongDate: \"l, F d, Y\",\n    FullDateTime: \"l, F d, Y g:i:s A\",\n    MonthDay: \"F d\",\n    ShortTime: \"g:i A\",\n    LongTime: \"g:i:s A\",\n    SortableDateTime: \"Y-m-d\\\\TH:i:s\",\n    UniversalSortableDateTime: \"Y-m-d H:i:sO\",\n    YearMonth: \"F, Y\"\n};\n</code></pre>\n *\n * Example usage:\n * <pre><code>\nvar dt = new Date();\nconsole.log(Ext.Date.format(dt, Ext.Date.patterns.ShortDate));\n</code></pre>\n * <p>Developer-written, custom formats may be used by supplying both a formatting and a parsing function\n * which perform to specialized requirements. The functions are stored in {@link #parseFunctions} and {@link #formatFunctions}.</p>\n * @singleton\n */\n\n/*\n * Most of the date-formatting functions below are the excellent work of Baron Schwartz.\n * (see http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/)\n * They generate precompiled functions from format patterns instead of parsing and\n * processing each pattern every time a date is formatted. These functions are available\n * on every Date object.\n */\n\n(function() {\n\n// create private copy of Ext's Ext.util.Format.format() method\n// - to remove unnecessary dependency\n// - to resolve namespace conflict with MS-Ajax's implementation\nfunction xf(format) {\n    var args = Array.prototype.slice.call(arguments, 1);\n    return format.replace(/\\{(\\d+)\\}/g, function(m, i) {\n        return args[i];\n    });\n}\n\nExt.Date = {\n    /**\n     * Returns the current timestamp.\n     * @return {Number} Milliseconds since UNIX epoch.\n     * @method\n     */\n    now: Date.now || function() {\n        return +new Date();\n    },\n\n    /**\n     * @private\n     * Private for now\n     */\n    toString: function(date) {\n        var pad = Ext.String.leftPad;\n\n        return date.getFullYear() + \"-\"\n            + pad(date.getMonth() + 1, 2, '0') + \"-\"\n            + pad(date.getDate(), 2, '0') + \"T\"\n            + pad(date.getHours(), 2, '0') + \":\"\n            + pad(date.getMinutes(), 2, '0') + \":\"\n            + pad(date.getSeconds(), 2, '0');\n    },\n\n    /**\n     * Returns the number of milliseconds between two dates\n     * @param {Date} dateA The first date\n     * @param {Date} dateB (optional) The second date, defaults to now\n     * @return {Number} The difference in milliseconds\n     */\n    getElapsed: function(dateA, dateB) {\n        return Math.abs(dateA - (dateB || new Date()));\n    },\n\n    /**\n     * Global flag which determines if strict date parsing should be used.\n     * Strict date parsing will not roll-over invalid dates, which is the\n     * default behaviour of javascript Date objects.\n     * (see {@link #parse} for more information)\n     * Defaults to <tt>false</tt>.\n     * @type Boolean\n    */\n    useStrict: false,\n\n    // private\n    formatCodeToRegex: function(character, currentGroup) {\n        // Note: currentGroup - position in regex result array (see notes for Ext.Date.parseCodes below)\n        var p = utilDate.parseCodes[character];\n\n        if (p) {\n          p = typeof p == 'function'? p() : p;\n          utilDate.parseCodes[character] = p; // reassign function result to prevent repeated execution\n        }\n\n        return p ? Ext.applyIf({\n          c: p.c ? xf(p.c, currentGroup || \"{0}\") : p.c\n        }, p) : {\n            g: 0,\n            c: null,\n            s: Ext.String.escapeRegex(character) // treat unrecognised characters as literals\n        };\n    },\n\n    /**\n     * <p>An object hash in which each property is a date parsing function. The property name is the\n     * format string which that function parses.</p>\n     * <p>This object is automatically populated with date parsing functions as\n     * date formats are requested for Ext standard formatting strings.</p>\n     * <p>Custom parsing functions may be inserted into this object, keyed by a name which from then on\n     * may be used as a format string to {@link #parse}.<p>\n     * <p>Example:</p><pre><code>\nExt.Date.parseFunctions['x-date-format'] = myDateParser;\n</code></pre>\n     * <p>A parsing function should return a Date object, and is passed the following parameters:<div class=\"mdetail-params\"><ul>\n     * <li><code>date</code> : String<div class=\"sub-desc\">The date string to parse.</div></li>\n     * <li><code>strict</code> : Boolean<div class=\"sub-desc\">True to validate date strings while parsing\n     * (i.e. prevent javascript Date \"rollover\") (The default must be false).\n     * Invalid date strings should return null when parsed.</div></li>\n     * </ul></div></p>\n     * <p>To enable Dates to also be <i>formatted</i> according to that format, a corresponding\n     * formatting function must be placed into the {@link #formatFunctions} property.\n     * @property parseFunctions\n     * @type Object\n     */\n    parseFunctions: {\n        \"MS\": function(input, strict) {\n            // note: the timezone offset is ignored since the MS Ajax server sends\n            // a UTC milliseconds-since-Unix-epoch value (negative values are allowed)\n            var re = new RegExp('\\\\/Date\\\\(([-+])?(\\\\d+)(?:[+-]\\\\d{4})?\\\\)\\\\/'),\n                r = (input || '').match(re);\n            return r? new Date(((r[1] || '') + r[2]) * 1) : null;\n        }\n    },\n    parseRegexes: [],\n\n    /**\n     * <p>An object hash in which each property is a date formatting function. The property name is the\n     * format string which corresponds to the produced formatted date string.</p>\n     * <p>This object is automatically populated with date formatting functions as\n     * date formats are requested for Ext standard formatting strings.</p>\n     * <p>Custom formatting functions may be inserted into this object, keyed by a name which from then on\n     * may be used as a format string to {@link #format}. Example:</p><pre><code>\nExt.Date.formatFunctions['x-date-format'] = myDateFormatter;\n</code></pre>\n     * <p>A formatting function should return a string representation of the passed Date object, and is passed the following parameters:<div class=\"mdetail-params\"><ul>\n     * <li><code>date</code> : Date<div class=\"sub-desc\">The Date to format.</div></li>\n     * </ul></div></p>\n     * <p>To enable date strings to also be <i>parsed</i> according to that format, a corresponding\n     * parsing function must be placed into the {@link #parseFunctions} property.\n     * @property formatFunctions\n     * @type Object\n     */\n    formatFunctions: {\n        \"MS\": function() {\n            // UTC milliseconds since Unix epoch (MS-AJAX serialized date format (MRSF))\n            return '\\\\/Date(' + this.getTime() + ')\\\\/';\n        }\n    },\n\n    y2kYear : 50,\n\n    /**\n     * Date interval constant\n     * @type String\n     */\n    MILLI : \"ms\",\n\n    /**\n     * Date interval constant\n     * @type String\n     */\n    SECOND : \"s\",\n\n    /**\n     * Date interval constant\n     * @type String\n     */\n    MINUTE : \"mi\",\n\n    /** Date interval constant\n     * @type String\n     */\n    HOUR : \"h\",\n\n    /**\n     * Date interval constant\n     * @type String\n     */\n    DAY : \"d\",\n\n    /**\n     * Date interval constant\n     * @type String\n     */\n    MONTH : \"mo\",\n\n    /**\n     * Date interval constant\n     * @type String\n     */\n    YEAR : \"y\",\n\n    /**\n     * <p>An object hash containing default date values used during date parsing.</p>\n     * <p>The following properties are available:<div class=\"mdetail-params\"><ul>\n     * <li><code>y</code> : Number<div class=\"sub-desc\">The default year value. (defaults to undefined)</div></li>\n     * <li><code>m</code> : Number<div class=\"sub-desc\">The default 1-based month value. (defaults to undefined)</div></li>\n     * <li><code>d</code> : Number<div class=\"sub-desc\">The default day value. (defaults to undefined)</div></li>\n     * <li><code>h</code> : Number<div class=\"sub-desc\">The default hour value. (defaults to undefined)</div></li>\n     * <li><code>i</code> : Number<div class=\"sub-desc\">The default minute value. (defaults to undefined)</div></li>\n     * <li><code>s</code> : Number<div class=\"sub-desc\">The default second value. (defaults to undefined)</div></li>\n     * <li><code>ms</code> : Number<div class=\"sub-desc\">The default millisecond value. (defaults to undefined)</div></li>\n     * </ul></div></p>\n     * <p>Override these properties to customize the default date values used by the {@link #parse} method.</p>\n     * <p><b>Note: In countries which experience Daylight Saving Time (i.e. DST), the <tt>h</tt>, <tt>i</tt>, <tt>s</tt>\n     * and <tt>ms</tt> properties may coincide with the exact time in which DST takes effect.\n     * It is the responsiblity of the developer to account for this.</b></p>\n     * Example Usage:\n     * <pre><code>\n// set default day value to the first day of the month\nExt.Date.defaults.d = 1;\n\n// parse a February date string containing only year and month values.\n// setting the default day value to 1 prevents weird date rollover issues\n// when attempting to parse the following date string on, for example, March 31st 2009.\nExt.Date.parse('2009-02', 'Y-m'); // returns a Date object representing February 1st 2009\n</code></pre>\n     * @property defaults\n     * @type Object\n     */\n    defaults: {},\n\n    //<locale type=\"array\">\n    /**\n     * @property {String[]} dayNames\n     * An array of textual day names.\n     * Override these values for international dates.\n     * Example:\n     * <pre><code>\nExt.Date.dayNames = [\n    'SundayInYourLang',\n    'MondayInYourLang',\n    ...\n];\n</code></pre>\n     */\n    dayNames : [\n        \"Sunday\",\n        \"Monday\",\n        \"Tuesday\",\n        \"Wednesday\",\n        \"Thursday\",\n        \"Friday\",\n        \"Saturday\"\n    ],\n    //</locale>\n\n    //<locale type=\"array\">\n    /**\n     * @property {String[]} monthNames\n     * An array of textual month names.\n     * Override these values for international dates.\n     * Example:\n     * <pre><code>\nExt.Date.monthNames = [\n    'JanInYourLang',\n    'FebInYourLang',\n    ...\n];\n</code></pre>\n     */\n    monthNames : [\n        \"January\",\n        \"February\",\n        \"March\",\n        \"April\",\n        \"May\",\n        \"June\",\n        \"July\",\n        \"August\",\n        \"September\",\n        \"October\",\n        \"November\",\n        \"December\"\n    ],\n    //</locale>\n\n    //<locale type=\"object\">\n    /**\n     * @property {Object} monthNumbers\n     * An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are case-sensitive).\n     * Override these values for international dates.\n     * Example:\n     * <pre><code>\nExt.Date.monthNumbers = {\n    'LongJanNameInYourLang': 0,\n    'ShortJanNameInYourLang':0,\n    'LongFebNameInYourLang':1,\n    'ShortFebNameInYourLang':1,\n    ...\n};\n</code></pre>\n     */\n    monthNumbers : {\n        January: 0,\n        Jan: 0,\n        February: 1,\n        Feb: 1,\n        March: 2,\n        Mar: 2,\n        April: 3,\n        Apr: 3,\n        May: 4,\n        June: 5,\n        Jun: 5,\n        July: 6,\n        Jul: 6,\n        August: 7,\n        Aug: 7,\n        September: 8,\n        Sep: 8,\n        October: 9,\n        Oct: 9,\n        November: 10,\n        Nov: 10,\n        December: 11,\n        Dec: 11\n    },\n    //</locale>\n    \n    //<locale>\n    /**\n     * @property {String} defaultFormat\n     * <p>The date format string that the {@link Ext.util.Format#dateRenderer}\n     * and {@link Ext.util.Format#date} functions use.  See {@link Ext.Date} for details.</p>\n     * <p>This may be overridden in a locale file.</p>\n     */\n    defaultFormat : \"m/d/Y\",\n    //</locale>\n    //<locale type=\"function\">\n    /**\n     * Get the short month name for the given month number.\n     * Override this function for international dates.\n     * @param {Number} month A zero-based javascript month number.\n     * @return {String} The short month name.\n     */\n    getShortMonthName : function(month) {\n        return Ext.Date.monthNames[month].substring(0, 3);\n    },\n    //</locale>\n\n    //<locale type=\"function\">\n    /**\n     * Get the short day name for the given day number.\n     * Override this function for international dates.\n     * @param {Number} day A zero-based javascript day number.\n     * @return {String} The short day name.\n     */\n    getShortDayName : function(day) {\n        return Ext.Date.dayNames[day].substring(0, 3);\n    },\n    //</locale>\n\n    //<locale type=\"function\">\n    /**\n     * Get the zero-based javascript month number for the given short/full month name.\n     * Override this function for international dates.\n     * @param {String} name The short/full month name.\n     * @return {Number} The zero-based javascript month number.\n     */\n    getMonthNumber : function(name) {\n        // handle camel casing for english month names (since the keys for the Ext.Date.monthNumbers hash are case sensitive)\n        return Ext.Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];\n    },\n    //</locale>\n\n    /**\n     * Checks if the specified format contains hour information\n     * @param {String} format The format to check\n     * @return {Boolean} True if the format contains hour information\n     * @method\n     */\n    formatContainsHourInfo : (function(){\n        var stripEscapeRe = /(\\\\.)/g,\n            hourInfoRe = /([gGhHisucUOPZ]|MS)/;\n        return function(format){\n            return hourInfoRe.test(format.replace(stripEscapeRe, ''));\n        };\n    }()),\n\n    /**\n     * Checks if the specified format contains information about\n     * anything other than the time.\n     * @param {String} format The format to check\n     * @return {Boolean} True if the format contains information about\n     * date/day information.\n     * @method\n     */\n    formatContainsDateInfo : (function(){\n        var stripEscapeRe = /(\\\\.)/g,\n            dateInfoRe = /([djzmnYycU]|MS)/;\n\n        return function(format){\n            return dateInfoRe.test(format.replace(stripEscapeRe, ''));\n        };\n    }()),\n    \n    /**\n     * Removes all escaping for a date format string. In date formats,\n     * using a '\\' can be used to escape special characters.\n     * @param {String} format The format to unescape\n     * @return {String} The unescaped format\n     * @method\n     */\n    unescapeFormat: (function() { \n        var slashRe = /\\\\/gi;\n        return function(format) {\n            // Escape the format, since \\ can be used to escape special\n            // characters in a date format. For example, in a spanish\n            // locale the format may be: 'd \\\\de F \\\\de Y'\n            return format.replace(slashRe, '');\n        }\n    }()),\n\n    /**\n     * The base format-code to formatting-function hashmap used by the {@link #format} method.\n     * Formatting functions are strings (or functions which return strings) which\n     * will return the appropriate value when evaluated in the context of the Date object\n     * from which the {@link #format} method is called.\n     * Add to / override these mappings for custom date formatting.\n     * Note: Ext.Date.format() treats characters as literals if an appropriate mapping cannot be found.\n     * Example:\n     * <pre><code>\nExt.Date.formatCodes.x = \"Ext.util.Format.leftPad(this.getDate(), 2, '0')\";\nconsole.log(Ext.Date.format(new Date(), 'X'); // returns the current day of the month\n</code></pre>\n     * @type Object\n     */\n    formatCodes : {\n        d: \"Ext.String.leftPad(this.getDate(), 2, '0')\",\n        D: \"Ext.Date.getShortDayName(this.getDay())\", // get localised short day name\n        j: \"this.getDate()\",\n        l: \"Ext.Date.dayNames[this.getDay()]\",\n        N: \"(this.getDay() ? this.getDay() : 7)\",\n        S: \"Ext.Date.getSuffix(this)\",\n        w: \"this.getDay()\",\n        z: \"Ext.Date.getDayOfYear(this)\",\n        W: \"Ext.String.leftPad(Ext.Date.getWeekOfYear(this), 2, '0')\",\n        F: \"Ext.Date.monthNames[this.getMonth()]\",\n        m: \"Ext.String.leftPad(this.getMonth() + 1, 2, '0')\",\n        M: \"Ext.Date.getShortMonthName(this.getMonth())\", // get localised short month name\n        n: \"(this.getMonth() + 1)\",\n        t: \"Ext.Date.getDaysInMonth(this)\",\n        L: \"(Ext.Date.isLeapYear(this) ? 1 : 0)\",\n        o: \"(this.getFullYear() + (Ext.Date.getWeekOfYear(this) == 1 && this.getMonth() > 0 ? +1 : (Ext.Date.getWeekOfYear(this) >= 52 && this.getMonth() < 11 ? -1 : 0)))\",\n        Y: \"Ext.String.leftPad(this.getFullYear(), 4, '0')\",\n        y: \"('' + this.getFullYear()).substring(2, 4)\",\n        a: \"(this.getHours() < 12 ? 'am' : 'pm')\",\n        A: \"(this.getHours() < 12 ? 'AM' : 'PM')\",\n        g: \"((this.getHours() % 12) ? this.getHours() % 12 : 12)\",\n        G: \"this.getHours()\",\n        h: \"Ext.String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')\",\n        H: \"Ext.String.leftPad(this.getHours(), 2, '0')\",\n        i: \"Ext.String.leftPad(this.getMinutes(), 2, '0')\",\n        s: \"Ext.String.leftPad(this.getSeconds(), 2, '0')\",\n        u: \"Ext.String.leftPad(this.getMilliseconds(), 3, '0')\",\n        O: \"Ext.Date.getGMTOffset(this)\",\n        P: \"Ext.Date.getGMTOffset(this, true)\",\n        T: \"Ext.Date.getTimezone(this)\",\n        Z: \"(this.getTimezoneOffset() * -60)\",\n\n        c: function() { // ISO-8601 -- GMT format\n            var c, code, i, l, e;\n            for (c = \"Y-m-dTH:i:sP\", code = [], i = 0, l = c.length; i < l; ++i) {\n                e = c.charAt(i);\n                code.push(e == \"T\" ? \"'T'\" : utilDate.getFormatCode(e)); // treat T as a character literal\n            }\n            return code.join(\" + \");\n        },\n        /*\n        c: function() { // ISO-8601 -- UTC format\n            return [\n              \"this.getUTCFullYear()\", \"'-'\",\n              \"Ext.util.Format.leftPad(this.getUTCMonth() + 1, 2, '0')\", \"'-'\",\n              \"Ext.util.Format.leftPad(this.getUTCDate(), 2, '0')\",\n              \"'T'\",\n              \"Ext.util.Format.leftPad(this.getUTCHours(), 2, '0')\", \"':'\",\n              \"Ext.util.Format.leftPad(this.getUTCMinutes(), 2, '0')\", \"':'\",\n              \"Ext.util.Format.leftPad(this.getUTCSeconds(), 2, '0')\",\n              \"'Z'\"\n            ].join(\" + \");\n        },\n        */\n\n        U: \"Math.round(this.getTime() / 1000)\"\n    },\n\n    /**\n     * Checks if the passed Date parameters will cause a javascript Date \"rollover\".\n     * @param {Number} year 4-digit year\n     * @param {Number} month 1-based month-of-year\n     * @param {Number} day Day of month\n     * @param {Number} hour (optional) Hour\n     * @param {Number} minute (optional) Minute\n     * @param {Number} second (optional) Second\n     * @param {Number} millisecond (optional) Millisecond\n     * @return {Boolean} true if the passed parameters do not cause a Date \"rollover\", false otherwise.\n     */\n    isValid : function(y, m, d, h, i, s, ms) {\n        // setup defaults\n        h = h || 0;\n        i = i || 0;\n        s = s || 0;\n        ms = ms || 0;\n\n        // Special handling for year < 100\n        var dt = utilDate.add(new Date(y < 100 ? 100 : y, m - 1, d, h, i, s, ms), utilDate.YEAR, y < 100 ? y - 100 : 0);\n\n        return y == dt.getFullYear() &&\n            m == dt.getMonth() + 1 &&\n            d == dt.getDate() &&\n            h == dt.getHours() &&\n            i == dt.getMinutes() &&\n            s == dt.getSeconds() &&\n            ms == dt.getMilliseconds();\n    },\n\n    /**\n     * Parses the passed string using the specified date format.\n     * Note that this function expects normal calendar dates, meaning that months are 1-based (i.e. 1 = January).\n     * The {@link #defaults} hash will be used for any date value (i.e. year, month, day, hour, minute, second or millisecond)\n     * which cannot be found in the passed string. If a corresponding default date value has not been specified in the {@link #defaults} hash,\n     * the current date's year, month, day or DST-adjusted zero-hour time value will be used instead.\n     * Keep in mind that the input date string must precisely match the specified format string\n     * in order for the parse operation to be successful (failed parse operations return a null value).\n     * <p>Example:</p><pre><code>\n//dt = Fri May 25 2007 (current date)\nvar dt = new Date();\n\n//dt = Thu May 25 2006 (today&#39;s month/day in 2006)\ndt = Ext.Date.parse(\"2006\", \"Y\");\n\n//dt = Sun Jan 15 2006 (all date parts specified)\ndt = Ext.Date.parse(\"2006-01-15\", \"Y-m-d\");\n\n//dt = Sun Jan 15 2006 15:20:01\ndt = Ext.Date.parse(\"2006-01-15 3:20:01 PM\", \"Y-m-d g:i:s A\");\n\n// attempt to parse Sun Feb 29 2006 03:20:01 in strict mode\ndt = Ext.Date.parse(\"2006-02-29 03:20:01\", \"Y-m-d H:i:s\", true); // returns null\n</code></pre>\n     * @param {String} input The raw date string.\n     * @param {String} format The expected date string format.\n     * @param {Boolean} strict (optional) True to validate date strings while parsing (i.e. prevents javascript Date \"rollover\")\n                        (defaults to false). Invalid date strings will return null when parsed.\n     * @return {Date} The parsed Date.\n     */\n    parse : function(input, format, strict) {\n        var p = utilDate.parseFunctions;\n        if (p[format] == null) {\n            utilDate.createParser(format);\n        }\n        return p[format](input, Ext.isDefined(strict) ? strict : utilDate.useStrict);\n    },\n\n    // Backwards compat\n    parseDate: function(input, format, strict){\n        return utilDate.parse(input, format, strict);\n    },\n\n\n    // private\n    getFormatCode : function(character) {\n        var f = utilDate.formatCodes[character];\n\n        if (f) {\n          f = typeof f == 'function'? f() : f;\n          utilDate.formatCodes[character] = f; // reassign function result to prevent repeated execution\n        }\n\n        // note: unknown characters are treated as literals\n        return f || (\"'\" + Ext.String.escape(character) + \"'\");\n    },\n\n    // private\n    createFormat : function(format) {\n        var code = [],\n            special = false,\n            ch = '',\n            i;\n\n        for (i = 0; i < format.length; ++i) {\n            ch = format.charAt(i);\n            if (!special && ch == \"\\\\\") {\n                special = true;\n            } else if (special) {\n                special = false;\n                code.push(\"'\" + Ext.String.escape(ch) + \"'\");\n            } else {\n                code.push(utilDate.getFormatCode(ch));\n            }\n        }\n        utilDate.formatFunctions[format] = Ext.functionFactory(\"return \" + code.join('+'));\n    },\n\n    // private\n    createParser : (function() {\n        var code = [\n            \"var dt, y, m, d, h, i, s, ms, o, z, zz, u, v,\",\n                \"def = Ext.Date.defaults,\",\n                \"results = String(input).match(Ext.Date.parseRegexes[{0}]);\", // either null, or an array of matched strings\n\n            \"if(results){\",\n                \"{1}\",\n\n                \"if(u != null){\", // i.e. unix time is defined\n                    \"v = new Date(u * 1000);\", // give top priority to UNIX time\n                \"}else{\",\n                    // create Date object representing midnight of the current day;\n                    // this will provide us with our date defaults\n                    // (note: clearTime() handles Daylight Saving Time automatically)\n                    \"dt = Ext.Date.clearTime(new Date);\",\n\n                    // date calculations (note: these calculations create a dependency on Ext.Number.from())\n                    \"y = Ext.Number.from(y, Ext.Number.from(def.y, dt.getFullYear()));\",\n                    \"m = Ext.Number.from(m, Ext.Number.from(def.m - 1, dt.getMonth()));\",\n                    \"d = Ext.Number.from(d, Ext.Number.from(def.d, dt.getDate()));\",\n\n                    // time calculations (note: these calculations create a dependency on Ext.Number.from())\n                    \"h  = Ext.Number.from(h, Ext.Number.from(def.h, dt.getHours()));\",\n                    \"i  = Ext.Number.from(i, Ext.Number.from(def.i, dt.getMinutes()));\",\n                    \"s  = Ext.Number.from(s, Ext.Number.from(def.s, dt.getSeconds()));\",\n                    \"ms = Ext.Number.from(ms, Ext.Number.from(def.ms, dt.getMilliseconds()));\",\n\n                    \"if(z >= 0 && y >= 0){\",\n                        // both the year and zero-based day of year are defined and >= 0.\n                        // these 2 values alone provide sufficient info to create a full date object\n\n                        // create Date object representing January 1st for the given year\n                        // handle years < 100 appropriately\n                        \"v = Ext.Date.add(new Date(y < 100 ? 100 : y, 0, 1, h, i, s, ms), Ext.Date.YEAR, y < 100 ? y - 100 : 0);\",\n\n                        // then add day of year, checking for Date \"rollover\" if necessary\n                        \"v = !strict? v : (strict === true && (z <= 364 || (Ext.Date.isLeapYear(v) && z <= 365))? Ext.Date.add(v, Ext.Date.DAY, z) : null);\",\n                    \"}else if(strict === true && !Ext.Date.isValid(y, m + 1, d, h, i, s, ms)){\", // check for Date \"rollover\"\n                        \"v = null;\", // invalid date, so return null\n                    \"}else{\",\n                        // plain old Date object\n                        // handle years < 100 properly\n                        \"v = Ext.Date.add(new Date(y < 100 ? 100 : y, m, d, h, i, s, ms), Ext.Date.YEAR, y < 100 ? y - 100 : 0);\",\n                    \"}\",\n                \"}\",\n            \"}\",\n\n            \"if(v){\",\n                // favour UTC offset over GMT offset\n                \"if(zz != null){\",\n                    // reset to UTC, then add offset\n                    \"v = Ext.Date.add(v, Ext.Date.SECOND, -v.getTimezoneOffset() * 60 - zz);\",\n                \"}else if(o){\",\n                    // reset to GMT, then add offset\n                    \"v = Ext.Date.add(v, Ext.Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));\",\n                \"}\",\n            \"}\",\n\n            \"return v;\"\n        ].join('\\n');\n\n        return function(format) {\n            var regexNum = utilDate.parseRegexes.length,\n                currentGroup = 1,\n                calc = [],\n                regex = [],\n                special = false,\n                ch = \"\",\n                i = 0,\n                len = format.length,\n                atEnd = [],\n                obj;\n\n            for (; i < len; ++i) {\n                ch = format.charAt(i);\n                if (!special && ch == \"\\\\\") {\n                    special = true;\n                } else if (special) {\n                    special = false;\n                    regex.push(Ext.String.escape(ch));\n                } else {\n                    obj = utilDate.formatCodeToRegex(ch, currentGroup);\n                    currentGroup += obj.g;\n                    regex.push(obj.s);\n                    if (obj.g && obj.c) {\n                        if (obj.calcAtEnd) {\n                            atEnd.push(obj.c);\n                        } else {\n                            calc.push(obj.c);\n                        }\n                    }\n                }\n            }\n            \n            calc = calc.concat(atEnd);\n\n            utilDate.parseRegexes[regexNum] = new RegExp(\"^\" + regex.join('') + \"$\", 'i');\n            utilDate.parseFunctions[format] = Ext.functionFactory(\"input\", \"strict\", xf(code, regexNum, calc.join('')));\n        };\n    }()),\n\n    // private\n    parseCodes : {\n        /*\n         * Notes:\n         * g = {Number} calculation group (0 or 1. only group 1 contributes to date calculations.)\n         * c = {String} calculation method (required for group 1. null for group 0. {0} = currentGroup - position in regex result array)\n         * s = {String} regex pattern. all matches are stored in results[], and are accessible by the calculation mapped to 'c'\n         */\n        d: {\n            g:1,\n            c:\"d = parseInt(results[{0}], 10);\\n\",\n            s:\"(3[0-1]|[1-2][0-9]|0[1-9])\" // day of month with leading zeroes (01 - 31)\n        },\n        j: {\n            g:1,\n            c:\"d = parseInt(results[{0}], 10);\\n\",\n            s:\"(3[0-1]|[1-2][0-9]|[1-9])\" // day of month without leading zeroes (1 - 31)\n        },\n        D: function() {\n            for (var a = [], i = 0; i < 7; a.push(utilDate.getShortDayName(i)), ++i); // get localised short day names\n            return {\n                g:0,\n                c:null,\n                s:\"(?:\" + a.join(\"|\") +\")\"\n            };\n        },\n        l: function() {\n            return {\n                g:0,\n                c:null,\n                s:\"(?:\" + utilDate.dayNames.join(\"|\") + \")\"\n            };\n        },\n        N: {\n            g:0,\n            c:null,\n            s:\"[1-7]\" // ISO-8601 day number (1 (monday) - 7 (sunday))\n        },\n        //<locale type=\"object\" property=\"parseCodes\">\n        S: {\n            g:0,\n            c:null,\n            s:\"(?:st|nd|rd|th)\"\n        },\n        //</locale>\n        w: {\n            g:0,\n            c:null,\n            s:\"[0-6]\" // javascript day number (0 (sunday) - 6 (saturday))\n        },\n        z: {\n            g:1,\n            c:\"z = parseInt(results[{0}], 10);\\n\",\n            s:\"(\\\\d{1,3})\" // day of the year (0 - 364 (365 in leap years))\n        },\n        W: {\n            g:0,\n            c:null,\n            s:\"(?:\\\\d{2})\" // ISO-8601 week number (with leading zero)\n        },\n        F: function() {\n            return {\n                g:1,\n                c:\"m = parseInt(Ext.Date.getMonthNumber(results[{0}]), 10);\\n\", // get localised month number\n                s:\"(\" + utilDate.monthNames.join(\"|\") + \")\"\n            };\n        },\n        M: function() {\n            for (var a = [], i = 0; i < 12; a.push(utilDate.getShortMonthName(i)), ++i); // get localised short month names\n            return Ext.applyIf({\n                s:\"(\" + a.join(\"|\") + \")\"\n            }, utilDate.formatCodeToRegex(\"F\"));\n        },\n        m: {\n            g:1,\n            c:\"m = parseInt(results[{0}], 10) - 1;\\n\",\n            s:\"(1[0-2]|0[1-9])\" // month number with leading zeros (01 - 12)\n        },\n        n: {\n            g:1,\n            c:\"m = parseInt(results[{0}], 10) - 1;\\n\",\n            s:\"(1[0-2]|[1-9])\" // month number without leading zeros (1 - 12)\n        },\n        t: {\n            g:0,\n            c:null,\n            s:\"(?:\\\\d{2})\" // no. of days in the month (28 - 31)\n        },\n        L: {\n            g:0,\n            c:null,\n            s:\"(?:1|0)\"\n        },\n        o: function() {\n            return utilDate.formatCodeToRegex(\"Y\");\n        },\n        Y: {\n            g:1,\n            c:\"y = parseInt(results[{0}], 10);\\n\",\n            s:\"(\\\\d{4})\" // 4-digit year\n        },\n        y: {\n            g:1,\n            c:\"var ty = parseInt(results[{0}], 10);\\n\"\n                + \"y = ty > Ext.Date.y2kYear ? 1900 + ty : 2000 + ty;\\n\", // 2-digit year\n            s:\"(\\\\d{1,2})\"\n        },\n        /*\n         * In the am/pm parsing routines, we allow both upper and lower case\n         * even though it doesn't exactly match the spec. It gives much more flexibility\n         * in being able to specify case insensitive regexes.\n         */\n        //<locale type=\"object\" property=\"parseCodes\">\n        a: {\n            g:1,\n            c:\"if (/(am)/i.test(results[{0}])) {\\n\"\n                + \"if (!h || h == 12) { h = 0; }\\n\"\n                + \"} else { if (!h || h < 12) { h = (h || 0) + 12; }}\",\n            s:\"(am|pm|AM|PM)\",\n            calcAtEnd: true\n        },\n        //</locale>\n        //<locale type=\"object\" property=\"parseCodes\">\n        A: {\n            g:1,\n            c:\"if (/(am)/i.test(results[{0}])) {\\n\"\n                + \"if (!h || h == 12) { h = 0; }\\n\"\n                + \"} else { if (!h || h < 12) { h = (h || 0) + 12; }}\",\n            s:\"(AM|PM|am|pm)\",\n            calcAtEnd: true\n        },\n        //</locale>\n        g: {\n            g:1,\n            c:\"h = parseInt(results[{0}], 10);\\n\",\n            s:\"(1[0-2]|[0-9])\" //  12-hr format of an hour without leading zeroes (1 - 12)\n        },\n        G: {\n            g:1,\n            c:\"h = parseInt(results[{0}], 10);\\n\",\n            s:\"(2[0-3]|1[0-9]|[0-9])\" // 24-hr format of an hour without leading zeroes (0 - 23)\n        },\n        h: {\n            g:1,\n            c:\"h = parseInt(results[{0}], 10);\\n\",\n            s:\"(1[0-2]|0[1-9])\" //  12-hr format of an hour with leading zeroes (01 - 12)\n        },\n        H: {\n            g:1,\n            c:\"h = parseInt(results[{0}], 10);\\n\",\n            s:\"(2[0-3]|[0-1][0-9])\" //  24-hr format of an hour with leading zeroes (00 - 23)\n        },\n        i: {\n            g:1,\n            c:\"i = parseInt(results[{0}], 10);\\n\",\n            s:\"([0-5][0-9])\" // minutes with leading zeros (00 - 59)\n        },\n        s: {\n            g:1,\n            c:\"s = parseInt(results[{0}], 10);\\n\",\n            s:\"([0-5][0-9])\" // seconds with leading zeros (00 - 59)\n        },\n        u: {\n            g:1,\n            c:\"ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\\n\",\n            s:\"(\\\\d+)\" // decimal fraction of a second (minimum = 1 digit, maximum = unlimited)\n        },\n        O: {\n            g:1,\n            c:[\n                \"o = results[{0}];\",\n                \"var sn = o.substring(0,1),\", // get + / - sign\n                    \"hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),\", // get hours (performs minutes-to-hour conversion also, just in case)\n                    \"mn = o.substring(3,5) % 60;\", // get minutes\n                \"o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + Ext.String.leftPad(hr, 2, '0') + Ext.String.leftPad(mn, 2, '0')) : null;\\n\" // -12hrs <= GMT offset <= 14hrs\n            ].join(\"\\n\"),\n            s: \"([+-]\\\\d{4})\" // GMT offset in hrs and mins\n        },\n        P: {\n            g:1,\n            c:[\n                \"o = results[{0}];\",\n                \"var sn = o.substring(0,1),\", // get + / - sign\n                    \"hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),\", // get hours (performs minutes-to-hour conversion also, just in case)\n                    \"mn = o.substring(4,6) % 60;\", // get minutes\n                \"o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + Ext.String.leftPad(hr, 2, '0') + Ext.String.leftPad(mn, 2, '0')) : null;\\n\" // -12hrs <= GMT offset <= 14hrs\n            ].join(\"\\n\"),\n            s: \"([+-]\\\\d{2}:\\\\d{2})\" // GMT offset in hrs and mins (with colon separator)\n        },\n        T: {\n            g:0,\n            c:null,\n            s:\"[A-Z]{1,4}\" // timezone abbrev. may be between 1 - 4 chars\n        },\n        Z: {\n            g:1,\n            c:\"zz = results[{0}] * 1;\\n\" // -43200 <= UTC offset <= 50400\n                  + \"zz = (-43200 <= zz && zz <= 50400)? zz : null;\\n\",\n            s:\"([+-]?\\\\d{1,5})\" // leading '+' sign is optional for UTC offset\n        },\n        c: function() {\n            var calc = [],\n                arr = [\n                    utilDate.formatCodeToRegex(\"Y\", 1), // year\n                    utilDate.formatCodeToRegex(\"m\", 2), // month\n                    utilDate.formatCodeToRegex(\"d\", 3), // day\n                    utilDate.formatCodeToRegex(\"H\", 4), // hour\n                    utilDate.formatCodeToRegex(\"i\", 5), // minute\n                    utilDate.formatCodeToRegex(\"s\", 6), // second\n                    {c:\"ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\\n\"}, // decimal fraction of a second (minimum = 1 digit, maximum = unlimited)\n                    {c:[ // allow either \"Z\" (i.e. UTC) or \"-0530\" or \"+08:00\" (i.e. UTC offset) timezone delimiters. assumes local timezone if no timezone is specified\n                        \"if(results[8]) {\", // timezone specified\n                            \"if(results[8] == 'Z'){\",\n                                \"zz = 0;\", // UTC\n                            \"}else if (results[8].indexOf(':') > -1){\",\n                                utilDate.formatCodeToRegex(\"P\", 8).c, // timezone offset with colon separator\n                            \"}else{\",\n                                utilDate.formatCodeToRegex(\"O\", 8).c, // timezone offset without colon separator\n                            \"}\",\n                        \"}\"\n                    ].join('\\n')}\n                ],\n                i,\n                l;\n\n            for (i = 0, l = arr.length; i < l; ++i) {\n                calc.push(arr[i].c);\n            }\n\n            return {\n                g:1,\n                c:calc.join(\"\"),\n                s:[\n                    arr[0].s, // year (required)\n                    \"(?:\", \"-\", arr[1].s, // month (optional)\n                        \"(?:\", \"-\", arr[2].s, // day (optional)\n                            \"(?:\",\n                                \"(?:T| )?\", // time delimiter -- either a \"T\" or a single blank space\n                                arr[3].s, \":\", arr[4].s,  // hour AND minute, delimited by a single colon (optional). MUST be preceded by either a \"T\" or a single blank space\n                                \"(?::\", arr[5].s, \")?\", // seconds (optional)\n                                \"(?:(?:\\\\.|,)(\\\\d+))?\", // decimal fraction of a second (e.g. \",12345\" or \".98765\") (optional)\n                                \"(Z|(?:[-+]\\\\d{2}(?::)?\\\\d{2}))?\", // \"Z\" (UTC) or \"-0530\" (UTC offset without colon delimiter) or \"+08:00\" (UTC offset with colon delimiter) (optional)\n                            \")?\",\n                        \")?\",\n                    \")?\"\n                ].join(\"\")\n            };\n        },\n        U: {\n            g:1,\n            c:\"u = parseInt(results[{0}], 10);\\n\",\n            s:\"(-?\\\\d+)\" // leading minus sign indicates seconds before UNIX epoch\n        }\n    },\n\n    //Old Ext.Date prototype methods.\n    // private\n    dateFormat: function(date, format) {\n        return utilDate.format(date, format);\n    },\n\n    /**\n     * Compares if two dates are equal by comparing their values.\n     * @param {Date} date1\n     * @param {Date} date2\n     * @return {Boolean} True if the date values are equal\n     */\n    isEqual: function(date1, date2) {\n        // check we have 2 date objects\n        if (date1 && date2) {\n            return (date1.getTime() === date2.getTime());\n        }\n        // one or both isn't a date, only equal if both are falsey\n        return !(date1 || date2);\n    },\n\n    /**\n     * Formats a date given the supplied format string.\n     * @param {Date} date The date to format\n     * @param {String} format The format string\n     * @return {String} The formatted date or an empty string if date parameter is not a JavaScript Date object\n     */\n    format: function(date, format) {\n        var formatFunctions = utilDate.formatFunctions;\n\n        if (!Ext.isDate(date)) {\n            return '';\n        }\n\n        if (formatFunctions[format] == null) {\n            utilDate.createFormat(format);\n        }\n\n        return formatFunctions[format].call(date) + '';\n    },\n\n    /**\n     * Get the timezone abbreviation of the current date (equivalent to the format specifier 'T').\n     *\n     * Note: The date string returned by the javascript Date object's toString() method varies\n     * between browsers (e.g. FF vs IE) and system region settings (e.g. IE in Asia vs IE in America).\n     * For a given date string e.g. \"Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)\",\n     * getTimezone() first tries to get the timezone abbreviation from between a pair of parentheses\n     * (which may or may not be present), failing which it proceeds to get the timezone abbreviation\n     * from the GMT offset portion of the date string.\n     * @param {Date} date The date\n     * @return {String} The abbreviated timezone name (e.g. 'CST', 'PDT', 'EDT', 'MPST' ...).\n     */\n    getTimezone : function(date) {\n        // the following list shows the differences between date strings from different browsers on a WinXP SP2 machine from an Asian locale:\n        //\n        // Opera  : \"Thu, 25 Oct 2007 22:53:45 GMT+0800\" -- shortest (weirdest) date string of the lot\n        // Safari : \"Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)\" -- value in parentheses always gives the correct timezone (same as FF)\n        // FF     : \"Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)\" -- value in parentheses always gives the correct timezone\n        // IE     : \"Thu Oct 25 22:54:35 UTC+0800 2007\" -- (Asian system setting) look for 3-4 letter timezone abbrev\n        // IE     : \"Thu Oct 25 17:06:37 PDT 2007\" -- (American system setting) look for 3-4 letter timezone abbrev\n        //\n        // this crazy regex attempts to guess the correct timezone abbreviation despite these differences.\n        // step 1: (?:\\((.*)\\) -- find timezone in parentheses\n        // step 2: ([A-Z]{1,4})(?:[\\-+][0-9]{4})?(?: -?\\d+)?) -- if nothing was found in step 1, find timezone from timezone offset portion of date string\n        // step 3: remove all non uppercase characters found in step 1 and 2\n        return date.toString().replace(/^.* (?:\\((.*)\\)|([A-Z]{1,4})(?:[\\-+][0-9]{4})?(?: -?\\d+)?)$/, \"$1$2\").replace(/[^A-Z]/g, \"\");\n    },\n\n    /**\n     * Get the offset from GMT of the current date (equivalent to the format specifier 'O').\n     * @param {Date} date The date\n     * @param {Boolean} colon (optional) true to separate the hours and minutes with a colon (defaults to false).\n     * @return {String} The 4-character offset string prefixed with + or - (e.g. '-0600').\n     */\n    getGMTOffset : function(date, colon) {\n        var offset = date.getTimezoneOffset();\n        return (offset > 0 ? \"-\" : \"+\")\n            + Ext.String.leftPad(Math.floor(Math.abs(offset) / 60), 2, \"0\")\n            + (colon ? \":\" : \"\")\n            + Ext.String.leftPad(Math.abs(offset % 60), 2, \"0\");\n    },\n\n    /**\n     * Get the numeric day number of the year, adjusted for leap year.\n     * @param {Date} date The date\n     * @return {Number} 0 to 364 (365 in leap years).\n     */\n    getDayOfYear: function(date) {\n        var num = 0,\n            d = Ext.Date.clone(date),\n            m = date.getMonth(),\n            i;\n\n        for (i = 0, d.setDate(1), d.setMonth(0); i < m; d.setMonth(++i)) {\n            num += utilDate.getDaysInMonth(d);\n        }\n        return num + date.getDate() - 1;\n    },\n\n    /**\n     * Get the numeric ISO-8601 week number of the year.\n     * (equivalent to the format specifier 'W', but without a leading zero).\n     * @param {Date} date The date\n     * @return {Number} 1 to 53\n     * @method\n     */\n    getWeekOfYear : (function() {\n        // adapted from http://www.merlyn.demon.co.uk/weekcalc.htm\n        var ms1d = 864e5, // milliseconds in a day\n            ms7d = 7 * ms1d; // milliseconds in a week\n\n        return function(date) { // return a closure so constants get calculated only once\n            var DC3 = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate() + 3) / ms1d, // an Absolute Day Number\n                AWN = Math.floor(DC3 / 7), // an Absolute Week Number\n                Wyr = new Date(AWN * ms7d).getUTCFullYear();\n\n            return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;\n        };\n    }()),\n\n    /**\n     * Checks if the current date falls within a leap year.\n     * @param {Date} date The date\n     * @return {Boolean} True if the current date falls within a leap year, false otherwise.\n     */\n    isLeapYear : function(date) {\n        var year = date.getFullYear();\n        return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));\n    },\n\n    /**\n     * Get the first day of the current month, adjusted for leap year.  The returned value\n     * is the numeric day index within the week (0-6) which can be used in conjunction with\n     * the {@link #monthNames} array to retrieve the textual day name.\n     * Example:\n     * <pre><code>\nvar dt = new Date('1/10/2007'),\n    firstDay = Ext.Date.getFirstDayOfMonth(dt);\nconsole.log(Ext.Date.dayNames[firstDay]); //output: 'Monday'\n     * </code></pre>\n     * @param {Date} date The date\n     * @return {Number} The day number (0-6).\n     */\n    getFirstDayOfMonth : function(date) {\n        var day = (date.getDay() - (date.getDate() - 1)) % 7;\n        return (day < 0) ? (day + 7) : day;\n    },\n\n    /**\n     * Get the last day of the current month, adjusted for leap year.  The returned value\n     * is the numeric day index within the week (0-6) which can be used in conjunction with\n     * the {@link #monthNames} array to retrieve the textual day name.\n     * Example:\n     * <pre><code>\nvar dt = new Date('1/10/2007'),\n    lastDay = Ext.Date.getLastDayOfMonth(dt);\nconsole.log(Ext.Date.dayNames[lastDay]); //output: 'Wednesday'\n     * </code></pre>\n     * @param {Date} date The date\n     * @return {Number} The day number (0-6).\n     */\n    getLastDayOfMonth : function(date) {\n        return utilDate.getLastDateOfMonth(date).getDay();\n    },\n\n\n    /**\n     * Get the date of the first day of the month in which this date resides.\n     * @param {Date} date The date\n     * @return {Date}\n     */\n    getFirstDateOfMonth : function(date) {\n        return new Date(date.getFullYear(), date.getMonth(), 1);\n    },\n\n    /**\n     * Get the date of the last day of the month in which this date resides.\n     * @param {Date} date The date\n     * @return {Date}\n     */\n    getLastDateOfMonth : function(date) {\n        return new Date(date.getFullYear(), date.getMonth(), utilDate.getDaysInMonth(date));\n    },\n\n    /**\n     * Get the number of days in the current month, adjusted for leap year.\n     * @param {Date} date The date\n     * @return {Number} The number of days in the month.\n     * @method\n     */\n    getDaysInMonth: (function() {\n        var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\n        return function(date) { // return a closure for efficiency\n            var m = date.getMonth();\n\n            return m == 1 && utilDate.isLeapYear(date) ? 29 : daysInMonth[m];\n        };\n    }()),\n\n    //<locale type=\"function\">\n    /**\n     * Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').\n     * @param {Date} date The date\n     * @return {String} 'st, 'nd', 'rd' or 'th'.\n     */\n    getSuffix : function(date) {\n        switch (date.getDate()) {\n            case 1:\n            case 21:\n            case 31:\n                return \"st\";\n            case 2:\n            case 22:\n                return \"nd\";\n            case 3:\n            case 23:\n                return \"rd\";\n            default:\n                return \"th\";\n        }\n    },\n    //</locale>\n\n    /**\n     * Creates and returns a new Date instance with the exact same date value as the called instance.\n     * Dates are copied and passed by reference, so if a copied date variable is modified later, the original\n     * variable will also be changed.  When the intention is to create a new variable that will not\n     * modify the original instance, you should create a clone.\n     *\n     * Example of correctly cloning a date:\n     * <pre><code>\n//wrong way:\nvar orig = new Date('10/1/2006');\nvar copy = orig;\ncopy.setDate(5);\nconsole.log(orig);  //returns 'Thu Oct 05 2006'!\n\n//correct way:\nvar orig = new Date('10/1/2006'),\n    copy = Ext.Date.clone(orig);\ncopy.setDate(5);\nconsole.log(orig);  //returns 'Thu Oct 01 2006'\n     * </code></pre>\n     * @param {Date} date The date\n     * @return {Date} The new Date instance.\n     */\n    clone : function(date) {\n        return new Date(date.getTime());\n    },\n\n    /**\n     * Checks if the current date is affected by Daylight Saving Time (DST).\n     * @param {Date} date The date\n     * @return {Boolean} True if the current date is affected by DST.\n     */\n    isDST : function(date) {\n        // adapted from http://sencha.com/forum/showthread.php?p=247172#post247172\n        // courtesy of @geoffrey.mcgill\n        return new Date(date.getFullYear(), 0, 1).getTimezoneOffset() != date.getTimezoneOffset();\n    },\n\n    /**\n     * Attempts to clear all time information from this Date by setting the time to midnight of the same day,\n     * automatically adjusting for Daylight Saving Time (DST) where applicable.\n     * (note: DST timezone information for the browser's host operating system is assumed to be up-to-date)\n     * @param {Date} date The date\n     * @param {Boolean} clone true to create a clone of this date, clear the time and return it (defaults to false).\n     * @return {Date} this or the clone.\n     */\n    clearTime : function(date, clone) {\n        if (clone) {\n            return Ext.Date.clearTime(Ext.Date.clone(date));\n        }\n\n        // get current date before clearing time\n        var d = date.getDate(),\n            hr,\n            c;\n\n        // clear time\n        date.setHours(0);\n        date.setMinutes(0);\n        date.setSeconds(0);\n        date.setMilliseconds(0);\n\n        if (date.getDate() != d) { // account for DST (i.e. day of month changed when setting hour = 0)\n            // note: DST adjustments are assumed to occur in multiples of 1 hour (this is almost always the case)\n            // refer to http://www.timeanddate.com/time/aboutdst.html for the (rare) exceptions to this rule\n\n            // increment hour until cloned date == current date\n            for (hr = 1, c = utilDate.add(date, Ext.Date.HOUR, hr); c.getDate() != d; hr++, c = utilDate.add(date, Ext.Date.HOUR, hr));\n\n            date.setDate(d);\n            date.setHours(c.getHours());\n        }\n\n        return date;\n    },\n\n    /**\n     * Provides a convenient method for performing basic date arithmetic. This method\n     * does not modify the Date instance being called - it creates and returns\n     * a new Date instance containing the resulting date value.\n     *\n     * Examples:\n     * <pre><code>\n// Basic usage:\nvar dt = Ext.Date.add(new Date('10/29/2006'), Ext.Date.DAY, 5);\nconsole.log(dt); //returns 'Fri Nov 03 2006 00:00:00'\n\n// Negative values will be subtracted:\nvar dt2 = Ext.Date.add(new Date('10/1/2006'), Ext.Date.DAY, -5);\nconsole.log(dt2); //returns 'Tue Sep 26 2006 00:00:00'\n\n     * </code></pre>\n     *\n     * @param {Date} date The date to modify\n     * @param {String} interval A valid date interval enum value.\n     * @param {Number} value The amount to add to the current date.\n     * @return {Date} The new Date instance.\n     */\n    add : function(date, interval, value) {\n        var d = Ext.Date.clone(date),\n            Date = Ext.Date,\n            day;\n        if (!interval || value === 0) {\n            return d;\n        }\n\n        switch(interval.toLowerCase()) {\n            case Ext.Date.MILLI:\n                d.setMilliseconds(d.getMilliseconds() + value);\n                break;\n            case Ext.Date.SECOND:\n                d.setSeconds(d.getSeconds() + value);\n                break;\n            case Ext.Date.MINUTE:\n                d.setMinutes(d.getMinutes() + value);\n                break;\n            case Ext.Date.HOUR:\n                d.setHours(d.getHours() + value);\n                break;\n            case Ext.Date.DAY:\n                d.setDate(d.getDate() + value);\n                break;\n            case Ext.Date.MONTH:\n                day = date.getDate();\n                if (day > 28) {\n                    day = Math.min(day, Ext.Date.getLastDateOfMonth(Ext.Date.add(Ext.Date.getFirstDateOfMonth(date), Ext.Date.MONTH, value)).getDate());\n                }\n                d.setDate(day);\n                d.setMonth(date.getMonth() + value);\n                break;\n            case Ext.Date.YEAR:\n                day = date.getDate();\n                if (day > 28) {\n                    day = Math.min(day, Ext.Date.getLastDateOfMonth(Ext.Date.add(Ext.Date.getFirstDateOfMonth(date), Ext.Date.YEAR, value)).getDate());\n                }\n                d.setDate(day);\n                d.setFullYear(date.getFullYear() + value);\n                break;\n        }\n        return d;\n    },\n\n    /**\n     * Checks if a date falls on or between the given start and end dates.\n     * @param {Date} date The date to check\n     * @param {Date} start Start date\n     * @param {Date} end End date\n     * @return {Boolean} true if this date falls on or between the given start and end dates.\n     */\n    between : function(date, start, end) {\n        var t = date.getTime();\n        return start.getTime() <= t && t <= end.getTime();\n    },\n\n    //Maintains compatibility with old static and prototype window.Date methods.\n    compat: function() {\n        var nativeDate = window.Date,\n            p, u,\n            statics = ['useStrict', 'formatCodeToRegex', 'parseFunctions', 'parseRegexes', 'formatFunctions', 'y2kYear', 'MILLI', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'MONTH', 'YEAR', 'defaults', 'dayNames', 'monthNames', 'monthNumbers', 'getShortMonthName', 'getShortDayName', 'getMonthNumber', 'formatCodes', 'isValid', 'parseDate', 'getFormatCode', 'createFormat', 'createParser', 'parseCodes'],\n            proto = ['dateFormat', 'format', 'getTimezone', 'getGMTOffset', 'getDayOfYear', 'getWeekOfYear', 'isLeapYear', 'getFirstDayOfMonth', 'getLastDayOfMonth', 'getDaysInMonth', 'getSuffix', 'clone', 'isDST', 'clearTime', 'add', 'between'],\n            sLen    = statics.length,\n            pLen    = proto.length,\n            stat, prot, s;\n\n        //Append statics\n        for (s = 0; s < sLen; s++) {\n            stat = statics[s];\n            nativeDate[stat] = utilDate[stat];\n        }\n\n        //Append to prototype\n        for (p = 0; p < pLen; p++) {\n            prot = proto[p];\n            nativeDate.prototype[prot] = function() {\n                var args = Array.prototype.slice.call(arguments);\n                args.unshift(this);\n                return utilDate[prot].apply(utilDate, args);\n            };\n        }\n    }\n};\n\nvar utilDate = Ext.Date;\n\n}());\n\n//@tag foundation,core\n//@require ../lang/Date.js\n\n/**\n * @author Jacky Nguyen <jacky@sencha.com>\n * @docauthor Jacky Nguyen <jacky@sencha.com>\n * @class Ext.Base\n *\n * The root of all classes created with {@link Ext#define}.\n *\n * Ext.Base is the building block of all Ext classes. All classes in Ext inherit from Ext.Base.\n * All prototype and static members of this class are inherited by all other classes.\n */\n(function(flexSetter) {\n\nvar noArgs = [],\n    Base = function(){};\n\n    // These static properties will be copied to every newly created class with {@link Ext#define}\n    Ext.apply(Base, {\n        $className: 'Ext.Base',\n\n        $isClass: true,\n\n        /**\n         * Create a new instance of this Class.\n         *\n         *     Ext.define('My.cool.Class', {\n         *         ...\n         *     });\n         *\n         *     My.cool.Class.create({\n         *         someConfig: true\n         *     });\n         *\n         * All parameters are passed to the constructor of the class.\n         *\n         * @return {Object} the created instance.\n         * @static\n         * @inheritable\n         */\n        create: function() {\n            return Ext.create.apply(Ext, [this].concat(Array.prototype.slice.call(arguments, 0)));\n        },\n\n        /**\n         * @private\n         * @static\n         * @inheritable\n         * @param config\n         */\n        extend: function(parent) {\n            var parentPrototype = parent.prototype,\n                basePrototype, prototype, i, ln, name, statics;\n\n            prototype = this.prototype = Ext.Object.chain(parentPrototype);\n            prototype.self = this;\n\n            this.superclass = prototype.superclass = parentPrototype;\n\n            if (!parent.$isClass) {\n                basePrototype = Ext.Base.prototype;\n\n                for (i in basePrototype) {\n                    if (i in prototype) {\n                        prototype[i] = basePrototype[i];\n                    }\n                }\n            }\n\n            // Statics inheritance\n            statics = parentPrototype.$inheritableStatics;\n\n            if (statics) {\n                for (i = 0,ln = statics.length; i < ln; i++) {\n                    name = statics[i];\n\n                    if (!this.hasOwnProperty(name)) {\n                        this[name] = parent[name];\n                    }\n                }\n            }\n\n            if (parent.$onExtended) {\n                this.$onExtended = parent.$onExtended.slice();\n            }\n\n            prototype.config = new prototype.configClass();\n            prototype.initConfigList = prototype.initConfigList.slice();\n            prototype.initConfigMap = Ext.clone(prototype.initConfigMap);\n            prototype.configMap = Ext.Object.chain(prototype.configMap);\n        },\n\n        /**\n         * @private\n         * @static\n         * @inheritable\n         */\n        $onExtended: [],\n\n        /**\n         * @private\n         * @static\n         * @inheritable\n         */\n        triggerExtended: function() {\n            var callbacks = this.$onExtended,\n                ln = callbacks.length,\n                i, callback;\n\n            if (ln > 0) {\n                for (i = 0; i < ln; i++) {\n                    callback = callbacks[i];\n                    callback.fn.apply(callback.scope || this, arguments);\n                }\n            }\n        },\n\n        /**\n         * @private\n         * @static\n         * @inheritable\n         */\n        onExtended: function(fn, scope) {\n            this.$onExtended.push({\n                fn: fn,\n                scope: scope\n            });\n\n            return this;\n        },\n\n        /**\n         * @private\n         * @static\n         * @inheritable\n         * @param config\n         */\n        addConfig: function(config, fullMerge) {\n            var prototype = this.prototype,\n                configNameCache = Ext.Class.configNameCache,\n                hasConfig = prototype.configMap,\n                initConfigList = prototype.initConfigList,\n                initConfigMap = prototype.initConfigMap,\n                defaultConfig = prototype.config,\n                initializedName, name, value;\n\n            for (name in config) {\n                if (config.hasOwnProperty(name)) {\n                    if (!hasConfig[name]) {\n                        hasConfig[name] = true;\n                    }\n\n                    value = config[name];\n\n                    initializedName = configNameCache[name].initialized;\n\n                    if (!initConfigMap[name] && value !== null && !prototype[initializedName]) {\n                        initConfigMap[name] = true;\n                        initConfigList.push(name);\n                    }\n                }\n            }\n\n            if (fullMerge) {\n                Ext.merge(defaultConfig, config);\n            }\n            else {\n                Ext.mergeIf(defaultConfig, config);\n            }\n\n            prototype.configClass = Ext.Object.classify(defaultConfig);\n        },\n\n        /**\n         * Add / override static properties of this class.\n         *\n         *     Ext.define('My.cool.Class', {\n         *         ...\n         *     });\n         *\n         *     My.cool.Class.addStatics({\n         *         someProperty: 'someValue',      // My.cool.Class.someProperty = 'someValue'\n         *         method1: function() { ... },    // My.cool.Class.method1 = function() { ... };\n         *         method2: function() { ... }     // My.cool.Class.method2 = function() { ... };\n         *     });\n         *\n         * @param {Object} members\n         * @return {Ext.Base} this\n         * @static\n         * @inheritable\n         */\n        addStatics: function(members) {\n            var member, name;\n\n            for (name in members) {\n                if (members.hasOwnProperty(name)) {\n                    member = members[name];\n                    if (typeof member == 'function' && !member.$isClass && member !== Ext.emptyFn && member !== Ext.identityFn) {\n                        member.$owner = this;\n                        member.$name = name;\n                        member.displayName = Ext.getClassName(this) + '.' + name;\n                    }\n                    this[name] = member;\n                }\n            }\n\n            return this;\n        },\n\n        /**\n         * @private\n         * @static\n         * @inheritable\n         * @param {Object} members\n         */\n        addInheritableStatics: function(members) {\n            var inheritableStatics,\n                hasInheritableStatics,\n                prototype = this.prototype,\n                name, member;\n\n            inheritableStatics = prototype.$inheritableStatics;\n            hasInheritableStatics = prototype.$hasInheritableStatics;\n\n            if (!inheritableStatics) {\n                inheritableStatics = prototype.$inheritableStatics = [];\n                hasInheritableStatics = prototype.$hasInheritableStatics = {};\n            }\n\n            for (name in members) {\n                if (members.hasOwnProperty(name)) {\n                    member = members[name];\n                    if (typeof member == 'function') {\n                        member.displayName = Ext.getClassName(this) + '.' + name;\n                    }\n                    this[name] = member;\n\n                    if (!hasInheritableStatics[name]) {\n                        hasInheritableStatics[name] = true;\n                        inheritableStatics.push(name);\n                    }\n                }\n            }\n\n            return this;\n        },\n\n        /**\n         * Add methods / properties to the prototype of this class.\n         *\n         *     Ext.define('My.awesome.Cat', {\n         *         constructor: function() {\n         *             ...\n         *         }\n         *     });\n         *\n         *      My.awesome.Cat.addMembers({\n         *          meow: function() {\n         *             alert('Meowww...');\n         *          }\n         *      });\n         *\n         *      var kitty = new My.awesome.Cat;\n         *      kitty.meow();\n         *\n         * @param {Object} members\n         * @static\n         * @inheritable\n         */\n        addMembers: function(members) {\n            var prototype = this.prototype,\n                enumerables = Ext.enumerables,\n                names = [],\n                i, ln, name, member;\n\n            for (name in members) {\n                names.push(name);\n            }\n\n            if (enumerables) {\n                names.push.apply(names, enumerables);\n            }\n\n            for (i = 0,ln = names.length; i < ln; i++) {\n                name = names[i];\n\n                if (members.hasOwnProperty(name)) {\n                    member = members[name];\n\n                    if (typeof member == 'function' && !member.$isClass && member !== Ext.emptyFn) {\n                        member.$owner = this;\n                        member.$name = name;\n                        member.displayName = (this.$className || '') + '#' + name;\n                    }\n\n                    prototype[name] = member;\n                }\n            }\n\n            return this;\n        },\n\n        /**\n         * @private\n         * @static\n         * @inheritable\n         * @param name\n         * @param member\n         */\n        addMember: function(name, member) {\n            if (typeof member == 'function' && !member.$isClass && member !== Ext.emptyFn) {\n                member.$owner = this;\n                member.$name = name;\n                member.displayName = (this.$className || '') + '#' + name;\n            }\n\n            this.prototype[name] = member;\n\n            return this;\n        },\n\n        /**\n         * Adds members to class.\n         * @static\n         * @inheritable\n         * @deprecated 4.1 Use {@link #addMembers} instead.\n         */\n        implement: function() {\n            this.addMembers.apply(this, arguments);\n        },\n\n        /**\n         * Borrow another class' members to the prototype of this class.\n         *\n         *     Ext.define('Bank', {\n         *         money: '$$$',\n         *         printMoney: function() {\n         *             alert('$$$$$$$');\n         *         }\n         *     });\n         *\n         *     Ext.define('Thief', {\n         *         ...\n         *     });\n         *\n         *     Thief.borrow(Bank, ['money', 'printMoney']);\n         *\n         *     var steve = new Thief();\n         *\n         *     alert(steve.money); // alerts '$$$'\n         *     steve.printMoney(); // alerts '$$$$$$$'\n         *\n         * @param {Ext.Base} fromClass The class to borrow members from\n         * @param {Array/String} members The names of the members to borrow\n         * @return {Ext.Base} this\n         * @static\n         * @inheritable\n         * @private\n         */\n        borrow: function(fromClass, members) {\n            var prototype = this.prototype,\n                fromPrototype = fromClass.prototype,\n                className = Ext.getClassName(this),\n                i, ln, name, fn, toBorrow;\n\n            members = Ext.Array.from(members);\n\n            for (i = 0,ln = members.length; i < ln; i++) {\n                name = members[i];\n\n                toBorrow = fromPrototype[name];\n\n                if (typeof toBorrow == 'function') {\n                    fn = Ext.Function.clone(toBorrow);\n\n                    if (className) {\n                        fn.displayName = className + '#' + name;\n                    }\n\n                    fn.$owner = this;\n                    fn.$name = name;\n\n                    prototype[name] = fn;\n                }\n                else {\n                    prototype[name] = toBorrow;\n                }\n            }\n\n            return this;\n        },\n\n        /**\n         * Override members of this class. Overridden methods can be invoked via\n         * {@link Ext.Base#callParent}.\n         *\n         *     Ext.define('My.Cat', {\n         *         constructor: function() {\n         *             alert(\"I'm a cat!\");\n         *         }\n         *     });\n         *\n         *     My.Cat.override({\n         *         constructor: function() {\n         *             alert(\"I'm going to be a cat!\");\n         *\n         *             this.callParent(arguments);\n         *\n         *             alert(\"Meeeeoooowwww\");\n         *         }\n         *     });\n         *\n         *     var kitty = new My.Cat(); // alerts \"I'm going to be a cat!\"\n         *                               // alerts \"I'm a cat!\"\n         *                               // alerts \"Meeeeoooowwww\"\n         *\n         * As of 4.1, direct use of this method is deprecated. Use {@link Ext#define Ext.define}\n         * instead:\n         *\n         *     Ext.define('My.CatOverride', {\n         *         override: 'My.Cat',\n         *         constructor: function() {\n         *             alert(\"I'm going to be a cat!\");\n         *\n         *             this.callParent(arguments);\n         *\n         *             alert(\"Meeeeoooowwww\");\n         *         }\n         *     });\n         *\n         * The above accomplishes the same result but can be managed by the {@link Ext.Loader}\n         * which can properly order the override and its target class and the build process\n         * can determine whether the override is needed based on the required state of the\n         * target class (My.Cat).\n         *\n         * @param {Object} members The properties to add to this class. This should be\n         * specified as an object literal containing one or more properties.\n         * @return {Ext.Base} this class\n         * @static\n         * @inheritable\n         * @markdown\n         * @deprecated 4.1.0 Use {@link Ext#define Ext.define} instead\n         */\n        override: function(members) {\n            var me = this,\n                enumerables = Ext.enumerables,\n                target = me.prototype,\n                cloneFunction = Ext.Function.clone,\n                name, index, member, statics, names, previous;\n\n            if (arguments.length === 2) {\n                name = members;\n                members = {};\n                members[name] = arguments[1];\n                enumerables = null;\n            }\n\n            do {\n                names = []; // clean slate for prototype (1st pass) and static (2nd pass)\n                statics = null; // not needed 1st pass, but needs to be cleared for 2nd pass\n\n                for (name in members) { // hasOwnProperty is checked in the next loop...\n                    if (name == 'statics') {\n                        statics = members[name];\n                    } else if (name == 'config') {\n                        me.addConfig(members[name], true);\n                    } else {\n                        names.push(name);\n                    }\n                }\n\n                if (enumerables) {\n                    names.push.apply(names, enumerables);\n                }\n\n                for (index = names.length; index--; ) {\n                    name = names[index];\n\n                    if (members.hasOwnProperty(name)) {\n                        member = members[name];\n\n                        if (typeof member == 'function' && !member.$className && member !== Ext.emptyFn) {\n                            if (typeof member.$owner != 'undefined') {\n                                member = cloneFunction(member);\n                            }\n\n                            if (me.$className) {\n                                member.displayName = me.$className + '#' + name;\n                            }\n\n                            member.$owner = me;\n                            member.$name = name;\n\n                            previous = target[name];\n                            if (previous) {\n                                member.$previous = previous;\n                            }\n                        }\n\n                        target[name] = member;\n                    }\n                }\n\n                target = me; // 2nd pass is for statics\n                members = statics; // statics will be null on 2nd pass\n            } while (members);\n\n            return this;\n        },\n\n        // Documented downwards\n        callParent: function(args) {\n            var method;\n\n            // This code is intentionally inlined for the least number of debugger stepping\n            return (method = this.callParent.caller) && (method.$previous ||\n                ((method = method.$owner ? method : method.caller) &&\n                    method.$owner.superclass.self[method.$name])).apply(this, args || noArgs);\n        },\n\n        // Documented downwards\n        callSuper: function(args) {\n            var method;\n\n            // This code is intentionally inlined for the least number of debugger stepping\n            return (method = this.callSuper.caller) &&\n                ((method = method.$owner ? method : method.caller) &&\n                    method.$owner.superclass.self[method.$name]).apply(this, args || noArgs);\n        },\n\n        /**\n         * Used internally by the mixins pre-processor\n         * @private\n         * @static\n         * @inheritable\n         */\n        mixin: function(name, mixinClass) {\n            var mixin = mixinClass.prototype,\n                prototype = this.prototype,\n                key;\n\n            if (typeof mixin.onClassMixedIn != 'undefined') {\n                mixin.onClassMixedIn.call(mixinClass, this);\n            }\n\n            if (!prototype.hasOwnProperty('mixins')) {\n                if ('mixins' in prototype) {\n                    prototype.mixins = Ext.Object.chain(prototype.mixins);\n                }\n                else {\n                    prototype.mixins = {};\n                }\n            }\n\n            for (key in mixin) {\n                if (key === 'mixins') {\n                    Ext.merge(prototype.mixins, mixin[key]);\n                }\n                else if (typeof prototype[key] == 'undefined' && key != 'mixinId' && key != 'config') {\n                    prototype[key] = mixin[key];\n                }\n            }\n\n            if ('config' in mixin) {\n                this.addConfig(mixin.config, false);\n            }\n\n            prototype.mixins[name] = mixin;\n        },\n\n        /**\n         * Get the current class' name in string format.\n         *\n         *     Ext.define('My.cool.Class', {\n         *         constructor: function() {\n         *             alert(this.self.getName()); // alerts 'My.cool.Class'\n         *         }\n         *     });\n         *\n         *     My.cool.Class.getName(); // 'My.cool.Class'\n         *\n         * @return {String} className\n         * @static\n         * @inheritable\n         */\n        getName: function() {\n            return Ext.getClassName(this);\n        },\n\n        /**\n         * Create aliases for existing prototype methods. Example:\n         *\n         *     Ext.define('My.cool.Class', {\n         *         method1: function() { ... },\n         *         method2: function() { ... }\n         *     });\n         *\n         *     var test = new My.cool.Class();\n         *\n         *     My.cool.Class.createAlias({\n         *         method3: 'method1',\n         *         method4: 'method2'\n         *     });\n         *\n         *     test.method3(); // test.method1()\n         *\n         *     My.cool.Class.createAlias('method5', 'method3');\n         *\n         *     test.method5(); // test.method3() -> test.method1()\n         *\n         * @param {String/Object} alias The new method name, or an object to set multiple aliases. See\n         * {@link Ext.Function#flexSetter flexSetter}\n         * @param {String/Object} origin The original method name\n         * @static\n         * @inheritable\n         * @method\n         */\n        createAlias: flexSetter(function(alias, origin) {\n            this.override(alias, function() {\n                return this[origin].apply(this, arguments);\n            });\n        }),\n\n        /**\n         * @private\n         * @static\n         * @inheritable\n         */\n        addXtype: function(xtype) {\n            var prototype = this.prototype,\n                xtypesMap = prototype.xtypesMap,\n                xtypes = prototype.xtypes,\n                xtypesChain = prototype.xtypesChain;\n\n            if (!prototype.hasOwnProperty('xtypesMap')) {\n                xtypesMap = prototype.xtypesMap = Ext.merge({}, prototype.xtypesMap || {});\n                xtypes = prototype.xtypes = prototype.xtypes ? [].concat(prototype.xtypes) : [];\n                xtypesChain = prototype.xtypesChain = prototype.xtypesChain ? [].concat(prototype.xtypesChain) : [];\n                prototype.xtype = xtype;\n            }\n\n            if (!xtypesMap[xtype]) {\n                xtypesMap[xtype] = true;\n                xtypes.push(xtype);\n                xtypesChain.push(xtype);\n                Ext.ClassManager.setAlias(this, 'widget.' + xtype);\n            }\n\n            return this;\n        }\n    });\n\n    Base.implement({\n        /** @private */\n        isInstance: true,\n\n        /** @private */\n        $className: 'Ext.Base',\n\n        /** @private */\n        configClass: Ext.emptyFn,\n\n        /** @private */\n        initConfigList: [],\n\n        /** @private */\n        configMap: {},\n\n        /** @private */\n        initConfigMap: {},\n\n        /**\n         * Get the reference to the class from which this object was instantiated. Note that unlike {@link Ext.Base#self},\n         * `this.statics()` is scope-independent and it always returns the class from which it was called, regardless of what\n         * `this` points to during run-time\n         *\n         *     Ext.define('My.Cat', {\n         *         statics: {\n         *             totalCreated: 0,\n         *             speciesName: 'Cat' // My.Cat.speciesName = 'Cat'\n         *         },\n         *\n         *         constructor: function() {\n         *             var statics = this.statics();\n         *\n         *             alert(statics.speciesName);     // always equals to 'Cat' no matter what 'this' refers to\n         *                                             // equivalent to: My.Cat.speciesName\n         *\n         *             alert(this.self.speciesName);   // dependent on 'this'\n         *\n         *             statics.totalCreated++;\n         *         },\n         *\n         *         clone: function() {\n         *             var cloned = new this.self;                      // dependent on 'this'\n         *\n         *             cloned.groupName = this.statics().speciesName;   // equivalent to: My.Cat.speciesName\n         *\n         *             return cloned;\n         *         }\n         *     });\n         *\n         *\n         *     Ext.define('My.SnowLeopard', {\n         *         extend: 'My.Cat',\n         *\n         *         statics: {\n         *             speciesName: 'Snow Leopard'     // My.SnowLeopard.speciesName = 'Snow Leopard'\n         *         },\n         *\n         *         constructor: function() {\n         *             this.callParent();\n         *         }\n         *     });\n         *\n         *     var cat = new My.Cat();                 // alerts 'Cat', then alerts 'Cat'\n         *\n         *     var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'\n         *\n         *     var clone = snowLeopard.clone();\n         *     alert(Ext.getClassName(clone));         // alerts 'My.SnowLeopard'\n         *     alert(clone.groupName);                 // alerts 'Cat'\n         *\n         *     alert(My.Cat.totalCreated);             // alerts 3\n         *\n         * @protected\n         * @return {Ext.Class}\n         */\n        statics: function() {\n            var method = this.statics.caller,\n                self = this.self;\n\n            if (!method) {\n                return self;\n            }\n\n            return method.$owner;\n        },\n\n        /**\n         * Call the \"parent\" method of the current method. That is the method previously\n         * overridden by derivation or by an override (see {@link Ext#define}).\n         *\n         *      Ext.define('My.Base', {\n         *          constructor: function (x) {\n         *              this.x = x;\n         *          },\n         *\n         *          statics: {\n         *              method: function (x) {\n         *                  return x;\n         *              }\n         *          }\n         *      });\n         *\n         *      Ext.define('My.Derived', {\n         *          extend: 'My.Base',\n         *\n         *          constructor: function () {\n         *              this.callParent([21]);\n         *          }\n         *      });\n         *\n         *      var obj = new My.Derived();\n         *\n         *      alert(obj.x);  // alerts 21\n         *\n         * This can be used with an override as follows:\n         *\n         *      Ext.define('My.DerivedOverride', {\n         *          override: 'My.Derived',\n         *\n         *          constructor: function (x) {\n         *              this.callParent([x*2]); // calls original My.Derived constructor\n         *          }\n         *      });\n         *\n         *      var obj = new My.Derived();\n         *\n         *      alert(obj.x);  // now alerts 42\n         *\n         * This also works with static methods.\n         *\n         *      Ext.define('My.Derived2', {\n         *          extend: 'My.Base',\n         *\n         *          statics: {\n         *              method: function (x) {\n         *                  return this.callParent([x*2]); // calls My.Base.method\n         *              }\n         *          }\n         *      });\n         *\n         *      alert(My.Base.method(10);     // alerts 10\n         *      alert(My.Derived2.method(10); // alerts 20\n         *\n         * Lastly, it also works with overridden static methods.\n         *\n         *      Ext.define('My.Derived2Override', {\n         *          override: 'My.Derived2',\n         *\n         *          statics: {\n         *              method: function (x) {\n         *                  return this.callParent([x*2]); // calls My.Derived2.method\n         *              }\n         *          }\n         *      });\n         *\n         *      alert(My.Derived2.method(10); // now alerts 40\n         *\n         * To override a method and replace it and also call the superclass method, use\n         * {@link #callSuper}. This is often done to patch a method to fix a bug.\n         *\n         * @protected\n         * @param {Array/Arguments} args The arguments, either an array or the `arguments` object\n         * from the current method, for example: `this.callParent(arguments)`\n         * @return {Object} Returns the result of calling the parent method\n         */\n        callParent: function(args) {\n            // NOTE: this code is deliberately as few expressions (and no function calls)\n            // as possible so that a debugger can skip over this noise with the minimum number\n            // of steps. Basically, just hit Step Into until you are where you really wanted\n            // to be.\n            var method,\n                superMethod = (method = this.callParent.caller) && (method.$previous ||\n                        ((method = method.$owner ? method : method.caller) &&\n                                method.$owner.superclass[method.$name]));\n\n            if (!superMethod) {\n                method = this.callParent.caller;\n                var parentClass, methodName;\n\n                if (!method.$owner) {\n                    if (!method.caller) {\n                        throw new Error(\"Attempting to call a protected method from the public scope, which is not allowed\");\n                    }\n\n                    method = method.caller;\n                }\n\n                parentClass = method.$owner.superclass;\n                methodName = method.$name;\n\n                if (!(methodName in parentClass)) {\n                    throw new Error(\"this.callParent() was called but there's no such method (\" + methodName +\n                                \") found in the parent class (\" + (Ext.getClassName(parentClass) || 'Object') + \")\");\n                }\n            }\n\n            return superMethod.apply(this, args || noArgs);\n        },\n\n        /**\n         * This method is used by an override to call the superclass method but bypass any\n         * overridden method. This is often done to \"patch\" a method that contains a bug\n         * but for whatever reason cannot be fixed directly.\n         *\n         * Consider:\n         *\n         *      Ext.define('Ext.some.Class', {\n         *          method: function () {\n         *              console.log('Good');\n         *          }\n         *      });\n         *\n         *      Ext.define('Ext.some.DerivedClass', {\n         *          method: function () {\n         *              console.log('Bad');\n         *\n         *              // ... logic but with a bug ...\n         *\n         *              this.callParent();\n         *          }\n         *      });\n         *\n         * To patch the bug in `DerivedClass.method`, the typical solution is to create an\n         * override:\n         *\n         *      Ext.define('App.paches.DerivedClass', {\n         *          override: 'Ext.some.DerivedClass',\n         *\n         *          method: function () {\n         *              console.log('Fixed');\n         *\n         *              // ... logic but with bug fixed ...\n         *\n         *              this.callSuper();\n         *          }\n         *      });\n         *\n         * The patch method cannot use `callParent` to call the superclass `method` since\n         * that would call the overridden method containing the bug. In other words, the\n         * above patch would only produce \"Fixed\" then \"Good\" in the console log, whereas,\n         * using `callParent` would produce \"Fixed\" then \"Bad\" then \"Good\".\n         *\n         * @protected\n         * @param {Array/Arguments} args The arguments, either an array or the `arguments` object\n         * from the current method, for example: `this.callSuper(arguments)`\n         * @return {Object} Returns the result of calling the superclass method\n         */\n        callSuper: function(args) {\n            // NOTE: this code is deliberately as few expressions (and no function calls)\n            // as possible so that a debugger can skip over this noise with the minimum number\n            // of steps. Basically, just hit Step Into until you are where you really wanted\n            // to be.\n            var method,\n                superMethod = (method = this.callSuper.caller) &&\n                    ((method = method.$owner ? method : method.caller) &&\n                        method.$owner.superclass[method.$name]);\n\n            if (!superMethod) {\n                method = this.callSuper.caller;\n                var parentClass, methodName;\n\n                if (!method.$owner) {\n                    if (!method.caller) {\n                        throw new Error(\"Attempting to call a protected method from the public scope, which is not allowed\");\n                    }\n\n                    method = method.caller;\n                }\n\n                parentClass = method.$owner.superclass;\n                methodName = method.$name;\n\n                if (!(methodName in parentClass)) {\n                    throw new Error(\"this.callSuper() was called but there's no such method (\" + methodName +\n                        \") found in the parent class (\" + (Ext.getClassName(parentClass) || 'Object') + \")\");\n                }\n            }\n\n            return superMethod.apply(this, args || noArgs);\n        },\n\n        /**\n         * @property {Ext.Class} self\n         *\n         * Get the reference to the current class from which this object was instantiated. Unlike {@link Ext.Base#statics},\n         * `this.self` is scope-dependent and it's meant to be used for dynamic inheritance. See {@link Ext.Base#statics}\n         * for a detailed comparison\n         *\n         *     Ext.define('My.Cat', {\n         *         statics: {\n         *             speciesName: 'Cat' // My.Cat.speciesName = 'Cat'\n         *         },\n         *\n         *         constructor: function() {\n         *             alert(this.self.speciesName); // dependent on 'this'\n         *         },\n         *\n         *         clone: function() {\n         *             return new this.self();\n         *         }\n         *     });\n         *\n         *\n         *     Ext.define('My.SnowLeopard', {\n         *         extend: 'My.Cat',\n         *         statics: {\n         *             speciesName: 'Snow Leopard'         // My.SnowLeopard.speciesName = 'Snow Leopard'\n         *         }\n         *     });\n         *\n         *     var cat = new My.Cat();                     // alerts 'Cat'\n         *     var snowLeopard = new My.SnowLeopard();     // alerts 'Snow Leopard'\n         *\n         *     var clone = snowLeopard.clone();\n         *     alert(Ext.getClassName(clone));             // alerts 'My.SnowLeopard'\n         *\n         * @protected\n         */\n        self: Base,\n\n        // Default constructor, simply returns `this`\n        constructor: function() {\n            return this;\n        },\n\n        /**\n         * Initialize configuration for this class. a typical example:\n         *\n         *     Ext.define('My.awesome.Class', {\n         *         // The default config\n         *         config: {\n         *             name: 'Awesome',\n         *             isAwesome: true\n         *         },\n         *\n         *         constructor: function(config) {\n         *             this.initConfig(config);\n         *         }\n         *     });\n         *\n         *     var awesome = new My.awesome.Class({\n         *         name: 'Super Awesome'\n         *     });\n         *\n         *     alert(awesome.getName()); // 'Super Awesome'\n         *\n         * @protected\n         * @param {Object} config\n         * @return {Ext.Base} this\n         */\n        initConfig: function(config) {\n            var instanceConfig = config,\n                configNameCache = Ext.Class.configNameCache,\n                defaultConfig = new this.configClass(),\n                defaultConfigList = this.initConfigList,\n                hasConfig = this.configMap,\n                nameMap, i, ln, name, initializedName;\n\n            this.initConfig = Ext.emptyFn;\n\n            this.initialConfig = instanceConfig || {};\n\n            this.config = config = (instanceConfig) ? Ext.merge(defaultConfig, config) : defaultConfig;\n\n            if (instanceConfig) {\n                defaultConfigList = defaultConfigList.slice();\n\n                for (name in instanceConfig) {\n                    if (hasConfig[name]) {\n                        if (instanceConfig[name] !== null) {\n                            defaultConfigList.push(name);\n                            this[configNameCache[name].initialized] = false;\n                        }\n                    }\n                }\n            }\n\n            for (i = 0,ln = defaultConfigList.length; i < ln; i++) {\n                name = defaultConfigList[i];\n                nameMap = configNameCache[name];\n                initializedName = nameMap.initialized;\n\n                if (!this[initializedName]) {\n                    this[initializedName] = true;\n                    this[nameMap.set].call(this, config[name]);\n                }\n            }\n\n            return this;\n        },\n\n        /**\n         * @private\n         * @param config\n         */\n        hasConfig: function(name) {\n            return Boolean(this.configMap[name]);\n        },\n\n        /**\n         * @private\n         */\n        setConfig: function(config, applyIfNotSet) {\n            if (!config) {\n                return this;\n            }\n\n            var configNameCache = Ext.Class.configNameCache,\n                currentConfig = this.config,\n                hasConfig = this.configMap,\n                initialConfig = this.initialConfig,\n                name, value;\n\n            applyIfNotSet = Boolean(applyIfNotSet);\n\n            for (name in config) {\n                if (applyIfNotSet && initialConfig.hasOwnProperty(name)) {\n                    continue;\n                }\n\n                value = config[name];\n                currentConfig[name] = value;\n\n                if (hasConfig[name]) {\n                    this[configNameCache[name].set](value);\n                }\n            }\n\n            return this;\n        },\n\n        /**\n         * @private\n         * @param name\n         */\n        getConfig: function(name) {\n            var configNameCache = Ext.Class.configNameCache;\n\n            return this[configNameCache[name].get]();\n        },\n\n        /**\n         * Returns the initial configuration passed to constructor when instantiating\n         * this class.\n         * @param {String} [name] Name of the config option to return.\n         * @return {Object/Mixed} The full config object or a single config value\n         * when `name` parameter specified.\n         */\n        getInitialConfig: function(name) {\n            var config = this.config;\n\n            if (!name) {\n                return config;\n            }\n            else {\n                return config[name];\n            }\n        },\n\n        /**\n         * @private\n         * @param names\n         * @param callback\n         * @param scope\n         */\n        onConfigUpdate: function(names, callback, scope) {\n            var self = this.self,\n                className = self.$className,\n                i, ln, name,\n                updaterName, updater, newUpdater;\n\n            names = Ext.Array.from(names);\n\n            scope = scope || this;\n\n            for (i = 0,ln = names.length; i < ln; i++) {\n                name = names[i];\n                updaterName = 'update' + Ext.String.capitalize(name);\n                updater = this[updaterName] || Ext.emptyFn;\n                newUpdater = function() {\n                    updater.apply(this, arguments);\n                    scope[callback].apply(scope, arguments);\n                };\n                newUpdater.$name = updaterName;\n                newUpdater.$owner = self;\n                newUpdater.displayName = className + '#' + updaterName;\n\n                this[updaterName] = newUpdater;\n            }\n        },\n\n        /**\n         * @private\n         */\n        destroy: function() {\n            this.destroy = Ext.emptyFn;\n        }\n    });\n\n    /**\n     * Call the original method that was previously overridden with {@link Ext.Base#override}\n     *\n     *     Ext.define('My.Cat', {\n     *         constructor: function() {\n     *             alert(\"I'm a cat!\");\n     *         }\n     *     });\n     *\n     *     My.Cat.override({\n     *         constructor: function() {\n     *             alert(\"I'm going to be a cat!\");\n     *\n     *             this.callOverridden();\n     *\n     *             alert(\"Meeeeoooowwww\");\n     *         }\n     *     });\n     *\n     *     var kitty = new My.Cat(); // alerts \"I'm going to be a cat!\"\n     *                               // alerts \"I'm a cat!\"\n     *                               // alerts \"Meeeeoooowwww\"\n     *\n     * @param {Array/Arguments} args The arguments, either an array or the `arguments` object\n     * from the current method, for example: `this.callOverridden(arguments)`\n     * @return {Object} Returns the result of calling the overridden method\n     * @protected\n     * @deprecated as of 4.1. Use {@link #callParent} instead.\n     */\n    Base.prototype.callOverridden = Base.prototype.callParent;\n\n    Ext.Base = Base;\n\n}(Ext.Function.flexSetter));\n\n//@tag foundation,core\n//@require Base.js\n\n/**\n * @author Jacky Nguyen <jacky@sencha.com>\n * @docauthor Jacky Nguyen <jacky@sencha.com>\n * @class Ext.Class\n *\n * Handles class creation throughout the framework. This is a low level factory that is used by Ext.ClassManager and generally\n * should not be used directly. If you choose to use Ext.Class you will lose out on the namespace, aliasing and depency loading\n * features made available by Ext.ClassManager. The only time you would use Ext.Class directly is to create an anonymous class.\n *\n * If you wish to create a class you should use {@link Ext#define Ext.define} which aliases\n * {@link Ext.ClassManager#create Ext.ClassManager.create} to enable namespacing and dynamic dependency resolution.\n *\n * Ext.Class is the factory and **not** the superclass of everything. For the base class that **all** Ext classes inherit\n * from, see {@link Ext.Base}.\n */\n(function() {\n    var ExtClass,\n        Base = Ext.Base,\n        baseStaticMembers = [],\n        baseStaticMember, baseStaticMemberLength;\n\n    for (baseStaticMember in Base) {\n        if (Base.hasOwnProperty(baseStaticMember)) {\n            baseStaticMembers.push(baseStaticMember);\n        }\n    }\n\n    baseStaticMemberLength = baseStaticMembers.length;\n\n    // Creates a constructor that has nothing extra in its scope chain.\n    function makeCtor (className) {\n        function constructor () {\n            // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to\n            // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61.\n            return this.constructor.apply(this, arguments) || null;\n        }\n        if (className) {\n            constructor.displayName = className;\n        }\n        return constructor;\n    }\n\n    /**\n     * @method constructor\n     * Create a new anonymous class.\n     *\n     * @param {Object} data An object represent the properties of this class\n     * @param {Function} onCreated Optional, the callback function to be executed when this class is fully created.\n     * Note that the creation process can be asynchronous depending on the pre-processors used.\n     *\n     * @return {Ext.Base} The newly created class\n     */\n    Ext.Class = ExtClass = function(Class, data, onCreated) {\n        if (typeof Class != 'function') {\n            onCreated = data;\n            data = Class;\n            Class = null;\n        }\n\n        if (!data) {\n            data = {};\n        }\n\n        Class = ExtClass.create(Class, data);\n\n        ExtClass.process(Class, data, onCreated);\n\n        return Class;\n    };\n\n    Ext.apply(ExtClass, {\n        /**\n         * @private\n         * @param Class\n         * @param data\n         * @param hooks\n         */\n        onBeforeCreated: function(Class, data, hooks) {\n            Class.addMembers(data);\n\n            hooks.onCreated.call(Class, Class);\n        },\n\n        /**\n         * @private\n         * @param Class\n         * @param classData\n         * @param onClassCreated\n         */\n        create: function(Class, data) {\n            var name, i;\n\n            if (!Class) {\n                Class = makeCtor(\n                    data.$className\n                );\n            }\n\n            for (i = 0; i < baseStaticMemberLength; i++) {\n                name = baseStaticMembers[i];\n                Class[name] = Base[name];\n            }\n\n            return Class;\n        },\n\n        /**\n         * @private\n         * @param Class\n         * @param data\n         * @param onCreated\n         */\n        process: function(Class, data, onCreated) {\n            var preprocessorStack = data.preprocessors || ExtClass.defaultPreprocessors,\n                registeredPreprocessors = this.preprocessors,\n                hooks = {\n                    onBeforeCreated: this.onBeforeCreated\n                },\n                preprocessors = [],\n                preprocessor, preprocessorsProperties,\n                i, ln, j, subLn, preprocessorProperty, process;\n\n            delete data.preprocessors;\n\n            for (i = 0,ln = preprocessorStack.length; i < ln; i++) {\n                preprocessor = preprocessorStack[i];\n\n                if (typeof preprocessor == 'string') {\n                    preprocessor = registeredPreprocessors[preprocessor];\n                    preprocessorsProperties = preprocessor.properties;\n\n                    if (preprocessorsProperties === true) {\n                        preprocessors.push(preprocessor.fn);\n                    }\n                    else if (preprocessorsProperties) {\n                        for (j = 0,subLn = preprocessorsProperties.length; j < subLn; j++) {\n                            preprocessorProperty = preprocessorsProperties[j];\n\n                            if (data.hasOwnProperty(preprocessorProperty)) {\n                                preprocessors.push(preprocessor.fn);\n                                break;\n                            }\n                        }\n                    }\n                }\n                else {\n                    preprocessors.push(preprocessor);\n                }\n            }\n\n            hooks.onCreated = onCreated ? onCreated : Ext.emptyFn;\n            hooks.preprocessors = preprocessors;\n\n            this.doProcess(Class, data, hooks);\n        },\n        \n        doProcess: function(Class, data, hooks){\n            var me = this,\n                preprocessor = hooks.preprocessors.shift();\n\n            if (!preprocessor) {\n                hooks.onBeforeCreated.apply(me, arguments);\n                return;\n            }\n\n            if (preprocessor.call(me, Class, data, hooks, me.doProcess) !== false) {\n                me.doProcess(Class, data, hooks);\n            }\n        },\n\n        /** @private */\n        preprocessors: {},\n\n        /**\n         * Register a new pre-processor to be used during the class creation process\n         *\n         * @param {String} name The pre-processor's name\n         * @param {Function} fn The callback function to be executed. Typical format:\n         *\n         *     function(cls, data, fn) {\n         *         // Your code here\n         *\n         *         // Execute this when the processing is finished.\n         *         // Asynchronous processing is perfectly ok\n         *         if (fn) {\n         *             fn.call(this, cls, data);\n         *         }\n         *     });\n         *\n         * @param {Function} fn.cls The created class\n         * @param {Object} fn.data The set of properties passed in {@link Ext.Class} constructor\n         * @param {Function} fn.fn The callback function that **must** to be executed when this\n         * pre-processor finishes, regardless of whether the processing is synchronous or aynchronous.\n         * @return {Ext.Class} this\n         * @private\n         * @static\n         */\n        registerPreprocessor: function(name, fn, properties, position, relativeTo) {\n            if (!position) {\n                position = 'last';\n            }\n\n            if (!properties) {\n                properties = [name];\n            }\n\n            this.preprocessors[name] = {\n                name: name,\n                properties: properties || false,\n                fn: fn\n            };\n\n            this.setDefaultPreprocessorPosition(name, position, relativeTo);\n\n            return this;\n        },\n\n        /**\n         * Retrieve a pre-processor callback function by its name, which has been registered before\n         *\n         * @param {String} name\n         * @return {Function} preprocessor\n         * @private\n         * @static\n         */\n        getPreprocessor: function(name) {\n            return this.preprocessors[name];\n        },\n\n        /**\n         * @private\n         */\n        getPreprocessors: function() {\n            return this.preprocessors;\n        },\n\n        /**\n         * @private\n         */\n        defaultPreprocessors: [],\n\n        /**\n         * Retrieve the array stack of default pre-processors\n         * @return {Function[]} defaultPreprocessors\n         * @private\n         * @static\n         */\n        getDefaultPreprocessors: function() {\n            return this.defaultPreprocessors;\n        },\n\n        /**\n         * Set the default array stack of default pre-processors\n         *\n         * @private\n         * @param {Array} preprocessors\n         * @return {Ext.Class} this\n         * @static\n         */\n        setDefaultPreprocessors: function(preprocessors) {\n            this.defaultPreprocessors = Ext.Array.from(preprocessors);\n\n            return this;\n        },\n\n        /**\n         * Insert this pre-processor at a specific position in the stack, optionally relative to\n         * any existing pre-processor. For example:\n         *\n         *     Ext.Class.registerPreprocessor('debug', function(cls, data, fn) {\n         *         // Your code here\n         *\n         *         if (fn) {\n         *             fn.call(this, cls, data);\n         *         }\n         *     }).setDefaultPreprocessorPosition('debug', 'last');\n         *\n         * @private\n         * @param {String} name The pre-processor name. Note that it needs to be registered with\n         * {@link Ext.Class#registerPreprocessor registerPreprocessor} before this\n         * @param {String} offset The insertion position. Four possible values are:\n         * 'first', 'last', or: 'before', 'after' (relative to the name provided in the third argument)\n         * @param {String} relativeName\n         * @return {Ext.Class} this\n         * @static\n         */\n        setDefaultPreprocessorPosition: function(name, offset, relativeName) {\n            var defaultPreprocessors = this.defaultPreprocessors,\n                index;\n\n            if (typeof offset == 'string') {\n                if (offset === 'first') {\n                    defaultPreprocessors.unshift(name);\n\n                    return this;\n                }\n                else if (offset === 'last') {\n                    defaultPreprocessors.push(name);\n\n                    return this;\n                }\n\n                offset = (offset === 'after') ? 1 : -1;\n            }\n\n            index = Ext.Array.indexOf(defaultPreprocessors, relativeName);\n\n            if (index !== -1) {\n                Ext.Array.splice(defaultPreprocessors, Math.max(0, index + offset), 0, name);\n            }\n\n            return this;\n        },\n\n        configNameCache: {},\n\n        getConfigNameMap: function(name) {\n            var cache = this.configNameCache,\n                map = cache[name],\n                capitalizedName;\n\n            if (!map) {\n                capitalizedName = name.charAt(0).toUpperCase() + name.substr(1);\n\n                map = cache[name] = {\n                    internal: name,\n                    initialized: '_is' + capitalizedName + 'Initialized',\n                    apply: 'apply' + capitalizedName,\n                    update: 'update' + capitalizedName,\n                    'set': 'set' + capitalizedName,\n                    'get': 'get' + capitalizedName,\n                    doSet : 'doSet' + capitalizedName,\n                    changeEvent: name.toLowerCase() + 'change'\n                };\n            }\n\n            return map;\n        }\n    });\n\n    /**\n     * @cfg {String} extend\n     * The parent class that this class extends. For example:\n     *\n     *     Ext.define('Person', {\n     *         say: function(text) { alert(text); }\n     *     });\n     *\n     *     Ext.define('Developer', {\n     *         extend: 'Person',\n     *         say: function(text) { this.callParent([\"print \"+text]); }\n     *     });\n     */\n    ExtClass.registerPreprocessor('extend', function(Class, data) {\n        var Base = Ext.Base,\n            basePrototype = Base.prototype,\n            extend = data.extend,\n            Parent, parentPrototype, i;\n\n        delete data.extend;\n\n        if (extend && extend !== Object) {\n            Parent = extend;\n        }\n        else {\n            Parent = Base;\n        }\n\n        parentPrototype = Parent.prototype;\n\n        if (!Parent.$isClass) {\n            for (i in basePrototype) {\n                if (!parentPrototype[i]) {\n                    parentPrototype[i] = basePrototype[i];\n                }\n            }\n        }\n\n        Class.extend(Parent);\n\n        Class.triggerExtended.apply(Class, arguments);\n\n        if (data.onClassExtended) {\n            Class.onExtended(data.onClassExtended, Class);\n            delete data.onClassExtended;\n        }\n\n    }, true);\n\n    /**\n     * @cfg {Object} statics\n     * List of static methods for this class. For example:\n     *\n     *     Ext.define('Computer', {\n     *          statics: {\n     *              factory: function(brand) {\n     *                  // 'this' in static methods refer to the class itself\n     *                  return new this(brand);\n     *              }\n     *          },\n     *\n     *          constructor: function() { ... }\n     *     });\n     *\n     *     var dellComputer = Computer.factory('Dell');\n     */\n    ExtClass.registerPreprocessor('statics', function(Class, data) {\n        Class.addStatics(data.statics);\n\n        delete data.statics;\n    });\n\n    /**\n     * @cfg {Object} inheritableStatics\n     * List of inheritable static methods for this class.\n     * Otherwise just like {@link #statics} but subclasses inherit these methods.\n     */\n    ExtClass.registerPreprocessor('inheritableStatics', function(Class, data) {\n        Class.addInheritableStatics(data.inheritableStatics);\n\n        delete data.inheritableStatics;\n    });\n\n    /**\n     * @cfg {Object} config\n     * List of configuration options with their default values, for which automatically\n     * accessor methods are generated.  For example:\n     *\n     *     Ext.define('SmartPhone', {\n     *          config: {\n     *              hasTouchScreen: false,\n     *              operatingSystem: 'Other',\n     *              price: 500\n     *          },\n     *          constructor: function(cfg) {\n     *              this.initConfig(cfg);\n     *          }\n     *     });\n     *\n     *     var iPhone = new SmartPhone({\n     *          hasTouchScreen: true,\n     *          operatingSystem: 'iOS'\n     *     });\n     *\n     *     iPhone.getPrice(); // 500;\n     *     iPhone.getOperatingSystem(); // 'iOS'\n     *     iPhone.getHasTouchScreen(); // true;\n     */\n    ExtClass.registerPreprocessor('config', function(Class, data) {\n        var config = data.config,\n            prototype = Class.prototype;\n\n        delete data.config;\n\n        Ext.Object.each(config, function(name, value) {\n            var nameMap = ExtClass.getConfigNameMap(name),\n                internalName = nameMap.internal,\n                initializedName = nameMap.initialized,\n                applyName = nameMap.apply,\n                updateName = nameMap.update,\n                setName = nameMap.set,\n                getName = nameMap.get,\n                hasOwnSetter = (setName in prototype) || data.hasOwnProperty(setName),\n                hasOwnApplier = (applyName in prototype) || data.hasOwnProperty(applyName),\n                hasOwnUpdater = (updateName in prototype) || data.hasOwnProperty(updateName),\n                optimizedGetter, customGetter;\n\n            if (value === null || (!hasOwnSetter && !hasOwnApplier && !hasOwnUpdater)) {\n                prototype[internalName] = value;\n                prototype[initializedName] = true;\n            }\n            else {\n                prototype[initializedName] = false;\n            }\n\n            if (!hasOwnSetter) {\n                data[setName] = function(value) {\n                    var oldValue = this[internalName],\n                        applier = this[applyName],\n                        updater = this[updateName];\n\n                    if (!this[initializedName]) {\n                        this[initializedName] = true;\n                    }\n\n                    if (applier) {\n                        value = applier.call(this, value, oldValue);\n                    }\n\n                    if (typeof value != 'undefined') {\n                        this[internalName] = value;\n\n                        if (updater && value !== oldValue) {\n                            updater.call(this, value, oldValue);\n                        }\n                    }\n\n                    return this;\n                };\n            }\n\n            if (!(getName in prototype) || data.hasOwnProperty(getName)) {\n                customGetter = data[getName] || false;\n\n                if (customGetter) {\n                    optimizedGetter = function() {\n                        return customGetter.apply(this, arguments);\n                    };\n                }\n                else {\n                    optimizedGetter = function() {\n                        return this[internalName];\n                    };\n                }\n\n                data[getName] = function() {\n                    var currentGetter;\n\n                    if (!this[initializedName]) {\n                        this[initializedName] = true;\n                        this[setName](this.config[name]);\n                    }\n\n                    currentGetter = this[getName];\n\n                    if ('$previous' in currentGetter) {\n                        currentGetter.$previous = optimizedGetter;\n                    }\n                    else {\n                        this[getName] = optimizedGetter;\n                    }\n\n                    return optimizedGetter.apply(this, arguments);\n                };\n            }\n        });\n\n        Class.addConfig(config, true);\n    });\n\n    /**\n     * @cfg {String[]/Object} mixins\n     * List of classes to mix into this class. For example:\n     *\n     *     Ext.define('CanSing', {\n     *          sing: function() {\n     *              alert(\"I'm on the highway to hell...\")\n     *          }\n     *     });\n     *\n     *     Ext.define('Musician', {\n     *          mixins: ['CanSing']\n     *     })\n     *\n     * In this case the Musician class will get a `sing` method from CanSing mixin.\n     *\n     * But what if the Musician already has a `sing` method? Or you want to mix\n     * in two classes, both of which define `sing`?  In such a cases it's good\n     * to define mixins as an object, where you assign a name to each mixin:\n     *\n     *     Ext.define('Musician', {\n     *          mixins: {\n     *              canSing: 'CanSing'\n     *          },\n     * \n     *          sing: function() {\n     *              // delegate singing operation to mixin\n     *              this.mixins.canSing.sing.call(this);\n     *          }\n     *     })\n     *\n     * In this case the `sing` method of Musician will overwrite the\n     * mixed in `sing` method. But you can access the original mixed in method\n     * through special `mixins` property.\n     */\n    ExtClass.registerPreprocessor('mixins', function(Class, data, hooks) {\n        var mixins = data.mixins,\n            name, mixin, i, ln;\n\n        delete data.mixins;\n\n        Ext.Function.interceptBefore(hooks, 'onCreated', function() {\n            if (mixins instanceof Array) {\n                for (i = 0,ln = mixins.length; i < ln; i++) {\n                    mixin = mixins[i];\n                    name = mixin.prototype.mixinId || mixin.$className;\n\n                    Class.mixin(name, mixin);\n                }\n            }\n            else {\n                for (var mixinName in mixins) {\n                    if (mixins.hasOwnProperty(mixinName)) {\n                        Class.mixin(mixinName, mixins[mixinName]);\n                    }\n                }\n            }\n        });\n    });\n\n    // Backwards compatible\n    Ext.extend = function(Class, Parent, members) {\n        if (arguments.length === 2 && Ext.isObject(Parent)) {\n            members = Parent;\n            Parent = Class;\n            Class = null;\n        }\n\n        var cls;\n\n        if (!Parent) {\n            throw new Error(\"[Ext.extend] Attempting to extend from a class which has not been loaded on the page.\");\n        }\n\n        members.extend = Parent;\n        members.preprocessors = [\n            'extend'\n            ,'statics'\n            ,'inheritableStatics'\n            ,'mixins'\n            ,'config'\n        ];\n\n        if (Class) {\n            cls = new ExtClass(Class, members);\n            // The 'constructor' is given as 'Class' but also needs to be on prototype\n            cls.prototype.constructor = Class;\n        } else {\n            cls = new ExtClass(members);\n        }\n\n        cls.prototype.override = function(o) {\n            for (var m in o) {\n                if (o.hasOwnProperty(m)) {\n                    this[m] = o[m];\n                }\n            }\n        };\n\n        return cls;\n    };\n\n}());\n\n//@tag foundation,core\n//@require Class.js\n\n/**\n * @author Jacky Nguyen <jacky@sencha.com>\n * @docauthor Jacky Nguyen <jacky@sencha.com>\n * @class Ext.ClassManager\n *\n * Ext.ClassManager manages all classes and handles mapping from string class name to\n * actual class objects throughout the whole framework. It is not generally accessed directly, rather through\n * these convenient shorthands:\n *\n * - {@link Ext#define Ext.define}\n * - {@link Ext#create Ext.create}\n * - {@link Ext#widget Ext.widget}\n * - {@link Ext#getClass Ext.getClass}\n * - {@link Ext#getClassName Ext.getClassName}\n *\n * # Basic syntax:\n *\n *     Ext.define(className, properties);\n *\n * in which `properties` is an object represent a collection of properties that apply to the class. See\n * {@link Ext.ClassManager#create} for more detailed instructions.\n *\n *     Ext.define('Person', {\n *          name: 'Unknown',\n *\n *          constructor: function(name) {\n *              if (name) {\n *                  this.name = name;\n *              }\n *          },\n *\n *          eat: function(foodType) {\n *              alert(\"I'm eating: \" + foodType);\n *\n *              return this;\n *          }\n *     });\n *\n *     var aaron = new Person(\"Aaron\");\n *     aaron.eat(\"Sandwich\"); // alert(\"I'm eating: Sandwich\");\n *\n * Ext.Class has a powerful set of extensible {@link Ext.Class#registerPreprocessor pre-processors} which takes care of\n * everything related to class creation, including but not limited to inheritance, mixins, configuration, statics, etc.\n *\n * # Inheritance:\n *\n *     Ext.define('Developer', {\n *          extend: 'Person',\n *\n *          constructor: function(name, isGeek) {\n *              this.isGeek = isGeek;\n *\n *              // Apply a method from the parent class' prototype\n *              this.callParent([name]);\n *          },\n *\n *          code: function(language) {\n *              alert(\"I'm coding in: \" + language);\n *\n *              this.eat(\"Bugs\");\n *\n *              return this;\n *          }\n *     });\n *\n *     var jacky = new Developer(\"Jacky\", true);\n *     jacky.code(\"JavaScript\"); // alert(\"I'm coding in: JavaScript\");\n *                               // alert(\"I'm eating: Bugs\");\n *\n * See {@link Ext.Base#callParent} for more details on calling superclass' methods\n *\n * # Mixins:\n *\n *     Ext.define('CanPlayGuitar', {\n *          playGuitar: function() {\n *             alert(\"F#...G...D...A\");\n *          }\n *     });\n *\n *     Ext.define('CanComposeSongs', {\n *          composeSongs: function() { ... }\n *     });\n *\n *     Ext.define('CanSing', {\n *          sing: function() {\n *              alert(\"I'm on the highway to hell...\")\n *          }\n *     });\n *\n *     Ext.define('Musician', {\n *          extend: 'Person',\n *\n *          mixins: {\n *              canPlayGuitar: 'CanPlayGuitar',\n *              canComposeSongs: 'CanComposeSongs',\n *              canSing: 'CanSing'\n *          }\n *     })\n *\n *     Ext.define('CoolPerson', {\n *          extend: 'Person',\n *\n *          mixins: {\n *              canPlayGuitar: 'CanPlayGuitar',\n *              canSing: 'CanSing'\n *          },\n *\n *          sing: function() {\n *              alert(\"Ahem....\");\n *\n *              this.mixins.canSing.sing.call(this);\n *\n *              alert(\"[Playing guitar at the same time...]\");\n *\n *              this.playGuitar();\n *          }\n *     });\n *\n *     var me = new CoolPerson(\"Jacky\");\n *\n *     me.sing(); // alert(\"Ahem...\");\n *                // alert(\"I'm on the highway to hell...\");\n *                // alert(\"[Playing guitar at the same time...]\");\n *                // alert(\"F#...G...D...A\");\n *\n * # Config:\n *\n *     Ext.define('SmartPhone', {\n *          config: {\n *              hasTouchScreen: false,\n *              operatingSystem: 'Other',\n *              price: 500\n *          },\n *\n *          isExpensive: false,\n *\n *          constructor: function(config) {\n *              this.initConfig(config);\n *          },\n *\n *          applyPrice: function(price) {\n *              this.isExpensive = (price > 500);\n *\n *              return price;\n *          },\n *\n *          applyOperatingSystem: function(operatingSystem) {\n *              if (!(/^(iOS|Android|BlackBerry)$/i).test(operatingSystem)) {\n *                  return 'Other';\n *              }\n *\n *              return operatingSystem;\n *          }\n *     });\n *\n *     var iPhone = new SmartPhone({\n *          hasTouchScreen: true,\n *          operatingSystem: 'iOS'\n *     });\n *\n *     iPhone.getPrice(); // 500;\n *     iPhone.getOperatingSystem(); // 'iOS'\n *     iPhone.getHasTouchScreen(); // true;\n *     iPhone.hasTouchScreen(); // true\n *\n *     iPhone.isExpensive; // false;\n *     iPhone.setPrice(600);\n *     iPhone.getPrice(); // 600\n *     iPhone.isExpensive; // true;\n *\n *     iPhone.setOperatingSystem('AlienOS');\n *     iPhone.getOperatingSystem(); // 'Other'\n *\n * # Statics:\n *\n *     Ext.define('Computer', {\n *          statics: {\n *              factory: function(brand) {\n *                 // 'this' in static methods refer to the class itself\n *                  return new this(brand);\n *              }\n *          },\n *\n *          constructor: function() { ... }\n *     });\n *\n *     var dellComputer = Computer.factory('Dell');\n *\n * Also see {@link Ext.Base#statics} and {@link Ext.Base#self} for more details on accessing\n * static properties within class methods\n *\n * @singleton\n */\n(function(Class, alias, arraySlice, arrayFrom, global) {\n\n    // Creates a constructor that has nothing extra in its scope chain.\n    function makeCtor () {\n        function constructor () {\n            // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to\n            // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61.\n            return this.constructor.apply(this, arguments) || null;\n        }\n        return constructor;\n    }\n\n    var Manager = Ext.ClassManager = {\n\n        /**\n         * @property {Object} classes\n         * All classes which were defined through the ClassManager. Keys are the\n         * name of the classes and the values are references to the classes.\n         * @private\n         */\n        classes: {},\n\n        /**\n         * @private\n         */\n        existCache: {},\n\n        /**\n         * @private\n         */\n        namespaceRewrites: [{\n            from: 'Ext.',\n            to: Ext\n        }],\n\n        /**\n         * @private\n         */\n        maps: {\n            alternateToName: {},\n            aliasToName: {},\n            nameToAliases: {},\n            nameToAlternates: {}\n        },\n\n        /** @private */\n        enableNamespaceParseCache: true,\n\n        /** @private */\n        namespaceParseCache: {},\n\n        /** @private */\n        instantiators: [],\n\n        /**\n         * Checks if a class has already been created.\n         *\n         * @param {String} className\n         * @return {Boolean} exist\n         */\n        isCreated: function(className) {\n            var existCache = this.existCache,\n                i, ln, part, root, parts;\n\n            if (typeof className != 'string' || className.length < 1) {\n                throw new Error(\"[Ext.ClassManager] Invalid classname, must be a string and must not be empty\");\n            }\n\n            if (this.classes[className] || existCache[className]) {\n                return true;\n            }\n\n            root = global;\n            parts = this.parseNamespace(className);\n\n            for (i = 0, ln = parts.length; i < ln; i++) {\n                part = parts[i];\n\n                if (typeof part != 'string') {\n                    root = part;\n                } else {\n                    if (!root || !root[part]) {\n                        return false;\n                    }\n\n                    root = root[part];\n                }\n            }\n\n            existCache[className] = true;\n\n            this.triggerCreated(className);\n\n            return true;\n        },\n\n        /**\n         * @private\n         */\n        createdListeners: [],\n\n        /**\n         * @private\n         */\n        nameCreatedListeners: {},\n\n        /**\n         * @private\n         */\n        triggerCreated: function(className) {\n            var listeners = this.createdListeners,\n                nameListeners = this.nameCreatedListeners,\n                alternateNames = this.maps.nameToAlternates[className],\n                names = [className],\n                i, ln, j, subLn, listener, name;\n\n            for (i = 0,ln = listeners.length; i < ln; i++) {\n                listener = listeners[i];\n                listener.fn.call(listener.scope, className);\n            }\n\n            if (alternateNames) {\n                names.push.apply(names, alternateNames);\n            }\n\n            for (i = 0,ln = names.length; i < ln; i++) {\n                name = names[i];\n                listeners = nameListeners[name];\n\n                if (listeners) {\n                    for (j = 0,subLn = listeners.length; j < subLn; j++) {\n                        listener = listeners[j];\n                        listener.fn.call(listener.scope, name);\n                    }\n                    delete nameListeners[name];\n                }\n            }\n        },\n\n        /**\n         * @private\n         */\n        onCreated: function(fn, scope, className) {\n            var listeners = this.createdListeners,\n                nameListeners = this.nameCreatedListeners,\n                listener = {\n                    fn: fn,\n                    scope: scope\n                };\n\n            if (className) {\n                if (this.isCreated(className)) {\n                    fn.call(scope, className);\n                    return;\n                }\n\n                if (!nameListeners[className]) {\n                    nameListeners[className] = [];\n                }\n\n                nameListeners[className].push(listener);\n            }\n            else {\n                listeners.push(listener);\n            }\n        },\n\n        /**\n         * Supports namespace rewriting\n         * @private\n         */\n        parseNamespace: function(namespace) {\n            if (typeof namespace != 'string') {\n                throw new Error(\"[Ext.ClassManager] Invalid namespace, must be a string\");\n            }\n\n            var cache = this.namespaceParseCache,\n                parts,\n                rewrites,\n                root,\n                name,\n                rewrite, from, to, i, ln;\n\n            if (this.enableNamespaceParseCache) {\n                if (cache.hasOwnProperty(namespace)) {\n                    return cache[namespace];\n                }\n            }\n\n            parts = [];\n            rewrites = this.namespaceRewrites;\n            root = global;\n            name = namespace;\n\n            for (i = 0, ln = rewrites.length; i < ln; i++) {\n                rewrite = rewrites[i];\n                from = rewrite.from;\n                to = rewrite.to;\n\n                if (name === from || name.substring(0, from.length) === from) {\n                    name = name.substring(from.length);\n\n                    if (typeof to != 'string') {\n                        root = to;\n                    } else {\n                        parts = parts.concat(to.split('.'));\n                    }\n\n                    break;\n                }\n            }\n\n            parts.push(root);\n\n            parts = parts.concat(name.split('.'));\n\n            if (this.enableNamespaceParseCache) {\n                cache[namespace] = parts;\n            }\n\n            return parts;\n        },\n\n        /**\n         * Creates a namespace and assign the `value` to the created object\n         *\n         *     Ext.ClassManager.setNamespace('MyCompany.pkg.Example', someObject);\n         *\n         *     alert(MyCompany.pkg.Example === someObject); // alerts true\n         *\n         * @param {String} name\n         * @param {Object} value\n         */\n        setNamespace: function(name, value) {\n            var root = global,\n                parts = this.parseNamespace(name),\n                ln = parts.length - 1,\n                leaf = parts[ln],\n                i, part;\n\n            for (i = 0; i < ln; i++) {\n                part = parts[i];\n\n                if (typeof part != 'string') {\n                    root = part;\n                } else {\n                    if (!root[part]) {\n                        root[part] = {};\n                    }\n\n                    root = root[part];\n                }\n            }\n\n            root[leaf] = value;\n\n            return root[leaf];\n        },\n\n        /**\n         * The new Ext.ns, supports namespace rewriting\n         * @private\n         */\n        createNamespaces: function() {\n            var root = global,\n                parts, part, i, j, ln, subLn;\n\n            for (i = 0, ln = arguments.length; i < ln; i++) {\n                parts = this.parseNamespace(arguments[i]);\n\n                for (j = 0, subLn = parts.length; j < subLn; j++) {\n                    part = parts[j];\n\n                    if (typeof part != 'string') {\n                        root = part;\n                    } else {\n                        if (!root[part]) {\n                            root[part] = {};\n                        }\n\n                        root = root[part];\n                    }\n                }\n            }\n\n            return root;\n        },\n\n        /**\n         * Sets a name reference to a class.\n         *\n         * @param {String} name\n         * @param {Object} value\n         * @return {Ext.ClassManager} this\n         */\n        set: function(name, value) {\n            var me = this,\n                maps = me.maps,\n                nameToAlternates = maps.nameToAlternates,\n                targetName = me.getName(value),\n                alternates;\n\n            me.classes[name] = me.setNamespace(name, value);\n\n            if (targetName && targetName !== name) {\n                maps.alternateToName[name] = targetName;\n                alternates = nameToAlternates[targetName] || (nameToAlternates[targetName] = []);\n                alternates.push(name);\n            }\n\n            return this;\n        },\n\n        /**\n         * Retrieve a class by its name.\n         *\n         * @param {String} name\n         * @return {Ext.Class} class\n         */\n        get: function(name) {\n            var classes = this.classes,\n                root,\n                parts,\n                part, i, ln;\n\n            if (classes[name]) {\n                return classes[name];\n            }\n\n            root = global;\n            parts = this.parseNamespace(name);\n\n            for (i = 0, ln = parts.length; i < ln; i++) {\n                part = parts[i];\n\n                if (typeof part != 'string') {\n                    root = part;\n                } else {\n                    if (!root || !root[part]) {\n                        return null;\n                    }\n\n                    root = root[part];\n                }\n            }\n\n            return root;\n        },\n\n        /**\n         * Register the alias for a class.\n         *\n         * @param {Ext.Class/String} cls a reference to a class or a className\n         * @param {String} alias Alias to use when referring to this class\n         */\n        setAlias: function(cls, alias) {\n            var aliasToNameMap = this.maps.aliasToName,\n                nameToAliasesMap = this.maps.nameToAliases,\n                className;\n\n            if (typeof cls == 'string') {\n                className = cls;\n            } else {\n                className = this.getName(cls);\n            }\n\n            if (alias && aliasToNameMap[alias] !== className) {\n                if (aliasToNameMap[alias] && Ext.isDefined(global.console)) {\n                    global.console.log(\"[Ext.ClassManager] Overriding existing alias: '\" + alias + \"' \" +\n                        \"of: '\" + aliasToNameMap[alias] + \"' with: '\" + className + \"'. Be sure it's intentional.\");\n                }\n\n                aliasToNameMap[alias] = className;\n            }\n\n            if (!nameToAliasesMap[className]) {\n                nameToAliasesMap[className] = [];\n            }\n\n            if (alias) {\n                Ext.Array.include(nameToAliasesMap[className], alias);\n            }\n\n            return this;\n        },\n\n        /**\n         * Adds a batch of class name to alias mappings\n         * @param {Object} aliases The set of mappings of the form\n         * className : [values...]\n         */\n        addNameAliasMappings: function(aliases){\n            var aliasToNameMap = this.maps.aliasToName,\n                nameToAliasesMap = this.maps.nameToAliases,\n                className, aliasList, alias, i;\n\n            for (className in aliases) {\n                aliasList = nameToAliasesMap[className] ||\n                    (nameToAliasesMap[className] = []);\n\n                for (i = 0; i < aliases[className].length; i++) {\n                    alias = aliases[className][i];\n                    if (!aliasToNameMap[alias]) {\n                        aliasToNameMap[alias] = className;\n                        aliasList.push(alias);\n                    }\n                }\n\n            }\n            return this;\n        },\n\n        /**\n         *\n         * @param {Object} alternates The set of mappings of the form\n         * className : [values...]\n         */\n        addNameAlternateMappings: function(alternates) {\n            var alternateToName = this.maps.alternateToName,\n                nameToAlternates = this.maps.nameToAlternates,\n                className, aliasList, alternate, i;\n\n            for (className in alternates) {\n                aliasList = nameToAlternates[className] ||\n                    (nameToAlternates[className] = []);\n\n                for (i  = 0; i < alternates[className].length; i++) {\n                    alternate = alternates[className];\n                    if (!alternateToName[alternate]) {\n                        alternateToName[alternate] = className;\n                        aliasList.push(alternate);\n                    }\n                }\n\n            }\n            return this;\n        },\n\n        /**\n         * Get a reference to the class by its alias.\n         *\n         * @param {String} alias\n         * @return {Ext.Class} class\n         */\n        getByAlias: function(alias) {\n            return this.get(this.getNameByAlias(alias));\n        },\n\n        /**\n         * Get the name of a class by its alias.\n         *\n         * @param {String} alias\n         * @return {String} className\n         */\n        getNameByAlias: function(alias) {\n            return this.maps.aliasToName[alias] || '';\n        },\n\n        /**\n         * Get the name of a class by its alternate name.\n         *\n         * @param {String} alternate\n         * @return {String} className\n         */\n        getNameByAlternate: function(alternate) {\n            return this.maps.alternateToName[alternate] || '';\n        },\n\n        /**\n         * Get the aliases of a class by the class name\n         *\n         * @param {String} name\n         * @return {Array} aliases\n         */\n        getAliasesByName: function(name) {\n            return this.maps.nameToAliases[name] || [];\n        },\n\n        /**\n         * Get the name of the class by its reference or its instance;\n         * usually invoked by the shorthand {@link Ext#getClassName Ext.getClassName}\n         *\n         *     Ext.ClassManager.getName(Ext.Action); // returns \"Ext.Action\"\n         *\n         * @param {Ext.Class/Object} object\n         * @return {String} className\n         */\n        getName: function(object) {\n            return object && object.$className || '';\n        },\n\n        /**\n         * Get the class of the provided object; returns null if it's not an instance\n         * of any class created with Ext.define. This is usually invoked by the shorthand {@link Ext#getClass Ext.getClass}\n         *\n         *     var component = new Ext.Component();\n         *\n         *     Ext.ClassManager.getClass(component); // returns Ext.Component\n         *\n         * @param {Object} object\n         * @return {Ext.Class} class\n         */\n        getClass: function(object) {\n            return object && object.self || null;\n        },\n\n        /**\n         * Defines a class.\n         * @deprecated 4.1.0 Use {@link Ext#define} instead, as that also supports creating overrides.\n         */\n        create: function(className, data, createdFn) {\n            if (className != null && typeof className != 'string') {\n                throw new Error(\"[Ext.define] Invalid class name '\" + className + \"' specified, must be a non-empty string\");\n            }\n\n            var ctor = makeCtor();\n            if (typeof data == 'function') {\n                data = data(ctor);\n            }\n\n            if (className) {\n                ctor.displayName = className;\n            }\n\n            data.$className = className;\n\n            return new Class(ctor, data, function() {\n                var postprocessorStack = data.postprocessors || Manager.defaultPostprocessors,\n                    registeredPostprocessors = Manager.postprocessors,\n                    postprocessors = [],\n                    postprocessor, i, ln, j, subLn, postprocessorProperties, postprocessorProperty;\n\n                delete data.postprocessors;\n\n                for (i = 0,ln = postprocessorStack.length; i < ln; i++) {\n                    postprocessor = postprocessorStack[i];\n\n                    if (typeof postprocessor == 'string') {\n                        postprocessor = registeredPostprocessors[postprocessor];\n                        postprocessorProperties = postprocessor.properties;\n\n                        if (postprocessorProperties === true) {\n                            postprocessors.push(postprocessor.fn);\n                        }\n                        else if (postprocessorProperties) {\n                            for (j = 0,subLn = postprocessorProperties.length; j < subLn; j++) {\n                                postprocessorProperty = postprocessorProperties[j];\n\n                                if (data.hasOwnProperty(postprocessorProperty)) {\n                                    postprocessors.push(postprocessor.fn);\n                                    break;\n                                }\n                            }\n                        }\n                    }\n                    else {\n                        postprocessors.push(postprocessor);\n                    }\n                }\n\n                data.postprocessors = postprocessors;\n                data.createdFn = createdFn;\n                Manager.processCreate(className, this, data);\n            });\n        },\n        \n        processCreate: function(className, cls, clsData){\n            var me = this,\n                postprocessor = clsData.postprocessors.shift(),\n                createdFn = clsData.createdFn;\n\n            if (!postprocessor) {\n                if (className) {\n                    me.set(className, cls);\n                }\n\n                if (createdFn) {\n                    createdFn.call(cls, cls);\n                }\n\n                if (className) {\n                    me.triggerCreated(className);\n                }\n                return;\n            }\n\n            if (postprocessor.call(me, className, cls, clsData, me.processCreate) !== false) {\n                me.processCreate(className, cls, clsData);\n            }\n        },\n\n        createOverride: function (className, data, createdFn) {\n            var me = this,\n                overriddenClassName = data.override,\n                requires = data.requires,\n                uses = data.uses,\n                classReady = function () {\n                    var cls, temp;\n\n                    if (requires) {\n                        temp = requires;\n                        requires = null; // do the real thing next time (which may be now)\n\n                        // Since the override is going to be used (its target class is now\n                        // created), we need to fetch the required classes for the override\n                        // and call us back once they are loaded:\n                        Ext.Loader.require(temp, classReady);\n                    } else {\n                        // The target class and the required classes for this override are\n                        // ready, so we can apply the override now:\n                        cls = me.get(overriddenClassName);\n\n                        // We don't want to apply these:\n                        delete data.override;\n                        delete data.requires;\n                        delete data.uses;\n\n                        Ext.override(cls, data);\n\n                        // This pushes the overridding file itself into Ext.Loader.history\n                        // Hence if the target class never exists, the overriding file will\n                        // never be included in the build.\n                        me.triggerCreated(className);\n\n                        if (uses) {\n                            Ext.Loader.addUsedClasses(uses); // get these classes too!\n                        }\n\n                        if (createdFn) {\n                            createdFn.call(cls); // last but not least!\n                        }\n                    }\n                };\n\n            me.existCache[className] = true;\n\n            // Override the target class right after it's created\n            me.onCreated(classReady, me, overriddenClassName);\n \n            return me;\n        },\n\n        /**\n         * Instantiate a class by its alias; usually invoked by the convenient shorthand {@link Ext#createByAlias Ext.createByAlias}\n         * If {@link Ext.Loader} is {@link Ext.Loader#setConfig enabled} and the class has not been defined yet, it will\n         * attempt to load the class via synchronous loading.\n         *\n         *     var window = Ext.ClassManager.instantiateByAlias('widget.window', { width: 600, height: 800, ... });\n         *\n         * @param {String} alias\n         * @param {Object...} args Additional arguments after the alias will be passed to the\n         * class constructor.\n         * @return {Object} instance\n         */\n        instantiateByAlias: function() {\n            var alias = arguments[0],\n                args = arraySlice.call(arguments),\n                className = this.getNameByAlias(alias);\n\n            if (!className) {\n                className = this.maps.aliasToName[alias];\n\n                if (!className) {\n                    throw new Error(\"[Ext.createByAlias] Cannot create an instance of unrecognized alias: \" + alias);\n                }\n\n                if (global.console) {\n                    global.console.warn(\"[Ext.Loader] Synchronously loading '\" + className + \"'; consider adding \" +\n                         \"Ext.require('\" + alias + \"') above Ext.onReady\");\n                }\n\n                Ext.syncRequire(className);\n            }\n\n            args[0] = className;\n\n            return this.instantiate.apply(this, args);\n        },\n\n        /**\n         * @private\n         */\n        instantiate: function() {\n            var name = arguments[0],\n                nameType = typeof name,\n                args = arraySlice.call(arguments, 1),\n                alias = name,\n                possibleName, cls;\n\n            if (nameType != 'function') {\n                if (nameType != 'string' && args.length === 0) {\n                    args = [name];\n                    name = name.xclass;\n                }\n\n                if (typeof name != 'string' || name.length < 1) {\n                    throw new Error(\"[Ext.create] Invalid class name or alias '\" + name + \"' specified, must be a non-empty string\");\n                }\n\n                cls = this.get(name);\n            }\n            else {\n                cls = name;\n            }\n\n            // No record of this class name, it's possibly an alias, so look it up\n            if (!cls) {\n                possibleName = this.getNameByAlias(name);\n\n                if (possibleName) {\n                    name = possibleName;\n\n                    cls = this.get(name);\n                }\n            }\n\n            // Still no record of this class name, it's possibly an alternate name, so look it up\n            if (!cls) {\n                possibleName = this.getNameByAlternate(name);\n\n                if (possibleName) {\n                    name = possibleName;\n\n                    cls = this.get(name);\n                }\n            }\n\n            // Still not existing at this point, try to load it via synchronous mode as the last resort\n            if (!cls) {\n                if (global.console) {\n                    global.console.warn(\"[Ext.Loader] Synchronously loading '\" + name + \"'; consider adding \" +\n                         \"Ext.require('\" + ((possibleName) ? alias : name) + \"') above Ext.onReady\");\n                }\n\n                Ext.syncRequire(name);\n\n                cls = this.get(name);\n            }\n\n            if (!cls) {\n                throw new Error(\"[Ext.create] Cannot create an instance of unrecognized class name / alias: \" + alias);\n            }\n\n            if (typeof cls != 'function') {\n                throw new Error(\"[Ext.create] '\" + name + \"' is a singleton and cannot be instantiated\");\n            }\n\n            return this.getInstantiator(args.length)(cls, args);\n        },\n\n        /**\n         * @private\n         * @param name\n         * @param args\n         */\n        dynInstantiate: function(name, args) {\n            args = arrayFrom(args, true);\n            args.unshift(name);\n\n            return this.instantiate.apply(this, args);\n        },\n\n        /**\n         * @private\n         * @param length\n         */\n        getInstantiator: function(length) {\n            var instantiators = this.instantiators,\n                instantiator,\n                i,\n                args;\n\n            instantiator = instantiators[length];\n\n            if (!instantiator) {\n                i = length;\n                args = [];\n\n                for (i = 0; i < length; i++) {\n                    args.push('a[' + i + ']');\n                }\n\n                instantiator = instantiators[length] = new Function('c', 'a', 'return new c(' + args.join(',') + ')');\n                instantiator.displayName = \"Ext.ClassManager.instantiate\" + length;\n            }\n\n            return instantiator;\n        },\n\n        /**\n         * @private\n         */\n        postprocessors: {},\n\n        /**\n         * @private\n         */\n        defaultPostprocessors: [],\n\n        /**\n         * Register a post-processor function.\n         *\n         * @private\n         * @param {String} name\n         * @param {Function} postprocessor\n         */\n        registerPostprocessor: function(name, fn, properties, position, relativeTo) {\n            if (!position) {\n                position = 'last';\n            }\n\n            if (!properties) {\n                properties = [name];\n            }\n\n            this.postprocessors[name] = {\n                name: name,\n                properties: properties || false,\n                fn: fn\n            };\n\n            this.setDefaultPostprocessorPosition(name, position, relativeTo);\n\n            return this;\n        },\n\n        /**\n         * Set the default post processors array stack which are applied to every class.\n         *\n         * @private\n         * @param {String/Array} The name of a registered post processor or an array of registered names.\n         * @return {Ext.ClassManager} this\n         */\n        setDefaultPostprocessors: function(postprocessors) {\n            this.defaultPostprocessors = arrayFrom(postprocessors);\n\n            return this;\n        },\n\n        /**\n         * Insert this post-processor at a specific position in the stack, optionally relative to\n         * any existing post-processor\n         *\n         * @private\n         * @param {String} name The post-processor name. Note that it needs to be registered with\n         * {@link Ext.ClassManager#registerPostprocessor} before this\n         * @param {String} offset The insertion position. Four possible values are:\n         * 'first', 'last', or: 'before', 'after' (relative to the name provided in the third argument)\n         * @param {String} relativeName\n         * @return {Ext.ClassManager} this\n         */\n        setDefaultPostprocessorPosition: function(name, offset, relativeName) {\n            var defaultPostprocessors = this.defaultPostprocessors,\n                index;\n\n            if (typeof offset == 'string') {\n                if (offset === 'first') {\n                    defaultPostprocessors.unshift(name);\n\n                    return this;\n                }\n                else if (offset === 'last') {\n                    defaultPostprocessors.push(name);\n\n                    return this;\n                }\n\n                offset = (offset === 'after') ? 1 : -1;\n            }\n\n            index = Ext.Array.indexOf(defaultPostprocessors, relativeName);\n\n            if (index !== -1) {\n                Ext.Array.splice(defaultPostprocessors, Math.max(0, index + offset), 0, name);\n            }\n\n            return this;\n        },\n\n        /**\n         * Converts a string expression to an array of matching class names. An expression can either refers to class aliases\n         * or class names. Expressions support wildcards:\n         *\n         *      // returns ['Ext.window.Window']\n         *     var window = Ext.ClassManager.getNamesByExpression('widget.window');\n         *\n         *     // returns ['widget.panel', 'widget.window', ...]\n         *     var allWidgets = Ext.ClassManager.getNamesByExpression('widget.*');\n         *\n         *     // returns ['Ext.data.Store', 'Ext.data.ArrayProxy', ...]\n         *     var allData = Ext.ClassManager.getNamesByExpression('Ext.data.*');\n         *\n         * @param {String} expression\n         * @return {String[]} classNames\n         */\n        getNamesByExpression: function(expression) {\n            var nameToAliasesMap = this.maps.nameToAliases,\n                names = [],\n                name, alias, aliases, possibleName, regex, i, ln;\n\n            if (typeof expression != 'string' || expression.length < 1) {\n                throw new Error(\"[Ext.ClassManager.getNamesByExpression] Expression \" + expression + \" is invalid, must be a non-empty string\");\n            }\n\n            if (expression.indexOf('*') !== -1) {\n                expression = expression.replace(/\\*/g, '(.*?)');\n                regex = new RegExp('^' + expression + '$');\n\n                for (name in nameToAliasesMap) {\n                    if (nameToAliasesMap.hasOwnProperty(name)) {\n                        aliases = nameToAliasesMap[name];\n\n                        if (name.search(regex) !== -1) {\n                            names.push(name);\n                        }\n                        else {\n                            for (i = 0, ln = aliases.length; i < ln; i++) {\n                                alias = aliases[i];\n\n                                if (alias.search(regex) !== -1) {\n                                    names.push(name);\n                                    break;\n                                }\n                            }\n                        }\n                    }\n                }\n\n            } else {\n                possibleName = this.getNameByAlias(expression);\n\n                if (possibleName) {\n                    names.push(possibleName);\n                } else {\n                    possibleName = this.getNameByAlternate(expression);\n\n                    if (possibleName) {\n                        names.push(possibleName);\n                    } else {\n                        names.push(expression);\n                    }\n                }\n            }\n\n            return names;\n        }\n    };\n\n    /**\n     * @cfg {String[]} alias\n     * @member Ext.Class\n     * List of short aliases for class names.  Most useful for defining xtypes for widgets:\n     *\n     *     Ext.define('MyApp.CoolPanel', {\n     *         extend: 'Ext.panel.Panel',\n     *         alias: ['widget.coolpanel'],\n     *         title: 'Yeah!'\n     *     });\n     *\n     *     // Using Ext.create\n     *     Ext.create('widget.coolpanel');\n     *\n     *     // Using the shorthand for defining widgets by xtype\n     *     Ext.widget('panel', {\n     *         items: [\n     *             {xtype: 'coolpanel', html: 'Foo'},\n     *             {xtype: 'coolpanel', html: 'Bar'}\n     *         ]\n     *     });\n     *\n     * Besides \"widget\" for xtype there are alias namespaces like \"feature\" for ftype and \"plugin\" for ptype.\n     */\n    Manager.registerPostprocessor('alias', function(name, cls, data) {\n        var aliases = data.alias,\n            i, ln;\n\n        for (i = 0,ln = aliases.length; i < ln; i++) {\n            alias = aliases[i];\n\n            this.setAlias(cls, alias);\n        }\n\n    }, ['xtype', 'alias']);\n\n    /**\n     * @cfg {Boolean} singleton\n     * @member Ext.Class\n     * When set to true, the class will be instantiated as singleton.  For example:\n     *\n     *     Ext.define('Logger', {\n     *         singleton: true,\n     *         log: function(msg) {\n     *             console.log(msg);\n     *         }\n     *     });\n     *\n     *     Logger.log('Hello');\n     */\n    Manager.registerPostprocessor('singleton', function(name, cls, data, fn) {\n        fn.call(this, name, new cls(), data);\n        return false;\n    });\n\n    /**\n     * @cfg {String/String[]} alternateClassName\n     * @member Ext.Class\n     * Defines alternate names for this class.  For example:\n     *\n     *     Ext.define('Developer', {\n     *         alternateClassName: ['Coder', 'Hacker'],\n     *         code: function(msg) {\n     *             alert('Typing... ' + msg);\n     *         }\n     *     });\n     *\n     *     var joe = Ext.create('Developer');\n     *     joe.code('stackoverflow');\n     *\n     *     var rms = Ext.create('Hacker');\n     *     rms.code('hack hack');\n     */\n    Manager.registerPostprocessor('alternateClassName', function(name, cls, data) {\n        var alternates = data.alternateClassName,\n            i, ln, alternate;\n\n        if (!(alternates instanceof Array)) {\n            alternates = [alternates];\n        }\n\n        for (i = 0, ln = alternates.length; i < ln; i++) {\n            alternate = alternates[i];\n\n            if (typeof alternate != 'string') {\n                throw new Error(\"[Ext.define] Invalid alternate of: '\" + alternate + \"' for class: '\" + name + \"'; must be a valid string\");\n            }\n\n            this.set(alternate, cls);\n        }\n    });\n\n    Ext.apply(Ext, {\n        /**\n         * Instantiate a class by either full name, alias or alternate name.\n         *\n         * If {@link Ext.Loader} is {@link Ext.Loader#setConfig enabled} and the class has\n         * not been defined yet, it will attempt to load the class via synchronous loading.\n         *\n         * For example, all these three lines return the same result:\n         *\n         *      // alias\n         *      var window = Ext.create('widget.window', {\n         *          width: 600,\n         *          height: 800,\n         *          ...\n         *      });\n         *\n         *      // alternate name\n         *      var window = Ext.create('Ext.Window', {\n         *          width: 600,\n         *          height: 800,\n         *          ...\n         *      });\n         *\n         *      // full class name\n         *      var window = Ext.create('Ext.window.Window', {\n         *          width: 600,\n         *          height: 800,\n         *          ...\n         *      });\n         *\n         *      // single object with xclass property:\n         *      var window = Ext.create({\n         *          xclass: 'Ext.window.Window', // any valid value for 'name' (above)\n         *          width: 600,\n         *          height: 800,\n         *          ...\n         *      });\n         *\n         * @param {String} [name] The class name or alias. Can be specified as `xclass`\n         * property if only one object parameter is specified.\n         * @param {Object...} [args] Additional arguments after the name will be passed to\n         * the class' constructor.\n         * @return {Object} instance\n         * @member Ext\n         * @method create\n         */\n        create: alias(Manager, 'instantiate'),\n\n        /**\n         * Convenient shorthand to create a widget by its xtype or a config object.\n         * See also {@link Ext.ClassManager#instantiateByAlias}.\n         *\n         *      var button = Ext.widget('button'); // Equivalent to Ext.create('widget.button');\n         *\n         *      var panel = Ext.widget('panel', { // Equivalent to Ext.create('widget.panel')\n         *          title: 'Panel'\n         *      });\n         *\n         *      var grid = Ext.widget({\n         *          xtype: 'grid',\n         *          ...\n         *      });\n         *\n         * If a {@link Ext.Component component} instance is passed, it is simply returned.\n         *\n         * @member Ext\n         * @param {String} [name] The xtype of the widget to create.\n         * @param {Object} [config] The configuration object for the widget constructor.\n         * @return {Object} The widget instance\n         */\n        widget: function(name, config) {\n            // forms:\n            //      1: (xtype)\n            //      2: (xtype, config)\n            //      3: (config)\n            //      4: (xtype, component)\n            //      5: (component)\n            //      \n            var xtype = name,\n                alias, className, T, load;\n\n            if (typeof xtype != 'string') { // if (form 3 or 5)\n                // first arg is config or component\n                config = name; // arguments[0]\n                xtype = config.xtype;\n            } else {\n                config = config || {};\n            }\n            \n            if (config.isComponent) {\n                return config;\n            }\n\n            alias = 'widget.' + xtype;\n            className = Manager.getNameByAlias(alias);\n\n            // this is needed to support demand loading of the class\n            if (!className) {\n                load = true;\n            }\n            \n            T = Manager.get(className);\n            if (load || !T) {\n                return Manager.instantiateByAlias(alias, config);\n            }\n            return new T(config);\n        },\n\n        /**\n         * Convenient shorthand, see {@link Ext.ClassManager#instantiateByAlias}\n         * @member Ext\n         * @method createByAlias\n         */\n        createByAlias: alias(Manager, 'instantiateByAlias'),\n\n        /**\n         * @method\n         * Defines a class or override. A basic class is defined like this:\n         *\n         *      Ext.define('My.awesome.Class', {\n         *          someProperty: 'something',\n         *\n         *          someMethod: function(s) {\n         *              alert(s + this.someProperty);\n         *          }\n         *\n         *          ...\n         *      });\n         *\n         *      var obj = new My.awesome.Class();\n         *\n         *      obj.someMethod('Say '); // alerts 'Say something'\n         *\n         * To create an anonymous class, pass `null` for the `className`:\n         * \n         *      Ext.define(null, {\n         *          constructor: function () {\n         *              // ...\n         *          }\n         *      });\n         *\n         * In some cases, it is helpful to create a nested scope to contain some private\n         * properties. The best way to do this is to pass a function instead of an object\n         * as the second parameter. This function will be called to produce the class\n         * body:\n         * \n         *      Ext.define('MyApp.foo.Bar', function () {\n         *          var id = 0;\n         *          \n         *          return {\n         *              nextId: function () {\n         *                  return ++id;\n         *              }\n         *          };\n         *      });\n         * \n         * When using this form of `Ext.define`, the function is passed a reference to its\n         * class. This can be used as an efficient way to access any static properties you\n         * may have:\n         * \n         *      Ext.define('MyApp.foo.Bar', function (Bar) {\n         *          return {\n         *              statics: {\n         *                  staticMethod: function () {\n         *                      // ...\n         *                  }\n         *              },\n         *              \n         *              method: function () {\n         *                  return Bar.staticMethod();\n         *              }\n         *          };\n         *      });\n         *\n         * To define an override, include the `override` property. The content of an\n         * override is aggregated with the specified class in order to extend or modify\n         * that class. This can be as simple as setting default property values or it can\n         * extend and/or replace methods. This can also extend the statics of the class.\n         *\n         * One use for an override is to break a large class into manageable pieces.\n         *\n         *      // File: /src/app/Panel.js\n         *\n         *      Ext.define('My.app.Panel', {\n         *          extend: 'Ext.panel.Panel',\n         *          requires: [\n         *              'My.app.PanelPart2',\n         *              'My.app.PanelPart3'\n         *          ]\n         *\n         *          constructor: function (config) {\n         *              this.callParent(arguments); // calls Ext.panel.Panel's constructor\n         *              //...\n         *          },\n         *\n         *          statics: {\n         *              method: function () {\n         *                  return 'abc';\n         *              }\n         *          }\n         *      });\n         *\n         *      // File: /src/app/PanelPart2.js\n         *      Ext.define('My.app.PanelPart2', {\n         *          override: 'My.app.Panel',\n         *\n         *          constructor: function (config) {\n         *              this.callParent(arguments); // calls My.app.Panel's constructor\n         *              //...\n         *          }\n         *      });\n         *\n         * Another use of overrides is to provide optional parts of classes that can be\n         * independently required. In this case, the class may even be unaware of the\n         * override altogether.\n         *\n         *      Ext.define('My.ux.CoolTip', {\n         *          override: 'Ext.tip.ToolTip',\n         *\n         *          constructor: function (config) {\n         *              this.callParent(arguments); // calls Ext.tip.ToolTip's constructor\n         *              //...\n         *          }\n         *      });\n         *\n         * The above override can now be required as normal.\n         *\n         *      Ext.define('My.app.App', {\n         *          requires: [\n         *              'My.ux.CoolTip'\n         *          ]\n         *      });\n         *\n         * Overrides can also contain statics:\n         *\n         *      Ext.define('My.app.BarMod', {\n         *          override: 'Ext.foo.Bar',\n         *\n         *          statics: {\n         *              method: function (x) {\n         *                  return this.callParent([x * 2]); // call Ext.foo.Bar.method\n         *              }\n         *          }\n         *      });\n         *\n         * IMPORTANT: An override is only included in a build if the class it overrides is\n         * required. Otherwise, the override, like the target class, is not included.\n         *\n         * @param {String} className The class name to create in string dot-namespaced format, for example:\n         * 'My.very.awesome.Class', 'FeedViewer.plugin.CoolPager'\n         * It is highly recommended to follow this simple convention:\n         *  - The root and the class name are 'CamelCased'\n         *  - Everything else is lower-cased\n         * Pass `null` to create an anonymous class.\n         * @param {Object} data The key - value pairs of properties to apply to this class. Property names can be of any valid\n         * strings, except those in the reserved listed below:\n         *  - `mixins`\n         *  - `statics`\n         *  - `config`\n         *  - `alias`\n         *  - `self`\n         *  - `singleton`\n         *  - `alternateClassName`\n         *  - `override`\n         *\n         * @param {Function} createdFn Optional callback to execute after the class is created, the execution scope of which\n         * (`this`) will be the newly created class itself.\n         * @return {Ext.Base}\n         * @markdown\n         * @member Ext\n         * @method define\n         */\n        define: function (className, data, createdFn) {\n            if (data.override) {\n                return Manager.createOverride.apply(Manager, arguments);\n            }\n\n            return Manager.create.apply(Manager, arguments);\n        },\n\n        /**\n         * Convenient shorthand, see {@link Ext.ClassManager#getName}\n         * @member Ext\n         * @method getClassName\n         */\n        getClassName: alias(Manager, 'getName'),\n\n        /**\n         * Returns the displayName property or className or object. When all else fails, returns \"Anonymous\".\n         * @param {Object} object\n         * @return {String}\n         */\n        getDisplayName: function(object) {\n            if (object) {\n                if (object.displayName) {\n                    return object.displayName;\n                }\n\n                if (object.$name && object.$class) {\n                    return Ext.getClassName(object.$class) + '#' + object.$name;\n                }\n\n                if (object.$className) {\n                    return object.$className;\n                }\n            }\n\n            return 'Anonymous';\n        },\n\n        /**\n         * Convenient shorthand, see {@link Ext.ClassManager#getClass}\n         * @member Ext\n         * @method getClass\n         */\n        getClass: alias(Manager, 'getClass'),\n\n        /**\n         * Creates namespaces to be used for scoping variables and classes so that they are not global.\n         * Specifying the last node of a namespace implicitly creates all other nodes. Usage:\n         *\n         *     Ext.namespace('Company', 'Company.data');\n         *\n         *     // equivalent and preferable to the above syntax\n         *     Ext.ns('Company.data');\n         *\n         *     Company.Widget = function() { ... };\n         *\n         *     Company.data.CustomStore = function(config) { ... };\n         *\n         * @param {String...} namespaces\n         * @return {Object} The namespace object.\n         * (If multiple arguments are passed, this will be the last namespace created)\n         * @member Ext\n         * @method namespace\n         */\n        namespace: alias(Manager, 'createNamespaces')\n    });\n\n    /**\n     * Old name for {@link Ext#widget}.\n     * @deprecated 4.0.0 Use {@link Ext#widget} instead.\n     * @method createWidget\n     * @member Ext\n     */\n    Ext.createWidget = Ext.widget;\n\n    /**\n     * Convenient alias for {@link Ext#namespace Ext.namespace}.\n     * @inheritdoc Ext#namespace\n     * @member Ext\n     * @method ns\n     */\n    Ext.ns = Ext.namespace;\n\n    Class.registerPreprocessor('className', function(cls, data) {\n        if (data.$className) {\n            cls.$className = data.$className;\n            cls.displayName = cls.$className;\n        }\n    }, true, 'first');\n\n    Class.registerPreprocessor('alias', function(cls, data) {\n        var prototype = cls.prototype,\n            xtypes = arrayFrom(data.xtype),\n            aliases = arrayFrom(data.alias),\n            widgetPrefix = 'widget.',\n            widgetPrefixLength = widgetPrefix.length,\n            xtypesChain = Array.prototype.slice.call(prototype.xtypesChain || []),\n            xtypesMap = Ext.merge({}, prototype.xtypesMap || {}),\n            i, ln, alias, xtype;\n\n        for (i = 0,ln = aliases.length; i < ln; i++) {\n            alias = aliases[i];\n\n            if (typeof alias != 'string' || alias.length < 1) {\n                throw new Error(\"[Ext.define] Invalid alias of: '\" + alias + \"' for class: '\" + name + \"'; must be a valid string\");\n            }\n\n            if (alias.substring(0, widgetPrefixLength) === widgetPrefix) {\n                xtype = alias.substring(widgetPrefixLength);\n                Ext.Array.include(xtypes, xtype);\n            }\n        }\n\n        cls.xtype = data.xtype = xtypes[0];\n        data.xtypes = xtypes;\n\n        for (i = 0,ln = xtypes.length; i < ln; i++) {\n            xtype = xtypes[i];\n\n            if (!xtypesMap[xtype]) {\n                xtypesMap[xtype] = true;\n                xtypesChain.push(xtype);\n            }\n        }\n\n        data.xtypesChain = xtypesChain;\n        data.xtypesMap = xtypesMap;\n\n        Ext.Function.interceptAfter(data, 'onClassCreated', function() {\n            var mixins = prototype.mixins,\n                key, mixin;\n\n            for (key in mixins) {\n                if (mixins.hasOwnProperty(key)) {\n                    mixin = mixins[key];\n\n                    xtypes = mixin.xtypes;\n\n                    if (xtypes) {\n                        for (i = 0,ln = xtypes.length; i < ln; i++) {\n                            xtype = xtypes[i];\n\n                            if (!xtypesMap[xtype]) {\n                                xtypesMap[xtype] = true;\n                                xtypesChain.push(xtype);\n                            }\n                        }\n                    }\n                }\n            }\n        });\n\n        for (i = 0,ln = xtypes.length; i < ln; i++) {\n            xtype = xtypes[i];\n\n            if (typeof xtype != 'string' || xtype.length < 1) {\n                throw new Error(\"[Ext.define] Invalid xtype of: '\" + xtype + \"' for class: '\" + name + \"'; must be a valid non-empty string\");\n            }\n\n            Ext.Array.include(aliases, widgetPrefix + xtype);\n        }\n\n        data.alias = aliases;\n\n    }, ['xtype', 'alias']);\n\n}(Ext.Class, Ext.Function.alias, Array.prototype.slice, Ext.Array.from, Ext.global));\n\n//@tag foundation,core\n//@require ClassManager.js\n//@define Ext.Loader\n\n/**\n * @author Jacky Nguyen <jacky@sencha.com>\n * @docauthor Jacky Nguyen <jacky@sencha.com>\n * @class Ext.Loader\n *\n * Ext.Loader is the heart of the new dynamic dependency loading capability in Ext JS 4+. It is most commonly used\n * via the {@link Ext#require} shorthand. Ext.Loader supports both asynchronous and synchronous loading\n * approaches, and leverage their advantages for the best development flow. We'll discuss about the pros and cons of each approach:\n *\n * # Asynchronous Loading #\n *\n * - Advantages:\n *     + Cross-domain\n *     + No web server needed: you can run the application via the file system protocol (i.e: `file://path/to/your/index\n *  .html`)\n *     + Best possible debugging experience: error messages come with the exact file name and line number\n *\n * - Disadvantages:\n *     + Dependencies need to be specified before-hand\n *\n * ### Method 1: Explicitly include what you need: ###\n *\n *     // Syntax\n *     Ext.require({String/Array} expressions);\n *\n *     // Example: Single alias\n *     Ext.require('widget.window');\n *\n *     // Example: Single class name\n *     Ext.require('Ext.window.Window');\n *\n *     // Example: Multiple aliases / class names mix\n *     Ext.require(['widget.window', 'layout.border', 'Ext.data.Connection']);\n *\n *     // Wildcards\n *     Ext.require(['widget.*', 'layout.*', 'Ext.data.*']);\n *\n * ### Method 2: Explicitly exclude what you don't need: ###\n *\n *     // Syntax: Note that it must be in this chaining format.\n *     Ext.exclude({String/Array} expressions)\n *        .require({String/Array} expressions);\n *\n *     // Include everything except Ext.data.*\n *     Ext.exclude('Ext.data.*').require('*');\n *\n *     // Include all widgets except widget.checkbox*,\n *     // which will match widget.checkbox, widget.checkboxfield, widget.checkboxgroup, etc.\n *     Ext.exclude('widget.checkbox*').require('widget.*');\n *\n * # Synchronous Loading on Demand #\n *\n * - Advantages:\n *     + There's no need to specify dependencies before-hand, which is always the convenience of including ext-all.js\n *  before\n *\n * - Disadvantages:\n *     + Not as good debugging experience since file name won't be shown (except in Firebug at the moment)\n *     + Must be from the same domain due to XHR restriction\n *     + Need a web server, same reason as above\n *\n * There's one simple rule to follow: Instantiate everything with Ext.create instead of the `new` keyword\n *\n *     Ext.create('widget.window', { ... }); // Instead of new Ext.window.Window({...});\n *\n *     Ext.create('Ext.window.Window', {}); // Same as above, using full class name instead of alias\n *\n *     Ext.widget('window', {}); // Same as above, all you need is the traditional `xtype`\n *\n * Behind the scene, {@link Ext.ClassManager} will automatically check whether the given class name / alias has already\n *  existed on the page. If it's not, Ext.Loader will immediately switch itself to synchronous mode and automatic load the given\n *  class and all its dependencies.\n *\n * # Hybrid Loading - The Best of Both Worlds #\n *\n * It has all the advantages combined from asynchronous and synchronous loading. The development flow is simple:\n *\n * ### Step 1: Start writing your application using synchronous approach.\n *\n * Ext.Loader will automatically fetch all dependencies on demand as they're needed during run-time. For example:\n *\n *     Ext.onReady(function(){\n *         var window = Ext.widget('window', {\n *             width: 500,\n *             height: 300,\n *             layout: {\n *                 type: 'border',\n *                 padding: 5\n *             },\n *             title: 'Hello Dialog',\n *             items: [{\n *                 title: 'Navigation',\n *                 collapsible: true,\n *                 region: 'west',\n *                 width: 200,\n *                 html: 'Hello',\n *                 split: true\n *             }, {\n *                 title: 'TabPanel',\n *                 region: 'center'\n *             }]\n *         });\n *\n *         window.show();\n *     })\n *\n * ### Step 2: Along the way, when you need better debugging ability, watch the console for warnings like these: ###\n *\n *     [Ext.Loader] Synchronously loading 'Ext.window.Window'; consider adding Ext.require('Ext.window.Window') before your application's code\n *     ClassManager.js:432\n *     [Ext.Loader] Synchronously loading 'Ext.layout.container.Border'; consider adding Ext.require('Ext.layout.container.Border') before your application's code\n *\n * Simply copy and paste the suggested code above `Ext.onReady`, i.e:\n *\n *     Ext.require('Ext.window.Window');\n *     Ext.require('Ext.layout.container.Border');\n *\n *     Ext.onReady(...);\n *\n * Everything should now load via asynchronous mode.\n *\n * # Deployment #\n *\n * It's important to note that dynamic loading should only be used during development on your local machines.\n * During production, all dependencies should be combined into one single JavaScript file. Ext.Loader makes\n * the whole process of transitioning from / to between development / maintenance and production as easy as\n * possible. Internally {@link Ext.Loader#history Ext.Loader.history} maintains the list of all dependencies your application\n * needs in the exact loading sequence. It's as simple as concatenating all files in this array into one,\n * then include it on top of your application.\n *\n * This process will be automated with Sencha Command, to be released and documented towards Ext JS 4 Final.\n *\n * @singleton\n */\n\nExt.Loader = new function() {\n    var Loader = this,\n        Manager = Ext.ClassManager,\n        Class = Ext.Class,\n        flexSetter = Ext.Function.flexSetter,\n        alias = Ext.Function.alias,\n        pass = Ext.Function.pass,\n        defer = Ext.Function.defer,\n        arrayErase = Ext.Array.erase,\n        dependencyProperties = ['extend', 'mixins', 'requires'],\n        isInHistory = {},\n        history = [],\n        slashDotSlashRe = /\\/\\.\\//g,\n        dotRe = /\\./g;\n\n    Ext.apply(Loader, {\n\n        /**\n         * @private\n         */\n        isInHistory: isInHistory,\n\n        /**\n         * An array of class names to keep track of the dependency loading order.\n         * This is not guaranteed to be the same everytime due to the asynchronous\n         * nature of the Loader.\n         *\n         * @property {Array} history\n         */\n        history: history,\n\n        /**\n         * Configuration\n         * @private\n         */\n        config: {\n            /**\n             * @cfg {Boolean} enabled\n             * Whether or not to enable the dynamic dependency loading feature.\n             */\n            enabled: false,\n\n            /**\n             * @cfg {Boolean} scriptChainDelay\n             * millisecond delay between asynchronous script injection (prevents stack overflow on some user agents)\n             * 'false' disables delay but potentially increases stack load.\n             */\n            scriptChainDelay : false,\n\n            /**\n             * @cfg {Boolean} disableCaching\n             * Appends current timestamp to script files to prevent caching.\n             */\n            disableCaching: true,\n\n            /**\n             * @cfg {String} disableCachingParam\n             * The get parameter name for the cache buster's timestamp.\n             */\n            disableCachingParam: '_dc',\n\n            /**\n             * @cfg {Boolean} garbageCollect\n             * True to prepare an asynchronous script tag for garbage collection (effective only\n             * if {@link #preserveScripts preserveScripts} is false)\n             */\n            garbageCollect : false,\n\n            /**\n             * @cfg {Object} paths\n             * The mapping from namespaces to file paths\n             *\n             *     {\n             *         'Ext': '.', // This is set by default, Ext.layout.container.Container will be\n             *                     // loaded from ./layout/Container.js\n             *\n             *         'My': './src/my_own_folder' // My.layout.Container will be loaded from\n             *                                     // ./src/my_own_folder/layout/Container.js\n             *     }\n             *\n             * Note that all relative paths are relative to the current HTML document.\n             * If not being specified, for example, <code>Other.awesome.Class</code>\n             * will simply be loaded from <code>./Other/awesome/Class.js</code>\n             */\n            paths: {\n                'Ext': '.'\n            },\n\n            /**\n             * @cfg {Boolean} preserveScripts\n             * False to remove and optionally {@link #garbageCollect garbage-collect} asynchronously loaded scripts,\n             * True to retain script element for browser debugger compatibility and improved load performance.\n             */\n            preserveScripts : true,\n\n            /**\n             * @cfg {String} scriptCharset\n             * Optional charset to specify encoding of dynamic script content.\n             */\n            scriptCharset : undefined\n        },\n\n        /**\n         * Set the configuration for the loader. This should be called right after ext-(debug).js\n         * is included in the page, and before Ext.onReady. i.e:\n         *\n         *     <script type=\"text/javascript\" src=\"ext-core-debug.js\"></script>\n         *     <script type=\"text/javascript\">\n         *         Ext.Loader.setConfig({\n         *           enabled: true,\n         *           paths: {\n         *               'My': 'my_own_path'\n         *           }\n         *         });\n         *     </script>\n         *     <script type=\"text/javascript\">\n         *         Ext.require(...);\n         *\n         *         Ext.onReady(function() {\n         *           // application code here\n         *         });\n         *     </script>\n         *\n         * Refer to config options of {@link Ext.Loader} for the list of possible properties\n         *\n         * @param {Object} config The config object to override the default values\n         * @return {Ext.Loader} this\n         */\n        setConfig: function(name, value) {\n            if (Ext.isObject(name) && arguments.length === 1) {\n                Ext.merge(Loader.config, name);\n            }\n            else {\n                Loader.config[name] = (Ext.isObject(value)) ? Ext.merge(Loader.config[name], value) : value;\n            }\n\n            return Loader;\n        },\n\n        /**\n         * Get the config value corresponding to the specified name. If no name is given, will return the config object\n         * @param {String} name The config property name\n         * @return {Object}\n         */\n        getConfig: function(name) {\n            if (name) {\n                return Loader.config[name];\n            }\n\n            return Loader.config;\n        },\n\n        /**\n         * Sets the path of a namespace.\n         * For Example:\n         *\n         *     Ext.Loader.setPath('Ext', '.');\n         *\n         * @param {String/Object} name See {@link Ext.Function#flexSetter flexSetter}\n         * @param {String} path See {@link Ext.Function#flexSetter flexSetter}\n         * @return {Ext.Loader} this\n         * @method\n         */\n        setPath: flexSetter(function(name, path) {\n            Loader.config.paths[name] = path;\n\n            return Loader;\n        }),\n\n        /**\n         * Sets a batch of path entries\n         *\n         * @param {Object } paths a set of className: path mappings\n         * @return {Ext.Loader} this\n         */\n        addClassPathMappings: function(paths) {\n            var name;\n\n            for(name in paths){\n                Loader.config.paths[name] = paths[name];\n            }\n            return Loader;\n        },\n\n        /**\n         * Translates a className to a file path by adding the\n         * the proper prefix and converting the .'s to /'s. For example:\n         *\n         *     Ext.Loader.setPath('My', '/path/to/My');\n         *\n         *     alert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/path/to/My/awesome/Class.js'\n         *\n         * Note that the deeper namespace levels, if explicitly set, are always resolved first. For example:\n         *\n         *     Ext.Loader.setPath({\n         *         'My': '/path/to/lib',\n         *         'My.awesome': '/other/path/for/awesome/stuff',\n         *         'My.awesome.more': '/more/awesome/path'\n         *     });\n         *\n         *     alert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/other/path/for/awesome/stuff/Class.js'\n         *\n         *     alert(Ext.Loader.getPath('My.awesome.more.Class')); // alerts '/more/awesome/path/Class.js'\n         *\n         *     alert(Ext.Loader.getPath('My.cool.Class')); // alerts '/path/to/lib/cool/Class.js'\n         *\n         *     alert(Ext.Loader.getPath('Unknown.strange.Stuff')); // alerts 'Unknown/strange/Stuff.js'\n         *\n         * @param {String} className\n         * @return {String} path\n         */\n        getPath: function(className) {\n            var path = '',\n                paths = Loader.config.paths,\n                prefix = Loader.getPrefix(className);\n\n            if (prefix.length > 0) {\n                if (prefix === className) {\n                    return paths[prefix];\n                }\n\n                path = paths[prefix];\n                className = className.substring(prefix.length + 1);\n            }\n\n            if (path.length > 0) {\n                path += '/';\n            }\n\n            return path.replace(slashDotSlashRe, '/') + className.replace(dotRe, \"/\") + '.js';\n        },\n\n        /**\n         * @private\n         * @param {String} className\n         */\n        getPrefix: function(className) {\n            var paths = Loader.config.paths,\n                prefix, deepestPrefix = '';\n\n            if (paths.hasOwnProperty(className)) {\n                return className;\n            }\n\n            for (prefix in paths) {\n                if (paths.hasOwnProperty(prefix) && prefix + '.' === className.substring(0, prefix.length + 1)) {\n                    if (prefix.length > deepestPrefix.length) {\n                        deepestPrefix = prefix;\n                    }\n                }\n            }\n\n            return deepestPrefix;\n        },\n\n        /**\n         * @private\n         * @param {String} className\n         */\n        isAClassNameWithAKnownPrefix: function(className) {\n            var prefix = Loader.getPrefix(className);\n\n            // we can only say it's really a class if className is not equal to any known namespace\n            return prefix !== '' && prefix !== className;\n        },\n\n        /**\n         * Loads all classes by the given names and all their direct dependencies; optionally executes the given callback function when\n         * finishes, within the optional scope. This method is aliased by {@link Ext#require Ext.require} for convenience\n         * @param {String/Array} expressions Can either be a string or an array of string\n         * @param {Function} fn (Optional) The callback function\n         * @param {Object} scope (Optional) The execution scope (`this`) of the callback function\n         * @param {String/Array} excludes (Optional) Classes to be excluded, useful when being used with expressions\n         */\n        require: function(expressions, fn, scope, excludes) {\n            if (fn) {\n                fn.call(scope);\n            }\n        },\n\n        /**\n         * Synchronously loads all classes by the given names and all their direct dependencies; optionally executes the given callback function when finishes, within the optional scope. This method is aliased by {@link Ext#syncRequire} for convenience\n         * @param {String/Array} expressions Can either be a string or an array of string\n         * @param {Function} fn (Optional) The callback function\n         * @param {Object} scope (Optional) The execution scope (`this`) of the callback function\n         * @param {String/Array} excludes (Optional) Classes to be excluded, useful when being used with expressions\n         */\n        syncRequire: function() {},\n\n        /**\n         * Explicitly exclude files from being loaded. Useful when used in conjunction with a broad include expression.\n         * Can be chained with more `require` and `exclude` methods, eg:\n         *\n         *     Ext.exclude('Ext.data.*').require('*');\n         *\n         *     Ext.exclude('widget.button*').require('widget.*');\n         *\n         * @param {Array} excludes\n         * @return {Object} object contains `require` method for chaining\n         */\n        exclude: function(excludes) {\n            return {\n                require: function(expressions, fn, scope) {\n                    return Loader.require(expressions, fn, scope, excludes);\n                },\n\n                syncRequire: function(expressions, fn, scope) {\n                    return Loader.syncRequire(expressions, fn, scope, excludes);\n                }\n            };\n        },\n\n        /**\n         * Add a new listener to be executed when all required scripts are fully loaded\n         *\n         * @param {Function} fn The function callback to be executed\n         * @param {Object} scope The execution scope (<code>this</code>) of the callback function\n         * @param {Boolean} withDomReady Whether or not to wait for document dom ready as well\n         */\n        onReady: function(fn, scope, withDomReady, options) {\n            var oldFn;\n\n            if (withDomReady !== false && Ext.onDocumentReady) {\n                oldFn = fn;\n\n                fn = function() {\n                    Ext.onDocumentReady(oldFn, scope, options);\n                };\n            }\n\n            fn.call(scope);\n        }\n    });\n\n    var queue = [],\n        isClassFileLoaded = {},\n        isFileLoaded = {},\n        classNameToFilePathMap = {},\n        scriptElements = {},\n        readyListeners = [],\n        usedClasses = [],\n        requiresMap = {};\n\n    Ext.apply(Loader, {\n        /**\n         * @private\n         */\n        documentHead: typeof document != 'undefined' && (document.head || document.getElementsByTagName('head')[0]),\n\n        /**\n         * Flag indicating whether there are still files being loaded\n         * @private\n         */\n        isLoading: false,\n\n        /**\n         * Maintain the queue for all dependencies. Each item in the array is an object of the format:\n         *\n         *     {\n         *          requires: [...], // The required classes for this queue item\n         *          callback: function() { ... } // The function to execute when all classes specified in requires exist\n         *     }\n         *\n         * @private\n         */\n        queue: queue,\n\n        /**\n         * Maintain the list of files that have already been handled so that they never get double-loaded\n         * @private\n         */\n        isClassFileLoaded: isClassFileLoaded,\n\n        /**\n         * @private\n         */\n        isFileLoaded: isFileLoaded,\n\n        /**\n         * Maintain the list of listeners to execute when all required scripts are fully loaded\n         * @private\n         */\n        readyListeners: readyListeners,\n\n        /**\n         * Contains classes referenced in `uses` properties.\n         * @private\n         */\n        optionalRequires: usedClasses,\n\n        /**\n         * Map of fully qualified class names to an array of dependent classes.\n         * @private\n         */\n        requiresMap: requiresMap,\n\n        /**\n         * @private\n         */\n        numPendingFiles: 0,\n\n        /**\n         * @private\n         */\n        numLoadedFiles: 0,\n\n        /** @private */\n        hasFileLoadError: false,\n\n        /**\n         * @private\n         */\n        classNameToFilePathMap: classNameToFilePathMap,\n\n        /**\n         * The number of scripts loading via loadScript.\n         * @private\n         */\n        scriptsLoading: 0,\n\n        /**\n         * @private\n         */\n        syncModeEnabled: false,\n\n        scriptElements: scriptElements,\n\n        /**\n         * Refresh all items in the queue. If all dependencies for an item exist during looping,\n         * it will execute the callback and call refreshQueue again. Triggers onReady when the queue is\n         * empty\n         * @private\n         */\n        refreshQueue: function() {\n            var ln = queue.length,\n                i, item, j, requires;\n\n            // When the queue of loading classes reaches zero, trigger readiness\n\n            if (!ln && !Loader.scriptsLoading) {\n                return Loader.triggerReady();\n            }\n\n            for (i = 0; i < ln; i++) {\n                item = queue[i];\n\n                if (item) {\n                    requires = item.requires;\n\n                    // Don't bother checking when the number of files loaded\n                    // is still less than the array length\n                    if (requires.length > Loader.numLoadedFiles) {\n                        continue;\n                    }\n\n                    // Remove any required classes that are loaded\n                    for (j = 0; j < requires.length; ) {\n                        if (Manager.isCreated(requires[j])) {\n                            // Take out from the queue\n                            arrayErase(requires, j, 1);\n                        }\n                        else {\n                            j++;\n                        }\n                    }\n\n                    // If we've ended up with no required classes, call the callback\n                    if (item.requires.length === 0) {\n                        arrayErase(queue, i, 1);\n                        item.callback.call(item.scope);\n                        Loader.refreshQueue();\n                        break;\n                    }\n                }\n            }\n\n            return Loader;\n        },\n\n        /**\n         * Inject a script element to document's head, call onLoad and onError accordingly\n         * @private\n         */\n        injectScriptElement: function(url, onLoad, onError, scope, charset) {\n            var script = document.createElement('script'),\n                dispatched = false,\n                config = Loader.config,\n                onLoadFn = function() {\n\n                    if(!dispatched) {\n                        dispatched = true;\n                        script.onload = script.onreadystatechange = script.onerror = null;\n                        if (typeof config.scriptChainDelay == 'number') {\n                            //free the stack (and defer the next script)\n                            defer(onLoad, config.scriptChainDelay, scope);\n                        } else {\n                            onLoad.call(scope);\n                        }\n                        Loader.cleanupScriptElement(script, config.preserveScripts === false, config.garbageCollect);\n                    }\n\n                },\n                onErrorFn = function(arg) {\n                    defer(onError, 1, scope);   //free the stack\n                    Loader.cleanupScriptElement(script, config.preserveScripts === false, config.garbageCollect);\n                };\n\n            script.type = 'text/javascript';\n            script.onerror = onErrorFn;\n            charset = charset || config.scriptCharset;\n            if (charset) {\n                script.charset = charset;\n            }\n\n            /*\n             * IE9 Standards mode (and others) SHOULD follow the load event only\n             * (Note: IE9 supports both onload AND readystatechange events)\n             */\n            if ('addEventListener' in script ) {\n                script.onload = onLoadFn;\n            } else if ('readyState' in script) {   // for <IE9 Compatability\n                script.onreadystatechange = function() {\n                    if ( this.readyState == 'loaded' || this.readyState == 'complete' ) {\n                        onLoadFn();\n                    }\n                };\n            } else {\n                 script.onload = onLoadFn;\n            }\n\n            script.src = url;\n            (Loader.documentHead || document.getElementsByTagName('head')[0]).appendChild(script);\n\n            return script;\n        },\n\n        /**\n         * @private\n         */\n        removeScriptElement: function(url) {\n            if (scriptElements[url]) {\n                Loader.cleanupScriptElement(scriptElements[url], true, !!Loader.getConfig('garbageCollect'));\n                delete scriptElements[url];\n            }\n\n            return Loader;\n        },\n\n        /**\n         * @private\n         */\n        cleanupScriptElement: function(script, remove, collect) {\n            var prop;\n            script.onload = script.onreadystatechange = script.onerror = null;\n            if (remove) {\n                Ext.removeNode(script);       // Remove, since its useless now\n                if (collect) {\n                    for (prop in script) {\n                        try {\n                            script[prop] = null;\n                            delete script[prop];      // and prepare for GC\n                        } catch (cleanEx) {\n                            //ignore\n                        }\n                    }\n                }\n            }\n\n            return Loader;\n        },\n\n        /**\n         * Loads the specified script URL and calls the supplied callbacks. If this method\n         * is called before {@link Ext#isReady}, the script's load will delay the transition\n         * to ready. This can be used to load arbitrary scripts that may contain further\n         * {@link Ext#require Ext.require} calls.\n         *\n         * @param {Object/String} options The options object or simply the URL to load.\n         * @param {String} options.url The URL from which to load the script.\n         * @param {Function} [options.onLoad] The callback to call on successful load.\n         * @param {Function} [options.onError] The callback to call on failure to load.\n         * @param {Object} [options.scope] The scope (`this`) for the supplied callbacks.\n         */\n        loadScript: function (options) {\n            var config = Loader.getConfig(),\n                isString = typeof options == 'string',\n                url = isString ? options : options.url,\n                onError = !isString && options.onError,\n                onLoad = !isString && options.onLoad,\n                scope = !isString && options.scope,\n                onScriptError = function() {\n                    Loader.numPendingFiles--;\n                    Loader.scriptsLoading--;\n\n                    if (onError) {\n                        onError.call(scope, \"Failed loading '\" + url + \"', please verify that the file exists\");\n                    }\n\n                    if (Loader.numPendingFiles + Loader.scriptsLoading === 0) {\n                        Loader.refreshQueue();\n                    }\n                },\n                onScriptLoad = function () {\n                    Loader.numPendingFiles--;\n                    Loader.scriptsLoading--;\n\n                    if (onLoad) {\n                        onLoad.call(scope);\n                    }\n\n                    if (Loader.numPendingFiles + Loader.scriptsLoading === 0) {\n                        Loader.refreshQueue();\n                    }\n                },\n                src;\n\n            Loader.isLoading = true;\n            Loader.numPendingFiles++;\n            Loader.scriptsLoading++;\n\n            src = config.disableCaching ?\n                (url + '?' + config.disableCachingParam + '=' + Ext.Date.now()) : url;\n\n            scriptElements[url] = Loader.injectScriptElement(src, onScriptLoad, onScriptError);\n        },\n\n        /**\n         * Load a script file, supports both asynchronous and synchronous approaches\n         * @private\n         */\n        loadScriptFile: function(url, onLoad, onError, scope, synchronous) {\n            if (isFileLoaded[url]) {\n                return Loader;\n            }\n\n            var config = Loader.getConfig(),\n                noCacheUrl = url + (config.disableCaching ? ('?' + config.disableCachingParam + '=' + Ext.Date.now()) : ''),\n                isCrossOriginRestricted = false,\n                xhr, status, onScriptError,\n                debugSourceURL = \"\";\n\n            scope = scope || Loader;\n\n            Loader.isLoading = true;\n\n            if (!synchronous) {\n                onScriptError = function() {\n                    onError.call(scope, \"Failed loading '\" + url + \"', please verify that the file exists\", synchronous);\n                };\n\n                scriptElements[url] = Loader.injectScriptElement(noCacheUrl, onLoad, onScriptError, scope);\n            } else {\n                if (typeof XMLHttpRequest != 'undefined') {\n                    xhr = new XMLHttpRequest();\n                } else {\n                    xhr = new ActiveXObject('Microsoft.XMLHTTP');\n                }\n\n                try {\n                    xhr.open('GET', noCacheUrl, false);\n                    xhr.send(null);\n                } catch (e) {\n                    isCrossOriginRestricted = true;\n                }\n\n                status = (xhr.status === 1223) ? 204 :\n                    (xhr.status === 0 && (self.location || {}).protocol == 'file:') ? 200 : xhr.status;\n\n                isCrossOriginRestricted = isCrossOriginRestricted || (status === 0);\n\n                if (isCrossOriginRestricted\n                ) {\n                    onError.call(Loader, \"Failed loading synchronously via XHR: '\" + url + \"'; It's likely that the file is either \" +\n                                       \"being loaded from a different domain or from the local file system whereby cross origin \" +\n                                       \"requests are not allowed due to security reasons. Use asynchronous loading with \" +\n                                       \"Ext.require instead.\", synchronous);\n                }\n                else if ((status >= 200 && status < 300) || (status === 304)\n                ) {\n                    // Debugger friendly, file names are still shown even though they're eval'ed code\n                    // Breakpoints work on both Firebug and Chrome's Web Inspector\n                    if (!Ext.isIE) {\n                        debugSourceURL = \"\\n//@ sourceURL=\" + url;\n                    }\n\n                    Ext.globalEval(xhr.responseText + debugSourceURL);\n\n                    onLoad.call(scope);\n                }\n                else {\n                    onError.call(Loader, \"Failed loading synchronously via XHR: '\" + url + \"'; please \" +\n                                       \"verify that the file exists. \" +\n                                       \"XHR status code: \" + status, synchronous);\n                }\n\n                // Prevent potential IE memory leak\n                xhr = null;\n            }\n        },\n\n        // documented above\n        syncRequire: function() {\n            var syncModeEnabled = Loader.syncModeEnabled;\n\n            if (!syncModeEnabled) {\n                Loader.syncModeEnabled = true;\n            }\n\n            Loader.require.apply(Loader, arguments);\n\n            if (!syncModeEnabled) {\n                Loader.syncModeEnabled = false;\n            }\n\n            Loader.refreshQueue();\n        },\n\n        // documented above\n        require: function(expressions, fn, scope, excludes) {\n            var excluded = {},\n                included = {},\n                excludedClassNames = [],\n                possibleClassNames = [],\n                classNames = [],\n                references = [],\n                callback,\n                syncModeEnabled,\n                filePath, expression, exclude, className,\n                possibleClassName, i, j, ln, subLn;\n\n            if (excludes) {\n                // Convert possible single string to an array.\n                excludes = (typeof excludes === 'string') ? [ excludes ] : excludes;\n\n                for (i = 0,ln = excludes.length; i < ln; i++) {\n                    exclude = excludes[i];\n\n                    if (typeof exclude == 'string' && exclude.length > 0) {\n                        excludedClassNames = Manager.getNamesByExpression(exclude);\n\n                        for (j = 0,subLn = excludedClassNames.length; j < subLn; j++) {\n                            excluded[excludedClassNames[j]] = true;\n                        }\n                    }\n                }\n            }\n\n            // Convert possible single string to an array.\n            expressions = (typeof expressions === 'string') ? [ expressions ] : (expressions ? expressions : []);\n\n            if (fn) {\n                if (fn.length > 0) {\n                    callback = function() {\n                        var classes = [],\n                            i, ln;\n\n                        for (i = 0,ln = references.length; i < ln; i++) {\n                            classes.push(Manager.get(references[i]));\n                        }\n\n                        return fn.apply(this, classes);\n                    };\n                }\n                else {\n                    callback = fn;\n                }\n            }\n            else {\n                callback = Ext.emptyFn;\n            }\n\n            scope = scope || Ext.global;\n\n            for (i = 0,ln = expressions.length; i < ln; i++) {\n                expression = expressions[i];\n\n                if (typeof expression == 'string' && expression.length > 0) {\n                    possibleClassNames = Manager.getNamesByExpression(expression);\n                    subLn = possibleClassNames.length;\n\n                    for (j = 0; j < subLn; j++) {\n                        possibleClassName = possibleClassNames[j];\n\n                        if (excluded[possibleClassName] !== true) {\n                            references.push(possibleClassName);\n\n                            if (!Manager.isCreated(possibleClassName) && !included[possibleClassName]) {\n                                included[possibleClassName] = true;\n                                classNames.push(possibleClassName);\n                            }\n                        }\n                    }\n                }\n            }\n\n            // If the dynamic dependency feature is not being used, throw an error\n            // if the dependencies are not defined\n            if (classNames.length > 0) {\n                if (!Loader.config.enabled) {\n                    throw new Error(\"Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. \" +\n                             \"Missing required class\" + ((classNames.length > 1) ? \"es\" : \"\") + \": \" + classNames.join(', '));\n                }\n            }\n            else {\n                callback.call(scope);\n                return Loader;\n            }\n\n            syncModeEnabled = Loader.syncModeEnabled;\n\n            if (!syncModeEnabled) {\n                queue.push({\n                    requires: classNames.slice(), // this array will be modified as the queue is processed,\n                                                  // so we need a copy of it\n                    callback: callback,\n                    scope: scope\n                });\n            }\n\n            ln = classNames.length;\n\n            for (i = 0; i < ln; i++) {\n                className = classNames[i];\n\n                filePath = Loader.getPath(className);\n\n                // If we are synchronously loading a file that has already been asychronously loaded before\n                // we need to destroy the script tag and revert the count\n                // This file will then be forced loaded in synchronous\n                if (syncModeEnabled && isClassFileLoaded.hasOwnProperty(className)) {\n                    Loader.numPendingFiles--;\n                    Loader.removeScriptElement(filePath);\n                    delete isClassFileLoaded[className];\n                }\n\n                if (!isClassFileLoaded.hasOwnProperty(className)) {\n                    isClassFileLoaded[className] = false;\n\n                    classNameToFilePathMap[className] = filePath;\n\n                    Loader.numPendingFiles++;\n                    Loader.loadScriptFile(\n                        filePath,\n                        pass(Loader.onFileLoaded, [className, filePath], Loader),\n                        pass(Loader.onFileLoadError, [className, filePath], Loader),\n                        Loader,\n                        syncModeEnabled\n                    );\n                }\n            }\n\n            if (syncModeEnabled) {\n                callback.call(scope);\n\n                if (ln === 1) {\n                    return Manager.get(className);\n                }\n            }\n\n            return Loader;\n        },\n\n        /**\n         * @private\n         * @param {String} className\n         * @param {String} filePath\n         */\n        onFileLoaded: function(className, filePath) {\n            Loader.numLoadedFiles++;\n\n            isClassFileLoaded[className] = true;\n            isFileLoaded[filePath] = true;\n\n            Loader.numPendingFiles--;\n\n            if (Loader.numPendingFiles === 0) {\n                Loader.refreshQueue();\n            }\n\n            if (!Loader.syncModeEnabled && Loader.numPendingFiles === 0 && Loader.isLoading && !Loader.hasFileLoadError) {\n                var missingClasses = [],\n                    missingPaths = [],\n                    requires,\n                    i, ln, j, subLn;\n\n                for (i = 0,ln = queue.length; i < ln; i++) {\n                    requires = queue[i].requires;\n\n                    for (j = 0,subLn = requires.length; j < subLn; j++) {\n                        if (isClassFileLoaded[requires[j]]) {\n                            missingClasses.push(requires[j]);\n                        }\n                    }\n                }\n\n                if (missingClasses.length < 1) {\n                    return;\n                }\n\n                missingClasses = Ext.Array.filter(Ext.Array.unique(missingClasses), function(item) {\n                    return !requiresMap.hasOwnProperty(item);\n                }, Loader);\n\n                for (i = 0,ln = missingClasses.length; i < ln; i++) {\n                    missingPaths.push(classNameToFilePathMap[missingClasses[i]]);\n                }\n\n                throw new Error(\"The following classes are not declared even if their files have been \" +\n                    \"loaded: '\" + missingClasses.join(\"', '\") + \"'. Please check the source code of their \" +\n                    \"corresponding files for possible typos: '\" + missingPaths.join(\"', '\"));\n            }\n        },\n\n        /**\n         * @private\n         */\n        onFileLoadError: function(className, filePath, errorMessage, isSynchronous) {\n            Loader.numPendingFiles--;\n            Loader.hasFileLoadError = true;\n\n            throw new Error(\"[Ext.Loader] \" + errorMessage);\n        },\n\n        /**\n         * @private\n         * Ensure that any classes referenced in the `uses` property are loaded.\n         */\n        addUsedClasses: function (classes) {\n            var cls, i, ln;\n\n            if (classes) {\n                classes = (typeof classes == 'string') ? [classes] : classes;\n                for (i = 0, ln = classes.length; i < ln; i++) {\n                    cls = classes[i];\n                    if (typeof cls == 'string' && !Ext.Array.contains(usedClasses, cls)) {\n                        usedClasses.push(cls);\n                    }\n                }\n            }\n\n            return Loader;\n        },\n\n        /**\n         * @private\n         */\n        triggerReady: function() {\n            var listener,\n                i, refClasses = usedClasses;\n\n            if (Loader.isLoading) {\n                Loader.isLoading = false;\n\n                if (refClasses.length !== 0) {\n                    // Clone then empty the array to eliminate potential recursive loop issue\n                    refClasses = refClasses.slice();\n                    usedClasses.length = 0;\n                    // this may immediately call us back if all 'uses' classes\n                    // have been loaded\n                    Loader.require(refClasses, Loader.triggerReady, Loader);\n                    return Loader;\n                }\n            }\n\n            // this method can be called with Loader.isLoading either true or false\n            // (can be called with false when all 'uses' classes are already loaded)\n            // this may bypass the above if condition\n            while (readyListeners.length && !Loader.isLoading) {\n                // calls to refreshQueue may re-enter triggerReady\n                // so we cannot necessarily iterate the readyListeners array\n                listener = readyListeners.shift();\n                listener.fn.call(listener.scope);\n            }\n\n            return Loader;\n        },\n\n        // Documented above already\n        onReady: function(fn, scope, withDomReady, options) {\n            var oldFn;\n\n            if (withDomReady !== false && Ext.onDocumentReady) {\n                oldFn = fn;\n\n                fn = function() {\n                    Ext.onDocumentReady(oldFn, scope, options);\n                };\n            }\n\n            if (!Loader.isLoading) {\n                fn.call(scope);\n            }\n            else {\n                readyListeners.push({\n                    fn: fn,\n                    scope: scope\n                });\n            }\n        },\n\n        /**\n         * @private\n         * @param {String} className\n         */\n        historyPush: function(className) {\n            if (className && isClassFileLoaded.hasOwnProperty(className) && !isInHistory[className]) {\n                isInHistory[className] = true;\n                history.push(className);\n            }\n            return Loader;\n        }\n    });\n\n    /**\n     * Turns on or off the \"cache buster\" applied to dynamically loaded scripts. Normally\n     * dynamically loaded scripts have an extra query parameter appended to avoid stale\n     * cached scripts. This method can be used to disable this mechanism, and is primarily\n     * useful for testing. This is done using a cookie.\n     * @param {Boolean} disable True to disable the cache buster.\n     * @param {String} [path=\"/\"] An optional path to scope the cookie.\n     * @private\n     */\n    Ext.disableCacheBuster = function (disable, path) {\n        var date = new Date();\n        date.setTime(date.getTime() + (disable ? 10*365 : -1) * 24*60*60*1000);\n        date = date.toGMTString();\n        document.cookie = 'ext-cache=1; expires=' + date + '; path='+(path || '/');\n    };\n\n\n    /**\n     * Convenient alias of {@link Ext.Loader#require}. Please see the introduction documentation of\n     * {@link Ext.Loader} for examples.\n     * @member Ext\n     * @method require\n     */\n    Ext.require = alias(Loader, 'require');\n\n    /**\n     * Synchronous version of {@link Ext#require}, convenient alias of {@link Ext.Loader#syncRequire}.\n     *\n     * @member Ext\n     * @method syncRequire\n     */\n    Ext.syncRequire = alias(Loader, 'syncRequire');\n\n    /**\n     * Convenient shortcut to {@link Ext.Loader#exclude}\n     * @member Ext\n     * @method exclude\n     */\n    Ext.exclude = alias(Loader, 'exclude');\n\n    /**\n     * @member Ext\n     * @method onReady\n     * @ignore\n     */\n    Ext.onReady = function(fn, scope, options) {\n        Loader.onReady(fn, scope, true, options);\n    };\n\n    /**\n     * @cfg {String[]} requires\n     * @member Ext.Class\n     * List of classes that have to be loaded before instantiating this class.\n     * For example:\n     *\n     *     Ext.define('Mother', {\n     *         requires: ['Child'],\n     *         giveBirth: function() {\n     *             // we can be sure that child class is available.\n     *             return new Child();\n     *         }\n     *     });\n     */\n    Class.registerPreprocessor('loader', function(cls, data, hooks, continueFn) {\n        var me = this,\n            dependencies = [],\n            dependency,\n            className = Manager.getName(cls),\n            i, j, ln, subLn, value, propertyName, propertyValue,\n            requiredMap, requiredDep;\n\n        /*\n        Loop through the dependencyProperties, look for string class names and push\n        them into a stack, regardless of whether the property's value is a string, array or object. For example:\n        {\n              extend: 'Ext.MyClass',\n              requires: ['Ext.some.OtherClass'],\n              mixins: {\n                  observable: 'Ext.util.Observable';\n              }\n        }\n        which will later be transformed into:\n        {\n              extend: Ext.MyClass,\n              requires: [Ext.some.OtherClass],\n              mixins: {\n                  observable: Ext.util.Observable;\n              }\n        }\n        */\n\n        for (i = 0,ln = dependencyProperties.length; i < ln; i++) {\n            propertyName = dependencyProperties[i];\n\n            if (data.hasOwnProperty(propertyName)) {\n                propertyValue = data[propertyName];\n\n                if (typeof propertyValue == 'string') {\n                    dependencies.push(propertyValue);\n                }\n                else if (propertyValue instanceof Array) {\n                    for (j = 0, subLn = propertyValue.length; j < subLn; j++) {\n                        value = propertyValue[j];\n\n                        if (typeof value == 'string') {\n                            dependencies.push(value);\n                        }\n                    }\n                }\n                else if (typeof propertyValue != 'function') {\n                    for (j in propertyValue) {\n                        if (propertyValue.hasOwnProperty(j)) {\n                            value = propertyValue[j];\n\n                            if (typeof value == 'string') {\n                                dependencies.push(value);\n                            }\n                        }\n                    }\n                }\n            }\n        }\n\n        if (dependencies.length === 0) {\n            return;\n        }\n\n        var deadlockPath = [],\n            detectDeadlock;\n\n        /*\n        Automatically detect deadlocks before-hand,\n        will throw an error with detailed path for ease of debugging. Examples of deadlock cases:\n\n        - A extends B, then B extends A\n        - A requires B, B requires C, then C requires A\n\n        The detectDeadlock function will recursively transverse till the leaf, hence it can detect deadlocks\n        no matter how deep the path is.\n        */\n\n        if (className) {\n            requiresMap[className] = dependencies;\n            requiredMap = Loader.requiredByMap || (Loader.requiredByMap = {});\n\n            for (i = 0,ln = dependencies.length; i < ln; i++) {\n                dependency = dependencies[i];\n                (requiredMap[dependency] || (requiredMap[dependency] = [])).push(className);\n            }\n            detectDeadlock = function(cls) {\n                deadlockPath.push(cls);\n\n                if (requiresMap[cls]) {\n                    if (Ext.Array.contains(requiresMap[cls], className)) {\n                        throw new Error(\"Deadlock detected while loading dependencies! '\" + className + \"' and '\" +\n                                deadlockPath[1] + \"' \" + \"mutually require each other. Path: \" +\n                                deadlockPath.join(' -> ') + \" -> \" + deadlockPath[0]);\n                    }\n\n                    for (i = 0,ln = requiresMap[cls].length; i < ln; i++) {\n                        detectDeadlock(requiresMap[cls][i]);\n                    }\n                }\n            };\n\n            detectDeadlock(className);\n        }\n\n\n        Loader.require(dependencies, function() {\n            for (i = 0,ln = dependencyProperties.length; i < ln; i++) {\n                propertyName = dependencyProperties[i];\n\n                if (data.hasOwnProperty(propertyName)) {\n                    propertyValue = data[propertyName];\n\n                    if (typeof propertyValue == 'string') {\n                        data[propertyName] = Manager.get(propertyValue);\n                    }\n                    else if (propertyValue instanceof Array) {\n                        for (j = 0, subLn = propertyValue.length; j < subLn; j++) {\n                            value = propertyValue[j];\n\n                            if (typeof value == 'string') {\n                                data[propertyName][j] = Manager.get(value);\n                            }\n                        }\n                    }\n                    else if (typeof propertyValue != 'function') {\n                        for (var k in propertyValue) {\n                            if (propertyValue.hasOwnProperty(k)) {\n                                value = propertyValue[k];\n\n                                if (typeof value == 'string') {\n                                    data[propertyName][k] = Manager.get(value);\n                                }\n                            }\n                        }\n                    }\n                }\n            }\n\n            continueFn.call(me, cls, data, hooks);\n        });\n\n        return false;\n    }, true, 'after', 'className');\n\n    /**\n     * @cfg {String[]} uses\n     * @member Ext.Class\n     * List of optional classes to load together with this class. These aren't neccessarily loaded before\n     * this class is created, but are guaranteed to be available before Ext.onReady listeners are\n     * invoked. For example:\n     *\n     *     Ext.define('Mother', {\n     *         uses: ['Child'],\n     *         giveBirth: function() {\n     *             // This code might, or might not work:\n     *             // return new Child();\n     *\n     *             // Instead use Ext.create() to load the class at the spot if not loaded already:\n     *             return Ext.create('Child');\n     *         }\n     *     });\n     */\n    Manager.registerPostprocessor('uses', function(name, cls, data) {\n        var uses = data.uses;\n        if (uses) {\n            Loader.addUsedClasses(uses);\n        }\n    });\n\n    Manager.onCreated(Loader.historyPush);\n};\n\n// simple mechanism for automated means of injecting large amounts of dependency info\n// at the appropriate time in the load cycle\nif (Ext._classPathMetadata) {\n    Ext.Loader.addClassPathMappings(Ext._classPathMetadata);\n    Ext._classPathMetadata = null;\n}\n\n// initalize the default path of the framework\n(function() {\n    var scripts = document.getElementsByTagName('script'),\n        currentScript = scripts[scripts.length - 1],\n        src = currentScript.src,\n        path = src.substring(0, src.lastIndexOf('/') + 1),\n        Loader = Ext.Loader;\n\n    if(src.indexOf(\"/platform/core/src/class/\") != -1) {\n        path = path + \"../../../../extjs/\";\n    } else if(src.indexOf(\"/core/src/class/\") != -1) {\n        path = path + \"../../../\";\n    }\n\n    Loader.setConfig({\n        enabled: true,\n        disableCaching: true,\n        paths: {\n            'Ext': path + 'src'\n        }\n    });\n})();\n\n// allows a tools like dynatrace to deterministically detect onReady state by invoking\n// a callback (intended for external consumption)\nExt._endTime = new Date().getTime();\nif (Ext._beforereadyhandler){\n    Ext._beforereadyhandler();\n}\n\n//@tag foundation,core\n//@require ../class/Loader.js\n\n/**\n * @author Brian Moeskau <brian@sencha.com>\n * @docauthor Brian Moeskau <brian@sencha.com>\n *\n * A wrapper class for the native JavaScript Error object that adds a few useful capabilities for handling\n * errors in an Ext application. When you use Ext.Error to {@link #raise} an error from within any class that\n * uses the Ext 4 class system, the Error class can automatically add the source class and method from which\n * the error was raised. It also includes logic to automatically log the eroor to the console, if available,\n * with additional metadata about the error. In all cases, the error will always be thrown at the end so that\n * execution will halt.\n *\n * Ext.Error also offers a global error {@link #handle handling} method that can be overridden in order to\n * handle application-wide errors in a single spot. You can optionally {@link #ignore} errors altogether,\n * although in a real application it's usually a better idea to override the handling function and perform\n * logging or some other method of reporting the errors in a way that is meaningful to the application.\n *\n * At its simplest you can simply raise an error as a simple string from within any code:\n *\n * Example usage:\n *\n *     Ext.Error.raise('Something bad happened!');\n *\n * If raised from plain JavaScript code, the error will be logged to the console (if available) and the message\n * displayed. In most cases however you'll be raising errors from within a class, and it may often be useful to add\n * additional metadata about the error being raised.  The {@link #raise} method can also take a config object.\n * In this form the `msg` attribute becomes the error description, and any other data added to the config gets\n * added to the error object and, if the console is available, logged to the console for inspection.\n *\n * Example usage:\n *\n *     Ext.define('Ext.Foo', {\n *         doSomething: function(option){\n *             if (someCondition === false) {\n *                 Ext.Error.raise({\n *                     msg: 'You cannot do that!',\n *                     option: option,   // whatever was passed into the method\n *                     'error code': 100 // other arbitrary info\n *                 });\n *             }\n *         }\n *     });\n *\n * If a console is available (that supports the `console.dir` function) you'll see console output like:\n *\n *     An error was raised with the following data:\n *     option:         Object { foo: \"bar\"}\n *         foo:        \"bar\"\n *     error code:     100\n *     msg:            \"You cannot do that!\"\n *     sourceClass:   \"Ext.Foo\"\n *     sourceMethod:  \"doSomething\"\n *\n *     uncaught exception: You cannot do that!\n *\n * As you can see, the error will report exactly where it was raised and will include as much information as the\n * raising code can usefully provide.\n *\n * If you want to handle all application errors globally you can simply override the static {@link #handle} method\n * and provide whatever handling logic you need. If the method returns true then the error is considered handled\n * and will not be thrown to the browser. If anything but true is returned then the error will be thrown normally.\n *\n * Example usage:\n *\n *     Ext.Error.handle = function(err) {\n *         if (err.someProperty == 'NotReallyAnError') {\n *             // maybe log something to the application here if applicable\n *             return true;\n *         }\n *         // any non-true return value (including none) will cause the error to be thrown\n *     }\n *\n */\nExt.Error = Ext.extend(Error, {\n    statics: {\n        /**\n         * @property {Boolean} ignore\n         * Static flag that can be used to globally disable error reporting to the browser if set to true\n         * (defaults to false). Note that if you ignore Ext errors it's likely that some other code may fail\n         * and throw a native JavaScript error thereafter, so use with caution. In most cases it will probably\n         * be preferable to supply a custom error {@link #handle handling} function instead.\n         *\n         * Example usage:\n         *\n         *     Ext.Error.ignore = true;\n         *\n         * @static\n         */\n        ignore: false,\n\n        /**\n         * @property {Boolean} notify\n         * Static flag that can be used to globally control error notification to the user. Unlike\n         * Ex.Error.ignore, this does not effect exceptions. They are still thrown. This value can be\n         * set to false to disable the alert notification (default is true for IE6 and IE7).\n         *\n         * Only the first error will generate an alert. Internally this flag is set to false when the\n         * first error occurs prior to displaying the alert.\n         *\n         * This flag is not used in a release build.\n         *\n         * Example usage:\n         *\n         *     Ext.Error.notify = false;\n         *\n         * @static\n         */\n        //notify: Ext.isIE6 || Ext.isIE7,\n\n        /**\n         * Raise an error that can include additional data and supports automatic console logging if available.\n         * You can pass a string error message or an object with the `msg` attribute which will be used as the\n         * error message. The object can contain any other name-value attributes (or objects) to be logged\n         * along with the error.\n         *\n         * Note that after displaying the error message a JavaScript error will ultimately be thrown so that\n         * execution will halt.\n         *\n         * Example usage:\n         *\n         *     Ext.Error.raise('A simple string error message');\n         *\n         *     // or...\n         *\n         *     Ext.define('Ext.Foo', {\n         *         doSomething: function(option){\n         *             if (someCondition === false) {\n         *                 Ext.Error.raise({\n         *                     msg: 'You cannot do that!',\n         *                     option: option,   // whatever was passed into the method\n         *                     'error code': 100 // other arbitrary info\n         *                 });\n         *             }\n         *         }\n         *     });\n         *\n         * @param {String/Object} err The error message string, or an object containing the attribute \"msg\" that will be\n         * used as the error message. Any other data included in the object will also be logged to the browser console,\n         * if available.\n         * @static\n         */\n        raise: function(err){\n            err = err || {};\n            if (Ext.isString(err)) {\n                err = { msg: err };\n            }\n\n            var method = this.raise.caller,\n                msg;\n\n            if (method) {\n                if (method.$name) {\n                    err.sourceMethod = method.$name;\n                }\n                if (method.$owner) {\n                    err.sourceClass = method.$owner.$className;\n                }\n            }\n\n            if (Ext.Error.handle(err) !== true) {\n                msg = Ext.Error.prototype.toString.call(err);\n\n                Ext.log({\n                    msg: msg,\n                    level: 'error',\n                    dump: err,\n                    stack: true\n                });\n\n                throw new Ext.Error(err);\n            }\n        },\n\n        /**\n         * Globally handle any Ext errors that may be raised, optionally providing custom logic to\n         * handle different errors individually. Return true from the function to bypass throwing the\n         * error to the browser, otherwise the error will be thrown and execution will halt.\n         *\n         * Example usage:\n         *\n         *     Ext.Error.handle = function(err) {\n         *         if (err.someProperty == 'NotReallyAnError') {\n         *             // maybe log something to the application here if applicable\n         *             return true;\n         *         }\n         *         // any non-true return value (including none) will cause the error to be thrown\n         *     }\n         *\n         * @param {Ext.Error} err The Ext.Error object being raised. It will contain any attributes that were originally\n         * raised with it, plus properties about the method and class from which the error originated (if raised from a\n         * class that uses the Ext 4 class system).\n         * @static\n         */\n        handle: function(){\n            return Ext.Error.ignore;\n        }\n    },\n\n    // This is the standard property that is the name of the constructor.\n    name: 'Ext.Error',\n\n    /**\n     * Creates new Error object.\n     * @param {String/Object} config The error message string, or an object containing the\n     * attribute \"msg\" that will be used as the error message. Any other data included in\n     * the object will be applied to the error instance and logged to the browser console, if available.\n     */\n    constructor: function(config){\n        if (Ext.isString(config)) {\n            config = { msg: config };\n        }\n\n        var me = this;\n\n        Ext.apply(me, config);\n\n        me.message = me.message || me.msg; // 'message' is standard ('msg' is non-standard)\n        // note: the above does not work in old WebKit (me.message is readonly) (Safari 4)\n    },\n\n    /**\n     * Provides a custom string representation of the error object. This is an override of the base JavaScript\n     * `Object.toString` method, which is useful so that when logged to the browser console, an error object will\n     * be displayed with a useful message instead of `[object Object]`, the default `toString` result.\n     *\n     * The default implementation will include the error message along with the raising class and method, if available,\n     * but this can be overridden with a custom implementation either at the prototype level (for all errors) or on\n     * a particular error instance, if you want to provide a custom description that will show up in the console.\n     * @return {String} The error message. If raised from within the Ext 4 class system, the error message will also\n     * include the raising class and method names, if available.\n     */\n    toString: function(){\n        var me = this,\n            className = me.sourceClass ? me.sourceClass : '',\n            methodName = me.sourceMethod ? '.' + me.sourceMethod + '(): ' : '',\n            msg = me.msg || '(No description provided)';\n\n        return className + methodName + msg;\n    }\n});\n\n/*\n * Create a function that will throw an error if called (in debug mode) with a message that\n * indicates the method has been removed.\n * @param {String} suggestion Optional text to include in the message (a workaround perhaps).\n * @return {Function} The generated function.\n * @private\n */\nExt.deprecated = function (suggestion) {\n    if (!suggestion) {\n        suggestion = '';\n    }\n\n    function fail () {\n        Ext.Error.raise('The method \"' + fail.$owner.$className + '.' + fail.$name + \n                '\" has been removed. ' + suggestion);\n    }\n\n    return fail;\n    return Ext.emptyFn;\n};\n\n/*\n * This mechanism is used to notify the user of the first error encountered on the page. This\n * was previously internal to Ext.Error.raise and is a desirable feature since errors often\n * slip silently under the radar. It cannot live in Ext.Error.raise since there are times\n * where exceptions are handled in a try/catch.\n */\n(function () {\n    var timer, errors = 0,\n        win = Ext.global,\n        msg;\n\n    if (typeof window === 'undefined') {\n        return; // build system or some such environment...\n    }\n\n    // This method is called to notify the user of the current error status.\n    function notify () {\n        var counters = Ext.log.counters,\n            supports = Ext.supports,\n            hasOnError = supports && supports.WindowOnError; // TODO - timing\n\n        // Put log counters to the status bar (for most browsers):\n        if (counters && (counters.error + counters.warn + counters.info + counters.log)) {\n            msg = [ 'Logged Errors:',counters.error, 'Warnings:',counters.warn,\n                        'Info:',counters.info, 'Log:',counters.log].join(' ');\n            if (errors) {\n                msg = '*** Errors: ' + errors + ' - ' + msg;\n            } else if (counters.error) {\n                msg = '*** ' + msg;\n            }\n            win.status = msg;\n        }\n\n        // Display an alert on the first error:\n        if (!Ext.isDefined(Ext.Error.notify)) {\n            Ext.Error.notify = Ext.isIE6 || Ext.isIE7; // TODO - timing\n        }\n        if (Ext.Error.notify && (hasOnError ? errors : (counters && counters.error))) {\n            Ext.Error.notify = false;\n\n            if (timer) {\n                win.clearInterval(timer); // ticks can queue up so stop...\n                timer = null;\n            }\n\n            alert('Unhandled error on page: See console or log');\n            poll();\n        }\n    }\n\n    // Sets up polling loop. This is the only way to know about errors in some browsers\n    // (Opera/Safari) and is the only way to update the status bar for warnings and other\n    // non-errors.\n    function poll () {\n        timer = win.setInterval(notify, 1000);\n    }\n\n    // window.onerror sounds ideal but it prevents the built-in error dialog from doing\n    // its (better) thing.\n    poll();\n}());\n\n//@tag extras,core\n//@require ../lang/Error.js\n\n/**\n * Modified version of [Douglas Crockford's JSON.js][dc] that doesn't\n * mess with the Object prototype.\n *\n * [dc]: http://www.json.org/js.html\n *\n * @singleton\n */\nExt.JSON = (new(function() {\n    var me = this,\n    encodingFunction,\n    decodingFunction,\n    useNative = null,\n    useHasOwn = !! {}.hasOwnProperty,\n    isNative = function() {\n        if (useNative === null) {\n            useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';\n        }\n        return useNative;\n    },\n    pad = function(n) {\n        return n < 10 ? \"0\" + n : n;\n    },\n    doDecode = function(json) {\n        return eval(\"(\" + json + ')');\n    },\n    doEncode = function(o, newline) {\n        // http://jsperf.com/is-undefined\n        if (o === null || o === undefined) {\n            return \"null\";\n        } else if (Ext.isDate(o)) {\n            return Ext.JSON.encodeDate(o);\n        } else if (Ext.isString(o)) {\n            return Ext.JSON.encodeString(o);\n        } else if (typeof o == \"number\") {\n            //don't use isNumber here, since finite checks happen inside isNumber\n            return isFinite(o) ? String(o) : \"null\";\n        } else if (Ext.isBoolean(o)) {\n            return String(o);\n        }\n        // Allow custom zerialization by adding a toJSON method to any object type.\n        // Date/String have a toJSON in some environments, so check these first.\n        else if (o.toJSON) {\n            return o.toJSON();\n        } else if (Ext.isArray(o)) {\n            return encodeArray(o, newline);\n        } else if (Ext.isObject(o)) {\n            return encodeObject(o, newline);\n        } else if (typeof o === \"function\") {\n            return \"null\";\n        }\n        return 'undefined';\n    },\n    m = {\n        \"\\b\": '\\\\b',\n        \"\\t\": '\\\\t',\n        \"\\n\": '\\\\n',\n        \"\\f\": '\\\\f',\n        \"\\r\": '\\\\r',\n        '\"': '\\\\\"',\n        \"\\\\\": '\\\\\\\\',\n        '\\x0b': '\\\\u000b' //ie doesn't handle \\v\n    },\n    charToReplace = /[\\\\\\\"\\x00-\\x1f\\x7f-\\uffff]/g,\n    encodeString = function(s) {\n        return '\"' + s.replace(charToReplace, function(a) {\n            var c = m[a];\n            return typeof c === 'string' ? c : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n        }) + '\"';\n    },\n\n    encodeArrayPretty = function(o, newline) {\n        var len = o.length,\n            cnewline = newline + '   ',\n            sep = ',' + cnewline,\n            a = [\"[\", cnewline], // Note newline in case there are no members\n            i;\n\n        for (i = 0; i < len; i += 1) {\n            a.push(Ext.JSON.encodeValue(o[i], cnewline), sep);\n        }\n\n        // Overwrite trailing comma (or empty string)\n        a[a.length - 1] = newline + ']';\n\n        return a.join('');\n    },\n\n    encodeObjectPretty = function(o, newline) {\n        var cnewline = newline + '   ',\n            sep = ',' + cnewline,\n            a = [\"{\", cnewline], // Note newline in case there are no members\n            i;\n\n        for (i in o) {\n            if (!useHasOwn || o.hasOwnProperty(i)) {\n                a.push(Ext.JSON.encodeValue(i) + ': ' + Ext.JSON.encodeValue(o[i], cnewline), sep);\n            }\n        }\n\n        // Overwrite trailing comma (or empty string)\n        a[a.length - 1] = newline + '}';\n\n        return a.join('');\n    },\n\n    encodeArray = function(o, newline) {\n        if (newline) {\n            return encodeArrayPretty(o, newline);\n        }\n\n        var a = [\"[\", \"\"], // Note empty string in case there are no serializable members.\n            len = o.length,\n            i;\n        for (i = 0; i < len; i += 1) {\n            a.push(Ext.JSON.encodeValue(o[i]), ',');\n        }\n        // Overwrite trailing comma (or empty string)\n        a[a.length - 1] = ']';\n        return a.join(\"\");\n    },\n\n    encodeObject = function(o, newline) {\n        if (newline) {\n            return encodeObjectPretty(o, newline);\n        }\n\n        var a = [\"{\", \"\"], // Note empty string in case there are no serializable members.\n            i;\n        for (i in o) {\n            if (!useHasOwn || o.hasOwnProperty(i)) {\n                a.push(Ext.JSON.encodeValue(i), \":\", Ext.JSON.encodeValue(o[i]), ',');\n            }\n        }\n        // Overwrite trailing comma (or empty string)\n        a[a.length - 1] = '}';\n        return a.join(\"\");\n    };\n    \n    /**\n     * Encodes a String. This returns the actual string which is inserted into the JSON string as the literal\n     * expression. **The returned value includes enclosing double quotation marks.**\n     *\n     * To override this:\n     *\n     *     Ext.JSON.encodeString = function(s) {\n     *         return 'Foo' + s;\n     *     };\n     *\n     * @param {String} s The String to encode\n     * @return {String} The string literal to use in a JSON string.\n     * @method\n     */\n    me.encodeString = encodeString;\n\n    /**\n     * The function which {@link #encode} uses to encode all javascript values to their JSON representations\n     * when {@link Ext#USE_NATIVE_JSON} is `false`.\n     * \n     * This is made public so that it can be replaced with a custom implementation.\n     *\n     * @param {Object} o Any javascript value to be converted to its JSON representation\n     * @return {String} The JSON representation of the passed value.\n     * @method\n     */\n    me.encodeValue = doEncode;\n\n    /**\n     * Encodes a Date. This returns the actual string which is inserted into the JSON string as the literal\n     * expression. **The returned value includes enclosing double quotation marks.**\n     *\n     * The default return format is `\"yyyy-mm-ddThh:mm:ss\"`.\n     *\n     * To override this:\n     *\n     *     Ext.JSON.encodeDate = function(d) {\n     *         return Ext.Date.format(d, '\"Y-m-d\"');\n     *     };\n     *\n     * @param {Date} d The Date to encode\n     * @return {String} The string literal to use in a JSON string.\n     */\n    me.encodeDate = function(o) {\n        return '\"' + o.getFullYear() + \"-\"\n        + pad(o.getMonth() + 1) + \"-\"\n        + pad(o.getDate()) + \"T\"\n        + pad(o.getHours()) + \":\"\n        + pad(o.getMinutes()) + \":\"\n        + pad(o.getSeconds()) + '\"';\n    };\n\n    /**\n     * Encodes an Object, Array or other value.\n     * \n     * If the environment's native JSON encoding is not being used ({@link Ext#USE_NATIVE_JSON} is not set,\n     * or the environment does not support it), then ExtJS's encoding will be used. This allows the developer\n     * to add a `toJSON` method to their classes which need serializing to return a valid JSON representation\n     * of the object.\n     * \n     * @param {Object} o The variable to encode\n     * @return {String} The JSON string\n     */\n    me.encode = function(o) {\n        if (!encodingFunction) {\n            // setup encoding function on first access\n            encodingFunction = isNative() ? JSON.stringify : me.encodeValue;\n        }\n        return encodingFunction(o);\n    };\n\n    /**\n     * Decodes (parses) a JSON string to an object. If the JSON is invalid, this function throws\n     * a SyntaxError unless the safe option is set.\n     *\n     * @param {String} json The JSON string\n     * @param {Boolean} [safe=false] True to return null, false to throw an exception if the JSON is invalid.\n     * @return {Object} The resulting object\n     */\n    me.decode = function(json, safe) {\n        if (!decodingFunction) {\n            // setup decoding function on first access\n            decodingFunction = isNative() ? JSON.parse : doDecode;\n        }\n        try {\n            return decodingFunction(json);\n        } catch (e) {\n            if (safe === true) {\n                return null;\n            }\n            Ext.Error.raise({\n                sourceClass: \"Ext.JSON\",\n                sourceMethod: \"decode\",\n                msg: \"You're trying to decode an invalid JSON String: \" + json\n            });\n        }\n    };\n})());\n/**\n * Shorthand for {@link Ext.JSON#encode}\n * @member Ext\n * @method encode\n * @inheritdoc Ext.JSON#encode\n */\nExt.encode = Ext.JSON.encode;\n/**\n * Shorthand for {@link Ext.JSON#decode}\n * @member Ext\n * @method decode\n * @inheritdoc Ext.JSON#decode\n */\nExt.decode = Ext.JSON.decode;\n\n//@tag extras,core\n//@require misc/JSON.js\n\n/**\n * @class Ext\n *\n * The Ext namespace (global object) encapsulates all classes, singletons, and\n * utility methods provided by Sencha's libraries.\n *\n * Most user interface Components are at a lower level of nesting in the namespace,\n * but many common utility functions are provided as direct properties of the Ext namespace.\n *\n * Also many frequently used methods from other classes are provided as shortcuts\n * within the Ext namespace. For example {@link Ext#getCmp Ext.getCmp} aliases\n * {@link Ext.ComponentManager#get Ext.ComponentManager.get}.\n *\n * Many applications are initiated with {@link Ext#onReady Ext.onReady} which is\n * called once the DOM is ready. This ensures all scripts have been loaded,\n * preventing dependency issues. For example:\n *\n *     Ext.onReady(function(){\n *         new Ext.Component({\n *             renderTo: document.body,\n *             html: 'DOM ready!'\n *         });\n *     });\n *\n * For more information about how to use the Ext classes, see:\n *\n * - <a href=\"http://www.sencha.com/learn/\">The Learning Center</a>\n * - <a href=\"http://www.sencha.com/learn/Ext_FAQ\">The FAQ</a>\n * - <a href=\"http://www.sencha.com/forum/\">The forums</a>\n *\n * @singleton\n */\nExt.apply(Ext, {\n    userAgent: navigator.userAgent.toLowerCase(),\n    cache: {},\n    idSeed: 1000,\n    windowId: 'ext-window',\n    documentId: 'ext-document',\n\n    /**\n     * True when the document is fully initialized and ready for action\n     */\n    isReady: false,\n\n    /**\n     * True to automatically uncache orphaned Ext.Elements periodically\n     */\n    enableGarbageCollector: true,\n\n    /**\n     * True to automatically purge event listeners during garbageCollection.\n     */\n    enableListenerCollection: true,\n\n    addCacheEntry: function(id, el, dom) {\n        dom = dom || el.dom;\n\n        if (!dom) {\n            // Without the DOM node we can't GC the entry\n            Ext.Error.raise('Cannot add an entry to the element cache without the DOM node');\n        }\n\n        var key = id || (el && el.id) || dom.id,\n            entry = Ext.cache[key] || (Ext.cache[key] = {\n                data: {},\n                events: {},\n\n                dom: dom,\n\n                // Skip garbage collection for special elements (window, document, iframes)\n                skipGarbageCollection: !!(dom.getElementById || dom.navigator)\n            });\n\n        if (el) {\n            el.$cache = entry;\n            // Inject the back link from the cache in case the cache entry\n            // had already been created by Ext.fly. Ext.fly creates a cache entry with no el link.\n            entry.el = el;\n        }\n\n        return entry;\n    },\n    \n    updateCacheEntry: function(cacheItem, dom){\n        cacheItem.dom = dom;\n        if (cacheItem.el) {\n            cacheItem.el.dom = dom;\n        }\n        return cacheItem;\n    },\n\n    /**\n     * Generates unique ids. If the element already has an id, it is unchanged\n     * @param {HTMLElement/Ext.Element} [el] The element to generate an id for\n     * @param {String} prefix (optional) Id prefix (defaults \"ext-gen\")\n     * @return {String} The generated Id.\n     */\n    id: function(el, prefix) {\n        var me = this,\n            sandboxPrefix = '';\n        el = Ext.getDom(el, true) || {};\n        if (el === document) {\n            el.id = me.documentId;\n        }\n        else if (el === window) {\n            el.id = me.windowId;\n        }\n        if (!el.id) {\n            if (me.isSandboxed) {\n                sandboxPrefix = Ext.sandboxName.toLowerCase() + '-';\n            }\n            el.id = sandboxPrefix + (prefix || \"ext-gen\") + (++Ext.idSeed);\n        }\n        return el.id;\n    },\n\n    escapeId: (function(){\n        var validIdRe = /^[a-zA-Z_][a-zA-Z0-9_\\-]*$/i,\n            escapeRx = /([\\W]{1})/g,\n            leadingNumRx = /^(\\d)/g,\n            escapeFn = function(match, capture){\n                return \"\\\\\" + capture;\n            },\n            numEscapeFn = function(match, capture){\n                return '\\\\00' + capture.charCodeAt(0).toString(16) + ' ';\n            };\n\n        return function(id) {\n            return validIdRe.test(id)\n                ? id\n                // replace the number portion last to keep the trailing ' '\n                // from being escaped\n                : id.replace(escapeRx, escapeFn)\n                    .replace(leadingNumRx, numEscapeFn);\n        };\n    }()),\n\n    /**\n     * Returns the current document body as an {@link Ext.Element}.\n     * @return Ext.Element The document body\n     */\n    getBody: (function() {\n        var body;\n        return function() {\n            return body || (body = Ext.get(document.body));\n        };\n    }()),\n\n    /**\n     * Returns the current document head as an {@link Ext.Element}.\n     * @return Ext.Element The document head\n     * @method\n     */\n    getHead: (function() {\n        var head;\n        return function() {\n            return head || (head = Ext.get(document.getElementsByTagName(\"head\")[0]));\n        };\n    }()),\n\n    /**\n     * Returns the current HTML document object as an {@link Ext.Element}.\n     * @return Ext.Element The document\n     */\n    getDoc: (function() {\n        var doc;\n        return function() {\n            return doc || (doc = Ext.get(document));\n        };\n    }()),\n\n    /**\n     * This is shorthand reference to {@link Ext.ComponentManager#get}.\n     * Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#id id}\n     *\n     * @param {String} id The component {@link Ext.Component#id id}\n     * @return Ext.Component The Component, `undefined` if not found, or `null` if a\n     * Class was found.\n    */\n    getCmp: function(id) {\n        return Ext.ComponentManager.get(id);\n    },\n\n    /**\n     * Returns the current orientation of the mobile device\n     * @return {String} Either 'portrait' or 'landscape'\n     */\n    getOrientation: function() {\n        return window.innerHeight > window.innerWidth ? 'portrait' : 'landscape';\n    },\n\n    /**\n     * Attempts to destroy any objects passed to it by removing all event listeners, removing them from the\n     * DOM (if applicable) and calling their destroy functions (if available).  This method is primarily\n     * intended for arguments of type {@link Ext.Element} and {@link Ext.Component}, but any subclass of\n     * {@link Ext.util.Observable} can be passed in.  Any number of elements and/or components can be\n     * passed into this function in a single call as separate arguments.\n     *\n     * @param {Ext.Element/Ext.Component/Ext.Element[]/Ext.Component[]...} args\n     * An {@link Ext.Element}, {@link Ext.Component}, or an Array of either of these to destroy\n     */\n    destroy: function() {\n        var ln = arguments.length,\n        i, arg;\n\n        for (i = 0; i < ln; i++) {\n            arg = arguments[i];\n            if (arg) {\n                if (Ext.isArray(arg)) {\n                    this.destroy.apply(this, arg);\n                }\n                else if (Ext.isFunction(arg.destroy)) {\n                    arg.destroy();\n                }\n                else if (arg.dom) {\n                    arg.remove();\n                }\n            }\n        }\n    },\n\n    /**\n     * Execute a callback function in a particular scope. If no function is passed the call is ignored.\n     *\n     * For example, these lines are equivalent:\n     *\n     *     Ext.callback(myFunc, this, [arg1, arg2]);\n     *     Ext.isFunction(myFunc) && myFunc.apply(this, [arg1, arg2]);\n     *\n     * @param {Function} callback The callback to execute\n     * @param {Object} [scope] The scope to execute in\n     * @param {Array} [args] The arguments to pass to the function\n     * @param {Number} [delay] Pass a number to delay the call by a number of milliseconds.\n     */\n    callback: function(callback, scope, args, delay){\n        if(Ext.isFunction(callback)){\n            args = args || [];\n            scope = scope || window;\n            if (delay) {\n                Ext.defer(callback, delay, scope, args);\n            } else {\n                callback.apply(scope, args);\n            }\n        }\n    },\n\n    /**\n     * Alias for {@link Ext.String#htmlEncode}.\n     * @inheritdoc Ext.String#htmlEncode\n     * @ignore\n     */\n    htmlEncode : function(value) {\n        return Ext.String.htmlEncode(value);\n    },\n\n    /**\n     * Alias for {@link Ext.String#htmlDecode}.\n     * @inheritdoc Ext.String#htmlDecode\n     * @ignore\n     */\n    htmlDecode : function(value) {\n         return Ext.String.htmlDecode(value);\n    },\n\n    /**\n     * Alias for {@link Ext.String#urlAppend}.\n     * @inheritdoc Ext.String#urlAppend\n     * @ignore\n     */\n    urlAppend : function(url, s) {\n        return Ext.String.urlAppend(url, s);\n    }\n});\n\n\nExt.ns = Ext.namespace;\n\n// for old browsers\nwindow.undefined = window.undefined;\n\n/**\n * @class Ext\n */\n(function(){\n/*\nFF 3.6      - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17\nFF 4.0.1    - Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1\nFF 5.0      - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0\n\nIE6         - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;)\nIE7         - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1;)\nIE8         - Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)\nIE9         - Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)\n\nChrome 11   - Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24\n\nSafari 5    - Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1\n\nOpera 11.11 - Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11\n*/\n    var check = function(regex){\n            return regex.test(Ext.userAgent);\n        },\n        isStrict = document.compatMode == \"CSS1Compat\",\n        version = function (is, regex) {\n            var m;\n            return (is && (m = regex.exec(Ext.userAgent))) ? parseFloat(m[1]) : 0;\n        },\n        docMode = document.documentMode,\n        isOpera = check(/opera/),\n        isOpera10_5 = isOpera && check(/version\\/10\\.5/),\n        isChrome = check(/\\bchrome\\b/),\n        isWebKit = check(/webkit/),\n        isSafari = !isChrome && check(/safari/),\n        isSafari2 = isSafari && check(/applewebkit\\/4/), // unique to Safari 2\n        isSafari3 = isSafari && check(/version\\/3/),\n        isSafari4 = isSafari && check(/version\\/4/),\n        isSafari5_0 = isSafari && check(/version\\/5\\.0/),\n        isSafari5 = isSafari && check(/version\\/5/),\n        isIE = !isOpera && check(/msie/),\n        isIE7 = isIE && ((check(/msie 7/) && docMode != 8 && docMode != 9) || docMode == 7),\n        isIE8 = isIE && ((check(/msie 8/) && docMode != 7 && docMode != 9) || docMode == 8),\n        isIE9 = isIE && ((check(/msie 9/) && docMode != 7 && docMode != 8) || docMode == 9),\n        isIE6 = isIE && check(/msie 6/),\n        isGecko = !isWebKit && check(/gecko/),\n        isGecko3 = isGecko && check(/rv:1\\.9/),\n        isGecko4 = isGecko && check(/rv:2\\.0/),\n        isGecko5 = isGecko && check(/rv:5\\./),\n        isGecko10 = isGecko && check(/rv:10\\./),\n        isFF3_0 = isGecko3 && check(/rv:1\\.9\\.0/),\n        isFF3_5 = isGecko3 && check(/rv:1\\.9\\.1/),\n        isFF3_6 = isGecko3 && check(/rv:1\\.9\\.2/),\n        isWindows = check(/windows|win32/),\n        isMac = check(/macintosh|mac os x/),\n        isLinux = check(/linux/),\n        scrollbarSize = null,\n        chromeVersion = version(true, /\\bchrome\\/(\\d+\\.\\d+)/),\n        firefoxVersion = version(true, /\\bfirefox\\/(\\d+\\.\\d+)/),\n        ieVersion = version(isIE, /msie (\\d+\\.\\d+)/),\n        operaVersion = version(isOpera, /version\\/(\\d+\\.\\d+)/),\n        safariVersion = version(isSafari, /version\\/(\\d+\\.\\d+)/),\n        webKitVersion = version(isWebKit, /webkit\\/(\\d+\\.\\d+)/),\n        isSecure = /^https/i.test(window.location.protocol),\n        nullLog;\n\n    // remove css image flicker\n    try {\n        document.execCommand(\"BackgroundImageCache\", false, true);\n    } catch(e) {}\n\n\n    var primitiveRe = /string|number|boolean/;\n    function dumpObject (object) {\n        var member, type, value, name,\n            members = [];\n\n        // Cannot use Ext.encode since it can recurse endlessly (if we're lucky)\n        // ...and the data could be prettier!\n        for (name in object) {\n            if (object.hasOwnProperty(name)) {\n                value = object[name];\n\n                type = typeof value;\n                if (type == \"function\") {\n                    continue;\n                }\n\n                if (type == 'undefined') {\n                    member = type;\n                } else if (value === null || primitiveRe.test(type) || Ext.isDate(value)) {\n                    member = Ext.encode(value);\n                } else if (Ext.isArray(value)) {\n                    member = '[ ]';\n                } else if (Ext.isObject(value)) {\n                    member = '{ }';\n                } else {\n                    member = type;\n                }\n                members.push(Ext.encode(name) + ': ' + member);\n            }\n        }\n\n        if (members.length) {\n            return ' \\nData: {\\n  ' + members.join(',\\n  ') + '\\n}';\n        }\n        return '';\n    }\n\n    function log (message) {\n        var options, dump,\n            con = Ext.global.console,\n            level = 'log',\n            indent = log.indent || 0,\n            stack,\n            out,\n            max;\n\n        log.indent = indent;\n\n        if (typeof message != 'string') {\n            options = message;\n            message = options.msg || '';\n            level = options.level || level;\n            dump = options.dump;\n            stack = options.stack;\n\n            if (options.indent) {\n                ++log.indent;\n            } else if (options.outdent) {\n                log.indent = indent = Math.max(indent - 1, 0);\n            }\n\n            if (dump && !(con && con.dir)) {\n                message += dumpObject(dump);\n                dump = null;\n            }\n        }\n\n        if (arguments.length > 1) {\n            message += Array.prototype.slice.call(arguments, 1).join('');\n        }\n\n        message = indent ? Ext.String.repeat(' ', log.indentSize * indent) + message : message;\n        // w/o console, all messages are equal, so munge the level into the message:\n        if (level != 'log') {\n            message = '[' + level.charAt(0).toUpperCase() + '] ' + message;\n        }\n\n        // Not obvious, but 'console' comes and goes when Firebug is turned on/off, so\n        // an early test may fail either direction if Firebug is toggled.\n        //\n        if (con) { // if (Firebug-like console)\n            if (con[level]) {\n                con[level](message);\n            } else {\n                con.log(message);\n            }\n\n            if (dump) {\n                con.dir(dump);\n            }\n\n            if (stack && con.trace) {\n                // Firebug's console.error() includes a trace already...\n                if (!con.firebug || level != 'error') {\n                    con.trace();\n                }\n            }\n        } else {\n            if (Ext.isOpera) {\n                opera.postError(message);\n            } else {\n                out = log.out;\n                max = log.max;\n\n                if (out.length >= max) {\n                    // this formula allows out.max to change (via debugger), where the\n                    // more obvious \"max/4\" would not quite be the same\n                    Ext.Array.erase(out, 0, out.length - 3 * Math.floor(max / 4)); // keep newest 75%\n                }\n\n                out.push(message);\n            }\n        }\n\n        // Mostly informational, but the Ext.Error notifier uses them:\n        ++log.count;\n        ++log.counters[level];\n    }\n\n    function logx (level, args) {\n        if (typeof args[0] == 'string') {\n            args.unshift({});\n        }\n        args[0].level = level;\n        log.apply(this, args);\n    }\n\n    log.error = function () {\n        logx('error', Array.prototype.slice.call(arguments));\n    };\n    log.info = function () {\n        logx('info', Array.prototype.slice.call(arguments));\n    };\n    log.warn = function () {\n        logx('warn', Array.prototype.slice.call(arguments));\n    };\n\n    log.count = 0;\n    log.counters = { error: 0, warn: 0, info: 0, log: 0 };\n    log.indentSize = 2;\n    log.out = [];\n    log.max = 750;\n    log.show = function () {\n        window.open('','extlog').document.write([\n            '<html><head><script type=\"text/javascript\">',\n                'var lastCount = 0;',\n                'function update () {',\n                    'var ext = window.opener.Ext,',\n                        'extlog = ext && ext.log;',\n                    'if (extlog && extlog.out && lastCount != extlog.count) {',\n                        'lastCount = extlog.count;',\n                        'var s = \"<tt>\" + extlog.out.join(\"~~~\").replace(/[&]/g, \"&amp;\").replace(/[<]/g, \"&lt;\").replace(/[ ]/g, \"&#160;\").replace(/\\\\~\\\\~\\\\~/g, \"<br/>\") + \"</tt>\";',\n                        'document.body.innerHTML = s;',\n                    '}',\n                    'setTimeout(update, 1000);',\n                '}',\n                'setTimeout(update, 1000);',\n            '</script></head><body></body></html>'].join(''));\n    };\n\n    nullLog = function () {};\n    nullLog.info = nullLog.warn = nullLog.error = Ext.emptyFn;\n\n    Ext.setVersion('extjs', '4.1.1.1');\n    Ext.apply(Ext, {\n        /**\n         * @property {String} SSL_SECURE_URL\n         * URL to a blank file used by Ext when in secure mode for iframe src and onReady src\n         * to prevent the IE insecure content warning (`'about:blank'`, except for IE\n         * in secure mode, which is `'javascript:\"\"'`).\n         */\n        SSL_SECURE_URL : isSecure && isIE ? 'javascript:\\'\\'' : 'about:blank',\n\n        /**\n         * @property {Boolean} enableFx\n         * True if the {@link Ext.fx.Anim} Class is available.\n         */\n\n        /**\n         * @property {Boolean} scopeResetCSS\n         * True to scope the reset CSS to be just applied to Ext components. Note that this\n         * wraps root containers with an additional element. Also remember that when you turn\n         * on this option, you have to use ext-all-scoped (unless you use the bootstrap.js to\n         * load your javascript, in which case it will be handled for you).\n         */\n        scopeResetCSS : Ext.buildSettings.scopeResetCSS,\n        \n        /**\n         * @property {String} resetCls\n         * The css class used to wrap Ext components when the {@link #scopeResetCSS} option\n         * is used.\n         */\n        resetCls: Ext.buildSettings.baseCSSPrefix + 'reset',\n\n        /**\n         * @property {Boolean} enableNestedListenerRemoval\n         * **Experimental.** True to cascade listener removal to child elements when an element\n         * is removed. Currently not optimized for performance.\n         */\n        enableNestedListenerRemoval : false,\n\n        /**\n         * @property {Boolean} USE_NATIVE_JSON\n         * Indicates whether to use native browser parsing for JSON methods.\n         * This option is ignored if the browser does not support native JSON methods.\n         *\n         * **Note:** Native JSON methods will not work with objects that have functions.\n         * Also, property names must be quoted, otherwise the data will not parse.\n         */\n        USE_NATIVE_JSON : false,\n\n        /**\n         * Returns the dom node for the passed String (id), dom node, or Ext.Element.\n         * Optional 'strict' flag is needed for IE since it can return 'name' and\n         * 'id' elements by using getElementById.\n         *\n         * Here are some examples:\n         *\n         *     // gets dom node based on id\n         *     var elDom = Ext.getDom('elId');\n         *     // gets dom node based on the dom node\n         *     var elDom1 = Ext.getDom(elDom);\n         *\n         *     // If we don&#39;t know if we are working with an\n         *     // Ext.Element or a dom node use Ext.getDom\n         *     function(el){\n         *         var dom = Ext.getDom(el);\n         *         // do something with the dom node\n         *     }\n         *\n         * **Note:** the dom node to be found actually needs to exist (be rendered, etc)\n         * when this method is called to be successful.\n         *\n         * @param {String/HTMLElement/Ext.Element} el\n         * @return HTMLElement\n         */\n        getDom : function(el, strict) {\n            if (!el || !document) {\n                return null;\n            }\n            if (el.dom) {\n                return el.dom;\n            } else {\n                if (typeof el == 'string') {\n                    var e = Ext.getElementById(el);\n                    // IE returns elements with the 'name' and 'id' attribute.\n                    // we do a strict check to return the element with only the id attribute\n                    if (e && isIE && strict) {\n                        if (el == e.getAttribute('id')) {\n                            return e;\n                        } else {\n                            return null;\n                        }\n                    }\n                    return e;\n                } else {\n                    return el;\n                }\n            }\n        },\n\n        /**\n         * Removes a DOM node from the document.\n         *\n         * Removes this element from the document, removes all DOM event listeners, and\n         * deletes the cache reference. All DOM event listeners are removed from this element.\n         * If {@link Ext#enableNestedListenerRemoval Ext.enableNestedListenerRemoval} is\n         * `true`, then DOM event listeners are also removed from all child nodes.\n         * The body node will be ignored if passed in.\n         *\n         * @param {HTMLElement} node The node to remove\n         * @method\n         */\n        removeNode : isIE6 || isIE7 || isIE8\n            ? (function() {\n                var d;\n                return function(n){\n                    if(n && n.tagName.toUpperCase() != 'BODY'){\n                        (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n) : Ext.EventManager.removeAll(n);\n\n                        var cache = Ext.cache,\n                            id = n.id;\n\n                        if (cache[id]) {\n                            delete cache[id].dom;\n                            delete cache[id];\n                        }\n\n                        if (isIE8 && n.parentNode) {\n                            n.parentNode.removeChild(n);\n                        }\n                        d = d || document.createElement('div');\n                        d.appendChild(n);\n                        d.innerHTML = '';\n                    }\n                };\n            }())\n            : function(n) {\n                if (n && n.parentNode && n.tagName.toUpperCase() != 'BODY') {\n                    (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n) : Ext.EventManager.removeAll(n);\n\n                    var cache = Ext.cache,\n                        id = n.id;\n\n                    if (cache[id]) {\n                        delete cache[id].dom;\n                        delete cache[id];\n                    }\n\n                    n.parentNode.removeChild(n);\n                }\n            },\n\n        isStrict: isStrict,\n\n        isIEQuirks: isIE && !isStrict,\n\n        /**\n         * True if the detected browser is Opera.\n         * @type Boolean\n         */\n        isOpera : isOpera,\n\n        /**\n         * True if the detected browser is Opera 10.5x.\n         * @type Boolean\n         */\n        isOpera10_5 : isOpera10_5,\n\n        /**\n         * True if the detected browser uses WebKit.\n         * @type Boolean\n         */\n        isWebKit : isWebKit,\n\n        /**\n         * True if the detected browser is Chrome.\n         * @type Boolean\n         */\n        isChrome : isChrome,\n\n        /**\n         * True if the detected browser is Safari.\n         * @type Boolean\n         */\n        isSafari : isSafari,\n\n        /**\n         * True if the detected browser is Safari 3.x.\n         * @type Boolean\n         */\n        isSafari3 : isSafari3,\n\n        /**\n         * True if the detected browser is Safari 4.x.\n         * @type Boolean\n         */\n        isSafari4 : isSafari4,\n\n        /**\n         * True if the detected browser is Safari 5.x.\n         * @type Boolean\n         */\n        isSafari5 : isSafari5,\n\n        /**\n         * True if the detected browser is Safari 5.0.x.\n         * @type Boolean\n         */\n        isSafari5_0 : isSafari5_0,\n\n\n        /**\n         * True if the detected browser is Safari 2.x.\n         * @type Boolean\n         */\n        isSafari2 : isSafari2,\n\n        /**\n         * True if the detected browser is Internet Explorer.\n         * @type Boolean\n         */\n        isIE : isIE,\n\n        /**\n         * True if the detected browser is Internet Explorer 6.x.\n         * @type Boolean\n         */\n        isIE6 : isIE6,\n\n        /**\n         * True if the detected browser is Internet Explorer 7.x.\n         * @type Boolean\n         */\n        isIE7 : isIE7,\n\n        /**\n         * True if the detected browser is Internet Explorer 8.x.\n         * @type Boolean\n         */\n        isIE8 : isIE8,\n\n        /**\n         * True if the detected browser is Internet Explorer 9.x.\n         * @type Boolean\n         */\n        isIE9 : isIE9,\n\n        /**\n         * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).\n         * @type Boolean\n         */\n        isGecko : isGecko,\n\n        /**\n         * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).\n         * @type Boolean\n         */\n        isGecko3 : isGecko3,\n\n        /**\n         * True if the detected browser uses a Gecko 2.0+ layout engine (e.g. Firefox 4.x).\n         * @type Boolean\n         */\n        isGecko4 : isGecko4,\n\n        /**\n         * True if the detected browser uses a Gecko 5.0+ layout engine (e.g. Firefox 5.x).\n         * @type Boolean\n         */\n        isGecko5 : isGecko5,\n\n        /**\n         * True if the detected browser uses a Gecko 5.0+ layout engine (e.g. Firefox 5.x).\n         * @type Boolean\n         */\n        isGecko10 : isGecko10,\n\n        /**\n         * True if the detected browser uses FireFox 3.0\n         * @type Boolean\n         */\n        isFF3_0 : isFF3_0,\n\n        /**\n         * True if the detected browser uses FireFox 3.5\n         * @type Boolean\n         */\n        isFF3_5 : isFF3_5,\n\n        /**\n         * True if the detected browser uses FireFox 3.6\n         * @type Boolean\n         */\n        isFF3_6 : isFF3_6,\n\n        /**\n         * True if the detected browser uses FireFox 4\n         * @type Boolean\n         */\n        isFF4 : 4 <= firefoxVersion && firefoxVersion < 5,\n\n        /**\n         * True if the detected browser uses FireFox 5\n         * @type Boolean\n         */\n        isFF5 : 5 <= firefoxVersion && firefoxVersion < 6,\n\n        /**\n         * True if the detected browser uses FireFox 10\n         * @type Boolean\n         */\n        isFF10 : 10 <= firefoxVersion && firefoxVersion < 11,\n\n        /**\n         * True if the detected platform is Linux.\n         * @type Boolean\n         */\n        isLinux : isLinux,\n\n        /**\n         * True if the detected platform is Windows.\n         * @type Boolean\n         */\n        isWindows : isWindows,\n\n        /**\n         * True if the detected platform is Mac OS.\n         * @type Boolean\n         */\n        isMac : isMac,\n\n        /**\n         * The current version of Chrome (0 if the browser is not Chrome).\n         * @type Number\n         */\n        chromeVersion: chromeVersion,\n\n        /**\n         * The current version of Firefox (0 if the browser is not Firefox).\n         * @type Number\n         */\n        firefoxVersion: firefoxVersion,\n\n        /**\n         * The current version of IE (0 if the browser is not IE). This does not account\n         * for the documentMode of the current page, which is factored into {@link #isIE7},\n         * {@link #isIE8} and {@link #isIE9}. Thus this is not always true:\n         *\n         *     Ext.isIE8 == (Ext.ieVersion == 8)\n         *\n         * @type Number\n         */\n        ieVersion: ieVersion,\n\n        /**\n         * The current version of Opera (0 if the browser is not Opera).\n         * @type Number\n         */\n        operaVersion: operaVersion,\n\n        /**\n         * The current version of Safari (0 if the browser is not Safari).\n         * @type Number\n         */\n        safariVersion: safariVersion,\n\n        /**\n         * The current version of WebKit (0 if the browser does not use WebKit).\n         * @type Number\n         */\n        webKitVersion: webKitVersion,\n\n        /**\n         * True if the page is running over SSL\n         * @type Boolean\n         */\n        isSecure: isSecure,\n        \n        /**\n         * URL to a 1x1 transparent gif image used by Ext to create inline icons with\n         * CSS background images. In older versions of IE, this defaults to\n         * \"http://sencha.com/s.gif\" and you should change this to a URL on your server.\n         * For other browsers it uses an inline data URL.\n         * @type String\n         */\n        BLANK_IMAGE_URL : (isIE6 || isIE7) ? '/' + '/www.sencha.com/s.gif' : 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',\n\n        /**\n         * Utility method for returning a default value if the passed value is empty.\n         *\n         * The value is deemed to be empty if it is:\n         *\n         * - null\n         * - undefined\n         * - an empty array\n         * - a zero length string (Unless the `allowBlank` parameter is `true`)\n         *\n         * @param {Object} value The value to test\n         * @param {Object} defaultValue The value to return if the original value is empty\n         * @param {Boolean} [allowBlank=false] true to allow zero length strings to qualify as non-empty.\n         * @return {Object} value, if non-empty, else defaultValue\n         * @deprecated 4.0.0 Use {@link Ext#valueFrom} instead\n         */\n        value : function(v, defaultValue, allowBlank){\n            return Ext.isEmpty(v, allowBlank) ? defaultValue : v;\n        },\n\n        /**\n         * Escapes the passed string for use in a regular expression.\n         * @param {String} str\n         * @return {String}\n         * @deprecated 4.0.0 Use {@link Ext.String#escapeRegex} instead\n         */\n        escapeRe : function(s) {\n            return s.replace(/([-.*+?\\^${}()|\\[\\]\\/\\\\])/g, \"\\\\$1\");\n        },\n\n        /**\n         * Applies event listeners to elements by selectors when the document is ready.\n         * The event name is specified with an `@` suffix.\n         *\n         *     Ext.addBehaviors({\n         *         // add a listener for click on all anchors in element with id foo\n         *         '#foo a@click' : function(e, t){\n         *             // do something\n         *         },\n         *\n         *         // add the same listener to multiple selectors (separated by comma BEFORE the @)\n         *         '#foo a, #bar span.some-class@mouseover' : function(){\n         *             // do something\n         *         }\n         *     });\n         *\n         * @param {Object} obj The list of behaviors to apply\n         */\n        addBehaviors : function(o){\n            if(!Ext.isReady){\n                Ext.onReady(function(){\n                    Ext.addBehaviors(o);\n                });\n            } else {\n                var cache = {}, // simple cache for applying multiple behaviors to same selector does query multiple times\n                    parts,\n                    b,\n                    s;\n                for (b in o) {\n                    if ((parts = b.split('@'))[1]) { // for Object prototype breakers\n                        s = parts[0];\n                        if(!cache[s]){\n                            cache[s] = Ext.select(s);\n                        }\n                        cache[s].on(parts[1], o[b]);\n                    }\n                }\n                cache = null;\n            }\n        },\n\n        /**\n         * Returns the size of the browser scrollbars. This can differ depending on\n         * operating system settings, such as the theme or font size.\n         * @param {Boolean} [force] true to force a recalculation of the value.\n         * @return {Object} An object containing scrollbar sizes.\n         * @return.width {Number} The width of the vertical scrollbar.\n         * @return.height {Number} The height of the horizontal scrollbar.\n         */\n        getScrollbarSize: function (force) {\n            if (!Ext.isReady) {\n                return {};\n            }\n\n            if (force || !scrollbarSize) {\n                var db = document.body,\n                    div = document.createElement('div');\n\n                div.style.width = div.style.height = '100px';\n                div.style.overflow = 'scroll';\n                div.style.position = 'absolute';\n\n                db.appendChild(div); // now we can measure the div...\n\n                // at least in iE9 the div is not 100px - the scrollbar size is removed!\n                scrollbarSize = {\n                    width: div.offsetWidth - div.clientWidth,\n                    height: div.offsetHeight - div.clientHeight\n                };\n\n                db.removeChild(div);\n            }\n\n            return scrollbarSize;\n        },\n\n        /**\n         * Utility method for getting the width of the browser's vertical scrollbar. This\n         * can differ depending on operating system settings, such as the theme or font size.\n         *\n         * This method is deprected in favor of {@link #getScrollbarSize}.\n         *\n         * @param {Boolean} [force] true to force a recalculation of the value.\n         * @return {Number} The width of a vertical scrollbar.\n         * @deprecated\n         */\n        getScrollBarWidth: function(force){\n            var size = Ext.getScrollbarSize(force);\n            return size.width + 2; // legacy fudge factor\n        },\n\n        /**\n         * Copies a set of named properties fom the source object to the destination object.\n         *\n         * Example:\n         *\n         *     ImageComponent = Ext.extend(Ext.Component, {\n         *         initComponent: function() {\n         *             this.autoEl = { tag: 'img' };\n         *             MyComponent.superclass.initComponent.apply(this, arguments);\n         *             this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height');\n         *         }\n         *     });\n         *\n         * Important note: To borrow class prototype methods, use {@link Ext.Base#borrow} instead.\n         *\n         * @param {Object} dest The destination object.\n         * @param {Object} source The source object.\n         * @param {String/String[]} names Either an Array of property names, or a comma-delimited list\n         * of property names to copy.\n         * @param {Boolean} [usePrototypeKeys] Defaults to false. Pass true to copy keys off of the\n         * prototype as well as the instance.\n         * @return {Object} The modified object.\n         */\n        copyTo : function(dest, source, names, usePrototypeKeys){\n            if(typeof names == 'string'){\n                names = names.split(/[,;\\s]/);\n            }\n\n            var n,\n                nLen = names.length,\n                name;\n\n            for(n = 0; n < nLen; n++) {\n                name = names[n];\n\n                if(usePrototypeKeys || source.hasOwnProperty(name)){\n                    dest[name] = source[name];\n                }\n            }\n\n            return dest;\n        },\n\n        /**\n         * Attempts to destroy and then remove a set of named properties of the passed object.\n         * @param {Object} o The object (most likely a Component) who's properties you wish to destroy.\n         * @param {String...} args One or more names of the properties to destroy and remove from the object.\n         */\n        destroyMembers : function(o){\n            for (var i = 1, a = arguments, len = a.length; i < len; i++) {\n                Ext.destroy(o[a[i]]);\n                delete o[a[i]];\n            }\n        },\n\n        /**\n         * Logs a message. If a console is present it will be used. On Opera, the method\n         * \"opera.postError\" is called. In other cases, the message is logged to an array\n         * \"Ext.log.out\". An attached debugger can watch this array and view the log. The\n         * log buffer is limited to a maximum of \"Ext.log.max\" entries (defaults to 250).\n         * The `Ext.log.out` array can also be written to a popup window by entering the\n         * following in the URL bar (a \"bookmarklet\"):\n         *\n         *     javascript:void(Ext.log.show());\n         *\n         * If additional parameters are passed, they are joined and appended to the message.\n         * A technique for tracing entry and exit of a function is this:\n         *\n         *     function foo () {\n         *         Ext.log({ indent: 1 }, '>> foo');\n         *\n         *         // log statements in here or methods called from here will be indented\n         *         // by one step\n         *\n         *         Ext.log({ outdent: 1 }, '<< foo');\n         *     }\n         *\n         * This method does nothing in a release build.\n         *\n         * @param {String/Object} [options] The message to log or an options object with any\n         * of the following properties:\n         *\n         *  - `msg`: The message to log (required).\n         *  - `level`: One of: \"error\", \"warn\", \"info\" or \"log\" (the default is \"log\").\n         *  - `dump`: An object to dump to the log as part of the message.\n         *  - `stack`: True to include a stack trace in the log.\n         *  - `indent`: Cause subsequent log statements to be indented one step.\n         *  - `outdent`: Cause this and following statements to be one step less indented.\n         *\n         * @param {String...} [message] The message to log (required unless specified in\n         * options object).\n         *\n         * @method\n         */\n        log :\n            log ||\n            nullLog,\n\n        /**\n         * Partitions the set into two sets: a true set and a false set.\n         *\n         * Example 1:\n         *\n         *     Ext.partition([true, false, true, true, false]);\n         *     // returns [[true, true, true], [false, false]]\n         *\n         * Example 2:\n         *\n         *     Ext.partition(\n         *         Ext.query(\"p\"),\n         *         function(val){\n         *             return val.className == \"class1\"\n         *         }\n         *     );\n         *     // true are those paragraph elements with a className of \"class1\",\n         *     // false set are those that do not have that className.\n         *\n         * @param {Array/NodeList} arr The array to partition\n         * @param {Function} truth (optional) a function to determine truth.\n         * If this is omitted the element itself must be able to be evaluated for its truthfulness.\n         * @return {Array} [array of truish values, array of falsy values]\n         * @deprecated 4.0.0 Will be removed in the next major version\n         */\n        partition : function(arr, truth){\n            var ret = [[],[]],\n                a, v,\n                aLen = arr.length;\n\n            for (a = 0; a < aLen; a++) {\n                v = arr[a];\n                ret[ (truth && truth(v, a, arr)) || (!truth && v) ? 0 : 1].push(v);\n            }\n\n            return ret;\n        },\n\n        /**\n         * Invokes a method on each item in an Array.\n         *\n         * Example:\n         *\n         *     Ext.invoke(Ext.query(\"p\"), \"getAttribute\", \"id\");\n         *     // [el1.getAttribute(\"id\"), el2.getAttribute(\"id\"), ..., elN.getAttribute(\"id\")]\n         *\n         * @param {Array/NodeList} arr The Array of items to invoke the method on.\n         * @param {String} methodName The method name to invoke.\n         * @param {Object...} args Arguments to send into the method invocation.\n         * @return {Array} The results of invoking the method on each item in the array.\n         * @deprecated 4.0.0 Will be removed in the next major version\n         */\n        invoke : function(arr, methodName){\n            var ret  = [],\n                args = Array.prototype.slice.call(arguments, 2),\n                a, v,\n                aLen = arr.length;\n\n            for (a = 0; a < aLen; a++) {\n                v = arr[a];\n\n                if (v && typeof v[methodName] == 'function') {\n                    ret.push(v[methodName].apply(v, args));\n                } else {\n                    ret.push(undefined);\n                }\n            }\n\n            return ret;\n        },\n\n        /**\n         * Zips N sets together.\n         *\n         * Example 1:\n         *\n         *     Ext.zip([1,2,3],[4,5,6]); // [[1,4],[2,5],[3,6]]\n         *\n         * Example 2:\n         *\n         *     Ext.zip(\n         *         [ \"+\", \"-\", \"+\"],\n         *         [  12,  10,  22],\n         *         [  43,  15,  96],\n         *         function(a, b, c){\n         *             return \"$\" + a + \"\" + b + \".\" + c\n         *         }\n         *     ); // [\"$+12.43\", \"$-10.15\", \"$+22.96\"]\n         *\n         * @param {Array/NodeList...} arr This argument may be repeated. Array(s)\n         * to contribute values.\n         * @param {Function} zipper (optional) The last item in the argument list.\n         * This will drive how the items are zipped together.\n         * @return {Array} The zipped set.\n         * @deprecated 4.0.0 Will be removed in the next major version\n         */\n        zip : function(){\n            var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),\n                arrs = parts[0],\n                fn = parts[1][0],\n                len = Ext.max(Ext.pluck(arrs, \"length\")),\n                ret = [],\n                i,\n                j,\n                aLen;\n\n            for (i = 0; i < len; i++) {\n                ret[i] = [];\n                if(fn){\n                    ret[i] = fn.apply(fn, Ext.pluck(arrs, i));\n                }else{\n                    for (j = 0, aLen = arrs.length; j < aLen; j++){\n                        ret[i].push( arrs[j][i] );\n                    }\n                }\n            }\n            return ret;\n        },\n\n        /**\n         * Turns an array into a sentence, joined by a specified connector - e.g.:\n         *\n         *     Ext.toSentence(['Adama', 'Tigh', 'Roslin']); //'Adama, Tigh and Roslin'\n         *     Ext.toSentence(['Adama', 'Tigh', 'Roslin'], 'or'); //'Adama, Tigh or Roslin'\n         *\n         * @param {String[]} items The array to create a sentence from\n         * @param {String} connector The string to use to connect the last two words.\n         * Usually 'and' or 'or' - defaults to 'and'.\n         * @return {String} The sentence string\n         * @deprecated 4.0.0 Will be removed in the next major version\n         */\n        toSentence: function(items, connector) {\n            var length = items.length,\n                head,\n                tail;\n\n            if (length <= 1) {\n                return items[0];\n            } else {\n                head = items.slice(0, length - 1);\n                tail = items[length - 1];\n\n                return Ext.util.Format.format(\"{0} {1} {2}\", head.join(\", \"), connector || 'and', tail);\n            }\n        },\n\n        /**\n         * @property {Boolean} useShims\n         * By default, Ext intelligently decides whether floating elements should be shimmed.\n         * If you are using flash, you may want to set this to true.\n         */\n        useShims: isIE6\n    });\n}());\n\n/**\n * Loads Ext.app.Application class and starts it up with given configuration after the page is ready.\n *\n * See Ext.app.Application for details.\n *\n * @param {Object} config\n */\nExt.application = function(config) {\n    Ext.require('Ext.app.Application');\n\n    Ext.onReady(function() {\n        new Ext.app.Application(config);\n    });\n};\n\n//@tag extras,core\n//@require ../Ext-more.js\n//@define Ext.util.Format\n\n/**\n * @class Ext.util.Format\n *  \n * This class is a centralized place for formatting functions. It includes\n * functions to format various different types of data, such as text, dates and numeric values.\n *  \n * ## Localization\n *\n * This class contains several options for localization. These can be set once the library has loaded,\n * all calls to the functions from that point will use the locale settings that were specified.\n *\n * Options include:\n *\n * - thousandSeparator\n * - decimalSeparator\n * - currenyPrecision\n * - currencySign\n * - currencyAtEnd\n *\n * This class also uses the default date format defined here: {@link Ext.Date#defaultFormat}.\n *\n * ## Using with renderers\n *\n * There are two helper functions that return a new function that can be used in conjunction with\n * grid renderers:\n *  \n *     columns: [{\n *         dataIndex: 'date',\n *         renderer: Ext.util.Format.dateRenderer('Y-m-d')\n *     }, {\n *         dataIndex: 'time',\n *         renderer: Ext.util.Format.numberRenderer('0.000')\n *     }]\n *  \n * Functions that only take a single argument can also be passed directly:\n *\n *     columns: [{\n *         dataIndex: 'cost',\n *         renderer: Ext.util.Format.usMoney\n *     }, {\n *         dataIndex: 'productCode',\n *         renderer: Ext.util.Format.uppercase\n *     }]\n *  \n * ## Using with XTemplates\n *\n * XTemplates can also directly use Ext.util.Format functions:\n *  \n *     new Ext.XTemplate([\n *         'Date: {startDate:date(\"Y-m-d\")}',\n *         'Cost: {cost:usMoney}'\n *     ]);\n *\n * @singleton\n */\n(function() {\n    Ext.ns('Ext.util');\n\n    Ext.util.Format = {};\n    var UtilFormat     = Ext.util.Format,\n        stripTagsRE    = /<\\/?[^>]+>/gi,\n        stripScriptsRe = /(?:<script.*?>)((\\n|\\r|.)*?)(?:<\\/script>)/ig,\n        nl2brRe        = /\\r?\\n/g,\n\n        // A RegExp to remove from a number format string, all characters except digits and '.'\n        formatCleanRe  = /[^\\d\\.]/g,\n\n        // A RegExp to remove from a number format string, all characters except digits and the local decimal separator.\n        // Created on first use. The local decimal separator character must be initialized for this to be created.\n        I18NFormatCleanRe;\n\n    Ext.apply(UtilFormat, {\n        //<locale>\n        /**\n         * @property {String} thousandSeparator\n         * The character that the {@link #number} function uses as a thousand separator.\n         *\n         * This may be overridden in a locale file.\n         */\n        thousandSeparator: ',',\n        //</locale>\n\n        //<locale>\n        /**\n         * @property {String} decimalSeparator\n         * The character that the {@link #number} function uses as a decimal point.\n         *\n         * This may be overridden in a locale file.\n         */\n        decimalSeparator: '.',\n        //</locale>\n\n        //<locale>\n        /**\n         * @property {Number} currencyPrecision\n         * The number of decimal places that the {@link #currency} function displays.\n         *\n         * This may be overridden in a locale file.\n         */\n        currencyPrecision: 2,\n        //</locale>\n\n         //<locale>\n        /**\n         * @property {String} currencySign\n         * The currency sign that the {@link #currency} function displays.\n         *\n         * This may be overridden in a locale file.\n         */\n        currencySign: '$',\n        //</locale>\n\n        //<locale>\n        /**\n         * @property {Boolean} currencyAtEnd\n         * This may be set to <code>true</code> to make the {@link #currency} function\n         * append the currency sign to the formatted value.\n         *\n         * This may be overridden in a locale file.\n         */\n        currencyAtEnd: false,\n        //</locale>\n\n        /**\n         * Checks a reference and converts it to empty string if it is undefined.\n         * @param {Object} value Reference to check\n         * @return {Object} Empty string if converted, otherwise the original value\n         */\n        undef : function(value) {\n            return value !== undefined ? value : \"\";\n        },\n\n        /**\n         * Checks a reference and converts it to the default value if it's empty.\n         * @param {Object} value Reference to check\n         * @param {String} [defaultValue=\"\"] The value to insert of it's undefined.\n         * @return {String}\n         */\n        defaultValue : function(value, defaultValue) {\n            return value !== undefined && value !== '' ? value : defaultValue;\n        },\n\n        /**\n         * Returns a substring from within an original string.\n         * @param {String} value The original text\n         * @param {Number} start The start index of the substring\n         * @param {Number} length The length of the substring\n         * @return {String} The substring\n         * @method\n         */\n        substr : 'ab'.substr(-1) != 'b'\n        ? function (value, start, length) {\n            var str = String(value);\n            return (start < 0)\n                ? str.substr(Math.max(str.length + start, 0), length)\n                : str.substr(start, length);\n        }\n        : function(value, start, length) {\n            return String(value).substr(start, length);\n        },\n\n        /**\n         * Converts a string to all lower case letters.\n         * @param {String} value The text to convert\n         * @return {String} The converted text\n         */\n        lowercase : function(value) {\n            return String(value).toLowerCase();\n        },\n\n        /**\n         * Converts a string to all upper case letters.\n         * @param {String} value The text to convert\n         * @return {String} The converted text\n         */\n        uppercase : function(value) {\n            return String(value).toUpperCase();\n        },\n\n        /**\n         * Format a number as US currency.\n         * @param {Number/String} value The numeric value to format\n         * @return {String} The formatted currency string\n         */\n        usMoney : function(v) {\n            return UtilFormat.currency(v, '$', 2);\n        },\n\n        /**\n         * Format a number as a currency.\n         * @param {Number/String} value The numeric value to format\n         * @param {String} [sign] The currency sign to use (defaults to {@link #currencySign})\n         * @param {Number} [decimals] The number of decimals to use for the currency\n         * (defaults to {@link #currencyPrecision})\n         * @param {Boolean} [end] True if the currency sign should be at the end of the string\n         * (defaults to {@link #currencyAtEnd})\n         * @return {String} The formatted currency string\n         */\n        currency: function(v, currencySign, decimals, end) {\n            var negativeSign = '',\n                format = \",0\",\n                i = 0;\n            v = v - 0;\n            if (v < 0) {\n                v = -v;\n                negativeSign = '-';\n            }\n            decimals = Ext.isDefined(decimals) ? decimals : UtilFormat.currencyPrecision;\n            format += format + (decimals > 0 ? '.' : '');\n            for (; i < decimals; i++) {\n                format += '0';\n            }\n            v = UtilFormat.number(v, format);\n            if ((end || UtilFormat.currencyAtEnd) === true) {\n                return Ext.String.format(\"{0}{1}{2}\", negativeSign, v, currencySign || UtilFormat.currencySign);\n            } else {\n                return Ext.String.format(\"{0}{1}{2}\", negativeSign, currencySign || UtilFormat.currencySign, v);\n            }\n        },\n\n        /**\n         * Formats the passed date using the specified format pattern.\n         * @param {String/Date} value The value to format. If a string is passed, it is converted to a Date\n         * by the Javascript's built-in Date#parse method.\n         * @param {String} [format] Any valid date format string. Defaults to {@link Ext.Date#defaultFormat}.\n         * @return {String} The formatted date string.\n         */\n        date: function(v, format) {\n            if (!v) {\n                return \"\";\n            }\n            if (!Ext.isDate(v)) {\n                v = new Date(Date.parse(v));\n            }\n            return Ext.Date.dateFormat(v, format || Ext.Date.defaultFormat);\n        },\n\n        /**\n         * Returns a date rendering function that can be reused to apply a date format multiple times efficiently.\n         * @param {String} format Any valid date format string. Defaults to {@link Ext.Date#defaultFormat}.\n         * @return {Function} The date formatting function\n         */\n        dateRenderer : function(format) {\n            return function(v) {\n                return UtilFormat.date(v, format);\n            };\n        },\n\n        /**\n         * Strips all HTML tags.\n         * @param {Object} value The text from which to strip tags\n         * @return {String} The stripped text\n         */\n        stripTags : function(v) {\n            return !v ? v : String(v).replace(stripTagsRE, \"\");\n        },\n\n        /**\n         * Strips all script tags.\n         * @param {Object} value The text from which to strip script tags\n         * @return {String} The stripped text\n         */\n        stripScripts : function(v) {\n            return !v ? v : String(v).replace(stripScriptsRe, \"\");\n        },\n\n        /**\n         * Simple format for a file size (xxx bytes, xxx KB, xxx MB).\n         * @param {Number/String} size The numeric value to format\n         * @return {String} The formatted file size\n         */\n        fileSize : function(size) {\n            if (size < 1024) {\n                return size + \" bytes\";\n            } else if (size < 1048576) {\n                return (Math.round(((size*10) / 1024))/10) + \" KB\";\n            } else {\n                return (Math.round(((size*10) / 1048576))/10) + \" MB\";\n            }\n        },\n\n        /**\n         * It does simple math for use in a template, for example:\n         *\n         *     var tpl = new Ext.Template('{value} * 10 = {value:math(\"* 10\")}');\n         *\n         * @return {Function} A function that operates on the passed value.\n         * @method\n         */\n        math : (function(){\n            var fns = {};\n\n            return function(v, a){\n                if (!fns[a]) {\n                    fns[a] = Ext.functionFactory('v', 'return v ' + a + ';');\n                }\n                return fns[a](v);\n            };\n        }()),\n\n        /**\n         * Rounds the passed number to the required decimal precision.\n         * @param {Number/String} value The numeric value to round.\n         * @param {Number} precision The number of decimal places to which to round the first parameter's value.\n         * @return {Number} The rounded value.\n         */\n        round : function(value, precision) {\n            var result = Number(value);\n            if (typeof precision == 'number') {\n                precision = Math.pow(10, precision);\n                result = Math.round(value * precision) / precision;\n            }\n            return result;\n        },\n\n        /**\n         * Formats the passed number according to the passed format string.\n         *\n         * The number of digits after the decimal separator character specifies the number of\n         * decimal places in the resulting string. The *local-specific* decimal character is\n         * used in the result.\n         *\n         * The *presence* of a thousand separator character in the format string specifies that\n         * the *locale-specific* thousand separator (if any) is inserted separating thousand groups.\n         *\n         * By default, \",\" is expected as the thousand separator, and \".\" is expected as the decimal separator.\n         *\n         * ## New to Ext JS 4\n         *\n         * Locale-specific characters are always used in the formatted output when inserting\n         * thousand and decimal separators.\n         *\n         * The format string must specify separator characters according to US/UK conventions (\",\" as the\n         * thousand separator, and \".\" as the decimal separator)\n         *\n         * To allow specification of format strings according to local conventions for separator characters, add\n         * the string `/i` to the end of the format string.\n         *\n         * examples (123456.789):\n         * \n         * - `0` - (123456) show only digits, no precision\n         * - `0.00` - (123456.78) show only digits, 2 precision\n         * - `0.0000` - (123456.7890) show only digits, 4 precision\n         * - `0,000` - (123,456) show comma and digits, no precision\n         * - `0,000.00` - (123,456.78) show comma and digits, 2 precision\n         * - `0,0.00` - (123,456.78) shortcut method, show comma and digits, 2 precision\n         *\n         * To allow specification of the formatting string using UK/US grouping characters (,) and\n         * decimal (.) for international numbers, add /i to the end. For example: 0.000,00/i\n         *\n         * @param {Number} v The number to format.\n         * @param {String} format The way you would like to format this text.\n         * @return {String} The formatted number.\n         */\n        number : function(v, formatString) {\n            if (!formatString) {\n                return v;\n            }\n            v = Ext.Number.from(v, NaN);\n            if (isNaN(v)) {\n                return '';\n            }\n            var comma = UtilFormat.thousandSeparator,\n                dec   = UtilFormat.decimalSeparator,\n                i18n  = false,\n                neg   = v < 0,\n                hasComma,\n                psplit,\n                fnum,\n                cnum,\n                parr,\n                j,\n                m,\n                n,\n                i;\n\n            v = Math.abs(v);\n\n            // The \"/i\" suffix allows caller to use a locale-specific formatting string.\n            // Clean the format string by removing all but numerals and the decimal separator.\n            // Then split the format string into pre and post decimal segments according to *what* the\n            // decimal separator is. If they are specifying \"/i\", they are using the local convention in the format string.\n            if (formatString.substr(formatString.length - 2) == '/i') {\n                if (!I18NFormatCleanRe) {\n                    I18NFormatCleanRe = new RegExp('[^\\\\d\\\\' + UtilFormat.decimalSeparator + ']','g');\n                }\n                formatString = formatString.substr(0, formatString.length - 2);\n                i18n   = true;\n                hasComma = formatString.indexOf(comma) != -1;\n                psplit = formatString.replace(I18NFormatCleanRe, '').split(dec);\n            } else {\n                hasComma = formatString.indexOf(',') != -1;\n                psplit = formatString.replace(formatCleanRe, '').split('.');\n            }\n\n            if (psplit.length > 2) {\n                Ext.Error.raise({\n                    sourceClass: \"Ext.util.Format\",\n                    sourceMethod: \"number\",\n                    value: v,\n                    formatString: formatString,\n                    msg: \"Invalid number format, should have no more than 1 decimal\"\n                });\n            } else if (psplit.length > 1) {\n                v = Ext.Number.toFixed(v, psplit[1].length);\n            } else {\n                v = Ext.Number.toFixed(v, 0);\n            }\n\n            fnum = v.toString();\n\n            psplit = fnum.split('.');\n\n            if (hasComma) {\n                cnum = psplit[0];\n                parr = [];\n                j = cnum.length;\n                m = Math.floor(j / 3);\n                n = cnum.length % 3 || 3;\n\n                for (i = 0; i < j; i += n) {\n                    if (i !== 0) {\n                        n = 3;\n                    }\n\n                    parr[parr.length] = cnum.substr(i, n);\n                    m -= 1;\n                }\n                fnum = parr.join(comma);\n                if (psplit[1]) {\n                    fnum += dec + psplit[1];\n                }\n            } else {\n                if (psplit[1]) {\n                    fnum = psplit[0] + dec + psplit[1];\n                }\n            }\n\n            if (neg) {\n                /*\n                 * Edge case. If we have a very small negative number it will get rounded to 0,\n                 * however the initial check at the top will still report as negative. Replace\n                 * everything but 1-9 and check if the string is empty to determine a 0 value.\n                 */\n                neg = fnum.replace(/[^1-9]/g, '') !== '';\n            }\n\n            return (neg ? '-' : '') + formatString.replace(/[\\d,?\\.?]+/, fnum);\n        },\n\n        /**\n         * Returns a number rendering function that can be reused to apply a number format multiple\n         * times efficiently.\n         *\n         * @param {String} format Any valid number format string for {@link #number}\n         * @return {Function} The number formatting function\n         */\n        numberRenderer : function(format) {\n            return function(v) {\n                return UtilFormat.number(v, format);\n            };\n        },\n\n        /**\n         * Selectively do a plural form of a word based on a numeric value. For example, in a template,\n         * `{commentCount:plural(\"Comment\")}`  would result in `\"1 Comment\"` if commentCount was 1 or\n         * would be `\"x Comments\"` if the value is 0 or greater than 1.\n         *\n         * @param {Number} value The value to compare against\n         * @param {String} singular The singular form of the word\n         * @param {String} [plural] The plural form of the word (defaults to the singular with an \"s\")\n         */\n        plural : function(v, s, p) {\n            return v +' ' + (v == 1 ? s : (p ? p : s+'s'));\n        },\n\n        /**\n         * Converts newline characters to the HTML tag `<br/>`\n         *\n         * @param {String} The string value to format.\n         * @return {String} The string with embedded `<br/>` tags in place of newlines.\n         */\n        nl2br : function(v) {\n            return Ext.isEmpty(v) ? '' : v.replace(nl2brRe, '<br/>');\n        },\n\n        /**\n         * Alias for {@link Ext.String#capitalize}.\n         * @method\n         * @inheritdoc Ext.String#capitalize\n         */\n        capitalize: Ext.String.capitalize,\n\n        /**\n         * Alias for {@link Ext.String#ellipsis}.\n         * @method\n         * @inheritdoc Ext.String#ellipsis\n         */\n        ellipsis: Ext.String.ellipsis,\n\n        /**\n         * Alias for {@link Ext.String#format}.\n         * @method\n         * @inheritdoc Ext.String#format\n         */\n        format: Ext.String.format,\n\n        /**\n         * Alias for {@link Ext.String#htmlDecode}.\n         * @method\n         * @inheritdoc Ext.String#htmlDecode\n         */\n        htmlDecode: Ext.String.htmlDecode,\n\n        /**\n         * Alias for {@link Ext.String#htmlEncode}.\n         * @method\n         * @inheritdoc Ext.String#htmlEncode\n         */\n        htmlEncode: Ext.String.htmlEncode,\n\n        /**\n         * Alias for {@link Ext.String#leftPad}.\n         * @method\n         * @inheritdoc Ext.String#leftPad\n         */\n        leftPad: Ext.String.leftPad,\n\n        /**\n         * Alias for {@link Ext.String#trim}.\n         * @method\n         * @inheritdoc Ext.String#trim\n         */\n        trim : Ext.String.trim,\n\n        /**\n         * Parses a number or string representing margin sizes into an object.\n         * Supports CSS-style margin declarations (e.g. 10, \"10\", \"10 10\", \"10 10 10\" and\n         * \"10 10 10 10\" are all valid options and would return the same result).\n         *\n         * @param {Number/String} v The encoded margins\n         * @return {Object} An object with margin sizes for top, right, bottom and left\n         */\n        parseBox : function(box) {\n          box = Ext.isEmpty(box) ? '' : box;\n            if (Ext.isNumber(box)) {\n                box = box.toString();\n            }\n            var parts  = box.split(' '),\n                ln = parts.length;\n\n            if (ln == 1) {\n                parts[1] = parts[2] = parts[3] = parts[0];\n            }\n            else if (ln == 2) {\n                parts[2] = parts[0];\n                parts[3] = parts[1];\n            }\n            else if (ln == 3) {\n                parts[3] = parts[1];\n            }\n\n            return {\n                top   :parseInt(parts[0], 10) || 0,\n                right :parseInt(parts[1], 10) || 0,\n                bottom:parseInt(parts[2], 10) || 0,\n                left  :parseInt(parts[3], 10) || 0\n            };\n        },\n\n        /**\n         * Escapes the passed string for use in a regular expression.\n         * @param {String} str\n         * @return {String}\n         */\n        escapeRegex : function(s) {\n            return s.replace(/([\\-.*+?\\^${}()|\\[\\]\\/\\\\])/g, \"\\\\$1\");\n        }\n    });\n}());\n\n//@tag extras,core\n//@require Format.js\n//@define Ext.util.TaskManager\n//@define Ext.TaskManager\n\n/**\n * Provides the ability to execute one or more arbitrary tasks in a asynchronous manner.\n * Generally, you can use the singleton {@link Ext.TaskManager} instead, but if needed,\n * you can create separate instances of TaskRunner. Any number of separate tasks can be\n * started at any time and will run independently of each other.\n * \n * Example usage:\n *\n *      // Start a simple clock task that updates a div once per second\n *      var updateClock = function () {\n *          Ext.fly('clock').update(new Date().format('g:i:s A'));\n *      }\n *\n *      var runner = new Ext.util.TaskRunner();\n *      var task = runner.start({\n *          run: updateClock,\n *          interval: 1000\n *      }\n *\n * The equivalent using TaskManager:\n *\n *      var task = Ext.TaskManager.start({\n *          run: updateClock,\n *          interval: 1000\n *      });\n *\n * To end a running task:\n * \n *      Ext.TaskManager.stop(task);\n *\n * If a task needs to be started and stopped repeated over time, you can create a\n * {@link Ext.util.TaskRunner.Task Task} instance.\n *\n *      var task = runner.newTask({\n *          run: function () {\n *              // useful code\n *          },\n *          interval: 1000\n *      });\n *      \n *      task.start();\n *      \n *      // ...\n *      \n *      task.stop();\n *      \n *      // ...\n *      \n *      task.start();\n *\n * A re-usable, one-shot task can be managed similar to the above:\n *\n *      var task = runner.newTask({\n *          run: function () {\n *              // useful code to run once\n *          },\n *          repeat: 1\n *      });\n *      \n *      task.start();\n *      \n *      // ...\n *      \n *      task.start();\n *\n * See the {@link #start} method for details about how to configure a task object.\n *\n * Also see {@link Ext.util.DelayedTask}. \n * \n * @constructor\n * @param {Number/Object} [interval=10] The minimum precision in milliseconds supported by this\n * TaskRunner instance. Alternatively, a config object to apply to the new instance.\n */\nExt.define('Ext.util.TaskRunner', {\n    /**\n     * @cfg interval\n     * The timer resolution.\n     */\n    interval: 10,\n\n    /**\n     * @property timerId\n     * The id of the current timer.\n     * @private\n     */\n    timerId: null,\n\n    constructor: function (interval) {\n        var me = this;\n\n        if (typeof interval == 'number') {\n            me.interval = interval;\n        } else if (interval) {\n            Ext.apply(me, interval);\n        }\n\n        me.tasks = [];\n        me.timerFn = Ext.Function.bind(me.onTick, me);\n    },\n\n    /**\n     * Creates a new {@link Ext.util.TaskRunner.Task Task} instance. These instances can\n     * be easily started and stopped.\n     * @param {Object} config The config object. For details on the supported properties,\n     * see {@link #start}.\n     */\n    newTask: function (config) {\n        var task = new Ext.util.TaskRunner.Task(config);\n        task.manager = this;\n        return task;\n    },\n\n    /**\n     * Starts a new task.\n     *\n     * Before each invocation, Ext injects the property `taskRunCount` into the task object\n     * so that calculations based on the repeat count can be performed.\n     * \n     * The returned task will contain a `destroy` method that can be used to destroy the\n     * task and cancel further calls. This is equivalent to the {@link #stop} method.\n     *\n     * @param {Object} task A config object that supports the following properties:\n     * @param {Function} task.run The function to execute each time the task is invoked. The\n     * function will be called at each interval and passed the `args` argument if specified,\n     * and the current invocation count if not.\n     * \n     * If a particular scope (`this` reference) is required, be sure to specify it using\n     * the `scope` argument.\n     * \n     * @param {Function} task.onError The function to execute in case of unhandled\n     * error on task.run.\n     *\n     * @param {Boolean} task.run.return `false` from this function to terminate the task.\n     *\n     * @param {Number} task.interval The frequency in milliseconds with which the task\n     * should be invoked.\n     *\n     * @param {Object[]} task.args An array of arguments to be passed to the function\n     * specified by `run`. If not specified, the current invocation count is passed.\n     *\n     * @param {Object} task.scope The scope (`this` reference) in which to execute the\n     * `run` function. Defaults to the task config object.\n     *\n     * @param {Number} task.duration The length of time in milliseconds to invoke the task\n     * before stopping automatically (defaults to indefinite).\n     *\n     * @param {Number} task.repeat The number of times to invoke the task before stopping\n     * automatically (defaults to indefinite).\n     * @return {Object} The task\n     */\n    start: function(task) {\n        var me = this,\n            now = new Date().getTime();\n\n        if (!task.pending) {\n            me.tasks.push(task);\n            task.pending = true; // don't allow the task to be added to me.tasks again\n        }\n\n        task.stopped = false; // might have been previously stopped...\n        task.taskStartTime = now;\n        task.taskRunTime = task.fireOnStart !== false ? 0 : task.taskStartTime;\n        task.taskRunCount = 0;\n\n        if (!me.firing) {\n            if (task.fireOnStart !== false) {\n                me.startTimer(0, now);\n            } else {\n                me.startTimer(task.interval, now);\n            }\n        }\n\n        return task;\n    },\n\n    /**\n     * Stops an existing running task.\n     * @param {Object} task The task to stop\n     * @return {Object} The task\n     */\n    stop: function(task) {\n        // NOTE: we don't attempt to remove the task from me.tasks at this point because\n        // this could be called from inside a task which would then corrupt the state of\n        // the loop in onTick\n        if (!task.stopped) {\n            task.stopped = true;\n\n            if (task.onStop) {\n                task.onStop.call(task.scope || task, task);\n            }\n        }\n\n        return task;\n    },\n\n    /**\n     * Stops all tasks that are currently running.\n     */\n    stopAll: function() {\n        // onTick will take care of cleaning up the mess after this point...\n        Ext.each(this.tasks, this.stop, this);\n    },\n\n    //-------------------------------------------------------------------------\n\n    firing: false,\n\n    nextExpires: 1e99,\n\n    // private\n    onTick: function () {\n        var me = this,\n            tasks = me.tasks,\n            now = new Date().getTime(),\n            nextExpires = 1e99,\n            len = tasks.length,\n            expires, newTasks, i, task, rt, remove;\n\n        me.timerId = null;\n        me.firing = true; // ensure we don't startTimer during this loop...\n\n        // tasks.length can be > len if start is called during a task.run call... so we\n        // first check len to avoid tasks.length reference but eventually we need to also\n        // check tasks.length. we avoid repeating use of tasks.length by setting len at\n        // that time (to help the next loop)\n        for (i = 0; i < len || i < (len = tasks.length); ++i) {\n            task = tasks[i];\n\n            if (!(remove = task.stopped)) {\n                expires = task.taskRunTime + task.interval;\n\n                if (expires <= now) {\n                    rt = 1; // otherwise we have a stale \"rt\"\n                    try {\n                        rt = task.run.apply(task.scope || task, task.args || [++task.taskRunCount]);\n                    } catch (taskError) {\n                        try {\n                            if (task.onError) {\n                                rt = task.onError.call(task.scope || task, task, taskError);\n                            }\n                        } catch (ignore) { }\n                    }\n                    task.taskRunTime = now;\n                    if (rt === false || task.taskRunCount === task.repeat) {\n                        me.stop(task);\n                        remove = true;\n                    } else {\n                        remove = task.stopped; // in case stop was called by run\n                        expires = now + task.interval;\n                    }\n                }\n\n                if (!remove && task.duration && task.duration <= (now - task.taskStartTime)) {\n                    me.stop(task);\n                    remove = true;\n                }\n            }\n\n            if (remove) {\n                task.pending = false; // allow the task to be added to me.tasks again\n\n                // once we detect that a task needs to be removed, we copy the tasks that\n                // will carry forward into newTasks... this way we avoid O(N*N) to remove\n                // each task from the tasks array (and ripple the array down) and also the\n                // potentially wasted effort of making a new tasks[] even if all tasks are\n                // going into the next wave.\n                if (!newTasks) {\n                    newTasks = tasks.slice(0, i);\n                    // we don't set me.tasks here because callbacks can also start tasks,\n                    // which get added to me.tasks... so we will visit them in this loop\n                    // and account for their expirations in nextExpires...\n                }\n            } else {\n                if (newTasks) {\n                    newTasks.push(task); // we've cloned the tasks[], so keep this one...\n                }\n\n                if (nextExpires > expires) {\n                    nextExpires = expires; // track the nearest expiration time\n                }\n            }\n        }\n\n        if (newTasks) {\n            // only now can we copy the newTasks to me.tasks since no user callbacks can\n            // take place\n            me.tasks = newTasks;\n        }\n\n        me.firing = false; // we're done, so allow startTimer afterwards\n\n        if (me.tasks.length) {\n            // we create a new Date here because all the callbacks could have taken a long\n            // time... we want to base the next timeout on the current time (after the\n            // callback storm):\n            me.startTimer(nextExpires - now, new Date().getTime());\n        }\n    },\n\n    // private\n    startTimer: function (timeout, now) {\n        var me = this,\n            expires = now + timeout,\n            timerId = me.timerId;\n\n        // Check to see if this request is enough in advance of the current timer. If so,\n        // we reschedule the timer based on this new expiration.\n        if (timerId && me.nextExpires - expires > me.interval) {\n            clearTimeout(timerId);\n            timerId = null;\n        }\n\n        if (!timerId) {\n            if (timeout < me.interval) {\n                timeout = me.interval;\n            }\n\n            me.timerId = setTimeout(me.timerFn, timeout);\n            me.nextExpires = expires;\n        }\n    }\n},\nfunction () {\n    var me = this,\n        proto = me.prototype;\n\n    /**\n     * Destroys this instance, stopping all tasks that are currently running.\n     * @method destroy\n     */\n    proto.destroy = proto.stopAll;\n\n    /**\n    * @class Ext.TaskManager\n    * @extends Ext.util.TaskRunner\n    * @singleton\n    *\n    * A static {@link Ext.util.TaskRunner} instance that can be used to start and stop\n    * arbitrary tasks. See {@link Ext.util.TaskRunner} for supported methods and task\n    * config properties.\n    *\n    *    // Start a simple clock task that updates a div once per second\n    *    var task = {\n    *       run: function(){\n    *           Ext.fly('clock').update(new Date().format('g:i:s A'));\n    *       },\n    *       interval: 1000 //1 second\n    *    }\n    *\n    *    Ext.TaskManager.start(task);\n    *\n    * See the {@link #start} method for details about how to configure a task object.\n    */\n    Ext.util.TaskManager = Ext.TaskManager = new me();\n\n    /**\n     * Instances of this class are created by {@link Ext.util.TaskRunner#newTask} method.\n     * \n     * For details on config properties, see {@link Ext.util.TaskRunner#start}.\n     * @class Ext.util.TaskRunner.Task\n     */\n    me.Task = new Ext.Class({\n        isTask: true,\n\n        /**\n         * This flag is set to `true` by {@link #stop}.\n         * @private\n         */\n        stopped: true, // this avoids the odd combination of !stopped && !pending\n\n        /**\n         * Override default behavior\n         */\n        fireOnStart: false,\n\n        constructor: function (config) {\n            Ext.apply(this, config);\n        },\n\n        /**\n         * Restarts this task, clearing it duration, expiration and run count.\n         * @param {Number} [interval] Optionally reset this task's interval.\n         */\n        restart: function (interval) {\n            if (interval !== undefined) {\n                this.interval = interval;\n            }\n\n            this.manager.start(this);\n        },\n\n        /**\n         * Starts this task if it is not already started.\n         * @param {Number} [interval] Optionally reset this task's interval.\n         */\n        start: function (interval) {\n            if (this.stopped) {\n                this.restart(interval);\n            }\n        },\n\n        /**\n         * Stops this task.\n         */\n        stop: function () {\n            this.manager.stop(this);\n        }\n    });\n\n    proto = me.Task.prototype;\n\n    /**\n     * Destroys this instance, stopping this task's execution.\n     * @method destroy\n     */\n    proto.destroy = proto.stop;\n});\n\n//@tag extras,core\n//@require ../util/TaskManager.js\n\n/**\n * @class Ext.perf.Accumulator\n * @private\n */\nExt.define('Ext.perf.Accumulator', (function () {\n    var currentFrame = null,\n        khrome = Ext.global['chrome'],\n        formatTpl,\n        // lazy init on first request for timestamp (avoids infobar in IE until needed)\n        // Also avoids kicking off Chrome's microsecond timer until first needed\n        getTimestamp = function () {\n\n            getTimestamp = function () {\n                return new Date().getTime();\n            };\n            \n            var interval, toolbox;\n\n            // If Chrome is started with the --enable-benchmarking switch\n            if (Ext.isChrome && khrome && khrome.Interval) {\n                interval = new khrome.Interval();\n                interval.start();\n                getTimestamp = function () {\n                    return interval.microseconds() / 1000;\n                };\n            } else if (window.ActiveXObject) {\n                try {\n                    // the above technique is not very accurate for small intervals...\n                    toolbox = new ActiveXObject('SenchaToolbox.Toolbox');\n                    Ext.senchaToolbox = toolbox; // export for other uses\n                    getTimestamp = function () {\n                        return toolbox.milliseconds;\n                    };\n                } catch (e) {\n                    // ignore\n                }\n            } else if (Date.now) {\n                getTimestamp = Date.now;\n            }\n\n            Ext.perf.getTimestamp = Ext.perf.Accumulator.getTimestamp = getTimestamp;\n            return getTimestamp();\n        };\n\n    function adjustSet (set, time) {\n        set.sum += time;\n        set.min = Math.min(set.min, time);\n        set.max = Math.max(set.max, time);\n    }\n\n    function leaveFrame (time) {\n        var totalTime = time ? time : (getTimestamp() - this.time), // do this first\n            me = this, // me = frame\n            accum = me.accum;\n\n        ++accum.count;\n        if (! --accum.depth) {\n            adjustSet(accum.total, totalTime);\n        }\n        adjustSet(accum.pure, totalTime - me.childTime);\n\n        currentFrame = me.parent;\n        if (currentFrame) {\n            ++currentFrame.accum.childCount;\n            currentFrame.childTime += totalTime;\n        }\n    }\n\n    function makeSet () {\n        return {\n            min: Number.MAX_VALUE,\n            max: 0,\n            sum: 0\n        };\n    }\n\n    function makeTap (me, fn) {\n        return function () {\n            var frame = me.enter(),\n                ret = fn.apply(this, arguments);\n\n            frame.leave();\n            return ret;\n        };\n    }\n\n    function round (x) {\n        return Math.round(x * 100) / 100;\n    }\n\n    function setToJSON (count, childCount, calibration, set) {\n        var data = {\n            avg: 0,\n            min: set.min,\n            max: set.max,\n            sum: 0\n        };\n\n        if (count) {\n            calibration = calibration || 0;\n            data.sum = set.sum - childCount * calibration;\n            data.avg = data.sum / count;\n            // min and max cannot be easily corrected since we don't know the number of\n            // child calls for them.\n        }\n\n        return data;\n    }\n\n    return {\n        constructor: function (name) {\n            var me = this;\n\n            me.count = me.childCount = me.depth = me.maxDepth = 0;\n            me.pure = makeSet();\n            me.total = makeSet();\n            me.name = name;\n        },\n\n        statics: {\n            getTimestamp: getTimestamp\n        },\n\n        format: function (calibration) {\n            if (!formatTpl) {\n                formatTpl = new Ext.XTemplate([\n                        '{name} - {count} call(s)',\n                        '<tpl if=\"count\">',\n                            '<tpl if=\"childCount\">',\n                                ' ({childCount} children)',\n                            '</tpl>',\n                            '<tpl if=\"depth - 1\">',\n                                ' ({depth} deep)',\n                            '</tpl>',\n                            '<tpl for=\"times\">',\n                                ', {type}: {[this.time(values.sum)]} msec (',\n                                     //'min={[this.time(values.min)]}, ',\n                                     'avg={[this.time(values.sum / parent.count)]}',\n                                     //', max={[this.time(values.max)]}',\n                                     ')',\n                            '</tpl>',\n                        '</tpl>'\n                    ].join(''), {\n                        time: function (t) {\n                            return Math.round(t * 100) / 100;\n                        }\n                    });\n            }\n\n            var data = this.getData(calibration);\n            data.name = this.name;\n            data.pure.type = 'Pure';\n            data.total.type = 'Total';\n            data.times = [data.pure, data.total];\n            return formatTpl.apply(data);\n        },\n\n        getData: function (calibration) {\n            var me = this;\n\n            return {\n                count: me.count,\n                childCount: me.childCount,\n                depth: me.maxDepth,\n                pure: setToJSON(me.count, me.childCount, calibration, me.pure),\n                total: setToJSON(me.count, me.childCount, calibration, me.total)\n            };\n        },\n\n        enter: function () {\n            var me = this,\n                frame = {\n                    accum: me,\n                    leave: leaveFrame,\n                    childTime: 0,\n                    parent: currentFrame\n                };\n\n            ++me.depth;\n            if (me.maxDepth < me.depth) {\n                me.maxDepth = me.depth;\n            }\n\n            currentFrame = frame;\n            frame.time = getTimestamp(); // do this last\n            return frame;\n        },\n\n        monitor: function (fn, scope, args) {\n            var frame = this.enter();\n            if (args) {\n                fn.apply(scope, args);\n            } else {\n                fn.call(scope);\n            }\n            frame.leave();\n        },\n\n        report: function () {\n            Ext.log(this.format());\n        },\n\n        tap: function (className, methodName) {\n            var me = this,\n                methods = typeof methodName == 'string' ? [methodName] : methodName,\n                klass, statik, i, parts, length, name, src,\n                tapFunc;\n\n            tapFunc = function(){\n                if (typeof className == 'string') {\n                    klass = Ext.global;\n                    parts = className.split('.');\n                    for (i = 0, length = parts.length; i < length; ++i) {\n                        klass = klass[parts[i]];\n                    }\n                } else {\n                    klass = className;\n                }\n\n                for (i = 0, length = methods.length; i < length; ++i) {\n                    name = methods[i];\n                    statik = name.charAt(0) == '!';\n\n                    if (statik) {\n                        name = name.substring(1);\n                    } else {\n                        statik = !(name in klass.prototype);\n                    }\n\n                    src = statik ? klass : klass.prototype;\n                    src[name] = makeTap(me, src[name]);\n                }\n            };\n\n            Ext.ClassManager.onCreated(tapFunc, me, className);\n\n            return me;\n        }\n    };\n}()),\n\nfunction () {\n    Ext.perf.getTimestamp = this.getTimestamp;\n});\n\n//@tag extras,core\n//@require Accumulator.js\n\n/**\n * @class Ext.perf.Monitor\n * @singleton\n * @private\n */\nExt.define('Ext.perf.Monitor', {\n    singleton: true,\n    alternateClassName: 'Ext.Perf',\n\n    requires: [\n        'Ext.perf.Accumulator'\n    ],\n\n    constructor: function () {\n        this.accumulators = [];\n        this.accumulatorsByName = {};\n    },\n\n    calibrate: function () {\n        var accum = new Ext.perf.Accumulator('$'),\n            total = accum.total,\n            getTimestamp = Ext.perf.Accumulator.getTimestamp,\n            count = 0,\n            frame,\n            endTime,\n            startTime;\n\n        startTime = getTimestamp();\n\n        do {\n            frame = accum.enter();\n            frame.leave();\n            ++count;\n        } while (total.sum < 100);\n\n        endTime = getTimestamp();\n\n        return (endTime - startTime) / count;\n    },\n\n    get: function (name) {\n        var me = this,\n            accum = me.accumulatorsByName[name];\n\n        if (!accum) {\n            me.accumulatorsByName[name] = accum = new Ext.perf.Accumulator(name);\n            me.accumulators.push(accum);\n        }\n\n        return accum;\n    },\n\n    enter: function (name) {\n        return this.get(name).enter();\n    },\n\n    monitor: function (name, fn, scope) {\n        this.get(name).monitor(fn, scope);\n    },\n\n    report: function () {\n        var me = this,\n            accumulators = me.accumulators,\n            calibration = me.calibrate();\n\n        accumulators.sort(function (a, b) {\n            return (a.name < b.name) ? -1 : ((b.name < a.name) ? 1 : 0);\n        });\n\n        me.updateGC();\n\n        Ext.log('Calibration: ' + Math.round(calibration * 100) / 100 + ' msec/sample');\n        Ext.each(accumulators, function (accum) {\n            Ext.log(accum.format(calibration));\n        });\n    },\n\n    getData: function (all) {\n        var ret = {},\n            accumulators = this.accumulators;\n\n        Ext.each(accumulators, function (accum) {\n            if (all || accum.count) {\n                ret[accum.name] = accum.getData();\n            }\n        });\n\n        return ret;\n    },\n\n    reset: function(){\n        Ext.each(this.accumulators, function(accum){\n            var me = accum;\n            me.count = me.childCount = me.depth = me.maxDepth = 0;\n            me.pure = {\n                min: Number.MAX_VALUE,\n                max: 0,\n                sum: 0\n            };\n            me.total = {\n                min: Number.MAX_VALUE,\n                max: 0,\n                sum: 0\n            };\n        });\n    },\n\n    updateGC: function () {\n        var accumGC = this.accumulatorsByName.GC,\n            toolbox = Ext.senchaToolbox,\n            bucket;\n\n        if (accumGC) {\n            accumGC.count = toolbox.garbageCollectionCounter || 0;\n\n            if (accumGC.count) {\n                bucket = accumGC.pure;\n                accumGC.total.sum = bucket.sum = toolbox.garbageCollectionMilliseconds;\n                bucket.min = bucket.max = bucket.sum / accumGC.count;\n                bucket = accumGC.total;\n                bucket.min = bucket.max = bucket.sum / accumGC.count;\n            }\n        }\n    },\n\n    watchGC: function () {\n        Ext.perf.getTimestamp(); // initializes SenchaToolbox (if available)\n\n        var toolbox = Ext.senchaToolbox;\n\n        if (toolbox) {\n            this.get(\"GC\");\n            toolbox.watchGarbageCollector(false); // no logging, just totals\n        }\n    },\n\n    setup: function (config) {\n        if (!config) {\n            config = {\n                /*insertHtml: {\n                    'Ext.dom.Helper': 'insertHtml'\n                },*/\n                /*xtplCompile: {\n                    'Ext.XTemplateCompiler': 'compile'\n                },*/\n//                doInsert: {\n//                    'Ext.Template': 'doInsert'\n//                },\n//                applyOut: {\n//                    'Ext.XTemplate': 'applyOut'\n//                },\n                render: {\n                    'Ext.AbstractComponent': 'render'\n                },\n//                fnishRender: {\n//                    'Ext.AbstractComponent': 'finishRender'\n//                },\n//                renderSelectors: {\n//                    'Ext.AbstractComponent': 'applyRenderSelectors'\n//                },\n//                compAddCls: {\n//                    'Ext.AbstractComponent': 'addCls'\n//                },\n//                compRemoveCls: {\n//                    'Ext.AbstractComponent': 'removeCls'\n//                },\n//                getStyle: {\n//                    'Ext.core.Element': 'getStyle'\n//                },\n//                setStyle: {\n//                    'Ext.core.Element': 'setStyle'\n//                },\n//                addCls: {\n//                    'Ext.core.Element': 'addCls'\n//                },\n//                removeCls: {\n//                    'Ext.core.Element': 'removeCls'\n//                },\n//                measure: {\n//                    'Ext.layout.component.Component': 'measureAutoDimensions'\n//                },\n//                moveItem: {\n//                    'Ext.layout.Layout': 'moveItem'\n//                },\n//                layoutFlush: {\n//                    'Ext.layout.Context': 'flush'\n//                },\n                layout: {\n                    'Ext.layout.Context': 'run'\n                }\n            };\n        }\n\n        this.currentConfig = config;\n\n        var key, prop,\n            accum, className, methods;\n        for (key in config) {\n            if (config.hasOwnProperty(key)) {\n                prop = config[key];\n                accum = Ext.Perf.get(key);\n\n                for (className in prop) {\n                    if (prop.hasOwnProperty(className)) {\n                        methods = prop[className];\n                        accum.tap(className, methods);\n                    }\n                }\n            }\n        }\n\n        this.watchGC();\n    }\n});\n\n//@tag extras,core\n//@require perf/Monitor.js\n//@define Ext.Supports\n\n/**\n * @class Ext.is\n * \n * Determines information about the current platform the application is running on.\n * \n * @singleton\n */\nExt.is = {\n    init : function(navigator) {\n        var platforms = this.platforms,\n            ln = platforms.length,\n            i, platform;\n\n        navigator = navigator || window.navigator;\n\n        for (i = 0; i < ln; i++) {\n            platform = platforms[i];\n            this[platform.identity] = platform.regex.test(navigator[platform.property]);\n        }\n\n        /**\n         * @property Desktop True if the browser is running on a desktop machine\n         * @type {Boolean}\n         */\n        this.Desktop = this.Mac || this.Windows || (this.Linux && !this.Android);\n        /**\n         * @property Tablet True if the browser is running on a tablet (iPad)\n         */\n        this.Tablet = this.iPad;\n        /**\n         * @property Phone True if the browser is running on a phone.\n         * @type {Boolean}\n         */\n        this.Phone = !this.Desktop && !this.Tablet;\n        /**\n         * @property iOS True if the browser is running on iOS\n         * @type {Boolean}\n         */\n        this.iOS = this.iPhone || this.iPad || this.iPod;\n        \n        /**\n         * @property Standalone Detects when application has been saved to homescreen.\n         * @type {Boolean}\n         */\n        this.Standalone = !!window.navigator.standalone;\n    },\n    \n    /**\n     * @property iPhone True when the browser is running on a iPhone\n     * @type {Boolean}\n     */\n    platforms: [{\n        property: 'platform',\n        regex: /iPhone/i,\n        identity: 'iPhone'\n    },\n    \n    /**\n     * @property iPod True when the browser is running on a iPod\n     * @type {Boolean}\n     */\n    {\n        property: 'platform',\n        regex: /iPod/i,\n        identity: 'iPod'\n    },\n    \n    /**\n     * @property iPad True when the browser is running on a iPad\n     * @type {Boolean}\n     */\n    {\n        property: 'userAgent',\n        regex: /iPad/i,\n        identity: 'iPad'\n    },\n    \n    /**\n     * @property Blackberry True when the browser is running on a Blackberry\n     * @type {Boolean}\n     */\n    {\n        property: 'userAgent',\n        regex: /Blackberry/i,\n        identity: 'Blackberry'\n    },\n    \n    /**\n     * @property Android True when the browser is running on an Android device\n     * @type {Boolean}\n     */\n    {\n        property: 'userAgent',\n        regex: /Android/i,\n        identity: 'Android'\n    },\n    \n    /**\n     * @property Mac True when the browser is running on a Mac\n     * @type {Boolean}\n     */\n    {\n        property: 'platform',\n        regex: /Mac/i,\n        identity: 'Mac'\n    },\n    \n    /**\n     * @property Windows True when the browser is running on Windows\n     * @type {Boolean}\n     */\n    {\n        property: 'platform',\n        regex: /Win/i,\n        identity: 'Windows'\n    },\n    \n    /**\n     * @property Linux True when the browser is running on Linux\n     * @type {Boolean}\n     */\n    {\n        property: 'platform',\n        regex: /Linux/i,\n        identity: 'Linux'\n    }]\n};\n\nExt.is.init();\n\n/**\n * @class Ext.supports\n *\n * Determines information about features are supported in the current environment\n * \n * @singleton\n */\n(function(){\n\n    // this is a local copy of certain logic from (Abstract)Element.getStyle\n    // to break a dependancy between the supports mechanism and Element\n    // use this instead of element references to check for styling info\n    var getStyle = function(element, styleName){\n        var view = element.ownerDocument.defaultView,\n            style = (view ? view.getComputedStyle(element, null) : element.currentStyle) || element.style;\n        return style[styleName];\n    };\n\nExt.supports = {\n    /**\n     * Runs feature detection routines and sets the various flags. This is called when\n     * the scripts loads (very early) and again at {@link Ext#onReady}. Some detections\n     * are flagged as `early` and run immediately. Others that require the document body\n     * will not run until ready.\n     *\n     * Each test is run only once, so calling this method from an onReady function is safe\n     * and ensures that all flags have been set.\n     * @markdown\n     * @private\n     */\n    init : function() {\n        var me = this,\n            doc = document,\n            tests = me.tests,\n            n = tests.length,\n            div = n && Ext.isReady && doc.createElement('div'),\n            test, notRun = [];\n\n        if (div) {\n            div.innerHTML = [\n                '<div style=\"height:30px;width:50px;\">',\n                    '<div style=\"height:20px;width:20px;\"></div>',\n                '</div>',\n                '<div style=\"width: 200px; height: 200px; position: relative; padding: 5px;\">',\n                    '<div style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%;\"></div>',\n                '</div>',\n                '<div style=\"position: absolute; left: 10%; top: 10%;\"></div>',\n                '<div style=\"float:left; background-color:transparent;\"></div>'\n            ].join('');\n\n            doc.body.appendChild(div);\n        }\n\n        while (n--) {\n            test = tests[n];\n            if (div || test.early) {\n                me[test.identity] = test.fn.call(me, doc, div);\n            } else {\n                notRun.push(test);\n            }\n        }\n\n        if (div) {\n            doc.body.removeChild(div);\n        }\n\n        me.tests = notRun;\n    },\n\n    /**\n     * @property PointerEvents True if document environment supports the CSS3 pointer-events style.\n     * @type {Boolean}\n     */\n    PointerEvents: 'pointerEvents' in document.documentElement.style,\n\n    /**\n     * @property CSS3BoxShadow True if document environment supports the CSS3 box-shadow style.\n     * @type {Boolean}\n     */\n    CSS3BoxShadow: 'boxShadow' in document.documentElement.style || 'WebkitBoxShadow' in document.documentElement.style || 'MozBoxShadow' in document.documentElement.style,\n\n    /**\n     * @property ClassList True if document environment supports the HTML5 classList API.\n     * @type {Boolean}\n     */\n    ClassList: !!document.documentElement.classList,\n\n    /**\n     * @property OrientationChange True if the device supports orientation change\n     * @type {Boolean}\n     */\n    OrientationChange: ((typeof window.orientation != 'undefined') && ('onorientationchange' in window)),\n\n    /**\n     * @property DeviceMotion True if the device supports device motion (acceleration and rotation rate)\n     * @type {Boolean}\n     */\n    DeviceMotion: ('ondevicemotion' in window),\n\n    /**\n     * @property Touch True if the device supports touch\n     * @type {Boolean}\n     */\n    // is.Desktop is needed due to the bug in Chrome 5.0.375, Safari 3.1.2\n    // and Safari 4.0 (they all have 'ontouchstart' in the window object).\n    Touch: ('ontouchstart' in window) && (!Ext.is.Desktop),\n\n    /**\n     * @property TimeoutActualLateness True if the browser passes the \"actualLateness\" parameter to\n     * setTimeout. See: https://developer.mozilla.org/en/DOM/window.setTimeout\n     * @type {Boolean}\n     */\n    TimeoutActualLateness: (function(){\n        setTimeout(function(){\n            Ext.supports.TimeoutActualLateness = arguments.length !== 0;\n        }, 0);\n    }()),\n\n    tests: [\n        /**\n         * @property Transitions True if the device supports CSS3 Transitions\n         * @type {Boolean}\n         */\n        {\n            identity: 'Transitions',\n            fn: function(doc, div) {\n                var prefix = [\n                        'webkit',\n                        'Moz',\n                        'o',\n                        'ms',\n                        'khtml'\n                    ],\n                    TE = 'TransitionEnd',\n                    transitionEndName = [\n                        prefix[0] + TE,\n                        'transitionend', //Moz bucks the prefixing convention\n                        prefix[2] + TE,\n                        prefix[3] + TE,\n                        prefix[4] + TE\n                    ],\n                    ln = prefix.length,\n                    i = 0,\n                    out = false;\n\n                for (; i < ln; i++) {\n                    if (getStyle(div, prefix[i] + \"TransitionProperty\")) {\n                        Ext.supports.CSS3Prefix = prefix[i];\n                        Ext.supports.CSS3TransitionEnd = transitionEndName[i];\n                        out = true;\n                        break;\n                    }\n                }\n                return out;\n            }\n        },\n\n        /**\n         * @property RightMargin True if the device supports right margin.\n         * See https://bugs.webkit.org/show_bug.cgi?id=13343 for why this is needed.\n         * @type {Boolean}\n         */\n        {\n            identity: 'RightMargin',\n            fn: function(doc, div) {\n                var view = doc.defaultView;\n                return !(view && view.getComputedStyle(div.firstChild.firstChild, null).marginRight != '0px');\n            }\n        },\n\n        /**\n         * @property DisplayChangeInputSelectionBug True if INPUT elements lose their\n         * selection when their display style is changed. Essentially, if a text input\n         * has focus and its display style is changed, the I-beam disappears.\n         *\n         * This bug is encountered due to the work around in place for the {@link #RightMargin}\n         * bug. This has been observed in Safari 4.0.4 and older, and appears to be fixed\n         * in Safari 5. It's not clear if Safari 4.1 has the bug, but it has the same WebKit\n         * version number as Safari 5 (according to http://unixpapa.com/js/gecko.html).\n         */\n        {\n            identity: 'DisplayChangeInputSelectionBug',\n            early: true,\n            fn: function() {\n                var webKitVersion = Ext.webKitVersion;\n                // WebKit but older than Safari 5 or Chrome 6:\n                return 0 < webKitVersion && webKitVersion < 533;\n            }\n        },\n\n        /**\n         * @property DisplayChangeTextAreaSelectionBug True if TEXTAREA elements lose their\n         * selection when their display style is changed. Essentially, if a text area has\n         * focus and its display style is changed, the I-beam disappears.\n         *\n         * This bug is encountered due to the work around in place for the {@link #RightMargin}\n         * bug. This has been observed in Chrome 10 and Safari 5 and older, and appears to\n         * be fixed in Chrome 11.\n         */\n        {\n            identity: 'DisplayChangeTextAreaSelectionBug',\n            early: true,\n            fn: function() {\n                var webKitVersion = Ext.webKitVersion;\n\n                /*\n                Has bug w/textarea:\n\n                (Chrome) Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US)\n                            AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.127\n                            Safari/534.16\n                (Safari) Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us)\n                            AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5\n                            Safari/533.21.1\n\n                No bug:\n\n                (Chrome) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7)\n                            AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57\n                            Safari/534.24\n                */\n                return 0 < webKitVersion && webKitVersion < 534.24;\n            }\n        },\n\n        /**\n         * @property TransparentColor True if the device supports transparent color\n         * @type {Boolean}\n         */\n        {\n            identity: 'TransparentColor',\n            fn: function(doc, div, view) {\n                view = doc.defaultView;\n                return !(view && view.getComputedStyle(div.lastChild, null).backgroundColor != 'transparent');\n            }\n        },\n\n        /**\n         * @property ComputedStyle True if the browser supports document.defaultView.getComputedStyle()\n         * @type {Boolean}\n         */\n        {\n            identity: 'ComputedStyle',\n            fn: function(doc, div, view) {\n                view = doc.defaultView;\n                return view && view.getComputedStyle;\n            }\n        },\n\n        /**\n         * @property Svg True if the device supports SVG\n         * @type {Boolean}\n         */\n        {\n            identity: 'Svg',\n            fn: function(doc) {\n                return !!doc.createElementNS && !!doc.createElementNS( \"http:/\" + \"/www.w3.org/2000/svg\", \"svg\").createSVGRect;\n            }\n        },\n\n        /**\n         * @property Canvas True if the device supports Canvas\n         * @type {Boolean}\n         */\n        {\n            identity: 'Canvas',\n            fn: function(doc) {\n                return !!doc.createElement('canvas').getContext;\n            }\n        },\n\n        /**\n         * @property Vml True if the device supports VML\n         * @type {Boolean}\n         */\n        {\n            identity: 'Vml',\n            fn: function(doc) {\n                var d = doc.createElement(\"div\");\n                d.innerHTML = \"<!--[if vml]><br/><br/><![endif]-->\";\n                return (d.childNodes.length == 2);\n            }\n        },\n\n        /**\n         * @property Float True if the device supports CSS float\n         * @type {Boolean}\n         */\n        {\n            identity: 'Float',\n            fn: function(doc, div) {\n                return !!div.lastChild.style.cssFloat;\n            }\n        },\n\n        /**\n         * @property AudioTag True if the device supports the HTML5 audio tag\n         * @type {Boolean}\n         */\n        {\n            identity: 'AudioTag',\n            fn: function(doc) {\n                return !!doc.createElement('audio').canPlayType;\n            }\n        },\n\n        /**\n         * @property History True if the device supports HTML5 history\n         * @type {Boolean}\n         */\n        {\n            identity: 'History',\n            fn: function() {\n                var history = window.history;\n                return !!(history && history.pushState);\n            }\n        },\n\n        /**\n         * @property CSS3DTransform True if the device supports CSS3DTransform\n         * @type {Boolean}\n         */\n        {\n            identity: 'CSS3DTransform',\n            fn: function() {\n                return (typeof WebKitCSSMatrix != 'undefined' && new WebKitCSSMatrix().hasOwnProperty('m41'));\n            }\n        },\n\n\t\t/**\n         * @property CSS3LinearGradient True if the device supports CSS3 linear gradients\n         * @type {Boolean}\n         */\n        {\n            identity: 'CSS3LinearGradient',\n            fn: function(doc, div) {\n                var property = 'background-image:',\n                    webkit   = '-webkit-gradient(linear, left top, right bottom, from(black), to(white))',\n                    w3c      = 'linear-gradient(left top, black, white)',\n                    moz      = '-moz-' + w3c,\n                    opera    = '-o-' + w3c,\n                    options  = [property + webkit, property + w3c, property + moz, property + opera];\n\n                div.style.cssText = options.join(';');\n\n                return (\"\" + div.style.backgroundImage).indexOf('gradient') !== -1;\n            }\n        },\n\n        /**\n         * @property CSS3BorderRadius True if the device supports CSS3 border radius\n         * @type {Boolean}\n         */\n        {\n            identity: 'CSS3BorderRadius',\n            fn: function(doc, div) {\n                var domPrefixes = ['borderRadius', 'BorderRadius', 'MozBorderRadius', 'WebkitBorderRadius', 'OBorderRadius', 'KhtmlBorderRadius'],\n                    pass = false,\n                    i;\n                for (i = 0; i < domPrefixes.length; i++) {\n                    if (document.body.style[domPrefixes[i]] !== undefined) {\n                        return true;\n                    }\n                }\n                return pass;\n            }\n        },\n\n        /**\n         * @property GeoLocation True if the device supports GeoLocation\n         * @type {Boolean}\n         */\n        {\n            identity: 'GeoLocation',\n            fn: function() {\n                return (typeof navigator != 'undefined' && typeof navigator.geolocation != 'undefined') || (typeof google != 'undefined' && typeof google.gears != 'undefined');\n            }\n        },\n        /**\n         * @property MouseEnterLeave True if the browser supports mouseenter and mouseleave events\n         * @type {Boolean}\n         */\n        {\n            identity: 'MouseEnterLeave',\n            fn: function(doc, div){\n                return ('onmouseenter' in div && 'onmouseleave' in div);\n            }\n        },\n        /**\n         * @property MouseWheel True if the browser supports the mousewheel event\n         * @type {Boolean}\n         */\n        {\n            identity: 'MouseWheel',\n            fn: function(doc, div) {\n                return ('onmousewheel' in div);\n            }\n        },\n        /**\n         * @property Opacity True if the browser supports normal css opacity\n         * @type {Boolean}\n         */\n        {\n            identity: 'Opacity',\n            fn: function(doc, div){\n                // Not a strict equal comparison in case opacity can be converted to a number.\n                if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {\n                    return false;\n                }\n                div.firstChild.style.cssText = 'opacity:0.73';\n                return div.firstChild.style.opacity == '0.73';\n            }\n        },\n        /**\n         * @property Placeholder True if the browser supports the HTML5 placeholder attribute on inputs\n         * @type {Boolean}\n         */\n        {\n            identity: 'Placeholder',\n            fn: function(doc) {\n                return 'placeholder' in doc.createElement('input');\n            }\n        },\n\n        /**\n         * @property Direct2DBug True if when asking for an element's dimension via offsetWidth or offsetHeight,\n         * getBoundingClientRect, etc. the browser returns the subpixel width rounded to the nearest pixel.\n         * @type {Boolean}\n         */\n        {\n            identity: 'Direct2DBug',\n            fn: function() {\n                return Ext.isString(document.body.style.msTransformOrigin);\n            }\n        },\n        /**\n         * @property BoundingClientRect True if the browser supports the getBoundingClientRect method on elements\n         * @type {Boolean}\n         */\n        {\n            identity: 'BoundingClientRect',\n            fn: function(doc, div) {\n                return Ext.isFunction(div.getBoundingClientRect);\n            }\n        },\n        {\n            identity: 'IncludePaddingInWidthCalculation',\n            fn: function(doc, div){\n                return div.childNodes[1].firstChild.offsetWidth == 210;\n            }\n        },\n        {\n            identity: 'IncludePaddingInHeightCalculation',\n            fn: function(doc, div){\n                return div.childNodes[1].firstChild.offsetHeight == 210;\n            }\n        },\n\n        /**\n         * @property ArraySort True if the Array sort native method isn't bugged.\n         * @type {Boolean}\n         */\n        {\n            identity: 'ArraySort',\n            fn: function() {\n                var a = [1,2,3,4,5].sort(function(){ return 0; });\n                return a[0] === 1 && a[1] === 2 && a[2] === 3 && a[3] === 4 && a[4] === 5;\n            }\n        },\n        /**\n         * @property Range True if browser support document.createRange native method.\n         * @type {Boolean}\n         */\n        {\n            identity: 'Range',\n            fn: function() {\n                return !!document.createRange;\n            }\n        },\n        /**\n         * @property CreateContextualFragment True if browser support CreateContextualFragment range native methods.\n         * @type {Boolean}\n         */\n        {\n            identity: 'CreateContextualFragment',\n            fn: function() {\n                var range = Ext.supports.Range ? document.createRange() : false;\n\n                return range && !!range.createContextualFragment;\n            }\n        },\n\n        /**\n         * @property WindowOnError True if browser supports window.onerror.\n         * @type {Boolean}\n         */\n        {\n            identity: 'WindowOnError',\n            fn: function () {\n                // sadly, we cannot feature detect this...\n                return Ext.isIE || Ext.isGecko || Ext.webKitVersion >= 534.16; // Chrome 10+\n            }\n        },\n\n        /**\n         * @property TextAreaMaxLength True if the browser supports maxlength on textareas.\n         * @type {Boolean}\n         */\n        {\n            identity: 'TextAreaMaxLength',\n            fn: function(){\n                var el = document.createElement('textarea');\n                return ('maxlength' in el);\n            }\n        },\n        /**\n         * @property GetPositionPercentage True if the browser will return the left/top/right/bottom\n         * position as a percentage when explicitly set as a percentage value.\n         * @type {Boolean}\n         */\n        // Related bug: https://bugzilla.mozilla.org/show_bug.cgi?id=707691#c7\n        {\n            identity: 'GetPositionPercentage',\n            fn: function(doc, div){\n               return getStyle(div.childNodes[2], 'left') == '10%';\n            }\n        }\n    ]\n};\n}());\n\nExt.supports.init(); // run the \"early\" detections now\n\n//@tag dom,core\n//@require ../Support.js\n//@define Ext.util.DelayedTask\n\n/**\n * @class Ext.util.DelayedTask\n * \n * The DelayedTask class provides a convenient way to \"buffer\" the execution of a method,\n * performing setTimeout where a new timeout cancels the old timeout. When called, the\n * task will wait the specified time period before executing. If durng that time period,\n * the task is called again, the original call will be cancelled. This continues so that\n * the function is only called a single time for each iteration.\n * \n * This method is especially useful for things like detecting whether a user has finished\n * typing in a text field. An example would be performing validation on a keypress. You can\n * use this class to buffer the keypress events for a certain number of milliseconds, and\n * perform only if they stop for that amount of time.  \n * \n * ## Usage\n * \n *     var task = new Ext.util.DelayedTask(function(){\n *         alert(Ext.getDom('myInputField').value.length);\n *     });\n *     \n *     // Wait 500ms before calling our function. If the user presses another key\n *     // during that 500ms, it will be cancelled and we'll wait another 500ms.\n *     Ext.get('myInputField').on('keypress', function(){\n *         task.{@link #delay}(500);\n *     });\n * \n * Note that we are using a DelayedTask here to illustrate a point. The configuration\n * option `buffer` for {@link Ext.util.Observable#addListener addListener/on} will\n * also setup a delayed task for you to buffer events.\n * \n * @constructor The parameters to this constructor serve as defaults and are not required.\n * @param {Function} fn (optional) The default function to call. If not specified here, it must be specified during the {@link #delay} call.\n * @param {Object} scope (optional) The default scope (The <code><b>this</b></code> reference) in which the\n * function is called. If not specified, <code>this</code> will refer to the browser window.\n * @param {Array} args (optional) The default Array of arguments.\n */\nExt.util.DelayedTask = function(fn, scope, args) {\n    var me = this,\n        id,\n        call = function() {\n            clearInterval(id);\n            id = null;\n            fn.apply(scope, args || []);\n        };\n\n    /**\n     * Cancels any pending timeout and queues a new one\n     * @param {Number} delay The milliseconds to delay\n     * @param {Function} newFn (optional) Overrides function passed to constructor\n     * @param {Object} newScope (optional) Overrides scope passed to constructor. Remember that if no scope\n     * is specified, <code>this</code> will refer to the browser window.\n     * @param {Array} newArgs (optional) Overrides args passed to constructor\n     */\n    this.delay = function(delay, newFn, newScope, newArgs) {\n        me.cancel();\n        fn = newFn || fn;\n        scope = newScope || scope;\n        args = newArgs || args;\n        id = setInterval(call, delay);\n    };\n\n    /**\n     * Cancel the last queued timeout\n     */\n    this.cancel = function(){\n        if (id) {\n            clearInterval(id);\n            id = null;\n        }\n    };\n};\n\n//@tag dom,core\n//@define Ext.util.Event\n//@require Ext.util.DelayedTask\n\nExt.require('Ext.util.DelayedTask', function() {\n\n    /**\n     * Represents single event type that an Observable object listens to.\n     * All actual listeners are tracked inside here.  When the event fires,\n     * it calls all the registered listener functions.\n     *\n     * @private\n     */\n    Ext.util.Event = Ext.extend(Object, (function() {\n        var noOptions = {};\n\n        function createTargeted(handler, listener, o, scope){\n            return function(){\n                if (o.target === arguments[0]){\n                    handler.apply(scope, arguments);\n                }\n            };\n        }\n\n        function createBuffered(handler, listener, o, scope) {\n            listener.task = new Ext.util.DelayedTask();\n            return function() {\n                listener.task.delay(o.buffer, handler, scope, Ext.Array.toArray(arguments));\n            };\n        }\n\n        function createDelayed(handler, listener, o, scope) {\n            return function() {\n                var task = new Ext.util.DelayedTask();\n                if (!listener.tasks) {\n                    listener.tasks = [];\n                }\n                listener.tasks.push(task);\n                task.delay(o.delay || 10, handler, scope, Ext.Array.toArray(arguments));\n            };\n        }\n\n        function createSingle(handler, listener, o, scope) {\n            return function() {\n                var event = listener.ev;\n\n                if (event.removeListener(listener.fn, scope) && event.observable) {\n                    // Removing from a regular Observable-owned, named event (not an anonymous\n                    // event such as Ext's readyEvent): Decrement the listeners count\n                    event.observable.hasListeners[event.name]--;\n                }\n\n                return handler.apply(scope, arguments);\n            };\n        }\n\n        return {\n            /**\n             * @property {Boolean} isEvent\n             * `true` in this class to identify an object as an instantiated Event, or subclass thereof.\n             */\n            isEvent: true,\n\n            constructor: function(observable, name) {\n                this.name = name;\n                this.observable = observable;\n                this.listeners = [];\n            },\n\n            addListener: function(fn, scope, options) {\n                var me = this,\n                    listener;\n                    scope = scope || me.observable;\n\n                if (!fn) {\n                    Ext.Error.raise({\n                        sourceClass: Ext.getClassName(this.observable),\n                        sourceMethod: \"addListener\",\n                        msg: \"The specified callback function is undefined\"\n                    });\n                }\n\n                if (!me.isListening(fn, scope)) {\n                    listener = me.createListener(fn, scope, options);\n                    if (me.firing) {\n                        // if we are currently firing this event, don't disturb the listener loop\n                        me.listeners = me.listeners.slice(0);\n                    }\n                    me.listeners.push(listener);\n                }\n            },\n\n            createListener: function(fn, scope, options) {\n                options = options || noOptions;\n                scope = scope || this.observable;\n\n                var listener = {\n                        fn: fn,\n                        scope: scope,\n                        o: options,\n                        ev: this\n                    },\n                    handler = fn;\n\n                // The order is important. The 'single' wrapper must be wrapped by the 'buffer' and 'delayed' wrapper\n                // because the event removal that the single listener does destroys the listener's DelayedTask(s)\n                if (options.single) {\n                    handler = createSingle(handler, listener, options, scope);\n                }\n                if (options.target) {\n                    handler = createTargeted(handler, listener, options, scope);\n                }\n                if (options.delay) {\n                    handler = createDelayed(handler, listener, options, scope);\n                }\n                if (options.buffer) {\n                    handler = createBuffered(handler, listener, options, scope);\n                }\n\n                listener.fireFn = handler;\n                return listener;\n            },\n\n            findListener: function(fn, scope) {\n                var listeners = this.listeners,\n                i = listeners.length,\n                listener,\n                s;\n\n                while (i--) {\n                    listener = listeners[i];\n                    if (listener) {\n                        s = listener.scope;\n\n                        // Compare the listener's scope with *JUST THE PASSED SCOPE* if one is passed, and only fall back to the owning Observable if none is passed.\n                        // We cannot use the test (s == scope || s == this.observable)\n                        // Otherwise, if the Observable itself adds Ext.emptyFn as a listener, and then Ext.emptyFn is added under another scope, there will be a false match.\n                        if (listener.fn == fn && (s == (scope || this.observable))) {\n                            return i;\n                        }\n                    }\n                }\n\n                return - 1;\n            },\n\n            isListening: function(fn, scope) {\n                return this.findListener(fn, scope) !== -1;\n            },\n\n            removeListener: function(fn, scope) {\n                var me = this,\n                    index,\n                    listener,\n                    k;\n                index = me.findListener(fn, scope);\n                if (index != -1) {\n                    listener = me.listeners[index];\n\n                    if (me.firing) {\n                        me.listeners = me.listeners.slice(0);\n                    }\n\n                    // cancel and remove a buffered handler that hasn't fired yet\n                    if (listener.task) {\n                        listener.task.cancel();\n                        delete listener.task;\n                    }\n\n                    // cancel and remove all delayed handlers that haven't fired yet\n                    k = listener.tasks && listener.tasks.length;\n                    if (k) {\n                        while (k--) {\n                            listener.tasks[k].cancel();\n                        }\n                        delete listener.tasks;\n                    }\n\n                    // remove this listener from the listeners array\n                    Ext.Array.erase(me.listeners, index, 1);\n                    return true;\n                }\n\n                return false;\n            },\n\n            // Iterate to stop any buffered/delayed events\n            clearListeners: function() {\n                var listeners = this.listeners,\n                    i = listeners.length;\n\n                while (i--) {\n                    this.removeListener(listeners[i].fn, listeners[i].scope);\n                }\n            },\n\n            fire: function() {\n                var me = this,\n                    listeners = me.listeners,\n                    count = listeners.length,\n                    i,\n                    args,\n                    listener;\n\n                if (count > 0) {\n                    me.firing = true;\n                    for (i = 0; i < count; i++) {\n                        listener = listeners[i];\n                        args = arguments.length ? Array.prototype.slice.call(arguments, 0) : [];\n                        if (listener.o) {\n                            args.push(listener.o);\n                        }\n                        if (listener && listener.fireFn.apply(listener.scope || me.observable, args) === false) {\n                            return (me.firing = false);\n                        }\n                    }\n                }\n                me.firing = false;\n                return true;\n            }\n        };\n    }()));\n});\n\n/**\n * Base class that provides a common interface for publishing events. Subclasses are expected to to have a property\n * \"events\" with all the events defined, and, optionally, a property \"listeners\" with configured listeners defined.\n *\n * For example:\n *\n *     Ext.define('Employee', {\n *         mixins: {\n *             observable: 'Ext.util.Observable'\n *         },\n *\n *         constructor: function (config) {\n *             // The Observable constructor copies all of the properties of `config` on\n *             // to `this` using {@link Ext#apply}. Further, the `listeners` property is\n *             // processed to add listeners.\n *             //\n *             this.mixins.observable.constructor.call(this, config);\n *\n *             this.addEvents(\n *                 'fired',\n *                 'quit'\n *             );\n *         }\n *     });\n *\n * This could then be used like this:\n *\n *     var newEmployee = new Employee({\n *         name: employeeName,\n *         listeners: {\n *             quit: function() {\n *                 // By default, \"this\" will be the object that fired the event.\n *                 alert(this.name + \" has quit!\");\n *             }\n *         }\n *     });\n */\nExt.define('Ext.util.Observable', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.util.Event'],\n\n    statics: {\n        /**\n         * Removes **all** added captures from the Observable.\n         *\n         * @param {Ext.util.Observable} o The Observable to release\n         * @static\n         */\n        releaseCapture: function(o) {\n            o.fireEvent = this.prototype.fireEvent;\n        },\n\n        /**\n         * Starts capture on the specified Observable. All events will be passed to the supplied function with the event\n         * name + standard signature of the event **before** the event is fired. If the supplied function returns false,\n         * the event will not fire.\n         *\n         * @param {Ext.util.Observable} o The Observable to capture events from.\n         * @param {Function} fn The function to call when an event is fired.\n         * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed. Defaults to\n         * the Observable firing the event.\n         * @static\n         */\n        capture: function(o, fn, scope) {\n            o.fireEvent = Ext.Function.createInterceptor(o.fireEvent, fn, scope);\n        },\n\n        /**\n         * Sets observability on the passed class constructor.\n         *\n         * This makes any event fired on any instance of the passed class also fire a single event through\n         * the **class** allowing for central handling of events on many instances at once.\n         *\n         * Usage:\n         *\n         *     Ext.util.Observable.observe(Ext.data.Connection);\n         *     Ext.data.Connection.on('beforerequest', function(con, options) {\n         *         console.log('Ajax request made to ' + options.url);\n         *     });\n         *\n         * @param {Function} c The class constructor to make observable.\n         * @param {Object} listeners An object containing a series of listeners to add. See {@link #addListener}.\n         * @static\n         */\n        observe: function(cls, listeners) {\n            if (cls) {\n                if (!cls.isObservable) {\n                    Ext.applyIf(cls, new this());\n                    this.capture(cls.prototype, cls.fireEvent, cls);\n                }\n                if (Ext.isObject(listeners)) {\n                    cls.on(listeners);\n                }\n            }\n            return cls;\n        },\n\n        /**\n         * Prepares a given class for observable instances. This method is called when a\n         * class derives from this class or uses this class as a mixin.\n         * @param {Function} T The class constructor to prepare.\n         * @private\n         */\n        prepareClass: function (T, mixin) {\n            // T.hasListeners is the object to track listeners on class T. This object's\n            // prototype (__proto__) is the \"hasListeners\" of T.superclass.\n\n            // Instances of T will create \"hasListeners\" that have T.hasListeners as their\n            // immediate prototype (__proto__).\n\n            if (!T.HasListeners) {\n                // We create a HasListeners \"class\" for this class. The \"prototype\" of the\n                // HasListeners class is an instance of the HasListeners class associated\n                // with this class's super class (or with Observable).\n                var Observable = Ext.util.Observable,\n                    HasListeners = function () {},\n                    SuperHL = T.superclass.HasListeners || (mixin && mixin.HasListeners) ||\n                              Observable.HasListeners;\n\n                // Make the HasListener class available on the class and its prototype:\n                T.prototype.HasListeners = T.HasListeners = HasListeners;\n\n                // And connect its \"prototype\" to the new HasListeners of our super class\n                // (which is also the class-level \"hasListeners\" instance).\n                HasListeners.prototype = T.hasListeners = new SuperHL();\n            }\n        }\n    },\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Object} listeners\n     *\n     * A config object containing one or more event handlers to be added to this object during initialization. This\n     * should be a valid listeners config object as specified in the {@link #addListener} example for attaching multiple\n     * handlers at once.\n     *\n     * **DOM events from Ext JS {@link Ext.Component Components}**\n     *\n     * While _some_ Ext JS Component classes export selected DOM events (e.g. \"click\", \"mouseover\" etc), this is usually\n     * only done when extra value can be added. For example the {@link Ext.view.View DataView}'s **`{@link\n     * Ext.view.View#itemclick itemclick}`** event passing the node clicked on. To access DOM events directly from a\n     * child element of a Component, we need to specify the `element` option to identify the Component property to add a\n     * DOM listener to:\n     *\n     *     new Ext.panel.Panel({\n     *         width: 400,\n     *         height: 200,\n     *         dockedItems: [{\n     *             xtype: 'toolbar'\n     *         }],\n     *         listeners: {\n     *             click: {\n     *                 element: 'el', //bind to the underlying el property on the panel\n     *                 fn: function(){ console.log('click el'); }\n     *             },\n     *             dblclick: {\n     *                 element: 'body', //bind to the underlying body property on the panel\n     *                 fn: function(){ console.log('dblclick body'); }\n     *             }\n     *         }\n     *     });\n     */\n\n    /**\n     * @property {Boolean} isObservable\n     * `true` in this class to identify an object as an instantiated Observable, or subclass thereof.\n     */\n    isObservable: true,\n\n    /**\n     * @private\n     * Initial suspended call count. Incremented when {@link #suspendEvents} is called, decremented when {@link #resumeEvents} is called.\n     */\n    eventsSuspended: 0,\n\n    /**\n     * @property {Object} hasListeners\n     * @readonly\n     * This object holds a key for any event that has a listener. The listener may be set\n     * directly on the instance, or on its class or a super class (via {@link #observe}) or\n     * on the {@link Ext.app.EventBus MVC EventBus}. The values of this object are truthy\n     * (a non-zero number) and falsy (0 or undefined). They do not represent an exact count\n     * of listeners. The value for an event is truthy if the event must be fired and is\n     * falsy if there is no need to fire the event.\n     * \n     * The intended use of this property is to avoid the expense of fireEvent calls when\n     * there are no listeners. This can be particularly helpful when one would otherwise\n     * have to call fireEvent hundreds or thousands of times. It is used like this:\n     * \n     *      if (this.hasListeners.foo) {\n     *          this.fireEvent('foo', this, arg1);\n     *      }\n     */\n\n    constructor: function(config) {\n        var me = this;\n\n        Ext.apply(me, config);\n\n        // The subclass may have already initialized it.\n        if (!me.hasListeners) {\n            me.hasListeners = new me.HasListeners();\n        }\n\n        me.events = me.events || {};\n        if (me.listeners) {\n            me.on(me.listeners);\n            me.listeners = null; //Set as an instance property to pre-empt the prototype in case any are set there.\n        }\n\n        if (me.bubbleEvents) {\n            me.enableBubble(me.bubbleEvents);\n        }\n    },\n\n    onClassExtended: function (T) {\n        if (!T.HasListeners) {\n            // Some classes derive from us and some others derive from those classes. All\n            // of these are passed to this method.\n            Ext.util.Observable.prepareClass(T);\n        }\n    },\n\n    // @private\n    eventOptionsRe : /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|element|vertical|horizontal|freezeEvent)$/,\n\n    /**\n     * Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is\n     * destroyed.\n     *\n     * @param {Ext.util.Observable/Ext.Element} item The item to which to add a listener/listeners.\n     * @param {Object/String} ename The event name, or an object containing event name properties.\n     * @param {Function} fn (optional) If the `ename` parameter was an event name, this is the handler function.\n     * @param {Object} scope (optional) If the `ename` parameter was an event name, this is the scope (`this` reference)\n     * in which the handler function is executed.\n     * @param {Object} opt (optional) If the `ename` parameter was an event name, this is the\n     * {@link Ext.util.Observable#addListener addListener} options.\n     */\n    addManagedListener : function(item, ename, fn, scope, options) {\n        var me = this,\n            managedListeners = me.managedListeners = me.managedListeners || [],\n            config;\n\n        if (typeof ename !== 'string') {\n            options = ename;\n            for (ename in options) {\n                if (options.hasOwnProperty(ename)) {\n                    config = options[ename];\n                    if (!me.eventOptionsRe.test(ename)) {\n                        me.addManagedListener(item, ename, config.fn || config, config.scope || options.scope, config.fn ? config : options);\n                    }\n                }\n            }\n        }\n        else {\n            managedListeners.push({\n                item: item,\n                ename: ename,\n                fn: fn,\n                scope: scope,\n                options: options\n            });\n\n            item.on(ename, fn, scope, options);\n        }\n    },\n\n    /**\n     * Removes listeners that were added by the {@link #mon} method.\n     *\n     * @param {Ext.util.Observable/Ext.Element} item The item from which to remove a listener/listeners.\n     * @param {Object/String} ename The event name, or an object containing event name properties.\n     * @param {Function} fn (optional) If the `ename` parameter was an event name, this is the handler function.\n     * @param {Object} scope (optional) If the `ename` parameter was an event name, this is the scope (`this` reference)\n     * in which the handler function is executed.\n     */\n    removeManagedListener : function(item, ename, fn, scope) {\n        var me = this,\n            options,\n            config,\n            managedListeners,\n            length,\n            i;\n\n        if (typeof ename !== 'string') {\n            options = ename;\n            for (ename in options) {\n                if (options.hasOwnProperty(ename)) {\n                    config = options[ename];\n                    if (!me.eventOptionsRe.test(ename)) {\n                        me.removeManagedListener(item, ename, config.fn || config, config.scope || options.scope);\n                    }\n                }\n            }\n        }\n\n        managedListeners = me.managedListeners ? me.managedListeners.slice() : [];\n\n        for (i = 0, length = managedListeners.length; i < length; i++) {\n            me.removeManagedListenerItem(false, managedListeners[i], item, ename, fn, scope);\n        }\n    },\n\n    /**\n     * Fires the specified event with the passed parameters (minus the event name, plus the `options` object passed\n     * to {@link #addListener}).\n     *\n     * An event may be set to bubble up an Observable parent hierarchy (See {@link Ext.Component#getBubbleTarget}) by\n     * calling {@link #enableBubble}.\n     *\n     * @param {String} eventName The name of the event to fire.\n     * @param {Object...} args Variable number of parameters are passed to handlers.\n     * @return {Boolean} returns false if any of the handlers return false otherwise it returns true.\n     */\n    fireEvent: function(eventName) {\n        eventName = eventName.toLowerCase();\n        var me = this,\n            events = me.events,\n            event = events && events[eventName],\n            ret = true;\n\n        // Only continue firing the event if there are listeners to be informed.\n        // Bubbled events will always have a listener count, so will be fired.\n        if (event && me.hasListeners[eventName]) {\n            ret = me.continueFireEvent(eventName, Ext.Array.slice(arguments, 1), event.bubble);\n        }\n        return ret;\n    },\n\n    /**\n     * Continue to fire event.\n     * @private\n     *\n     * @param {String} eventName\n     * @param {Array} args\n     * @param {Boolean} bubbles\n     */\n    continueFireEvent: function(eventName, args, bubbles) {\n        var target = this,\n            queue, event,\n            ret = true;\n\n        do {\n            if (target.eventsSuspended) {\n                if ((queue = target.eventQueue)) {\n                    queue.push([eventName, args, bubbles]);\n                }\n                return ret;\n            } else {\n                event = target.events[eventName];\n                // Continue bubbling if event exists and it is `true` or the handler didn't returns false and it\n                // configure to bubble.\n                if (event && event != true) {\n                    if ((ret = event.fire.apply(event, args)) === false) {\n                        break;\n                    }\n                }\n            }\n        } while (bubbles && (target = target.getBubbleParent()));\n        return ret;\n    },\n\n    /**\n     * Gets the bubbling parent for an Observable\n     * @private\n     * @return {Ext.util.Observable} The bubble parent. null is returned if no bubble target exists\n     */\n    getBubbleParent: function(){\n        var me = this, parent = me.getBubbleTarget && me.getBubbleTarget();\n        if (parent && parent.isObservable) {\n            return parent;\n        }\n        return null;\n    },\n\n    /**\n     * Appends an event handler to this object.  For example:\n     *\n     *     myGridPanel.on(\"mouseover\", this.onMouseOver, this);\n     *\n     * The method also allows for a single argument to be passed which is a config object\n     * containing properties which specify multiple events. For example:\n     *\n     *     myGridPanel.on({\n     *         cellClick: this.onCellClick,\n     *         mouseover: this.onMouseOver,\n     *         mouseout: this.onMouseOut,\n     *         scope: this // Important. Ensure \"this\" is correct during handler execution\n     *     });\n     *\n     * One can also specify options for each event handler separately:\n     *\n     *     myGridPanel.on({\n     *         cellClick: {fn: this.onCellClick, scope: this, single: true},\n     *         mouseover: {fn: panel.onMouseOver, scope: panel}\n     *     });\n     *\n     * *Names* of methods in a specified scope may also be used. Note that\n     * `scope` MUST be specified to use this option:\n     *\n     *     myGridPanel.on({\n     *         cellClick: {fn: 'onCellClick', scope: this, single: true},\n     *         mouseover: {fn: 'onMouseOver', scope: panel}\n     *     });\n     *\n     * @param {String/Object} eventName The name of the event to listen for.\n     * May also be an object who's property names are event names.\n     *\n     * @param {Function} [fn] The method the event invokes, or *if `scope` is specified, the *name* of the method within\n     * the specified `scope`.  Will be called with arguments\n     * given to {@link #fireEvent} plus the `options` parameter described below.\n     *\n     * @param {Object} [scope] The scope (`this` reference) in which the handler function is\n     * executed. **If omitted, defaults to the object which fired the event.**\n     *\n     * @param {Object} [options] An object containing handler configuration.\n     *\n     * **Note:** Unlike in ExtJS 3.x, the options object will also be passed as the last\n     * argument to every event handler.\n     *\n     * This object may contain any of the following properties:\n     *\n     * @param {Object} options.scope\n     *   The scope (`this` reference) in which the handler function is executed. **If omitted,\n     *   defaults to the object which fired the event.**\n     *\n     * @param {Number} options.delay\n     *   The number of milliseconds to delay the invocation of the handler after the event fires.\n     *\n     * @param {Boolean} options.single\n     *   True to add a handler to handle just the next firing of the event, and then remove itself.\n     *\n     * @param {Number} options.buffer\n     *   Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed\n     *   by the specified number of milliseconds. If the event fires again within that time,\n     *   the original handler is _not_ invoked, but the new handler is scheduled in its place.\n     *\n     * @param {Ext.util.Observable} options.target\n     *   Only call the handler if the event was fired on the target Observable, _not_ if the event\n     *   was bubbled up from a child Observable.\n     *\n     * @param {String} options.element\n     *   **This option is only valid for listeners bound to {@link Ext.Component Components}.**\n     *   The name of a Component property which references an element to add a listener to.\n     *\n     *   This option is useful during Component construction to add DOM event listeners to elements of\n     *   {@link Ext.Component Components} which will exist only after the Component is rendered.\n     *   For example, to add a click listener to a Panel's body:\n     *\n     *       new Ext.panel.Panel({\n     *           title: 'The title',\n     *           listeners: {\n     *               click: this.handlePanelClick,\n     *               element: 'body'\n     *           }\n     *       });\n     *\n     * **Combining Options**\n     *\n     * Using the options argument, it is possible to combine different types of listeners:\n     *\n     * A delayed, one-time listener.\n     *\n     *     myPanel.on('hide', this.handleClick, this, {\n     *         single: true,\n     *         delay: 100\n     *     });\n     *\n     */\n    addListener: function(ename, fn, scope, options) {\n        var me = this,\n            config, event, hasListeners,\n            prevListenerCount = 0;\n\n        if (typeof ename !== 'string') {\n            options = ename;\n            for (ename in options) {\n                if (options.hasOwnProperty(ename)) {\n                    config = options[ename];\n                    if (!me.eventOptionsRe.test(ename)) {\n                        me.addListener(ename, config.fn || config, config.scope || options.scope, config.fn ? config : options);\n                    }\n                }\n            }\n        } else {\n            ename = ename.toLowerCase();\n            event = me.events[ename];\n            if (event && event.isEvent) {\n                prevListenerCount = event.listeners.length;\n            } else {\n                me.events[ename] = event = new Ext.util.Event(me, ename);\n            }\n\n            // Allow listeners: { click: 'onClick', scope: myObject }\n            if (typeof fn === 'string') {\n                if (!(scope[fn] || me[fn])) {\n                    Ext.Error.raise('No method named \"' + fn + '\"');\n                }\n                fn = scope[fn] || me[fn];\n            }\n            event.addListener(fn, scope, options);\n\n            // If a new listener has been added (Event.addListener rejects duplicates of the same fn+scope)\n            // then increment the hasListeners counter\n            if (event.listeners.length !== prevListenerCount) {\n                hasListeners = me.hasListeners;\n                if (hasListeners.hasOwnProperty(ename)) {\n                    // if we already have listeners at this level, just increment the count...\n                    ++hasListeners[ename];\n                } else {\n                    // otherwise, start the count at 1 (which hides whatever is in our prototype\n                    // chain)...\n                    hasListeners[ename] = 1;\n                }\n            }\n        }\n    },\n\n    /**\n     * Removes an event handler.\n     *\n     * @param {String} eventName The type of event the handler was associated with.\n     * @param {Function} fn The handler to remove. **This must be a reference to the function passed into the\n     * {@link #addListener} call.**\n     * @param {Object} scope (optional) The scope originally specified for the handler. It must be the same as the\n     * scope argument specified in the original call to {@link #addListener} or the listener will not be removed.\n     */\n    removeListener: function(ename, fn, scope) {\n        var me = this,\n            config,\n            event,\n            options;\n\n        if (typeof ename !== 'string') {\n            options = ename;\n            for (ename in options) {\n                if (options.hasOwnProperty(ename)) {\n                    config = options[ename];\n                    if (!me.eventOptionsRe.test(ename)) {\n                        me.removeListener(ename, config.fn || config, config.scope || options.scope);\n                    }\n                }\n            }\n        } else {\n            ename = ename.toLowerCase();\n            event = me.events[ename];\n            if (event && event.isEvent) {\n                if (event.removeListener(fn, scope) && !--me.hasListeners[ename]) {\n                    // Delete this entry, since 0 does not mean no one is listening, just\n                    // that no one is *directly& listening. This allows the eventBus or\n                    // class observers to \"poke\" through and expose their presence.\n                    delete me.hasListeners[ename];\n                }\n            }\n        }\n    },\n\n    /**\n     * Removes all listeners for this object including the managed listeners\n     */\n    clearListeners: function() {\n        var events = this.events,\n            event,\n            key;\n\n        for (key in events) {\n            if (events.hasOwnProperty(key)) {\n                event = events[key];\n                if (event.isEvent) {\n                    event.clearListeners();\n                }\n            }\n        }\n\n        this.clearManagedListeners();\n    },\n\n    purgeListeners : function() {\n        if (Ext.global.console) {\n            Ext.global.console.warn('Observable: purgeListeners has been deprecated. Please use clearListeners.');\n        }\n        return this.clearListeners.apply(this, arguments);\n    },\n\n    /**\n     * Removes all managed listeners for this object.\n     */\n    clearManagedListeners : function() {\n        var managedListeners = this.managedListeners || [],\n            i = 0,\n            len = managedListeners.length;\n\n        for (; i < len; i++) {\n            this.removeManagedListenerItem(true, managedListeners[i]);\n        }\n\n        this.managedListeners = [];\n    },\n\n    /**\n     * Remove a single managed listener item\n     * @private\n     * @param {Boolean} isClear True if this is being called during a clear\n     * @param {Object} managedListener The managed listener item\n     * See removeManagedListener for other args\n     */\n    removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope){\n        if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) {\n            managedListener.item.un(managedListener.ename, managedListener.fn, managedListener.scope);\n            if (!isClear) {\n                Ext.Array.remove(this.managedListeners, managedListener);\n            }\n        }\n    },\n\n    purgeManagedListeners : function() {\n        if (Ext.global.console) {\n            Ext.global.console.warn('Observable: purgeManagedListeners has been deprecated. Please use clearManagedListeners.');\n        }\n        return this.clearManagedListeners.apply(this, arguments);\n    },\n\n    /**\n     * Adds the specified events to the list of events which this Observable may fire.\n     *\n     * @param {Object/String...} eventNames Either an object with event names as properties with\n     * a value of `true`. For example:\n     *\n     *     this.addEvents({\n     *         storeloaded: true,\n     *         storecleared: true\n     *     });\n     *\n     * Or any number of event names as separate parameters. For example:\n     *\n     *     this.addEvents('storeloaded', 'storecleared');\n     *\n     */\n    addEvents: function(o) {\n        var me = this,\n            events = me.events || (me.events = {}),\n            arg, args, i;\n\n        if (typeof o == 'string') {\n            for (args = arguments, i = args.length; i--; ) {\n                arg = args[i];\n                if (!events[arg]) {\n                    events[arg] = true;\n                }\n            }\n        } else {\n            Ext.applyIf(me.events, o);\n        }\n    },\n\n    /**\n     * Checks to see if this object has any listeners for a specified event, or whether the event bubbles. The answer\n     * indicates whether the event needs firing or not.\n     *\n     * @param {String} eventName The name of the event to check for\n     * @return {Boolean} `true` if the event is being listened for or bubbles, else `false`\n     */\n    hasListener: function(ename) {\n        return !!this.hasListeners[ename.toLowerCase()];\n    },\n\n    /**\n     * Suspends the firing of all events. (see {@link #resumeEvents})\n     *\n     * @param {Boolean} queueSuspended Pass as true to queue up suspended events to be fired\n     * after the {@link #resumeEvents} call instead of discarding all suspended events.\n     */\n    suspendEvents: function(queueSuspended) {\n        this.eventsSuspended += 1;\n        if (queueSuspended && !this.eventQueue) {\n            this.eventQueue = [];\n        }\n    },\n\n    /**\n     * Resumes firing events (see {@link #suspendEvents}).\n     *\n     * If events were suspended using the `queueSuspended` parameter, then all events fired\n     * during event suspension will be sent to any listeners now.\n     */\n    resumeEvents: function() {\n        var me = this,\n            queued = me.eventQueue,\n            qLen, q;\n\n        if (me.eventsSuspended && ! --me.eventsSuspended) {\n            delete me.eventQueue;\n\n            if (queued) {\n                qLen = queued.length;\n                for (q = 0; q < qLen; q++) {\n                    me.continueFireEvent.apply(me, queued[q]);\n                }\n            }\n        }\n    },\n\n    /**\n     * Relays selected events from the specified Observable as if the events were fired by `this`.\n     *\n     * For example if you are extending Grid, you might decide to forward some events from store.\n     * So you can do this inside your initComponent:\n     *\n     *     this.relayEvents(this.getStore(), ['load']);\n     *\n     * The grid instance will then have an observable 'load' event which will be passed the\n     * parameters of the store's load event and any function fired with the grid's load event\n     * would have access to the grid using the `this` keyword.\n     *\n     * @param {Object} origin The Observable whose events this object is to relay.\n     * @param {String[]} events Array of event names to relay.\n     * @param {String} [prefix] A common prefix to prepend to the event names. For example:\n     *\n     *     this.relayEvents(this.getStore(), ['load', 'clear'], 'store');\n     *\n     * Now the grid will forward 'load' and 'clear' events of store as 'storeload' and 'storeclear'.\n     */\n    relayEvents : function(origin, events, prefix) {\n        var me = this,\n            len = events.length,\n            i = 0,\n            oldName,\n            newName;\n\n        for (; i < len; i++) {\n            oldName = events[i];\n            newName = prefix ? prefix + oldName : oldName;\n\n            // Add the relaying function as a ManagedListener so that it is removed when this.clearListeners is called (usually when _this_ is destroyed)\n            me.mon(origin, oldName, me.createRelayer(newName));\n        }\n    },\n\n    /**\n     * @private\n     * Creates an event handling function which refires the event from this object as the passed event name.\n     * @param newName\n     * @param {Array} beginEnd (optional) The caller can specify on which indices to slice\n     * @returns {Function}\n     */\n    createRelayer: function(newName, beginEnd){\n        var me = this;\n        return function() {\n            return me.fireEvent.apply(me, [newName].concat(Array.prototype.slice.apply(arguments, beginEnd || [0, -1])));\n        };\n    },\n\n    /**\n     * Enables events fired by this Observable to bubble up an owner hierarchy by calling `this.getBubbleTarget()` if\n     * present. There is no implementation in the Observable base class.\n     *\n     * This is commonly used by Ext.Components to bubble events to owner Containers.\n     * See {@link Ext.Component#getBubbleTarget}. The default implementation in Ext.Component returns the\n     * Component's immediate owner. But if a known target is required, this can be overridden to access the\n     * required target more quickly.\n     *\n     * Example:\n     *\n     *     Ext.override(Ext.form.field.Base, {\n     *         //  Add functionality to Field's initComponent to enable the change event to bubble\n     *         initComponent : Ext.Function.createSequence(Ext.form.field.Base.prototype.initComponent, function() {\n     *             this.enableBubble('change');\n     *         }),\n     *\n     *         //  We know that we want Field's events to bubble directly to the FormPanel.\n     *         getBubbleTarget : function() {\n     *             if (!this.formPanel) {\n     *                 this.formPanel = this.findParentByType('form');\n     *             }\n     *             return this.formPanel;\n     *         }\n     *     });\n     *\n     *     var myForm = new Ext.formPanel({\n     *         title: 'User Details',\n     *         items: [{\n     *             ...\n     *         }],\n     *         listeners: {\n     *             change: function() {\n     *                 // Title goes red if form has been modified.\n     *                 myForm.header.setStyle('color', 'red');\n     *             }\n     *         }\n     *     });\n     *\n     * @param {String/String[]} eventNames The event name to bubble, or an Array of event names.\n     */\n    enableBubble: function(eventNames) {\n        if (eventNames) {\n            var me = this,\n                names = (typeof eventNames == 'string') ? arguments : eventNames,\n                length = names.length,\n                events = me.events,\n                ename, event, i;\n\n            for (i = 0; i < length; ++i) {\n                ename = names[i].toLowerCase();\n                event = events[ename];\n\n                if (!event || typeof event == 'boolean') {\n                    events[ename] = event = new Ext.util.Event(me, ename);\n                }\n\n                // Event must fire if it bubbles (We don't know if anyone up the bubble hierarchy has listeners added)\n                me.hasListeners[ename] = (me.hasListeners[ename]||0) + 1;\n\n                event.bubble = true;\n            }\n        }\n    }\n}, function() {\n    var Observable = this,\n        proto = Observable.prototype,\n        HasListeners = function () {},\n        prepareMixin = function (T) {\n            if (!T.HasListeners) {\n                var proto = T.prototype;\n\n                // Classes that use us as a mixin (best practice) need to be prepared.\n                Observable.prepareClass(T, this);\n\n                // Now that we are mixed in to class T, we need to watch T for derivations\n                // and prepare them also.\n                T.onExtended(function (U) {\n                    Observable.prepareClass(U);\n                });\n\n                // Also, if a class uses us as a mixin and that class is then used as\n                // a mixin, we need to be notified of that as well.\n                if (proto.onClassMixedIn) {\n                    // play nice with other potential overrides...\n                    Ext.override(T, {\n                        onClassMixedIn: function (U) {\n                            prepareMixin.call(this, U);\n                            this.callParent(arguments);\n                        }\n                    });\n                } else {\n                    // just us chickens, so add the method...\n                    proto.onClassMixedIn = function (U) {\n                        prepareMixin.call(this, U);\n                    };\n                }\n            }\n        };\n\n    HasListeners.prototype = {\n        //$$: 42  // to make sure we have a proper prototype\n    };\n\n    proto.HasListeners = Observable.HasListeners = HasListeners;\n\n    Observable.createAlias({\n        /**\n         * @method\n         * Shorthand for {@link #addListener}.\n         * @inheritdoc Ext.util.Observable#addListener\n         */\n        on: 'addListener',\n        /**\n         * @method\n         * Shorthand for {@link #removeListener}.\n         * @inheritdoc Ext.util.Observable#removeListener\n         */\n        un: 'removeListener',\n        /**\n         * @method\n         * Shorthand for {@link #addManagedListener}.\n         * @inheritdoc Ext.util.Observable#addManagedListener\n         */\n        mon: 'addManagedListener',\n        /**\n         * @method\n         * Shorthand for {@link #removeManagedListener}.\n         * @inheritdoc Ext.util.Observable#removeManagedListener\n         */\n        mun: 'removeManagedListener'\n    });\n\n    //deprecated, will be removed in 5.0\n    Observable.observeClass = Observable.observe;\n\n    // this is considered experimental (along with beforeMethod, afterMethod, removeMethodListener?)\n    // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call\n    // private\n    function getMethodEvent(method){\n        var e = (this.methodEvents = this.methodEvents || {})[method],\n            returnValue,\n            v,\n            cancel,\n            obj = this,\n            makeCall;\n\n        if (!e) {\n            this.methodEvents[method] = e = {};\n            e.originalFn = this[method];\n            e.methodName = method;\n            e.before = [];\n            e.after = [];\n\n            makeCall = function(fn, scope, args){\n                if((v = fn.apply(scope || obj, args)) !== undefined){\n                    if (typeof v == 'object') {\n                        if(v.returnValue !== undefined){\n                            returnValue = v.returnValue;\n                        }else{\n                            returnValue = v;\n                        }\n                        cancel = !!v.cancel;\n                    }\n                    else\n                        if (v === false) {\n                            cancel = true;\n                        }\n                        else {\n                            returnValue = v;\n                        }\n                }\n            };\n\n            this[method] = function(){\n                var args = Array.prototype.slice.call(arguments, 0),\n                    b, i, len;\n                returnValue = v = undefined;\n                cancel = false;\n\n                for(i = 0, len = e.before.length; i < len; i++){\n                    b = e.before[i];\n                    makeCall(b.fn, b.scope, args);\n                    if (cancel) {\n                        return returnValue;\n                    }\n                }\n\n                if((v = e.originalFn.apply(obj, args)) !== undefined){\n                    returnValue = v;\n                }\n\n                for(i = 0, len = e.after.length; i < len; i++){\n                    b = e.after[i];\n                    makeCall(b.fn, b.scope, args);\n                    if (cancel) {\n                        return returnValue;\n                    }\n                }\n                return returnValue;\n            };\n        }\n        return e;\n    }\n\n    Ext.apply(proto, {\n        onClassMixedIn: prepareMixin,\n\n        // these are considered experimental\n        // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call\n        // adds an 'interceptor' called before the original method\n        beforeMethod : function(method, fn, scope){\n            getMethodEvent.call(this, method).before.push({\n                fn: fn,\n                scope: scope\n            });\n        },\n\n        // adds a 'sequence' called after the original method\n        afterMethod : function(method, fn, scope){\n            getMethodEvent.call(this, method).after.push({\n                fn: fn,\n                scope: scope\n            });\n        },\n\n        removeMethodListener: function(method, fn, scope){\n            var e = this.getMethodEvent(method),\n                i, len;\n            for(i = 0, len = e.before.length; i < len; i++){\n                if(e.before[i].fn == fn && e.before[i].scope == scope){\n                    Ext.Array.erase(e.before, i, 1);\n                    return;\n                }\n            }\n            for(i = 0, len = e.after.length; i < len; i++){\n                if(e.after[i].fn == fn && e.after[i].scope == scope){\n                    Ext.Array.erase(e.after, i, 1);\n                    return;\n                }\n            }\n        },\n\n        toggleEventLogging: function(toggle) {\n            Ext.util.Observable[toggle ? 'capture' : 'releaseCapture'](this, function(en) {\n                if (Ext.isDefined(Ext.global.console)) {\n                    Ext.global.console.log(en, arguments);\n                }\n            });\n        }\n    });\n});\n\n/**\n * @class Ext.util.HashMap\n * <p>\n * Represents a collection of a set of key and value pairs. Each key in the HashMap\n * must be unique, the same key cannot exist twice. Access to items is provided via\n * the key only. Sample usage:\n * <pre><code>\nvar map = new Ext.util.HashMap();\nmap.add('key1', 1);\nmap.add('key2', 2);\nmap.add('key3', 3);\n\nmap.each(function(key, value, length){\n    console.log(key, value, length);\n});\n * </code></pre>\n * </p>\n *\n * <p>The HashMap is an unordered class,\n * there is no guarantee when iterating over the items that they will be in any particular\n * order. If this is required, then use a {@link Ext.util.MixedCollection}.\n * </p>\n */\nExt.define('Ext.util.HashMap', {\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @cfg {Function} keyFn A function that is used to retrieve a default key for a passed object.\n     * A default is provided that returns the <b>id</b> property on the object. This function is only used\n     * if the add method is called with a single argument.\n     */\n\n    /**\n     * Creates new HashMap.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        config = config || {};\n\n        var me = this,\n            keyFn = config.keyFn;\n\n        me.addEvents(\n            /**\n             * @event add\n             * Fires when a new item is added to the hash\n             * @param {Ext.util.HashMap} this.\n             * @param {String} key The key of the added item.\n             * @param {Object} value The value of the added item.\n             */\n            'add',\n            /**\n             * @event clear\n             * Fires when the hash is cleared.\n             * @param {Ext.util.HashMap} this.\n             */\n            'clear',\n            /**\n             * @event remove\n             * Fires when an item is removed from the hash.\n             * @param {Ext.util.HashMap} this.\n             * @param {String} key The key of the removed item.\n             * @param {Object} value The value of the removed item.\n             */\n            'remove',\n            /**\n             * @event replace\n             * Fires when an item is replaced in the hash.\n             * @param {Ext.util.HashMap} this.\n             * @param {String} key The key of the replaced item.\n             * @param {Object} value The new value for the item.\n             * @param {Object} old The old value for the item.\n             */\n            'replace'\n        );\n\n        me.mixins.observable.constructor.call(me, config);\n        me.clear(true);\n\n        if (keyFn) {\n            me.getKey = keyFn;\n        }\n    },\n\n    /**\n     * Gets the number of items in the hash.\n     * @return {Number} The number of items in the hash.\n     */\n    getCount: function() {\n        return this.length;\n    },\n\n    /**\n     * Implementation for being able to extract the key from an object if only\n     * a single argument is passed.\n     * @private\n     * @param {String} key The key\n     * @param {Object} value The value\n     * @return {Array} [key, value]\n     */\n    getData: function(key, value) {\n        // if we have no value, it means we need to get the key from the object\n        if (value === undefined) {\n            value = key;\n            key = this.getKey(value);\n        }\n\n        return [key, value];\n    },\n\n    /**\n     * Extracts the key from an object. This is a default implementation, it may be overridden\n     * @param {Object} o The object to get the key from\n     * @return {String} The key to use.\n     */\n    getKey: function(o) {\n        return o.id;\n    },\n\n    /**\n     * Adds an item to the collection. Fires the {@link #event-add} event when complete.\n     *\n     * @param {String/Object} key The key to associate with the item, or the new item.\n     *\n     * If a {@link #getKey} implementation was specified for this HashMap,\n     * or if the key of the stored items is in a property called `id`,\n     * the HashMap will be able to *derive* the key for the new item.\n     * In this case just pass the new item in this parameter.\n     *\n     * @param {Object} [o] The item to add.\n     *\n     * @return {Object} The item added.\n     */\n    add: function(key, value) {\n        var me = this;\n\n        if (value === undefined) {\n            value = key;\n            key = me.getKey(value);\n        }\n\n        if (me.containsKey(key)) {\n            return me.replace(key, value);\n        }\n\n        me.map[key] = value;\n        ++me.length;\n        if (me.hasListeners.add) {\n            me.fireEvent('add', me, key, value);\n        }\n        return value;\n    },\n\n    /**\n     * Replaces an item in the hash. If the key doesn't exist, the\n     * {@link #method-add} method will be used.\n     * @param {String} key The key of the item.\n     * @param {Object} value The new value for the item.\n     * @return {Object} The new value of the item.\n     */\n    replace: function(key, value) {\n        var me = this,\n            map = me.map,\n            old;\n\n        if (value === undefined) {\n            value = key;\n            key = me.getKey(value);\n        }\n\n        if (!me.containsKey(key)) {\n            me.add(key, value);\n        }\n        old = map[key];\n        map[key] = value;\n        if (me.hasListeners.replace) {\n            me.fireEvent('replace', me, key, value, old);\n        }\n        return value;\n    },\n\n    /**\n     * Remove an item from the hash.\n     * @param {Object} o The value of the item to remove.\n     * @return {Boolean} True if the item was successfully removed.\n     */\n    remove: function(o) {\n        var key = this.findKey(o);\n        if (key !== undefined) {\n            return this.removeAtKey(key);\n        }\n        return false;\n    },\n\n    /**\n     * Remove an item from the hash.\n     * @param {String} key The key to remove.\n     * @return {Boolean} True if the item was successfully removed.\n     */\n    removeAtKey: function(key) {\n        var me = this,\n            value;\n\n        if (me.containsKey(key)) {\n            value = me.map[key];\n            delete me.map[key];\n            --me.length;\n            if (me.hasListeners.remove) {\n                me.fireEvent('remove', me, key, value);\n            }\n            return true;\n        }\n        return false;\n    },\n\n    /**\n     * Retrieves an item with a particular key.\n     * @param {String} key The key to lookup.\n     * @return {Object} The value at that key. If it doesn't exist, <tt>undefined</tt> is returned.\n     */\n    get: function(key) {\n        return this.map[key];\n    },\n\n    /**\n     * Removes all items from the hash.\n     * @return {Ext.util.HashMap} this\n     */\n    clear: function(/* private */ initial) {\n        var me = this;\n        me.map = {};\n        me.length = 0;\n        if (initial !== true && me.hasListeners.clear) {\n            me.fireEvent('clear', me);\n        }\n        return me;\n    },\n\n    /**\n     * Checks whether a key exists in the hash.\n     * @param {String} key The key to check for.\n     * @return {Boolean} True if they key exists in the hash.\n     */\n    containsKey: function(key) {\n        return this.map[key] !== undefined;\n    },\n\n    /**\n     * Checks whether a value exists in the hash.\n     * @param {Object} value The value to check for.\n     * @return {Boolean} True if the value exists in the dictionary.\n     */\n    contains: function(value) {\n        return this.containsKey(this.findKey(value));\n    },\n\n    /**\n     * Return all of the keys in the hash.\n     * @return {Array} An array of keys.\n     */\n    getKeys: function() {\n        return this.getArray(true);\n    },\n\n    /**\n     * Return all of the values in the hash.\n     * @return {Array} An array of values.\n     */\n    getValues: function() {\n        return this.getArray(false);\n    },\n\n    /**\n     * Gets either the keys/values in an array from the hash.\n     * @private\n     * @param {Boolean} isKey True to extract the keys, otherwise, the value\n     * @return {Array} An array of either keys/values from the hash.\n     */\n    getArray: function(isKey) {\n        var arr = [],\n            key,\n            map = this.map;\n        for (key in map) {\n            if (map.hasOwnProperty(key)) {\n                arr.push(isKey ? key: map[key]);\n            }\n        }\n        return arr;\n    },\n\n    /**\n     * Executes the specified function once for each item in the hash.\n     * Returning false from the function will cease iteration.\n     *\n     * The paramaters passed to the function are:\n     * <div class=\"mdetail-params\"><ul>\n     * <li><b>key</b> : String<p class=\"sub-desc\">The key of the item</p></li>\n     * <li><b>value</b> : Number<p class=\"sub-desc\">The value of the item</p></li>\n     * <li><b>length</b> : Number<p class=\"sub-desc\">The total number of items in the hash</p></li>\n     * </ul></div>\n     * @param {Function} fn The function to execute.\n     * @param {Object} scope The scope to execute in. Defaults to <tt>this</tt>.\n     * @return {Ext.util.HashMap} this\n     */\n    each: function(fn, scope) {\n        // copy items so they may be removed during iteration.\n        var items = Ext.apply({}, this.map),\n            key,\n            length = this.length;\n\n        scope = scope || this;\n        for (key in items) {\n            if (items.hasOwnProperty(key)) {\n                if (fn.call(scope, key, items[key], length) === false) {\n                    break;\n                }\n            }\n        }\n        return this;\n    },\n\n    /**\n     * Performs a shallow copy on this hash.\n     * @return {Ext.util.HashMap} The new hash object.\n     */\n    clone: function() {\n        var hash = new this.self(),\n            map = this.map,\n            key;\n\n        hash.suspendEvents();\n        for (key in map) {\n            if (map.hasOwnProperty(key)) {\n                hash.add(key, map[key]);\n            }\n        }\n        hash.resumeEvents();\n        return hash;\n    },\n\n    /**\n     * @private\n     * Find the key for a value.\n     * @param {Object} value The value to find.\n     * @return {Object} The value of the item. Returns <tt>undefined</tt> if not found.\n     */\n    findKey: function(value) {\n        var key,\n            map = this.map;\n\n        for (key in map) {\n            if (map.hasOwnProperty(key) && map[key] === value) {\n                return key;\n            }\n        }\n        return undefined;\n    }\n});\n\n/**\n * Base Manager class\n */\nExt.define('Ext.AbstractManager', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.util.HashMap'],\n\n    /* End Definitions */\n\n    typeName: 'type',\n\n    constructor: function(config) {\n        Ext.apply(this, config || {});\n\n        /**\n         * @property {Ext.util.HashMap} all\n         * Contains all of the items currently managed\n         */\n        this.all = new Ext.util.HashMap();\n\n        this.types = {};\n    },\n\n    /**\n     * Returns an item by id.\n     * For additional details see {@link Ext.util.HashMap#get}.\n     * @param {String} id The id of the item\n     * @return {Object} The item, undefined if not found.\n     */\n    get : function(id) {\n        return this.all.get(id);\n    },\n\n    /**\n     * Registers an item to be managed\n     * @param {Object} item The item to register\n     */\n    register: function(item) {\n        var all = this.all,\n            key = all.getKey(item);\n            \n        if (all.containsKey(key)) {\n            Ext.Error.raise('Registering duplicate id \"' + key + '\" with this manager');\n        }\n        this.all.add(item);\n    },\n\n    /**\n     * Unregisters an item by removing it from this manager\n     * @param {Object} item The item to unregister\n     */\n    unregister: function(item) {\n        this.all.remove(item);\n    },\n\n    /**\n     * Registers a new item constructor, keyed by a type key.\n     * @param {String} type The mnemonic string by which the class may be looked up.\n     * @param {Function} cls The new instance class.\n     */\n    registerType : function(type, cls) {\n        this.types[type] = cls;\n        cls[this.typeName] = type;\n    },\n\n    /**\n     * Checks if an item type is registered.\n     * @param {String} type The mnemonic string by which the class may be looked up\n     * @return {Boolean} Whether the type is registered.\n     */\n    isRegistered : function(type){\n        return this.types[type] !== undefined;\n    },\n\n    /**\n     * Creates and returns an instance of whatever this manager manages, based on the supplied type and\n     * config object.\n     * @param {Object} config The config object\n     * @param {String} defaultType If no type is discovered in the config object, we fall back to this type\n     * @return {Object} The instance of whatever this manager is managing\n     */\n    create: function(config, defaultType) {\n        var type        = config[this.typeName] || config.type || defaultType,\n            Constructor = this.types[type];\n\n        if (Constructor === undefined) {\n            Ext.Error.raise(\"The '\" + type + \"' type has not been registered with this manager\");\n        }\n\n        return new Constructor(config);\n    },\n\n    /**\n     * Registers a function that will be called when an item with the specified id is added to the manager.\n     * This will happen on instantiation.\n     * @param {String} id The item id\n     * @param {Function} fn The callback function. Called with a single parameter, the item.\n     * @param {Object} scope The scope (this reference) in which the callback is executed.\n     * Defaults to the item.\n     */\n    onAvailable : function(id, fn, scope){\n        var all = this.all,\n            item,\n            callback;\n        \n        if (all.containsKey(id)) {\n            item = all.get(id);\n            fn.call(scope || item, item);\n        } else {\n            callback = function(map, key, item){\n                if (key == id) {\n                    fn.call(scope || item, item);\n                    all.un('add', callback);\n                }\n            }; \n            all.on('add', callback);\n        }\n    },\n    \n    /**\n     * Executes the specified function once for each item in the collection.\n     * @param {Function} fn The function to execute.\n     * @param {String} fn.key The key of the item\n     * @param {Number} fn.value The value of the item\n     * @param {Number} fn.length The total number of items in the collection\n     * @param {Boolean} fn.return False to cease iteration.\n     * @param {Object} scope The scope to execute in. Defaults to `this`.\n     */\n    each: function(fn, scope){\n        this.all.each(fn, scope || this);    \n    },\n    \n    /**\n     * Gets the number of items in the collection.\n     * @return {Number} The number of items in the collection.\n     */\n    getCount: function(){\n        return this.all.getCount();\n    }\n});\n\n/**\n * @class Ext.ComponentManager\n * <p>Provides a registry of all Components (instances of {@link Ext.Component} or any subclass\n * thereof) on a page so that they can be easily accessed by {@link Ext.Component component}\n * {@link Ext.Component#id id} (see {@link #get}, or the convenience method {@link Ext#getCmp Ext.getCmp}).</p>\n * <p>This object also provides a registry of available Component <i>classes</i>\n * indexed by a mnemonic code known as the Component's {@link Ext.Component#xtype xtype}.\n * The <code>xtype</code> provides a way to avoid instantiating child Components\n * when creating a full, nested config object for a complete Ext page.</p>\n * <p>A child Component may be specified simply as a <i>config object</i>\n * as long as the correct <code>{@link Ext.Component#xtype xtype}</code> is specified so that if and when the Component\n * needs rendering, the correct type can be looked up for lazy instantiation.</p>\n * <p>For a list of all available <code>{@link Ext.Component#xtype xtypes}</code>, see {@link Ext.Component}.</p>\n * @singleton\n */\nExt.define('Ext.ComponentManager', {\n    extend: 'Ext.AbstractManager',\n    alternateClassName: 'Ext.ComponentMgr',\n    \n    singleton: true,\n    \n    typeName: 'xtype',\n    \n    /**\n     * Creates a new Component from the specified config object using the\n     * config object's xtype to determine the class to instantiate.\n     * @param {Object} config A configuration object for the Component you wish to create.\n     * @param {String} defaultType (optional) The xtype to use if the config object does not\n     * contain a <code>xtype</code>. (Optional if the config contains a <code>xtype</code>).\n     * @return {Ext.Component} The newly instantiated Component.\n     */\n    create: function(component, defaultType){\n        if (typeof component == 'string') {\n            return Ext.widget(component);\n        }\n        if (component.isComponent) {\n            return component;\n        }\n        return Ext.widget(component.xtype || defaultType, component);\n    },\n\n    registerType: function(type, cls) {\n        this.types[type] = cls;\n        cls[this.typeName] = type;\n        cls.prototype[this.typeName] = type;\n    }\n});\n\n/**\n * Provides searching of Components within Ext.ComponentManager (globally) or a specific\n * Ext.container.Container on the document with a similar syntax to a CSS selector.\n *\n * Components can be retrieved by using their {@link Ext.Component xtype}\n *\n * - `component`\n * - `gridpanel`\n * \n * Matching by xtype matches inherited types, so in the following code, the previous field\n * *of any type which inherits from `TextField`* will be found:\n *\n *     prevField = myField.previousNode('textfield');\n *\n * To match only the exact type, pass the \"shallow\" flag (See {@link Ext.AbstractComponent#isXType AbstractComponent's isXType method})\n *\n *     prevTextField = myField.previousNode('textfield(true)');\n *\n * An itemId or id must be prefixed with a #\n *\n * - `#myContainer`\n *\n * Attributes must be wrapped in brackets\n *\n * - `component[autoScroll]`\n * - `panel[title=\"Test\"]`\n *\n * Member expressions from candidate Components may be tested. If the expression returns a *truthy* value,\n * the candidate Component will be included in the query:\n *\n *     var disabledFields = myFormPanel.query(\"{isDisabled()}\");\n *\n * Pseudo classes may be used to filter results in the same way as in {@link Ext.DomQuery DomQuery}:\n *\n *     // Function receives array and returns a filtered array.\n *     Ext.ComponentQuery.pseudos.invalid = function(items) {\n *         var i = 0, l = items.length, c, result = [];\n *         for (; i < l; i++) {\n *             if (!(c = items[i]).isValid()) {\n *                 result.push(c);\n *             }\n *         }\n *         return result;\n *     };\n *      \n *     var invalidFields = myFormPanel.query('field:invalid');\n *     if (invalidFields.length) {\n *         invalidFields[0].getEl().scrollIntoView(myFormPanel.body);\n *         for (var i = 0, l = invalidFields.length; i < l; i++) {\n *             invalidFields[i].getEl().frame(\"red\");\n *         }\n *     }\n *\n * Default pseudos include:\n *\n * - not\n * - first\n * - last\n *\n * Queries return an array of components.\n * Here are some example queries.\n *\n *     // retrieve all Ext.Panels in the document by xtype\n *     var panelsArray = Ext.ComponentQuery.query('panel');\n *\n *     // retrieve all Ext.Panels within the container with an id myCt\n *     var panelsWithinmyCt = Ext.ComponentQuery.query('#myCt panel');\n *\n *     // retrieve all direct children which are Ext.Panels within myCt\n *     var directChildPanel = Ext.ComponentQuery.query('#myCt > panel');\n *\n *     // retrieve all grids and trees\n *     var gridsAndTrees = Ext.ComponentQuery.query('gridpanel, treepanel');\n *\n * For easy access to queries based from a particular Container see the {@link Ext.container.Container#query},\n * {@link Ext.container.Container#down} and {@link Ext.container.Container#child} methods. Also see\n * {@link Ext.Component#up}.\n */\nExt.define('Ext.ComponentQuery', {\n    singleton: true,\n    requires: ['Ext.ComponentManager']\n}, function() {\n\n    var cq = this,\n\n        // A function source code pattern with a placeholder which accepts an expression which yields a truth value when applied\n        // as a member on each item in the passed array.\n        filterFnPattern = [\n            'var r = [],',\n                'i = 0,',\n                'it = items,',\n                'l = it.length,',\n                'c;',\n            'for (; i < l; i++) {',\n                'c = it[i];',\n                'if (c.{0}) {',\n                   'r.push(c);',\n                '}',\n            '}',\n            'return r;'\n        ].join(''),\n\n        filterItems = function(items, operation) {\n            // Argument list for the operation is [ itemsArray, operationArg1, operationArg2...]\n            // The operation's method loops over each item in the candidate array and\n            // returns an array of items which match its criteria\n            return operation.method.apply(this, [ items ].concat(operation.args));\n        },\n\n        getItems = function(items, mode) {\n            var result = [],\n                i = 0,\n                length = items.length,\n                candidate,\n                deep = mode !== '>';\n                \n            for (; i < length; i++) {\n                candidate = items[i];\n                if (candidate.getRefItems) {\n                    result = result.concat(candidate.getRefItems(deep));\n                }\n            }\n            return result;\n        },\n\n        getAncestors = function(items) {\n            var result = [],\n                i = 0,\n                length = items.length,\n                candidate;\n            for (; i < length; i++) {\n                candidate = items[i];\n                while (!!(candidate = (candidate.ownerCt || candidate.floatParent))) {\n                    result.push(candidate);\n                }\n            }\n            return result;\n        },\n\n        // Filters the passed candidate array and returns only items which match the passed xtype\n        filterByXType = function(items, xtype, shallow) {\n            if (xtype === '*') {\n                return items.slice();\n            }\n            else {\n                var result = [],\n                    i = 0,\n                    length = items.length,\n                    candidate;\n                for (; i < length; i++) {\n                    candidate = items[i];\n                    if (candidate.isXType(xtype, shallow)) {\n                        result.push(candidate);\n                    }\n                }\n                return result;\n            }\n        },\n\n        // Filters the passed candidate array and returns only items which have the passed className\n        filterByClassName = function(items, className) {\n            var EA = Ext.Array,\n                result = [],\n                i = 0,\n                length = items.length,\n                candidate;\n            for (; i < length; i++) {\n                candidate = items[i];\n                if (candidate.hasCls(className)) {\n                    result.push(candidate);\n                }\n            }\n            return result;\n        },\n\n        // Filters the passed candidate array and returns only items which have the specified property match\n        filterByAttribute = function(items, property, operator, value) {\n            var result = [],\n                i = 0,\n                length = items.length,\n                candidate;\n            for (; i < length; i++) {\n                candidate = items[i];\n                if (!value ? !!candidate[property] : (String(candidate[property]) === value)) {\n                    result.push(candidate);\n                }\n            }\n            return result;\n        },\n\n        // Filters the passed candidate array and returns only items which have the specified itemId or id\n        filterById = function(items, id) {\n            var result = [],\n                i = 0,\n                length = items.length,\n                candidate;\n            for (; i < length; i++) {\n                candidate = items[i];\n                if (candidate.getItemId() === id) {\n                    result.push(candidate);\n                }\n            }\n            return result;\n        },\n\n        // Filters the passed candidate array and returns only items which the named pseudo class matcher filters in\n        filterByPseudo = function(items, name, value) {\n            return cq.pseudos[name](items, value);\n        },\n\n        // Determines leading mode\n        // > for direct child, and ^ to switch to ownerCt axis\n        modeRe = /^(\\s?([>\\^])\\s?|\\s|$)/,\n\n        // Matches a token with possibly (true|false) appended for the \"shallow\" parameter\n        tokenRe = /^(#)?([\\w\\-]+|\\*)(?:\\((true|false)\\))?/,\n\n        matchers = [{\n            // Checks for .xtype with possibly (true|false) appended for the \"shallow\" parameter\n            re: /^\\.([\\w\\-]+)(?:\\((true|false)\\))?/,\n            method: filterByXType\n        },{\n            // checks for [attribute=value]\n            re: /^(?:[\\[](?:@)?([\\w\\-]+)\\s?(?:(=|.=)\\s?['\"]?(.*?)[\"']?)?[\\]])/,\n            method: filterByAttribute\n        }, {\n            // checks for #cmpItemId\n            re: /^#([\\w\\-]+)/,\n            method: filterById\n        }, {\n            // checks for :<pseudo_class>(<selector>)\n            re: /^\\:([\\w\\-]+)(?:\\(((?:\\{[^\\}]+\\})|(?:(?!\\{)[^\\s>\\/]*?(?!\\})))\\))?/,\n            method: filterByPseudo\n        }, {\n            // checks for {<member_expression>}\n            re: /^(?:\\{([^\\}]+)\\})/,\n            method: filterFnPattern\n        }];\n\n    // Internal class Ext.ComponentQuery.Query\n    cq.Query = Ext.extend(Object, {\n        constructor: function(cfg) {\n            cfg = cfg || {};\n            Ext.apply(this, cfg);\n        },\n\n        // Executes this Query upon the selected root.\n        // The root provides the initial source of candidate Component matches which are progressively\n        // filtered by iterating through this Query's operations cache.\n        // If no root is provided, all registered Components are searched via the ComponentManager.\n        // root may be a Container who's descendant Components are filtered\n        // root may be a Component with an implementation of getRefItems which provides some nested Components such as the\n        // docked items within a Panel.\n        // root may be an array of candidate Components to filter using this Query.\n        execute : function(root) {\n            var operations = this.operations,\n                i = 0,\n                length = operations.length,\n                operation,\n                workingItems;\n\n            // no root, use all Components in the document\n            if (!root) {\n                workingItems = Ext.ComponentManager.all.getArray();\n            }\n            // Root is a candidate Array\n            else if (Ext.isArray(root)) {\n                workingItems = root;\n            }\n            // Root is a MixedCollection\n            else if (root.isMixedCollection) {\n                workingItems = root.items;\n            }\n\n            // We are going to loop over our operations and take care of them\n            // one by one.\n            for (; i < length; i++) {\n                operation = operations[i];\n\n                // The mode operation requires some custom handling.\n                // All other operations essentially filter down our current\n                // working items, while mode replaces our current working\n                // items by getting children from each one of our current\n                // working items. The type of mode determines the type of\n                // children we get. (e.g. > only gets direct children)\n                if (operation.mode === '^') {\n                    workingItems = getAncestors(workingItems || [root]);\n                }\n                else if (operation.mode) {\n                    workingItems = getItems(workingItems || [root], operation.mode);\n                }\n                else {\n                    workingItems = filterItems(workingItems || getItems([root]), operation);\n                }\n\n                // If this is the last operation, it means our current working\n                // items are the final matched items. Thus return them!\n                if (i === length -1) {\n                    return workingItems;\n                }\n            }\n            return [];\n        },\n\n        is: function(component) {\n            var operations = this.operations,\n                components = Ext.isArray(component) ? component : [component],\n                originalLength = components.length,\n                lastOperation = operations[operations.length-1],\n                ln, i;\n\n            components = filterItems(components, lastOperation);\n            if (components.length === originalLength) {\n                if (operations.length > 1) {\n                    for (i = 0, ln = components.length; i < ln; i++) {\n                        if (Ext.Array.indexOf(this.execute(), components[i]) === -1) {\n                            return false;\n                        }\n                    }\n                }\n                return true;\n            }\n            return false;\n        }\n    });\n\n    Ext.apply(this, {\n\n        // private cache of selectors and matching ComponentQuery.Query objects\n        cache: {},\n\n        // private cache of pseudo class filter functions\n        pseudos: {\n            not: function(components, selector){\n                var CQ = Ext.ComponentQuery,\n                    i = 0,\n                    length = components.length,\n                    results = [],\n                    index = -1,\n                    component;\n                \n                for(; i < length; ++i) {\n                    component = components[i];\n                    if (!CQ.is(component, selector)) {\n                        results[++index] = component;\n                    }\n                }\n                return results;\n            },\n            first: function(components) {\n                var ret = [];\n                    \n                if (components.length > 0) {\n                    ret.push(components[0]);\n                }\n                return ret;       \n            },\n            last: function(components) {\n                var len = components.length,\n                    ret = [];\n                    \n                if (len > 0) {\n                    ret.push(components[len - 1]);\n                }\n                return ret;\n            }\n        },\n\n        /**\n         * Returns an array of matched Components from within the passed root object.\n         *\n         * This method filters returned Components in a similar way to how CSS selector based DOM\n         * queries work using a textual selector string.\n         *\n         * See class summary for details.\n         *\n         * @param {String} selector The selector string to filter returned Components\n         * @param {Ext.container.Container} root The Container within which to perform the query.\n         * If omitted, all Components within the document are included in the search.\n         * \n         * This parameter may also be an array of Components to filter according to the selector.</p>\n         * @returns {Ext.Component[]} The matched Components.\n         * \n         * @member Ext.ComponentQuery\n         */\n        query: function(selector, root) {\n            var selectors = selector.split(','),\n                length = selectors.length,\n                i = 0,\n                results = [],\n                noDupResults = [], \n                dupMatcher = {}, \n                query, resultsLn, cmp;\n\n            for (; i < length; i++) {\n                selector = Ext.String.trim(selectors[i]);\n                query = this.cache[selector] || (this.cache[selector] = this.parse(selector));\n                results = results.concat(query.execute(root));\n            }\n\n            // multiple selectors, potential to find duplicates\n            // lets filter them out.\n            if (length > 1) {\n                resultsLn = results.length;\n                for (i = 0; i < resultsLn; i++) {\n                    cmp = results[i];\n                    if (!dupMatcher[cmp.id]) {\n                        noDupResults.push(cmp);\n                        dupMatcher[cmp.id] = true;\n                    }\n                }\n                results = noDupResults;\n            }\n            return results;\n        },\n\n        /**\n         * Tests whether the passed Component matches the selector string.\n         * @param {Ext.Component} component The Component to test\n         * @param {String} selector The selector string to test against.\n         * @return {Boolean} True if the Component matches the selector.\n         * @member Ext.ComponentQuery\n         */\n        is: function(component, selector) {\n            if (!selector) {\n                return true;\n            }\n            var selectors = selector.split(','),\n                length = selectors.length,\n                i = 0,\n                query;\n\n            for (; i < length; i++) {\n                selector = Ext.String.trim(selectors[i]);\n                query = this.cache[selector] || (this.cache[selector] = this.parse(selector));\n                if (query.is(component)) {\n                    return true;\n                }\n            }\n            return false;\n        },\n\n        parse: function(selector) {\n            var operations = [],\n                length = matchers.length,\n                lastSelector,\n                tokenMatch,\n                matchedChar,\n                modeMatch,\n                selectorMatch,\n                i, matcher, method;\n\n            // We are going to parse the beginning of the selector over and\n            // over again, slicing off the selector any portions we converted into an\n            // operation, until it is an empty string.\n            while (selector && lastSelector !== selector) {\n                lastSelector = selector;\n\n                // First we check if we are dealing with a token like #, * or an xtype\n                tokenMatch = selector.match(tokenRe);\n\n                if (tokenMatch) {\n                    matchedChar = tokenMatch[1];\n\n                    // If the token is prefixed with a # we push a filterById operation to our stack\n                    if (matchedChar === '#') {\n                        operations.push({\n                            method: filterById,\n                            args: [Ext.String.trim(tokenMatch[2])]\n                        });\n                    }\n                    // If the token is prefixed with a . we push a filterByClassName operation to our stack\n                    // FIXME: Not enabled yet. just needs \\. adding to the tokenRe prefix\n                    else if (matchedChar === '.') {\n                        operations.push({\n                            method: filterByClassName,\n                            args: [Ext.String.trim(tokenMatch[2])]\n                        });\n                    }\n                    // If the token is a * or an xtype string, we push a filterByXType\n                    // operation to the stack.\n                    else {\n                        operations.push({\n                            method: filterByXType,\n                            args: [Ext.String.trim(tokenMatch[2]), Boolean(tokenMatch[3])]\n                        });\n                    }\n\n                    // Now we slice of the part we just converted into an operation\n                    selector = selector.replace(tokenMatch[0], '');\n                }\n\n                // If the next part of the query is not a space or > or ^, it means we\n                // are going to check for more things that our current selection\n                // has to comply to.\n                while (!(modeMatch = selector.match(modeRe))) {\n                    // Lets loop over each type of matcher and execute it\n                    // on our current selector.\n                    for (i = 0; selector && i < length; i++) {\n                        matcher = matchers[i];\n                        selectorMatch = selector.match(matcher.re);\n                        method = matcher.method;\n\n                        // If we have a match, add an operation with the method\n                        // associated with this matcher, and pass the regular\n                        // expression matches are arguments to the operation.\n                        if (selectorMatch) {\n                            operations.push({\n                                method: Ext.isString(matcher.method)\n                                    // Turn a string method into a function by formatting the string with our selector matche expression\n                                    // A new method is created for different match expressions, eg {id=='textfield-1024'}\n                                    // Every expression may be different in different selectors.\n                                    ? Ext.functionFactory('items', Ext.String.format.apply(Ext.String, [method].concat(selectorMatch.slice(1))))\n                                    : matcher.method,\n                                args: selectorMatch.slice(1)\n                            });\n                            selector = selector.replace(selectorMatch[0], '');\n                            break; // Break on match\n                        }\n                        // Exhausted all matches: It's an error\n                        if (i === (length - 1)) {\n                            Ext.Error.raise('Invalid ComponentQuery selector: \"' + arguments[0] + '\"');\n                        }\n                    }\n                }\n\n                // Now we are going to check for a mode change. This means a space\n                // or a > to determine if we are going to select all the children\n                // of the currently matched items, or a ^ if we are going to use the\n                // ownerCt axis as the candidate source.\n                if (modeMatch[1]) { // Assignment, and test for truthiness!\n                    operations.push({\n                        mode: modeMatch[2]||modeMatch[1]\n                    });\n                    selector = selector.replace(modeMatch[0], '');\n                }\n            }\n\n            //  Now that we have all our operations in an array, we are going\n            // to create a new Query using these operations.\n            return new cq.Query({\n                operations: operations\n            });\n        }\n    });\n});\n\n/*\n * The dirty implementation in this class is quite naive. The reasoning for this is that the dirty state\n * will only be used in very specific circumstances, specifically, after the render process has begun but\n * the component is not yet rendered to the DOM. As such, we want it to perform as quickly as possible\n * so it's not as fully featured as you may expect.\n */\n\n/**\n * Manages certain element-like data prior to rendering. These values are passed\n * on to the render process. This is currently used to manage the \"class\" and \"style\" attributes\n * of a component's primary el as well as the bodyEl of panels. This allows things like\n * addBodyCls in Panel to share logic with addCls in AbstractComponent.\n * @private\n */\nExt.define('Ext.util.ProtoElement', (function () {\n    var splitWords = Ext.String.splitWords,\n        toMap = Ext.Array.toMap;\n\n    return {\n        \n        isProtoEl: true,\n        \n        /**\n         * The property name for the className on the data object passed to {@link #writeTo}.\n         */\n        clsProp: 'cls',\n\n        /**\n         * The property name for the style on the data object passed to {@link #writeTo}.\n         */\n        styleProp: 'style',\n        \n        /**\n         * The property name for the removed classes on the data object passed to {@link #writeTo}.\n         */\n        removedProp: 'removed',\n\n        /**\n         * True if the style must be converted to text during {@link #writeTo}. When used to\n         * populate tpl data, this will be true. When used to populate {@link Ext.DomHelper}\n         * specs, this will be false (the default).\n         */\n        styleIsText: false,\n\n        constructor: function (config) {\n            var me = this;\n\n            Ext.apply(me, config);\n\n            me.classList = splitWords(me.cls);\n            me.classMap = toMap(me.classList);\n            delete me.cls;\n\n            if (Ext.isFunction(me.style)) {\n                me.styleFn = me.style;\n                delete me.style;\n            } else if (typeof me.style == 'string') {\n                me.style = Ext.Element.parseStyles(me.style);\n            } else if (me.style) {\n                me.style = Ext.apply({}, me.style); // don't edit the given object\n            }\n        },\n        \n        /**\n         * Indicates that the current state of the object has been flushed to the DOM, so we need\n         * to track any subsequent changes\n         */\n        flush: function(){\n            this.flushClassList = [];\n            this.removedClasses = {};\n            // clear the style, it will be recreated if we add anything new\n            delete this.style;\n        },\n\n        /**\n         * Adds class to the element.\n         * @param {String} cls One or more classnames separated with spaces.\n         * @return {Ext.util.ProtoElement} this\n         */\n        addCls: function (cls) {\n            var me = this,\n                add = splitWords(cls),\n                length = add.length,\n                list = me.classList,\n                map = me.classMap,\n                flushList = me.flushClassList,\n                i = 0,\n                c;\n\n            for (; i < length; ++i) {\n                c = add[i];\n                if (!map[c]) {\n                    map[c] = true;\n                    list.push(c);\n                    if (flushList) {\n                        flushList.push(c);\n                        delete me.removedClasses[c];\n                    }\n                }\n            }\n\n            return me;\n        },\n\n        /**\n         * True if the element has given class.\n         * @param {String} cls\n         * @return {Boolean}\n         */\n        hasCls: function (cls) {\n            return cls in this.classMap;\n        },\n\n        /**\n         * Removes class from the element.\n         * @param {String} cls One or more classnames separated with spaces.\n         * @return {Ext.util.ProtoElement} this\n         */\n        removeCls: function (cls) {\n            var me = this,\n                list = me.classList,\n                newList = (me.classList = []),\n                remove = toMap(splitWords(cls)),\n                length = list.length,\n                map = me.classMap,\n                removedClasses = me.removedClasses,\n                i, c;\n\n            for (i = 0; i < length; ++i) {\n                c = list[i];\n                if (remove[c]) {\n                    if (removedClasses) {\n                        if (map[c]) {\n                            removedClasses[c] = true;\n                            Ext.Array.remove(me.flushClassList, c);\n                        }\n                    }\n                    delete map[c];\n                } else {\n                    newList.push(c);\n                }\n            }\n\n            return me;\n        },\n\n        /**\n         * Adds styles to the element.\n         * @param {String/Object} prop The style property to be set, or an object of multiple styles.\n         * @param {String} [value] The value to apply to the given property.\n         * @return {Ext.util.ProtoElement} this\n         */\n        setStyle: function (prop, value) {\n            var me = this,\n                style = me.style || (me.style = {});\n\n            if (typeof prop == 'string') {\n                if (arguments.length === 1) {\n                    me.setStyle(Ext.Element.parseStyles(prop));\n                } else {\n                    style[prop] = value;\n                }\n            } else {\n                Ext.apply(style, prop);\n            }\n\n            return me;\n        },\n\n        /**\n         * Writes style and class properties to given object.\n         * Styles will be written to {@link #styleProp} and class names to {@link #clsProp}.\n         * @param {Object} to\n         * @return {Object} to\n         */\n        writeTo: function (to) {\n            var me = this,\n                classList = me.flushClassList || me.classList,\n                removedClasses = me.removedClasses,\n                style;\n\n            if (me.styleFn) {\n                style = Ext.apply({}, me.styleFn());\n                Ext.apply(style, me.style);\n            } else {\n                style = me.style;\n            }\n\n            to[me.clsProp] = classList.join(' ');\n\n            if (style) {\n                to[me.styleProp] = me.styleIsText ? Ext.DomHelper.generateStyles(style) : style;\n            }\n            \n            if (removedClasses) {\n                removedClasses = Ext.Object.getKeys(removedClasses);\n                if (removedClasses.length) {\n                    to[me.removedProp] = removedClasses.join(' ');\n                }\n            }\n\n            return to;\n        }\n    };\n}()));\n\n//@tag dom,core\n//@require util/Event.js\n//@define Ext.EventManager\n\n/**\n * @class Ext.EventManager\n * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides\n * several useful events directly.\n * See {@link Ext.EventObject} for more details on normalized event objects.\n * @singleton\n */\nExt.EventManager = new function() {\n    var EventManager = this,\n        doc = document,\n        win = window,\n        initExtCss = function() {\n            // find the body element\n            var bd = doc.body || doc.getElementsByTagName('body')[0],\n                baseCSSPrefix = Ext.baseCSSPrefix,\n                cls = [baseCSSPrefix + 'body'],\n                htmlCls = [],\n                supportsLG = Ext.supports.CSS3LinearGradient,\n                supportsBR = Ext.supports.CSS3BorderRadius,\n                resetCls = [],\n                html,\n                resetElementSpec;\n\n            if (!bd) {\n                return false;\n            }\n\n            html = bd.parentNode;\n\n            function add (c) {\n                cls.push(baseCSSPrefix + c);\n            }\n\n            //Let's keep this human readable!\n            if (Ext.isIE) {\n                add('ie');\n\n                // very often CSS needs to do checks like \"IE7+\" or \"IE6 or 7\". To help\n                // reduce the clutter (since CSS/SCSS cannot do these tests), we add some\n                // additional classes:\n                //\n                //      x-ie7p      : IE7+      :  7 <= ieVer\n                //      x-ie7m      : IE7-      :  ieVer <= 7\n                //      x-ie8p      : IE8+      :  8 <= ieVer\n                //      x-ie8m      : IE8-      :  ieVer <= 8\n                //      x-ie9p      : IE9+      :  9 <= ieVer\n                //      x-ie78      : IE7 or 8  :  7 <= ieVer <= 8\n                //\n                if (Ext.isIE6) {\n                    add('ie6');\n                } else { // ignore pre-IE6 :)\n                    add('ie7p');\n\n                    if (Ext.isIE7) {\n                        add('ie7');\n                    } else {\n                        add('ie8p');\n\n                        if (Ext.isIE8) {\n                            add('ie8');\n                        } else {\n                            add('ie9p');\n\n                            if (Ext.isIE9) {\n                                add('ie9');\n                            }\n                        }\n                    }\n                }\n\n                if (Ext.isIE6 || Ext.isIE7) {\n                    add('ie7m');\n                }\n                if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {\n                    add('ie8m');\n                }\n                if (Ext.isIE7 || Ext.isIE8) {\n                    add('ie78');\n                }\n            }\n            if (Ext.isGecko) {\n                add('gecko');\n                if (Ext.isGecko3) {\n                    add('gecko3');\n                }\n                if (Ext.isGecko4) {\n                    add('gecko4');\n                }\n                if (Ext.isGecko5) {\n                    add('gecko5');\n                }\n            }\n            if (Ext.isOpera) {\n                add('opera');\n            }\n            if (Ext.isWebKit) {\n                add('webkit');\n            }\n            if (Ext.isSafari) {\n                add('safari');\n                if (Ext.isSafari2) {\n                    add('safari2');\n                }\n                if (Ext.isSafari3) {\n                    add('safari3');\n                }\n                if (Ext.isSafari4) {\n                    add('safari4');\n                }\n                if (Ext.isSafari5) {\n                    add('safari5');\n                }\n                if (Ext.isSafari5_0) {\n                    add('safari5_0')\n                }\n            }\n            if (Ext.isChrome) {\n                add('chrome');\n            }\n            if (Ext.isMac) {\n                add('mac');\n            }\n            if (Ext.isLinux) {\n                add('linux');\n            }\n            if (!supportsBR) {\n                add('nbr');\n            }\n            if (!supportsLG) {\n                add('nlg');\n            }\n\n            // If we are not globally resetting scope, but just resetting it in a wrapper around\n            // serarately rendered widgets, then create a common reset element for use when creating\n            // measurable elements. Using a common DomHelper spec.\n            if (Ext.scopeResetCSS) {\n\n                // Create Ext.resetElementSpec for use in Renderable when wrapping top level Components.\n                resetElementSpec = Ext.resetElementSpec = {\n                    cls: baseCSSPrefix + 'reset'\n                };\n                \n                if (!supportsLG) {\n                    resetCls.push(baseCSSPrefix + 'nlg');\n                }\n                \n                if (!supportsBR) {\n                    resetCls.push(baseCSSPrefix + 'nbr');\n                }\n                \n                if (resetCls.length) {                    \n                    resetElementSpec.cn = {\n                        cls: resetCls.join(' ')\n                    };\n                }\n                \n                Ext.resetElement = Ext.getBody().createChild(resetElementSpec);\n                if (resetCls.length) {\n                    Ext.resetElement = Ext.get(Ext.resetElement.dom.firstChild);\n                }\n            }\n            // Otherwise, the common reset element is the document body\n            else {\n                Ext.resetElement = Ext.getBody();\n                add('reset');\n            }\n\n            // add to the parent to allow for selectors x-strict x-border-box, also set the isBorderBox property correctly\n            if (html) {\n                if (Ext.isStrict && (Ext.isIE6 || Ext.isIE7)) {\n                    Ext.isBorderBox = false;\n                }\n                else {\n                    Ext.isBorderBox = true;\n                }\n\n                if(Ext.isBorderBox) {\n                    htmlCls.push(baseCSSPrefix + 'border-box');\n                }\n                if (Ext.isStrict) {\n                    htmlCls.push(baseCSSPrefix + 'strict');\n                } else {\n                    htmlCls.push(baseCSSPrefix + 'quirks');\n                }\n                Ext.fly(html, '_internal').addCls(htmlCls);\n            }\n\n            Ext.fly(bd, '_internal').addCls(cls);\n            return true;\n        };\n\n    Ext.apply(EventManager, {\n        /**\n         * Check if we have bound our global onReady listener\n         * @private\n         */\n        hasBoundOnReady: false,\n\n        /**\n         * Check if fireDocReady has been called\n         * @private\n         */\n        hasFiredReady: false,\n\n        /**\n         * Additionally, allow the 'DOM' listener thread to complete (usually desirable with mobWebkit, Gecko)\n         * before firing the entire onReady chain (high stack load on Loader) by specifying a delay value\n         * @default 1ms\n         * @private\n         */\n        deferReadyEvent : 1,\n\n        /*\n         * diags: a list of event names passed to onReadyEvent (in chron order)\n         * @private\n         */\n        onReadyChain : [],\n\n        /**\n         * Holds references to any onReady functions\n         * @private\n         */\n        readyEvent:\n            (function () {\n                var event = new Ext.util.Event();\n                event.fire = function () {\n                    Ext._beforeReadyTime = Ext._beforeReadyTime || new Date().getTime();\n                    event.self.prototype.fire.apply(event, arguments);\n                    Ext._afterReadytime = new Date().getTime();\n                };\n                return event;\n            }()),\n\n        /**\n         * Fires when a DOM event handler finishes its run, just before returning to browser control.\n         * This can be useful for performing cleanup, or upfdate tasks which need to happen only\n         * after all code in an event handler has been run, but which should not be executed in a timer\n         * due to the intervening browser reflow/repaint which would take place.\n         *\n         */\n        idleEvent: new Ext.util.Event(),\n\n        /**\n         * detects whether the EventManager has been placed in a paused state for synchronization\n         * with external debugging / perf tools (PageAnalyzer)\n         * @private\n         */\n        isReadyPaused: function(){\n            return (/[?&]ext-pauseReadyFire\\b/i.test(location.search) && !Ext._continueFireReady);\n        },\n\n        /**\n         * Binds the appropriate browser event for checking if the DOM has loaded.\n         * @private\n         */\n        bindReadyEvent: function() {\n            if (EventManager.hasBoundOnReady) {\n                return;\n            }\n\n            // Test scenario where Core is dynamically loaded AFTER window.load\n            if ( doc.readyState == 'complete'  ) {  // Firefox4+ got support for this state, others already do.\n                EventManager.onReadyEvent({\n                    type: doc.readyState || 'body'\n                });\n            } else {\n                document.addEventListener('DOMContentLoaded', EventManager.onReadyEvent, false);\n                window.addEventListener('load', EventManager.onReadyEvent, false);\n                EventManager.hasBoundOnReady = true;\n            }\n        },\n\n        onReadyEvent : function(e) {\n            if (e && e.type) {\n                EventManager.onReadyChain.push(e.type);\n            }\n\n            if (EventManager.hasBoundOnReady) {\n                document.removeEventListener('DOMContentLoaded', EventManager.onReadyEvent, false);\n                window.removeEventListener('load', EventManager.onReadyEvent, false);\n            }\n\n            if (!Ext.isReady) {\n                EventManager.fireDocReady();\n            }\n        },\n\n        /**\n         * We know the document is loaded, so trigger any onReady events.\n         * @private\n         */\n        fireDocReady: function() {\n            if (!Ext.isReady) {\n                Ext._readyTime = new Date().getTime();\n                Ext.isReady = true;\n\n                Ext.supports.init();\n                EventManager.onWindowUnload();\n                EventManager.readyEvent.onReadyChain = EventManager.onReadyChain;    //diags report\n\n                if (Ext.isNumber(EventManager.deferReadyEvent)) {\n                    Ext.Function.defer(EventManager.fireReadyEvent, EventManager.deferReadyEvent);\n                    EventManager.hasDocReadyTimer = true;\n                } else {\n                    EventManager.fireReadyEvent();\n                }\n            }\n        },\n\n        /**\n         * Fires the ready event\n         * @private\n         */\n        fireReadyEvent: function(){\n            var readyEvent = EventManager.readyEvent;\n\n            // Unset the timer flag here since other onReady events may be\n            // added during the fire() call and we don't want to block them\n            EventManager.hasDocReadyTimer = false;\n            EventManager.isFiring = true;\n\n            // Ready events are all single: true, if we get to the end\n            // & there are more listeners, it means they were added\n            // inside some other ready event\n            while (readyEvent.listeners.length && !EventManager.isReadyPaused()) {\n                readyEvent.fire();\n            }\n            EventManager.isFiring = false;\n            EventManager.hasFiredReady = true;\n        },\n\n        /**\n         * Adds a listener to be notified when the document is ready (before onload and before images are loaded).\n         *\n         * @param {Function} fn The method the event invokes.\n         * @param {Object} [scope] The scope (`this` reference) in which the handler function executes.\n         * Defaults to the browser window.\n         * @param {Object} [options] Options object as passed to {@link Ext.Element#addListener}.\n         */\n        onDocumentReady: function(fn, scope, options) {\n            options = options || {};\n            // force single, only ever fire it once\n            options.single = true;\n            EventManager.readyEvent.addListener(fn, scope, options);\n\n            // If we're in the middle of firing, or we have a deferred timer\n            // pending, drop out since the event will be fired  later\n            if (!(EventManager.isFiring || EventManager.hasDocReadyTimer)) {\n                if (Ext.isReady) {\n                    EventManager.fireReadyEvent();\n                } else {\n                    EventManager.bindReadyEvent();\n                }\n            }\n        },\n\n        // --------------------- event binding ---------------------\n\n        /**\n         * Contains a list of all document mouse downs, so we can ensure they fire even when stopEvent is called.\n         * @private\n         */\n        stoppedMouseDownEvent: new Ext.util.Event(),\n\n        /**\n         * Options to parse for the 4th argument to addListener.\n         * @private\n         */\n        propRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|freezeEvent)$/,\n\n        /**\n         * Get the id of the element. If one has not been assigned, automatically assign it.\n         * @param {HTMLElement/Ext.Element} element The element to get the id for.\n         * @return {String} id\n         */\n        getId : function(element) {\n            var id;\n\n            element = Ext.getDom(element);\n\n            if (element === doc || element === win) {\n                id = element === doc ? Ext.documentId : Ext.windowId;\n            }\n            else {\n                id = Ext.id(element);\n            }\n\n            if (!Ext.cache[id]) {\n                Ext.addCacheEntry(id, null, element);\n            }\n\n            return id;\n        },\n\n        /**\n         * Convert a \"config style\" listener into a set of flat arguments so they can be passed to addListener\n         * @private\n         * @param {Object} element The element the event is for\n         * @param {Object} event The event configuration\n         * @param {Object} isRemove True if a removal should be performed, otherwise an add will be done.\n         */\n        prepareListenerConfig: function(element, config, isRemove) {\n            var propRe = EventManager.propRe,\n                key, value, args;\n\n            // loop over all the keys in the object\n            for (key in config) {\n                if (config.hasOwnProperty(key)) {\n                    // if the key is something else then an event option\n                    if (!propRe.test(key)) {\n                        value = config[key];\n                        // if the value is a function it must be something like click: function() {}, scope: this\n                        // which means that there might be multiple event listeners with shared options\n                        if (typeof value == 'function') {\n                            // shared options\n                            args = [element, key, value, config.scope, config];\n                        } else {\n                            // if its not a function, it must be an object like click: {fn: function() {}, scope: this}\n                            args = [element, key, value.fn, value.scope, value];\n                        }\n\n                        if (isRemove) {\n                            EventManager.removeListener.apply(EventManager, args);\n                        } else {\n                            EventManager.addListener.apply(EventManager, args);\n                        }\n                    }\n                }\n            }\n        },\n\n        mouseEnterLeaveRe: /mouseenter|mouseleave/,\n\n        /**\n         * Normalize cross browser event differences\n         * @private\n         * @param {Object} eventName The event name\n         * @param {Object} fn The function to execute\n         * @return {Object} The new event name/function\n         */\n        normalizeEvent: function(eventName, fn) {\n            if (EventManager.mouseEnterLeaveRe.test(eventName) && !Ext.supports.MouseEnterLeave) {\n                if (fn) {\n                    fn = Ext.Function.createInterceptor(fn, EventManager.contains);\n                }\n                eventName = eventName == 'mouseenter' ? 'mouseover' : 'mouseout';\n            } else if (eventName == 'mousewheel' && !Ext.supports.MouseWheel && !Ext.isOpera) {\n                eventName = 'DOMMouseScroll';\n            }\n            return {\n                eventName: eventName,\n                fn: fn\n            };\n        },\n\n        /**\n         * Checks whether the event's relatedTarget is contained inside (or <b>is</b>) the element.\n         * @private\n         * @param {Object} event\n         */\n        contains: function(event) {\n            var parent = event.browserEvent.currentTarget,\n                child = EventManager.getRelatedTarget(event);\n\n            if (parent && parent.firstChild) {\n                while (child) {\n                    if (child === parent) {\n                        return false;\n                    }\n                    child = child.parentNode;\n                    if (child && (child.nodeType != 1)) {\n                        child = null;\n                    }\n                }\n            }\n            return true;\n        },\n\n        /**\n        * Appends an event handler to an element.  The shorthand version {@link #on} is equivalent.  Typically you will\n        * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.\n        * @param {String/HTMLElement} el The html element or id to assign the event handler to.\n        * @param {String} eventName The name of the event to listen for.\n        * @param {Function} handler The handler function the event invokes. This function is passed\n        * the following parameters:<ul>\n        * <li>evt : EventObject<div class=\"sub-desc\">The {@link Ext.EventObject EventObject} describing the event.</div></li>\n        * <li>t : Element<div class=\"sub-desc\">The {@link Ext.Element Element} which was the target of the event.\n        * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>\n        * <li>o : Object<div class=\"sub-desc\">The options object from the addListener call.</div></li>\n        * </ul>\n        * @param {Object} scope (optional) The scope (<b><code>this</code></b> reference) in which the handler function is executed. <b>Defaults to the Element</b>.\n        * @param {Object} options (optional) An object containing handler configuration properties.\n        * This may contain any of the following properties:<ul>\n        * <li>scope : Object<div class=\"sub-desc\">The scope (<b><code>this</code></b> reference) in which the handler function is executed. <b>Defaults to the Element</b>.</div></li>\n        * <li>delegate : String<div class=\"sub-desc\">A simple selector to filter the target or look for a descendant of the target</div></li>\n        * <li>stopEvent : Boolean<div class=\"sub-desc\">True to stop the event. That is stop propagation, and prevent the default action.</div></li>\n        * <li>preventDefault : Boolean<div class=\"sub-desc\">True to prevent the default action</div></li>\n        * <li>stopPropagation : Boolean<div class=\"sub-desc\">True to prevent event propagation</div></li>\n        * <li>normalized : Boolean<div class=\"sub-desc\">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>\n        * <li>delay : Number<div class=\"sub-desc\">The number of milliseconds to delay the invocation of the handler after te event fires.</div></li>\n        * <li>single : Boolean<div class=\"sub-desc\">True to add a handler to handle just the next firing of the event, and then remove itself.</div></li>\n        * <li>buffer : Number<div class=\"sub-desc\">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed\n        * by the specified number of milliseconds. If the event fires again within that time, the original\n        * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>\n        * <li>target : Element<div class=\"sub-desc\">Only call the handler if the event was fired on the target Element, <i>not</i> if the event was bubbled up from a child node.</div></li>\n        * </ul><br>\n        * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>\n        */\n        addListener: function(element, eventName, fn, scope, options) {\n            // Check if we've been passed a \"config style\" event.\n            if (typeof eventName !== 'string') {\n                EventManager.prepareListenerConfig(element, eventName);\n                return;\n            }\n\n            var dom = element.dom || Ext.getDom(element),\n                bind, wrap;\n\n            if (!fn) {\n                Ext.Error.raise({\n                    sourceClass: 'Ext.EventManager',\n                    sourceMethod: 'addListener',\n                    targetElement: element,\n                    eventName: eventName,\n                    msg: 'Error adding \"' + eventName + '\\\" listener. The handler function is undefined.'\n                });\n            }\n\n            // create the wrapper function\n            options = options || {};\n\n            bind = EventManager.normalizeEvent(eventName, fn);\n            wrap = EventManager.createListenerWrap(dom, eventName, bind.fn, scope, options);\n\n            if (dom.attachEvent) {\n                dom.attachEvent('on' + bind.eventName, wrap);\n            } else {\n                dom.addEventListener(bind.eventName, wrap, options.capture || false);\n            }\n\n            if (dom == doc && eventName == 'mousedown') {\n                EventManager.stoppedMouseDownEvent.addListener(wrap);\n            }\n\n            // add all required data into the event cache\n            EventManager.getEventListenerCache(element.dom ? element : dom, eventName).push({\n                fn: fn,\n                wrap: wrap,\n                scope: scope\n            });\n        },\n\n        /**\n        * Removes an event handler from an element.  The shorthand version {@link #un} is equivalent.  Typically\n        * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.\n        * @param {String/HTMLElement} el The id or html element from which to remove the listener.\n        * @param {String} eventName The name of the event.\n        * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>\n        * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,\n        * then this must refer to the same object.\n        */\n        removeListener : function(element, eventName, fn, scope) {\n            // handle our listener config object syntax\n            if (typeof eventName !== 'string') {\n                EventManager.prepareListenerConfig(element, eventName, true);\n                return;\n            }\n\n            var dom = Ext.getDom(element),\n                el = element.dom ? element : Ext.get(dom),\n                cache = EventManager.getEventListenerCache(el, eventName),\n                bindName = EventManager.normalizeEvent(eventName).eventName,\n                i = cache.length, j,\n                listener, wrap, tasks;\n\n\n            while (i--) {\n                listener = cache[i];\n\n                if (listener && (!fn || listener.fn == fn) && (!scope || listener.scope === scope)) {\n                    wrap = listener.wrap;\n\n                    // clear buffered calls\n                    if (wrap.task) {\n                        clearTimeout(wrap.task);\n                        delete wrap.task;\n                    }\n\n                    // clear delayed calls\n                    j = wrap.tasks && wrap.tasks.length;\n                    if (j) {\n                        while (j--) {\n                            clearTimeout(wrap.tasks[j]);\n                        }\n                        delete wrap.tasks;\n                    }\n\n                    if (dom.detachEvent) {\n                        dom.detachEvent('on' + bindName, wrap);\n                    } else {\n                        dom.removeEventListener(bindName, wrap, false);\n                    }\n\n                    if (wrap && dom == doc && eventName == 'mousedown') {\n                        EventManager.stoppedMouseDownEvent.removeListener(wrap);\n                    }\n\n                    // remove listener from cache\n                    Ext.Array.erase(cache, i, 1);\n                }\n            }\n        },\n\n        /**\n        * Removes all event handers from an element.  Typically you will use {@link Ext.Element#removeAllListeners}\n        * directly on an Element in favor of calling this version.\n        * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.\n        */\n        removeAll : function(element) {\n            var el = element.dom ? element : Ext.get(element),\n                cache, events, eventName;\n\n            if (!el) {\n                return;\n            }\n            cache = (el.$cache || el.getCache());\n            events = cache.events;\n\n            for (eventName in events) {\n                if (events.hasOwnProperty(eventName)) {\n                    EventManager.removeListener(el, eventName);\n                }\n            }\n            cache.events = {};\n        },\n\n        /**\n         * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.Element#purgeAllListeners}\n         * directly on an Element in favor of calling this version.\n         * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.\n         * @param {String} eventName (optional) The name of the event.\n         */\n        purgeElement : function(element, eventName) {\n            var dom = Ext.getDom(element),\n                i = 0, len;\n\n            if (eventName) {\n                EventManager.removeListener(element, eventName);\n            }\n            else {\n                EventManager.removeAll(element);\n            }\n\n            if (dom && dom.childNodes) {\n                for (len = element.childNodes.length; i < len; i++) {\n                    EventManager.purgeElement(element.childNodes[i], eventName);\n                }\n            }\n        },\n\n        /**\n         * Create the wrapper function for the event\n         * @private\n         * @param {HTMLElement} dom The dom element\n         * @param {String} ename The event name\n         * @param {Function} fn The function to execute\n         * @param {Object} scope The scope to execute callback in\n         * @param {Object} options The options\n         * @return {Function} the wrapper function\n         */\n        createListenerWrap : function(dom, ename, fn, scope, options) {\n            options = options || {};\n\n            var f, gen, escapeRx = /\\\\/g, wrap = function(e, args) {\n                // Compile the implementation upon first firing\n                if (!gen) {\n                    f = ['if(!' + Ext.name + ') {return;}'];\n\n                    if(options.buffer || options.delay || options.freezeEvent) {\n                        f.push('e = new X.EventObjectImpl(e, ' + (options.freezeEvent ? 'true' : 'false' ) + ');');\n                    } else {\n                        f.push('e = X.EventObject.setEvent(e);');\n                    }\n\n                    if (options.delegate) {\n                        // double up '\\' characters so escape sequences survive the\n                        // string-literal translation\n                        f.push('var result, t = e.getTarget(\"' + (options.delegate + '').replace(escapeRx, '\\\\\\\\') + '\", this);');\n                        f.push('if(!t) {return;}');\n                    } else {\n                        f.push('var t = e.target, result;');\n                    }\n\n                    if (options.target) {\n                        f.push('if(e.target !== options.target) {return;}');\n                    }\n\n                    if(options.stopEvent) {\n                        f.push('e.stopEvent();');\n                    } else {\n                        if(options.preventDefault) {\n                            f.push('e.preventDefault();');\n                        }\n                        if(options.stopPropagation) {\n                            f.push('e.stopPropagation();');\n                        }\n                    }\n\n                    if(options.normalized === false) {\n                        f.push('e = e.browserEvent;');\n                    }\n\n                    if(options.buffer) {\n                        f.push('(wrap.task && clearTimeout(wrap.task));');\n                        f.push('wrap.task = setTimeout(function() {');\n                    }\n\n                    if(options.delay) {\n                        f.push('wrap.tasks = wrap.tasks || [];');\n                        f.push('wrap.tasks.push(setTimeout(function() {');\n                    }\n\n                    // finally call the actual handler fn\n                    f.push('result = fn.call(scope || dom, e, t, options);');\n\n                    if(options.single) {\n                        f.push('evtMgr.removeListener(dom, ename, fn, scope);');\n                    }\n\n                    // Fire the global idle event for all events except mousemove which is too common, and\n                    // fires too frequently and fast to be use in tiggering onIdle processing.\n                    if (ename !== 'mousemove') {\n                        f.push('if (evtMgr.idleEvent.listeners.length) {');\n                        f.push('evtMgr.idleEvent.fire();');\n                        f.push('}');\n                    }\n\n                    if(options.delay) {\n                        f.push('}, ' + options.delay + '));');\n                    }\n\n                    if(options.buffer) {\n                        f.push('}, ' + options.buffer + ');');\n                    }\n                    f.push('return result;')\n\n                    gen = Ext.cacheableFunctionFactory('e', 'options', 'fn', 'scope', 'ename', 'dom', 'wrap', 'args', 'X', 'evtMgr', f.join('\\n'));\n                }\n\n                return gen.call(dom, e, options, fn, scope, ename, dom, wrap, args, Ext, EventManager);\n            };\n            return wrap;\n        },\n\n        /**\n         * Get the event cache for a particular element for a particular event\n         * @private\n         * @param {HTMLElement} element The element\n         * @param {Object} eventName The event name\n         * @return {Array} The events for the element\n         */\n        getEventListenerCache : function(element, eventName) {\n            var elementCache, eventCache;\n            if (!element) {\n                return [];\n            }\n\n            if (element.$cache) {\n                elementCache = element.$cache;\n            } else {\n                // getId will populate the cache for this element if it isn't already present\n                elementCache = Ext.cache[EventManager.getId(element)];\n            }\n            eventCache = elementCache.events || (elementCache.events = {});\n\n            return eventCache[eventName] || (eventCache[eventName] = []);\n        },\n\n        // --------------------- utility methods ---------------------\n        mouseLeaveRe: /(mouseout|mouseleave)/,\n        mouseEnterRe: /(mouseover|mouseenter)/,\n\n        /**\n         * Stop the event (preventDefault and stopPropagation)\n         * @param {Event} The event to stop\n         */\n        stopEvent: function(event) {\n            EventManager.stopPropagation(event);\n            EventManager.preventDefault(event);\n        },\n\n        /**\n         * Cancels bubbling of the event.\n         * @param {Event} The event to stop bubbling.\n         */\n        stopPropagation: function(event) {\n            event = event.browserEvent || event;\n            if (event.stopPropagation) {\n                event.stopPropagation();\n            } else {\n                event.cancelBubble = true;\n            }\n        },\n\n        /**\n         * Prevents the browsers default handling of the event.\n         * @param {Event} The event to prevent the default\n         */\n        preventDefault: function(event) {\n            event = event.browserEvent || event;\n            if (event.preventDefault) {\n                event.preventDefault();\n            } else {\n                event.returnValue = false;\n                // Some keys events require setting the keyCode to -1 to be prevented\n                try {\n                  // all ctrl + X and F1 -> F12\n                  if (event.ctrlKey || event.keyCode > 111 && event.keyCode < 124) {\n                      event.keyCode = -1;\n                  }\n                } catch (e) {\n                    // see this outdated document http://support.microsoft.com/kb/934364/en-us for more info\n                }\n            }\n        },\n\n        /**\n         * Gets the related target from the event.\n         * @param {Object} event The event\n         * @return {HTMLElement} The related target.\n         */\n        getRelatedTarget: function(event) {\n            event = event.browserEvent || event;\n            var target = event.relatedTarget;\n            if (!target) {\n                if (EventManager.mouseLeaveRe.test(event.type)) {\n                    target = event.toElement;\n                } else if (EventManager.mouseEnterRe.test(event.type)) {\n                    target = event.fromElement;\n                }\n            }\n            return EventManager.resolveTextNode(target);\n        },\n\n        /**\n         * Gets the x coordinate from the event\n         * @param {Object} event The event\n         * @return {Number} The x coordinate\n         */\n        getPageX: function(event) {\n            return EventManager.getPageXY(event)[0];\n        },\n\n        /**\n         * Gets the y coordinate from the event\n         * @param {Object} event The event\n         * @return {Number} The y coordinate\n         */\n        getPageY: function(event) {\n            return EventManager.getPageXY(event)[1];\n        },\n\n        /**\n         * Gets the x & y coordinate from the event\n         * @param {Object} event The event\n         * @return {Number[]} The x/y coordinate\n         */\n        getPageXY: function(event) {\n            event = event.browserEvent || event;\n            var x = event.pageX,\n                y = event.pageY,\n                docEl = doc.documentElement,\n                body = doc.body;\n\n            // pageX/pageY not available (undefined, not null), use clientX/clientY instead\n            if (!x && x !== 0) {\n                x = event.clientX + (docEl && docEl.scrollLeft || body && body.scrollLeft || 0) - (docEl && docEl.clientLeft || body && body.clientLeft || 0);\n                y = event.clientY + (docEl && docEl.scrollTop  || body && body.scrollTop  || 0) - (docEl && docEl.clientTop  || body && body.clientTop  || 0);\n            }\n            return [x, y];\n        },\n\n        /**\n         * Gets the target of the event.\n         * @param {Object} event The event\n         * @return {HTMLElement} target\n         */\n        getTarget: function(event) {\n            event = event.browserEvent || event;\n            return EventManager.resolveTextNode(event.target || event.srcElement);\n        },\n\n        // technically no need to browser sniff this, however it makes\n        // no sense to check this every time, for every event, whether\n        // the string is equal.\n        /**\n         * Resolve any text nodes accounting for browser differences.\n         * @private\n         * @param {HTMLElement} node The node\n         * @return {HTMLElement} The resolved node\n         */\n        resolveTextNode: Ext.isGecko ?\n            function(node) {\n                if (!node) {\n                    return;\n                }\n                // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197\n                var s = HTMLElement.prototype.toString.call(node);\n                if (s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]') {\n                    return;\n                }\n                    return node.nodeType == 3 ? node.parentNode: node;\n                }: function(node) {\n                    return node && node.nodeType == 3 ? node.parentNode: node;\n                },\n\n        // --------------------- custom event binding ---------------------\n\n        // Keep track of the current width/height\n        curWidth: 0,\n        curHeight: 0,\n\n        /**\n         * Adds a listener to be notified when the browser window is resized and provides resize event buffering (100 milliseconds),\n         * passes new viewport width and height to handlers.\n         * @param {Function} fn      The handler function the window resize event invokes.\n         * @param {Object}   scope   The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.\n         * @param {Boolean}  options Options object as passed to {@link Ext.Element#addListener}\n         */\n        onWindowResize: function(fn, scope, options) {\n            var resize = EventManager.resizeEvent;\n\n            if (!resize) {\n                EventManager.resizeEvent = resize = new Ext.util.Event();\n                EventManager.on(win, 'resize', EventManager.fireResize, null, {buffer: 100});\n            }\n            resize.addListener(fn, scope, options);\n        },\n\n        /**\n         * Fire the resize event.\n         * @private\n         */\n        fireResize: function() {\n            var w = Ext.Element.getViewWidth(),\n                h = Ext.Element.getViewHeight();\n\n             //whacky problem in IE where the resize event will sometimes fire even though the w/h are the same.\n             if (EventManager.curHeight != h || EventManager.curWidth != w) {\n                 EventManager.curHeight = h;\n                 EventManager.curWidth = w;\n                 EventManager.resizeEvent.fire(w, h);\n             }\n        },\n\n        /**\n         * Removes the passed window resize listener.\n         * @param {Function} fn        The method the event invokes\n         * @param {Object}   scope    The scope of handler\n         */\n        removeResizeListener: function(fn, scope) {\n            var resize = EventManager.resizeEvent;\n            if (resize) {\n                resize.removeListener(fn, scope);\n            }\n        },\n\n        /**\n         * Adds a listener to be notified when the browser window is unloaded.\n         * @param {Function} fn      The handler function the window unload event invokes.\n         * @param {Object}   scope   The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.\n         * @param {Boolean}  options Options object as passed to {@link Ext.Element#addListener}\n         */\n        onWindowUnload: function(fn, scope, options) {\n            var unload = EventManager.unloadEvent;\n\n            if (!unload) {\n                EventManager.unloadEvent = unload = new Ext.util.Event();\n                EventManager.addListener(win, 'unload', EventManager.fireUnload);\n            }\n            if (fn) {\n                unload.addListener(fn, scope, options);\n            }\n        },\n\n        /**\n         * Fires the unload event for items bound with onWindowUnload\n         * @private\n         */\n        fireUnload: function() {\n            // wrap in a try catch, could have some problems during unload\n            try {\n                // relinquish references.\n                doc = win = undefined;\n\n                var gridviews, i, ln,\n                    el, cache;\n\n                EventManager.unloadEvent.fire();\n                // Work around FF3 remembering the last scroll position when refreshing the grid and then losing grid view\n                if (Ext.isGecko3) {\n                    gridviews = Ext.ComponentQuery.query('gridview');\n                    i = 0;\n                    ln = gridviews.length;\n                    for (; i < ln; i++) {\n                        gridviews[i].scrollToTop();\n                    }\n                }\n                // Purge all elements in the cache\n                cache = Ext.cache;\n\n                for (el in cache) {\n                    if (cache.hasOwnProperty(el)) {\n                        EventManager.removeAll(el);\n                    }\n                }\n            } catch(e) {\n            }\n        },\n\n        /**\n         * Removes the passed window unload listener.\n         * @param {Function} fn        The method the event invokes\n         * @param {Object}   scope    The scope of handler\n         */\n        removeUnloadListener: function(fn, scope) {\n            var unload = EventManager.unloadEvent;\n            if (unload) {\n                unload.removeListener(fn, scope);\n            }\n        },\n\n        /**\n         * note 1: IE fires ONLY the keydown event on specialkey autorepeat\n         * note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat\n         * (research done by Jan Wolter at http://unixpapa.com/js/key.html)\n         * @private\n         */\n        useKeyDown: Ext.isWebKit ?\n                       parseInt(navigator.userAgent.match(/AppleWebKit\\/(\\d+)/)[1], 10) >= 525 :\n                       !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera),\n\n        /**\n         * Indicates which event to use for getting key presses.\n         * @return {String} The appropriate event name.\n         */\n        getKeyEvent: function() {\n            return EventManager.useKeyDown ? 'keydown' : 'keypress';\n        }\n    });\n\n    // route \"< ie9-Standards\" to a legacy IE onReady implementation\n    if(!('addEventListener' in document) && document.attachEvent) {\n        Ext.apply( EventManager, {\n            /* Customized implementation for Legacy IE.  The default implementation is configured for use\n             *  with all other 'standards compliant' agents.\n             *  References: http://javascript.nwbox.com/IEContentLoaded/\n             *  licensed courtesy of http://developer.yahoo.com/yui/license.html\n             */\n\n            /**\n             * This strategy has minimal benefits for Sencha solutions that build themselves (ie. minimal initial page markup).\n             * However, progressively-enhanced pages (with image content and/or embedded frames) will benefit the most from it.\n             * Browser timer resolution is too poor to ensure a doScroll check more than once on a page loaded with minimal\n             * assets (the readystatechange event 'complete' usually beats the doScroll timer on a 'lightly-loaded' initial document).\n             */\n            pollScroll : function() {\n                var scrollable = true;\n\n                try {\n                    document.documentElement.doScroll('left');\n                } catch(e) {\n                    scrollable = false;\n                }\n\n                // on IE8, when running within an iFrame, document.body is not immediately available\n                if (scrollable && document.body) {\n                    EventManager.onReadyEvent({\n                        type:'doScroll'\n                    });\n                } else {\n                    /*\n                     * minimize thrashing --\n                     * adjusted for setTimeout's close-to-minimums (not too low),\n                     * as this method SHOULD always be called once initially\n                     */\n                    EventManager.scrollTimeout = setTimeout(EventManager.pollScroll, 20);\n                }\n\n                return scrollable;\n            },\n\n            /**\n             * Timer for doScroll polling\n             * @private\n             */\n            scrollTimeout: null,\n\n            /* @private\n             */\n            readyStatesRe  : /complete/i,\n\n            /* @private\n             */\n            checkReadyState: function() {\n                var state = document.readyState;\n\n                if (EventManager.readyStatesRe.test(state)) {\n                    EventManager.onReadyEvent({\n                        type: state\n                    });\n                }\n            },\n\n            bindReadyEvent: function() {\n                var topContext = true;\n\n                if (EventManager.hasBoundOnReady) {\n                    return;\n                }\n\n                //are we in an IFRAME? (doScroll ineffective here)\n                try {\n                    topContext = window.frameElement === undefined;\n                } catch(e) {\n                    // If we throw an exception, it means we're probably getting access denied,\n                    // which means we're in an iframe cross domain.\n                    topContext = false;\n                }\n\n                if (!topContext || !doc.documentElement.doScroll) {\n                    EventManager.pollScroll = Ext.emptyFn;   //then noop this test altogether\n                }\n\n                // starts doScroll polling if necessary\n                if (EventManager.pollScroll() === true) {\n                    return;\n                }\n\n                // Core is loaded AFTER initial document write/load ?\n                if (doc.readyState == 'complete' )  {\n                    EventManager.onReadyEvent({type: 'already ' + (doc.readyState || 'body') });\n                } else {\n                    doc.attachEvent('onreadystatechange', EventManager.checkReadyState);\n                    window.attachEvent('onload', EventManager.onReadyEvent);\n                    EventManager.hasBoundOnReady = true;\n                }\n            },\n\n            onReadyEvent : function(e) {\n                if (e && e.type) {\n                    EventManager.onReadyChain.push(e.type);\n                }\n\n                if (EventManager.hasBoundOnReady) {\n                    document.detachEvent('onreadystatechange', EventManager.checkReadyState);\n                    window.detachEvent('onload', EventManager.onReadyEvent);\n                }\n\n                if (Ext.isNumber(EventManager.scrollTimeout)) {\n                    clearTimeout(EventManager.scrollTimeout);\n                    delete EventManager.scrollTimeout;\n                }\n\n                if (!Ext.isReady) {\n                    EventManager.fireDocReady();\n                }\n            },\n\n            //diags: a list of event types passed to onReadyEvent (in chron order)\n            onReadyChain : []\n        });\n    }\n\n\n    /**\n     * Alias for {@link Ext.Loader#onReady Ext.Loader.onReady} with withDomReady set to true\n     * @member Ext\n     * @method onReady\n     */\n    Ext.onReady = function(fn, scope, options) {\n        Ext.Loader.onReady(fn, scope, true, options);\n    };\n\n    /**\n     * Alias for {@link Ext.EventManager#onDocumentReady Ext.EventManager.onDocumentReady}\n     * @member Ext\n     * @method onDocumentReady\n     */\n    Ext.onDocumentReady = EventManager.onDocumentReady;\n\n    /**\n     * Alias for {@link Ext.EventManager#addListener Ext.EventManager.addListener}\n     * @member Ext.EventManager\n     * @method on\n     */\n    EventManager.on = EventManager.addListener;\n\n    /**\n     * Alias for {@link Ext.EventManager#removeListener Ext.EventManager.removeListener}\n     * @member Ext.EventManager\n     * @method un\n     */\n    EventManager.un = EventManager.removeListener;\n\n    Ext.onReady(initExtCss);\n};\n\n//@tag dom,core\n//@require EventManager.js\n//@define Ext.EventObject\n\n/**\n * @class Ext.EventObject\n\nJust as {@link Ext.Element} wraps around a native DOM node, Ext.EventObject\nwraps the browser's native event-object normalizing cross-browser differences,\nsuch as which mouse button is clicked, keys pressed, mechanisms to stop\nevent-propagation along with a method to prevent default actions from taking place.\n\nFor example:\n\n    function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject\n        e.preventDefault();\n        var target = e.getTarget(); // same as t (the target HTMLElement)\n        ...\n    }\n\n    var myDiv = {@link Ext#get Ext.get}(\"myDiv\");  // get reference to an {@link Ext.Element}\n    myDiv.on(         // 'on' is shorthand for addListener\n        \"click\",      // perform an action on click of myDiv\n        handleClick   // reference to the action handler\n    );\n\n    // other methods to do the same:\n    Ext.EventManager.on(\"myDiv\", 'click', handleClick);\n    Ext.EventManager.addListener(\"myDiv\", 'click', handleClick);\n\n * @singleton\n * @markdown\n */\nExt.define('Ext.EventObjectImpl', {\n    uses: ['Ext.util.Point'],\n\n    /** Key constant @type Number */\n    BACKSPACE: 8,\n    /** Key constant @type Number */\n    TAB: 9,\n    /** Key constant @type Number */\n    NUM_CENTER: 12,\n    /** Key constant @type Number */\n    ENTER: 13,\n    /** Key constant @type Number */\n    RETURN: 13,\n    /** Key constant @type Number */\n    SHIFT: 16,\n    /** Key constant @type Number */\n    CTRL: 17,\n    /** Key constant @type Number */\n    ALT: 18,\n    /** Key constant @type Number */\n    PAUSE: 19,\n    /** Key constant @type Number */\n    CAPS_LOCK: 20,\n    /** Key constant @type Number */\n    ESC: 27,\n    /** Key constant @type Number */\n    SPACE: 32,\n    /** Key constant @type Number */\n    PAGE_UP: 33,\n    /** Key constant @type Number */\n    PAGE_DOWN: 34,\n    /** Key constant @type Number */\n    END: 35,\n    /** Key constant @type Number */\n    HOME: 36,\n    /** Key constant @type Number */\n    LEFT: 37,\n    /** Key constant @type Number */\n    UP: 38,\n    /** Key constant @type Number */\n    RIGHT: 39,\n    /** Key constant @type Number */\n    DOWN: 40,\n    /** Key constant @type Number */\n    PRINT_SCREEN: 44,\n    /** Key constant @type Number */\n    INSERT: 45,\n    /** Key constant @type Number */\n    DELETE: 46,\n    /** Key constant @type Number */\n    ZERO: 48,\n    /** Key constant @type Number */\n    ONE: 49,\n    /** Key constant @type Number */\n    TWO: 50,\n    /** Key constant @type Number */\n    THREE: 51,\n    /** Key constant @type Number */\n    FOUR: 52,\n    /** Key constant @type Number */\n    FIVE: 53,\n    /** Key constant @type Number */\n    SIX: 54,\n    /** Key constant @type Number */\n    SEVEN: 55,\n    /** Key constant @type Number */\n    EIGHT: 56,\n    /** Key constant @type Number */\n    NINE: 57,\n    /** Key constant @type Number */\n    A: 65,\n    /** Key constant @type Number */\n    B: 66,\n    /** Key constant @type Number */\n    C: 67,\n    /** Key constant @type Number */\n    D: 68,\n    /** Key constant @type Number */\n    E: 69,\n    /** Key constant @type Number */\n    F: 70,\n    /** Key constant @type Number */\n    G: 71,\n    /** Key constant @type Number */\n    H: 72,\n    /** Key constant @type Number */\n    I: 73,\n    /** Key constant @type Number */\n    J: 74,\n    /** Key constant @type Number */\n    K: 75,\n    /** Key constant @type Number */\n    L: 76,\n    /** Key constant @type Number */\n    M: 77,\n    /** Key constant @type Number */\n    N: 78,\n    /** Key constant @type Number */\n    O: 79,\n    /** Key constant @type Number */\n    P: 80,\n    /** Key constant @type Number */\n    Q: 81,\n    /** Key constant @type Number */\n    R: 82,\n    /** Key constant @type Number */\n    S: 83,\n    /** Key constant @type Number */\n    T: 84,\n    /** Key constant @type Number */\n    U: 85,\n    /** Key constant @type Number */\n    V: 86,\n    /** Key constant @type Number */\n    W: 87,\n    /** Key constant @type Number */\n    X: 88,\n    /** Key constant @type Number */\n    Y: 89,\n    /** Key constant @type Number */\n    Z: 90,\n    /** Key constant @type Number */\n    CONTEXT_MENU: 93,\n    /** Key constant @type Number */\n    NUM_ZERO: 96,\n    /** Key constant @type Number */\n    NUM_ONE: 97,\n    /** Key constant @type Number */\n    NUM_TWO: 98,\n    /** Key constant @type Number */\n    NUM_THREE: 99,\n    /** Key constant @type Number */\n    NUM_FOUR: 100,\n    /** Key constant @type Number */\n    NUM_FIVE: 101,\n    /** Key constant @type Number */\n    NUM_SIX: 102,\n    /** Key constant @type Number */\n    NUM_SEVEN: 103,\n    /** Key constant @type Number */\n    NUM_EIGHT: 104,\n    /** Key constant @type Number */\n    NUM_NINE: 105,\n    /** Key constant @type Number */\n    NUM_MULTIPLY: 106,\n    /** Key constant @type Number */\n    NUM_PLUS: 107,\n    /** Key constant @type Number */\n    NUM_MINUS: 109,\n    /** Key constant @type Number */\n    NUM_PERIOD: 110,\n    /** Key constant @type Number */\n    NUM_DIVISION: 111,\n    /** Key constant @type Number */\n    F1: 112,\n    /** Key constant @type Number */\n    F2: 113,\n    /** Key constant @type Number */\n    F3: 114,\n    /** Key constant @type Number */\n    F4: 115,\n    /** Key constant @type Number */\n    F5: 116,\n    /** Key constant @type Number */\n    F6: 117,\n    /** Key constant @type Number */\n    F7: 118,\n    /** Key constant @type Number */\n    F8: 119,\n    /** Key constant @type Number */\n    F9: 120,\n    /** Key constant @type Number */\n    F10: 121,\n    /** Key constant @type Number */\n    F11: 122,\n    /** Key constant @type Number */\n    F12: 123,\n    /**\n     * The mouse wheel delta scaling factor. This value depends on browser version and OS and\n     * attempts to produce a similar scrolling experience across all platforms and browsers.\n     *\n     * To change this value:\n     *\n     *      Ext.EventObjectImpl.prototype.WHEEL_SCALE = 72;\n     *\n     * @type Number\n     * @markdown\n     */\n    WHEEL_SCALE: (function () {\n        var scale;\n\n        if (Ext.isGecko) {\n            // Firefox uses 3 on all platforms\n            scale = 3;\n        } else if (Ext.isMac) {\n            // Continuous scrolling devices have momentum and produce much more scroll than\n            // discrete devices on the same OS and browser. To make things exciting, Safari\n            // (and not Chrome) changed from small values to 120 (like IE).\n\n            if (Ext.isSafari && Ext.webKitVersion >= 532.0) {\n                // Safari changed the scrolling factor to match IE (for details see\n                // https://bugs.webkit.org/show_bug.cgi?id=24368). The WebKit version where this\n                // change was introduced was 532.0\n                //      Detailed discussion:\n                //      https://bugs.webkit.org/show_bug.cgi?id=29601\n                //      http://trac.webkit.org/browser/trunk/WebKit/chromium/src/mac/WebInputEventFactory.mm#L1063\n                scale = 120;\n            } else {\n                // MS optical wheel mouse produces multiples of 12 which is close enough\n                // to help tame the speed of the continuous mice...\n                scale = 12;\n            }\n\n            // Momentum scrolling produces very fast scrolling, so increase the scale factor\n            // to help produce similar results cross platform. This could be even larger and\n            // it would help those mice, but other mice would become almost unusable as a\n            // result (since we cannot tell which device type is in use).\n            scale *= 3;\n        } else {\n            // IE, Opera and other Windows browsers use 120.\n            scale = 120;\n        }\n\n        return scale;\n    }()),\n\n    /**\n     * Simple click regex\n     * @private\n     */\n    clickRe: /(dbl)?click/,\n    // safari keypress events for special keys return bad keycodes\n    safariKeys: {\n        3: 13, // enter\n        63234: 37, // left\n        63235: 39, // right\n        63232: 38, // up\n        63233: 40, // down\n        63276: 33, // page up\n        63277: 34, // page down\n        63272: 46, // delete\n        63273: 36, // home\n        63275: 35 // end\n    },\n    // normalize button clicks, don't see any way to feature detect this.\n    btnMap: Ext.isIE ? {\n        1: 0,\n        4: 1,\n        2: 2\n    } : {\n        0: 0,\n        1: 1,\n        2: 2\n    },\n    \n    /**\n     * @property {Boolean} ctrlKey\n     * True if the control key was down during the event.\n     * In Mac this will also be true when meta key was down.\n     */\n    /**\n     * @property {Boolean} altKey\n     * True if the alt key was down during the event.\n     */\n    /**\n     * @property {Boolean} shiftKey\n     * True if the shift key was down during the event.\n     */\n\n    constructor: function(event, freezeEvent){\n        if (event) {\n            this.setEvent(event.browserEvent || event, freezeEvent);\n        }\n    },\n\n    setEvent: function(event, freezeEvent){\n        var me = this, button, options;\n\n        if (event == me || (event && event.browserEvent)) { // already wrapped\n            return event;\n        }\n        me.browserEvent = event;\n        if (event) {\n            // normalize buttons\n            button = event.button ? me.btnMap[event.button] : (event.which ? event.which - 1 : -1);\n            if (me.clickRe.test(event.type) && button == -1) {\n                button = 0;\n            }\n            options = {\n                type: event.type,\n                button: button,\n                shiftKey: event.shiftKey,\n                // mac metaKey behaves like ctrlKey\n                ctrlKey: event.ctrlKey || event.metaKey || false,\n                altKey: event.altKey,\n                // in getKey these will be normalized for the mac\n                keyCode: event.keyCode,\n                charCode: event.charCode,\n                // cache the targets for the delayed and or buffered events\n                target: Ext.EventManager.getTarget(event),\n                relatedTarget: Ext.EventManager.getRelatedTarget(event),\n                currentTarget: event.currentTarget,\n                xy: (freezeEvent ? me.getXY() : null)\n            };\n        } else {\n            options = {\n                button: -1,\n                shiftKey: false,\n                ctrlKey: false,\n                altKey: false,\n                keyCode: 0,\n                charCode: 0,\n                target: null,\n                xy: [0, 0]\n            };\n        }\n        Ext.apply(me, options);\n        return me;\n    },\n\n    /**\n     * Stop the event (preventDefault and stopPropagation)\n     */\n    stopEvent: function(){\n        this.stopPropagation();\n        this.preventDefault();\n    },\n\n    /**\n     * Prevents the browsers default handling of the event.\n     */\n    preventDefault: function(){\n        if (this.browserEvent) {\n            Ext.EventManager.preventDefault(this.browserEvent);\n        }\n    },\n\n    /**\n     * Cancels bubbling of the event.\n     */\n    stopPropagation: function(){\n        var browserEvent = this.browserEvent;\n\n        if (browserEvent) {\n            if (browserEvent.type == 'mousedown') {\n                Ext.EventManager.stoppedMouseDownEvent.fire(this);\n            }\n            Ext.EventManager.stopPropagation(browserEvent);\n        }\n    },\n\n    /**\n     * Gets the character code for the event.\n     * @return {Number}\n     */\n    getCharCode: function(){\n        return this.charCode || this.keyCode;\n    },\n\n    /**\n     * Returns a normalized keyCode for the event.\n     * @return {Number} The key code\n     */\n    getKey: function(){\n        return this.normalizeKey(this.keyCode || this.charCode);\n    },\n\n    /**\n     * Normalize key codes across browsers\n     * @private\n     * @param {Number} key The key code\n     * @return {Number} The normalized code\n     */\n    normalizeKey: function(key){\n        // can't feature detect this\n        return Ext.isWebKit ? (this.safariKeys[key] || key) : key;\n    },\n\n    /**\n     * Gets the x coordinate of the event.\n     * @return {Number}\n     * @deprecated 4.0 Replaced by {@link #getX}\n     */\n    getPageX: function(){\n        return this.getX();\n    },\n\n    /**\n     * Gets the y coordinate of the event.\n     * @return {Number}\n     * @deprecated 4.0 Replaced by {@link #getY}\n     */\n    getPageY: function(){\n        return this.getY();\n    },\n\n    /**\n     * Gets the x coordinate of the event.\n     * @return {Number}\n     */\n    getX: function() {\n        return this.getXY()[0];\n    },\n\n    /**\n     * Gets the y coordinate of the event.\n     * @return {Number}\n     */\n    getY: function() {\n        return this.getXY()[1];\n    },\n\n    /**\n     * Gets the page coordinates of the event.\n     * @return {Number[]} The xy values like [x, y]\n     */\n    getXY: function() {\n        if (!this.xy) {\n            // same for XY\n            this.xy = Ext.EventManager.getPageXY(this.browserEvent);\n        }\n        return this.xy;\n    },\n\n    /**\n     * Gets the target for the event.\n     * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target\n     * @param {Number/HTMLElement} maxDepth (optional) The max depth to search as a number or element (defaults to 10 || document.body)\n     * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node\n     * @return {HTMLElement}\n     */\n    getTarget : function(selector, maxDepth, returnEl){\n        if (selector) {\n            return Ext.fly(this.target).findParent(selector, maxDepth, returnEl);\n        }\n        return returnEl ? Ext.get(this.target) : this.target;\n    },\n\n    /**\n     * Gets the related target.\n     * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target\n     * @param {Number/HTMLElement} maxDepth (optional) The max depth to search as a number or element (defaults to 10 || document.body)\n     * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node\n     * @return {HTMLElement}\n     */\n    getRelatedTarget : function(selector, maxDepth, returnEl){\n        if (selector) {\n            return Ext.fly(this.relatedTarget).findParent(selector, maxDepth, returnEl);\n        }\n        return returnEl ? Ext.get(this.relatedTarget) : this.relatedTarget;\n    },\n\n    /**\n     * Correctly scales a given wheel delta.\n     * @param {Number} delta The delta value.\n     */\n    correctWheelDelta : function (delta) {\n        var scale = this.WHEEL_SCALE,\n            ret = Math.round(delta / scale);\n\n        if (!ret && delta) {\n            ret = (delta < 0) ? -1 : 1; // don't allow non-zero deltas to go to zero!\n        }\n\n        return ret;\n    },\n\n    /**\n     * Returns the mouse wheel deltas for this event.\n     * @return {Object} An object with \"x\" and \"y\" properties holding the mouse wheel deltas.\n     */\n    getWheelDeltas : function () {\n        var me = this,\n            event = me.browserEvent,\n            dx = 0, dy = 0; // the deltas\n\n        if (Ext.isDefined(event.wheelDeltaX)) { // WebKit has both dimensions\n            dx = event.wheelDeltaX;\n            dy = event.wheelDeltaY;\n        } else if (event.wheelDelta) { // old WebKit and IE\n            dy = event.wheelDelta;\n        } else if (event.detail) { // Gecko\n            dy = -event.detail; // gecko is backwards\n\n            // Gecko sometimes returns really big values if the user changes settings to\n            // scroll a whole page per scroll\n            if (dy > 100) {\n                dy = 3;\n            } else if (dy < -100) {\n                dy = -3;\n            }\n\n            // Firefox 3.1 adds an axis field to the event to indicate direction of\n            // scroll.  See https://developer.mozilla.org/en/Gecko-Specific_DOM_Events\n            if (Ext.isDefined(event.axis) && event.axis === event.HORIZONTAL_AXIS) {\n                dx = dy;\n                dy = 0;\n            }\n        }\n\n        return {\n            x: me.correctWheelDelta(dx),\n            y: me.correctWheelDelta(dy)\n        };\n    },\n\n    /**\n     * Normalizes mouse wheel y-delta across browsers. To get x-delta information, use\n     * {@link #getWheelDeltas} instead.\n     * @return {Number} The mouse wheel y-delta\n     */\n    getWheelDelta : function(){\n        var deltas = this.getWheelDeltas();\n\n        return deltas.y;\n    },\n\n    /**\n     * Returns true if the target of this event is a child of el.  Unless the allowEl parameter is set, it will return false if if the target is el.\n     * Example usage:<pre><code>\n// Handle click on any child of an element\nExt.getBody().on('click', function(e){\n    if(e.within('some-el')){\n        alert('Clicked on a child of some-el!');\n    }\n});\n\n// Handle click directly on an element, ignoring clicks on child nodes\nExt.getBody().on('click', function(e,t){\n    if((t.id == 'some-el') && !e.within(t, true)){\n        alert('Clicked directly on some-el!');\n    }\n});\n</code></pre>\n     * @param {String/HTMLElement/Ext.Element} el The id, DOM element or Ext.Element to check\n     * @param {Boolean} related (optional) true to test if the related target is within el instead of the target\n     * @param {Boolean} allowEl (optional) true to also check if the passed element is the target or related target\n     * @return {Boolean}\n     */\n    within : function(el, related, allowEl){\n        if(el){\n            var t = related ? this.getRelatedTarget() : this.getTarget(),\n                result;\n\n            if (t) {\n                result = Ext.fly(el).contains(t);\n                if (!result && allowEl) {\n                    result = t == Ext.getDom(el);\n                }\n                return result;\n            }\n        }\n        return false;\n    },\n\n    /**\n     * Checks if the key pressed was a \"navigation\" key\n     * @return {Boolean} True if the press is a navigation keypress\n     */\n    isNavKeyPress : function(){\n        var me = this,\n            k = this.normalizeKey(me.keyCode);\n\n       return (k >= 33 && k <= 40) ||  // Page Up/Down, End, Home, Left, Up, Right, Down\n       k == me.RETURN ||\n       k == me.TAB ||\n       k == me.ESC;\n    },\n\n    /**\n     * Checks if the key pressed was a \"special\" key\n     * @return {Boolean} True if the press is a special keypress\n     */\n    isSpecialKey : function(){\n        var k = this.normalizeKey(this.keyCode);\n        return (this.type == 'keypress' && this.ctrlKey) ||\n        this.isNavKeyPress() ||\n        (k == this.BACKSPACE) || // Backspace\n        (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock\n        (k >= 44 && k <= 46);   // Print Screen, Insert, Delete\n    },\n\n    /**\n     * Returns a point object that consists of the object coordinates.\n     * @return {Ext.util.Point} point\n     */\n    getPoint : function(){\n        var xy = this.getXY();\n        return new Ext.util.Point(xy[0], xy[1]);\n    },\n\n   /**\n    * Returns true if the control, meta, shift or alt key was pressed during this event.\n    * @return {Boolean}\n    */\n    hasModifier : function(){\n        return this.ctrlKey || this.altKey || this.shiftKey || this.metaKey;\n    },\n\n    /**\n     * Injects a DOM event using the data in this object and (optionally) a new target.\n     * This is a low-level technique and not likely to be used by application code. The\n     * currently supported event types are:\n     * <p><b>HTMLEvents</b></p>\n     * <ul>\n     * <li>load</li>\n     * <li>unload</li>\n     * <li>select</li>\n     * <li>change</li>\n     * <li>submit</li>\n     * <li>reset</li>\n     * <li>resize</li>\n     * <li>scroll</li>\n     * </ul>\n     * <p><b>MouseEvents</b></p>\n     * <ul>\n     * <li>click</li>\n     * <li>dblclick</li>\n     * <li>mousedown</li>\n     * <li>mouseup</li>\n     * <li>mouseover</li>\n     * <li>mousemove</li>\n     * <li>mouseout</li>\n     * </ul>\n     * <p><b>UIEvents</b></p>\n     * <ul>\n     * <li>focusin</li>\n     * <li>focusout</li>\n     * <li>activate</li>\n     * <li>focus</li>\n     * <li>blur</li>\n     * </ul>\n     * @param {Ext.Element/HTMLElement} target (optional) If specified, the target for the event. This\n     * is likely to be used when relaying a DOM event. If not specified, {@link #getTarget}\n     * is used to determine the target.\n     */\n    injectEvent: (function () {\n        var API,\n            dispatchers = {}, // keyed by event type (e.g., 'mousedown')\n            crazyIEButtons;\n\n        // Good reference: http://developer.yahoo.com/yui/docs/UserAction.js.html\n\n        // IE9 has createEvent, but this code causes major problems with htmleditor (it\n        // blocks all mouse events and maybe more). TODO\n\n        if (!Ext.isIE && document.createEvent) { // if (DOM compliant)\n            API = {\n                createHtmlEvent: function (doc, type, bubbles, cancelable) {\n                    var event = doc.createEvent('HTMLEvents');\n\n                    event.initEvent(type, bubbles, cancelable);\n                    return event;\n                },\n\n                createMouseEvent: function (doc, type, bubbles, cancelable, detail,\n                                            clientX, clientY, ctrlKey, altKey, shiftKey, metaKey,\n                                            button, relatedTarget) {\n                    var event = doc.createEvent('MouseEvents'),\n                        view = doc.defaultView || window;\n\n                    if (event.initMouseEvent) {\n                        event.initMouseEvent(type, bubbles, cancelable, view, detail,\n                                    clientX, clientY, clientX, clientY, ctrlKey, altKey,\n                                    shiftKey, metaKey, button, relatedTarget);\n                    } else { // old Safari\n                        event = doc.createEvent('UIEvents');\n                        event.initEvent(type, bubbles, cancelable);\n                        event.view = view;\n                        event.detail = detail;\n                        event.screenX = clientX;\n                        event.screenY = clientY;\n                        event.clientX = clientX;\n                        event.clientY = clientY;\n                        event.ctrlKey = ctrlKey;\n                        event.altKey = altKey;\n                        event.metaKey = metaKey;\n                        event.shiftKey = shiftKey;\n                        event.button = button;\n                        event.relatedTarget = relatedTarget;\n                    }\n\n                    return event;\n                },\n\n                createUIEvent: function (doc, type, bubbles, cancelable, detail) {\n                    var event = doc.createEvent('UIEvents'),\n                        view = doc.defaultView || window;\n\n                    event.initUIEvent(type, bubbles, cancelable, view, detail);\n                    return event;\n                },\n\n                fireEvent: function (target, type, event) {\n                    target.dispatchEvent(event);\n                },\n\n                fixTarget: function (target) {\n                    // Safari3 doesn't have window.dispatchEvent()\n                    if (target == window && !target.dispatchEvent) {\n                        return document;\n                    }\n\n                    return target;\n                }\n            };\n        } else if (document.createEventObject) { // else if (IE)\n            crazyIEButtons = { 0: 1, 1: 4, 2: 2 };\n\n            API = {\n                createHtmlEvent: function (doc, type, bubbles, cancelable) {\n                    var event = doc.createEventObject();\n                    event.bubbles = bubbles;\n                    event.cancelable = cancelable;\n                    return event;\n                },\n\n                createMouseEvent: function (doc, type, bubbles, cancelable, detail,\n                                            clientX, clientY, ctrlKey, altKey, shiftKey, metaKey,\n                                            button, relatedTarget) {\n                    var event = doc.createEventObject();\n                    event.bubbles = bubbles;\n                    event.cancelable = cancelable;\n                    event.detail = detail;\n                    event.screenX = clientX;\n                    event.screenY = clientY;\n                    event.clientX = clientX;\n                    event.clientY = clientY;\n                    event.ctrlKey = ctrlKey;\n                    event.altKey = altKey;\n                    event.shiftKey = shiftKey;\n                    event.metaKey = metaKey;\n                    event.button = crazyIEButtons[button] || button;\n                    event.relatedTarget = relatedTarget; // cannot assign to/fromElement\n                    return event;\n                },\n\n                createUIEvent: function (doc, type, bubbles, cancelable, detail) {\n                    var event = doc.createEventObject();\n                    event.bubbles = bubbles;\n                    event.cancelable = cancelable;\n                    return event;\n                },\n\n                fireEvent: function (target, type, event) {\n                    target.fireEvent('on' + type, event);\n                },\n\n                fixTarget: function (target) {\n                    if (target == document) {\n                        // IE6,IE7 thinks window==document and doesn't have window.fireEvent()\n                        // IE6,IE7 cannot properly call document.fireEvent()\n                        return document.documentElement;\n                    }\n\n                    return target;\n                }\n            };\n        }\n\n        //----------------\n        // HTMLEvents\n\n        Ext.Object.each({\n                load:   [false, false],\n                unload: [false, false],\n                select: [true, false],\n                change: [true, false],\n                submit: [true, true],\n                reset:  [true, false],\n                resize: [true, false],\n                scroll: [true, false]\n            },\n            function (name, value) {\n                var bubbles = value[0], cancelable = value[1];\n                dispatchers[name] = function (targetEl, srcEvent) {\n                    var e = API.createHtmlEvent(name, bubbles, cancelable);\n                    API.fireEvent(targetEl, name, e);\n                };\n            });\n\n        //----------------\n        // MouseEvents\n\n        function createMouseEventDispatcher (type, detail) {\n            var cancelable = (type != 'mousemove');\n            return function (targetEl, srcEvent) {\n                var xy = srcEvent.getXY(),\n                    e = API.createMouseEvent(targetEl.ownerDocument, type, true, cancelable,\n                                detail, xy[0], xy[1], srcEvent.ctrlKey, srcEvent.altKey,\n                                srcEvent.shiftKey, srcEvent.metaKey, srcEvent.button,\n                                srcEvent.relatedTarget);\n                API.fireEvent(targetEl, type, e);\n            };\n        }\n\n        Ext.each(['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout'],\n            function (eventName) {\n                dispatchers[eventName] = createMouseEventDispatcher(eventName, 1);\n            });\n\n        //----------------\n        // UIEvents\n\n        Ext.Object.each({\n                focusin:  [true, false],\n                focusout: [true, false],\n                activate: [true, true],\n                focus:    [false, false],\n                blur:     [false, false]\n            },\n            function (name, value) {\n                var bubbles = value[0], cancelable = value[1];\n                dispatchers[name] = function (targetEl, srcEvent) {\n                    var e = API.createUIEvent(targetEl.ownerDocument, name, bubbles, cancelable, 1);\n                    API.fireEvent(targetEl, name, e);\n                };\n            });\n\n        //---------\n        if (!API) {\n            // not even sure what ancient browsers fall into this category...\n\n            dispatchers = {}; // never mind all those we just built :P\n\n            API = {\n                fixTarget: function (t) {\n                    return t;\n                }\n            };\n        }\n\n        function cannotInject (target, srcEvent) {\n            // TODO log something\n        }\n\n        return function (target) {\n            var me = this,\n                dispatcher = dispatchers[me.type] || cannotInject,\n                t = target ? (target.dom || target) : me.getTarget();\n\n            t = API.fixTarget(t);\n            dispatcher(t, me);\n        };\n    }()) // call to produce method\n\n}, function() {\n\nExt.EventObject = new Ext.EventObjectImpl();\n\n});\n\n\n//@tag dom,core\n//@require ../EventObject.js\n\n/**\n * @class Ext.dom.AbstractQuery\n * @private\n */\nExt.define('Ext.dom.AbstractQuery', {\n    /**\n     * Selects a group of elements.\n     * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)\n     * @param {HTMLElement/String} [root] The start of the query (defaults to document).\n     * @return {HTMLElement[]} An Array of DOM elements which match the selector. If there are\n     * no matches, and empty Array is returned.\n     */\n    select: function(q, root) {\n        var results = [],\n            nodes,\n            i,\n            j,\n            qlen,\n            nlen;\n\n        root = root || document;\n\n        if (typeof root == 'string') {\n            root = document.getElementById(root);\n        }\n\n        q = q.split(\",\");\n\n        for (i = 0,qlen = q.length; i < qlen; i++) {\n            if (typeof q[i] == 'string') {\n                \n                //support for node attribute selection\n                if (typeof q[i][0] == '@') {\n                    nodes = root.getAttributeNode(q[i].substring(1));\n                    results.push(nodes);\n                } else {\n                    nodes = root.querySelectorAll(q[i]);\n\n                    for (j = 0,nlen = nodes.length; j < nlen; j++) {\n                        results.push(nodes[j]);\n                    }\n                }\n            }\n        }\n\n        return results;\n    },\n\n    /**\n     * Selects a single element.\n     * @param {String} selector The selector/xpath query\n     * @param {HTMLElement/String} [root] The start of the query (defaults to document).\n     * @return {HTMLElement} The DOM element which matched the selector.\n     */\n    selectNode: function(q, root) {\n        return this.select(q, root)[0];\n    },\n\n    /**\n     * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)\n     * @param {String/HTMLElement/Array} el An element id, element or array of elements\n     * @param {String} selector The simple selector to test\n     * @return {Boolean}\n     */\n    is: function(el, q) {\n        if (typeof el == \"string\") {\n            el = document.getElementById(el);\n        }\n        return this.select(q).indexOf(el) !== -1;\n    }\n\n});\n\n//@tag dom,core\n//@require AbstractQuery.js\n\n/**\n * Abstract base class for {@link Ext.dom.Helper}.\n * @private\n */\nExt.define('Ext.dom.AbstractHelper', {\n    emptyTags : /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,\n    confRe : /(?:tag|children|cn|html|tpl|tplData)$/i,\n    endRe : /end/i,\n\n    // Since cls & for are reserved words, we need to transform them\n    attributeTransform: { cls : 'class', htmlFor : 'for' },\n\n    closeTags: {},\n\n    decamelizeName : (function () {\n        var camelCaseRe = /([a-z])([A-Z])/g,\n            cache = {};\n\n        function decamel (match, p1, p2) {\n            return p1 + '-' + p2.toLowerCase();\n        }\n\n        return function (s) {\n            return cache[s] || (cache[s] = s.replace(camelCaseRe, decamel));\n        };\n    }()),\n\n    generateMarkup: function(spec, buffer) {\n        var me = this,\n            attr, val, tag, i, closeTags;\n\n        if (typeof spec == \"string\") {\n            buffer.push(spec);\n        } else if (Ext.isArray(spec)) {\n            for (i = 0; i < spec.length; i++) {\n                if (spec[i]) {\n                    me.generateMarkup(spec[i], buffer);\n                }\n            }\n        } else {\n            tag = spec.tag || 'div';\n            buffer.push('<', tag);\n\n            for (attr in spec) {\n                if (spec.hasOwnProperty(attr)) {\n                    val = spec[attr];\n                    if (!me.confRe.test(attr)) {\n                        if (typeof val == \"object\") {\n                            buffer.push(' ', attr, '=\"');\n                            me.generateStyles(val, buffer).push('\"');\n                        } else {\n                            buffer.push(' ', me.attributeTransform[attr] || attr, '=\"', val, '\"');\n                        }\n                    }\n                }\n            }\n\n            // Now either just close the tag or try to add children and close the tag.\n            if (me.emptyTags.test(tag)) {\n                buffer.push('/>');\n            } else {\n                buffer.push('>');\n\n                // Apply the tpl html, and cn specifications\n                if ((val = spec.tpl)) {\n                    val.applyOut(spec.tplData, buffer);\n                }\n                if ((val = spec.html)) {\n                    buffer.push(val);\n                }\n                if ((val = spec.cn || spec.children)) {\n                    me.generateMarkup(val, buffer);\n                }\n\n                // we generate a lot of close tags, so cache them rather than push 3 parts\n                closeTags = me.closeTags;\n                buffer.push(closeTags[tag] || (closeTags[tag] = '</' + tag + '>'));\n            }\n        }\n\n        return buffer;\n    },\n\n    /**\n     * Converts the styles from the given object to text. The styles are CSS style names\n     * with their associated value.\n     * \n     * The basic form of this method returns a string:\n     * \n     *      var s = Ext.DomHelper.generateStyles({\n     *          backgroundColor: 'red'\n     *      });\n     *      \n     *      // s = 'background-color:red;'\n     *\n     * Alternatively, this method can append to an output array.\n     * \n     *      var buf = [];\n     *\n     *      ...\n     *\n     *      Ext.DomHelper.generateStyles({\n     *          backgroundColor: 'red'\n     *      }, buf);\n     *\n     * In this case, the style text is pushed on to the array and the array is returned.\n     * \n     * @param {Object} styles The object describing the styles.\n     * @param {String[]} [buffer] The output buffer.\n     * @return {String/String[]} If buffer is passed, it is returned. Otherwise the style\n     * string is returned.\n     */\n    generateStyles: function (styles, buffer) {\n        var a = buffer || [],\n            name;\n\n        for (name in styles) {\n            if (styles.hasOwnProperty(name)) {\n                a.push(this.decamelizeName(name), ':', styles[name], ';');\n            }\n        }\n\n        return buffer || a.join('');\n    },\n\n    /**\n     * Returns the markup for the passed Element(s) config.\n     * @param {Object} spec The DOM object spec (and children)\n     * @return {String}\n     */\n    markup: function(spec) {\n        if (typeof spec == \"string\") {\n            return spec;\n        }\n\n        var buf = this.generateMarkup(spec, []);\n        return buf.join('');\n    },\n\n    /**\n     * Applies a style specification to an element.\n     * @param {String/HTMLElement} el The element to apply styles to\n     * @param {String/Object/Function} styles A style specification string e.g. 'width:100px', or object in the form {width:'100px'}, or\n     * a function which returns such a specification.\n     */\n    applyStyles: function(el, styles) {\n        if (styles) {\n            var i = 0,\n                len,\n                style;\n\n            el = Ext.fly(el);\n            if (typeof styles == 'function') {\n                styles = styles.call();\n            }\n            if (typeof styles == 'string'){\n                styles = Ext.util.Format.trim(styles).split(/\\s*(?::|;)\\s*/);\n                for(len = styles.length; i < len;){\n                    el.setStyle(styles[i++], styles[i++]);\n                }\n            } else if (Ext.isObject(styles)) {\n                el.setStyle(styles);\n            }\n        }\n    },\n\n    /**\n     * Inserts an HTML fragment into the DOM.\n     * @param {String} where Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.\n     *\n     * For example take the following HTML: `<div>Contents</div>`\n     *\n     * Using different `where` values inserts element to the following places:\n     *\n     * - beforeBegin: `<HERE><div>Contents</div>`\n     * - afterBegin: `<div><HERE>Contents</div>`\n     * - beforeEnd: `<div>Contents<HERE></div>`\n     * - afterEnd: `<div>Contents</div><HERE>`\n     *\n     * @param {HTMLElement/TextNode} el The context element\n     * @param {String} html The HTML fragment\n     * @return {HTMLElement} The new node\n     */\n    insertHtml: function(where, el, html) {\n        var hash = {},\n            hashVal,\n            setStart,\n            range,\n            frag,\n            rangeEl,\n            rs;\n\n        where = where.toLowerCase();\n\n        // add these here because they are used in both branches of the condition.\n        hash['beforebegin'] = ['BeforeBegin', 'previousSibling'];\n        hash['afterend'] = ['AfterEnd', 'nextSibling'];\n\n        range = el.ownerDocument.createRange();\n        setStart = 'setStart' + (this.endRe.test(where) ? 'After' : 'Before');\n        if (hash[where]) {\n            range[setStart](el);\n            frag = range.createContextualFragment(html);\n            el.parentNode.insertBefore(frag, where == 'beforebegin' ? el : el.nextSibling);\n            return el[(where == 'beforebegin' ? 'previous' : 'next') + 'Sibling'];\n        }\n        else {\n            rangeEl = (where == 'afterbegin' ? 'first' : 'last') + 'Child';\n            if (el.firstChild) {\n                range[setStart](el[rangeEl]);\n                frag = range.createContextualFragment(html);\n                if (where == 'afterbegin') {\n                    el.insertBefore(frag, el.firstChild);\n                }\n                else {\n                    el.appendChild(frag);\n                }\n            }\n            else {\n                el.innerHTML = html;\n            }\n            return el[rangeEl];\n        }\n\n        throw 'Illegal insertion point -> \"' + where + '\"';\n    },\n\n    /**\n     * Creates new DOM element(s) and inserts them before el.\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\n     * @param {Boolean} [returnElement] true to return a Ext.Element\n     * @return {HTMLElement/Ext.Element} The new node\n     */\n    insertBefore: function(el, o, returnElement) {\n        return this.doInsert(el, o, returnElement, 'beforebegin');\n    },\n\n    /**\n     * Creates new DOM element(s) and inserts them after el.\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object} o The DOM object spec (and children)\n     * @param {Boolean} [returnElement] true to return a Ext.Element\n     * @return {HTMLElement/Ext.Element} The new node\n     */\n    insertAfter: function(el, o, returnElement) {\n        return this.doInsert(el, o, returnElement, 'afterend', 'nextSibling');\n    },\n\n    /**\n     * Creates new DOM element(s) and inserts them as the first child of el.\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\n     * @param {Boolean} [returnElement] true to return a Ext.Element\n     * @return {HTMLElement/Ext.Element} The new node\n     */\n    insertFirst: function(el, o, returnElement) {\n        return this.doInsert(el, o, returnElement, 'afterbegin', 'firstChild');\n    },\n\n    /**\n     * Creates new DOM element(s) and appends them to el.\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\n     * @param {Boolean} [returnElement] true to return a Ext.Element\n     * @return {HTMLElement/Ext.Element} The new node\n     */\n    append: function(el, o, returnElement) {\n        return this.doInsert(el, o, returnElement, 'beforeend', '', true);\n    },\n\n    /**\n     * Creates new DOM element(s) and overwrites the contents of el with them.\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\n     * @param {Boolean} [returnElement] true to return a Ext.Element\n     * @return {HTMLElement/Ext.Element} The new node\n     */\n    overwrite: function(el, o, returnElement) {\n        el = Ext.getDom(el);\n        el.innerHTML = this.markup(o);\n        return returnElement ? Ext.get(el.firstChild) : el.firstChild;\n    },\n\n    doInsert: function(el, o, returnElement, pos, sibling, append) {\n        var newNode = this.insertHtml(pos, Ext.getDom(el), this.markup(o));\n        return returnElement ? Ext.get(newNode, true) : newNode;\n    }\n\n});\n\n//@tag dom,core\n//@require AbstractHelper.js\n//@require Ext.Supports\n//@require Ext.EventManager\n//@define Ext.dom.AbstractElement\n\n/**\n * @class Ext.dom.AbstractElement\n * @extend Ext.Base\n * @private\n */\n(function() {\n\nvar document = window.document,\n    trimRe = /^\\s+|\\s+$/g,\n    whitespaceRe = /\\s/;\n\nif (!Ext.cache){\n    Ext.cache = {};\n}\n\nExt.define('Ext.dom.AbstractElement', {\n\n    inheritableStatics: {\n\n        /**\n         * Retrieves Ext.dom.Element objects. {@link Ext#get} is alias for {@link Ext.dom.Element#get}.\n         *\n         * **This method does not retrieve {@link Ext.Component Component}s.** This method retrieves Ext.dom.Element\n         * objects which encapsulate DOM elements. To retrieve a Component by its ID, use {@link Ext.ComponentManager#get}.\n         *\n         * Uses simple caching to consistently return the same object. Automatically fixes if an object was recreated with\n         * the same id via AJAX or DOM.\n         *\n         * @param {String/HTMLElement/Ext.Element} el The id of the node, a DOM Node or an existing Element.\n         * @return {Ext.dom.Element} The Element object (or null if no matching element was found)\n         * @static\n         * @inheritable\n         */\n        get: function(el) {\n            var me = this,\n                El = Ext.dom.Element,\n                cacheItem,\n                extEl,\n                dom,\n                id;\n\n            if (!el) {\n                return null;\n            }\n\n            if (typeof el == \"string\") { // element id\n                if (el == Ext.windowId) {\n                    return El.get(window);\n                } else if (el == Ext.documentId) {\n                    return El.get(document);\n                }\n                \n                cacheItem = Ext.cache[el];\n                // This code is here to catch the case where we've got a reference to a document of an iframe\n                // It getElementById will fail because it's not part of the document, so if we're skipping\n                // GC it means it's a window/document object that isn't the default window/document, which we have\n                // already handled above\n                if (cacheItem && cacheItem.skipGarbageCollection) {\n                    extEl = cacheItem.el;\n                    return extEl;\n                }\n                \n                if (!(dom = document.getElementById(el))) {\n                    return null;\n                }\n\n                if (cacheItem && cacheItem.el) {\n                    extEl = Ext.updateCacheEntry(cacheItem, dom).el;\n                } else {\n                    // Force new element if there's a cache but no el attached\n                    extEl = new El(dom, !!cacheItem);\n                }\n                return extEl;\n            } else if (el.tagName) { // dom element\n                if (!(id = el.id)) {\n                    id = Ext.id(el);\n                }\n                cacheItem = Ext.cache[id];\n                if (cacheItem && cacheItem.el) {\n                    extEl = Ext.updateCacheEntry(cacheItem, el).el;\n                } else {\n                    // Force new element if there's a cache but no el attached\n                    extEl = new El(el, !!cacheItem);\n                }\n                return extEl;\n            } else if (el instanceof me) {\n                if (el != me.docEl && el != me.winEl) {\n                    id = el.id;\n                    // refresh dom element in case no longer valid,\n                    // catch case where it hasn't been appended\n                    cacheItem = Ext.cache[id];\n                    if (cacheItem) {\n                        Ext.updateCacheEntry(cacheItem, document.getElementById(id) || el.dom);\n                    }\n                }\n                return el;\n            } else if (el.isComposite) {\n                return el;\n            } else if (Ext.isArray(el)) {\n                return me.select(el);\n            } else if (el === document) {\n                // create a bogus element object representing the document object\n                if (!me.docEl) {\n                    me.docEl = Ext.Object.chain(El.prototype);\n                    me.docEl.dom = document;\n                    me.docEl.id = Ext.id(document);\n                    me.addToCache(me.docEl);\n                }\n                return me.docEl;\n            } else if (el === window) {\n                if (!me.winEl) {\n                    me.winEl = Ext.Object.chain(El.prototype);\n                    me.winEl.dom = window;\n                    me.winEl.id = Ext.id(window);\n                    me.addToCache(me.winEl);\n                }\n                return me.winEl;\n            }\n            return null;\n        },\n\n        addToCache: function(el, id) {\n            if (el) {\n                Ext.addCacheEntry(id, el);\n            }\n            return el;\n        },\n\n        addMethods: function() {\n            this.override.apply(this, arguments);\n        },\n\n        /**\n         * <p>Returns an array of unique class names based upon the input strings, or string arrays.</p>\n         * <p>The number of parameters is unlimited.</p>\n         * <p>Example</p><code><pre>\n// Add x-invalid and x-mandatory classes, do not duplicate\nmyElement.dom.className = Ext.core.Element.mergeClsList(this.initialClasses, 'x-invalid x-mandatory');\n</pre></code>\n         * @param {Mixed} clsList1 A string of class names, or an array of class names.\n         * @param {Mixed} clsList2 A string of class names, or an array of class names.\n         * @return {Array} An array of strings representing remaining unique, merged class names. If class names were added to the first list, the <code>changed</code> property will be <code>true</code>.\n         * @static\n         * @inheritable\n         */\n        mergeClsList: function() {\n            var clsList, clsHash = {},\n                i, length, j, listLength, clsName, result = [],\n                changed = false;\n\n            for (i = 0, length = arguments.length; i < length; i++) {\n                clsList = arguments[i];\n                if (Ext.isString(clsList)) {\n                    clsList = clsList.replace(trimRe, '').split(whitespaceRe);\n                }\n                if (clsList) {\n                    for (j = 0, listLength = clsList.length; j < listLength; j++) {\n                        clsName = clsList[j];\n                        if (!clsHash[clsName]) {\n                            if (i) {\n                                changed = true;\n                            }\n                            clsHash[clsName] = true;\n                        }\n                    }\n                }\n            }\n\n            for (clsName in clsHash) {\n                result.push(clsName);\n            }\n            result.changed = changed;\n            return result;\n        },\n\n        /**\n         * <p>Returns an array of unique class names deom the first parameter with all class names\n         * from the second parameter removed.</p>\n         * <p>Example</p><code><pre>\n// Remove x-invalid and x-mandatory classes if present.\nmyElement.dom.className = Ext.core.Element.removeCls(this.initialClasses, 'x-invalid x-mandatory');\n</pre></code>\n         * @param {Mixed} existingClsList A string of class names, or an array of class names.\n         * @param {Mixed} removeClsList A string of class names, or an array of class names to remove from <code>existingClsList</code>.\n         * @return {Array} An array of strings representing remaining class names. If class names were removed, the <code>changed</code> property will be <code>true</code>.\n         * @static\n         * @inheritable\n         */\n        removeCls: function(existingClsList, removeClsList) {\n            var clsHash = {},\n                i, length, clsName, result = [],\n                changed = false;\n\n            if (existingClsList) {\n                if (Ext.isString(existingClsList)) {\n                    existingClsList = existingClsList.replace(trimRe, '').split(whitespaceRe);\n                }\n                for (i = 0, length = existingClsList.length; i < length; i++) {\n                    clsHash[existingClsList[i]] = true;\n                }\n            }\n            if (removeClsList) {\n                if (Ext.isString(removeClsList)) {\n                    removeClsList = removeClsList.split(whitespaceRe);\n                }\n                for (i = 0, length = removeClsList.length; i < length; i++) {\n                    clsName = removeClsList[i];\n                    if (clsHash[clsName]) {\n                        changed = true;\n                        delete clsHash[clsName];\n                    }\n                }\n            }\n            for (clsName in clsHash) {\n                result.push(clsName);\n            }\n            result.changed = changed;\n            return result;\n        },\n\n        /**\n         * @property\n         * Visibility mode constant for use with {@link Ext.dom.Element#setVisibilityMode}. \n         * Use the CSS 'visibility' property to hide the element.\n         *\n         * Note that in this mode, {@link Ext.dom.Element#isVisible isVisible} may return true\n         * for an element even though it actually has a parent element that is hidden. For this\n         * reason, and in most cases, using the {@link #OFFSETS} mode is a better choice.\n         * @static\n         * @inheritable\n         */\n        VISIBILITY: 1,\n\n        /**\n         * @property\n         * Visibility mode constant for use with {@link Ext.dom.Element#setVisibilityMode}. \n         * Use the CSS 'display' property to hide the element.\n         * @static\n         * @inheritable\n         */\n        DISPLAY: 2,\n\n        /**\n         * @property\n         * Visibility mode constant for use with {@link Ext.dom.Element#setVisibilityMode}. \n         * Use CSS absolute positioning and top/left offsets to hide the element.\n         * @static\n         * @inheritable\n         */\n        OFFSETS: 3,\n\n        /**\n         * @property\n         * Visibility mode constant for use with {@link Ext.dom.Element#setVisibilityMode}. \n         * Add or remove the {@link Ext.Layer#visibilityCls} class to hide the element.\n         * @static\n         * @inheritable\n         */\n        ASCLASS: 4\n    },\n\n    constructor: function(element, forceNew) {\n        var me = this,\n            dom = typeof element == 'string'\n                ? document.getElementById(element)\n                : element,\n            id;\n\n        if (!dom) {\n            return null;\n        }\n\n        id = dom.id;\n        if (!forceNew && id && Ext.cache[id]) {\n            // element object already exists\n            return Ext.cache[id].el;\n        }\n\n        /**\n         * @property {HTMLElement} dom\n         * The DOM element\n         */\n        me.dom = dom;\n\n        /**\n         * @property {String} id\n         * The DOM element ID\n         */\n        me.id = id || Ext.id(dom);\n\n        me.self.addToCache(me);\n    },\n\n    /**\n     * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)\n     * @param {Object} o The object with the attributes\n     * @param {Boolean} [useSet=true] false to override the default setAttribute to use expandos.\n     * @return {Ext.dom.Element} this\n     */\n    set: function(o, useSet) {\n         var el = this.dom,\n             attr,\n             value;\n\n         for (attr in o) {\n             if (o.hasOwnProperty(attr)) {\n                 value = o[attr];\n                 if (attr == 'style') {\n                     this.applyStyles(value);\n                 }\n                 else if (attr == 'cls') {\n                     el.className = value;\n                 }\n                 else if (useSet !== false) {\n                     if (value === undefined) {\n                         el.removeAttribute(attr);\n                     } else {\n                        el.setAttribute(attr, value);\n                     }\n                 }\n                 else {\n                     el[attr] = value;\n                 }\n             }\n         }\n         return this;\n     },\n\n    /**\n     * @property {String} defaultUnit\n     * The default unit to append to CSS values where a unit isn't provided.\n     */\n    defaultUnit: \"px\",\n\n    /**\n     * Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child)\n     * @param {String} selector The simple selector to test\n     * @return {Boolean} True if this element matches the selector, else false\n     */\n    is: function(simpleSelector) {\n        return Ext.DomQuery.is(this.dom, simpleSelector);\n    },\n\n    /**\n     * Returns the value of the \"value\" attribute\n     * @param {Boolean} asNumber true to parse the value as a number\n     * @return {String/Number}\n     */\n    getValue: function(asNumber) {\n        var val = this.dom.value;\n        return asNumber ? parseInt(val, 10) : val;\n    },\n\n    /**\n     * Removes this element's dom reference. Note that event and cache removal is handled at {@link Ext#removeNode\n     * Ext.removeNode}\n     */\n    remove: function() {\n        var me = this,\n        dom = me.dom;\n\n        if (dom) {\n            Ext.removeNode(dom);\n            delete me.dom;\n        }\n    },\n\n    /**\n     * Returns true if this element is an ancestor of the passed element\n     * @param {HTMLElement/String} el The element to check\n     * @return {Boolean} True if this element is an ancestor of el, else false\n     */\n    contains: function(el) {\n        if (!el) {\n            return false;\n        }\n\n        var me = this,\n            dom = el.dom || el;\n\n        // we need el-contains-itself logic here because isAncestor does not do that:\n        return (dom === me.dom) || Ext.dom.AbstractElement.isAncestor(me.dom, dom);\n    },\n\n    /**\n     * Returns the value of an attribute from the element's underlying DOM node.\n     * @param {String} name The attribute name\n     * @param {String} [namespace] The namespace in which to look for the attribute\n     * @return {String} The attribute value\n     */\n    getAttribute: function(name, ns) {\n        var dom = this.dom;\n        return dom.getAttributeNS(ns, name) || dom.getAttribute(ns + \":\" + name) || dom.getAttribute(name) || dom[name];\n    },\n\n    /**\n     * Update the innerHTML of this element\n     * @param {String} html The new HTML\n     * @return {Ext.dom.Element} this\n     */\n    update: function(html) {\n        if (this.dom) {\n            this.dom.innerHTML = html;\n        }\n        return this;\n    },\n\n\n    /**\n    * Set the innerHTML of this element\n    * @param {String} html The new HTML\n    * @return {Ext.Element} this\n     */\n    setHTML: function(html) {\n        if(this.dom) {\n            this.dom.innerHTML = html;\n        }\n        return this;\n    },\n\n    /**\n     * Returns the innerHTML of an Element or an empty string if the element's\n     * dom no longer exists.\n     */\n    getHTML: function() {\n        return this.dom ? this.dom.innerHTML : '';\n    },\n\n    /**\n     * Hide this element - Uses display mode to determine whether to use \"display\" or \"visibility\". See {@link #setVisible}.\n     * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\n     * @return {Ext.Element} this\n     */\n    hide: function() {\n        this.setVisible(false);\n        return this;\n    },\n\n    /**\n     * Show this element - Uses display mode to determine whether to use \"display\" or \"visibility\". See {@link #setVisible}.\n     * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\n     * @return {Ext.Element} this\n     */\n    show: function() {\n        this.setVisible(true);\n        return this;\n    },\n\n    /**\n     * Sets the visibility of the element (see details). If the visibilityMode is set to Element.DISPLAY, it will use\n     * the display property to hide the element, otherwise it uses visibility. The default is to hide and show using the visibility property.\n     * @param {Boolean} visible Whether the element is visible\n     * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object\n     * @return {Ext.Element} this\n     */\n    setVisible: function(visible, animate) {\n        var me = this,\n            statics = me.self,\n            mode = me.getVisibilityMode(),\n            prefix = Ext.baseCSSPrefix;\n\n        switch (mode) {\n            case statics.VISIBILITY:\n                me.removeCls([prefix + 'hidden-display', prefix + 'hidden-offsets']);\n                me[visible ? 'removeCls' : 'addCls'](prefix + 'hidden-visibility');\n            break;\n\n            case statics.DISPLAY:\n                me.removeCls([prefix + 'hidden-visibility', prefix + 'hidden-offsets']);\n                me[visible ? 'removeCls' : 'addCls'](prefix + 'hidden-display');\n            break;\n\n            case statics.OFFSETS:\n                me.removeCls([prefix + 'hidden-visibility', prefix + 'hidden-display']);\n                me[visible ? 'removeCls' : 'addCls'](prefix + 'hidden-offsets');\n            break;\n        }\n\n        return me;\n    },\n\n    getVisibilityMode: function() {\n        // Only flyweights won't have a $cache object, by calling getCache the cache\n        // will be created for future accesses. As such, we're eliminating the method\n        // call since it's mostly redundant\n        var data = (this.$cache || this.getCache()).data,\n            visMode = data.visibilityMode;\n\n        if (visMode === undefined) {\n            data.visibilityMode = visMode = this.self.DISPLAY;\n        }\n        \n        return visMode;\n    },\n\n    /**\n     * Use this to change the visibility mode between {@link #VISIBILITY}, {@link #DISPLAY}, {@link #OFFSETS} or {@link #ASCLASS}.\n     */\n    setVisibilityMode: function(mode) {\n        (this.$cache || this.getCache()).data.visibilityMode = mode;\n        return this;\n    },\n    \n    getCache: function() {\n        var me = this,\n            id = me.dom.id || Ext.id(me.dom);\n\n        // Note that we do not assign an ID to the calling object here.\n        // An Ext.dom.Element will have one assigned at construction, and an Ext.dom.AbstractElement.Fly must not have one.\n        // We assign an ID to the DOM element if it does not have one.\n        me.$cache = Ext.cache[id] || Ext.addCacheEntry(id, null, me.dom);\n            \n        return me.$cache;\n    }\n    \n}, function() {\n    var AbstractElement = this;\n\n    /**\n     * @private\n     * @member Ext\n     */\n    Ext.getDetachedBody = function () {\n        var detachedEl = AbstractElement.detachedBodyEl;\n\n        if (!detachedEl) {\n            detachedEl = document.createElement('div');\n            AbstractElement.detachedBodyEl = detachedEl = new AbstractElement.Fly(detachedEl);\n            detachedEl.isDetachedBody = true;\n        }\n\n        return detachedEl;\n    };\n\n    /**\n     * @private\n     * @member Ext\n     */\n    Ext.getElementById = function (id) {\n        var el = document.getElementById(id),\n            detachedBodyEl;\n\n        if (!el && (detachedBodyEl = AbstractElement.detachedBodyEl)) {\n            el = detachedBodyEl.dom.querySelector('#' + Ext.escapeId(id));\n        }\n\n        return el;\n    };\n\n    /**\n     * @member Ext\n     * @method get\n     * @inheritdoc Ext.dom.Element#get\n     */\n    Ext.get = function(el) {\n        return Ext.dom.Element.get(el);\n    };\n\n    this.addStatics({\n        /**\n         * @class Ext.dom.AbstractElement.Fly\n         * @extends Ext.dom.AbstractElement\n         *\n         * A non-persistent wrapper for a DOM element which may be used to execute methods of {@link Ext.dom.Element}\n         * upon a DOM element without creating an instance of {@link Ext.dom.Element}.\n         *\n         * A **singleton** instance of this class is returned when you use {@link Ext#fly}\n         *\n         * Because it is a singleton, this Flyweight does not have an ID, and must be used and discarded in a single line.\n         * You should not keep and use the reference to this singleton over multiple lines because methods that you call\n         * may themselves make use of {@link Ext#fly} and may change the DOM element to which the instance refers.\n         */\n        Fly: new Ext.Class({\n            extend: AbstractElement,\n\n            /**\n             * @property {Boolean} isFly\n             * This is `true` to identify Element flyweights\n             */\n            isFly: true,\n\n            constructor: function(dom) {\n                this.dom = dom;\n            },\n\n            /**\n             * @private\n             * Attach this fliyweight instance to the passed DOM element.\n             *\n             * Note that a flightweight does **not** have an ID, and does not acquire the ID of the DOM element.\n             */\n            attach: function (dom) {\n\n                // Attach to the passed DOM element. The same code as in Ext.Fly\n                this.dom = dom;\n                // Use cached data if there is existing cached data for the referenced DOM element,\n                // otherwise it will be created when needed by getCache.\n                this.$cache = dom.id ? Ext.cache[dom.id] : null;\n                return this;\n            }\n        }),\n\n        _flyweights: {},\n\n        /**\n         * Gets the singleton {@link Ext.dom.AbstractElement.Fly flyweight} element, with the passed node as the active element.\n         * \n         * Because it is a singleton, this Flyweight does not have an ID, and must be used and discarded in a single line.\n         * You may not keep and use the reference to this singleton over multiple lines because methods that you call\n         * may themselves make use of {@link Ext#fly} and may change the DOM element to which the instance refers.\n         *  \n         * {@link Ext#fly} is alias for {@link Ext.dom.AbstractElement#fly}.\n         *\n         * Use this to make one-time references to DOM elements which are not going to be accessed again either by\n         * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link\n         * Ext#get Ext.get} will be more appropriate to take advantage of the caching provided by the Ext.dom.Element\n         * class.\n         *\n         * @param {String/HTMLElement} dom The dom node or id\n         * @param {String} [named] Allows for creation of named reusable flyweights to prevent conflicts (e.g.\n         * internally Ext uses \"_global\")\n         * @return {Ext.dom.AbstractElement.Fly} The singleton flyweight object (or null if no matching element was found)\n         * @static\n         * @member Ext.dom.AbstractElement\n         */\n        fly: function(dom, named) {\n            var fly = null,\n                _flyweights = AbstractElement._flyweights;\n\n            named = named || '_global';\n\n            dom = Ext.getDom(dom);\n\n            if (dom) {\n                fly = _flyweights[named] || (_flyweights[named] = new AbstractElement.Fly());\n\n                // Attach to the passed DOM element.\n                // This code performs the same function as Fly.attach, but inline it for efficiency\n                fly.dom = dom;\n                // Use cached data if there is existing cached data for the referenced DOM element,\n                // otherwise it will be created when needed by getCache.\n                fly.$cache = dom.id ? Ext.cache[dom.id] : null;\n            }\n            return fly;\n        }\n    });\n\n    /**\n     * @member Ext\n     * @method fly\n     * @inheritdoc Ext.dom.AbstractElement#fly\n     */\n    Ext.fly = function() {\n        return AbstractElement.fly.apply(AbstractElement, arguments);\n    };\n\n    (function (proto) {\n        /**\n         * @method destroy\n         * @member Ext.dom.AbstractElement\n         * @inheritdoc Ext.dom.AbstractElement#remove\n         * Alias to {@link #remove}.\n         */\n        proto.destroy = proto.remove;\n\n        /**\n         * Returns a child element of this element given its `id`.\n         * @method getById\n         * @member Ext.dom.AbstractElement\n         * @param {String} id The id of the desired child element.\n         * @param {Boolean} [asDom=false] True to return the DOM element, false to return a\n         * wrapped Element object.\n         */\n        if (document.querySelector) {\n            proto.getById = function (id, asDom) {\n                // for normal elements getElementById is the best solution, but if the el is\n                // not part of the document.body, we have to resort to querySelector\n                var dom = document.getElementById(id) ||\n                    this.dom.querySelector('#'+Ext.escapeId(id));\n                return asDom ? dom : (dom ? Ext.get(dom) : null);\n            };\n        } else {\n            proto.getById = function (id, asDom) {\n                var dom = document.getElementById(id);\n                return asDom ? dom : (dom ? Ext.get(dom) : null);\n            };\n        }\n    }(this.prototype));\n});\n\n}());\n\n//@tag dom,core\n//@require AbstractElement.js\n//@define Ext.dom.AbstractElement-static\n//@define Ext.dom.AbstractElement\n\n/**\n * @class Ext.dom.AbstractElement\n */\nExt.dom.AbstractElement.addInheritableStatics({\n    unitRe: /\\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,\n    camelRe: /(-[a-z])/gi,\n    cssRe: /([a-z0-9\\-]+)\\s*:\\s*([^;\\s]+(?:\\s*[^;\\s]+)*);?/gi,\n    opacityRe: /alpha\\(opacity=(.*)\\)/i,\n    propertyCache: {},\n    defaultUnit : \"px\",\n    borders: {l: 'border-left-width', r: 'border-right-width', t: 'border-top-width', b: 'border-bottom-width'},\n    paddings: {l: 'padding-left', r: 'padding-right', t: 'padding-top', b: 'padding-bottom'},\n    margins: {l: 'margin-left', r: 'margin-right', t: 'margin-top', b: 'margin-bottom'},\n    /**\n     * Test if size has a unit, otherwise appends the passed unit string, or the default for this Element.\n     * @param size {Object} The size to set\n     * @param units {String} The units to append to a numeric size value\n     * @private\n     * @static\n     */\n    addUnits: function(size, units) {\n        // Most common case first: Size is set to a number\n        if (typeof size == 'number') {\n            return size + (units || this.defaultUnit || 'px');\n        }\n\n        // Size set to a value which means \"auto\"\n        if (size === \"\" || size == \"auto\" || size === undefined || size === null) {\n            return size || '';\n        }\n\n        // Otherwise, warn if it's not a valid CSS measurement\n        if (!this.unitRe.test(size)) {\n            if (Ext.isDefined(Ext.global.console)) {\n                Ext.global.console.warn(\"Warning, size detected as NaN on Element.addUnits.\");\n            }\n            return size || '';\n        }\n\n        return size;\n    },\n\n    /**\n     * @static\n     * @private\n     */\n    isAncestor: function(p, c) {\n        var ret = false;\n\n        p = Ext.getDom(p);\n        c = Ext.getDom(c);\n        if (p && c) {\n            if (p.contains) {\n                return p.contains(c);\n            } else if (p.compareDocumentPosition) {\n                return !!(p.compareDocumentPosition(c) & 16);\n            } else {\n                while ((c = c.parentNode)) {\n                    ret = c == p || ret;\n                }\n            }\n        }\n        return ret;\n    },\n\n    /**\n     * Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations\n     * (e.g. 10, \"10\", \"10 10\", \"10 10 10\" and \"10 10 10 10\" are all valid options and would return the same result)\n     * @static\n     * @param {Number/String} box The encoded margins\n     * @return {Object} An object with margin sizes for top, right, bottom and left\n     */\n    parseBox: function(box) {\n        if (typeof box != 'string') {\n            box = box.toString();\n        }\n        var parts  = box.split(' '),\n            ln = parts.length;\n\n        if (ln == 1) {\n            parts[1] = parts[2] = parts[3] = parts[0];\n        }\n        else if (ln == 2) {\n            parts[2] = parts[0];\n            parts[3] = parts[1];\n        }\n        else if (ln == 3) {\n            parts[3] = parts[1];\n        }\n\n        return {\n            top   :parseFloat(parts[0]) || 0,\n            right :parseFloat(parts[1]) || 0,\n            bottom:parseFloat(parts[2]) || 0,\n            left  :parseFloat(parts[3]) || 0\n        };\n    },\n\n    /**\n     * Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations\n     * (e.g. 10, \"10\", \"10 10\", \"10 10 10\" and \"10 10 10 10\" are all valid options and would return the same result)\n     * @static\n     * @param {Number/String} box The encoded margins\n     * @param {String} units The type of units to add\n     * @return {String} An string with unitized (px if units is not specified) metrics for top, right, bottom and left\n     */\n    unitizeBox: function(box, units) {\n        var a = this.addUnits,\n            b = this.parseBox(box);\n\n        return a(b.top, units) + ' ' +\n               a(b.right, units) + ' ' +\n               a(b.bottom, units) + ' ' +\n               a(b.left, units);\n\n    },\n\n    // private\n    camelReplaceFn: function(m, a) {\n        return a.charAt(1).toUpperCase();\n    },\n\n    /**\n     * Normalizes CSS property keys from dash delimited to camel case JavaScript Syntax.\n     * For example:\n     *\n     * - border-width -> borderWidth\n     * - padding-top -> paddingTop\n     *\n     * @static\n     * @param {String} prop The property to normalize\n     * @return {String} The normalized string\n     */\n    normalize: function(prop) {\n        // TODO: Mobile optimization?\n        if (prop == 'float') {\n            prop = Ext.supports.Float ? 'cssFloat' : 'styleFloat';\n        }\n        return this.propertyCache[prop] || (this.propertyCache[prop] = prop.replace(this.camelRe, this.camelReplaceFn));\n    },\n\n    /**\n     * Retrieves the document height\n     * @static\n     * @return {Number} documentHeight\n     */\n    getDocumentHeight: function() {\n        return Math.max(!Ext.isStrict ? document.body.scrollHeight : document.documentElement.scrollHeight, this.getViewportHeight());\n    },\n\n    /**\n     * Retrieves the document width\n     * @static\n     * @return {Number} documentWidth\n     */\n    getDocumentWidth: function() {\n        return Math.max(!Ext.isStrict ? document.body.scrollWidth : document.documentElement.scrollWidth, this.getViewportWidth());\n    },\n\n    /**\n     * Retrieves the viewport height of the window.\n     * @static\n     * @return {Number} viewportHeight\n     */\n    getViewportHeight: function(){\n        return window.innerHeight;\n    },\n\n    /**\n     * Retrieves the viewport width of the window.\n     * @static\n     * @return {Number} viewportWidth\n     */\n    getViewportWidth: function() {\n        return window.innerWidth;\n    },\n\n    /**\n     * Retrieves the viewport size of the window.\n     * @static\n     * @return {Object} object containing width and height properties\n     */\n    getViewSize: function() {\n        return {\n            width: window.innerWidth,\n            height: window.innerHeight\n        };\n    },\n\n    /**\n     * Retrieves the current orientation of the window. This is calculated by\n     * determing if the height is greater than the width.\n     * @static\n     * @return {String} Orientation of window: 'portrait' or 'landscape'\n     */\n    getOrientation: function() {\n        if (Ext.supports.OrientationChange) {\n            return (window.orientation == 0) ? 'portrait' : 'landscape';\n        }\n\n        return (window.innerHeight > window.innerWidth) ? 'portrait' : 'landscape';\n    },\n\n    /**\n     * Returns the top Element that is located at the passed coordinates\n     * @static\n     * @param {Number} x The x coordinate\n     * @param {Number} y The y coordinate\n     * @return {String} The found Element\n     */\n    fromPoint: function(x, y) {\n        return Ext.get(document.elementFromPoint(x, y));\n    },\n\n    /**\n     * Converts a CSS string into an object with a property for each style.\n     *\n     * The sample code below would return an object with 2 properties, one\n     * for background-color and one for color.\n     *\n     *     var css = 'background-color: red;color: blue; ';\n     *     console.log(Ext.dom.Element.parseStyles(css));\n     *\n     * @static\n     * @param {String} styles A CSS string\n     * @return {Object} styles\n     */\n    parseStyles: function(styles){\n        var out = {},\n            cssRe = this.cssRe,\n            matches;\n\n        if (styles) {\n            // Since we're using the g flag on the regex, we need to set the lastIndex.\n            // This automatically happens on some implementations, but not others, see:\n            // http://stackoverflow.com/questions/2645273/javascript-regular-expression-literal-persists-between-function-calls\n            // http://blog.stevenlevithan.com/archives/fixing-javascript-regexp\n            cssRe.lastIndex = 0;\n            while ((matches = cssRe.exec(styles))) {\n                out[matches[1]] = matches[2];\n            }\n        }\n        return out;\n    }\n});\n\n//TODO Need serious cleanups\n(function(){\n    var doc = document,\n        AbstractElement = Ext.dom.AbstractElement,\n        activeElement = null,\n        isCSS1 = doc.compatMode == \"CSS1Compat\",\n        flyInstance,\n        fly = function (el) {\n            if (!flyInstance) {\n                flyInstance = new AbstractElement.Fly();\n            }\n            flyInstance.attach(el);\n            return flyInstance;\n        };\n\n    // If the browser does not support document.activeElement we need some assistance.\n    // This covers old Safari 3.2 (4.0 added activeElement along with just about all\n    // other browsers). We need this support to handle issues with old Safari.\n    if (!('activeElement' in doc) && doc.addEventListener) {\n        doc.addEventListener('focus',\n            function (ev) {\n                if (ev && ev.target) {\n                    activeElement = (ev.target == doc) ? null : ev.target;\n                }\n            }, true);\n    }\n\n    /*\n     * Helper function to create the function that will restore the selection.\n     */\n    function makeSelectionRestoreFn (activeEl, start, end) {\n        return function () {\n            activeEl.selectionStart = start;\n            activeEl.selectionEnd = end;\n        };\n    }\n\n    AbstractElement.addInheritableStatics({\n        /**\n         * Returns the active element in the DOM. If the browser supports activeElement\n         * on the document, this is returned. If not, the focus is tracked and the active\n         * element is maintained internally.\n         * @return {HTMLElement} The active (focused) element in the document.\n         */\n        getActiveElement: function () {\n            return doc.activeElement || activeElement;\n        },\n\n        /**\n         * Creates a function to call to clean up problems with the work-around for the\n         * WebKit RightMargin bug. The work-around is to add \"display: 'inline-block'\" to\n         * the element before calling getComputedStyle and then to restore its original\n         * display value. The problem with this is that it corrupts the selection of an\n         * INPUT or TEXTAREA element (as in the \"I-beam\" goes away but ths focus remains).\n         * To cleanup after this, we need to capture the selection of any such element and\n         * then restore it after we have restored the display style.\n         *\n         * @param {Ext.dom.Element} target The top-most element being adjusted.\n         * @private\n         */\n        getRightMarginFixCleaner: function (target) {\n            var supports = Ext.supports,\n                hasInputBug = supports.DisplayChangeInputSelectionBug,\n                hasTextAreaBug = supports.DisplayChangeTextAreaSelectionBug,\n                activeEl,\n                tag,\n                start,\n                end;\n\n            if (hasInputBug || hasTextAreaBug) {\n                activeEl = doc.activeElement || activeElement; // save a call\n                tag = activeEl && activeEl.tagName;\n\n                if ((hasTextAreaBug && tag == 'TEXTAREA') ||\n                    (hasInputBug && tag == 'INPUT' && activeEl.type == 'text')) {\n                    if (Ext.dom.Element.isAncestor(target, activeEl)) {\n                        start = activeEl.selectionStart;\n                        end = activeEl.selectionEnd;\n\n                        if (Ext.isNumber(start) && Ext.isNumber(end)) { // to be safe...\n                            // We don't create the raw closure here inline because that\n                            // will be costly even if we don't want to return it (nested\n                            // function decls and exprs are often instantiated on entry\n                            // regardless of whether execution ever reaches them):\n                            return makeSelectionRestoreFn(activeEl, start, end);\n                        }\n                    }\n                }\n            }\n\n            return Ext.emptyFn; // avoid special cases, just return a nop\n        },\n\n        getViewWidth: function(full) {\n            return full ? Ext.dom.Element.getDocumentWidth() : Ext.dom.Element.getViewportWidth();\n        },\n\n        getViewHeight: function(full) {\n            return full ? Ext.dom.Element.getDocumentHeight() : Ext.dom.Element.getViewportHeight();\n        },\n\n        getDocumentHeight: function() {\n            return Math.max(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, Ext.dom.Element.getViewportHeight());\n        },\n\n        getDocumentWidth: function() {\n            return Math.max(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, Ext.dom.Element.getViewportWidth());\n        },\n\n        getViewportHeight: function(){\n            return Ext.isIE ?\n                   (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :\n                   self.innerHeight;\n        },\n\n        getViewportWidth: function() {\n            return (!Ext.isStrict && !Ext.isOpera) ? doc.body.clientWidth :\n                   Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;\n        },\n\n        getY: function(el) {\n            return Ext.dom.Element.getXY(el)[1];\n        },\n\n        getX: function(el) {\n            return Ext.dom.Element.getXY(el)[0];\n        },\n\n        getXY: function(el) {\n            var bd = doc.body,\n                docEl = doc.documentElement,\n                leftBorder = 0,\n                topBorder = 0,\n                ret = [0,0],\n                round = Math.round,\n                box,\n                scroll;\n\n            el = Ext.getDom(el);\n\n            if(el != doc && el != bd){\n                // IE has the potential to throw when getBoundingClientRect called\n                // on element not attached to dom\n                if (Ext.isIE) {\n                    try {\n                        box = el.getBoundingClientRect();\n                        // In some versions of IE, the documentElement (HTML element) will have a 2px border that gets included, so subtract it off\n                        topBorder = docEl.clientTop || bd.clientTop;\n                        leftBorder = docEl.clientLeft || bd.clientLeft;\n                    } catch (ex) {\n                        box = { left: 0, top: 0 };\n                    }\n                } else {\n                    box = el.getBoundingClientRect();\n                }\n\n                scroll = fly(document).getScroll();\n                ret = [round(box.left + scroll.left - leftBorder), round(box.top + scroll.top - topBorder)];\n            }\n            return ret;\n        },\n\n        setXY: function(el, xy) {\n            (el = Ext.fly(el, '_setXY')).position();\n\n            var pts = el.translatePoints(xy),\n                style = el.dom.style,\n                pos;\n\n            for (pos in pts) {\n                if (!isNaN(pts[pos])) {\n                    style[pos] = pts[pos] + \"px\";\n                }\n            }\n        },\n\n        setX: function(el, x) {\n            Ext.dom.Element.setXY(el, [x, false]);\n        },\n\n        setY: function(el, y) {\n            Ext.dom.Element.setXY(el, [false, y]);\n        },\n\n        /**\n         * Serializes a DOM form into a url encoded string\n         * @param {Object} form The form\n         * @return {String} The url encoded form\n         */\n        serializeForm: function(form) {\n            var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,\n                hasSubmit = false,\n                encoder   = encodeURIComponent,\n                data      = '',\n                eLen      = fElements.length,\n                element, name, type, options, hasValue, e,\n                o, oLen, opt;\n\n            for (e = 0; e < eLen; e++) {\n                element = fElements[e];\n                name    = element.name;\n                type    = element.type;\n                options = element.options;\n\n                if (!element.disabled && name) {\n                    if (/select-(one|multiple)/i.test(type)) {\n                        oLen = options.length;\n                        for (o = 0; o < oLen; o++) {\n                            opt = options[o];\n                            if (opt.selected) {\n                                hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified;\n                                data += Ext.String.format(\"{0}={1}&\", encoder(name), encoder(hasValue ? opt.value : opt.text));\n                            }\n                        }\n                    } else if (!(/file|undefined|reset|button/i.test(type))) {\n                        if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) {\n                            data += encoder(name) + '=' + encoder(element.value) + '&';\n                            hasSubmit = /submit/i.test(type);\n                        }\n                    }\n                }\n            }\n            return data.substr(0, data.length - 1);\n        }\n    });\n}());\n\n//@tag dom,core\n//@require Ext.dom.AbstractElement-static\n//@define Ext.dom.AbstractElement-alignment\n\n/**\n * @class Ext.dom.AbstractElement\n */\nExt.dom.AbstractElement.override({\n\n    /**\n     * Gets the x,y coordinates specified by the anchor position on the element.\n     * @param {String} [anchor] The specified anchor position (defaults to \"c\").  See {@link Ext.dom.Element#alignTo}\n     * for details on supported anchor positions.\n     * @param {Boolean} [local] True to get the local (element top/left-relative) anchor position instead\n     * of page coordinates\n     * @param {Object} [size] An object containing the size to use for calculating anchor position\n     * {width: (target width), height: (target height)} (defaults to the element's current size)\n     * @return {Array} [x, y] An array containing the element's x and y coordinates\n     */\n    getAnchorXY: function(anchor, local, size) {\n        //Passing a different size is useful for pre-calculating anchors,\n        //especially for anchored animations that change the el size.\n        anchor = (anchor || \"tl\").toLowerCase();\n        size = size || {};\n\n        var me = this,\n            vp = me.dom == document.body || me.dom == document,\n            width = size.width || vp ? window.innerWidth: me.getWidth(),\n            height = size.height || vp ? window.innerHeight: me.getHeight(),\n            xy,\n            rnd = Math.round,\n            myXY = me.getXY(),\n            extraX = vp ? 0: !local ? myXY[0] : 0,\n            extraY = vp ? 0: !local ? myXY[1] : 0,\n            hash = {\n                c: [rnd(width * 0.5), rnd(height * 0.5)],\n                t: [rnd(width * 0.5), 0],\n                l: [0, rnd(height * 0.5)],\n                r: [width, rnd(height * 0.5)],\n                b: [rnd(width * 0.5), height],\n                tl: [0, 0],\n                bl: [0, height],\n                br: [width, height],\n                tr: [width, 0]\n            };\n\n        xy = hash[anchor];\n        return [xy[0] + extraX, xy[1] + extraY];\n    },\n\n    alignToRe: /^([a-z]+)-([a-z]+)(\\?)?$/,\n\n    /**\n     * Gets the x,y coordinates to align this element with another element. See {@link Ext.dom.Element#alignTo} for more info on the\n     * supported position values.\n     * @param {Ext.Element/HTMLElement/String} element The element to align to.\n     * @param {String} [position=\"tl-bl?\"] The position to align to.\n     * @param {Array} [offsets=[0,0]] Offset the positioning by [x, y]\n     * @return {Array} [x, y]\n     */\n    getAlignToXY: function(el, position, offsets, local) {\n        local = !!local;\n        el = Ext.get(el);\n\n        if (!el || !el.dom) {\n            throw new Error(\"Element.alignToXY with an element that doesn't exist\");\n        }\n        offsets = offsets || [0, 0];\n\n        if (!position || position == '?') {\n            position = 'tl-bl?';\n        }\n        else if (! (/-/).test(position) && position !== \"\") {\n            position = 'tl-' + position;\n        }\n        position = position.toLowerCase();\n\n        var me = this,\n            matches = position.match(this.alignToRe),\n            dw = window.innerWidth,\n            dh = window.innerHeight,\n            p1 = \"\",\n            p2 = \"\",\n            a1,\n            a2,\n            x,\n            y,\n            swapX,\n            swapY,\n            p1x,\n            p1y,\n            p2x,\n            p2y,\n            width,\n            height,\n            region,\n            constrain;\n\n        if (!matches) {\n            throw \"Element.alignTo with an invalid alignment \" + position;\n        }\n\n        p1 = matches[1];\n        p2 = matches[2];\n        constrain = !!matches[3];\n\n        //Subtract the aligned el's internal xy from the target's offset xy\n        //plus custom offset to get the aligned el's new offset xy\n        a1 = me.getAnchorXY(p1, true);\n        a2 = el.getAnchorXY(p2, local);\n\n        x = a2[0] - a1[0] + offsets[0];\n        y = a2[1] - a1[1] + offsets[1];\n\n        if (constrain) {\n            width = me.getWidth();\n            height = me.getHeight();\n\n            region = el.getPageBox();\n\n            //If we are at a viewport boundary and the aligned el is anchored on a target border that is\n            //perpendicular to the vp border, allow the aligned el to slide on that border,\n            //otherwise swap the aligned el to the opposite border of the target.\n            p1y = p1.charAt(0);\n            p1x = p1.charAt(p1.length - 1);\n            p2y = p2.charAt(0);\n            p2x = p2.charAt(p2.length - 1);\n\n            swapY = ((p1y == \"t\" && p2y == \"b\") || (p1y == \"b\" && p2y == \"t\"));\n            swapX = ((p1x == \"r\" && p2x == \"l\") || (p1x == \"l\" && p2x == \"r\"));\n\n            if (x + width > dw) {\n                x = swapX ? region.left - width: dw - width;\n            }\n            if (x < 0) {\n                x = swapX ? region.right: 0;\n            }\n            if (y + height > dh) {\n                y = swapY ? region.top - height: dh - height;\n            }\n            if (y < 0) {\n                y = swapY ? region.bottom: 0;\n            }\n        }\n\n        return [x, y];\n    },\n\n    // private\n    getAnchor: function(){\n        var data = (this.$cache || this.getCache()).data,\n            anchor;\n            \n        if (!this.dom) {\n            return;\n        }\n        anchor = data._anchor;\n\n        if(!anchor){\n            anchor = data._anchor = {};\n        }\n        return anchor;\n    },\n\n    // private ==>  used outside of core\n    adjustForConstraints: function(xy, parent) {\n        var vector = this.getConstrainVector(parent, xy);\n        if (vector) {\n            xy[0] += vector[0];\n            xy[1] += vector[1];\n        }\n        return xy;\n    }\n\n});\n\n//@tag dom,core\n//@require Ext.dom.AbstractElement-alignment\n//@define Ext.dom.AbstractElement-insertion\n//@define Ext.dom.AbstractElement\n\n/**\n * @class Ext.dom.AbstractElement\n */\nExt.dom.AbstractElement.addMethods({\n    /**\n     * Appends the passed element(s) to this element\n     * @param {String/HTMLElement/Ext.dom.AbstractElement} el\n     * The id of the node, a DOM Node or an existing Element.\n     * @return {Ext.dom.AbstractElement} This element\n     */\n    appendChild: function(el) {\n        return Ext.get(el).appendTo(this);\n    },\n\n    /**\n     * Appends this element to the passed element\n     * @param {String/HTMLElement/Ext.dom.AbstractElement} el The new parent element.\n     * The id of the node, a DOM Node or an existing Element.\n     * @return {Ext.dom.AbstractElement} This element\n     */\n    appendTo: function(el) {\n        Ext.getDom(el).appendChild(this.dom);\n        return this;\n    },\n\n    /**\n     * Inserts this element before the passed element in the DOM\n     * @param {String/HTMLElement/Ext.dom.AbstractElement} el The element before which this element will be inserted.\n     * The id of the node, a DOM Node or an existing Element.\n     * @return {Ext.dom.AbstractElement} This element\n     */\n    insertBefore: function(el) {\n        el = Ext.getDom(el);\n        el.parentNode.insertBefore(this.dom, el);\n        return this;\n    },\n\n    /**\n     * Inserts this element after the passed element in the DOM\n     * @param {String/HTMLElement/Ext.dom.AbstractElement} el The element to insert after.\n     * The id of the node, a DOM Node or an existing Element.\n     * @return {Ext.dom.AbstractElement} This element\n     */\n    insertAfter: function(el) {\n        el = Ext.getDom(el);\n        el.parentNode.insertBefore(this.dom, el.nextSibling);\n        return this;\n    },\n\n    /**\n     * Inserts (or creates) an element (or DomHelper config) as the first child of this element\n     * @param {String/HTMLElement/Ext.dom.AbstractElement/Object} el The id or element to insert or a DomHelper config\n     * to create and insert\n     * @return {Ext.dom.AbstractElement} The new child\n     */\n    insertFirst: function(el, returnDom) {\n        el = el || {};\n        if (el.nodeType || el.dom || typeof el == 'string') { // element\n            el = Ext.getDom(el);\n            this.dom.insertBefore(el, this.dom.firstChild);\n            return !returnDom ? Ext.get(el) : el;\n        }\n        else { // dh config\n            return this.createChild(el, this.dom.firstChild, returnDom);\n        }\n    },\n\n    /**\n     * Inserts (or creates) the passed element (or DomHelper config) as a sibling of this element\n     * @param {String/HTMLElement/Ext.dom.AbstractElement/Object/Array} el The id, element to insert or a DomHelper config\n     * to create and insert *or* an array of any of those.\n     * @param {String} [where='before'] 'before' or 'after'\n     * @param {Boolean} [returnDom=false] True to return the .;ll;l,raw DOM element instead of Ext.dom.AbstractElement\n     * @return {Ext.dom.AbstractElement} The inserted Element. If an array is passed, the last inserted element is returned.\n     */\n    insertSibling: function(el, where, returnDom){\n        var me      = this,\n            isAfter = (where || 'before').toLowerCase() == 'after',\n            rt, insertEl, eLen, e;\n\n        if (Ext.isArray(el)) {\n            insertEl = me;\n            eLen = el.length;\n            \n            for (e = 0; e < eLen; e++) {\n                rt = Ext.fly(insertEl, '_internal').insertSibling(el[e], where, returnDom);\n\n                if (isAfter) {\n                    insertEl = rt;\n                }\n            }\n\n            return rt;\n        }\n\n        el = el || {};\n\n        if(el.nodeType || el.dom){\n            rt = me.dom.parentNode.insertBefore(Ext.getDom(el), isAfter ? me.dom.nextSibling : me.dom);\n            if (!returnDom) {\n                rt = Ext.get(rt);\n            }\n        }else{\n            if (isAfter && !me.dom.nextSibling) {\n                rt = Ext.core.DomHelper.append(me.dom.parentNode, el, !returnDom);\n            } else {\n                rt = Ext.core.DomHelper[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);\n            }\n        }\n        return rt;\n    },\n\n    /**\n     * Replaces the passed element with this element\n     * @param {String/HTMLElement/Ext.dom.AbstractElement} el The element to replace.\n     * The id of the node, a DOM Node or an existing Element.\n     * @return {Ext.dom.AbstractElement} This element\n     */\n    replace: function(el) {\n        el = Ext.get(el);\n        this.insertBefore(el);\n        el.remove();\n        return this;\n    },\n\n    /**\n     * Replaces this element with the passed element\n     * @param {String/HTMLElement/Ext.dom.AbstractElement/Object} el The new element (id of the node, a DOM Node\n     * or an existing Element) or a DomHelper config of an element to create\n     * @return {Ext.dom.AbstractElement} This element\n     */\n    replaceWith: function(el){\n        var me = this;\n\n        if(el.nodeType || el.dom || typeof el == 'string'){\n            el = Ext.get(el);\n            me.dom.parentNode.insertBefore(el, me.dom);\n        }else{\n            el = Ext.core.DomHelper.insertBefore(me.dom, el);\n        }\n\n        delete Ext.cache[me.id];\n        Ext.removeNode(me.dom);\n        me.id = Ext.id(me.dom = el);\n        Ext.dom.AbstractElement.addToCache(me.isFlyweight ? new Ext.dom.AbstractElement(me.dom) : me);\n        return me;\n    },\n\n    /**\n     * Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.\n     * @param {Object} config DomHelper element config object.  If no tag is specified (e.g., {tag:'input'}) then a div will be\n     * automatically generated with the specified attributes.\n     * @param {HTMLElement} [insertBefore] a child element of this element\n     * @param {Boolean} [returnDom=false] true to return the dom node instead of creating an Element\n     * @return {Ext.dom.AbstractElement} The new child element\n     */\n    createChild: function(config, insertBefore, returnDom) {\n        config = config || {tag:'div'};\n        if (insertBefore) {\n            return Ext.core.DomHelper.insertBefore(insertBefore, config, returnDom !== true);\n        }\n        else {\n            return Ext.core.DomHelper[!this.dom.firstChild ? 'insertFirst' : 'append'](this.dom, config,  returnDom !== true);\n        }\n    },\n\n    /**\n     * Creates and wraps this element with another element\n     * @param {Object} [config] DomHelper element config object for the wrapper element or null for an empty div\n     * @param {Boolean} [returnDom=false] True to return the raw DOM element instead of Ext.dom.AbstractElement\n     * @param {String} [selector] A {@link Ext.dom.Query DomQuery} selector to select a descendant node within the created element to use as the wrapping element.\n     * @return {HTMLElement/Ext.dom.AbstractElement} The newly created wrapper element\n     */\n    wrap: function(config, returnDom, selector) {\n        var newEl = Ext.core.DomHelper.insertBefore(this.dom, config || {tag: \"div\"}, true),\n            target = newEl;\n        \n        if (selector) {\n            target = Ext.DomQuery.selectNode(selector, newEl.dom);\n        }\n\n        target.appendChild(this.dom);\n        return returnDom ? newEl.dom : newEl;\n    },\n\n    /**\n     * Inserts an html fragment into this element\n     * @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.\n     * See {@link Ext.dom.Helper#insertHtml} for details.\n     * @param {String} html The HTML fragment\n     * @param {Boolean} [returnEl=false] True to return an Ext.dom.AbstractElement\n     * @return {HTMLElement/Ext.dom.AbstractElement} The inserted node (or nearest related if more than 1 inserted)\n     */\n    insertHtml: function(where, html, returnEl) {\n        var el = Ext.core.DomHelper.insertHtml(where, this.dom, html);\n        return returnEl ? Ext.get(el) : el;\n    }\n});\n\n//@tag dom,core\n//@require Ext.dom.AbstractElement-insertion\n//@define Ext.dom.AbstractElement-position\n//@define Ext.dom.AbstractElement\n\n/**\n * @class Ext.dom.AbstractElement\n */\n(function(){\n\nvar Element = Ext.dom.AbstractElement;\n\nElement.override({\n\n    /**\n     * Gets the current X position of the element based on page coordinates.  Element must be part of the DOM\n     * tree to have page coordinates (display:none or elements not appended return false).\n     * @return {Number} The X position of the element\n     */\n    getX: function(el) {\n        return this.getXY(el)[0];\n    },\n\n    /**\n     * Gets the current Y position of the element based on page coordinates.  Element must be part of the DOM\n     * tree to have page coordinates (display:none or elements not appended return false).\n     * @return {Number} The Y position of the element\n     */\n    getY: function(el) {\n        return this.getXY(el)[1];\n    },\n\n    /**\n     * Gets the current position of the element based on page coordinates.  Element must be part of the DOM\n     * tree to have page coordinates (display:none or elements not appended return false).\n     * @return {Array} The XY position of the element\n     */\n    getXY: function() {\n        // @FEATUREDETECT\n        var point = window.webkitConvertPointFromNodeToPage(this.dom, new WebKitPoint(0, 0));\n        return [point.x, point.y];\n    },\n\n    /**\n     * Returns the offsets of this element from the passed element. Both element must be part of the DOM\n     * tree and not have display:none to have page coordinates.\n     * @param {Ext.Element/HTMLElement/String} element The element to get the offsets from.\n     * @return {Array} The XY page offsets (e.g. [100, -200])\n     */\n    getOffsetsTo: function(el){\n        var o = this.getXY(),\n            e = Ext.fly(el, '_internal').getXY();\n        return [o[0]-e[0],o[1]-e[1]];\n    },\n\n    /**\n     * Sets the X position of the element based on page coordinates.  Element must be part of the DOM tree\n     * to have page coordinates (display:none or elements not appended return false).\n     * @param {Number} The X position of the element\n     * @param {Boolean/Object} [animate] True for the default animation, or a standard Element\n     * animation config object\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setX: function(x){\n        return this.setXY([x, this.getY()]);\n    },\n\n    /**\n     * Sets the Y position of the element based on page coordinates.  Element must be part of the DOM tree\n     * to have page coordinates (display:none or elements not appended return false).\n     * @param {Number} The Y position of the element\n     * @param {Boolean/Object} [animate] True for the default animation, or a standard Element\n     * animation config object\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setY: function(y) {\n        return this.setXY([this.getX(), y]);\n    },\n\n    /**\n     * Sets the element's left position directly using CSS style (instead of {@link #setX}).\n     * @param {String} left The left CSS property value\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setLeft: function(left) {\n        this.setStyle('left', Element.addUnits(left));\n        return this;\n    },\n\n    /**\n     * Sets the element's top position directly using CSS style (instead of {@link #setY}).\n     * @param {String} top The top CSS property value\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setTop: function(top) {\n        this.setStyle('top', Element.addUnits(top));\n        return this;\n    },\n\n    /**\n     * Sets the element's CSS right style.\n     * @param {String} right The right CSS property value\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setRight: function(right) {\n        this.setStyle('right', Element.addUnits(right));\n        return this;\n    },\n\n    /**\n     * Sets the element's CSS bottom style.\n     * @param {String} bottom The bottom CSS property value\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setBottom: function(bottom) {\n        this.setStyle('bottom', Element.addUnits(bottom));\n        return this;\n    },\n\n    /**\n     * Sets the position of the element in page coordinates, regardless of how the element is positioned.\n     * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\n     * @param {Array} pos Contains X & Y [x, y] values for new position (coordinates are page-based)\n     * @param {Boolean/Object} [animate] True for the default animation, or a standard Element animation config object\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setXY: function(pos) {\n        var me = this,\n            pts,\n            style,\n            pt;\n\n        if (arguments.length > 1) {\n            pos = [pos, arguments[1]];\n        }\n\n        // me.position();\n        pts = me.translatePoints(pos);\n        style = me.dom.style;\n\n        for (pt in pts) {\n            if (!pts.hasOwnProperty(pt)) {\n                continue;\n            }\n            if (!isNaN(pts[pt])) {\n                style[pt] = pts[pt] + \"px\";\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Gets the left X coordinate\n     * @param {Boolean} local True to get the local css position instead of page coordinate\n     * @return {Number}\n     */\n    getLeft: function(local) {\n        return parseInt(this.getStyle('left'), 10) || 0;\n    },\n\n    /**\n     * Gets the right X coordinate of the element (element X position + element width)\n     * @param {Boolean} local True to get the local css position instead of page coordinate\n     * @return {Number}\n     */\n    getRight: function(local) {\n        return parseInt(this.getStyle('right'), 10) || 0;\n    },\n\n    /**\n     * Gets the top Y coordinate\n     * @param {Boolean} local True to get the local css position instead of page coordinate\n     * @return {Number}\n     */\n    getTop: function(local) {\n        return parseInt(this.getStyle('top'), 10) || 0;\n    },\n\n    /**\n     * Gets the bottom Y coordinate of the element (element Y position + element height)\n     * @param {Boolean} local True to get the local css position instead of page coordinate\n     * @return {Number}\n     */\n    getBottom: function(local) {\n        return parseInt(this.getStyle('bottom'), 10) || 0;\n    },\n\n    /**\n     * Translates the passed page coordinates into left/top css values for this element\n     * @param {Number/Array} x The page x or an array containing [x, y]\n     * @param {Number} [y] The page y, required if x is not an array\n     * @return {Object} An object with left and top properties. e.g. {left: (value), top: (value)}\n     */\n    translatePoints: function(x, y) {\n        y = isNaN(x[1]) ? y : x[1];\n        x = isNaN(x[0]) ? x : x[0];\n        var me = this,\n            relative = me.isStyle('position', 'relative'),\n            o = me.getXY(),\n            l = parseInt(me.getStyle('left'), 10),\n            t = parseInt(me.getStyle('top'), 10);\n\n        l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);\n        t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);\n\n        return {left: (x - o[0] + l), top: (y - o[1] + t)};\n    },\n\n    /**\n     * Sets the element's box. Use getBox() on another element to get a box obj.\n     * If animate is true then width, height, x and y will be animated concurrently.\n     * @param {Object} box The box to fill {x, y, width, height}\n     * @param {Boolean} [adjust] Whether to adjust for box-model issues automatically\n     * @param {Boolean/Object} [animate] true for the default animation or a standard\n     * Element animation config object\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setBox: function(box) {\n        var me = this,\n            width = box.width,\n            height = box.height,\n            top = box.top,\n            left = box.left;\n\n        if (left !== undefined) {\n            me.setLeft(left);\n        }\n        if (top !== undefined) {\n            me.setTop(top);\n        }\n        if (width !== undefined) {\n            me.setWidth(width);\n        }\n        if (height !== undefined) {\n            me.setHeight(height);\n        }\n\n        return this;\n    },\n\n    /**\n     * Return an object defining the area of this Element which can be passed to {@link #setBox} to\n     * set another Element's size/location to match this element.\n     *\n     * @param {Boolean} [contentBox] If true a box for the content of the element is returned.\n     * @param {Boolean} [local] If true the element's left and top are returned instead of page x/y.\n     * @return {Object} box An object in the format:\n     *\n     *     {\n     *         x: <Element's X position>,\n     *         y: <Element's Y position>,\n     *         width: <Element's width>,\n     *         height: <Element's height>,\n     *         bottom: <Element's lower bound>,\n     *         right: <Element's rightmost bound>\n     *     }\n     *\n     * The returned object may also be addressed as an Array where index 0 contains the X position\n     * and index 1 contains the Y position. So the result may also be used for {@link #setXY}\n     */\n    getBox: function(contentBox, local) {\n        var me = this,\n            dom = me.dom,\n            width = dom.offsetWidth,\n            height = dom.offsetHeight,\n            xy, box, l, r, t, b;\n\n        if (!local) {\n            xy = me.getXY();\n        }\n        else if (contentBox) {\n            xy = [0,0];\n        }\n        else {\n            xy = [parseInt(me.getStyle(\"left\"), 10) || 0, parseInt(me.getStyle(\"top\"), 10) || 0];\n        }\n\n        if (!contentBox) {\n            box = {\n                x: xy[0],\n                y: xy[1],\n                0: xy[0],\n                1: xy[1],\n                width: width,\n                height: height\n            };\n        }\n        else {\n            l = me.getBorderWidth.call(me, \"l\") + me.getPadding.call(me, \"l\");\n            r = me.getBorderWidth.call(me, \"r\") + me.getPadding.call(me, \"r\");\n            t = me.getBorderWidth.call(me, \"t\") + me.getPadding.call(me, \"t\");\n            b = me.getBorderWidth.call(me, \"b\") + me.getPadding.call(me, \"b\");\n            box = {\n                x: xy[0] + l,\n                y: xy[1] + t,\n                0: xy[0] + l,\n                1: xy[1] + t,\n                width: width - (l + r),\n                height: height - (t + b)\n            };\n        }\n\n        box.left = box.x;\n        box.top = box.y;\n        box.right = box.x + box.width;\n        box.bottom = box.y + box.height;\n\n        return box;\n    },\n\n    /**\n     * Return an object defining the area of this Element which can be passed to {@link #setBox} to\n     * set another Element's size/location to match this element.\n     *\n     * @param {Boolean} [asRegion] If true an Ext.util.Region will be returned\n     * @return {Object} box An object in the format\n     *\n     *     {\n     *         left: <Element's X position>,\n     *         top: <Element's Y position>,\n     *         width: <Element's width>,\n     *         height: <Element's height>,\n     *         bottom: <Element's lower bound>,\n     *         right: <Element's rightmost bound>\n     *     }\n     *\n     * The returned object may also be addressed as an Array where index 0 contains the X position\n     * and index 1 contains the Y position. So the result may also be used for {@link #setXY}\n     */\n    getPageBox: function(getRegion) {\n        var me = this,\n            el = me.dom,\n            w = el.offsetWidth,\n            h = el.offsetHeight,\n            xy = me.getXY(),\n            t = xy[1],\n            r = xy[0] + w,\n            b = xy[1] + h,\n            l = xy[0];\n\n        if (!el) {\n            return new Ext.util.Region();\n        }\n\n        if (getRegion) {\n            return new Ext.util.Region(t, r, b, l);\n        }\n        else {\n            return {\n                left: l,\n                top: t,\n                width: w,\n                height: h,\n                right: r,\n                bottom: b\n            };\n        }\n    }\n});\n\n}());\n\n//@tag dom,core\n//@require Ext.dom.AbstractElement-position\n//@define Ext.dom.AbstractElement-style\n//@define Ext.dom.AbstractElement\n\n/**\n * @class Ext.dom.AbstractElement\n */\n(function(){\n    // local style camelizing for speed\n    var Element = Ext.dom.AbstractElement,\n        view = document.defaultView,\n        array = Ext.Array,\n        trimRe = /^\\s+|\\s+$/g,\n        wordsRe = /\\w/g,\n        spacesRe = /\\s+/,\n        transparentRe = /^(?:transparent|(?:rgba[(](?:\\s*\\d+\\s*[,]){3}\\s*0\\s*[)]))$/i,\n        hasClassList = Ext.supports.ClassList,\n        PADDING = 'padding',\n        MARGIN = 'margin',\n        BORDER = 'border',\n        LEFT_SUFFIX = '-left',\n        RIGHT_SUFFIX = '-right',\n        TOP_SUFFIX = '-top',\n        BOTTOM_SUFFIX = '-bottom',\n        WIDTH = '-width',\n        // special markup used throughout Ext when box wrapping elements\n        borders = {l: BORDER + LEFT_SUFFIX + WIDTH, r: BORDER + RIGHT_SUFFIX + WIDTH, t: BORDER + TOP_SUFFIX + WIDTH, b: BORDER + BOTTOM_SUFFIX + WIDTH},\n        paddings = {l: PADDING + LEFT_SUFFIX, r: PADDING + RIGHT_SUFFIX, t: PADDING + TOP_SUFFIX, b: PADDING + BOTTOM_SUFFIX},\n        margins = {l: MARGIN + LEFT_SUFFIX, r: MARGIN + RIGHT_SUFFIX, t: MARGIN + TOP_SUFFIX, b: MARGIN + BOTTOM_SUFFIX};\n\n\n    Element.override({\n\n        /**\n         * This shared object is keyed by style name (e.g., 'margin-left' or 'marginLeft'). The\n         * values are objects with the following properties:\n         *\n         *  * `name` (String) : The actual name to be presented to the DOM. This is typically the value\n         *      returned by {@link #normalize}.\n         *  * `get` (Function) : A hook function that will perform the get on this style. These\n         *      functions receive \"(dom, el)\" arguments. The `dom` parameter is the DOM Element\n         *      from which to get ths tyle. The `el` argument (may be null) is the Ext.Element.\n         *  * `set` (Function) : A hook function that will perform the set on this style. These\n         *      functions receive \"(dom, value, el)\" arguments. The `dom` parameter is the DOM Element\n         *      from which to get ths tyle. The `value` parameter is the new value for the style. The\n         *      `el` argument (may be null) is the Ext.Element.\n         *\n         * The `this` pointer is the object that contains `get` or `set`, which means that\n         * `this.name` can be accessed if needed. The hook functions are both optional.\n         * @private\n         */\n        styleHooks: {},\n\n        // private\n        addStyles : function(sides, styles){\n            var totalSize = 0,\n                sidesArr = (sides || '').match(wordsRe),\n                i,\n                len = sidesArr.length,\n                side,\n                styleSides = [];\n\n            if (len == 1) {\n                totalSize = Math.abs(parseFloat(this.getStyle(styles[sidesArr[0]])) || 0);\n            } else if (len) {\n                for (i = 0; i < len; i++) {\n                    side = sidesArr[i];\n                    styleSides.push(styles[side]);\n                }\n                //Gather all at once, returning a hash\n                styleSides = this.getStyle(styleSides);\n\n                for (i=0; i < len; i++) {\n                    side = sidesArr[i];\n                    totalSize += Math.abs(parseFloat(styleSides[styles[side]]) || 0);\n                }\n            }\n\n            return totalSize;\n        },\n\n        /**\n         * Adds one or more CSS classes to the element. Duplicate classes are automatically filtered out.\n         * @param {String/String[]} className The CSS classes to add separated by space, or an array of classes\n         * @return {Ext.dom.Element} this\n         * @method\n         */\n        addCls: hasClassList ?\n            function (className) {\n                if (String(className).indexOf('undefined') > -1) {\n                    Ext.Logger.warn(\"called with an undefined className: \" + className);\n                }\n                var me = this,\n                    dom = me.dom,\n                    classList,\n                    newCls,\n                    i,\n                    len,\n                    cls;\n\n                if (typeof(className) == 'string') {\n                    // split string on spaces to make an array of className\n                    className = className.replace(trimRe, '').split(spacesRe);\n                }\n\n                // the gain we have here is that we can skip parsing className and use the\n                // classList.contains method, so now O(M) not O(M+N)\n                if (dom && className && !!(len = className.length)) {\n                    if (!dom.className) {\n                        dom.className = className.join(' ');\n                    } else {\n                        classList = dom.classList;\n                        for (i = 0; i < len; ++i) {\n                            cls = className[i];\n                            if (cls) {\n                                if (!classList.contains(cls)) {\n                                    if (newCls) {\n                                        newCls.push(cls);\n                                    } else {\n                                        newCls = dom.className.replace(trimRe, '');\n                                        newCls = newCls ? [newCls, cls] : [cls];\n                                    }\n                                }\n                            }\n                        }\n\n                        if (newCls) {\n                            dom.className = newCls.join(' '); // write to DOM once\n                        }\n                    }\n                }\n                return me;\n            } :\n            function(className) {\n                if (String(className).indexOf('undefined') > -1) {\n                    Ext.Logger.warn(\"called with an undefined className: '\" + className + \"'\");\n                }\n                var me = this,\n                    dom = me.dom,\n                    changed,\n                    elClasses;\n\n                if (dom && className && className.length) {\n                    elClasses = Ext.Element.mergeClsList(dom.className, className);\n                    if (elClasses.changed) {\n                        dom.className = elClasses.join(' '); // write to DOM once\n                    }\n                }\n                return me;\n            },\n\n\n        /**\n         * Removes one or more CSS classes from the element.\n         * @param {String/String[]} className The CSS classes to remove separated by space, or an array of classes\n         * @return {Ext.dom.Element} this\n         */\n        removeCls: function(className) {\n            var me = this,\n                dom = me.dom,\n                len,\n                elClasses;\n\n            if (typeof(className) == 'string') {\n                // split string on spaces to make an array of className\n                className = className.replace(trimRe, '').split(spacesRe);\n            }\n\n            if (dom && dom.className && className && !!(len = className.length)) {\n                if (len == 1 && hasClassList) {\n                    if (className[0]) {\n                        dom.classList.remove(className[0]); // one DOM write\n                    }\n                } else {\n                    elClasses = Ext.Element.removeCls(dom.className, className);\n                    if (elClasses.changed) {\n                        dom.className = elClasses.join(' ');\n                    }\n                }\n            }\n            return me;\n        },\n\n        /**\n         * Adds one or more CSS classes to this element and removes the same class(es) from all siblings.\n         * @param {String/String[]} className The CSS class to add, or an array of classes\n         * @return {Ext.dom.Element} this\n         */\n        radioCls: function(className) {\n            var cn = this.dom.parentNode.childNodes,\n                v,\n                i, len;\n            className = Ext.isArray(className) ? className: [className];\n            for (i = 0, len = cn.length; i < len; i++) {\n                v = cn[i];\n                if (v && v.nodeType == 1) {\n                    Ext.fly(v, '_internal').removeCls(className);\n                }\n            }\n            return this.addCls(className);\n        },\n\n        /**\n         * Toggles the specified CSS class on this element (removes it if it already exists, otherwise adds it).\n         * @param {String} className The CSS class to toggle\n         * @return {Ext.dom.Element} this\n         * @method\n         */\n        toggleCls: hasClassList ?\n            function (className) {\n                var me = this,\n                    dom = me.dom;\n\n                if (dom) {\n                    className = className.replace(trimRe, '');\n                    if (className) {\n                        dom.classList.toggle(className);\n                    }\n                }\n\n                return me;\n            } :\n            function(className) {\n                var me = this;\n                return me.hasCls(className) ? me.removeCls(className) : me.addCls(className);\n            },\n\n        /**\n         * Checks if the specified CSS class exists on this element's DOM node.\n         * @param {String} className The CSS class to check for\n         * @return {Boolean} True if the class exists, else false\n         * @method\n         */\n        hasCls: hasClassList ?\n            function (className) {\n                var dom = this.dom;\n                return (dom && className) ? dom.classList.contains(className) : false;\n            } :\n            function(className) {\n                var dom = this.dom;\n                return dom ? className && (' '+dom.className+' ').indexOf(' '+className+' ') != -1 : false;\n            },\n\n        /**\n         * Replaces a CSS class on the element with another.  If the old name does not exist, the new name will simply be added.\n         * @param {String} oldClassName The CSS class to replace\n         * @param {String} newClassName The replacement CSS class\n         * @return {Ext.dom.Element} this\n         */\n        replaceCls: function(oldClassName, newClassName){\n            return this.removeCls(oldClassName).addCls(newClassName);\n        },\n\n        /**\n         * Checks if the current value of a style is equal to a given value.\n         * @param {String} style property whose value is returned.\n         * @param {String} value to check against.\n         * @return {Boolean} true for when the current value equals the given value.\n         */\n        isStyle: function(style, val) {\n            return this.getStyle(style) == val;\n        },\n\n        /**\n         * Returns a named style property based on computed/currentStyle (primary) and\n         * inline-style if primary is not available.\n         *\n         * @param {String/String[]} property The style property (or multiple property names\n         * in an array) whose value is returned.\n         * @param {Boolean} [inline=false] if `true` only inline styles will be returned.\n         * @return {String/Object} The current value of the style property for this element\n         * (or a hash of named style values if multiple property arguments are requested).\n         * @method\n         */\n        getStyle: function (property, inline) {\n            var me = this,\n                dom = me.dom,\n                multiple = typeof property != 'string',\n                hooks = me.styleHooks,\n                prop = property,\n                props = prop,\n                len = 1,\n                domStyle, camel, values, hook, out, style, i;\n\n            if (multiple) {\n                values = {};\n                prop = props[0];\n                i = 0;\n                if (!(len = props.length)) {\n                    return values;\n                }\n            }\n\n            if (!dom || dom.documentElement) {\n                return values || '';\n            }\n\n            domStyle = dom.style;\n\n            if (inline) {\n                style = domStyle;\n            } else {\n                // Caution: Firefox will not render \"presentation\" (ie. computed styles) in\n                // iframes that are display:none or those inheriting display:none. Similar\n                // issues with legacy Safari.\n                //\n                style = dom.ownerDocument.defaultView.getComputedStyle(dom, null);\n\n                // fallback to inline style if rendering context not available\n                if (!style) {\n                    inline = true;\n                    style = domStyle;\n                }\n            }\n\n            do {\n                hook = hooks[prop];\n\n                if (!hook) {\n                    hooks[prop] = hook = { name: Element.normalize(prop) };\n                }\n\n                if (hook.get) {\n                    out = hook.get(dom, me, inline, style);\n                } else {\n                    camel = hook.name;\n                    out = style[camel];\n                }\n\n                if (!multiple) {\n                   return out;\n                }\n\n                values[prop] = out;\n                prop = props[++i];\n            } while (i < len);\n\n            return values;\n        },\n\n        getStyles: function () {\n            var props = Ext.Array.slice(arguments),\n                len = props.length,\n                inline;\n\n            if (len && typeof props[len-1] == 'boolean') {\n                inline = props.pop();\n            }\n\n            return this.getStyle(props, inline);\n        },\n\n        /**\n         * Returns true if the value of the given property is visually transparent. This\n         * may be due to a 'transparent' style value or an rgba value with 0 in the alpha\n         * component.\n         * @param {String} prop The style property whose value is to be tested.\n         * @return {Boolean} True if the style property is visually transparent.\n         */\n        isTransparent: function (prop) {\n            var value = this.getStyle(prop);\n            return value ? transparentRe.test(value) : false;\n        },\n\n        /**\n         * Wrapper for setting style properties, also takes single object parameter of multiple styles.\n         * @param {String/Object} property The style property to be set, or an object of multiple styles.\n         * @param {String} [value] The value to apply to the given property, or null if an object was passed.\n         * @return {Ext.dom.Element} this\n         */\n        setStyle: function(prop, value) {\n            var me = this,\n                dom = me.dom,\n                hooks = me.styleHooks,\n                style = dom.style,\n                name = prop,\n                hook;\n\n            // we don't promote the 2-arg form to object-form to avoid the overhead...\n            if (typeof name == 'string') {\n                hook = hooks[name];\n                if (!hook) {\n                    hooks[name] = hook = { name: Element.normalize(name) };\n                }\n                value = (value == null) ? '' : value;\n                if (hook.set) {\n                    hook.set(dom, value, me);\n                } else {\n                    style[hook.name] = value;\n                }\n                if (hook.afterSet) {\n                    hook.afterSet(dom, value, me);\n                }\n            } else {\n                for (name in prop) {\n                    if (prop.hasOwnProperty(name)) {\n                        hook = hooks[name];\n                        if (!hook) {\n                            hooks[name] = hook = { name: Element.normalize(name) };\n                        }\n                        value = prop[name];\n                        value = (value == null) ? '' : value;\n                        if (hook.set) {\n                            hook.set(dom, value, me);\n                        } else {\n                            style[hook.name] = value;\n                        }\n                        if (hook.afterSet) {\n                            hook.afterSet(dom, value, me);\n                        }\n                    }\n                }\n            }\n\n            return me;\n        },\n\n        /**\n         * Returns the offset height of the element\n         * @param {Boolean} [contentHeight] true to get the height minus borders and padding\n         * @return {Number} The element's height\n         */\n        getHeight: function(contentHeight) {\n            var dom = this.dom,\n                height = contentHeight ? (dom.clientHeight - this.getPadding(\"tb\")) : dom.offsetHeight;\n            return height > 0 ? height: 0;\n        },\n\n        /**\n         * Returns the offset width of the element\n         * @param {Boolean} [contentWidth] true to get the width minus borders and padding\n         * @return {Number} The element's width\n         */\n        getWidth: function(contentWidth) {\n            var dom = this.dom,\n                width = contentWidth ? (dom.clientWidth - this.getPadding(\"lr\")) : dom.offsetWidth;\n            return width > 0 ? width: 0;\n        },\n\n        /**\n         * Set the width of this Element.\n         * @param {Number/String} width The new width. This may be one of:\n         *\n         * - A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels).\n         * - A String used to set the CSS width style. Animation may **not** be used.\n         *\n         * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object\n         * @return {Ext.dom.Element} this\n         */\n        setWidth: function(width) {\n            var me = this;\n                me.dom.style.width = Element.addUnits(width);\n            return me;\n        },\n\n        /**\n         * Set the height of this Element.\n         *\n         *     // change the height to 200px and animate with default configuration\n         *     Ext.fly('elementId').setHeight(200, true);\n         *\n         *     // change the height to 150px and animate with a custom configuration\n         *     Ext.fly('elId').setHeight(150, {\n         *         duration : 500, // animation will have a duration of .5 seconds\n         *         // will change the content to \"finished\"\n         *         callback: function(){ this.{@link #update}(\"finished\"); }\n         *     });\n         *\n         * @param {Number/String} height The new height. This may be one of:\n         *\n         * - A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels.)\n         * - A String used to set the CSS height style. Animation may **not** be used.\n         *\n         * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object\n         * @return {Ext.dom.Element} this\n         */\n        setHeight: function(height) {\n            var me = this;\n                me.dom.style.height = Element.addUnits(height);\n            return me;\n        },\n\n        /**\n         * Gets the width of the border(s) for the specified side(s)\n         * @param {String} side Can be t, l, r, b or any combination of those to add multiple values. For example,\n         * passing `'lr'` would get the border **l**eft width + the border **r**ight width.\n         * @return {Number} The width of the sides passed added together\n         */\n        getBorderWidth: function(side){\n            return this.addStyles(side, borders);\n        },\n\n        /**\n         * Gets the width of the padding(s) for the specified side(s)\n         * @param {String} side Can be t, l, r, b or any combination of those to add multiple values. For example,\n         * passing `'lr'` would get the padding **l**eft + the padding **r**ight.\n         * @return {Number} The padding of the sides passed added together\n         */\n        getPadding: function(side){\n            return this.addStyles(side, paddings);\n        },\n\n        margins : margins,\n\n        /**\n         * More flexible version of {@link #setStyle} for setting style properties.\n         * @param {String/Object/Function} styles A style specification string, e.g. \"width:100px\", or object in the form {width:\"100px\"}, or\n         * a function which returns such a specification.\n         * @return {Ext.dom.Element} this\n         */\n        applyStyles: function(styles) {\n            if (styles) {\n                var i,\n                    len,\n                    dom = this.dom;\n\n                if (typeof styles == 'function') {\n                    styles = styles.call();\n                }\n                if (typeof styles == 'string') {\n                    styles = Ext.util.Format.trim(styles).split(/\\s*(?::|;)\\s*/);\n                    for (i = 0, len = styles.length; i < len;) {\n                        dom.style[Element.normalize(styles[i++])] = styles[i++];\n                    }\n                }\n                else if (typeof styles == 'object') {\n                    this.setStyle(styles);\n                }\n            }\n        },\n\n        /**\n         * Set the size of this Element. If animation is true, both width and height will be animated concurrently.\n         * @param {Number/String} width The new width. This may be one of:\n         *\n         * - A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels).\n         * - A String used to set the CSS width style. Animation may **not** be used.\n         * - A size object in the format `{width: widthValue, height: heightValue}`.\n         *\n         * @param {Number/String} height The new height. This may be one of:\n         *\n         * - A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels).\n         * - A String used to set the CSS height style. Animation may **not** be used.\n         *\n         * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object\n         * @return {Ext.dom.Element} this\n         */\n        setSize: function(width, height) {\n            var me = this,\n                style = me.dom.style;\n\n            if (Ext.isObject(width)) {\n                // in case of object from getSize()\n                height = width.height;\n                width = width.width;\n            }\n\n            style.width = Element.addUnits(width);\n            style.height = Element.addUnits(height);\n            return me;\n        },\n\n        /**\n         * Returns the dimensions of the element available to lay content out in.\n         *\n         * If the element (or any ancestor element) has CSS style `display: none`, the dimensions will be zero.\n         *\n         * Example:\n         *\n         *     var vpSize = Ext.getBody().getViewSize();\n         *\n         *     // all Windows created afterwards will have a default value of 90% height and 95% width\n         *     Ext.Window.override({\n         *         width: vpSize.width * 0.9,\n         *         height: vpSize.height * 0.95\n         *     });\n         *     // To handle window resizing you would have to hook onto onWindowResize.\n         *\n         * getViewSize utilizes clientHeight/clientWidth which excludes sizing of scrollbars.\n         * To obtain the size including scrollbars, use getStyleSize\n         *\n         * Sizing of the document body is handled at the adapter level which handles special cases for IE and strict modes, etc.\n         *\n         * @return {Object} Object describing width and height.\n         * @return {Number} return.width\n         * @return {Number} return.height\n         */\n        getViewSize: function() {\n            var doc = document,\n                dom = this.dom;\n\n            if (dom == doc || dom == doc.body) {\n                return {\n                    width: Element.getViewportWidth(),\n                    height: Element.getViewportHeight()\n                };\n            }\n            else {\n                return {\n                    width: dom.clientWidth,\n                    height: dom.clientHeight\n                };\n            }\n        },\n\n        /**\n         * Returns the size of the element.\n         * @param {Boolean} [contentSize] true to get the width/size minus borders and padding\n         * @return {Object} An object containing the element's size:\n         * @return {Number} return.width\n         * @return {Number} return.height\n         */\n        getSize: function(contentSize) {\n            var dom = this.dom;\n            return {\n                width: Math.max(0, contentSize ? (dom.clientWidth - this.getPadding(\"lr\")) : dom.offsetWidth),\n                height: Math.max(0, contentSize ? (dom.clientHeight - this.getPadding(\"tb\")) : dom.offsetHeight)\n            };\n        },\n\n        /**\n         * Forces the browser to repaint this element\n         * @return {Ext.dom.Element} this\n         */\n        repaint: function(){\n            var dom = this.dom;\n            this.addCls(Ext.baseCSSPrefix + 'repaint');\n            setTimeout(function(){\n                Ext.fly(dom).removeCls(Ext.baseCSSPrefix + 'repaint');\n            }, 1);\n            return this;\n        },\n\n        /**\n         * Returns an object with properties top, left, right and bottom representing the margins of this element unless sides is passed,\n         * then it returns the calculated width of the sides (see getPadding)\n         * @param {String} [sides] Any combination of l, r, t, b to get the sum of those sides\n         * @return {Object/Number}\n         */\n        getMargin: function(side){\n            var me = this,\n                hash = {t:\"top\", l:\"left\", r:\"right\", b: \"bottom\"},\n                key,\n                o,\n                margins;\n\n            if (!side) {\n                margins = [];\n                for (key in me.margins) {\n                    if(me.margins.hasOwnProperty(key)) {\n                        margins.push(me.margins[key]);\n                    }\n                }\n                o = me.getStyle(margins);\n                if(o && typeof o == 'object') {\n                    //now mixin nomalized values (from hash table)\n                    for (key in me.margins) {\n                        if(me.margins.hasOwnProperty(key)) {\n                            o[hash[key]] = parseFloat(o[me.margins[key]]) || 0;\n                        }\n                    }\n                }\n\n                return o;\n            } else {\n                return me.addStyles.call(me, side, me.margins);\n            }\n        },\n\n        /**\n         * Puts a mask over this element to disable user interaction. Requires core.css.\n         * This method can only be applied to elements which accept child nodes.\n         * @param {String} [msg] A message to display in the mask\n         * @param {String} [msgCls] A css class to apply to the msg element\n         */\n        mask: function(msg, msgCls, transparent) {\n            var me = this,\n                dom = me.dom,\n                data = (me.$cache || me.getCache()).data,\n                el = data.mask,\n                mask,\n                size,\n                cls = '',\n                prefix = Ext.baseCSSPrefix;\n\n            me.addCls(prefix + 'masked');\n            if (me.getStyle(\"position\") == \"static\") {\n                me.addCls(prefix + 'masked-relative');\n            }\n            if (el) {\n                el.remove();\n            }\n            if (msgCls && typeof msgCls == 'string' ) {\n                cls = ' ' + msgCls;\n            }\n            else {\n                cls = ' ' + prefix + 'mask-gray';\n            }\n\n            mask = me.createChild({\n                cls: prefix + 'mask' + ((transparent !== false) ? '' : (' ' + prefix + 'mask-gray')),\n                html: msg ? ('<div class=\"' + (msgCls || (prefix + 'mask-message')) + '\">' + msg + '</div>') : ''\n            });\n\n            size = me.getSize();\n\n            data.mask = mask;\n\n            if (dom === document.body) {\n                size.height = window.innerHeight;\n                if (me.orientationHandler) {\n                    Ext.EventManager.unOrientationChange(me.orientationHandler, me);\n                }\n\n                me.orientationHandler = function() {\n                    size = me.getSize();\n                    size.height = window.innerHeight;\n                    mask.setSize(size);\n                };\n\n                Ext.EventManager.onOrientationChange(me.orientationHandler, me);\n            }\n            mask.setSize(size);\n            if (Ext.is.iPad) {\n                Ext.repaint();\n            }\n        },\n\n        /**\n         * Removes a previously applied mask.\n         */\n        unmask: function() {\n            var me = this,\n                data = (me.$cache || me.getCache()).data,\n                mask = data.mask,\n                prefix = Ext.baseCSSPrefix;\n\n            if (mask) {\n                mask.remove();\n                delete data.mask;\n            }\n            me.removeCls([prefix + 'masked', prefix + 'masked-relative']);\n\n            if (me.dom === document.body) {\n                Ext.EventManager.unOrientationChange(me.orientationHandler, me);\n                delete me.orientationHandler;\n            }\n        }\n    });\n\n    /**\n     * Creates mappings for 'margin-before' to 'marginLeft' (etc.) given the output\n     * map and an ordering pair (e.g., ['left', 'right']). The ordering pair is in\n     * before/after order.\n     */\n    Element.populateStyleMap = function (map, order) {\n        var baseStyles = ['margin-', 'padding-', 'border-width-'],\n            beforeAfter = ['before', 'after'],\n            index, style, name, i;\n\n        for (index = baseStyles.length; index--; ) {\n            for (i = 2; i--; ) {\n                style = baseStyles[index] + beforeAfter[i]; // margin-before\n                // ex: maps margin-before and marginBefore to marginLeft\n                map[Element.normalize(style)] = map[style] = {\n                    name: Element.normalize(baseStyles[index] + order[i])\n                };\n            }\n        }\n    };\n\n    Ext.onReady(function () {\n        var supports = Ext.supports,\n            styleHooks,\n            colorStyles, i, name, camel;\n\n        function fixTransparent (dom, el, inline, style) {\n            var value = style[this.name] || '';\n            return transparentRe.test(value) ? 'transparent' : value;\n        }\n\n        function fixRightMargin (dom, el, inline, style) {\n            var result = style.marginRight,\n                domStyle, display;\n\n            // Ignore cases when the margin is correctly reported as 0, the bug only shows\n            // numbers larger.\n            if (result != '0px') {\n                domStyle = dom.style;\n                display = domStyle.display;\n                domStyle.display = 'inline-block';\n                result = (inline ? style : dom.ownerDocument.defaultView.getComputedStyle(dom, null)).marginRight;\n                domStyle.display = display;\n            }\n\n            return result;\n        }\n\n        function fixRightMarginAndInputFocus (dom, el, inline, style) {\n            var result = style.marginRight,\n                domStyle, cleaner, display;\n\n            if (result != '0px') {\n                domStyle = dom.style;\n                cleaner = Element.getRightMarginFixCleaner(dom);\n                display = domStyle.display;\n                domStyle.display = 'inline-block';\n                result = (inline ? style : dom.ownerDocument.defaultView.getComputedStyle(dom, '')).marginRight;\n                domStyle.display = display;\n                cleaner();\n            }\n\n            return result;\n        }\n\n        styleHooks = Element.prototype.styleHooks;\n\n        // Populate the LTR flavors of margin-before et.al. (see Ext.rtl.AbstractElement):\n        Element.populateStyleMap(styleHooks, ['left', 'right']);\n\n        // Ext.supports needs to be initialized (we run very early in the onready sequence),\n        // but it is OK to call Ext.supports.init() more times than necessary...\n        if (supports.init) {\n            supports.init();\n        }\n\n        // Fix bug caused by this: https://bugs.webkit.org/show_bug.cgi?id=13343\n        if (!supports.RightMargin) {\n            styleHooks.marginRight = styleHooks['margin-right'] = {\n                name: 'marginRight',\n                // TODO - Touch should use conditional compilation here or ensure that the\n                //      underlying Ext.supports flags are set correctly...\n                get: (supports.DisplayChangeInputSelectionBug || supports.DisplayChangeTextAreaSelectionBug) ?\n                        fixRightMarginAndInputFocus : fixRightMargin\n            };\n        }\n\n        if (!supports.TransparentColor) {\n            colorStyles = ['background-color', 'border-color', 'color', 'outline-color'];\n            for (i = colorStyles.length; i--; ) {\n                name = colorStyles[i];\n                camel = Element.normalize(name);\n\n                styleHooks[name] = styleHooks[camel] = {\n                    name: camel,\n                    get: fixTransparent\n                };\n            }\n        }\n    });\n}());\n\n//@tag dom,core\n//@require Ext.dom.AbstractElement-style\n//@define Ext.dom.AbstractElement-traversal\n//@define Ext.dom.AbstractElement\n\n/**\n * @class Ext.dom.AbstractElement\n */\nExt.dom.AbstractElement.override({\n    /**\n     * Looks at this node and then at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)\n     * @param {String} selector The simple selector to test\n     * @param {Number/String/HTMLElement/Ext.Element} [limit]\n     * The max depth to search as a number or an element which causes the upward traversal to stop\n     * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)\n     * @param {Boolean} [returnEl=false] True to return a Ext.Element object instead of DOM node\n     * @return {HTMLElement} The matching DOM node (or null if no match was found)\n     */\n    findParent: function(simpleSelector, limit, returnEl) {\n        var target = this.dom,\n            topmost = document.documentElement,\n            depth = 0,\n            stopEl;\n\n        limit = limit || 50;\n        if (isNaN(limit)) {\n            stopEl = Ext.getDom(limit);\n            limit = Number.MAX_VALUE;\n        }\n        while (target && target.nodeType == 1 && depth < limit && target != topmost && target != stopEl) {\n            if (Ext.DomQuery.is(target, simpleSelector)) {\n                return returnEl ? Ext.get(target) : target;\n            }\n            depth++;\n            target = target.parentNode;\n        }\n        return null;\n    },\n\n    /**\n     * Looks at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)\n     * @param {String} selector The simple selector to test\n     * @param {Number/String/HTMLElement/Ext.Element} [limit]\n     * The max depth to search as a number or an element which causes the upward traversal to stop\n     * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)\n     * @param {Boolean} [returnEl=false] True to return a Ext.Element object instead of DOM node\n     * @return {HTMLElement} The matching DOM node (or null if no match was found)\n     */\n    findParentNode: function(simpleSelector, limit, returnEl) {\n        var p = Ext.fly(this.dom.parentNode, '_internal');\n        return p ? p.findParent(simpleSelector, limit, returnEl) : null;\n    },\n\n    /**\n     * Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child).\n     * This is a shortcut for findParentNode() that always returns an Ext.dom.Element.\n     * @param {String} selector The simple selector to test\n     * @param {Number/String/HTMLElement/Ext.Element} [limit]\n     * The max depth to search as a number or an element which causes the upward traversal to stop\n     * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)\n     * @return {Ext.Element} The matching DOM node (or null if no match was found)\n     */\n    up: function(simpleSelector, limit) {\n        return this.findParentNode(simpleSelector, limit, true);\n    },\n\n    /**\n     * Creates a {@link Ext.CompositeElement} for child nodes based on the passed CSS selector (the selector should not contain an id).\n     * @param {String} selector The CSS selector\n     * @param {Boolean} [unique] True to create a unique Ext.Element for each element. Defaults to a shared flyweight object.\n     * @return {Ext.CompositeElement} The composite element\n     */\n    select: function(selector, composite) {\n        return Ext.dom.Element.select(selector, this.dom, composite);\n    },\n\n    /**\n     * Selects child nodes based on the passed CSS selector (the selector should not contain an id).\n     * @param {String} selector The CSS selector\n     * @return {HTMLElement[]} An array of the matched nodes\n     */\n    query: function(selector) {\n        return Ext.DomQuery.select(selector, this.dom);\n    },\n\n    /**\n     * Selects a single child at any depth below this element based on the passed CSS selector (the selector should not contain an id).\n     * @param {String} selector The CSS selector\n     * @param {Boolean} [returnDom=false] True to return the DOM node instead of Ext.dom.Element\n     * @return {HTMLElement/Ext.dom.Element} The child Ext.dom.Element (or DOM node if returnDom = true)\n     */\n    down: function(selector, returnDom) {\n        var n = Ext.DomQuery.selectNode(selector, this.dom);\n        return returnDom ? n : Ext.get(n);\n    },\n\n    /**\n     * Selects a single *direct* child based on the passed CSS selector (the selector should not contain an id).\n     * @param {String} selector The CSS selector\n     * @param {Boolean} [returnDom=false] True to return the DOM node instead of Ext.dom.Element.\n     * @return {HTMLElement/Ext.dom.Element} The child Ext.dom.Element (or DOM node if returnDom = true)\n     */\n    child: function(selector, returnDom) {\n        var node,\n            me = this,\n            id;\n\n        // Pull the ID from the DOM (Ext.id also ensures that there *is* an ID).\n        // If this object is a Flyweight, it will not have an ID\n        id = Ext.id(me.dom);\n        // Escape \"invalid\" chars\n        id = Ext.escapeId(id);\n        node = Ext.DomQuery.selectNode('#' + id + \" > \" + selector, me.dom);\n        return returnDom ? node : Ext.get(node);\n    },\n\n     /**\n     * Gets the parent node for this element, optionally chaining up trying to match a selector\n     * @param {String} [selector] Find a parent node that matches the passed simple selector\n     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element\n     * @return {Ext.dom.Element/HTMLElement} The parent node or null\n     */\n    parent: function(selector, returnDom) {\n        return this.matchNode('parentNode', 'parentNode', selector, returnDom);\n    },\n\n     /**\n     * Gets the next sibling, skipping text nodes\n     * @param {String} [selector] Find the next sibling that matches the passed simple selector\n     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element\n     * @return {Ext.dom.Element/HTMLElement} The next sibling or null\n     */\n    next: function(selector, returnDom) {\n        return this.matchNode('nextSibling', 'nextSibling', selector, returnDom);\n    },\n\n    /**\n     * Gets the previous sibling, skipping text nodes\n     * @param {String} [selector] Find the previous sibling that matches the passed simple selector\n     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element\n     * @return {Ext.dom.Element/HTMLElement} The previous sibling or null\n     */\n    prev: function(selector, returnDom) {\n        return this.matchNode('previousSibling', 'previousSibling', selector, returnDom);\n    },\n\n\n    /**\n     * Gets the first child, skipping text nodes\n     * @param {String} [selector] Find the next sibling that matches the passed simple selector\n     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element\n     * @return {Ext.dom.Element/HTMLElement} The first child or null\n     */\n    first: function(selector, returnDom) {\n        return this.matchNode('nextSibling', 'firstChild', selector, returnDom);\n    },\n\n    /**\n     * Gets the last child, skipping text nodes\n     * @param {String} [selector] Find the previous sibling that matches the passed simple selector\n     * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element\n     * @return {Ext.dom.Element/HTMLElement} The last child or null\n     */\n    last: function(selector, returnDom) {\n        return this.matchNode('previousSibling', 'lastChild', selector, returnDom);\n    },\n\n    matchNode: function(dir, start, selector, returnDom) {\n        if (!this.dom) {\n            return null;\n        }\n\n        var n = this.dom[start];\n        while (n) {\n            if (n.nodeType == 1 && (!selector || Ext.DomQuery.is(n, selector))) {\n                return !returnDom ? Ext.get(n) : n;\n            }\n            n = n[dir];\n        }\n        return null;\n    },\n\n    isAncestor: function(element) {\n        return this.self.isAncestor.call(this.self, this.dom, element);\n    }\n});\n\n//@tag dom,core\n//@define Ext.DomHelper\n//@define Ext.core.DomHelper\n//@require Ext.dom.AbstractElement-traversal\n\n/**\n * @class Ext.DomHelper\n * @extends Ext.dom.Helper\n * @alternateClassName Ext.core.DomHelper\n * @singleton\n *\n * The DomHelper class provides a layer of abstraction from DOM and transparently supports creating elements via DOM or\n * using HTML fragments. It also has the ability to create HTML fragment templates from your DOM building code.\n *\n * # DomHelper element specification object\n *\n * A specification object is used when creating elements. Attributes of this object are assumed to be element\n * attributes, except for 4 special attributes:\n *\n * - **tag** - The tag name of the element.\n * - **children** or **cn** - An array of the same kind of element definition objects to be created and appended.\n *   These can be nested as deep as you want.\n * - **cls** - The class attribute of the element. This will end up being either the \"class\" attribute on a HTML\n *   fragment or className for a DOM node, depending on whether DomHelper is using fragments or DOM.\n * - **html** - The innerHTML for the element.\n *\n * **NOTE:** For other arbitrary attributes, the value will currently **not** be automatically HTML-escaped prior to\n * building the element's HTML string. This means that if your attribute value contains special characters that would\n * not normally be allowed in a double-quoted attribute value, you **must** manually HTML-encode it beforehand (see\n * {@link Ext.String#htmlEncode}) or risk malformed HTML being created. This behavior may change in a future release.\n *\n * # Insertion methods\n *\n * Commonly used insertion methods:\n *\n * - **{@link #append}**\n * - **{@link #insertBefore}**\n * - **{@link #insertAfter}**\n * - **{@link #overwrite}**\n * - **{@link #createTemplate}**\n * - **{@link #insertHtml}**\n *\n * # Example\n *\n * This is an example, where an unordered list with 3 children items is appended to an existing element with\n * id 'my-div':\n *\n *     var dh = Ext.DomHelper; // create shorthand alias\n *     // specification object\n *     var spec = {\n *         id: 'my-ul',\n *         tag: 'ul',\n *         cls: 'my-list',\n *         // append children after creating\n *         children: [     // may also specify 'cn' instead of 'children'\n *             {tag: 'li', id: 'item0', html: 'List Item 0'},\n *             {tag: 'li', id: 'item1', html: 'List Item 1'},\n *             {tag: 'li', id: 'item2', html: 'List Item 2'}\n *         ]\n *     };\n *     var list = dh.append(\n *         'my-div', // the context element 'my-div' can either be the id or the actual node\n *         spec      // the specification object\n *     );\n *\n * Element creation specification parameters in this class may also be passed as an Array of specification objects. This\n * can be used to insert multiple sibling nodes into an existing container very efficiently. For example, to add more\n * list items to the example above:\n *\n *     dh.append('my-ul', [\n *         {tag: 'li', id: 'item3', html: 'List Item 3'},\n *         {tag: 'li', id: 'item4', html: 'List Item 4'}\n *     ]);\n *\n * # Templating\n *\n * The real power is in the built-in templating. Instead of creating or appending any elements, {@link #createTemplate}\n * returns a Template object which can be used over and over to insert new elements. Revisiting the example above, we\n * could utilize templating this time:\n *\n *     // create the node\n *     var list = dh.append('my-div', {tag: 'ul', cls: 'my-list'});\n *     // get template\n *     var tpl = dh.createTemplate({tag: 'li', id: 'item{0}', html: 'List Item {0}'});\n *\n *     for(var i = 0; i < 5, i++){\n *         tpl.append(list, [i]); // use template to append to the actual node\n *     }\n *\n * An example using a template:\n *\n *     var html = '<a id=\"{0}\" href=\"{1}\" class=\"nav\">{2}</a>';\n *\n *     var tpl = new Ext.DomHelper.createTemplate(html);\n *     tpl.append('blog-roll', ['link1', 'http://www.edspencer.net/', \"Ed's Site\"]);\n *     tpl.append('blog-roll', ['link2', 'http://www.dustindiaz.com/', \"Dustin's Site\"]);\n *\n * The same example using named parameters:\n *\n *     var html = '<a id=\"{id}\" href=\"{url}\" class=\"nav\">{text}</a>';\n *\n *     var tpl = new Ext.DomHelper.createTemplate(html);\n *     tpl.append('blog-roll', {\n *         id: 'link1',\n *         url: 'http://www.edspencer.net/',\n *         text: \"Ed's Site\"\n *     });\n *     tpl.append('blog-roll', {\n *         id: 'link2',\n *         url: 'http://www.dustindiaz.com/',\n *         text: \"Dustin's Site\"\n *     });\n *\n * # Compiling Templates\n *\n * Templates are applied using regular expressions. The performance is great, but if you are adding a bunch of DOM\n * elements using the same template, you can increase performance even further by {@link Ext.Template#compile\n * \"compiling\"} the template. The way \"{@link Ext.Template#compile compile()}\" works is the template is parsed and\n * broken up at the different variable points and a dynamic function is created and eval'ed. The generated function\n * performs string concatenation of these parts and the passed variables instead of using regular expressions.\n *\n *     var html = '<a id=\"{id}\" href=\"{url}\" class=\"nav\">{text}</a>';\n *\n *     var tpl = new Ext.DomHelper.createTemplate(html);\n *     tpl.compile();\n *\n *     //... use template like normal\n *\n * # Performance Boost\n *\n * DomHelper will transparently create HTML fragments when it can. Using HTML fragments instead of DOM can significantly\n * boost performance.\n *\n * Element creation specification parameters may also be strings. If {@link #useDom} is false, then the string is used\n * as innerHTML. If {@link #useDom} is true, a string specification results in the creation of a text node. Usage:\n *\n *     Ext.DomHelper.useDom = true; // force it to use DOM; reduces performance\n *\n */\n(function() {\n\n// kill repeat to save bytes\nvar afterbegin = 'afterbegin',\n    afterend = 'afterend',\n    beforebegin = 'beforebegin',\n    beforeend = 'beforeend',\n    ts = '<table>',\n    te = '</table>',\n    tbs = ts+'<tbody>',\n    tbe = '</tbody>'+te,\n    trs = tbs + '<tr>',\n    tre = '</tr>'+tbe,\n    detachedDiv = document.createElement('div'),\n    bbValues = ['BeforeBegin', 'previousSibling'],\n    aeValues = ['AfterEnd', 'nextSibling'],\n    bb_ae_PositionHash = {\n        beforebegin: bbValues,\n        afterend: aeValues\n    },\n    fullPositionHash = {\n        beforebegin: bbValues,\n        afterend: aeValues,\n        afterbegin: ['AfterBegin', 'firstChild'],\n        beforeend: ['BeforeEnd', 'lastChild']\n    };\n\n/**\n * The actual class of which {@link Ext.DomHelper} is instance of.\n * \n * Use singleton {@link Ext.DomHelper} instead.\n * \n * @private\n */\nExt.define('Ext.dom.Helper', {\n    extend: 'Ext.dom.AbstractHelper',\n    requires:['Ext.dom.AbstractElement'],\n\n    tableRe: /^table|tbody|tr|td$/i,\n\n    tableElRe: /td|tr|tbody/i,\n\n    /**\n     * @property {Boolean} useDom\n     * True to force the use of DOM instead of html fragments.\n     */\n    useDom : false,\n\n    /**\n     * Creates new DOM element(s) without inserting them to the document.\n     * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\n     * @return {HTMLElement} The new uninserted node\n     */\n    createDom: function(o, parentNode){\n        var el,\n            doc = document,\n            useSet,\n            attr,\n            val,\n            cn,\n            i, l;\n\n        if (Ext.isArray(o)) {                       // Allow Arrays of siblings to be inserted\n            el = doc.createDocumentFragment(); // in one shot using a DocumentFragment\n            for (i = 0, l = o.length; i < l; i++) {\n                this.createDom(o[i], el);\n            }\n        } else if (typeof o == 'string') {         // Allow a string as a child spec.\n            el = doc.createTextNode(o);\n        } else {\n            el = doc.createElement(o.tag || 'div');\n            useSet = !!el.setAttribute; // In IE some elements don't have setAttribute\n            for (attr in o) {\n                if (!this.confRe.test(attr)) {\n                    val = o[attr];\n                    if (attr == 'cls') {\n                        el.className = val;\n                    } else {\n                        if (useSet) {\n                            el.setAttribute(attr, val);\n                        } else {\n                            el[attr] = val;\n                        }\n                    }\n                }\n            }\n            Ext.DomHelper.applyStyles(el, o.style);\n\n            if ((cn = o.children || o.cn)) {\n                this.createDom(cn, el);\n            } else if (o.html) {\n                el.innerHTML = o.html;\n            }\n        }\n        if (parentNode) {\n            parentNode.appendChild(el);\n        }\n        return el;\n    },\n\n    ieTable: function(depth, openingTags, htmlContent, closingTags){\n        detachedDiv.innerHTML = [openingTags, htmlContent, closingTags].join('');\n\n        var i = -1,\n            el = detachedDiv,\n            ns;\n\n        while (++i < depth) {\n            el = el.firstChild;\n        }\n        // If the result is multiple siblings, then encapsulate them into one fragment.\n        ns = el.nextSibling;\n\n        if (ns) {\n            el = document.createDocumentFragment();\n            while (ns) {\n                el.appendChild(ns);\n                ns = ns.nextSibling;\n            }\n        }\n        return el;\n    },\n\n    /**\n     * @private\n     * Nasty code for IE's broken table implementation\n     */\n    insertIntoTable: function(tag, where, destinationEl, html) {\n        var node,\n            before,\n            bb = where == beforebegin,\n            ab = where == afterbegin,\n            be = where == beforeend,\n            ae = where == afterend;\n\n        if (tag == 'td' && (ab || be) || !this.tableElRe.test(tag) && (bb || ae)) {\n            return null;\n        }\n        before = bb ? destinationEl :\n                 ae ? destinationEl.nextSibling :\n                 ab ? destinationEl.firstChild : null;\n\n        if (bb || ae) {\n            destinationEl = destinationEl.parentNode;\n        }\n\n        if (tag == 'td' || (tag == 'tr' && (be || ab))) {\n            node = this.ieTable(4, trs, html, tre);\n        } else if ((tag == 'tbody' && (be || ab)) ||\n                (tag == 'tr' && (bb || ae))) {\n            node = this.ieTable(3, tbs, html, tbe);\n        } else {\n            node = this.ieTable(2, ts, html, te);\n        }\n        destinationEl.insertBefore(node, before);\n        return node;\n    },\n\n    /**\n     * @private\n     * Fix for IE9 createContextualFragment missing method\n     */\n    createContextualFragment: function(html) {\n        var fragment = document.createDocumentFragment(),\n            length, childNodes;\n\n        detachedDiv.innerHTML = html;\n        childNodes = detachedDiv.childNodes;\n        length = childNodes.length;\n\n        // Move nodes into fragment, don't clone: http://jsperf.com/create-fragment\n        while (length--) {\n            fragment.appendChild(childNodes[0]);\n        }\n        return fragment;\n    },\n\n    applyStyles: function(el, styles) {\n        if (styles) {\n            el = Ext.fly(el);\n            if (typeof styles == \"function\") {\n                styles = styles.call();\n            }\n            if (typeof styles == \"string\") {\n                styles = Ext.dom.Element.parseStyles(styles);\n            }\n            if (typeof styles == \"object\") {\n                el.setStyle(styles);\n            }\n        }\n    },\n\n    /**\n     * Alias for {@link #markup}.\n     * @inheritdoc Ext.dom.AbstractHelper#markup\n     */\n    createHtml: function(spec) {\n        return this.markup(spec);\n    },\n\n    doInsert: function(el, o, returnElement, pos, sibling, append) {\n        \n        el = el.dom || Ext.getDom(el);\n\n        var newNode;\n\n        if (this.useDom) {\n            newNode = this.createDom(o, null);\n\n            if (append) {\n                el.appendChild(newNode);\n            }\n            else {\n                (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);\n            }\n\n        } else {\n            newNode = this.insertHtml(pos, el, this.markup(o));\n        }\n        return returnElement ? Ext.get(newNode, true) : newNode;\n    },\n\n    /**\n     * Creates new DOM element(s) and overwrites the contents of el with them.\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/String} o The DOM object spec (and children) or raw HTML blob\n     * @param {Boolean} [returnElement] true to return an Ext.Element\n     * @return {HTMLElement/Ext.Element} The new node\n     */\n    overwrite: function(el, html, returnElement) {\n        var newNode;\n\n        el = Ext.getDom(el);\n        html = this.markup(html);\n\n        // IE Inserting HTML into a table/tbody/tr requires extra processing: http://www.ericvasilik.com/2006/07/code-karma.html\n        if (Ext.isIE && this.tableRe.test(el.tagName)) {\n            // Clearing table elements requires removal of all elements.\n            while (el.firstChild) {\n                el.removeChild(el.firstChild);\n            }\n            if (html) {\n                newNode = this.insertHtml('afterbegin', el, html);\n                return returnElement ? Ext.get(newNode) : newNode;\n            }\n            return null;\n        }\n        el.innerHTML = html;\n        return returnElement ? Ext.get(el.firstChild) : el.firstChild;\n    },\n\n    insertHtml: function(where, el, html) {\n        var hashVal,\n            range,\n            rangeEl,\n            setStart,\n            frag;\n\n        where = where.toLowerCase();\n\n        // Has fast HTML insertion into existing DOM: http://www.w3.org/TR/html5/apis-in-html-documents.html#insertadjacenthtml\n        if (el.insertAdjacentHTML) {\n\n            // IE's incomplete table implementation: http://www.ericvasilik.com/2006/07/code-karma.html\n            if (Ext.isIE && this.tableRe.test(el.tagName) && (frag = this.insertIntoTable(el.tagName.toLowerCase(), where, el, html))) {\n                return frag;\n            }\n\n            if ((hashVal = fullPositionHash[where])) {\n                el.insertAdjacentHTML(hashVal[0], html);\n                return el[hashVal[1]];\n            }\n            // if (not IE and context element is an HTMLElement) or TextNode\n        } else {\n            // we cannot insert anything inside a textnode so...\n            if (el.nodeType === 3) {\n                where = where === 'afterbegin' ? 'beforebegin' : where;\n                where = where === 'beforeend' ? 'afterend' : where;\n            }\n            range = Ext.supports.CreateContextualFragment ? el.ownerDocument.createRange() : undefined;\n            setStart = 'setStart' + (this.endRe.test(where) ? 'After' : 'Before');\n            if (bb_ae_PositionHash[where]) {\n                if (range) {\n                    range[setStart](el);\n                    frag = range.createContextualFragment(html);\n                } else {\n                    frag = this.createContextualFragment(html);\n                }\n                el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);\n                return el[(where == beforebegin ? 'previous' : 'next') + 'Sibling'];\n            } else {\n                rangeEl = (where == afterbegin ? 'first' : 'last') + 'Child';\n                if (el.firstChild) {\n                    if (range) {\n                        range[setStart](el[rangeEl]);\n                        frag = range.createContextualFragment(html);\n                    } else {\n                        frag = this.createContextualFragment(html);\n                    }\n\n                    if (where == afterbegin) {\n                        el.insertBefore(frag, el.firstChild);\n                    } else {\n                        el.appendChild(frag);\n                    }\n                } else {\n                    el.innerHTML = html;\n                }\n                return el[rangeEl];\n            }\n        }\n        Ext.Error.raise({\n            sourceClass: 'Ext.DomHelper',\n            sourceMethod: 'insertHtml',\n            htmlToInsert: html,\n            targetElement: el,\n            msg: 'Illegal insertion point reached: \"' + where + '\"'\n        });\n    },\n\n    /**\n     * Creates a new Ext.Template from the DOM object spec.\n     * @param {Object} o The DOM object spec (and children)\n     * @return {Ext.Template} The new template\n     */\n    createTemplate: function(o) {\n        var html = this.markup(o);\n        return new Ext.Template(html);\n    }\n\n}, function() {\n    Ext.ns('Ext.core');\n    Ext.DomHelper = Ext.core.DomHelper = new this;\n});\n\n\n}());\n\n//@tag dom,core\n//@require Helper.js\n//@define Ext.dom.Query\n//@define Ext.core.Query\n//@define Ext.DomQuery\n\n/*\n * This is code is also distributed under MIT license for use\n * with jQuery and prototype JavaScript libraries.\n */\n/**\n * @class Ext.dom.Query\n * @alternateClassName Ext.DomQuery\n * @alternateClassName Ext.core.DomQuery\n * @singleton\n *\n * Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes\n * and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).\n *\n * DomQuery supports most of the [CSS3 selectors spec][1], along with some custom selectors and basic XPath.\n *\n * All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example\n * `div.foo:nth-child(odd)[@foo=bar].bar:first` would be a perfectly valid selector. Node filters are processed\n * in the order in which they appear, which allows you to optimize your queries for your document structure.\n *\n * ## Element Selectors:\n *\n *   - **`*`** any element\n *   - **`E`** an element with the tag E\n *   - **`E F`** All descendent elements of E that have the tag F\n *   - **`E > F`** or **E/F** all direct children elements of E that have the tag F\n *   - **`E + F`** all elements with the tag F that are immediately preceded by an element with the tag E\n *   - **`E ~ F`** all elements with the tag F that are preceded by a sibling element with the tag E\n *\n * ## Attribute Selectors:\n *\n * The use of `@` and quotes are optional. For example, `div[@foo='bar']` is also a valid attribute selector.\n *\n *   - **`E[foo]`** has an attribute \"foo\"\n *   - **`E[foo=bar]`** has an attribute \"foo\" that equals \"bar\"\n *   - **`E[foo^=bar]`** has an attribute \"foo\" that starts with \"bar\"\n *   - **`E[foo$=bar]`** has an attribute \"foo\" that ends with \"bar\"\n *   - **`E[foo*=bar]`** has an attribute \"foo\" that contains the substring \"bar\"\n *   - **`E[foo%=2]`** has an attribute \"foo\" that is evenly divisible by 2\n *   - **`E[foo!=bar]`** attribute \"foo\" does not equal \"bar\"\n *\n * ## Pseudo Classes:\n *\n *   - **`E:first-child`** E is the first child of its parent\n *   - **`E:last-child`** E is the last child of its parent\n *   - **`E:nth-child(_n_)`** E is the _n_th child of its parent (1 based as per the spec)\n *   - **`E:nth-child(odd)`** E is an odd child of its parent\n *   - **`E:nth-child(even)`** E is an even child of its parent\n *   - **`E:only-child`** E is the only child of its parent\n *   - **`E:checked`** E is an element that is has a checked attribute that is true (e.g. a radio or checkbox)\n *   - **`E:first`** the first E in the resultset\n *   - **`E:last`** the last E in the resultset\n *   - **`E:nth(_n_)`** the _n_th E in the resultset (1 based)\n *   - **`E:odd`** shortcut for :nth-child(odd)\n *   - **`E:even`** shortcut for :nth-child(even)\n *   - **`E:contains(foo)`** E's innerHTML contains the substring \"foo\"\n *   - **`E:nodeValue(foo)`** E contains a textNode with a nodeValue that equals \"foo\"\n *   - **`E:not(S)`** an E element that does not match simple selector S\n *   - **`E:has(S)`** an E element that has a descendent that matches simple selector S\n *   - **`E:next(S)`** an E element whose next sibling matches simple selector S\n *   - **`E:prev(S)`** an E element whose previous sibling matches simple selector S\n *   - **`E:any(S1|S2|S2)`** an E element which matches any of the simple selectors S1, S2 or S3\n *\n * ## CSS Value Selectors:\n *\n *   - **`E{display=none}`** css value \"display\" that equals \"none\"\n *   - **`E{display^=none}`** css value \"display\" that starts with \"none\"\n *   - **`E{display$=none}`** css value \"display\" that ends with \"none\"\n *   - **`E{display*=none}`** css value \"display\" that contains the substring \"none\"\n *   - **`E{display%=2}`** css value \"display\" that is evenly divisible by 2\n *   - **`E{display!=none}`** css value \"display\" that does not equal \"none\"\n *\n * [1]: http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#selectors\n */\nExt.ns('Ext.core');\n\nExt.dom.Query = Ext.core.DomQuery = Ext.DomQuery = (function(){\n    var cache = {},\n        simpleCache = {},\n        valueCache = {},\n        nonSpace = /\\S/,\n        trimRe = /^\\s+|\\s+$/g,\n        tplRe = /\\{(\\d+)\\}/g,\n        modeRe = /^(\\s?[\\/>+~]\\s?|\\s|$)/,\n        tagTokenRe = /^(#)?([\\w\\-\\*\\\\]+)/,\n        nthRe = /(\\d*)n\\+?(\\d*)/,\n        nthRe2 = /\\D/,\n        startIdRe = /^\\s*\\#/,\n        // This is for IE MSXML which does not support expandos.\n        // IE runs the same speed using setAttribute, however FF slows way down\n        // and Safari completely fails so they need to continue to use expandos.\n        isIE = window.ActiveXObject ? true : false,\n        key = 30803,\n        longHex = /\\\\([0-9a-fA-F]{6})/g,\n        shortHex = /\\\\([0-9a-fA-F]{1,6})\\s{0,1}/g,\n        nonHex = /\\\\([^0-9a-fA-F]{1})/g,\n        escapes = /\\\\/g,\n        num, hasEscapes,\n\n        // replaces a long hex regex match group with the appropriate ascii value\n        // $args indicate regex match pos\n        longHexToChar = function($0, $1) {\n            return String.fromCharCode(parseInt($1, 16));\n        },\n\n        // converts a shortHex regex match to the long form\n        shortToLongHex = function($0, $1) {\n            while ($1.length < 6) {\n                $1 = '0' + $1;\n            }\n            return '\\\\' + $1;\n        },\n\n        // converts a single char escape to long escape form\n        charToLongHex = function($0, $1) {\n            num = $1.charCodeAt(0).toString(16);\n            if (num.length === 1) {\n                num = '0' + num;\n            }\n            return '\\\\0000' + num;\n        },\n\n        // Un-escapes an input selector string.  Assumes all escape sequences have been\n        // normalized to the css '\\\\0000##' 6-hex-digit style escape sequence :\n        // will not handle any other escape formats\n        unescapeCssSelector = function (selector) {\n            return (hasEscapes)\n                ? selector.replace(longHex, longHexToChar)\n                : selector;\n        },\n        \n        // checks if the path has escaping & does any appropriate replacements\n        setupEscapes = function(path){\n            hasEscapes = (path.indexOf('\\\\') > -1);\n            if (hasEscapes) {\n                path = path\n                    .replace(shortHex, shortToLongHex)\n                    .replace(nonHex, charToLongHex)\n                    .replace(escapes, '\\\\\\\\');  // double the '\\' for js compilation\n            }\n            return path;\n        };\n\n    // this eval is stop the compressor from\n    // renaming the variable to something shorter\n    eval(\"var batch = 30803;\");\n\n    // Retrieve the child node from a particular\n    // parent at the specified index.\n    function child(parent, index){\n        var i = 0,\n            n = parent.firstChild;\n        while(n){\n            if(n.nodeType == 1){\n               if(++i == index){\n                   return n;\n               }\n            }\n            n = n.nextSibling;\n        }\n        return null;\n    }\n\n    // retrieve the next element node\n    function next(n){\n        while((n = n.nextSibling) && n.nodeType != 1);\n        return n;\n    }\n\n    // retrieve the previous element node\n    function prev(n){\n        while((n = n.previousSibling) && n.nodeType != 1);\n        return n;\n    }\n\n    // Mark each child node with a nodeIndex skipping and\n    // removing empty text nodes.\n    function children(parent){\n        var n = parent.firstChild,\n        nodeIndex = -1,\n        nextNode;\n        while(n){\n            nextNode = n.nextSibling;\n            // clean worthless empty nodes.\n            if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){\n                parent.removeChild(n);\n            }else{\n                // add an expando nodeIndex\n                n.nodeIndex = ++nodeIndex;\n            }\n            n = nextNode;\n        }\n        return this;\n    }\n\n    // nodeSet - array of nodes\n    // cls - CSS Class\n    function byClassName(nodeSet, cls){\n        cls = unescapeCssSelector(cls);\n        if(!cls){\n            return nodeSet;\n        }\n        var result = [], ri = -1,\n            i, ci;\n        for(i = 0, ci; ci = nodeSet[i]; i++){\n            if((' '+ci.className+' ').indexOf(cls) != -1){\n                result[++ri] = ci;\n            }\n        }\n        return result;\n    }\n\n    function attrValue(n, attr){\n        // if its an array, use the first node.\n        if(!n.tagName && typeof n.length != \"undefined\"){\n            n = n[0];\n        }\n        if(!n){\n            return null;\n        }\n\n        if(attr == \"for\"){\n            return n.htmlFor;\n        }\n        if(attr == \"class\" || attr == \"className\"){\n            return n.className;\n        }\n        return n.getAttribute(attr) || n[attr];\n\n    }\n\n\n    // ns - nodes\n    // mode - false, /, >, +, ~\n    // tagName - defaults to \"*\"\n    function getNodes(ns, mode, tagName){\n        var result = [], ri = -1, cs,\n            i, ni, j, ci, cn, utag, n, cj;\n        if(!ns){\n            return result;\n        }\n        tagName = tagName || \"*\";\n        // convert to array\n        if(typeof ns.getElementsByTagName != \"undefined\"){\n            ns = [ns];\n        }\n\n        // no mode specified, grab all elements by tagName\n        // at any depth\n        if(!mode){\n            for(i = 0, ni; ni = ns[i]; i++){\n                cs = ni.getElementsByTagName(tagName);\n                for(j = 0, ci; ci = cs[j]; j++){\n                    result[++ri] = ci;\n                }\n            }\n        // Direct Child mode (/ or >)\n        // E > F or E/F all direct children elements of E that have the tag\n        } else if(mode == \"/\" || mode == \">\"){\n            utag = tagName.toUpperCase();\n            for(i = 0, ni, cn; ni = ns[i]; i++){\n                cn = ni.childNodes;\n                for(j = 0, cj; cj = cn[j]; j++){\n                    if(cj.nodeName == utag || cj.nodeName == tagName  || tagName == '*'){\n                        result[++ri] = cj;\n                    }\n                }\n            }\n        // Immediately Preceding mode (+)\n        // E + F all elements with the tag F that are immediately preceded by an element with the tag E\n        }else if(mode == \"+\"){\n            utag = tagName.toUpperCase();\n            for(i = 0, n; n = ns[i]; i++){\n                while((n = n.nextSibling) && n.nodeType != 1);\n                if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){\n                    result[++ri] = n;\n                }\n            }\n        // Sibling mode (~)\n        // E ~ F all elements with the tag F that are preceded by a sibling element with the tag E\n        }else if(mode == \"~\"){\n            utag = tagName.toUpperCase();\n            for(i = 0, n; n = ns[i]; i++){\n                while((n = n.nextSibling)){\n                    if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){\n                        result[++ri] = n;\n                    }\n                }\n            }\n        }\n        return result;\n    }\n\n    function concat(a, b){\n        if(b.slice){\n            return a.concat(b);\n        }\n        for(var i = 0, l = b.length; i < l; i++){\n            a[a.length] = b[i];\n        }\n        return a;\n    }\n\n    function byTag(cs, tagName){\n        if(cs.tagName || cs == document){\n            cs = [cs];\n        }\n        if(!tagName){\n            return cs;\n        }\n        var result = [], ri = -1,\n            i, ci;\n        tagName = tagName.toLowerCase();\n        for(i = 0, ci; ci = cs[i]; i++){\n            if(ci.nodeType == 1 && ci.tagName.toLowerCase() == tagName){\n                result[++ri] = ci;\n            }\n        }\n        return result;\n    }\n\n    function byId(cs, id){\n        id = unescapeCssSelector(id);\n        if(cs.tagName || cs == document){\n            cs = [cs];\n        }\n        if(!id){\n            return cs;\n        }\n        var result = [], ri = -1,\n            i, ci;\n        for(i = 0, ci; ci = cs[i]; i++){\n            if(ci && ci.id == id){\n                result[++ri] = ci;\n                return result;\n            }\n        }\n        return result;\n    }\n\n    // operators are =, !=, ^=, $=, *=, %=, |= and ~=\n    // custom can be \"{\"\n    function byAttribute(cs, attr, value, op, custom){\n        var result = [],\n            ri = -1,\n            useGetStyle = custom == \"{\",\n            fn = Ext.DomQuery.operators[op],\n            a,\n            xml,\n            hasXml,\n            i, ci;\n\n        value = unescapeCssSelector(value);\n\n        for(i = 0, ci; ci = cs[i]; i++){\n            // skip non-element nodes.\n            if(ci.nodeType != 1){\n                continue;\n            }\n            // only need to do this for the first node\n            if(!hasXml){\n                xml = Ext.DomQuery.isXml(ci);\n                hasXml = true;\n            }\n\n            // we only need to change the property names if we're dealing with html nodes, not XML\n            if(!xml){\n                if(useGetStyle){\n                    a = Ext.DomQuery.getStyle(ci, attr);\n                } else if (attr == \"class\" || attr == \"className\"){\n                    a = ci.className;\n                } else if (attr == \"for\"){\n                    a = ci.htmlFor;\n                } else if (attr == \"href\"){\n                    // getAttribute href bug\n                    // http://www.glennjones.net/Post/809/getAttributehrefbug.htm\n                    a = ci.getAttribute(\"href\", 2);\n                } else{\n                    a = ci.getAttribute(attr);\n                }\n            }else{\n                a = ci.getAttribute(attr);\n            }\n            if((fn && fn(a, value)) || (!fn && a)){\n                result[++ri] = ci;\n            }\n        }\n        return result;\n    }\n\n    function byPseudo(cs, name, value){\n        value = unescapeCssSelector(value);\n        return Ext.DomQuery.pseudos[name](cs, value);\n    }\n\n    function nodupIEXml(cs){\n        var d = ++key,\n            r,\n            i, len, c;\n        cs[0].setAttribute(\"_nodup\", d);\n        r = [cs[0]];\n        for(i = 1, len = cs.length; i < len; i++){\n            c = cs[i];\n            if(!c.getAttribute(\"_nodup\") != d){\n                c.setAttribute(\"_nodup\", d);\n                r[r.length] = c;\n            }\n        }\n        for(i = 0, len = cs.length; i < len; i++){\n            cs[i].removeAttribute(\"_nodup\");\n        }\n        return r;\n    }\n\n    function nodup(cs){\n        if(!cs){\n            return [];\n        }\n        var len = cs.length, c, i, r = cs, cj, ri = -1, d, j;\n        if(!len || typeof cs.nodeType != \"undefined\" || len == 1){\n            return cs;\n        }\n        if(isIE && typeof cs[0].selectSingleNode != \"undefined\"){\n            return nodupIEXml(cs);\n        }\n        d = ++key;\n        cs[0]._nodup = d;\n        for(i = 1; c = cs[i]; i++){\n            if(c._nodup != d){\n                c._nodup = d;\n            }else{\n                r = [];\n                for(j = 0; j < i; j++){\n                    r[++ri] = cs[j];\n                }\n                for(j = i+1; cj = cs[j]; j++){\n                    if(cj._nodup != d){\n                        cj._nodup = d;\n                        r[++ri] = cj;\n                    }\n                }\n                return r;\n            }\n        }\n        return r;\n    }\n\n    function quickDiffIEXml(c1, c2){\n        var d = ++key,\n            r = [],\n            i, len;\n        for(i = 0, len = c1.length; i < len; i++){\n            c1[i].setAttribute(\"_qdiff\", d);\n        }\n        for(i = 0, len = c2.length; i < len; i++){\n            if(c2[i].getAttribute(\"_qdiff\") != d){\n                r[r.length] = c2[i];\n            }\n        }\n        for(i = 0, len = c1.length; i < len; i++){\n           c1[i].removeAttribute(\"_qdiff\");\n        }\n        return r;\n    }\n\n    function quickDiff(c1, c2){\n        var len1 = c1.length,\n            d = ++key,\n            r = [],\n            i, len;\n        if(!len1){\n            return c2;\n        }\n        if(isIE && typeof c1[0].selectSingleNode != \"undefined\"){\n            return quickDiffIEXml(c1, c2);\n        }\n        for(i = 0; i < len1; i++){\n            c1[i]._qdiff = d;\n        }\n        for(i = 0, len = c2.length; i < len; i++){\n            if(c2[i]._qdiff != d){\n                r[r.length] = c2[i];\n            }\n        }\n        return r;\n    }\n\n    function quickId(ns, mode, root, id){\n        if(ns == root){\n            id = unescapeCssSelector(id);\n            var d = root.ownerDocument || root;\n            return d.getElementById(id);\n        }\n        ns = getNodes(ns, mode, \"*\");\n        return byId(ns, id);\n    }\n\n    return {\n        getStyle : function(el, name){\n            return Ext.fly(el).getStyle(name);\n        },\n        /**\n         * Compiles a selector/xpath query into a reusable function. The returned function\n         * takes one parameter \"root\" (optional), which is the context node from where the query should start.\n         * @param {String} selector The selector/xpath query\n         * @param {String} [type=\"select\"] Either \"select\" or \"simple\" for a simple selector match\n         * @return {Function}\n         */\n        compile : function(path, type){\n            type = type || \"select\";\n\n            // setup fn preamble\n            var fn = [\"var f = function(root){\\n var mode; ++batch; var n = root || document;\\n\"],\n                mode,\n                lastPath,\n                matchers = Ext.DomQuery.matchers,\n                matchersLn = matchers.length,\n                modeMatch,\n                // accept leading mode switch\n                lmode = path.match(modeRe),\n                tokenMatch, matched, j, t, m;\n\n            path = setupEscapes(path);\n\n            if(lmode && lmode[1]){\n                fn[fn.length] = 'mode=\"'+lmode[1].replace(trimRe, \"\")+'\";';\n                path = path.replace(lmode[1], \"\");\n            }\n\n            // strip leading slashes\n            while(path.substr(0, 1)==\"/\"){\n                path = path.substr(1);\n            }\n\n            while(path && lastPath != path){\n                lastPath = path;\n                tokenMatch = path.match(tagTokenRe);\n                if(type == \"select\"){\n                    if(tokenMatch){\n                        // ID Selector\n                        if(tokenMatch[1] == \"#\"){\n                            fn[fn.length] = 'n = quickId(n, mode, root, \"'+tokenMatch[2]+'\");';\n                        }else{\n                            fn[fn.length] = 'n = getNodes(n, mode, \"'+tokenMatch[2]+'\");';\n                        }\n                        path = path.replace(tokenMatch[0], \"\");\n                    }else if(path.substr(0, 1) != '@'){\n                        fn[fn.length] = 'n = getNodes(n, mode, \"*\");';\n                    }\n                // type of \"simple\"\n                }else{\n                    if(tokenMatch){\n                        if(tokenMatch[1] == \"#\"){\n                            fn[fn.length] = 'n = byId(n, \"'+tokenMatch[2]+'\");';\n                        }else{\n                            fn[fn.length] = 'n = byTag(n, \"'+tokenMatch[2]+'\");';\n                        }\n                        path = path.replace(tokenMatch[0], \"\");\n                    }\n                }\n                while(!(modeMatch = path.match(modeRe))){\n                    matched = false;\n                    for(j = 0; j < matchersLn; j++){\n                        t = matchers[j];\n                        m = path.match(t.re);\n                        if(m){\n                            fn[fn.length] = t.select.replace(tplRe, function(x, i){\n                                return m[i];\n                            });\n                            path = path.replace(m[0], \"\");\n                            matched = true;\n                            break;\n                        }\n                    }\n                    // prevent infinite loop on bad selector\n                    if(!matched){\n                        Ext.Error.raise({\n                            sourceClass: 'Ext.DomQuery',\n                            sourceMethod: 'compile',\n                            msg: 'Error parsing selector. Parsing failed at \"' + path + '\"'\n                        });\n                    }\n                }\n                if(modeMatch[1]){\n                    fn[fn.length] = 'mode=\"'+modeMatch[1].replace(trimRe, \"\")+'\";';\n                    path = path.replace(modeMatch[1], \"\");\n                }\n            }\n            // close fn out\n            fn[fn.length] = \"return nodup(n);\\n}\";\n\n            // eval fn and return it\n            eval(fn.join(\"\"));\n            return f;\n        },\n\n        /**\n         * Selects an array of DOM nodes using JavaScript-only implementation.\n         *\n         * Use {@link #select} to take advantage of browsers built-in support for CSS selectors.\n         * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)\n         * @param {HTMLElement/String} [root=document] The start of the query.\n         * @return {HTMLElement[]} An Array of DOM elements which match the selector. If there are\n         * no matches, and empty Array is returned.\n         */\n        jsSelect: function(path, root, type){\n            // set root to doc if not specified.\n            root = root || document;\n\n            if(typeof root == \"string\"){\n                root = document.getElementById(root);\n            }\n            var paths = path.split(\",\"),\n                results = [],\n                i, len, subPath, result;\n\n            // loop over each selector\n            for(i = 0, len = paths.length; i < len; i++){\n                subPath = paths[i].replace(trimRe, \"\");\n                // compile and place in cache\n                if(!cache[subPath]){\n                    // When we compile, escaping is handled inside the compile method\n                    cache[subPath] = Ext.DomQuery.compile(subPath, type);\n                    if(!cache[subPath]){\n                        Ext.Error.raise({\n                            sourceClass: 'Ext.DomQuery',\n                            sourceMethod: 'jsSelect',\n                            msg: subPath + ' is not a valid selector'\n                        });\n                    }\n                } else {\n                    // If we've already compiled, we still need to check if the\n                    // selector has escaping and setup the appropriate flags\n                    setupEscapes(subPath);\n                }\n                result = cache[subPath](root);\n                if(result && result != document){\n                    results = results.concat(result);\n                }\n            }\n\n            // if there were multiple selectors, make sure dups\n            // are eliminated\n            if(paths.length > 1){\n                return nodup(results);\n            }\n            return results;\n        },\n\n        isXml: function(el) {\n            var docEl = (el ? el.ownerDocument || el : 0).documentElement;\n            return docEl ? docEl.nodeName !== \"HTML\" : false;\n        },\n\n        /**\n         * Selects an array of DOM nodes by CSS/XPath selector.\n         *\n         * Uses [document.querySelectorAll][0] if browser supports that, otherwise falls back to\n         * {@link Ext.dom.Query#jsSelect} to do the work.\n         *\n         * Aliased as {@link Ext#query}.\n         *\n         * [0]: https://developer.mozilla.org/en/DOM/document.querySelectorAll\n         *\n         * @param {String} path The selector/xpath query\n         * @param {HTMLElement} [root=document] The start of the query.\n         * @return {HTMLElement[]} An array of DOM elements (not a NodeList as returned by `querySelectorAll`).\n         * @param {String} [type=\"select\"] Either \"select\" or \"simple\" for a simple selector match (only valid when\n         * used when the call is deferred to the jsSelect method)\n         * @method\n         */\n        select : document.querySelectorAll ? function(path, root, type) {\n            root = root || document;\n            if (!Ext.DomQuery.isXml(root)) {\n                try {\n                    /*\n                     * This checking here is to \"fix\" the behaviour of querySelectorAll\n                     * for non root document queries. The way qsa works is intentional,\n                     * however it's definitely not the expected way it should work.\n                     * When descendant selectors are used, only the lowest selector must be inside the root!\n                     * More info: http://ejohn.org/blog/thoughts-on-queryselectorall/\n                     * So we create a descendant selector by prepending the root's ID, and query the parent node.\n                     * UNLESS the root has no parent in which qsa will work perfectly.\n                     *\n                     * We only modify the path for single selectors (ie, no multiples),\n                     * without a full parser it makes it difficult to do this correctly.\n                     */\n                    if (root.parentNode && (root.nodeType !== 9) && path.indexOf(',') === -1 && !startIdRe.test(path)) {\n                        path = '#' + Ext.escapeId(Ext.id(root)) + ' ' + path;\n                        root = root.parentNode;\n                    }\n                    return Ext.Array.toArray(root.querySelectorAll(path));\n                }\n                catch (e) {\n                }\n            }\n            return Ext.DomQuery.jsSelect.call(this, path, root, type);\n        } : function(path, root, type) {\n            return Ext.DomQuery.jsSelect.call(this, path, root, type);\n        },\n\n        /**\n         * Selects a single element.\n         * @param {String} selector The selector/xpath query\n         * @param {HTMLElement} [root=document] The start of the query.\n         * @return {HTMLElement} The DOM element which matched the selector.\n         */\n        selectNode : function(path, root){\n            return Ext.DomQuery.select(path, root)[0];\n        },\n\n        /**\n         * Selects the value of a node, optionally replacing null with the defaultValue.\n         * @param {String} selector The selector/xpath query\n         * @param {HTMLElement} [root=document] The start of the query.\n         * @param {String} [defaultValue] When specified, this is return as empty value.\n         * @return {String}\n         */\n        selectValue : function(path, root, defaultValue){\n            path = path.replace(trimRe, \"\");\n            if (!valueCache[path]) {\n                valueCache[path] = Ext.DomQuery.compile(path, \"select\");\n            } else {\n                setupEscapes(path);\n            }\n            \n            var n = valueCache[path](root), \n                v;\n                \n            n = n[0] ? n[0] : n;\n\n            // overcome a limitation of maximum textnode size\n            // Rumored to potentially crash IE6 but has not been confirmed.\n            // http://reference.sitepoint.com/javascript/Node/normalize\n            // https://developer.mozilla.org/En/DOM/Node.normalize\n            if (typeof n.normalize == 'function') {\n                n.normalize();\n            }\n\n            v = (n && n.firstChild ? n.firstChild.nodeValue : null);\n            return ((v === null||v === undefined||v==='') ? defaultValue : v);\n        },\n\n        /**\n         * Selects the value of a node, parsing integers and floats.\n         * Returns the defaultValue, or 0 if none is specified.\n         * @param {String} selector The selector/xpath query\n         * @param {HTMLElement} [root=document] The start of the query.\n         * @param {Number} [defaultValue] When specified, this is return as empty value.\n         * @return {Number}\n         */\n        selectNumber : function(path, root, defaultValue){\n            var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);\n            return parseFloat(v);\n        },\n\n        /**\n         * Returns true if the passed element(s) match the passed simple selector\n         * (e.g. `div.some-class` or `span:first-child`)\n         * @param {String/HTMLElement/HTMLElement[]} el An element id, element or array of elements\n         * @param {String} selector The simple selector to test\n         * @return {Boolean}\n         */\n        is : function(el, ss){\n            if(typeof el == \"string\"){\n                el = document.getElementById(el);\n            }\n            var isArray = Ext.isArray(el),\n                result = Ext.DomQuery.filter(isArray ? el : [el], ss);\n            return isArray ? (result.length == el.length) : (result.length > 0);\n        },\n\n        /**\n         * Filters an array of elements to only include matches of a simple selector\n         * (e.g. `div.some-class` or `span:first-child`)\n         * @param {HTMLElement[]} el An array of elements to filter\n         * @param {String} selector The simple selector to test\n         * @param {Boolean} nonMatches If true, it returns the elements that DON'T match the selector instead of the\n         * ones that match\n         * @return {HTMLElement[]} An Array of DOM elements which match the selector. If there are no matches, and empty\n         * Array is returned.\n         */\n        filter : function(els, ss, nonMatches){\n            ss = ss.replace(trimRe, \"\");\n            if (!simpleCache[ss]) {\n                simpleCache[ss] = Ext.DomQuery.compile(ss, \"simple\");\n            } else {\n                setupEscapes(ss);\n            }\n            \n            var result = simpleCache[ss](els);\n            return nonMatches ? quickDiff(result, els) : result;\n        },\n\n        /**\n         * Collection of matching regular expressions and code snippets.\n         * Each capture group within `()` will be replace the `{}` in the select\n         * statement as specified by their index.\n         */\n        matchers : [{\n                re: /^\\.([\\w\\-\\\\]+)/,\n                select: 'n = byClassName(n, \" {1} \");'\n            }, {\n                re: /^\\:([\\w\\-]+)(?:\\(((?:[^\\s>\\/]*|.*?))\\))?/,\n                select: 'n = byPseudo(n, \"{1}\", \"{2}\");'\n            },{\n                re: /^(?:([\\[\\{])(?:@)?([\\w\\-]+)\\s?(?:(=|.=)\\s?['\"]?(.*?)[\"']?)?[\\]\\}])/,\n                select: 'n = byAttribute(n, \"{2}\", \"{4}\", \"{3}\", \"{1}\");'\n            }, {\n                re: /^#([\\w\\-\\\\]+)/,\n                select: 'n = byId(n, \"{1}\");'\n            },{\n                re: /^@([\\w\\-]+)/,\n                select: 'return {firstChild:{nodeValue:attrValue(n, \"{1}\")}};'\n            }\n        ],\n\n        /**\n         * Collection of operator comparison functions.\n         * The default operators are `=`, `!=`, `^=`, `$=`, `*=`, `%=`, `|=` and `~=`.\n         * New operators can be added as long as the match the format *c*`=` where *c*\n         * is any character other than space, `>`, or `<`.\n         */\n        operators : {\n            \"=\" : function(a, v){\n                return a == v;\n            },\n            \"!=\" : function(a, v){\n                return a != v;\n            },\n            \"^=\" : function(a, v){\n                return a && a.substr(0, v.length) == v;\n            },\n            \"$=\" : function(a, v){\n                return a && a.substr(a.length-v.length) == v;\n            },\n            \"*=\" : function(a, v){\n                return a && a.indexOf(v) !== -1;\n            },\n            \"%=\" : function(a, v){\n                return (a % v) == 0;\n            },\n            \"|=\" : function(a, v){\n                return a && (a == v || a.substr(0, v.length+1) == v+'-');\n            },\n            \"~=\" : function(a, v){\n                return a && (' '+a+' ').indexOf(' '+v+' ') != -1;\n            }\n        },\n\n        /**\n         * Object hash of \"pseudo class\" filter functions which are used when filtering selections.\n         * Each function is passed two parameters:\n         *\n         * - **c** : Array\n         *     An Array of DOM elements to filter.\n         *\n         * - **v** : String\n         *     The argument (if any) supplied in the selector.\n         *\n         * A filter function returns an Array of DOM elements which conform to the pseudo class.\n         * In addition to the provided pseudo classes listed above such as `first-child` and `nth-child`,\n         * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.\n         *\n         * For example, to filter `a` elements to only return links to __external__ resources:\n         *\n         *     Ext.DomQuery.pseudos.external = function(c, v){\n         *         var r = [], ri = -1;\n         *         for(var i = 0, ci; ci = c[i]; i++){\n         *             // Include in result set only if it's a link to an external resource\n         *             if(ci.hostname != location.hostname){\n         *                 r[++ri] = ci;\n         *             }\n         *         }\n         *         return r;\n         *     };\n         *\n         * Then external links could be gathered with the following statement:\n         *\n         *     var externalLinks = Ext.select(\"a:external\");\n         */\n        pseudos : {\n            \"first-child\" : function(c){\n                var r = [], ri = -1, n,\n                    i, ci;\n                for(i = 0; (ci = n = c[i]); i++){\n                    while((n = n.previousSibling) && n.nodeType != 1);\n                    if(!n){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"last-child\" : function(c){\n                var r = [], ri = -1, n,\n                    i, ci;\n                for(i = 0; (ci = n = c[i]); i++){\n                    while((n = n.nextSibling) && n.nodeType != 1);\n                    if(!n){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"nth-child\" : function(c, a) {\n                var r = [], ri = -1,\n                    m = nthRe.exec(a == \"even\" && \"2n\" || a == \"odd\" && \"2n+1\" || !nthRe2.test(a) && \"n+\" + a || a),\n                    f = (m[1] || 1) - 0, l = m[2] - 0,\n                    i, n, j, cn, pn;\n                for(i = 0; n = c[i]; i++){\n                    pn = n.parentNode;\n                    if (batch != pn._batch) {\n                        j = 0;\n                        for(cn = pn.firstChild; cn; cn = cn.nextSibling){\n                            if(cn.nodeType == 1){\n                               cn.nodeIndex = ++j;\n                            }\n                        }\n                        pn._batch = batch;\n                    }\n                    if (f == 1) {\n                        if (l == 0 || n.nodeIndex == l){\n                            r[++ri] = n;\n                        }\n                    } else if ((n.nodeIndex + l) % f == 0){\n                        r[++ri] = n;\n                    }\n                }\n\n                return r;\n            },\n\n            \"only-child\" : function(c){\n                var r = [], ri = -1,\n                    i, ci;\n                for(i = 0; ci = c[i]; i++){\n                    if(!prev(ci) && !next(ci)){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"empty\" : function(c){\n                var r = [], ri = -1,\n                    i, ci, cns, j, cn, empty;\n                for(i = 0, ci; ci = c[i]; i++){\n                    cns = ci.childNodes;\n                    j = 0;\n                    empty = true;\n                    while(cn = cns[j]){\n                        ++j;\n                        if(cn.nodeType == 1 || cn.nodeType == 3){\n                            empty = false;\n                            break;\n                        }\n                    }\n                    if(empty){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"contains\" : function(c, v){\n                var r = [], ri = -1,\n                    i, ci;\n                for(i = 0; ci = c[i]; i++){\n                    if((ci.textContent||ci.innerText||ci.text||'').indexOf(v) != -1){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"nodeValue\" : function(c, v){\n                var r = [], ri = -1,\n                    i, ci;\n                for(i = 0; ci = c[i]; i++){\n                    if(ci.firstChild && ci.firstChild.nodeValue == v){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"checked\" : function(c){\n                var r = [], ri = -1,\n                    i, ci;\n                for(i = 0; ci = c[i]; i++){\n                    if(ci.checked == true){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"not\" : function(c, ss){\n                return Ext.DomQuery.filter(c, ss, true);\n            },\n\n            \"any\" : function(c, selectors){\n                var ss = selectors.split('|'),\n                    r = [], ri = -1, s,\n                    i, ci, j;\n                for(i = 0; ci = c[i]; i++){\n                    for(j = 0; s = ss[j]; j++){\n                        if(Ext.DomQuery.is(ci, s)){\n                            r[++ri] = ci;\n                            break;\n                        }\n                    }\n                }\n                return r;\n            },\n\n            \"odd\" : function(c){\n                return this[\"nth-child\"](c, \"odd\");\n            },\n\n            \"even\" : function(c){\n                return this[\"nth-child\"](c, \"even\");\n            },\n\n            \"nth\" : function(c, a){\n                return c[a-1] || [];\n            },\n\n            \"first\" : function(c){\n                return c[0] || [];\n            },\n\n            \"last\" : function(c){\n                return c[c.length-1] || [];\n            },\n\n            \"has\" : function(c, ss){\n                var s = Ext.DomQuery.select,\n                    r = [], ri = -1,\n                    i, ci;\n                for(i = 0; ci = c[i]; i++){\n                    if(s(ss, ci).length > 0){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"next\" : function(c, ss){\n                var is = Ext.DomQuery.is,\n                    r = [], ri = -1,\n                    i, ci, n;\n                for(i = 0; ci = c[i]; i++){\n                    n = next(ci);\n                    if(n && is(n, ss)){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            },\n\n            \"prev\" : function(c, ss){\n                var is = Ext.DomQuery.is,\n                    r = [], ri = -1,\n                    i, ci, n;\n                for(i = 0; ci = c[i]; i++){\n                    n = prev(ci);\n                    if(n && is(n, ss)){\n                        r[++ri] = ci;\n                    }\n                }\n                return r;\n            }\n        }\n    };\n}());\n\n/**\n * Shorthand of {@link Ext.dom.Query#select}\n * @member Ext\n * @method query\n * @inheritdoc Ext.dom.Query#select\n */\nExt.query = Ext.DomQuery.select;\n\n\n//@tag dom,core\n//@require Query.js\n//@define Ext.dom.Element\n//@require Ext.dom.AbstractElement\n\n/**\n * @class Ext.dom.Element\n * @alternateClassName Ext.Element\n * @alternateClassName Ext.core.Element\n * @extend Ext.dom.AbstractElement\n *\n * Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.\n *\n * All instances of this class inherit the methods of {@link Ext.fx.Anim} making visual effects easily available to all\n * DOM elements.\n *\n * Note that the events documented in this class are not Ext events, they encapsulate browser events. Some older browsers\n * may not support the full range of events. Which events are supported is beyond the control of Ext JS.\n *\n * Usage:\n *\n *     // by id\n *     var el = Ext.get(\"my-div\");\n *\n *     // by DOM element reference\n *     var el = Ext.get(myDivElement);\n *\n * # Animations\n *\n * When an element is manipulated, by default there is no animation.\n *\n *     var el = Ext.get(\"my-div\");\n *\n *     // no animation\n *     el.setWidth(100);\n *\n * Many of the functions for manipulating an element have an optional \"animate\" parameter. This parameter can be\n * specified as boolean (true) for default animation effects.\n *\n *     // default animation\n *     el.setWidth(100, true);\n *\n * To configure the effects, an object literal with animation options to use as the Element animation configuration\n * object can also be specified. Note that the supported Element animation configuration options are a subset of the\n * {@link Ext.fx.Anim} animation options specific to Fx effects. The supported Element animation configuration options\n * are:\n *\n *     Option    Default   Description\n *     --------- --------  ---------------------------------------------\n *     {@link Ext.fx.Anim#duration duration}  350       The duration of the animation in milliseconds\n *     {@link Ext.fx.Anim#easing easing}    easeOut   The easing method\n *     {@link Ext.fx.Anim#callback callback}  none      A function to execute when the anim completes\n *     {@link Ext.fx.Anim#scope scope}     this      The scope (this) of the callback function\n *\n * Usage:\n *\n *     // Element animation options object\n *     var opt = {\n *         {@link Ext.fx.Anim#duration duration}: 1000,\n *         {@link Ext.fx.Anim#easing easing}: 'elasticIn',\n *         {@link Ext.fx.Anim#callback callback}: this.foo,\n *         {@link Ext.fx.Anim#scope scope}: this\n *     };\n *     // animation with some options set\n *     el.setWidth(100, opt);\n *\n * The Element animation object being used for the animation will be set on the options object as \"anim\", which allows\n * you to stop or manipulate the animation. Here is an example:\n *\n *     // using the \"anim\" property to get the Anim object\n *     if(opt.anim.isAnimated()){\n *         opt.anim.stop();\n *     }\n *\n * # Composite (Collections of) Elements\n *\n * For working with collections of Elements, see {@link Ext.CompositeElement}\n *\n * @constructor\n * Creates new Element directly.\n * @param {String/HTMLElement} element\n * @param {Boolean} [forceNew] By default the constructor checks to see if there is already an instance of this\n * element in the cache and if there is it returns the same instance. This will skip that check (useful for extending\n * this class).\n * @return {Object}\n */\n(function() {\n\nvar HIDDEN = 'hidden',\n    DOC             = document,\n    VISIBILITY      = \"visibility\",\n    DISPLAY         = \"display\",\n    NONE            = \"none\",\n    XMASKED         = Ext.baseCSSPrefix + \"masked\",\n    XMASKEDRELATIVE = Ext.baseCSSPrefix + \"masked-relative\",\n    EXTELMASKMSG    = Ext.baseCSSPrefix + \"mask-msg\",\n    bodyRe          = /^body/i,\n    visFly,\n\n    // speedy lookup for elements never to box adjust\n    noBoxAdjust = Ext.isStrict ? {\n        select: 1\n    }: {\n        input: 1,\n        select: 1,\n        textarea: 1\n    },\n\n    // Pseudo for use by cacheScrollValues\n    isScrolled = function(c) {\n        var r = [], ri = -1,\n            i, ci;\n        for (i = 0; ci = c[i]; i++) {\n            if (ci.scrollTop > 0 || ci.scrollLeft > 0) {\n                r[++ri] = ci;\n            }\n        }\n        return r;\n    },\n\n    Element = Ext.define('Ext.dom.Element', {\n\n    extend: 'Ext.dom.AbstractElement',\n\n    alternateClassName: ['Ext.Element', 'Ext.core.Element'],\n\n    addUnits: function() {\n        return this.self.addUnits.apply(this.self, arguments);\n    },\n\n    /**\n     * Tries to focus the element. Any exceptions are caught and ignored.\n     * @param {Number} [defer] Milliseconds to defer the focus\n     * @return {Ext.dom.Element} this\n     */\n    focus: function(defer, /* private */ dom) {\n        var me = this,\n            scrollTop,\n            body;\n\n        dom = dom || me.dom;\n        body = (dom.ownerDocument || DOC).body || DOC.body;\n        try {\n            if (Number(defer)) {\n                Ext.defer(me.focus, defer, me, [null, dom]);\n            } else {\n                // Focusing a large element, the browser attempts to scroll as much of it into view\n                // as possible. We need to override this behaviour.\n                if (dom.offsetHeight > Element.getViewHeight()) {\n                    scrollTop = body.scrollTop;\n                }\n                dom.focus();\n                if (scrollTop !== undefined) {\n                    body.scrollTop = scrollTop;\n                }\n            }\n        } catch(e) {\n        }\n        return me;\n    },\n\n    /**\n     * Tries to blur the element. Any exceptions are caught and ignored.\n     * @return {Ext.dom.Element} this\n     */\n    blur: function() {\n        try {\n            this.dom.blur();\n        } catch(e) {\n        }\n        return this;\n    },\n\n    /**\n     * Tests various css rules/browsers to determine if this element uses a border box\n     * @return {Boolean}\n     */\n    isBorderBox: function() {\n        var box = Ext.isBorderBox;\n        if (box) {\n            box = !((this.dom.tagName || \"\").toLowerCase() in noBoxAdjust);\n        }\n        return box;\n    },\n\n    /**\n     * Sets up event handlers to call the passed functions when the mouse is moved into and out of the Element.\n     * @param {Function} overFn The function to call when the mouse enters the Element.\n     * @param {Function} outFn The function to call when the mouse leaves the Element.\n     * @param {Object} [scope] The scope (`this` reference) in which the functions are executed. Defaults\n     * to the Element's DOM element.\n     * @param {Object} [options] Options for the listener. See {@link Ext.util.Observable#addListener the\n     * options parameter}.\n     * @return {Ext.dom.Element} this\n     */\n    hover: function(overFn, outFn, scope, options) {\n        var me = this;\n        me.on('mouseenter', overFn, scope || me.dom, options);\n        me.on('mouseleave', outFn, scope || me.dom, options);\n        return me;\n    },\n\n    /**\n     * Returns the value of a namespaced attribute from the element's underlying DOM node.\n     * @param {String} namespace The namespace in which to look for the attribute\n     * @param {String} name The attribute name\n     * @return {String} The attribute value\n     */\n    getAttributeNS: function(ns, name) {\n        return this.getAttribute(name, ns);\n    },\n\n    getAttribute: (Ext.isIE && !(Ext.isIE9 && DOC.documentMode === 9)) ?\n        function(name, ns) {\n            var d = this.dom,\n                    type;\n            if (ns) {\n                type = typeof d[ns + \":\" + name];\n                if (type != 'undefined' && type != 'unknown') {\n                    return d[ns + \":\" + name] || null;\n                }\n                return null;\n            }\n            if (name === \"for\") {\n                name = \"htmlFor\";\n            }\n            return d[name] || null;\n        } : function(name, ns) {\n            var d = this.dom;\n            if (ns) {\n                return d.getAttributeNS(ns, name) || d.getAttribute(ns + \":\" + name);\n            }\n            return  d.getAttribute(name) || d[name] || null;\n        },\n\n    /**\n     * When an element is moved around in the DOM, or is hidden using `display:none`, it loses layout, and therefore\n     * all scroll positions of all descendant elements are lost.\n     * \n     * This function caches them, and returns a function, which when run will restore the cached positions.\n     * In the following example, the Panel is moved from one Container to another which will cause it to lose all scroll positions:\n     * \n     *     var restoreScroll = myPanel.el.cacheScrollValues();\n     *     myOtherContainer.add(myPanel);\n     *     restoreScroll();\n     * \n     * @return {Function} A function which will restore all descentant elements of this Element to their scroll\n     * positions recorded when this function was executed. Be aware that the returned function is a closure which has\n     * captured the scope of `cacheScrollValues`, so take care to derefence it as soon as not needed - if is it is a `var`\n     * it will drop out of scope, and the reference will be freed.\n     */\n    cacheScrollValues: function() {\n        var me = this,\n            scrolledDescendants,\n            el, i,\n            scrollValues = [],\n            result = function() {\n                for (i = 0; i < scrolledDescendants.length; i++) {\n                    el = scrolledDescendants[i];\n                    el.scrollLeft = scrollValues[i][0];\n                    el.scrollTop  = scrollValues[i][1];\n                }\n            };\n\n        if (!Ext.DomQuery.pseudos.isScrolled) {\n            Ext.DomQuery.pseudos.isScrolled = isScrolled;\n        }\n        scrolledDescendants = me.query(':isScrolled');\n        for (i = 0; i < scrolledDescendants.length; i++) {\n            el = scrolledDescendants[i];\n            scrollValues[i] = [el.scrollLeft, el.scrollTop];\n        }\n        return result;\n    },\n\n    /**\n     * @property {Boolean} autoBoxAdjust\n     * True to automatically adjust width and height settings for box-model issues.\n     */\n    autoBoxAdjust: true,\n\n    /**\n     * Checks whether the element is currently visible using both visibility and display properties.\n     * @param {Boolean} [deep=false] True to walk the dom and see if parent elements are hidden.\n     * If false, the function only checks the visibility of the element itself and it may return\n     * `true` even though a parent is not visible.\n     * @return {Boolean} `true` if the element is currently visible, else `false`\n     */\n    isVisible : function(deep) {\n        var me = this,\n            dom = me.dom,\n            stopNode = dom.ownerDocument.documentElement;\n\n        if (!visFly) {\n            visFly = new Element.Fly();\n        }\n\n        while (dom !== stopNode) {\n            // We're invisible if we hit a nonexistent parentNode or a document\n            // fragment or computed style visibility:hidden or display:none\n            if (!dom || dom.nodeType === 11 || (visFly.attach(dom)).isStyle(VISIBILITY, HIDDEN) || visFly.isStyle(DISPLAY, NONE)) {\n                return false;\n            }\n            // Quit now unless we are being asked to check parent nodes.\n            if (!deep) {\n                break;\n            }\n            dom = dom.parentNode;\n        }\n        return true;\n    },\n\n    /**\n     * Returns true if display is not \"none\"\n     * @return {Boolean}\n     */\n    isDisplayed : function() {\n        return !this.isStyle(DISPLAY, NONE);\n    },\n\n    /**\n     * Convenience method for setVisibilityMode(Element.DISPLAY)\n     * @param {String} [display] What to set display to when visible\n     * @return {Ext.dom.Element} this\n     */\n    enableDisplayMode : function(display) {\n        var me = this;\n        \n        me.setVisibilityMode(Element.DISPLAY);\n\n        if (!Ext.isEmpty(display)) {\n            (me.$cache || me.getCache()).data.originalDisplay = display;\n        }\n\n        return me;\n    },\n\n    /**\n     * Puts a mask over this element to disable user interaction. Requires core.css.\n     * This method can only be applied to elements which accept child nodes.\n     * @param {String} [msg] A message to display in the mask\n     * @param {String} [msgCls] A css class to apply to the msg element\n     * @return {Ext.dom.Element} The mask element\n     */\n    mask : function(msg, msgCls /* private - passed by AbstractComponent.mask to avoid the need to interrogate the DOM to get the height*/, elHeight) {\n        var me            = this,\n            dom           = me.dom,\n            // In some cases, setExpression will exist but not be of a function type,\n            // so we check it explicitly here to stop IE throwing errors\n            setExpression = dom.style.setExpression,\n            data          = (me.$cache || me.getCache()).data,\n            maskEl        = data.maskEl,\n            maskMsg       = data.maskMsg;\n\n        if (!(bodyRe.test(dom.tagName) && me.getStyle('position') == 'static')) {\n            me.addCls(XMASKEDRELATIVE);\n        }\n        \n        // We always needs to recreate the mask since the DOM element may have been re-created\n        if (maskEl) {\n            maskEl.remove();\n        }\n        \n        if (maskMsg) {\n            maskMsg.remove();\n        }\n\n        Ext.DomHelper.append(dom, [{\n            cls : Ext.baseCSSPrefix + \"mask\"\n        }, {\n            cls : msgCls ? EXTELMASKMSG + \" \" + msgCls : EXTELMASKMSG,\n            cn  : {\n                tag: 'div',\n                html: msg || ''\n            }\n        }]);\n            \n        maskMsg = Ext.get(dom.lastChild);\n        maskEl = Ext.get(maskMsg.dom.previousSibling);\n        data.maskMsg = maskMsg;\n        data.maskEl = maskEl;\n\n        me.addCls(XMASKED);\n        maskEl.setDisplayed(true);\n\n        if (typeof msg == 'string') {\n            maskMsg.setDisplayed(true);\n            maskMsg.center(me);\n        } else {\n            maskMsg.setDisplayed(false);\n        }\n        // NOTE: CSS expressions are resource intensive and to be used only as a last resort\n        // These expressions are removed as soon as they are no longer necessary - in the unmask method.\n        // In normal use cases an element will be masked for a limited period of time.\n        // Fix for https://sencha.jira.com/browse/EXTJSIV-19.\n        // IE6 strict mode and IE6-9 quirks mode takes off left+right padding when calculating width!\n        if (!Ext.supports.IncludePaddingInWidthCalculation && setExpression) {\n            // In an occasional case setExpression will throw an exception\n            try {\n                maskEl.dom.style.setExpression('width', 'this.parentNode.clientWidth + \"px\"');\n            } catch (e) {}\n        }\n\n        // Some versions and modes of IE subtract top+bottom padding when calculating height.\n        // Different versions from those which make the same error for width!\n        if (!Ext.supports.IncludePaddingInHeightCalculation && setExpression) {\n            // In an occasional case setExpression will throw an exception\n            try {\n                maskEl.dom.style.setExpression('height', 'this.parentNode.' + (dom == DOC.body ? 'scrollHeight' : 'offsetHeight') + ' + \"px\"');\n            } catch (e) {}\n        }\n        // ie will not expand full height automatically\n        else if (Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto') {\n            maskEl.setSize(undefined, elHeight || me.getHeight());\n        }\n        return maskEl;\n    },\n\n    /**\n     * Hides a previously applied mask.\n     */\n    unmask : function() {\n        var me      = this,\n            data    = (me.$cache || me.getCache()).data,\n            maskEl  = data.maskEl,\n            maskMsg = data.maskMsg,\n            style;\n\n        if (maskEl) {\n            style = maskEl.dom.style;\n            // Remove resource-intensive CSS expressions as soon as they are not required.\n            if (style.clearExpression) {\n                style.clearExpression('width');\n                style.clearExpression('height');\n            }\n            \n            if (maskEl) {\n                maskEl.remove();\n                delete data.maskEl;\n            }\n            \n            if (maskMsg) {\n                maskMsg.remove();\n                delete data.maskMsg;\n            }\n            \n            me.removeCls([XMASKED, XMASKEDRELATIVE]);\n        }\n    },\n\n    /**\n     * Returns true if this element is masked. Also re-centers any displayed message within the mask.\n     * @return {Boolean}\n     */\n    isMasked : function() {\n        var me      = this,\n            data    = (me.$cache || me.getCache()).data,\n            maskEl  = data.maskEl,\n            maskMsg = data.maskMsg,\n            hasMask = false; \n\n        if (maskEl && maskEl.isVisible()) {\n            if (maskMsg) {\n                maskMsg.center(me);\n            }\n            hasMask = true;\n        }\n        return hasMask;\n    },\n\n    /**\n     * Creates an iframe shim for this element to keep selects and other windowed objects from\n     * showing through.\n     * @return {Ext.dom.Element} The new shim element\n     */\n    createShim : function() {\n        var el = DOC.createElement('iframe'),\n            shim;\n\n        el.frameBorder = '0';\n        el.className = Ext.baseCSSPrefix + 'shim';\n        el.src = Ext.SSL_SECURE_URL;\n        shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));\n        shim.autoBoxAdjust = false;\n        return shim;\n    },\n\n    /**\n     * Convenience method for constructing a KeyMap\n     * @param {String/Number/Number[]/Object} key Either a string with the keys to listen for, the numeric key code,\n     * array of key codes or an object with the following options:\n     * @param {Number/Array} key.key\n     * @param {Boolean} key.shift\n     * @param {Boolean} key.ctrl\n     * @param {Boolean} key.alt\n     * @param {Function} fn The function to call\n     * @param {Object} [scope] The scope (`this` reference) in which the specified function is executed. Defaults to this Element.\n     * @return {Ext.util.KeyMap} The KeyMap created\n     */\n    addKeyListener : function(key, fn, scope){\n        var config;\n        if(typeof key != 'object' || Ext.isArray(key)){\n            config = {\n                target: this,\n                key: key,\n                fn: fn,\n                scope: scope\n            };\n        }else{\n            config = {\n                target: this,\n                key : key.key,\n                shift : key.shift,\n                ctrl : key.ctrl,\n                alt : key.alt,\n                fn: fn,\n                scope: scope\n            };\n        }\n        return new Ext.util.KeyMap(config);\n    },\n\n    /**\n     * Creates a KeyMap for this element\n     * @param {Object} config The KeyMap config. See {@link Ext.util.KeyMap} for more details\n     * @return {Ext.util.KeyMap} The KeyMap created\n     */\n    addKeyMap : function(config) {\n        return new Ext.util.KeyMap(Ext.apply({\n            target: this\n        }, config));\n    },\n\n    //  Mouse events\n    /**\n     * @event click\n     * Fires when a mouse click is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event contextmenu\n     * Fires when a right click is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event dblclick\n     * Fires when a mouse double click is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event mousedown\n     * Fires when a mousedown is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event mouseup\n     * Fires when a mouseup is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event mouseover\n     * Fires when a mouseover is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event mousemove\n     * Fires when a mousemove is detected with the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event mouseout\n     * Fires when a mouseout is detected with the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event mouseenter\n     * Fires when the mouse enters the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event mouseleave\n     * Fires when the mouse leaves the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n\n    //  Keyboard events\n    /**\n     * @event keypress\n     * Fires when a keypress is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event keydown\n     * Fires when a keydown is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event keyup\n     * Fires when a keyup is detected within the element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n\n    //  HTML frame/object events\n    /**\n     * @event load\n     * Fires when the user agent finishes loading all content within the element. Only supported by window, frames,\n     * objects and images.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event unload\n     * Fires when the user agent removes all content from a window or frame. For elements, it fires when the target\n     * element or any of its content has been removed.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event abort\n     * Fires when an object/image is stopped from loading before completely loaded.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event error\n     * Fires when an object/image/frame cannot be loaded properly.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event resize\n     * Fires when a document view is resized.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event scroll\n     * Fires when a document view is scrolled.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n\n    //  Form events\n    /**\n     * @event select\n     * Fires when a user selects some text in a text field, including input and textarea.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event change\n     * Fires when a control loses the input focus and its value has been modified since gaining focus.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event submit\n     * Fires when a form is submitted.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event reset\n     * Fires when a form is reset.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event focus\n     * Fires when an element receives focus either via the pointing device or by tab navigation.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event blur\n     * Fires when an element loses focus either via the pointing device or by tabbing navigation.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n\n    //  User Interface events\n    /**\n     * @event DOMFocusIn\n     * Where supported. Similar to HTML focus event, but can be applied to any focusable element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event DOMFocusOut\n     * Where supported. Similar to HTML blur event, but can be applied to any focusable element.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event DOMActivate\n     * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n\n    //  DOM Mutation events\n    /**\n     * @event DOMSubtreeModified\n     * Where supported. Fires when the subtree is modified.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event DOMNodeInserted\n     * Where supported. Fires when a node has been added as a child of another node.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event DOMNodeRemoved\n     * Where supported. Fires when a descendant node of the element is removed.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event DOMNodeRemovedFromDocument\n     * Where supported. Fires when a node is being removed from a document.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event DOMNodeInsertedIntoDocument\n     * Where supported. Fires when a node is being inserted into a document.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event DOMAttrModified\n     * Where supported. Fires when an attribute has been modified.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n    /**\n     * @event DOMCharacterDataModified\n     * Where supported. Fires when the character data has been modified.\n     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\n     * @param {HTMLElement} t The target of the event.\n     */\n\n    /**\n     * Appends an event handler to this element.\n     *\n     * @param {String} eventName The name of event to handle.\n     *\n     * @param {Function} fn The handler function the event invokes. This function is passed the following parameters:\n     *\n     * - **evt** : EventObject\n     *\n     *   The {@link Ext.EventObject EventObject} describing the event.\n     *\n     * - **el** : HtmlElement\n     *\n     *   The DOM element which was the target of the event. Note that this may be filtered by using the delegate option.\n     *\n     * - **o** : Object\n     *\n     *   The options object from the call that setup the listener.\n     *\n     * @param {Object} scope (optional) The scope (**this** reference) in which the handler function is executed. **If\n     * omitted, defaults to this Element.**\n     *\n     * @param {Object} options (optional) An object containing handler configuration properties. This may contain any of\n     * the following properties:\n     *\n     * - **scope** Object :\n     *\n     *   The scope (**this** reference) in which the handler function is executed. **If omitted, defaults to this\n     *   Element.**\n     *\n     * - **delegate** String:\n     *\n     *   A simple selector to filter the target or look for a descendant of the target. See below for additional details.\n     *\n     * - **stopEvent** Boolean:\n     *\n     *   True to stop the event. That is stop propagation, and prevent the default action.\n     *\n     * - **preventDefault** Boolean:\n     *\n     *   True to prevent the default action\n     *\n     * - **stopPropagation** Boolean:\n     *\n     *   True to prevent event propagation\n     *\n     * - **normalized** Boolean:\n     *\n     *   False to pass a browser event to the handler function instead of an Ext.EventObject\n     *\n     * - **target** Ext.dom.Element:\n     *\n     *   Only call the handler if the event was fired on the target Element, _not_ if the event was bubbled up from a\n     *   child node.\n     *\n     * - **delay** Number:\n     *\n     *   The number of milliseconds to delay the invocation of the handler after the event fires.\n     *\n     * - **single** Boolean:\n     *\n     *   True to add a handler to handle just the next firing of the event, and then remove itself.\n     *\n     * - **buffer** Number:\n     *\n     *   Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed by the specified number of\n     *   milliseconds. If the event fires again within that time, the original handler is _not_ invoked, but the new\n     *   handler is scheduled in its place.\n     *\n     * **Combining Options**\n     *\n     * Using the options argument, it is possible to combine different types of listeners:\n     *\n     * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the options\n     * object. The options object is available as the third parameter in the handler function.\n     *\n     * Code:\n     *\n     *     el.on('click', this.onClick, this, {\n     *         single: true,\n     *         delay: 100,\n     *         stopEvent : true,\n     *         forumId: 4\n     *     });\n     *\n     * **Attaching multiple handlers in 1 call**\n     *\n     * The method also allows for a single argument to be passed which is a config object containing properties which\n     * specify multiple handlers.\n     *\n     * Code:\n     *\n     *     el.on({\n     *         'click' : {\n     *             fn: this.onClick,\n     *             scope: this,\n     *             delay: 100\n     *         },\n     *         'mouseover' : {\n     *             fn: this.onMouseOver,\n     *             scope: this\n     *         },\n     *         'mouseout' : {\n     *             fn: this.onMouseOut,\n     *             scope: this\n     *         }\n     *     });\n     *\n     * Or a shorthand syntax:\n     *\n     * Code:\n     *\n     *     el.on({\n     *         'click' : this.onClick,\n     *         'mouseover' : this.onMouseOver,\n     *         'mouseout' : this.onMouseOut,\n     *         scope: this\n     *     });\n     *\n     * **delegate**\n     *\n     * This is a configuration option that you can pass along when registering a handler for an event to assist with\n     * event delegation. Event delegation is a technique that is used to reduce memory consumption and prevent exposure\n     * to memory-leaks. By registering an event for a container element as opposed to each element within a container.\n     * By setting this configuration option to a simple selector, the target element will be filtered to look for a\n     * descendant of the target. For example:\n     *\n     *     // using this markup:\n     *     <div id='elId'>\n     *         <p id='p1'>paragraph one</p>\n     *         <p id='p2' class='clickable'>paragraph two</p>\n     *         <p id='p3'>paragraph three</p>\n     *     </div>\n     *\n     *     // utilize event delegation to registering just one handler on the container element:\n     *     el = Ext.get('elId');\n     *     el.on(\n     *         'click',\n     *         function(e,t) {\n     *             // handle click\n     *             console.info(t.id); // 'p2'\n     *         },\n     *         this,\n     *         {\n     *             // filter the target element to be a descendant with the class 'clickable'\n     *             delegate: '.clickable'\n     *         }\n     *     );\n     *\n     * @return {Ext.dom.Element} this\n     */\n    on: function(eventName, fn, scope, options) {\n        Ext.EventManager.on(this, eventName, fn, scope || this, options);\n        return this;\n    },\n\n    /**\n     * Removes an event handler from this element.\n     *\n     * **Note**: if a *scope* was explicitly specified when {@link #on adding} the listener,\n     * the same scope must be specified here.\n     *\n     * Example:\n     *\n     *     el.un('click', this.handlerFn);\n     *     // or\n     *     el.removeListener('click', this.handlerFn);\n     *\n     * @param {String} eventName The name of the event from which to remove the handler.\n     * @param {Function} fn The handler function to remove. **This must be a reference to the function passed into the\n     * {@link #on} call.**\n     * @param {Object} scope If a scope (**this** reference) was specified when the listener was added, then this must\n     * refer to the same object.\n     * @return {Ext.dom.Element} this\n     */\n    un: function(eventName, fn, scope) {\n        Ext.EventManager.un(this, eventName, fn, scope || this);\n        return this;\n    },\n\n    /**\n     * Removes all previous added listeners from this element\n     * @return {Ext.dom.Element} this\n     */\n    removeAllListeners: function() {\n        Ext.EventManager.removeAll(this);\n        return this;\n    },\n\n    /**\n     * Recursively removes all previous added listeners from this element and its children\n     * @return {Ext.dom.Element} this\n     */\n    purgeAllListeners: function() {\n        Ext.EventManager.purgeElement(this);\n        return this;\n    }\n\n}, function() {\n\n    var EC              = Ext.cache,\n        El              = this,\n        AbstractElement = Ext.dom.AbstractElement,\n        focusRe         = /a|button|embed|iframe|img|input|object|select|textarea/i,\n        nonSpaceRe      = /\\S/,\n        scriptTagRe     = /(?:<script([^>]*)?>)((\\n|\\r|.)*?)(?:<\\/script>)/ig,\n        replaceScriptTagRe = /(?:<script.*?>)((\\n|\\r|.)*?)(?:<\\/script>)/ig,\n        srcRe           = /\\ssrc=([\\'\\\"])(.*?)\\1/i,\n        typeRe          = /\\stype=([\\'\\\"])(.*?)\\1/i,\n        useDocForId = !(Ext.isIE6 || Ext.isIE7 || Ext.isIE8);\n\n    El.boxMarkup = '<div class=\"{0}-tl\"><div class=\"{0}-tr\"><div class=\"{0}-tc\"></div></div></div><div class=\"{0}-ml\"><div class=\"{0}-mr\"><div class=\"{0}-mc\"></div></div></div><div class=\"{0}-bl\"><div class=\"{0}-br\"><div class=\"{0}-bc\"></div></div></div>';\n    //</!if>\n\n    // private\n    // Garbage collection - uncache elements/purge listeners on orphaned elements\n    // so we don't hold a reference and cause the browser to retain them\n    function garbageCollect() {\n        if (!Ext.enableGarbageCollector) {\n            clearInterval(El.collectorThreadId);\n        } else {\n            var eid,\n                d,\n                o,\n                t;\n\n            for (eid in EC) {\n                if (!EC.hasOwnProperty(eid)) {\n                    continue;\n                }\n\n                o = EC[eid];\n\n                // Skip document and window elements\n                if (o.skipGarbageCollection) {\n                    continue;\n                }\n\n                d = o.dom;\n\n                // Should always have a DOM node\n                if (!d) {\n                    Ext.Error.raise('Missing DOM node in element garbage collection: ' + eid);\n                }\n\n                // Check that document and window elements haven't got through\n                if (d && (d.getElementById || d.navigator)) {\n                    Ext.Error.raise('Unexpected document or window element in element garbage collection');\n                }\n\n                // -------------------------------------------------------\n                // Determining what is garbage:\n                // -------------------------------------------------------\n                // !d.parentNode\n                // no parentNode == direct orphan, definitely garbage\n                // -------------------------------------------------------\n                // !d.offsetParent && !document.getElementById(eid)\n                // display none elements have no offsetParent so we will\n                // also try to look it up by it's id. However, check\n                // offsetParent first so we don't do unneeded lookups.\n                // This enables collection of elements that are not orphans\n                // directly, but somewhere up the line they have an orphan\n                // parent.\n                // -------------------------------------------------------\n                if (!d.parentNode || (!d.offsetParent && !Ext.getElementById(eid))) {\n                    if (d && Ext.enableListenerCollection) {\n                        Ext.EventManager.removeAll(d);\n                    }\n                    delete EC[eid];\n                }\n            }\n            // Cleanup IE Object leaks\n            if (Ext.isIE) {\n                t = {};\n                for (eid in EC) {\n                    if (!EC.hasOwnProperty(eid)) {\n                        continue;\n                    }\n                    t[eid] = EC[eid];\n                }\n                EC = Ext.cache = t;\n            }\n        }\n    }\n\n    El.collectorThreadId = setInterval(garbageCollect, 30000);\n\n    //Stuff from Element-more.js\n    El.addMethods({\n\n        /**\n         * Monitors this Element for the mouse leaving. Calls the function after the specified delay only if\n         * the mouse was not moved back into the Element within the delay. If the mouse *was* moved\n         * back in, the function is not called.\n         * @param {Number} delay The delay **in milliseconds** to wait for possible mouse re-entry before calling the handler function.\n         * @param {Function} handler The function to call if the mouse remains outside of this Element for the specified time.\n         * @param {Object} [scope] The scope (`this` reference) in which the handler function executes. Defaults to this Element.\n         * @return {Object} The listeners object which was added to this element so that monitoring can be stopped. Example usage:\n         *\n         *     // Hide the menu if the mouse moves out for 250ms or more\n         *     this.mouseLeaveMonitor = this.menuEl.monitorMouseLeave(250, this.hideMenu, this);\n         *\n         *     ...\n         *     // Remove mouseleave monitor on menu destroy\n         *     this.menuEl.un(this.mouseLeaveMonitor);\n         *\n         */\n        monitorMouseLeave: function(delay, handler, scope) {\n            var me = this,\n                timer,\n                listeners = {\n                    mouseleave: function(e) {\n                        timer = setTimeout(Ext.Function.bind(handler, scope||me, [e]), delay);\n                    },\n                    mouseenter: function() {\n                        clearTimeout(timer);\n                    },\n                    freezeEvent: true\n                };\n\n            me.on(listeners);\n            return listeners;\n        },\n\n        /**\n         * Stops the specified event(s) from bubbling and optionally prevents the default action\n         * @param {String/String[]} eventName an event / array of events to stop from bubbling\n         * @param {Boolean} [preventDefault] true to prevent the default action too\n         * @return {Ext.dom.Element} this\n         */\n        swallowEvent : function(eventName, preventDefault) {\n            var me = this,\n                e, eLen;\n            function fn(e) {\n                e.stopPropagation();\n                if (preventDefault) {\n                    e.preventDefault();\n                }\n            }\n\n            if (Ext.isArray(eventName)) {\n                eLen = eventName.length;\n\n                for (e = 0; e < eLen; e++) {\n                    me.on(eventName[e], fn);\n                }\n\n                return me;\n            }\n            me.on(eventName, fn);\n            return me;\n        },\n\n        /**\n         * Create an event handler on this element such that when the event fires and is handled by this element,\n         * it will be relayed to another object (i.e., fired again as if it originated from that object instead).\n         * @param {String} eventName The type of event to relay\n         * @param {Object} observable Any object that extends {@link Ext.util.Observable} that will provide the context\n         * for firing the relayed event\n         */\n        relayEvent : function(eventName, observable) {\n            this.on(eventName, function(e) {\n                observable.fireEvent(eventName, e);\n            });\n        },\n\n        /**\n         * Removes Empty, or whitespace filled text nodes. Combines adjacent text nodes.\n         * @param {Boolean} [forceReclean=false] By default the element keeps track if it has been cleaned already\n         * so you can call this over and over. However, if you update the element and need to force a reclean, you\n         * can pass true.\n         */\n        clean : function(forceReclean) {\n            var me   = this,\n                dom  = me.dom,\n                data = (me.$cache || me.getCache()).data,\n                n    = dom.firstChild,\n                ni   = -1,\n                nx;\n\n            if (data.isCleaned && forceReclean !== true) {\n                return me;\n            }\n\n            while (n) {\n                nx = n.nextSibling;\n                if (n.nodeType == 3) {\n                    // Remove empty/whitespace text nodes\n                    if (!(nonSpaceRe.test(n.nodeValue))) {\n                        dom.removeChild(n);\n                    // Combine adjacent text nodes\n                    } else if (nx && nx.nodeType == 3) {\n                        n.appendData(Ext.String.trim(nx.data));\n                        dom.removeChild(nx);\n                        nx = n.nextSibling;\n                        n.nodeIndex = ++ni;\n                    }\n                } else {\n                    // Recursively clean\n                    Ext.fly(n).clean();\n                    n.nodeIndex = ++ni;\n                }\n                n = nx;\n            }\n\n            data.isCleaned = true;\n            return me;\n        },\n\n        /**\n         * Direct access to the Ext.ElementLoader {@link Ext.ElementLoader#method-load} method. The method takes the same object\n         * parameter as {@link Ext.ElementLoader#method-load}\n         * @return {Ext.dom.Element} this\n         */\n        load : function(options) {\n            this.getLoader().load(options);\n            return this;\n        },\n\n        /**\n         * Gets this element's {@link Ext.ElementLoader ElementLoader}\n         * @return {Ext.ElementLoader} The loader\n         */\n        getLoader : function() {\n            var me = this,\n                data = (me.$cache || me.getCache()).data,\n                loader = data.loader;\n\n            if (!loader) {\n                data.loader = loader = new Ext.ElementLoader({\n                    target: me\n                });\n            }\n            return loader;\n        },\n\n        /**\n         * @private.\n         * Currently used for updating grid cells without modifying DOM structure\n         *\n         * Synchronizes content of this Element with the content of the passed element.\n         * \n         * Style and CSS class are copied from source into this Element, and contents are synched\n         * recursively. If a child node is a text node, the textual data is copied.\n         */\n        syncContent: function(source) {\n            source = Ext.getDom(source);\n            var me = this,\n                sourceNodes = source.childNodes,\n                sourceLen = sourceNodes.length,\n                dest = me.dom,\n                destNodes = dest.childNodes,\n                destLen = destNodes.length,\n                i,  destNode, sourceNode,\n                nodeType;\n\n            // Copy top node's style and CSS class\n            dest.style.cssText = source.style.cssText;\n            dest.className = source.className;\n\n            // If the number of child nodes does not match, fall back to replacing innerHTML\n            if (sourceLen !== destLen) {\n                source.innerHTML = dest.innerHTML;\n                return;\n            }\n\n            // Loop through source nodes.\n            // If there are fewer, we must remove excess\n            for (i = 0; i < sourceLen; i++) {\n                sourceNode = sourceNodes[i];\n                destNode = destNodes[i];\n                nodeType = sourceNode.nodeType;\n\n                // If node structure is out of sync, just drop innerHTML in and return\n                if (nodeType !== destNode.nodeType || (nodeType === 1 && sourceNode.tagName !== destNode.tagName)) {\n                    dest.innerHTML = source.innerHTML;\n                    return;\n                }\n\n                // Update text node\n                if (nodeType === 3) {\n                    destNode.data = sourceNode.data;\n                }\n                // Sync element content\n                else {\n                    if (sourceNode.id && destNode.id !== sourceNode.id) {\n                        destNode.id = sourceNode.id;\n                    }\n                    destNode.style.cssText = sourceNode.style.cssText;\n                    destNode.className = sourceNode.className;\n                    Ext.fly(destNode).syncContent(sourceNode);\n                }\n            }\n        },\n\n        /**\n         * Updates the innerHTML of this element, optionally searching for and processing scripts.\n         * @param {String} html The new HTML\n         * @param {Boolean} [loadScripts] True to look for and process scripts (defaults to false)\n         * @param {Function} [callback] For async script loading you can be notified when the update completes\n         * @return {Ext.dom.Element} this\n         */\n        update : function(html, loadScripts, callback) {\n            var me = this,\n                id,\n                dom,\n                interval;\n\n            if (!me.dom) {\n                return me;\n            }\n            html = html || '';\n            dom = me.dom;\n\n            if (loadScripts !== true) {\n                dom.innerHTML = html;\n                Ext.callback(callback, me);\n                return me;\n            }\n\n            id  = Ext.id();\n            html += '<span id=\"' + id + '\"></span>';\n\n            interval = setInterval(function() {\n                var hd,\n                    match,\n                    attrs,\n                    srcMatch,\n                    typeMatch,\n                    el,\n                    s;\n                if (!(el = DOC.getElementById(id))) {\n                    return false;\n                }\n                clearInterval(interval);\n                Ext.removeNode(el);\n                hd = Ext.getHead().dom;\n\n                while ((match = scriptTagRe.exec(html))) {\n                    attrs = match[1];\n                    srcMatch = attrs ? attrs.match(srcRe) : false;\n                    if (srcMatch && srcMatch[2]) {\n                       s = DOC.createElement(\"script\");\n                       s.src = srcMatch[2];\n                       typeMatch = attrs.match(typeRe);\n                       if (typeMatch && typeMatch[2]) {\n                           s.type = typeMatch[2];\n                       }\n                       hd.appendChild(s);\n                    } else if (match[2] && match[2].length > 0) {\n                        if (window.execScript) {\n                           window.execScript(match[2]);\n                        } else {\n                           window.eval(match[2]);\n                        }\n                    }\n                }\n                Ext.callback(callback, me);\n            }, 20);\n            dom.innerHTML = html.replace(replaceScriptTagRe, '');\n            return me;\n        },\n\n        // inherit docs, overridden so we can add removeAnchor\n        removeAllListeners : function() {\n            this.removeAnchor();\n            Ext.EventManager.removeAll(this.dom);\n            return this;\n        },\n\n        /**\n         * Creates a proxy element of this element\n         * @param {String/Object} config The class name of the proxy element or a DomHelper config object\n         * @param {String/HTMLElement} [renderTo] The element or element id to render the proxy to. Defaults to: document.body.\n         * @param {Boolean} [matchBox=false] True to align and size the proxy to this element now.\n         * @return {Ext.dom.Element} The new proxy element\n         */\n        createProxy : function(config, renderTo, matchBox) {\n            config = (typeof config == 'object') ? config : {tag : \"div\", cls: config};\n\n            var me = this,\n                proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :\n                                   Ext.DomHelper.insertBefore(me.dom, config, true);\n\n            proxy.setVisibilityMode(Element.DISPLAY);\n            proxy.hide();\n            if (matchBox && me.setBox && me.getBox) { // check to make sure Element.position.js is loaded\n               proxy.setBox(me.getBox());\n            }\n            return proxy;\n        },\n        \n        /**\n         * Gets the parent node of the current element taking into account Ext.scopeResetCSS\n         * @protected\n         * @return {HTMLElement} The parent element\n         */\n        getScopeParent: function() {\n            var parent = this.dom.parentNode;\n            if (Ext.scopeResetCSS) {\n                // If it's a normal reset, we will be wrapped in a single x-reset element, so grab the parent\n                parent = parent.parentNode;\n                if (!Ext.supports.CSS3LinearGradient || !Ext.supports.CSS3BorderRadius) {\n                    // In the cases where we have nbr or nlg, it will be wrapped in a second element,\n                    // so we need to go and get the parent again.\n                    parent = parent.parentNode;\n                }\n            }\n            return parent;\n        },\n\n        /**\n         * Returns true if this element needs an explicit tabIndex to make it focusable. Input fields, text areas, buttons\n         * anchors elements **with an href** etc do not need a tabIndex, but structural elements do.\n         */\n        needsTabIndex: function() {\n            if (this.dom) {\n                if ((this.dom.nodeName === 'a') && (!this.dom.href)) {\n                    return true;\n                }\n                return !focusRe.test(this.dom.nodeName);\n            }\n        },\n\n        /**\n         * Checks whether this element can be focused.\n         * @return {Boolean} True if the element is focusable\n         */\n        focusable: function () {\n            var dom = this.dom,\n                nodeName = dom.nodeName,\n                canFocus = false;\n\n            if (!dom.disabled) {\n                if (focusRe.test(nodeName)) {\n                    if ((nodeName !== 'a') || dom.href) {\n                        canFocus = true;\n                    }\n                } else {\n                    canFocus = !isNaN(dom.tabIndex);\n                }\n            }\n            return canFocus && this.isVisible(true);\n        }\n    });\n\n    if (Ext.isIE) {\n        El.prototype.getById = function (id, asDom) {\n            var dom = this.dom,\n                cacheItem, el, ret;\n\n            if (dom) {\n                // for normal elements getElementById is the best solution, but if the el is\n                // not part of the document.body, we need to use all[]\n                el = (useDocForId && DOC.getElementById(id)) || dom.all[id];\n                if (el) {\n                    if (asDom) {\n                        ret = el;\n                    } else {\n                        // calling El.get here is a real hit (2x slower) because it has to\n                        // redetermine that we are giving it a dom el.\n                        cacheItem = EC[id];\n                        if (cacheItem && cacheItem.el) {\n                            ret = Ext.updateCacheEntry(cacheItem, el).el;\n                        } else {\n                            ret = new Element(el);\n                        }\n                    }\n                    return ret;\n                }\n            }\n\n            return asDom ? Ext.getDom(id) : El.get(id);\n        };\n    }\n\n    El.createAlias({\n        /**\n         * @method\n         * @inheritdoc Ext.dom.Element#on\n         * Shorthand for {@link #on}.\n         */\n        addListener: 'on',\n        /**\n         * @method\n         * @inheritdoc Ext.dom.Element#un\n         * Shorthand for {@link #un}.\n         */\n        removeListener: 'un',\n        /**\n         * @method\n         * @inheritdoc Ext.dom.Element#removeAllListeners\n         * Alias for {@link #removeAllListeners}.\n         */\n        clearListeners: 'removeAllListeners'\n    });\n\n    El.Fly = AbstractElement.Fly = new Ext.Class({\n        extend: El,\n\n        constructor: function(dom) {\n            this.dom = dom;\n        },\n        \n        attach: AbstractElement.Fly.prototype.attach\n    });\n\n    if (Ext.isIE) {\n        Ext.getElementById = function (id) {\n            var el = DOC.getElementById(id),\n                detachedBodyEl;\n\n            if (!el && (detachedBodyEl = AbstractElement.detachedBodyEl)) {\n                el = detachedBodyEl.dom.all[id];\n            }\n\n            return el;\n        };\n    } else if (!DOC.querySelector) {\n        Ext.getDetachedBody = Ext.getBody;\n\n        Ext.getElementById = function (id) {\n            return DOC.getElementById(id);\n        };\n    }\n});\n\n}());\n\n//@tag dom,core\n//@require Element.js\n//@define Ext.dom.Element-alignment\n//@define Ext.dom.Element\n\n/**\n * @class Ext.dom.Element\n */\nExt.dom.Element.override((function() {\n\n    var doc = document,\n        win = window,\n        alignRe = /^([a-z]+)-([a-z]+)(\\?)?$/,\n        round = Math.round;\n\n    return {\n\n        /**\n         * Gets the x,y coordinates specified by the anchor position on the element.\n         * @param {String} [anchor='c'] The specified anchor position.  See {@link #alignTo}\n         * for details on supported anchor positions.\n         * @param {Boolean} [local] True to get the local (element top/left-relative) anchor position instead\n         * of page coordinates\n         * @param {Object} [size] An object containing the size to use for calculating anchor position\n         * {width: (target width), height: (target height)} (defaults to the element's current size)\n         * @return {Number[]} [x, y] An array containing the element's x and y coordinates\n         */\n        getAnchorXY: function(anchor, local, mySize) {\n            //Passing a different size is useful for pre-calculating anchors,\n            //especially for anchored animations that change the el size.\n            anchor = (anchor || \"tl\").toLowerCase();\n            mySize = mySize || {};\n\n            var me = this,\n                isViewport = me.dom == doc.body || me.dom == doc,\n                myWidth = mySize.width || isViewport ? Ext.dom.Element.getViewWidth() : me.getWidth(),\n                myHeight = mySize.height || isViewport ? Ext.dom.Element.getViewHeight() : me.getHeight(),\n                xy,\n                myPos = me.getXY(),\n                scroll = me.getScroll(),\n                extraX = isViewport ? scroll.left : !local ? myPos[0] : 0,\n                extraY = isViewport ? scroll.top : !local ? myPos[1] : 0;\n\n            // Calculate anchor position.\n            // Test most common cases for picker alignment first.\n            switch (anchor) {\n                case 'tl' : xy = [ 0,                    0];\n                            break;\n                case 'bl' : xy = [ 0,                    myHeight];\n                            break;\n                case 'tr' : xy = [ myWidth,              0];\n                            break;\n                case 'c'  : xy = [ round(myWidth * 0.5), round(myHeight * 0.5)];\n                            break;\n                case 't'  : xy = [ round(myWidth * 0.5), 0];\n                            break;\n                case 'l'  : xy = [ 0,                    round(myHeight * 0.5)];\n                            break;\n                case 'r'  : xy = [ myWidth,              round(myHeight * 0.5)];\n                            break;\n                case 'b'  : xy = [ round(myWidth * 0.5), myHeight];\n                            break;\n                case 'br' : xy = [ myWidth,              myHeight];\n            }\n            return [xy[0] + extraX, xy[1] + extraY];\n        },\n\n        /**\n         * Gets the x,y coordinates to align this element with another element. See {@link #alignTo} for more info on the\n         * supported position values.\n         * @param {String/HTMLElement/Ext.Element} element The element to align to.\n         * @param {String} [position=\"tl-bl?\"] The position to align to (defaults to )\n         * @param {Number[]} [offsets] Offset the positioning by [x, y]\n         * @return {Number[]} [x, y]\n         */\n        getAlignToXY : function(alignToEl, posSpec, offset) {\n            alignToEl = Ext.get(alignToEl);\n\n            if (!alignToEl || !alignToEl.dom) {\n                Ext.Error.raise({\n                    sourceClass: 'Ext.dom.Element',\n                    sourceMethod: 'getAlignToXY',\n                    msg: 'Attempted to align an element that doesn\\'t exist'\n                });\n            }\n\n            offset = offset || [0,0];\n            posSpec = (!posSpec || posSpec == \"?\" ? \"tl-bl?\" : (!(/-/).test(posSpec) && posSpec !== \"\" ? \"tl-\" + posSpec : posSpec || \"tl-bl\")).toLowerCase();\n\n            var me = this,\n                    myPosition,\n                    alignToElPosition,\n                    x,\n                    y,\n                    myWidth,\n                    myHeight,\n                    alignToElRegion,\n                    viewportWidth = Ext.dom.Element.getViewWidth() - 10, // 10px of margin for ie\n                    viewportHeight = Ext.dom.Element.getViewHeight() - 10, // 10px of margin for ie\n                    p1y,\n                    p1x,\n                    p2y,\n                    p2x,\n                    swapY,\n                    swapX,\n                    docElement = doc.documentElement,\n                    docBody = doc.body,\n                    scrollX = (docElement.scrollLeft || docBody.scrollLeft || 0),// + 5, WHY was 5 ever added?\n                    scrollY = (docElement.scrollTop  || docBody.scrollTop  || 0),// + 5, It means align will fail if the alignTo el was at less than 5,5\n                    constrain, //constrain to viewport\n                    align1,\n                    align2,\n                    alignMatch = posSpec.match(alignRe);\n\n            if (!alignMatch) {\n                Ext.Error.raise({\n                    sourceClass: 'Ext.dom.Element',\n                    sourceMethod: 'getAlignToXY',\n                    el: alignToEl,\n                    position: posSpec,\n                    offset: offset,\n                    msg: 'Attemmpted to align an element with an invalid position: \"' + posSpec + '\"'\n                });\n            }\n\n            align1 = alignMatch[1];\n            align2 = alignMatch[2];\n            constrain = !!alignMatch[3];\n\n            //Subtract the aligned el's internal xy from the target's offset xy\n            //plus custom offset to get this Element's new offset xy\n            myPosition = me.getAnchorXY(align1, true);\n            alignToElPosition = alignToEl.getAnchorXY(align2, false);\n\n            x = alignToElPosition[0] - myPosition[0] + offset[0];\n            y = alignToElPosition[1] - myPosition[1] + offset[1];\n\n            // If position spec ended with a \"?\", then constrain to viewport is necessary\n            if (constrain) {\n                myWidth = me.getWidth();\n                myHeight = me.getHeight();\n                alignToElRegion = alignToEl.getRegion();\n                //If we are at a viewport boundary and the aligned el is anchored on a target border that is\n                //perpendicular to the vp border, allow the aligned el to slide on that border,\n                //otherwise swap the aligned el to the opposite border of the target.\n                p1y = align1.charAt(0);\n                p1x = align1.charAt(align1.length - 1);\n                p2y = align2.charAt(0);\n                p2x = align2.charAt(align2.length - 1);\n                swapY = ((p1y == \"t\" && p2y == \"b\") || (p1y == \"b\" && p2y == \"t\"));\n                swapX = ((p1x == \"r\" && p2x == \"l\") || (p1x == \"l\" && p2x == \"r\"));\n\n                if (x + myWidth > viewportWidth + scrollX) {\n                    x = swapX ? alignToElRegion.left - myWidth : viewportWidth + scrollX - myWidth;\n                }\n                if (x < scrollX) {\n                    x = swapX ? alignToElRegion.right : scrollX;\n                }\n                if (y + myHeight > viewportHeight + scrollY) {\n                    y = swapY ? alignToElRegion.top - myHeight : viewportHeight + scrollY - myHeight;\n                }\n                if (y < scrollY) {\n                    y = swapY ? alignToElRegion.bottom : scrollY;\n                }\n            }\n            return [x,y];\n        },\n\n\n        /**\n         * Anchors an element to another element and realigns it when the window is resized.\n         * @param {String/HTMLElement/Ext.Element} element The element to align to.\n         * @param {String} position The position to align to.\n         * @param {Number[]} [offsets] Offset the positioning by [x, y]\n         * @param {Boolean/Object} [animate] True for the default animation or a standard Element animation config object\n         * @param {Boolean/Number} [monitorScroll] True to monitor body scroll and reposition. If this parameter\n         * is a number, it is used as the buffer delay (defaults to 50ms).\n         * @param {Function} [callback] The function to call after the animation finishes\n         * @return {Ext.Element} this\n         */\n        anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback) {\n            var me = this,\n                dom = me.dom,\n                scroll = !Ext.isEmpty(monitorScroll),\n                action = function() {\n                    Ext.fly(dom).alignTo(el, alignment, offsets, animate);\n                    Ext.callback(callback, Ext.fly(dom));\n                },\n                anchor = this.getAnchor();\n\n            // previous listener anchor, remove it\n            this.removeAnchor();\n            Ext.apply(anchor, {\n                fn: action,\n                scroll: scroll\n            });\n\n            Ext.EventManager.onWindowResize(action, null);\n\n            if (scroll) {\n                Ext.EventManager.on(win, 'scroll', action, null,\n                        {buffer: !isNaN(monitorScroll) ? monitorScroll : 50});\n            }\n            action.call(me); // align immediately\n            return me;\n        },\n\n        /**\n         * Remove any anchor to this element. See {@link #anchorTo}.\n         * @return {Ext.dom.Element} this\n         */\n        removeAnchor : function() {\n            var me = this,\n                anchor = this.getAnchor();\n\n            if (anchor && anchor.fn) {\n                Ext.EventManager.removeResizeListener(anchor.fn);\n                if (anchor.scroll) {\n                    Ext.EventManager.un(win, 'scroll', anchor.fn);\n                }\n                delete anchor.fn;\n            }\n            return me;\n        },\n\n        getAlignVector: function(el, spec, offset) {\n            var me = this,\n                myPos = me.getXY(),\n                alignedPos = me.getAlignToXY(el, spec, offset);\n\n            el = Ext.get(el);\n            if (!el || !el.dom) {\n                Ext.Error.raise({\n                    sourceClass: 'Ext.dom.Element',\n                    sourceMethod: 'getAlignVector',\n                    msg: 'Attempted to align an element that doesn\\'t exist'\n                });\n            }\n\n            alignedPos[0] -= myPos[0];\n            alignedPos[1] -= myPos[1];\n            return alignedPos;\n        },\n\n        /**\n         * Aligns this element with another element relative to the specified anchor points. If the other element is the\n         * document it aligns it to the viewport. The position parameter is optional, and can be specified in any one of\n         * the following formats:\n         *\n         * - **Blank**: Defaults to aligning the element's top-left corner to the target's bottom-left corner (\"tl-bl\").\n         * - **One anchor (deprecated)**: The passed anchor position is used as the target element's anchor point.\n         *   The element being aligned will position its top-left corner (tl) to that point. *This method has been\n         *   deprecated in favor of the newer two anchor syntax below*.\n         * - **Two anchors**: If two values from the table below are passed separated by a dash, the first value is used as the\n         *   element's anchor point, and the second value is used as the target's anchor point.\n         *\n         * In addition to the anchor points, the position parameter also supports the \"?\" character.  If \"?\" is passed at the end of\n         * the position string, the element will attempt to align as specified, but the position will be adjusted to constrain to\n         * the viewport if necessary.  Note that the element being aligned might be swapped to align to a different position than\n         * that specified in order to enforce the viewport constraints.\n         * Following are all of the supported anchor positions:\n         *\n         * <pre>\n         * Value  Description\n         * -----  -----------------------------\n         * tl     The top left corner (default)\n         * t      The center of the top edge\n         * tr     The top right corner\n         * l      The center of the left edge\n         * c      In the center of the element\n         * r      The center of the right edge\n         * bl     The bottom left corner\n         * b      The center of the bottom edge\n         * br     The bottom right corner\n         * </pre>\n         *\n         * Example Usage:\n         *\n         *     // align el to other-el using the default positioning (\"tl-bl\", non-constrained)\n         *     el.alignTo(\"other-el\");\n         *\n         *     // align the top left corner of el with the top right corner of other-el (constrained to viewport)\n         *     el.alignTo(\"other-el\", \"tr?\");\n         *\n         *     // align the bottom right corner of el with the center left edge of other-el\n         *     el.alignTo(\"other-el\", \"br-l?\");\n         *\n         *     // align the center of el with the bottom left corner of other-el and\n         *     // adjust the x position by -6 pixels (and the y position by 0)\n         *     el.alignTo(\"other-el\", \"c-bl\", [-6, 0]);\n         *\n         * @param {String/HTMLElement/Ext.Element} element The element to align to.\n         * @param {String} [position=\"tl-bl?\"] The position to align to\n         * @param {Number[]} [offsets] Offset the positioning by [x, y]\n         * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object\n         * @return {Ext.Element} this\n         */\n        alignTo: function(element, position, offsets, animate) {\n            var me = this;\n            return me.setXY(me.getAlignToXY(element, position, offsets),\n                    me.anim && !!animate ? me.anim(animate) : false);\n        },\n\n        /**\n         * Returns the `[X, Y]` vector by which this element must be translated to make a best attempt\n         * to constrain within the passed constraint. Returns `false` is this element does not need to be moved.\n         *\n         * Priority is given to constraining the top and left within the constraint.\n         *\n         * The constraint may either be an existing element into which this element is to be constrained, or\n         * an {@link Ext.util.Region Region} into which this element is to be constrained.\n         *\n         * @param {Ext.Element/Ext.util.Region} constrainTo The Element or Region into which this element is to be constrained.\n         * @param {Number[]} proposedPosition A proposed `[X, Y]` position to test for validity and to produce a vector for instead\n         * of using this Element's current position;\n         * @returns {Number[]/Boolean} **If** this element *needs* to be translated, an `[X, Y]`\n         * vector by which this element must be translated. Otherwise, `false`.\n         */\n        getConstrainVector: function(constrainTo, proposedPosition) {\n            if (!(constrainTo instanceof Ext.util.Region)) {\n                constrainTo = Ext.get(constrainTo).getViewRegion();\n            }\n            var thisRegion = this.getRegion(),\n                    vector = [0, 0],\n                    shadowSize = (this.shadow && !this.shadowDisabled) ? this.shadow.getShadowSize() : undefined,\n                    overflowed = false;\n\n            // Shift this region to occupy the proposed position\n            if (proposedPosition) {\n                thisRegion.translateBy(proposedPosition[0] - thisRegion.x, proposedPosition[1] - thisRegion.y);\n            }\n\n            // Reduce the constrain region to allow for shadow\n            if (shadowSize) {\n                constrainTo.adjust(shadowSize[0], -shadowSize[1], -shadowSize[2], shadowSize[3]);\n            }\n\n            // Constrain the X coordinate by however much this Element overflows\n            if (thisRegion.right > constrainTo.right) {\n                overflowed = true;\n                vector[0] = (constrainTo.right - thisRegion.right);    // overflowed the right\n            }\n            if (thisRegion.left + vector[0] < constrainTo.left) {\n                overflowed = true;\n                vector[0] = (constrainTo.left - thisRegion.left);      // overflowed the left\n            }\n\n            // Constrain the Y coordinate by however much this Element overflows\n            if (thisRegion.bottom > constrainTo.bottom) {\n                overflowed = true;\n                vector[1] = (constrainTo.bottom - thisRegion.bottom);  // overflowed the bottom\n            }\n            if (thisRegion.top + vector[1] < constrainTo.top) {\n                overflowed = true;\n                vector[1] = (constrainTo.top - thisRegion.top);        // overflowed the top\n            }\n            return overflowed ? vector : false;\n        },\n\n        /**\n        * Calculates the x, y to center this element on the screen\n        * @return {Number[]} The x, y values [x, y]\n        */\n        getCenterXY : function(){\n            return this.getAlignToXY(doc, 'c-c');\n        },\n\n        /**\n        * Centers the Element in either the viewport, or another Element.\n        * @param {String/HTMLElement/Ext.Element} [centerIn] The element in which to center the element.\n        */\n        center : function(centerIn){\n            return this.alignTo(centerIn || doc, 'c-c');\n        }\n    };\n}()));\n\n//@tag dom,core\n//@require Ext.dom.Element-alignment\n//@define Ext.dom.Element-anim\n//@define Ext.dom.Element\n\n/**\n * @class Ext.dom.Element\n */\n/* ================================\n * A Note About Wrapped Animations\n * ================================\n * A few of the effects below implement two different animations per effect, one wrapping\n * animation that performs the visual effect and a \"no-op\" animation on this Element where\n * no attributes of the element itself actually change. The purpose for this is that the\n * wrapper is required for the effect to work and so it does the actual animation work, but\n * we always animate `this` so that the element's events and callbacks work as expected to\n * the callers of this API.\n * \n * Because of this, we always want each wrap animation to complete first (we don't want to\n * cut off the visual effect early). To ensure that, we arbitrarily increase the duration of\n * the element's no-op animation, also ensuring that it has a decent minimum value -- on slow\n * systems, too-low durations can cause race conditions between the wrap animation and the\n * element animation being removed out of order. Note that in each wrap's `afteranimate`\n * callback it will explicitly terminate the element animation as soon as the wrap is complete,\n * so there's no real danger in making the duration too long.\n * \n * This applies to all effects that get wrapped, including slideIn, slideOut, switchOff and frame.\n */\n\nExt.dom.Element.override({\n    /**\n     * Performs custom animation on this Element.\n     *\n     * The following properties may be specified in `from`, `to`, and `keyframe` objects:\n     *\n     *   - `x` - The page X position in pixels.\n     *\n     *   - `y` - The page Y position in pixels\n     *\n     *   - `left` - The element's CSS `left` value. Units must be supplied.\n     *\n     *   - `top` - The element's CSS `top` value. Units must be supplied.\n     *\n     *   - `width` - The element's CSS `width` value. Units must be supplied.\n     *\n     *   - `height` - The element's CSS `height` value. Units must be supplied.\n     *\n     *   - `scrollLeft` - The element's `scrollLeft` value.\n     *\n     *   - `scrollTop` - The element's `scrollTop` value.\n     *\n     *   - `opacity` - The element's `opacity` value. This must be a value between `0` and `1`.\n     *\n     * **Be aware** that animating an Element which is being used by an Ext Component without in some way informing the\n     * Component about the changed element state will result in incorrect Component behaviour. This is because the\n     * Component will be using the old state of the element. To avoid this problem, it is now possible to directly\n     * animate certain properties of Components.\n     *\n     * @param {Object} config  Configuration for {@link Ext.fx.Anim}.\n     * Note that the {@link Ext.fx.Anim#to to} config is required.\n     * @return {Ext.dom.Element} this\n     */\n    animate: function(config) {\n        var me = this,\n            listeners,\n            anim,\n            animId = me.dom.id || Ext.id(me.dom);\n\n        if (!Ext.fx.Manager.hasFxBlock(animId)) {\n            // Bit of gymnastics here to ensure our internal listeners get bound first\n            if (config.listeners) {\n                listeners = config.listeners;\n                delete config.listeners;\n            }\n            if (config.internalListeners) {\n                config.listeners = config.internalListeners;\n                delete config.internalListeners;\n            }\n            anim = new Ext.fx.Anim(me.anim(config));\n            if (listeners) {\n                anim.on(listeners);\n            }\n            Ext.fx.Manager.queueFx(anim);\n        }\n        return me;\n    },\n\n    // @private - process the passed fx configuration.\n    anim: function(config) {\n        if (!Ext.isObject(config)) {\n            return (config) ? {} : false;\n        }\n\n        var me = this,\n            duration = config.duration || Ext.fx.Anim.prototype.duration,\n            easing = config.easing || 'ease',\n            animConfig;\n\n        if (config.stopAnimation) {\n            me.stopAnimation();\n        }\n\n        Ext.applyIf(config, Ext.fx.Manager.getFxDefaults(me.id));\n\n        // Clear any 'paused' defaults.\n        Ext.fx.Manager.setFxDefaults(me.id, {\n            delay: 0\n        });\n\n        animConfig = {\n            // Pass the DOM reference. That's tested first so will be converted to an Ext.fx.Target fastest.\n            target: me.dom,\n            remove: config.remove,\n            alternate: config.alternate || false,\n            duration: duration,\n            easing: easing,\n            callback: config.callback,\n            listeners: config.listeners,\n            iterations: config.iterations || 1,\n            scope: config.scope,\n            block: config.block,\n            concurrent: config.concurrent,\n            delay: config.delay || 0,\n            paused: true,\n            keyframes: config.keyframes,\n            from: config.from || {},\n            to: Ext.apply({}, config)\n        };\n        Ext.apply(animConfig.to, config.to);\n\n        // Anim API properties - backward compat\n        delete animConfig.to.to;\n        delete animConfig.to.from;\n        delete animConfig.to.remove;\n        delete animConfig.to.alternate;\n        delete animConfig.to.keyframes;\n        delete animConfig.to.iterations;\n        delete animConfig.to.listeners;\n        delete animConfig.to.target;\n        delete animConfig.to.paused;\n        delete animConfig.to.callback;\n        delete animConfig.to.scope;\n        delete animConfig.to.duration;\n        delete animConfig.to.easing;\n        delete animConfig.to.concurrent;\n        delete animConfig.to.block;\n        delete animConfig.to.stopAnimation;\n        delete animConfig.to.delay;\n        return animConfig;\n    },\n\n    /**\n     * Slides the element into view. An anchor point can be optionally passed to set the point of origin for the slide\n     * effect. This function automatically handles wrapping the element with a fixed-size container if needed. See the\n     * Fx class overview for valid anchor point options. Usage:\n     *\n     *     // default: slide the element in from the top\n     *     el.slideIn();\n     *\n     *     // custom: slide the element in from the right with a 2-second duration\n     *     el.slideIn('r', { duration: 2000 });\n     *\n     *     // common config options shown with default values\n     *     el.slideIn('t', {\n     *         easing: 'easeOut',\n     *         duration: 500\n     *     });\n     *\n     * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @param {Boolean} options.preserveScroll Set to true if preservation of any descendant elements'\n     * `scrollTop` values is required. By default the DOM wrapping operation performed by `slideIn` and\n     * `slideOut` causes the browser to lose all scroll positions.\n     * @return {Ext.dom.Element} The Element\n     */\n    slideIn: function(anchor, obj, slideOut) {\n        var me = this,\n            elStyle = me.dom.style,\n            beforeAnim,\n            wrapAnim,\n            restoreScroll,\n            wrapDomParentNode;\n\n        anchor = anchor || \"t\";\n        obj = obj || {};\n\n        beforeAnim = function() {\n            var animScope = this,\n                listeners = obj.listeners,\n                box, originalStyles, anim, wrap;\n\n            if (!slideOut) {\n                me.fixDisplay();\n            }\n\n            box = me.getBox();\n            if ((anchor == 't' || anchor == 'b') && box.height === 0) {\n                box.height = me.dom.scrollHeight;\n            }\n            else if ((anchor == 'l' || anchor == 'r') && box.width === 0) {\n                box.width = me.dom.scrollWidth;\n            }\n\n            originalStyles = me.getStyles('width', 'height', 'left', 'right', 'top', 'bottom', 'position', 'z-index', true);\n            me.setSize(box.width, box.height);\n\n            // Cache all descendants' scrollTop & scrollLeft values if configured to preserve scroll.\n            if (obj.preserveScroll) {\n                restoreScroll = me.cacheScrollValues();\n            }\n\n            wrap = me.wrap({\n                id: Ext.id() + '-anim-wrap-for-' + me.id,\n                style: {\n                    visibility: slideOut ? 'visible' : 'hidden'\n                }\n            });\n            wrapDomParentNode = wrap.dom.parentNode;\n            wrap.setPositioning(me.getPositioning());\n            if (wrap.isStyle('position', 'static')) {\n                wrap.position('relative');\n            }\n            me.clearPositioning('auto');\n            wrap.clip();\n\n            // The wrap will have reset all descendant scrollTops. Restore them if we cached them.\n            if (restoreScroll) {\n                restoreScroll();\n            }\n\n            // This element is temporarily positioned absolute within its wrapper.\n            // Restore to its default, CSS-inherited visibility setting.\n            // We cannot explicitly poke visibility:visible into its style because that overrides the visibility of the wrap.\n            me.setStyle({\n                visibility: '',\n                position: 'absolute'\n            });\n            if (slideOut) {\n                wrap.setSize(box.width, box.height);\n            }\n\n            switch (anchor) {\n                case 't':\n                    anim = {\n                        from: {\n                            width: box.width + 'px',\n                            height: '0px'\n                        },\n                        to: {\n                            width: box.width + 'px',\n                            height: box.height + 'px'\n                        }\n                    };\n                    elStyle.bottom = '0px';\n                    break;\n                case 'l':\n                    anim = {\n                        from: {\n                            width: '0px',\n                            height: box.height + 'px'\n                        },\n                        to: {\n                            width: box.width + 'px',\n                            height: box.height + 'px'\n                        }\n                    };\n                    elStyle.right = '0px';\n                    break;\n                case 'r':\n                    anim = {\n                        from: {\n                            x: box.x + box.width,\n                            width: '0px',\n                            height: box.height + 'px'\n                        },\n                        to: {\n                            x: box.x,\n                            width: box.width + 'px',\n                            height: box.height + 'px'\n                        }\n                    };\n                    break;\n                case 'b':\n                    anim = {\n                        from: {\n                            y: box.y + box.height,\n                            width: box.width + 'px',\n                            height: '0px'\n                        },\n                        to: {\n                            y: box.y,\n                            width: box.width + 'px',\n                            height: box.height + 'px'\n                        }\n                    };\n                    break;\n                case 'tl':\n                    anim = {\n                        from: {\n                            x: box.x,\n                            y: box.y,\n                            width: '0px',\n                            height: '0px'\n                        },\n                        to: {\n                            width: box.width + 'px',\n                            height: box.height + 'px'\n                        }\n                    };\n                    elStyle.bottom = '0px';\n                    elStyle.right = '0px';\n                    break;\n                case 'bl':\n                    anim = {\n                        from: {\n                            y: box.y + box.height,\n                            width: '0px',\n                            height: '0px'\n                        },\n                        to: {\n                            y: box.y,\n                            width: box.width + 'px',\n                            height: box.height + 'px'\n                        }\n                    };\n                    elStyle.bottom = '0px';\n                    break;\n                case 'br':\n                    anim = {\n                        from: {\n                            x: box.x + box.width,\n                            y: box.y + box.height,\n                            width: '0px',\n                            height: '0px'\n                        },\n                        to: {\n                            x: box.x,\n                            y: box.y,\n                            width: box.width + 'px',\n                            height: box.height + 'px'\n                        }\n                    };\n                    break;\n                case 'tr':\n                    anim = {\n                        from: {\n                            x: box.x + box.width,\n                            width: '0px',\n                            height: '0px'\n                        },\n                        to: {\n                            x: box.x,\n                            width: box.width + 'px',\n                            height: box.height + 'px'\n                        }\n                    };\n                    elStyle.right = '0px';\n                    break;\n            }\n\n            wrap.show();\n            wrapAnim = Ext.apply({}, obj);\n            delete wrapAnim.listeners;\n            wrapAnim = new Ext.fx.Anim(Ext.applyIf(wrapAnim, {\n                target: wrap,\n                duration: 500,\n                easing: 'ease-out',\n                from: slideOut ? anim.to : anim.from,\n                to: slideOut ? anim.from : anim.to\n            }));\n\n            // In the absence of a callback, this listener MUST be added first\n            wrapAnim.on('afteranimate', function() {\n                me.setStyle(originalStyles);\n                if (slideOut) {\n                    if (obj.useDisplay) {\n                        me.setDisplayed(false);\n                    } else {\n                        me.hide();\n                    }\n                }\n                if (wrap.dom) {\n                    if (wrap.dom.parentNode) {\n                        wrap.dom.parentNode.insertBefore(me.dom, wrap.dom);\n                    } else {\n                        wrapDomParentNode.appendChild(me.dom);\n                    }\n                    wrap.remove();\n                }\n                // The unwrap will have reset all descendant scrollTops. Restore them if we cached them.\n                if (restoreScroll) {\n                    restoreScroll();\n                }\n                // kill the no-op element animation created below\n                animScope.end();\n            });\n            // Add configured listeners after\n            if (listeners) {\n                wrapAnim.on(listeners);\n            }\n        };\n\n        me.animate({\n            // See \"A Note About Wrapped Animations\" at the top of this class:\n            duration: obj.duration ? Math.max(obj.duration, 500) * 2 : 1000,\n            listeners: {\n                beforeanimate: beforeAnim // kick off the wrap animation\n            }\n        });\n        return me;\n    },\n\n\n    /**\n     * Slides the element out of view. An anchor point can be optionally passed to set the end point for the slide\n     * effect. When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will\n     * still take up space in the document. The element must be removed from the DOM using the 'remove' config option if\n     * desired. This function automatically handles wrapping the element with a fixed-size container if needed. See the\n     * Fx class overview for valid anchor point options. Usage:\n     *\n     *     // default: slide the element out to the top\n     *     el.slideOut();\n     *\n     *     // custom: slide the element out to the right with a 2-second duration\n     *     el.slideOut('r', { duration: 2000 });\n     *\n     *     // common config options shown with default values\n     *     el.slideOut('t', {\n     *         easing: 'easeOut',\n     *         duration: 500,\n     *         remove: false,\n     *         useDisplay: false\n     *     });\n     *\n     * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @return {Ext.dom.Element} The Element\n     */\n    slideOut: function(anchor, o) {\n        return this.slideIn(anchor, o, true);\n    },\n\n    /**\n     * Fades the element out while slowly expanding it in all directions. When the effect is completed, the element will\n     * be hidden (visibility = 'hidden') but block elements will still take up space in the document. Usage:\n     *\n     *     // default\n     *     el.puff();\n     *\n     *     // common config options shown with default values\n     *     el.puff({\n     *         easing: 'easeOut',\n     *         duration: 500,\n     *         useDisplay: false\n     *     });\n     *\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @return {Ext.dom.Element} The Element\n     */\n    puff: function(obj) {\n        var me = this,\n            beforeAnim,\n            box = me.getBox(),\n            originalStyles = me.getStyles('width', 'height', 'left', 'right', 'top', 'bottom', 'position', 'z-index', 'font-size', 'opacity', true);\n\n       obj = Ext.applyIf(obj || {}, {\n            easing: 'ease-out',\n            duration: 500,\n            useDisplay: false\n        });\n\n        beforeAnim = function() {\n            me.clearOpacity();\n            me.show();\n            this.to = {\n                width: box.width * 2,\n                height: box.height * 2,\n                x: box.x - (box.width / 2),\n                y: box.y - (box.height /2),\n                opacity: 0,\n                fontSize: '200%'\n            };\n            this.on('afteranimate',function() {\n                if (me.dom) {\n                    if (obj.useDisplay) {\n                        me.setDisplayed(false);\n                    } else {\n                        me.hide();\n                    }\n                    me.setStyle(originalStyles);\n                    obj.callback.call(obj.scope);\n                }\n            });\n        };\n\n        me.animate({\n            duration: obj.duration,\n            easing: obj.easing,\n            listeners: {\n                beforeanimate: {\n                    fn: beforeAnim\n                }\n            }\n        });\n        return me;\n    },\n\n    /**\n     * Blinks the element as if it was clicked and then collapses on its center (similar to switching off a television).\n     * When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will still\n     * take up space in the document. The element must be removed from the DOM using the 'remove' config option if\n     * desired. Usage:\n     *\n     *     // default\n     *     el.switchOff();\n     *\n     *     // all config options shown with default values\n     *     el.switchOff({\n     *         easing: 'easeIn',\n     *         duration: .3,\n     *         remove: false,\n     *         useDisplay: false\n     *     });\n     *\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @return {Ext.dom.Element} The Element\n     */\n    switchOff: function(obj) {\n        var me = this,\n            beforeAnim;\n\n        obj = Ext.applyIf(obj || {}, {\n            easing: 'ease-in',\n            duration: 500,\n            remove: false,\n            useDisplay: false\n        });\n\n        beforeAnim = function() {\n            var animScope = this,\n                size = me.getSize(),\n                xy = me.getXY(),\n                keyframe, position;\n            me.clearOpacity();\n            me.clip();\n            position = me.getPositioning();\n\n            keyframe = new Ext.fx.Animator({\n                target: me,\n                duration: obj.duration,\n                easing: obj.easing,\n                keyframes: {\n                    33: {\n                        opacity: 0.3\n                    },\n                    66: {\n                        height: 1,\n                        y: xy[1] + size.height / 2\n                    },\n                    100: {\n                        width: 1,\n                        x: xy[0] + size.width / 2\n                    }\n                }\n            });\n            keyframe.on('afteranimate', function() {\n                if (obj.useDisplay) {\n                    me.setDisplayed(false);\n                } else {\n                    me.hide();\n                }\n                me.clearOpacity();\n                me.setPositioning(position);\n                me.setSize(size);\n                // kill the no-op element animation created below\n                animScope.end();\n            });\n        };\n        \n        me.animate({\n            // See \"A Note About Wrapped Animations\" at the top of this class:\n            duration: (Math.max(obj.duration, 500) * 2),\n            listeners: {\n                beforeanimate: {\n                    fn: beforeAnim\n                }\n            }\n        });\n        return me;\n    },\n\n    /**\n     * Shows a ripple of exploding, attenuating borders to draw attention to an Element. Usage:\n     *\n     *     // default: a single light blue ripple\n     *     el.frame();\n     *\n     *     // custom: 3 red ripples lasting 3 seconds total\n     *     el.frame(\"#ff0000\", 3, { duration: 3000 });\n     *\n     *     // common config options shown with default values\n     *     el.frame(\"#C3DAF9\", 1, {\n     *         duration: 1000 // duration of each individual ripple.\n     *         // Note: Easing is not configurable and will be ignored if included\n     *     });\n     *\n     * @param {String} [color='#C3DAF9'] The hex color value for the border.\n     * @param {Number} [count=1] The number of ripples to display.\n     * @param {Object} [options] Object literal with any of the Fx config options\n     * @return {Ext.dom.Element} The Element\n     */\n    frame : function(color, count, obj){\n        var me = this,\n            beforeAnim;\n\n        color = color || '#C3DAF9';\n        count = count || 1;\n        obj = obj || {};\n\n        beforeAnim = function() {\n            me.show();\n            var animScope = this,\n                box = me.getBox(),\n                proxy = Ext.getBody().createChild({\n                    id: me.id + '-anim-proxy',\n                    style: {\n                        position : 'absolute',\n                        'pointer-events': 'none',\n                        'z-index': 35000,\n                        border : '0px solid ' + color\n                    }\n                }),\n                proxyAnim;\n            proxyAnim = new Ext.fx.Anim({\n                target: proxy,\n                duration: obj.duration || 1000,\n                iterations: count,\n                from: {\n                    top: box.y,\n                    left: box.x,\n                    borderWidth: 0,\n                    opacity: 1,\n                    height: box.height,\n                    width: box.width\n                },\n                to: {\n                    top: box.y - 20,\n                    left: box.x - 20,\n                    borderWidth: 10,\n                    opacity: 0,\n                    height: box.height + 40,\n                    width: box.width + 40\n                }\n            });\n            proxyAnim.on('afteranimate', function() {\n                proxy.remove();\n                // kill the no-op element animation created below\n                animScope.end();\n            });\n        };\n\n        me.animate({\n            // See \"A Note About Wrapped Animations\" at the top of this class:\n            duration: (Math.max(obj.duration, 500) * 2) || 2000,\n            listeners: {\n                beforeanimate: {\n                    fn: beforeAnim\n                }\n            }\n        });\n        return me;\n    },\n\n    /**\n     * Slides the element while fading it out of view. An anchor point can be optionally passed to set the ending point\n     * of the effect. Usage:\n     *\n     *     // default: slide the element downward while fading out\n     *     el.ghost();\n     *\n     *     // custom: slide the element out to the right with a 2-second duration\n     *     el.ghost('r', { duration: 2000 });\n     *\n     *     // common config options shown with default values\n     *     el.ghost('b', {\n     *         easing: 'easeOut',\n     *         duration: 500\n     *     });\n     *\n     * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to bottom: 'b')\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @return {Ext.dom.Element} The Element\n     */\n    ghost: function(anchor, obj) {\n        var me = this,\n            beforeAnim;\n\n        anchor = anchor || \"b\";\n        beforeAnim = function() {\n            var width = me.getWidth(),\n                height = me.getHeight(),\n                xy = me.getXY(),\n                position = me.getPositioning(),\n                to = {\n                    opacity: 0\n                };\n            switch (anchor) {\n                case 't':\n                    to.y = xy[1] - height;\n                    break;\n                case 'l':\n                    to.x = xy[0] - width;\n                    break;\n                case 'r':\n                    to.x = xy[0] + width;\n                    break;\n                case 'b':\n                    to.y = xy[1] + height;\n                    break;\n                case 'tl':\n                    to.x = xy[0] - width;\n                    to.y = xy[1] - height;\n                    break;\n                case 'bl':\n                    to.x = xy[0] - width;\n                    to.y = xy[1] + height;\n                    break;\n                case 'br':\n                    to.x = xy[0] + width;\n                    to.y = xy[1] + height;\n                    break;\n                case 'tr':\n                    to.x = xy[0] + width;\n                    to.y = xy[1] - height;\n                    break;\n            }\n            this.to = to;\n            this.on('afteranimate', function () {\n                if (me.dom) {\n                    me.hide();\n                    me.clearOpacity();\n                    me.setPositioning(position);\n                }\n            });\n        };\n\n        me.animate(Ext.applyIf(obj || {}, {\n            duration: 500,\n            easing: 'ease-out',\n            listeners: {\n                beforeanimate: {\n                    fn: beforeAnim\n                }\n            }\n        }));\n        return me;\n    },\n\n    /**\n     * Highlights the Element by setting a color (applies to the background-color by default, but can be changed using\n     * the \"attr\" config option) and then fading back to the original color. If no original color is available, you\n     * should provide the \"endColor\" config option which will be cleared after the animation. Usage:\n     *\n     *     // default: highlight background to yellow\n     *     el.highlight();\n     *\n     *     // custom: highlight foreground text to blue for 2 seconds\n     *     el.highlight(\"0000ff\", { attr: 'color', duration: 2000 });\n     *\n     *     // common config options shown with default values\n     *     el.highlight(\"ffff9c\", {\n     *         attr: \"backgroundColor\", //can be any valid CSS property (attribute) that supports a color value\n     *         endColor: (current color) or \"ffffff\",\n     *         easing: 'easeIn',\n     *         duration: 1000\n     *     });\n     *\n     * @param {String} color (optional) The highlight color. Should be a 6 char hex color without the leading #\n     * (defaults to yellow: 'ffff9c')\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @return {Ext.dom.Element} The Element\n     */\n    highlight: function(color, o) {\n        var me = this,\n            dom = me.dom,\n            from = {},\n            restore, to, attr, lns, event, fn;\n\n        o = o || {};\n        lns = o.listeners || {};\n        attr = o.attr || 'backgroundColor';\n        from[attr] = color || 'ffff9c';\n\n        if (!o.to) {\n            to = {};\n            to[attr] = o.endColor || me.getColor(attr, 'ffffff', '');\n        }\n        else {\n            to = o.to;\n        }\n\n        // Don't apply directly on lns, since we reference it in our own callbacks below\n        o.listeners = Ext.apply(Ext.apply({}, lns), {\n            beforeanimate: function() {\n                restore = dom.style[attr];\n                me.clearOpacity();\n                me.show();\n\n                event = lns.beforeanimate;\n                if (event) {\n                    fn = event.fn || event;\n                    return fn.apply(event.scope || lns.scope || window, arguments);\n                }\n            },\n            afteranimate: function() {\n                if (dom) {\n                    dom.style[attr] = restore;\n                }\n\n                event = lns.afteranimate;\n                if (event) {\n                    fn = event.fn || event;\n                    fn.apply(event.scope || lns.scope || window, arguments);\n                }\n            }\n        });\n\n        me.animate(Ext.apply({}, o, {\n            duration: 1000,\n            easing: 'ease-in',\n            from: from,\n            to: to\n        }));\n        return me;\n    },\n\n   /**\n    * Creates a pause before any subsequent queued effects begin. If there are no effects queued after the pause it will\n    * have no effect. Usage:\n    *\n    *     el.pause(1);\n    *\n    * @deprecated 4.0 Use the `delay` config to {@link #animate} instead.\n    * @param {Number} seconds The length of time to pause (in seconds)\n    * @return {Ext.Element} The Element\n    */\n    pause: function(ms) {\n        var me = this;\n        Ext.fx.Manager.setFxDefaults(me.id, {\n            delay: ms\n        });\n        return me;\n    },\n\n    /**\n     * Fade an element in (from transparent to opaque). The ending opacity can be specified using the `opacity`\n     * config option. Usage:\n     *\n     *     // default: fade in from opacity 0 to 100%\n     *     el.fadeIn();\n     *\n     *     // custom: fade in from opacity 0 to 75% over 2 seconds\n     *     el.fadeIn({ opacity: .75, duration: 2000});\n     *\n     *     // common config options shown with default values\n     *     el.fadeIn({\n     *         opacity: 1, //can be any value between 0 and 1 (e.g. .5)\n     *         easing: 'easeOut',\n     *         duration: 500\n     *     });\n     *\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @return {Ext.Element} The Element\n     */\n    fadeIn: function(o) {\n        var me = this;\n        me.animate(Ext.apply({}, o, {\n            opacity: 1,\n            internalListeners: {\n                beforeanimate: function(anim){\n                    // restore any visibility/display that may have \n                    // been applied by a fadeout animation\n                    if (me.isStyle('display', 'none')) {\n                        me.setDisplayed('');\n                    } else {\n                        me.show();\n                    } \n                }\n            }\n        }));\n        return this;\n    },\n\n    /**\n     * Fade an element out (from opaque to transparent). The ending opacity can be specified using the `opacity`\n     * config option. Note that IE may require `useDisplay:true` in order to redisplay correctly.\n     * Usage:\n     *\n     *     // default: fade out from the element's current opacity to 0\n     *     el.fadeOut();\n     *\n     *     // custom: fade out from the element's current opacity to 25% over 2 seconds\n     *     el.fadeOut({ opacity: .25, duration: 2000});\n     *\n     *     // common config options shown with default values\n     *     el.fadeOut({\n     *         opacity: 0, //can be any value between 0 and 1 (e.g. .5)\n     *         easing: 'easeOut',\n     *         duration: 500,\n     *         remove: false,\n     *         useDisplay: false\n     *     });\n     *\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @return {Ext.Element} The Element\n     */\n    fadeOut: function(o) {\n        var me = this;\n        o = Ext.apply({\n            opacity: 0,\n            internalListeners: {\n                afteranimate: function(anim){\n                    var dom = me.dom;\n                    if (dom && anim.to.opacity === 0) {\n                        if (o.useDisplay) {\n                            me.setDisplayed(false);\n                        } else {\n                            me.hide();\n                        }\n                    }         \n                }\n            }\n        }, o);\n        me.animate(o);\n        return me;\n    },\n\n    /**\n     * Animates the transition of an element's dimensions from a starting height/width to an ending height/width. This\n     * method is a convenience implementation of {@link #shift}. Usage:\n     *\n     *     // change height and width to 100x100 pixels\n     *     el.scale(100, 100);\n     *\n     *     // common config options shown with default values.  The height and width will default to\n     *     // the element's existing values if passed as null.\n     *     el.scale(\n     *         [element's width],\n     *         [element's height], {\n     *             easing: 'easeOut',\n     *             duration: 350\n     *         }\n     *     );\n     *\n     * @deprecated 4.0 Just use {@link #animate} instead.\n     * @param {Number} width The new width (pass undefined to keep the original width)\n     * @param {Number} height The new height (pass undefined to keep the original height)\n     * @param {Object} options (optional) Object literal with any of the Fx config options\n     * @return {Ext.Element} The Element\n     */\n    scale: function(w, h, o) {\n        this.animate(Ext.apply({}, o, {\n            width: w,\n            height: h\n        }));\n        return this;\n    },\n\n    /**\n     * Animates the transition of any combination of an element's dimensions, xy position and/or opacity. Any of these\n     * properties not specified in the config object will not be changed. This effect requires that at least one new\n     * dimension, position or opacity setting must be passed in on the config object in order for the function to have\n     * any effect. Usage:\n     *\n     *     // slide the element horizontally to x position 200 while changing the height and opacity\n     *     el.shift({ x: 200, height: 50, opacity: .8 });\n     *\n     *     // common config options shown with default values.\n     *     el.shift({\n     *         width: [element's width],\n     *         height: [element's height],\n     *         x: [element's x position],\n     *         y: [element's y position],\n     *         opacity: [element's opacity],\n     *         easing: 'easeOut',\n     *         duration: 350\n     *     });\n     *\n     * @deprecated 4.0 Just use {@link #animate} instead.\n     * @param {Object} options Object literal with any of the Fx config options\n     * @return {Ext.Element} The Element\n     */\n    shift: function(config) {\n        this.animate(config);\n        return this;\n    }\n});\n\n//@tag dom,core\n//@require Ext.dom.Element-anim\n//@define Ext.dom.Element-dd\n//@define Ext.dom.Element\n\n/**\n * @class Ext.dom.Element\n */\nExt.dom.Element.override({\n    /**\n     * Initializes a {@link Ext.dd.DD} drag drop object for this element.\n     * @param {String} group The group the DD object is member of\n     * @param {Object} config The DD config object\n     * @param {Object} overrides An object containing methods to override/implement on the DD object\n     * @return {Ext.dd.DD} The DD object\n     */\n    initDD : function(group, config, overrides){\n        var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);\n        return Ext.apply(dd, overrides);\n    },\n\n    /**\n     * Initializes a {@link Ext.dd.DDProxy} object for this element.\n     * @param {String} group The group the DDProxy object is member of\n     * @param {Object} config The DDProxy config object\n     * @param {Object} overrides An object containing methods to override/implement on the DDProxy object\n     * @return {Ext.dd.DDProxy} The DDProxy object\n     */\n    initDDProxy : function(group, config, overrides){\n        var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);\n        return Ext.apply(dd, overrides);\n    },\n\n    /**\n     * Initializes a {@link Ext.dd.DDTarget} object for this element.\n     * @param {String} group The group the DDTarget object is member of\n     * @param {Object} config The DDTarget config object\n     * @param {Object} overrides An object containing methods to override/implement on the DDTarget object\n     * @return {Ext.dd.DDTarget} The DDTarget object\n     */\n    initDDTarget : function(group, config, overrides){\n        var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);\n        return Ext.apply(dd, overrides);\n    }\n});\n\n//@tag dom,core\n//@require Ext.dom.Element-dd\n//@define Ext.dom.Element-fx\n//@define Ext.dom.Element\n\n/**\n * @class Ext.dom.Element\n */\n(function() {\n\nvar Element         = Ext.dom.Element,\n    VISIBILITY      = \"visibility\",\n    DISPLAY         = \"display\",\n    NONE            = \"none\",\n    HIDDEN          = 'hidden',\n    VISIBLE         = 'visible',\n    OFFSETS         = \"offsets\",\n    ASCLASS         = \"asclass\",\n    NOSIZE          = 'nosize',\n    ORIGINALDISPLAY = 'originalDisplay',\n    VISMODE         = 'visibilityMode',\n    ISVISIBLE       = 'isVisible',\n    OFFSETCLASS     = Ext.baseCSSPrefix + 'hide-offsets',\n    getDisplay = function(el) {\n        var data = (el.$cache || el.getCache()).data,\n            display = data[ORIGINALDISPLAY];\n            \n        if (display === undefined) {\n            data[ORIGINALDISPLAY] = display = '';\n        }\n        return display;\n    },\n    getVisMode = function(el){\n        var data = (el.$cache || el.getCache()).data,\n            visMode = data[VISMODE];\n            \n        if (visMode === undefined) {\n            data[VISMODE] = visMode = Element.VISIBILITY;\n        }\n        return visMode;\n    };\n\nElement.override({\n    /**\n     * The element's default display mode.\n     */\n    originalDisplay : \"\",\n    visibilityMode : 1,\n\n    /**\n     * Sets the visibility of the element (see details). If the visibilityMode is set to Element.DISPLAY, it will use\n     * the display property to hide the element, otherwise it uses visibility. The default is to hide and show using the visibility property.\n     * @param {Boolean} visible Whether the element is visible\n     * @param {Boolean/Object} [animate] True for the default animation, or a standard Element animation config object\n     * @return {Ext.dom.Element} this\n     */\n    setVisible : function(visible, animate) {\n        var me = this,\n            dom = me.dom,\n            visMode = getVisMode(me);\n\n        // hideMode string override\n        if (typeof animate == 'string') {\n            switch (animate) {\n                case DISPLAY:\n                    visMode = Element.DISPLAY;\n                    break;\n                case VISIBILITY:\n                    visMode = Element.VISIBILITY;\n                    break;\n                case OFFSETS:\n                    visMode = Element.OFFSETS;\n                    break;\n                case NOSIZE:\n                case ASCLASS:\n                    visMode = Element.ASCLASS;\n                    break;\n            }\n            me.setVisibilityMode(visMode);\n            animate = false;\n        }\n\n        if (!animate || !me.anim) {\n            if (visMode == Element.DISPLAY) {\n                return me.setDisplayed(visible);\n            } else if (visMode == Element.OFFSETS) {\n                me[visible?'removeCls':'addCls'](OFFSETCLASS);\n            } else if (visMode == Element.VISIBILITY) {\n                me.fixDisplay();\n                // Show by clearing visibility style. Explicitly setting to \"visible\" overrides parent visibility setting\n                dom.style.visibility = visible ? '' : HIDDEN;\n            } else if (visMode == Element.ASCLASS) {\n                me[visible?'removeCls':'addCls'](me.visibilityCls || Element.visibilityCls);\n            }\n        } else {\n            // closure for composites\n            if (visible) {\n                me.setOpacity(0.01);\n                me.setVisible(true);\n            }\n            if (!Ext.isObject(animate)) {\n                animate = {\n                    duration: 350,\n                    easing: 'ease-in'\n                };\n            }\n            me.animate(Ext.applyIf({\n                callback: function() {\n                    if (!visible) {\n                        me.setVisible(false).setOpacity(1);\n                    }\n                },\n                to: {\n                    opacity: (visible) ? 1 : 0\n                }\n            }, animate));\n        }\n        (me.$cache || me.getCache()).data[ISVISIBLE] = visible;\n        return me;\n    },\n\n    /**\n     * @private\n     * Determine if the Element has a relevant height and width available based\n     * upon current logical visibility state\n     */\n    hasMetrics  : function(){\n        var visMode = getVisMode(this);\n        return this.isVisible() || (visMode == Element.OFFSETS) || (visMode == Element.VISIBILITY);\n    },\n\n    /**\n     * Toggles the element's visibility or display, depending on visibility mode.\n     * @param {Boolean/Object} [animate] True for the default animation, or a standard Element animation config object\n     * @return {Ext.dom.Element} this\n     */\n    toggle : function(animate){\n        var me = this;\n        me.setVisible(!me.isVisible(), me.anim(animate));\n        return me;\n    },\n\n    /**\n     * Sets the CSS display property. Uses originalDisplay if the specified value is a boolean true.\n     * @param {Boolean/String} value Boolean value to display the element using its default display, or a string to set the display directly.\n     * @return {Ext.dom.Element} this\n     */\n    setDisplayed : function(value) {\n        if(typeof value == \"boolean\"){\n           value = value ? getDisplay(this) : NONE;\n        }\n        this.setStyle(DISPLAY, value);\n        return this;\n    },\n\n    // private\n    fixDisplay : function(){\n        var me = this;\n        if (me.isStyle(DISPLAY, NONE)) {\n            me.setStyle(VISIBILITY, HIDDEN);\n            me.setStyle(DISPLAY, getDisplay(me)); // first try reverting to default\n            if (me.isStyle(DISPLAY, NONE)) { // if that fails, default to block\n                me.setStyle(DISPLAY, \"block\");\n            }\n        }\n    },\n\n    /**\n     * Hide this element - Uses display mode to determine whether to use \"display\" or \"visibility\". See {@link #setVisible}.\n     * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object\n     * @return {Ext.dom.Element} this\n     */\n    hide : function(animate){\n        // hideMode override\n        if (typeof animate == 'string'){\n            this.setVisible(false, animate);\n            return this;\n        }\n        this.setVisible(false, this.anim(animate));\n        return this;\n    },\n\n    /**\n     * Show this element - Uses display mode to determine whether to use \"display\" or \"visibility\". See {@link #setVisible}.\n     * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object\n     * @return {Ext.dom.Element} this\n     */\n    show : function(animate){\n        // hideMode override\n        if (typeof animate == 'string'){\n            this.setVisible(true, animate);\n            return this;\n        }\n        this.setVisible(true, this.anim(animate));\n        return this;\n    }\n});\n\n}());\n\n//@tag dom,core\n//@require Ext.dom.Element-fx\n//@define Ext.dom.Element-position\n//@define Ext.dom.Element\n\n/**\n * @class Ext.dom.Element\n */\n(function() {\n\nvar Element = Ext.dom.Element,\n    LEFT = \"left\",\n    RIGHT = \"right\",\n    TOP = \"top\",\n    BOTTOM = \"bottom\",\n    POSITION = \"position\",\n    STATIC = \"static\",\n    RELATIVE = \"relative\",\n    AUTO = \"auto\",\n    ZINDEX = \"z-index\",\n    BODY = 'BODY',\n\n    PADDING = 'padding',\n    BORDER = 'border',\n    SLEFT = '-left',\n    SRIGHT = '-right',\n    STOP = '-top',\n    SBOTTOM = '-bottom',\n    SWIDTH = '-width',\n    // special markup used throughout Ext when box wrapping elements\n    borders = {l: BORDER + SLEFT + SWIDTH, r: BORDER + SRIGHT + SWIDTH, t: BORDER + STOP + SWIDTH, b: BORDER + SBOTTOM + SWIDTH},\n    paddings = {l: PADDING + SLEFT, r: PADDING + SRIGHT, t: PADDING + STOP, b: PADDING + SBOTTOM},\n    paddingsTLRB = [paddings.l, paddings.r, paddings.t, paddings.b],\n    bordersTLRB = [borders.l,  borders.r,  borders.t,  borders.b],\n    positionTopLeft = ['position', 'top', 'left'];\n\nElement.override({\n\n    getX: function() {\n        return Element.getX(this.dom);\n    },\n\n    getY: function() {\n        return Element.getY(this.dom);\n    },\n\n    /**\n      * Gets the current position of the element based on page coordinates.\n      * Element must be part of the DOM tree to have page coordinates\n      * (display:none or elements not appended return false).\n      * @return {Number[]} The XY position of the element\n      */\n    getXY: function() {\n        return Element.getXY(this.dom);\n    },\n\n    /**\n      * Returns the offsets of this element from the passed element. Both element must be part\n      * of the DOM tree and not have display:none to have page coordinates.\n      * @param {String/HTMLElement/Ext.Element} element The element to get the offsets from.\n      * @return {Number[]} The XY page offsets (e.g. `[100, -200]`)\n      */\n    getOffsetsTo : function(el){\n        var o = this.getXY(),\n                e = Ext.fly(el, '_internal').getXY();\n        return [o[0] - e[0],o[1] - e[1]];\n    },\n\n    setX: function(x, animate) {\n        return this.setXY([x, this.getY()], animate);\n    },\n\n    setY: function(y, animate) {\n        return this.setXY([this.getX(), y], animate);\n    },\n\n    setLeft: function(left) {\n        this.setStyle(LEFT, this.addUnits(left));\n        return this;\n    },\n\n    setTop: function(top) {\n        this.setStyle(TOP, this.addUnits(top));\n        return this;\n    },\n\n    setRight: function(right) {\n        this.setStyle(RIGHT, this.addUnits(right));\n        return this;\n    },\n\n    setBottom: function(bottom) {\n        this.setStyle(BOTTOM, this.addUnits(bottom));\n        return this;\n    },\n\n    /**\n     * Sets the position of the element in page coordinates, regardless of how the element\n     * is positioned. The element must be part of the DOM tree to have page coordinates\n     * (`display:none` or elements not appended return false).\n     * @param {Number[]} pos Contains X & Y [x, y] values for new position (coordinates are page-based)\n     * @param {Boolean/Object} [animate] True for the default animation, or a standard Element\n     * animation config object\n     * @return {Ext.Element} this\n     */\n    setXY: function(pos, animate) {\n        var me = this;\n        if (!animate || !me.anim) {\n            Element.setXY(me.dom, pos);\n        }\n        else {\n            if (!Ext.isObject(animate)) {\n                animate = {};\n            }\n            me.animate(Ext.applyIf({ to: { x: pos[0], y: pos[1] } }, animate));\n        }\n        return me;\n    },\n\n    pxRe: /^\\d+(?:\\.\\d*)?px$/i,\n\n    /**\n     * Returns the x-coordinate of this element reletive to its `offsetParent`.\n     * @return {Number} The local x-coordinate (relative to the `offsetParent`).\n     */\n    getLocalX: function() {\n        var me = this,\n            offsetParent,\n            x = me.getStyle(LEFT);\n\n        if (!x || x === AUTO) {\n            return 0;\n        }\n        if (x && me.pxRe.test(x)) {\n            return parseFloat(x);\n        }\n\n        x = me.getX();\n\n        offsetParent = me.dom.offsetParent;\n        if (offsetParent) {\n            x -= Ext.fly(offsetParent).getX();\n        }\n\n        return x;\n    },\n\n    /**\n     * Returns the y-coordinate of this element reletive to its `offsetParent`.\n     * @return {Number} The local y-coordinate (relative to the `offsetParent`).\n     */\n    getLocalY: function() {\n        var me = this,\n            offsetParent,\n            y = me.getStyle(TOP);\n\n        if (!y || y === AUTO) {\n            return 0;\n        }\n        if (y && me.pxRe.test(y)) {\n            return parseFloat(y);\n        }\n\n        y = me.getY();\n\n        offsetParent = me.dom.offsetParent;\n        if (offsetParent) {\n            y -= Ext.fly(offsetParent).getY();\n        }\n\n        return y;\n    },\n\n    getLeft: function(local) {\n        return local ? this.getLocalX() : this.getX();\n    },\n\n    getRight: function(local) {\n        return (local ? this.getLocalX() : this.getX()) + this.getWidth();\n    },\n\n    getTop: function(local) {\n        return local ? this.getLocalY() : this.getY();\n    },\n\n    getBottom: function(local) {\n        return (local ? this.getLocalY() : this.getY()) + this.getHeight();\n    },\n\n    translatePoints: function(x, y) {\n        var me = this,\n            styles = me.getStyle(positionTopLeft),\n            relative = styles.position == 'relative',\n            left = parseFloat(styles.left),\n            top = parseFloat(styles.top),\n            xy = me.getXY();\n\n        if (Ext.isArray(x)) {\n             y = x[1];\n             x = x[0];\n        }\n        if (isNaN(left)) {\n            left = relative ? 0 : me.dom.offsetLeft;\n        }\n        if (isNaN(top)) {\n            top = relative ? 0 : me.dom.offsetTop;\n        }\n        left = (typeof x == 'number') ? x - xy[0] + left : undefined;\n        top = (typeof y == 'number') ? y - xy[1] + top : undefined;\n        return {\n            left: left,\n            top: top\n        };\n\n    },\n\n    setBox: function(box, adjust, animate) {\n        var me = this,\n                w = box.width,\n                h = box.height;\n        if ((adjust && !me.autoBoxAdjust) && !me.isBorderBox()) {\n            w -= (me.getBorderWidth(\"lr\") + me.getPadding(\"lr\"));\n            h -= (me.getBorderWidth(\"tb\") + me.getPadding(\"tb\"));\n        }\n        me.setBounds(box.x, box.y, w, h, animate);\n        return me;\n    },\n\n    getBox: function(contentBox, local) {\n        var me = this,\n            xy,\n            left,\n            top,\n            paddingWidth,\n            bordersWidth,\n            l, r, t, b, w, h, bx;\n\n        if (!local) {\n            xy = me.getXY();\n        } else {\n            xy = me.getStyle([LEFT, TOP]);\n            xy = [ parseFloat(xy.left) || 0, parseFloat(xy.top) || 0];\n        }\n        w = me.getWidth();\n        h = me.getHeight();\n        if (!contentBox) {\n            bx = {\n                x: xy[0],\n                y: xy[1],\n                0: xy[0],\n                1: xy[1],\n                width: w,\n                height: h\n            };\n        } else {\n            paddingWidth = me.getStyle(paddingsTLRB);\n            bordersWidth = me.getStyle(bordersTLRB);\n\n            l = (parseFloat(bordersWidth[borders.l]) || 0) + (parseFloat(paddingWidth[paddings.l]) || 0);\n            r = (parseFloat(bordersWidth[borders.r]) || 0) + (parseFloat(paddingWidth[paddings.r]) || 0);\n            t = (parseFloat(bordersWidth[borders.t]) || 0) + (parseFloat(paddingWidth[paddings.t]) || 0);\n            b = (parseFloat(bordersWidth[borders.b]) || 0) + (parseFloat(paddingWidth[paddings.b]) || 0);\n\n            bx = {\n                x: xy[0] + l,\n                y: xy[1] + t,\n                0: xy[0] + l,\n                1: xy[1] + t,\n                width: w - (l + r),\n                height: h - (t + b)\n            };\n        }\n        bx.right = bx.x + bx.width;\n        bx.bottom = bx.y + bx.height;\n\n        return bx;\n    },\n\n    getPageBox: function(getRegion) {\n        var me = this,\n            el = me.dom,\n            isDoc = el.nodeName == BODY,\n            w = isDoc ? Ext.dom.AbstractElement.getViewWidth() : el.offsetWidth,\n            h = isDoc ? Ext.dom.AbstractElement.getViewHeight() : el.offsetHeight,\n            xy = me.getXY(),\n            t = xy[1],\n            r = xy[0] + w,\n            b = xy[1] + h,\n            l = xy[0];\n\n        if (getRegion) {\n            return new Ext.util.Region(t, r, b, l);\n        }\n        else {\n            return {\n                left: l,\n                top: t,\n                width: w,\n                height: h,\n                right: r,\n                bottom: b\n            };\n        }\n    },\n\n    /**\n     * Sets the position of the element in page coordinates, regardless of how the element\n     * is positioned. The element must be part of the DOM tree to have page coordinates\n     * (`display:none` or elements not appended return false).\n     * @param {Number} x X value for new position (coordinates are page-based)\n     * @param {Number} y Y value for new position (coordinates are page-based)\n     * @param {Boolean/Object} [animate] True for the default animation, or a standard Element\n     * animation config object\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setLocation : function(x, y, animate) {\n        return this.setXY([x, y], animate);\n    },\n\n    /**\n     * Sets the position of the element in page coordinates, regardless of how the element\n     * is positioned. The element must be part of the DOM tree to have page coordinates\n     * (`display:none` or elements not appended return false).\n     * @param {Number} x X value for new position (coordinates are page-based)\n     * @param {Number} y Y value for new position (coordinates are page-based)\n     * @param {Boolean/Object} [animate] True for the default animation, or a standard Element\n     * animation config object\n     * @return {Ext.dom.AbstractElement} this\n     */\n    moveTo : function(x, y, animate) {\n        return this.setXY([x, y], animate);\n    },\n\n    /**\n     * Initializes positioning on this element. If a desired position is not passed, it will make the\n     * the element positioned relative IF it is not already positioned.\n     * @param {String} [pos] Positioning to use \"relative\", \"absolute\" or \"fixed\"\n     * @param {Number} [zIndex] The zIndex to apply\n     * @param {Number} [x] Set the page X position\n     * @param {Number} [y] Set the page Y position\n     */\n    position : function(pos, zIndex, x, y) {\n        var me = this;\n\n        if (!pos && me.isStyle(POSITION, STATIC)) {\n            me.setStyle(POSITION, RELATIVE);\n        } else if (pos) {\n            me.setStyle(POSITION, pos);\n        }\n        if (zIndex) {\n            me.setStyle(ZINDEX, zIndex);\n        }\n        if (x || y) {\n            me.setXY([x || false, y || false]);\n        }\n    },\n\n    /**\n     * Clears positioning back to the default when the document was loaded.\n     * @param {String} [value=''] The value to use for the left, right, top, bottom. You could use 'auto'.\n     * @return {Ext.dom.AbstractElement} this\n     */\n    clearPositioning : function(value) {\n        value = value || '';\n        this.setStyle({\n            left : value,\n            right : value,\n            top : value,\n            bottom : value,\n            \"z-index\" : \"\",\n            position : STATIC\n        });\n        return this;\n    },\n\n    /**\n     * Gets an object with all CSS positioning properties. Useful along with #setPostioning to get\n     * snapshot before performing an update and then restoring the element.\n     * @return {Object}\n     */\n    getPositioning : function(){\n        var styles = this.getStyle([LEFT, TOP, POSITION, RIGHT, BOTTOM, ZINDEX]);\n        styles[RIGHT] =  styles[LEFT] ? '' : styles[RIGHT];\n        styles[BOTTOM] = styles[TOP] ? '' : styles[BOTTOM];\n        return styles;\n    },\n\n    /**\n     * Set positioning with an object returned by #getPositioning.\n     * @param {Object} posCfg\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setPositioning : function(pc) {\n        var me = this,\n            style = me.dom.style;\n\n        me.setStyle(pc);\n\n        if (pc.right == AUTO) {\n            style.right = \"\";\n        }\n        if (pc.bottom == AUTO) {\n            style.bottom = \"\";\n        }\n\n        return me;\n    },\n\n    /**\n     * Move this element relative to its current position.\n     * @param {String} direction Possible values are:\n     *\n     * - `\"l\"` (or `\"left\"`)\n     * - `\"r\"` (or `\"right\"`)\n     * - `\"t\"` (or `\"top\"`, or `\"up\"`)\n     * - `\"b\"` (or `\"bottom\"`, or `\"down\"`)\n     *\n     * @param {Number} distance How far to move the element in pixels\n     * @param {Boolean/Object} [animate] true for the default animation or a standard Element\n     * animation config object\n     */\n    move: function(direction, distance, animate) {\n        var me = this,\n            xy = me.getXY(),\n            x = xy[0],\n            y = xy[1],\n            left = [x - distance, y],\n            right = [x + distance, y],\n            top = [x, y - distance],\n            bottom = [x, y + distance],\n            hash = {\n                l: left,\n                left: left,\n                r: right,\n                right: right,\n                t: top,\n                top: top,\n                up: top,\n                b: bottom,\n                bottom: bottom,\n                down: bottom\n            };\n\n        direction = direction.toLowerCase();\n        me.moveTo(hash[direction][0], hash[direction][1], animate);\n    },\n\n    /**\n     * Conveniently sets left and top adding default units.\n     * @param {String} left The left CSS property value\n     * @param {String} top The top CSS property value\n     * @return {Ext.dom.Element} this\n     */\n    setLeftTop: function(left, top) {\n        var style = this.dom.style;\n\n        style.left = Element.addUnits(left);\n        style.top = Element.addUnits(top);\n\n        return this;\n    },\n\n    /**\n     * Returns the region of this element.\n     * The element must be part of the DOM tree to have a region\n     * (display:none or elements not appended return false).\n     * @return {Ext.util.Region} A Region containing \"top, left, bottom, right\" member data.\n     */\n    getRegion: function() {\n        return this.getPageBox(true);\n    },\n\n    /**\n     * Returns the **content** region of this element. That is the region within the borders and padding.\n     * @return {Ext.util.Region} A Region containing \"top, left, bottom, right\" member data.\n     */\n    getViewRegion: function() {\n        var me = this,\n            isBody = me.dom.nodeName == BODY,\n            scroll, pos, top, left, width, height;\n\n        // For the body we want to do some special logic\n        if (isBody) {\n            scroll = me.getScroll();\n            left = scroll.left;\n            top = scroll.top;\n            width = Ext.dom.AbstractElement.getViewportWidth();\n            height = Ext.dom.AbstractElement.getViewportHeight();\n        }\n        else {\n            pos = me.getXY();\n            left = pos[0] + me.getBorderWidth('l') + me.getPadding('l');\n            top = pos[1] + me.getBorderWidth('t') + me.getPadding('t');\n            width = me.getWidth(true);\n            height = me.getHeight(true);\n        }\n\n        return new Ext.util.Region(top, left + width - 1, top + height - 1, left);\n    },\n\n    /**\n     * Sets the element's position and size in one shot. If animation is true then width, height,\n     * x and y will be animated concurrently.\n     *\n     * @param {Number} x X value for new position (coordinates are page-based)\n     * @param {Number} y Y value for new position (coordinates are page-based)\n     * @param {Number/String} width The new width. This may be one of:\n     *\n     * - A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels)\n     * - A String used to set the CSS width style. Animation may **not** be used.\n     *\n     * @param {Number/String} height The new height. This may be one of:\n     *\n     * - A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels)\n     * - A String used to set the CSS height style. Animation may **not** be used.\n     *\n     * @param {Boolean/Object} [animate] true for the default animation or a standard Element\n     * animation config object\n     *\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setBounds: function(x, y, width, height, animate) {\n        var me = this;\n        if (!animate || !me.anim) {\n            me.setSize(width, height);\n            me.setLocation(x, y);\n        } else {\n            if (!Ext.isObject(animate)) {\n                animate = {};\n            }\n            me.animate(Ext.applyIf({\n                to: {\n                    x: x,\n                    y: y,\n                    width: me.adjustWidth(width),\n                    height: me.adjustHeight(height)\n                }\n            }, animate));\n        }\n        return me;\n    },\n\n    /**\n     * Sets the element's position and size the specified region. If animation is true then width, height,\n     * x and y will be animated concurrently.\n     *\n     * @param {Ext.util.Region} region The region to fill\n     * @param {Boolean/Object} [animate] true for the default animation or a standard Element\n     * animation config object\n     * @return {Ext.dom.AbstractElement} this\n     */\n    setRegion: function(region, animate) {\n        return this.setBounds(region.left, region.top, region.right - region.left, region.bottom - region.top, animate);\n    }\n});\n\n}());\n\n\n//@tag dom,core\n//@require Ext.dom.Element-position\n//@define Ext.dom.Element-scroll\n//@define Ext.dom.Element\n\n/**\n * @class Ext.dom.Element\n */\nExt.dom.Element.override({\n    /**\n     * Returns true if this element is scrollable.\n     * @return {Boolean}\n     */\n    isScrollable: function() {\n        var dom = this.dom;\n        return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;\n    },\n\n    /**\n     * Returns the current scroll position of the element.\n     * @return {Object} An object containing the scroll position in the format\n     * `{left: (scrollLeft), top: (scrollTop)}`\n     */\n    getScroll: function() {\n        var d = this.dom,\n            doc = document,\n            body = doc.body,\n            docElement = doc.documentElement,\n            l,\n            t,\n            ret;\n\n        if (d == doc || d == body) {\n            if (Ext.isIE && Ext.isStrict) {\n                l = docElement.scrollLeft;\n                t = docElement.scrollTop;\n            } else {\n                l = window.pageXOffset;\n                t = window.pageYOffset;\n            }\n            ret = {\n                left: l || (body ? body.scrollLeft : 0),\n                top : t || (body ? body.scrollTop : 0)\n            };\n        } else {\n            ret = {\n                left: d.scrollLeft,\n                top : d.scrollTop\n            };\n        }\n\n        return ret;\n    },\n\n    /**\n     * Scrolls this element by the passed delta values, optionally animating.\n     * \n     * All of the following are equivalent:\n     *\n     *      el.scrollBy(10, 10, true);\n     *      el.scrollBy([10, 10], true);\n     *      el.scrollBy({ x: 10, y: 10 }, true);\n     * \n     * @param {Number/Number[]/Object} deltaX Either the x delta, an Array specifying x and y deltas or\n     * an object with \"x\" and \"y\" properties.\n     * @param {Number/Boolean/Object} deltaY Either the y delta, or an animate flag or config object.\n     * @param {Boolean/Object} animate Animate flag/config object if the delta values were passed separately.\n     * @return {Ext.Element} this\n     */\n    scrollBy: function(deltaX, deltaY, animate) {\n        var me = this,\n            dom = me.dom;\n\n        // Extract args if deltas were passed as an Array.\n        if (deltaX.length) {\n            animate = deltaY;\n            deltaY = deltaX[1];\n            deltaX = deltaX[0];\n        } else if (typeof deltaX != 'number') { // or an object\n            animate = deltaY;\n            deltaY = deltaX.y;\n            deltaX = deltaX.x;\n        }\n\n        if (deltaX) {\n            me.scrollTo('left', Math.max(Math.min(dom.scrollLeft + deltaX, dom.scrollWidth - dom.clientWidth), 0), animate);\n        }\n        if (deltaY) {\n            me.scrollTo('top', Math.max(Math.min(dom.scrollTop + deltaY, dom.scrollHeight - dom.clientHeight), 0), animate);\n        }\n\n        return me;\n    },\n\n    /**\n     * Scrolls this element the specified scroll point. It does NOT do bounds checking so\n     * if you scroll to a weird value it will try to do it. For auto bounds checking, use #scroll.\n     * @param {String} side Either \"left\" for scrollLeft values or \"top\" for scrollTop values.\n     * @param {Number} value The new scroll value\n     * @param {Boolean/Object} [animate] true for the default animation or a standard Element\n     * animation config object\n     * @return {Ext.Element} this\n     */\n    scrollTo: function(side, value, animate) {\n        //check if we're scrolling top or left\n        var top = /top/i.test(side),\n            me = this,\n            dom = me.dom,\n            animCfg,\n            prop;\n\n        if (!animate || !me.anim) {\n            // just setting the value, so grab the direction\n            prop = 'scroll' + (top ? 'Top' : 'Left');\n            dom[prop] = value;\n            // corrects IE, other browsers will ignore\n            dom[prop] = value;\n        }\n        else {\n            animCfg = {\n                to: {}\n            };\n            animCfg.to['scroll' + (top ? 'Top' : 'Left')] = value;\n            if (Ext.isObject(animate)) {\n                Ext.applyIf(animCfg, animate);\n            }\n            me.animate(animCfg);\n        }\n        return me;\n    },\n\n    /**\n     * Scrolls this element into view within the passed container.\n     * @param {String/HTMLElement/Ext.Element} [container=document.body] The container element\n     * to scroll.  Should be a string (id), dom node, or Ext.Element.\n     * @param {Boolean} [hscroll=true] False to disable horizontal scroll.\n     * @param {Boolean/Object} [animate] true for the default animation or a standard Element\n     * animation config object\n     * @return {Ext.dom.Element} this\n     */\n    scrollIntoView: function(container, hscroll, animate) {\n        container = Ext.getDom(container) || Ext.getBody().dom;\n        var el = this.dom,\n            offsets = this.getOffsetsTo(container),\n        // el's box\n            left = offsets[0] + container.scrollLeft,\n            top = offsets[1] + container.scrollTop,\n            bottom = top + el.offsetHeight,\n            right = left + el.offsetWidth,\n        // ct's box\n            ctClientHeight = container.clientHeight,\n            ctScrollTop = parseInt(container.scrollTop, 10),\n            ctScrollLeft = parseInt(container.scrollLeft, 10),\n            ctBottom = ctScrollTop + ctClientHeight,\n            ctRight = ctScrollLeft + container.clientWidth,\n            newPos;\n\n        if (el.offsetHeight > ctClientHeight || top < ctScrollTop) {\n            newPos = top;\n        } else if (bottom > ctBottom) {\n            newPos = bottom - ctClientHeight;\n        }\n        if (newPos != null) {\n            Ext.get(container).scrollTo('top', newPos, animate);\n        }\n\n        if (hscroll !== false) {\n            newPos = null;\n            if (el.offsetWidth > container.clientWidth || left < ctScrollLeft) {\n                newPos = left;\n            } else if (right > ctRight) {\n                newPos = right - container.clientWidth;\n            }\n            if (newPos != null) {\n                Ext.get(container).scrollTo('left', newPos, animate);\n            }\n        }\n        return this;\n    },\n\n    // @private\n    scrollChildIntoView: function(child, hscroll) {\n        Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);\n    },\n\n    /**\n     * Scrolls this element the specified direction. Does bounds checking to make sure the scroll is\n     * within this element's scrollable range.\n     * @param {String} direction Possible values are:\n     *\n     * - `\"l\"` (or `\"left\"`)\n     * - `\"r\"` (or `\"right\"`)\n     * - `\"t\"` (or `\"top\"`, or `\"up\"`)\n     * - `\"b\"` (or `\"bottom\"`, or `\"down\"`)\n     *\n     * @param {Number} distance How far to scroll the element in pixels\n     * @param {Boolean/Object} [animate] true for the default animation or a standard Element\n     * animation config object\n     * @return {Boolean} Returns true if a scroll was triggered or false if the element\n     * was scrolled as far as it could go.\n     */\n    scroll: function(direction, distance, animate) {\n        if (!this.isScrollable()) {\n            return false;\n        }\n        var el = this.dom,\n            l = el.scrollLeft, t = el.scrollTop,\n            w = el.scrollWidth, h = el.scrollHeight,\n            cw = el.clientWidth, ch = el.clientHeight,\n            scrolled = false, v,\n            hash = {\n                l: Math.min(l + distance, w - cw),\n                r: v = Math.max(l - distance, 0),\n                t: Math.max(t - distance, 0),\n                b: Math.min(t + distance, h - ch)\n            };\n\n        hash.d = hash.b;\n        hash.u = hash.t;\n\n        direction = direction.substr(0, 1);\n        if ((v = hash[direction]) > -1) {\n            scrolled = true;\n            this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.anim(animate));\n        }\n        return scrolled;\n    }\n});\n\n//@tag dom,core\n//@require Ext.dom.Element-scroll\n//@define Ext.dom.Element-style\n//@define Ext.dom.Element\n\n/**\n * @class Ext.dom.Element\n */\n(function() {\n\nvar Element = Ext.dom.Element,\n    view = document.defaultView,\n    adjustDirect2DTableRe = /table-row|table-.*-group/,\n    INTERNAL = '_internal',\n    HIDDEN = 'hidden',\n    HEIGHT = 'height',\n    WIDTH = 'width',\n    ISCLIPPED = 'isClipped',\n    OVERFLOW = 'overflow',\n    OVERFLOWX = 'overflow-x',\n    OVERFLOWY = 'overflow-y',\n    ORIGINALCLIP = 'originalClip',\n    DOCORBODYRE = /#document|body/i,\n    // This reduces the lookup of 'me.styleHooks' by one hop in the prototype chain. It is\n    // the same object.\n    styleHooks,\n    edges, k, edge, borderWidth;\n\nif (!view || !view.getComputedStyle) {\n    Element.prototype.getStyle = function (property, inline) {\n        var me = this,\n            dom = me.dom,\n            multiple = typeof property != 'string',\n            hooks = me.styleHooks,\n            prop = property,\n            props = prop,\n            len = 1,\n            isInline = inline,\n            camel, domStyle, values, hook, out, style, i;\n\n        if (multiple) {\n            values = {};\n            prop = props[0];\n            i = 0;\n            if (!(len = props.length)) {\n                return values;\n            }\n        }\n\n        if (!dom || dom.documentElement) {\n            return values || '';\n        }\n\n        domStyle = dom.style;\n\n        if (inline) {\n            style = domStyle;\n        } else {\n            style = dom.currentStyle;\n\n            // fallback to inline style if rendering context not available\n            if (!style) {\n                isInline = true;\n                style = domStyle;\n            }\n        }\n\n        do {\n            hook = hooks[prop];\n\n            if (!hook) {\n                hooks[prop] = hook = { name: Element.normalize(prop) };\n            }\n\n            if (hook.get) {\n                out = hook.get(dom, me, isInline, style);\n            } else {\n                camel = hook.name;\n\n                // In some cases, IE6 will throw Invalid Argument exceptions for properties\n                // like fontSize (/examples/tabs/tabs.html in 4.0 used to exhibit this but\n                // no longer does due to font style changes). There is a real cost to a try\n                // block, so we avoid it where possible...\n                if (hook.canThrow) {\n                    try {\n                        out = style[camel];\n                    } catch (e) {\n                        out = '';\n                    }\n                } else {\n                    // EXTJSIV-5657 - In IE9 quirks mode there is a chance that VML root element \n                    // has neither `currentStyle` nor `style`. Return '' this case.\n                    out = style ? style[camel] : '';\n                }\n            }\n\n            if (!multiple) {\n                return out;\n            }\n\n            values[prop] = out;\n            prop = props[++i];\n        } while (i < len);\n\n        return values;\n    };\n}\n\nElement.override({\n    getHeight: function(contentHeight, preciseHeight) {\n        var me = this,\n            dom = me.dom,\n            hidden = me.isStyle('display', 'none'),\n            height,\n            floating;\n\n        if (hidden) {\n            return 0;\n        }\n\n        height = Math.max(dom.offsetHeight, dom.clientHeight) || 0;\n\n        // IE9 Direct2D dimension rounding bug\n        if (Ext.supports.Direct2DBug) {\n            floating = me.adjustDirect2DDimension(HEIGHT);\n            if (preciseHeight) {\n                height += floating;\n            }\n            else if (floating > 0 && floating < 0.5) {\n                height++;\n            }\n        }\n\n        if (contentHeight) {\n            height -= me.getBorderWidth(\"tb\") + me.getPadding(\"tb\");\n        }\n\n        return (height < 0) ? 0 : height;\n    },\n\n    getWidth: function(contentWidth, preciseWidth) {\n        var me = this,\n            dom = me.dom,\n            hidden = me.isStyle('display', 'none'),\n            rect, width, floating;\n\n        if (hidden) {\n            return 0;\n        }\n\n        // Gecko will in some cases report an offsetWidth that is actually less than the width of the\n        // text contents, because it measures fonts with sub-pixel precision but rounds the calculated\n        // value down. Using getBoundingClientRect instead of offsetWidth allows us to get the precise\n        // subpixel measurements so we can force them to always be rounded up. See\n        // https://bugzilla.mozilla.org/show_bug.cgi?id=458617\n        // Rounding up ensures that the width includes the full width of the text contents.\n        if (Ext.supports.BoundingClientRect) {\n            rect = dom.getBoundingClientRect();\n            width = rect.right - rect.left;\n            width = preciseWidth ? width : Math.ceil(width);\n        } else {\n            width = dom.offsetWidth;\n        }\n\n        width = Math.max(width, dom.clientWidth) || 0;\n\n        // IE9 Direct2D dimension rounding bug\n        if (Ext.supports.Direct2DBug) {\n            // get the fractional portion of the sub-pixel precision width of the element's text contents\n            floating = me.adjustDirect2DDimension(WIDTH);\n            if (preciseWidth) {\n                width += floating;\n            }\n            // IE9 also measures fonts with sub-pixel precision, but unlike Gecko, instead of rounding the offsetWidth down,\n            // it rounds to the nearest integer. This means that in order to ensure that the width includes the full\n            // width of the text contents we need to increment the width by 1 only if the fractional portion is less than 0.5\n            else if (floating > 0 && floating < 0.5) {\n                width++;\n            }\n        }\n\n        if (contentWidth) {\n            width -= me.getBorderWidth(\"lr\") + me.getPadding(\"lr\");\n        }\n\n        return (width < 0) ? 0 : width;\n    },\n\n    setWidth: function(width, animate) {\n        var me = this;\n        width = me.adjustWidth(width);\n        if (!animate || !me.anim) {\n            me.dom.style.width = me.addUnits(width);\n        }\n        else {\n            if (!Ext.isObject(animate)) {\n                animate = {};\n            }\n            me.animate(Ext.applyIf({\n                to: {\n                    width: width\n                }\n            }, animate));\n        }\n        return me;\n    },\n\n    setHeight : function(height, animate) {\n        var me = this;\n\n        height = me.adjustHeight(height);\n        if (!animate || !me.anim) {\n            me.dom.style.height = me.addUnits(height);\n        }\n        else {\n            if (!Ext.isObject(animate)) {\n                animate = {};\n            }\n            me.animate(Ext.applyIf({\n                to: {\n                    height: height\n                }\n            }, animate));\n        }\n\n        return me;\n    },\n\n    applyStyles: function(style) {\n        Ext.DomHelper.applyStyles(this.dom, style);\n        return this;\n    },\n\n    setSize: function(width, height, animate) {\n        var me = this;\n\n        if (Ext.isObject(width)) { // in case of object from getSize()\n            animate = height;\n            height = width.height;\n            width = width.width;\n        }\n\n        width = me.adjustWidth(width);\n        height = me.adjustHeight(height);\n\n        if (!animate || !me.anim) {\n            me.dom.style.width = me.addUnits(width);\n            me.dom.style.height = me.addUnits(height);\n        }\n        else {\n            if (animate === true) {\n                animate = {};\n            }\n            me.animate(Ext.applyIf({\n                to: {\n                    width: width,\n                    height: height\n                }\n            }, animate));\n        }\n\n        return me;\n    },\n\n    getViewSize : function() {\n        var me = this,\n            dom = me.dom,\n            isDoc = DOCORBODYRE.test(dom.nodeName),\n            ret;\n\n        // If the body, use static methods\n        if (isDoc) {\n            ret = {\n                width : Element.getViewWidth(),\n                height : Element.getViewHeight()\n            };\n        } else {\n            ret = {\n                width : dom.clientWidth,\n                height : dom.clientHeight\n            };\n        }\n\n        return ret;\n    },\n\n    getSize: function(contentSize) {\n        return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};\n    },\n\n    // TODO: Look at this\n\n    // private  ==> used by Fx\n    adjustWidth : function(width) {\n        var me = this,\n            isNum = (typeof width == 'number');\n\n        if (isNum && me.autoBoxAdjust && !me.isBorderBox()) {\n            width -= (me.getBorderWidth(\"lr\") + me.getPadding(\"lr\"));\n        }\n        return (isNum && width < 0) ? 0 : width;\n    },\n\n    // private   ==> used by Fx\n    adjustHeight : function(height) {\n        var me = this,\n            isNum = (typeof height == \"number\");\n\n        if (isNum && me.autoBoxAdjust && !me.isBorderBox()) {\n            height -= (me.getBorderWidth(\"tb\") + me.getPadding(\"tb\"));\n        }\n        return (isNum && height < 0) ? 0 : height;\n    },\n\n    /**\n     * Return the CSS color for the specified CSS attribute. rgb, 3 digit (like `#fff`) and valid values\n     * are convert to standard 6 digit hex color.\n     * @param {String} attr The css attribute\n     * @param {String} defaultValue The default value to use when a valid color isn't found\n     * @param {String} [prefix] defaults to #. Use an empty string when working with\n     * color anims.\n     */\n    getColor : function(attr, defaultValue, prefix) {\n        var v = this.getStyle(attr),\n            color = prefix || prefix === '' ? prefix : '#',\n            h, len, i=0;\n\n        if (!v || (/transparent|inherit/.test(v))) {\n            return defaultValue;\n        }\n        if (/^r/.test(v)) {\n             v = v.slice(4, v.length - 1).split(',');\n             len = v.length;\n             for (; i<len; i++) {\n                h = parseInt(v[i], 10);\n                color += (h < 16 ? '0' : '') + h.toString(16);\n            }\n        } else {\n            v = v.replace('#', '');\n            color += v.length == 3 ? v.replace(/^(\\w)(\\w)(\\w)$/, '$1$1$2$2$3$3') : v;\n        }\n        return(color.length > 5 ? color.toLowerCase() : defaultValue);\n    },\n\n    /**\n     * Set the opacity of the element\n     * @param {Number} opacity The new opacity. 0 = transparent, .5 = 50% visibile, 1 = fully visible, etc\n     * @param {Boolean/Object} [animate] a standard Element animation config object or `true` for\n     * the default animation (`{duration: 350, easing: 'easeIn'}`)\n     * @return {Ext.dom.Element} this\n     */\n    setOpacity: function(opacity, animate) {\n        var me = this;\n\n        if (!me.dom) {\n            return me;\n        }\n\n        if (!animate || !me.anim) {\n            me.setStyle('opacity', opacity);\n        }\n        else {\n            if (typeof animate != 'object') {\n                animate = {\n                    duration: 350,\n                    easing: 'ease-in'\n                };\n            }\n\n            me.animate(Ext.applyIf({\n                to: {\n                    opacity: opacity\n                }\n            }, animate));\n        }\n        return me;\n    },\n\n    /**\n     * Clears any opacity settings from this element. Required in some cases for IE.\n     * @return {Ext.dom.Element} this\n     */\n    clearOpacity : function() {\n        return this.setOpacity('');\n    },\n\n    /**\n     * @private\n     * Returns 1 if the browser returns the subpixel dimension rounded to the lowest pixel.\n     * @return {Number} 0 or 1\n     */\n    adjustDirect2DDimension: function(dimension) {\n        var me = this,\n            dom = me.dom,\n            display = me.getStyle('display'),\n            inlineDisplay = dom.style.display,\n            inlinePosition = dom.style.position,\n            originIndex = dimension === WIDTH ? 0 : 1,\n            currentStyle = dom.currentStyle,\n            floating;\n\n        if (display === 'inline') {\n            dom.style.display = 'inline-block';\n        }\n\n        dom.style.position = display.match(adjustDirect2DTableRe) ? 'absolute' : 'static';\n\n        // floating will contain digits that appears after the decimal point\n        // if height or width are set to auto we fallback to msTransformOrigin calculation\n        \n        // Use currentStyle here instead of getStyle. In some difficult to reproduce \n        // instances it resets the scrollWidth of the element\n        floating = (parseFloat(currentStyle[dimension]) || parseFloat(currentStyle.msTransformOrigin.split(' ')[originIndex]) * 2) % 1;\n\n        dom.style.position = inlinePosition;\n\n        if (display === 'inline') {\n            dom.style.display = inlineDisplay;\n        }\n\n        return floating;\n    },\n\n    /**\n     * Store the current overflow setting and clip overflow on the element - use {@link #unclip} to remove\n     * @return {Ext.dom.Element} this\n     */\n    clip : function() {\n        var me = this,\n            data = (me.$cache || me.getCache()).data,\n            style;\n\n        if (!data[ISCLIPPED]) {\n            data[ISCLIPPED] = true;\n            style = me.getStyle([OVERFLOW, OVERFLOWX, OVERFLOWY]);\n            data[ORIGINALCLIP] = {\n                o: style[OVERFLOW],\n                x: style[OVERFLOWX],\n                y: style[OVERFLOWY]\n            };\n            me.setStyle(OVERFLOW, HIDDEN);\n            me.setStyle(OVERFLOWX, HIDDEN);\n            me.setStyle(OVERFLOWY, HIDDEN);\n        }\n        return me;\n    },\n\n    /**\n     * Return clipping (overflow) to original clipping before {@link #clip} was called\n     * @return {Ext.dom.Element} this\n     */\n    unclip : function() {\n        var me = this,\n            data = (me.$cache || me.getCache()).data,\n            clip;\n\n        if (data[ISCLIPPED]) {\n            data[ISCLIPPED] = false;\n            clip = data[ORIGINALCLIP];\n            if (clip.o) {\n                me.setStyle(OVERFLOW, clip.o);\n            }\n            if (clip.x) {\n                me.setStyle(OVERFLOWX, clip.x);\n            }\n            if (clip.y) {\n                me.setStyle(OVERFLOWY, clip.y);\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Wraps the specified element with a special 9 element markup/CSS block that renders by default as\n     * a gray container with a gradient background, rounded corners and a 4-way shadow.\n     *\n     * This special markup is used throughout Ext when box wrapping elements ({@link Ext.button.Button},\n     * {@link Ext.panel.Panel} when {@link Ext.panel.Panel#frame frame=true}, {@link Ext.window.Window}).\n     * The markup is of this form:\n     *\n     *     Ext.dom.Element.boxMarkup =\n     *     '<div class=\"{0}-tl\"><div class=\"{0}-tr\"><div class=\"{0}-tc\"></div></div></div>\n     *     <div class=\"{0}-ml\"><div class=\"{0}-mr\"><div class=\"{0}-mc\"></div></div></div>\n     *     <div class=\"{0}-bl\"><div class=\"{0}-br\"><div class=\"{0}-bc\"></div></div></div>';\n     *\n     * Example usage:\n     *\n     *     // Basic box wrap\n     *     Ext.get(\"foo\").boxWrap();\n     *\n     *     // You can also add a custom class and use CSS inheritance rules to customize the box look.\n     *     // 'x-box-blue' is a built-in alternative -- look at the related CSS definitions as an example\n     *     // for how to create a custom box wrap style.\n     *     Ext.get(\"foo\").boxWrap().addCls(\"x-box-blue\");\n     *\n     * @param {String} [class='x-box'] A base CSS class to apply to the containing wrapper element.\n     * Note that there are a number of CSS rules that are dependent on this name to make the overall effect work,\n     * so if you supply an alternate base class, make sure you also supply all of the necessary rules.\n     * @return {Ext.dom.Element} The outermost wrapping element of the created box structure.\n     */\n    boxWrap : function(cls) {\n        cls = cls || Ext.baseCSSPrefix + 'box';\n        var el = Ext.get(this.insertHtml(\"beforeBegin\", \"<div class='\" + cls + \"'>\" + Ext.String.format(Element.boxMarkup, cls) + \"</div>\"));\n        Ext.DomQuery.selectNode('.' + cls + '-mc', el.dom).appendChild(this.dom);\n        return el;\n    },\n\n    /**\n     * Returns either the offsetHeight or the height of this element based on CSS height adjusted by padding or borders\n     * when needed to simulate offsetHeight when offsets aren't available. This may not work on display:none elements\n     * if a height has not been set using CSS.\n     * @return {Number}\n     */\n    getComputedHeight : function() {\n        var me = this,\n            h = Math.max(me.dom.offsetHeight, me.dom.clientHeight);\n        if (!h) {\n            h = parseFloat(me.getStyle(HEIGHT)) || 0;\n            if (!me.isBorderBox()) {\n                h += me.getFrameWidth('tb');\n            }\n        }\n        return h;\n    },\n\n    /**\n     * Returns either the offsetWidth or the width of this element based on CSS width adjusted by padding or borders\n     * when needed to simulate offsetWidth when offsets aren't available. This may not work on display:none elements\n     * if a width has not been set using CSS.\n     * @return {Number}\n     */\n    getComputedWidth : function() {\n        var me = this,\n            w = Math.max(me.dom.offsetWidth, me.dom.clientWidth);\n\n        if (!w) {\n            w = parseFloat(me.getStyle(WIDTH)) || 0;\n            if (!me.isBorderBox()) {\n                w += me.getFrameWidth('lr');\n            }\n        }\n        return w;\n    },\n\n    /**\n     * Returns the sum width of the padding and borders for the passed \"sides\". See getBorderWidth()\n     * for more information about the sides.\n     * @param {String} sides\n     * @return {Number}\n     */\n    getFrameWidth : function(sides, onlyContentBox) {\n        return (onlyContentBox && this.isBorderBox()) ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));\n    },\n\n    /**\n     * Sets up event handlers to add and remove a css class when the mouse is over this element\n     * @param {String} className The class to add\n     * @param {Function} [testFn] A test function to execute before adding the class. The passed parameter\n     * will be the Element instance. If this functions returns false, the class will not be added.\n     * @param {Object} [scope] The scope to execute the testFn in.\n     * @return {Ext.dom.Element} this\n     */\n    addClsOnOver : function(className, testFn, scope) {\n        var me = this,\n            dom = me.dom,\n            hasTest = Ext.isFunction(testFn);\n            \n        me.hover(\n            function() {\n                if (hasTest && testFn.call(scope || me, me) === false) {\n                    return;\n                }\n                Ext.fly(dom, INTERNAL).addCls(className);\n            },\n            function() {\n                Ext.fly(dom, INTERNAL).removeCls(className);\n            }\n        );\n        return me;\n    },\n\n    /**\n     * Sets up event handlers to add and remove a css class when this element has the focus\n     * @param {String} className The class to add\n     * @param {Function} [testFn] A test function to execute before adding the class. The passed parameter\n     * will be the Element instance. If this functions returns false, the class will not be added.\n     * @param {Object} [scope] The scope to execute the testFn in.\n     * @return {Ext.dom.Element} this\n     */\n    addClsOnFocus : function(className, testFn, scope) {\n        var me = this,\n            dom = me.dom,\n            hasTest = Ext.isFunction(testFn);\n            \n        me.on(\"focus\", function() {\n            if (hasTest && testFn.call(scope || me, me) === false) {\n                return false;\n            }\n            Ext.fly(dom, INTERNAL).addCls(className);\n        });\n        me.on(\"blur\", function() {\n            Ext.fly(dom, INTERNAL).removeCls(className);\n        });\n        return me;\n    },\n\n    /**\n     * Sets up event handlers to add and remove a css class when the mouse is down and then up on this element (a click effect)\n     * @param {String} className The class to add\n     * @param {Function} [testFn] A test function to execute before adding the class. The passed parameter\n     * will be the Element instance. If this functions returns false, the class will not be added.\n     * @param {Object} [scope] The scope to execute the testFn in.\n     * @return {Ext.dom.Element} this\n     */\n    addClsOnClick : function(className, testFn, scope) {\n        var me = this,\n            dom = me.dom,\n            hasTest = Ext.isFunction(testFn);\n            \n        me.on(\"mousedown\", function() {\n            if (hasTest && testFn.call(scope || me, me) === false) {\n                return false;\n            }\n            Ext.fly(dom, INTERNAL).addCls(className);\n            var d = Ext.getDoc(),\n                fn = function() {\n                    Ext.fly(dom, INTERNAL).removeCls(className);\n                    d.removeListener(\"mouseup\", fn);\n                };\n            d.on(\"mouseup\", fn);\n        });\n        return me;\n    },\n\n    /**\n     * Returns the dimensions of the element available to lay content out in.\n     *\n     * getStyleSize utilizes prefers style sizing if present, otherwise it chooses the larger of offsetHeight/clientHeight and\n     * offsetWidth/clientWidth. To obtain the size excluding scrollbars, use getViewSize.\n     *\n     * Sizing of the document body is handled at the adapter level which handles special cases for IE and strict modes, etc.\n     *\n     * @return {Object} Object describing width and height.\n     * @return {Number} return.width\n     * @return {Number} return.height\n     */\n    getStyleSize : function() {\n        var me = this,\n            d = this.dom,\n            isDoc = DOCORBODYRE.test(d.nodeName),\n            s ,\n            w, h;\n\n        // If the body, use static methods\n        if (isDoc) {\n            return {\n                width : Element.getViewWidth(),\n                height : Element.getViewHeight()\n            };\n        }\n\n        s = me.getStyle([HEIGHT, WIDTH], true);  //seek inline\n        // Use Styles if they are set\n        if (s.width && s.width != 'auto') {\n            w = parseFloat(s.width);\n            if (me.isBorderBox()) {\n                w -= me.getFrameWidth('lr');\n            }\n        }\n        // Use Styles if they are set\n        if (s.height && s.height != 'auto') {\n            h = parseFloat(s.height);\n            if (me.isBorderBox()) {\n                h -= me.getFrameWidth('tb');\n            }\n        }\n        // Use getWidth/getHeight if style not set.\n        return {width: w || me.getWidth(true), height: h || me.getHeight(true)};\n    },\n\n    /**\n     * Enable text selection for this element (normalized across browsers)\n     * @return {Ext.Element} this\n     */\n    selectable : function() {\n        var me = this;\n        me.dom.unselectable = \"off\";\n        // Prevent it from bubles up and enables it to be selectable\n        me.on('selectstart', function (e) {\n            e.stopPropagation();\n            return true;\n        });\n        me.applyStyles(\"-moz-user-select: text; -khtml-user-select: text;\");\n        me.removeCls(Ext.baseCSSPrefix + 'unselectable');\n        return me;\n    },\n\n    /**\n     * Disables text selection for this element (normalized across browsers)\n     * @return {Ext.dom.Element} this\n     */\n    unselectable : function() {\n        var me = this;\n        me.dom.unselectable = \"on\";\n\n        me.swallowEvent(\"selectstart\", true);\n        me.applyStyles(\"-moz-user-select:-moz-none;-khtml-user-select:none;\");\n        me.addCls(Ext.baseCSSPrefix + 'unselectable');\n\n        return me;\n    }\n});\n\nElement.prototype.styleHooks = styleHooks = Ext.dom.AbstractElement.prototype.styleHooks;\n\nif (Ext.isIE6 || Ext.isIE7) {\n    styleHooks.fontSize = styleHooks['font-size'] = {\n        name: 'fontSize',\n        canThrow: true\n    };\n    \n    styleHooks.fontStyle = styleHooks['font-style'] = {\n        name: 'fontStyle',\n        canThrow: true\n    };\n    \n    styleHooks.fontFamily = styleHooks['font-family'] = {\n        name: 'fontFamily',\n        canThrow: true\n    };\n}\n\n// override getStyle for border-*-width\nif (Ext.isIEQuirks || Ext.isIE && Ext.ieVersion <= 8) {\n    function getBorderWidth (dom, el, inline, style) {\n        if (style[this.styleName] == 'none') {\n            return '0px';\n        }\n        return style[this.name];\n    }\n\n    edges = ['Top','Right','Bottom','Left'];\n    k = edges.length;\n\n    while (k--) {\n        edge = edges[k];\n        borderWidth = 'border' + edge + 'Width';\n\n        styleHooks['border-'+edge.toLowerCase()+'-width'] = styleHooks[borderWidth] = {\n            name: borderWidth,\n            styleName: 'border' + edge + 'Style',\n            get: getBorderWidth\n        };\n    }\n}\n\n}());\n\nExt.onReady(function () {\n    var opacityRe = /alpha\\(opacity=(.*)\\)/i,\n        trimRe = /^\\s+|\\s+$/g,\n        hooks = Ext.dom.Element.prototype.styleHooks;\n\n    // Ext.supports flags are not populated until onReady...\n    hooks.opacity = {\n        name: 'opacity',\n        afterSet: function(dom, value, el) {\n            if (el.isLayer) {\n                el.onOpacitySet(value);\n            }\n        }\n    };\n    if (!Ext.supports.Opacity && Ext.isIE) {\n        Ext.apply(hooks.opacity, {\n            get: function (dom) {\n                var filter = dom.style.filter,\n                    match, opacity;\n                if (filter.match) {\n                    match = filter.match(opacityRe);\n                    if (match) {\n                        opacity = parseFloat(match[1]);\n                        if (!isNaN(opacity)) {\n                            return opacity ? opacity / 100 : 0;\n                        }\n                    }\n                }\n                return 1;\n            },\n            set: function (dom, value) {\n                var style = dom.style,\n                    val = style.filter.replace(opacityRe, '').replace(trimRe, '');\n\n                style.zoom = 1; // ensure dom.hasLayout\n\n                // value can be a number or '' or null... so treat falsey as no opacity\n                if (typeof(value) == 'number' && value >= 0 && value < 1) {\n                    value *= 100;\n                    style.filter = val + (val.length ? ' ' : '') + 'alpha(opacity='+value+')';\n                } else {\n                    style.filter = val;\n                }\n            }  \n        });\n    }\n    // else there is no work around for the lack of opacity support. Should not be a\n    // problem given that this has been supported for a long time now...\n});\n\n//@tag dom,core\n//@require Ext.dom.Element-style\n//@define Ext.dom.Element-traversal\n//@define Ext.dom.Element\n\n/**\n * @class Ext.dom.Element\n */\nExt.dom.Element.override({\n    select: function(selector) {\n        return Ext.dom.Element.select(selector, false,  this.dom);\n    }\n});\n\n//@tag dom,core\n//@require Ext.dom.Element-traversal\n\n/**\n * This class encapsulates a *collection* of DOM elements, providing methods to filter members, or to perform collective\n * actions upon the whole set.\n *\n * Although they are not listed, this class supports all of the methods of {@link Ext.dom.Element} and\n * {@link Ext.fx.Anim}. The methods from these classes will be performed on all the elements in this collection.\n *\n * Example:\n *\n *     var els = Ext.select(\"#some-el div.some-class\");\n *     // or select directly from an existing element\n *     var el = Ext.get('some-el');\n *     el.select('div.some-class');\n *\n *     els.setWidth(100); // all elements become 100 width\n *     els.hide(true); // all elements fade out and hide\n *     // or\n *     els.setWidth(100).hide(true);\n */\nExt.define('Ext.dom.CompositeElementLite', {\n    alternateClassName: 'Ext.CompositeElementLite',\n\n    requires: ['Ext.dom.Element', 'Ext.dom.Query'],\n\n    statics: {\n        /**\n         * @private\n         * Copies all of the functions from Ext.dom.Element's prototype onto CompositeElementLite's prototype.\n         * This is called twice - once immediately below, and once again after additional Ext.dom.Element\n         * are added in Ext JS\n         */\n        importElementMethods: function() {\n            var name,\n                elementPrototype = Ext.dom.Element.prototype,\n                prototype = this.prototype;\n\n            for (name in elementPrototype) {\n                if (typeof elementPrototype[name] == 'function'){\n                    (function(key) {\n                        prototype[key] = prototype[key] || function() {\n                            return this.invoke(key, arguments);\n                        };\n                    }).call(prototype, name);\n\n                }\n            }\n        }\n    },\n\n    constructor: function(elements, root) {\n        /**\n         * @property {HTMLElement[]} elements\n         * The Array of DOM elements which this CompositeElement encapsulates.\n         *\n         * This will not *usually* be accessed in developers' code, but developers wishing to augment the capabilities\n         * of the CompositeElementLite class may use it when adding methods to the class.\n         *\n         * For example to add the `nextAll` method to the class to **add** all following siblings of selected elements,\n         * the code would be\n         *\n         *     Ext.override(Ext.dom.CompositeElementLite, {\n         *         nextAll: function() {\n         *             var elements = this.elements, i, l = elements.length, n, r = [], ri = -1;\n         *              \n         *             // Loop through all elements in this Composite, accumulating\n         *             // an Array of all siblings.\n         *             for (i = 0; i < l; i++) {\n         *                 for (n = elements[i].nextSibling; n; n = n.nextSibling) {\n         *                     r[++ri] = n;\n         *                 }\n         *             }\n         *              \n         *             // Add all found siblings to this Composite\n         *             return this.add(r);\n         *         }\n         *     });\n         *\n         * @readonly\n         */\n        this.elements = [];\n        this.add(elements, root);\n        this.el = new Ext.dom.AbstractElement.Fly();\n    },\n\n    /**\n     * @property {Boolean} isComposite\n     * `true` in this class to identify an object as an instantiated CompositeElement, or subclass thereof.\n     */\n    isComposite: true,\n\n    // private\n    getElement: function(el) {\n        // Set the shared flyweight dom property to the current element\n        return this.el.attach(el);\n    },\n\n    // private\n    transformElement: function(el) {\n        return Ext.getDom(el);\n    },\n\n    /**\n     * Returns the number of elements in this Composite.\n     * @return {Number}\n     */\n    getCount: function() {\n        return this.elements.length;\n    },\n\n    /**\n     * Adds elements to this Composite object.\n     * @param {HTMLElement[]/Ext.dom.CompositeElement} els Either an Array of DOM elements to add, or another Composite\n     * object who's elements should be added.\n     * @return {Ext.dom.CompositeElement} This Composite object.\n     */\n    add: function(els, root) {\n        var elements = this.elements,\n            i, ln;\n\n        if (!els) {\n            return this;\n        }\n\n        if (typeof els == \"string\") {\n            els = Ext.dom.Element.selectorFunction(els, root);\n        }\n        else if (els.isComposite) {\n            els = els.elements;\n        }\n        else if (!Ext.isIterable(els)) {\n            els = [els];\n        }\n\n        for (i = 0, ln = els.length; i < ln; ++i) {\n            elements.push(this.transformElement(els[i]));\n        }\n\n        return this;\n    },\n\n    invoke: function(fn, args) {\n        var elements = this.elements,\n            ln = elements.length,\n            element,\n            i;\n\n        fn = Ext.dom.Element.prototype[fn];\n        for (i = 0; i < ln; i++) {\n            element = elements[i];\n\n            if (element) {\n                fn.apply(this.getElement(element), args);\n            }\n        }\n        return this;\n    },\n\n    /**\n     * Returns a flyweight Element of the dom element object at the specified index\n     * @param {Number} index\n     * @return {Ext.dom.Element}\n     */\n    item: function(index) {\n        var el = this.elements[index],\n            out = null;\n\n        if (el) {\n            out = this.getElement(el);\n        }\n\n        return out;\n    },\n\n    // fixes scope with flyweight\n    addListener: function(eventName, handler, scope, opt) {\n        var els = this.elements,\n                len = els.length,\n                i, e;\n\n        for (i = 0; i < len; i++) {\n            e = els[i];\n            if (e) {\n                Ext.EventManager.on(e, eventName, handler, scope || e, opt);\n            }\n        }\n        return this;\n    },\n    /**\n     * Calls the passed function for each element in this composite.\n     * @param {Function} fn The function to call.\n     * @param {Ext.dom.Element} fn.el The current Element in the iteration. **This is the flyweight\n     * (shared) Ext.dom.Element instance, so if you require a a reference to the dom node, use el.dom.**\n     * @param {Ext.dom.CompositeElement} fn.c This Composite object.\n     * @param {Number} fn.index The zero-based index in the iteration.\n     * @param {Object} [scope] The scope (this reference) in which the function is executed.\n     * Defaults to the Element.\n     * @return {Ext.dom.CompositeElement} this\n     */\n    each: function(fn, scope) {\n        var me  = this,\n            els = me.elements,\n            len = els.length,\n            i, e;\n\n        for (i = 0; i < len; i++) {\n            e = els[i];\n            if (e) {\n                e = this.getElement(e);\n                if (fn.call(scope || e, e, me, i) === false) {\n                    break;\n                }\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Clears this Composite and adds the elements passed.\n     * @param {HTMLElement[]/Ext.dom.CompositeElement} els Either an array of DOM elements, or another Composite from which\n     * to fill this Composite.\n     * @return {Ext.dom.CompositeElement} this\n     */\n    fill: function(els) {\n        var me = this;\n        me.elements = [];\n        me.add(els);\n        return me;\n    },\n\n    /**\n     * Filters this composite to only elements that match the passed selector.\n     * @param {String/Function} selector A string CSS selector or a comparison function. The comparison function will be\n     * called with the following arguments:\n     * @param {Ext.dom.Element} selector.el The current DOM element.\n     * @param {Number} selector.index The current index within the collection.\n     * @return {Ext.dom.CompositeElement} this\n     */\n    filter: function(selector) {\n        var me  = this,\n            els = me.elements,\n            len = els.length,\n            out = [],\n            i = 0,\n            isFunc = typeof selector == 'function',\n            add,\n            el;\n\n        for (; i < len; i++) {\n            el = els[i];\n            add = false;\n            if (el) {\n                el = me.getElement(el);\n\n                if (isFunc) {\n                    add = selector.call(el, el, me, i) !== false;\n                } else {\n                    add = el.is(selector);\n                }\n                \n                if (add) {\n                    out.push(me.transformElement(el));\n                }\n            }\n        }\n\n        me.elements = out;\n        return me;\n    },\n\n    /**\n     * Find the index of the passed element within the composite collection.\n     * @param {String/HTMLElement/Ext.Element/Number} el The id of an element, or an Ext.dom.Element, or an HtmlElement\n     * to find within the composite collection.\n     * @return {Number} The index of the passed Ext.dom.Element in the composite collection, or -1 if not found.\n     */\n    indexOf: function(el) {\n        return Ext.Array.indexOf(this.elements, this.transformElement(el));\n    },\n\n    /**\n     * Replaces the specified element with the passed element.\n     * @param {String/HTMLElement/Ext.Element/Number} el The id of an element, the Element itself, the index of the\n     * element in this composite to replace.\n     * @param {String/Ext.Element} replacement The id of an element or the Element itself.\n     * @param {Boolean} [domReplace] True to remove and replace the element in the document too.\n     * @return {Ext.dom.CompositeElement} this\n     */\n    replaceElement: function(el, replacement, domReplace) {\n        var index = !isNaN(el) ? el : this.indexOf(el),\n                d;\n        if (index > -1) {\n            replacement = Ext.getDom(replacement);\n            if (domReplace) {\n                d = this.elements[index];\n                d.parentNode.insertBefore(replacement, d);\n                Ext.removeNode(d);\n            }\n            Ext.Array.splice(this.elements, index, 1, replacement);\n        }\n        return this;\n    },\n\n    /**\n     * Removes all elements.\n     */\n    clear: function() {\n        this.elements = [];\n    },\n\n    addElements: function(els, root) {\n        if (!els) {\n            return this;\n        }\n\n        if (typeof els == \"string\") {\n            els = Ext.dom.Element.selectorFunction(els, root);\n        }\n\n        var yels = this.elements,\n            eLen = els.length,\n            e;\n\n        for (e = 0; e < eLen; e++) {\n            yels.push(Ext.get(els[e]));\n        }\n\n        return this;\n    },\n\n    /**\n     * Returns the first Element\n     * @return {Ext.dom.Element}\n     */\n    first: function() {\n        return this.item(0);\n    },\n\n    /**\n     * Returns the last Element\n     * @return {Ext.dom.Element}\n     */\n    last: function() {\n        return this.item(this.getCount() - 1);\n    },\n\n    /**\n     * Returns true if this composite contains the passed element\n     * @param {String/HTMLElement/Ext.Element/Number} el The id of an element, or an Ext.Element, or an HtmlElement to\n     * find within the composite collection.\n     * @return {Boolean}\n     */\n    contains: function(el) {\n        return this.indexOf(el) != -1;\n    },\n\n    /**\n     * Removes the specified element(s).\n     * @param {String/HTMLElement/Ext.Element/Number} el The id of an element, the Element itself, the index of the\n     * element in this composite or an array of any of those.\n     * @param {Boolean} [removeDom] True to also remove the element from the document\n     * @return {Ext.dom.CompositeElement} this\n     */\n    removeElement: function(keys, removeDom) {\n        keys = [].concat(keys);\n\n        var me       = this,\n            elements = me.elements,\n            kLen     = keys.length,\n            val, el, k;\n\n        for (k = 0; k < kLen; k++) {\n            val = keys[k];\n\n            if ((el = (elements[val] || elements[val = me.indexOf(val)]))) {\n                if (removeDom) {\n                    if (el.dom) {\n                        el.remove();\n                    } else {\n                        Ext.removeNode(el);\n                    }\n                }\n                Ext.Array.erase(elements, val, 1);\n            }\n        }\n\n        return me;\n    }\n\n}, function() {\n    this.importElementMethods();\n\n    this.prototype.on = this.prototype.addListener;\n\n    if (Ext.DomQuery){\n        Ext.dom.Element.selectorFunction = Ext.DomQuery.select;\n    }\n\n    /**\n     * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods\n     * to be applied to many related elements in one statement through the returned\n     * {@link Ext.dom.CompositeElement CompositeElement} or\n     * {@link Ext.dom.CompositeElementLite CompositeElementLite} object.\n     * @param {String/HTMLElement[]} selector The CSS selector or an array of elements\n     * @param {HTMLElement/String} [root] The root element of the query or id of the root\n     * @return {Ext.dom.CompositeElementLite/Ext.dom.CompositeElement}\n     * @member Ext.dom.Element\n     * @method select\n     * @static\n     * @ignore\n     */\n   Ext.dom.Element.select = function(selector, root) {\n        var elements;\n\n        if (typeof selector == \"string\") {\n            elements = Ext.dom.Element.selectorFunction(selector, root);\n        }\n        else if (selector.length !== undefined) {\n            elements = selector;\n        }\n        else {\n            throw new Error(\"[Ext.select] Invalid selector specified: \" + selector);\n        }\n\n        return new Ext.CompositeElementLite(elements);\n    };\n\n    /**\n     * @member Ext\n     * @method select\n     * @inheritdoc Ext.dom.Element#select\n     * @ignore\n     */\n    Ext.select = function() {\n        return Ext.dom.Element.select.apply(Ext.dom.Element, arguments);\n    };\n});\n\n/**\n * This animation class is a mixin.\n *\n * Ext.util.Animate provides an API for the creation of animated transitions of properties and styles.\n * This class is used as a mixin and currently applied to {@link Ext.Element}, {@link Ext.CompositeElement},\n * {@link Ext.draw.Sprite}, {@link Ext.draw.CompositeSprite}, and {@link Ext.Component}.  Note that Components\n * have a limited subset of what attributes can be animated such as top, left, x, y, height, width, and\n * opacity (color, paddings, and margins can not be animated).\n *\n * ## Animation Basics\n *\n * All animations require three things - `easing`, `duration`, and `to` (the final end value for each property)\n * you wish to animate. Easing and duration are defaulted values specified below.\n * Easing describes how the intermediate values used during a transition will be calculated.\n * {@link Ext.fx.Anim#easing Easing} allows for a transition to change speed over its duration.\n * You may use the defaults for easing and duration, but you must always set a\n * {@link Ext.fx.Anim#to to} property which is the end value for all animations.\n *\n * Popular element 'to' configurations are:\n *\n *  - opacity\n *  - x\n *  - y\n *  - color\n *  - height\n *  - width\n *\n * Popular sprite 'to' configurations are:\n *\n *  - translation\n *  - path\n *  - scale\n *  - stroke\n *  - rotation\n *\n * The default duration for animations is 250 (which is a 1/4 of a second).  Duration is denoted in\n * milliseconds.  Therefore 1 second is 1000, 1 minute would be 60000, and so on. The default easing curve\n * used for all animations is 'ease'.  Popular easing functions are included and can be found in {@link Ext.fx.Anim#easing Easing}.\n *\n * For example, a simple animation to fade out an element with a default easing and duration:\n *\n *     var p1 = Ext.get('myElementId');\n *\n *     p1.animate({\n *         to: {\n *             opacity: 0\n *         }\n *     });\n *\n * To make this animation fade out in a tenth of a second:\n *\n *     var p1 = Ext.get('myElementId');\n *\n *     p1.animate({\n *        duration: 100,\n *         to: {\n *             opacity: 0\n *         }\n *     });\n *\n * ## Animation Queues\n *\n * By default all animations are added to a queue which allows for animation via a chain-style API.\n * For example, the following code will queue 4 animations which occur sequentially (one right after the other):\n *\n *     p1.animate({\n *         to: {\n *             x: 500\n *         }\n *     }).animate({\n *         to: {\n *             y: 150\n *         }\n *     }).animate({\n *         to: {\n *             backgroundColor: '#f00'  //red\n *         }\n *     }).animate({\n *         to: {\n *             opacity: 0\n *         }\n *     });\n *\n * You can change this behavior by calling the {@link Ext.util.Animate#syncFx syncFx} method and all\n * subsequent animations for the specified target will be run concurrently (at the same time).\n *\n *     p1.syncFx();  //this will make all animations run at the same time\n *\n *     p1.animate({\n *         to: {\n *             x: 500\n *         }\n *     }).animate({\n *         to: {\n *             y: 150\n *         }\n *     }).animate({\n *         to: {\n *             backgroundColor: '#f00'  //red\n *         }\n *     }).animate({\n *         to: {\n *             opacity: 0\n *         }\n *     });\n *\n * This works the same as:\n *\n *     p1.animate({\n *         to: {\n *             x: 500,\n *             y: 150,\n *             backgroundColor: '#f00'  //red\n *             opacity: 0\n *         }\n *     });\n *\n * The {@link Ext.util.Animate#stopAnimation stopAnimation} method can be used to stop any\n * currently running animations and clear any queued animations.\n *\n * ## Animation Keyframes\n *\n * You can also set up complex animations with {@link Ext.fx.Anim#keyframes keyframes} which follow the\n * CSS3 Animation configuration pattern. Note rotation, translation, and scaling can only be done for sprites.\n * The previous example can be written with the following syntax:\n *\n *     p1.animate({\n *         duration: 1000,  //one second total\n *         keyframes: {\n *             25: {     //from 0 to 250ms (25%)\n *                 x: 0\n *             },\n *             50: {   //from 250ms to 500ms (50%)\n *                 y: 0\n *             },\n *             75: {  //from 500ms to 750ms (75%)\n *                 backgroundColor: '#f00'  //red\n *             },\n *             100: {  //from 750ms to 1sec\n *                 opacity: 0\n *             }\n *         }\n *     });\n *\n * ## Animation Events\n *\n * Each animation you create has events for {@link Ext.fx.Anim#beforeanimate beforeanimate},\n * {@link Ext.fx.Anim#afteranimate afteranimate}, and {@link Ext.fx.Anim#lastframe lastframe}.\n * Keyframed animations adds an additional {@link Ext.fx.Animator#keyframe keyframe} event which\n * fires for each keyframe in your animation.\n *\n * All animations support the {@link Ext.util.Observable#listeners listeners} configuration to attact functions to these events.\n *\n *     startAnimate: function() {\n *         var p1 = Ext.get('myElementId');\n *         p1.animate({\n *            duration: 100,\n *             to: {\n *                 opacity: 0\n *             },\n *             listeners: {\n *                 beforeanimate:  function() {\n *                     // Execute my custom method before the animation\n *                     this.myBeforeAnimateFn();\n *                 },\n *                 afteranimate: function() {\n *                     // Execute my custom method after the animation\n *                     this.myAfterAnimateFn();\n *                 },\n *                 scope: this\n *         });\n *     },\n *     myBeforeAnimateFn: function() {\n *       // My custom logic\n *     },\n *     myAfterAnimateFn: function() {\n *       // My custom logic\n *     }\n *\n * Due to the fact that animations run asynchronously, you can determine if an animation is currently\n * running on any target by using the {@link Ext.util.Animate#getActiveAnimation getActiveAnimation}\n * method.  This method will return false if there are no active animations or return the currently\n * running {@link Ext.fx.Anim} instance.\n *\n * In this example, we're going to wait for the current animation to finish, then stop any other\n * queued animations before we fade our element's opacity to 0:\n *\n *     var curAnim = p1.getActiveAnimation();\n *     if (curAnim) {\n *         curAnim.on('afteranimate', function() {\n *             p1.stopAnimation();\n *             p1.animate({\n *                 to: {\n *                     opacity: 0\n *                 }\n *             });\n *         });\n *     }\n */\nExt.define('Ext.util.Animate', {\n    requires: ['Ext.Element', 'Ext.CompositeElementLite'],\n    uses: ['Ext.fx.Manager', 'Ext.fx.Anim'],\n\n    /**\n     * Performs custom animation on this object.\n     *\n     * This method is applicable to both the {@link Ext.Component Component} class and the {@link Ext.draw.Sprite Sprite}\n     * class. It performs animated transitions of certain properties of this object over a specified timeline.\n     *\n     * ### Animating a {@link Ext.Component Component}\n     *\n     * When animating a Component, the following properties may be specified in `from`, `to`, and `keyframe` objects:\n     *\n     *   - `x` - The Component's page X position in pixels.\n     *\n     *   - `y` - The Component's page Y position in pixels\n     *\n     *   - `left` - The Component's `left` value in pixels.\n     *\n     *   - `top` - The Component's `top` value in pixels.\n     *\n     *   - `width` - The Component's `width` value in pixels.\n     *\n     *   - `width` - The Component's `width` value in pixels.\n     *\n     *   - `dynamic` - Specify as true to update the Component's layout (if it is a Container) at every frame of the animation.\n     *     *Use sparingly as laying out on every intermediate size change is an expensive operation.*\n     *\n     * For example, to animate a Window to a new size, ensuring that its internal layout and any shadow is correct:\n     *\n     *     myWindow = Ext.create('Ext.window.Window', {\n     *         title: 'Test Component animation',\n     *         width: 500,\n     *         height: 300,\n     *         layout: {\n     *             type: 'hbox',\n     *             align: 'stretch'\n     *         },\n     *         items: [{\n     *             title: 'Left: 33%',\n     *             margins: '5 0 5 5',\n     *             flex: 1\n     *         }, {\n     *             title: 'Left: 66%',\n     *             margins: '5 5 5 5',\n     *             flex: 2\n     *         }]\n     *     });\n     *     myWindow.show();\n     *     myWindow.header.el.on('click', function() {\n     *         myWindow.animate({\n     *             to: {\n     *                 width: (myWindow.getWidth() == 500) ? 700 : 500,\n     *                 height: (myWindow.getHeight() == 300) ? 400 : 300\n     *             }\n     *         });\n     *     });\n     *\n     * For performance reasons, by default, the internal layout is only updated when the Window reaches its final `\"to\"`\n     * size. If dynamic updating of the Window's child Components is required, then configure the animation with\n     * `dynamic: true` and the two child items will maintain their proportions during the animation.\n     *\n     * @param {Object} config  Configuration for {@link Ext.fx.Anim}.\n     * Note that the {@link Ext.fx.Anim#to to} config is required.\n     * @return {Object} this\n     */\n    animate: function(animObj) {\n        var me = this;\n        if (Ext.fx.Manager.hasFxBlock(me.id)) {\n            return me;\n        }\n        Ext.fx.Manager.queueFx(new Ext.fx.Anim(me.anim(animObj)));\n        return this;\n    },\n\n    // @private - process the passed fx configuration.\n    anim: function(config) {\n        if (!Ext.isObject(config)) {\n            return (config) ? {} : false;\n        }\n\n        var me = this;\n\n        if (config.stopAnimation) {\n            me.stopAnimation();\n        }\n\n        Ext.applyIf(config, Ext.fx.Manager.getFxDefaults(me.id));\n\n        return Ext.apply({\n            target: me,\n            paused: true\n        }, config);\n    },\n\n    /**\n     * Stops any running effects and clears this object's internal effects queue if it contains any additional effects\n     * that haven't started yet.\n     * @deprecated 4.0 Replaced by {@link #stopAnimation}\n     * @return {Ext.Element} The Element\n     * @method\n     */\n    stopFx: Ext.Function.alias(Ext.util.Animate, 'stopAnimation'),\n\n    /**\n     * Stops any running effects and clears this object's internal effects queue if it contains any additional effects\n     * that haven't started yet.\n     * @return {Ext.Element} The Element\n     */\n    stopAnimation: function() {\n        Ext.fx.Manager.stopAnimation(this.id);\n        return this;\n    },\n\n    /**\n     * Ensures that all effects queued after syncFx is called on this object are run concurrently. This is the opposite\n     * of {@link #sequenceFx}.\n     * @return {Object} this\n     */\n    syncFx: function() {\n        Ext.fx.Manager.setFxDefaults(this.id, {\n            concurrent: true\n        });\n        return this;\n    },\n\n    /**\n     * Ensures that all effects queued after sequenceFx is called on this object are run in sequence. This is the\n     * opposite of {@link #syncFx}.\n     * @return {Object} this\n     */\n    sequenceFx: function() {\n        Ext.fx.Manager.setFxDefaults(this.id, {\n            concurrent: false\n        });\n        return this;\n    },\n\n    /**\n     * @deprecated 4.0 Replaced by {@link #getActiveAnimation}\n     * @inheritdoc Ext.util.Animate#getActiveAnimation\n     * @method\n     */\n    hasActiveFx: Ext.Function.alias(Ext.util.Animate, 'getActiveAnimation'),\n\n    /**\n     * Returns the current animation if this object has any effects actively running or queued, else returns false.\n     * @return {Ext.fx.Anim/Boolean} Anim if element has active effects, else false\n     */\n    getActiveAnimation: function() {\n        return Ext.fx.Manager.getActiveAnimation(this.id);\n    }\n}, function(){\n    // Apply Animate mixin manually until Element is defined in the proper 4.x way\n    Ext.applyIf(Ext.Element.prototype, this.prototype);\n    // We need to call this again so the animation methods get copied over to CE\n    Ext.CompositeElementLite.importElementMethods();\n});\n\n/**\n * This mixin enables classes to declare relationships to child elements and provides the\n * mechanics for acquiring the {@link Ext.Element elements} and storing them on an object\n * instance as properties.\n *\n * This class is used by {@link Ext.Component components} and {@link Ext.layout.container.Container container layouts} to\n * manage their child elements.\n * \n * A typical component that uses these features might look something like this:\n * \n *      Ext.define('Ext.ux.SomeComponent', {\n *          extend: 'Ext.Component',\n *          \n *          childEls: [\n *              'bodyEl'\n *          ],\n *          \n *          renderTpl: [\n *              '<div id=\"{id}-bodyEl\"></div>'\n *          ],\n *          \n *          // ...\n *      });\n * \n * The `childEls` array lists one or more relationships to child elements managed by the\n * component. The items in this array can be either of the following types:\n * \n * - String: the id suffix and property name in one. For example, \"bodyEl\" in the above\n * example means a \"bodyEl\" property will be added to the instance with the result of\n * {@link Ext#get} given \"componentId-bodyEl\" where \"componentId\" is the component instance's\n * id.\n * - Object: with a `name` property that names the instance property for the element, and\n * one of the following additional properties:\n *      - `id`: The full id of the child element.\n *      - `itemId`: The suffix part of the id to which \"componentId-\" is prepended.\n *      - `select`: A selector that will be passed to {@link Ext#select}.\n *      - `selectNode`: A selector that will be passed to {@link Ext.DomQuery#selectNode}.\n * \n * The example above could have used this instead to achieve the same result:\n *\n *      childEls: [\n *          { name: 'bodyEl', itemId: 'bodyEl' }\n *      ]\n *\n * When using `select`, the property will be an instance of {@link Ext.CompositeElement}. In\n * all other cases, the property will be an {@link Ext.Element} or `null` if not found.\n *\n * Care should be taken when using `select` or `selectNode` to find child elements. The\n * following issues should be considered:\n * \n * - Performance: using selectors can be slower than id lookup by a factor 10x or more.\n * - Over-selecting: selectors are applied after the DOM elements for all children have\n * been rendered, so selectors can match elements from child components (including nested\n * versions of the same component) accidentally.\n * \n * This above issues are most important when using `select` since it returns multiple\n * elements.\n *\n * **IMPORTANT** \n * Unlike a `renderTpl` where there is a single value for an instance, `childEls` are aggregated\n * up the class hierarchy so that they are effectively inherited. In other words, if a\n * class where to derive from `Ext.ux.SomeComponent` in the example above, it could also\n * have a `childEls` property in the same way as `Ext.ux.SomeComponent`.\n * \n *      Ext.define('Ext.ux.AnotherComponent', {\n *          extend: 'Ext.ux.SomeComponent',\n *          \n *          childEls: [\n *              // 'bodyEl' is inherited\n *              'innerEl'\n *          ],\n *          \n *          renderTpl: [\n *              '<div id=\"{id}-bodyEl\">'\n *                  '<div id=\"{id}-innerEl\"></div>'\n *              '</div>'\n *          ],\n *          \n *          // ...\n *      });\n * \n * The `renderTpl` contains both child elements and unites them in the desired markup, but\n * the `childEls` only contains the new child element. The {@link #applyChildEls} method\n * takes care of looking up all `childEls` for an instance and considers `childEls`\n * properties on all the super classes and mixins.\n * \n * @private\n */\nExt.define('Ext.util.ElementContainer', {\n\n    childEls: [\n        // empty - this solves a couple problems:\n        //  1. It ensures that all classes have a childEls (avoid null ptr)\n        //  2. It prevents mixins from smashing on their own childEls (these are gathered\n        //      specifically)\n    ],\n\n    constructor: function () {\n        var me = this,\n            childEls;\n\n        // if we have configured childEls, we need to merge them with those from this\n        // class, its bases and the set of mixins...\n        if (me.hasOwnProperty('childEls')) {\n            childEls = me.childEls;\n            delete me.childEls;\n\n            me.addChildEls.apply(me, childEls);\n        }\n    },\n\n    destroy: function () {\n        var me = this,\n            childEls = me.getChildEls(),\n            child, childName, i, k;\n\n        for (i = childEls.length; i--; ) {\n            childName = childEls[i];\n            if (typeof childName != 'string') {\n                childName = childName.name;\n            }\n\n            child = me[childName];\n            if (child) {\n                me[childName] = null; // better than delete since that changes the \"shape\"\n                child.remove();\n            }\n        }\n    },\n\n    /**\n     * Adds each argument passed to this method to the {@link Ext.AbstractComponent#cfg-childEls childEls} array.\n     */\n    addChildEls: function () {\n        var me = this,\n            args = arguments;\n\n        if (me.hasOwnProperty('childEls')) {\n            me.childEls.push.apply(me.childEls, args);\n        } else {\n            me.childEls = me.getChildEls().concat(Array.prototype.slice.call(args));\n        }\n        \n        me.prune(me.childEls, false);\n    },\n\n    /**\n     * Sets references to elements inside the component. \n     * @private\n     */\n    applyChildEls: function(el, id) {\n        var me = this,\n            childEls = me.getChildEls(),\n            baseId, childName, i, selector, value;\n\n        baseId = (id || me.id) + '-';\n        for (i = childEls.length; i--; ) {\n            childName = childEls[i];\n\n            if (typeof childName == 'string') {\n                // We don't use Ext.get because that is 3x (or more) slower on IE6-8. Since\n                // we know the el's are children of our el we use getById instead:\n                value = el.getById(baseId + childName);\n            } else {\n                if ((selector = childName.select)) {\n                    value = Ext.select(selector, true, el.dom); // a CompositeElement\n                } else if ((selector = childName.selectNode)) {\n                    value = Ext.get(Ext.DomQuery.selectNode(selector, el.dom));\n                } else {\n                    // see above re:getById...\n                    value = el.getById(childName.id || (baseId + childName.itemId));\n                }\n\n                childName = childName.name;\n            }\n\n            me[childName] = value;\n        }\n    },\n\n    getChildEls: function () {\n        var me = this,\n            self;\n\n        // If an instance has its own childEls, that is the complete set:\n        if (me.hasOwnProperty('childEls')) {\n            return me.childEls;\n        }\n\n        // Typically, however, the childEls is a class-level concept, so check to see if\n        // we have cached the complete set on the class:\n        self = me.self;\n        return self.$childEls || me.getClassChildEls(self);\n    },\n\n    getClassChildEls: function (cls) {\n        var me = this,\n            result = cls.$childEls,\n            childEls, i, length, forked, mixin, mixins, name, parts, proto, supr, superMixins;\n\n        if (!result) {\n            // We put the various childEls arrays into parts in the order of superclass,\n            // new mixins and finally from cls. These parts can be null or undefined and\n            // we will skip them later.\n\n            supr = cls.superclass;\n            if (supr) {\n                supr = supr.self;\n                parts = [supr.$childEls || me.getClassChildEls(supr)]; // super+mixins\n                superMixins = supr.prototype.mixins || {};\n            } else {\n                parts = [];\n                superMixins = {};\n            }\n\n            proto = cls.prototype;\n            mixins = proto.mixins; // since we are a mixin, there will be at least us\n            for (name in mixins) {\n                if (mixins.hasOwnProperty(name) && !superMixins.hasOwnProperty(name)) {\n                    mixin = mixins[name].self;\n                    parts.push(mixin.$childEls || me.getClassChildEls(mixin));\n                }\n            }\n\n            parts.push(proto.hasOwnProperty('childEls') && proto.childEls);\n\n            for (i = 0, length = parts.length; i < length; ++i) {\n                childEls = parts[i];\n                if (childEls && childEls.length) {\n                    if (!result) {\n                        result = childEls;\n                    } else {\n                        if (!forked) {\n                            forked = true;\n                            result = result.slice(0);\n                        }\n                        result.push.apply(result, childEls);\n                    }\n                }\n            }\n\n            cls.$childEls = result = (result ? me.prune(result, !forked) : []);\n        }\n\n        return result;\n    },\n\n    prune: function (childEls, shared) {\n        var index = childEls.length,\n            map = {},\n            name;\n\n        while (index--) {\n            name = childEls[index];\n            if (typeof name != 'string') {\n                name = name.name;\n            }\n\n            if (!map[name]) {\n                map[name] = 1;\n            } else {\n                if (shared) {\n                    shared = false;\n                    childEls = childEls.slice(0);\n                }\n                Ext.Array.erase(childEls, index, 1);\n            }\n        }\n\n        return childEls;\n    },\n\n    /**\n     * Removes items in the childEls array based on the return value of a supplied test\n     * function. The function is called with a entry in childEls and if the test function\n     * return true, that entry is removed. If false, that entry is kept.\n     *\n     * @param {Function} testFn The test function.\n     */\n    removeChildEls: function (testFn) {\n        var me = this,\n            old = me.getChildEls(),\n            keepers = (me.childEls = []),\n            n, i, cel;\n\n        for (i = 0, n = old.length; i < n; ++i) {\n            cel = old[i];\n            if (!testFn(cel)) {\n                keepers.push(cel);\n            }\n        }\n    }\n});\n\n/**\n * Given a component hierarchy of this:\n *\n *      {\n *          xtype: 'panel',\n *          id: 'ContainerA',\n *          layout: 'hbox',\n *          renderTo: Ext.getBody(),\n *          items: [\n *              {\n *                  id: 'ContainerB',\n *                  xtype: 'container',\n *                  items: [\n *                      { id: 'ComponentA' }\n *                  ]\n *              }\n *          ]\n *      }\n *\n * The rendering of the above proceeds roughly like this:\n *\n *  - ContainerA's initComponent calls #render passing the `renderTo` property as the\n *    container argument.\n *  - `render` calls the `getRenderTree` method to get a complete {@link Ext.DomHelper} spec.\n *  - `getRenderTree` fires the \"beforerender\" event and calls the #beforeRender\n *    method. Its result is obtained by calling #getElConfig.\n *  - The #getElConfig method uses the `renderTpl` and its render data as the content\n *    of the `autoEl` described element.\n *  - The result of `getRenderTree` is passed to {@link Ext.DomHelper#append}.\n *  - The `renderTpl` contains calls to render things like docked items, container items\n *    and raw markup (such as the `html` or `tpl` config properties). These calls are to\n *    methods added to the {@link Ext.XTemplate} instance by #setupRenderTpl.\n *  - The #setupRenderTpl method adds methods such as `renderItems`, `renderContent`, etc.\n *    to the template. These are directed to \"doRenderItems\", \"doRenderContent\" etc..\n *  - The #setupRenderTpl calls traverse from components to their {@link Ext.layout.Layout}\n *    object.\n *  - When a container is rendered, it also has a `renderTpl`. This is processed when the\n *    `renderContainer` method is called in the component's `renderTpl`. This call goes to\n *    Ext.layout.container.Container#doRenderContainer. This method repeats this\n *    process for all components in the container.\n *  - After the top-most component's markup is generated and placed in to the DOM, the next\n *    step is to link elements to their components and finish calling the component methods\n *    `onRender` and `afterRender` as well as fire the corresponding events.\n *  - The first step in this is to call #finishRender. This method descends the\n *    component hierarchy and calls `onRender` and fires the `render` event. These calls\n *    are delivered top-down to approximate the timing of these calls/events from previous\n *    versions.\n *  - During the pass, the component's `el` is set. Likewise, the `renderSelectors` and\n *    `childEls` are applied to capture references to the component's elements.\n *  - These calls are also made on the {@link Ext.layout.container.Container} layout to\n *    capture its elements. Both of these classes use {@link Ext.util.ElementContainer} to\n *    handle `childEls` processing.\n *  - Once this is complete, a similar pass is made by calling #finishAfterRender.\n *    This call also descends the component hierarchy, but this time the calls are made in\n *    a bottom-up order to `afterRender`.\n *\n * @private\n */\nExt.define('Ext.util.Renderable', {\n    requires: [\n        'Ext.dom.Element'\n    ],\n\n    frameCls: Ext.baseCSSPrefix + 'frame',\n\n    frameIdRegex: /[\\-]frame\\d+[TMB][LCR]$/,\n\n    frameElementCls: {\n        tl: [],\n        tc: [],\n        tr: [],\n        ml: [],\n        mc: [],\n        mr: [],\n        bl: [],\n        bc: [],\n        br: []\n    },\n\n    frameElNames: ['TL','TC','TR','ML','MC','MR','BL','BC','BR'],\n\n    frameTpl: [\n        '{%this.renderDockedItems(out,values,0);%}',\n        '<tpl if=\"top\">',\n            '<tpl if=\"left\"><div id=\"{fgid}TL\" class=\"{frameCls}-tl {baseCls}-tl {baseCls}-{ui}-tl<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-tl</tpl>\" style=\"background-position: {tl}; padding-left: {frameWidth}px\" role=\"presentation\"></tpl>',\n                '<tpl if=\"right\"><div id=\"{fgid}TR\" class=\"{frameCls}-tr {baseCls}-tr {baseCls}-{ui}-tr<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-tr</tpl>\" style=\"background-position: {tr}; padding-right: {frameWidth}px\" role=\"presentation\"></tpl>',\n                    '<div id=\"{fgid}TC\" class=\"{frameCls}-tc {baseCls}-tc {baseCls}-{ui}-tc<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-tc</tpl>\" style=\"background-position: {tc}; height: {frameWidth}px\" role=\"presentation\"></div>',\n                '<tpl if=\"right\"></div></tpl>',\n            '<tpl if=\"left\"></div></tpl>',\n        '</tpl>',\n        '<tpl if=\"left\"><div id=\"{fgid}ML\" class=\"{frameCls}-ml {baseCls}-ml {baseCls}-{ui}-ml<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-ml</tpl>\" style=\"background-position: {ml}; padding-left: {frameWidth}px\" role=\"presentation\"></tpl>',\n            '<tpl if=\"right\"><div id=\"{fgid}MR\" class=\"{frameCls}-mr {baseCls}-mr {baseCls}-{ui}-mr<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-mr</tpl>\" style=\"background-position: {mr}; padding-right: {frameWidth}px\" role=\"presentation\"></tpl>',\n                '<div id=\"{fgid}MC\" class=\"{frameCls}-mc {baseCls}-mc {baseCls}-{ui}-mc<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-mc</tpl>\" role=\"presentation\">',\n                    '{%this.applyRenderTpl(out, values)%}',\n                '</div>',\n            '<tpl if=\"right\"></div></tpl>',\n        '<tpl if=\"left\"></div></tpl>',\n        '<tpl if=\"bottom\">',\n            '<tpl if=\"left\"><div id=\"{fgid}BL\" class=\"{frameCls}-bl {baseCls}-bl {baseCls}-{ui}-bl<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-bl</tpl>\" style=\"background-position: {bl}; padding-left: {frameWidth}px\" role=\"presentation\"></tpl>',\n                '<tpl if=\"right\"><div id=\"{fgid}BR\" class=\"{frameCls}-br {baseCls}-br {baseCls}-{ui}-br<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-br</tpl>\" style=\"background-position: {br}; padding-right: {frameWidth}px\" role=\"presentation\"></tpl>',\n                    '<div id=\"{fgid}BC\" class=\"{frameCls}-bc {baseCls}-bc {baseCls}-{ui}-bc<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-bc</tpl>\" style=\"background-position: {bc}; height: {frameWidth}px\" role=\"presentation\"></div>',\n                '<tpl if=\"right\"></div></tpl>',\n            '<tpl if=\"left\"></div></tpl>',\n        '</tpl>',\n        '{%this.renderDockedItems(out,values,1);%}'\n    ],\n\n    frameTableTpl: [\n        '{%this.renderDockedItems(out,values,0);%}',\n        '<table><tbody>',\n            '<tpl if=\"top\">',\n                '<tr>',\n                    '<tpl if=\"left\"><td id=\"{fgid}TL\" class=\"{frameCls}-tl {baseCls}-tl {baseCls}-{ui}-tl<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-tl</tpl>\" style=\"background-position: {tl}; padding-left:{frameWidth}px\" role=\"presentation\"></td></tpl>',\n                    '<td id=\"{fgid}TC\" class=\"{frameCls}-tc {baseCls}-tc {baseCls}-{ui}-tc<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-tc</tpl>\" style=\"background-position: {tc}; height: {frameWidth}px\" role=\"presentation\"></td>',\n                    '<tpl if=\"right\"><td id=\"{fgid}TR\" class=\"{frameCls}-tr {baseCls}-tr {baseCls}-{ui}-tr<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-tr</tpl>\" style=\"background-position: {tr}; padding-left: {frameWidth}px\" role=\"presentation\"></td></tpl>',\n                '</tr>',\n            '</tpl>',\n            '<tr>',\n                '<tpl if=\"left\"><td id=\"{fgid}ML\" class=\"{frameCls}-ml {baseCls}-ml {baseCls}-{ui}-ml<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-ml</tpl>\" style=\"background-position: {ml}; padding-left: {frameWidth}px\" role=\"presentation\"></td></tpl>',\n                '<td id=\"{fgid}MC\" class=\"{frameCls}-mc {baseCls}-mc {baseCls}-{ui}-mc<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-mc</tpl>\" style=\"background-position: 0 0;\" role=\"presentation\">',\n                    '{%this.applyRenderTpl(out, values)%}',\n                '</td>',\n                '<tpl if=\"right\"><td id=\"{fgid}MR\" class=\"{frameCls}-mr {baseCls}-mr {baseCls}-{ui}-mr<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-mr</tpl>\" style=\"background-position: {mr}; padding-left: {frameWidth}px\" role=\"presentation\"></td></tpl>',\n            '</tr>',\n            '<tpl if=\"bottom\">',\n                '<tr>',\n                    '<tpl if=\"left\"><td id=\"{fgid}BL\" class=\"{frameCls}-bl {baseCls}-bl {baseCls}-{ui}-bl<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-bl</tpl>\" style=\"background-position: {bl}; padding-left: {frameWidth}px\" role=\"presentation\"></td></tpl>',\n                    '<td id=\"{fgid}BC\" class=\"{frameCls}-bc {baseCls}-bc {baseCls}-{ui}-bc<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-bc</tpl>\" style=\"background-position: {bc}; height: {frameWidth}px\" role=\"presentation\"></td>',\n                    '<tpl if=\"right\"><td id=\"{fgid}BR\" class=\"{frameCls}-br {baseCls}-br {baseCls}-{ui}-br<tpl for=\"uiCls\"> {parent.baseCls}-{parent.ui}-{.}-br</tpl>\" style=\"background-position: {br}; padding-left: {frameWidth}px\" role=\"presentation\"></td></tpl>',\n                '</tr>',\n            '</tpl>',\n        '</tbody></table>',\n        '{%this.renderDockedItems(out,values,1);%}'\n    ],\n\n    /**\n     * Allows addition of behavior after rendering is complete. At this stage the Component’s Element\n     * will have been styled according to the configuration, will have had any configured CSS class\n     * names added, and will be in the configured visibility and the configured enable state.\n     *\n     * @template\n     * @protected\n     */\n    afterRender : function() {\n        var me = this,\n            data = {},\n            protoEl = me.protoEl,\n            target = me.getTargetEl(),\n            item;\n\n        me.finishRenderChildren();\n\n        if (me.styleHtmlContent) {\n            target.addCls(me.styleHtmlCls);\n        }\n        \n        protoEl.writeTo(data);\n        \n        // Here we apply any styles that were set on the protoEl during the rendering phase\n        // A majority of times this will not happen, but we still need to handle it\n        \n        item = data.removed;\n        if (item) {\n            target.removeCls(item);\n        }\n        \n        item = data.cls;\n        if (item.length) {\n            target.addCls(item);\n        }\n        \n        item = data.style;\n        if (data.style) {\n            target.setStyle(item);\n        }\n        \n        me.protoEl = null;\n\n        // If this is the outermost Container, lay it out as soon as it is rendered.\n        if (!me.ownerCt) {\n            me.updateLayout();\n        }\n    },\n\n    afterFirstLayout : function(width, height) {\n        var me = this,\n            hasX = Ext.isDefined(me.x),\n            hasY = Ext.isDefined(me.y),\n            pos, xy;\n\n        // For floaters, calculate x and y if they aren't defined by aligning\n        // the sized element to the center of either the container or the ownerCt\n        if (me.floating && (!hasX || !hasY)) {\n            if (me.floatParent) {\n                pos = me.floatParent.getTargetEl().getViewRegion();\n                xy = me.el.getAlignToXY(me.floatParent.getTargetEl(), 'c-c');\n                pos.left = xy[0] - pos.left;\n                pos.top =  xy[1] - pos.top;\n            } else {\n                xy = me.el.getAlignToXY(me.container, 'c-c');\n                pos = me.container.translatePoints(xy[0], xy[1]);\n            }\n            me.x = hasX ? me.x : pos.left;\n            me.y = hasY ? me.y : pos.top;\n            hasX = hasY = true;\n        }\n\n        if (hasX || hasY) {\n            me.setPosition(me.x, me.y);\n        }\n        me.onBoxReady(width, height);\n        if (me.hasListeners.boxready) {\n            me.fireEvent('boxready', me, width, height);\n        }\n    },\n\n    onBoxReady: Ext.emptyFn,\n\n    /**\n     * Sets references to elements inside the component. This applies {@link Ext.AbstractComponent#cfg-renderSelectors renderSelectors}\n     * as well as {@link Ext.AbstractComponent#cfg-childEls childEls}.\n     * @private\n     */\n    applyRenderSelectors: function() {\n        var me = this,\n            selectors = me.renderSelectors,\n            el = me.el,\n            dom = el.dom,\n            selector;\n\n        me.applyChildEls(el);\n\n        // We still support renderSelectors. There are a few places in the framework that\n        // need them and they are a documented part of the API. In fact, we support mixing\n        // childEls and renderSelectors (no reason not to).\n        if (selectors) {\n            for (selector in selectors) {\n                if (selectors.hasOwnProperty(selector) && selectors[selector]) {\n                    me[selector] = Ext.get(Ext.DomQuery.selectNode(selectors[selector], dom));\n                }\n            }\n        }\n    },\n\n    beforeRender: function () {\n        var me = this,\n            target = me.getTargetEl(),\n            layout = me.getComponentLayout();\n\n        // Just before rendering, set the frame flag if we are an always-framed component like Window or Tip.\n        me.frame = me.frame || me.alwaysFramed;\n\n        if (!layout.initialized) {\n            layout.initLayout();\n        }\n\n        // Attempt to set overflow style prior to render if the targetEl can be accessed.\n        // If the targetEl does not exist yet, this will take place in finishRender\n        if (target) {\n            target.setStyle(me.getOverflowStyle());\n            me.overflowStyleSet = true;\n        }\n\n        me.setUI(me.ui);\n\n        if (me.disabled) {\n            // pass silent so the event doesn't fire the first time.\n            me.disable(true);\n        }\n    },\n\n    /**\n     * @private\n     * Called from the selected frame generation template to insert this Component's inner structure inside the framing structure.\n     *\n     * When framing is used, a selected frame generation template is used as the primary template of the #getElConfig instead\n     * of the configured {@link Ext.AbstractComponent#renderTpl renderTpl}. The renderTpl is invoked by this method which is injected into the framing template.\n     */\n    doApplyRenderTpl: function(out, values) {\n        // Careful! This method is bolted on to the frameTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the frameTpl instance!\n\n        var me = values.$comp,\n            tpl;\n\n        // Don't do this if the component is already rendered:\n        if (!me.rendered) {\n            tpl = me.initRenderTpl();\n            tpl.applyOut(values.renderData, out);\n        }\n    },\n\n    /**\n     * Handles autoRender.\n     * Floating Components may have an ownerCt. If they are asking to be constrained, constrain them within that\n     * ownerCt, and have their z-index managed locally. Floating Components are always rendered to document.body\n     */\n    doAutoRender: function() {\n        var me = this;\n        if (!me.rendered) {\n            if (me.floating) {\n                me.render(document.body);\n            } else {\n                me.render(Ext.isBoolean(me.autoRender) ? Ext.getBody() : me.autoRender);\n            }\n        }\n    },\n\n    doRenderContent: function (out, renderData) {\n        // Careful! This method is bolted on to the renderTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the renderTpl instance!\n\n        var me = renderData.$comp;\n\n        if (me.html) {\n            Ext.DomHelper.generateMarkup(me.html, out);\n            delete me.html;\n        }\n\n        if (me.tpl) {\n            // Make sure this.tpl is an instantiated XTemplate\n            if (!me.tpl.isTemplate) {\n                me.tpl = new Ext.XTemplate(me.tpl);\n            }\n\n            if (me.data) {\n                //me.tpl[me.tplWriteMode](target, me.data);\n                me.tpl.applyOut(me.data, out);\n                delete me.data;\n            }\n        }\n    },\n\n    doRenderFramingDockedItems: function (out, renderData, after) {\n        // Careful! This method is bolted on to the frameTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the frameTpl instance!\n\n        var me = renderData.$comp;\n\n        // Most components don't have dockedItems, so check for doRenderDockedItems on the\n        // component (also, don't do this if the component is already rendered):\n        if (!me.rendered && me.doRenderDockedItems) {\n            // The \"renderData\" property is placed in scope for the renderTpl, but we don't\n            // want to render docked items at that level in addition to the framing level:\n            renderData.renderData.$skipDockedItems = true;\n\n            // doRenderDockedItems requires the $comp property on renderData, but this is\n            // set on the frameTpl's renderData as well:\n            me.doRenderDockedItems.call(this, out, renderData, after);\n        }\n    },\n\n    /**\n     * This method visits the rendered component tree in a \"top-down\" order. That is, this\n     * code runs on a parent component before running on a child. This method calls the\n     * {@link #onRender} method of each component.\n     * @param {Number} containerIdx The index into the Container items of this Component.\n     *\n     * @private\n     */\n    finishRender: function(containerIdx) {\n        var me = this,\n            tpl, data, contentEl, el, pre, hide;\n\n        // We are typically called w/me.el==null as a child of some ownerCt that is being\n        // rendered. We are also called by render for a normal component (w/o a configured\n        // me.el). In this case, render sets me.el and me.rendering (indirectly). Lastly\n        // we are also called on a component (like a Viewport) that has a configured me.el\n        // (body for a Viewport) when render is called. In this case, it is not flagged as\n        // \"me.rendering\" yet becasue it does not produce a renderTree. We use this to know\n        // not to regen the renderTpl.\n\n        if (!me.el || me.$pid) {\n            if (me.container) {\n                el = me.container.getById(me.id, true);\n            } else {\n                el = Ext.getDom(me.id);\n            }\n\n            if (!me.el) {\n                // Typical case: we produced the el during render\n                me.wrapPrimaryEl(el);\n            } else {\n                // We were configured with an el and created a proxy, so now we can swap\n                // the proxy for me.el:\n                delete me.$pid;\n\n                if (!me.el.dom) {\n                    // make sure me.el is an Element\n                    me.wrapPrimaryEl(me.el);\n                }\n                el.parentNode.insertBefore(me.el.dom, el);\n                Ext.removeNode(el); // remove placeholder el\n                // TODO - what about class/style?\n            }\n        } else if (!me.rendering) {\n            // We were configured with an el and then told to render (e.g., Viewport). We\n            // need to generate the proper DOM. Insert first because the layout system\n            // insists that child Component elements indices match the Component indices.\n            tpl = me.initRenderTpl();\n            if (tpl) {\n                data = me.initRenderData();\n                tpl.insertFirst(me.getTargetEl(), data);\n            }\n        }\n        // else we are rendering\n\n        if (!me.container) {\n            // top-level rendered components will already have me.container set up\n            me.container = Ext.get(me.el.dom.parentNode);\n        }\n\n        if (me.ctCls) {\n            me.container.addCls(me.ctCls);\n        }\n\n        // Sets the rendered flag and clears the redering flag\n        me.onRender(me.container, containerIdx);\n\n        // If we could not access a target protoEl in bewforeRender, we have to set the overflow styles here.\n        if (!me.overflowStyleSet) {\n            me.getTargetEl().setStyle(me.getOverflowStyle());\n        }\n\n        // Tell the encapsulating element to hide itself in the way the Component is configured to hide\n        // This means DISPLAY, VISIBILITY or OFFSETS.\n        me.el.setVisibilityMode(Ext.Element[me.hideMode.toUpperCase()]);\n\n        if (me.overCls) {\n            me.el.hover(me.addOverCls, me.removeOverCls, me);\n        }\n\n        if (me.hasListeners.render) {\n            me.fireEvent('render', me);\n        }\n\n        if (me.contentEl) {\n            pre = Ext.baseCSSPrefix;\n            hide = pre + 'hide-';\n            contentEl = Ext.get(me.contentEl);\n            contentEl.removeCls([pre+'hidden', hide+'display', hide+'offsets', hide+'nosize']);\n            me.getTargetEl().appendChild(contentEl.dom);\n        }\n\n        me.afterRender(); // this can cause a layout\n        if (me.hasListeners.afterrender) {\n            me.fireEvent('afterrender', me);\n        }\n        me.initEvents();\n\n        if (me.hidden) {\n            // Hiding during the render process should not perform any ancillary\n            // actions that the full hide process does; It is not hiding, it begins in a hidden state.'\n            // So just make the element hidden according to the configured hideMode\n            me.el.hide();\n        }\n    },\n\n    finishRenderChildren: function () {\n        var layout = this.getComponentLayout();\n\n        layout.finishRender();\n    },\n\n    getElConfig : function() {\n        var me = this,\n            autoEl = me.autoEl,\n            frameInfo = me.getFrameInfo(),\n            config = {\n                tag: 'div',\n                tpl: frameInfo ? me.initFramingTpl(frameInfo.table) : me.initRenderTpl()\n            },\n            i, frameElNames, len, suffix, frameGenId;\n\n        me.initStyles(me.protoEl);\n        me.protoEl.writeTo(config);\n        me.protoEl.flush();\n\n        if (Ext.isString(autoEl)) {\n            config.tag = autoEl;\n        } else {\n            Ext.apply(config, autoEl); // harmless if !autoEl\n        }\n\n        // It's important to assign the id here as an autoEl.id could have been (wrongly) applied and this would get things out of sync\n        config.id = me.id;\n\n        if (config.tpl) {\n            // Use the framingTpl as the main content creating template. It will call out to this.applyRenderTpl(out, values)\n            if (frameInfo) {\n                frameElNames = me.frameElNames;\n                len = frameElNames.length;\n                frameGenId = me.id + '-frame1';\n\n                me.frameGenId = 1;\n                config.tplData = Ext.apply({}, {\n                    $comp:      me,\n                    fgid:       frameGenId,\n                    ui:         me.ui,\n                    uiCls:      me.uiCls,\n                    frameCls:   me.frameCls,\n                    baseCls:    me.baseCls,\n                    frameWidth: frameInfo.maxWidth,\n                    top:        !!frameInfo.top,\n                    left:       !!frameInfo.left,\n                    right:      !!frameInfo.right,\n                    bottom:     !!frameInfo.bottom,\n                    renderData: me.initRenderData()\n                }, me.getFramePositions(frameInfo));\n\n                // Add the childEls for each of the frame elements\n                for (i = 0; i < len; i++) {\n                    suffix = frameElNames[i];\n                    me.addChildEls({ name: 'frame' + suffix, id: frameGenId + suffix });\n                }\n\n                // Panel must have a frameBody\n                me.addChildEls({\n                    name: 'frameBody',\n                    id: frameGenId + 'MC'\n                });\n            } else {\n                config.tplData = me.initRenderData();\n            }\n        }\n\n        return config;\n    },\n\n    // Create the framingTpl from the string.\n    // Poke in a reference to applyRenderTpl(frameInfo, out)\n    initFramingTpl: function(table) {\n        var tpl = table ? this.getTpl('frameTableTpl') : this.getTpl('frameTpl');\n\n        if (tpl && !tpl.applyRenderTpl) {\n            this.setupFramingTpl(tpl);\n        }\n\n        return tpl;\n    },\n\n    /**\n     * @private\n     * Inject a reference to the function which applies the render template into the framing template. The framing template\n     * wraps the content.\n     */\n    setupFramingTpl: function(frameTpl) {\n        frameTpl.applyRenderTpl = this.doApplyRenderTpl;\n        frameTpl.renderDockedItems = this.doRenderFramingDockedItems;\n    },\n\n    /**\n     * This function takes the position argument passed to onRender and returns a\n     * DOM element that you can use in the insertBefore.\n     * @param {String/Number/Ext.dom.Element/HTMLElement} position Index, element id or element you want\n     * to put this component before.\n     * @return {HTMLElement} DOM element that you can use in the insertBefore\n     */\n    getInsertPosition: function(position) {\n        // Convert the position to an element to insert before\n        if (position !== undefined) {\n            if (Ext.isNumber(position)) {\n                position = this.container.dom.childNodes[position];\n            }\n            else {\n                position = Ext.getDom(position);\n            }\n        }\n\n        return position;\n    },\n\n    getRenderTree: function() {\n        var me = this;\n\n        if (!me.hasListeners.beforerender || me.fireEvent('beforerender', me) !== false) {\n            me.beforeRender();\n\n            // Flag to let the layout's finishRenderItems and afterFinishRenderItems\n            // know which items to process\n            me.rendering = true;\n\n            if (me.el) {\n                // Since we are producing a render tree, we produce a \"proxy el\" that will\n                // sit in the rendered DOM precisely where me.el belongs. We replace the\n                // proxy el in the finishRender phase.\n                return {\n                    tag: 'div',\n                    id: (me.$pid = Ext.id())\n                };\n            }\n\n            return me.getElConfig();\n        }\n\n        return null;\n    },\n\n    initContainer: function(container) {\n        var me = this;\n\n        // If you render a component specifying the el, we get the container\n        // of the el, and make sure we dont move the el around in the dom\n        // during the render\n        if (!container && me.el) {\n            container = me.el.dom.parentNode;\n            me.allowDomMove = false;\n        }\n        me.container = container.dom ? container : Ext.get(container);\n\n        return me.container;\n    },\n\n    /**\n     * Initialized the renderData to be used when rendering the renderTpl.\n     * @return {Object} Object with keys and values that are going to be applied to the renderTpl\n     * @private\n     */\n    initRenderData: function() {\n        var me = this;\n\n        return Ext.apply({\n            $comp: me,\n            id: me.id,\n            ui: me.ui,\n            uiCls: me.uiCls,\n            baseCls: me.baseCls,\n            componentCls: me.componentCls,\n            frame: me.frame\n        }, me.renderData);\n    },\n\n    /**\n     * Initializes the renderTpl.\n     * @return {Ext.XTemplate} The renderTpl XTemplate instance.\n     * @private\n     */\n    initRenderTpl: function() {\n        var tpl = this.getTpl('renderTpl');\n\n        if (tpl && !tpl.renderContent) {\n            this.setupRenderTpl(tpl);\n        }\n\n        return tpl;\n    },\n\n    /**\n     * Template method called when this Component's DOM structure is created.\n     *\n     * At this point, this Component's (and all descendants') DOM structure *exists* but it has not\n     * been layed out (positioned and sized).\n     *\n     * Subclasses which override this to gain access to the structure at render time should\n     * call the parent class's method before attempting to access any child elements of the Component.\n     *\n     * @param {Ext.core.Element} parentNode The parent Element in which this Component's encapsulating element is contained.\n     * @param {Number} containerIdx The index within the parent Container's child collection of this Component.\n     *\n     * @template\n     * @protected\n     */\n    onRender: function(parentNode, containerIdx) {\n        var me = this,\n            x = me.x,\n            y = me.y,\n            lastBox, width, height,\n            el = me.el,\n            body = Ext.getBody().dom;\n\n        // Wrap this Component in a reset wraper if necessary\n        if (Ext.scopeResetCSS && !me.ownerCt) {\n            // If this component's el is the body element, we add the reset class to the html tag\n            if (el.dom === body) {\n                el.parent().addCls(Ext.resetCls);\n            }\n            // Otherwise, we ensure that there is a wrapper which has the reset class\n            else {\n                // Floaters rendered into the body can all be bumped into the common reset element\n                if (me.floating && me.el.dom.parentNode === body) {\n                    Ext.resetElement.appendChild(me.el);\n                }\n                // Else we wrap this element in an element that adds the reset class.\n                else {\n                    // Wrap this Component's DOM with a reset structure as determined in EventManager's initExtCss closure.\n                    me.resetEl = el.wrap(Ext.resetElementSpec, false, Ext.supports.CSS3LinearGradient ? undefined : '*');\n                }\n            }\n        }\n\n        me.applyRenderSelectors();\n\n        // Flag set on getRenderTree to flag to the layout's postprocessing routine that\n        // the Component is in the process of being rendered and needs postprocessing.\n        delete me.rendering;\n\n        me.rendered = true;\n\n        // We need to remember these to avoid writing them during the initial layout:\n        lastBox = null;\n\n        if (x !== undefined) {\n            lastBox = lastBox || {};\n            lastBox.x = x;\n        }\n        if (y !== undefined) {\n            lastBox = lastBox || {};\n            lastBox.y = y;\n        }\n        // Framed components need their width/height to apply to the frame, which is\n        // best handled in layout at present.\n        // If we're using the content box model, we also cannot assign initial sizes since we do not know the border widths to subtract\n        if (!me.getFrameInfo() && Ext.isBorderBox) {\n            width = me.width;\n            height = me.height;\n\n            if (typeof width == 'number') {\n                lastBox = lastBox || {};\n                lastBox.width = width;\n            }\n            if (typeof height == 'number') {\n                lastBox = lastBox || {};\n                lastBox.height = height;\n            }\n        }\n\n        me.lastBox = me.el.lastBox = lastBox;\n    },\n\n    /**\n     * Renders the Component into the passed HTML element.\n     * \n     * **If you are using a {@link Ext.container.Container Container} object to house this\n     * Component, then do not use the render method.**\n     *\n     * A Container's child Components are rendered by that Container's\n     * {@link Ext.container.Container#layout layout} manager when the Container is first rendered.\n     *\n     * If the Container is already rendered when a new child Component is added, you may need to call\n     * the Container's {@link Ext.container.Container#doLayout doLayout} to refresh the view which\n     * causes any unrendered child Components to be rendered. This is required so that you can add\n     * multiple child components if needed while only refreshing the layout once.\n     *\n     * When creating complex UIs, it is important to remember that sizing and positioning\n     * of child items is the responsibility of the Container's {@link Ext.container.Container#layout layout}\n     * manager.  If you expect child items to be sized in response to user interactions, you must\n     * configure the Container with a layout manager which creates and manages the type of layout you\n     * have in mind.\n     *\n     * **Omitting the Container's {@link Ext.Container#layout layout} config means that a basic\n     * layout manager is used which does nothing but render child components sequentially into the\n     * Container. No sizing or positioning will be performed in this situation.**\n     *\n     * @param {Ext.Element/HTMLElement/String} [container] The element this Component should be\n     * rendered into. If it is being created from existing markup, this should be omitted.\n     * @param {String/Number} [position] The element ID or DOM node index within the container **before**\n     * which this component will be inserted (defaults to appending to the end of the container)\n     */\n    render: function(container, position) {\n        var me = this,\n            el = me.el && (me.el = Ext.get(me.el)), // ensure me.el is wrapped\n            vetoed,\n            tree,\n            nextSibling;\n\n        Ext.suspendLayouts();\n\n        container = me.initContainer(container);\n\n        nextSibling = me.getInsertPosition(position);\n\n        if (!el) {\n            tree = me.getRenderTree();\n            if (me.ownerLayout && me.ownerLayout.transformItemRenderTree) {\n                tree = me.ownerLayout.transformItemRenderTree(tree);\n            }\n\n            // tree will be null if a beforerender listener returns false\n            if (tree) {\n                if (nextSibling) {\n                    el = Ext.DomHelper.insertBefore(nextSibling, tree);\n                } else {\n                    el = Ext.DomHelper.append(container, tree);\n                }\n\n                me.wrapPrimaryEl(el);\n            }\n        } else {\n            if (!me.hasListeners.beforerender || me.fireEvent('beforerender', me) !== false) {\n                // Set configured styles on pre-rendered Component's element\n                me.initStyles(el);\n                if (me.allowDomMove !== false) {\n                    //debugger; // TODO\n                    if (nextSibling) {\n                        container.dom.insertBefore(el.dom, nextSibling);\n                    } else {\n                        container.dom.appendChild(el.dom);\n                    }\n                }\n            } else {\n                vetoed = true;\n            }\n        }\n\n        if (el && !vetoed) {\n            me.finishRender(position);\n        }\n\n        Ext.resumeLayouts(!container.isDetachedBody);\n    },\n\n    /**\n     * Ensures that this component is attached to `document.body`. If the component was\n     * rendered to {@link Ext#getDetachedBody}, then it will be appended to `document.body`.\n     * Any configured position is also restored.\n     * @param {Boolean} [runLayout=false] True to run the component's layout.\n     */\n    ensureAttachedToBody: function (runLayout) {\n        var comp = this,\n            body;\n\n        while (comp.ownerCt) {\n            comp = comp.ownerCt;\n        }\n\n        if (comp.container.isDetachedBody) {\n            comp.container = body = Ext.resetElement;\n            body.appendChild(comp.el.dom);\n            if (runLayout) {\n                comp.updateLayout();\n            }\n            if (typeof comp.x == 'number' || typeof comp.y == 'number') {\n                comp.setPosition(comp.x, comp.y);\n            }\n        }\n    },\n\n    setupRenderTpl: function (renderTpl) {\n        renderTpl.renderBody = renderTpl.renderContent = this.doRenderContent;\n    },\n\n    wrapPrimaryEl: function (dom) {\n        this.el = Ext.get(dom, true);\n    },\n\n    /**\n     * @private\n     */\n    initFrame : function() {\n        if (Ext.supports.CSS3BorderRadius || !this.frame) {\n            return;\n        }\n\n        var me = this,\n            frameInfo = me.getFrameInfo(),\n            frameWidth, frameTpl, frameGenId,\n            i,\n            frameElNames = me.frameElNames,\n            len = frameElNames.length,\n            suffix;\n\n        if (frameInfo) {\n            frameWidth = frameInfo.maxWidth;\n            frameTpl = me.getFrameTpl(frameInfo.table);\n\n            // since we render id's into the markup and id's NEED to be unique, we have a\n            // simple strategy for numbering their generations.\n            me.frameGenId = frameGenId = (me.frameGenId || 0) + 1;\n            frameGenId = me.id + '-frame' + frameGenId;\n\n            // Here we render the frameTpl to this component. This inserts the 9point div or the table framing.\n            frameTpl.insertFirst(me.el, Ext.apply({\n                $comp:      me,\n                fgid:       frameGenId,\n                ui:         me.ui,\n                uiCls:      me.uiCls,\n                frameCls:   me.frameCls,\n                baseCls:    me.baseCls,\n                frameWidth: frameWidth,\n                top:        !!frameInfo.top,\n                left:       !!frameInfo.left,\n                right:      !!frameInfo.right,\n                bottom:     !!frameInfo.bottom\n            }, me.getFramePositions(frameInfo)));\n\n            // The frameBody is returned in getTargetEl, so that layouts render items to the correct target.\n            me.frameBody = me.el.down('.' + me.frameCls + '-mc');\n\n            // Clean out the childEls for the old frame elements (the majority of the els)\n            me.removeChildEls(function (c) {\n                return c.id && me.frameIdRegex.test(c.id);\n            });\n\n            // Grab references to the childEls for each of the new frame elements\n            for (i = 0; i < len; i++) {\n                suffix = frameElNames[i];\n                me['frame' + suffix] = me.el.getById(frameGenId + suffix);\n            }\n        }\n    },\n\n    updateFrame: function() {\n        if (Ext.supports.CSS3BorderRadius || !this.frame) {\n            return;\n        }\n\n        var me = this,\n            wasTable = this.frameSize && this.frameSize.table,\n            oldFrameTL = this.frameTL,\n            oldFrameBL = this.frameBL,\n            oldFrameML = this.frameML,\n            oldFrameMC = this.frameMC,\n            newMCClassName;\n\n        this.initFrame();\n\n        if (oldFrameMC) {\n            if (me.frame) {\n\n                // Store the class names set on the new MC\n                newMCClassName = this.frameMC.dom.className;\n\n                // Framing elements have been selected in initFrame, no need to run applyRenderSelectors\n                // Replace the new mc with the old mc\n                oldFrameMC.insertAfter(this.frameMC);\n                this.frameMC.remove();\n\n                // Restore the reference to the old frame mc as the framebody\n                this.frameBody = this.frameMC = oldFrameMC;\n\n                // Apply the new mc classes to the old mc element\n                oldFrameMC.dom.className = newMCClassName;\n\n                // Remove the old framing\n                if (wasTable) {\n                    me.el.query('> table')[1].remove();\n                }\n                else {\n                    if (oldFrameTL) {\n                        oldFrameTL.remove();\n                    }\n                    if (oldFrameBL) {\n                        oldFrameBL.remove();\n                    }\n                    if (oldFrameML) {\n                        oldFrameML.remove();\n                    }\n                }\n            }\n        }\n        else if (me.frame) {\n            this.applyRenderSelectors();\n        }\n    },\n\n    /**\n     * @private\n     * On render, reads an encoded style attribute, \"background-position\" from the style of this Component's element.\n     * This information is memoized based upon the CSS class name of this Component's element.\n     * Because child Components are rendered as textual HTML as part of the topmost Container, a dummy div is inserted\n     * into the document to receive the document element's CSS class name, and therefore style attributes.\n     */\n    getFrameInfo: function() {\n        // If native framing can be used, or this component is not going to be framed, then do not attempt to read CSS framing info.\n        if (Ext.supports.CSS3BorderRadius || !this.frame) {\n            return false;\n        }\n\n        var me = this,\n            frameInfoCache = me.frameInfoCache,\n            el = me.el || me.protoEl,\n            cls = el.dom ? el.dom.className : el.classList.join(' '),\n            frameInfo = frameInfoCache[cls],\n            styleEl, left, top, info;\n\n        if (frameInfo == null) {\n            // Get the singleton frame style proxy with our el class name stamped into it.\n            styleEl = Ext.fly(me.getStyleProxy(cls), 'frame-style-el');\n            left = styleEl.getStyle('background-position-x');\n            top = styleEl.getStyle('background-position-y');\n\n            // Some browsers don't support background-position-x and y, so for those\n            // browsers let's split background-position into two parts.\n            if (!left && !top) {\n                info = styleEl.getStyle('background-position').split(' ');\n                left = info[0];\n                top = info[1];\n            }\n\n            frameInfo = me.calculateFrame(left, top);\n\n            if (frameInfo) {\n                // Just to be sure we set the background image of the el to none.\n                el.setStyle('background-image', 'none');\n            }\n\n            // This happens when you set frame: true explicitly without using the x-frame mixin in sass.\n            // This way IE can't figure out what sizes to use and thus framing can't work.\n            if (me.frame === true && !frameInfo) {\n                Ext.log.error('You have set frame: true explicity on this component (' + me.getXType() + ') and it ' +\n                        'does not have any framing defined in the CSS template. In this case IE cannot figure out ' +\n                        'what sizes to use and thus framing on this component will be disabled.');\n            }\n\n            frameInfoCache[cls] = frameInfo;\n        }\n\n        me.frame = !!frameInfo;\n        me.frameSize = frameInfo;\n\n        return frameInfo;\n    },\n    \n    calculateFrame: function(left, top){\n        // We actually pass a string in the form of '[type][tl][tr]px [direction][br][bl]px' as\n        // the background position of this.el from the CSS to indicate to IE that this component needs\n        // framing. We parse it here.\n        if (!(parseInt(left, 10) >= 1000000 && parseInt(top, 10) >= 1000000)) {\n            return false;\n        }\n        var max = Math.max,\n            tl = parseInt(left.substr(3, 2), 10),\n            tr = parseInt(left.substr(5, 2), 10),\n            br = parseInt(top.substr(3, 2), 10),\n            bl = parseInt(top.substr(5, 2), 10),\n            frameInfo = {\n                // Table markup starts with 110, div markup with 100.\n                table: left.substr(0, 3) == '110',\n\n                // Determine if we are dealing with a horizontal or vertical component\n                vertical: top.substr(0, 3) == '110',\n\n                // Get and parse the different border radius sizes\n                top:    max(tl, tr),\n                right:  max(tr, br),\n                bottom: max(bl, br),\n                left:   max(tl, bl)\n            };\n\n        frameInfo.maxWidth = max(frameInfo.top, frameInfo.right, frameInfo.bottom, frameInfo.left);\n        frameInfo.width = frameInfo.left + frameInfo.right;\n        frameInfo.height = frameInfo.top + frameInfo.bottom;\n        return frameInfo;\n    },\n\n    /**\n     * @private\n     * Returns an offscreen div with the same class name as the element this is being rendered.\n     * This is because child item rendering takes place in a detached div which, being not part of the document, has no styling.\n     */\n    getStyleProxy: function(cls) {\n        var result = this.styleProxyEl || (Ext.AbstractComponent.prototype.styleProxyEl = Ext.resetElement.createChild({\n                style: {\n                    position: 'absolute',\n                    top: '-10000px'\n                }\n            }, null, true));\n\n        result.className = cls;\n        return result;\n    },\n\n    getFramePositions: function(frameInfo) {\n        var me = this,\n            frameWidth = frameInfo.maxWidth,\n            dock = me.dock,\n            positions, tc, bc, ml, mr;\n\n        if (frameInfo.vertical) {\n            tc = '0 -' + (frameWidth * 0) + 'px';\n            bc = '0 -' + (frameWidth * 1) + 'px';\n\n            if (dock && dock == \"right\") {\n                tc = 'right -' + (frameWidth * 0) + 'px';\n                bc = 'right -' + (frameWidth * 1) + 'px';\n            }\n\n            positions = {\n                tl: '0 -' + (frameWidth * 0) + 'px',\n                tr: '0 -' + (frameWidth * 1) + 'px',\n                bl: '0 -' + (frameWidth * 2) + 'px',\n                br: '0 -' + (frameWidth * 3) + 'px',\n\n                ml: '-' + (frameWidth * 1) + 'px 0',\n                mr: 'right 0',\n\n                tc: tc,\n                bc: bc\n            };\n        } else {\n            ml = '-' + (frameWidth * 0) + 'px 0';\n            mr = 'right 0';\n\n            if (dock && dock == \"bottom\") {\n                ml = 'left bottom';\n                mr = 'right bottom';\n            }\n\n            positions = {\n                tl: '0 -' + (frameWidth * 2) + 'px',\n                tr: 'right -' + (frameWidth * 3) + 'px',\n                bl: '0 -' + (frameWidth * 4) + 'px',\n                br: 'right -' + (frameWidth * 5) + 'px',\n\n                ml: ml,\n                mr: mr,\n\n                tc: '0 -' + (frameWidth * 0) + 'px',\n                bc: '0 -' + (frameWidth * 1) + 'px'\n            };\n        }\n\n        return positions;\n    },\n\n    /**\n     * @private\n     */\n    getFrameTpl : function(table) {\n        return this.getTpl(table ? 'frameTableTpl' : 'frameTpl');\n    },\n\n    // Cache the frame information object so as not to cause style recalculations\n    frameInfoCache: {}\n});\n\n/**\n * @class Ext.state.Provider\n * <p>Abstract base class for state provider implementations. The provider is responsible\n * for setting values  and extracting values to/from the underlying storage source. The \n * storage source can vary and the details should be implemented in a subclass. For example\n * a provider could use a server side database or the browser localstorage where supported.</p>\n *\n * <p>This class provides methods for encoding and decoding <b>typed</b> variables including \n * dates and defines the Provider interface. By default these methods put the value and the\n * type information into a delimited string that can be stored. These should be overridden in \n * a subclass if you want to change the format of the encoded value and subsequent decoding.</p>\n */\nExt.define('Ext.state.Provider', {\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n    \n    /**\n     * @cfg {String} prefix A string to prefix to items stored in the underlying state store. \n     * Defaults to <tt>'ext-'</tt>\n     */\n    prefix: 'ext-',\n    \n    constructor : function(config){\n        config = config || {};\n        var me = this;\n        Ext.apply(me, config);\n        /**\n         * @event statechange\n         * Fires when a state change occurs.\n         * @param {Ext.state.Provider} this This state provider\n         * @param {String} key The state key which was changed\n         * @param {String} value The encoded value for the state\n         */\n        me.addEvents(\"statechange\");\n        me.state = {};\n        me.mixins.observable.constructor.call(me);\n    },\n    \n    /**\n     * Returns the current value for a key\n     * @param {String} name The key name\n     * @param {Object} defaultValue A default value to return if the key's value is not found\n     * @return {Object} The state data\n     */\n    get : function(name, defaultValue){\n        return typeof this.state[name] == \"undefined\" ?\n            defaultValue : this.state[name];\n    },\n\n    /**\n     * Clears a value from the state\n     * @param {String} name The key name\n     */\n    clear : function(name){\n        var me = this;\n        delete me.state[name];\n        me.fireEvent(\"statechange\", me, name, null);\n    },\n\n    /**\n     * Sets the value for a key\n     * @param {String} name The key name\n     * @param {Object} value The value to set\n     */\n    set : function(name, value){\n        var me = this;\n        me.state[name] = value;\n        me.fireEvent(\"statechange\", me, name, value);\n    },\n\n    /**\n     * Decodes a string previously encoded with {@link #encodeValue}.\n     * @param {String} value The value to decode\n     * @return {Object} The decoded value\n     */\n    decodeValue : function(value){\n\n        // a -> Array\n        // n -> Number\n        // d -> Date\n        // b -> Boolean\n        // s -> String\n        // o -> Object\n        // -> Empty (null)\n\n        var me = this,\n            re = /^(a|n|d|b|s|o|e)\\:(.*)$/,\n            matches = re.exec(unescape(value)),\n            all,\n            type,\n            keyValue,\n            values,\n            vLen,\n            v;\n            \n        if(!matches || !matches[1]){\n            return; // non state\n        }\n        \n        type = matches[1];\n        value = matches[2];\n        switch (type) {\n            case 'e':\n                return null;\n            case 'n':\n                return parseFloat(value);\n            case 'd':\n                return new Date(Date.parse(value));\n            case 'b':\n                return (value == '1');\n            case 'a':\n                all = [];\n                if(value != ''){\n                    values = value.split('^');\n                    vLen   = values.length;\n\n                    for (v = 0; v < vLen; v++) {\n                        value = values[v];\n                        all.push(me.decodeValue(value));\n                    }\n                }\n                return all;\n           case 'o':\n                all = {};\n                if(value != ''){\n                    values = value.split('^');\n                    vLen   = values.length;\n\n                    for (v = 0; v < vLen; v++) {\n                        value = values[v];\n                        keyValue         = value.split('=');\n                        all[keyValue[0]] = me.decodeValue(keyValue[1]);\n                    }\n                }\n                return all;\n           default:\n                return value;\n        }\n    },\n\n    /**\n     * Encodes a value including type information.  Decode with {@link #decodeValue}.\n     * @param {Object} value The value to encode\n     * @return {String} The encoded value\n     */\n    encodeValue : function(value){\n        var flat = '',\n            i = 0,\n            enc,\n            len,\n            key;\n            \n        if (value == null) {\n            return 'e:1';    \n        } else if(typeof value == 'number') {\n            enc = 'n:' + value;\n        } else if(typeof value == 'boolean') {\n            enc = 'b:' + (value ? '1' : '0');\n        } else if(Ext.isDate(value)) {\n            enc = 'd:' + value.toGMTString();\n        } else if(Ext.isArray(value)) {\n            for (len = value.length; i < len; i++) {\n                flat += this.encodeValue(value[i]);\n                if (i != len - 1) {\n                    flat += '^';\n                }\n            }\n            enc = 'a:' + flat;\n        } else if (typeof value == 'object') {\n            for (key in value) {\n                if (typeof value[key] != 'function' && value[key] !== undefined) {\n                    flat += key + '=' + this.encodeValue(value[key]) + '^';\n                }\n            }\n            enc = 'o:' + flat.substring(0, flat.length-1);\n        } else {\n            enc = 's:' + value;\n        }\n        return escape(enc);\n    }\n});\n\n/**\n * @class Ext.state.Manager\n * This is the global state manager. By default all components that are \"state aware\" check this class\n * for state information if you don't pass them a custom state provider. In order for this class\n * to be useful, it must be initialized with a provider when your application initializes. Example usage:\n <pre><code>\n// in your initialization function\ninit : function(){\n   Ext.state.Manager.setProvider(new Ext.state.CookieProvider());\n}\n </code></pre>\n * This class passes on calls from components to the underlying {@link Ext.state.Provider} so that\n * there is a common interface that can be used without needing to refer to a specific provider instance\n * in every component.\n * @singleton\n * @docauthor Evan Trimboli <evan@sencha.com>\n */\nExt.define('Ext.state.Manager', {\n    singleton: true,\n    requires: ['Ext.state.Provider'],\n    constructor: function() {\n        this.provider = new Ext.state.Provider();\n    },\n    \n    \n    /**\n     * Configures the default state provider for your application\n     * @param {Ext.state.Provider} stateProvider The state provider to set\n     */\n    setProvider : function(stateProvider){\n        this.provider = stateProvider;\n    },\n\n    /**\n     * Returns the current value for a key\n     * @param {String} name The key name\n     * @param {Object} defaultValue The default value to return if the key lookup does not match\n     * @return {Object} The state data\n     */\n    get : function(key, defaultValue){\n        return this.provider.get(key, defaultValue);\n    },\n\n    /**\n     * Sets the value for a key\n     * @param {String} name The key name\n     * @param {Object} value The state data\n     */\n     set : function(key, value){\n        this.provider.set(key, value);\n    },\n\n    /**\n     * Clears a value from the state\n     * @param {String} name The key name\n     */\n    clear : function(key){\n        this.provider.clear(key);\n    },\n\n    /**\n     * Gets the currently configured state provider\n     * @return {Ext.state.Provider} The state provider\n     */\n    getProvider : function(){\n        return this.provider;\n    }\n});\n\n/**\n * @class Ext.state.Stateful\n * A mixin for being able to save the state of an object to an underlying\n * {@link Ext.state.Provider}.\n */\nExt.define('Ext.state.Stateful', {\n\n    /* Begin Definitions */\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    requires: ['Ext.state.Manager'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Boolean} stateful\n     * A flag which causes the object to attempt to restore the state of\n     * internal properties from a saved state on startup. The object must have\n     * a {@link #stateId} for state to be managed.\n     * \n     * Auto-generated ids are not guaranteed to be stable across page loads and\n     * cannot be relied upon to save and restore the same state for a object.<p>\n     *\n     * For state saving to work, the state manager's provider must have been\n     * set to an implementation of {@link Ext.state.Provider} which overrides the\n     * {@link Ext.state.Provider#set set} and {@link Ext.state.Provider#get get}\n     * methods to save and recall name/value pairs. A built-in implementation,\n     * {@link Ext.state.CookieProvider} is available.\n     * \n     * To set the state provider for the current page:\n     * \n     *    Ext.state.Manager.setProvider(new Ext.state.CookieProvider({\n     *        expires: new Date(new Date().getTime()+(1000*60*60*24*7)), //7 days from now\n     *    }));\n     *\n     * A stateful object attempts to save state when one of the events\n     * listed in the {@link #stateEvents} configuration fires.\n     * \n     * To save state, a stateful object first serializes its state by\n     * calling *{@link #getState}*.\n     * \n     * The Component base class implements {@link #getState} to save its width and height within the state\n     * only if they were initially configured, and have changed from the configured value.\n     * \n     * The Panel class saves its collapsed state in addition to that.\n     * \n     * The Grid class saves its column state in addition to its superclass state.\n     * \n     * If there is more application state to be save, the developer must provide an implementation which\n     * first calls the superclass method to inherit the above behaviour, and then injects new properties\n     * into the returned object.\n     * \n     * The value yielded by getState is passed to {@link Ext.state.Manager#set}\n     * which uses the configured {@link Ext.state.Provider} to save the object\n     * keyed by the {@link #stateId}.\n     * \n     * During construction, a stateful object attempts to *restore* its state by calling\n     * {@link Ext.state.Manager#get} passing the {@link #stateId}\n     * \n     * The resulting object is passed to {@link #applyState}*. The default implementation of\n     * {@link #applyState} simply copies properties into the object, but a developer may\n     * override this to support restoration of more complex application state.\n     * \n     * You can perform extra processing on state save and restore by attaching\n     * handlers to the {@link #beforestaterestore}, {@link #staterestore},\n     * {@link #beforestatesave} and {@link #statesave} events.\n     */\n    stateful: false,\n\n    /**\n     * @cfg {String} stateId\n     * The unique id for this object to use for state management purposes.\n     * <p>See {@link #stateful} for an explanation of saving and restoring state.</p>\n     */\n\n    /**\n     * @cfg {String[]} stateEvents\n     * <p>An array of events that, when fired, should trigger this object to\n     * save its state. Defaults to none. <code>stateEvents</code> may be any type\n     * of event supported by this object, including browser or custom events\n     * (e.g., <tt>['click', 'customerchange']</tt>).</p>\n     * <p>See <code>{@link #stateful}</code> for an explanation of saving and\n     * restoring object state.</p>\n     */\n\n    /**\n     * @cfg {Number} saveDelay\n     * A buffer to be applied if many state events are fired within a short period.\n     */\n    saveDelay: 100,\n\n    constructor: function(config) {\n        var me = this;\n\n        config = config || {};\n        if (config.stateful !== undefined) {\n            me.stateful = config.stateful;\n        }\n        if (config.saveDelay !== undefined) {\n            me.saveDelay = config.saveDelay;\n        }\n        me.stateId = me.stateId || config.stateId;\n\n        if (!me.stateEvents) {\n            me.stateEvents = [];\n        }\n        if (config.stateEvents) {\n            me.stateEvents.concat(config.stateEvents);\n        }\n        this.addEvents(\n            /**\n             * @event beforestaterestore\n             * Fires before the state of the object is restored. Return false from an event handler to stop the restore.\n             * @param {Ext.state.Stateful} this\n             * @param {Object} state The hash of state values returned from the StateProvider. If this\n             * event is not vetoed, then the state object is passed to <b><tt>applyState</tt></b>. By default,\n             * that simply copies property values into this object. The method maybe overriden to\n             * provide custom state restoration.\n             */\n            'beforestaterestore',\n\n            /**\n             * @event staterestore\n             * Fires after the state of the object is restored.\n             * @param {Ext.state.Stateful} this\n             * @param {Object} state The hash of state values returned from the StateProvider. This is passed\n             * to <b><tt>applyState</tt></b>. By default, that simply copies property values into this\n             * object. The method maybe overriden to provide custom state restoration.\n             */\n            'staterestore',\n\n            /**\n             * @event beforestatesave\n             * Fires before the state of the object is saved to the configured state provider. Return false to stop the save.\n             * @param {Ext.state.Stateful} this\n             * @param {Object} state The hash of state values. This is determined by calling\n             * <b><tt>getState()</tt></b> on the object. This method must be provided by the\n             * developer to return whetever representation of state is required, by default, Ext.state.Stateful\n             * has a null implementation.\n             */\n            'beforestatesave',\n\n            /**\n             * @event statesave\n             * Fires after the state of the object is saved to the configured state provider.\n             * @param {Ext.state.Stateful} this\n             * @param {Object} state The hash of state values. This is determined by calling\n             * <b><tt>getState()</tt></b> on the object. This method must be provided by the\n             * developer to return whetever representation of state is required, by default, Ext.state.Stateful\n             * has a null implementation.\n             */\n            'statesave'\n        );\n        me.mixins.observable.constructor.call(me);\n\n        if (me.stateful !== false) {\n            me.addStateEvents(me.stateEvents);\n            me.initState();\n        }\n    },\n\n    /**\n     * Add events that will trigger the state to be saved. If the first argument is an\n     * array, each element of that array is the name of a state event. Otherwise, each\n     * argument passed to this method is the name of a state event.\n     *\n     * @param {String/String[]} events The event name or an array of event names.\n     */\n    addStateEvents: function (events) {\n        var me = this,\n            i, event, stateEventsByName;\n\n        if (me.stateful && me.getStateId()) {\n            if (typeof events == 'string') {\n                events = Array.prototype.slice.call(arguments, 0);\n            }\n\n            stateEventsByName = me.stateEventsByName || (me.stateEventsByName = {});\n\n            for (i = events.length; i--; ) {\n                event = events[i];\n\n                if (!stateEventsByName[event]) {\n                    stateEventsByName[event] = 1;\n                    me.on(event, me.onStateChange, me);\n                }\n            }\n        }\n    },\n\n    /**\n     * This method is called when any of the {@link #stateEvents} are fired.\n     * @private\n     */\n    onStateChange: function(){\n        var me = this,\n            delay = me.saveDelay,\n            statics, runner;\n\n        if (!me.stateful) {\n            return;\n        }\n\n        if (delay) {\n            if (!me.stateTask) {\n                statics = Ext.state.Stateful;\n                runner = statics.runner || (statics.runner = new Ext.util.TaskRunner());\n\n                me.stateTask = runner.newTask({\n                    run: me.saveState,\n                    scope: me,\n                    interval: delay,\n                    repeat: 1\n                });\n            }\n\n            me.stateTask.start();\n        } else {\n            me.saveState();\n        }\n    },\n\n    /**\n     * Saves the state of the object to the persistence store.\n     */\n    saveState: function() {\n        var me = this,\n            id = me.stateful && me.getStateId(),\n            hasListeners = me.hasListeners,\n            state;\n\n        if (id) {\n            state = me.getState() || {};    //pass along for custom interactions\n            if (!hasListeners.beforestatesave || me.fireEvent('beforestatesave', me, state) !== false) {\n                Ext.state.Manager.set(id, state);\n                if (hasListeners.statesave) {\n                    me.fireEvent('statesave', me, state);\n                }\n            }\n        }\n    },\n\n    /**\n     * Gets the current state of the object. By default this function returns null,\n     * it should be overridden in subclasses to implement methods for getting the state.\n     * @return {Object} The current state\n     */\n    getState: function(){\n        return null;\n    },\n\n    /**\n     * Applies the state to the object. This should be overridden in subclasses to do\n     * more complex state operations. By default it applies the state properties onto\n     * the current object.\n     * @param {Object} state The state\n     */\n    applyState: function(state) {\n        if (state) {\n            Ext.apply(this, state);\n        }\n    },\n\n    /**\n     * Gets the state id for this object.\n     * @return {String} The 'stateId' or the implicit 'id' specified by component configuration.\n     * @private\n     */\n    getStateId: function() {\n        var me = this;\n        return me.stateId || (me.autoGenId ? null : me.id);\n    },\n\n    /**\n     * Initializes the state of the object upon construction.\n     * @private\n     */\n    initState: function(){\n        var me = this,\n            id = me.stateful && me.getStateId(),\n            hasListeners = me.hasListeners,\n            state;\n\n        if (id) {\n            state = Ext.state.Manager.get(id);\n            if (state) {\n                state = Ext.apply({}, state);\n                if (!hasListeners.beforestaterestore || me.fireEvent('beforestaterestore', me, state) !== false) {\n                    me.applyState(state);\n                    if (hasListeners.staterestore) {\n                        me.fireEvent('staterestore', me, state);\n                    }\n                }\n            }\n        }\n    },\n\n    /**\n     * Conditionally saves a single property from this object to the given state object.\n     * The idea is to only save state which has changed from the initial state so that\n     * current software settings do not override future software settings. Only those\n     * values that are user-changed state should be saved.\n     *\n     * @param {String} propName The name of the property to save.\n     * @param {Object} state The state object in to which to save the property.\n     * @param {String} stateName (optional) The name to use for the property in state.\n     * @return {Boolean} True if the property was saved, false if not.\n     */\n    savePropToState: function (propName, state, stateName) {\n        var me = this,\n            value = me[propName],\n            config = me.initialConfig;\n\n        if (me.hasOwnProperty(propName)) {\n            if (!config || config[propName] !== value) {\n                if (state) {\n                    state[stateName || propName] = value;\n                }\n                return true;\n            }\n        }\n        return false;\n    },\n\n    /**\n     * Gathers additional named properties of the instance and adds their current values\n     * to the passed state object.\n     * @param {String/String[]} propNames The name (or array of names) of the property to save.\n     * @param {Object} state The state object in to which to save the property values.\n     * @return {Object} state\n     */\n    savePropsToState: function (propNames, state) {\n        var me = this,\n            i, n;\n\n        if (typeof propNames == 'string') {\n            me.savePropToState(propNames, state);\n        } else {\n            for (i = 0, n = propNames.length; i < n; ++i) {\n                me.savePropToState(propNames[i], state);\n            }\n        }\n\n        return state;\n    },\n\n    /**\n     * Destroys this stateful object.\n     */\n    destroy: function(){\n        var me = this,\n            task = me.stateTask;\n\n        if (task) {\n            task.destroy();\n            me.stateTask = null;\n        }\n\n        me.clearListeners();\n    }\n});\n\n/**\n * An abstract base class which provides shared methods for Components across the Sencha product line.\n *\n * Please refer to sub class's documentation\n * @private\n */\nExt.define('Ext.AbstractComponent', {\n\n    /* Begin Definitions */\n    requires: [\n        'Ext.ComponentQuery',\n        'Ext.ComponentManager',\n        'Ext.util.ProtoElement'\n    ],\n\n    mixins: {\n        observable: 'Ext.util.Observable',\n        animate: 'Ext.util.Animate',\n        elementCt: 'Ext.util.ElementContainer',\n        renderable: 'Ext.util.Renderable',\n        state: 'Ext.state.Stateful'\n    },\n\n    // The \"uses\" property specifies class which are used in an instantiated AbstractComponent.\n    // They do *not* have to be loaded before this class may be defined - that is what \"requires\" is for.\n    uses: [\n        'Ext.PluginManager',\n        'Ext.Element',\n        'Ext.DomHelper',\n        'Ext.XTemplate',\n        'Ext.ComponentQuery',\n        'Ext.ComponentLoader',\n        'Ext.EventManager',\n        'Ext.layout.Context',\n        'Ext.layout.Layout',\n        'Ext.layout.component.Auto',\n        'Ext.LoadMask',\n        'Ext.ZIndexManager'\n    ],\n\n    statics: {\n        AUTO_ID: 1000,\n\n        pendingLayouts: null,\n\n        layoutSuspendCount: 0,\n\n        /**\n         * Cancels layout of a component.\n         * @param {Ext.Component} comp\n         */\n        cancelLayout: function(comp, isDestroying) {\n            var context = this.runningLayoutContext || this.pendingLayouts;\n\n            if (context) {\n                context.cancelComponent(comp, false, isDestroying);\n            }\n        },\n\n        /**\n         * Performs all pending layouts that were sceduled while\n         * {@link Ext.AbstractComponent#suspendLayouts suspendLayouts} was in effect.\n         * @static\n         */\n        flushLayouts: function () {\n            var me = this,\n                context = me.pendingLayouts;\n\n            if (context && context.invalidQueue.length) {\n                me.pendingLayouts = null;\n                me.runningLayoutContext = context;\n\n                Ext.override(context, {\n                    runComplete: function () {\n                        // we need to release the layout queue before running any of the\n                        // finishedLayout calls because they call afterComponentLayout\n                        // which can re-enter by calling doLayout/doComponentLayout.\n                        me.runningLayoutContext = null;\n\n                        return this.callParent(); // not \"me\" here!\n                    }\n                });\n\n                context.run();\n            }\n        },\n\n        /**\n         * Resumes layout activity in the whole framework.\n         *\n         * {@link Ext#suspendLayouts} is alias of {@link Ext.AbstractComponent#suspendLayouts}.\n         *\n         * @param {Boolean} [flush=false] True to perform all the pending layouts. This can also be\n         * achieved by calling {@link Ext.AbstractComponent#flushLayouts flushLayouts} directly.\n         * @static\n         */\n        resumeLayouts: function (flush) {\n            if (this.layoutSuspendCount && ! --this.layoutSuspendCount) {\n                if (flush) {\n                    this.flushLayouts();\n                }\n            }\n        },\n\n        /**\n         * Stops layouts from happening in the whole framework.\n         *\n         * It's useful to suspend the layout activity while updating multiple components and\n         * containers:\n         *\n         *     Ext.suspendLayouts();\n         *     // batch of updates...\n         *     Ext.resumeLayouts(true);\n         *\n         * {@link Ext#suspendLayouts} is alias of {@link Ext.AbstractComponent#suspendLayouts}.\n         *\n         * See also {@link Ext#batchLayouts} for more abstract way of doing this.\n         *\n         * @static\n         */\n        suspendLayouts: function () {\n            ++this.layoutSuspendCount;\n        },\n\n        /**\n         * Updates layout of a component.\n         *\n         * @param {Ext.Component} comp The component to update.\n         * @param {Boolean} [defer=false] True to just queue the layout if this component.\n         * @static\n         */\n        updateLayout: function (comp, defer) {\n            var me = this,\n                running = me.runningLayoutContext,\n                pending;\n\n            if (running) {\n                running.queueInvalidate(comp);\n            } else {\n                pending = me.pendingLayouts || (me.pendingLayouts = new Ext.layout.Context());\n                pending.queueInvalidate(comp);\n\n                if (!defer && !me.layoutSuspendCount && !comp.isLayoutSuspended()) {\n                    me.flushLayouts();\n                }\n            }\n        }\n    },\n\n    /* End Definitions */\n\n    /**\n     * @property {Boolean} isComponent\n     * `true` in this class to identify an object as an instantiated Component, or subclass thereof.\n     */\n    isComponent: true,\n\n    /**\n     * @private\n     */\n    getAutoId: function() {\n        this.autoGenId = true;\n        return ++Ext.AbstractComponent.AUTO_ID;\n    },\n\n    deferLayouts: false,\n\n    /**\n     * @cfg {String} id\n     * The **unique id of this component instance.**\n     *\n     * It should not be necessary to use this configuration except for singleton objects in your application. Components\n     * created with an id may be accessed globally using {@link Ext#getCmp Ext.getCmp}.\n     *\n     * Instead of using assigned ids, use the {@link #itemId} config, and {@link Ext.ComponentQuery ComponentQuery}\n     * which provides selector-based searching for Sencha Components analogous to DOM querying. The {@link\n     * Ext.container.Container Container} class contains {@link Ext.container.Container#down shortcut methods} to query\n     * its descendant Components by selector.\n     *\n     * Note that this id will also be used as the element id for the containing HTML element that is rendered to the\n     * page for this component. This allows you to write id-based CSS rules to style the specific instance of this\n     * component uniquely, and also to select sub-elements using this component's id as the parent.\n     *\n     * **Note**: to avoid complications imposed by a unique id also see `{@link #itemId}`.\n     *\n     * **Note**: to access the container of a Component see `{@link #ownerCt}`.\n     *\n     * Defaults to an {@link #getId auto-assigned id}.\n     */\n\n     /**\n     * @property {Boolean} autoGenId\n     * `true` indicates an id was auto-generated rather than provided by configuration.\n     * @private\n     */\n    autoGenId: false,\n\n    /**\n     * @cfg {String} itemId\n     * An itemId can be used as an alternative way to get a reference to a component when no object reference is\n     * available. Instead of using an `{@link #id}` with {@link Ext}.{@link Ext#getCmp getCmp}, use `itemId` with\n     * {@link Ext.container.Container}.{@link Ext.container.Container#getComponent getComponent} which will retrieve\n     * `itemId`'s or {@link #id}'s. Since `itemId`'s are an index to the container's internal MixedCollection, the\n     * `itemId` is scoped locally to the container -- avoiding potential conflicts with {@link Ext.ComponentManager}\n     * which requires a **unique** `{@link #id}`.\n     *\n     *     var c = new Ext.panel.Panel({ //\n     *         {@link Ext.Component#height height}: 300,\n     *         {@link #renderTo}: document.body,\n     *         {@link Ext.container.Container#layout layout}: 'auto',\n     *         {@link Ext.container.Container#cfg-items items}: [\n     *             {\n     *                 itemId: 'p1',\n     *                 {@link Ext.panel.Panel#title title}: 'Panel 1',\n     *                 {@link Ext.Component#height height}: 150\n     *             },\n     *             {\n     *                 itemId: 'p2',\n     *                 {@link Ext.panel.Panel#title title}: 'Panel 2',\n     *                 {@link Ext.Component#height height}: 150\n     *             }\n     *         ]\n     *     })\n     *     p1 = c.{@link Ext.container.Container#getComponent getComponent}('p1'); // not the same as {@link Ext#getCmp Ext.getCmp()}\n     *     p2 = p1.{@link #ownerCt}.{@link Ext.container.Container#getComponent getComponent}('p2'); // reference via a sibling\n     *\n     * Also see {@link #id}, `{@link Ext.container.Container#query}`, `{@link Ext.container.Container#down}` and\n     * `{@link Ext.container.Container#child}`.\n     *\n     * **Note**: to access the container of an item see {@link #ownerCt}.\n     */\n\n    /**\n     * @property {Ext.Container} ownerCt\n     * This Component's owner {@link Ext.container.Container Container} (is set automatically\n     * when this Component is added to a Container).\n     *\n     * **Note**: to access items within the Container see {@link #itemId}.\n     * @readonly\n     */\n\n    /**\n     * @cfg {String/Object} autoEl\n     * A tag name or {@link Ext.DomHelper DomHelper} spec used to create the {@link #getEl Element} which will\n     * encapsulate this Component.\n     *\n     * You do not normally need to specify this. For the base classes {@link Ext.Component} and\n     * {@link Ext.container.Container}, this defaults to **'div'**. The more complex Sencha classes use a more\n     * complex DOM structure specified by their own {@link #renderTpl}s.\n     *\n     * This is intended to allow the developer to create application-specific utility Components encapsulated by\n     * different DOM elements. Example usage:\n     *\n     *     {\n     *         xtype: 'component',\n     *         autoEl: {\n     *             tag: 'img',\n     *             src: 'http://www.example.com/example.jpg'\n     *         }\n     *     }, {\n     *         xtype: 'component',\n     *         autoEl: {\n     *             tag: 'blockquote',\n     *             html: 'autoEl is cool!'\n     *         }\n     *     }, {\n     *         xtype: 'container',\n     *         autoEl: 'ul',\n     *         cls: 'ux-unordered-list',\n     *         items: {\n     *             xtype: 'component',\n     *             autoEl: 'li',\n     *             html: 'First list item'\n     *         }\n     *     }\n     */\n\n    /**\n     * @cfg {Ext.XTemplate/String/String[]} renderTpl\n     * An {@link Ext.XTemplate XTemplate} used to create the internal structure inside this Component's encapsulating\n     * {@link #getEl Element}.\n     *\n     * You do not normally need to specify this. For the base classes {@link Ext.Component} and\n     * {@link Ext.container.Container}, this defaults to **`null`** which means that they will be initially rendered\n     * with no internal structure; they render their {@link #getEl Element} empty. The more specialized ExtJS and Touch\n     * classes which use a more complex DOM structure, provide their own template definitions.\n     *\n     * This is intended to allow the developer to create application-specific utility Components with customized\n     * internal structure.\n     *\n     * Upon rendering, any created child elements may be automatically imported into object properties using the\n     * {@link #renderSelectors} and {@link #cfg-childEls} options.\n     * @protected\n     */\n    renderTpl: '{%this.renderContent(out,values)%}',\n\n    /**\n     * @cfg {Object} renderData\n     *\n     * The data used by {@link #renderTpl} in addition to the following property values of the component:\n     *\n     * - id\n     * - ui\n     * - uiCls\n     * - baseCls\n     * - componentCls\n     * - frame\n     *\n     * See {@link #renderSelectors} and {@link #cfg-childEls} for usage examples.\n     */\n\n    /**\n     * @cfg {Object} renderSelectors\n     * An object containing properties specifying {@link Ext.DomQuery DomQuery} selectors which identify child elements\n     * created by the render process.\n     *\n     * After the Component's internal structure is rendered according to the {@link #renderTpl}, this object is iterated through,\n     * and the found Elements are added as properties to the Component using the `renderSelector` property name.\n     *\n     * For example, a Component which renderes a title and description into its element:\n     *\n     *     Ext.create('Ext.Component', {\n     *         renderTo: Ext.getBody(),\n     *         renderTpl: [\n     *             '<h1 class=\"title\">{title}</h1>',\n     *             '<p>{desc}</p>'\n     *         ],\n     *         renderData: {\n     *             title: \"Error\",\n     *             desc: \"Something went wrong\"\n     *         },\n     *         renderSelectors: {\n     *             titleEl: 'h1.title',\n     *             descEl: 'p'\n     *         },\n     *         listeners: {\n     *             afterrender: function(cmp){\n     *                 // After rendering the component will have a titleEl and descEl properties\n     *                 cmp.titleEl.setStyle({color: \"red\"});\n     *             }\n     *         }\n     *     });\n     *\n     * For a faster, but less flexible, alternative that achieves the same end result (properties for child elements on the\n     * Component after render), see {@link #cfg-childEls} and {@link #addChildEls}.\n     */\n\n    /**\n     * @cfg {Object[]} childEls\n     * An array describing the child elements of the Component. Each member of the array\n     * is an object with these properties:\n     *\n     * - `name` - The property name on the Component for the child element.\n     * - `itemId` - The id to combine with the Component's id that is the id of the child element.\n     * - `id` - The id of the child element.\n     *\n     * If the array member is a string, it is equivalent to `{ name: m, itemId: m }`.\n     *\n     * For example, a Component which renders a title and body text:\n     *\n     *     Ext.create('Ext.Component', {\n     *         renderTo: Ext.getBody(),\n     *         renderTpl: [\n     *             '<h1 id=\"{id}-title\">{title}</h1>',\n     *             '<p>{msg}</p>',\n     *         ],\n     *         renderData: {\n     *             title: \"Error\",\n     *             msg: \"Something went wrong\"\n     *         },\n     *         childEls: [\"title\"],\n     *         listeners: {\n     *             afterrender: function(cmp){\n     *                 // After rendering the component will have a title property\n     *                 cmp.title.setStyle({color: \"red\"});\n     *             }\n     *         }\n     *     });\n     *\n     * A more flexible, but somewhat slower, approach is {@link #renderSelectors}.\n     */\n\n    /**\n     * @cfg {String/HTMLElement/Ext.Element} renderTo\n     * Specify the id of the element, a DOM element or an existing Element that this component will be rendered into.\n     *\n     * **Notes:**\n     *\n     * Do *not* use this option if the Component is to be a child item of a {@link Ext.container.Container Container}.\n     * It is the responsibility of the {@link Ext.container.Container Container}'s\n     * {@link Ext.container.Container#layout layout manager} to render and manage its child items.\n     *\n     * When using this config, a call to render() is not required.\n     *\n     * See also: {@link #method-render}.\n     */\n\n    /**\n     * @cfg {Boolean} frame\n     * Specify as `true` to have the Component inject framing elements within the Component at render time to provide a\n     * graphical rounded frame around the Component content.\n     *\n     * This is only necessary when running on outdated, or non standard-compliant browsers such as Microsoft's Internet\n     * Explorer prior to version 9 which do not support rounded corners natively.\n     *\n     * The extra space taken up by this framing is available from the read only property {@link #frameSize}.\n     */\n\n    /**\n     * @property {Object} frameSize\n     * @readonly\n     * Indicates the width of any framing elements which were added within the encapsulating element\n     * to provide graphical, rounded borders. See the {@link #frame} config.\n     *\n     * This is an object containing the frame width in pixels for all four sides of the Component containing the\n     * following properties:\n     *\n     * @property {Number} [frameSize.top=0] The width of the top framing element in pixels.\n     * @property {Number} [frameSize.right=0] The width of the right framing element in pixels.\n     * @property {Number} [frameSize.bottom=0] The width of the bottom framing element in pixels.\n     * @property {Number} [frameSize.left=0] The width of the left framing element in pixels.\n     * @property {Number} [frameSize.width=0] The total width of the left and right framing elements in pixels.\n     * @property {Number} [frameSize.height=0] The total height of the top and right bottom elements in pixels.\n     */\n    frameSize: { left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 },\n\n    /**\n     * @cfg {String/Object} componentLayout\n     * The sizing and positioning of a Component's internal Elements is the responsibility of the Component's layout\n     * manager which sizes a Component's internal structure in response to the Component being sized.\n     *\n     * Generally, developers will not use this configuration as all provided Components which need their internal\n     * elements sizing (Such as {@link Ext.form.field.Base input fields}) come with their own componentLayout managers.\n     *\n     * The {@link Ext.layout.container.Auto default layout manager} will be used on instances of the base Ext.Component\n     * class which simply sizes the Component's encapsulating element to the height and width specified in the\n     * {@link #setSize} method.\n     */\n\n    /**\n     * @cfg {Ext.XTemplate/Ext.Template/String/String[]} tpl\n     * An {@link Ext.Template}, {@link Ext.XTemplate} or an array of strings to form an Ext.XTemplate. Used in\n     * conjunction with the `{@link #data}` and `{@link #tplWriteMode}` configurations.\n     */\n\n    /**\n     * @cfg {Object} data\n     * The initial set of data to apply to the `{@link #tpl}` to update the content area of the Component.\n     */\n\n    /**\n     * @cfg {String} xtype\n     * This property provides a shorter alternative to creating objects than using a full\n     * class name. Using `xtype` is the most common way to define component instances,\n     * especially in a container. For example, the items in a form containing text fields\n     * could be created explicitly like so:\n     *\n     *      items: [\n     *          Ext.create('Ext.form.field.Text', {\n     *              fieldLabel: 'Foo'\n     *          }),\n     *          Ext.create('Ext.form.field.Text', {\n     *              fieldLabel: 'Bar'\n     *          }),\n     *          Ext.create('Ext.form.field.Number', {\n     *              fieldLabel: 'Num'\n     *          })\n     *      ]\n     *\n     * But by using `xtype`, the above becomes:\n     *\n     *      items: [\n     *          {\n     *              xtype: 'textfield',\n     *              fieldLabel: 'Foo'\n     *          },\n     *          {\n     *              xtype: 'textfield',\n     *              fieldLabel: 'Bar'\n     *          },\n     *          {\n     *              xtype: 'numberfield',\n     *              fieldLabel: 'Num'\n     *          }\n     *      ]\n     *\n     * When the `xtype` is common to many items, {@link Ext.container.AbstractContainer#defaultType}\n     * is another way to specify the `xtype` for all items that don't have an explicit `xtype`:\n     *\n     *      defaultType: 'textfield',\n     *      items: [\n     *          { fieldLabel: 'Foo' },\n     *          { fieldLabel: 'Bar' },\n     *          { fieldLabel: 'Num', xtype: 'numberfield' }\n     *      ]\n     *\n     * Each member of the `items` array is now just a \"configuration object\". These objects\n     * are used to create and configure component instances. A configuration object can be\n     * manually used to instantiate a component using {@link Ext#widget}:\n     *\n     *      var text1 = Ext.create('Ext.form.field.Text', {\n     *          fieldLabel: 'Foo'\n     *      });\n     *\n     *      // or alternatively:\n     *\n     *      var text1 = Ext.widget({\n     *          xtype: 'textfield',\n     *          fieldLabel: 'Foo'\n     *      });\n     *\n     * This conversion of configuration objects into instantiated components is done when\n     * a container is created as part of its {Ext.container.AbstractContainer#initComponent}\n     * process. As part of the same process, the `items` array is converted from its raw\n     * array form into a {@link Ext.util.MixedCollection} instance.\n     *\n     * You can define your own `xtype` on a custom {@link Ext.Component component} by specifying\n     * the `xtype` property in {@link Ext#define}. For example:\n     *\n     *     Ext.define('MyApp.PressMeButton', {\n     *         extend: 'Ext.button.Button',\n     *         xtype: 'pressmebutton',\n     *         text: 'Press Me'\n     *     });\n     *\n     * Care should be taken when naming an `xtype` in a custom component because there is\n     * a single, shared scope for all xtypes. Third part components should consider using\n     * a prefix to avoid collisions.\n     *\n     *     Ext.define('Foo.form.CoolButton', {\n     *         extend: 'Ext.button.Button',\n     *         xtype: 'ux-coolbutton',\n     *         text: 'Cool!'\n     *     });\n     */\n\n    /**\n     * @cfg {String} tplWriteMode\n     * The Ext.(X)Template method to use when updating the content area of the Component.\n     * See `{@link Ext.XTemplate#overwrite}` for information on default mode.\n     */\n    tplWriteMode: 'overwrite',\n\n    /**\n     * @cfg {String} [baseCls='x-component']\n     * The base CSS class to apply to this components's element. This will also be prepended to elements within this\n     * component like Panel's body will get a class x-panel-body. This means that if you create a subclass of Panel, and\n     * you want it to get all the Panels styling for the element and the body, you leave the baseCls x-panel and use\n     * componentCls to add specific styling for this component.\n     */\n    baseCls: Ext.baseCSSPrefix + 'component',\n\n    /**\n     * @cfg {String} componentCls\n     * CSS Class to be added to a components root level element to give distinction to it via styling.\n     */\n\n    /**\n     * @cfg {String} [cls='']\n     * An optional extra CSS class that will be added to this component's Element. This can be useful\n     * for adding customized styles to the component or any of its children using standard CSS rules.\n     */\n\n    /**\n     * @cfg {String} [overCls='']\n     * An optional extra CSS class that will be added to this component's Element when the mouse moves over the Element,\n     * and removed when the mouse moves out. This can be useful for adding customized 'active' or 'hover' styles to the\n     * component or any of its children using standard CSS rules.\n     */\n\n    /**\n     * @cfg {String} [disabledCls='x-item-disabled']\n     * CSS class to add when the Component is disabled. Defaults to 'x-item-disabled'.\n     */\n    disabledCls: Ext.baseCSSPrefix + 'item-disabled',\n\n    /**\n     * @cfg {String} ui\n     * A UI style for a component.\n     */\n    ui: 'default',\n\n    /**\n     * @cfg {String[]} uiCls\n     * An array of of classNames which are currently applied to this component\n     * @private\n     */\n    uiCls: [],\n\n    /**\n     * @cfg {String/Object} style\n     * A custom style specification to be applied to this component's Element. Should be a valid argument to\n     * {@link Ext.Element#applyStyles}.\n     *\n     *     new Ext.panel.Panel({\n     *         title: 'Some Title',\n     *         renderTo: Ext.getBody(),\n     *         width: 400, height: 300,\n     *         layout: 'form',\n     *         items: [{\n     *             xtype: 'textarea',\n     *             style: {\n     *                 width: '95%',\n     *                 marginBottom: '10px'\n     *             }\n     *         },\n     *         new Ext.button.Button({\n     *             text: 'Send',\n     *             minWidth: '100',\n     *             style: {\n     *                 marginBottom: '10px'\n     *             }\n     *         })\n     *         ]\n     *     });\n     */\n\n    /**\n     * @cfg {Number} width\n     * The width of this component in pixels.\n     */\n\n    /**\n     * @cfg {Number} height\n     * The height of this component in pixels.\n     */\n\n    /**\n     * @cfg {Number/String/Boolean} border\n     * Specifies the border size for this component. The border can be a single numeric value to apply to all sides or it can\n     * be a CSS style specification for each style, for example: '10 5 3 10'.\n     *\n     * For components that have no border by default, setting this won't make the border appear by itself.\n     * You also need to specify border color and style:\n     *\n     *     border: 5,\n     *     style: {\n     *         borderColor: 'red',\n     *         borderStyle: 'solid'\n     *     }\n     * \n     * To turn off the border, use `border: false`.\n     */\n\n    /**\n     * @cfg {Number/String} padding\n     * Specifies the padding for this component. The padding can be a single numeric value to apply to all sides or it\n     * can be a CSS style specification for each style, for example: '10 5 3 10'.\n     */\n\n    /**\n     * @cfg {Number/String} margin\n     * Specifies the margin for this component. The margin can be a single numeric value to apply to all sides or it can\n     * be a CSS style specification for each style, for example: '10 5 3 10'.\n     */\n\n    /**\n     * @cfg {Boolean} hidden\n     * True to hide the component.\n     */\n    hidden: false,\n\n    /**\n     * @cfg {Boolean} disabled\n     * True to disable the component.\n     */\n    disabled: false,\n\n    /**\n     * @cfg {Boolean} [draggable=false]\n     * Allows the component to be dragged.\n     */\n\n    /**\n     * @property {Boolean} draggable\n     * Indicates whether or not the component can be dragged.\n     * @readonly\n     */\n    draggable: false,\n\n    /**\n     * @cfg {Boolean} floating\n     * Create the Component as a floating and use absolute positioning.\n     *\n     * The z-index of floating Components is handled by a ZIndexManager. If you simply render a floating Component into the DOM, it will be managed\n     * by the global {@link Ext.WindowManager WindowManager}.\n     *\n     * If you include a floating Component as a child item of a Container, then upon render, ExtJS will seek an ancestor floating Component to house a new\n     * ZIndexManager instance to manage its descendant floaters. If no floating ancestor can be found, the global WindowManager will be used.\n     *\n     * When a floating Component which has a ZindexManager managing descendant floaters is destroyed, those descendant floaters will also be destroyed.\n     */\n    floating: false,\n\n    /**\n     * @cfg {String} hideMode\n     * A String which specifies how this Component's encapsulating DOM element will be hidden. Values may be:\n     *\n     *   - `'display'` : The Component will be hidden using the `display: none` style.\n     *   - `'visibility'` : The Component will be hidden using the `visibility: hidden` style.\n     *   - `'offsets'` : The Component will be hidden by absolutely positioning it out of the visible area of the document.\n     *     This is useful when a hidden Component must maintain measurable dimensions. Hiding using `display` results in a\n     *     Component having zero dimensions.\n     */\n    hideMode: 'display',\n\n    /**\n     * @cfg {String} contentEl\n     * Specify an existing HTML element, or the `id` of an existing HTML element to use as the content for this component.\n     *\n     * This config option is used to take an existing HTML element and place it in the layout element of a new component\n     * (it simply moves the specified DOM element _after the Component is rendered_ to use as the content.\n     *\n     * **Notes:**\n     *\n     * The specified HTML element is appended to the layout element of the component _after any configured\n     * {@link #html HTML} has been inserted_, and so the document will not contain this element at the time\n     * the {@link #event-render} event is fired.\n     *\n     * The specified HTML element used will not participate in any **`{@link Ext.container.Container#layout layout}`**\n     * scheme that the Component may use. It is just HTML. Layouts operate on child\n     * **`{@link Ext.container.Container#cfg-items items}`**.\n     *\n     * Add either the `x-hidden` or the `x-hide-display` CSS class to prevent a brief flicker of the content before it\n     * is rendered to the panel.\n     */\n\n    /**\n     * @cfg {String/Object} [html='']\n     * An HTML fragment, or a {@link Ext.DomHelper DomHelper} specification to use as the layout element content.\n     * The HTML content is added after the component is rendered, so the document will not contain this HTML at the time\n     * the {@link #event-render} event is fired. This content is inserted into the body _before_ any configured {@link #contentEl}\n     * is appended.\n     */\n\n    /**\n     * @cfg {Boolean} styleHtmlContent\n     * True to automatically style the html inside the content target of this component (body for panels).\n     */\n    styleHtmlContent: false,\n\n    /**\n     * @cfg {String} [styleHtmlCls='x-html']\n     * The class that is added to the content target when you set styleHtmlContent to true.\n     */\n    styleHtmlCls: Ext.baseCSSPrefix + 'html',\n\n    /**\n     * @cfg {Number} minHeight\n     * The minimum value in pixels which this Component will set its height to.\n     *\n     * **Warning:** This will override any size management applied by layout managers.\n     */\n    /**\n     * @cfg {Number} minWidth\n     * The minimum value in pixels which this Component will set its width to.\n     *\n     * **Warning:** This will override any size management applied by layout managers.\n     */\n    /**\n     * @cfg {Number} maxHeight\n     * The maximum value in pixels which this Component will set its height to.\n     *\n     * **Warning:** This will override any size management applied by layout managers.\n     */\n    /**\n     * @cfg {Number} maxWidth\n     * The maximum value in pixels which this Component will set its width to.\n     *\n     * **Warning:** This will override any size management applied by layout managers.\n     */\n\n    /**\n     * @cfg {Ext.ComponentLoader/Object} loader\n     * A configuration object or an instance of a {@link Ext.ComponentLoader} to load remote content\n     * for this Component.\n     *\n     *     Ext.create('Ext.Component', {\n     *         loader: {\n     *             url: 'content.html',\n     *             autoLoad: true\n     *         },\n     *         renderTo: Ext.getBody()\n     *     });\n     */\n\n    /**\n     * @cfg {Ext.ComponentLoader/Object/String/Boolean} autoLoad\n     * An alias for {@link #loader} config which also allows to specify just a string which will be\n     * used as the url that's automatically loaded:\n     *\n     *     Ext.create('Ext.Component', {\n     *         autoLoad: 'content.html',\n     *         renderTo: Ext.getBody()\n     *     });\n     *\n     * The above is the same as:\n     *\n     *     Ext.create('Ext.Component', {\n     *         loader: {\n     *             url: 'content.html',\n     *             autoLoad: true\n     *         },\n     *         renderTo: Ext.getBody()\n     *     });\n     *\n     * Don't use it together with {@link #loader} config.\n     *\n     * @deprecated 4.1.1 Use {@link #loader} config instead.\n     */\n\n    /**\n     * @cfg {Boolean} autoShow\n     * True to automatically show the component upon creation. This config option may only be used for\n     * {@link #floating} components or components that use {@link #autoRender}. Defaults to false.\n     */\n    autoShow: false,\n\n    /**\n     * @cfg {Boolean/String/HTMLElement/Ext.Element} autoRender\n     * This config is intended mainly for non-{@link #floating} Components which may or may not be shown. Instead of using\n     * {@link #renderTo} in the configuration, and rendering upon construction, this allows a Component to render itself\n     * upon first _{@link Ext.Component#method-show show}_. If {@link #floating} is true, the value of this config is omited as if it is `true`.\n     *\n     * Specify as `true` to have this Component render to the document body upon first show.\n     *\n     * Specify as an element, or the ID of an element to have this Component render to a specific element upon first\n     * show.\n     */\n    autoRender: false,\n\n    // @private\n    allowDomMove: true,\n\n    /**\n     * @cfg {Object/Object[]} plugins\n     * An object or array of objects that will provide custom functionality for this component. The only requirement for\n     * a valid plugin is that it contain an init method that accepts a reference of type Ext.Component. When a component\n     * is created, if any plugins are available, the component will call the init method on each plugin, passing a\n     * reference to itself. Each plugin can then call methods or respond to events on the component as needed to provide\n     * its functionality.\n     */\n\n    /**\n     * @property {Boolean} rendered\n     * Indicates whether or not the component has been rendered.\n     * @readonly\n     */\n    rendered: false,\n\n    /**\n     * @property {Number} componentLayoutCounter\n     * @private\n     * The number of component layout calls made on this object.\n     */\n    componentLayoutCounter: 0,\n\n    /**\n     * @cfg {Boolean/Number} [shrinkWrap=2]\n     *\n     * If this property is a number, it is interpreted as follows:\n     *\n     *   - 0: Neither width nor height depend on content. This is equivalent to `false`.\n     *   - 1: Width depends on content (shrink wraps), but height does not.\n     *   - 2: Height depends on content (shrink wraps), but width does not. The default.\n     *   - 3: Both width and height depend on content (shrink wrap). This is equivalent to `true`.\n     *\n     * In CSS terms, shrink-wrap width is analogous to an inline-block element as opposed\n     * to a block-level element. Some container layouts always shrink-wrap their children,\n     * effectively ignoring this property (e.g., {@link Ext.layout.container.HBox},\n     * {@link Ext.layout.container.VBox}, {@link Ext.layout.component.Dock}).\n     */\n    shrinkWrap: 2,\n\n    weight: 0,\n\n    /**\n     * @property {Boolean} maskOnDisable\n     * This is an internal flag that you use when creating custom components. By default this is set to true which means\n     * that every component gets a mask when it's disabled. Components like FieldContainer, FieldSet, Field, Button, Tab\n     * override this property to false since they want to implement custom disable logic.\n     */\n    maskOnDisable: true,\n\n    /**\n     * @property {Boolean} [_isLayoutRoot=false]\n     * Setting this property to `true` causes the {@link #isLayoutRoot} method to return\n     * `true` and stop the search for the top-most component for a layout.\n     * @protected\n     */\n    _isLayoutRoot: false,\n\n    /**\n     * Creates new Component.\n     * @param {Object} config  (optional) Config object.\n     */\n    constructor : function(config) {\n        var me = this,\n            i, len, xhooks;\n\n        if (config) {\n            Ext.apply(me, config);\n\n            xhooks = me.xhooks;\n            if (xhooks) {\n                delete me.xhooks;\n                Ext.override(me, xhooks);\n            }\n        } else {\n            config = {};\n        }\n\n        me.initialConfig = config;\n\n        me.mixins.elementCt.constructor.call(me);\n\n        me.addEvents(\n            /**\n             * @event beforeactivate\n             * Fires before a Component has been visually activated. Returning false from an event listener can prevent\n             * the activate from occurring.\n             * @param {Ext.Component} this\n             */\n            'beforeactivate',\n            /**\n             * @event activate\n             * Fires after a Component has been visually activated.\n             * @param {Ext.Component} this\n             */\n            'activate',\n            /**\n             * @event beforedeactivate\n             * Fires before a Component has been visually deactivated. Returning false from an event listener can\n             * prevent the deactivate from occurring.\n             * @param {Ext.Component} this\n             */\n            'beforedeactivate',\n            /**\n             * @event deactivate\n             * Fires after a Component has been visually deactivated.\n             * @param {Ext.Component} this\n             */\n            'deactivate',\n            /**\n             * @event added\n             * Fires after a Component had been added to a Container.\n             * @param {Ext.Component} this\n             * @param {Ext.container.Container} container Parent Container\n             * @param {Number} pos position of Component\n             */\n            'added',\n            /**\n             * @event disable\n             * Fires after the component is disabled.\n             * @param {Ext.Component} this\n             */\n            'disable',\n            /**\n             * @event enable\n             * Fires after the component is enabled.\n             * @param {Ext.Component} this\n             */\n            'enable',\n            /**\n             * @event beforeshow\n             * Fires before the component is shown when calling the {@link Ext.Component#method-show show} method. Return false from an event\n             * handler to stop the show.\n             * @param {Ext.Component} this\n             */\n            'beforeshow',\n            /**\n             * @event show\n             * Fires after the component is shown when calling the {@link Ext.Component#method-show show} method.\n             * @param {Ext.Component} this\n             */\n            'show',\n            /**\n             * @event beforehide\n             * Fires before the component is hidden when calling the {@link Ext.Component#method-hide hide} method. Return false from an event\n             * handler to stop the hide.\n             * @param {Ext.Component} this\n             */\n            'beforehide',\n            /**\n             * @event hide\n             * Fires after the component is hidden. Fires after the component is hidden when calling the {@link Ext.Component#method-hide hide}\n             * method.\n             * @param {Ext.Component} this\n             */\n            'hide',\n            /**\n             * @event removed\n             * Fires when a component is removed from an Ext.container.Container\n             * @param {Ext.Component} this\n             * @param {Ext.container.Container} ownerCt Container which holds the component\n             */\n            'removed',\n            /**\n             * @event beforerender\n             * Fires before the component is {@link #rendered}. Return false from an event handler to stop the\n             * {@link #method-render}.\n             * @param {Ext.Component} this\n             */\n            'beforerender',\n            /**\n             * @event render\n             * Fires after the component markup is {@link #rendered}.\n             * @param {Ext.Component} this\n             */\n            'render',\n            /**\n             * @event afterrender\n             * Fires after the component rendering is finished.\n             *\n             * The afterrender event is fired after this Component has been {@link #rendered}, been postprocesed by any\n             * afterRender method defined for the Component.\n             * @param {Ext.Component} this\n             */\n            'afterrender',\n            /**\n             * @event boxready\n             * Fires *one time* - after the component has been layed out for the first time at its initial size.\n             * @param {Ext.Component} this\n             * @param {Number} width The initial width\n             * @param {Number} height The initial height\n             */\n            'boxready',\n            /**\n             * @event beforedestroy\n             * Fires before the component is {@link #method-destroy}ed. Return false from an event handler to stop the\n             * {@link #method-destroy}.\n             * @param {Ext.Component} this\n             */\n            'beforedestroy',\n            /**\n             * @event destroy\n             * Fires after the component is {@link #method-destroy}ed.\n             * @param {Ext.Component} this\n             */\n            'destroy',\n            /**\n             * @event resize\n             * Fires after the component is resized. Note that this does *not* fire when the component is first layed out at its initial\n             * size. To hook that point in the lifecycle, use the {@link #boxready} event.\n             * @param {Ext.Component} this\n             * @param {Number} width The new width that was set\n             * @param {Number} height The new height that was set\n             * @param {Number} oldWidth The previous width\n             * @param {Number} oldHeight The previous height\n             */\n            'resize',\n            /**\n             * @event move\n             * Fires after the component is moved.\n             * @param {Ext.Component} this\n             * @param {Number} x The new x position\n             * @param {Number} y The new y position\n             */\n             'move',\n            /**\n             * @event focus\n             * Fires when this Component receives focus.\n             * @param {Ext.Component} this\n             * @param {Ext.EventObject} The focus event.\n             */\n            'focus',\n            /**\n             * @event blur\n             * Fires when this Component loses focus.\n             * @param {Ext.Component} this\n             * @param {Ext.EventObject} The blur event.\n             */\n            'blur'\n        );\n\n        me.getId();\n\n        me.setupProtoEl();\n\n        // initComponent, beforeRender, or event handlers may have set the style or cls property since the protoEl was set up\n        // so we must apply styles and classes here too.\n        if (me.cls) {\n            me.initialCls = me.cls;\n            me.protoEl.addCls(me.cls);\n        }\n        if (me.style) {\n            me.initialStyle = me.style;\n            me.protoEl.setStyle(me.style);\n        }\n\n        me.mons = [];\n        me.renderData = me.renderData || {};\n        me.renderSelectors = me.renderSelectors || {};\n\n        if (me.plugins) {\n            me.plugins = me.constructPlugins();\n        }\n\n        // we need this before we call initComponent\n        if (!me.hasListeners) {\n            me.hasListeners = new me.HasListeners();\n        }\n\n        me.initComponent();\n\n        // ititComponent gets a chance to change the id property before registering\n        Ext.ComponentManager.register(me);\n\n        // Dont pass the config so that it is not applied to 'this' again\n        me.mixins.observable.constructor.call(me);\n        me.mixins.state.constructor.call(me, config);\n\n        // Save state on resize.\n        this.addStateEvents('resize');\n\n        // Move this into Observable?\n        if (me.plugins) {\n            for (i = 0, len = me.plugins.length; i < len; i++) {\n                me.plugins[i] = me.initPlugin(me.plugins[i]);\n            }\n        }\n\n        me.loader = me.getLoader();\n\n        if (me.renderTo) {\n            me.render(me.renderTo);\n            // EXTJSIV-1935 - should be a way to do afterShow or something, but that\n            // won't work. Likewise, rendering hidden and then showing (w/autoShow) has\n            // implications to afterRender so we cannot do that.\n        }\n\n        // Auto show only works unilaterally on *uncontained* Components.\n        // If contained, then it is the Container's responsibility to do the showing at next layout time.\n        if (me.autoShow && !me.isContained) {\n            me.show();\n        }\n\n        if (Ext.isDefined(me.disabledClass)) {\n            if (Ext.isDefined(Ext.global.console)) {\n                Ext.global.console.warn('Ext.Component: disabledClass has been deprecated. Please use disabledCls.');\n            }\n            me.disabledCls = me.disabledClass;\n            delete me.disabledClass;\n        }\n    },\n\n    initComponent: function () {\n        // This is called again here to allow derived classes to add plugin configs to the\n        // plugins array before calling down to this, the base initComponent.\n        this.plugins = this.constructPlugins();\n\n        // this will properly (ignore or) constrain the configured width/height to their\n        // min/max values for consistency.\n        this.setSize(this.width, this.height);\n    },\n\n    /**\n     * The supplied default state gathering method for the AbstractComponent class.\n     *\n     * This method returns dimension settings such as `flex`, `anchor`, `width` and `height` along with `collapsed`\n     * state.\n     *\n     * Subclasses which implement more complex state should call the superclass's implementation, and apply their state\n     * to the result if this basic state is to be saved.\n     *\n     * Note that Component state will only be saved if the Component has a {@link #stateId} and there as a StateProvider\n     * configured for the document.\n     *\n     * @return {Object}\n     */\n    getState: function() {\n        var me = this,\n            state = null,\n            sizeModel = me.getSizeModel();\n\n        if (sizeModel.width.configured) {\n            state = me.addPropertyToState(state, 'width');\n        }\n        if (sizeModel.height.configured) {\n            state = me.addPropertyToState(state, 'height');\n        }\n\n        return state;\n    },\n\n    /**\n     * Save a property to the given state object if it is not its default or configured\n     * value.\n     *\n     * @param {Object} state The state object\n     * @param {String} propName The name of the property on this object to save.\n     * @param {String} [value] The value of the state property (defaults to `this[propName]`).\n     * @return {Boolean} The state object or a new object if state was null and the property\n     * was saved.\n     * @protected\n     */\n    addPropertyToState: function (state, propName, value) {\n        var me = this,\n            len = arguments.length;\n\n        // If the property is inherited, it is a default and we don't want to save it to\n        // the state, however if we explicitly specify a value, always save it\n        if (len == 3 || me.hasOwnProperty(propName)) {\n            if (len < 3) {\n                value = me[propName];\n            }\n\n            // If the property has the same value as was initially configured, again, we\n            // don't want to save it.\n            if (value !== me.initialConfig[propName]) {\n                (state || (state = {}))[propName] = value;\n            }\n        }\n\n        return state;\n    },\n\n    show: Ext.emptyFn,\n\n    animate: function(animObj) {\n        var me = this,\n            hasToWidth,\n            hasToHeight,\n            toHeight,\n            toWidth,\n            to,\n            clearWidth,\n            clearHeight,\n            curWidth, w, curHeight, h, needsResize;\n\n        animObj = animObj || {};\n        to = animObj.to || {};\n\n        if (Ext.fx.Manager.hasFxBlock(me.id)) {\n            return me;\n        }\n\n        hasToWidth = Ext.isDefined(to.width);\n        if (hasToWidth) {\n            toWidth = Ext.Number.constrain(to.width, me.minWidth, me.maxWidth);\n        }\n\n        hasToHeight = Ext.isDefined(to.height);\n        if (hasToHeight) {\n            toHeight = Ext.Number.constrain(to.height, me.minHeight, me.maxHeight);\n        }\n\n        // Special processing for animating Component dimensions.\n        if (!animObj.dynamic && (hasToWidth || hasToHeight)) {\n            curWidth = (animObj.from ? animObj.from.width : undefined) || me.getWidth();\n            w = curWidth;\n            curHeight = (animObj.from ? animObj.from.height : undefined) || me.getHeight();\n            h = curHeight;\n            needsResize = false;\n\n            if (hasToHeight && toHeight > curHeight) {\n                h = toHeight;\n                needsResize = true;\n            }\n            if (hasToWidth && toWidth > curWidth) {\n                w = toWidth;\n                needsResize = true;\n            }\n\n            // If any dimensions are being increased, we must resize the internal structure\n            // of the Component, but then clip it by sizing its encapsulating element back to original dimensions.\n            // The animation will then progressively reveal the larger content.\n            if (needsResize) {\n                clearWidth = !Ext.isNumber(me.width);\n                clearHeight = !Ext.isNumber(me.height);\n\n                me.setSize(w, h);\n                me.el.setSize(curWidth, curHeight);\n                if (clearWidth) {\n                    delete me.width;\n                }\n                if (clearHeight) {\n                    delete me.height;\n                }\n            }\n            if (hasToWidth) {\n                to.width = toWidth;\n            }\n\n            if (hasToHeight) {\n                to.height = toHeight;\n            }\n        }\n        return me.mixins.animate.animate.apply(me, arguments);\n    },\n\n    onHide: function() {\n        this.updateLayout({ isRoot: false });\n    },\n\n    onShow : function() {\n        this.updateLayout({ isRoot: false });\n    },\n\n    constructPlugin: function(plugin) {\n        \n        // If a config object with a ptype\n        if (plugin.ptype && typeof plugin.init != 'function') {\n            plugin.cmp = this;\n            plugin = Ext.PluginManager.create(plugin);\n        }\n        // Just a ptype\n        else if (typeof plugin == 'string') {\n            plugin = Ext.PluginManager.create({\n                ptype: plugin,\n                cmp: this\n            });\n        }\n        return plugin;\n    },\n\n    /**\n     * @private\n     * Returns an array of fully constructed plugin instances. This converts any configs into their\n     * appropriate instances.\n     *\n     * It does not mutate the plugins array. It creates a new array.\n     *\n     * This is borrowed by {@link Ext.grid.Lockable Lockable} which clones and distributes Plugins\n     * to both child grids of a locking grid, so must keep to that contract.\n     */\n    constructPlugins: function() {\n        var me = this,\n            plugins,\n            result = [],\n            i, len;\n\n        if (me.plugins) {\n            plugins = Ext.isArray(me.plugins) ? me.plugins : [ me.plugins ];\n            for (i = 0, len = plugins.length; i < len; i++) {\n                // this just returns already-constructed plugin instances...\n                result[i] = me.constructPlugin(plugins[i]);\n            }\n            return result;\n        }\n    },\n\n    // @private\n    initPlugin : function(plugin) {\n        plugin.init(this);\n\n        return plugin;\n    },\n\n    /**\n     * @private\n     * Injected as an override by Ext.Aria.initialize\n     */\n    updateAria: Ext.emptyFn,\n\n    /**\n     * Called by Component#doAutoRender\n     *\n     * Register a Container configured `floating: true` with this Component's {@link Ext.ZIndexManager ZIndexManager}.\n     *\n     * Components added in ths way will not participate in any layout, but will be rendered\n     * upon first show in the way that {@link Ext.window.Window Window}s are.\n     */\n    registerFloatingItem: function(cmp) {\n        var me = this;\n        if (!me.floatingDescendants) {\n            me.floatingDescendants = new Ext.ZIndexManager(me);\n        }\n        me.floatingDescendants.register(cmp);\n    },\n\n    unregisterFloatingItem: function(cmp) {\n        var me = this;\n        if (me.floatingDescendants) {\n            me.floatingDescendants.unregister(cmp);\n        }\n    },\n\n    layoutSuspendCount: 0,\n\n    suspendLayouts: function () {\n        var me = this;\n        if (!me.rendered) {\n            return;\n        }\n        if (++me.layoutSuspendCount == 1) {\n            me.suspendLayout = true;\n        }\n    },\n\n    resumeLayouts: function (flushOptions) {\n        var me = this;\n        if (!me.rendered) {\n            return;\n        }\n        if (! --me.layoutSuspendCount) {\n            me.suspendLayout = false;\n            if (flushOptions && !me.isLayoutSuspended()) {\n                me.updateLayout(flushOptions);\n            }\n        }\n    },\n\n    setupProtoEl: function() {\n        var me = this,\n            cls = [ me.baseCls, me.getComponentLayout().targetCls ];\n\n        if (Ext.isDefined(me.cmpCls)) {\n            if (Ext.isDefined(Ext.global.console)) {\n                Ext.global.console.warn('Ext.Component: cmpCls has been deprecated. Please use componentCls.');\n            }\n            me.componentCls = me.cmpCls;\n            delete me.cmpCls;\n        }\n\n        if (me.componentCls) {\n            cls.push(me.componentCls);\n        } else {\n            me.componentCls = me.baseCls;\n        }\n\n        me.protoEl = new Ext.util.ProtoElement({\n            cls: cls.join(' ') // in case any of the parts have multiple classes\n        });\n    },\n\n    /**\n     * Sets the UI for the component. This will remove any existing UIs on the component. It will also loop through any\n     * uiCls set on the component and rename them so they include the new UI\n     * @param {String} ui The new UI for the component\n     */\n    setUI: function(ui) {\n        var me = this,\n            oldUICls = Ext.Array.clone(me.uiCls),\n            newUICls = [],\n            classes = [],\n            cls,\n            i;\n\n        //loop through all existing uiCls and update the ui in them\n        for (i = 0; i < oldUICls.length; i++) {\n            cls = oldUICls[i];\n\n            classes = classes.concat(me.removeClsWithUI(cls, true));\n            newUICls.push(cls);\n        }\n\n        if (classes.length) {\n            me.removeCls(classes);\n        }\n\n        //remove the UI from the element\n        me.removeUIFromElement();\n\n        //set the UI\n        me.ui = ui;\n\n        //add the new UI to the element\n        me.addUIToElement();\n\n        //loop through all existing uiCls and update the ui in them\n        classes = [];\n        for (i = 0; i < newUICls.length; i++) {\n            cls = newUICls[i];\n            classes = classes.concat(me.addClsWithUI(cls, true));\n        }\n\n        if (classes.length) {\n            me.addCls(classes);\n        }\n\n        // Changing the ui can lead to significant changes to a component's appearance, so the layout needs to be\n        // updated. Internally most calls to setUI are pre-render. Buttons are a notable exception as setScale changes\n        // the ui and often requires the layout to be updated.\n        if (me.rendered) {\n            me.updateLayout();\n        }\n    },\n\n    /**\n     * Adds a cls to the uiCls array, which will also call {@link #addUIClsToElement} and adds to all elements of this\n     * component.\n     * @param {String/String[]} classes A string or an array of strings to add to the uiCls\n     * @param {Object} skip (Boolean) skip True to skip adding it to the class and do it later (via the return)\n     */\n    addClsWithUI: function(classes, skip) {\n        var me = this,\n            clsArray = [],\n            length,\n            i = 0,\n            cls;\n\n        if (typeof classes === \"string\") {\n            classes = (classes.indexOf(' ') < 0) ? [classes] : Ext.String.splitWords(classes);\n        }\n\n        length = classes.length;\n\n        me.uiCls = Ext.Array.clone(me.uiCls);\n\n        for (; i < length; i++) {\n            cls = classes[i];\n            if (cls && !me.hasUICls(cls)) {\n                me.uiCls.push(cls);\n                clsArray = clsArray.concat(me.addUIClsToElement(cls));\n            }\n        }\n\n        if (skip !== true) {\n            me.addCls(clsArray);\n        }\n\n        return clsArray;\n    },\n\n    /**\n     * Removes a cls to the uiCls array, which will also call {@link #removeUIClsFromElement} and removes it from all\n     * elements of this component.\n     * @param {String/String[]} cls A string or an array of strings to remove to the uiCls\n     */\n    removeClsWithUI: function(classes, skip) {\n        var me = this,\n            clsArray = [],\n            i = 0,\n            length, cls;\n\n        if (typeof classes === \"string\") {\n            classes = (classes.indexOf(' ') < 0) ? [classes] : Ext.String.splitWords(classes);\n        }\n\n        length = classes.length;\n\n        for (i = 0; i < length; i++) {\n            cls = classes[i];\n            if (cls && me.hasUICls(cls)) {\n                me.uiCls = Ext.Array.remove(me.uiCls, cls);\n                clsArray = clsArray.concat(me.removeUIClsFromElement(cls));\n            }\n        }\n\n        if (skip !== true) {\n            me.removeCls(clsArray);\n        }\n\n        return clsArray;\n    },\n\n    /**\n     * Checks if there is currently a specified uiCls\n     * @param {String} cls The cls to check\n     */\n    hasUICls: function(cls) {\n        var me = this,\n            uiCls = me.uiCls || [];\n\n        return Ext.Array.contains(uiCls, cls);\n    },\n\n    frameElementsArray: ['tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br'],\n\n    /**\n     * Method which adds a specified UI + uiCls to the components element. Can be overridden to remove the UI from more\n     * than just the components element.\n     * @param {String} ui The UI to remove from the element\n     */\n    addUIClsToElement: function(cls) {\n        var me = this,\n            baseClsUi = me.baseCls + '-' + me.ui + '-' + cls,\n            result = [Ext.baseCSSPrefix + cls, me.baseCls + '-' + cls, baseClsUi],\n            frameElementCls = me.frameElementCls,\n            frameElementsArray, frameElementsLength, i, el, frameElement, c;\n\n        if (me.frame && !Ext.supports.CSS3BorderRadius) {\n            // define each element of the frame\n            frameElementsArray = me.frameElementsArray;\n            frameElementsLength = frameElementsArray.length;\n            i = 0;\n\n            // loop through each of them, and if they are defined add the ui\n            for (; i < frameElementsLength; i++) {\n                frameElement = frameElementsArray[i];\n                el = me['frame' + frameElement.toUpperCase()];\n                c = baseClsUi + '-' + frameElement;\n                if (el && el.dom) {\n                    el.addCls(c);\n                } else if (Ext.Array.indexOf(frameElementCls[frameElement], c) == -1) {\n                    frameElementCls[frameElement].push(c);\n                }\n            }\n        }\n\n        me.frameElementCls = frameElementCls;\n\n        return result;\n    },\n\n    /**\n     * Method which removes a specified UI + uiCls from the components element. The cls which is added to the element\n     * will be: `this.baseCls + '-' + ui`\n     * @param {String} ui The UI to add to the element\n     */\n    removeUIClsFromElement: function(cls) {\n        var me = this,\n            baseClsUi = me.baseCls + '-' + me.ui + '-' + cls,\n            result = [Ext.baseCSSPrefix + cls, me.baseCls + '-' + cls, baseClsUi],\n            frameElementCls = me.frameElementCls,\n            frameElementsArray, frameElementsLength, i, el, frameElement, c;\n\n        if (me.frame && !Ext.supports.CSS3BorderRadius) {\n            // define each element of the frame\n            frameElementsArray = me.frameElementsArray;\n            frameElementsLength = frameElementsArray.length;\n            i = 0;\n\n            // loop through each of them, and if they are defined add the ui\n            for (; i < frameElementsLength; i++) {\n                frameElement = frameElementsArray[i];\n                el = me['frame' + frameElement.toUpperCase()];\n                c = baseClsUi + '-' + frameElement;\n                if (el && el.dom) {\n                    el.addCls(c);\n                } else {\n                    Ext.Array.remove(frameElementCls[frameElement], c);\n                }\n            }\n        }\n\n        me.frameElementCls = frameElementCls;\n\n        return result;\n    },\n\n    /**\n     * Method which adds a specified UI to the components element.\n     * @private\n     */\n    addUIToElement: function() {\n        var me = this,\n            baseClsUI = me.baseCls + '-' + me.ui,\n            frameElementCls = me.frameElementCls,\n            frameElementsArray, frameElementsLength, i, el, frameElement, c;\n\n        me.addCls(baseClsUI);\n\n        if (me.frame && !Ext.supports.CSS3BorderRadius) {\n            // define each element of the frame\n            frameElementsArray = me.frameElementsArray;\n            frameElementsLength = frameElementsArray.length;\n            i = 0;\n\n            // loop through each of them, and if they are defined add the ui\n            for (; i < frameElementsLength; i++) {\n                frameElement = frameElementsArray[i];\n                el = me['frame' + frameElement.toUpperCase()];\n                c = baseClsUI + '-' + frameElement;\n                if (el) {\n                    el.addCls(c);\n                } else {\n                    if (!Ext.Array.contains(frameElementCls[frameElement], c)) {\n                        frameElementCls[frameElement].push(c);\n                    }\n                }\n            }\n        }\n    },\n\n    /**\n     * Method which removes a specified UI from the components element.\n     * @private\n     */\n    removeUIFromElement: function() {\n        var me = this,\n            baseClsUI = me.baseCls + '-' + me.ui,\n            frameElementCls = me.frameElementCls,\n            frameElementsArray, frameElementsLength, i, el, frameElement, c;\n\n        me.removeCls(baseClsUI);\n\n        if (me.frame && !Ext.supports.CSS3BorderRadius) {\n            // define each element of the frame\n            frameElementsArray = me.frameElementsArray;\n            frameElementsLength = frameElementsArray.length;\n            i = 0;\n\n            for (; i < frameElementsLength; i++) {\n                frameElement = frameElementsArray[i];\n                el = me['frame' + frameElement.toUpperCase()];\n                c = baseClsUI + '-' + frameElement;\n                if (el) {\n                    el.removeCls(c);\n                } else {\n                    Ext.Array.remove(frameElementCls[frameElement], c);\n                }\n            }\n        }\n    },\n\n    /**\n     * @private\n     */\n    getTpl: function(name) {\n        return Ext.XTemplate.getTpl(this, name);\n    },\n\n    /**\n     * Converts style definitions to String.\n     * @return {String} A CSS style string with style, padding, margin and border.\n     * @private\n     */\n    initStyles: function(targetEl) {\n        var me = this,\n            Element = Ext.Element,\n            padding = me.padding,\n            margin = me.margin,\n            x = me.x,\n            y = me.y,\n            width, height;\n\n        // Convert the padding, margin and border properties from a space separated string\n        // into a proper style string\n        if (padding !== undefined) {\n            targetEl.setStyle('padding', Element.unitizeBox((padding === true) ? 5 : padding));\n        }\n\n        if (margin !== undefined) {\n            targetEl.setStyle('margin', Element.unitizeBox((margin === true) ? 5 : margin));\n        }\n\n        if (me.border !== undefined) {\n            me.setBorder(me.border, targetEl);\n        }\n\n        // initComponent, beforeRender, or event handlers may have set the style or cls property since the protoEl was set up\n        // so we must apply styles and classes here too.\n        if (me.cls && me.cls != me.initialCls) {\n            targetEl.addCls(me.cls);\n            delete me.cls;\n            delete me.initialCls;\n        }\n        if (me.style && me.style != me.initialStyle) {\n            targetEl.setStyle(me.style);\n            delete me.style;\n            delete me.initialStyle;\n        }\n\n        if (x !== undefined) {\n            targetEl.setStyle('left', (typeof x == 'number') ? (x + 'px') : x);\n        }\n        if (y !== undefined) {\n            targetEl.setStyle('top', (typeof y == 'number') ? (y + 'px') : y);\n        }\n\n        // Framed components need their width/height to apply to the frame, which is\n        // best handled in layout at present.\n        if (!me.getFrameInfo()) {\n            width = me.width;\n            height = me.height;\n\n            // If we're using the content box model, we also cannot assign numeric initial sizes since we do not know the border widths to subtract\n            if (width !== undefined) {\n                if (typeof width === 'number') {\n                    if (Ext.isBorderBox) {\n                        targetEl.setStyle('width', width + 'px');\n                    }\n                } else {\n                    targetEl.setStyle('width', width);\n                }\n            }\n            if (height !== undefined) {\n                if (typeof height === 'number') {\n                    if (Ext.isBorderBox) {\n                        targetEl.setStyle('height', height + 'px');\n                    }\n                } else {\n                    targetEl.setStyle('height', height);\n                }\n            }\n        }\n    },\n\n    // @private\n    initEvents : function() {\n        var me = this,\n            afterRenderEvents = me.afterRenderEvents,\n            el,\n            property,\n            fn = function(listeners){\n                me.mon(el, listeners);\n            };\n\n        if (afterRenderEvents) {\n            for (property in afterRenderEvents) {\n                if (afterRenderEvents.hasOwnProperty(property)) {\n                    el = me[property];\n                    if (el && el.on) {\n                        Ext.each(afterRenderEvents[property], fn);\n                    }\n                }\n            }\n        }\n\n        // This will add focus/blur listeners to the getFocusEl() element if that is naturally focusable.\n        // If *not* naturally focusable, then the FocusManager must be enabled to get it to listen for focus so that\n        // the FocusManager can track and highlight focus.\n        me.addFocusListener();\n    },\n\n    /**\n     * @private\n     * <p>Sets up the focus listener on this Component's {@link #getFocusEl focusEl} if it has one.</p>\n     * <p>Form Components which must implicitly participate in tabbing order usually have a naturally focusable\n     * element as their {@link #getFocusEl focusEl}, and it is the DOM event of that recieving focus which drives\n     * the Component's onFocus handling, and the DOM event of it being blurred which drives the onBlur handling.</p>\n     * <p>If the {@link #getFocusEl focusEl} is <b>not</b> naturally focusable, then the listeners are only added\n     * if the {@link Ext.FocusManager FocusManager} is enabled.</p>\n     */\n    addFocusListener: function() {\n        var me = this,\n            focusEl = me.getFocusEl(),\n            needsTabIndex;\n\n        // All Containers may be focusable, not only \"form\" type elements, but also\n        // Panels, Toolbars, Windows etc.\n        // Usually, the <DIV> element they will return as their focusEl will not be able to recieve focus\n        // However, if the FocusManager is invoked, its non-default navigation handlers (invoked when\n        // tabbing/arrowing off of certain Components) may explicitly focus a Panel or Container or FieldSet etc.\n        // Add listeners to the focus and blur events on the focus element\n\n        // If this Component returns a focusEl, we might need to add a focus listener to it.\n        if (focusEl) {\n            // getFocusEl might return a Component if a Container wishes to delegate focus to a descendant.\n            // Window can do this via its defaultFocus configuration which can reference a Button.\n            if (focusEl.isComponent) {\n                return focusEl.addFocusListener();\n            }\n\n            // If the focusEl is naturally focusable, then we always need a focus listener to drive the Component's\n            // onFocus handling.\n            // If *not* naturally focusable, then we only need the focus listener if the FocusManager is enabled.\n            needsTabIndex = focusEl.needsTabIndex();\n            if (!me.focusListenerAdded && (!needsTabIndex || Ext.FocusManager.enabled)) {\n                if (needsTabIndex) {\n                    focusEl.dom.tabIndex = -1;\n                }\n                focusEl.on({\n                    focus: me.onFocus,\n                    blur: me.onBlur,\n                    scope: me\n                });\n                me.focusListenerAdded = true;\n            }\n        }\n    },\n\n    /**\n     * @private\n     * <p>Returns the focus holder element associated with this Component. At the Component base class level, this function returns <code>undefined</code>.</p>\n     * <p>Subclasses which use embedded focusable elements (such as Window, Field and Button) should override this for use by the {@link #focus} method.</p>\n     * <p>Containers which need to participate in the {@link Ext.FocusManager FocusManager}'s navigation and Container focusing scheme also\n     * need to return a focusEl, although focus is only listened for in this case if the {@link Ext.FocusManager FocusManager} is {@link Ext.FocusManager#method-enable enable}d.</p>\n     * @returns {undefined} <code>undefined</code> because raw Components cannot by default hold focus.\n     */\n    getFocusEl: Ext.emptyFn,\n\n    isFocusable: function(c) {\n        var me = this,\n            focusEl;\n        if ((me.focusable !== false) && (focusEl = me.getFocusEl()) && me.rendered && !me.destroying && !me.isDestroyed && !me.disabled && me.isVisible(true)) {\n\n            // getFocusEl might return a Component if a Container wishes to delegate focus to a descendant.\n            // Window can do this via its defaultFocus configuration which can reference a Button.\n            if (focusEl.isComponent) {\n                return focusEl.isFocusable();\n            }\n\n            return focusEl && focusEl.dom && focusEl.isVisible();\n        }\n    },\n\n    // private\n    preFocus: Ext.emptyFn,\n\n    // private\n    onFocus: function(e) {\n        var me = this,\n            focusCls = me.focusCls,\n            focusEl = me.getFocusEl();\n\n        if (!me.disabled) {\n            me.preFocus(e);\n            if (focusCls && focusEl) {\n                focusEl.addCls(me.addClsWithUI(focusCls, true));\n            }\n            if (!me.hasFocus) {\n                me.hasFocus = true;\n                me.fireEvent('focus', me, e);\n            }\n        }\n    },\n\n    // private\n    beforeBlur : Ext.emptyFn,\n\n    // private\n    onBlur : function(e) {\n        var me = this,\n            focusCls = me.focusCls,\n            focusEl = me.getFocusEl();\n\n        if (me.destroying) {\n            return;\n        }\n\n        me.beforeBlur(e);\n        if (focusCls && focusEl) {\n            focusEl.removeCls(me.removeClsWithUI(focusCls, true));\n        }\n        if (me.validateOnBlur) {\n            me.validate();\n        }\n        me.hasFocus = false;\n        me.fireEvent('blur', me, e);\n        me.postBlur(e);\n    },\n\n    // private\n    postBlur : Ext.emptyFn,\n\n    /**\n     * Tests whether this Component matches the selector string.\n     * @param {String} selector The selector string to test against.\n     * @return {Boolean} True if this Component matches the selector.\n     */\n    is: function(selector) {\n        return Ext.ComponentQuery.is(this, selector);\n    },\n\n    /**\n     * Walks up the `ownerCt` axis looking for an ancestor Container which matches the passed simple selector.\n     *\n     * Example:\n     *\n     *     var owningTabPanel = grid.up('tabpanel');\n     *\n     * @param {String} [selector] The simple selector to test.\n     * @return {Ext.container.Container} The matching ancestor Container (or `undefined` if no match was found).\n     */\n    up: function(selector) {\n        // Use bubble target to navigate upwards so that Components can implement their own hierarchy.\n        // For example Menus implement getBubbleTarget because they have a parentMenu or ownerButton as an\n        // upward link depending upon how they are owned and triggered.\n        var result = this.getBubbleTarget();\n        if (selector) {\n            for (; result; result = result.getBubbleTarget()) {\n                if (Ext.ComponentQuery.is(result, selector)) {\n                    return result;\n                }\n            }\n        }\n        return result;\n    },\n\n    /**\n     * Returns the next sibling of this Component.\n     *\n     * Optionally selects the next sibling which matches the passed {@link Ext.ComponentQuery ComponentQuery} selector.\n     *\n     * May also be refered to as **`next()`**\n     *\n     * Note that this is limited to siblings, and if no siblings of the item match, `null` is returned. Contrast with\n     * {@link #nextNode}\n     * @param {String} [selector] A {@link Ext.ComponentQuery ComponentQuery} selector to filter the following items.\n     * @return {Ext.Component} The next sibling (or the next sibling which matches the selector).\n     * Returns null if there is no matching sibling.\n     */\n    nextSibling: function(selector) {\n        var o = this.ownerCt, it, last, idx, c;\n        if (o) {\n            it = o.items;\n            idx = it.indexOf(this) + 1;\n            if (idx) {\n                if (selector) {\n                    for (last = it.getCount(); idx < last; idx++) {\n                        if ((c = it.getAt(idx)).is(selector)) {\n                            return c;\n                        }\n                    }\n                } else {\n                    if (idx < it.getCount()) {\n                        return it.getAt(idx);\n                    }\n                }\n            }\n        }\n        return null;\n    },\n\n    /**\n     * Returns the previous sibling of this Component.\n     *\n     * Optionally selects the previous sibling which matches the passed {@link Ext.ComponentQuery ComponentQuery}\n     * selector.\n     *\n     * May also be refered to as **`prev()`**\n     *\n     * Note that this is limited to siblings, and if no siblings of the item match, `null` is returned. Contrast with\n     * {@link #previousNode}\n     * @param {String} [selector] A {@link Ext.ComponentQuery ComponentQuery} selector to filter the preceding items.\n     * @return {Ext.Component} The previous sibling (or the previous sibling which matches the selector).\n     * Returns null if there is no matching sibling.\n     */\n    previousSibling: function(selector) {\n        var o = this.ownerCt, it, idx, c;\n        if (o) {\n            it = o.items;\n            idx = it.indexOf(this);\n            if (idx != -1) {\n                if (selector) {\n                    for (--idx; idx >= 0; idx--) {\n                        if ((c = it.getAt(idx)).is(selector)) {\n                            return c;\n                        }\n                    }\n                } else {\n                    if (idx) {\n                        return it.getAt(--idx);\n                    }\n                }\n            }\n        }\n        return null;\n    },\n\n    /**\n     * Returns the previous node in the Component tree in tree traversal order.\n     *\n     * Note that this is not limited to siblings, and if invoked upon a node with no matching siblings, will walk the\n     * tree in reverse order to attempt to find a match. Contrast with {@link #previousSibling}.\n     * @param {String} [selector] A {@link Ext.ComponentQuery ComponentQuery} selector to filter the preceding nodes.\n     * @return {Ext.Component} The previous node (or the previous node which matches the selector).\n     * Returns null if there is no matching node.\n     */\n    previousNode: function(selector, /* private */ includeSelf) {\n        var node = this,\n            ownerCt = node.ownerCt,\n            result,\n            it, i, sib;\n\n        // If asked to include self, test me\n        if (includeSelf && node.is(selector)) {\n            return node;\n        }\n\n        if (ownerCt) {\n            for (it = ownerCt.items.items, i = Ext.Array.indexOf(it, node) - 1; i > -1; i--) {\n                sib = it[i];\n                if (sib.query) {\n                    result = sib.query(selector);\n                    result = result[result.length - 1];\n                    if (result) {\n                        return result;\n                    }\n                }\n                if (sib.is(selector)) {\n                    return sib;\n                }\n            }\n            return ownerCt.previousNode(selector, true);\n        }\n        return null;\n    },\n\n    /**\n     * Returns the next node in the Component tree in tree traversal order.\n     *\n     * Note that this is not limited to siblings, and if invoked upon a node with no matching siblings, will walk the\n     * tree to attempt to find a match. Contrast with {@link #nextSibling}.\n     * @param {String} [selector] A {@link Ext.ComponentQuery ComponentQuery} selector to filter the following nodes.\n     * @return {Ext.Component} The next node (or the next node which matches the selector).\n     * Returns null if there is no matching node.\n     */\n    nextNode: function(selector, /* private */ includeSelf) {\n        var node = this,\n            ownerCt = node.ownerCt,\n            result,\n            it, len, i, sib;\n\n        // If asked to include self, test me\n        if (includeSelf && node.is(selector)) {\n            return node;\n        }\n\n        if (ownerCt) {\n            for (it = ownerCt.items.items, i = Ext.Array.indexOf(it, node) + 1, len = it.length; i < len; i++) {\n                sib = it[i];\n                if (sib.is(selector)) {\n                    return sib;\n                }\n                if (sib.down) {\n                    result = sib.down(selector);\n                    if (result) {\n                        return result;\n                    }\n                }\n            }\n            return ownerCt.nextNode(selector);\n        }\n        return null;\n    },\n\n    /**\n     * Retrieves the id of this component. Will autogenerate an id if one has not already been set.\n     * @return {String}\n     */\n    getId : function() {\n        return this.id || (this.id = 'ext-comp-' + (this.getAutoId()));\n    },\n\n    /**\n     * Returns the value of {@link #itemId} assigned to this component, or when that\n     * is not set, returns the value of {@link #id}.\n     * @return {String}\n     */\n    getItemId : function() {\n        return this.itemId || this.id;\n    },\n\n    /**\n     * Retrieves the top level element representing this component.\n     * @return {Ext.dom.Element}\n     */\n    getEl : function() {\n        return this.el;\n    },\n\n    /**\n     * This is used to determine where to insert the 'html', 'contentEl' and 'items' in this component.\n     * @private\n     */\n    getTargetEl: function() {\n        return this.frameBody || this.el;\n    },\n\n    /**\n     * @private\n     * Returns the CSS style object which will set the Component's scroll styles. This must be applied\n     * to the {@link #getTargetEl target element}.\n     */\n    getOverflowStyle: function() {\n        var me = this,\n            result = null;\n\n        if (typeof me.autoScroll == 'boolean') {\n            result = {\n                overflow: me.autoScroll ? 'auto' : ''\n            };\n        } else if (me.overflowX !== undefined || me.overflowY !== undefined) {\n            result = {\n                'overflow-x':  (me.overflowX||''),\n                'overflow-y':  (me.overflowY||'')\n            };\n        }\n\n        // The scrollable container element must be non-statically positioned or IE6/7 will make\n        // positioned children stay in place rather than scrolling with the rest of the content\n        if (result && (Ext.isIE6 || Ext.isIE7)) {\n            result.position = 'relative';\n        }\n\n        return result;\n    },\n\n    /**\n     * Tests whether or not this Component is of a specific xtype. This can test whether this Component is descended\n     * from the xtype (default) or whether it is directly of the xtype specified (shallow = true).\n     *\n     * **If using your own subclasses, be aware that a Component must register its own xtype to participate in\n     * determination of inherited xtypes.**\n     *\n     * For a list of all available xtypes, see the {@link Ext.Component} header.\n     *\n     * Example usage:\n     *\n     *     var t = new Ext.form.field.Text();\n     *     var isText = t.isXType('textfield');        // true\n     *     var isBoxSubclass = t.isXType('field');       // true, descended from Ext.form.field.Base\n     *     var isBoxInstance = t.isXType('field', true); // false, not a direct Ext.form.field.Base instance\n     *\n     * @param {String} xtype The xtype to check for this Component\n     * @param {Boolean} [shallow=false] True to check whether this Component is directly of the specified xtype, false to\n     * check whether this Component is descended from the xtype.\n     * @return {Boolean} True if this component descends from the specified xtype, false otherwise.\n     */\n    isXType: function(xtype, shallow) {\n        if (shallow) {\n            return this.xtype === xtype;\n        }\n        else {\n            return this.xtypesMap[xtype];\n        }\n    },\n\n    /**\n     * Returns this Component's xtype hierarchy as a slash-delimited string. For a list of all available xtypes, see the\n     * {@link Ext.Component} header.\n     *\n     * **If using your own subclasses, be aware that a Component must register its own xtype to participate in\n     * determination of inherited xtypes.**\n     *\n     * Example usage:\n     *\n     *     var t = new Ext.form.field.Text();\n     *     alert(t.getXTypes());  // alerts 'component/field/textfield'\n     *\n     * @return {String} The xtype hierarchy string\n     */\n    getXTypes: function() {\n        var self = this.self,\n            xtypes, parentPrototype, parentXtypes;\n\n        if (!self.xtypes) {\n            xtypes = [];\n            parentPrototype = this;\n\n            while (parentPrototype) {\n                parentXtypes = parentPrototype.xtypes;\n\n                if (parentXtypes !== undefined) {\n                    xtypes.unshift.apply(xtypes, parentXtypes);\n                }\n\n                parentPrototype = parentPrototype.superclass;\n            }\n\n            self.xtypeChain = xtypes;\n            self.xtypes = xtypes.join('/');\n        }\n\n        return self.xtypes;\n    },\n\n    /**\n     * Update the content area of a component.\n     * @param {String/Object} htmlOrData If this component has been configured with a template via the tpl config then\n     * it will use this argument as data to populate the template. If this component was not configured with a template,\n     * the components content area will be updated via Ext.Element update\n     * @param {Boolean} [loadScripts=false] Only legitimate when using the html configuration.\n     * @param {Function} [callback] Only legitimate when using the html configuration. Callback to execute when\n     * scripts have finished loading\n     */\n    update : function(htmlOrData, loadScripts, cb) {\n        var me = this;\n\n        if (me.tpl && !Ext.isString(htmlOrData)) {\n            me.data = htmlOrData;\n            if (me.rendered) {\n                me.tpl[me.tplWriteMode](me.getTargetEl(), htmlOrData || {});\n            }\n        } else {\n            me.html = Ext.isObject(htmlOrData) ? Ext.DomHelper.markup(htmlOrData) : htmlOrData;\n            if (me.rendered) {\n                me.getTargetEl().update(me.html, loadScripts, cb);\n            }\n        }\n\n        if (me.rendered) {\n            me.updateLayout();\n        }\n    },\n\n    /**\n     * Convenience function to hide or show this component by boolean.\n     * @param {Boolean} visible True to show, false to hide\n     * @return {Ext.Component} this\n     */\n    setVisible : function(visible) {\n        return this[visible ? 'show': 'hide']();\n    },\n\n    /**\n     * Returns true if this component is visible.\n     *\n     * @param {Boolean} [deep=false] Pass `true` to interrogate the visibility status of all parent Containers to\n     * determine whether this Component is truly visible to the user.\n     *\n     * Generally, to determine whether a Component is hidden, the no argument form is needed. For example when creating\n     * dynamically laid out UIs in a hidden Container before showing them.\n     *\n     * @return {Boolean} True if this component is visible, false otherwise.\n     */\n    isVisible: function(deep) {\n        var me = this,\n            child = me,\n            visible = me.rendered && !me.hidden,\n            ancestor = me.ownerCt;\n\n        // Clear hiddenOwnerCt property\n        me.hiddenAncestor = false;\n        if (me.destroyed) {\n            return false;\n        }\n\n        if (deep && visible && ancestor) {\n            while (ancestor) {\n                // If any ancestor is hidden, then this is hidden.\n                // If an ancestor Panel (only Panels have a collapse method) is collapsed,\n                // then its layoutTarget (body) is hidden, so this is hidden unless its within a\n                // docked item; they are still visible when collapsed (Unless they themseves are hidden)\n                if (ancestor.hidden || (ancestor.collapsed &&\n                        !(ancestor.getDockedItems && Ext.Array.contains(ancestor.getDockedItems(), child)))) {\n                    // Store hiddenOwnerCt property if needed\n                    me.hiddenAncestor = ancestor;\n                    visible = false;\n                    break;\n                }\n                child = ancestor;\n                ancestor = ancestor.ownerCt;\n            }\n        }\n        return visible;\n    },\n\n    onBoxReady: function(){\n        var me = this;\n\n        if (me.disableOnBoxReady) {\n            me.onDisable();\n        } else if (me.enableOnBoxReady) {\n            me.onEnable();\n        }\n        if (me.resizable) {\n            me.initResizable(me.resizable);\n        }\n\n        // Draggability must be initialized after resizability\n        // Because if we have to be wrapped, the resizer wrapper must be dragged as a pseudo-Component\n        if (me.draggable) {\n            me.initDraggable();\n        }\n    },\n\n    /**\n     * Enable the component\n     * @param {Boolean} [silent=false] Passing true will supress the 'enable' event from being fired.\n     */\n    enable: function(silent) {\n        var me = this;\n\n        delete me.disableOnBoxReady;\n        me.removeCls(me.disabledCls);\n        if (me.rendered) {\n            me.onEnable();\n        } else {\n            me.enableOnBoxReady = true;\n        }\n\n        me.disabled = false;\n        delete me.resetDisable;\n\n        if (silent !== true) {\n            me.fireEvent('enable', me);\n        }\n\n        return me;\n    },\n\n    /**\n     * Disable the component.\n     * @param {Boolean} [silent=false] Passing true will supress the 'disable' event from being fired.\n     */\n    disable: function(silent) {\n        var me = this;\n\n        delete me.enableOnBoxReady;\n        me.addCls(me.disabledCls);\n        if (me.rendered) {\n            me.onDisable();\n        } else {\n            me.disableOnBoxReady = true;\n        }\n\n        me.disabled = true;\n\n        if (silent !== true) {\n            delete me.resetDisable;\n            me.fireEvent('disable', me);\n        }\n\n        return me;\n    },\n\n    /**\n     * Allows addition of behavior to the enable operation.\n     * After calling the superclass’s onEnable, the Component will be enabled.\n     *\n     * @template\n     * @protected\n     */\n    onEnable: function() {\n        if (this.maskOnDisable) {\n            this.el.dom.disabled = false;\n            this.unmask();\n        }\n    },\n\n    /**\n     * Allows addition of behavior to the disable operation.\n     * After calling the superclass’s onDisable, the Component will be disabled.\n     *\n     * @template\n     * @protected\n     */\n    onDisable : function() {\n        var me = this,\n            focusCls = me.focusCls,\n            focusEl = me.getFocusEl();\n            \n        if (focusCls && focusEl) {\n            focusEl.removeCls(me.removeClsWithUI(focusCls, true));\n        }\n        \n        if (me.maskOnDisable) {\n            me.el.dom.disabled = true;\n            me.mask();\n        }\n    },\n\n    mask: function() {\n        var box = this.lastBox,\n            target = this.getMaskTarget(),\n            args = [];\n\n        // Pass it the height of our element if we know it.\n        if (box) {\n            args[2] = box.height;\n        }\n        target.mask.apply(target, args);\n    },\n\n    unmask: function() {\n        this.getMaskTarget().unmask();\n    },\n\n    getMaskTarget: function(){\n        return this.el;\n    },\n\n    /**\n     * Method to determine whether this Component is currently disabled.\n     * @return {Boolean} the disabled state of this Component.\n     */\n    isDisabled : function() {\n        return this.disabled;\n    },\n\n    /**\n     * Enable or disable the component.\n     * @param {Boolean} disabled True to disable.\n     */\n    setDisabled : function(disabled) {\n        return this[disabled ? 'disable': 'enable']();\n    },\n\n    /**\n     * Method to determine whether this Component is currently set to hidden.\n     * @return {Boolean} the hidden state of this Component.\n     */\n    isHidden : function() {\n        return this.hidden;\n    },\n\n    /**\n     * Adds a CSS class to the top level element representing this component.\n     * @param {String/String[]} cls The CSS class name to add\n     * @return {Ext.Component} Returns the Component to allow method chaining.\n     */\n    addCls : function(cls) {\n        var me = this,\n            el = me.rendered ? me.el : me.protoEl;\n\n        el.addCls.apply(el, arguments);\n        return me;\n    },\n\n    /**\n     * @inheritdoc Ext.AbstractComponent#addCls\n     * @deprecated 4.1 Use {@link #addCls} instead.\n     */\n    addClass : function() {\n        return this.addCls.apply(this, arguments);\n    },\n\n    /**\n     * Checks if the specified CSS class exists on this element's DOM node.\n     * @param {String} className The CSS class to check for\n     * @return {Boolean} True if the class exists, else false\n     * @method\n     */\n    hasCls: function (cls) {\n        var me = this,\n            el = me.rendered ? me.el : me.protoEl;\n\n        return el.hasCls.apply(el, arguments);\n    },\n\n    /**\n     * Removes a CSS class from the top level element representing this component.\n     * @param {String/String[]} cls The CSS class name to remove\n     * @returns {Ext.Component} Returns the Component to allow method chaining.\n     */\n    removeCls : function(cls) {\n        var me = this,\n            el = me.rendered ? me.el : me.protoEl;\n\n        el.removeCls.apply(el, arguments);\n        return me;\n    },\n\n    removeClass : function() {\n        if (Ext.isDefined(Ext.global.console)) {\n            Ext.global.console.warn('Ext.Component: removeClass has been deprecated. Please use removeCls.');\n        }\n        return this.removeCls.apply(this, arguments);\n    },\n\n    addOverCls: function() {\n        var me = this;\n        if (!me.disabled) {\n            me.el.addCls(me.overCls);\n        }\n    },\n\n    removeOverCls: function() {\n        this.el.removeCls(this.overCls);\n    },\n\n    addListener : function(element, listeners, scope, options) {\n        var me = this,\n            fn,\n            option;\n\n        if (Ext.isString(element) && (Ext.isObject(listeners) || options && options.element)) {\n            if (options.element) {\n                fn = listeners;\n\n                listeners = {};\n                listeners[element] = fn;\n                element = options.element;\n                if (scope) {\n                    listeners.scope = scope;\n                }\n\n                for (option in options) {\n                    if (options.hasOwnProperty(option)) {\n                        if (me.eventOptionsRe.test(option)) {\n                            listeners[option] = options[option];\n                        }\n                    }\n                }\n            }\n\n            // At this point we have a variable called element,\n            // and a listeners object that can be passed to on\n            if (me[element] && me[element].on) {\n                me.mon(me[element], listeners);\n            } else {\n                me.afterRenderEvents = me.afterRenderEvents || {};\n                if (!me.afterRenderEvents[element]) {\n                    me.afterRenderEvents[element] = [];\n                }\n                me.afterRenderEvents[element].push(listeners);\n            }\n        }\n\n        return me.mixins.observable.addListener.apply(me, arguments);\n    },\n\n    // inherit docs\n    removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope){\n        var me = this,\n            element = managedListener.options ? managedListener.options.element : null;\n\n        if (element) {\n            element = me[element];\n            if (element && element.un) {\n                if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) {\n                    element.un(managedListener.ename, managedListener.fn, managedListener.scope);\n                    if (!isClear) {\n                        Ext.Array.remove(me.managedListeners, managedListener);\n                    }\n                }\n            }\n        } else {\n            return me.mixins.observable.removeManagedListenerItem.apply(me, arguments);\n        }\n    },\n\n    /**\n     * Provides the link for Observable's fireEvent method to bubble up the ownership hierarchy.\n     * @return {Ext.container.Container} the Container which owns this Component.\n     */\n    getBubbleTarget : function() {\n        return this.ownerCt;\n    },\n\n    /**\n     * Method to determine whether this Component is floating.\n     * @return {Boolean} the floating state of this component.\n     */\n    isFloating : function() {\n        return this.floating;\n    },\n\n    /**\n     * Method to determine whether this Component is draggable.\n     * @return {Boolean} the draggable state of this component.\n     */\n    isDraggable : function() {\n        return !!this.draggable;\n    },\n\n    /**\n     * Method to determine whether this Component is droppable.\n     * @return {Boolean} the droppable state of this component.\n     */\n    isDroppable : function() {\n        return !!this.droppable;\n    },\n\n    /**\n     * Method to manage awareness of when components are added to their\n     * respective Container, firing an #added event. References are\n     * established at add time rather than at render time.\n     *\n     * Allows addition of behavior when a Component is added to a\n     * Container. At this stage, the Component is in the parent\n     * Container's collection of child items. After calling the\n     * superclass's onAdded, the ownerCt reference will be present,\n     * and if configured with a ref, the refOwner will be set.\n     *\n     * @param {Ext.container.Container} container Container which holds the component\n     * @param {Number} pos Position at which the component was added\n     *\n     * @template\n     * @protected\n     */\n    onAdded : function(container, pos) {\n        var me = this;\n        me.ownerCt = container;\n        if (me.hasListeners.added) {\n            me.fireEvent('added', me, container, pos);\n        }\n    },\n\n    /**\n     * Method to manage awareness of when components are removed from their\n     * respective Container, firing a #removed event. References are properly\n     * cleaned up after removing a component from its owning container.\n     *\n     * Allows addition of behavior when a Component is removed from\n     * its parent Container. At this stage, the Component has been\n     * removed from its parent Container's collection of child items,\n     * but has not been destroyed (It will be destroyed if the parent\n     * Container's autoDestroy is true, or if the remove call was\n     * passed a truthy second parameter). After calling the\n     * superclass's onRemoved, the ownerCt and the refOwner will not\n     * be present.\n     * @param {Boolean} destroying Will be passed as true if the Container performing the remove operation will delete this\n     * Component upon remove.\n     *\n     * @template\n     * @protected\n     */\n    onRemoved : function(destroying) {\n        var me = this;\n        if (me.hasListeners.removed) {\n            me.fireEvent('removed', me, me.ownerCt);\n        }\n        delete me.ownerCt;\n        delete me.ownerLayout;\n    },\n\n    /**\n     * Invoked before the Component is destroyed.\n     *\n     * @method\n     * @template\n     * @protected\n     */\n    beforeDestroy : Ext.emptyFn,\n\n    /**\n     * Allows addition of behavior to the resize operation.\n     *\n     * Called when Ext.resizer.Resizer#drag event is fired.\n     *\n     * @method\n     * @template\n     * @protected\n     */\n    onResize : Ext.emptyFn,\n\n    /**\n     * Sets the width and height of this Component. This method fires the {@link #resize} event. This method can accept\n     * either width and height as separate arguments, or you can pass a size object like `{width:10, height:20}`.\n     *\n     * @param {Number/String/Object} width The new width to set. This may be one of:\n     *\n     *   - A Number specifying the new width in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).\n     *   - A String used to set the CSS width style.\n     *   - A size object in the format `{width: widthValue, height: heightValue}`.\n     *   - `undefined` to leave the width unchanged.\n     *\n     * @param {Number/String} height The new height to set (not required if a size object is passed as the first arg).\n     * This may be one of:\n     *\n     *   - A Number specifying the new height in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).\n     *   - A String used to set the CSS height style. Animation may **not** be used.\n     *   - `undefined` to leave the height unchanged.\n     *\n     * @return {Ext.Component} this\n     */\n    setSize : function(width, height) {\n        var me = this;\n\n        // support for standard size objects\n        if (width && typeof width == 'object') {\n            height = width.height;\n            width  = width.width;\n        }\n\n        // Constrain within configured maxima\n        if (typeof width == 'number') {\n            me.width = Ext.Number.constrain(width, me.minWidth, me.maxWidth);\n        } else if (width === null) {\n            delete me.width;\n        }\n        \n        if (typeof height == 'number') {\n            me.height = Ext.Number.constrain(height, me.minHeight, me.maxHeight);\n        } else if (height === null) {\n            delete me.height;\n        }\n\n        // If not rendered, all we need to is set the properties.\n        // The initial layout will set the size\n        if (me.rendered && me.isVisible()) {\n\n            // If we are changing size, then we are not the root.\n            me.updateLayout({\n                isRoot: false\n            });\n        }\n\n        return me;\n    },\n\n    /**\n     * Determines whether this Component is the root of a layout. This returns `true` if\n     * this component can run its layout without assistance from or impact on its owner.\n     * If this component cannot run its layout given these restrictions, `false` is returned\n     * and its owner will be considered as the next candidate for the layout root.\n     *\n     * Setting the {@link #_isLayoutRoot} property to `true` causes this method to always\n     * return `true`. This may be useful when updating a layout of a Container which shrink\n     * wraps content, and you know that it will not change size, and so can safely be the\n     * topmost participant in the layout run.\n     * @protected\n     */\n    isLayoutRoot: function() {\n        var me = this,\n            ownerLayout = me.ownerLayout;\n\n        // Return true if we have been explicitly flagged as the layout root, or if we are floating.\n        // Sometimes floating Components get an ownerCt ref injected into them which is *not* a true ownerCt, merely\n        // an upward link for reference purposes. For example a grid column menu is linked to the\n        // owning header via an ownerCt reference.\n        if (!ownerLayout || me._isLayoutRoot || me.floating) {\n            return true;\n        }\n\n        return ownerLayout.isItemLayoutRoot(me);\n    },\n\n    /**\n     * Returns true if layout is suspended for this component. This can come from direct\n     * suspension of this component's layout activity ({@link Ext.Container#suspendLayout}) or if one\n     * of this component's containers is suspended.\n     *\n     * @return {Boolean} True layout of this component is suspended.\n     */\n    isLayoutSuspended: function () {\n        var comp = this,\n            ownerLayout;\n\n        while (comp) {\n            if (comp.layoutSuspendCount || comp.suspendLayout) {\n                return true;\n            }\n\n            ownerLayout = comp.ownerLayout;\n            if (!ownerLayout) {\n                break;\n            }\n\n            // TODO - what about suspending a Layout instance?\n\n            // this works better than ownerCt since ownerLayout means \"is managed by\" in\n            // the proper sense... some floating components have ownerCt but won't have an\n            // ownerLayout\n            comp = ownerLayout.owner;\n        }\n\n        return false;\n    },\n\n    /**\n     * Updates this component's layout. If this update effects this components {@link #ownerCt},\n     * that component's `updateLayout` method will be called to perform the layout instead.\n     * Otherwise, just this component (and its child items) will layout.\n     *\n     * @param {Object} options An object with layout options.\n     * @param {Boolean} options.defer True if this layout should be deferred.\n     * @param {Boolean} options.isRoot True if this layout should be the root of the layout.\n     */\n    updateLayout: function (options) {\n        var me = this,\n            defer,\n            isRoot = options && options.isRoot;\n\n        if (!me.rendered || me.layoutSuspendCount || me.suspendLayout) {\n            return;\n        }\n\n        if (me.hidden) {\n            Ext.AbstractComponent.cancelLayout(me);\n        } else if (typeof isRoot != 'boolean') {\n            isRoot = me.isLayoutRoot();\n        }\n\n        // if we aren't the root, see if our ownerLayout will handle it...\n        if (isRoot || !me.ownerLayout || !me.ownerLayout.onContentChange(me)) {\n            // either we are the root or our ownerLayout doesn't care\n            if (!me.isLayoutSuspended()) {\n                // we aren't suspended (knew that), but neither is any of our ownerCt's...\n                defer = (options && options.hasOwnProperty('defer')) ? options.defer : me.deferLayouts;\n                Ext.AbstractComponent.updateLayout(me, defer);\n            }\n        }\n    },\n\n    /**\n     * Returns an object that describes how this component's width and height are managed.\n     * All of these objects are shared and should not be modified.\n     *\n     * @return {Object} The size model for this component.\n     * @return {Ext.layout.SizeModel} return.width The {@link Ext.layout.SizeModel size model}\n     * for the width.\n     * @return {Ext.layout.SizeModel} return.height The {@link Ext.layout.SizeModel size model}\n     * for the height.\n     */\n    getSizeModel: function (ownerCtSizeModel) {\n        var me = this,\n            models = Ext.layout.SizeModel,\n            ownerContext = me.componentLayout.ownerContext,\n            width = me.width,\n            height = me.height,\n            typeofWidth, typeofHeight,\n            hasPixelWidth, hasPixelHeight,\n            heightModel, ownerLayout, policy, shrinkWrap, topLevel, widthModel;\n\n        if (ownerContext) {\n            // If we are in the middle of a running layout, always report the current,\n            // dynamic size model rather than recompute it. This is not (only) a time\n            // saving thing, but a correctness thing since we cannot get the right answer\n            // otherwise.\n            widthModel = ownerContext.widthModel;\n            heightModel = ownerContext.heightModel;\n        }\n\n        if (!widthModel || !heightModel) {\n            hasPixelWidth = ((typeofWidth = typeof width) == 'number');\n            hasPixelHeight = ((typeofHeight = typeof height) == 'number');\n            topLevel = me.floating || !(ownerLayout = me.ownerLayout);\n\n            // Floating or no owner layout, e.g. rendered using renderTo\n            if (topLevel) {\n                policy = Ext.layout.Layout.prototype.autoSizePolicy;\n                shrinkWrap = me.floating ? 3 : me.shrinkWrap;\n\n                if (hasPixelWidth) {\n                    widthModel = models.configured;\n                }\n\n                if (hasPixelHeight) {\n                    heightModel = models.configured;\n                }\n            } else {\n                policy = ownerLayout.getItemSizePolicy(me, ownerCtSizeModel);\n                shrinkWrap = ownerLayout.isItemShrinkWrap(me);\n            }\n\n            shrinkWrap = (shrinkWrap === true) ? 3 : (shrinkWrap || 0); // false->0, true->3\n\n            // Now that we have shrinkWrap as a 0-3 value, we need to turn off shrinkWrap\n            // bits for any dimension that has a configured size not in pixels. These must\n            // be read from the DOM.\n            //\n            if (topLevel && shrinkWrap) {\n                if (width && typeofWidth == 'string') {\n                    shrinkWrap &= 2; // percentage, \"30em\" or whatever - not width shrinkWrap\n                }\n                if (height && typeofHeight == 'string') {\n                    shrinkWrap &= 1; // percentage, \"30em\" or whatever - not height shrinkWrap\n                }\n            }\n\n            if (shrinkWrap !== 3) {\n                if (!ownerCtSizeModel) {\n                    ownerCtSizeModel = me.ownerCt && me.ownerCt.getSizeModel();\n                }\n\n                if (ownerCtSizeModel) {\n                    shrinkWrap |= (ownerCtSizeModel.width.shrinkWrap ? 1 : 0) | (ownerCtSizeModel.height.shrinkWrap ? 2 : 0);\n                }\n            }\n\n            if (!widthModel) {\n                if (!policy.setsWidth) {\n                    if (hasPixelWidth) {\n                        widthModel = models.configured;\n                    } else {\n                        widthModel = (shrinkWrap & 1) ? models.shrinkWrap : models.natural;\n                    }\n                } else if (policy.readsWidth) {\n                    if (hasPixelWidth) {\n                        widthModel = models.calculatedFromConfigured;\n                    } else {\n                        widthModel = (shrinkWrap & 1) ? models.calculatedFromShrinkWrap :\n                                    models.calculatedFromNatural;\n                    }\n                } else {\n                    widthModel = models.calculated;\n                }\n            }\n\n            if (!heightModel) {\n                if (!policy.setsHeight) {\n                    if (hasPixelHeight) {\n                        heightModel = models.configured;\n                    } else {\n                        heightModel = (shrinkWrap & 2) ? models.shrinkWrap : models.natural;\n                    }\n                } else if (policy.readsHeight) {\n                    if (hasPixelHeight) {\n                        heightModel = models.calculatedFromConfigured;\n                    } else {\n                        heightModel = (shrinkWrap & 2) ? models.calculatedFromShrinkWrap :\n                                    models.calculatedFromNatural;\n                    }\n                } else {\n                    heightModel = models.calculated;\n                }\n            }\n        }\n\n        // We return one of the cached objects with the proper \"width\" and \"height\" as the\n        // sizeModels we have determined.\n        return widthModel.pairsByHeightOrdinal[heightModel.ordinal];\n    },\n\n    isDescendant: function(ancestor) {\n        if (ancestor.isContainer) {\n            for (var c = this.ownerCt; c; c = c.ownerCt) {\n                if (c === ancestor) {\n                    return true;\n                }\n            }\n        }\n        return false;\n    },\n\n    /**\n     * This method needs to be called whenever you change something on this component that requires the Component's\n     * layout to be recalculated.\n     * @return {Ext.container.Container} this\n     */\n    doComponentLayout : function() {\n        this.updateLayout();\n        return this;\n    },\n\n    /**\n     * Forces this component to redo its componentLayout.\n     * @deprecated 4.1.0 Use {@link #updateLayout} instead.\n     */\n    forceComponentLayout: function () {\n        this.updateLayout();\n    },\n\n    // @private\n    setComponentLayout : function(layout) {\n        var currentLayout = this.componentLayout;\n        if (currentLayout && currentLayout.isLayout && currentLayout != layout) {\n            currentLayout.setOwner(null);\n        }\n        this.componentLayout = layout;\n        layout.setOwner(this);\n    },\n\n    getComponentLayout : function() {\n        var me = this;\n\n        if (!me.componentLayout || !me.componentLayout.isLayout) {\n            me.setComponentLayout(Ext.layout.Layout.create(me.componentLayout, 'autocomponent'));\n        }\n        return me.componentLayout;\n    },\n\n    /**\n     * Called by the layout system after the Component has been layed out.\n     *\n     * @param {Number} width The width that was set\n     * @param {Number} height The height that was set\n     * @param {Number} oldWidth The old width. <code>undefined</code> if this was the initial layout.\n     * @param {Number} oldHeight The old height. <code>undefined</code> if this was the initial layout.\n     *\n     * @template\n     * @protected\n     */\n    afterComponentLayout: function(width, height, oldWidth, oldHeight) {\n        var me = this,\n            floaters, len, i, floater;\n\n        if (++me.componentLayoutCounter === 1) {\n            me.afterFirstLayout(width, height);\n        }\n\n        // Contained autoShow items must be shown upon next layout of the Container\n        if (me.floatingItems) {\n            floaters = me.floatingItems.items;\n            len = floaters.length;\n            for (i = 0; i < len; i++) {\n                floater = floaters[i];\n                if (!floater.rendered && floater.autoShow) {\n                    floater.show();\n                }\n            }\n        }\n        if (me.hasListeners.resize && (width !== oldWidth || height !== oldHeight)) {\n            me.fireEvent('resize', me, width, height, oldWidth, oldHeight);\n        }\n    },\n\n    /**\n     * Occurs before componentLayout is run. Returning false from this method will prevent the componentLayout from\n     * being executed.\n     *\n     * @param {Number} adjWidth The box-adjusted width that was set\n     * @param {Number} adjHeight The box-adjusted height that was set\n     *\n     * @template\n     * @protected\n     */\n    beforeComponentLayout: function(width, height) {\n        return true;\n    },\n\n    /**\n     * Sets the left and top of the component. To set the page XY position instead, use {@link Ext.Component#setPagePosition setPagePosition}. This\n     * method fires the {@link #move} event.\n     * @param {Number} left The new left\n     * @param {Number} top The new top\n     * @param {Boolean/Object} [animate] If true, the Component is _animated_ into its new position. You may also pass an\n     * animation configuration.\n     * @return {Ext.Component} this\n     */\n    setPosition : function(x, y, animate) {\n        var me = this,\n            pos = me.beforeSetPosition.apply(me, arguments);\n\n        if (pos && me.rendered) {\n            // Convert position WRT RTL\n            pos = me.convertPosition(pos);\n\n            // Proceed only if the new position is different from the current one.\n            if (pos.left !== me.el.getLeft() || pos.top !== me.el.getTop()) {\n                if (animate) {\n                    me.stopAnimation();\n                    me.animate(Ext.apply({\n                        duration: 1000,\n                        listeners: {\n                            afteranimate: Ext.Function.bind(me.afterSetPosition, me, [pos.left, pos.top])\n                        },\n                        to: pos\n                    }, animate));\n                } else {\n                    // Must use Element's methods to set element position because, if it is a Layer (floater), it may need to sync a shadow\n                    // We must also only set the properties which are defined because Element.setLeftTop autos any undefined coordinates\n                    if (pos.left !== undefined && pos.top !== undefined) {\n                        me.el.setLeftTop(pos.left, pos.top);\n                    } else if (pos.left !== undefined) {\n                        me.el.setLeft(pos.left);\n                    } else if (pos.top !==undefined) {\n                        me.el.setTop(pos.top);\n                    }\n                    me.afterSetPosition(pos.left, pos.top);\n                }\n            }\n        }\n        return me;\n    },\n\n    /**\n     * @private Template method called before a Component is positioned.\n     */\n    beforeSetPosition: function (x, y, animate) {\n        var pos, x0;\n\n        // decode the position arguments:\n        if (!x || Ext.isNumber(x)) {\n            pos = { x: x, y : y, anim: animate };\n        } else if (Ext.isNumber(x0 = x[0])) { // an array of [x, y]\n            pos = { x : x0, y : x[1], anim: y };\n        } else {\n            pos = { x: x.x, y: x.y, anim: y }; // already an object w/ x & y properties\n        }\n\n        pos.hasX = Ext.isNumber(pos.x);\n        pos.hasY = Ext.isNumber(pos.y);\n\n        // store the position as specified:\n        this.x = pos.x;\n        this.y = pos.y;\n\n        return (pos.hasX || pos.hasY) ? pos : null;\n    },\n\n    /**\n     * Template method called after a Component has been positioned.\n     *\n     * @param {Number} x\n     * @param {Number} y\n     *\n     * @template\n     * @protected\n     */\n    afterSetPosition: function(x, y) {\n        var me = this;\n        me.onPosition(x, y);\n        if (me.hasListeners.move) {\n            me.fireEvent('move', me, x, y);\n        }\n    },\n\n    /**\n     * This method converts an \"{x: x, y: y}\" object to a \"{left: x+'px', top: y+'px'}\" object.\n     * The returned object contains the styles to set to effect the position. This is\n     * overridden in RTL mode to be \"{right: x, top: y}\".\n     * @private\n     */\n    convertPosition: function (pos, withUnits) {\n        var ret = {},\n            El = Ext.Element;\n\n        if (pos.hasX) {\n            ret.left = withUnits ? El.addUnits(pos.x) : pos.x;\n        }\n        if (pos.hasY) {\n            ret.top = withUnits ? El.addUnits(pos.y) : pos.y;\n        }\n\n        return ret;\n    },\n\n    /**\n     * Called after the component is moved, this method is empty by default but can be implemented by any\n     * subclass that needs to perform custom logic after a move occurs.\n     *\n     * @param {Number} x The new x position\n     * @param {Number} y The new y position\n     *\n     * @template\n     * @protected\n     */\n    onPosition: Ext.emptyFn,\n\n    /**\n     * Sets the width of the component. This method fires the {@link #resize} event.\n     *\n     * @param {Number} width The new width to setThis may be one of:\n     *\n     *   - A Number specifying the new width in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).\n     *   - A String used to set the CSS width style.\n     *\n     * @return {Ext.Component} this\n     */\n    setWidth : function(width) {\n        return this.setSize(width);\n    },\n\n    /**\n     * Sets the height of the component. This method fires the {@link #resize} event.\n     *\n     * @param {Number} height The new height to set. This may be one of:\n     *\n     *   - A Number specifying the new height in the {@link #getEl Element}'s {@link Ext.Element#defaultUnit}s (by default, pixels).\n     *   - A String used to set the CSS height style.\n     *   - _undefined_ to leave the height unchanged.\n     *\n     * @return {Ext.Component} this\n     */\n    setHeight : function(height) {\n        return this.setSize(undefined, height);\n    },\n\n    /**\n     * Gets the current size of the component's underlying element.\n     * @return {Object} An object containing the element's size {width: (element width), height: (element height)}\n     */\n    getSize : function() {\n        return this.el.getSize();\n    },\n\n    /**\n     * Gets the current width of the component's underlying element.\n     * @return {Number}\n     */\n    getWidth : function() {\n        return this.el.getWidth();\n    },\n\n    /**\n     * Gets the current height of the component's underlying element.\n     * @return {Number}\n     */\n    getHeight : function() {\n        return this.el.getHeight();\n    },\n\n    /**\n     * Gets the {@link Ext.ComponentLoader} for this Component.\n     * @return {Ext.ComponentLoader} The loader instance, null if it doesn't exist.\n     */\n    getLoader: function(){\n        var me = this,\n            autoLoad = me.autoLoad ? (Ext.isObject(me.autoLoad) ? me.autoLoad : {url: me.autoLoad}) : null,\n            loader = me.loader || autoLoad;\n\n        if (loader) {\n            if (!loader.isLoader) {\n                me.loader = new Ext.ComponentLoader(Ext.apply({\n                    target: me,\n                    autoLoad: autoLoad\n                }, loader));\n            } else {\n                loader.setTarget(me);\n            }\n            return me.loader;\n\n        }\n        return null;\n    },\n\n    /**\n     * Sets the dock position of this component in its parent panel. Note that this only has effect if this item is part\n     * of the dockedItems collection of a parent that has a DockLayout (note that any Panel has a DockLayout by default)\n     * @param {Object} dock The dock position.\n     * @param {Boolean} [layoutParent=false] True to re-layout parent.\n     * @return {Ext.Component} this\n     */\n    setDocked : function(dock, layoutParent) {\n        var me = this;\n\n        me.dock = dock;\n        if (layoutParent && me.ownerCt && me.rendered) {\n            me.ownerCt.updateLayout();\n        }\n        return me;\n    },\n\n    /**\n     *\n     * @param {String/Number} border The border, see {@link #border}. If a falsey value is passed\n     * the border will be removed.\n     */\n    setBorder: function(border, /* private */ targetEl) {\n        var me = this,\n            initial = !!targetEl;\n\n        if (me.rendered || initial) {\n            if (!initial) {\n                targetEl = me.el;\n            }\n\n            if (!border) {\n                border = 0;\n            } else {\n                border = Ext.Element.unitizeBox((border === true) ? 1 : border);\n            }\n            targetEl.setStyle('border-width', border);\n            if (!initial) {\n                me.updateLayout();\n            }\n        }\n        me.border = border;\n    },\n\n    onDestroy : function() {\n        var me = this;\n\n        if (me.monitorResize && Ext.EventManager.resizeEvent) {\n            Ext.EventManager.resizeEvent.removeListener(me.setSize, me);\n        }\n\n        // Destroying the floatingItems ZIndexManager will also destroy descendant floating Components\n        Ext.destroy(\n            me.componentLayout,\n            me.loadMask,\n            me.floatingDescendants\n        );\n    },\n\n    /**\n     * Destroys the Component.\n     */\n    destroy : function() {\n        var me = this,\n            selectors = me.renderSelectors,\n            selector,\n            el;\n\n        if (!me.isDestroyed) {\n            if (!me.hasListeners.beforedestroy || me.fireEvent('beforedestroy', me) !== false) {\n                me.destroying = true;\n                me.beforeDestroy();\n\n                if (me.floating) {\n                    delete me.floatParent;\n                    // A zIndexManager is stamped into a *floating* Component when it is added to a Container.\n                    // If it has no zIndexManager at render time, it is assigned to the global Ext.WindowManager instance.\n                    if (me.zIndexManager) {\n                        me.zIndexManager.unregister(me);\n                    }\n                } else if (me.ownerCt && me.ownerCt.remove) {\n                    me.ownerCt.remove(me, false);\n                }\n\n                me.onDestroy();\n\n                // Attempt to destroy all plugins\n                Ext.destroy(me.plugins);\n\n                if (me.hasListeners.destroy) {\n                    me.fireEvent('destroy', me);\n                }\n                Ext.ComponentManager.unregister(me);\n\n                me.mixins.state.destroy.call(me);\n\n                me.clearListeners();\n                // make sure we clean up the element references after removing all events\n                if (me.rendered) {\n                    if (!me.preserveElOnDestroy) {\n                        me.el.remove();\n                    }\n                    me.mixins.elementCt.destroy.call(me); // removes childEls\n                    if (selectors) {\n                        for (selector in selectors) {\n                            if (selectors.hasOwnProperty(selector)) {\n                                el = me[selector];\n                                if (el) { // in case any other code may have already removed it\n                                    delete me[selector];\n                                    el.remove();\n                                }\n                            }\n                        }\n                    }\n\n                    delete me.el;\n                    delete me.frameBody;\n                    delete me.rendered;\n                }\n\n                me.destroying = false;\n                me.isDestroyed = true;\n            }\n        }\n    },\n\n    /**\n     * Retrieves a plugin by its pluginId which has been bound to this component.\n     * @param {String} pluginId\n     * @return {Ext.AbstractPlugin} plugin instance.\n     */\n    getPlugin: function(pluginId) {\n        var i = 0,\n            plugins = this.plugins,\n            ln = plugins.length;\n        for (; i < ln; i++) {\n            if (plugins[i].pluginId === pluginId) {\n                return plugins[i];\n            }\n        }\n    },\n\n    /**\n     * Determines whether this component is the descendant of a particular container.\n     * @param {Ext.Container} container\n     * @return {Boolean} True if it is.\n     */\n    isDescendantOf: function(container) {\n        return !!this.findParentBy(function(p){\n            return p === container;\n        });\n    }\n}, function() {\n    var AbstractComponent = this;\n\n    AbstractComponent.createAlias({\n        on: 'addListener',\n        prev: 'previousSibling',\n        next: 'nextSibling'\n    });\n\n    /**\n     * @inheritdoc Ext.AbstractComponent#resumeLayouts\n     * @member Ext\n     */\n    Ext.resumeLayouts = function (flush) {\n        AbstractComponent.resumeLayouts(flush);\n    };\n\n    /**\n     * @inheritdoc Ext.AbstractComponent#suspendLayouts\n     * @member Ext\n     */\n    Ext.suspendLayouts = function () {\n        AbstractComponent.suspendLayouts();\n    };\n\n    /**\n     * Utility wrapper that suspends layouts of all components for the duration of a given function.\n     * @param {Function} fn The function to execute.\n     * @param {Object} [scope] The scope (`this` reference) in which the specified function is executed.\n     * @member Ext\n     */\n    Ext.batchLayouts = function(fn, scope) {\n        AbstractComponent.suspendLayouts();\n        // Invoke the function\n        fn.call(scope);\n        AbstractComponent.resumeLayouts(true);\n    };\n});\n\n/**\n * The AbstractPlugin class is the base class from which user-implemented plugins should inherit.\n *\n * This class defines the essential API of plugins as used by Components by defining the following methods:\n *\n *   - `init` : The plugin initialization method which the owning Component calls at Component initialization time.\n *\n *     The Component passes itself as the sole parameter.\n *\n *     Subclasses should set up bidirectional links between the plugin and its client Component here.\n *\n *   - `destroy` : The plugin cleanup method which the owning Component calls at Component destruction time.\n *\n *     Use this method to break links between the plugin and the Component and to free any allocated resources.\n *\n *   - `enable` : The base implementation just sets the plugin's `disabled` flag to `false`\n *\n *   - `disable` : The base implementation just sets the plugin's `disabled` flag to `true`\n */\nExt.define('Ext.AbstractPlugin', {\n    disabled: false,\n\n    constructor: function(config) {\n        this.initialConfig = config;\n        Ext.apply(this, config);\n    },\n\n    clone: function() {\n        return new this.self(this.initialConfig);\n    },\n\n    getCmp: function() {\n        return this.cmp;\n    },\n\n    /**\n     * @cfg {String} pluginId\n     * A name for the plugin that can be set at creation time to then retrieve the plugin\n     * through {@link Ext.AbstractComponent#getPlugin getPlugin} method.  For example:\n     *\n     *     var grid = Ext.create('Ext.grid.Panel', {\n     *         plugins: [{\n     *             ptype: 'cellediting',\n     *             clicksToEdit: 2,\n     *             pluginId: 'cellplugin'\n     *         }]\n     *     });\n     *\n     *     // later on:\n     *     var plugin = grid.getPlugin('cellplugin');\n     */\n\n    /**\n     * @method\n     * The init method is invoked after initComponent method has been run for the client Component.\n     *\n     * The supplied implementation is empty. Subclasses should perform plugin initialization, and set up bidirectional\n     * links between the plugin and its client Component in their own implementation of this method.\n     * @param {Ext.Component} client The client Component which owns this plugin.\n     */\n    init: Ext.emptyFn,\n\n    /**\n     * @method\n     * The destroy method is invoked by the owning Component at the time the Component is being destroyed.\n     *\n     * The supplied implementation is empty. Subclasses should perform plugin cleanup in their own implementation of\n     * this method.\n     */\n    destroy: Ext.emptyFn,\n\n    /**\n     * The base implementation just sets the plugin's `disabled` flag to `false`\n     *\n     * Plugin subclasses which need more complex processing may implement an overriding implementation.\n     */\n    enable: function() {\n        this.disabled = false;\n    },\n\n    /**\n     * The base implementation just sets the plugin's `disabled` flag to `true`\n     *\n     * Plugin subclasses which need more complex processing may implement an overriding implementation.\n     */\n    disable: function() {\n        this.disabled = true;\n    }\n});\n\n/**\n * An Action is a piece of reusable functionality that can be abstracted out of any particular component so that it\n * can be usefully shared among multiple components.  Actions let you share handlers, configuration options and UI\n * updates across any components that support the Action interface (primarily {@link Ext.toolbar.Toolbar},\n * {@link Ext.button.Button} and {@link Ext.menu.Menu} components).\n *\n * Use a single Action instance as the config object for any number of UI Components which share the same configuration. The\n * Action not only supplies the configuration, but allows all Components based upon it to have a common set of methods\n * called at once through a single call to the Action.\n *\n * Any Component that is to be configured with an Action must also support\n * the following methods:\n *\n * - setText(string)\n * - setIconCls(string)\n * - setDisabled(boolean)\n * - setVisible(boolean)\n * - setHandler(function)\n *\n * This allows the Action to control its associated Components.\n *\n * Example usage:\n *\n *     // Define the shared Action.  Each Component below will have the same\n *     // display text and icon, and will display the same message on click.\n *     var action = new Ext.Action({\n *         {@link #text}: 'Do something',\n *         {@link #handler}: function(){\n *             Ext.Msg.alert('Click', 'You did something.');\n *         },\n *         {@link #iconCls}: 'do-something',\n *         {@link #itemId}: 'myAction'\n *     });\n *\n *     var panel = new Ext.panel.Panel({\n *         title: 'Actions',\n *         width: 500,\n *         height: 300,\n *         tbar: [\n *             // Add the Action directly to a toolbar as a menu button\n *             action,\n *             {\n *                 text: 'Action Menu',\n *                 // Add the Action to a menu as a text item\n *                 menu: [action]\n *             }\n *         ],\n *         items: [\n *             // Add the Action to the panel body as a standard button\n *             new Ext.button.Button(action)\n *         ],\n *         renderTo: Ext.getBody()\n *     });\n *\n *     // Change the text for all components using the Action\n *     action.setText('Something else');\n *\n *     // Reference an Action through a container using the itemId\n *     var btn = panel.getComponent('myAction');\n *     var aRef = btn.baseAction;\n *     aRef.setText('New text');\n */\nExt.define('Ext.Action', {\n\n    /* Begin Definitions */\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String} [text='']\n     * The text to set for all components configured by this Action.\n     */\n    /**\n     * @cfg {String} [iconCls='']\n     * The CSS class selector that specifies a background image to be used as the header icon for\n     * all components configured by this Action.\n     *\n     * An example of specifying a custom icon class would be something like:\n     *\n     *     // specify the property in the config for the class:\n     *          ...\n     *          iconCls: 'do-something'\n     *\n     *     // css class that specifies background image to be used as the icon image:\n     *     .do-something { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }\n     */\n    /**\n     * @cfg {Boolean} [disabled=false]\n     * True to disable all components configured by this Action, false to enable them.\n     */\n    /**\n     * @cfg {Boolean} [hidden=false]\n     * True to hide all components configured by this Action, false to show them.\n     */\n    /**\n     * @cfg {Function} handler\n     * The function that will be invoked by each component tied to this Action\n     * when the component's primary event is triggered.\n     */\n    /**\n     * @cfg {String} itemId\n     * See {@link Ext.Component}.{@link Ext.Component#itemId itemId}.\n     */\n    /**\n     * @cfg {Object} scope\n     * The scope (this reference) in which the {@link #handler} is executed.\n     * Defaults to the browser window.\n     */\n\n    /**\n     * Creates new Action.\n     * @param {Object} config Config object.\n     */\n    constructor : function(config){\n        this.initialConfig = config;\n        this.itemId = config.itemId = (config.itemId || config.id || Ext.id());\n        this.items = [];\n    },\n\n    /*\n     * @property {Boolean} isAction\n     * `true` in this class to identify an object as an instantiated Action, or subclass thereof.\n     */\n    isAction : true,\n\n    /**\n     * Sets the text to be displayed by all components configured by this Action.\n     * @param {String} text The text to display\n     */\n    setText : function(text){\n        this.initialConfig.text = text;\n        this.callEach('setText', [text]);\n    },\n\n    /**\n     * Gets the text currently displayed by all components configured by this Action.\n     */\n    getText : function(){\n        return this.initialConfig.text;\n    },\n\n    /**\n     * Sets the icon CSS class for all components configured by this Action.  The class should supply\n     * a background image that will be used as the icon image.\n     * @param {String} cls The CSS class supplying the icon image\n     */\n    setIconCls : function(cls){\n        this.initialConfig.iconCls = cls;\n        this.callEach('setIconCls', [cls]);\n    },\n\n    /**\n     * Gets the icon CSS class currently used by all components configured by this Action.\n     */\n    getIconCls : function(){\n        return this.initialConfig.iconCls;\n    },\n\n    /**\n     * Sets the disabled state of all components configured by this Action.  Shortcut method\n     * for {@link #enable} and {@link #disable}.\n     * @param {Boolean} disabled True to disable the component, false to enable it\n     */\n    setDisabled : function(v){\n        this.initialConfig.disabled = v;\n        this.callEach('setDisabled', [v]);\n    },\n\n    /**\n     * Enables all components configured by this Action.\n     */\n    enable : function(){\n        this.setDisabled(false);\n    },\n\n    /**\n     * Disables all components configured by this Action.\n     */\n    disable : function(){\n        this.setDisabled(true);\n    },\n\n    /**\n     * Returns true if the components using this Action are currently disabled, else returns false.\n     */\n    isDisabled : function(){\n        return this.initialConfig.disabled;\n    },\n\n    /**\n     * Sets the hidden state of all components configured by this Action.  Shortcut method\n     * for `{@link #hide}` and `{@link #show}`.\n     * @param {Boolean} hidden True to hide the component, false to show it.\n     */\n    setHidden : function(v){\n        this.initialConfig.hidden = v;\n        this.callEach('setVisible', [!v]);\n    },\n\n    /**\n     * Shows all components configured by this Action.\n     */\n    show : function(){\n        this.setHidden(false);\n    },\n\n    /**\n     * Hides all components configured by this Action.\n     */\n    hide : function(){\n        this.setHidden(true);\n    },\n\n    /**\n     * Returns true if the components configured by this Action are currently hidden, else returns false.\n     */\n    isHidden : function(){\n        return this.initialConfig.hidden;\n    },\n\n    /**\n     * Sets the function that will be called by each Component using this action when its primary event is triggered.\n     * @param {Function} fn The function that will be invoked by the action's components.  The function\n     * will be called with no arguments.\n     * @param {Object} scope The scope (this reference) in which the function is executed. Defaults to the Component\n     * firing the event.\n     */\n    setHandler : function(fn, scope){\n        this.initialConfig.handler = fn;\n        this.initialConfig.scope = scope;\n        this.callEach('setHandler', [fn, scope]);\n    },\n\n    /**\n     * Executes the specified function once for each Component currently tied to this Action.  The function passed\n     * in should accept a single argument that will be an object that supports the basic Action config/method interface.\n     * @param {Function} fn The function to execute for each component\n     * @param {Object} scope The scope (this reference) in which the function is executed.\n     * Defaults to the Component.\n     */\n    each : function(fn, scope){\n        Ext.each(this.items, fn, scope);\n    },\n\n    // private\n    callEach : function(fnName, args){\n        var items = this.items,\n            i = 0,\n            len = items.length,\n            item;\n\n        Ext.suspendLayouts();\n        for(; i < len; i++){\n            item = items[i];\n            item[fnName].apply(item, args);\n        }\n        Ext.resumeLayouts(true);\n    },\n\n    // private\n    addComponent : function(comp){\n        this.items.push(comp);\n        comp.on('destroy', this.removeComponent, this);\n    },\n\n    // private\n    removeComponent : function(comp){\n        Ext.Array.remove(this.items, comp);\n    },\n\n    /**\n     * Executes this Action manually using the handler function specified in the original config object\n     * or the handler function set with {@link #setHandler}.  Any arguments passed to this\n     * function will be passed on to the handler function.\n     * @param {Object...} args Variable number of arguments passed to the handler function\n     */\n    execute : function(){\n        this.initialConfig.handler.apply(this.initialConfig.scope || Ext.global, arguments);\n    }\n});\n\n/**\n * The Connection class encapsulates a connection to the page's originating domain, allowing requests to be made either\n * to a configured URL, or to a URL specified at request time.\n *\n * Requests made by this class are asynchronous, and will return immediately. No data from the server will be available\n * to the statement immediately following the {@link #request} call. To process returned data, use a success callback\n * in the request options object, or an {@link #requestcomplete event listener}.\n *\n * # File Uploads\n *\n * File uploads are not performed using normal \"Ajax\" techniques, that is they are not performed using XMLHttpRequests.\n * Instead the form is submitted in the standard manner with the DOM &lt;form&gt; element temporarily modified to have its\n * target set to refer to a dynamically generated, hidden &lt;iframe&gt; which is inserted into the document but removed\n * after the return data has been gathered.\n *\n * The server response is parsed by the browser to create the document for the IFRAME. If the server is using JSON to\n * send the return object, then the Content-Type header must be set to \"text/html\" in order to tell the browser to\n * insert the text unchanged into the document body.\n *\n * Characters which are significant to an HTML parser must be sent as HTML entities, so encode `<` as `&lt;`, `&` as\n * `&amp;` etc.\n *\n * The response text is retrieved from the document, and a fake XMLHttpRequest object is created containing a\n * responseText property in order to conform to the requirements of event handlers and callbacks.\n *\n * Be aware that file upload packets are sent with the content type multipart/form and some server technologies\n * (notably JEE) may require some custom processing in order to retrieve parameter names and parameter values from the\n * packet content.\n *\n * Also note that it's not possible to check the response code of the hidden iframe, so the success handler will ALWAYS fire.\n */\nExt.define('Ext.data.Connection', {\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    statics: {\n        requestId: 0\n    },\n\n    url: null,\n    async: true,\n    method: null,\n    username: '',\n    password: '',\n\n    /**\n     * @cfg {Boolean} disableCaching\n     * True to add a unique cache-buster param to GET requests.\n     */\n    disableCaching: true,\n\n    /**\n     * @cfg {Boolean} withCredentials\n     * True to set `withCredentials = true` on the XHR object\n     */\n    withCredentials: false,\n\n    /**\n     * @cfg {Boolean} cors\n     * True to enable CORS support on the XHR object. Currently the only effect of this option\n     * is to use the XDomainRequest object instead of XMLHttpRequest if the browser is IE8 or above.\n     */\n    cors: false,\n\n    /**\n     * @cfg {String} disableCachingParam\n     * Change the parameter which is sent went disabling caching through a cache buster.\n     */\n    disableCachingParam: '_dc',\n\n    /**\n     * @cfg {Number} timeout\n     * The timeout in milliseconds to be used for requests.\n     */\n    timeout : 30000,\n\n    /**\n     * @cfg {Object} extraParams\n     * Any parameters to be appended to the request.\n     */\n\n    /**\n     * @cfg {Boolean} [autoAbort=false]\n     * Whether this request should abort any pending requests.\n     */\n\n    /**\n     * @cfg {String} method\n     * The default HTTP method to be used for requests.\n     *\n     * If not set, but {@link #request} params are present, POST will be used;\n     * otherwise, GET will be used.\n     */\n\n    /**\n     * @cfg {Object} defaultHeaders\n     * An object containing request headers which are added to each request made by this object.\n     */\n\n    useDefaultHeader : true,\n    defaultPostHeader : 'application/x-www-form-urlencoded; charset=UTF-8',\n    useDefaultXhrHeader : true,\n    defaultXhrHeader : 'XMLHttpRequest',\n\n    constructor : function(config) {\n        config = config || {};\n        Ext.apply(this, config);\n\n        /**\n         * @event beforerequest\n         * Fires before a network request is made to retrieve a data object.\n         * @param {Ext.data.Connection} conn This Connection object.\n         * @param {Object} options The options config object passed to the {@link #request} method.\n         */\n        /**\n         * @event requestcomplete\n         * Fires if the request was successfully completed.\n         * @param {Ext.data.Connection} conn This Connection object.\n         * @param {Object} response The XHR object containing the response data.\n         * See [The XMLHttpRequest Object](http://www.w3.org/TR/XMLHttpRequest/) for details.\n         * @param {Object} options The options config object passed to the {@link #request} method.\n         */\n        /**\n         * @event requestexception\n         * Fires if an error HTTP status was returned from the server.\n         * See [HTTP Status Code Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)\n         * for details of HTTP status codes.\n         * @param {Ext.data.Connection} conn This Connection object.\n         * @param {Object} response The XHR object containing the response data.\n         * See [The XMLHttpRequest Object](http://www.w3.org/TR/XMLHttpRequest/) for details.\n         * @param {Object} options The options config object passed to the {@link #request} method.\n         */\n        this.requests = {};\n        this.mixins.observable.constructor.call(this);\n    },\n\n    /**\n     * Sends an HTTP request to a remote server.\n     *\n     * **Important:** Ajax server requests are asynchronous, and this call will\n     * return before the response has been received. Process any returned data\n     * in a callback function.\n     *\n     *     Ext.Ajax.request({\n     *         url: 'ajax_demo/sample.json',\n     *         success: function(response, opts) {\n     *             var obj = Ext.decode(response.responseText);\n     *             console.dir(obj);\n     *         },\n     *         failure: function(response, opts) {\n     *             console.log('server-side failure with status code ' + response.status);\n     *         }\n     *     });\n     *\n     * To execute a callback function in the correct scope, use the `scope` option.\n     *\n     * @param {Object} options An object which may contain the following properties:\n     *\n     * (The options object may also contain any other property which might be needed to perform\n     * postprocessing in a callback because it is passed to callback functions.)\n     *\n     * @param {String/Function} options.url The URL to which to send the request, or a function\n     * to call which returns a URL string. The scope of the function is specified by the `scope` option.\n     * Defaults to the configured `url`.\n     *\n     * @param {Object/String/Function} options.params An object containing properties which are\n     * used as parameters to the request, a url encoded string or a function to call to get either. The scope\n     * of the function is specified by the `scope` option.\n     *\n     * @param {String} options.method The HTTP method to use\n     * for the request. Defaults to the configured method, or if no method was configured,\n     * \"GET\" if no parameters are being sent, and \"POST\" if parameters are being sent.  Note that\n     * the method name is case-sensitive and should be all caps.\n     *\n     * @param {Function} options.callback The function to be called upon receipt of the HTTP response.\n     * The callback is called regardless of success or failure and is passed the following parameters:\n     * @param {Object} options.callback.options The parameter to the request call.\n     * @param {Boolean} options.callback.success True if the request succeeded.\n     * @param {Object} options.callback.response The XMLHttpRequest object containing the response data.\n     * See [www.w3.org/TR/XMLHttpRequest/](http://www.w3.org/TR/XMLHttpRequest/) for details about\n     * accessing elements of the response.\n     *\n     * @param {Function} options.success The function to be called upon success of the request.\n     * The callback is passed the following parameters:\n     * @param {Object} options.success.response The XMLHttpRequest object containing the response data.\n     * @param {Object} options.success.options The parameter to the request call.\n     *\n     * @param {Function} options.failure The function to be called upon failure of the request.\n     * The callback is passed the following parameters:\n     * @param {Object} options.failure.response The XMLHttpRequest object containing the response data.\n     * @param {Object} options.failure.options The parameter to the request call.\n     *\n     * @param {Object} options.scope The scope in which to execute the callbacks: The \"this\" object for\n     * the callback function. If the `url`, or `params` options were specified as functions from which to\n     * draw values, then this also serves as the scope for those function calls. Defaults to the browser\n     * window.\n     *\n     * @param {Number} options.timeout The timeout in milliseconds to be used for this request.\n     * Defaults to 30 seconds.\n     *\n     * @param {Ext.Element/HTMLElement/String} options.form The `<form>` Element or the id of the `<form>`\n     * to pull parameters from.\n     *\n     * @param {Boolean} options.isUpload **Only meaningful when used with the `form` option.**\n     *\n     * True if the form object is a file upload (will be set automatically if the form was configured\n     * with **`enctype`** `\"multipart/form-data\"`).\n     *\n     * File uploads are not performed using normal \"Ajax\" techniques, that is they are **not**\n     * performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the\n     * DOM `<form>` element temporarily modified to have its [target][] set to refer to a dynamically\n     * generated, hidden `<iframe>` which is inserted into the document but removed after the return data\n     * has been gathered.\n     *\n     * The server response is parsed by the browser to create the document for the IFRAME. If the\n     * server is using JSON to send the return object, then the [Content-Type][] header must be set to\n     * \"text/html\" in order to tell the browser to insert the text unchanged into the document body.\n     *\n     * The response text is retrieved from the document, and a fake XMLHttpRequest object is created\n     * containing a `responseText` property in order to conform to the requirements of event handlers\n     * and callbacks.\n     *\n     * Be aware that file upload packets are sent with the content type [multipart/form][] and some server\n     * technologies (notably JEE) may require some custom processing in order to retrieve parameter names\n     * and parameter values from the packet content.\n     *\n     * [target]: http://www.w3.org/TR/REC-html40/present/frames.html#adef-target\n     * [Content-Type]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17\n     * [multipart/form]: http://www.faqs.org/rfcs/rfc2388.html\n     *\n     * @param {Object} options.headers Request headers to set for the request.\n     *\n     * @param {Object} options.xmlData XML document to use for the post. Note: This will be used instead\n     * of params for the post data. Any params will be appended to the URL.\n     *\n     * @param {Object/String} options.jsonData JSON data to use as the post. Note: This will be used\n     * instead of params for the post data. Any params will be appended to the URL.\n     *\n     * @param {Boolean} options.disableCaching True to add a unique cache-buster param to GET requests.\n     *\n     * @param {Boolean} options.withCredentials True to add the withCredentials property to the XHR object\n     *\n     * @return {Object} The request object. This may be used to cancel the request.\n     */\n    request : function(options) {\n        options = options || {};\n        var me = this,\n            scope = options.scope || window,\n            username = options.username || me.username,\n            password = options.password || me.password || '',\n            async,\n            requestOptions,\n            request,\n            headers,\n            xhr;\n\n        if (me.fireEvent('beforerequest', me, options) !== false) {\n\n            requestOptions = me.setOptions(options, scope);\n\n            if (me.isFormUpload(options)) {\n                me.upload(options.form, requestOptions.url, requestOptions.data, options);\n                return null;\n            }\n\n            // if autoabort is set, cancel the current transactions\n            if (options.autoAbort || me.autoAbort) {\n                me.abort();\n            }\n\n            // create a connection object\n            async = options.async !== false ? (options.async || me.async) : false;\n            xhr = me.openRequest(options, requestOptions, async, username, password);\n\n            headers = me.setupHeaders(xhr, options, requestOptions.data, requestOptions.params);\n\n            // create the transaction object\n            request = {\n                id: ++Ext.data.Connection.requestId,\n                xhr: xhr,\n                headers: headers,\n                options: options,\n                async: async,\n                timeout: setTimeout(function() {\n                    request.timedout = true;\n                    me.abort(request);\n                }, options.timeout || me.timeout)\n            };\n            me.requests[request.id] = request;\n            me.latestId = request.id;\n            // bind our statechange listener\n            if (async) {\n                xhr.onreadystatechange = Ext.Function.bind(me.onStateChange, me, [request]);\n            }\n\n            // start the request!\n            xhr.send(requestOptions.data);\n            if (!async) {\n                return me.onComplete(request);\n            }\n            return request;\n        } else {\n            Ext.callback(options.callback, options.scope, [options, undefined, undefined]);\n            return null;\n        }\n    },\n\n    /**\n     * Uploads a form using a hidden iframe.\n     * @param {String/HTMLElement/Ext.Element} form The form to upload\n     * @param {String} url The url to post to\n     * @param {String} params Any extra parameters to pass\n     * @param {Object} options The initial options\n     */\n    upload: function(form, url, params, options) {\n        form = Ext.getDom(form);\n        options = options || {};\n\n        var id = Ext.id(),\n            frame = document.createElement('iframe'),\n            hiddens = [],\n            encoding = 'multipart/form-data',\n            buf = {\n                target: form.target,\n                method: form.method,\n                encoding: form.encoding,\n                enctype: form.enctype,\n                action: form.action\n            },\n            addField = function(name, value) {\n                hiddenItem = document.createElement('input');\n                Ext.fly(hiddenItem).set({\n                    type: 'hidden',\n                    value: value,\n                    name: name\n                });\n                form.appendChild(hiddenItem);\n                hiddens.push(hiddenItem);\n            },\n            hiddenItem, obj, value, name, vLen, v, hLen, h;\n\n        /*\n         * Originally this behaviour was modified for Opera 10 to apply the secure URL after\n         * the frame had been added to the document. It seems this has since been corrected in\n         * Opera so the behaviour has been reverted, the URL will be set before being added.\n         */\n        Ext.fly(frame).set({\n            id: id,\n            name: id,\n            cls: Ext.baseCSSPrefix + 'hide-display',\n            src: Ext.SSL_SECURE_URL\n        });\n\n        document.body.appendChild(frame);\n\n        // This is required so that IE doesn't pop the response up in a new window.\n        if (document.frames) {\n            document.frames[id].name = id;\n        }\n\n        Ext.fly(form).set({\n            target: id,\n            method: 'POST',\n            enctype: encoding,\n            encoding: encoding,\n            action: url || buf.action\n        });\n\n        // add dynamic params\n        if (params) {\n            obj = Ext.Object.fromQueryString(params) || {};\n\n            for (name in obj) {\n                if (obj.hasOwnProperty(name)) {\n                    value = obj[name];  \n                    if (Ext.isArray(value)) {\n                        vLen = value.length;\n                        for (v = 0; v < vLen; v++) {\n                            addField(name, value[v]);\n                        }\n                    } else {\n                        addField(name, value);\n                    }\n                }\n            }\n        }\n\n        Ext.fly(frame).on('load', Ext.Function.bind(this.onUploadComplete, this, [frame, options]), null, {single: true});\n        form.submit();\n\n        Ext.fly(form).set(buf);\n\n        hLen = hiddens.length;\n\n        for (h = 0; h < hLen; h++) {\n            Ext.removeNode(hiddens[h]);\n        }\n    },\n\n    /**\n     * @private\n     * Callback handler for the upload function. After we've submitted the form via the iframe this creates a bogus\n     * response object to simulate an XHR and populates its responseText from the now-loaded iframe's document body\n     * (or a textarea inside the body). We then clean up by removing the iframe\n     */\n    onUploadComplete: function(frame, options) {\n        var me = this,\n            // bogus response object\n            response = {\n                responseText: '',\n                responseXML: null\n            }, doc, contentNode;\n\n        try {\n            doc = frame.contentWindow.document || frame.contentDocument || window.frames[frame.id].document;\n            if (doc) {\n                if (doc.body) {\n\n                    // Response sent as Content-Type: text/json or text/plain. Browser will embed in a <pre> element\n                    // Note: The statement below tests the result of an assignment.\n                    if ((contentNode = doc.body.firstChild) && /pre/i.test(contentNode.tagName)) {\n                        response.responseText = contentNode.innerText;\n                    }\n\n                    // Response sent as Content-Type: text/html. We must still support JSON response wrapped in textarea.\n                    // Note: The statement below tests the result of an assignment.\n                    else if (contentNode = doc.getElementsByTagName('textarea')[0]) {\n                        response.responseText = contentNode.value;\n                    }\n                    // Response sent as Content-Type: text/html with no wrapping. Scrape JSON response out of text\n                    else {\n                        response.responseText = doc.body.textContent || doc.body.innerText;\n                    }\n                }\n                //in IE the document may still have a body even if returns XML.\n                response.responseXML = doc.XMLDocument || doc;\n            }\n        } catch (e) {\n        }\n\n        me.fireEvent('requestcomplete', me, response, options);\n\n        Ext.callback(options.success, options.scope, [response, options]);\n        Ext.callback(options.callback, options.scope, [options, true, response]);\n\n        setTimeout(function() {\n            Ext.removeNode(frame);\n        }, 100);\n    },\n\n    /**\n     * Detects whether the form is intended to be used for an upload.\n     * @private\n     */\n    isFormUpload: function(options) {\n        var form = this.getForm(options);\n        if (form) {\n            return (options.isUpload || (/multipart\\/form-data/i).test(form.getAttribute('enctype')));\n        }\n        return false;\n    },\n\n    /**\n     * Gets the form object from options.\n     * @private\n     * @param {Object} options The request options\n     * @return {HTMLElement} The form, null if not passed\n     */\n    getForm: function(options) {\n        return Ext.getDom(options.form) || null;\n    },\n\n    /**\n     * Sets various options such as the url, params for the request\n     * @param {Object} options The initial options\n     * @param {Object} scope The scope to execute in\n     * @return {Object} The params for the request\n     */\n    setOptions: function(options, scope) {\n        var me = this,\n            params = options.params || {},\n            extraParams = me.extraParams,\n            urlParams = options.urlParams,\n            url = options.url || me.url,\n            jsonData = options.jsonData,\n            method,\n            disableCache,\n            data;\n\n\n        // allow params to be a method that returns the params object\n        if (Ext.isFunction(params)) {\n            params = params.call(scope, options);\n        }\n\n        // allow url to be a method that returns the actual url\n        if (Ext.isFunction(url)) {\n            url = url.call(scope, options);\n        }\n\n        url = this.setupUrl(options, url);\n\n        if (!url) {\n            Ext.Error.raise({\n                options: options,\n                msg: 'No URL specified'\n            });\n        }\n\n        // check for xml or json data, and make sure json data is encoded\n        data = options.rawData || options.xmlData || jsonData || null;\n        if (jsonData && !Ext.isPrimitive(jsonData)) {\n            data = Ext.encode(data);\n        }\n\n        // make sure params are a url encoded string and include any extraParams if specified\n        if (Ext.isObject(params)) {\n            params = Ext.Object.toQueryString(params);\n        }\n\n        if (Ext.isObject(extraParams)) {\n            extraParams = Ext.Object.toQueryString(extraParams);\n        }\n\n        params = params + ((extraParams) ? ((params) ? '&' : '') + extraParams : '');\n\n        urlParams = Ext.isObject(urlParams) ? Ext.Object.toQueryString(urlParams) : urlParams;\n\n        params = this.setupParams(options, params);\n\n        // decide the proper method for this request\n        method = (options.method || me.method || ((params || data) ? 'POST' : 'GET')).toUpperCase();\n        this.setupMethod(options, method);\n\n\n        disableCache = options.disableCaching !== false ? (options.disableCaching || me.disableCaching) : false;\n        // if the method is get append date to prevent caching\n        if (method === 'GET' && disableCache) {\n            url = Ext.urlAppend(url, (options.disableCachingParam || me.disableCachingParam) + '=' + (new Date().getTime()));\n        }\n\n        // if the method is get or there is json/xml data append the params to the url\n        if ((method == 'GET' || data) && params) {\n            url = Ext.urlAppend(url, params);\n            params = null;\n        }\n\n        // allow params to be forced into the url\n        if (urlParams) {\n            url = Ext.urlAppend(url, urlParams);\n        }\n\n        return {\n            url: url,\n            method: method,\n            data: data || params || null\n        };\n    },\n\n    /**\n     * Template method for overriding url\n     * @template\n     * @private\n     * @param {Object} options\n     * @param {String} url\n     * @return {String} The modified url\n     */\n    setupUrl: function(options, url) {\n        var form = this.getForm(options);\n        if (form) {\n            url = url || form.action;\n        }\n        return url;\n    },\n\n\n    /**\n     * Template method for overriding params\n     * @template\n     * @private\n     * @param {Object} options\n     * @param {String} params\n     * @return {String} The modified params\n     */\n    setupParams: function(options, params) {\n        var form = this.getForm(options),\n            serializedForm;\n        if (form && !this.isFormUpload(options)) {\n            serializedForm = Ext.Element.serializeForm(form);\n            params = params ? (params + '&' + serializedForm) : serializedForm;\n        }\n        return params;\n    },\n\n    /**\n     * Template method for overriding method\n     * @template\n     * @private\n     * @param {Object} options\n     * @param {String} method\n     * @return {String} The modified method\n     */\n    setupMethod: function(options, method) {\n        if (this.isFormUpload(options)) {\n            return 'POST';\n        }\n        return method;\n    },\n\n    /**\n     * Setup all the headers for the request\n     * @private\n     * @param {Object} xhr The xhr object\n     * @param {Object} options The options for the request\n     * @param {Object} data The data for the request\n     * @param {Object} params The params for the request\n     */\n    setupHeaders: function(xhr, options, data, params) {\n        var me = this,\n            headers = Ext.apply({}, options.headers || {}, me.defaultHeaders || {}),\n            contentType = me.defaultPostHeader,\n            jsonData = options.jsonData,\n            xmlData = options.xmlData,\n            key,\n            header;\n\n        if (!headers['Content-Type'] && (data || params)) {\n            if (data) {\n                if (options.rawData) {\n                    contentType = 'text/plain';\n                } else {\n                    if (xmlData && Ext.isDefined(xmlData)) {\n                        contentType = 'text/xml';\n                    } else if (jsonData && Ext.isDefined(jsonData)) {\n                        contentType = 'application/json';\n                    }\n                }\n            }\n            headers['Content-Type'] = contentType;\n        }\n\n        if (me.useDefaultXhrHeader && !headers['X-Requested-With']) {\n            headers['X-Requested-With'] = me.defaultXhrHeader;\n        }\n        // set up all the request headers on the xhr object\n        try {\n            for (key in headers) {\n                if (headers.hasOwnProperty(key)) {\n                    header = headers[key];\n                    xhr.setRequestHeader(key, header);\n                }\n\n            }\n        } catch(e) {\n            me.fireEvent('exception', key, header);\n        }\n        return headers;\n    },\n\n    /**\n     * Creates the appropriate XHR transport for a given request on this browser. On IE\n     * this may be an `XDomainRequest` rather than an `XMLHttpRequest`.\n     * @private\n     */\n    newRequest: function (options) {\n        var xhr;\n\n        if ((options.cors || this.cors) && Ext.isIE && Ext.ieVersion >= 8) {\n            xhr = new XDomainRequest();\n        } else {\n            xhr = this.getXhrInstance();\n        }\n\n        return xhr;\n    },\n\n    /**\n     * Creates and opens an appropriate XHR transport for a given request on this browser.\n     * This logic is contained in an individual method to allow for overrides to process all\n     * of the parameters and options and return a suitable, open connection.\n     * @private\n     */\n    openRequest: function (options, requestOptions, async, username, password) {\n        var xhr = this.newRequest(options);\n\n        if (username) {\n            xhr.open(requestOptions.method, requestOptions.url, async, username, password);\n        } else {\n            xhr.open(requestOptions.method, requestOptions.url, async);\n        }\n\n        if (options.withCredentials || this.withCredentials) {\n            xhr.withCredentials = true;\n        }\n\n        return xhr;\n    },\n\n    /**\n     * Creates the appropriate XHR transport for this browser.\n     * @private\n     */\n    getXhrInstance: (function() {\n        var options = [function() {\n            return new XMLHttpRequest();\n        }, function() {\n            return new ActiveXObject('MSXML2.XMLHTTP.3.0');\n        }, function() {\n            return new ActiveXObject('MSXML2.XMLHTTP');\n        }, function() {\n            return new ActiveXObject('Microsoft.XMLHTTP');\n        }], i = 0,\n            len = options.length,\n            xhr;\n\n        for (; i < len; ++i) {\n            try {\n                xhr = options[i];\n                xhr();\n                break;\n            } catch(e) {\n            }\n        }\n        return xhr;\n    }()),\n\n    /**\n     * Determines whether this object has a request outstanding.\n     * @param {Object} [request] Defaults to the last transaction\n     * @return {Boolean} True if there is an outstanding request.\n     */\n    isLoading : function(request) {\n        if (!request) {\n            request = this.getLatest();\n        }\n        if (!(request && request.xhr)) {\n            return false;\n        }\n        // if there is a connection and readyState is not 0 or 4\n        var state = request.xhr.readyState;\n        return !(state === 0 || state == 4);\n    },\n\n    /**\n     * Aborts an active request.\n     * @param {Object} [request] Defaults to the last request\n     */\n    abort : function(request) {\n        var me = this,\n            xhr;\n        \n        if (!request) {\n            request = me.getLatest();\n        }\n\n        if (request && me.isLoading(request)) {\n            /*\n             * Clear out the onreadystatechange here, this allows us\n             * greater control, the browser may/may not fire the function\n             * depending on a series of conditions.\n             */\n            xhr = request.xhr;\n            try {\n                xhr.onreadystatechange = null;\n            } catch (e) {\n                // Setting onreadystatechange to null can cause problems in IE, see\n                // http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_a_1.html\n                xhr = Ext.emptyFn;\n            }\n            xhr.abort();\n            me.clearTimeout(request);\n            if (!request.timedout) {\n                request.aborted = true;\n            }\n            me.onComplete(request);\n            me.cleanup(request);\n        }\n    },\n    \n    /**\n     * Aborts all active requests\n     */\n    abortAll: function(){\n        var requests = this.requests,\n            id;\n        \n        for (id in requests) {\n            if (requests.hasOwnProperty(id)) {\n                this.abort(requests[id]);\n            }\n        }\n    },\n    \n    /**\n     * Gets the most recent request\n     * @private\n     * @return {Object} The request. Null if there is no recent request\n     */\n    getLatest: function(){\n        var id = this.latestId,\n            request;\n            \n        if (id) {\n            request = this.requests[id];\n        }\n        return request || null;\n    },\n\n    /**\n     * Fires when the state of the xhr changes\n     * @private\n     * @param {Object} request The request\n     */\n    onStateChange : function(request) {\n        if (request.xhr.readyState == 4) {\n            this.clearTimeout(request);\n            this.onComplete(request);\n            this.cleanup(request);\n        }\n    },\n\n    /**\n     * Clears the timeout on the request\n     * @private\n     * @param {Object} The request\n     */\n    clearTimeout: function(request) {\n        clearTimeout(request.timeout);\n        delete request.timeout;\n    },\n\n    /**\n     * Cleans up any left over information from the request\n     * @private\n     * @param {Object} The request\n     */\n    cleanup: function(request) {\n        request.xhr = null;\n        delete request.xhr;\n    },\n\n    /**\n     * To be called when the request has come back from the server\n     * @private\n     * @param {Object} request\n     * @return {Object} The response\n     */\n    onComplete : function(request) {\n        var me = this,\n            options = request.options,\n            result,\n            success,\n            response;\n\n        try {\n            result = me.parseStatus(request.xhr.status);\n        } catch (e) {\n            // in some browsers we can't access the status if the readyState is not 4, so the request has failed\n            result = {\n                success : false,\n                isException : false\n            };\n        }\n        success = result.success;\n\n        if (success) {\n            response = me.createResponse(request);\n            me.fireEvent('requestcomplete', me, response, options);\n            Ext.callback(options.success, options.scope, [response, options]);\n        } else {\n            if (result.isException || request.aborted || request.timedout) {\n                response = me.createException(request);\n            } else {\n                response = me.createResponse(request);\n            }\n            me.fireEvent('requestexception', me, response, options);\n            Ext.callback(options.failure, options.scope, [response, options]);\n        }\n        Ext.callback(options.callback, options.scope, [options, success, response]);\n        delete me.requests[request.id];\n        return response;\n    },\n\n    /**\n     * Checks if the response status was successful\n     * @param {Number} status The status code\n     * @return {Object} An object containing success/status state\n     */\n    parseStatus: function(status) {\n        // see: https://prototype.lighthouseapp.com/projects/8886/tickets/129-ie-mangles-http-response-status-code-204-to-1223\n        status = status == 1223 ? 204 : status;\n\n        var success = (status >= 200 && status < 300) || status == 304,\n            isException = false;\n\n        if (!success) {\n            switch (status) {\n                case 12002:\n                case 12029:\n                case 12030:\n                case 12031:\n                case 12152:\n                case 13030:\n                    isException = true;\n                    break;\n            }\n        }\n        return {\n            success: success,\n            isException: isException\n        };\n    },\n\n    /**\n     * Creates the response object\n     * @private\n     * @param {Object} request\n     */\n    createResponse : function(request) {\n        var xhr = request.xhr,\n            headers = {},\n            lines = xhr.getAllResponseHeaders().replace(/\\r\\n/g, '\\n').split('\\n'),\n            count = lines.length,\n            line, index, key, value, response;\n\n        while (count--) {\n            line = lines[count];\n            index = line.indexOf(':');\n            if (index >= 0) {\n                key = line.substr(0, index).toLowerCase();\n                if (line.charAt(index + 1) == ' ') {\n                    ++index;\n                }\n                headers[key] = line.substr(index + 1);\n            }\n        }\n\n        request.xhr = null;\n        delete request.xhr;\n\n        response = {\n            request: request,\n            requestId : request.id,\n            status : xhr.status,\n            statusText : xhr.statusText,\n            getResponseHeader : function(header) {\n                return headers[header.toLowerCase()];\n            },\n            getAllResponseHeaders : function() {\n                return headers;\n            },\n            responseText : xhr.responseText,\n            responseXML : xhr.responseXML\n        };\n\n        // If we don't explicitly tear down the xhr reference, IE6/IE7 will hold this in the closure of the\n        // functions created with getResponseHeader/getAllResponseHeaders\n        xhr = null;\n        return response;\n    },\n\n    /**\n     * Creates the exception object\n     * @private\n     * @param {Object} request\n     */\n    createException : function(request) {\n        return {\n            request : request,\n            requestId : request.id,\n            status : request.aborted ? -1 : 0,\n            statusText : request.aborted ? 'transaction aborted' : 'communication failure',\n            aborted: request.aborted,\n            timedout: request.timedout\n        };\n    }\n});\n\n/**\n * @class Ext.Ajax\n * @singleton\n * @markdown\n\nA singleton instance of an {@link Ext.data.Connection}. This class\nis used to communicate with your server side code. It can be used as follows:\n\n    Ext.Ajax.request({\n        url: 'page.php',\n        params: {\n            id: 1\n        },\n        success: function(response){\n            var text = response.responseText;\n            // process server response here\n        }\n    });\n\nDefault options for all requests can be set by changing a property on the Ext.Ajax class:\n\n    Ext.Ajax.timeout = 60000; // 60 seconds\n\nAny options specified in the request method for the Ajax request will override any\ndefaults set on the Ext.Ajax class. In the code sample below, the timeout for the\nrequest will be 60 seconds.\n\n    Ext.Ajax.timeout = 120000; // 120 seconds\n    Ext.Ajax.request({\n        url: 'page.aspx',\n        timeout: 60000\n    });\n\nIn general, this class will be used for all Ajax requests in your application.\nThe main reason for creating a separate {@link Ext.data.Connection} is for a\nseries of requests that share common settings that are different to all other\nrequests in the application.\n\n */\nExt.define('Ext.Ajax', {\n    extend: 'Ext.data.Connection',\n    singleton: true,\n\n    /**\n     * @cfg {Object} extraParams @hide\n     */\n    /**\n     * @cfg {Object} defaultHeaders @hide\n     */\n    /**\n     * @cfg {String} method @hide\n     */\n    /**\n     * @cfg {Number} timeout @hide\n     */\n    /**\n     * @cfg {Boolean} autoAbort @hide\n     */\n    /**\n     * @cfg {Boolean} disableCaching @hide\n     */\n\n    /**\n     * @property {Boolean} disableCaching\n     * True to add a unique cache-buster param to GET requests. Defaults to true.\n     */\n    /**\n     * @property {String} url\n     * The default URL to be used for requests to the server.\n     * If the server receives all requests through one URL, setting this once is easier than\n     * entering it on every request.\n     */\n    /**\n     * @property {Object} extraParams\n     * An object containing properties which are used as extra parameters to each request made\n     * by this object. Session information and other data that you need\n     * to pass with each request are commonly put here.\n     */\n    /**\n     * @property {Object} defaultHeaders\n     * An object containing request headers which are added to each request made by this object.\n     */\n    /**\n     * @property {String} method\n     * The default HTTP method to be used for requests. Note that this is case-sensitive and\n     * should be all caps (if not set but params are present will use\n     * <tt>\"POST\"</tt>, otherwise will use <tt>\"GET\"</tt>.)\n     */\n    /**\n     * @property {Number} timeout\n     * The timeout in milliseconds to be used for requests. Defaults to 30000.\n     */\n\n    /**\n     * @property {Boolean} autoAbort\n     * Whether a new request should abort any pending requests.\n     */\n    autoAbort : false\n});\n\n/**\n * A mixin to add floating capability to a Component.\n */\nExt.define('Ext.util.Floating', {\n\n    uses: ['Ext.Layer', 'Ext.window.Window'],\n\n    /**\n     * @cfg {Boolean} focusOnToFront\n     * Specifies whether the floated component should be automatically {@link Ext.Component#method-focus focused} when\n     * it is {@link #toFront brought to the front}.\n     */\n    focusOnToFront: true,\n\n    /**\n     * @cfg {String/Boolean} shadow\n     * Specifies whether the floating component should be given a shadow. Set to true to automatically create an\n     * {@link Ext.Shadow}, or a string indicating the shadow's display {@link Ext.Shadow#mode}. Set to false to\n     * disable the shadow.\n     */\n    shadow: 'sides',\n\n    /**\n     * @cfg {String/Boolean} shadowOffset\n     * Number of pixels to offset the shadow.\n     */\n\n    constructor: function (dom) {\n        var me = this;\n\n        me.el = new Ext.Layer(Ext.apply({\n            hideMode     : me.hideMode,\n            hidden       : me.hidden,\n            shadow       : (typeof me.shadow != 'undefined') ? me.shadow : 'sides',\n            shadowOffset : me.shadowOffset,\n            constrain    : false,\n            shim         : (me.shim === false) ? false : undefined\n        }, me.floating), dom);\n\n        // release config object (if it was one)\n        me.floating = true;\n        \n        // Register with the configured ownerCt.\n        // With this we acquire a floatParent for relative positioning, and a zIndexParent which is an\n        // ancestor floater which provides zIndex management.\n        me.registerWithOwnerCt();\n    },\n\n    registerWithOwnerCt: function() {\n        var me = this;\n\n        if (me.zIndexParent) {\n            me.zIndexParent.unregisterFloatingItem(me);\n        }\n\n        // Acquire a zIndexParent by traversing the ownerCt axis for the nearest floating ancestor\n        me.zIndexParent = me.up('[floating]');\n        me.setFloatParent(me.ownerCt);\n        delete me.ownerCt;\n\n        if (me.zIndexParent) {\n            me.zIndexParent.registerFloatingItem(me);\n        } else {\n            Ext.WindowManager.register(me);\n        }\n    },\n\n    setFloatParent: function(floatParent) {\n        var me = this;\n\n        // Remove listeners from previous floatParent\n        if (me.floatParent) {\n            me.mun(me.floatParent, {\n                hide: me.onFloatParentHide,\n                show: me.onFloatParentShow,\n                scope: me\n            });\n        }\n\n        me.floatParent = floatParent;\n\n        // Floating Components as children of Containers must hide when their parent hides.\n        if (floatParent) {\n            me.mon(me.floatParent, {\n                hide: me.onFloatParentHide,\n                show: me.onFloatParentShow,\n                scope: me\n            });\n        }\n\n        // If a floating Component is configured to be constrained, but has no configured\n        // constrainTo setting, set its constrainTo to be it's ownerCt before rendering.\n        if ((me.constrain || me.constrainHeader) && !me.constrainTo) {\n            me.constrainTo = floatParent ? floatParent.getTargetEl() : me.container;\n        }\n    },\n    \n    onAfterFloatLayout: function(){\n        this.syncShadow();   \n    },\n\n    onFloatParentHide: function() {\n        var me = this;\n\n        if (me.hideOnParentHide !== false && me.isVisible()) {\n            me.hide();\n            me.showOnParentShow = true;\n        }\n    },\n\n    onFloatParentShow: function() {\n        if (this.showOnParentShow) {\n            delete this.showOnParentShow;\n            this.show();\n        }\n    },\n\n    // private\n    // z-index is managed by the zIndexManager and may be overwritten at any time.\n    // Returns the next z-index to be used.\n    // If this is a Container, then it will have rebased any managed floating Components,\n    // and so the next available z-index will be approximately 10000 above that.\n    setZIndex: function(index) {\n        var me = this;\n\n        me.el.setZIndex(index);\n\n        // Next item goes 10 above;\n        index += 10;\n\n        // When a Container with floating descendants has its z-index set, it rebases any floating descendants it is managing.\n        // The returned value is a round number approximately 10000 above the last z-index used.\n        if (me.floatingDescendants) {\n            index = Math.floor(me.floatingDescendants.setBase(index) / 100) * 100 + 10000;\n        }\n        return index;\n    },\n\n    /**\n     * Moves this floating Component into a constrain region.\n     *\n     * By default, this Component is constrained to be within the container it was added to, or the element it was\n     * rendered to.\n     *\n     * An alternative constraint may be passed.\n     * @param {String/HTMLElement/Ext.Element/Ext.util.Region} [constrainTo] The Element or {@link Ext.util.Region Region}\n     * into which this Component is to be constrained. Defaults to the element into which this floating Component\n     * was rendered.\n     */\n    doConstrain: function(constrainTo) {\n        var me = this,\n\n            // Calculate the constrain vector to coerce our position to within our\n            // constrainTo setting. getConstrainVector will provide a default constraint\n            // region if there is no explicit constrainTo, *and* there is no floatParent owner Component.\n            vector = me.getConstrainVector(constrainTo),\n            xy;\n\n        if (vector) {\n            xy = me.getPosition(!!me.floatParent);\n            xy[0] += vector[0];\n            xy[1] += vector[1];\n            me.setPosition(xy);\n        }\n    },\n\n\n    /**\n     * Gets the x/y offsets to constrain this float\n     * @private\n     * @param {String/HTMLElement/Ext.Element/Ext.util.Region} [constrainTo] The Element or {@link Ext.util.Region Region}\n     * into which this Component is to be constrained.\n     * @return {Number[]} The x/y constraints\n     */\n    getConstrainVector: function(constrainTo){\n        var me = this;\n\n        if (me.constrain || me.constrainHeader) {\n            constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();\n            return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);\n        }\n    },\n\n    /**\n     * Aligns this floating Component to the specified element\n     *\n     * @param {Ext.Component/Ext.Element/HTMLElement/String} element\n     * The element or {@link Ext.Component} to align to. If passing a component, it must be a\n     * component instance. If a string id is passed, it will be used as an element id.\n     * @param {String} [position=\"tl-bl?\"] The position to align to\n     * (see {@link Ext.Element#alignTo} for more details).\n     * @param {Number[]} [offsets] Offset the positioning by [x, y]\n     * @return {Ext.Component} this\n     */\n    alignTo: function(element, position, offsets) {\n\n        // element may be a Component, so first attempt to use its el to align to.\n        // When aligning to an Element's X,Y position, we must use setPagePosition which disregards any floatParent\n        this.setPagePosition(this.el.getAlignToXY(element.el || element, position, offsets));\n        return this;\n    },\n\n    /**\n     * Brings this floating Component to the front of any other visible, floating Components managed by the same\n     * {@link Ext.ZIndexManager ZIndexManager}\n     *\n     * If this Component is modal, inserts the modal mask just below this Component in the z-index stack.\n     *\n     * @param {Boolean} [preventFocus=false] Specify `true` to prevent the Component from being focused.\n     * @return {Ext.Component} this\n     */\n    toFront: function(preventFocus) {\n        var me = this;\n\n        // Find the floating Component which provides the base for this Component's zIndexing.\n        // That must move to front to then be able to rebase its zIndex stack and move this to the front\n        if (me.zIndexParent && me.bringParentToFront !== false) {\n            me.zIndexParent.toFront(true);\n        }\n        \n        if (!Ext.isDefined(preventFocus)) {\n            preventFocus = !me.focusOnToFront;\n        }\n        \n        if (preventFocus) {\n            me.preventFocusOnActivate = true;\n        }\n        if (me.zIndexManager.bringToFront(me)) {    \n            if (!preventFocus) {\n                // Kick off a delayed focus request.\n                // If another floating Component is toFronted before the delay expires\n                // this will not receive focus.\n                me.focus(false, true);\n            }\n        }\n        delete me.preventFocusOnActivate;\n        return me;\n    },\n\n    /**\n     * This method is called internally by {@link Ext.ZIndexManager} to signal that a floating Component has either been\n     * moved to the top of its zIndex stack, or pushed from the top of its zIndex stack.\n     *\n     * If a _Window_ is superceded by another Window, deactivating it hides its shadow.\n     *\n     * This method also fires the {@link Ext.Component#activate activate} or\n     * {@link Ext.Component#deactivate deactivate} event depending on which action occurred.\n     *\n     * @param {Boolean} [active=false] True to activate the Component, false to deactivate it.\n     * @param {Ext.Component} [newActive] The newly active Component which is taking over topmost zIndex position.\n     */\n    setActive: function(active, newActive) {\n        var me = this;\n        \n        if (active) {\n            if (me.el.shadow && !me.maximized) {\n                me.el.enableShadow(true);\n            }\n            if (me.modal && !me.preventFocusOnActivate) {\n                me.focus(false, true);\n            }\n            me.fireEvent('activate', me);\n        } else {\n            // Only the *Windows* in a zIndex stack share a shadow. All other types of floaters\n            // can keep their shadows all the time\n            if (me.isWindow && (newActive && newActive.isWindow)) {\n                me.el.disableShadow();\n            }\n            me.fireEvent('deactivate', me);\n        }\n    },\n\n    /**\n     * Sends this Component to the back of (lower z-index than) any other visible windows\n     * @return {Ext.Component} this\n     */\n    toBack: function() {\n        this.zIndexManager.sendToBack(this);\n        return this;\n    },\n\n    /**\n     * Center this Component in its container.\n     * @return {Ext.Component} this\n     */\n    center: function() {\n        var me = this,\n            xy;\n            \n        if (me.isVisible()) {\n            xy = me.el.getAlignToXY(me.container, 'c-c');\n            me.setPagePosition(xy);\n        } else {\n            me.needsCenter = true;\n        }\n        return me;\n    },\n    \n    onFloatShow: function() {\n        if (this.needsCenter) {\n            this.center();    \n        }\n        delete this.needsCenter;\n    },\n\n    // private\n    syncShadow : function() {\n        if (this.floating) {\n            this.el.sync(true);\n        }\n    },\n\n    // private\n    fitContainer: function() {\n        var me = this,\n            parent = me.floatParent,\n            container = parent ? parent.getTargetEl() : me.container;\n\n        me.setSize(container.getViewSize(false));\n        me.setPosition.apply(me, parent ? [0, 0] : container.getXY());\n    }\n});\n\n/**\n * Base class for all Ext components.\n *\n * The Component base class has built-in support for basic hide/show and enable/disable and size control behavior.\n *\n * ## xtypes\n *\n * Every component has a specific xtype, which is its Ext-specific type name, along with methods for checking the xtype\n * like {@link #getXType} and {@link #isXType}. See the [Component Guide][1] for more information on xtypes and the\n * Component hierarchy.\n *\n * ## Finding components\n *\n * All Components are registered with the {@link Ext.ComponentManager} on construction so that they can be referenced at\n * any time via {@link Ext#getCmp Ext.getCmp}, passing the {@link #id}.\n *\n * Additionally the {@link Ext.ComponentQuery} provides a CSS-selectors-like way to look up components by their xtype\n * and many other attributes.  For example the following code will find all textfield components inside component with\n * `id: 'myform'`:\n *\n *     Ext.ComponentQuery.query('#myform textfield');\n *\n * ## Extending Ext.Component\n *\n * All subclasses of Component may participate in the automated Ext component\n * lifecycle of creation, rendering and destruction which is provided by the {@link Ext.container.Container Container}\n * class. Components may be added to a Container through the {@link Ext.container.Container#cfg-items items} config option\n * at the time the Container is created, or they may be added dynamically via the\n * {@link Ext.container.Container#method-add add} method.\n *\n * All user-developed visual widgets that are required to participate in automated lifecycle and size management should\n * subclass Component.\n *\n * See the Creating new UI controls chapter in [Component Guide][1] for details on how and to either extend\n * or augment Ext JS base classes to create custom Components.\n *\n * ## The Ext.Component class by itself\n *\n * Usually one doesn't need to instantiate the Ext.Component class. There are subclasses which implement\n * specialized use cases, covering most application needs. However it is possible to instantiate a base\n * Component, and it can be rendered to document, or handled by layouts as the child item of a Container:\n *\n *     @example\n *     Ext.create('Ext.Component', {\n *         html: 'Hello world!',\n *         width: 300,\n *         height: 200,\n *         padding: 20,\n *         style: {\n *             color: '#FFFFFF',\n *             backgroundColor:'#000000'\n *         },\n *         renderTo: Ext.getBody()\n *     });\n *\n * The Component above creates its encapsulating `div` upon render, and use the configured HTML as content. More complex\n * internal structure may be created using the {@link #renderTpl} configuration, although to display database-derived\n * mass data, it is recommended that an ExtJS data-backed Component such as a {@link Ext.view.View View},\n * {@link Ext.grid.Panel GridPanel}, or {@link Ext.tree.Panel TreePanel} be used.\n *\n * [1]: #!/guide/components\n */\nExt.define('Ext.Component', {\n\n    /* Begin Definitions */\n\n    alias: ['widget.component', 'widget.box'],\n\n    extend: 'Ext.AbstractComponent',\n\n    requires: [\n        'Ext.util.DelayedTask'\n    ],\n\n    uses: [\n        'Ext.Layer',\n        'Ext.resizer.Resizer',\n        'Ext.util.ComponentDragger'\n    ],\n\n    mixins: {\n        floating: 'Ext.util.Floating'\n    },\n\n    statics: {\n        // Collapse/expand directions\n        DIRECTION_TOP: 'top',\n        DIRECTION_RIGHT: 'right',\n        DIRECTION_BOTTOM: 'bottom',\n        DIRECTION_LEFT: 'left',\n\n        VERTICAL_DIRECTION_Re: /^(?:top|bottom)$/,\n\n        // RegExp whih specifies characters in an xtype which must be translated to '-' when generating auto IDs.\n        // This includes dot, comma and whitespace\n        INVALID_ID_CHARS_Re: /[\\.,\\s]/g\n    },\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Boolean/Object} resizable\n     * Specify as `true` to apply a {@link Ext.resizer.Resizer Resizer} to this Component after rendering.\n     *\n     * May also be specified as a config object to be passed to the constructor of {@link Ext.resizer.Resizer Resizer}\n     * to override any defaults. By default the Component passes its minimum and maximum size, and uses\n     * `{@link Ext.resizer.Resizer#dynamic}: false`\n     */\n\n    /**\n     * @cfg {String} resizeHandles\n     * A valid {@link Ext.resizer.Resizer} handles config string. Only applies when resizable = true.\n     */\n    resizeHandles: 'all',\n\n    /**\n     * @cfg {Boolean} [autoScroll=false]\n     * `true` to use overflow:'auto' on the components layout element and show scroll bars automatically when necessary,\n     * `false` to clip any overflowing content.\n     * This should not be combined with {@link #overflowX} or  {@link #overflowY}.\n     */\n\n    /**\n     * @cfg {String} overflowX\n     * Possible values are:\n     *  * `'auto'` to enable automatic horizontal scrollbar (overflow-x: 'auto').\n     *  * `'scroll'` to always enable horizontal scrollbar (overflow-x: 'scroll').\n     * The default is overflow-x: 'hidden'. This should not be combined with {@link #autoScroll}.\n     */\n\n    /**\n     * @cfg {String} overflowY\n     * Possible values are:\n     *  * `'auto'` to enable automatic vertical scrollbar (overflow-y: 'auto').\n     *  * `'scroll'` to always enable vertical scrollbar (overflow-y: 'scroll').\n     * The default is overflow-y: 'hidden'. This should not be combined with {@link #autoScroll}.\n     */\n\n    /**\n     * @cfg {Boolean} floating\n     * Specify as true to float the Component outside of the document flow using CSS absolute positioning.\n     *\n     * Components such as {@link Ext.window.Window Window}s and {@link Ext.menu.Menu Menu}s are floating by default.\n     *\n     * Floating Components that are programatically {@link Ext.Component#method-render rendered} will register\n     * themselves with the global {@link Ext.WindowManager ZIndexManager}\n     *\n     * ### Floating Components as child items of a Container\n     *\n     * A floating Component may be used as a child item of a Container. This just allows the floating Component to seek\n     * a ZIndexManager by examining the ownerCt chain.\n     *\n     * When configured as floating, Components acquire, at render time, a {@link Ext.ZIndexManager ZIndexManager} which\n     * manages a stack of related floating Components. The ZIndexManager brings a single floating Component to the top\n     * of its stack when the Component's {@link #toFront} method is called.\n     *\n     * The ZIndexManager is found by traversing up the {@link #ownerCt} chain to find an ancestor which itself is\n     * floating. This is so that descendant floating Components of floating _Containers_ (Such as a ComboBox dropdown\n     * within a Window) can have its zIndex managed relative to any siblings, but always **above** that floating\n     * ancestor Container.\n     *\n     * If no floating ancestor is found, a floating Component registers itself with the default {@link Ext.WindowManager\n     * ZIndexManager}.\n     *\n     * Floating components _do not participate in the Container's layout_. Because of this, they are not rendered until\n     * you explicitly {@link #method-show} them.\n     *\n     * After rendering, the ownerCt reference is deleted, and the {@link #floatParent} property is set to the found\n     * floating ancestor Container. If no floating ancestor Container was found the {@link #floatParent} property will\n     * not be set.\n     */\n    floating: false,\n\n    /**\n     * @cfg {Boolean} toFrontOnShow\n     * True to automatically call {@link #toFront} when the {@link #method-show} method is called on an already visible,\n     * floating component.\n     */\n    toFrontOnShow: true,\n\n    /**\n     * @property {Ext.ZIndexManager} zIndexManager\n     * Only present for {@link #floating} Components after they have been rendered.\n     *\n     * A reference to the ZIndexManager which is managing this Component's z-index.\n     *\n     * The {@link Ext.ZIndexManager ZIndexManager} maintains a stack of floating Component z-indices, and also provides\n     * a single modal mask which is insert just beneath the topmost visible modal floating Component.\n     *\n     * Floating Components may be {@link #toFront brought to the front} or {@link #toBack sent to the back} of the\n     * z-index stack.\n     *\n     * This defaults to the global {@link Ext.WindowManager ZIndexManager} for floating Components that are\n     * programatically {@link Ext.Component#method-render rendered}.\n     *\n     * For {@link #floating} Components which are added to a Container, the ZIndexManager is acquired from the first\n     * ancestor Container found which is floating. If no floating ancestor is found, the global {@link Ext.WindowManager ZIndexManager} is\n     * used.\n     *\n     * See {@link #floating} and {@link #zIndexParent}\n     * @readonly\n     */\n\n    /**\n     * @property {Ext.Container} floatParent\n     * Only present for {@link #floating} Components which were inserted as child items of Containers.\n     *\n     * Floating Components that are programatically {@link Ext.Component#method-render rendered} will not have a `floatParent`\n     * property.\n     *\n     * For {@link #floating} Components which are child items of a Container, the floatParent will be the owning Container.\n     *\n     * For example, the dropdown {@link Ext.view.BoundList BoundList} of a ComboBox which is in a Window will have the\n     * Window as its `floatParent`\n     *\n     * See {@link #floating} and {@link #zIndexManager}\n     * @readonly\n     */\n\n    /**\n     * @property {Ext.Container} zIndexParent\n     * Only present for {@link #floating} Components which were inserted as child items of Containers, and which have a floating\n     * Container in their containment ancestry.\n     *\n     * For {@link #floating} Components which are child items of a Container, the zIndexParent will be a floating\n     * ancestor Container which is responsible for the base z-index value of all its floating descendants. It provides\n     * a {@link Ext.ZIndexManager ZIndexManager} which provides z-indexing services for all its descendant floating\n     * Components.\n     *\n     * Floating Components that are programatically {@link Ext.Component#method-render rendered} will not have a `zIndexParent`\n     * property.\n     *\n     * For example, the dropdown {@link Ext.view.BoundList BoundList} of a ComboBox which is in a Window will have the\n     * Window as its `zIndexParent`, and will always show above that Window, wherever the Window is placed in the z-index stack.\n     *\n     * See {@link #floating} and {@link #zIndexManager}\n     * @readonly\n     */\n\n    /**\n     * @cfg {Boolean/Object} [draggable=false]\n     * Specify as true to make a {@link #floating} Component draggable using the Component's encapsulating element as\n     * the drag handle.\n     *\n     * This may also be specified as a config object for the {@link Ext.util.ComponentDragger ComponentDragger} which is\n     * instantiated to perform dragging.\n     *\n     * For example to create a Component which may only be dragged around using a certain internal element as the drag\n     * handle, use the delegate option:\n     *\n     *     new Ext.Component({\n     *         constrain: true,\n     *         floating: true,\n     *         style: {\n     *             backgroundColor: '#fff',\n     *             border: '1px solid black'\n     *         },\n     *         html: '<h1 style=\"cursor:move\">The title</h1><p>The content</p>',\n     *         draggable: {\n     *             delegate: 'h1'\n     *         }\n     *     }).show();\n     */\n    \n    /**\n     * @cfg {Boolean} [formBind=false]\n     * When inside FormPanel, any component configured with `formBind: true` will\n     * be enabled/disabled depending on the validity state of the form.\n     * See {@link Ext.form.Panel} for more information and example.\n     */\n\n    /**\n     * @cfg {Number/String} [columnWidth=undefined]\n     * Defines the column width inside {@link Ext.layout.container.Column column layout}.\n     *\n     * Can be specified as a number or as a percentage.\n     */\n\n    /**\n     * @cfg {String} [region=undefined]\n     * Defines the region inside {@link Ext.layout.container.Border border layout}.\n     *\n     * Possible values:\n     *\n     * - center\n     * - north\n     * - south\n     * - east\n     * - west\n     */\n\n    hideMode: 'display',\n\n    bubbleEvents: [],\n\n    monPropRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,\n\n    defaultComponentLayoutType: 'autocomponent',\n\n    //renderTpl: new Ext.XTemplate(\n    //    '<div id=\"{id}\" class=\"{baseCls} {cls} {cmpCls}<tpl if=\"typeof ui !== \\'undefined\\'\"> {uiBase}-{ui}</tpl>\"<tpl if=\"typeof style !== \\'undefined\\'\"> style=\"{style}\"</tpl>></div>', {\n    //        compiled: true,\n    //        disableFormats: true\n    //    }\n    //),\n\n    /**\n     * Creates new Component.\n     * @param {Ext.Element/String/Object} config The configuration options may be specified as either:\n     *\n     * - **an element** : it is set as the internal element and its id used as the component id\n     * - **a string** : it is assumed to be the id of an existing element and is used as the component id\n     * - **anything else** : it is assumed to be a standard config object and is applied to the component\n     */\n    constructor: function(config) {\n        var me = this;\n\n        config = config || {};\n        if (config.initialConfig) {\n\n            // Being initialized from an Ext.Action instance...\n            if (config.isAction) {\n                me.baseAction = config;\n            }\n            config = config.initialConfig;\n            // component cloning / action set up\n        }\n        else if (config.tagName || config.dom || Ext.isString(config)) {\n            // element object\n            config = {\n                applyTo: config,\n                id: config.id || config\n            };\n        }\n\n        me.callParent([config]);\n\n        // If we were configured from an instance of Ext.Action, (or configured with a baseAction option),\n        // register this Component as one of its items\n        if (me.baseAction){\n            me.baseAction.addComponent(me);\n        }\n    },\n\n    /**\n     * The initComponent template method is an important initialization step for a Component. It is intended to be\n     * implemented by each subclass of Ext.Component to provide any needed constructor logic. The\n     * initComponent method of the class being created is called first, with each initComponent method\n     * up the hierarchy to Ext.Component being called thereafter. This makes it easy to implement and,\n     * if needed, override the constructor logic of the Component at any step in the hierarchy.\n     *\n     * The initComponent method **must** contain a call to {@link Ext.Base#callParent callParent} in order\n     * to ensure that the parent class' initComponent method is also called.\n     *\n     * All config options passed to the constructor are applied to `this` before initComponent is called,\n     * so you can simply access them with `this.someOption`.\n     *\n     * The following example demonstrates using a dynamic string for the text of a button at the time of\n     * instantiation of the class.\n     *\n     *     Ext.define('DynamicButtonText', {\n     *         extend: 'Ext.button.Button',\n     *\n     *         initComponent: function() {\n     *             this.text = new Date();\n     *             this.renderTo = Ext.getBody();\n     *             this.callParent();\n     *         }\n     *     });\n     *\n     *     Ext.onReady(function() {\n     *         Ext.create('DynamicButtonText');\n     *     });\n     *\n     * @template\n     * @protected\n     */\n    initComponent: function() {\n        var me = this;\n\n        me.callParent();\n\n        if (me.listeners) {\n            me.on(me.listeners);\n            me.listeners = null; //change the value to remove any on prototype\n        }\n        me.enableBubble(me.bubbleEvents);\n        me.mons = [];\n    },\n\n\n    // private\n    afterRender: function() {\n        var me = this;\n\n        me.callParent();\n\n        if (!(me.x && me.y) && (me.pageX || me.pageY)) {\n            me.setPagePosition(me.pageX, me.pageY);\n        }\n    },\n\n    /**\n     * Sets the overflow on the content element of the component.\n     * @param {Boolean} scroll True to allow the Component to auto scroll.\n     * @return {Ext.Component} this\n     */\n    setAutoScroll : function(scroll) {\n        var me = this;\n\n        me.autoScroll = !!scroll;\n\n        // Scrolling styles must be applied to Component's main element.\n        // Layouts which use an innerCt (Box layout), shrinkwrap the innerCt round overflowing content,\n        // so the innerCt must be scrolled by the container, it does not scroll content.\n        if (me.rendered) {\n            me.getTargetEl().setStyle(me.getOverflowStyle());\n        }\n        me.updateLayout();\n        return me;\n    },\n\n    /**\n     * Sets the overflow x/y on the content element of the component. The x/y overflow\n     * values can be any valid CSS overflow (e.g., 'auto' or 'scroll'). By default, the\n     * value is 'hidden'. Passing null for one of the values will erase the inline style.\n     * Passing `undefined` will preserve the current value.\n     *\n     * @param {String} overflowX The overflow-x value.\n     * @param {String} overflowY The overflow-y value.\n     * @return {Ext.Component} this\n     */\n    setOverflowXY: function(overflowX, overflowY) {\n        var me = this,\n            argCount = arguments.length;\n\n        if (argCount) {\n            me.overflowX = overflowX || '';\n            if (argCount > 1) {\n                me.overflowY = overflowY || '';\n            }\n        }\n\n        // Scrolling styles must be applied to Component's main element.\n        // Layouts which use an innerCt (Box layout), shrinkwrap the innerCt round overflowing content,\n        // so the innerCt must be scrolled by the container, it does not scroll content.\n        if (me.rendered) {\n            me.getTargetEl().setStyle(me.getOverflowStyle());\n        }\n        me.updateLayout();\n        return me;\n    },\n\n    beforeRender: function () {\n        var me = this,\n            floating = me.floating,\n            cls;\n\n        if (floating) {\n            me.addCls(Ext.baseCSSPrefix + 'layer');\n\n            cls = floating.cls;\n            if (cls) {\n                me.addCls(cls);\n            }\n        }\n\n        return me.callParent();\n    },\n    \n    afterComponentLayout: function(){\n        this.callParent(arguments);\n        if (this.floating) {\n            this.onAfterFloatLayout();\n        }\n    },\n\n    // private\n    makeFloating : function (dom) {\n        this.mixins.floating.constructor.call(this, dom);\n    },\n\n    wrapPrimaryEl: function (dom) {\n        if (this.floating) {\n            this.makeFloating(dom);\n        } else {\n            this.callParent(arguments);\n        }\n    },\n\n    initResizable: function(resizable) {\n        var me = this;\n\n        resizable = Ext.apply({\n            target: me,\n            dynamic: false,\n            constrainTo: me.constrainTo || (me.floatParent ? me.floatParent.getTargetEl() : null),\n            handles: me.resizeHandles\n        }, resizable);\n        resizable.target = me;\n        me.resizer = new Ext.resizer.Resizer(resizable);\n    },\n\n    getDragEl: function() {\n        return this.el;\n    },\n\n    initDraggable: function() {\n        var me = this,\n\n            // If we are resizable, and the resizer had to wrap this Component's el (eg an Img)\n            // Then we have to create a pseudo-Component out of the resizer to drag that,\n            // otherwise, we just drag this Component\n            dragTarget = (me.resizer && me.resizer.el !== me.el) ? me.resizerComponent = new Ext.Component({\n                el: me.resizer.el,\n                rendered: true,\n                container: me.container\n            }) : me,\n            ddConfig = Ext.applyIf({\n                el: dragTarget.getDragEl(),\n                constrainTo: me.constrain ? (me.constrainTo || (me.floatParent ? me.floatParent.getTargetEl() : me.el.getScopeParent())) : undefined\n            }, me.draggable);\n\n        // Add extra configs if Component is specified to be constrained\n        if (me.constrain || me.constrainDelegate) {\n            ddConfig.constrain = me.constrain;\n            ddConfig.constrainDelegate = me.constrainDelegate;\n        }\n\n        me.dd = new Ext.util.ComponentDragger(dragTarget, ddConfig);\n    },\n\n    /**\n     * Scrolls this Component's {@link #getTargetEl target element} by the passed delta values, optionally animating.\n     *\n     * All of the following are equivalent:\n     *\n     *      comp.scrollBy(10, 10, true);\n     *      comp.scrollBy([10, 10], true);\n     *      comp.scrollBy({ x: 10, y: 10 }, true);\n     *\n     * @param {Number/Number[]/Object} deltaX Either the x delta, an Array specifying x and y deltas or\n     * an object with \"x\" and \"y\" properties.\n     * @param {Number/Boolean/Object} deltaY Either the y delta, or an animate flag or config object.\n     * @param {Boolean/Object} animate Animate flag/config object if the delta values were passed separately.\n     */\n    scrollBy: function(deltaX, deltaY, animate) {\n        var el;\n\n        if ((el = this.getTargetEl()) && el.dom) {\n            el.scrollBy.apply(el, arguments);\n        }\n    },\n\n    /**\n     * This method allows you to show or hide a LoadMask on top of this component.\n     *\n     * @param {Boolean/Object/String} load True to show the default LoadMask, a config object that will be passed to the\n     * LoadMask constructor, or a message String to show. False to hide the current LoadMask.\n     * @param {Boolean} [targetEl=false] True to mask the targetEl of this Component instead of the `this.el`. For example,\n     * setting this to true on a Panel will cause only the body to be masked.\n     * @return {Ext.LoadMask} The LoadMask instance that has just been shown.\n     */\n    setLoading : function(load, targetEl) {\n        var me = this,\n            config;\n\n        if (me.rendered) {\n            Ext.destroy(me.loadMask);\n            me.loadMask = null;\n\n            if (load !== false && !me.collapsed) {\n                if (Ext.isObject(load)) {\n                    config = Ext.apply({}, load);\n                } else if (Ext.isString(load)) {\n                    config = {msg: load};\n                } else {\n                    config = {};\n                }\n                if (targetEl) {\n                    Ext.applyIf(config, {\n                        useTargetEl: true\n                    });\n                }\n                me.loadMask = new Ext.LoadMask(me, config);\n                me.loadMask.show();\n            }\n        }\n        return me.loadMask;\n    },\n\n    beforeSetPosition: function () {\n        var me = this,\n            pos = me.callParent(arguments), // pass all args on for signature decoding\n            adj;\n\n        if (pos) {\n            adj = me.adjustPosition(pos.x, pos.y);\n            pos.x = adj.x;\n            pos.y = adj.y;\n        }\n        return pos || null;\n    },\n\n    afterSetPosition: function(ax, ay) {\n        this.onPosition(ax, ay);\n        this.fireEvent('move', this, ax, ay);\n    },\n\n    /**\n     * Displays component at specific xy position.\n     * A floating component (like a menu) is positioned relative to its ownerCt if any.\n     * Useful for popping up a context menu:\n     *\n     *     listeners: {\n     *         itemcontextmenu: function(view, record, item, index, event, options) {\n     *             Ext.create('Ext.menu.Menu', {\n     *                 width: 100,\n     *                 height: 100,\n     *                 margin: '0 0 10 0',\n     *                 items: [{\n     *                     text: 'regular item 1'\n     *                 },{\n     *                     text: 'regular item 2'\n     *                 },{\n     *                     text: 'regular item 3'\n     *                 }]\n     *             }).showAt(event.getXY());\n     *         }\n     *     }\n     *\n     * @param {Number} x The new x position\n     * @param {Number} y The new y position\n     * @param {Boolean/Object} [animate] True to animate the Component into its new position. You may also pass an\n     * animation configuration.\n     */\n    showAt: function(x, y, animate) {\n        var me = this;\n\n        if (!me.rendered && (me.autoRender || me.floating)) {\n            me.doAutoRender();\n            // forcibly set hidden here, since we still want the initial beforeshow/show event to fire\n            me.hidden = true;\n        }\n        if (me.floating) {\n            me.setPosition(x, y, animate);\n        } else {\n            me.setPagePosition(x, y, animate);\n        }\n        me.show();\n    },\n\n    /**\n     * Sets the page XY position of the component. To set the left and top instead, use {@link #setPosition}.\n     * This method fires the {@link #event-move} event.\n     * @param {Number} x The new x position\n     * @param {Number} y The new y position\n     * @param {Boolean/Object} [animate] True to animate the Component into its new position. You may also pass an\n     * animation configuration.\n     * @return {Ext.Component} this\n     */\n    setPagePosition: function(x, y, animate) {\n        var me = this,\n            p,\n            floatParentBox;\n\n        if (Ext.isArray(x)) {\n            y = x[1];\n            x = x[0];\n        }\n        me.pageX = x;\n        me.pageY = y;\n\n        if (me.floating) {\n\n            // Floating Components which are registered with a Container have to have their x and y properties made relative\n            if (me.isContainedFloater()) {\n                floatParentBox = me.floatParent.getTargetEl().getViewRegion();\n                if (Ext.isNumber(x) && Ext.isNumber(floatParentBox.left)) {\n                    x -= floatParentBox.left;\n                }\n                if (Ext.isNumber(y) && Ext.isNumber(floatParentBox.top)) {\n                    y -= floatParentBox.top;\n                }\n            } else {\n                p = me.el.translatePoints(x, y);\n                x = p.left;\n                y = p.top;\n            }\n\n            me.setPosition(x, y, animate);\n        } else {\n            p = me.el.translatePoints(x, y);\n            me.setPosition(p.left, p.top, animate);\n        }\n\n        return me;\n    },\n\n    // Utility method to determine if a Component is floating, and has an owning Container whose coordinate system\n    // it must be positioned in when using setPosition.\n    isContainedFloater: function() {\n        return (this.floating && this.floatParent);\n    },\n\n    /**\n     * Gets the current box measurements of the component's underlying element.\n     * @param {Boolean} [local=false] If true the element's left and top are returned instead of page XY.\n     * @return {Object} box An object in the format {x, y, width, height}\n     */\n    getBox : function(local){\n        var pos = local ? this.getPosition(local) : this.el.getXY(),\n            size = this.getSize();\n\n        size.x = pos[0];\n        size.y = pos[1];\n        return size;\n    },\n\n    /**\n     * Sets the current box measurements of the component's underlying element.\n     * @param {Object} box An object in the format {x, y, width, height}\n     * @return {Ext.Component} this\n     */\n    updateBox : function(box){\n        this.setSize(box.width, box.height);\n        this.setPagePosition(box.x, box.y);\n        return this;\n    },\n\n    // Include margins\n    getOuterSize: function() {\n        var el = this.el;\n        return {\n            width: el.getWidth() + el.getMargin('lr'),\n            height: el.getHeight() + el.getMargin('tb')\n        };\n    },\n\n    // private\n    adjustPosition: function(x, y) {\n        var me = this,\n            floatParentBox;\n\n        // Floating Components being positioned in their ownerCt have to be made absolute.\n        if (me.isContainedFloater()) {\n            floatParentBox = me.floatParent.getTargetEl().getViewRegion();\n            x += floatParentBox.left;\n            y += floatParentBox.top;\n        }\n\n        return {\n            x: x,\n            y: y\n        };\n    },\n\n    /**\n     * Gets the current XY position of the component's underlying element.\n     * @param {Boolean} [local=false] If true the element's left and top are returned instead of page XY.\n     * @return {Number[]} The XY position of the element (e.g., [100, 200])\n     */\n    getPosition: function(local) {\n        var me = this,\n            el = me.el,\n            xy,\n            isContainedFloater = me.isContainedFloater(),\n            floatParentBox;\n\n        // Local position for non-floaters means element's local position\n        if ((local === true) && !isContainedFloater) {\n            return [el.getLocalX(), el.getLocalY()];\n        }\n\n        xy = me.el.getXY();\n\n        // Local position for floaters means position relative to the container's target element\n        if ((local === true) && isContainedFloater) {\n            floatParentBox = me.floatParent.getTargetEl().getViewRegion();\n            xy[0] -= floatParentBox.left;\n            xy[1] -= floatParentBox.top;\n        }\n        return xy;\n    },\n\n    getId: function() {\n        var me = this,\n            xtype;\n\n        if (!me.id) {\n            xtype = me.getXType();\n            if (xtype) {\n                xtype = xtype.replace(Ext.Component.INVALID_ID_CHARS_Re, '-');\n            } else {\n                xtype = Ext.name.toLowerCase() + '-comp';\n            }\n            me.id = xtype + '-' + me.getAutoId();\n        }\n        return me.id;\n    },\n\n    /**\n     * Shows this Component, rendering it first if {@link #autoRender} or {@link #floating} are `true`.\n     *\n     * After being shown, a {@link #floating} Component (such as a {@link Ext.window.Window}), is activated it and\n     * brought to the front of its {@link #zIndexManager z-index stack}.\n     *\n     * @param {String/Ext.Element} [animateTarget=null] **only valid for {@link #floating} Components such as {@link\n     * Ext.window.Window Window}s or {@link Ext.tip.ToolTip ToolTip}s, or regular Components which have been configured\n     * with `floating: true`.** The target from which the Component should animate from while opening.\n     * @param {Function} [callback] A callback function to call after the Component is displayed.\n     * Only necessary if animation was specified.\n     * @param {Object} [scope] The scope (`this` reference) in which the callback is executed.\n     * Defaults to this Component.\n     * @return {Ext.Component} this\n     */\n    show: function(animateTarget, cb, scope) {\n        var me = this,\n            rendered = me.rendered;\n\n        if (rendered && me.isVisible()) {\n            if (me.toFrontOnShow && me.floating) {\n                me.toFront();\n            }\n        } else {\n            if (me.fireEvent('beforeshow', me) !== false) {\n                // Render on first show if there is an autoRender config, or if this is a floater (Window, Menu, BoundList etc).\n                me.hidden = false;\n                if (!rendered && (me.autoRender || me.floating)) {\n                    me.doAutoRender();\n                    rendered = me.rendered;\n                }\n            \n                if (rendered) {\n                    me.beforeShow();\n                    me.onShow.apply(me, arguments);\n                    me.afterShow.apply(me, arguments);\n                }\n            } else {\n                me.onShowVeto();\n            }\n        }\n        return me;\n    },\n    \n    onShowVeto: Ext.emptyFn,\n\n    /**\n     * Invoked before the Component is shown.\n     *\n     * @method\n     * @template\n     * @protected\n     */\n    beforeShow: Ext.emptyFn,\n\n    /**\n     * Allows addition of behavior to the show operation. After\n     * calling the superclass's onShow, the Component will be visible.\n     *\n     * Override in subclasses where more complex behaviour is needed.\n     *\n     * Gets passed the same parameters as #show.\n     *\n     * @param {String/Ext.Element} [animateTarget]\n     * @param {Function} [callback]\n     * @param {Object} [scope]\n     *\n     * @template\n     * @protected\n     */\n    onShow: function() {\n        var me = this;\n\n        me.el.show();\n        me.callParent(arguments);\n\n        // Constraining/containing element may have changed size while this Component was hidden\n        if (me.floating) {\n            if (me.maximized) {\n                me.fitContainer();\n            }\n            else if (me.constrain) {\n                me.doConstrain();\n            }\n        }\n    },\n\n    /**\n     * Invoked after the Component is shown (after #onShow is called).\n     *\n     * Gets passed the same parameters as #show.\n     *\n     * @param {String/Ext.Element} [animateTarget]\n     * @param {Function} [callback]\n     * @param {Object} [scope]\n     *\n     * @template\n     * @protected\n     */\n    afterShow: function(animateTarget, cb, scope) {\n        var me = this,\n            fromBox,\n            toBox,\n            ghostPanel;\n\n        // Default to configured animate target if none passed\n        animateTarget = animateTarget || me.animateTarget;\n\n        // Need to be able to ghost the Component\n        if (!me.ghost) {\n            animateTarget = null;\n        }\n        // If we're animating, kick of an animation of the ghost from the target to the *Element* current box\n        if (animateTarget) {\n            animateTarget = animateTarget.el ? animateTarget.el : Ext.get(animateTarget);\n            toBox = me.el.getBox();\n            fromBox = animateTarget.getBox();\n            me.el.addCls(Ext.baseCSSPrefix + 'hide-offsets');\n            ghostPanel = me.ghost();\n            ghostPanel.el.stopAnimation();\n\n            // Shunting it offscreen immediately, *before* the Animation class grabs it ensure no flicker.\n            ghostPanel.el.setX(-10000);\n\n            ghostPanel.el.animate({\n                from: fromBox,\n                to: toBox,\n                listeners: {\n                    afteranimate: function() {\n                        delete ghostPanel.componentLayout.lastComponentSize;\n                        me.unghost();\n                        me.el.removeCls(Ext.baseCSSPrefix + 'hide-offsets');\n                        me.onShowComplete(cb, scope);\n                    }\n                }\n            });\n        }\n        else {\n            me.onShowComplete(cb, scope);\n        }\n    },\n\n    /**\n     * Invoked after the #afterShow method is complete.\n     *\n     * Gets passed the same `callback` and `scope` parameters that #afterShow received.\n     *\n     * @param {Function} [callback]\n     * @param {Object} [scope]\n     *\n     * @template\n     * @protected\n     */\n    onShowComplete: function(cb, scope) {\n        var me = this;\n        if (me.floating) {\n            me.toFront();\n            me.onFloatShow();\n        }\n        Ext.callback(cb, scope || me);\n        me.fireEvent('show', me);\n        delete me.hiddenByLayout;\n    },\n\n    /**\n     * Hides this Component, setting it to invisible using the configured {@link #hideMode}.\n     * @param {String/Ext.Element/Ext.Component} [animateTarget=null] **only valid for {@link #floating} Components\n     * such as {@link Ext.window.Window Window}s or {@link Ext.tip.ToolTip ToolTip}s, or regular Components which have\n     * been configured with `floating: true`.**. The target to which the Component should animate while hiding.\n     * @param {Function} [callback] A callback function to call after the Component is hidden.\n     * @param {Object} [scope] The scope (`this` reference) in which the callback is executed.\n     * Defaults to this Component.\n     * @return {Ext.Component} this\n     */\n    hide: function() {\n        var me = this;\n\n        // Clear the flag which is set if a floatParent was hidden while this is visible.\n        // If a hide operation was subsequently called, that pending show must be hidden.\n        me.showOnParentShow = false;\n\n        if (!(me.rendered && !me.isVisible()) && me.fireEvent('beforehide', me) !== false) {\n            me.hidden = true;\n            if (me.rendered) {\n                me.onHide.apply(me, arguments);\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Possibly animates down to a target element.\n     *\n     * Allows addition of behavior to the hide operation. After\n     * calling the superclass’s onHide, the Component will be hidden.\n     *\n     * Gets passed the same parameters as #hide.\n     *\n     * @param {String/Ext.Element/Ext.Component} [animateTarget]\n     * @param {Function} [callback]\n     * @param {Object} [scope]\n     *\n     * @template\n     * @protected\n     */\n    onHide: function(animateTarget, cb, scope) {\n        var me = this,\n            ghostPanel,\n            toBox;\n\n        // Default to configured animate target if none passed\n        animateTarget = animateTarget || me.animateTarget;\n\n        // Need to be able to ghost the Component\n        if (!me.ghost) {\n            animateTarget = null;\n        }\n        // If we're animating, kick off an animation of the ghost down to the target\n        if (animateTarget) {\n            animateTarget = animateTarget.el ? animateTarget.el : Ext.get(animateTarget);\n            ghostPanel = me.ghost();\n            ghostPanel.el.stopAnimation();\n            toBox = animateTarget.getBox();\n            toBox.width += 'px';\n            toBox.height += 'px';\n            ghostPanel.el.animate({\n                to: toBox,\n                listeners: {\n                    afteranimate: function() {\n                        delete ghostPanel.componentLayout.lastComponentSize;\n                        ghostPanel.el.hide();\n                        me.afterHide(cb, scope);\n                    }\n                }\n            });\n        }\n        me.el.hide();\n        if (!animateTarget) {\n            me.afterHide(cb, scope);\n        }\n    },\n\n    /**\n     * Invoked after the Component has been hidden.\n     *\n     * Gets passed the same `callback` and `scope` parameters that #onHide received.\n     *\n     * @param {Function} [callback]\n     * @param {Object} [scope]\n     *\n     * @template\n     * @protected\n     */\n    afterHide: function(cb, scope) {\n        var me = this;\n        delete me.hiddenByLayout;\n\n        // we are the back-end method of onHide at this level, but our call to our parent\n        // may need to be async... so callParent won't quite work here...\n        Ext.AbstractComponent.prototype.onHide.call(this);\n\n        Ext.callback(cb, scope || me);\n        me.fireEvent('hide', me);\n    },\n\n    /**\n     * Allows addition of behavior to the destroy operation.\n     * After calling the superclass’s onDestroy, the Component will be destroyed.\n     *\n     * @template\n     * @protected\n     */\n    onDestroy: function() {\n        var me = this;\n\n        // Ensure that any ancillary components are destroyed.\n        if (me.rendered) {\n            Ext.destroy(\n                me.proxy,\n                me.proxyWrap,\n                me.resizer,\n                me.resizerComponent\n            );\n        }\n        delete me.focusTask;\n        me.callParent();\n    },\n\n    deleteMembers: function() {\n        var args = arguments,\n            len = args.length,\n            i = 0;\n        for (; i < len; ++i) {\n            delete this[args[i]];\n        }\n    },\n\n    /**\n     * Try to focus this component.\n     * @param {Boolean} [selectText] If applicable, true to also select the text in this component\n     * @param {Boolean/Number} [delay] Delay the focus this number of milliseconds (true for 10 milliseconds).\n     * @return {Ext.Component} The focused Component. Usually <code>this</code> Component. Some Containers may\n     * delegate focus to a descendant Component ({@link Ext.window.Window Window}s can do this through their\n     * {@link Ext.window.Window#defaultFocus defaultFocus} config option.\n     */\n    focus: function(selectText, delay) {\n        var me = this,\n            focusEl,\n            focusElDom,\n            containerScrollTop;\n\n        // If delay is wanted, queue a call to this function.\n        if (delay) {\n            if (!me.focusTask) {\n                me.focusTask = new Ext.util.DelayedTask(me.focus);\n            }\n            me.focusTask.delay(Ext.isNumber(delay) ? delay : 10, null, me, [selectText, false]);\n            return me;\n        }\n\n        if (me.rendered && !me.isDestroyed && me.isVisible(true) && (focusEl = me.getFocusEl())) {\n\n            // getFocusEl might return a Component if a Container wishes to delegate focus to a descendant.\n            // Window can do this via its defaultFocus configuration which can reference a Button.\n            if (focusEl.isComponent) {\n                return focusEl.focus(selectText, delay);\n            }\n\n            // If it was an Element with a dom property\n            if ((focusElDom = focusEl.dom)) {\n\n                // Not a natural focus holding element, add a tab index to make it programatically focusable.\n                if (focusEl.needsTabIndex()) {\n                    focusElDom.tabIndex = -1;\n                }\n\n                if (me.floating) {\n                    containerScrollTop = me.container.dom.scrollTop;\n                }\n\n                // Focus the element.\n                // The focusEl has a DOM focus listener on it which invokes the Component's onFocus method\n                // to perform Component-specific focus processing\n                focusEl.focus();\n                if (selectText === true) {\n                    focusElDom.select();\n                }\n            }\n\n            // Focusing a floating Component brings it to the front of its stack.\n            // this is performed by its zIndexManager. Pass preventFocus true to avoid recursion.\n            if (me.floating) {\n                me.toFront(true);\n                if (containerScrollTop !== undefined) {\n                    me.container.dom.scrollTop = containerScrollTop;\n                }\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Cancel any deferred focus on this component\n     * @protected\n     */\n    cancelFocus: function() {\n        var task = this.focusTask;\n        if (task) {\n            task.cancel();\n        }\n    },\n\n    // private\n    blur: function() {\n        var focusEl;\n        if (this.rendered && (focusEl = this.getFocusEl())) {\n            focusEl.blur();\n        }\n        return this;\n    },\n\n    getEl: function() {\n        return this.el;\n    },\n\n    // Deprecate 5.0\n    getResizeEl: function() {\n        return this.el;\n    },\n\n    // Deprecate 5.0\n    getPositionEl: function() {\n        return this.el;\n    },\n\n    // Deprecate 5.0\n    getActionEl: function() {\n        return this.el;\n    },\n\n    // Deprecate 5.0\n    getVisibilityEl: function() {\n        return this.el;\n    },\n\n    // Deprecate 5.0\n    onResize: Ext.emptyFn,\n\n    // private\n    // Implements an upward event bubbilng policy. By default a Component bubbles events up to its ownerCt\n    // Floating Components target the floatParent.\n    // Some Component subclasses (such as Menu) might implement a different ownership hierarchy.\n    // The up() method uses this to find the immediate owner.\n    getBubbleTarget: function() {\n        return this.ownerCt || this.floatParent;\n    },\n\n    // private\n    getContentTarget: function() {\n        return this.el;\n    },\n\n    /**\n     * Clone the current component using the original config values passed into this instance by default.\n     * @param {Object} overrides A new config containing any properties to override in the cloned version.\n     * An id property can be passed on this object, otherwise one will be generated to avoid duplicates.\n     * @return {Ext.Component} clone The cloned copy of this component\n     */\n    cloneConfig: function(overrides) {\n        overrides = overrides || {};\n        var id = overrides.id || Ext.id(),\n            cfg = Ext.applyIf(overrides, this.initialConfig),\n            self;\n\n        cfg.id = id;\n\n        self = Ext.getClass(this);\n\n        // prevent dup id\n        return new self(cfg);\n    },\n\n    /**\n     * Gets the xtype for this component as registered with {@link Ext.ComponentManager}. For a list of all available\n     * xtypes, see the {@link Ext.Component} header. Example usage:\n     *\n     *     var t = new Ext.form.field.Text();\n     *     alert(t.getXType());  // alerts 'textfield'\n     *\n     * @return {String} The xtype\n     */\n    getXType: function() {\n        return this.self.xtype;\n    },\n\n    /**\n     * Find a container above this component at any level by a custom function. If the passed function returns true, the\n     * container will be returned.\n     *\n     * See also the {@link Ext.Component#up up} method.\n     *\n     * @param {Function} fn The custom function to call with the arguments (container, this component).\n     * @return {Ext.container.Container} The first Container for which the custom function returns true\n     */\n    findParentBy: function(fn) {\n        var p;\n\n        // Iterate up the ownerCt chain until there's no ownerCt, or we find an ancestor which matches using the selector function.\n        for (p = this.getBubbleTarget(); p && !fn(p, this); p = p.getBubbleTarget()) {\n            // do nothing\n        }\n        return p || null;\n    },\n\n    /**\n     * Find a container above this component at any level by xtype or class\n     *\n     * See also the {@link Ext.Component#up up} method.\n     *\n     * @param {String/Ext.Class} xtype The xtype string for a component, or the class of the component directly\n     * @return {Ext.container.Container} The first Container which matches the given xtype or class\n     */\n    findParentByType: function(xtype) {\n        return Ext.isFunction(xtype) ?\n            this.findParentBy(function(p) {\n                return p.constructor === xtype;\n            })\n        :\n            this.up(xtype);\n    },\n\n    /**\n     * Bubbles up the component/container heirarchy, calling the specified function with each component. The scope\n     * (*this*) of function call will be the scope provided or the current component. The arguments to the function will\n     * be the args provided or the current component. If the function returns false at any point, the bubble is stopped.\n     *\n     * @param {Function} fn The function to call\n     * @param {Object} [scope] The scope of the function. Defaults to current node.\n     * @param {Array} [args] The args to call the function with. Defaults to passing the current component.\n     * @return {Ext.Component} this\n     */\n    bubble: function(fn, scope, args) {\n        var p = this;\n        while (p) {\n            if (fn.apply(scope || p, args || [p]) === false) {\n                break;\n            }\n            p = p.getBubbleTarget();\n        }\n        return this;\n    },\n\n    getProxy: function() {\n        var me = this,\n            target;\n\n        if (!me.proxy) {\n            target = Ext.getBody();\n            if (Ext.scopeResetCSS) {\n                me.proxyWrap = target = Ext.getBody().createChild({\n                    cls: Ext.resetCls\n                });\n            }\n            me.proxy = me.el.createProxy(Ext.baseCSSPrefix + 'proxy-el', target, true);\n        }\n        return me.proxy;\n    }\n});\n\n/**\n * A class used to load remote content to an Element. Sample usage:\n *\n *     Ext.get('el').load({\n *         url: 'myPage.php',\n *         scripts: true,\n *         params: {\n *             id: 1\n *         }\n *     });\n *\n * In general this class will not be instanced directly, rather the {@link Ext.Element#method-load} method\n * will be used.\n */\nExt.define('Ext.ElementLoader', {\n\n    /* Begin Definitions */\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    uses: [\n        'Ext.data.Connection',\n        'Ext.Ajax'\n    ],\n\n    statics: {\n        Renderer: {\n            Html: function(loader, response, active){\n                loader.getTarget().update(response.responseText, active.scripts === true);\n                return true;\n            }\n        }\n    },\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String} url (required)\n     * The url to retrieve the content from.\n     */\n    url: null,\n\n    /**\n     * @cfg {Object} params\n     * Any params to be attached to the Ajax request. These parameters will\n     * be overridden by any params in the load options.\n     */\n    params: null,\n\n    /**\n     * @cfg {Object} baseParams Params that will be attached to every request. These parameters\n     * will not be overridden by any params in the load options.\n     */\n    baseParams: null,\n\n    /**\n     * @cfg {Boolean/Object} autoLoad\n     * True to have the loader make a request as soon as it is created.\n     * This argument can also be a set of options that will be passed to {@link #method-load} is called.\n     */\n    autoLoad: false,\n\n    /**\n     * @cfg {HTMLElement/Ext.Element/String} target\n     * The target element for the loader. It can be the DOM element, the id or an {@link Ext.Element}.\n     */\n    target: null,\n\n    /**\n     * @cfg {Boolean/String} loadMask\n     * True or a string to show when the element is loading.\n     */\n    loadMask: false,\n\n    /**\n     * @cfg {Object} ajaxOptions\n     * Any additional options to be passed to the request, for example timeout or headers.\n     */\n    ajaxOptions: null,\n\n    /**\n     * @cfg {Boolean} scripts\n     * True to parse any inline script tags in the response.\n     */\n    scripts: false,\n\n    /**\n     * @cfg {Function} success\n     * A function to be called when a load request is successful.\n     * Will be called with the following config parameters:\n     *\n     * - this - The ElementLoader instance.\n     * - response - The response object.\n     * - options - Ajax options.\n     */\n\n    /**\n     * @cfg {Function} failure A function to be called when a load request fails.\n     * Will be called with the following config parameters:\n     *\n     * - this - The ElementLoader instance.\n     * - response - The response object.\n     * - options - Ajax options.\n     */\n\n    /**\n     * @cfg {Function} callback A function to be called when a load request finishes.\n     * Will be called with the following config parameters:\n     *\n     * - this - The ElementLoader instance.\n     * - success - True if successful request.\n     * - response - The response object.\n     * - options - Ajax options.\n     */\n\n    /**\n     * @cfg {Object} scope\n     * The scope to execute the {@link #success} and {@link #failure} functions in.\n     */\n\n    /**\n     * @cfg {Function} renderer\n     * A custom function to render the content to the element. The function should\n     * return false if the renderer could not be applied. The passed parameters are:\n     *\n     * - The loader\n     * - The response\n     * - The active request\n     */\n\n    /**\n     * @property {Boolean} isLoader\n     * `true` in this class to identify an object as an instantiated ElementLoader, or subclass thereof.\n     */\n    isLoader: true,\n\n    constructor: function(config) {\n        var me = this,\n            autoLoad;\n\n        config = config || {};\n        Ext.apply(me, config);\n        me.setTarget(me.target);\n        me.addEvents(\n            /**\n             * @event beforeload\n             * Fires before a load request is made to the server.\n             * Returning false from an event listener can prevent the load\n             * from occurring.\n             * @param {Ext.ElementLoader} this\n             * @param {Object} options The options passed to the request\n             */\n            'beforeload',\n\n            /**\n             * @event exception\n             * Fires after an unsuccessful load.\n             * @param {Ext.ElementLoader} this\n             * @param {Object} response The response from the server\n             * @param {Object} options The options passed to the request\n             */\n            'exception',\n\n            /**\n             * @event load\n             * Fires after a successful load.\n             * @param {Ext.ElementLoader} this\n             * @param {Object} response The response from the server\n             * @param {Object} options The options passed to the request\n             */\n            'load'\n        );\n\n        // don't pass config because we have already applied it.\n        me.mixins.observable.constructor.call(me);\n\n        if (me.autoLoad) {\n            autoLoad = me.autoLoad;\n            if (autoLoad === true) {\n                autoLoad = {};\n            }\n            me.load(autoLoad);\n        }\n    },\n\n    /**\n     * Sets an {@link Ext.Element} as the target of this loader.\n     * Note that if the target is changed, any active requests will be aborted.\n     * @param {String/HTMLElement/Ext.Element} target The element or its ID.\n     */\n    setTarget: function(target){\n        var me = this;\n        target = Ext.get(target);\n        if (me.target && me.target != target) {\n            me.abort();\n        }\n        me.target = target;\n    },\n\n    /**\n     * Returns the target of this loader.\n     * @return {Ext.Component} The target or null if none exists.\n     */\n    getTarget: function(){\n        return this.target || null;\n    },\n\n    /**\n     * Aborts the active load request\n     */\n    abort: function(){\n        var active = this.active;\n        if (active !== undefined) {\n            Ext.Ajax.abort(active.request);\n            if (active.mask) {\n                this.removeMask();\n            }\n            delete this.active;\n        }\n    },\n\n    /**\n     * Removes the mask on the target\n     * @private\n     */\n    removeMask: function(){\n        this.target.unmask();\n    },\n\n    /**\n     * Adds the mask on the target\n     * @private\n     * @param {Boolean/Object} mask The mask configuration\n     */\n    addMask: function(mask){\n        this.target.mask(mask === true ? null : mask);\n    },\n\n    /**\n     * Loads new data from the server.\n     * @param {Object} options The options for the request. They can be any configuration option that can be specified for\n     * the class, with the exception of the target option. Note that any options passed to the method will override any\n     * class defaults.\n     */\n    load: function(options) {\n        if (!this.target) {\n            Ext.Error.raise('A valid target is required when loading content');\n        }\n\n        options = Ext.apply({}, options);\n\n        var me = this,\n            target = me.target,\n            mask = Ext.isDefined(options.loadMask) ? options.loadMask : me.loadMask,\n            params = Ext.apply({}, options.params),\n            ajaxOptions = Ext.apply({}, options.ajaxOptions),\n            callback = options.callback || me.callback,\n            scope = options.scope || me.scope || me,\n            request;\n\n        Ext.applyIf(ajaxOptions, me.ajaxOptions);\n        Ext.applyIf(options, ajaxOptions);\n\n        Ext.applyIf(params, me.params);\n        Ext.apply(params, me.baseParams);\n\n        Ext.applyIf(options, {\n            url: me.url\n        });\n\n        if (!options.url) {\n            Ext.Error.raise('You must specify the URL from which content should be loaded');\n        }\n\n        Ext.apply(options, {\n            scope: me,\n            params: params,\n            callback: me.onComplete\n        });\n\n        if (me.fireEvent('beforeload', me, options) === false) {\n            return;\n        }\n\n        if (mask) {\n            me.addMask(mask);\n        }\n\n        request = Ext.Ajax.request(options);\n        me.active = {\n            request: request,\n            options: options,\n            mask: mask,\n            scope: scope,\n            callback: callback,\n            success: options.success || me.success,\n            failure: options.failure || me.failure,\n            renderer: options.renderer || me.renderer,\n            scripts: Ext.isDefined(options.scripts) ? options.scripts : me.scripts\n        };\n        me.setOptions(me.active, options);\n    },\n\n    /**\n     * Sets any additional options on the active request\n     * @private\n     * @param {Object} active The active request\n     * @param {Object} options The initial options\n     */\n    setOptions: Ext.emptyFn,\n\n    /**\n     * Parses the response after the request completes\n     * @private\n     * @param {Object} options Ajax options\n     * @param {Boolean} success Success status of the request\n     * @param {Object} response The response object\n     */\n    onComplete: function(options, success, response) {\n        var me = this,\n            active = me.active,\n            scope = active.scope,\n            renderer = me.getRenderer(active.renderer);\n\n\n        if (success) {\n            success = renderer.call(me, me, response, active) !== false;\n        }\n\n        if (success) {\n            Ext.callback(active.success, scope, [me, response, options]);\n            me.fireEvent('load', me, response, options);\n        } else {\n            Ext.callback(active.failure, scope, [me, response, options]);\n            me.fireEvent('exception', me, response, options);\n        }\n        Ext.callback(active.callback, scope, [me, success, response, options]);\n\n        if (active.mask) {\n            me.removeMask();\n        }\n\n        delete me.active;\n    },\n\n    /**\n     * Gets the renderer to use\n     * @private\n     * @param {String/Function} renderer The renderer to use\n     * @return {Function} A rendering function to use.\n     */\n    getRenderer: function(renderer){\n        if (Ext.isFunction(renderer)) {\n            return renderer;\n        }\n        return this.statics().Renderer.Html;\n    },\n\n    /**\n     * Automatically refreshes the content over a specified period.\n     * @param {Number} interval The interval to refresh in ms.\n     * @param {Object} options (optional) The options to pass to the load method. See {@link #method-load}\n     */\n    startAutoRefresh: function(interval, options){\n        var me = this;\n        me.stopAutoRefresh();\n        me.autoRefresh = setInterval(function(){\n            me.load(options);\n        }, interval);\n    },\n\n    /**\n     * Clears any auto refresh. See {@link #startAutoRefresh}.\n     */\n    stopAutoRefresh: function(){\n        clearInterval(this.autoRefresh);\n        delete this.autoRefresh;\n    },\n\n    /**\n     * Checks whether the loader is automatically refreshing. See {@link #startAutoRefresh}.\n     * @return {Boolean} True if the loader is automatically refreshing\n     */\n    isAutoRefreshing: function(){\n        return Ext.isDefined(this.autoRefresh);\n    },\n\n    /**\n     * Destroys the loader. Any active requests will be aborted.\n     */\n    destroy: function(){\n        var me = this;\n        me.stopAutoRefresh();\n        delete me.target;\n        me.abort();\n        me.clearListeners();\n    }\n});\n\n/**\n * This class is used to load content via Ajax into a {@link Ext.Component}. In general \n * this class will not be instanced directly, rather a loader configuration will be passed to the\n * constructor of the {@link Ext.Component}.\n *\n * ## HTML Renderer\n *\n * By default, the content loaded will be processed as raw html. The response text\n * from the request is taken and added to the component. This can be used in\n * conjunction with the {@link #scripts} option to execute any inline scripts in\n * the resulting content. Using this renderer has the same effect as passing the\n * {@link Ext.Component#html} configuration option.\n *\n * ## Data Renderer\n *\n * This renderer allows content to be added by using JSON data and a {@link Ext.XTemplate}.\n * The content received from the response is passed to the {@link Ext.Component#update} method.\n * This content is run through the attached {@link Ext.Component#tpl} and the data is added to\n * the Component. Using this renderer has the same effect as using the {@link Ext.Component#data}\n * configuration in conjunction with a {@link Ext.Component#tpl}.\n *\n * ## Component Renderer\n *\n * This renderer can only be used with a {@link Ext.container.Container} and subclasses. It allows for\n * Components to be loaded remotely into a Container. The response is expected to be a single/series of\n * {@link Ext.Component} configuration objects. When the response is received, the data is decoded\n * and then passed to {@link Ext.container.Container#method-add}. Using this renderer has the same effect as specifying\n * the {@link Ext.container.Container#cfg-items} configuration on a Container.\n *\n * ## Custom Renderer\n *\n * A custom function can be passed to handle any other special case, see the {@link #renderer} option.\n *\n * ## Example Usage\n *\n *     var cmp = Ext.create('Ext.Component', {\n *         renderTo: Ext.getBody(),\n *         tpl: '{firstName} - {lastName}',\n *         loader: {\n *             url: 'myPage.php',\n *             renderer: 'data',\n *             params: {\n *                 userId: 1\n *             }\n *         }\n *     });\n *\n *     // call the loader manually (or use autoLoad:true instead)\n *     cmp.getLoader().load();\n */\nExt.define('Ext.ComponentLoader', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.ElementLoader',\n\n    statics: {\n        Renderer: {\n            Data: function(loader, response, active){\n                var success = true;\n                try {\n                    loader.getTarget().update(Ext.decode(response.responseText));\n                } catch (e) {\n                    success = false;\n                }\n                return success;\n            },\n\n            Component: function(loader, response, active){\n                var success = true,\n                    target = loader.getTarget(),\n                    items = [];\n\n                if (!target.isContainer) {\n                    Ext.Error.raise({\n                        target: target,\n                        msg: 'Components can only be loaded into a container'\n                    });\n                }\n\n                try {\n                    items = Ext.decode(response.responseText);\n                } catch (e) {\n                    success = false;\n                }\n\n                if (success) {\n                    target.suspendLayouts();\n                    if (active.removeAll) {\n                        target.removeAll();\n                    }\n                    target.add(items);\n                    target.resumeLayouts(true);\n                }\n                return success;\n            }\n        }\n    },\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Ext.Component/String} target The target {@link Ext.Component} for the loader.\n     * If a string is passed it will be looked up via the id.\n     */\n    target: null,\n\n    /**\n     * @cfg {Boolean/Object} loadMask True or a {@link Ext.LoadMask} configuration to enable masking during loading.\n     */\n    loadMask: false,\n\n    /**\n     * @cfg {Boolean} scripts True to parse any inline script tags in the response. This only used when using the html\n     * {@link #renderer}.\n     */\n\n    /**\n     * @cfg {String/Function} renderer\n\nThe type of content that is to be loaded into, which can be one of 3 types:\n\n+ **html** : Loads raw html content, see {@link Ext.Component#html}\n+ **data** : Loads raw html content, see {@link Ext.Component#data}\n+ **component** : Loads child {Ext.Component} instances. This option is only valid when used with a Container.\n\nAlternatively, you can pass a function which is called with the following parameters.\n\n+ loader - Loader instance\n+ response - The server response\n+ active - The active request\n\nThe function must return false is loading is not successful. Below is a sample of using a custom renderer:\n\n    new Ext.Component({\n        loader: {\n            url: 'myPage.php',\n            renderer: function(loader, response, active) {\n                var text = response.responseText;\n                loader.getTarget().update('The response is ' + text);\n                return true;\n            }\n        }\n    });\n     */\n    renderer: 'html',\n\n    /**\n     * Set a {Ext.Component} as the target of this loader. Note that if the target is changed,\n     * any active requests will be aborted.\n     * @param {String/Ext.Component} target The component to be the target of this loader. If a string is passed\n     * it will be looked up via its id.\n     */\n    setTarget: function(target){\n        var me = this;\n\n        if (Ext.isString(target)) {\n            target = Ext.getCmp(target);\n        }\n\n        if (me.target && me.target != target) {\n            me.abort();\n        }\n        me.target = target;\n    },\n\n    // inherit docs\n    removeMask: function(){\n        this.target.setLoading(false);\n    },\n\n    /**\n     * Add the mask on the target\n     * @private\n     * @param {Boolean/Object} mask The mask configuration\n     */\n    addMask: function(mask){\n        this.target.setLoading(mask);\n    },\n\n\n    setOptions: function(active, options){\n        active.removeAll = Ext.isDefined(options.removeAll) ? options.removeAll : this.removeAll;\n    },\n\n    /**\n     * Gets the renderer to use\n     * @private\n     * @param {String/Function} renderer The renderer to use\n     * @return {Function} A rendering function to use.\n     */\n    getRenderer: function(renderer){\n        if (Ext.isFunction(renderer)) {\n            return renderer;\n        }\n\n        var renderers = this.statics().Renderer;\n        switch (renderer) {\n            case 'component':\n                return renderers.Component;\n            case 'data':\n                return renderers.Data;\n            default:\n                return Ext.ElementLoader.Renderer.Html;\n        }\n    }\n});\n\n/**\n * Represents an HTML fragment template. Templates may be {@link #compile precompiled} for greater performance.\n *\n * An instance of this class may be created by passing to the constructor either a single argument, or multiple\n * arguments:\n *\n * # Single argument: String/Array\n *\n * The single argument may be either a String or an Array:\n *\n * - String:\n *\n *       var t = new Ext.Template(\"<div>Hello {0}.</div>\");\n *       t.{@link #append}('some-element', ['foo']);\n *\n * - Array:\n *\n *   An Array will be combined with `join('')`.\n *\n *       var t = new Ext.Template([\n *           '<div name=\"{id}\">',\n *               '<span class=\"{cls}\">{name:trim} {value:ellipsis(10)}</span>',\n *           '</div>',\n *       ]);\n *       t.{@link #compile}();\n *       t.{@link #append}('some-element', {id: 'myid', cls: 'myclass', name: 'foo', value: 'bar'});\n *\n * # Multiple arguments: String, Object, Array, ...\n *\n * Multiple arguments will be combined with `join('')`.\n *\n *     var t = new Ext.Template(\n *         '<div name=\"{id}\">',\n *             '<span class=\"{cls}\">{name} {value}</span>',\n *         '</div>',\n *         // a configuration object:\n *         {\n *             compiled: true,      // {@link #compile} immediately\n *         }\n *     );\n *\n * # Notes\n *\n * - For a list of available format functions, see {@link Ext.util.Format}.\n * - `disableFormats` reduces `{@link #apply}` time when no formatting is required.\n */\nExt.define('Ext.Template', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.dom.Helper', 'Ext.util.Format'],\n\n    inheritableStatics: {\n        /**\n         * Creates a template from the passed element's value (_display:none_ textarea, preferred) or innerHTML.\n         * @param {String/HTMLElement} el A DOM element or its id\n         * @param {Object} config (optional) Config object\n         * @return {Ext.Template} The created template\n         * @static\n         * @inheritable\n         */\n        from: function(el, config) {\n            el = Ext.getDom(el);\n            return new this(el.value || el.innerHTML, config || '');\n        }\n    },\n\n    /* End Definitions */\n\n    /**\n     * Creates new template.\n     * \n     * @param {String...} html List of strings to be concatenated into template.\n     * Alternatively an array of strings can be given, but then no config object may be passed.\n     * @param {Object} config (optional) Config object\n     */\n    constructor: function(html) {\n        var me = this,\n            args = arguments,\n            buffer = [],\n            i = 0,\n            length = args.length,\n            value;\n\n        me.initialConfig = {};\n        \n        // Allow an array to be passed here so we can\n        // pass an array of strings and an object\n        // at the end\n        if (length === 1 && Ext.isArray(html)) {\n            args = html;\n            length = args.length;\n        }\n\n        if (length > 1) {\n            for (; i < length; i++) {\n                value = args[i];\n                if (typeof value == 'object') {\n                    Ext.apply(me.initialConfig, value);\n                    Ext.apply(me, value);\n                } else {\n                    buffer.push(value);\n                }\n            }\n        } else {\n            buffer.push(html);\n        }\n\n        // @private\n        me.html = buffer.join('');\n\n        if (me.compiled) {\n            me.compile();\n        }\n    },\n\n    /**\n     * @property {Boolean} isTemplate\n     * `true` in this class to identify an object as an instantiated Template, or subclass thereof.\n     */\n    isTemplate: true,\n\n    /**\n     * @cfg {Boolean} compiled\n     * True to immediately compile the template. Defaults to false.\n     */\n\n    /**\n     * @cfg {Boolean} disableFormats\n     * True to disable format functions in the template. If the template doesn't contain\n     * format functions, setting disableFormats to true will reduce apply time. Defaults to false.\n     */\n    disableFormats: false,\n\n    re: /\\{([\\w\\-]+)(?:\\:([\\w\\.]*)(?:\\((.*?)?\\))?)?\\}/g,\n\n    /**\n     * Returns an HTML fragment of this template with the specified values applied.\n     *\n     * @param {Object/Array} values The template values. Can be an array if your params are numeric:\n     *\n     *     var tpl = new Ext.Template('Name: {0}, Age: {1}');\n     *     tpl.apply(['John', 25]);\n     *\n     * or an object:\n     *\n     *     var tpl = new Ext.Template('Name: {name}, Age: {age}');\n     *     tpl.apply({name: 'John', age: 25});\n     *\n     * @return {String} The HTML fragment\n     */\n    apply: function(values) {\n        var me = this,\n            useFormat = me.disableFormats !== true,\n            fm = Ext.util.Format,\n            tpl = me,\n            ret;\n\n        if (me.compiled) {\n            return me.compiled(values).join('');\n        }\n\n        function fn(m, name, format, args) {\n            if (format && useFormat) {\n                if (args) {\n                    args = [values[name]].concat(Ext.functionFactory('return ['+ args +'];')());\n                } else {\n                    args = [values[name]];\n                }\n                if (format.substr(0, 5) == \"this.\") {\n                    return tpl[format.substr(5)].apply(tpl, args);\n                }\n                else {\n                    return fm[format].apply(fm, args);\n                }\n            }\n            else {\n                return values[name] !== undefined ? values[name] : \"\";\n            }\n        }\n\n        ret = me.html.replace(me.re, fn);\n        return ret;\n    },\n\n    /**\n     * Appends the result of this template to the provided output array.\n     * @param {Object/Array} values The template values. See {@link #apply}.\n     * @param {Array} out The array to which output is pushed.\n     * @return {Array} The given out array.\n     */\n    applyOut: function(values, out) {\n        var me = this;\n\n        if (me.compiled) {\n            out.push.apply(out, me.compiled(values));\n        } else {\n            out.push(me.apply(values));\n        }\n\n        return out;\n    },\n\n    /**\n     * @method applyTemplate\n     * @member Ext.Template\n     * Alias for {@link #apply}.\n     * @inheritdoc Ext.Template#apply\n     */\n    applyTemplate: function () {\n        return this.apply.apply(this, arguments);\n    },\n\n    /**\n     * Sets the HTML used as the template and optionally compiles it.\n     * @param {String} html\n     * @param {Boolean} compile (optional) True to compile the template.\n     * @return {Ext.Template} this\n     */\n    set: function(html, compile) {\n        var me = this;\n        me.html = html;\n        me.compiled = null;\n        return compile ? me.compile() : me;\n    },\n\n    compileARe: /\\\\/g,\n    compileBRe: /(\\r\\n|\\n)/g,\n    compileCRe: /'/g,\n\n    /**\n     * Compiles the template into an internal function, eliminating the RegEx overhead.\n     * @return {Ext.Template} this\n     */\n    compile: function() {\n        var me = this,\n            fm = Ext.util.Format,\n            useFormat = me.disableFormats !== true,\n            body, bodyReturn;\n\n        function fn(m, name, format, args) {\n            if (format && useFormat) {\n                args = args ? ',' + args: \"\";\n                if (format.substr(0, 5) != \"this.\") {\n                    format = \"fm.\" + format + '(';\n                }\n                else {\n                    format = 'this.' + format.substr(5) + '(';\n                }\n            }\n            else {\n                args = '';\n                format = \"(values['\" + name + \"'] == undefined ? '' : \";\n            }\n            return \"',\" + format + \"values['\" + name + \"']\" + args + \") ,'\";\n        }\n\n        bodyReturn = me.html.replace(me.compileARe, '\\\\\\\\').replace(me.compileBRe, '\\\\n').replace(me.compileCRe, \"\\\\'\").replace(me.re, fn);\n        body = \"this.compiled = function(values){ return ['\" + bodyReturn + \"'];};\";\n        eval(body);\n        return me;\n    },\n\n    /**\n     * Applies the supplied values to the template and inserts the new node(s) as the first child of el.\n     *\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.\n     * @param {Boolean} returnElement (optional) true to return a Ext.Element.\n     * @return {HTMLElement/Ext.Element} The new node or Element\n     */\n    insertFirst: function(el, values, returnElement) {\n        return this.doInsert('afterBegin', el, values, returnElement);\n    },\n\n    /**\n     * Applies the supplied values to the template and inserts the new node(s) before el.\n     *\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.\n     * @param {Boolean} returnElement (optional) true to return a Ext.Element.\n     * @return {HTMLElement/Ext.Element} The new node or Element\n     */\n    insertBefore: function(el, values, returnElement) {\n        return this.doInsert('beforeBegin', el, values, returnElement);\n    },\n\n    /**\n     * Applies the supplied values to the template and inserts the new node(s) after el.\n     *\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.\n     * @param {Boolean} returnElement (optional) true to return a Ext.Element.\n     * @return {HTMLElement/Ext.Element} The new node or Element\n     */\n    insertAfter: function(el, values, returnElement) {\n        return this.doInsert('afterEnd', el, values, returnElement);\n    },\n\n    /**\n     * Applies the supplied `values` to the template and appends the new node(s) to the specified `el`.\n     *\n     * For example usage see {@link Ext.Template Ext.Template class docs}.\n     *\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.\n     * @param {Boolean} returnElement (optional) true to return an Ext.Element.\n     * @return {HTMLElement/Ext.Element} The new node or Element\n     */\n    append: function(el, values, returnElement) {\n        return this.doInsert('beforeEnd', el, values, returnElement);\n    },\n\n    doInsert: function(where, el, values, returnElement) {\n        var newNode = Ext.DomHelper.insertHtml(where, Ext.getDom(el), this.apply(values));\n        return returnElement ? Ext.get(newNode) : newNode;\n    },\n\n    /**\n     * Applies the supplied values to the template and overwrites the content of el with the new node(s).\n     *\n     * @param {String/HTMLElement/Ext.Element} el The context element\n     * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.\n     * @param {Boolean} returnElement (optional) true to return a Ext.Element.\n     * @return {HTMLElement/Ext.Element} The new node or Element\n     */\n    overwrite: function(el, values, returnElement) {\n        var newNode = Ext.DomHelper.overwrite(Ext.getDom(el), this.apply(values));\n        return returnElement ? Ext.get(newNode) : newNode;\n    }\n});\n\n/**\n * This class parses the XTemplate syntax and calls abstract methods to process the parts.\n * @private\n */\nExt.define('Ext.XTemplateParser', {\n    constructor: function (config) {\n        Ext.apply(this, config);\n    },\n\n    /**\n     * @property {Number} level The 'for' loop context level. This is adjusted up by one\n     * prior to calling {@link #doFor} and down by one after calling the corresponding\n     * {@link #doEnd} that closes the loop. This will be 1 on the first {@link #doFor}\n     * call.\n     */\n\n    /**\n     * This method is called to process a piece of raw text from the tpl.\n     * @param {String} text\n     * @method doText\n     */\n    // doText: function (text)\n\n    /**\n     * This method is called to process expressions (like `{[expr]}`).\n     * @param {String} expr The body of the expression (inside \"{[\" and \"]}\").\n     * @method doExpr\n     */\n    // doExpr: function (expr)\n\n    /**\n     * This method is called to process simple tags (like `{tag}`).\n     * @method doTag\n     */\n    // doTag: function (tag)\n\n    /**\n     * This method is called to process `<tpl else>`.\n     * @method doElse\n     */\n    // doElse: function ()\n\n    /**\n     * This method is called to process `{% text %}`.\n     * @param {String} text\n     * @method doEval\n     */\n    // doEval: function (text)\n\n    /**\n     * This method is called to process `<tpl if=\"action\">`. If there are other attributes,\n     * these are passed in the actions object.\n     * @param {String} action\n     * @param {Object} actions Other actions keyed by the attribute name (such as 'exec').\n     * @method doIf\n     */\n    // doIf: function (action, actions)\n\n    /**\n     * This method is called to process `<tpl elseif=\"action\">`. If there are other attributes,\n     * these are passed in the actions object.\n     * @param {String} action\n     * @param {Object} actions Other actions keyed by the attribute name (such as 'exec').\n     * @method doElseIf\n     */\n    // doElseIf: function (action, actions)\n\n    /**\n     * This method is called to process `<tpl switch=\"action\">`. If there are other attributes,\n     * these are passed in the actions object.\n     * @param {String} action\n     * @param {Object} actions Other actions keyed by the attribute name (such as 'exec').\n     * @method doSwitch\n     */\n    // doSwitch: function (action, actions)\n\n    /**\n     * This method is called to process `<tpl case=\"action\">`. If there are other attributes,\n     * these are passed in the actions object.\n     * @param {String} action\n     * @param {Object} actions Other actions keyed by the attribute name (such as 'exec').\n     * @method doCase\n     */\n    // doCase: function (action, actions)\n\n    /**\n     * This method is called to process `<tpl default>`.\n     * @method doDefault\n     */\n    // doDefault: function ()\n\n    /**\n     * This method is called to process `</tpl>`. It is given the action type that started\n     * the tpl and the set of additional actions.\n     * @param {String} type The type of action that is being ended.\n     * @param {Object} actions The other actions keyed by the attribute name (such as 'exec').\n     * @method doEnd\n     */\n    // doEnd: function (type, actions) \n\n    /**\n     * This method is called to process `<tpl for=\"action\">`. If there are other attributes,\n     * these are passed in the actions object.\n     * @param {String} action\n     * @param {Object} actions Other actions keyed by the attribute name (such as 'exec').\n     * @method doFor\n     */\n    // doFor: function (action, actions)\n\n    /**\n     * This method is called to process `<tpl exec=\"action\">`. If there are other attributes,\n     * these are passed in the actions object.\n     * @param {String} action\n     * @param {Object} actions Other actions keyed by the attribute name.\n     * @method doExec\n     */\n    // doExec: function (action, actions)\n\n    /**\n     * This method is called to process an empty `<tpl>`. This is unlikely to need to be\n     * implemented, so a default (do nothing) version is provided.\n     * @method\n     */\n    doTpl: Ext.emptyFn,\n\n    parse: function (str) {\n        var me = this,\n            len = str.length,\n            aliases = { elseif: 'elif' },\n            topRe = me.topRe,\n            actionsRe = me.actionsRe,\n            index, stack, s, m, t, prev, frame, subMatch, begin, end, actions,\n            prop;\n\n        me.level = 0;\n        me.stack = stack = [];\n\n        for (index = 0; index < len; index = end) {\n            topRe.lastIndex = index;\n            m = topRe.exec(str);\n\n            if (!m) {\n                me.doText(str.substring(index, len));\n                break;\n            }\n\n            begin = m.index;\n            end = topRe.lastIndex;\n\n            if (index < begin) {\n                me.doText(str.substring(index, begin));\n            }\n\n            if (m[1]) {\n                end = str.indexOf('%}', begin+2);\n                me.doEval(str.substring(begin+2, end));\n                end += 2;\n            } else if (m[2]) {\n                end = str.indexOf(']}', begin+2);\n                me.doExpr(str.substring(begin+2, end));\n                end += 2;\n            } else if (m[3]) { // if ('{' token)\n                me.doTag(m[3]);\n            } else if (m[4]) { // content of a <tpl xxxxxx xxx> tag\n                actions = null;\n                while ((subMatch = actionsRe.exec(m[4])) !== null) {\n                    s = subMatch[2] || subMatch[3];\n                    if (s) {\n                        s = Ext.String.htmlDecode(s); // decode attr value\n                        t = subMatch[1];\n                        t = aliases[t] || t;\n                        actions = actions || {};\n                        prev = actions[t];\n\n                        if (typeof prev == 'string') {\n                            actions[t] = [prev, s];\n                        } else if (prev) {\n                            actions[t].push(s);\n                        } else {\n                            actions[t] = s;\n                        }\n                    }\n                }\n\n                if (!actions) {\n                    if (me.elseRe.test(m[4])) {\n                        me.doElse();\n                    } else if (me.defaultRe.test(m[4])) {\n                        me.doDefault();\n                    } else {\n                        me.doTpl();\n                        stack.push({ type: 'tpl' });\n                    }\n                }\n                else if (actions['if']) {\n                    me.doIf(actions['if'], actions);\n                    stack.push({ type: 'if' });\n                }\n                else if (actions['switch']) {\n                    me.doSwitch(actions['switch'], actions);\n                    stack.push({ type: 'switch' });\n                }\n                else if (actions['case']) {\n                    me.doCase(actions['case'], actions);\n                }\n                else if (actions['elif']) {\n                    me.doElseIf(actions['elif'], actions);\n                }\n                else if (actions['for']) {\n                    ++me.level;\n\n                    // Extract property name to use from indexed item\n                    if (prop = me.propRe.exec(m[4])) {\n                        actions.propName = prop[1] || prop[2];\n                    }\n                    me.doFor(actions['for'], actions);\n                    stack.push({ type: 'for', actions: actions });\n                }\n                else if (actions.exec) {\n                    me.doExec(actions.exec, actions);\n                    stack.push({ type: 'exec', actions: actions });\n                }\n                /*\n                else {\n                    // todo - error\n                }\n                */\n            } else if (m[0].length === 5) {\n                // if the length of m[0] is 5, assume that we're dealing with an opening tpl tag with no attributes (e.g. <tpl>...</tpl>)\n                // in this case no action is needed other than pushing it on to the stack\n                stack.push({ type: 'tpl' });\n            } else {\n                frame = stack.pop();\n                me.doEnd(frame.type, frame.actions);\n                if (frame.type == 'for') {\n                    --me.level;\n                }\n            }\n        }\n    },\n\n    // Internal regexes\n    \n    topRe:     /(?:(\\{\\%)|(\\{\\[)|\\{([^{}]*)\\})|(?:<tpl([^>]*)\\>)|(?:<\\/tpl>)/g,\n    actionsRe: /\\s*(elif|elseif|if|for|exec|switch|case|eval)\\s*\\=\\s*(?:(?:\"([^\"]*)\")|(?:'([^']*)'))\\s*/g,\n    propRe:    /prop=(?:(?:\"([^\"]*)\")|(?:'([^']*)'))/,\n    defaultRe: /^\\s*default\\s*$/,\n    elseRe:    /^\\s*else\\s*$/\n});\n\n/**\n * This class compiles the XTemplate syntax into a function object. The function is used\n * like so:\n * \n *      function (out, values, parent, xindex, xcount) {\n *          // out is the output array to store results\n *          // values, parent, xindex and xcount have their historical meaning\n *      }\n *\n * @markdown\n * @private\n */\nExt.define('Ext.XTemplateCompiler', {\n    extend: 'Ext.XTemplateParser',\n\n    // Chrome really likes \"new Function\" to realize the code block (as in it is\n    // 2x-3x faster to call it than using eval), but Firefox chokes on it badly.\n    // IE and Opera are also fine with the \"new Function\" technique.\n    useEval: Ext.isGecko,\n\n    // See http://jsperf.com/nige-array-append for quickest way to append to an array of unknown length\n    // (Due to arbitrary code execution inside a template, we cannot easily track the length in  var)\n    // On IE6 and 7 myArray[myArray.length]='foo' is better. On other browsers myArray.push('foo') is better.\n    useIndex: Ext.isIE6 || Ext.isIE7,\n\n    useFormat: true,\n    \n    propNameRe: /^[\\w\\d\\$]*$/,\n\n    compile: function (tpl) {\n        var me = this,\n            code = me.generate(tpl);\n\n        // When using \"new Function\", we have to pass our \"Ext\" variable to it in order to\n        // support sandboxing. If we did not, the generated function would use the global\n        // \"Ext\", not the \"Ext\" from our sandbox (scope chain).\n        //\n        return me.useEval ? me.evalTpl(code) : (new Function('Ext', code))(Ext);\n    },\n\n    generate: function (tpl) {\n        var me = this,\n            // note: Ext here is properly sandboxed\n            definitions = 'var fm=Ext.util.Format,ts=Object.prototype.toString;',\n            code;\n\n        // Track how many levels we use, so that we only \"var\" each level's variables once\n        me.maxLevel = 0;\n\n        me.body = [\n            'var c0=values, a0=' + me.createArrayTest(0) + ', p0=parent, n0=xcount, i0=xindex, v;\\n'\n        ];\n        if (me.definitions) {\n            if (typeof me.definitions === 'string') {\n                me.definitions = [me.definitions, definitions ];\n            } else {\n                me.definitions.push(definitions);\n            }\n        } else {\n            me.definitions = [ definitions ];\n        }\n        me.switches = [];\n\n        me.parse(tpl);\n\n        me.definitions.push(\n            (me.useEval ? '$=' : 'return') + ' function (' + me.fnArgs + ') {',\n                me.body.join(''),\n            '}'\n        );\n\n        code = me.definitions.join('\\n');\n\n        // Free up the arrays.\n        me.definitions.length = me.body.length = me.switches.length = 0;\n        delete me.definitions;\n        delete me.body;\n        delete me.switches;\n\n        return code;\n    },\n\n    //-----------------------------------\n    // XTemplateParser callouts\n\n    doText: function (text) {\n        var me = this,\n            out = me.body;\n\n        text = text.replace(me.aposRe, \"\\\\'\").replace(me.newLineRe, '\\\\n');\n        if (me.useIndex) {\n            out.push('out[out.length]=\\'', text, '\\'\\n');\n        } else {\n            out.push('out.push(\\'', text, '\\')\\n');\n        }\n    },\n\n    doExpr: function (expr) {\n        var out = this.body;\n        out.push('if ((v=' + expr + ')!==undefined) out');\n\n        // Coerce value to string using concatenation of an empty string literal.\n        // See http://jsperf.com/tostringvscoercion/5\n        if (this.useIndex) {\n             out.push('[out.length]=v+\\'\\'\\n');\n        } else {\n             out.push('.push(v+\\'\\')\\n');\n        }\n    },\n\n    doTag: function (tag) {\n        this.doExpr(this.parseTag(tag));\n    },\n\n    doElse: function () {\n        this.body.push('} else {\\n');\n    },\n\n    doEval: function (text) {\n        this.body.push(text, '\\n');\n    },\n\n    doIf: function (action, actions) {\n        var me = this;\n\n        // If it's just a propName, use it directly in the if\n        if (action === '.') {\n            me.body.push('if (values) {\\n');\n        } else if (me.propNameRe.test(action)) {\n            me.body.push('if (', me.parseTag(action), ') {\\n');\n        }\n        // Otherwise, it must be an expression, and needs to be returned from an fn which uses with(values)\n        else {\n            me.body.push('if (', me.addFn(action), me.callFn, ') {\\n');\n        }\n        if (actions.exec) {\n            me.doExec(actions.exec);\n        }\n    },\n\n    doElseIf: function (action, actions) {\n        var me = this;\n\n        // If it's just a propName, use it directly in the else if\n        if (action === '.') {\n            me.body.push('else if (values) {\\n');\n        } else if (me.propNameRe.test(action)) {\n            me.body.push('} else if (', me.parseTag(action), ') {\\n');\n        }\n        // Otherwise, it must be an expression, and needs to be returned from an fn which uses with(values)\n        else {\n            me.body.push('} else if (', me.addFn(action), me.callFn, ') {\\n');\n        }\n        if (actions.exec) {\n            me.doExec(actions.exec);\n        }\n    },\n\n    doSwitch: function (action) {\n        var me = this;\n\n        // If it's just a propName, use it directly in the switch\n        if (action === '.') {\n            me.body.push('switch (values) {\\n');\n        } else if (me.propNameRe.test(action)) {\n            me.body.push('switch (', me.parseTag(action), ') {\\n');\n        }\n        // Otherwise, it must be an expression, and needs to be returned from an fn which uses with(values)\n        else {\n            me.body.push('switch (', me.addFn(action), me.callFn, ') {\\n');\n        }\n        me.switches.push(0);\n    },\n\n    doCase: function (action) {\n        var me = this,\n            cases = Ext.isArray(action) ? action : [action],\n            n = me.switches.length - 1,\n            match, i;\n\n        if (me.switches[n]) {\n            me.body.push('break;\\n');\n        } else {\n            me.switches[n]++;\n        }\n\n        for (i = 0, n = cases.length; i < n; ++i) {\n            match = me.intRe.exec(cases[i]);\n            cases[i] = match ? match[1] : (\"'\" + cases[i].replace(me.aposRe,\"\\\\'\") + \"'\");\n        }\n\n        me.body.push('case ', cases.join(': case '), ':\\n');\n    },\n\n    doDefault: function () {\n        var me = this,\n            n = me.switches.length - 1;\n\n        if (me.switches[n]) {\n            me.body.push('break;\\n');\n        } else {\n            me.switches[n]++;\n        }\n\n        me.body.push('default:\\n');\n    },\n\n    doEnd: function (type, actions) {\n        var me = this,\n            L = me.level-1;\n\n        if (type == 'for') {\n            /*\n            To exit a for loop we must restore the outer loop's context. The code looks\n            like this (which goes with that produced by doFor:\n\n                    for (...) { // the part generated by doFor\n                        ...  // the body of the for loop\n\n                        // ... any tpl for exec statement goes here...\n                    }\n                    parent = p1;\n                    values = r2;\n                    xcount = n1;\n                    xindex = i1\n            */\n            if (actions.exec) {\n                me.doExec(actions.exec);\n            }\n\n            me.body.push('}\\n');\n            me.body.push('parent=p',L,';values=r',L+1,';xcount=n',L,';xindex=i',L,'\\n');\n        } else if (type == 'if' || type == 'switch') {\n            me.body.push('}\\n');\n        }\n    },\n\n    doFor: function (action, actions) {\n        var me = this,\n            s,\n            L = me.level,\n            up = L-1,\n            pL = 'p' + L,\n            parentAssignment;\n\n        // If it's just a propName, use it directly in the switch\n        if (action === '.') {\n            s = 'values';\n        } else if (me.propNameRe.test(action)) {\n            s = me.parseTag(action);\n        }\n        // Otherwise, it must be an expression, and needs to be returned from an fn which uses with(values)\n        else {\n            s = me.addFn(action) + me.callFn;\n        }\n\n        /*\n        We are trying to produce a block of code that looks like below. We use the nesting\n        level to uniquely name the control variables.\n\n            // Omit \"var \" if we have already been through level 2\n            var i2 = 0,\n                n2 = 0,\n                c2 = values['propName'],\n                    // c2 is the context object for the for loop\n                a2 = Array.isArray(c2);\n                p2 = c1,\n                    // p2 is the parent context (of the outer for loop)\n                r2 = values\n                    // r2 is the values object to \n\n            // If iterating over the current data, the parent is always set to c2\n            parent = c2;\n            // If iterating over a property in an object, set the parent to the object\n            parent = a1 ? c1[i1] : p2 // set parent\n            if (c2) {\n                if (a2) {\n                    n2 = c2.length;\n                } else if (c2.isMixedCollection) {\n                    c2 = c2.items;\n                    n2 = c2.length;\n                } else if (c2.isStore) {\n                    c2 = c2.data.items;\n                    n2 = c2.length;\n                } else {\n                    c2 = [ c2 ];\n                    n2 = 1;\n                }\n            }\n            // i2 is the loop index and n2 is the number (xcount) of this for loop\n            for (xcount = n2; i2 < n2; ++i2) {\n                values = c2[i2]           // adjust special vars to inner scope\n                xindex = i2 + 1           // xindex is 1-based\n\n        The body of the loop is whatever comes between the tpl and /tpl statements (which\n        is handled by doEnd).\n        */\n\n        // Declare the vars for a particular level only if we have not already declared them.\n        if (me.maxLevel < L) {\n            me.maxLevel = L;\n            me.body.push('var ');\n        }\n        \n        if (action == '.') {\n            parentAssignment = 'c' + L;\n        } else {\n            parentAssignment = 'a' + up + '?c' + up + '[i' + up + ']:p' + L;\n        }\n        \n        me.body.push('i',L,'=0,n', L, '=0,c',L,'=',s,',a',L,'=', me.createArrayTest(L), ',p',L,'=c',up,',r',L,'=values;\\n',\n            'parent=',parentAssignment,'\\n',\n            'if (c',L,'){if(a',L,'){n', L,'=c', L, '.length;}else if (c', L, '.isMixedCollection){c',L,'=c',L,'.items;n',L,'=c',L,'.length;}else if(c',L,'.isStore){c',L,'=c',L,'.data.items;n',L,'=c',L,'.length;}else{c',L,'=[c',L,'];n',L,'=1;}}\\n',\n            'for (xcount=n',L,';i',L,'<n'+L+';++i',L,'){\\n',\n            'values=c',L,'[i',L,']');\n        if (actions.propName) {\n            me.body.push('.', actions.propName);\n        }\n        me.body.push('\\n',\n            'xindex=i',L,'+1\\n');\n    },\n\n    createArrayTest: ('isArray' in Array) ? function(L) {\n        return 'Array.isArray(c' + L + ')';\n    } : function(L) {\n        return 'ts.call(c' + L + ')===\"[object Array]\"';\n    },\n\n    doExec: function (action, actions) {\n        var me = this,\n            name = 'f' + me.definitions.length;\n\n        me.definitions.push('function ' + name + '(' + me.fnArgs + ') {',\n                            ' try { with(values) {',\n                            '  ' + action,\n                            ' }} catch(e) {',\n                            'Ext.log(\"XTemplate Error: \" + e.message);',\n                            '}',\n                      '}');\n\n        me.body.push(name + me.callFn + '\\n');\n    },\n\n    //-----------------------------------\n    // Internal\n\n    addFn: function (body) {\n        var me = this,\n            name = 'f' + me.definitions.length;\n\n        if (body === '.') {\n            me.definitions.push('function ' + name + '(' + me.fnArgs + ') {',\n                            ' return values',\n                       '}');\n        } else if (body === '..') {\n            me.definitions.push('function ' + name + '(' + me.fnArgs + ') {',\n                            ' return parent',\n                       '}');\n        } else {\n            me.definitions.push('function ' + name + '(' + me.fnArgs + ') {',\n                            ' try { with(values) {',\n                            '  return(' + body + ')',\n                            ' }} catch(e) {',\n                            'Ext.log(\"XTemplate Error: \" + e.message);',\n                            '}',\n                       '}');\n        }\n\n        return name;\n    },\n\n    parseTag: function (tag) {\n        var me = this,\n            m = me.tagRe.exec(tag),\n            name = m[1],\n            format = m[2],\n            args = m[3],\n            math = m[4],\n            v;\n\n        // name = \".\" - Just use the values object.\n        if (name == '.') {\n            // filter to not include arrays/objects/nulls\n            if (!me.validTypes) {\n                me.definitions.push('var validTypes={string:1,number:1,boolean:1};');\n                me.validTypes = true;\n            }\n            v = 'validTypes[typeof values] || ts.call(values) === \"[object Date]\" ? values : \"\"';\n        }\n        // name = \"#\" - Use the xindex\n        else if (name == '#') {\n            v = 'xindex';\n        }\n        else if (name.substr(0, 7) == \"parent.\") {\n            v = name;\n        }\n        // compound Javascript property name (e.g., \"foo.bar\")\n        else if (isNaN(name) && name.indexOf('-') == -1 && name.indexOf('.') != -1) {\n            v = \"values.\" + name;\n        }\n        // number or a '-' in it or a single word (maybe a keyword): use array notation\n        // (http://jsperf.com/string-property-access/4)\n        else {    \n            v = \"values['\" + name + \"']\";\n        }\n\n        if (math) {\n            v = '(' + v + math + ')';\n        }\n\n        if (format && me.useFormat) {\n            args = args ? ',' + args : \"\";\n            if (format.substr(0, 5) != \"this.\") {\n                format = \"fm.\" + format + '(';\n            } else {\n                format += '(';\n            }\n        } else {\n            return v;\n        }\n\n        return format + v + args + ')';\n    },\n\n    // @private\n    evalTpl: function ($) {\n\n        // We have to use eval to realize the code block and capture the inner func we also\n        // don't want a deep scope chain. We only do this in Firefox and it is also unhappy\n        // with eval containing a return statement, so instead we assign to \"$\" and return\n        // that. Because we use \"eval\", we are automatically sandboxed properly.\n        eval($);\n        return $;\n    },\n\n    newLineRe: /\\r\\n|\\r|\\n/g,\n    aposRe: /[']/g,\n    intRe:  /^\\s*(\\d+)\\s*$/,\n    tagRe:  /([\\w-\\.\\#]+)(?:\\:([\\w\\.]*)(?:\\((.*?)?\\))?)?(\\s?[\\+\\-\\*\\/]\\s?[\\d\\.\\+\\-\\*\\/\\(\\)]+)?/\n\n}, function () {\n    var proto = this.prototype;\n\n    proto.fnArgs = 'out,values,parent,xindex,xcount';\n    proto.callFn = '.call(this,' + proto.fnArgs + ')';\n});\n\n/**\n * A template class that supports advanced functionality like:\n *\n * - Autofilling arrays using templates and sub-templates\n * - Conditional processing with basic comparison operators\n * - Basic math function support\n * - Execute arbitrary inline code with special built-in template variables\n * - Custom member functions\n * - Many special tags and built-in operators that aren't defined as part of the API, but are supported in the templates that can be created\n *\n * XTemplate provides the templating mechanism built into {@link Ext.view.View}.\n *\n * The {@link Ext.Template} describes the acceptable parameters to pass to the constructor. The following examples\n * demonstrate all of the supported features.\n *\n * # Sample Data\n *\n * This is the data object used for reference in each code example:\n *\n *     var data = {\n *         name: 'Don Griffin',\n *         title: 'Senior Technomage',\n *         company: 'Sencha Inc.',\n *         drinks: ['Coffee', 'Water', 'More Coffee'],\n *         kids: [\n *             { name: 'Aubrey',  age: 17 },\n *             { name: 'Joshua',  age: 13 },\n *             { name: 'Cale',    age: 10 },\n *             { name: 'Nikol',   age: 5 },\n *             { name: 'Solomon', age: 0 }\n *         ]\n *     };\n *\n * # Auto filling of arrays\n *\n * The **tpl** tag and the **for** operator are used to process the provided data object:\n *\n * - If the value specified in for is an array, it will auto-fill, repeating the template block inside the tpl\n *   tag for each item in the array.\n * - If for=\".\" is specified, the data object provided is examined.\n * - While processing an array, the special variable {#} will provide the current array index + 1 (starts at 1, not 0).\n *\n * Examples:\n *\n *     <tpl for=\".\">...</tpl>       // loop through array at root node\n *     <tpl for=\"foo\">...</tpl>     // loop through array at foo node\n *     <tpl for=\"foo.bar\">...</tpl> // loop through array at foo.bar node\n *\n * Using the sample data above:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Kids: ',\n *         '<tpl for=\".\">',       // process the data.kids node\n *             '<p>{#}. {name}</p>',  // use current array index to autonumber\n *         '</tpl></p>'\n *     );\n *     tpl.overwrite(panel.body, data.kids); // pass the kids property of the data object\n *\n * An example illustrating how the **for** property can be leveraged to access specified members of the provided data\n * object to populate the template:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Title: {title}</p>',\n *         '<p>Company: {company}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',     // interrogate the kids property within the data\n *             '<p>{name}</p>',\n *         '</tpl></p>'\n *     );\n *     tpl.overwrite(panel.body, data);  // pass the root node of the data object\n *\n * Flat arrays that contain values (and not objects) can be auto-rendered using the special **`{.}`** variable inside a\n * loop. This variable will represent the value of the array at the current index:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>{name}\\'s favorite beverages:</p>',\n *         '<tpl for=\"drinks\">',\n *             '<div> - {.}</div>',\n *         '</tpl>'\n *     );\n *     tpl.overwrite(panel.body, data);\n *\n * When processing a sub-template, for example while looping through a child array, you can access the parent object's\n * members via the **parent** object:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',\n *             '<tpl if=\"age &gt; 1\">',\n *                 '<p>{name}</p>',\n *                 '<p>Dad: {parent.name}</p>',\n *             '</tpl>',\n *         '</tpl></p>'\n *     );\n *     tpl.overwrite(panel.body, data);\n *\n * # Conditional processing with basic comparison operators\n *\n * The **tpl** tag and the **if** operator are used to provide conditional checks for deciding whether or not to render\n * specific parts of the template.\n *\n * Using the sample data above:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',\n *             '<tpl if=\"age &gt; 1\">',\n *                 '<p>{name}</p>',\n *             '</tpl>',\n *         '</tpl></p>'\n *     );\n *     tpl.overwrite(panel.body, data);\n *\n * More advanced conditionals are also supported:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',\n *             '<p>{name} is a ',\n *             '<tpl if=\"age &gt;= 13\">',\n *                 '<p>teenager</p>',\n *             '<tpl elseif=\"age &gt;= 2\">',\n *                 '<p>kid</p>',\n *             '<tpl else>',\n *                 '<p>baby</p>',\n *             '</tpl>',\n *         '</tpl></p>'\n *     );\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',\n *             '<p>{name} is a ',\n *             '<tpl switch=\"name\">',\n *                 '<tpl case=\"Aubrey\" case=\"Nikol\">',\n *                     '<p>girl</p>',\n *                 '<tpl default>',\n *                     '<p>boy</p>',\n *             '</tpl>',\n *         '</tpl></p>'\n *     );\n *\n * A `break` is implied between each case and default, however, multiple cases can be listed\n * in a single &lt;tpl&gt; tag.\n *\n * # Using double quotes\n *\n * Examples:\n *\n *     var tpl = new Ext.XTemplate(\n *         \"<tpl if='age &gt; 1 && age &lt; 10'>Child</tpl>\",\n *         \"<tpl if='age &gt;= 10 && age &lt; 18'>Teenager</tpl>\",\n *         \"<tpl if='this.isGirl(name)'>...</tpl>\",\n *         '<tpl if=\"id == \\'download\\'\">...</tpl>',\n *         \"<tpl if='needsIcon'><img src='{icon}' class='{iconCls}'/></tpl>\",\n *         \"<tpl if='name == \\\"Don\\\"'>Hello</tpl>\"\n *     );\n *\n * # Basic math support\n *\n * The following basic math operators may be applied directly on numeric data values:\n *\n *     + - * /\n *\n * For example:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',\n *             '<tpl if=\"age &gt; 1\">',  // <-- Note that the > is encoded\n *                 '<p>{#}: {name}</p>',  // <-- Auto-number each item\n *                 '<p>In 5 Years: {age+5}</p>',  // <-- Basic math\n *                 '<p>Dad: {parent.name}</p>',\n *             '</tpl>',\n *         '</tpl></p>'\n *     );\n *     tpl.overwrite(panel.body, data);\n *\n * # Execute arbitrary inline code with special built-in template variables\n *\n * Anything between `{[ ... ]}` is considered code to be executed in the scope of the template.\n * The expression is evaluated and the result is included in the generated result. There are\n * some special variables available in that code:\n *\n * - **out**: The output array into which the template is being appended (using `push` to later\n *   `join`).\n * - **values**: The values in the current scope. If you are using scope changing sub-templates,\n *   you can change what values is.\n * - **parent**: The scope (values) of the ancestor template.\n * - **xindex**: If you are in a looping template, the index of the loop you are in (1-based).\n * - **xcount**: If you are in a looping template, the total length of the array you are looping.\n *\n * This example demonstrates basic row striping using an inline code block and the xindex variable:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Company: {[values.company.toUpperCase() + \", \" + values.title]}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',\n *             '<div class=\"{[xindex % 2 === 0 ? \"even\" : \"odd\"]}\">',\n *             '{name}',\n *             '</div>',\n *         '</tpl></p>'\n *      );\n *\n * Any code contained in \"verbatim\" blocks (using \"{% ... %}\") will be inserted directly in\n * the generated code for the template. These blocks are not included in the output. This\n * can be used for simple things like break/continue in a loop, or control structures or\n * method calls (when they don't produce output). The `this` references the template instance.\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Company: {[values.company.toUpperCase() + \", \" + values.title]}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',\n *             '{% if (xindex % 2 === 0) continue; %}',\n *             '{name}',\n *             '{% if (xindex > 100) break; %}',\n *             '</div>',\n *         '</tpl></p>'\n *      );\n *\n * # Template member functions\n *\n * One or more member functions can be specified in a configuration object passed into the XTemplate constructor for\n * more complex processing:\n *\n *     var tpl = new Ext.XTemplate(\n *         '<p>Name: {name}</p>',\n *         '<p>Kids: ',\n *         '<tpl for=\"kids\">',\n *             '<tpl if=\"this.isGirl(name)\">',\n *                 '<p>Girl: {name} - {age}</p>',\n *             '<tpl else>',\n *                 '<p>Boy: {name} - {age}</p>',\n *             '</tpl>',\n *             '<tpl if=\"this.isBaby(age)\">',\n *                 '<p>{name} is a baby!</p>',\n *             '</tpl>',\n *         '</tpl></p>',\n *         {\n *             // XTemplate configuration:\n *             disableFormats: true,\n *             // member functions:\n *             isGirl: function(name){\n *                return name == 'Aubrey' || name == 'Nikol';\n *             },\n *             isBaby: function(age){\n *                return age < 1;\n *             }\n *         }\n *     );\n *     tpl.overwrite(panel.body, data);\n */\nExt.define('Ext.XTemplate', {\n    extend: 'Ext.Template',\n\n    requires: 'Ext.XTemplateCompiler',\n\n    /**\n     * @private\n     */\n    emptyObj: {},\n\n    /**\n     * @cfg {Boolean} compiled\n     * Only applies to {@link Ext.Template}, XTemplates are compiled automatically on the\n     * first call to {@link #apply} or {@link #applyOut}.\n     */\n\n    /**\n     * @cfg {String/Array} definitions\n     * Optional. A statement, or array of statements which set up `var`s which may then\n     * be accessed within the scope of the generated function.\n     */\n\n    apply: function(values, parent) {\n        return this.applyOut(values, [], parent).join('');\n    },\n\n    applyOut: function(values, out, parent) {\n        var me = this,\n            compiler;\n\n        if (!me.fn) {\n            compiler = new Ext.XTemplateCompiler({\n                useFormat: me.disableFormats !== true,\n                definitions: me.definitions\n            });\n\n            me.fn = compiler.compile(me.html);\n        }\n\n        try {\n            me.fn.call(me, out, values, parent || me.emptyObj, 1, 1);\n        } catch (e) {\n            Ext.log('Error: ' + e.message);\n        }\n\n        return out;\n    },\n\n    /**\n     * Does nothing. XTemplates are compiled automatically, so this function simply returns this.\n     * @return {Ext.XTemplate} this\n     */\n    compile: function() {\n        return this;\n    },\n\n    statics: {\n        /**\n         * Gets an `XTemplate` from an object (an instance of an {@link Ext#define}'d class).\n         * Many times, templates are configured high in the class hierarchy and are to be\n         * shared by all classes that derive from that base. To further complicate matters,\n         * these templates are seldom actual instances but are rather configurations. For\n         * example:\n         * \n         *      Ext.define('MyApp.Class', {\n         *          someTpl: [\n         *              'tpl text here'\n         *          ]\n         *      });\n         * \n         * The goal being to share that template definition with all instances and even\n         * instances of derived classes, until `someTpl` is overridden. This method will\n         * \"upgrade\" these configurations to be real `XTemplate` instances *in place* (to\n         * avoid creating one instance per object).\n         *\n         * @param {Object} instance The object from which to get the `XTemplate` (must be\n         * an instance of an {@link Ext#define}'d class).\n         * @param {String} name The name of the property by which to get the `XTemplate`.\n         * @return {Ext.XTemplate} The `XTemplate` instance or null if not found.\n         * @protected\n         */\n        getTpl: function (instance, name) {\n            var tpl = instance[name], // go for it! 99% of the time we will get it!\n                proto;\n\n            if (tpl && !tpl.isTemplate) { // tpl is just a configuration (not an instance)\n                // create the template instance from the configuration:\n                tpl = Ext.ClassManager.dynInstantiate('Ext.XTemplate', tpl);\n\n                // and replace the reference with the new instance:\n                if (instance.hasOwnProperty(name)) { // the tpl is on the instance\n                    instance[name] = tpl;\n                } else { // must be somewhere in the prototype chain\n                    for (proto = instance.self.prototype; proto; proto = proto.superclass) {\n                        if (proto.hasOwnProperty(name)) {\n                            proto[name] = tpl;\n                            break;\n                        }\n                    }\n                }\n            }\n            // else !tpl (no such tpl) or the tpl is an instance already... either way, tpl\n            // is ready to return\n\n            return tpl || null;\n        }\n    }\n});\n\n/**\n * Base Layout class - extended by ComponentLayout and ContainerLayout\n */\nExt.define('Ext.layout.Layout', {\n\n    requires: [\n        'Ext.XTemplate'\n    ],\n\n    uses: [ 'Ext.layout.Context' ],\n\n    /**\n     * @property {Boolean} isLayout\n     * `true` in this class to identify an object as an instantiated Layout, or subclass thereof.\n     */\n    isLayout: true,\n    initialized: false,\n    running: false,\n\n    autoSizePolicy: {\n        setsWidth: 0,\n        setsHeight: 0\n    },\n\n    statics: {\n        layoutsByType: {},\n\n        create: function(layout, defaultType) {\n            var ClassManager = Ext.ClassManager,\n                layoutsByType = this.layoutsByType,\n                alias, className, config, layoutClass, type, load;\n\n            if (!layout || typeof layout === 'string') {\n                type = layout || defaultType;\n                config = {};                    \n            } else if (layout.isLayout) {\n                return layout;\n            } else {\n                config = layout;\n                type = layout.type || defaultType;\n            }\n\n            if (!(layoutClass = layoutsByType[type])) {\n                alias = 'layout.' + type;\n                className = ClassManager.getNameByAlias(alias);\n\n                // this is needed to support demand loading of the class\n                if (!className) {\n                    load = true;\n                }\n                \n                layoutClass = ClassManager.get(className);\n                if (load || !layoutClass) {\n                    return ClassManager.instantiateByAlias(alias, config || {});\n                }\n                layoutsByType[type] = layoutClass;\n            }\n\n            return new layoutClass(config);\n        }\n    },\n\n    constructor : function(config) {\n        var me = this;\n\n        me.id = Ext.id(null, me.type + '-');\n        Ext.apply(me, config);\n        me.layoutCount = 0;\n    },\n\n    /**\n     * @property {Boolean} done Used only during a layout run, this value indicates that a\n     * layout has finished its calculations. This flag is set to true prior to the call to\n     * {@link #calculate} and should be set to false if this layout has more work to do.\n     */\n\n    /**\n     * Called before any calculation cycles to prepare for layout.\n     * \n     * This is a write phase and DOM reads should be strictly avoided when overridding\n     * this method.\n     * \n     * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner\n     * component.\n     * @method beginLayout\n     */\n    beginLayout: Ext.emptyFn,\n\n    /**\n     * Called before any calculation cycles to reset DOM values and prepare for calculation.\n     * \n     * This is a write phase and DOM reads should be strictly avoided when overridding\n     * this method.\n     * \n     * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner\n     * component.\n     * @method beginLayoutCycle\n     */\n    beginLayoutCycle: function (ownerContext) {\n        var me = this,\n            context = me.context,\n            changed;\n\n        if (me.lastWidthModel != ownerContext.widthModel) {\n            if (me.lastWidthModel) {\n                changed = true;\n            }\n            me.lastWidthModel = ownerContext.widthModel;\n        }\n\n        if (me.lastHeightModel != ownerContext.heightModel) {\n            if (me.lastWidthModel) {\n                changed = true;\n            }\n            me.lastHeightModel = ownerContext.heightModel;\n        }\n\n        if (changed) {\n            (context = ownerContext.context).clearTriggers(me, false);\n            context.clearTriggers(me, true);\n            me.triggerCount = 0;\n        }\n    },\n\n    /**\n     * Called to perform the calculations for this layout. This method will be called at\n     * least once and may be called repeatedly if the {@link #done} property is cleared\n     * before return to indicate that this layout is not yet done. The {@link #done} property\n     * is always set to `true` before entering this method.\n     * \n     * This is a read phase and DOM writes should be strictly avoided in derived classes.\n     * Instead, DOM writes need to be written to {@link Ext.layout.ContextItem} objects to\n     *  be flushed at the next opportunity.\n     * \n     * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner\n     * component.\n     * @method calculate\n     * @abstract\n     */\n\n    /**\n     * This method (if implemented) is called at the end of the cycle in which this layout\n     * completes (by not setting {@link #done} to `false` in {@link #calculate}). It is\n     * possible for the layout to complete and yet become invalid before the end of the cycle,\n     * in which case, this method will not be called. It is also possible for this method to\n     * be called and then later the layout becomes invalidated. This will result in\n     * {@link #calculate} being called again, followed by another call to this method.\n     * \n     * This is a read phase and DOM writes should be strictly avoided in derived classes.\n     * Instead, DOM writes need to be written to {@link Ext.layout.ContextItem} objects to\n     * be flushed at the next opportunity.\n     * \n     * This method need not be implemented by derived classes and, in fact, should only be\n     * implemented when needed.\n     * \n     * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner\n     * component.\n     * @method completeLayout\n     */\n\n    /**\n     * This method (if implemented) is called after all layouts have completed. In most\n     * ways this is similar to {@link #completeLayout}. This call can cause this (or any\n     * layout) to be become invalid (see {@link Ext.layout.Context#invalidate}), but this\n     * is best avoided. This method is intended to be where final reads are made and so it\n     * is best to avoid invalidating layouts at this point whenever possible. Even so, this\n     * method can be used to perform final checks that may require all other layouts to be\n     * complete and then invalidate some results.\n     * \n     * This is a read phase and DOM writes should be strictly avoided in derived classes.\n     * Instead, DOM writes need to be written to {@link Ext.layout.ContextItem} objects to\n     * be flushed at the next opportunity.\n     * \n     * This method need not be implemented by derived classes and, in fact, should only be\n     * implemented when needed.\n     * \n     * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner\n     * component.\n     * @method finalizeLayout\n     */\n\n    /**\n     * This method is called after all layouts are complete and their calculations flushed\n     * to the DOM. No further layouts will be run and this method is only called once per\n     * layout run. The base component layout caches `lastComponentSize`.\n     * \n     * This is a write phase and DOM reads should be avoided if possible when overridding\n     * this method.\n     * \n     * This method need not be implemented by derived classes and, in fact, should only be\n     * implemented when needed.\n     * \n     * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner\n     * component.\n     */\n    finishedLayout: function () {\n        this.ownerContext = null;\n    },\n    \n    /**\n     * This method (if implemented) is called after all layouts are finished, and all have\n     * a `lastComponentSize` cached. No further layouts will be run and this method is only\n     * called once per layout run. It is the bookend to {@link #beginLayout}.\n     * \n     * This is a write phase and DOM reads should be avoided if possible when overridding\n     * this method. This is the catch-all tail method to a layout and so the rules are more\n     * relaxed. Even so, for performance reasons, it is best to avoid reading the DOM. If\n     * a read is necessary, consider implementing a {@link #finalizeLayout} method to do the\n     * required reads.\n     * \n     * This method need not be implemented by derived classes and, in fact, should only be\n     * implemented when needed.\n     * \n     * @param {Ext.layout.ContextItem} ownerContext The context item for the layout's owner\n     * component.\n     * @method notifyOwner\n     */\n    \n    redoLayout: Ext.emptyFn,\n    undoLayout: Ext.emptyFn,\n\n    getAnimatePolicy: function() {\n        return this.animatePolicy;\n    },\n\n    /**\n     * Returns an object describing how this layout manages the size of the given component.\n     * This method must be implemented by any layout that manages components.\n     *\n     * @param {Ext.Component} item\n     *\n     * @return {Object} An object describing the sizing done by the layout for this item or\n     * null if the layout mimics the size policy of its ownerCt (e.g., 'fit' and 'card').\n     * @return {Boolean} return.readsWidth True if the natural/auto width of this component\n     * is used by the ownerLayout.\n     * @return {Boolean} return.readsHeight True if the natural/auto height of this component\n     * is used by the ownerLayout.\n     * @return {Boolean} return.setsWidth True if the ownerLayout set this component's width.\n     * @return {Boolean} return.setsHeight True if the ownerLayout set this component's height.\n     *\n     * @protected\n     */\n    getItemSizePolicy: function (item) {\n        return this.autoSizePolicy;\n    },\n\n    isItemBoxParent: function (itemContext) {\n        return false;\n    },\n\n    isItemLayoutRoot: function (item) {\n        var sizeModel = item.getSizeModel(),\n            width = sizeModel.width,\n            height = sizeModel.height;\n\n        // If this component has never had a layout and some of its dimensions are set by\n        // its ownerLayout, we cannot be the layoutRoot...\n        if (!item.componentLayout.lastComponentSize && (width.calculated || height.calculated)) {\n            return false;\n        }\n\n        // otherwise an ownerCt whose size is not effected by its content is a root\n        return !width.shrinkWrap && !height.shrinkWrap;\n    },\n\n    isItemShrinkWrap: function (item) {\n        return item.shrinkWrap;\n    },\n\n    isRunning: function () {\n        return !!this.ownerContext;\n    },\n\n    //-----------------------------------------------------\n    /*\n     * Clears any styles which must be cleared before layout can take place.\n     * Only DOM WRITES must be performed at this stage.\n     *\n     * An entry for the owner's element ID must be created in the layoutContext containing\n     * a reference to the target which must be sized/positioned/styled by the layout at\n     * the flush stage:\n     *\n     *     {\n     *         target: me.owner\n     *     }\n     *\n     * Component layouts should iterate through managed Elements,\n     * pushing an entry for each element:\n     *\n     *     {\n     *         target: childElement\n     *     }\n     */\n    //-----------------------------------------------------\n\n    getItemsRenderTree: function (items, renderCfgs) {\n        var length = items.length,\n            i, item, itemConfig, result;\n\n        if (length) {\n            result = [];\n            for (i = 0; i < length; ++i) {\n                item = items[i];\n\n                // If we are being asked to move an already rendered Component, we must not recalculate its renderTree\n                // and rerun its render process. The Layout's isValidParent check will ensure that the DOM is moved into place.\n                if (!item.rendered) {\n\n                    // If we've already calculated the item's element config, don't calculate it again.\n                    // This may happen if the rendering process mutates the owning Container's items\n                    // collection, and Ext.layout.Container#getRenderTree runs through the collection again.\n                    // Note that the config may be null if a beforerender listener vetoed the operation, so\n                    // we must compare to undefined.\n                    if (renderCfgs && (renderCfgs[item.id] !== undefined)) {\n                        itemConfig = renderCfgs[item.id];\n                    } else {\n                        // Perform layout preprocessing in the bulk render path\n                        this.configureItem(item);\n                        itemConfig = item.getRenderTree();\n                        if (renderCfgs) {\n                            renderCfgs[item.id] = itemConfig;\n                        }\n                    }\n\n                    // itemConfig mey be null if a beforerender listener vetoed the operation.\n                    if (itemConfig) {\n                        result.push(itemConfig);\n                    }\n                }\n            }\n        }\n\n        return result;\n    },\n\n    finishRender: Ext.emptyFn,\n\n    finishRenderItems: function (target, items) {\n        var length = items.length,\n            i, item;\n\n        for (i = 0; i < length; i++) {\n            item = items[i];\n\n            // Only postprocess items which are being rendered. deferredRender may mean that only one has been rendered.\n            if (item.rendering) {\n\n                // Tell the item at which index in the Container it is\n                item.finishRender(i);\n\n                this.afterRenderItem(item);\n            }\n        }\n    },\n\n    renderChildren: function () {\n        var me = this,\n            items = me.getLayoutItems(),\n            target = me.getRenderTarget();\n\n        me.renderItems(items, target);\n    },\n\n    /**\n     * Iterates over all passed items, ensuring they are rendered.  If the items are already rendered,\n     * also determines if the items are in the proper place in the dom.\n     * @protected\n     */\n    renderItems : function(items, target) {\n        var me = this,\n            ln = items.length,\n            i = 0,\n            item;\n\n        if (ln) {\n            Ext.suspendLayouts();\n            for (; i < ln; i++) {\n                item = items[i];\n                if (item && !item.rendered) {\n                    me.renderItem(item, target, i);\n                } else if (!me.isValidParent(item, target, i)) {\n                    me.moveItem(item, target, i);\n                } else {\n                    // still need to configure the item, it may have moved in the container.\n                    me.configureItem(item);\n                }\n            }\n            Ext.resumeLayouts(true);\n        }\n    },\n\n    /**\n     * Validates item is in the proper place in the dom.\n     * @protected\n     */\n    isValidParent : function(item, target, position) {\n        var itemDom = item.el ? item.el.dom : Ext.getDom(item),\n            targetDom = (target && target.dom) || target;\n\n        // If it's resizable+wrapped, the position element is the wrapper.\n        if (itemDom.parentNode && itemDom.parentNode.className.indexOf(Ext.baseCSSPrefix + 'resizable-wrap') !== -1) {\n            itemDom = itemDom.parentNode;\n        }\n\n        // Test DOM nodes for equality using \"===\" : http://jsperf.com/dom-equality-test\n        if (itemDom && targetDom) {\n            if (typeof position == 'number') {\n                return itemDom === targetDom.childNodes[position];\n            }\n            return itemDom.parentNode === targetDom;\n        }\n\n        return false;\n    },\n\n    /**\n     * Called before an item is rendered to allow the layout to configure the item.\n     * @param {Ext.Component} item The item to be configured\n     * @protected\n     */\n    configureItem: function(item) {\n        item.ownerLayout = this;\n    },\n\n    /**\n     * Renders the given Component into the target Element.\n     * @param {Ext.Component} item The Component to render\n     * @param {Ext.dom.Element} target The target Element\n     * @param {Number} position The position within the target to render the item to\n     * @private\n     */\n    renderItem : function(item, target, position) {\n        var me = this;\n        if (!item.rendered) {\n            me.configureItem(item);\n            item.render(target, position);\n            me.afterRenderItem(item);\n        }\n    },\n\n    /**\n     * Moves Component to the provided target instead.\n     * @private\n     */\n    moveItem : function(item, target, position) {\n        target = target.dom || target;\n        if (typeof position == 'number') {\n            position = target.childNodes[position];\n        }\n        target.insertBefore(item.el.dom, position || null);\n        item.container = Ext.get(target);\n        this.configureItem(item);\n    },\n\n    /**\n     * This method is called when a child item changes in some way. By default this calls\n     * {@link Ext.AbstractComponent#updateLayout} on this layout's owner.\n     * \n     * @param {Ext.Component} child The child item that has changed.\n     * @return {Boolean} True if this layout has handled the content change.\n     */\n    onContentChange: function () {\n        this.owner.updateLayout();\n        return true;\n    },\n\n    /**\n     * A one-time initialization method called just before rendering.\n     * @protected\n     */\n    initLayout : function() {\n        this.initialized = true;\n    },\n\n    // @private Sets the layout owner\n    setOwner : function(owner) {\n        this.owner = owner;\n    },\n\n    /**\n     * Returns the set of items to layout (empty by default).\n     * @protected\n     */\n    getLayoutItems : function() {\n        return [];\n    },\n\n    // Placeholder empty functions for subclasses to extend\n    afterRenderItem: Ext.emptyFn,\n    onAdd : Ext.emptyFn,\n    onRemove : Ext.emptyFn,\n    onDestroy : Ext.emptyFn,\n\n    /**\n     * Removes layout's itemCls and owning Container's itemCls.\n     * Clears the managed dimensions flags\n     * @protected\n     */\n    afterRemove : function(item) {\n        var me = this,\n            el = item.el,\n            owner = me.owner,\n            removeClasses;\n\n        if (item.rendered) {\n            removeClasses = [].concat(me.itemCls || []);\n            if (owner.itemCls) {\n                removeClasses = Ext.Array.push(removeClasses, owner.itemCls);\n            }\n            if (removeClasses.length) {\n                el.removeCls(removeClasses);\n            }\n        }\n\n        delete item.ownerLayout;\n    },\n\n    /**\n     * Destroys this layout. This method removes a `targetCls` from the `target`\n     * element and calls `onDestroy`.\n     * \n     * A derived class can override either this method or `onDestroy` but in all\n     * cases must call the base class versions of these methods to allow the base class to\n     * perform its cleanup.\n     * \n     * This method (or `onDestroy`) are overridden by subclasses most often to purge\n     * event handlers or remove unmanged DOM nodes.\n     *\n     * @protected\n     */\n    destroy : function() {\n        var me = this,\n            target;\n\n        if (me.targetCls) {\n            target = me.getTarget();\n            if (target) {\n                target.removeCls(me.targetCls);\n            }\n        }\n\n        me.onDestroy();\n    },\n\n    sortWeightedItems: function (items, reverseProp) {\n        for (var i = 0, length = items.length; i < length; ++i) {\n            items[i].$i = i;\n        }\n\n        Ext.Array.sort(items, function (item1, item2) {\n            var ret = item2.weight - item1.weight;\n\n            if (!ret) {\n                ret = item1.$i - item2.$i;\n                if (item1[reverseProp]) {\n                    ret = -ret;\n                }\n            }\n\n            return ret;\n        });\n\n        for (i = 0; i < length; ++i) {\n            delete items[i].$i;\n        }\n    }\n}, function () {\n    var Layout = this,\n        sizeModels = {},\n        sizeModelsArray = [],\n        i, j, n, pairs, sizeModel;\n\n    Layout.prototype.sizeModels = Layout.sizeModels = sizeModels;\n\n    /**\n    * This class describes a size determination strategy or algorithm used by the layout\n    * system. There are special instances of this class stored as static properties to\n    * avoid needless object instantiation. These instances should be treated as readonly.\n    * \n    *  * `calculated`\n    *  * `configured`\n    *  * `constrainedMax`\n    *  * `constrainedMin`\n    *  * `natural`\n    *  * `shrinkWrap`\n    *  * `calculatedFromConfigured`\n    *  * `calculatedFromNatural`\n    *  * `calculatedFromShrinkWrap`\n    *\n    * Using one of these instances is simply:\n    *\n    *       var calculated = Ext.layout.SizeModel.calculated;\n    *\n    * @class Ext.layout.SizeModel\n    * @protected\n    */\n    var SizeModel = function (config) {\n        var me = this,\n            name = config.name;\n\n        Ext.apply(Ext.apply(me, defaults), config);\n\n        me[name] = true; // set the one special flag that matches our name\n        SizeModel[name] = sizeModels[name] = me;\n\n        me.fixed = !(me.auto = me.natural || me.shrinkWrap);\n\n        /**\n         * @prop {Number} ordinal\n         * The 0-based ordinal for this `SizeModel` instance.\n         * @readonly\n         */\n        me.ordinal = sizeModelsArray.length;\n        sizeModelsArray.push(me);\n    };\n\n    Ext.layout.SizeModel = SizeModel;\n\n    var defaults = {\n        /**\n        * @property {String} name\n        * The name of this size model (e.g., \"calculated\").\n        * @readonly\n        */\n\n        /**\n        * @property {Boolean} auto\n        * True if the size is either `natural` or `shrinkWrap`, otherwise false.\n        * @readonly\n        */\n\n        /**\n        * @property {Boolean} calculated\n        * True if the size is calculated by the `ownerLayout`.\n        * @readonly\n        */\n        calculated: false,\n\n        /**\n        * @property {Boolean} configured\n        * True if the size is configured (e.g., by a `width` or `minWidth`). The names of\n        * configuration properties can be found in the {@link #names} property.\n        * @readonly\n        */\n        configured: false,\n\n        /**\n        * @property {Boolean} constrainedMax\n        * True if the size is constrained by a `maxWidth` or `maxHeight` configuration. This\n        * is a flavor of `configured` (since `maxWidth` and `maxHeight` are config options).\n        * If true, the {@link #names} property will be defined as well.\n        * @readonly\n        */\n        constrainedMax: false,\n\n        /**\n        * @property {Boolean} constrainedMin\n        * True if the size is constrained by a `minWidth` or `minHeight` configuration. This\n        * is a flavor of `configured` (since `minWidth` and `minHeight` are config options).\n        * If true, the {@link #names} property will be defined as well.\n        * @readonly\n        */\n        constrainedMin: false,\n\n        /**\n        * @property {Boolean} fixed\n        * True if the size is either `calculated` or `configured`, otherwise false.\n        * @readonly\n        */\n\n        /**\n        * @property {Boolean} natural\n        * True if the size is determined by CSS and not by content. Such sizes are assumed to\n        * be dependent on the container box and measurement occurs on the outer-most element.\n        * @readonly\n        */\n        natural: false,\n\n        /**\n        * @property {Boolean} shrinkWrap\n        * True if the size is determined by content irrespective of the container box.\n        * @readonly\n        */\n        shrinkWrap: false,\n\n        /**\n        * @property {Boolean} calculatedFromConfigured\n        * True if the size is calculated by the `ownerLayout` based on a configured size.\n        * @readonly\n        */\n        calculatedFromConfigured: false,\n\n        /**\n        * @property {Boolean} calculatedFromNatural\n        * True if the size is calculated by the `ownerLayout` based on `natural` size model\n        * results.\n        * @readonly\n        */\n        calculatedFromNatural: false,\n\n        /**\n        * @property {Boolean} calculatedFromShrinkWrap\n        * True if the size is calculated by the `ownerLayout` based on `shrinkWrap` size model\n        * results.\n        * @readonly\n        */\n        calculatedFromShrinkWrap: false,\n\n        /**\n        * @property {Object} names An object with the config property names that determine the\n        * size.\n        * @property {String} names.width The width property name (e.g., 'width').\n        * @property {String} names.height The height property name (e.g., 'minHeight').\n        * @readonly\n        */\n        names: null\n    };\n\n    //-------------------------------------------------------------------------------\n    // These are the 4 fundamental size models.\n\n    new SizeModel({\n        name: 'calculated'\n    });\n\n    new SizeModel({\n        name: 'configured',\n        names: { width: 'width', height: 'height' }\n    });\n\n    new SizeModel({\n        name: 'natural'\n    });\n\n    new SizeModel({\n        name: 'shrinkWrap'\n    });\n\n    //-------------------------------------------------------------------------------\n    // These are the size models are flavors of the above but with some extra detail\n    // about their dynamic use.\n\n    new SizeModel({\n        name: 'calculatedFromConfigured',\n        configured: true,\n        names: { width: 'width', height: 'height' }\n    });\n\n    new SizeModel({\n        name: 'calculatedFromNatural',\n        natural: true\n    });\n\n    new SizeModel({\n        name: 'calculatedFromShrinkWrap',\n        shrinkWrap: true\n    });\n\n    new SizeModel({\n        name: 'constrainedMax',\n        configured: true,\n        constrained: true,\n        names: { width: 'maxWidth', height: 'maxHeight' }\n    });\n\n    new SizeModel({\n        name: 'constrainedMin',\n        configured: true,\n        constrained: true,\n        names: { width: 'minWidth', height: 'minHeight' }\n    });\n\n    for (i = 0, n = sizeModelsArray.length; i < n; ++i) {\n        sizeModel = sizeModelsArray[i];\n        /**\n         * An array of objects indexed by the {@link #ordinal} of a height `SizeModel` on\n         * a width `SizeModel` to yield an object describing both height and width size\n         * models.\n         * \n         * Used like this:\n         *\n         *      widthModel.pairsByHeightOrdinal[heightModel.ordinal]\n         *\n         * This provides a reusable object equivalent to the following:\n         * \n         *      {\n         *          width: widthModel,\n         *          height: heightModel\n         *      }\n         *\n         * @property {Object[]} pairsByHeightOrdinal\n         * @property {Ext.layout.SizeModel} pairsByHeightOrdinal.width The `SizeModel` for\n         * the width.\n         * @property {Ext.layout.SizeModel} pairsByHeightOrdinal.height The `SizeModel` for\n         * the height.\n         */\n        sizeModel.pairsByHeightOrdinal = pairs = [];\n\n        for (j = 0; j < n; ++j) {\n            pairs.push({\n                width: sizeModel,\n                height: sizeModelsArray[j]\n            });\n        }\n    }\n});\n\n/**\n * This class is intended to be extended or created via the {@link Ext.container.Container#layout layout}\n * configuration property.  See {@link Ext.container.Container#layout} for additional details.\n */\nExt.define('Ext.layout.container.Container', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.layout.Layout',\n\n    alternateClassName: 'Ext.layout.ContainerLayout',\n\n    mixins: {\n        elementCt: 'Ext.util.ElementContainer'\n    },\n\n    requires: [\n        'Ext.XTemplate'\n    ],\n\n    type: 'container',\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String} itemCls\n     * An optional extra CSS class that will be added to the container. This can be useful for\n     * adding customized styles to the container or any of its children using standard CSS\n     * rules. See {@link Ext.Component}.{@link Ext.Component#componentCls componentCls} also.\n     */\n\n    /**\n     * @cfg {Number} [manageOverflow=0]\n     * One of the following values:\n     *\n     *  - 0 if the layout should ignore overflow.\n     *  - 1 if the layout should be rerun if scrollbars are needed.\n     *  - 2 if the layout should also correct padding when overflowed.\n     */\n    manageOverflow: 0,\n\n    /**\n     * @private\n     * Called by an owning Panel before the Panel begins its collapse process.\n     * Most layouts will not need to override the default Ext.emptyFn implementation.\n     */\n    beginCollapse: Ext.emptyFn,\n\n    /**\n     * @private\n     * Called by an owning Panel before the Panel begins its expand process.\n     * Most layouts will not need to override the default Ext.emptyFn implementation.\n     */\n    beginExpand: Ext.emptyFn,\n\n    /**\n     * An object which contains boolean properties specifying which properties are to be \n     * animated upon flush of child Component ContextItems. For example, Accordion would\n     * have:\n     *\n     *      {\n     *          y: true,\n     *          height: true\n     *      }\n     *\n     * @private\n     */\n    animatePolicy: null,\n\n    childEls: [\n        /**\n         * @property {Ext.Element} overflowPadderEl\n         * The element used to correct body padding during overflow.\n         */\n        'overflowPadderEl'\n    ],\n\n    renderTpl: [\n        '{%this.renderBody(out,values)%}'\n    ],\n\n    usesContainerHeight: true,\n    usesContainerWidth: true,\n    usesHeight: true,\n    usesWidth: true,\n\n\n    /**\n     * @cfg {Boolean} [reserveScrollbar=false]\n     * Set to `true` to leave space for a vertical scrollbar (if the OS shows space-consuming scrollbars) regardless\n     * of whether a scrollbar is needed.\n     *\n     * This is useful if content height changes during application usage, but you do not want the calculated width\n     * of child items to change when a scrollbar appears or disappears. The scrollbar will appear in the reserved space,\n     * and the calculated width of child Components will not change.\n     *\n     *     @example\n     *     Ext.define('Employee', {\n     *         extend: 'Ext.data.Model',\n     *         fields: [\n     *            {name: 'rating', type: 'int'},\n     *            {name: 'salary', type: 'float'},\n     *            {name: 'name'}\n     *         ]\n     *     });\n     *\n     *     function createFakeData(count) {\n     *         var firstNames   = ['Ed', 'Tommy', 'Aaron', 'Abe', 'Jamie', 'Adam', 'Dave', 'David', 'Jay', 'Nicolas', 'Nige'],\n     *             lastNames    = ['Spencer', 'Maintz', 'Conran', 'Elias', 'Avins', 'Mishcon', 'Kaneda', 'Davis', 'Robinson', 'Ferrero', 'White'],\n     *             ratings      = [1, 2, 3, 4, 5],\n     *             salaries     = [100, 400, 900, 1500, 1000000];\n     *\n     *         var data = [];\n     *         for (var i = 0; i < (count || 25); i++) {\n     *             var ratingId    = Math.floor(Math.random() * ratings.length),\n     *                 salaryId    = Math.floor(Math.random() * salaries.length),\n     *                 firstNameId = Math.floor(Math.random() * firstNames.length),\n     *                 lastNameId  = Math.floor(Math.random() * lastNames.length),\n     *\n     *                 rating      = ratings[ratingId],\n     *                 salary      = salaries[salaryId],\n     *                 name        = Ext.String.format(\"{0} {1}\", firstNames[firstNameId], lastNames[lastNameId]);\n     *\n     *             data.push({\n     *                 rating: rating,\n     *                 salary: salary,\n     *                 name: name\n     *             });\n     *         }\n     *         store.loadData(data);\n     *     }\n     *\n     *     // create the Data Store\n     *     var store = Ext.create('Ext.data.Store', {\n     *         id: 'store',\n     *         model: 'Employee',\n     *         proxy: {\n     *             type: 'memory'\n     *         }\n     *     });\n     *     createFakeData(10);\n     *\n     *     var grid = Ext.create('Ext.grid.Panel', {\n     *         title: 'Grid loaded with varying number of records',\n     *         anchor: '100%',\n     *         store: store,\n     *         columns: [{\n     *             xtype: 'rownumberer',\n     *             width: 40,\n     *             sortable: false\n     *         },{\n     *             text: 'Name',\n     *             flex: 1,\n     *             sortable: true,\n     *             dataIndex: 'name'\n     *         },{\n     *             text: 'Rating',\n     *             width: 125,\n     *             sortable: true,\n     *             dataIndex: 'rating'\n     *         },{\n     *             text: 'Salary',\n     *             width: 125,\n     *             sortable: true,\n     *             dataIndex: 'salary',\n     *             align: 'right',\n     *             renderer: Ext.util.Format.usMoney\n     *         }]\n     *     });\n     *\n     *     Ext.create('Ext.panel.Panel', {\n     *         renderTo: document.body,\n     *         width: 800,\n     *         height: 600,\n     *         layout: {\n     *             type: 'anchor',\n     *             reserveScrollbar: true // There will be a gap even when there's no scrollbar\n     *         },\n     *         autoScroll: true,\n     *         items: grid,\n     *         tbar: {\n     *             defaults: {\n     *                 handler: function(b) {\n     *                     createFakeData(b.count);\n     *                 }\n     *             },\n     *             items: [{\n     *                  text: '10 Items',\n     *                  count: 10\n     *             },{\n     *                  text: '100 Items',\n     *                  count: 100\n     *             },{\n     *                  text: '300 Items',\n     *                  count: 300\n     *             },{\n     *                  text: '1000 Items',\n     *                  count: 1000\n     *             },{\n     *                  text: '5000 Items',\n     *                  count: 5000\n     *             }]\n     *         }\n     *     });\n     *\n     */\n    reserveScrollbar: false,\n\n    // Begin with no previous adjustments\n    lastOverflowAdjust: {\n        width: 0,\n        height: 0\n    },\n\n    constructor: function () {\n        this.callParent(arguments);\n        this.mixins.elementCt.constructor.call(this);\n    },\n\n    destroy : function() {\n        this.callParent();\n        this.mixins.elementCt.destroy.call(this);\n    },\n\n    initLayout: function() {\n        var me = this,\n            scrollbarWidth = Ext.getScrollbarSize().width;\n\n        me.callParent();\n\n        // Create a default lastOverflowAdjust based upon scrolling configuration.\n        // If the Container is to overflow, or we *always* reserve space for a scrollbar\n        // then reserve space for a vertical scrollbar\n        if (scrollbarWidth && me.manageOverflow && !me.hasOwnProperty('lastOverflowAdjust')) {\n            if (me.owner.autoScroll || me.reserveScrollbar) {\n                me.lastOverflowAdjust = {\n                    width: scrollbarWidth,\n                    height: 0\n                };\n            }\n        }\n    },\n\n    /**\n     * In addition to work done by our base classes, containers benefit from some extra\n     * cached data. The following properties are added to the ownerContext:\n     * \n     *  - visibleItems: the result of {@link #getVisibleItems}\n     *  - childItems: the ContextItem[] for each visible item\n     *  - targetContext: the ContextItem for the {@link #getTarget} element\n     */\n    beginLayout: function (ownerContext) {\n        this.callParent(arguments);\n\n        ownerContext.targetContext = ownerContext.getEl('getTarget', this);\n\n        this.cacheChildItems(ownerContext);\n    },\n\n    beginLayoutCycle: function (ownerContext, firstCycle) {\n        var me = this,\n            padEl = me.overflowPadderEl;\n\n        me.callParent(arguments);\n\n        // Begin with the scrollbar adjustment that we used last time - this is more likely to be correct\n        // than beginning with no adjustment at all\n        if (!ownerContext.state.overflowAdjust) {\n            ownerContext.state.overflowAdjust = me.lastOverflowAdjust;\n        }\n\n        if (firstCycle) {\n            if (me.usesContainerHeight) {\n                ++ownerContext.consumersContainerHeight;\n            }\n            if (me.usesContainerWidth) {\n                ++ownerContext.consumersContainerWidth;\n            }\n        }\n\n        if (padEl) {\n            padEl.setStyle('display', 'none');\n        }\n    },\n\n    completeLayout: function (ownerContext) {\n        // Cache the scrollbar adjustment\n        this.lastOverflowAdjust = ownerContext.state.overflowAdjust;\n    },\n\n    cacheChildItems: function (ownerContext) {\n        var context = ownerContext.context,\n            childItems = [],\n            items = this.getVisibleItems(),\n            length = items.length,\n            i;\n\n        ownerContext.childItems = childItems;\n        ownerContext.visibleItems = items;\n\n        for (i = 0; i < length; ++i) {\n            childItems.push(context.getCmp(items[i]));\n        }\n    },\n\n    cacheElements: function () {\n        var owner = this.owner;\n\n        this.applyChildEls(owner.el, owner.id); // from ElementContainer mixin\n    },\n\n    calculateContentSize: function (ownerContext, dimensions) {\n        var me = this,\n            containerDimensions = (dimensions || 0) | me.manageOverflow |\n                   ((ownerContext.widthModel.shrinkWrap ? 1 : 0) |\n                    (ownerContext.heightModel.shrinkWrap ? 2 : 0)),\n            calcWidth = (containerDimensions & 1) || undefined,\n            calcHeight = (containerDimensions & 2) || undefined,\n            childItems = ownerContext.childItems,\n            length = childItems.length,\n            contentHeight = 0,\n            contentWidth = 0,\n            needed = 0,\n            props = ownerContext.props,\n            targetXY, targetX, targetY, targetPadding,\n            borders, child, childContext, childX, childY, height, i, margins, width, xy;\n\n        if (calcWidth) {\n            if (isNaN(props.contentWidth)) {\n                ++needed;\n            } else {\n                calcWidth = undefined;\n            }\n        }\n        if (calcHeight) {\n            if (isNaN(props.contentHeight)) {\n                ++needed;\n            } else {\n                calcHeight = undefined;\n            }\n        }\n\n        if (needed) {\n            // TODO - this is rather brute force... maybe a wrapping el or clientHeight/Width\n            // trick might help. Whatever we do, it must either work for Absolute layout or\n            // at least be correctable by an overridden method in that derived class.\n            for (i = 0; i < length; ++i) {\n                childContext = childItems[i];\n                child = childContext.target;\n                height = calcHeight && childContext.getProp('height');\n                width = calcWidth && childContext.getProp('width');\n                margins = childContext.getMarginInfo();\n\n                // getXY is the root method here (meaning that we cannot avoid getting both\n                // even if we need only one), so dip into the DOM if something is needed\n                if ((calcWidth && isNaN(child.x)) || (calcHeight && isNaN(child.y))) {\n                    xy = child.el.getXY();\n                    if (!targetXY) {\n                        targetXY = ownerContext.targetContext.el.getXY();\n                        borders = ownerContext.targetContext.getBorderInfo();\n                        targetX = targetXY[0] + borders.left;\n                        targetY = targetXY[1] + borders.top;\n                    }\n                    // not worth avoiding the possibly useless calculation here:\n                    childX = xy[0] - targetX;\n                    childY = xy[1] - targetY;\n                } else {\n                    // not worth avoiding these either:\n                    childX = child.x;\n                    childY = child.y;\n                }\n                // XY includes the top/left margin\n\n                height += margins.bottom;\n                width  += margins.right;\n\n                contentHeight = Math.max(contentHeight, childY + height);\n                contentWidth = Math.max(contentWidth, childX + width);\n\n                if (isNaN(contentHeight) && isNaN(contentWidth)) {\n                    me.done = false;\n                    return;\n                }\n            }\n\n            if (calcWidth || calcHeight) {\n                targetPadding = ownerContext.targetContext.getPaddingInfo();\n            }\n            if (calcWidth && !ownerContext.setContentWidth(contentWidth + targetPadding.right)) {\n                me.done = false;\n            }\n            if (calcHeight && !ownerContext.setContentHeight(contentHeight + targetPadding.bottom)) {\n                me.done = false;\n            }\n\n            /* add a '/' to turn on this log ('//* enables, '/*' disables)\n            if (me.done) {\n                var el = ownerContext.targetContext.el.dom;\n                Ext.log(this.owner.id, '.contentSize: ', contentWidth, 'x', contentHeight,\n                    ' => scrollSize: ', el.scrollWidth, 'x', el.scrollHeight);\n            }/**/\n        }\n    },\n\n    /**\n     * Handles overflow processing for a container. This should be called once the layout\n     * has determined contentWidth/Height. In addition to the ownerContext passed to the\n     * {@link #calculate} method, this method also needs the containerSize (the object\n     * returned by {@link #getContainerSize}).\n     * \n     * @param {Ext.layout.ContextItem} ownerContext\n     * @param {Object} containerSize\n     * @param {Number} dimensions A bit mask for the overflow managed dimensions. The 0-bit\n     * is for `width` and the 1-bit is for `height`. In other words, a value of 1 would be\n     * only `width`, 2 would be only `height` and 3 would be both.\n     */\n    calculateOverflow: function (ownerContext, containerSize, dimensions) {\n        var me = this,\n            owner = me.owner,\n            manageOverflow = me.manageOverflow,\n            state = ownerContext.state,\n            overflowAdjust = state.overflowAdjust,\n            padWidth, padHeight, padElContext, padding, scrollRangeFlags,\n            overflow, scrollbarSize, contentW, contentH, ownerW, ownerH, scrollbars,\n            xauto, yauto;\n\n        if (manageOverflow && !state.secondPass && !me.reserveScrollbar) {\n            // Determine the dimensions that have overflow:auto applied. If these come by\n            // way of component config, this does not require a DOM read:\n            if (owner.autoScroll) {\n                xauto = yauto = true;\n            } else {\n                if (owner.overflowX) {\n                    xauto = owner.overflowX == 'auto';\n                } else {\n                    overflow = ownerContext.targetContext.getStyle('overflow-x');\n                    xauto = overflow && overflow != 'hidden' && overflow != 'scroll';\n                }\n\n                if (owner.overflowY) {\n                    yauto = owner.overflowY == 'auto';\n                } else {\n                    overflow = ownerContext.targetContext.getStyle('overflow-y');\n                    yauto = overflow && overflow != 'hidden' && overflow != 'scroll';\n                }\n            }\n\n            // If the container layout is not using width, we don't need to adjust for the\n            // vscroll (likewise for height). Perhaps we don't even need to run the layout\n            // again if the adjustments won't have any effect on the result!\n            if (!containerSize.gotWidth) {\n                xauto = false;\n            }\n            if (!containerSize.gotHeight) {\n                yauto = false;\n            }\n\n            if (xauto || yauto) {\n                scrollbarSize = Ext.getScrollbarSize();\n\n                // as a container we calculate contentWidth/Height, so we don't want\n                // to use getProp and make it look like we are triggered by them...\n                contentW = ownerContext.peek('contentWidth');\n                contentH = ownerContext.peek('contentHeight');\n                ownerW = containerSize.width;\n                ownerH = containerSize.height;\n\n                scrollbars = me.getScrollbarsNeeded(ownerW, ownerH, contentW, contentH);\n                state.overflowState = scrollbars;\n\n                if (typeof dimensions == 'number') {\n                    scrollbars &= ~dimensions; // ignore dimensions that have no effect\n                }\n\n                overflowAdjust = {\n                    width:  (xauto && (scrollbars & 2)) ? scrollbarSize.width : 0,\n                    height: (yauto && (scrollbars & 1)) ? scrollbarSize.height : 0\n                };\n\n                // We can have 0-sized scrollbars (new Mac OS) and so don't invalidate\n                // the layout unless this will change something...\n                if (overflowAdjust.width !== me.lastOverflowAdjust.width || overflowAdjust.height !== me.lastOverflowAdjust.height) {\n                    me.done = false;\n\n                    // we pass overflowAdjust and overflowState in as state for the next\n                    // cycle (these are discarded if one of our ownerCt's invalidates):\n                    ownerContext.invalidate({\n                        state: {\n                            overflowAdjust: overflowAdjust,\n                            overflowState: state.overflowState,\n                            secondPass: true\n                        }\n                    });\n                }\n            }\n        }\n\n        if (!me.done) {\n            return;\n        }\n\n        padElContext = ownerContext.padElContext ||\n                      (ownerContext.padElContext = ownerContext.getEl('overflowPadderEl', me));\n\n        // Even if overflow does not effect the layout, we still do need the padEl to be\n        // sized or hidden appropriately...\n        if (padElContext) {\n            scrollbars = state.overflowState; // the true overflow state\n            padWidth = containerSize.width;\n            padHeight = 0;//  TODO me.padHeightAdj; // 0 or 1\n\n            if (scrollbars) {\n                padding = ownerContext.targetContext.getPaddingInfo();\n                scrollRangeFlags = me.scrollRangeFlags;\n\n                if ((scrollbars & 2) && (scrollRangeFlags & 1)) { // if (vscroll and loses bottom)\n                    padHeight += padding.bottom;\n                }\n\n                if ((scrollbars & 1) && (scrollRangeFlags & 4)) { // if (hscroll and loses right)\n                    padWidth += padding.right;\n                }\n                padElContext.setProp('display', '');\n                padElContext.setSize(padWidth, padHeight);\n            } else {\n                padElContext.setProp('display', 'none');\n            }\n        }\n    },\n\n    /**\n     * Adds layout's itemCls and owning Container's itemCls\n     * @protected\n     */\n    configureItem: function(item) {\n        var me = this,\n            ownerItemCls = me.owner.itemCls,\n            addClasses = [].concat(me.itemCls || []);\n\n        me.callParent(arguments);\n\n        if (ownerItemCls) {\n            addClasses = Ext.Array.push(addClasses, ownerItemCls);\n        }\n        item.addCls(addClasses);\n    },\n\n    doRenderBody: function (out, renderData) {\n        // Careful! This method is bolted on to the renderTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the renderTpl instance!\n\n        this.renderItems(out, renderData);\n        this.renderContent(out, renderData);\n    },\n\n    doRenderContainer: function (out, renderData) {\n        // Careful! This method is bolted on to the renderTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the renderTpl instance!\n\n        var me = renderData.$comp.layout,\n            tpl = me.getRenderTpl(),\n            data = me.getRenderData();\n\n        tpl.applyOut(data, out);\n    },\n\n    doRenderItems: function (out, renderData) {\n        // Careful! This method is bolted on to the renderTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the renderTpl instance!\n\n        var me = renderData.$layout,\n            tree = me.getRenderTree();\n\n        if (tree) {\n            Ext.DomHelper.generateMarkup(tree, out);\n        }\n    },\n\n    /**\n     * Creates an element that makes bottom/right body padding consistent across browsers.\n     * This element is sized based on the need for scrollbars in {@link #calculateOverflow}.\n     * If the {@link #manageOverflow} option is false, this element is not created.\n     *\n     * See {@link #getScrollRangeFlags} for more details.\n     */\n    doRenderPadder: function (out, renderData) {\n        // Careful! This method is bolted on to the renderTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the renderTpl instance!\n\n        var me = renderData.$layout,\n            owner = me.owner,\n            scrollRangeFlags = me.getScrollRangeFlags();\n\n        if (me.manageOverflow == 2) {\n            if (scrollRangeFlags & 5) { // if (loses parent bottom and/or right padding)\n                out.push('<div id=\"',owner.id,'-overflowPadderEl\" ',\n                    'style=\"font-size: 1px; width:1px; height: 1px;');\n\n                // We won't want the height of the padder to cause problems when we only\n                // want to adjust for right padding, so we relatively position it up 1px so\n                // its height of 1px will have no vertical effect. This trick does not work\n                // on IE due to bugs (the effects are worse than the off-by-1px in scroll\n                // height).\n                //\n                /* turns out this does not work on FF (5) either... TODO\n                if (Ext.isIE || Ext.isGecko) {\n                    me.padHeightAdj = 0;\n                } else {\n                    me.padHeightAdj = 1;\n                    out.push('position: relative; top: -1px;');\n                }/**/\n\n                out.push('\"></div>');\n\n                me.scrollRangeFlags = scrollRangeFlags; // remember for calculateOverflow\n            }\n        }\n    }, \n\n    finishRender: function () {\n        var me = this,\n            target, items;\n\n        me.callParent();\n\n        me.cacheElements();\n\n        target = me.getRenderTarget();\n        items = me.getLayoutItems();\n\n        if (me.targetCls) {\n            me.getTarget().addCls(me.targetCls);\n        }\n\n        me.finishRenderItems(target, items);\n    },\n\n    /**\n     * @private\n     * Called for every layout in the layout context after all the layouts have been finally flushed\n     */\n    notifyOwner: function() {\n        this.owner.afterLayout(this);\n    },\n\n    /**\n     * Returns the container size (that of the target). Only the fixed-sized dimensions can\n     * be returned because the shrinkWrap dimensions are based on the contentWidth/Height\n     * as determined by the container layout.\n     *\n     * If the {@link #calculateOverflow} method is used and if {@link #manageOverflow} is\n     * true, this may adjust the width/height by the size of scrollbars.\n     * \n     * @param {Ext.layout.ContextItem} ownerContext The owner's context item.\n     * @param {Boolean} [inDom=false] True if the container size must be in the DOM.\n     * @return {Object} The size\n     * @return {Number} return.width The width\n     * @return {Number} return.height The height\n     * @protected\n     */\n    getContainerSize : function(ownerContext, inDom) {\n        // Subtle But Important:\n        // \n        // We don't want to call getProp/hasProp et.al. unless we in fact need that value\n        // for our results! If we call it and don't need it, the layout manager will think\n        // we depend on it and will schedule us again should it change.\n\n        var targetContext = ownerContext.targetContext,\n            frameInfo = targetContext.getFrameInfo(),\n            padding = targetContext.getPaddingInfo(),\n            got = 0,\n            needed = 0,\n            overflowAdjust = ownerContext.state.overflowAdjust,\n            gotWidth, gotHeight, width, height;\n\n        // In an shrinkWrap width/height case, we must not ask for any of these dimensions\n        // because they will be determined by contentWidth/Height which is calculated by\n        // this layout...\n\n        // Fit/Card layouts are able to set just the width of children, allowing child's\n        // resulting height to autosize the Container.\n        // See examples/tabs/tabs.html for an example of this.\n\n        if (!ownerContext.widthModel.shrinkWrap) {\n            ++needed;\n            width = inDom ? targetContext.getDomProp('width') : targetContext.getProp('width');\n            gotWidth = (typeof width == 'number');\n            if (gotWidth) {\n                ++got;\n                width -= frameInfo.width + padding.width;\n                if (overflowAdjust) {\n                    width -= overflowAdjust.width;\n                }\n            }\n        }\n\n        if (!ownerContext.heightModel.shrinkWrap) {\n            ++needed;\n            height = inDom ? targetContext.getDomProp('height') : targetContext.getProp('height');\n            gotHeight = (typeof height == 'number');\n            if (gotHeight) {\n                ++got;\n                height -= frameInfo.height + padding.height;\n                if (overflowAdjust) {\n                    height -= overflowAdjust.height;\n                }\n            }\n        }\n\n        return {\n            width: width,\n            height: height,\n            needed: needed,\n            got: got,\n            gotAll: got == needed,\n            gotWidth: gotWidth,\n            gotHeight: gotHeight\n        };\n    },\n\n    /**\n     * Returns an array of child components either for a render phase (Performed in the beforeLayout\n     * method of the layout's base class), or the layout phase (onLayout).\n     * @return {Ext.Component[]} of child components\n     */\n    getLayoutItems: function() {\n        var owner = this.owner,\n            items = owner && owner.items;\n\n        return (items && items.items) || [];\n    },\n\n    getRenderData: function () {\n        var comp = this.owner;\n\n        return {\n            $comp: comp,\n            $layout: this,\n            ownerId: comp.id\n        };\n    },\n\n    /**\n     * @protected\n     * Returns all items that are rendered\n     * @return {Array} All matching items\n     */\n    getRenderedItems: function() {\n        var me = this,\n            target = me.getRenderTarget(),\n            items = me.getLayoutItems(),\n            ln = items.length,\n            renderedItems = [],\n            i, item;\n\n        for (i = 0; i < ln; i++) {\n            item = items[i];\n            if (item.rendered && me.isValidParent(item, target, i)) {\n                renderedItems.push(item);\n            }\n        }\n\n        return renderedItems;\n    },\n\n    /**\n     * Returns the element into which rendering must take place. Defaults to the owner Container's\n     * target element.\n     *\n     * May be overridden in layout managers which implement an inner element.\n     *\n     * @return {Ext.Element}\n     */\n    getRenderTarget: function() {\n        return this.owner.getTargetEl();\n    },\n\n    /**\n     * Returns the element into which extra functional DOM elements can be inserted. Defaults to the owner Component's encapsulating element.\n     *\n     * May be overridden in Component layout managers which implement a {@link #getRenderTarget component render target} which must only\n     * contain child components.\n     * @return {Ext.Element}\n     */\n    getElementTarget: function() {\n        return this.getRenderTarget();\n    },\n\n    getRenderTpl: function () {\n        var me = this,\n            renderTpl = Ext.XTemplate.getTpl(this, 'renderTpl');\n\n        // Make sure all standard callout methods for the owner component are placed on the\n        // XTemplate instance (but only once please):\n        if (!renderTpl.renderContent) {\n            me.owner.setupRenderTpl(renderTpl);\n        }\n\n        return renderTpl;\n    },\n\n    getRenderTree: function () {\n        var result,\n            items = this.owner.items,\n            itemsGen,\n            renderCfgs = {};\n        \n        do {\n            itemsGen = items.generation;\n            result = this.getItemsRenderTree(this.getLayoutItems(), renderCfgs);\n        } while (items.generation !== itemsGen);\n        return result;\n    },\n\n    getScrollbarsNeeded: function (width, height, contentWidth, contentHeight) {\n        var scrollbarSize = Ext.getScrollbarSize(),\n            hasWidth = typeof width == 'number',\n            hasHeight = typeof height == 'number',\n            needHorz = 0,\n            needVert = 0;\n\n        // No space-consuming scrollbars.\n        if (!scrollbarSize.width) {\n            return 0;\n        }\n        if (hasHeight && height < contentHeight) {\n            needVert = 2;\n            width -= scrollbarSize.width;\n        }\n\n        if (hasWidth && width < contentWidth) {\n            needHorz = 1;\n            if (!needVert && hasHeight) {\n                height -= scrollbarSize.height;\n                if (height < contentHeight) {\n                    needVert = 2;\n                }\n            }\n        }\n\n        return needVert + needHorz;\n    },\n\n    /**\n     * Returns flags indicating cross-browser handling of scrollHeight/Width. In particular,\n     * IE has issues with padding-bottom in a scrolling element (it does not include that\n     * padding in the scrollHeight). Also, margin-bottom on a child in a scrolling element\n     * can be lost.\n     * \n     * All browsers seem to ignore margin-right on children and padding-right on the parent\n     * element (the one with the overflow)\n     * \n     * This method returns a number with the follow bit positions set based on things not\n     * accounted for in scrollHeight and scrollWidth:\n     *\n     *  - 1: Scrolling element's padding-bottom is not included in scrollHeight.\n     *  - 2: Last child's margin-bottom is not included in scrollHeight.\n     *  - 4: Scrolling element's padding-right is not included in scrollWidth.\n     *  - 8: Child's margin-right is not included in scrollWidth.\n     *\n     * To work around the margin-bottom issue, it is sufficient to create a 0px tall last\n     * child that will \"hide\" the margin. This can also be handled by wrapping the children\n     * in an element, again \"hiding\" the margin. Wrapping the elements is about the only\n     * way to preserve their right margins. This is the strategy used by Column layout.\n     *\n     * To work around the padding-bottom problem, since it is comes from a style on the\n     * parent element, about the only simple fix is to create a last child with height\n     * equal to padding-bottom. To preserve the right padding, the sizing element needs to\n     * have a width that includes the right padding.\n     */\n    getScrollRangeFlags: (function () {\n        var flags = -1;\n\n        return function () {\n            if (flags < 0) {\n                var div = Ext.getBody().createChild({\n                        //cls: 'x-border-box x-hide-offsets',\n                        cls: Ext.baseCSSPrefix + 'border-box',\n                        style: {\n                            width: '100px', height: '100px', padding: '10px',\n                            overflow: 'auto'\n                        },\n                        children: [{\n                            style: {\n                                border: '1px solid red',\n                                width: '150px', height: '150px',\n                                margin: '0 5px 5px 0' // TRBL\n                            }\n                        }]\n                    }),\n                    scrollHeight = div.dom.scrollHeight,\n                    scrollWidth = div.dom.scrollWidth,\n                    heightFlags = {\n                        // right answer, nothing missing:\n                        175: 0,\n                        // missing parent padding-bottom:\n                        165: 1,\n                        // missing child margin-bottom:\n                        170: 2,\n                        // missing both\n                        160: 3\n                    },\n                    widthFlags = {\n                        // right answer, nothing missing:\n                        175: 0,\n                        // missing parent padding-right:\n                        165: 4,\n                        // missing child margin-right:\n                        170: 8,\n                        // missing both\n                        160: 12\n                    };\n\n                flags = (heightFlags[scrollHeight] || 0) | (widthFlags[scrollWidth] || 0);\n                //Ext.log('flags=',flags.toString(2));\n                div.remove();\n            }\n\n            return flags;\n        };\n    }()),\n\n    /**\n     * Returns the owner component's resize element.\n     * @return {Ext.Element}\n     */\n    getTarget: function() {\n        return this.owner.getTargetEl();\n    },\n\n    /**\n     * @protected\n     * Returns all items that are both rendered and visible\n     * @return {Array} All matching items\n     */\n    getVisibleItems: function() {\n        var target   = this.getRenderTarget(),\n            items = this.getLayoutItems(),\n            ln = items.length,\n            visibleItems = [],\n            i, item;\n\n        for (i = 0; i < ln; i++) {\n            item = items[i];\n            if (item.rendered && this.isValidParent(item, target, i) && item.hidden !== true) {\n                visibleItems.push(item);\n            }\n        }\n\n        return visibleItems;\n    },\n\n    setupRenderTpl: function (renderTpl) {\n        var me = this;\n\n        renderTpl.renderBody = me.doRenderBody;\n        renderTpl.renderContainer = me.doRenderContainer;\n        renderTpl.renderItems = me.doRenderItems;\n        renderTpl.renderPadder = me.doRenderPadder;\n    }\n});\n\n/**\n * Component layout for editors\n * @private\n */\nExt.define('Ext.layout.container.Editor', {\n\n    /* Begin Definitions */\n\n    alias: 'layout.editor',\n\n    extend: 'Ext.layout.container.Container',\n\n    /* End Definitions */\n\n    autoSizeDefault: {\n        width: 'field',\n        height: 'field'    \n    },\n\n    getItemSizePolicy: function (item) {\n        var me = this,\n            autoSize = me.owner.autoSize;\n\n        return me.sizePolicy || (me.sizePolicy = {\n            setsWidth:  autoSize && autoSize.width  === 'boundEl' ? 1 : 0,\n            setsHeight: autoSize && autoSize.height === 'boundEl' ? 1 : 0\n        });\n    },\n\n    calculate: function(ownerContext) {\n        var me = this,\n            owner = me.owner,\n            autoSize = owner.autoSize,\n            fieldWidth,\n            fieldHeight;\n            \n        if (autoSize === true) {\n            autoSize = me.autoSizeDefault;\n        }\n\n        // Calculate size of both Editor, and its owned Field\n        if (autoSize) {\n            fieldWidth  = me.getDimension(owner, autoSize.width,  'getWidth',  owner.width);\n            fieldHeight = me.getDimension(owner, autoSize.height, 'getHeight', owner.height);\n        }\n\n        // Set Field size\n        ownerContext.childItems[0].setSize(fieldWidth, fieldHeight);\n\n        // Bypass validity checking. Container layouts should not usually set their owner's size.\n        ownerContext.setWidth(fieldWidth);\n        ownerContext.setHeight(fieldHeight);\n\n        // This is a Container layout, so publish content size\n        ownerContext.setContentSize(fieldWidth || owner.field.getWidth(),\n                                    fieldHeight || owner.field.getHeight());\n    },\n\n    getDimension: function(owner, type, getMethod, ownerSize){\n        switch (type) {\n            // Size to boundEl's dimension\n            case 'boundEl':\n                return owner.boundEl[getMethod]();\n\n            // Auto size (shrink wrap the Field's size\n            case 'field':\n                return undefined;\n\n            // Size to the Editor's configured size\n            default:\n                return ownerSize;\n        }\n    }\n});\n\n/**\n * This class is intended to be extended or created via the {@link Ext.Component#componentLayout layout}\n * configuration property.  See {@link Ext.Component#componentLayout} for additional details.\n * @private\n */\nExt.define('Ext.layout.component.Component', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.layout.Layout',\n\n    /* End Definitions */\n\n    type: 'component',\n\n    isComponentLayout: true,\n\n    nullBox: {},\n\n    usesContentHeight: true,\n    usesContentWidth: true,\n    usesHeight: true,\n    usesWidth: true,\n\n    beginLayoutCycle: function (ownerContext, firstCycle) {\n        var me = this,\n            owner = me.owner,\n            ownerCtContext = ownerContext.ownerCtContext,\n            heightModel = ownerContext.heightModel,\n            widthModel = ownerContext.widthModel,\n            body = owner.el.dom === document.body,\n            lastBox = owner.lastBox || me.nullBox,\n            lastSize = owner.el.lastBox || me.nullBox,\n            dirty = !body,\n            ownerLayout, v, widthName, heightName;\n\n        me.callParent(arguments);\n\n        if (firstCycle) {\n            if (me.usesContentWidth) {\n                ++ownerContext.consumersContentWidth;\n            }\n            if (me.usesContentHeight) {\n                ++ownerContext.consumersContentHeight;\n            }\n            if (me.usesWidth) {\n                ++ownerContext.consumersWidth;\n            }\n            if (me.usesHeight) {\n                ++ownerContext.consumersHeight;\n            }\n\n            if (ownerCtContext && !ownerCtContext.hasRawContent) {\n                ownerLayout = owner.ownerLayout;\n\n                if (ownerLayout.usesWidth) {\n                    ++ownerContext.consumersWidth;\n                }\n                if (ownerLayout.usesHeight) {\n                    ++ownerContext.consumersHeight;\n                }\n            }\n        }\n\n        // we want to publish configured dimensions as early as possible and since this is\n        // a write phase...\n\n        if (widthModel.configured) {\n            // If the owner.el is the body, owner.width is not dirty (we don't want to write\n            // it to the body el). For other el's, the width may already be correct in the\n            // DOM (e.g., it is rendered in the markup initially). If the width is not\n            // correct in the DOM, this is only going to be the case on the first cycle.\n            widthName = widthModel.names.width;\n\n            if (!body) {\n                dirty = firstCycle ? owner[widthName] !== lastSize.width\n                                   : widthModel.constrained;\n            }\n            \n            ownerContext.setWidth(owner[widthName], dirty);\n        } else if (ownerContext.isTopLevel) {\n            if (widthModel.calculated) {\n                v = lastBox.width;\n                ownerContext.setWidth(v, /*dirty=*/v != lastSize.width);\n            }\n\n            v = lastBox.x;\n            ownerContext.setProp('x', v, /*dirty=*/v != lastSize.x);\n        }\n\n        if (heightModel.configured) {\n            heightName = heightModel.names.height;\n\n            if (!body) {\n                dirty = firstCycle ? owner[heightName] !== lastSize.height\n                                   : heightModel.constrained;\n            }\n\n            ownerContext.setHeight(owner[heightName], dirty);\n        } else if (ownerContext.isTopLevel) {\n            if (heightModel.calculated) {\n                v = lastBox.height;\n                ownerContext.setHeight(v, v != lastSize.height);\n            }\n\n            v = lastBox.y;\n            ownerContext.setProp('y', v, /*dirty=*/v != lastSize.y);\n        }\n    },\n\n    finishedLayout: function(ownerContext) {\n        var me = this,\n            elementChildren = ownerContext.children,\n            owner = me.owner,\n            len, i, elContext, lastBox, props, v;\n\n        // NOTE: In the code below we cannot use getProp because that will generate a layout dependency\n\n        // Set lastBox on managed child Elements.\n        // So that ContextItem.constructor can snag the lastBox for use by its undo method.\n        if (elementChildren) {\n            len = elementChildren.length;\n            for (i = 0; i < len; i++) {\n                elContext = elementChildren[i];\n                elContext.el.lastBox = elContext.props;\n            }\n        }\n\n        // Cache the size from which we are changing so that notifyOwner can notify the owningComponent with all essential information\n        ownerContext.previousSize = me.lastComponentSize;\n\n        // Cache the currently layed out size\n        me.lastComponentSize = owner.el.lastBox = props = ownerContext.props;\n\n        // lastBox is a copy of the defined props to allow save/restore of these (panel\n        // collapse needs this)\n        owner.lastBox = lastBox = {};\n\n        v = props.x;\n        if (v !== undefined) {\n            lastBox.x = v;\n        }\n        v = props.y;\n        if (v !== undefined) {\n            lastBox.y = v;\n        }\n        v = props.width;\n        if (v !== undefined) {\n            lastBox.width = v;\n        }\n        v = props.height;\n        if (v !== undefined) {\n            lastBox.height = v;\n        }\n\n        me.callParent(arguments);\n    },\n    \n    notifyOwner: function(ownerContext) {\n        var me = this,\n            currentSize = me.lastComponentSize,\n            prevSize = ownerContext.previousSize,\n            args = [currentSize.width, currentSize.height];\n\n        if (prevSize) {\n            args.push(prevSize.width, prevSize.height);\n        }\n\n        // Call afterComponentLayout passing new size, and only passing old size if there *was* an old size.\n        me.owner.afterComponentLayout.apply(me.owner, args);\n    },\n\n    /**\n     * Returns the owner component's resize element.\n     * @return {Ext.Element}\n     */\n    getTarget : function() {\n        return this.owner.el;\n    },\n\n    /**\n     * Returns the element into which rendering must take place. Defaults to the owner Component's encapsulating element.\n     *\n     * May be overridden in Component layout managers which implement an inner element.\n     * @return {Ext.Element}\n     */\n    getRenderTarget : function() {\n        return this.owner.el;\n    },\n\n    cacheTargetInfo: function(ownerContext) {\n        var me = this,\n            targetInfo = me.targetInfo,\n            target;\n\n        if (!targetInfo) {\n            target = ownerContext.getEl('getTarget', me);\n\n            me.targetInfo = targetInfo = {\n                padding: target.getPaddingInfo(),\n                border: target.getBorderInfo()\n            };\n        }\n\n        return targetInfo;\n    },\n\n    measureAutoDimensions: function (ownerContext, dimensions) {\n        // Subtle But Important:\n        // \n        // We don't want to call getProp/hasProp et.al. unless we in fact need that value\n        // for our results! If we call it and don't need it, the layout manager will think\n        // we depend on it and will schedule us again should it change.\n\n        var me = this,\n            owner = me.owner,\n            containerLayout = owner.layout,\n            heightModel = ownerContext.heightModel,\n            widthModel = ownerContext.widthModel,\n            boxParent = ownerContext.boxParent,\n            isBoxParent = ownerContext.isBoxParent,\n            props = ownerContext.props,\n            isContainer,\n            ret = {\n                gotWidth: false,\n                gotHeight: false,\n                isContainer: (isContainer = !ownerContext.hasRawContent)\n            },\n            hv = dimensions || 3,\n            zeroWidth, zeroHeight,\n            needed = 0,\n            got = 0,\n            ready, size, temp;\n\n        // Note: this method is called *a lot*, so we have to be careful not to waste any\n        // time or make useless calls or, especially, read the DOM when we can avoid it.\n\n        //---------------------------------------------------------------------\n        // Width\n\n        if (widthModel.shrinkWrap && ownerContext.consumersContentWidth) {\n            ++needed;\n            zeroWidth = !(hv & 1);\n\n            if (isContainer) {\n                // as a componentLayout for a container, we rely on the container layout to\n                // produce contentWidth...\n                if (zeroWidth) {\n                    ret.contentWidth = 0;\n                    ret.gotWidth = true;\n                    ++got;\n                } else if ((ret.contentWidth = ownerContext.getProp('contentWidth')) !== undefined) {\n                    ret.gotWidth = true;\n                    ++got;\n                }\n            } else {\n                size = props.contentWidth;\n\n                if (typeof size == 'number') { // if (already determined)\n                    ret.contentWidth = size;\n                    ret.gotWidth = true;\n                    ++got;\n                } else {\n                    if (zeroWidth) {\n                        ready = true;\n                    } else if (!ownerContext.hasDomProp('containerChildrenDone')) {\n                        ready = false;\n                    } else if (isBoxParent || !boxParent || boxParent.widthModel.shrinkWrap) {\n                        // if we have no boxParent, we are ready, but a shrinkWrap boxParent\n                        // artificially provides width early in the measurement process so\n                        // we are ready to go in that case as well...\n                        ready = true;\n                    } else {\n                        // lastly, we have a boxParent that will be given a width, so we\n                        // can wait for that width to be set in order to properly measure\n                        // whatever is inside...\n                        ready = boxParent.hasDomProp('width');\n                    }\n\n                    if (ready) {\n                        if (zeroWidth) {\n                            temp = 0;\n                        } else if (containerLayout && containerLayout.measureContentWidth) {\n                            // Allow the container layout to do the measurement since it\n                            // may have a better idea of how to do it even with no items:\n                            temp = containerLayout.measureContentWidth(ownerContext);\n                        } else {\n                            temp = me.measureContentWidth(ownerContext);\n                        }\n\n                        if (!isNaN(ret.contentWidth = temp)) {\n                            ownerContext.setContentWidth(temp, true);\n                            ret.gotWidth = true;\n                            ++got;\n                        }\n                    }\n                }\n            }\n        } else if (widthModel.natural && ownerContext.consumersWidth) {\n            ++needed;\n            size = props.width;\n            // zeroWidth does not apply\n\n            if (typeof size == 'number') { // if (already determined)\n                ret.width = size;\n                ret.gotWidth = true;\n                ++got;\n            } else {\n                if (isBoxParent || !boxParent) {\n                    ready = true;\n                } else {\n                    // lastly, we have a boxParent that will be given a width, so we\n                    // can wait for that width to be set in order to properly measure\n                    // whatever is inside...\n                    ready = boxParent.hasDomProp('width');\n                }\n\n                if (ready) {\n                    if (!isNaN(ret.width = me.measureOwnerWidth(ownerContext))) {\n                        ownerContext.setWidth(ret.width, false);\n                        ret.gotWidth = true;\n                        ++got;\n                    }\n                }\n            }\n        }\n\n        //---------------------------------------------------------------------\n        // Height\n\n        if (heightModel.shrinkWrap && ownerContext.consumersContentHeight) {\n            ++needed;\n            zeroHeight = !(hv & 2);\n\n            if (isContainer) {\n                // don't ask unless we need to know...\n                if (zeroHeight) {\n                    ret.contentHeight = 0;\n                    ret.gotHeight = true;\n                    ++got;\n                } else if ((ret.contentHeight = ownerContext.getProp('contentHeight')) !== undefined) {\n                    ret.gotHeight = true;\n                    ++got;\n                }\n            } else {\n                size = props.contentHeight;\n\n                if (typeof size == 'number') { // if (already determined)\n                    ret.contentHeight = size;\n                    ret.gotHeight = true;\n                    ++got;\n                } else {\n                    if (zeroHeight) {\n                        ready = true;\n                    } else if (!ownerContext.hasDomProp('containerChildrenDone')) {\n                        ready = false;\n                    } else if (owner.noWrap) {\n                        ready = true;\n                    } else if (!widthModel.shrinkWrap) {\n                        // fixed width, so we need the width to determine the height...\n                        ready = (ownerContext.bodyContext || ownerContext).hasDomProp('width');// && (!ownerContext.bodyContext || ownerContext.bodyContext.hasDomProp('width'));\n                    } else if (isBoxParent || !boxParent || boxParent.widthModel.shrinkWrap) {\n                        // if we have no boxParent, we are ready, but an autoWidth boxParent\n                        // artificially provides width early in the measurement process so\n                        // we are ready to go in that case as well...\n                        ready = true;\n                    } else {\n                        // lastly, we have a boxParent that will be given a width, so we\n                        // can wait for that width to be set in order to properly measure\n                        // whatever is inside...\n                        ready = boxParent.hasDomProp('width');\n                    }\n\n                    if (ready) {\n                        if (zeroHeight) {\n                            temp = 0;\n                        } else if (containerLayout && containerLayout.measureContentHeight) {\n                            // Allow the container layout to do the measurement since it\n                            // may have a better idea of how to do it even with no items:\n                            temp = containerLayout.measureContentHeight(ownerContext);\n                        } else {\n                            temp = me.measureContentHeight(ownerContext);\n                        }\n\n                        if (!isNaN(ret.contentHeight = temp)) {\n                            ownerContext.setContentHeight(temp, true);\n                            ret.gotHeight = true;\n                            ++got;\n                        }\n                    }\n                }\n            }\n        } else if (heightModel.natural && ownerContext.consumersHeight) {\n            ++needed;\n            size = props.height;\n            // zeroHeight does not apply\n\n            if (typeof size == 'number') { // if (already determined)\n                ret.height = size;\n                ret.gotHeight = true;\n                ++got;\n            } else {\n                if (isBoxParent || !boxParent) {\n                    ready = true;\n                } else {\n                    // lastly, we have a boxParent that will be given a width, so we\n                    // can wait for that width to be set in order to properly measure\n                    // whatever is inside...\n                    ready = boxParent.hasDomProp('width');\n                }\n\n                if (ready) {\n                    if (!isNaN(ret.height = me.measureOwnerHeight(ownerContext))) {\n                        ownerContext.setHeight(ret.height, false);\n                        ret.gotHeight = true;\n                        ++got;\n                    }\n                }\n            }\n        }\n\n        if (boxParent) {\n            ownerContext.onBoxMeasured();\n        }\n\n        ret.gotAll = got == needed;\n        // see if we can avoid calling this method by storing something on ownerContext.\n        return ret;\n    },\n\n    measureContentWidth: function (ownerContext) {\n        // contentWidth includes padding, but not border, framing or margins\n        return ownerContext.el.getWidth() - ownerContext.getFrameInfo().width;\n    },\n\n    measureContentHeight: function (ownerContext) {\n        // contentHeight includes padding, but not border, framing or margins\n        return ownerContext.el.getHeight() - ownerContext.getFrameInfo().height;\n    },\n\n    measureOwnerHeight: function (ownerContext) {\n        return ownerContext.el.getHeight();\n    },\n\n    measureOwnerWidth: function (ownerContext) {\n        return ownerContext.el.getWidth();\n    }\n});\n\n/**\n * The class is the default component layout for {@link Ext.Component} when no explicit\n * `{@link Ext.Component#componentLayout componentLayout}` is configured.\n *\n * This class uses template methods to perform the individual aspects of measurement,\n * calculation and publication of results. The methods called depend on the component's\n * {@link Ext.AbstractComponent#getSizeModel size model}.\n * \n * ## configured / calculated\n *\n * In either of these size models, the dimension of the outer element is of a known size.\n * The size is found in the `ownerContext` (the {@link Ext.layout.ContextItem} for the owner\n * component) as either \"width\" or \"height\". This value, if available, is passed to the\n * `publishInnerWidth` or `publishInnerHeight` method, respectively.\n * \n * ## shrinkWrap\n *\n * When a dimension uses the `shrinkWrap` size model, that means the content is measured,\n * then the outer (owner) size is calculated and published.\n * \n * For example, for a shrinkWrap width, the following sequence of calls are made:\n * \n * - `Ext.layout.component.Component#measureContentWidth`\n * - `publishOwnerWidth`\n *    - `calculateOwnerWidthFromContentWidth`\n *    - `publishInnerWidth` (in the event of hitting a min/maxWidth constraint)\n *\n * ## natural\n *\n * When a dimension uses the `natural` size model, the measurement is made on the outer\n * (owner) element. This size is then used to determine the content area in much the same\n * way as if the outer element had a `configured` or `calculated` size model.\n * \n * - `Ext.layout.component.Component#measureOwnerWidth`\n * - `publishInnerWidth`\n *\n * @protected\n */\nExt.define('Ext.layout.component.Auto', {\n\n    /* Begin Definitions */\n\n    alias: 'layout.autocomponent',\n\n    extend: 'Ext.layout.component.Component',\n\n    /* End Definitions */\n\n    type: 'autocomponent',\n\n    /**\n     * @cfg {Boolean} [setHeightInDom=false]\n     * @protected\n     * When publishing height of an auto Component, it is usually not written to the DOM.\n     * Setting this to `true` overrides this behaviour.\n     */\n    setHeightInDom: false,\n\n    /**\n     * @cfg {Boolean} [setWidthInDom=false]\n     * @protected\n     * When publishing width of an auto Component, it is usually not written to the DOM.\n     * Setting this to `true` overrides this behaviour.\n     */\n    setWidthInDom: false,\n\n    waitForOuterHeightInDom: false,\n    waitForOuterWidthInDom: false,\n    \n    beginLayoutCycle: function(ownerContext, firstCycle){\n        var me = this,\n            lastWidthModel = me.lastWidthModel,\n            lastHeightModel = me.lastHeightModel,\n            owner = me.owner;\n            \n        me.callParent(arguments);\n            \n        if (lastWidthModel && lastWidthModel.fixed && ownerContext.widthModel.shrinkWrap) {\n            owner.el.setWidth(null);\n        }\n            \n        if (lastHeightModel && lastHeightModel.fixed && ownerContext.heightModel.shrinkWrap) {\n            owner.el.setHeight(null);\n        }    \n    },\n\n    calculate: function(ownerContext) {\n        var me = this,\n            measurement = me.measureAutoDimensions(ownerContext),\n            heightModel = ownerContext.heightModel,\n            widthModel = ownerContext.widthModel,\n            width, height;\n\n        // It is generally important to process widths before heights, since widths can\n        // often effect heights...\n        if (measurement.gotWidth) {\n            if (widthModel.shrinkWrap) {\n                me.publishOwnerWidth(ownerContext, measurement.contentWidth);\n            } else if (me.publishInnerWidth) {\n                me.publishInnerWidth(ownerContext, measurement.width);\n            }\n        } else if (!widthModel.auto && me.publishInnerWidth) {\n            width = me.waitForOuterWidthInDom ? ownerContext.getDomProp('width')\n                        : ownerContext.getProp('width');\n            if (width === undefined) {\n                me.done = false;\n            } else {\n                me.publishInnerWidth(ownerContext, width);\n            }\n        }\n\n        if (measurement.gotHeight) {\n            if (heightModel.shrinkWrap) {\n                me.publishOwnerHeight(ownerContext, measurement.contentHeight);\n            } else if (me.publishInnerHeight) {\n                me.publishInnerHeight(ownerContext, measurement.height);\n            }\n        } else if (!heightModel.auto && me.publishInnerHeight) {\n            height = me.waitForOuterHeightInDom ? ownerContext.getDomProp('height')\n                        : ownerContext.getProp('height');\n            if (height === undefined) {\n                me.done = false;\n            } else {\n               me.publishInnerHeight(ownerContext, height);\n            }\n        }\n\n        if (!measurement.gotAll) {\n            me.done = false;\n        }\n    },\n\n    calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {\n        return contentHeight + ownerContext.getFrameInfo().height;\n    },\n\n    calculateOwnerWidthFromContentWidth: function (ownerContext, contentWidth) {\n        return contentWidth + ownerContext.getFrameInfo().width;\n    },\n\n    publishOwnerHeight: function (ownerContext, contentHeight) {\n        var me = this,\n            owner = me.owner,\n            height = me.calculateOwnerHeightFromContentHeight(ownerContext, contentHeight),\n            constrainedHeight, dirty, heightModel;\n\n        if (isNaN(height)) {\n            me.done = false;\n        } else {\n            constrainedHeight = Ext.Number.constrain(height, owner.minHeight, owner.maxHeight);\n\n            if (constrainedHeight == height) {\n                dirty = me.setHeightInDom;\n            } else {\n                heightModel = me.sizeModels[\n                    (constrainedHeight < height) ? 'constrainedMax' : 'constrainedMin'];\n                height = constrainedHeight;\n\n                if (ownerContext.heightModel.calculatedFromShrinkWrap) {\n                    // Don't bother to invalidate since that will come soon... but we need\n                    // to signal our ownerLayout that we need an invalidate to actually\n                    // make good on the determined (constrained) size!\n                    ownerContext.heightModel = heightModel;\n                } else {\n                    ownerContext.invalidate({ heightModel: heightModel });\n                }\n            }\n            \n            ownerContext.setHeight(height, dirty);\n        }\n    },\n\n    publishOwnerWidth: function (ownerContext, contentWidth) {\n        var me = this,\n            owner = me.owner,\n            width = me.calculateOwnerWidthFromContentWidth(ownerContext, contentWidth),\n            constrainedWidth, dirty, widthModel;\n\n        if (isNaN(width)) {\n            me.done = false;\n        } else {\n            constrainedWidth = Ext.Number.constrain(width, owner.minWidth, owner.maxWidth);\n\n            if (constrainedWidth == width) {\n                dirty = me.setWidthInDom;\n            } else {\n                widthModel = me.sizeModels[\n                    (constrainedWidth < width) ? 'constrainedMax' : 'constrainedMin'];\n                width = constrainedWidth;\n\n                if (ownerContext.widthModel.calculatedFromShrinkWrap) {\n                    // Don't bother to invalidate since that will come soon... but we need\n                    // to signal our ownerLayout that we need an invalidate to actually\n                    // make good on the determined (constrained) size!\n                    ownerContext.widthModel = widthModel;\n                } else {\n                    ownerContext.invalidate({ widthModel: widthModel });\n                }\n            }\n\n            ownerContext.setWidth(width, dirty);\n        }\n    }\n});\n\n/**\n * @class Ext.layout.container.Auto\n *\n * The AutoLayout is the default layout manager delegated by {@link Ext.container.Container} to\n * render any child Components when no `{@link Ext.container.Container#layout layout}` is configured into\n * a `{@link Ext.container.Container Container}.` AutoLayout provides only a passthrough of any layout calls\n * to any child containers.\n *\n *     @example\n *     Ext.create('Ext.Panel', {\n *         width: 500,\n *         height: 280,\n *         title: \"AutoLayout Panel\",\n *         layout: 'auto',\n *         renderTo: document.body,\n *         items: [{\n *             xtype: 'panel',\n *             title: 'Top Inner Panel',\n *             width: '75%',\n *             height: 90\n *         },\n *         {\n *             xtype: 'panel',\n *             title: 'Bottom Inner Panel',\n *             width: '75%',\n *             height: 90\n *         }]\n *     });\n */\nExt.define('Ext.layout.container.Auto', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.auto', 'layout.autocontainer'],\n\n    extend: 'Ext.layout.container.Container',\n\n    /* End Definitions */\n\n    type: 'autocontainer',\n\n    childEls: [\n        'clearEl'\n    ],\n\n    renderTpl: [\n        '{%this.renderBody(out,values)%}',\n        // clear element is needed to prevent the bottom margins of the last child element from collapsing\n        '<div id=\"{ownerId}-clearEl\" class=\"', Ext.baseCSSPrefix, 'clear\" role=\"presentation\"></div>'\n    ],\n\n    // TODO - do we need to clear sizes in beginLayout?\n\n    calculate: function(ownerContext) {\n        var me = this,\n            containerSize;\n\n        if (!ownerContext.hasDomProp('containerChildrenDone')) {\n            me.done = false;\n        } else {\n            // Once the child layouts are done we can determine the content sizes...\n            containerSize = me.getContainerSize(ownerContext);\n            if (!containerSize.gotAll) {\n                me.done = false;\n            }\n\n            me.calculateContentSize(ownerContext);\n        }\n    }\n});\n\n/**\n * Represents a filter that can be applied to a {@link Ext.util.MixedCollection MixedCollection}. Can either simply\n * filter on a property/value pair or pass in a filter function with custom logic. Filters are always used in the\n * context of MixedCollections, though {@link Ext.data.Store Store}s frequently create them when filtering and searching\n * on their records. Example usage:\n *\n *     //set up a fictional MixedCollection containing a few people to filter on\n *     var allNames = new Ext.util.MixedCollection();\n *     allNames.addAll([\n *         {id: 1, name: 'Ed',    age: 25},\n *         {id: 2, name: 'Jamie', age: 37},\n *         {id: 3, name: 'Abe',   age: 32},\n *         {id: 4, name: 'Aaron', age: 26},\n *         {id: 5, name: 'David', age: 32}\n *     ]);\n *\n *     var ageFilter = new Ext.util.Filter({\n *         property: 'age',\n *         value   : 32\n *     });\n *\n *     var longNameFilter = new Ext.util.Filter({\n *         filterFn: function(item) {\n *             return item.name.length > 4;\n *         }\n *     });\n *\n *     //a new MixedCollection with the 3 names longer than 4 characters\n *     var longNames = allNames.filter(longNameFilter);\n *\n *     //a new MixedCollection with the 2 people of age 32:\n *     var youngFolk = allNames.filter(ageFilter);\n *\n */\nExt.define('Ext.util.Filter', {\n\n    /* Begin Definitions */\n\n    /* End Definitions */\n    /**\n     * @cfg {String} property\n     * The property to filter on. Required unless a {@link #filterFn} is passed\n     */\n    \n    /**\n     * @cfg {Function} filterFn\n     * A custom filter function which is passed each item in the {@link Ext.util.MixedCollection} in turn. Should return\n     * true to accept each item or false to reject it\n     */\n    \n    /**\n     * @cfg {Boolean} anyMatch\n     * True to allow any match - no regex start/end line anchors will be added.\n     */\n    anyMatch: false,\n    \n    /**\n     * @cfg {Boolean} exactMatch\n     * True to force exact match (^ and $ characters added to the regex). Ignored if anyMatch is true.\n     */\n    exactMatch: false,\n    \n    /**\n     * @cfg {Boolean} caseSensitive\n     * True to make the regex case sensitive (adds 'i' switch to regex).\n     */\n    caseSensitive: false,\n    \n    /**\n     * @cfg {String} root\n     * Optional root property. This is mostly useful when filtering a Store, in which case we set the root to 'data' to\n     * make the filter pull the {@link #property} out of the data object of each item\n     */\n\n    /**\n     * Creates new Filter.\n     * @param {Object} [config] Config object\n     */\n    constructor: function(config) {\n        var me = this;\n        Ext.apply(me, config);\n        \n        //we're aliasing filter to filterFn mostly for API cleanliness reasons, despite the fact it dirties the code here.\n        //Ext.util.Sorter takes a sorterFn property but allows .sort to be called - we do the same here\n        me.filter = me.filter || me.filterFn;\n        \n        if (me.filter === undefined) {\n            if (me.property === undefined || me.value === undefined) {\n                // Commented this out temporarily because it stops us using string ids in models. TODO: Remove this once\n                // Model has been updated to allow string ids\n                \n                // Ext.Error.raise(\"A Filter requires either a property or a filterFn to be set\");\n            } else {\n                me.filter = me.createFilterFn();\n            }\n            \n            me.filterFn = me.filter;\n        }\n    },\n    \n    /**\n     * @private\n     * Creates a filter function for the configured property/value/anyMatch/caseSensitive options for this Filter\n     */\n    createFilterFn: function() {\n        var me       = this,\n            matcher  = me.createValueMatcher(),\n            property = me.property;\n        \n        return function(item) {\n            var value = me.getRoot.call(me, item)[property];\n            return matcher === null ? value === null : matcher.test(value);\n        };\n    },\n    \n    /**\n     * @private\n     * Returns the root property of the given item, based on the configured {@link #root} property\n     * @param {Object} item The item\n     * @return {Object} The root property of the object\n     */\n    getRoot: function(item) {\n        var root = this.root;\n        return root === undefined ? item : item[root];\n    },\n    \n    /**\n     * @private\n     * Returns a regular expression based on the given value and matching options\n     */\n    createValueMatcher : function() {\n        var me            = this,\n            value         = me.value,\n            anyMatch      = me.anyMatch,\n            exactMatch    = me.exactMatch,\n            caseSensitive = me.caseSensitive,\n            escapeRe      = Ext.String.escapeRegex;\n            \n        if (value === null) {\n            return value;\n        }\n        \n        if (!value.exec) { // not a regex\n            value = String(value);\n\n            if (anyMatch === true) {\n                value = escapeRe(value);\n            } else {\n                value = '^' + escapeRe(value);\n                if (exactMatch === true) {\n                    value += '$';\n                }\n            }\n            value = new RegExp(value, caseSensitive ? '' : 'i');\n         }\n         \n         return value;\n    }\n});\n\n/**\n * @class Ext.util.AbstractMixedCollection\n * @private\n */\nExt.define('Ext.util.AbstractMixedCollection', {\n    requires: ['Ext.util.Filter'],\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @property {Boolean} isMixedCollection\n     * `true` in this class to identify an object as an instantiated MixedCollection, or subclass thereof.\n     */\n    isMixedCollection: true,\n\n    /**\n     * @private Mutation counter which is incremented upon add and remove.\n     */\n    generation: 0,\n\n    constructor: function(allowFunctions, keyFn) {\n        var me = this;\n\n        me.items = [];\n        me.map = {};\n        me.keys = [];\n        me.length = 0;\n\n            /**\n             * @event clear\n             * Fires when the collection is cleared.\n             */\n\n            /**\n             * @event add\n             * Fires when an item is added to the collection.\n             * @param {Number} index The index at which the item was added.\n             * @param {Object} o The item added.\n             * @param {String} key The key associated with the added item.\n             */\n\n            /**\n             * @event replace\n             * Fires when an item is replaced in the collection.\n             * @param {String} key he key associated with the new added.\n             * @param {Object} old The item being replaced.\n             * @param {Object} new The new item.\n             */\n            /**\n             * @event remove\n             * Fires when an item is removed from the collection.\n             * @param {Object} o The item being removed.\n             * @param {String} key (optional) The key associated with the removed item.\n             */\n\n        me.allowFunctions = allowFunctions === true;\n\n        if (keyFn) {\n            me.getKey = keyFn;\n        }\n\n        me.mixins.observable.constructor.call(me);\n    },\n\n    /**\n     * @cfg {Boolean} allowFunctions Specify <code>true</code> if the {@link #addAll}\n     * function should add function references to the collection. Defaults to\n     * <code>false</code>.\n     */\n    allowFunctions : false,\n\n    /**\n     * Adds an item to the collection. Fires the {@link #event-add} event when complete.\n     *\n     * @param {String/Object} key The key to associate with the item, or the new item.\n     *\n     * If a {@link #getKey} implementation was specified for this MixedCollection,\n     * or if the key of the stored items is in a property called `id`,\n     * the MixedCollection will be able to *derive* the key for the new item.\n     * In this case just pass the new item in this parameter.\n     *\n     * @param {Object} [o] The item to add.\n     *\n     * @return {Object} The item added.\n     */\n    add : function(key, obj){\n        var me = this,\n            myObj = obj,\n            myKey = key,\n            old;\n\n        if (arguments.length == 1) {\n            myObj = myKey;\n            myKey = me.getKey(myObj);\n        }\n        if (typeof myKey != 'undefined' && myKey !== null) {\n            old = me.map[myKey];\n            if (typeof old != 'undefined') {\n                return me.replace(myKey, myObj);\n            }\n            me.map[myKey] = myObj;\n        }\n        me.generation++;\n        me.length++;\n        me.items.push(myObj);\n        me.keys.push(myKey);\n        if (me.hasListeners.add) {\n            me.fireEvent('add', me.length - 1, myObj, myKey);\n        }\n        return myObj;\n    },\n\n    /**\n      * MixedCollection has a generic way to fetch keys if you implement getKey.  The default implementation\n      * simply returns <b><code>item.id</code></b> but you can provide your own implementation\n      * to return a different value as in the following examples:<pre><code>\n// normal way\nvar mc = new Ext.util.MixedCollection();\nmc.add(someEl.dom.id, someEl);\nmc.add(otherEl.dom.id, otherEl);\n//and so on\n\n// using getKey\nvar mc = new Ext.util.MixedCollection();\nmc.getKey = function(el){\n   return el.dom.id;\n};\nmc.add(someEl);\nmc.add(otherEl);\n\n// or via the constructor\nvar mc = new Ext.util.MixedCollection(false, function(el){\n   return el.dom.id;\n});\nmc.add(someEl);\nmc.add(otherEl);\n     * </code></pre>\n     * @param {Object} item The item for which to find the key.\n     * @return {Object} The key for the passed item.\n     */\n    getKey : function(o){\n         return o.id;\n    },\n\n    /**\n     * Replaces an item in the collection. Fires the {@link #event-replace} event when complete.\n     * @param {String} key <p>The key associated with the item to replace, or the replacement item.</p>\n     * <p>If you supplied a {@link #getKey} implementation for this MixedCollection, or if the key\n     * of your stored items is in a property called <code><b>id</b></code>, then the MixedCollection\n     * will be able to <i>derive</i> the key of the replacement item. If you want to replace an item\n     * with one having the same key value, then just pass the replacement item in this parameter.</p>\n     * @param o {Object} o (optional) If the first parameter passed was a key, the item to associate\n     * with that key.\n     * @return {Object}  The new item.\n     */\n    replace : function(key, o){\n        var me = this,\n            old,\n            index;\n\n        if (arguments.length == 1) {\n            o = arguments[0];\n            key = me.getKey(o);\n        }\n        old = me.map[key];\n        if (typeof key == 'undefined' || key === null || typeof old == 'undefined') {\n             return me.add(key, o);\n        }\n        me.generation++;\n        index = me.indexOfKey(key);\n        me.items[index] = o;\n        me.map[key] = o;\n        if (me.hasListeners.replace) {\n            me.fireEvent('replace', key, old, o);\n        }\n        return o;\n    },\n\n    /**\n     * Adds all elements of an Array or an Object to the collection.\n     * @param {Object/Array} objs An Object containing properties which will be added\n     * to the collection, or an Array of values, each of which are added to the collection.\n     * Functions references will be added to the collection if <code>{@link #allowFunctions}</code>\n     * has been set to <code>true</code>.\n     */\n    addAll : function(objs){\n        var me = this,\n            i = 0,\n            args,\n            len,\n            key;\n\n        if (arguments.length > 1 || Ext.isArray(objs)) {\n            args = arguments.length > 1 ? arguments : objs;\n            for (len = args.length; i < len; i++) {\n                me.add(args[i]);\n            }\n        } else {\n            for (key in objs) {\n                if (objs.hasOwnProperty(key)) {\n                    if (me.allowFunctions || typeof objs[key] != 'function') {\n                        me.add(key, objs[key]);\n                    }\n                }\n            }\n        }\n    },\n\n    /**\n     * Executes the specified function once for every item in the collection.\n     * The function should return a boolean value.\n     * Returning false from the function will stop the iteration.\n     *\n     * @param {Function} fn The function to execute for each item.\n     * @param {Mixed} fn.item The collection item.\n     * @param {Number} fn.index The index of item.\n     * @param {Number} fn.len Total length of collection.\n     * @param {Object} scope (optional) The scope (<code>this</code> reference)\n     * in which the function is executed. Defaults to the current item in the iteration.\n     */\n    each : function(fn, scope){\n        var items = [].concat(this.items), // each safe for removal\n            i = 0,\n            len = items.length,\n            item;\n\n        for (; i < len; i++) {\n            item = items[i];\n            if (fn.call(scope || item, item, i, len) === false) {\n                break;\n            }\n        }\n    },\n\n    /**\n     * Executes the specified function once for every key in the collection, passing each\n     * key, and its associated item as the first two parameters.\n     * @param {Function} fn The function to execute for each item.\n     * @param {String} fn.key The key of collection item.\n     * @param {Mixed} fn.item The collection item.\n     * @param {Number} fn.index The index of item.\n     * @param {Number} fn.len Total length of collection.\n     * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the\n     * function is executed. Defaults to the browser window.\n     */\n    eachKey : function(fn, scope){\n        var keys = this.keys,\n            items = this.items,\n            i = 0,\n            len = keys.length;\n\n        for (; i < len; i++) {\n            fn.call(scope || window, keys[i], items[i], i, len);\n        }\n    },\n\n    /**\n     * Returns the first item in the collection which elicits a true return value from the\n     * passed selection function.\n     * @param {Function} fn The selection function to execute for each item.\n     * @param {Mixed} fn.item The collection item.\n     * @param {String} fn.key The key of collection item.\n     * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the\n     * function is executed. Defaults to the browser window.\n     * @return {Object} The first item in the collection which returned true from the selection\n     * function, or null if none was found.\n     */\n    findBy : function(fn, scope) {\n        var keys = this.keys,\n            items = this.items,\n            i = 0,\n            len = items.length;\n\n        for (; i < len; i++) {\n            if (fn.call(scope || window, items[i], keys[i])) {\n                return items[i];\n            }\n        }\n        return null;\n    },\n\n    find : function() {\n        if (Ext.isDefined(Ext.global.console)) {\n            Ext.global.console.warn('Ext.util.MixedCollection: find has been deprecated. Use findBy instead.');\n        }\n        return this.findBy.apply(this, arguments);\n    },\n\n    /**\n     * Inserts an item at the specified index in the collection. Fires the {@link #event-add} event when complete.\n     * @param {Number} index The index to insert the item at.\n     * @param {String} key The key to associate with the new item, or the item itself.\n     * @param {Object} o (optional) If the second parameter was a key, the new item.\n     * @return {Object} The item inserted.\n     */\n    insert : function(index, key, obj){\n        var me = this,\n            myKey = key,\n            myObj = obj;\n\n        if (arguments.length == 2) {\n            myObj = myKey;\n            myKey = me.getKey(myObj);\n        }\n        if (me.containsKey(myKey)) {\n            me.suspendEvents();\n            me.removeAtKey(myKey);\n            me.resumeEvents();\n        }\n        if (index >= me.length) {\n            return me.add(myKey, myObj);\n        }\n        me.generation++;\n        me.length++;\n        Ext.Array.splice(me.items, index, 0, myObj);\n        if (typeof myKey != 'undefined' && myKey !== null) {\n            me.map[myKey] = myObj;\n        }\n        Ext.Array.splice(me.keys, index, 0, myKey);\n        if (me.hasListeners.add) {\n            me.fireEvent('add', index, myObj, myKey);\n        }\n        return myObj;\n    },\n\n    /**\n     * Remove an item from the collection.\n     * @param {Object} o The item to remove.\n     * @return {Object} The item removed or false if no item was removed.\n     */\n    remove : function(o) {\n        this.generation++;\n        return this.removeAt(this.indexOf(o));\n    },\n\n    /**\n     * Remove all items in the passed array from the collection.\n     * @param {Array} items An array of items to be removed.\n     * @return {Ext.util.MixedCollection} this object\n     */\n    removeAll : function(items) {\n        items = [].concat(items);\n        var i, iLen = items.length;\n        for (i = 0; i < iLen; i++) {\n            this.remove(items[i]);\n        }\n\n        return this;\n    },\n\n    /**\n     * Remove an item from a specified index in the collection. Fires the {@link #event-remove} event when complete.\n     * @param {Number} index The index within the collection of the item to remove.\n     * @return {Object} The item removed or false if no item was removed.\n     */\n    removeAt : function(index) {\n        var me = this,\n            o,\n            key;\n\n        if (index < me.length && index >= 0) {\n            me.length--;\n            o = me.items[index];\n            Ext.Array.erase(me.items, index, 1);\n            key = me.keys[index];\n            if (typeof key != 'undefined') {\n                delete me.map[key];\n            }\n            Ext.Array.erase(me.keys, index, 1);\n            if (me.hasListeners.remove) {\n                me.fireEvent('remove', o, key);\n            }\n            me.generation++;\n            return o;\n        }\n        return false;\n    },\n\n    /**\n     * Removed an item associated with the passed key fom the collection.\n     * @param {String} key The key of the item to remove.\n     * @return {Object} The item removed or false if no item was removed.\n     */\n    removeAtKey : function(key){\n        return this.removeAt(this.indexOfKey(key));\n    },\n\n    /**\n     * Returns the number of items in the collection.\n     * @return {Number} the number of items in the collection.\n     */\n    getCount : function(){\n        return this.length;\n    },\n\n    /**\n     * Returns index within the collection of the passed Object.\n     * @param {Object} o The item to find the index of.\n     * @return {Number} index of the item. Returns -1 if not found.\n     */\n    indexOf : function(o){\n        return Ext.Array.indexOf(this.items, o);\n    },\n\n    /**\n     * Returns index within the collection of the passed key.\n     * @param {String} key The key to find the index of.\n     * @return {Number} index of the key.\n     */\n    indexOfKey : function(key){\n        return Ext.Array.indexOf(this.keys, key);\n    },\n\n    /**\n     * Returns the item associated with the passed key OR index.\n     * Key has priority over index.  This is the equivalent\n     * of calling {@link #getByKey} first, then if nothing matched calling {@link #getAt}.\n     * @param {String/Number} key The key or index of the item.\n     * @return {Object} If the item is found, returns the item.  If the item was not found, returns <code>undefined</code>.\n     * If an item was found, but is a Class, returns <code>null</code>.\n     */\n    get : function(key) {\n        var me = this,\n            mk = me.map[key],\n            item = mk !== undefined ? mk : (typeof key == 'number') ? me.items[key] : undefined;\n        return typeof item != 'function' || me.allowFunctions ? item : null; // for prototype!\n    },\n\n    /**\n     * Returns the item at the specified index.\n     * @param {Number} index The index of the item.\n     * @return {Object} The item at the specified index.\n     */\n    getAt : function(index) {\n        return this.items[index];\n    },\n\n    /**\n     * Returns the item associated with the passed key.\n     * @param {String/Number} key The key of the item.\n     * @return {Object} The item associated with the passed key.\n     */\n    getByKey : function(key) {\n        return this.map[key];\n    },\n\n    /**\n     * Returns true if the collection contains the passed Object as an item.\n     * @param {Object} o  The Object to look for in the collection.\n     * @return {Boolean} True if the collection contains the Object as an item.\n     */\n    contains : function(o){\n        return typeof this.map[this.getKey(o)] != 'undefined';\n    },\n\n    /**\n     * Returns true if the collection contains the passed Object as a key.\n     * @param {String} key The key to look for in the collection.\n     * @return {Boolean} True if the collection contains the Object as a key.\n     */\n    containsKey : function(key){\n        return typeof this.map[key] != 'undefined';\n    },\n\n    /**\n     * Removes all items from the collection.  Fires the {@link #event-clear} event when complete.\n     */\n    clear : function(){\n        var me = this;\n\n        me.length = 0;\n        me.items = [];\n        me.keys = [];\n        me.map = {};\n        me.generation++;\n        if (me.hasListeners.clear) {\n            me.fireEvent('clear');\n        }\n    },\n\n    /**\n     * Returns the first item in the collection.\n     * @return {Object} the first item in the collection..\n     */\n    first : function() {\n        return this.items[0];\n    },\n\n    /**\n     * Returns the last item in the collection.\n     * @return {Object} the last item in the collection..\n     */\n    last : function() {\n        return this.items[this.length - 1];\n    },\n\n    /**\n     * Collects all of the values of the given property and returns their sum\n     * @param {String} property The property to sum by\n     * @param {String} [root] 'root' property to extract the first argument from. This is used mainly when\n     * summing fields in records, where the fields are all stored inside the 'data' object\n     * @param {Number} [start=0] The record index to start at\n     * @param {Number} [end=-1] The record index to end at\n     * @return {Number} The total\n     */\n    sum: function(property, root, start, end) {\n        var values = this.extractValues(property, root),\n            length = values.length,\n            sum    = 0,\n            i;\n\n        start = start || 0;\n        end   = (end || end === 0) ? end : length - 1;\n\n        for (i = start; i <= end; i++) {\n            sum += values[i];\n        }\n\n        return sum;\n    },\n\n    /**\n     * Collects unique values of a particular property in this MixedCollection\n     * @param {String} property The property to collect on\n     * @param {String} root (optional) 'root' property to extract the first argument from. This is used mainly when\n     * summing fields in records, where the fields are all stored inside the 'data' object\n     * @param {Boolean} allowBlank (optional) Pass true to allow null, undefined or empty string values\n     * @return {Array} The unique values\n     */\n    collect: function(property, root, allowNull) {\n        var values = this.extractValues(property, root),\n            length = values.length,\n            hits   = {},\n            unique = [],\n            value, strValue, i;\n\n        for (i = 0; i < length; i++) {\n            value = values[i];\n            strValue = String(value);\n\n            if ((allowNull || !Ext.isEmpty(value)) && !hits[strValue]) {\n                hits[strValue] = true;\n                unique.push(value);\n            }\n        }\n\n        return unique;\n    },\n\n    /**\n     * @private\n     * Extracts all of the given property values from the items in the MC. Mainly used as a supporting method for\n     * functions like sum and collect.\n     * @param {String} property The property to extract\n     * @param {String} root (optional) 'root' property to extract the first argument from. This is used mainly when\n     * extracting field data from Model instances, where the fields are stored inside the 'data' object\n     * @return {Array} The extracted values\n     */\n    extractValues: function(property, root) {\n        var values = this.items;\n\n        if (root) {\n            values = Ext.Array.pluck(values, root);\n        }\n\n        return Ext.Array.pluck(values, property);\n    },\n\n    /**\n     * Returns a range of items in this collection\n     * @param {Number} startIndex (optional) The starting index. Defaults to 0.\n     * @param {Number} endIndex (optional) The ending index. Defaults to the last item.\n     * @return {Array} An array of items\n     */\n    getRange : function(start, end){\n        var me = this,\n            items = me.items,\n            range = [],\n            i;\n\n        if (items.length < 1) {\n            return range;\n        }\n\n        start = start || 0;\n        end = Math.min(typeof end == 'undefined' ? me.length - 1 : end, me.length - 1);\n        if (start <= end) {\n            for (i = start; i <= end; i++) {\n                range[range.length] = items[i];\n            }\n        } else {\n            for (i = start; i >= end; i--) {\n                range[range.length] = items[i];\n            }\n        }\n        return range;\n    },\n\n    /**\n     * <p>Filters the objects in this collection by a set of {@link Ext.util.Filter Filter}s, or by a single\n     * property/value pair with optional parameters for substring matching and case sensitivity. See\n     * {@link Ext.util.Filter Filter} for an example of using Filter objects (preferred). Alternatively,\n     * MixedCollection can be easily filtered by property like this:</p>\n<pre><code>\n//create a simple store with a few people defined\nvar people = new Ext.util.MixedCollection();\npeople.addAll([\n    {id: 1, age: 25, name: 'Ed'},\n    {id: 2, age: 24, name: 'Tommy'},\n    {id: 3, age: 24, name: 'Arne'},\n    {id: 4, age: 26, name: 'Aaron'}\n]);\n\n//a new MixedCollection containing only the items where age == 24\nvar middleAged = people.filter('age', 24);\n</code></pre>\n     *\n     *\n     * @param {Ext.util.Filter[]/String} property A property on your objects, or an array of {@link Ext.util.Filter Filter} objects\n     * @param {String/RegExp} value Either string that the property values\n     * should start with or a RegExp to test against the property\n     * @param {Boolean} [anyMatch=false] True to match any part of the string, not just the beginning\n     * @param {Boolean} [caseSensitive=false] True for case sensitive comparison.\n     * @return {Ext.util.MixedCollection} The new filtered collection\n     */\n    filter : function(property, value, anyMatch, caseSensitive) {\n        var filters = [],\n            filterFn;\n\n        //support for the simple case of filtering by property/value\n        if (Ext.isString(property)) {\n            filters.push(new Ext.util.Filter({\n                property     : property,\n                value        : value,\n                anyMatch     : anyMatch,\n                caseSensitive: caseSensitive\n            }));\n        } else if (Ext.isArray(property) || property instanceof Ext.util.Filter) {\n            filters = filters.concat(property);\n        }\n\n        //at this point we have an array of zero or more Ext.util.Filter objects to filter with,\n        //so here we construct a function that combines these filters by ANDing them together\n        filterFn = function(record) {\n            var isMatch = true,\n                length = filters.length,\n                i,\n                filter,\n                fn,\n                scope;\n                \n\n            for (i = 0; i < length; i++) {\n                filter = filters[i];\n                fn     = filter.filterFn;\n                scope  = filter.scope;\n\n                isMatch = isMatch && fn.call(scope, record);\n            }\n\n            return isMatch;\n        };\n\n        return this.filterBy(filterFn);\n    },\n\n    /**\n     * Filter by a function. Returns a <i>new</i> collection that has been filtered.\n     * The passed function will be called with each object in the collection.\n     * If the function returns true, the value is included otherwise it is filtered.\n     * @param {Function} fn The function to be called.\n     * @param {Mixed} fn.item The collection item.\n     * @param {String} fn.key The key of collection item.\n     * @param {Object} scope (optional) The scope (<code>this</code> reference) in\n     * which the function is executed. Defaults to this MixedCollection.\n     * @return {Ext.util.MixedCollection} The new filtered collection\n     */\n    filterBy : function(fn, scope) {\n        var me = this,\n            newMC  = new this.self(),\n            keys   = me.keys,\n            items  = me.items,\n            length = items.length,\n            i;\n\n        newMC.getKey = me.getKey;\n\n        for (i = 0; i < length; i++) {\n            if (fn.call(scope || me, items[i], keys[i])) {\n                newMC.add(keys[i], items[i]);\n            }\n        }\n\n        return newMC;\n    },\n\n    /**\n     * Finds the index of the first matching object in this collection by a specific property/value.\n     * @param {String} property The name of a property on your objects.\n     * @param {String/RegExp} value A string that the property values\n     * should start with or a RegExp to test against the property.\n     * @param {Number} [start=0] The index to start searching at.\n     * @param {Boolean} [anyMatch=false] True to match any part of the string, not just the beginning.\n     * @param {Boolean} [caseSensitive=false] True for case sensitive comparison.\n     * @return {Number} The matched index or -1\n     */\n    findIndex : function(property, value, start, anyMatch, caseSensitive){\n        if(Ext.isEmpty(value, false)){\n            return -1;\n        }\n        value = this.createValueMatcher(value, anyMatch, caseSensitive);\n        return this.findIndexBy(function(o){\n            return o && value.test(o[property]);\n        }, null, start);\n    },\n\n    /**\n     * Find the index of the first matching object in this collection by a function.\n     * If the function returns <i>true</i> it is considered a match.\n     * @param {Function} fn The function to be called.\n     * @param {Mixed} fn.item The collection item.\n     * @param {String} fn.key The key of collection item.\n     * @param {Object} [scope] The scope (<code>this</code> reference) in which the function is executed. Defaults to this MixedCollection.\n     * @param {Number} [start=0] The index to start searching at.\n     * @return {Number} The matched index or -1\n     */\n    findIndexBy : function(fn, scope, start){\n        var me = this,\n            keys = me.keys,\n            items = me.items,\n            i = start || 0,\n            len = items.length;\n\n        for (; i < len; i++) {\n            if (fn.call(scope || me, items[i], keys[i])) {\n                return i;\n            }\n        }\n        return -1;\n    },\n\n    /**\n     * Returns a regular expression based on the given value and matching options. This is used internally for finding and filtering,\n     * and by Ext.data.Store#filter\n     * @private\n     * @param {String} value The value to create the regex for. This is escaped using Ext.escapeRe\n     * @param {Boolean} anyMatch True to allow any match - no regex start/end line anchors will be added. Defaults to false\n     * @param {Boolean} caseSensitive True to make the regex case sensitive (adds 'i' switch to regex). Defaults to false.\n     * @param {Boolean} exactMatch True to force exact match (^ and $ characters added to the regex). Defaults to false. Ignored if anyMatch is true.\n     */\n    createValueMatcher : function(value, anyMatch, caseSensitive, exactMatch) {\n        if (!value.exec) { // not a regex\n            var er = Ext.String.escapeRegex;\n            value = String(value);\n\n            if (anyMatch === true) {\n                value = er(value);\n            } else {\n                value = '^' + er(value);\n                if (exactMatch === true) {\n                    value += '$';\n                }\n            }\n            value = new RegExp(value, caseSensitive ? '' : 'i');\n        }\n        return value;\n    },\n\n    /**\n     * Creates a shallow copy of this collection\n     * @return {Ext.util.MixedCollection}\n     */\n    clone : function() {\n        var me = this,\n            copy = new this.self(),\n            keys = me.keys,\n            items = me.items,\n            i = 0,\n            len = items.length;\n\n        for(; i < len; i++){\n            copy.add(keys[i], items[i]);\n        }\n        copy.getKey = me.getKey;\n        return copy;\n    }\n});\n\n/**\n * Represents a single sorter that can be applied to a Store. The sorter is used\n * to compare two values against each other for the purpose of ordering them. Ordering\n * is achieved by specifying either:\n *\n * - {@link #property A sorting property}\n * - {@link #sorterFn A sorting function}\n *\n * As a contrived example, we can specify a custom sorter that sorts by rank:\n *\n *     Ext.define('Person', {\n *         extend: 'Ext.data.Model',\n *         fields: ['name', 'rank']\n *     });\n *\n *     Ext.create('Ext.data.Store', {\n *         model: 'Person',\n *         proxy: 'memory',\n *         sorters: [{\n *             sorterFn: function(o1, o2){\n *                 var getRank = function(o){\n *                     var name = o.get('rank');\n *                     if (name === 'first') {\n *                         return 1;\n *                     } else if (name === 'second') {\n *                         return 2;\n *                     } else {\n *                         return 3;\n *                     }\n *                 },\n *                 rank1 = getRank(o1),\n *                 rank2 = getRank(o2);\n *\n *                 if (rank1 === rank2) {\n *                     return 0;\n *                 }\n *\n *                 return rank1 < rank2 ? -1 : 1;\n *             }\n *         }],\n *         data: [{\n *             name: 'Person1',\n *             rank: 'second'\n *         }, {\n *             name: 'Person2',\n *             rank: 'third'\n *         }, {\n *             name: 'Person3',\n *             rank: 'first'\n *         }]\n *     });\n */\nExt.define('Ext.util.Sorter', {\n\n    /**\n     * @cfg {String} property\n     * The property to sort by. Required unless {@link #sorterFn} is provided. The property is extracted from the object\n     * directly and compared for sorting using the built in comparison operators.\n     */\n    \n    /**\n     * @cfg {Function} sorterFn\n     * A specific sorter function to execute. Can be passed instead of {@link #property}. This sorter function allows\n     * for any kind of custom/complex comparisons. The sorterFn receives two arguments, the objects being compared. The\n     * function should return:\n     *\n     *   - -1 if o1 is \"less than\" o2\n     *   - 0 if o1 is \"equal\" to o2\n     *   - 1 if o1 is \"greater than\" o2\n     */\n    \n    /**\n     * @cfg {String} root\n     * Optional root property. This is mostly useful when sorting a Store, in which case we set the root to 'data' to\n     * make the filter pull the {@link #property} out of the data object of each item\n     */\n    \n    /**\n     * @cfg {Function} transform\n     * A function that will be run on each value before it is compared in the sorter. The function will receive a single\n     * argument, the value.\n     */\n    \n    /**\n     * @cfg {String} direction\n     * The direction to sort by.\n     */\n    direction: \"ASC\",\n    \n    constructor: function(config) {\n        var me = this;\n        \n        Ext.apply(me, config);\n        \n        if (me.property === undefined && me.sorterFn === undefined) {\n            Ext.Error.raise(\"A Sorter requires either a property or a sorter function\");\n        }\n        \n        me.updateSortFunction();\n    },\n    \n    /**\n     * @private\n     * Creates and returns a function which sorts an array by the given property and direction\n     * @return {Function} A function which sorts by the property/direction combination provided\n     */\n    createSortFunction: function(sorterFn) {\n        var me        = this,\n            property  = me.property,\n            direction = me.direction || \"ASC\",\n            modifier  = direction.toUpperCase() == \"DESC\" ? -1 : 1;\n        \n        //create a comparison function. Takes 2 objects, returns 1 if object 1 is greater,\n        //-1 if object 2 is greater or 0 if they are equal\n        return function(o1, o2) {\n            return modifier * sorterFn.call(me, o1, o2);\n        };\n    },\n    \n    /**\n     * @private\n     * Basic default sorter function that just compares the defined property of each object\n     */\n    defaultSorterFn: function(o1, o2) {\n        var me = this,\n            transform = me.transform,\n            v1 = me.getRoot(o1)[me.property],\n            v2 = me.getRoot(o2)[me.property];\n            \n        if (transform) {\n            v1 = transform(v1);\n            v2 = transform(v2);\n        }\n\n        return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);\n    },\n    \n    /**\n     * @private\n     * Returns the root property of the given item, based on the configured {@link #root} property\n     * @param {Object} item The item\n     * @return {Object} The root property of the object\n     */\n    getRoot: function(item) {\n        return this.root === undefined ? item : item[this.root];\n    },\n    \n    /**\n     * Set the sorting direction for this sorter.\n     * @param {String} direction The direction to sort in. Should be either 'ASC' or 'DESC'.\n     */\n    setDirection: function(direction) {\n        var me = this;\n        me.direction = direction ? direction.toUpperCase() : direction;\n        me.updateSortFunction();\n    },\n    \n    /**\n     * Toggles the sorting direction for this sorter.\n     */\n    toggle: function() {\n        var me = this;\n        me.direction = Ext.String.toggle(me.direction, \"ASC\", \"DESC\");\n        me.updateSortFunction();\n    },\n    \n    /**\n     * Update the sort function for this sorter.\n     * @param {Function} [fn] A new sorter function for this sorter. If not specified it will use the default\n     * sorting function.\n     */\n    updateSortFunction: function(fn) {\n        var me = this;\n        fn = fn || me.sorterFn || me.defaultSorterFn;\n        me.sort = me.createSortFunction(fn);\n    }\n});\n\n/**\n * @docauthor Tommy Maintz <tommy@sencha.com>\n *\n * A mixin which allows a data component to be sorted. This is used by e.g. {@link Ext.data.Store} and {@link Ext.data.TreeStore}.\n *\n * **NOTE**: This mixin is mainly for internal use and most users should not need to use it directly. It\n * is more likely you will want to use one of the component classes that import this mixin, such as\n * {@link Ext.data.Store} or {@link Ext.data.TreeStore}.\n */\nExt.define(\"Ext.util.Sortable\", {\n    /**\n     * @property {Boolean} isSortable\n     * `true` in this class to identify an object as an instantiated Sortable, or subclass thereof.\n     */\n    isSortable: true,\n\n    /**\n     * @property {String} defaultSortDirection\n     * The default sort direction to use if one is not specified.\n     */\n    defaultSortDirection: \"ASC\",\n\n    requires: [\n        'Ext.util.Sorter'\n    ],\n\n    /**\n     * @property {String} sortRoot\n     * The property in each item that contains the data to sort.\n     */\n\n    /**\n     * Performs initialization of this mixin. Component classes using this mixin should call this method during their\n     * own initialization.\n     */\n    initSortable: function() {\n        var me = this,\n            sorters = me.sorters;\n\n        /**\n         * @property {Ext.util.MixedCollection} sorters\n         * The collection of {@link Ext.util.Sorter Sorters} currently applied to this Store\n         */\n        me.sorters = new Ext.util.AbstractMixedCollection(false, function(item) {\n            return item.id || item.property;\n        });\n\n        if (sorters) {\n            me.sorters.addAll(me.decodeSorters(sorters));\n        }\n    },\n\n    /**\n     * Sorts the data in the Store by one or more of its properties. Example usage:\n     *\n     *     //sort by a single field\n     *     myStore.sort('myField', 'DESC');\n     *\n     *     //sorting by multiple fields\n     *     myStore.sort([\n     *         {\n     *             property : 'age',\n     *             direction: 'ASC'\n     *         },\n     *         {\n     *             property : 'name',\n     *             direction: 'DESC'\n     *         }\n     *     ]);\n     *\n     * Internally, Store converts the passed arguments into an array of {@link Ext.util.Sorter} instances, and delegates\n     * the actual sorting to its internal {@link Ext.util.MixedCollection}.\n     *\n     * When passing a single string argument to sort, Store maintains a ASC/DESC toggler per field, so this code:\n     *\n     *     store.sort('myField');\n     *     store.sort('myField');\n     *\n     * Is equivalent to this code, because Store handles the toggling automatically:\n     *\n     *     store.sort('myField', 'ASC');\n     *     store.sort('myField', 'DESC');\n     *\n     * @param {String/Ext.util.Sorter[]} [sorters] Either a string name of one of the fields in this Store's configured\n     * {@link Ext.data.Model Model}, or an array of sorter configurations.\n     * @param {String} [direction=\"ASC\"] The overall direction to sort the data by.\n     * @return {Ext.util.Sorter[]}\n     */\n    sort: function(sorters, direction, where, doSort) {\n        var me = this,\n            sorter, sorterFn,\n            newSorters;\n\n        if (Ext.isArray(sorters)) {\n            doSort = where;\n            where = direction;\n            newSorters = sorters;\n        }\n        else if (Ext.isObject(sorters)) {\n            doSort = where;\n            where = direction;\n            newSorters = [sorters];\n        }\n        else if (Ext.isString(sorters)) {\n            sorter = me.sorters.get(sorters);\n\n            if (!sorter) {\n                sorter = {\n                    property : sorters,\n                    direction: direction\n                };\n                newSorters = [sorter];\n            }\n            else if (direction === undefined) {\n                sorter.toggle();\n            }\n            else {\n                sorter.setDirection(direction);\n            }\n        }\n\n        if (newSorters && newSorters.length) {\n            newSorters = me.decodeSorters(newSorters);\n            if (Ext.isString(where)) {\n                if (where === 'prepend') {\n                    sorters = me.sorters.clone().items;\n\n                    me.sorters.clear();\n                    me.sorters.addAll(newSorters);\n                    me.sorters.addAll(sorters);\n                }\n                else {\n                    me.sorters.addAll(newSorters);\n                }\n            }\n            else {\n                me.sorters.clear();\n                me.sorters.addAll(newSorters);\n            }\n        }\n\n        if (doSort !== false) {\n            me.onBeforeSort(newSorters);\n            \n            sorters = me.sorters.items;\n            if (sorters.length) {\n                // Sort using a generated sorter function which combines all of the Sorters passed\n                me.doSort(me.generateComparator());\n            }\n        }\n\n        return sorters;\n    },\n\n    /**\n     * <p>Returns a comparator function which compares two items and returns -1, 0, or 1 depending\n     * on the currently defined set of {@link #sorters}.</p>\n     * <p>If there are no {@link #sorters} defined, it returns a function which returns <code>0</code> meaning that no sorting will occur.</p>\n     */\n    generateComparator: function() {\n        var sorters = this.sorters.getRange();\n        return sorters.length ? this.createComparator(sorters) : this.emptyComparator;\n    },\n    \n    createComparator: function(sorters) {\n        return function(r1, r2) {\n            var result = sorters[0].sort(r1, r2),\n                length = sorters.length,\n                i = 1;\n\n            // if we have more than one sorter, OR any additional sorter functions together\n            for (; i < length; i++) {\n                result = result || sorters[i].sort.call(this, r1, r2);\n            }\n            return result;\n        };\n    },\n    \n    emptyComparator: function(){\n        return 0;\n    },\n\n    onBeforeSort: Ext.emptyFn,\n\n    /**\n     * @private\n     * Normalizes an array of sorter objects, ensuring that they are all Ext.util.Sorter instances\n     * @param {Object[]} sorters The sorters array\n     * @return {Ext.util.Sorter[]} Array of Ext.util.Sorter objects\n     */\n    decodeSorters: function(sorters) {\n        if (!Ext.isArray(sorters)) {\n            if (sorters === undefined) {\n                sorters = [];\n            } else {\n                sorters = [sorters];\n            }\n        }\n\n        var length = sorters.length,\n            Sorter = Ext.util.Sorter,\n            fields = this.model ? this.model.prototype.fields : null,\n            field,\n            config, i;\n\n        for (i = 0; i < length; i++) {\n            config = sorters[i];\n\n            if (!(config instanceof Sorter)) {\n                if (Ext.isString(config)) {\n                    config = {\n                        property: config\n                    };\n                }\n\n                Ext.applyIf(config, {\n                    root     : this.sortRoot,\n                    direction: \"ASC\"\n                });\n\n                //support for 3.x style sorters where a function can be defined as 'fn'\n                if (config.fn) {\n                    config.sorterFn = config.fn;\n                }\n\n                //support a function to be passed as a sorter definition\n                if (typeof config == 'function') {\n                    config = {\n                        sorterFn: config\n                    };\n                }\n\n                // ensure sortType gets pushed on if necessary\n                if (fields && !config.transform) {\n                    field = fields.get(config.property);\n                    config.transform = field ? field.sortType : undefined;\n                }\n                sorters[i] = new Ext.util.Sorter(config);\n            }\n        }\n\n        return sorters;\n    },\n\n    getSorters: function() {\n        return this.sorters.items;\n    },\n    \n    /**\n     * Gets the first sorter from the sorters collection, excluding\n     * any groupers that may be in place\n     * @protected\n     * @return {Ext.util.Sorter} The sorter, null if none exist\n     */\n    getFirstSorter: function(){\n        var sorters = this.sorters.items,\n            len = sorters.length,\n            i = 0,\n            sorter;\n            \n        for (; i < len; ++i) {\n            sorter = sorters[i];\n            if (!sorter.isGrouper) {\n                return sorter;    \n            }\n        }\n        return null;\n    }\n});\n\n/**\n * @class Ext.util.MixedCollection\n * <p>\n * Represents a collection of a set of key and value pairs. Each key in the MixedCollection\n * must be unique, the same key cannot exist twice. This collection is ordered, items in the\n * collection can be accessed by index  or via the key. Newly added items are added to\n * the end of the collection. This class is similar to {@link Ext.util.HashMap} however it\n * is heavier and provides more functionality. Sample usage:\n * <pre><code>\nvar coll = new Ext.util.MixedCollection();\ncoll.add('key1', 'val1');\ncoll.add('key2', 'val2');\ncoll.add('key3', 'val3');\n\nconsole.log(coll.get('key1')); // prints 'val1'\nconsole.log(coll.indexOfKey('key3')); // prints 2\n * </code></pre>\n *\n * <p>\n * The MixedCollection also has support for sorting and filtering of the values in the collection.\n * <pre><code>\nvar coll = new Ext.util.MixedCollection();\ncoll.add('key1', 100);\ncoll.add('key2', -100);\ncoll.add('key3', 17);\ncoll.add('key4', 0);\nvar biggerThanZero = coll.filterBy(function(value){\n    return value > 0;\n});\nconsole.log(biggerThanZero.getCount()); // prints 2\n * </code></pre>\n * </p>\n */\nExt.define('Ext.util.MixedCollection', {\n    extend: 'Ext.util.AbstractMixedCollection',\n    mixins: {\n        sortable: 'Ext.util.Sortable'\n    },\n\n    /**\n     * Creates new MixedCollection.\n     * @param {Boolean} allowFunctions Specify <tt>true</tt> if the {@link #addAll}\n     * function should add function references to the collection. Defaults to\n     * <tt>false</tt>.\n     * @param {Function} keyFn A function that can accept an item of the type(s) stored in this MixedCollection\n     * and return the key value for that item.  This is used when available to look up the key on items that\n     * were passed without an explicit key parameter to a MixedCollection method.  Passing this parameter is\n     * equivalent to providing an implementation for the {@link #getKey} method.\n     */\n    constructor: function() {\n        var me = this;\n        me.callParent(arguments);\n        me.addEvents('sort');\n        me.mixins.sortable.initSortable.call(me);\n    },\n\n    doSort: function(sorterFn) {\n        this.sortBy(sorterFn);\n    },\n\n    /**\n     * @private\n     * Performs the actual sorting based on a direction and a sorting function. Internally,\n     * this creates a temporary array of all items in the MixedCollection, sorts it and then writes\n     * the sorted array data back into this.items and this.keys\n     * @param {String} property Property to sort by ('key', 'value', or 'index')\n     * @param {String} dir (optional) Direction to sort 'ASC' or 'DESC'. Defaults to 'ASC'.\n     * @param {Function} fn (optional) Comparison function that defines the sort order.\n     * Defaults to sorting by numeric value.\n     */\n    _sort : function(property, dir, fn){\n        var me = this,\n            i, len,\n            dsc   = String(dir).toUpperCase() == 'DESC' ? -1 : 1,\n\n            //this is a temporary array used to apply the sorting function\n            c     = [],\n            keys  = me.keys,\n            items = me.items;\n\n        //default to a simple sorter function if one is not provided\n        fn = fn || function(a, b) {\n            return a - b;\n        };\n\n        //copy all the items into a temporary array, which we will sort\n        for(i = 0, len = items.length; i < len; i++){\n            c[c.length] = {\n                key  : keys[i],\n                value: items[i],\n                index: i\n            };\n        }\n\n        //sort the temporary array\n        Ext.Array.sort(c, function(a, b){\n            var v = fn(a[property], b[property]) * dsc;\n            if(v === 0){\n                v = (a.index < b.index ? -1 : 1);\n            }\n            return v;\n        });\n\n        //copy the temporary array back into the main this.items and this.keys objects\n        for(i = 0, len = c.length; i < len; i++){\n            items[i] = c[i].value;\n            keys[i]  = c[i].key;\n        }\n\n        me.fireEvent('sort', me);\n    },\n\n    /**\n     * Sorts the collection by a single sorter function\n     * @param {Function} sorterFn The function to sort by\n     */\n    sortBy: function(sorterFn) {\n        var me     = this,\n            items  = me.items,\n            keys   = me.keys,\n            length = items.length,\n            temp   = [],\n            i;\n\n        //first we create a copy of the items array so that we can sort it\n        for (i = 0; i < length; i++) {\n            temp[i] = {\n                key  : keys[i],\n                value: items[i],\n                index: i\n            };\n        }\n\n        Ext.Array.sort(temp, function(a, b) {\n            var v = sorterFn(a.value, b.value);\n            if (v === 0) {\n                v = (a.index < b.index ? -1 : 1);\n            }\n\n            return v;\n        });\n\n        //copy the temporary array back into the main this.items and this.keys objects\n        for (i = 0; i < length; i++) {\n            items[i] = temp[i].value;\n            keys[i]  = temp[i].key;\n        }\n\n        me.fireEvent('sort', me, items, keys);\n    },\n\n    /**\n     * Calculates the insertion index of the new item based upon the comparison function passed, or the current sort order.\n     * @param {Object} newItem The new object to find the insertion position of.\n     * @param {Function} [sorterFn] The function to sort by. This is the same as the sorting function\n     * passed to {@link #sortBy}. It accepts 2 items from this MixedCollection, and returns -1 0, or 1\n     * depending on the relative sort positions of the 2 compared items.\n     *\n     * If omitted, a function {@link #generateComparator generated} from the currently defined set of\n     * {@link #sorters} will be used.\n     *\n     * @return {Number} The insertion point to add the new item into this MixedCollection at using {@link #insert}\n     */\n    findInsertionIndex: function(newItem, sorterFn) {\n        var me    = this,\n            items = me.items,\n            start = 0,\n            end   = items.length - 1,\n            middle,\n            comparison;\n\n        if (!sorterFn) {\n            sorterFn = me.generateComparator();\n        }\n        while (start <= end) {\n            middle = (start + end) >> 1;\n            comparison = sorterFn(newItem, items[middle]);\n            if (comparison >= 0) {\n                start = middle + 1;\n            } else if (comparison < 0) {\n                end = middle - 1;\n            }\n        }\n        return start;\n    },\n\n    /**\n     * Reorders each of the items based on a mapping from old index to new index. Internally this\n     * just translates into a sort. The 'sort' event is fired whenever reordering has occured.\n     * @param {Object} mapping Mapping from old item index to new item index\n     */\n    reorder: function(mapping) {\n        var me = this,\n            items = me.items,\n            index = 0,\n            length = items.length,\n            order = [],\n            remaining = [],\n            oldIndex;\n\n        me.suspendEvents();\n\n        //object of {oldPosition: newPosition} reversed to {newPosition: oldPosition}\n        for (oldIndex in mapping) {\n            order[mapping[oldIndex]] = items[oldIndex];\n        }\n\n        for (index = 0; index < length; index++) {\n            if (mapping[index] == undefined) {\n                remaining.push(items[index]);\n            }\n        }\n\n        for (index = 0; index < length; index++) {\n            if (order[index] == undefined) {\n                order[index] = remaining.shift();\n            }\n        }\n\n        me.clear();\n        me.addAll(order);\n\n        me.resumeEvents();\n        me.fireEvent('sort', me);\n    },\n\n    /**\n     * Sorts this collection by <b>key</b>s.\n     * @param {String} direction (optional) 'ASC' or 'DESC'. Defaults to 'ASC'.\n     * @param {Function} fn (optional) Comparison function that defines the sort order.\n     * Defaults to sorting by case insensitive string.\n     */\n    sortByKey : function(dir, fn){\n        this._sort('key', dir, fn || function(a, b){\n            var v1 = String(a).toUpperCase(), v2 = String(b).toUpperCase();\n            return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);\n        });\n    }\n});\n\n/**\n * A class that manages a group of {@link Ext.Component#floating} Components and provides z-order management,\n * and Component activation behavior, including masking below the active (topmost) Component.\n *\n * {@link Ext.Component#floating Floating} Components which are rendered directly into the document (such as\n * {@link Ext.window.Window Window}s) which are {@link Ext.Component#method-show show}n are managed by a\n * {@link Ext.WindowManager global instance}.\n *\n * {@link Ext.Component#floating Floating} Components which are descendants of {@link Ext.Component#floating floating}\n * *Containers* (for example a {@link Ext.view.BoundList BoundList} within an {@link Ext.window.Window Window},\n * or a {@link Ext.menu.Menu Menu}), are managed by a ZIndexManager owned by that floating Container. Therefore\n * ComboBox dropdowns within Windows will have managed z-indices guaranteed to be correct, relative to the Window.\n */\nExt.define('Ext.ZIndexManager', {\n    alternateClassName: 'Ext.WindowGroup',\n\n    statics: {\n        zBase : 9000\n    },\n\n    constructor: function(container) {\n        var me = this;\n\n        me.list = {};\n        me.zIndexStack = [];\n        me.front = null;\n\n        if (container) {\n\n            // This is the ZIndexManager for an Ext.container.Container, base its zseed on the zIndex of the Container's element\n            if (container.isContainer) {\n                container.on('resize', me._onContainerResize, me);\n                me.zseed = Ext.Number.from(me.rendered ? container.getEl().getStyle('zIndex') : undefined, me.getNextZSeed());\n                // The containing element we will be dealing with (eg masking) is the content target\n                me.targetEl = container.getTargetEl();\n                me.container = container;\n            }\n            // This is the ZIndexManager for a DOM element\n            else {\n                Ext.EventManager.onWindowResize(me._onContainerResize, me);\n                me.zseed = me.getNextZSeed();\n                me.targetEl = Ext.get(container);\n            }\n        }\n        // No container passed means we are the global WindowManager. Our target is the doc body.\n        // DOM must be ready to collect that ref.\n        else {\n            Ext.EventManager.onWindowResize(me._onContainerResize, me);\n            me.zseed = me.getNextZSeed();\n            Ext.onDocumentReady(function() {\n                me.targetEl = Ext.getBody();\n            });\n        }\n    },\n\n    getNextZSeed: function() {\n        return (Ext.ZIndexManager.zBase += 10000);\n    },\n\n    setBase: function(baseZIndex) {\n        this.zseed = baseZIndex;\n        var result = this.assignZIndices();\n        this._activateLast();\n        return result;\n    },\n\n    // private\n    assignZIndices: function() {\n        var a = this.zIndexStack,\n            len = a.length,\n            i = 0,\n            zIndex = this.zseed,\n            comp;\n\n        for (; i < len; i++) {\n            comp = a[i];\n            if (comp && !comp.hidden) {\n\n                // Setting the zIndex of a Component returns the topmost zIndex consumed by\n                // that Component.\n                // If it's just a plain floating Component such as a BoundList, then the\n                // return value is the passed value plus 10, ready for the next item.\n                // If a floating *Container* has its zIndex set, it re-orders its managed\n                // floating children, starting from that new base, and returns a value 10000 above\n                // the highest zIndex which it allocates.\n                zIndex = comp.setZIndex(zIndex);\n            }\n        }\n\n        // Activate new topmost\n        this._activateLast();\n        return zIndex;\n    },\n\n    // private\n    _setActiveChild: function(comp, oldFront) {\n        var front = this.front;\n        if (comp !== front) {\n\n            if (front && !front.destroying) {\n                front.setActive(false, comp);\n            }\n            this.front = comp;\n            if (comp && comp != oldFront) {\n                comp.setActive(true);\n                if (comp.modal) {\n                    this._showModalMask(comp);\n                }\n            }\n        }\n    },\n    \n    onComponentHide: function(comp){\n        comp.setActive(false);\n        this._activateLast();\n    },\n\n    // private\n    _activateLast: function() {\n        var me = this,\n            stack = me.zIndexStack,\n            i = stack.length - 1,\n            oldFront = me.front,\n            comp;\n\n        // There may be no visible floater to activate\n        me.front = undefined;\n\n        // Go down through the z-index stack.\n        // Activate the next visible one down.\n        // If that was modal, then we're done\n        for (; i >= 0 && stack[i].hidden; --i);\n        if ((comp = stack[i])) {\n            me._setActiveChild(comp, oldFront);\n            if (comp.modal) {\n                return;\n            }\n        }\n\n        // If the new top one was not modal, keep going down to find the next visible\n        // modal one to shift the modal mask down under\n        for (; i >= 0; --i) {\n            comp = stack[i];\n            // If we find a visible modal further down the zIndex stack, move the mask to just under it.\n            if (comp.isVisible() && comp.modal) {\n                me._showModalMask(comp);\n                return;\n            }\n        }\n\n        // No visible modal Component was found in the run down the stack.\n        // So hide the modal mask\n        me._hideModalMask();\n    },\n\n    _showModalMask: function(comp) {\n        var me = this,\n            zIndex = comp.el.getStyle('zIndex') - 4,\n            maskTarget = comp.floatParent ? comp.floatParent.getTargetEl() : comp.container,\n            viewSize = maskTarget.getBox();\n\n        if (maskTarget.dom === document.body) {\n            viewSize.height = Math.max(document.body.scrollHeight, Ext.dom.Element.getDocumentHeight());\n            viewSize.width = Math.max(document.body.scrollWidth, viewSize.width);\n        }\n        if (!me.mask) {\n            me.mask = Ext.getBody().createChild({\n                cls: Ext.baseCSSPrefix + 'mask'\n            });\n            me.mask.setVisibilityMode(Ext.Element.DISPLAY);\n            me.mask.on('click', me._onMaskClick, me);\n        }\n        me.mask.maskTarget = maskTarget;\n        maskTarget.addCls(Ext.baseCSSPrefix + 'body-masked');\n        me.mask.setStyle('zIndex', zIndex);\n\n        // setting mask box before showing it in an IE7 strict iframe within a quirks page\n        // can cause body scrolling [EXTJSIV-6219]\n        me.mask.show();\n        me.mask.setBox(viewSize);\n    },\n\n    _hideModalMask: function() {\n        var mask = this.mask;\n        if (mask && mask.isVisible()) {\n            mask.maskTarget.removeCls(Ext.baseCSSPrefix + 'body-masked');\n            mask.maskTarget = undefined;\n            mask.hide();\n        }\n    },\n\n    _onMaskClick: function() {\n        if (this.front) {\n            this.front.focus();\n        }\n    },\n\n    _onContainerResize: function() {\n        var mask = this.mask,\n            maskTarget,\n            viewSize;\n\n        if (mask && mask.isVisible()) {\n\n            // At the new container size, the mask might be *causing* the scrollbar, so to find the valid\n            // client size to mask, we must temporarily unmask the parent node.\n            mask.hide();\n            maskTarget = mask.maskTarget;\n\n            if (maskTarget.dom === document.body) {\n                viewSize = {\n                    height: Math.max(document.body.scrollHeight, Ext.dom.Element.getDocumentHeight()),\n                    width: Math.max(document.body.scrollWidth, document.documentElement.clientWidth)\n                };\n            } else {\n                viewSize = maskTarget.getViewSize(true);\n            }\n            mask.setSize(viewSize);\n            mask.show();\n        }\n    },\n\n    /**\n     * Registers a floating {@link Ext.Component} with this ZIndexManager. This should not\n     * need to be called under normal circumstances. Floating Components (such as Windows,\n     * BoundLists and Menus) are automatically registered with a\n     * {@link Ext.Component#zIndexManager zIndexManager} at render time.\n     *\n     * Where this may be useful is moving Windows between two ZIndexManagers. For example,\n     * to bring the Ext.MessageBox dialog under the same manager as the Desktop's\n     * ZIndexManager in the desktop sample app:\n     *\n     *     MyDesktop.getDesktop().getManager().register(Ext.MessageBox);\n     *\n     * @param {Ext.Component} comp The Component to register.\n     */\n    register : function(comp) {\n        var me = this;\n        \n        if (comp.zIndexManager) {\n            comp.zIndexManager.unregister(comp);\n        }\n        comp.zIndexManager = me;\n\n        me.list[comp.id] = comp;\n        me.zIndexStack.push(comp);\n        comp.on('hide', me.onComponentHide, me);\n    },\n\n    /**\n     * Unregisters a {@link Ext.Component} from this ZIndexManager. This should not\n     * need to be called. Components are automatically unregistered upon destruction.\n     * See {@link #register}.\n     * @param {Ext.Component} comp The Component to unregister.\n     */\n    unregister : function(comp) {\n        var me = this,\n            list = me.list;\n        \n        delete comp.zIndexManager;\n        if (list && list[comp.id]) {\n            delete list[comp.id];\n            comp.un('hide', me.onComponentHide);\n            Ext.Array.remove(me.zIndexStack, comp);\n\n            // Destruction requires that the topmost visible floater be activated. Same as hiding.\n            me._activateLast();\n        }\n    },\n\n    /**\n     * Gets a registered Component by id.\n     * @param {String/Object} id The id of the Component or a {@link Ext.Component} instance\n     * @return {Ext.Component}\n     */\n    get : function(id) {\n        return id.isComponent ? id : this.list[id];\n    },\n\n   /**\n     * Brings the specified Component to the front of any other active Components in this ZIndexManager.\n     * @param {String/Object} comp The id of the Component or a {@link Ext.Component} instance\n     * @return {Boolean} True if the dialog was brought to the front, else false\n     * if it was already in front\n     */\n    bringToFront : function(comp) {\n        var me = this,\n            result = false,\n            zIndexStack = me.zIndexStack;\n        \n        comp = me.get(comp);\n        if (comp !== me.front) {\n            Ext.Array.remove(zIndexStack, comp);\n            if (comp.preventBringToFront) {\n                // this takes care of cases where a load mask should be displayed under a floated component\n                zIndexStack.unshift(comp);\n            } else {\n                // the default behavior is to push onto the stack\n                zIndexStack.push(comp);\n            }\n\n            me.assignZIndices();\n            result = true;\n            this.front = comp;\n        }\n        if (result && comp.modal) {\n            me._showModalMask(comp);\n        }\n        return result;\n    },\n\n    /**\n     * Sends the specified Component to the back of other active Components in this ZIndexManager.\n     * @param {String/Object} comp The id of the Component or a {@link Ext.Component} instance\n     * @return {Ext.Component} The Component\n     */\n    sendToBack : function(comp) {\n        var me = this;\n        \n        comp = me.get(comp);\n        Ext.Array.remove(me.zIndexStack, comp);\n        me.zIndexStack.unshift(comp);\n        me.assignZIndices();\n        this._activateLast();\n        return comp;\n    },\n\n    /**\n     * Hides all Components managed by this ZIndexManager.\n     */\n    hideAll : function() {\n        var list = this.list,\n            item,\n            id;\n            \n        for (id in list) {\n            if (list.hasOwnProperty(id)) {\n                item = list[id];\n                if (item.isComponent && item.isVisible()) {\n                    item.hide();\n                }\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Temporarily hides all currently visible managed Components. This is for when\n     * dragging a Window which may manage a set of floating descendants in its ZIndexManager;\n     * they should all be hidden just for the duration of the drag.\n     */\n    hide: function() {\n        var me = this,\n            mask = me.mask,\n            i = 0,\n            stack = me.zIndexStack,\n            len = stack.length,\n            comp;\n\n        me.tempHidden = me.tempHidden||[];\n        for (; i < len; i++) {\n            comp = stack[i];\n            if (comp.isVisible()) {\n                me.tempHidden.push(comp);\n                comp.el.hide();\n            }\n        }\n        \n        // Also hide modal mask during hidden state\n        if (mask) {\n            mask.hide();\n        }\n    },\n\n    /**\n     * @private\n     * Restores temporarily hidden managed Components to visibility.\n     */\n    show: function() {\n        var me = this,\n            mask = me.mask,\n            i = 0,\n            tempHidden = me.tempHidden,\n            len = tempHidden ? tempHidden.length : 0,\n            comp;\n\n        for (; i < len; i++) {\n            comp = tempHidden[i];\n            comp.el.show();\n            comp.setPosition(comp.x, comp.y);\n        }\n        me.tempHidden.length = 0;\n\n        // Also restore mask to visibility and ensure it is aligned with its target element\n        if (mask) {\n            mask.show();\n            mask.alignTo(mask.maskTarget, 'tl-tl');\n        }\n    },\n\n    /**\n     * Gets the currently-active Component in this ZIndexManager.\n     * @return {Ext.Component} The active Component\n     */\n    getActive : function() {\n        return this.front;\n    },\n\n    /**\n     * Returns zero or more Components in this ZIndexManager using the custom search function passed to this method.\n     * The function should accept a single {@link Ext.Component} reference as its only argument and should\n     * return true if the Component matches the search criteria, otherwise it should return false.\n     * @param {Function} fn The search function\n     * @param {Object} [scope] The scope (this reference) in which the function is executed.\n     * Defaults to the Component being tested. That gets passed to the function if not specified.\n     * @return {Array} An array of zero or more matching windows\n     */\n    getBy : function(fn, scope) {\n        var r = [],\n            i = 0,\n            stack = this.zIndexStack,\n            len = stack.length,\n            comp;\n\n        for (; i < len; i++) {\n            comp = stack[i];\n            if (fn.call(scope||comp, comp) !== false) {\n                r.push(comp);\n            }\n        }\n        return r;\n    },\n\n    /**\n     * Executes the specified function once for every Component in this ZIndexManager, passing each\n     * Component as the only parameter. Returning false from the function will stop the iteration.\n     * @param {Function} fn The function to execute for each item\n     * @param {Object} [scope] The scope (this reference) in which the function\n     * is executed. Defaults to the current Component in the iteration.\n     */\n    each : function(fn, scope) {\n        var list = this.list,\n            id,\n            comp;\n            \n        for (id in list) {\n            if (list.hasOwnProperty(id)) {\n                comp = list[id];\n                if (comp.isComponent && fn.call(scope || comp, comp) === false) {\n                    return;\n                }\n            }\n        }\n    },\n\n    /**\n     * Executes the specified function once for every Component in this ZIndexManager, passing each\n     * Component as the only parameter. Returning false from the function will stop the iteration.\n     * The components are passed to the function starting at the bottom and proceeding to the top.\n     * @param {Function} fn The function to execute for each item\n     * @param {Object} scope (optional) The scope (this reference) in which the function\n     * is executed. Defaults to the current Component in the iteration.\n     */\n    eachBottomUp: function (fn, scope) {\n        var stack = this.zIndexStack,\n            i = 0,\n            len = stack.length,\n            comp;\n\n        for (; i < len; i++) {\n            comp = stack[i];\n            if (comp.isComponent && fn.call(scope || comp, comp) === false) {\n                return;\n            }\n        }\n    },\n\n    /**\n     * Executes the specified function once for every Component in this ZIndexManager, passing each\n     * Component as the only parameter. Returning false from the function will stop the iteration.\n     * The components are passed to the function starting at the top and proceeding to the bottom.\n     * @param {Function} fn The function to execute for each item\n     * @param {Object} [scope] The scope (this reference) in which the function\n     * is executed. Defaults to the current Component in the iteration.\n     */\n    eachTopDown: function (fn, scope) {\n        var stack = this.zIndexStack,\n            i = stack.length,\n            comp;\n\n        for (; i-- > 0; ) {\n            comp = stack[i];\n            if (comp.isComponent && fn.call(scope || comp, comp) === false) {\n                return;\n            }\n        }\n    },\n\n    destroy: function() {\n        var me   = this,\n            list = me.list,\n            comp,\n            id;\n\n        for (id in list) {\n            if (list.hasOwnProperty(id)) {\n                comp = list[id];\n\n                if (comp.isComponent) {\n                    comp.destroy();\n                }\n            }\n        }\n\n        delete me.zIndexStack;\n        delete me.list;\n        delete me.container;\n        delete me.targetEl;\n    }\n}, function() {\n    /**\n     * @class Ext.WindowManager\n     * @extends Ext.ZIndexManager\n     *\n     * The default global floating Component group that is available automatically.\n     *\n     * This manages instances of floating Components which were rendered programatically without\n     * being added to a {@link Ext.container.Container Container}, and for floating Components\n     * which were added into non-floating Containers.\n     * \n     * *Floating* Containers create their own instance of ZIndexManager, and floating Components\n     * added at any depth below there are managed by that ZIndexManager.\n     *\n     * @singleton\n     */\n    Ext.WindowManager = Ext.WindowMgr = new this();\n});\n\n/**\n * An abstract base class which provides shared methods for Containers across the Sencha product line.\n *\n * Please refer to sub class's documentation\n *\n * @private\n */\nExt.define('Ext.container.AbstractContainer', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.Component',\n\n    requires: [\n        'Ext.util.MixedCollection',\n        'Ext.layout.container.Auto',\n        'Ext.ZIndexManager'\n    ],\n\n    /* End Definitions */\n\n    renderTpl: '{%this.renderContainer(out,values)%}',\n\n    /**\n     * @cfg {String/Object} layout\n     * **Important**: In order for child items to be correctly sized and\n     * positioned, typically a layout manager **must** be specified through\n     * the `layout` configuration option.\n     *\n     * The sizing and positioning of child {@link #cfg-items} is the responsibility of\n     * the Container's layout manager which creates and manages the type of layout\n     * you have in mind.  For example:\n     *\n     * If the {@link #layout} configuration is not explicitly specified for\n     * a general purpose container (e.g. Container or Panel) the\n     * {@link Ext.layout.container.Auto default layout manager} will be used\n     * which does nothing but render child components sequentially into the\n     * Container (no sizing or positioning will be performed in this situation).\n     *\n     * **layout** may be specified as either as an Object or as a String:\n     *\n     * # Specify as an Object\n     *\n     * Example usage:\n     *\n     *     layout: {\n     *         type: 'vbox',\n     *         align: 'left'\n     *     }\n     *\n     *   - **type**\n     *\n     *     The layout type to be used for this container.  If not specified,\n     *     a default {@link Ext.layout.container.Auto} will be created and used.\n     *\n     *     Valid layout <code>type</code> values are:\n     *\n     *     - {@link Ext.layout.container.Auto Auto} - **Default**\n     *     - {@link Ext.layout.container.Card card}\n     *     - {@link Ext.layout.container.Fit fit}\n     *     - {@link Ext.layout.container.HBox hbox}\n     *     - {@link Ext.layout.container.VBox vbox}\n     *     - {@link Ext.layout.container.Anchor anchor}\n     *     - {@link Ext.layout.container.Table table}\n     *\n     *   - Layout specific configuration properties\n     *\n     *     Additional layout specific configuration properties may also be\n     *     specified. For complete details regarding the valid config options for\n     *     each layout type, see the layout class corresponding to the `type`\n     *     specified.\n     *\n     * # Specify as a String\n     *\n     * Example usage:\n     *\n     *     layout: 'vbox'\n     *\n     *   - **layout**\n     *\n     *     The layout `type` to be used for this container (see list\n     *     of valid layout type values above).\n     *\n     *     Additional layout specific configuration properties. For complete\n     *     details regarding the valid config options for each layout type, see the\n     *     layout class corresponding to the `layout` specified.\n     *\n     * # Configuring the default layout type\n     *\n     *     If a certain Container class has a default layout (For example a {@link Ext.toolbar.Toolbar Toolbar}\n     *     with a default `Box` layout), then to simply configure the default layout,\n     *     use an object, but without the `type` property:\n     *\n     *\n     *     xtype: 'toolbar',\n     *     layout: {\n     *         pack: 'center'\n     *     }\n     */\n\n    /**\n     * @cfg {String/Number} activeItem\n     * A string component id or the numeric index of the component that should be\n     * initially activated within the container's layout on render.  For example,\n     * activeItem: 'item-1' or activeItem: 0 (index 0 = the first item in the\n     * container's collection).  activeItem only applies to layout styles that can\n     * display items one at a time (like {@link Ext.layout.container.Card} and\n     * {@link Ext.layout.container.Fit}).\n     */\n\n    /**\n     * @cfg {Object/Object[]} items\n     * A single item, or an array of child Components to be added to this container\n     *\n     * **Unless configured with a {@link #layout}, a Container simply renders child\n     * Components serially into its encapsulating element and performs no sizing or\n     * positioning upon them.**\n     *\n     * Example:\n     *\n     *     // specifying a single item\n     *     items: {...},\n     *     layout: 'fit',    // The single items is sized to fit\n     *      \n     *     // specifying multiple items\n     *     items: [{...}, {...}],\n     *     layout: 'hbox', // The items are arranged horizontally\n     *\n     * Each item may be:\n     *\n     * - A {@link Ext.Component Component}\n     * - A Component configuration object\n     *\n     * If a configuration object is specified, the actual type of Component to be\n     * instantiated my be indicated by using the {@link Ext.Component#xtype xtype} option.\n     *\n     * Every Component class has its own {@link Ext.Component#xtype xtype}.\n     *\n     * If an {@link Ext.Component#xtype xtype} is not explicitly specified, the\n     * {@link #defaultType} for the Container is used, which by default is usually `panel`.\n     *\n     * # Notes:\n     *\n     * Ext uses lazy rendering. Child Components will only be rendered\n     * should it become necessary. Items are automatically laid out when they are first\n     * shown (no sizing is done while hidden), or in response to a {@link #doLayout} call.\n     *\n     * Do not specify {@link Ext.panel.Panel#contentEl contentEl} or\n     * {@link Ext.panel.Panel#html html} with `items`.\n     */\n\n    /**\n     * @cfg {Object/Function} defaults\n     * This option is a means of applying default settings to all added items whether added\n     * through the {@link #cfg-items} config or via the {@link #method-add} or {@link #insert} methods.\n     *\n     * Defaults are applied to both config objects and instantiated components conditionally\n     * so as not to override existing properties in the item (see {@link Ext#applyIf}).\n     *\n     * If the defaults option is specified as a function, then the function will be called\n     * using this Container as the scope (`this` reference) and passing the added item as\n     * the first parameter. Any resulting object from that call is then applied to the item\n     * as default properties.\n     *\n     * For example, to automatically apply padding to the body of each of a set of\n     * contained {@link Ext.panel.Panel} items, you could pass:\n     * `defaults: {bodyStyle:'padding:15px'}`.\n     *\n     * Usage:\n     *\n     *     defaults: { // defaults are applied to items, not the container\n     *         autoScroll: true\n     *     },\n     *     items: [\n     *         // default will not be applied here, panel1 will be autoScroll: false\n     *         {\n     *             xtype: 'panel',\n     *             id: 'panel1',\n     *             autoScroll: false\n     *         },\n     *         // this component will have autoScroll: true\n     *         new Ext.panel.Panel({\n     *             id: 'panel2'\n     *         })\n     *     ]\n     */\n\n    /**\n     * @cfg {Boolean} suspendLayout\n     * If true, suspend calls to doLayout. Useful when batching multiple adds to a container\n     * and not passing them as multiple arguments or an array.\n     */\n    suspendLayout : false,\n\n    /**\n     * @cfg {Boolean} [autoDestroy=true]\n     * If true the container will automatically destroy any contained component that is removed\n     * from it, else destruction must be handled manually.\n     */\n    autoDestroy : true,\n\n     /**\n      * @cfg {String} [defaultType=\"panel\"]\n      * The default {@link Ext.Component xtype} of child Components to create in this Container when\n      * a child item is specified as a raw configuration object, rather than as an instantiated Component.\n      */\n    defaultType: 'panel',\n    \n    /**\n     * @cfg {Boolean} [detachOnRemove=true]\n     * True to move any component to the {@link Ext#getDetachedBody detachedBody} when the component is\n     * removed from this container. This option is only applicable when the component is not destroyed while\n     * being removed, see {@link #autoDestroy} and {@link #method-remove}. If this option is set to false, the DOM\n     * of the component will remain in the current place until it is explicitly moved.\n     */\n    detachOnRemove: true,\n\n    /*\n     * @property {Boolean} isContainer\n     * `true` in this class to identify an object as an instantiated Container, or subclass thereof.\n     */\n    isContainer : true,\n\n    /**\n     * @property {Number} layoutCounter\n     * The number of container layout calls made on this object.\n     * @private\n     */\n    layoutCounter : 0,\n\n    baseCls: Ext.baseCSSPrefix + 'container',\n\n    /**\n     * @cfg {String[]} bubbleEvents\n     * An array of events that, when fired, should be bubbled to any parent container.\n     * See {@link Ext.util.Observable#enableBubble}.\n     */\n    bubbleEvents: ['add', 'remove'],\n\n    defaultLayoutType: 'auto',\n\n    // @private\n    initComponent : function(){\n        var me = this;\n        me.addEvents(\n            /**\n             * @event afterlayout\n             * Fires when the components in this container are arranged by the associated layout manager.\n             * @param {Ext.container.Container} this\n             * @param {Ext.layout.container.Container} layout The ContainerLayout implementation for this container\n             */\n            'afterlayout',\n            /**\n             * @event beforeadd\n             * Fires before any {@link Ext.Component} is added or inserted into the container.\n             * A handler can return false to cancel the add.\n             * @param {Ext.container.Container} this\n             * @param {Ext.Component} component The component being added\n             * @param {Number} index The index at which the component will be added to the container's items collection\n             */\n            'beforeadd',\n            /**\n             * @event beforeremove\n             * Fires before any {@link Ext.Component} is removed from the container.  A handler can return\n             * false to cancel the remove.\n             * @param {Ext.container.Container} this\n             * @param {Ext.Component} component The component being removed\n             */\n            'beforeremove',\n            /**\n             * @event add\n             * Fires after any {@link Ext.Component} is added or inserted into the container.\n             * \n             * **This event bubbles:** 'add' will also be fired when Component is added to any of\n             * the child containers or their childern or ...\n             * @param {Ext.container.Container} this\n             * @param {Ext.Component} component The component that was added\n             * @param {Number} index The index at which the component was added to the container's items collection\n             */\n            'add',\n            /**\n             * @event remove\n             * Fires after any {@link Ext.Component} is removed from the container.\n             *\n             * **This event bubbles:** 'remove' will also be fired when Component is removed from any of\n             * the child containers or their children or ...\n             * @param {Ext.container.Container} this\n             * @param {Ext.Component} component The component that was removed\n             */\n            'remove'\n        );\n\n        me.callParent();\n\n        me.getLayout();\n        me.initItems();\n    },\n\n    // @private\n    initItems : function() {\n        var me = this,\n            items = me.items;\n\n        /**\n         * The MixedCollection containing all the child items of this container.\n         * @property items\n         * @type Ext.util.AbstractMixedCollection\n         */\n        me.items = new Ext.util.AbstractMixedCollection(false, me.getComponentId);\n\n        if (items) {\n            if (!Ext.isArray(items)) {\n                items = [items];\n            }\n\n            me.add(items);\n        }\n    },\n\n    /**\n     * @private\n     * Returns the focus holder element associated with this Container. By default, this is the Container's target\n     * element. Subclasses which use embedded focusable elements (such as Window and Button) should override this for use\n     * by the {@link #method-focus} method.\n     * @returns {Ext.Element} the focus holding element.\n     */\n    getFocusEl: function() {\n        return this.getTargetEl();\n    },\n\n    finishRenderChildren: function () {\n        this.callParent();\n\n        var layout = this.getLayout();\n\n        if (layout) {\n            layout.finishRender();\n        }\n    },\n\n    beforeRender: function () {\n        var me = this,\n            layout = me.getLayout();\n\n        me.callParent();\n\n        if (!layout.initialized) {\n            layout.initLayout();\n        }\n    },\n    \n    setupRenderTpl: function (renderTpl) {\n        var layout = this.getLayout();\n\n        this.callParent(arguments);\n\n        layout.setupRenderTpl(renderTpl);\n    },\n\n    // @private\n    setLayout : function(layout) {\n        var currentLayout = this.layout;\n\n        if (currentLayout && currentLayout.isLayout && currentLayout != layout) {\n            currentLayout.setOwner(null);\n        }\n\n        this.layout = layout;\n        layout.setOwner(this);\n    },\n\n    /**\n     * Returns the {@link Ext.layout.container.Container layout} instance currently associated with this Container.\n     * If a layout has not been instantiated yet, that is done first\n     * @return {Ext.layout.container.Container} The layout\n     */\n    getLayout : function() {\n        var me = this;\n        if (!me.layout || !me.layout.isLayout) {\n            // Pass any configured in layout property, defaulting to the prototype's layout property, falling back to Auto.\n            me.setLayout(Ext.layout.Layout.create(me.layout, me.self.prototype.layout || 'autocontainer'));\n        }\n\n        return me.layout;\n    },\n\n    /**\n     * Manually force this container's layout to be recalculated. The framework uses this internally to refresh layouts\n     * form most cases.\n     * @return {Ext.container.Container} this\n     */\n    doLayout : function() {\n        this.updateLayout();\n        return this;\n    },\n\n    /**\n     * Invoked after the Container has laid out (and rendered if necessary)\n     * its child Components.\n     *\n     * @param {Ext.layout.container.Container} layout\n     *\n     * @template\n     * @protected\n     */\n    afterLayout : function(layout) {\n        var me = this;\n        ++me.layoutCounter;\n        if (me.hasListeners.afterlayout) {\n            me.fireEvent('afterlayout', me, layout);\n        }\n    },\n\n    // @private\n    prepareItems : function(items, applyDefaults) {\n        // Create an Array which does not refer to the passed array.\n        // The passed array is a reference to a user's config object and MUST NOT be mutated.\n        if (Ext.isArray(items)) {\n            items = items.slice();\n        } else {\n            items = [items];\n        }\n\n        // Make sure defaults are applied and item is initialized\n        var me = this,\n            i = 0,\n            len = items.length,\n            item;\n\n        for (; i < len; i++) {\n            item = items[i];\n            if (item == null) {\n                Ext.Array.erase(items, i, 1);\n                --i;\n                --len;\n            } else {\n                if (applyDefaults) {\n                    item = this.applyDefaults(item);\n                }\n\n                // Tell the item we're in a container during construction\n                item.isContained = me;\n                items[i] = me.lookupComponent(item);\n                delete item.isContained;\n            }\n        }\n\n        return items;\n    },\n\n    // @private\n    applyDefaults : function(config) {\n        var defaults = this.defaults;\n\n        if (defaults) {\n            if (Ext.isFunction(defaults)) {\n                defaults = defaults.call(this, config);\n            }\n\n            if (Ext.isString(config)) {\n                config = Ext.ComponentManager.get(config);\n            }\n            Ext.applyIf(config, defaults);\n        }\n        return config;\n    },\n\n    // @private\n    lookupComponent : function(comp) {\n        return (typeof comp == 'string') ? Ext.ComponentManager.get(comp)\n                                         : Ext.ComponentManager.create(comp, this.defaultType);\n    },\n\n    // @private - used as the key lookup function for the items collection\n    getComponentId : function(comp) {\n        return comp.getItemId();\n    },\n\n    /**\n     * Adds {@link Ext.Component Component}(s) to this Container.\n     *\n     * ## Description:\n     *\n     * - Fires the {@link #beforeadd} event before adding.\n     * - The Container's {@link #defaults default config values} will be applied\n     *   accordingly (see `{@link #defaults}` for details).\n     * - Fires the `{@link #event-add}` event after the component has been added.\n     *\n     * ## Notes:\n     *\n     * If the Container is __already rendered__ when `add`\n     * is called, it will render the newly added Component into its content area.\n     *\n     * **If** the Container was configured with a size-managing {@link #layout} manager,\n     * the Container will recalculate its internal layout at this time too.\n     *  \n     * Note that the default layout manager simply renders child Components sequentially\n     * into the content area and thereafter performs no sizing.\n     *  \n     * If adding multiple new child Components, pass them as an array to the `add` method,\n     * so that only one layout recalculation is performed.\n     *  \n     *     tb = new {@link Ext.toolbar.Toolbar}({\n     *         renderTo: document.body\n     *     });  // toolbar is rendered\n     *     // add multiple items.\n     *     // ({@link #defaultType} for {@link Ext.toolbar.Toolbar Toolbar} is 'button')\n     *     tb.add([{text:'Button 1'}, {text:'Button 2'}]);\n     *\n     * To inject components between existing ones, use the {@link #insert} method.\n     *\n     * ## Warning:\n     *\n     * Components directly managed by the BorderLayout layout manager may not be removed\n     * or added.  See the Notes for {@link Ext.layout.container.Border BorderLayout} for\n     * more details.\n     *\n     * @param {Ext.Component[]/Ext.Component...} component\n     * Either one or more Components to add or an Array of Components to add.\n     * See `{@link #cfg-items}` for additional information.\n     *\n     * @return {Ext.Component[]/Ext.Component} The Components that were added.\n     */\n    add : function() {\n        var me = this,\n            args = Ext.Array.slice(arguments),\n            index = (typeof args[0] == 'number') ? args.shift() : -1,\n            layout = me.getLayout(),\n            addingArray, items, i, length, item, pos, ret;\n\n        if (args.length == 1 && Ext.isArray(args[0])) {\n            items = args[0];\n            addingArray = true;\n        } else {\n            items = args;\n        }\n\n        ret = items = me.prepareItems(items, true);\n        length = items.length;\n\n        if (me.rendered) {\n            Ext.suspendLayouts(); // suspend layouts while adding items...\n        }\n\n        if (!addingArray && length == 1) { // an array of 1 should still return an array...\n            ret = items[0];\n        }\n\n        // loop\n        for (i = 0; i < length; i++) {\n            item = items[i];\n            if (!item) {\n                Ext.Error.raise(\"Cannot add null item to Container with itemId/id: \" + me.getItemId());\n            }\n\n            pos = (index < 0) ? me.items.length : (index + i);\n\n            // Floating Components are not added into the items collection, but to a separate floatingItems collection\n            if (item.floating) {\n                me.floatingItems = me.floatingItems || new Ext.util.MixedCollection();\n                me.floatingItems.add(item);\n                item.onAdded(me, pos);\n            } else if ((!me.hasListeners.beforeadd || me.fireEvent('beforeadd', me, item, pos) !== false) && me.onBeforeAdd(item) !== false) {\n                me.items.insert(pos, item);\n                item.onAdded(me, pos);\n                me.onAdd(item, pos);\n                layout.onAdd(item, pos);\n\n                if (me.hasListeners.add) {\n                    me.fireEvent('add', me, item, pos);\n                }\n            }\n        }\n\n        // We need to update our layout after adding all passed items\n        me.updateLayout();\n        if (me.rendered) {\n            Ext.resumeLayouts(true);\n        }\n\n        return ret;\n    },\n\n    /**\n     * This method is invoked after a new Component has been added. It\n     * is passed the Component which has been added. This method may\n     * be used to update any internal structure which may depend upon\n     * the state of the child items.\n     *\n     * @param {Ext.Component} component\n     * @param {Number} position\n     *\n     * @template\n     * @protected\n     */\n    onAdd : Ext.emptyFn,\n\n    /**\n     * This method is invoked after a new Component has been\n     * removed. It is passed the Component which has been\n     * removed. This method may be used to update any internal\n     * structure which may depend upon the state of the child items.\n     *\n     * @param {Ext.Component} component\n     * @param {Boolean} autoDestroy\n     *\n     * @template\n     * @protected\n     */\n    onRemove : Ext.emptyFn,\n\n    /**\n     * Inserts a Component into this Container at a specified index. Fires the\n     * {@link #beforeadd} event before inserting, then fires the {@link #event-add}\n     * event after the Component has been inserted.\n     *\n     * @param {Number} index The index at which the Component will be inserted\n     * into the Container's items collection\n     *\n     * @param {Ext.Component} component The child Component to insert.\n     *\n     * Ext uses lazy rendering, and will only render the inserted Component should\n     * it become necessary.\n     *\n     * A Component config object may be passed in order to avoid the overhead of\n     * constructing a real Component object if lazy rendering might mean that the\n     * inserted Component will not be rendered immediately. To take advantage of\n     * this 'lazy instantiation', set the {@link Ext.Component#xtype} config\n     * property to the registered type of the Component wanted.\n     *\n     * For a list of all available xtypes, see {@link Ext.Component}.\n     *\n     * @return {Ext.Component} component The Component (or config object) that was\n     * inserted with the Container's default config values applied.\n     */\n    insert : function(index, comp) {\n        return this.add(index, comp);\n    },\n\n    /**\n     * Moves a Component within the Container\n     * @param {Number} fromIdx The index the Component you wish to move is currently at.\n     * @param {Number} toIdx The new index for the Component.\n     * @return {Ext.Component} component The Component (or config object) that was moved.\n     */\n    move : function(fromIdx, toIdx) {\n        var items = this.items,\n            item;\n        item = items.removeAt(fromIdx);\n        if (item === false) {\n            return false;\n        }\n        items.insert(toIdx, item);\n        this.doLayout();\n        return item;\n    },\n\n    /**\n     * This method is invoked before adding a new child Component. It\n     * is passed the new Component, and may be used to modify the\n     * Component, or prepare the Container in some way. Returning\n     * false aborts the add operation.\n     *\n     * @param {Ext.Component} item\n     *\n     * @template\n     * @protected\n     */\n    onBeforeAdd : function(item) {\n        var me = this,\n            border = item.border;\n\n        // Remove from current container if it's not us.\n        if (item.ownerCt && item.ownerCt !== me) {\n            item.ownerCt.remove(item, false);\n        }\n\n        if (me.border === false || me.border === 0) {\n            // If the parent has no border, only use an explicitly defined border\n            item.border = Ext.isDefined(border) && border !== false && border !== 0;\n        }\n    },\n\n    /**\n     * Removes a component from this container.  Fires the {@link #beforeremove} event\n     * before removing, then fires the {@link #event-remove} event after the component has\n     * been removed.\n     *\n     * @param {Ext.Component/String} component The component reference or id to remove.\n     *\n     * @param {Boolean} [autoDestroy] True to automatically invoke the removed Component's\n     * {@link Ext.Component#method-destroy} function.\n     *\n     * Defaults to the value of this Container's {@link #autoDestroy} config.\n     *\n     * @return {Ext.Component} component The Component that was removed.\n     */\n    remove : function(comp, autoDestroy) {\n        var me = this,\n            c = me.getComponent(comp);\n            if (Ext.isDefined(Ext.global.console) && !c) {\n                Ext.global.console.warn(\"Attempted to remove a component that does not exist. Ext.container.Container: remove takes an argument of the component to remove. cmp.remove() is incorrect usage.\");\n            }\n\n        if (c && (!me.hasListeners.beforeremove || me.fireEvent('beforeremove', me, c) !== false)) {\n            me.doRemove(c, autoDestroy);\n            if (me.hasListeners.remove) {\n                me.fireEvent('remove', me, c);\n            }\n\n            if (!me.destroying) {\n                me.doLayout();\n            }\n        }\n\n        return c;\n    },\n\n    // @private\n    doRemove : function(component, autoDestroy) {\n        var me = this,\n            layout = me.layout,\n            hasLayout = layout && me.rendered,\n            destroying = autoDestroy === true || (autoDestroy !== false && me.autoDestroy);\n\n        autoDestroy = autoDestroy === true || (autoDestroy !== false && me.autoDestroy);\n        me.items.remove(component);\n\n        // Inform ownerLayout of removal before deleting the ownerLayout & ownerCt references in the onRemoved call\n        if (hasLayout) {\n            // Removing a component from a running layout has to cancel the layout\n            if (layout.running) {\n                Ext.AbstractComponent.cancelLayout(component, destroying);\n            }\n            layout.onRemove(component, destroying);\n        }\n\n        component.onRemoved(destroying);\n\n        me.onRemove(component, destroying);\n\n        // Destroy if we were explicitly told to, or we're defaulting to our autoDestroy configuration\n        if (destroying) {\n            component.destroy();\n        }\n        // Only have the layout perform remove postprocessing if the Component is not being destroyed\n        else {\n            if (hasLayout) {\n                layout.afterRemove(component);       \n            }\n            if (me.detachOnRemove && component.rendered) {\n                Ext.getDetachedBody().appendChild(component.getEl());\n            }\n        }\n    },\n\n    /**\n     * Removes all components from this container.\n     * @param {Boolean} [autoDestroy] True to automatically invoke the removed\n     * Component's {@link Ext.Component#method-destroy} function.\n     * Defaults to the value of this Container's {@link #autoDestroy} config.\n     * @return {Ext.Component[]} Array of the removed components\n     */\n    removeAll : function(autoDestroy) {\n        var me = this,\n            removeItems = me.items.items.slice(),\n            items = [],\n            i = 0,\n            len = removeItems.length,\n            item;\n\n        // Suspend Layouts while we remove multiple items from the container\n        me.suspendLayouts();\n        for (; i < len; i++) {\n            item = removeItems[i];\n            me.remove(item, autoDestroy);\n\n            if (item.ownerCt !== me) {\n                items.push(item);\n            }\n        }\n\n        // Resume Layouts now that all items have been removed and do a single layout (if we removed anything!)\n        me.resumeLayouts(!!len);\n        return items;\n    },\n\n    // Used by ComponentQuery to retrieve all of the items\n    // which can potentially be considered a child of this Container.\n    // This should be overriden by components which have child items\n    // that are not contained in items. For example dockedItems, menu, etc\n    // IMPORTANT note for maintainers:\n    //  Items are returned in tree traversal order. Each item is appended to the result array\n    //  followed by the results of that child's getRefItems call.\n    //  Floating child items are appended after internal child items.\n    getRefItems : function(deep) {\n        var me = this,\n            items = me.items.items,\n            len = items.length,\n            i = 0,\n            item,\n            result = [];\n\n        for (; i < len; i++) {\n            item = items[i];\n            result.push(item);\n            if (deep && item.getRefItems) {\n                result.push.apply(result, item.getRefItems(true));\n            }\n        }\n\n        // Append floating items to the list.\n        if (me.floatingItems) {\n            result.push.apply(result, me.floatingItems.items);\n        }\n\n        return result;\n    },\n\n    /**\n     * Cascades down the component/container heirarchy from this component (passed in\n     * the first call), calling the specified function with each component. The scope\n     * (this reference) of the function call will be the scope provided or the current\n     * component. The arguments to the function will be the args provided or the current\n     * component. If the function returns false at any point, the cascade is stopped on\n     * that branch.\n     * @param {Function} fn The function to call\n     * @param {Object} [scope] The scope of the function (defaults to current component)\n     * @param {Array} [args] The args to call the function with. The current component\n     * always passed as the last argument.\n     * @return {Ext.Container} this\n     */\n    cascade : function(fn, scope, origArgs){\n        var me = this,\n            cs = me.items ? me.items.items : [],\n            len = cs.length,\n            i = 0,\n            c,\n            args = origArgs ? origArgs.concat(me) : [me],\n            componentIndex = args.length - 1;\n\n        if (fn.apply(scope || me, args) !== false) {\n            for (; i < len; i++){\n                c = cs[i];\n                if (c.cascade) {\n                    c.cascade(fn, scope, origArgs);\n                } else {\n                    args[componentIndex] = c;\n                    fn.apply(scope || cs, args);\n                }\n            }\n        }\n        return this;\n    },\n\n    /**\n     * Determines whether **this Container** is an ancestor of the passed Component.\n     * This will return `true` if the passed Component is anywhere within the subtree\n     * beneath this Container.\n     * @param {Ext.Component} possibleDescendant The Component to test for presence\n     * within this Container's subtree.\n     */\n    isAncestor: function(possibleDescendant) {\n        while (possibleDescendant) {\n            if (possibleDescendant.ownerCt === this) {\n                return true;\n            }\n            possibleDescendant = possibleDescendant.ownerCt;\n        }\n    },\n\n    /**\n     * Examines this container's {@link #property-items} **property** and gets a direct child\n     * component of this container.\n     *\n     * @param {String/Number} comp This parameter may be any of the following:\n     *\n     * - a **String** : representing the {@link Ext.Component#itemId itemId}\n     *   or {@link Ext.Component#id id} of the child component.\n     * - a **Number** : representing the position of the child component\n     *   within the {@link #property-items} **property**\n     *\n     * For additional information see {@link Ext.util.MixedCollection#get}.\n     *\n     * @return {Ext.Component} The component (if found).\n     */\n    getComponent : function(comp) {\n        if (Ext.isObject(comp)) {\n            comp = comp.getItemId();\n        }\n\n        return this.items.get(comp);\n    },\n\n    /**\n     * Retrieves all descendant components which match the passed selector.\n     * Executes an Ext.ComponentQuery.query using this container as its root.\n     * @param {String} [selector] Selector complying to an Ext.ComponentQuery selector.\n     * If no selector is specified all items will be returned.\n     * @return {Ext.Component[]} Components which matched the selector\n     */\n    query : function(selector) {\n        selector = selector || '*';\n        return Ext.ComponentQuery.query(selector, this);\n    },\n    \n    /**\n     * Retrieves all descendant components which match the passed function.\n     * The function should return false for components that are to be\n     * excluded from the selection.\n     * @param {Function} fn The matcher function. It will be called with a single argument,\n     * the component being tested.\n     * @param {Object} [scope] The scope in which to run the function. If not specified,\n     * it will default to the active component.\n     * @return {Ext.Component[]} Components matched by the passed function\n     */\n    queryBy: function(fn, scope) {\n        var out = [],\n            items = this.getRefItems(true),\n            i = 0,\n            len = items.length,\n            item;\n            \n        for (; i < len; ++i) {\n            item = items[i];\n            if (fn.call(scope || item, item) !== false) {\n                out.push(item);\n            }\n        }\n        return out;\n    },\n    \n    /**\n     * Finds a component at any level under this container matching the id/itemId.\n     * This is a shorthand for calling ct.down('#' + id);\n     * @param {String} id The id to find\n     * @return {Ext.Component} The matching id, null if not found\n     */\n    queryById: function(id){\n        return this.down('#' + id);\n    },\n\n    /**\n     * Retrieves the first direct child of this container which matches the passed selector.\n     * The passed in selector must comply with an Ext.ComponentQuery selector.\n     * @param {String} [selector] An Ext.ComponentQuery selector. If no selector is\n     * specified, the first child will be returned.\n     * @return Ext.Component\n     */\n    child : function(selector) {\n        selector = selector || '';\n        return this.query('> ' + selector)[0] || null;\n    },\n\n    nextChild: function(child, selector) {\n        var me = this,\n            result,\n            childIndex = me.items.indexOf(child);\n\n        if (childIndex !== -1) {\n            result = selector ? Ext.ComponentQuery(selector, me.items.items.slice(childIndex + 1)) : me.items.getAt(childIndex + 1);\n            if (!result && me.ownerCt) {\n                result = me.ownerCt.nextChild(me, selector);\n            }\n        }\n        return result;\n    },\n\n    prevChild: function(child, selector) {\n        var me = this,\n            result,\n            childIndex = me.items.indexOf(child);\n\n        if (childIndex !== -1) {\n            result = selector ? Ext.ComponentQuery(selector, me.items.items.slice(childIndex + 1)) : me.items.getAt(childIndex + 1);\n            if (!result && me.ownerCt) {\n                result = me.ownerCt.nextChild(me, selector);\n            }\n        }\n        return result;\n    },\n\n    /**\n     * Retrieves the first descendant of this container which matches the passed selector.\n     * The passed in selector must comply with an Ext.ComponentQuery selector.\n     * @param {String} [selector] An Ext.ComponentQuery selector. If no selector is\n     * specified, the first child will be returned.\n     * @return Ext.Component\n     */\n    down : function(selector) {\n        return this.query(selector)[0] || null;\n    },\n\n    // @private\n    // Enable all immediate children that was previously disabled\n    // Override enable because onEnable only gets called when rendered\n    enable: function() {\n        this.callParent(arguments);\n\n        var itemsToDisable = this.getChildItemsToDisable(),\n            length         = itemsToDisable.length,\n            item, i;\n\n        for (i = 0; i < length; i++) {\n            item = itemsToDisable[i];\n\n            if (item.resetDisable) {\n                item.enable();\n            }\n        }\n\n        return this;\n    },\n\n    // Inherit docs\n    // Disable all immediate children that was previously disabled\n    // Override disable because onDisable only gets called when rendered\n    disable: function() {\n        this.callParent(arguments);\n\n        var itemsToDisable = this.getChildItemsToDisable(),\n            length         = itemsToDisable.length,\n            item, i;\n\n        for (i = 0; i < length; i++) {\n            item = itemsToDisable[i];\n\n            if (item.resetDisable !== false && !item.disabled) {\n                item.disable();\n                item.resetDisable = true;\n            }\n        }\n\n        return this;\n    },\n    \n    /**\n     * Gets a list of child components to enable/disable when the container is\n     * enabled/disabled\n     * @private\n     * @return {Ext.Component[]} Items to be enabled/disabled\n     */\n    getChildItemsToDisable: function(){\n        return this.query('[isFormField],button');\n    },\n\n    /**\n     * Occurs before componentLayout is run. Returning false from this method\n     * will prevent the containerLayout from being executed.\n     *\n     * @template\n     * @protected\n     */\n    beforeLayout: function() {\n        return true;\n    },\n\n    // @private\n    beforeDestroy : function() {\n        var me = this,\n            items = me.items,\n            c;\n\n        if (items) {\n            while ((c = items.first())) {\n                me.doRemove(c, true);\n            }\n        }\n\n        Ext.destroy(\n            me.layout\n        );\n        me.callParent();\n    }\n});\n\n/**\n * Base class for any Ext.Component that may contain other Components. Containers handle the basic behavior of\n * containing items, namely adding, inserting and removing items.\n *\n * The most commonly used Container classes are Ext.panel.Panel, Ext.window.Window and\n * Ext.tab.Panel. If you do not need the capabilities offered by the aforementioned classes you can create a\n * lightweight Container to be encapsulated by an HTML element to your specifications by using the\n * {@link Ext.Component#autoEl autoEl} config option.\n *\n * The code below illustrates how to explicitly create a Container:\n *\n *     @example\n *     // Explicitly create a Container\n *     Ext.create('Ext.container.Container', {\n *         layout: {\n *             type: 'hbox'\n *         },\n *         width: 400,\n *         renderTo: Ext.getBody(),\n *         border: 1,\n *         style: {borderColor:'#000000', borderStyle:'solid', borderWidth:'1px'},\n *         defaults: {\n *             labelWidth: 80,\n *             // implicitly create Container by specifying xtype\n *             xtype: 'datefield',\n *             flex: 1,\n *             style: {\n *                 padding: '10px'\n *             }\n *         },\n *         items: [{\n *             xtype: 'datefield',\n *             name: 'startDate',\n *             fieldLabel: 'Start date'\n *         },{\n *             xtype: 'datefield',\n *             name: 'endDate',\n *             fieldLabel: 'End date'\n *         }]\n *     });\n *\n * ## Layout\n *\n * Container classes delegate the rendering of child Components to a layout manager class which must be configured into\n * the Container using the `{@link #layout}` configuration property.\n *\n * When either specifying child `{@link #cfg-items}` of a Container, or dynamically {@link #method-add adding} Components to a\n * Container, remember to consider how you wish the Container to arrange those child elements, and whether those child\n * elements need to be sized using one of Ext's built-in `{@link #layout}` schemes. By default, Containers use the\n * {@link Ext.layout.container.Auto Auto} scheme which only renders child components, appending them one after the other\n * inside the Container, and **does not apply any sizing** at all.\n *\n * A common mistake is when a developer neglects to specify a `{@link #layout}` (e.g. widgets like GridPanels or\n * TreePanels are added to Containers for which no `{@link #layout}` has been specified). If a Container is left to\n * use the default {@link Ext.layout.container.Auto Auto} scheme, none of its child components will be resized, or changed in\n * any way when the Container is resized.\n *\n * Certain layout managers allow dynamic addition of child components. Those that do include\n * Ext.layout.container.Card, Ext.layout.container.Anchor, Ext.layout.container.VBox,\n * Ext.layout.container.HBox, and Ext.layout.container.Table. For example:\n *\n *     //  Create the GridPanel.\n *     var myNewGrid = Ext.create('Ext.grid.Panel', {\n *         store: myStore,\n *         headers: myHeaders,\n *         title: 'Results', // the title becomes the title of the tab\n *     });\n *\n *     myTabPanel.add(myNewGrid); // {@link Ext.tab.Panel} implicitly uses {@link Ext.layout.container.Card Card}\n *     myTabPanel.{@link Ext.tab.Panel#setActiveTab setActiveTab}(myNewGrid);\n *\n * The example above adds a newly created GridPanel to a TabPanel. Note that a TabPanel uses {@link\n * Ext.layout.container.Card} as its layout manager which means all its child items are sized to {@link\n * Ext.layout.container.Fit fit} exactly into its client area.\n *\n * **_Overnesting is a common problem_**. An example of overnesting occurs when a GridPanel is added to a TabPanel by\n * wrapping the GridPanel _inside_ a wrapping Panel (that has no `{@link #layout}` specified) and then add that\n * wrapping Panel to the TabPanel. The point to realize is that a GridPanel **is** a Component which can be added\n * directly to a Container. If the wrapping Panel has no `{@link #layout}` configuration, then the overnested\n * GridPanel will not be sized as expected.\n *\n * ## Adding via remote configuration\n *\n * A server side script can be used to add Components which are generated dynamically on the server. An example of\n * adding a GridPanel to a TabPanel where the GridPanel is generated by the server based on certain parameters:\n *\n *     // execute an Ajax request to invoke server side script:\n *     Ext.Ajax.request({\n *         url: 'gen-invoice-grid.php',\n *         // send additional parameters to instruct server script\n *         params: {\n *             startDate: Ext.getCmp('start-date').getValue(),\n *             endDate: Ext.getCmp('end-date').getValue()\n *         },\n *         // process the response object to add it to the TabPanel:\n *         success: function(xhr) {\n *             var newComponent = eval(xhr.responseText); // see discussion below\n *             myTabPanel.add(newComponent); // add the component to the TabPanel\n *             myTabPanel.setActiveTab(newComponent);\n *         },\n *         failure: function() {\n *             Ext.Msg.alert(\"Grid create failed\", \"Server communication failure\");\n *         }\n *     });\n *\n * The server script needs to return a JSON representation of a configuration object, which, when decoded will return a\n * config object with an {@link Ext.Component#xtype xtype}. The server might return the following JSON:\n *\n *     {\n *         \"xtype\": 'grid',\n *         \"title\": 'Invoice Report',\n *         \"store\": {\n *             \"model\": 'Invoice',\n *             \"proxy\": {\n *                 \"type\": 'ajax',\n *                 \"url\": 'get-invoice-data.php',\n *                 \"reader\": {\n *                     \"type\": 'json'\n *                     \"record\": 'transaction',\n *                     \"idProperty\": 'id',\n *                     \"totalRecords\": 'total'\n *                 })\n *             },\n *             \"autoLoad\": {\n *                 \"params\": {\n *                     \"startDate\": '01/01/2008',\n *                     \"endDate\": '01/31/2008'\n *                 }\n *             }\n *         },\n *         \"headers\": [\n *             {\"header\": \"Customer\", \"width\": 250, \"dataIndex\": 'customer', \"sortable\": true},\n *             {\"header\": \"Invoice Number\", \"width\": 120, \"dataIndex\": 'invNo', \"sortable\": true},\n *             {\"header\": \"Invoice Date\", \"width\": 100, \"dataIndex\": 'date', \"renderer\": Ext.util.Format.dateRenderer('M d, y'), \"sortable\": true},\n *             {\"header\": \"Value\", \"width\": 120, \"dataIndex\": 'value', \"renderer\": 'usMoney', \"sortable\": true}\n *         ]\n *     }\n *\n * When the above code fragment is passed through the `eval` function in the success handler of the Ajax request, the\n * result will be a config object which, when added to a Container, will cause instantiation of a GridPanel. **Be sure\n * that the Container is configured with a layout which sizes and positions the child items to your requirements.**\n *\n * **Note:** since the code above is _generated_ by a server script, the `autoLoad` params for the Store, the user's\n * preferred date format, the metadata to allow generation of the Model layout, and the ColumnModel can all be generated\n * into the code since these are all known on the server.\n */\nExt.define('Ext.container.Container', {\n    extend: 'Ext.container.AbstractContainer',\n    alias: 'widget.container',\n    alternateClassName: 'Ext.Container',\n\n    /*\n     * For more information on the following methods, see the note for the\n     * hierarchyEventSource observer defined in the class' callback\n     */\n    fireHierarchyEvent: function (ename) {\n        this.hierarchyEventSource.fireEvent(ename, this);\n    },\n\n    // note that the collapse and expand events are fired explicitly from Panel.js\n    afterHide: function() {\n        this.callParent(arguments);\n        this.fireHierarchyEvent('hide');\n    },\n    \n    afterShow: function(){\n        this.callParent(arguments);\n        this.fireHierarchyEvent('show');\n    },\n\n    onAdded: function() {\n        this.callParent(arguments);\n        if (this.hierarchyEventSource.hasListeners.added) {\n            this.fireHierarchyEvent('added');\n        }\n    },\n\n    /**\n     * Return the immediate child Component in which the passed element is located.\n     * @param {Ext.Element/HTMLElement/String} el The element to test (or ID of element).\n     * @param {Boolean} deep If `true`, returns the deepest descendant Component which contains the passed element.\n     * @return {Ext.Component} The child item which contains the passed element.\n     */\n    getChildByElement: function(el, deep) {\n        var item,\n            itemEl,\n            i = 0,\n            it = this.getRefItems(),\n            ln = it.length;\n\n        el = Ext.getDom(el);\n        for (; i < ln; i++) {\n            item = it[i];\n            itemEl = item.getEl();\n            if (itemEl && ((itemEl.dom === el) || itemEl.contains(el))) {\n                return (deep && item.getChildByElement) ? item.getChildByElement(el, deep) : item;\n            }\n        }\n        return null;\n    }\n}, function () {\n    /*\n     * The observer below is used to be able to detect showing/hiding at various levels\n     * in the hierarchy. While it's not particularly expensive to bubble an event up,\n     * cascading an event down can be quite costly.\n     * \n     * The main usage for this is to do with floating components. For example, the load mask\n     * is a floating component. The component it is masking may be inside several containers.\n     * As such, we need to know when component is hidden, either directly, or via a parent\n     * container being hidden. We can subscribe to these events and filter out the appropriate\n     * container.\n     */\n    this.hierarchyEventSource = this.prototype.hierarchyEventSource = new Ext.util.Observable({ events: {\n        hide: true,\n        show: true,\n        collapse: true,\n        expand: true,\n        added: true\n    }});\n});\n\n/**\n * The Editor class is used to provide inline editing for elements on the page. The editor\n * is backed by a {@link Ext.form.field.Field} that will be displayed to edit the underlying content.\n * The editor is a floating Component, when the editor is shown it is automatically aligned to\n * display over the top of the bound element it is editing. The Editor contains several options\n * for how to handle key presses:\n *\n * - {@link #completeOnEnter}\n * - {@link #cancelOnEsc}\n * - {@link #swallowKeys}\n *\n * It also has options for how to use the value once the editor has been activated:\n *\n * - {@link #revertInvalid}\n * - {@link #ignoreNoChange}\n * - {@link #updateEl}\n *\n * Sample usage:\n *\n *     var editor = new Ext.Editor({\n *         updateEl: true, // update the innerHTML of the bound element when editing completes\n *         field: {\n *             xtype: 'textfield'\n *         }\n *     });\n *     var el = Ext.get('my-text'); // The element to 'edit'\n *     editor.startEdit(el); // The value of the field will be taken as the innerHTML of the element.\n *\n * {@img Ext.Editor/Ext.Editor.png Ext.Editor component}\n *\n */\nExt.define('Ext.Editor', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.container.Container',\n\n    alias: 'widget.editor',\n\n    requires: ['Ext.layout.container.Editor'],\n\n    /* End Definitions */\n\n   layout: 'editor',\n\n    /**\n    * @cfg {Ext.form.field.Field} field\n    * The Field object (or descendant) or config object for field\n    */\n\n    /**\n     * @cfg {Boolean} allowBlur\n     * True to {@link #completeEdit complete the editing process} if in edit mode when the\n     * field is blurred.\n     */\n    allowBlur: true,\n\n    /**\n     * @cfg {Boolean/Object} autoSize\n     * True for the editor to automatically adopt the size of the underlying field. Otherwise, an object\n     * can be passed to indicate where to get each dimension. The available properties are 'boundEl' and\n     * 'field'. If a dimension is not specified, it will use the underlying height/width specified on\n     * the editor object.\n     * Examples:\n     *\n     *     autoSize: true // The editor will be sized to the height/width of the field\n     *\n     *     height: 21,\n     *     autoSize: {\n     *         width: 'boundEl' // The width will be determined by the width of the boundEl, the height from the editor (21)\n     *     }\n     *\n     *     autoSize: {\n     *         width: 'field', // Width from the field\n     *         height: 'boundEl' // Height from the boundEl\n     *     }\n     */\n\n    /**\n     * @cfg {Boolean} revertInvalid\n     * True to automatically revert the field value and cancel the edit when the user completes an edit and the field\n     * validation fails\n     */\n    revertInvalid: true,\n\n    /**\n     * @cfg {Boolean} [ignoreNoChange=false]\n     * True to skip the edit completion process (no save, no events fired) if the user completes an edit and\n     * the value has not changed.  Applies only to string values - edits for other data types\n     * will never be ignored.\n     */\n\n    /**\n     * @cfg {Boolean} [hideEl=true]\n     * False to keep the bound element visible while the editor is displayed\n     */\n\n    /**\n     * @cfg {Object} value\n     * The data value of the underlying field\n     */\n    value : '',\n\n    /**\n     * @cfg {String} alignment\n     * The position to align to (see {@link Ext.Element#alignTo} for more details).\n     */\n    alignment: 'c-c?',\n\n    /**\n     * @cfg {Number[]} offsets\n     * The offsets to use when aligning (see {@link Ext.Element#alignTo} for more details.\n     */\n    offsets: [0, 0],\n\n    /**\n     * @cfg {Boolean/String} shadow\n     * \"sides\" for sides/bottom only, \"frame\" for 4-way shadow, and \"drop\" for bottom-right shadow.\n     */\n    shadow : 'frame',\n\n    /**\n     * @cfg {Boolean} constrain\n     * True to constrain the editor to the viewport\n     */\n    constrain : false,\n\n    /**\n     * @cfg {Boolean} swallowKeys\n     * Handle the keydown/keypress events so they don't propagate\n     */\n    swallowKeys : true,\n\n    /**\n     * @cfg {Boolean} completeOnEnter\n     * True to complete the edit when the enter key is pressed.\n     */\n    completeOnEnter : true,\n\n    /**\n     * @cfg {Boolean} cancelOnEsc\n     * True to cancel the edit when the escape key is pressed.\n     */\n    cancelOnEsc : true,\n\n    /**\n     * @cfg {Boolean} updateEl\n     * True to update the innerHTML of the bound element when the update completes\n     */\n    updateEl : false,\n\n    /**\n     * @cfg {String/HTMLElement/Ext.Element} [parentEl=document.body]\n     * An element to render to.\n     */\n\n    // private overrides\n    hidden: true,\n    baseCls: Ext.baseCSSPrefix + 'editor',\n\n    initComponent : function() {\n        var me = this,\n            field = me.field = Ext.ComponentManager.create(me.field, 'textfield');\n\n        Ext.apply(field, {\n            inEditor: true,\n            msgTarget: field.msgTarget == 'title' ? 'title' :  'qtip'\n        });\n        me.mon(field, {\n            scope: me,\n            blur: {\n                fn: me.onFieldBlur,\n                // slight delay to avoid race condition with startEdits (e.g. grid view refresh)\n                delay: 1\n            },\n            specialkey: me.onSpecialKey\n        });\n\n        if (field.grow) {\n            me.mon(field, 'autosize', me.onFieldAutosize,  me, {delay: 1});\n        }\n        me.floating = {\n            constrain: me.constrain\n        };\n        me.items = field;\n\n        me.callParent(arguments);\n\n        me.addEvents(\n            /**\n             * @event beforestartedit\n             * Fires when editing is initiated, but before the value changes.  Editing can be canceled by returning\n             * false from the handler of this event.\n             * @param {Ext.Editor} this\n             * @param {Ext.Element} boundEl The underlying element bound to this editor\n             * @param {Object} value The field value being set\n             */\n            'beforestartedit',\n\n            /**\n             * @event startedit\n             * Fires when this editor is displayed\n             * @param {Ext.Editor} this\n             * @param {Ext.Element} boundEl The underlying element bound to this editor\n             * @param {Object} value The starting field value\n             */\n            'startedit',\n\n            /**\n             * @event beforecomplete\n             * Fires after a change has been made to the field, but before the change is reflected in the underlying\n             * field.  Saving the change to the field can be canceled by returning false from the handler of this event.\n             * Note that if the value has not changed and ignoreNoChange = true, the editing will still end but this\n             * event will not fire since no edit actually occurred.\n             * @param {Ext.Editor} this\n             * @param {Object} value The current field value\n             * @param {Object} startValue The original field value\n             */\n            'beforecomplete',\n            /**\n             * @event complete\n             * Fires after editing is complete and any changed value has been written to the underlying field.\n             * @param {Ext.Editor} this\n             * @param {Object} value The current field value\n             * @param {Object} startValue The original field value\n             */\n            'complete',\n            /**\n             * @event canceledit\n             * Fires after editing has been canceled and the editor's value has been reset.\n             * @param {Ext.Editor} this\n             * @param {Object} value The user-entered field value that was discarded\n             * @param {Object} startValue The original field value that was set back into the editor after cancel\n             */\n            'canceledit',\n            /**\n             * @event specialkey\n             * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed.  You can check\n             * {@link Ext.EventObject#getKey} to determine which key was pressed.\n             * @param {Ext.Editor} this\n             * @param {Ext.form.field.Field} field The field attached to this editor\n             * @param {Ext.EventObject} event The event object\n             */\n            'specialkey'\n        );\n    },\n\n    // private\n    onFieldAutosize: function(){\n        this.updateLayout();\n    },\n\n    // private\n    afterRender : function(ct, position) {\n        var me = this,\n            field = me.field,\n            inputEl = field.inputEl;\n\n        me.callParent(arguments);\n\n        // Ensure the field doesn't get submitted as part of any form\n        if (inputEl) {\n            inputEl.dom.name = '';\n            if (me.swallowKeys) {\n                inputEl.swallowEvent([\n                    'keypress', // *** Opera\n                    'keydown'   // *** all other browsers\n                ]);\n            }\n        }\n    },\n\n    // private\n    onSpecialKey : function(field, event) {\n        var me = this,\n            key = event.getKey(),\n            complete = me.completeOnEnter && key == event.ENTER,\n            cancel = me.cancelOnEsc && key == event.ESC;\n\n        if (complete || cancel) {\n            event.stopEvent();\n            // Must defer this slightly to prevent exiting edit mode before the field's own\n            // key nav can handle the enter key, e.g. selecting an item in a combobox list\n            Ext.defer(function() {\n                if (complete) {\n                    me.completeEdit();\n                } else {\n                    me.cancelEdit();\n                }\n                if (field.triggerBlur) {\n                    field.triggerBlur(event);\n                }\n            }, 10);\n        }\n\n        me.fireEvent('specialkey', me, field, event);\n    },\n\n    /**\n     * Starts the editing process and shows the editor.\n     * @param {String/HTMLElement/Ext.Element} el The element to edit\n     * @param {String} value (optional) A value to initialize the editor with. If a value is not provided, it defaults\n      * to the innerHTML of el.\n     */\n    startEdit : function(el, value) {\n        var me = this,\n            field = me.field;\n\n        me.completeEdit();\n        me.boundEl = Ext.get(el);\n        value = Ext.isDefined(value) ? value : Ext.String.trim(me.boundEl.dom.innerText || me.boundEl.dom.innerHTML);\n\n        if (!me.rendered) {\n            me.render(me.parentEl || document.body);\n        }\n\n        if (me.fireEvent('beforestartedit', me, me.boundEl, value) !== false) {\n            me.startValue = value;\n            me.show();\n            // temporarily suspend events on field to prevent the \"change\" event from firing when reset() and setValue() are called\n            field.suspendEvents();\n            field.reset();\n            field.setValue(value);\n            field.resumeEvents();\n            me.realign(true);\n            field.focus(false, 10);\n            if (field.autoSize) {\n                field.autoSize();\n            }\n            me.editing = true;\n        }\n    },\n\n    /**\n     * Realigns the editor to the bound field based on the current alignment config value.\n     * @param {Boolean} autoSize (optional) True to size the field to the dimensions of the bound element.\n     */\n    realign : function(autoSize) {\n        var me = this;\n        if (autoSize === true) {\n            me.updateLayout();\n        }\n        me.alignTo(me.boundEl, me.alignment, me.offsets);\n    },\n\n    /**\n     * Ends the editing process, persists the changed value to the underlying field, and hides the editor.\n     * @param {Boolean} [remainVisible=false] Override the default behavior and keep the editor visible after edit\n     */\n    completeEdit : function(remainVisible) {\n        var me = this,\n            field = me.field,\n            value;\n\n        if (!me.editing) {\n            return;\n        }\n\n        // Assert combo values first\n        if (field.assertValue) {\n            field.assertValue();\n        }\n\n        value = me.getValue();\n        if (!field.isValid()) {\n            if (me.revertInvalid !== false) {\n                me.cancelEdit(remainVisible);\n            }\n            return;\n        }\n\n        if (String(value) === String(me.startValue) && me.ignoreNoChange) {\n            me.hideEdit(remainVisible);\n            return;\n        }\n\n        if (me.fireEvent('beforecomplete', me, value, me.startValue) !== false) {\n            // Grab the value again, may have changed in beforecomplete\n            value = me.getValue();\n            if (me.updateEl && me.boundEl) {\n                me.boundEl.update(value);\n            }\n            me.hideEdit(remainVisible);\n            me.fireEvent('complete', me, value, me.startValue);\n        }\n    },\n\n    // private\n    onShow : function() {\n        var me = this;\n\n        me.callParent(arguments);\n        if (me.hideEl !== false) {\n            me.boundEl.hide();\n        }\n        me.fireEvent('startedit', me, me.boundEl, me.startValue);\n    },\n\n    /**\n     * Cancels the editing process and hides the editor without persisting any changes.  The field value will be\n     * reverted to the original starting value.\n     * @param {Boolean} [remainVisible=false] Override the default behavior and keep the editor visible after cancel\n     */\n    cancelEdit : function(remainVisible) {\n        var me = this,\n            startValue = me.startValue,\n            field = me.field,\n            value;\n\n        if (me.editing) {\n            value = me.getValue();\n            // temporarily suspend events on field to prevent the \"change\" event from firing when setValue() is called\n            field.suspendEvents();\n            me.setValue(startValue);\n            field.resumeEvents();\n            me.hideEdit(remainVisible);\n            me.fireEvent('canceledit', me, value, startValue);\n        }\n    },\n\n    // private\n    hideEdit: function(remainVisible) {\n        if (remainVisible !== true) {\n            this.editing = false;\n            this.hide();\n        }\n    },\n\n    // private\n    onFieldBlur : function(field, e) {\n        var me = this,\n            target;\n\n        // selectSameEditor flag allows the same editor to be started without onFieldBlur firing on itself\n        if(me.allowBlur === true && me.editing && me.selectSameEditor !== true) {\n            me.completeEdit();\n        }\n\n        // If the target of the event was focusable, prevent reacquisition of focus by editor owner\n        if (e && Ext.fly(target = e.getTarget()).focusable()) {\n            target.focus();\n        }\n    },\n\n    // private\n    onHide : function() {\n        var me = this,\n            field = me.field;\n\n        if (me.editing) {\n            me.completeEdit();\n            return;\n        }\n        if (field.hasFocus) {\n            field.blur();\n        }\n        if (field.collapse) {\n            field.collapse();\n        }\n\n        //field.hide();\n        if (me.hideEl !== false) {\n            me.boundEl.show();\n        }\n        me.callParent(arguments);\n    },\n\n    /**\n     * Sets the data value of the editor\n     * @param {Object} value Any valid value supported by the underlying field\n     */\n    setValue : function(value) {\n        this.field.setValue(value);\n    },\n\n    /**\n     * Gets the data value of the editor\n     * @return {Object} The data value\n     */\n    getValue : function() {\n        return this.field.getValue();\n    },\n\n    beforeDestroy : function() {\n        var me = this;\n\n        Ext.destroy(me.field);\n        delete me.field;\n        delete me.parentEl;\n        delete me.boundEl;\n\n        me.callParent(arguments);\n    }\n});\n\n/**\n * Handles mapping key events to handling functions for an element or a Component. One KeyMap can be used for multiple\n * actions.\n *\n * A KeyMap must be configured with a {@link #target} as an event source which may be an Element or a Component.\n *\n * If the target is an element, then the `keydown` event will trigger the invocation of {@link #binding}s.\n *\n * It is possible to configure the KeyMap with a custom {@link #eventName} to listen for. This may be useful when the\n * {@link #target} is a Component.\n *\n * The KeyMap's event handling requires that the first parameter passed is a key event. So if the Component's event\n * signature is different, specify a {@link #processEvent} configuration which accepts the event's parameters and\n * returns a key event.\n *\n * Functions specified in {@link #binding}s are called with this signature : `(String key, Ext.EventObject e)` (if the\n * match is a multi-key combination the callback will still be called only once). A KeyMap can also handle a string\n * representation of keys. By default KeyMap starts enabled.\n *\n * Usage:\n *\n *     // map one key by key code\n *     var map = new Ext.util.KeyMap({\n *         target: \"my-element\",\n *         key: 13, // or Ext.EventObject.ENTER\n *         fn: myHandler,\n *         scope: myObject\n *     });\n *\n *     // map multiple keys to one action by string\n *     var map = new Ext.util.KeyMap({\n *         target: \"my-element\",\n *         key: \"a\\r\\n\\t\",\n *         fn: myHandler,\n *         scope: myObject\n *     });\n *\n *     // map multiple keys to multiple actions by strings and array of codes\n *     var map = new Ext.util.KeyMap({\n *         target: \"my-element\",\n *         binding: [{\n *             key: [10,13],\n *             fn: function(){ alert(\"Return was pressed\"); }\n *         }, {\n *             key: \"abc\",\n *             fn: function(){ alert('a, b or c was pressed'); }\n *         }, {\n *             key: \"\\t\",\n *             ctrl:true,\n *             shift:true,\n *             fn: function(){ alert('Control + shift + tab was pressed.'); }\n *         }]\n *     });\n *\n * Since 4.1.0, KeyMaps can bind to Components and process key-based events fired by Components.\n *\n * To bind to a Component, use the single parameter form of constructor and include the Component event name\n * to listen for, and a `processEvent` implementation which returns the key event for further processing by\n * the KeyMap:\n *\n *     var map = new Ext.util.KeyMap({\n *         target: myGridView,\n *         eventName: 'itemkeydown',\n *         processEvent: function(view, record, node, index, event) {\n *\n *             // Load the event with the extra information needed by the mappings\n *             event.view = view;\n *             event.store = view.getStore();\n *             event.record = record;\n *             event.index = index;\n *             return event;\n *         },\n *         binding: {\n *             key: Ext.EventObject.DELETE,\n *             fn: function(keyCode, e) {\n *                 e.store.remove(e.record);\n *\n *                 // Attempt to select the record that's now in its place\n *                 e.view.getSelectionModel().select(e.index);\n *                 e.view.el.focus();\n *             }\n *         }\n *     });\n */\nExt.define('Ext.util.KeyMap', {\n    alternateClassName: 'Ext.KeyMap',\n\n    /**\n     * @cfg {Ext.Component/Ext.Element/HTMLElement/String} target\n     * The object on which to listen for the event specified by the {@link #eventName} config option.\n     */\n\n    /**\n     * @cfg {Object/Object[][]} binding\n     * Either a single object describing a handling function for s specified key (or set of keys), or\n     * an array of such objects.\n     * @cfg {String/String[]} binding.key A single keycode or an array of keycodes to handle\n     * @cfg {Boolean}  binding.shift True to handle key only when shift is pressed, False to handle the\n     *  key only when shift is not pressed (defaults to undefined)\n     * @cfg {Boolean}  binding.ctrl True to handle key only when ctrl is pressed, False to handle the\n     *  key only when ctrl is not pressed (defaults to undefined)\n     * @cfg {Boolean}  binding.alt True to handle key only when alt is pressed, False to handle the key\n     *  only when alt is not pressed (defaults to undefined)\n     * @cfg {Function} binding.handler The function to call when KeyMap finds the expected key combination\n     * @cfg {Function} binding.fn Alias of handler (for backwards-compatibility)\n     * @cfg {Object}   binding.scope The scope of the callback function\n     * @cfg {String}   binding.defaultEventAction A default action to apply to the event. Possible values\n     *  are: stopEvent, stopPropagation, preventDefault. If no value is set no action is performed.\n     */\n\n    /**\n     * @cfg {Object} [processEventScope=this]\n     * The scope (`this` context) in which the {@link #processEvent} method is executed.\n     */\n\n    /**\n     * @cfg {Boolean} [ignoreInputFields=false]\n     * Configure this as `true` if there are any input fields within the {@link #target}, and this KeyNav\n     * should not process events from input fields, (`&lt;input>, &lt;textarea> and elements with `contentEditable=\"true\"`)\n     */\n\n    /**\n     * @cfg {String} eventName\n     * The event to listen for to pick up key events.\n     */\n    eventName: 'keydown',\n\n    constructor: function(config) {\n        var me = this;\n\n        // Handle legacy arg list in which the first argument is the target.\n        // TODO: Deprecate in V5\n        if ((arguments.length !== 1) || (typeof config === 'string') || config.dom || config.tagName || config === document || config.isComponent) {\n            me.legacyConstructor.apply(me, arguments);\n            return;\n        }\n\n        Ext.apply(me, config);\n        me.bindings = [];\n\n        if (!me.target.isComponent) {\n            me.target = Ext.get(me.target);\n        }\n\n        if (me.binding) {\n            me.addBinding(me.binding);\n        } else if (config.key) {\n            me.addBinding(config);\n        }\n        me.enable();\n    },\n\n    /**\n     * @private\n     * Old constructor signature\n     * @param {String/HTMLElement/Ext.Element/Ext.Component} el The element or its ID, or Component to bind to\n     * @param {Object} binding The binding (see {@link #addBinding})\n     * @param {String} [eventName=\"keydown\"] The event to bind to\n     */\n    legacyConstructor: function(el, binding, eventName){\n        var me = this;\n\n        Ext.apply(me, {\n            target: Ext.get(el),\n            eventName: eventName || me.eventName,\n            bindings: []\n        });\n        if (binding) {\n            me.addBinding(binding);\n        }\n        me.enable();\n    },\n\n    /**\n     * Add a new binding to this KeyMap.\n     *\n     * Usage:\n     *\n     *     // Create a KeyMap\n     *     var map = new Ext.util.KeyMap(document, {\n     *         key: Ext.EventObject.ENTER,\n     *         fn: handleKey,\n     *         scope: this\n     *     });\n     *\n     *     //Add a new binding to the existing KeyMap later\n     *     map.addBinding({\n     *         key: 'abc',\n     *         shift: true,\n     *         fn: handleKey,\n     *         scope: this\n     *     });\n     *\n     * @param {Object/Object[]} binding A single KeyMap config or an array of configs.\n     * The following config object properties are supported:\n     * @param {String/Array} binding.key A single keycode or an array of keycodes to handle.\n     * @param {Boolean} binding.shift True to handle key only when shift is pressed,\n     * False to handle the keyonly when shift is not pressed (defaults to undefined).\n     * @param {Boolean} binding.ctrl True to handle key only when ctrl is pressed,\n     * False to handle the key only when ctrl is not pressed (defaults to undefined).\n     * @param {Boolean} binding.alt True to handle key only when alt is pressed,\n     * False to handle the key only when alt is not pressed (defaults to undefined).\n     * @param {Function} binding.handler The function to call when KeyMap finds the\n     * expected key combination.\n     * @param {Function} binding.fn Alias of handler (for backwards-compatibility).\n     * @param {Object} binding.scope The scope of the callback function.\n     * @param {String} binding.defaultEventAction A default action to apply to the event.\n     * Possible values are: stopEvent, stopPropagation, preventDefault. If no value is\n     * set no action is performed..\n     */\n    addBinding : function(binding){\n        var keyCode = binding.key,\n            processed = false,\n            key,\n            keys,\n            keyString,\n            i,\n            len;\n\n        if (Ext.isArray(binding)) {\n            for (i = 0, len = binding.length; i < len; i++) {\n                this.addBinding(binding[i]);\n            }\n            return;\n        }\n\n        if (Ext.isString(keyCode)) {\n            keys = [];\n            keyString = keyCode.toUpperCase();\n\n            for (i = 0, len = keyString.length; i < len; ++i){\n                keys.push(keyString.charCodeAt(i));\n            }\n            keyCode = keys;\n            processed = true;\n        }\n\n        if (!Ext.isArray(keyCode)) {\n            keyCode = [keyCode];\n        }\n\n        if (!processed) {\n            for (i = 0, len = keyCode.length; i < len; ++i) {\n                key = keyCode[i];\n                if (Ext.isString(key)) {\n                    keyCode[i] = key.toUpperCase().charCodeAt(0);\n                }\n            }\n        }\n\n        this.bindings.push(Ext.apply({\n            keyCode: keyCode\n        }, binding));\n    },\n\n    /**\n     * Process the {@link #eventName event} from the {@link #target}.\n     * @private\n     * @param {Ext.EventObject} event\n     */\n    handleTargetEvent: (function() {\n        var tagRe = /input|textarea/i;\n\n        return function(event) {\n            var me = this,\n                bindings, i, len,\n                target, contentEditable;\n\n            if (this.enabled) { //just in case\n                bindings = this.bindings;\n                i = 0;\n                len = bindings.length;\n\n                // Process the event\n                event = me.processEvent.apply(me||me.processEventScope, arguments);\n\n                // Ignore events from input fields if configured to do so\n                if (me.ignoreInputFields) {\n                    target = event.target;\n                    contentEditable = target.contentEditable;\n                    // contentEditable will default to inherit if not specified, only check if the\n                    // attribute has been set or explicitly set to true\n                    // http://html5doctor.com/the-contenteditable-attribute/\n                    if (tagRe.test(target.tagName) || (contentEditable === '' || contentEditable === 'true')) {\n                        return;\n                    }\n                }\n\n                // If the processor does not return a keyEvent, we can't process it.\n                // Allow them to return false to cancel processing of the event\n                if (!event.getKey) {\n                    return event;\n                }\n                for(; i < len; ++i){\n                    this.processBinding(bindings[i], event);\n                }\n            }\n        }\n    }()),\n\n    /**\n     * @cfg {Function} processEvent\n     * An optional event processor function which accepts the argument list provided by the\n     * {@link #eventName configured event} of the {@link #target}, and returns a keyEvent for processing by the KeyMap.\n     *\n     * This may be useful when the {@link #target} is a Component with s complex event signature, where the event is not\n     * the first parameter. Extra information from the event arguments may be injected into the event for use by the handler\n     * functions before returning it.\n     */\n    processEvent: function(event){\n        return event;\n    },\n\n    /**\n     * Process a particular binding and fire the handler if necessary.\n     * @private\n     * @param {Object} binding The binding information\n     * @param {Ext.EventObject} event\n     */\n    processBinding: function(binding, event){\n        if (this.checkModifiers(binding, event)) {\n            var key = event.getKey(),\n                handler = binding.fn || binding.handler,\n                scope = binding.scope || this,\n                keyCode = binding.keyCode,\n                defaultEventAction = binding.defaultEventAction,\n                i,\n                len,\n                keydownEvent = new Ext.EventObjectImpl(event);\n\n\n            for (i = 0, len = keyCode.length; i < len; ++i) {\n                if (key === keyCode[i]) {\n                    if (handler.call(scope, key, event) !== true && defaultEventAction) {\n                        keydownEvent[defaultEventAction]();\n                    }\n                    break;\n                }\n            }\n        }\n    },\n\n    /**\n     * Check if the modifiers on the event match those on the binding\n     * @private\n     * @param {Object} binding\n     * @param {Ext.EventObject} event\n     * @return {Boolean} True if the event matches the binding\n     */\n    checkModifiers: function(binding, e) {\n        var keys = ['shift', 'ctrl', 'alt'],\n            i = 0,\n            len = keys.length,\n            val, key;\n\n        for (; i < len; ++i){\n            key = keys[i];\n            val = binding[key];\n            if (!(val === undefined || (val === e[key + 'Key']))) {\n                return false;\n            }\n        }\n        return true;\n    },\n\n    /**\n     * Shorthand for adding a single key listener.\n     *\n     * @param {Number/Number[]/Object} key Either the numeric key code, array of key codes or an object with the\n     * following options: `{key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}`\n     * @param {Function} fn The function to call\n     * @param {Object} [scope] The scope (`this` reference) in which the function is executed.\n     * Defaults to the browser window.\n     */\n    on: function(key, fn, scope) {\n        var keyCode, shift, ctrl, alt;\n        if (Ext.isObject(key) && !Ext.isArray(key)) {\n            keyCode = key.key;\n            shift = key.shift;\n            ctrl = key.ctrl;\n            alt = key.alt;\n        } else {\n            keyCode = key;\n        }\n        this.addBinding({\n            key: keyCode,\n            shift: shift,\n            ctrl: ctrl,\n            alt: alt,\n            fn: fn,\n            scope: scope\n        });\n    },\n\n    /**\n     * Returns true if this KeyMap is enabled\n     * @return {Boolean}\n     */\n    isEnabled : function() {\n        return this.enabled;\n    },\n\n    /**\n     * Enables this KeyMap\n     */\n    enable: function() {\n        var me = this;\n        \n        if (!me.enabled) {\n            me.target.on(me.eventName, me.handleTargetEvent, me);\n            me.enabled = true;\n        }\n    },\n\n    /**\n     * Disable this KeyMap\n     */\n    disable: function() {\n        var me = this;\n        \n        if (me.enabled) {\n            me.target.removeListener(me.eventName, me.handleTargetEvent, me);\n            me.enabled = false;\n        }\n    },\n\n    /**\n     * Convenience function for setting disabled/enabled by boolean.\n     * @param {Boolean} disabled\n     */\n    setDisabled : function(disabled) {\n        if (disabled) {\n            this.disable();\n        } else {\n            this.enable();\n        }\n    },\n\n    /**\n     * Destroys the KeyMap instance and removes all handlers.\n     * @param {Boolean} removeTarget True to also remove the {@link #target}\n     */\n    destroy: function(removeTarget) {\n        var me = this,\n            target = me.target;\n\n        me.bindings = [];\n        me.disable();\n        if (removeTarget === true) {\n            if (target.isComponent) {\n                target.destroy();\n            } else {\n                target.remove();\n            }\n        }\n        delete me.target;\n    }\n});\n\n/**\n * Provides a convenient wrapper for normalized keyboard navigation. KeyNav allows you to bind navigation keys to\n * function calls that will get called when the keys are pressed, providing an easy way to implement custom navigation\n * schemes for any UI component.\n *\n * The following are all of the possible keys that can be implemented: enter, space, left, right, up, down, tab, esc,\n * pageUp, pageDown, del, backspace, home, end.\n *\n * Usage:\n *\n *     var nav = new Ext.util.KeyNav({\n *         target : \"my-element\",\n *         left   : function(e){\n *             this.moveLeft(e.ctrlKey);\n *         },\n *         right  : function(e){\n *             this.moveRight(e.ctrlKey);\n *         },\n *         enter  : function(e){\n *             this.save();\n *         },\n *         \n *         // Binding may be a function specifiying fn, scope and defaultAction\n *         esc: {\n *             fn: this.onEsc,\n *             defaultEventAction: false\n *         },\n *         scope : this\n *     });\n */\nExt.define('Ext.util.KeyNav', {\n    alternateClassName: 'Ext.KeyNav',\n    \n    requires: ['Ext.util.KeyMap'],\n    \n    statics: {\n        keyOptions: {\n            left: 37,\n            right: 39,\n            up: 38,\n            down: 40,\n            space: 32,\n            pageUp: 33,\n            pageDown: 34,\n            del: 46,\n            backspace: 8,\n            home: 36,\n            end: 35,\n            enter: 13,\n            esc: 27,\n            tab: 9\n        }\n    },\n\n    constructor: function(config) {\n        var me = this;\n        if (arguments.length === 2) {\n            me.legacyConstructor.apply(me, arguments);\n            return;\n        }\n        me.setConfig(config);\n    },\n\n    /**\n     * @private\n     * Old constructor signature.\n     * @param {String/HTMLElement/Ext.Element} el The element or its ID to bind to\n     * @param {Object} config The config\n     */\n    legacyConstructor: function(el, config) {\n        this.setConfig(Ext.apply({\n            target: el\n        }, config));\n    },\n\n    /**\n     * Sets up a configuration for the KeyNav.\n     * @private\n     * @param {String/HTMLElement/Ext.Element} el The element or its ID to bind to\n     * @param {Object} config A configuration object as specified in the constructor.\n     */\n    setConfig: function(config) {\n        var me = this,\n            keymapCfg = {\n                target: config.target,\n                ignoreInputFields: config.ignoreInputFields,\n                eventName: me.getKeyEvent('forceKeyDown' in config ? config.forceKeyDown : me.forceKeyDown, config.eventName)\n            },\n            map, keyCodes, defaultScope, keyName, binding;\n\n        if (me.map) {\n            me.map.destroy();\n        }\n\n        if (config.processEvent) {\n            keymapCfg.processEvent = config.processEvent;\n            keymapCfg.processEventScope = config.processEventScope||me;\n        }\n        map = me.map = new Ext.util.KeyMap(keymapCfg);\n        keyCodes = Ext.util.KeyNav.keyOptions;\n        defaultScope = config.scope || me;\n        \n        for (keyName in keyCodes) {\n            if (keyCodes.hasOwnProperty(keyName)) {\n\n                // There is a property named after a key name.\n                // It may be a function or an binding spec containing handler, scope and defaultAction configs\n                if (binding = config[keyName]) {\n                    if (typeof binding === 'function') {\n                        binding = {\n                            handler: binding,\n                            defaultAction: (config.defaultEventAction !== undefined) ? config.defaultEventAction : me.defaultEventAction\n                        };\n                    }\n                    map.addBinding({\n                        key: keyCodes[keyName],\n                        handler: Ext.Function.bind(me.handleEvent, binding.scope||defaultScope, binding.handler||binding.fn, true),\n                        defaultEventAction: (binding.defaultEventAction !== undefined) ? binding.defaultAction : me.defaultEventAction\n                    });\n                }\n            }\n        }\n        \n        map.disable();\n        if (!config.disabled) {\n            map.enable();\n        }\n    },\n    \n    /**\n     * Method for filtering out the map argument\n     * @private\n     * @param {Number} keyCode\n     * @param {Ext.EventObject} event\n     * @param {Object} options Contains the handler to call\n     */\n    handleEvent: function(keyCode, event, handler){\n        return handler.call(this, event);\n    },\n    \n    /**\n     * @cfg {Boolean} disabled\n     * True to disable this KeyNav instance.\n     */\n    disabled: false,\n    \n    /**\n     * @cfg {String} defaultEventAction\n     * The method to call on the {@link Ext.EventObject} after this KeyNav intercepts a key. Valid values are {@link\n     * Ext.EventObject#stopEvent}, {@link Ext.EventObject#preventDefault} and {@link Ext.EventObject#stopPropagation}.\n     *\n     * If a falsy value is specified, no method is called on the key event.\n     */\n    defaultEventAction: \"stopEvent\",\n    \n    /**\n     * @cfg {Boolean} forceKeyDown\n     * Handle the keydown event instead of keypress. KeyNav automatically does this for IE since IE does not propagate\n     * special keys on keypress, but setting this to true will force other browsers to also handle keydown instead of\n     * keypress.\n     */\n    forceKeyDown: false,\n\n    /**\n     * @cfg {Ext.Component/Ext.Element/HTMLElement/String} target\n     * The object on which to listen for the event specified by the {@link #eventName} config option.\n     */\n\n    /**\n     * @cfg {String} eventName\n     * The event to listen for to pick up key events.\n     */\n    eventName: 'keypress',\n\n    /**\n     * @cfg {Function} processEvent\n     * An optional event processor function which accepts the argument list provided by the {@link #eventName configured\n     * event} of the {@link #target}, and returns a keyEvent for processing by the KeyMap.\n     *\n     * This may be useful when the {@link #target} is a Component with s complex event signature. Extra information from\n     * the event arguments may be injected into the event for use by the handler functions before returning it.\n     */\n\n    /**\n     * @cfg {Object} [processEventScope=this]\n     * The scope (`this` context) in which the {@link #processEvent} method is executed.\n     */\n\n    /**\n     * @cfg {Boolean} [ignoreInputFields=false]\n     * Configure this as `true` if there are any input fields within the {@link #target}, and this KeyNav\n     * should not process events from input fields, (`&lt;input>, &lt;textarea> and elements with `contentEditable=\"true\"`)\n     */\n\n    /**\n     * Destroy this KeyNav (this is the same as calling disable).\n     * @param {Boolean} removeEl True to remove the element associated with this KeyNav.\n     */\n    destroy: function(removeEl) {\n        this.map.destroy(removeEl);\n        delete this.map;\n    },\n\n    /**\n     * Enables this KeyNav.\n     */\n    enable: function() {\n        this.map.enable();\n        this.disabled = false;\n    },\n\n    /**\n     * Disables this KeyNav.\n     */\n    disable: function() {\n        this.map.disable();\n        this.disabled = true;\n    },\n    \n    /**\n     * Convenience function for setting disabled/enabled by boolean.\n     * @param {Boolean} disabled\n     */\n    setDisabled : function(disabled) {\n        this.map.setDisabled(disabled);\n        this.disabled = disabled;\n    },\n    \n    /**\n     * @private\n     * Determines the event to bind to listen for keys. Defaults to the {@link #eventName} value, but\n     * may be overridden the {@link #forceKeyDown} setting.\n     *\n     * The useKeyDown option on the EventManager modifies the default {@link #eventName} to be `keydown`,\n     * but a configured {@link #eventName} takes priority over this.\n     *\n     * @return {String} The type of event to listen for.\n     */\n    getKeyEvent: function(forceKeyDown, configuredEventName) {\n        if (forceKeyDown || (Ext.EventManager.useKeyDown && !configuredEventName)) {\n            return 'keydown';\n        } else {\n            return configuredEventName||this.eventName;\n        }\n    }\n});\n\n/**\n * The FocusManager is responsible for globally:\n *\n * 1. Managing component focus\n * 2. Providing basic keyboard navigation\n * 3. (optional) Provide a visual cue for focused components, in the form of a focus ring/frame.\n *\n * To activate the FocusManager, simply call `Ext.FocusManager.enable();`. In turn, you may\n * deactivate the FocusManager by subsequently calling `Ext.FocusManager.disable();`.  The\n * FocusManager is disabled by default.\n *\n * To enable the optional focus frame, pass `true` or `{focusFrame: true}` to {@link #method-enable}.\n *\n * Another feature of the FocusManager is to provide basic keyboard focus navigation scoped to any {@link Ext.container.Container}\n * that would like to have navigation between its child {@link Ext.Component}'s.\n *\n * @author Jarred Nicholls <jarred@sencha.com>\n * @docauthor Jarred Nicholls <jarred@sencha.com>\n */\nExt.define('Ext.FocusManager', {\n    singleton: true,\n    alternateClassName: ['Ext.FocusMgr' ],\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    requires: [\n        'Ext.AbstractComponent',\n        'Ext.Component',\n        'Ext.ComponentManager',\n        'Ext.ComponentQuery',\n        'Ext.util.HashMap',\n        'Ext.util.KeyNav'\n    ],\n\n    /**\n     * @property {Boolean} enabled\n     * Whether or not the FocusManager is currently enabled\n     */\n    enabled: false,\n\n    /**\n     * @property {Ext.Component} focusedCmp\n     * The currently focused component.\n     */\n\n    focusElementCls: Ext.baseCSSPrefix + 'focus-element',\n\n    focusFrameCls: Ext.baseCSSPrefix + 'focus-frame',\n\n    /**\n     * @property {String[]} whitelist\n     * A list of xtypes that should ignore certain navigation input keys and\n     * allow for the default browser event/behavior. These input keys include:\n     *\n     * 1. Backspace\n     * 2. Delete\n     * 3. Left\n     * 4. Right\n     * 5. Up\n     * 6. Down\n     *\n     * The FocusManager will not attempt to navigate when a component is an xtype (or descendents thereof)\n     * that belongs to this whitelist. E.g., an {@link Ext.form.field.Text} should allow\n     * the user to move the input cursor left and right, and to delete characters, etc.\n     */\n    whitelist: [\n        'textfield'\n    ],\n\n    constructor: function(config) {\n        var me = this,\n            CQ = Ext.ComponentQuery;\n\n        me.mixins.observable.constructor.call(me, config);\n\n        me.addEvents(\n            /**\n             * @event beforecomponentfocus\n             * Fires before a component becomes focused. Return `false` to prevent\n             * the component from gaining focus.\n             * @param {Ext.FocusManager} fm A reference to the FocusManager singleton\n             * @param {Ext.Component} cmp The component that is being focused\n             * @param {Ext.Component} previousCmp The component that was previously focused,\n             * or `undefined` if there was no previously focused component.\n             */\n            'beforecomponentfocus',\n\n            /**\n             * @event componentfocus\n             * Fires after a component becomes focused.\n             * @param {Ext.FocusManager} fm A reference to the FocusManager singleton\n             * @param {Ext.Component} cmp The component that has been focused\n             * @param {Ext.Component} previousCmp The component that was previously focused,\n             * or `undefined` if there was no previously focused component.\n             */\n            'componentfocus',\n\n            /**\n             * @event disable\n             * Fires when the FocusManager is disabled\n             * @param {Ext.FocusManager} fm A reference to the FocusManager singleton\n             */\n            'disable',\n\n            /**\n             * @event enable\n             * Fires when the FocusManager is enabled\n             * @param {Ext.FocusManager} fm A reference to the FocusManager singleton\n             */\n            'enable'\n        );\n\n        me.focusTask = new Ext.util.DelayedTask(me.handleComponentFocus, me);\n\n        // Gain control on Component focus, blur, hide and destroy\n        Ext.override(Ext.AbstractComponent, {\n            onFocus: function() {\n                this.callParent(arguments);\n                if (me.enabled && this.hasFocus) {\n                    Array.prototype.unshift.call(arguments, this);\n                    me.onComponentFocus.apply(me, arguments);\n                }\n            },\n            onBlur: function() {\n                this.callParent(arguments);\n                if (me.enabled && !this.hasFocus) {\n                    Array.prototype.unshift.call(arguments, this);\n                    me.onComponentBlur.apply(me, arguments);\n                }\n            },\n            onDestroy: function() {\n                this.callParent(arguments);\n                if (me.enabled) {\n                    Array.prototype.unshift.call(arguments, this);\n                    me.onComponentDestroy.apply(me, arguments);\n                }\n            }\n        });\n        Ext.override(Ext.Component, {\n            afterHide: function() {\n                this.callParent(arguments);\n                if (me.enabled) {\n                    Array.prototype.unshift.call(arguments, this);\n                    me.onComponentHide.apply(me, arguments);\n                }\n            }\n        });\n        // Setup KeyNav that's bound to document to catch all\n        // unhandled/bubbled key events for navigation\n        me.keyNav = new Ext.util.KeyNav(Ext.getDoc(), {\n            disabled: true,\n            scope: me,\n\n            backspace: me.focusLast,\n            enter: me.navigateIn,\n            esc: me.navigateOut,\n            tab: me.navigateSiblings,\n            space: me.navigateIn,\n            del: me.focusLast,\n            left: me.navigateSiblings,\n            right: me.navigateSiblings,\n            down: me.navigateSiblings,\n            up: me.navigateSiblings\n        });\n\n        me.focusData = {};\n        me.subscribers = new Ext.util.HashMap();\n        me.focusChain = {};\n\n        // Setup some ComponentQuery pseudos\n        Ext.apply(CQ.pseudos, {\n            focusable: function(cmps) {\n                var len = cmps.length,\n                    results = [],\n                    i = 0,\n                    c;\n\n                for (; i < len; i++) {\n                    c = cmps[i];\n                    if (c.isFocusable()) {\n                        results.push(c);\n                    }\n                }\n\n                return results;\n            },\n\n            // Return the single next focusable sibling from the current idx in either direction (step -1 or 1)\n            nextFocus: function(cmps, idx, step) {\n                step = step || 1;\n                idx = parseInt(idx, 10);\n\n                var len = cmps.length,\n                    i = idx, c;\n\n                for (;;) {\n                    // Increment index, and loop round if off either end\n                    if ((i += step) >= len) {\n                        i = 0;\n                    } else if (i < 0) {\n                        i = len - 1;\n                    }\n\n                    // As soon as we loop back to the starting index, give up, there are no focusable siblings.\n                    if (i === idx) {\n                        return [];\n                    }\n\n                    // If we have found a focusable sibling, return it\n                    if ((c = cmps[i]).isFocusable()) {\n                        return [c];\n                    }\n                }\n\n                return [];\n            },\n\n            prevFocus: function(cmps, idx) {\n                return this.nextFocus(cmps, idx, -1);\n            },\n\n            root: function(cmps) {\n                var len = cmps.length,\n                    results = [],\n                    i = 0,\n                    c;\n\n                for (; i < len; i++) {\n                    c = cmps[i];\n                    if (!c.ownerCt) {\n                        results.push(c);\n                    }\n                }\n\n                return results;\n            }\n        });\n    },\n\n    /**\n     * Adds the specified xtype to the {@link #whitelist}.\n     * @param {String/String[]} xtype Adds the xtype(s) to the {@link #whitelist}.\n     */\n    addXTypeToWhitelist: function(xtype) {\n        var me = this;\n\n        if (Ext.isArray(xtype)) {\n            Ext.Array.forEach(xtype, me.addXTypeToWhitelist, me);\n            return;\n        }\n\n        if (!Ext.Array.contains(me.whitelist, xtype)) {\n            me.whitelist.push(xtype);\n        }\n    },\n\n    clearComponent: function(cmp) {\n        clearTimeout(this.cmpFocusDelay);\n        if (!cmp.isDestroyed) {\n            cmp.blur();\n        }\n    },\n\n    /**\n     * Disables the FocusManager by turning of all automatic focus management and keyboard navigation\n     */\n    disable: function() {\n        var me = this;\n\n        if (!me.enabled) {\n            return;\n        }\n\n        delete me.options;\n        me.enabled = false;\n\n        me.removeDOM();\n\n        // Stop handling key navigation\n        me.keyNav.disable();\n\n        me.fireEvent('disable', me);\n    },\n\n    /**\n     * Enables the FocusManager by turning on all automatic focus management and keyboard navigation\n     * @param {Boolean/Object} options Either `true`/`false` to turn on the focus frame, or an object\n     * with the following options:\n     * @param {Boolean} [focusFrame=false] `true` to show the focus frame around a component when it is focused.\n     */\n    enable: function(options) {\n        var me = this;\n\n        if (options === true) {\n            options = { focusFrame: true };\n        }\n        me.options = options = options || {};\n\n        if (me.enabled) {\n            return;\n        }\n\n        // When calling addFocusListener on Containers, the FocusManager must be enabled, otherwise it won't do it.\n        me.enabled = true;\n        me.initDOM(options);\n\n        // Start handling key navigation\n        me.keyNav.enable();\n\n        // Finally, let's focus our global focus el so we start fresh\n        me.focusEl.focus();\n        delete me.focusedCmp;\n\n        me.fireEvent('enable', me);\n    },\n\n    focusLast: function(e) {\n        var me = this;\n\n        if (me.isWhitelisted(me.focusedCmp)) {\n            return true;\n        }\n\n        // Go back to last focused item\n        if (me.previousFocusedCmp) {\n            me.previousFocusedCmp.focus();\n        }\n    },\n\n    getRootComponents: function() {\n        var me = this,\n            CQ = Ext.ComponentQuery,\n            inline = CQ.query(':focusable:root:not([floating])'),\n            floating = CQ.query(':focusable:root[floating]');\n\n        // Floating items should go to the top of our root stack, and be ordered\n        // by their z-index (highest first)\n        floating.sort(function(a, b) {\n            return a.el.getZIndex() > b.el.getZIndex();\n        });\n\n        return floating.concat(inline);\n    },\n\n    initDOM: function(options) {\n        var me = this,\n            cls = me.focusFrameCls,\n            needListeners = Ext.ComponentQuery.query('{getFocusEl()}:not([focusListenerAdded])'),\n            i = 0, len = needListeners.length;\n\n        if (!Ext.isReady) {\n            return Ext.onReady(me.initDOM, me);\n        }\n\n        // When we are enabled, we must ensure that all Components which return a focusEl that is *not naturally focusable*\n        // have focus/blur listeners enabled to then trigger onFocus/onBlur handling so that we get to know about their focus action.\n        // These listeners are not added at initialization unless the FocusManager is enabled at that time.\n        for (; i < len; i++) {\n            needListeners[i].addFocusListener();\n        }\n\n        // Make the document body the global focus element\n        if (!me.focusEl) {\n            me.focusEl = Ext.getBody();\n            me.focusEl.dom.tabIndex = -1;\n        }\n\n        // Create global focus frame\n        if (!me.focusFrame && options.focusFrame) {\n            me.focusFrame = Ext.getBody().createChild({\n                cls: cls,\n                children: [\n                    { cls: cls + '-top' },\n                    { cls: cls + '-bottom' },\n                    { cls: cls + '-left' },\n                    { cls: cls + '-right' }\n                ],\n                style: 'top: -100px; left: -100px;'\n            });\n            me.focusFrame.setVisibilityMode(Ext.Element.DISPLAY);\n            me.focusFrame.hide().setLeftTop(0, 0);\n        }\n    },\n\n    isWhitelisted: function(cmp) {\n        return cmp && Ext.Array.some(this.whitelist, function(x) {\n            return cmp.isXType(x);\n        });\n    },\n\n    navigateIn: function(e) {\n        var me = this,\n            focusedCmp = me.focusedCmp,\n            defaultRoot,\n            firstChild;\n\n        if (me.isWhitelisted(focusedCmp)) {\n            return true;\n        }\n\n        if (!focusedCmp) {\n            // No focus yet, so focus the first root cmp on the page\n            defaultRoot = me.getRootComponents()[0];\n            if (defaultRoot) {\n                // If the default root is based upon the body, then it will already be focused, and will not fire a focus event to\n                // trigger its own onFocus processing, so we have to programatically blur it first.\n                if (defaultRoot.getFocusEl() === me.focusEl) {\n                    me.focusEl.blur();\n                }\n                defaultRoot.focus();\n            }\n        } else {\n            // Drill into child ref items of the focused cmp, if applicable.\n            // This works for any Component with a getRefItems implementation.\n            firstChild = focusedCmp.hasFocus ? Ext.ComponentQuery.query('>:focusable', focusedCmp)[0] : focusedCmp;\n            if (firstChild) {\n                firstChild.focus();\n            } else {\n                // Let's try to fire a click event, as if it came from the mouse\n                if (Ext.isFunction(focusedCmp.onClick)) {\n                    e.button = 0;\n                    focusedCmp.onClick(e);\n                    if (focusedCmp.isVisible(true)) {\n                        focusedCmp.focus();\n                    } else {\n                        me.navigateOut();\n                    }\n                }\n            }\n        }\n    },\n\n    navigateOut: function(e) {\n        var me = this,\n            parent;\n\n        if (!me.focusedCmp || !(parent = me.focusedCmp.up(':focusable'))) {\n            me.focusEl.focus();\n        } else {\n            parent.focus();\n        }\n\n        // In some browsers (Chrome) FocusManager can handle this before other\n        // handlers. Ext Windows have their own Esc key handling, so we need to\n        // return true here to allow the event to bubble.\n        return true;\n    },\n\n    navigateSiblings: function(e, source, parent) {\n        var me = this,\n            src = source || me,\n            key = e.getKey(),\n            EO = Ext.EventObject,\n            goBack = e.shiftKey || key == EO.LEFT || key == EO.UP,\n            checkWhitelist = key == EO.LEFT || key == EO.RIGHT || key == EO.UP || key == EO.DOWN,\n            nextSelector = goBack ? 'prev' : 'next',\n            idx, next, focusedCmp, siblings;\n\n        focusedCmp = (src.focusedCmp && src.focusedCmp.comp) || src.focusedCmp;\n        if (!focusedCmp && !parent) {\n            return true;\n        }\n\n        if (checkWhitelist && me.isWhitelisted(focusedCmp)) {\n            return true;\n        }\n\n        // If no focused Component, or a root level one was focused, then siblings are root components.\n        if (!focusedCmp || focusedCmp.is(':root')) {\n            siblings = me.getRootComponents();\n        } else {\n            // Else if the focused component has a parent, get siblings from there\n            parent = parent || focusedCmp.up();\n            if (parent) {\n                siblings = parent.getRefItems();\n            }\n        }\n\n\n        // Navigate if we have found siblings.\n        if (siblings) {\n            idx = focusedCmp ? Ext.Array.indexOf(siblings, focusedCmp) : -1;\n            next = Ext.ComponentQuery.query(':' + nextSelector + 'Focus(' + idx + ')', siblings)[0];\n            if (next && focusedCmp !== next) {\n                next.focus();\n                return next;\n            }\n        }\n    },\n\n    onComponentBlur: function(cmp, e) {\n        var me = this;\n\n        if (me.focusedCmp === cmp) {\n            me.previousFocusedCmp = cmp;\n            delete me.focusedCmp;\n        }\n\n        if (me.focusFrame) {\n            me.focusFrame.hide();\n        }\n    },\n\n    onComponentFocus: function(cmp, e) {\n        var me = this,\n            chain = me.focusChain,\n            parent;\n\n        if (!cmp.isFocusable()) {\n            me.clearComponent(cmp);\n\n            // Check our focus chain, so we don't run into a never ending recursion\n            // If we've attempted (unsuccessfully) to focus this component before,\n            // then we're caught in a loop of child->parent->...->child and we\n            // need to cut the loop off rather than feed into it.\n            if (chain[cmp.id]) {\n                return;\n            }\n\n            // Try to focus the parent instead\n            parent = cmp.up();\n            if (parent) {\n                // Add component to our focus chain to detect infinite focus loop\n                // before we fire off an attempt to focus our parent.\n                // See the comments above.\n                chain[cmp.id] = true;\n                parent.focus();\n            }\n\n            return;\n        }\n        // Clear our focus chain when we have a focusable component\n        me.focusChain = {};\n\n        // Capture the focusEl to frame now.\n        // Button returns its encapsulating element during the focus phase\n        // So that element gets styled and framed.\n        me.focusTask.delay(10, null, null, [cmp, cmp.getFocusEl()]);\n    },\n\n    handleComponentFocus: function(cmp, focusEl) {\n        var me = this,\n            cls,\n            ff,\n            fw,\n            box,\n            bt,\n            bl,\n            bw,\n            bh,\n            ft,\n            fb,\n            fl,\n            fr;\n\n        if (me.fireEvent('beforecomponentfocus', me, cmp, me.previousFocusedCmp) === false) {\n            me.clearComponent(cmp);\n            return;\n        }\n\n        me.focusedCmp = cmp;\n\n        // If we have a focus frame, show it around the focused component\n        if (me.shouldShowFocusFrame(cmp)) {\n            cls = '.' + me.focusFrameCls + '-';\n            ff = me.focusFrame;\n            box = focusEl.getPageBox();\n\n            // Size the focus frame's t/b/l/r according to the box\n            // This leaves a hole in the middle of the frame so user\n            // interaction w/ the mouse can continue\n            bt = box.top;\n            bl = box.left;\n            bw = box.width;\n            bh = box.height;\n            ft = ff.child(cls + 'top');\n            fb = ff.child(cls + 'bottom');\n            fl = ff.child(cls + 'left');\n            fr = ff.child(cls + 'right');\n\n            ft.setWidth(bw).setLeftTop(bl, bt);\n            fb.setWidth(bw).setLeftTop(bl, bt + bh - 2);\n            fl.setHeight(bh - 2).setLeftTop(bl, bt + 2);\n            fr.setHeight(bh - 2).setLeftTop(bl + bw - 2, bt + 2);\n\n            ff.show();\n        }\n\n        me.fireEvent('componentfocus', me, cmp, me.previousFocusedCmp);\n    },\n\n    onComponentHide: function(cmp) {\n        var me = this,\n            cmpHadFocus = false,\n            focusedCmp = me.focusedCmp,\n            parent;\n\n        if (focusedCmp) {\n            // See if the Component being hidden was the focused Component, or owns the focused Component\n            // In these cases, focus needs to be removed from the focused Component to the nearest focusable ancestor\n            cmpHadFocus = cmp.hasFocus || (cmp.isContainer && cmp.isAncestor(me.focusedCmp));\n        }\n\n        me.clearComponent(cmp);\n\n        // Move focus onto the nearest focusable ancestor, or this is there is none\n        if (cmpHadFocus && (parent = cmp.up(':focusable'))) {\n            parent.focus();\n        } else {\n            me.focusEl.focus();\n        }\n    },\n\n    onComponentDestroy: function() {\n\n    },\n\n    removeDOM: function() {\n        var me = this;\n\n        // If we are still enabled globally, or there are still subscribers\n        // then we will halt here, since our DOM stuff is still being used\n        if (me.enabled || me.subscribers.length) {\n            return;\n        }\n\n        Ext.destroy(\n            me.focusFrame\n        );\n        delete me.focusEl;\n        delete me.focusFrame;\n    },\n\n    /**\n     * Removes the specified xtype from the {@link #whitelist}.\n     * @param {String/String[]} xtype Removes the xtype(s) from the {@link #whitelist}.\n     */\n    removeXTypeFromWhitelist: function(xtype) {\n        var me = this;\n\n        if (Ext.isArray(xtype)) {\n            Ext.Array.forEach(xtype, me.removeXTypeFromWhitelist, me);\n            return;\n        }\n\n        Ext.Array.remove(me.whitelist, xtype);\n    },\n\n    setupSubscriberKeys: function(container, keys) {\n        var me = this,\n            el = container.getFocusEl(),\n            scope = keys.scope,\n            handlers = {\n                backspace: me.focusLast,\n                enter: me.navigateIn,\n                esc: me.navigateOut,\n                scope: me\n            },\n\n            navSiblings = function(e) {\n                if (me.focusedCmp === container) {\n                    // Root the sibling navigation to this container, so that we\n                    // can automatically dive into the container, rather than forcing\n                    // the user to hit the enter key to dive in.\n                    return me.navigateSiblings(e, me, container);\n                } else {\n                    return me.navigateSiblings(e);\n                }\n            };\n\n        Ext.iterate(keys, function(key, cb) {\n            handlers[key] = function(e) {\n                var ret = navSiblings(e);\n\n                if (Ext.isFunction(cb) && cb.call(scope || container, e, ret) === true) {\n                    return true;\n                }\n\n                return ret;\n            };\n        }, me);\n\n        return new Ext.util.KeyNav(el, handlers);\n    },\n\n    shouldShowFocusFrame: function(cmp) {\n        var me = this,\n            opts = me.options || {},\n            cmpFocusEl = cmp.getFocusEl(),\n            cmpFocusElTag = Ext.getDom(cmpFocusEl).tagName;\n\n        // Do not show a focus frame if\n        // 1. We are configured not to.\n        // 2. No Component was passed\n        if (!me.focusFrame || !cmp) {\n            return false;\n        }\n\n        // Global trumps\n        if (opts.focusFrame) {\n            return true;\n        }\n\n        if (me.focusData[cmp.id].focusFrame) {\n            return true;\n        }\n\n        return false;\n    }\n});\n\n/**\n * Simple helper class for easily creating image components. This renders an image tag to\n * the DOM with the configured src.\n *\n * {@img Ext.Img/Ext.Img.png Ext.Img component}\n *\n * ## Example usage:\n *\n *     var changingImage = Ext.create('Ext.Img', {\n *         src: 'http://www.sencha.com/img/20110215-feat-html5.png',\n *         renderTo: Ext.getBody()\n *     });\n *\n *     // change the src of the image programmatically\n *     changingImage.setSrc('http://www.sencha.com/img/20110215-feat-perf.png');\n *\n * By default, only an img element is rendered and that is this component's primary\n * {@link Ext.AbstractComponent#getEl element}. If the {@link Ext.AbstractComponent#autoEl} property\n * is other than 'img' (the default), the a child img element will be added to the primary\n * element. This can be used to create a wrapper element around the img.\n *\n * ## Wrapping the img in a div:\n *\n *     var wrappedImage = Ext.create('Ext.Img', {\n *         src: 'http://www.sencha.com/img/20110215-feat-html5.png',\n *         autoEl: 'div', // wrap in a div\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.Img', {\n    extend: 'Ext.Component',\n    alias: ['widget.image', 'widget.imagecomponent'],\n\n    autoEl: 'img',\n\n    /**\n     * @cfg {String} src\n     * The image src.\n     */\n    src: '',\n\n    /**\n     * @cfg {String} alt\n     * The descriptive text for non-visual UI description.\n     */\n    alt: '',\n\n    /**\n     * @cfg {String} imgCls\n     * Optional CSS classes to add to the img element.\n     */\n    imgCls: '',\n\n    getElConfig: function() {\n        var me = this,\n            config = me.callParent(),\n            img;\n\n        // It is sometimes helpful (like in a panel header icon) to have the img wrapped\n        // by a div. If our autoEl is not 'img' then we just add an img child to the el.\n        if (me.autoEl == 'img') {\n            img = config;\n        } else {\n            config.cn = [img = {\n                tag: 'img',\n                id: me.id + '-img'\n            }];\n        }\n\n        if (me.imgCls) {\n            img.cls = (img.cls ? img.cls + ' ' : '') + me.imgCls;\n        }\n\n        img.src = me.src || Ext.BLANK_IMAGE_URL;\n        if (me.alt) {\n            img.alt = me.alt;\n        }\n\n        return config;\n    },\n\n    onRender: function () {\n        var me = this,\n            el;\n\n        me.callParent(arguments);\n\n        el = me.el;\n        me.imgEl = (me.autoEl == 'img') ? el : el.getById(me.id + '-img');\n    },\n\n    onDestroy: function () {\n        Ext.destroy(this.imgEl);\n        this.imgEl = null;\n        this.callParent();\n    },\n\n    /**\n     * Updates the {@link #src} of the image.\n     * @param {String} src\n     */\n    setSrc: function(src) {\n        var me = this,\n            imgEl = me.imgEl;\n\n        me.src = src;\n\n        if (imgEl) {\n            imgEl.dom.src = src || Ext.BLANK_IMAGE_URL;\n        }\n    }\n});\n\n/**\n * An extended {@link Ext.Element} object that supports a shadow and shim, constrain to viewport and\n * automatic maintaining of shadow/shim positions.\n */\nExt.define('Ext.Layer', {\n    extend: 'Ext.Element',\n    uses: ['Ext.Shadow'],\n\n    /**\n     * @cfg {Boolean} [shim=true]\n     * False to disable the iframe shim in browsers which need one.\n     */\n\n    /**\n     * @cfg {String/Boolean} [shadow=false]\n     * True to automatically create an {@link Ext.Shadow}, or a string indicating the\n     * shadow's display {@link Ext.Shadow#mode}. False to disable the shadow.\n     */\n\n    /**\n     * @cfg {Object} [dh={tag: 'div', cls: 'x-layer'}]\n     * DomHelper object config to create element with.\n     */\n\n    /**\n     * @cfg {Boolean} [constrain=true]\n     * False to disable constrain to viewport.\n     */\n\n    /**\n     * @cfg {String} cls\n     * CSS class to add to the element\n     */\n\n    /**\n     * @cfg {Number} [zindex=11000]\n     * Starting z-index.\n     */\n\n    /**\n     * @cfg {Number} [shadowOffset=4]\n     * Number of pixels to offset the shadow\n     */\n\n    /**\n     * @cfg {Boolean} [useDisplay=false]\n     * Defaults to use css offsets to hide the Layer. Specify <tt>true</tt>\n     * to use css style <tt>'display:none;'</tt> to hide the Layer.\n     */\n\n    /**\n     * @cfg {String} visibilityCls\n     * The CSS class name to add in order to hide this Layer if this layer\n     * is configured with <code>{@link #hideMode}: 'asclass'</code>\n     */\n\n    /**\n     * @cfg {String} hideMode\n     * A String which specifies how this Layer will be hidden.\n     * Values may be:\n     *\n     * - `'display'` : The Component will be hidden using the `display: none` style.\n     * - `'visibility'` : The Component will be hidden using the `visibility: hidden` style.\n     * - `'offsets'` : The Component will be hidden by absolutely positioning it out of the visible area\n     *   of the document. This is useful when a hidden Component must maintain measurable dimensions.\n     *   Hiding using `display` results in a Component having zero dimensions.\n     */\n\n    // shims are shared among layer to keep from having 100 iframes\n    statics: {\n        shims: []\n    },\n    \n    isLayer: true,\n\n    /**\n     * Creates new Layer.\n     * @param {Object} [config] An object with config options.\n     * @param {String/HTMLElement} [existingEl] Uses an existing DOM element.\n     * If the element is not found it creates it.\n     */\n    constructor: function(config, existingEl) {\n        config = config || {};\n        var me = this,\n            dh = Ext.DomHelper,\n            cp = config.parentEl,\n            pel = cp ? Ext.getDom(cp) : document.body,\n        hm = config.hideMode;\n\n        if (existingEl) {\n            me.dom = Ext.getDom(existingEl);\n        }\n        if (!me.dom) {\n            me.dom = dh.append(pel, config.dh || {\n                tag: 'div',\n                cls: Ext.baseCSSPrefix + 'layer' // primarily to give el 'position:absolute'\n            });\n        } else {\n            me.addCls(Ext.baseCSSPrefix + 'layer');\n            if (!me.dom.parentNode) {\n                pel.appendChild(me.dom);\n            }\n        }\n\n        if (config.id) {\n            me.id = me.dom.id = config.id;\n        } else {\n            me.id = Ext.id(me.dom);\n        }\n\n        Ext.Element.addToCache(me);\n\n        if (config.cls) {\n            me.addCls(config.cls);\n        }\n        me.constrain = config.constrain !== false;\n\n        // Allow Components to pass their hide mode down to the Layer if they are floating.\n        // Otherwise, allow useDisplay to override the default hiding method which is visibility.\n        // TODO: Have ExtJS's Element implement visibilityMode by using classes as in Mobile.\n        if (hm) {\n            me.setVisibilityMode(Ext.Element[hm.toUpperCase()]);\n            if (me.visibilityMode == Ext.Element.ASCLASS) {\n                me.visibilityCls = config.visibilityCls;\n            }\n        } else if (config.useDisplay) {\n            me.setVisibilityMode(Ext.Element.DISPLAY);\n        } else {\n            me.setVisibilityMode(Ext.Element.VISIBILITY);\n        }\n\n        if (config.shadow) {\n            me.shadowOffset = config.shadowOffset || 4;\n            me.shadow = new Ext.Shadow({\n                offset: me.shadowOffset,\n                mode: config.shadow\n            });\n            me.disableShadow();\n        } else {\n            me.shadowOffset = 0;\n        }\n        me.useShim = config.shim !== false && Ext.useShims;\n        if (config.hidden === true) {\n            me.hide();\n        } else {\n            me.show();\n        }\n    },\n\n    getZIndex: function() {\n        return parseInt((this.getShim() || this).getStyle('z-index'), 10);\n    },\n\n    getShim: function() {\n        var me = this,\n            shim, pn;\n\n        if (!me.useShim) {\n            return null;\n        }\n        if (!me.shim) {\n            shim = me.self.shims.shift();\n            if (!shim) {\n                shim = me.createShim();\n                shim.enableDisplayMode('block');\n                shim.hide();\n            }\n            pn = me.dom.parentNode;\n            if (shim.dom.parentNode != pn) {\n                pn.insertBefore(shim.dom, me.dom);\n            }\n            me.shim = shim;\n        }\n        return me.shim;\n    },\n\n    hideShim: function() {\n        var me = this;\n        \n        if (me.shim) {\n            me.shim.setDisplayed(false);\n            me.self.shims.push(me.shim);\n            delete me.shim;\n        }\n    },\n\n    disableShadow: function() {\n        var me = this;\n        \n        if (me.shadow && !me.shadowDisabled) {\n            me.shadowDisabled = true;\n            me.shadow.hide();\n            me.lastShadowOffset = me.shadowOffset;\n            me.shadowOffset = 0;\n        }\n    },\n\n    enableShadow: function(show) {\n        var me = this;\n        \n        if (me.shadow && me.shadowDisabled) {\n            me.shadowDisabled = false;\n            me.shadowOffset = me.lastShadowOffset;\n            delete me.lastShadowOffset;\n            if (show) {\n                me.sync(true);\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Synchronize this Layer's associated elements, the shadow, and possibly the shim.\n     *\n     * This code can execute repeatedly in milliseconds,\n     * eg: dragging a Component configured liveDrag: true, or which has no ghost method\n     * so code size was sacrificed for efficiency (e.g. no getBox/setBox, no XY calls)\n     *\n     * @param {Boolean} doShow Pass true to ensure that the shadow is shown.\n     */\n    sync: function(doShow) {\n        var me = this,\n            shadow = me.shadow,\n            shadowPos, shimStyle, shadowSize,\n            shim, l, t, w, h, shimIndex;\n\n        if (!me.updating && me.isVisible() && (shadow || me.useShim)) {\n            shim = me.getShim();\n            l = me.getLocalX();\n            t = me.getLocalY();\n            w = me.dom.offsetWidth;\n            h = me.dom.offsetHeight;\n\n            if (shadow && !me.shadowDisabled) {\n                if (doShow && !shadow.isVisible()) {\n                    shadow.show(me);\n                } else {\n                    shadow.realign(l, t, w, h);\n                }\n                if (shim) {\n                    // TODO: Determine how the shims zIndex is above the layer zIndex at this point\n                    shimIndex = shim.getStyle('z-index');\n                    if (shimIndex > me.zindex) {\n                        me.shim.setStyle('z-index', me.zindex - 2);\n                    }\n                    shim.show();\n                    // fit the shim behind the shadow, so it is shimmed too\n                    if (shadow.isVisible()) {\n                        shadowPos = shadow.el.getXY();\n                        shimStyle = shim.dom.style;\n                        shadowSize = shadow.el.getSize();\n                        if (Ext.supports.CSS3BoxShadow) {\n                            shadowSize.height += 6;\n                            shadowSize.width += 4;\n                            shadowPos[0] -= 2;\n                            shadowPos[1] -= 4;\n                        }\n                        shimStyle.left = (shadowPos[0]) + 'px';\n                        shimStyle.top = (shadowPos[1]) + 'px';\n                        shimStyle.width = (shadowSize.width) + 'px';\n                        shimStyle.height = (shadowSize.height) + 'px';\n                    } else {\n                        shim.setSize(w, h);\n                        shim.setLeftTop(l, t);\n                    }\n                }\n            } else if (shim) {\n                // TODO: Determine how the shims zIndex is above the layer zIndex at this point\n                shimIndex = shim.getStyle('z-index');\n                if (shimIndex > me.zindex) {\n                    me.shim.setStyle('z-index', me.zindex - 2);\n                }\n                shim.show();\n                shim.setSize(w, h);\n                shim.setLeftTop(l, t);\n            }\n        }\n        return me;\n    },\n\n    remove: function() {\n        this.hideUnders();\n        this.callParent();\n    },\n\n    // private\n    beginUpdate: function() {\n        this.updating = true;\n    },\n\n    // private\n    endUpdate: function() {\n        this.updating = false;\n        this.sync(true);\n    },\n\n    // private\n    hideUnders: function() {\n        if (this.shadow) {\n            this.shadow.hide();\n        }\n        this.hideShim();\n    },\n\n    // private\n    constrainXY: function() {\n        if (this.constrain) {\n            var vw = Ext.Element.getViewWidth(),\n                vh = Ext.Element.getViewHeight(),\n                s = Ext.getDoc().getScroll(),\n                xy = this.getXY(),\n                x = xy[0],\n                y = xy[1],\n                so = this.shadowOffset,\n                w = this.dom.offsetWidth + so,\n                h = this.dom.offsetHeight + so,\n                moved = false; // only move it if it needs it\n            // first validate right/bottom\n            if ((x + w) > vw + s.left) {\n                x = vw - w - so;\n                moved = true;\n            }\n            if ((y + h) > vh + s.top) {\n                y = vh - h - so;\n                moved = true;\n            }\n            // then make sure top/left isn't negative\n            if (x < s.left) {\n                x = s.left;\n                moved = true;\n            }\n            if (y < s.top) {\n                y = s.top;\n                moved = true;\n            }\n            if (moved) {\n                Ext.Layer.superclass.setXY.call(this, [x, y]);\n                this.sync();\n            }\n        }\n        return this;\n    },\n\n    getConstrainOffset: function() {\n        return this.shadowOffset;\n    },\n\n    // overridden Element method\n    setVisible: function(visible, animate, duration, callback, easing) {\n        var me = this,\n            cb;\n\n        // post operation processing\n        cb = function() {\n            if (visible) {\n                me.sync(true);\n            }\n            if (callback) {\n                callback();\n            }\n        };\n\n        // Hide shadow and shim if hiding\n        if (!visible) {\n            me.hideUnders(true);\n        }\n        me.callParent([visible, animate, duration, callback, easing]);\n        if (!animate) {\n            cb();\n        }\n        return me;\n    },\n\n    // private\n    beforeFx: function() {\n        this.beforeAction();\n        return this.callParent(arguments);\n    },\n\n    // private\n    afterFx: function() {\n        this.callParent(arguments);\n        this.sync(this.isVisible());\n    },\n\n    // private\n    beforeAction: function() {\n        if (!this.updating && this.shadow) {\n            this.shadow.hide();\n        }\n    },\n\n    // overridden Element method\n    setLeft: function(left) {\n        this.callParent(arguments);\n        return this.sync();\n    },\n\n    setTop: function(top) {\n        this.callParent(arguments);\n        return this.sync();\n    },\n\n    setLeftTop: function(left, top) {\n        this.callParent(arguments);\n        return this.sync();\n    },\n\n    setXY: function(xy, animate, duration, callback, easing) {\n        var me = this;\n        \n        // Callback will restore shadow state and call the passed callback\n        callback = me.createCB(callback);\n\n        me.fixDisplay();\n        me.beforeAction();\n        me.callParent([xy, animate, duration, callback, easing]);\n        if (!animate) {\n            callback();\n        }\n        return me;\n    },\n\n    // private\n    createCB: function(callback) {\n        var me = this,\n            showShadow = me.shadow && me.shadow.isVisible();\n\n        return function() {\n            me.constrainXY();\n            me.sync(showShadow);\n            if (callback) {\n                callback();\n            }\n        };\n    },\n\n    // overridden Element method\n    setX: function(x, animate, duration, callback, easing) {\n        this.setXY([x, this.getY()], animate, duration, callback, easing);\n        return this;\n    },\n\n    // overridden Element method\n    setY: function(y, animate, duration, callback, easing) {\n        this.setXY([this.getX(), y], animate, duration, callback, easing);\n        return this;\n    },\n\n    // overridden Element method\n    setSize: function(w, h, animate, duration, callback, easing) {\n        var me = this;\n        \n        // Callback will restore shadow state and call the passed callback\n        callback = me.createCB(callback);\n\n        me.beforeAction();\n        me.callParent([w, h, animate, duration, callback, easing]);\n        if (!animate) {\n            callback();\n        }\n        return me;\n    },\n\n    // overridden Element method\n    setWidth: function(w, animate, duration, callback, easing) {\n        var me = this;\n        \n        // Callback will restore shadow state and call the passed callback\n        callback = me.createCB(callback);\n\n        me.beforeAction();\n        me.callParent([w, animate, duration, callback, easing]);\n        if (!animate) {\n            callback();\n        }\n        return me;\n    },\n\n    // overridden Element method\n    setHeight: function(h, animate, duration, callback, easing) {\n        var me = this;\n        \n        // Callback will restore shadow state and call the passed callback\n        callback = me.createCB(callback);\n\n        me.beforeAction();\n        me.callParent([h, animate, duration, callback, easing]);\n        if (!animate) {\n            callback();\n        }\n        return me;\n    },\n\n    // overridden Element method\n    setBounds: function(x, y, width, height, animate, duration, callback, easing) {\n        var me = this;\n        \n        // Callback will restore shadow state and call the passed callback\n        callback = me.createCB(callback);\n\n        me.beforeAction();\n        if (!animate) {\n            Ext.Layer.superclass.setXY.call(me, [x, y]);\n            Ext.Layer.superclass.setSize.call(me, width, height);\n            callback();\n        } else {\n            me.callParent([x, y, width, height, animate, duration, callback, easing]);\n        }\n        return me;\n    },\n\n    /**\n     * Sets the z-index of this layer and adjusts any shadow and shim z-indexes. The layer\n     * z-index is automatically incremented depending upon the presence of a shim or a\n     * shadow in so that it always shows above those two associated elements.\n     *\n     * Any shim, will be assigned the passed z-index. A shadow will be assigned the next\n     * highet z-index, and the Layer's element will receive the highest  z-index.\n     *\n     * @param {Number} zindex The new z-index to set\n     * @return {Ext.Layer} The Layer\n     */\n    setZIndex: function(zindex) {\n        var me = this;\n        \n        me.zindex = zindex;\n        if (me.getShim()) {\n            me.shim.setStyle('z-index', zindex++);\n        }\n        if (me.shadow) {\n            me.shadow.setZIndex(zindex++);\n        }\n        return me.setStyle('z-index', zindex);\n    },\n    \n    onOpacitySet: function(opacity){\n        var shadow = this.shadow;\n        if (shadow) {\n            shadow.setOpacity(opacity);\n        }\n    }\n});\n\n/**\n * This class is used as a mixin.\n *\n * This class is to be used to provide basic methods for binding/unbinding stores to other\n * classes. In general it will not be used directly.\n */\nExt.define('Ext.util.Bindable', {\n    \n    /**\n     * Binds a store to this instance.\n     * @param {Ext.data.AbstractStore/String} [store] The store to bind or ID of the store.\n     * When no store given (or when `null` or `undefined` passed), unbinds the existing store.\n     * @param {Boolean} [initial=false] True to not remove listeners from existing store.\n     */\n    bindStore: function(store, initial){\n        var me = this,\n            oldStore = me.store;\n        \n        if (!initial && me.store) {\n            // Perform implementation-specific unbinding operations *before* possible Store destruction.\n            me.onUnbindStore(oldStore, initial);\n\n            if (store !== oldStore && oldStore.autoDestroy) {\n                oldStore.destroyStore();\n            } else {\n                me.unbindStoreListeners(oldStore);\n            }\n        }\n        if (store) {\n            store = Ext.data.StoreManager.lookup(store);\n            me.bindStoreListeners(store);\n            me.onBindStore(store, initial);\n        }\n        me.store = store || null;\n        return me;\n    },\n    \n    /**\n     * Gets the current store instance.\n     * @return {Ext.data.AbstractStore} The store, null if one does not exist.\n     */\n    getStore: function(){\n        return this.store;\n    },\n    \n    /**\n     * Unbinds listeners from this component to the store. By default it will remove\n     * anything bound by the bindStoreListeners method, however it can be overridden\n     * in a subclass to provide any more complicated handling.\n     * @protected \n     * @param {Ext.data.AbstractStore} store The store to unbind from\n     */\n    unbindStoreListeners: function(store) {\n        // Can be overridden in the subclass for more complex removal\n        var listeners = this.storeListeners;\n        if (listeners) {\n            store.un(listeners);\n        }\n    },\n    \n    /**\n     * Binds listeners for this component to the store. By default it will add\n     * anything bound by the getStoreListeners method, however it can be overridden\n     * in a subclass to provide any more complicated handling.\n     * @protected \n     * @param {Ext.data.AbstractStore} store The store to bind to\n     */\n    bindStoreListeners: function(store) {\n        // Can be overridden in the subclass for more complex binding\n        var me = this,\n            listeners = Ext.apply({}, me.getStoreListeners());\n            \n        if (!listeners.scope) {\n            listeners.scope = me;\n        }\n        me.storeListeners = listeners;\n        store.on(listeners);\n    },\n    \n    /**\n     * Gets the listeners to bind to a new store.\n     * @protected\n     * @return {Object} The listeners to be bound to the store in object literal form. The scope\n     * may be omitted, it is assumed to be the current instance.\n     */\n    getStoreListeners: Ext.emptyFn,\n    \n    /**\n     * Template method, it is called when an existing store is unbound\n     * from the current instance.\n     * @protected\n     * @param {Ext.data.AbstractStore} store The store being unbound\n     * @param {Boolean} initial True if this store is being bound as initialization of the instance.\n     */\n    onUnbindStore: Ext.emptyFn,\n    \n    /**\n     * Template method, it is called when a new store is bound\n     * to the current instance.\n     * @protected\n     * @param {Ext.data.AbstractStore} store The store being bound\n     * @param {Boolean} initial True if this store is being bound as initialization of the instance.\n     */\n    onBindStore: Ext.emptyFn    \n});\n\n/**\n * A modal, floating Component which may be shown above a specified {@link Ext.Component Component} while loading data.\n * When shown, the configured owning Component will be covered with a modality mask, and the LoadMask's {@link #msg} will be\n * displayed centered, accompanied by a spinner image.\n *\n * If the {@link #store} config option is specified, the masking will be automatically shown and then hidden synchronized with\n * the Store's loading process.\n *\n * Because this is a floating Component, its z-index will be managed by the global {@link Ext.WindowManager ZIndexManager}\n * object, and upon show, it will place itsef at the top of the hierarchy.\n *\n * Example usage:\n *\n *     // Basic mask:\n *     var myMask = new Ext.LoadMask(myPanel, {msg:\"Please wait...\"});\n *     myMask.show();\n */\nExt.define('Ext.LoadMask', {\n\n    extend: 'Ext.Component',\n\n    alias: 'widget.loadmask',\n\n    /* Begin Definitions */\n\n    mixins: {\n        floating: 'Ext.util.Floating',\n        bindable: 'Ext.util.Bindable'\n    },\n\n    uses: ['Ext.data.StoreManager'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Ext.data.Store} store\n     * Optional Store to which the mask is bound. The mask is displayed when a load request is issued, and\n     * hidden on either load success, or load fail.\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} [msg=\"Loading...\"]\n     * The text to display in a centered loading message box.\n     */\n    msg : 'Loading...',\n    //</locale>\n\n    /**\n     * @cfg {String} [msgCls=\"x-mask-loading\"]\n     * The CSS class to apply to the loading message element.\n     */\n    msgCls : Ext.baseCSSPrefix + 'mask-loading',\n\n    /**\n     * @cfg {String} [maskCls=\"x-mask\"]\n     * The CSS class to apply to the mask element\n     */\n    maskCls: Ext.baseCSSPrefix + 'mask',\n\n    /**\n     * @cfg {Boolean} [useMsg=true]\n     * Whether or not to use a loading message class or simply mask the bound element.\n     */\n    useMsg: true,\n\n    /**\n     * @cfg {Boolean} [useTargetEl=false]\n     * True to mask the {@link Ext.Component#getTargetEl targetEl} of the bound Component. By default,\n     * the {@link Ext.Component#getEl el} will be masked.\n     */\n    useTargetEl: false,\n\n    baseCls: Ext.baseCSSPrefix + 'mask-msg',\n\n    childEls: [\n        'msgEl'\n    ],\n\n    renderTpl: '<div id=\"{id}-msgEl\" style=\"position:relative\" class=\"{[values.$comp.msgCls]}\"></div>',\n\n    // Private. Obviously, it's floating.\n    floating: {\n        shadow: 'frame'\n    },\n\n    // Private. Masks are not focusable\n    focusOnToFront: false,\n\n    // When we put the load mask to the front of it's owner, we generally don't want to also bring the owning\n    // component to the front.\n    bringParentToFront: false,\n\n    /**\n     * Creates new LoadMask.\n     * @param {Ext.Component} comp The Component you wish to mask. The the mask will be automatically sized\n     * upon Component resize, and the message box will be kept centered.</p>\n     * @param {Object} [config] The config object\n     */\n    constructor : function(comp, config) {\n        var me = this;\n\n        // Element support to be deprecated\n        if (!comp.isComponent) {\n            if (Ext.isDefined(Ext.global.console)) {\n                Ext.global.console.warn('Ext.LoadMask: LoadMask for elements has been deprecated, use Ext.dom.Element.mask & Ext.dom.Element.unmask');\n            }\n            comp = Ext.get(comp);\n            this.isElement = true;\n        }\n\n        me.ownerCt = comp;\n        if (!this.isElement) {\n            me.bindComponent(comp);\n        }\n        me.callParent([config]);\n\n        if (me.store) {\n            me.bindStore(me.store, true);\n        }\n    },\n\n    bindComponent: function(comp){\n        var me = this,\n            listeners = {\n                scope: this,\n                resize: me.sizeMask,\n                added: me.onComponentAdded,\n                removed: me.onComponentRemoved\n            },\n            hierarchyEventSource = Ext.container.Container.hierarchyEventSource;\n            \n        if (comp.floating) {\n            listeners.move = me.sizeMask;\n            me.activeOwner = comp;\n        } else if (comp.ownerCt) {\n            me.onComponentAdded(comp.ownerCt);\n        } else {\n            // if the target comp is non-floating and under a floating comp don't bring the load mask to the front of the stack\n            me.preventBringToFront = true;\n        }\n\n        me.mon(comp, listeners);\n        \n        // subscribe to the observer that manages the hierarchy\n        me.mon(hierarchyEventSource, {\n            show: me.onContainerShow,\n            hide: me.onContainerHide,\n            expand: me.onContainerExpand,\n            collapse: me.onContainerCollapse,\n            scope: me\n        });\n    },\n\n    onComponentAdded: function(owner){\n        var me = this;\n        delete me.activeOwner;\n        me.floatParent = owner;\n        if (!owner.floating) {\n            owner = owner.up('[floating]');\n        }\n        if (owner) {\n            me.activeOwner = owner;\n            me.mon(owner, 'move', me.sizeMask, me);\n        }\n        owner = me.floatParent.ownerCt;\n        if (me.rendered && me.isVisible() && owner) {\n            me.floatOwner = owner;\n            me.mon(owner, 'afterlayout', me.sizeMask, me, {single: true});\n        }\n    },\n\n    onComponentRemoved: function(owner){\n        var me = this,\n            activeOwner = me.activeOwner,\n            floatOwner = me.floatOwner;\n\n        if (activeOwner) {\n            me.mun(activeOwner, 'move', me.sizeMask, me);\n        }\n        if (floatOwner) {\n            me.mun(floatOwner, 'afterlayout', me.sizeMask, me);\n        }\n        delete me.activeOwner;\n        delete me.floatOwner;\n    },\n\n    afterRender: function() {\n        this.callParent(arguments);\n        this.container = this.floatParent.getContentTarget();\n    },\n\n    onContainerShow: function(container){\n        if (this.isActiveContainer(container)) {\n            this.onComponentShow();\n        }\n    },\n\n    onContainerHide: function(container){\n        if (this.isActiveContainer(container)) {\n            this.onComponentHide();\n        }\n    },\n\n    onContainerExpand: function(container){\n        if (this.isActiveContainer(container)) {\n            this.onComponentShow();\n        }\n    },\n\n    onContainerCollapse: function(container){\n        if (this.isActiveContainer(container)) {\n            this.onComponentHide();\n        }\n    },\n\n    isActiveContainer: function(container){\n        return this.isDescendantOf(container);\n    },\n\n    onComponentHide: function(){\n        var me = this;\n\n        if (me.rendered && me.isVisible()) {\n            me.hide();\n            me.showNext = true;\n        }\n    },\n\n    onComponentShow: function(){\n        if (this.showNext) {\n            this.show();\n        }\n        delete this.showNext;\n    },\n\n    /**\n     * @private\n     * Called when this LoadMask's Component is resized. The toFront method rebases and resizes the modal mask.\n     */\n    sizeMask: function() {\n        var me = this,\n            target;\n\n        if (me.rendered && me.isVisible()) {\n            me.center();\n\n            target = me.getMaskTarget();\n            me.getMaskEl().show().setSize(target.getSize()).alignTo(target, 'tl-tl');\n\n        }\n    },\n\n    /**\n     * Changes the data store bound to this LoadMask.\n     * @param {Ext.data.Store} store The store to bind to this LoadMask\n     */\n    bindStore : function(store, initial) {\n        var me = this;\n        me.mixins.bindable.bindStore.apply(me, arguments);\n        store = me.store;\n        if (store && store.isLoading()) {\n            me.onBeforeLoad();\n        }\n    },\n\n    getStoreListeners: function(){\n        return {\n            beforeload: this.onBeforeLoad,\n            load: this.onLoad,\n            exception: this.onLoad,\n\n            // Fired when a range is requested for rendering that is not in the cache\n            cachemiss: this.onBeforeLoad,\n\n            // Fired when a range for rendering which was previously missing from the cache is loaded\n            cachefilled: this.onLoad\n        };\n    },\n\n    onDisable : function() {\n        this.callParent(arguments);\n        if (this.loading) {\n            this.onLoad();\n        }\n    },\n\n    getOwner: function(){\n        return this.ownerCt || this.floatParent;\n    },\n\n    getMaskTarget: function(){\n        var owner = this.getOwner();\n        return this.useTargetEl ? owner.getTargetEl() : owner.getEl();\n    },\n\n    // private\n    onBeforeLoad : function() {\n        var me = this,\n            owner = me.getOwner(),\n            origin;\n\n        if (!me.disabled) {\n            me.loading = true;\n            // If the owning Component has not been layed out, defer so that the ZIndexManager\n            // gets to read its layed out size when sizing the modal mask\n            if (owner.componentLayoutCounter) {\n                me.maybeShow();\n            } else {\n                // The code below is a 'run-once' interceptor.\n                origin = owner.afterComponentLayout;\n                owner.afterComponentLayout = function() {\n                    owner.afterComponentLayout = origin;\n                    origin.apply(owner, arguments);\n                    me.maybeShow();\n                };\n            }\n        }\n    },\n\n    maybeShow: function(){\n        var me = this,\n            owner = me.getOwner();\n\n        if (!owner.isVisible(true)) {\n            me.showNext = true;\n        }\n        else if (me.loading && owner.rendered) {\n            me.show();\n        }\n    },\n\n    getMaskEl: function(){\n        var me = this;\n        return me.maskEl || (me.maskEl = me.el.insertSibling({\n            cls: me.maskCls,\n            style: {\n                zIndex: me.el.getStyle('zIndex') - 2\n            }\n        }, 'before'));\n    },\n\n    onShow: function() {\n        var me = this,\n            msgEl = me.msgEl;\n\n        me.callParent(arguments);\n        me.loading = true;\n\n        if (me.useMsg) {\n            msgEl.show().update(me.msg);\n        } else {\n            msgEl.parent().hide();\n        }\n    },\n\n    hide: function(){\n        // Element support to be deprecated\n        if (this.isElement) {\n            this.ownerCt.unmask();\n            this.fireEvent('hide', this);\n            return;\n        }\n        delete this.showNext;\n        return this.callParent(arguments);\n    },\n\n    onHide: function(){\n        this.callParent();\n        this.getMaskEl().hide();\n    },\n\n    show: function(){\n        // Element support to be deprecated\n        if (this.isElement) {\n            this.ownerCt.mask(this.useMsg ? this.msg : '', this.msgCls);\n            this.fireEvent('show', this);\n            return;\n        }\n        return this.callParent(arguments);\n    },\n\n    afterShow: function() {\n        this.callParent(arguments);\n        this.sizeMask();\n    },\n\n    setZIndex: function(index) {\n        var me = this,\n            owner = me.activeOwner;\n            \n        if (owner) {\n            // it seems silly to add 1 to have it subtracted in the call below,\n            // but this allows the x-mask el to have the correct z-index (same as the component)\n            // so instead of directly changing the zIndexStack just get the z-index of the owner comp\n            index = parseInt(owner.el.getStyle('zIndex'), 10) + 1;\n        }\n\n        me.getMaskEl().setStyle('zIndex', index - 1);\n        return me.mixins.floating.setZIndex.apply(me, arguments);\n    },\n\n    // private\n    onLoad : function() {\n        this.loading = false;\n        this.hide();\n    },\n\n    onDestroy: function(){\n        var me = this;\n\n        if (me.isElement) {\n            me.ownerCt.unmask();\n        }\n\n        Ext.destroy(me.maskEl);\n        me.callParent();\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * Associations enable you to express relationships between different {@link Ext.data.Model Models}. Let's say we're\n * writing an ecommerce system where Users can make Orders - there's a relationship between these Models that we can\n * express like this:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'name', 'email'],\n *\n *         hasMany: {model: 'Order', name: 'orders'}\n *     });\n *\n *     Ext.define('Order', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'user_id', 'status', 'price'],\n *\n *         belongsTo: 'User'\n *     });\n *\n * We've set up two models - User and Order - and told them about each other. You can set up as many associations on\n * each Model as you need using the two default types - {@link Ext.data.HasManyAssociation hasMany} and {@link\n * Ext.data.BelongsToAssociation belongsTo}. There's much more detail on the usage of each of those inside their\n * documentation pages. If you're not familiar with Models already, {@link Ext.data.Model there is plenty on those too}.\n *\n * **Further Reading**\n *\n *   - {@link Ext.data.association.HasMany hasMany associations}\n *   - {@link Ext.data.association.BelongsTo belongsTo associations}\n *   - {@link Ext.data.association.HasOne hasOne associations}\n *   - {@link Ext.data.Model using Models}\n *\n * # Self association models\n *\n * We can also have models that create parent/child associations between the same type. Below is an example, where\n * groups can be nested inside other groups:\n *\n *     // Server Data\n *     {\n *         \"groups\": {\n *             \"id\": 10,\n *             \"parent_id\": 100,\n *             \"name\": \"Main Group\",\n *             \"parent_group\": {\n *                 \"id\": 100,\n *                 \"parent_id\": null,\n *                 \"name\": \"Parent Group\"\n *             },\n *             \"child_groups\": [{\n *                 \"id\": 2,\n *                 \"parent_id\": 10,\n *                 \"name\": \"Child Group 1\"\n *             },{\n *                 \"id\": 3,\n *                 \"parent_id\": 10,\n *                 \"name\": \"Child Group 2\"\n *             },{\n *                 \"id\": 4,\n *                 \"parent_id\": 10,\n *                 \"name\": \"Child Group 3\"\n *             }]\n *         }\n *     }\n *\n *     // Client code\n *     Ext.define('Group', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'parent_id', 'name'],\n *         proxy: {\n *             type: 'ajax',\n *             url: 'data.json',\n *             reader: {\n *                 type: 'json',\n *                 root: 'groups'\n *             }\n *         },\n *         associations: [{\n *             type: 'hasMany',\n *             model: 'Group',\n *             primaryKey: 'id',\n *             foreignKey: 'parent_id',\n *             autoLoad: true,\n *             associationKey: 'child_groups' // read child data from child_groups\n *         }, {\n *             type: 'belongsTo',\n *             model: 'Group',\n *             primaryKey: 'id',\n *             foreignKey: 'parent_id',\n *             associationKey: 'parent_group' // read parent data from parent_group\n *         }]\n *     });\n *\n *     Ext.onReady(function(){\n *\n *         Group.load(10, {\n *             success: function(group){\n *                 console.log(group.getGroup().get('name'));\n *\n *                 group.groups().each(function(rec){\n *                     console.log(rec.get('name'));\n *                 });\n *             }\n *         });\n *\n *     });\n *\n */\nExt.define('Ext.data.association.Association', {\n    alternateClassName: 'Ext.data.Association',\n    /**\n     * @cfg {String} ownerModel\n     * The string name of the model that owns the association.\n     *\n     * **NB!** This config is required when instantiating the Association directly.\n     * However, it cannot be used at all when defining the association as a config\n     * object inside Model, because the name of the model itself will be supplied\n     * automatically as the value of this config.\n     */\n\n    /**\n     * @cfg {String} associatedModel\n     * The string name of the model that is being associated with.\n     *\n     * **NB!** This config is required when instantiating the Association directly.\n     * When defining the association as a config object inside Model, the #model\n     * configuration will shadow this config.\n     */\n\n    /**\n     * @cfg {String} model\n     * The string name of the model that is being associated with.\n     *\n     * This config option is to be used when defining the association as a config\n     * object within Model.  The value is then mapped to #associatedModel when\n     * Association is instantiated inside Model.\n     */\n\n    /**\n     * @cfg {String} primaryKey\n     * The name of the primary key on the associated model. In general this will be the\n     * {@link Ext.data.Model#idProperty} of the Model.\n     */\n    primaryKey: 'id',\n\n    /**\n     * @cfg {Ext.data.reader.Reader} reader\n     * A special reader to read associated data\n     */\n    \n    /**\n     * @cfg {String} associationKey\n     * The name of the property in the data to read the association from. Defaults to the name of the associated model.\n     */\n\n    defaultReaderType: 'json',\n\n    isAssociation: true,\n\n    initialConfig: null,\n\n    statics: {\n        AUTO_ID: 1000,\n        \n        create: function(association){\n            if (Ext.isString(association)) {\n                association = {\n                    type: association\n                };\n            }\n\n            switch (association.type) {\n                case 'belongsTo':\n                    return new Ext.data.association.BelongsTo(association);\n                case 'hasMany':\n                    return new Ext.data.association.HasMany(association);\n                case 'hasOne':\n                    return new Ext.data.association.HasOne(association);\n                //TODO Add this back when it's fixed\n//                    case 'polymorphic':\n//                        return Ext.create('Ext.data.PolymorphicAssociation', association);\n                default:\n                    Ext.Error.raise('Unknown Association type: \"' + association.type + '\"');\n            }\n            return association;\n        }\n    },\n\n    /**\n     * Creates the Association object.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        Ext.apply(this, config);\n\n        var me = this,\n            types           = Ext.ModelManager.types,\n            ownerName       = config.ownerModel,\n            associatedName  = config.associatedModel,\n            ownerModel      = types[ownerName],\n            associatedModel = types[associatedName];\n\n        me.initialConfig = config;\n\n        if (ownerModel === undefined) {\n            Ext.Error.raise(\"The configured ownerModel was not valid (you tried \" + ownerName + \")\");\n        }\n        if (associatedModel === undefined) {\n            Ext.Error.raise(\"The configured associatedModel was not valid (you tried \" + associatedName + \")\");\n        }\n\n        me.ownerModel = ownerModel;\n        me.associatedModel = associatedModel;\n\n        /**\n         * @property {String} ownerName\n         * The name of the model that 'owns' the association\n         */\n\n        /**\n         * @property {String} associatedName\n         * The name of the model is on the other end of the association (e.g. if a User model hasMany Orders, this is\n         * 'Order')\n         */\n\n        Ext.applyIf(me, {\n            ownerName : ownerName,\n            associatedName: associatedName\n        });\n        \n        me.associationId = 'association' + (++me.statics().AUTO_ID);\n    },\n\n    /**\n     * Get a specialized reader for reading associated data\n     * @return {Ext.data.reader.Reader} The reader, null if not supplied\n     */\n    getReader: function(){\n        var me = this,\n            reader = me.reader,\n            model = me.associatedModel;\n\n        if (reader) {\n            if (Ext.isString(reader)) {\n                reader = {\n                    type: reader\n                };\n            }\n            if (reader.isReader) {\n                reader.setModel(model);\n            } else {\n                Ext.applyIf(reader, {\n                    model: model,\n                    type : me.defaultReaderType\n                });\n            }\n            me.reader = Ext.createByAlias('reader.' + reader.type, reader);\n        }\n        return me.reader || null;\n    }\n});\n\n/**\n * @author Ed Spencer\n * @class Ext.ModelManager\n\nThe ModelManager keeps track of all {@link Ext.data.Model} types defined in your application.\n\n__Creating Model Instances__\n\nModel instances can be created by using the {@link Ext#create Ext.create} method. Ext.create replaces\nthe deprecated {@link #create Ext.ModelManager.create} method. It is also possible to create a model instance\nthis by using the Model type directly. The following 3 snippets are equivalent:\n\n    Ext.define('User', {\n        extend: 'Ext.data.Model',\n        fields: ['first', 'last']\n    });\n\n    // method 1, create using Ext.create (recommended)\n    Ext.create('User', {\n        first: 'Ed',\n        last: 'Spencer'\n    });\n\n    // method 2, create through the manager (deprecated)\n    Ext.ModelManager.create({\n        first: 'Ed',\n        last: 'Spencer'\n    }, 'User');\n\n    // method 3, create on the type directly\n    new User({\n        first: 'Ed',\n        last: 'Spencer'\n    });\n\n__Accessing Model Types__\n\nA reference to a Model type can be obtained by using the {@link #getModel} function. Since models types\nare normal classes, you can access the type directly. The following snippets are equivalent:\n\n    Ext.define('User', {\n        extend: 'Ext.data.Model',\n        fields: ['first', 'last']\n    });\n\n    // method 1, access model type through the manager\n    var UserType = Ext.ModelManager.getModel('User');\n\n    // method 2, reference the type directly\n    var UserType = User;\n\n * @markdown\n * @singleton\n */\nExt.define('Ext.ModelManager', {\n    extend: 'Ext.AbstractManager',\n    alternateClassName: 'Ext.ModelMgr',\n    requires: ['Ext.data.association.Association'],\n    \n    singleton: true,\n\n    typeName: 'mtype',\n\n    /**\n     * Private stack of associations that must be created once their associated model has been defined\n     * @property {Ext.data.association.Association[]} associationStack\n     */\n    associationStack: [],\n\n    /**\n     * Registers a model definition. All model plugins marked with isDefault: true are bootstrapped\n     * immediately, as are any addition plugins defined in the model config.\n     * @private\n     */\n    registerType: function(name, config) {\n        var proto = config.prototype,\n            model;\n        if (proto && proto.isModel) {\n            // registering an already defined model\n            model = config;\n        } else {\n            // passing in a configuration\n            if (!config.extend) {\n                config.extend = 'Ext.data.Model';\n            }\n            model = Ext.define(name, config);\n        }\n        this.types[name] = model;\n        return model;\n    },\n\n    /**\n     * @private\n     * Private callback called whenever a model has just been defined. This sets up any associations\n     * that were waiting for the given model to be defined\n     * @param {Function} model The model that was just created\n     */\n    onModelDefined: function(model) {\n        var stack  = this.associationStack,\n            length = stack.length,\n            create = [],\n            association, i, created;\n\n        for (i = 0; i < length; i++) {\n            association = stack[i];\n\n            if (association.associatedModel == model.modelName) {\n                create.push(association);\n            }\n        }\n\n        for (i = 0, length = create.length; i < length; i++) {\n            created = create[i];\n            this.types[created.ownerModel].prototype.associations.add(Ext.data.association.Association.create(created));\n            Ext.Array.remove(stack, created);\n        }\n    },\n\n    /**\n     * Registers an association where one of the models defined doesn't exist yet.\n     * The ModelManager will check when new models are registered if it can link them\n     * together\n     * @private\n     * @param {Ext.data.association.Association} association The association\n     */\n    registerDeferredAssociation: function(association){\n        this.associationStack.push(association);\n    },\n\n    /**\n     * Returns the {@link Ext.data.Model} for a given model name\n     * @param {String/Object} id The id of the model or the model instance.\n     * @return {Ext.data.Model} a model class.\n     */\n    getModel: function(id) {\n        var model = id;\n        if (typeof model == 'string') {\n            model = this.types[model];\n        }\n        return model;\n    },\n\n    /**\n     * Creates a new instance of a Model using the given data. Deprecated, instead use Ext.create:\n     *\n     *     Ext.create('User', {\n     *         first: 'Ed',\n     *         last: 'Spencer'\n     *     });\n     *\n     * @deprecated 4.1 Use {@link Ext#create Ext.create} instead.\n     *\n     * @param {Object} data Data to initialize the Model's fields with\n     * @param {String} name The name of the model to create\n     * @param {Number} id (Optional) unique id of the Model instance (see {@link Ext.data.Model})\n     */\n    create: function(config, name, id) {\n        var Con = typeof name == 'function' ? name : this.types[name || config.name];\n\n        return new Con(config, id);\n    }\n}, function() {\n\n    /**\n     * Old way for creating Model classes.  Instead use:\n     *\n     *     Ext.define(\"MyModel\", {\n     *         extend: \"Ext.data.Model\",\n     *         fields: []\n     *     });\n     *\n     * @param {String} name Name of the Model class.\n     * @param {Object} config A configuration object for the Model you wish to create.\n     * @return {Ext.data.Model} The newly registered Model\n     * @member Ext\n     * @deprecated 4.0.0 Use {@link Ext#define} instead.\n     */\n    Ext.regModel = function() {\n        if (Ext.isDefined(Ext.global.console)) {\n            Ext.global.console.warn('Ext.regModel has been deprecated. Models can now be created by extending Ext.data.Model: Ext.define(\"MyModel\", {extend: \"Ext.data.Model\", fields: []});.');\n        }\n        return this.ModelManager.registerType.apply(this.ModelManager, arguments);\n    };\n});\n\n/**\n * Provides a registry of available Plugin classes indexed by a mnemonic code known as the Plugin's ptype.\n *\n * A plugin may be specified simply as a *config object* as long as the correct `ptype` is specified:\n *\n *     {\n *         ptype: 'gridviewdragdrop',\n *         dragText: 'Drag and drop to reorganize'\n *     }\n *\n * Or just use the ptype on its own:\n *\n *     'gridviewdragdrop'\n *\n * Alternatively you can instantiate the plugin with Ext.create:\n *\n *     Ext.create('Ext.grid.plugin.DragDrop', {\n *         dragText: 'Drag and drop to reorganize'\n *     })\n */\nExt.define('Ext.PluginManager', {\n    extend: 'Ext.AbstractManager',\n    alternateClassName: 'Ext.PluginMgr',\n    singleton: true,\n    typeName: 'ptype',\n\n    /**\n     * Creates a new Plugin from the specified config object using the config object's ptype to determine the class to\n     * instantiate.\n     * @param {Object} config A configuration object for the Plugin you wish to create.\n     * @param {Function} defaultType (optional) The constructor to provide the default Plugin type if the config object does not\n     * contain a `ptype`. (Optional if the config contains a `ptype`).\n     * @return {Ext.Component} The newly instantiated Plugin.\n     */\n    create : function(config, defaultType){\n        if (config.init) {\n            return config;\n        } else {\n            return Ext.createByAlias('plugin.' + (config.ptype || defaultType), config);\n        }\n\n        // Prior system supported Singleton plugins.\n        //var PluginCls = this.types[config.ptype || defaultType];\n        //if (PluginCls.init) {\n        //    return PluginCls;\n        //} else {\n        //    return new PluginCls(config);\n        //}\n    },\n\n    //create: function(plugin, defaultType) {\n    //    if (plugin instanceof this) {\n    //        return plugin;\n    //    } else {\n    //        var type, config = {};\n    //\n    //        if (Ext.isString(plugin)) {\n    //            type = plugin;\n    //        }\n    //        else {\n    //            type = plugin[this.typeName] || defaultType;\n    //            config = plugin;\n    //        }\n    //\n    //        return Ext.createByAlias('plugin.' + type, config);\n    //    }\n    //},\n\n    /**\n     * Returns all plugins registered with the given type. Here, 'type' refers to the type of plugin, not its ptype.\n     * @param {String} type The type to search for\n     * @param {Boolean} defaultsOnly True to only return plugins of this type where the plugin's isDefault property is\n     * truthy\n     * @return {Ext.AbstractPlugin[]} All matching plugins\n     */\n    findByType: function(type, defaultsOnly) {\n        var matches = [],\n            types   = this.types,\n            name,\n            item;\n\n        for (name in types) {\n            if (!types.hasOwnProperty(name)) {\n                continue;\n            }\n            item = types[name];\n\n            if (item.type == type && (!defaultsOnly || (defaultsOnly === true && item.isDefault))) {\n                matches.push(item);\n            }\n        }\n\n        return matches;\n    }\n}, function() {\n    /**\n     * Shorthand for {@link Ext.PluginManager#registerType}\n     * @param {String} ptype The ptype mnemonic string by which the Plugin class\n     * may be looked up.\n     * @param {Function} cls The new Plugin class.\n     * @member Ext\n     * @method preg\n     */\n    Ext.preg = function() {\n        return Ext.PluginManager.registerType.apply(Ext.PluginManager, arguments);\n    };\n});\n\n/**\n * @private\n */\nExt.define('Ext.layout.component.ProgressBar', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.progressbar'],\n\n    extend: 'Ext.layout.component.Auto',\n\n    /* End Definitions */\n\n    type: 'progressbar',\n\n    beginLayout: function (ownerContext) {\n        var me = this,\n            i, textEls;\n\n        me.callParent(arguments);\n\n        if (!ownerContext.textEls) {\n            textEls = me.owner.textEl; // an Ext.Element or CompositeList (raw DOM el's)\n\n            if (textEls.isComposite) {\n                ownerContext.textEls = [];\n                textEls = textEls.elements;\n                for (i = textEls.length; i--; ) {\n                    ownerContext.textEls[i] = ownerContext.getEl(Ext.get(textEls[i]));\n                }\n            } else {\n                ownerContext.textEls = [ ownerContext.getEl('textEl') ];\n            }\n        }\n    },\n\n    calculate: function(ownerContext) {\n        var me = this,\n            i, textEls, width;\n\n        me.callParent(arguments);\n\n        if (Ext.isNumber(width = ownerContext.getProp('width'))) {\n            width -= ownerContext.getBorderInfo().width;\n            textEls = ownerContext.textEls;\n\n            for (i = textEls.length; i--; ) {\n                textEls[i].setWidth(width);\n            }\n        } else {\n            me.done = false;\n        }\n    }\n});\n\n//@tag dom,core\n/**\n * @class Ext.dom.CompositeElement\n * <p>This class encapsulates a <i>collection</i> of DOM elements, providing methods to filter\n * members, or to perform collective actions upon the whole set.</p>\n * <p>Although they are not listed, this class supports all of the methods of {@link Ext.dom.Element} and\n * {@link Ext.fx.Anim}. The methods from these classes will be performed on all the elements in this collection.</p>\n * <p>All methods return <i>this</i> and can be chained.</p>\n * Usage:\n <pre><code>\n var els = Ext.select(\"#some-el div.some-class\", true);\n // or select directly from an existing element\n var el = Ext.get('some-el');\n el.select('div.some-class', true);\n\n els.setWidth(100); // all elements become 100 width\n els.hide(true); // all elements fade out and hide\n // or\n els.setWidth(100).hide(true);\n </code></pre>\n */\nExt.define('Ext.dom.CompositeElement', {\n    alternateClassName: 'Ext.CompositeElement',\n\n    extend: 'Ext.dom.CompositeElementLite',\n\n    // private\n    getElement: function(el) {\n        // In this case just return it, since we already have a reference to it\n        return el;\n    },\n\n    // private\n    transformElement: function(el) {\n        return Ext.get(el);\n    }\n\n}, function() {\n    /**\n     * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods\n     * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or\n     * {@link Ext.CompositeElementLite CompositeElementLite} object.\n     * @param {String/HTMLElement[]} selector The CSS selector or an array of elements\n     * @param {Boolean} [unique] true to create a unique Ext.Element for each element (defaults to a shared flyweight object)\n     * @param {HTMLElement/String} [root] The root element of the query or id of the root\n     * @return {Ext.CompositeElementLite/Ext.CompositeElement}\n     * @member Ext.dom.Element\n     * @method select\n     * @static\n     */\n\n    Ext.dom.Element.select = function(selector, unique, root) {\n        var elements;\n\n        if (typeof selector == \"string\") {\n            elements = Ext.dom.Element.selectorFunction(selector, root);\n        }\n        else if (selector.length !== undefined) {\n            elements = selector;\n        }\n        else {\n            throw new Error(\"[Ext.select] Invalid selector specified: \" + selector);\n        }\n        return (unique === true) ? new Ext.CompositeElement(elements) : new Ext.CompositeElementLite(elements);\n    };\n});\n\n/**\n * Shorthand of {@link Ext.Element#method-select}.\n * @member Ext\n * @method select\n * @inheritdoc Ext.Element#select\n */\nExt.select = Ext.Element.select;\n\n/**\n * An updateable progress bar component. The progress bar supports two different modes: manual and automatic.\n *\n * In manual mode, you are responsible for showing, updating (via {@link #updateProgress}) and clearing the progress bar\n * as needed from your own code. This method is most appropriate when you want to show progress throughout an operation\n * that has predictable points of interest at which you can update the control.\n *\n * In automatic mode, you simply call {@link #wait} and let the progress bar run indefinitely, only clearing it once the\n * operation is complete. You can optionally have the progress bar wait for a specific amount of time and then clear\n * itself. Automatic mode is most appropriate for timed operations or asynchronous operations in which you have no need\n * for indicating intermediate progress.\n *\n *     @example\n *     var p = Ext.create('Ext.ProgressBar', {\n *        renderTo: Ext.getBody(),\n *        width: 300\n *     });\n *\n *     // Wait for 5 seconds, then update the status el (progress bar will auto-reset)\n *     p.wait({\n *         interval: 500, //bar will move fast!\n *         duration: 50000,\n *         increment: 15,\n *         text: 'Updating...',\n *         scope: this,\n *         fn: function(){\n *             p.updateText('Done!');\n *         }\n *     });\n */\nExt.define('Ext.ProgressBar', {\n    extend: 'Ext.Component',\n    alias: 'widget.progressbar',\n\n    requires: [\n        'Ext.Template',\n        'Ext.CompositeElement',\n        'Ext.TaskManager',\n        'Ext.layout.component.ProgressBar'\n    ],\n\n    uses: ['Ext.fx.Anim'],\n\n   /**\n    * @cfg {Number} [value=0]\n    * A floating point value between 0 and 1 (e.g., .5)\n    */\n\n   /**\n    * @cfg {String/HTMLElement/Ext.Element} textEl\n    * The element to render the progress text to (defaults to the progress bar's internal text element)\n    */\n\n   /**\n    * @cfg {String} id\n    * The progress bar element's id (defaults to an auto-generated id)\n    */\n\n   /**\n    * @cfg {String} [baseCls='x-progress']\n    * The base CSS class to apply to the progress bar's wrapper element.\n    */\n    baseCls: Ext.baseCSSPrefix + 'progress',\n\n    /**\n     * @cfg {Boolean} animate\n     * True to animate the progress bar during transitions.\n     */\n    animate: false,\n\n    /**\n     * @cfg {String} text\n     * The text shown in the progress bar.\n     */\n    text: '',\n\n    // private\n    waitTimer: null,\n\n    childEls: [\n        'bar'\n    ],\n\n    renderTpl: [\n        '<tpl if=\"internalText\">',\n            '<div class=\"{baseCls}-text {baseCls}-text-back\">{text}</div>',\n        '</tpl>',\n        '<div id=\"{id}-bar\" class=\"{baseCls}-bar\" style=\"width:{percentage}%\">',\n            '<tpl if=\"internalText\">',\n                '<div class=\"{baseCls}-text\">',\n                    '<div>{text}</div>',\n                '</div>',\n            '</tpl>',\n        '</div>'\n    ],\n\n    componentLayout: 'progressbar',\n\n    // private\n    initComponent: function() {\n        this.callParent();\n\n        this.addEvents(\n            /**\n             * @event update\n             * Fires after each update interval\n             * @param {Ext.ProgressBar} this\n             * @param {Number} value The current progress value\n             * @param {String} text The current progress text\n             */\n            \"update\"\n        );\n    },\n\n    initRenderData: function() {\n        var me = this;\n        return Ext.apply(me.callParent(), {\n            internalText : !me.hasOwnProperty('textEl'),\n            text         : me.text || '&#160;',\n            percentage   : me.value ? me.value * 100 : 0\n        });\n    },\n\n    onRender : function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        // External text display\n        if (me.textEl) {\n            me.textEl = Ext.get(me.textEl);\n            me.updateText(me.text);\n        }\n        // Inline text display\n        else {\n            // This produces a composite w/2 el's (which is why we cannot use childEls or\n            // renderSelectors):\n            me.textEl = me.el.select('.' + me.baseCls + '-text');\n        }\n    },\n\n    /**\n     * Updates the progress bar value, and optionally its text. If the text argument is not specified, any existing text\n     * value will be unchanged. To blank out existing text, pass ''. Note that even if the progress bar value exceeds 1,\n     * it will never automatically reset -- you are responsible for determining when the progress is complete and\n     * calling {@link #reset} to clear and/or hide the control.\n     * @param {Number} [value=0] A floating point value between 0 and 1 (e.g., .5)\n     * @param {String} [text=''] The string to display in the progress text element\n     * @param {Boolean} [animate=false] Whether to animate the transition of the progress bar. If this value is not\n     * specified, the default for the class is used\n     * @return {Ext.ProgressBar} this\n     */\n    updateProgress: function(value, text, animate) {\n        var me = this,\n            oldValue = me.value;\n\n        me.value = value || 0;\n        if (text) {\n            me.updateText(text);\n        }\n        if (me.rendered && !me.isDestroyed) {\n            if (animate === true || (animate !== false && me.animate)) {\n                me.bar.stopAnimation();\n                me.bar.animate(Ext.apply({\n                    from: {\n                        width: (oldValue * 100) + '%'\n                    },\n                    to: {\n                        width: (me.value * 100) + '%'\n                    }\n                }, me.animate));\n            } else {\n                me.bar.setStyle('width', (me.value * 100) + '%');\n            }\n        }\n        me.fireEvent('update', me, me.value, text);\n        return me;\n    },\n\n    /**\n     * Updates the progress bar text. If specified, textEl will be updated, otherwise the progress bar itself will\n     * display the updated text.\n     * @param {String} [text=''] The string to display in the progress text element\n     * @return {Ext.ProgressBar} this\n     */\n    updateText: function(text) {\n        var me = this;\n        \n        me.text = text;\n        if (me.rendered) {\n            me.textEl.update(me.text);\n        }\n        return me;\n    },\n\n    applyText : function(text) {\n        this.updateText(text);\n    },\n    \n    getText: function(){\n        return this.text;    \n    },\n\n    /**\n     * Initiates an auto-updating progress bar. A duration can be specified, in which case the progress bar will\n     * automatically reset after a fixed amount of time and optionally call a callback function if specified. If no\n     * duration is passed in, then the progress bar will run indefinitely and must be manually cleared by calling\n     * {@link #reset}.\n     *\n     * Example usage:\n     *\n     *     var p = new Ext.ProgressBar({\n     *        renderTo: 'my-el'\n     *     });\n     *\n     *     //Wait for 5 seconds, then update the status el (progress bar will auto-reset)\n     *     var p = Ext.create('Ext.ProgressBar', {\n     *        renderTo: Ext.getBody(),\n     *        width: 300\n     *     });\n     *\n     *     //Wait for 5 seconds, then update the status el (progress bar will auto-reset)\n     *     p.wait({\n     *        interval: 500, //bar will move fast!\n     *        duration: 50000,\n     *        increment: 15,\n     *        text: 'Updating...',\n     *        scope: this,\n     *        fn: function(){\n     *           p.updateText('Done!');\n     *        }\n     *     });\n     *\n     *     //Or update indefinitely until some async action completes, then reset manually\n     *     p.wait();\n     *     myAction.on('complete', function(){\n     *         p.reset();\n     *         p.updateText('Done!');\n     *     });\n     *\n     * @param {Object} config (optional) Configuration options\n     * @param {Number} config.duration The length of time in milliseconds that the progress bar should\n     * run before resetting itself (defaults to undefined, in which case it will run indefinitely\n     * until reset is called)\n     * @param {Number} config.interval The length of time in milliseconds between each progress update\n     * (defaults to 1000 ms)\n     * @param {Boolean} config.animate Whether to animate the transition of the progress bar. If this\n     * value is not specified, the default for the class is used.\n     * @param {Number} config.increment The number of progress update segments to display within the\n     * progress bar (defaults to 10).  If the bar reaches the end and is still updating, it will\n     * automatically wrap back to the beginning.\n     * @param {String} config.text Optional text to display in the progress bar element (defaults to '').\n     * @param {Function} config.fn A callback function to execute after the progress bar finishes auto-\n     * updating.  The function will be called with no arguments.  This function will be ignored if\n     * duration is not specified since in that case the progress bar can only be stopped programmatically,\n     * so any required function should be called by the same code after it resets the progress bar.\n     * @param {Object} config.scope The scope that is passed to the callback function (only applies when\n     * duration and fn are both passed).\n     * @return {Ext.ProgressBar} this\n     */\n    wait: function(o) {\n        var me = this, scope;\n            \n        if (!me.waitTimer) {\n            scope = me;\n            o = o || {};\n            me.updateText(o.text);\n            me.waitTimer = Ext.TaskManager.start({\n                run: function(i){\n                    var inc = o.increment || 10;\n                    i -= 1;\n                    me.updateProgress(((((i+inc)%inc)+1)*(100/inc))*0.01, null, o.animate);\n                },\n                interval: o.interval || 1000,\n                duration: o.duration,\n                onStop: function(){\n                    if (o.fn) {\n                        o.fn.apply(o.scope || me);\n                    }\n                    me.reset();\n                },\n                scope: scope\n            });\n        }\n        return me;\n    },\n\n    /**\n     * Returns true if the progress bar is currently in a {@link #wait} operation\n     * @return {Boolean} True if waiting, else false\n     */\n    isWaiting: function(){\n        return this.waitTimer !== null;\n    },\n\n    /**\n     * Resets the progress bar value to 0 and text to empty string. If hide = true, the progress bar will also be hidden\n     * (using the {@link #hideMode} property internally).\n     * @param {Boolean} [hide=false] True to hide the progress bar.\n     * @return {Ext.ProgressBar} this\n     */\n    reset: function(hide){\n        var me = this;\n        \n        me.updateProgress(0);\n        me.clearTimer();\n        if (hide === true) {\n            me.hide();\n        }\n        return me;\n    },\n\n    // private\n    clearTimer: function(){\n        var me = this;\n        \n        if (me.waitTimer) {\n            me.waitTimer.onStop = null; //prevent recursion\n            Ext.TaskManager.stop(me.waitTimer);\n            me.waitTimer = null;\n        }\n    },\n\n    onDestroy: function(){\n        var me = this;\n        \n        me.clearTimer();\n        if (me.rendered) {\n            if (me.textEl.isComposite) {\n                me.textEl.clear();\n            }\n            Ext.destroyMembers(me, 'textEl', 'progressBar');\n        }\n        me.callParent();\n    }\n});\n\n/**\n * Private utility class that manages the internal Shadow cache.\n * @private\n */\nExt.define('Ext.ShadowPool', {\n    singleton: true,\n    requires: ['Ext.DomHelper'],\n\n    markup: (function() {\n        return Ext.String.format(\n            '<div class=\"{0}{1}-shadow\" role=\"presentation\"></div>',\n            Ext.baseCSSPrefix,\n            Ext.isIE && !Ext.supports.CSS3BoxShadow ? 'ie' : 'css'\n        );\n    }()),\n\n    shadows: [],\n\n    pull: function() {\n        var sh = this.shadows.shift();\n        if (!sh) {\n            sh = Ext.get(Ext.DomHelper.insertHtml(\"beforeBegin\", document.body.firstChild, this.markup));\n            sh.autoBoxAdjust = false;\n        }\n        return sh;\n    },\n\n    push: function(sh) {\n        this.shadows.push(sh);\n    },\n    \n    reset: function() {\n        var shadows = [].concat(this.shadows),\n            s,\n            sLen    = shadows.length;\n\n        for (s = 0; s < sLen; s++) {\n            shadows[s].remove();\n        }\n\n        this.shadows = [];\n    }\n});\n\n/**\n * Simple class that can provide a shadow effect for any element.  Note that the element\n * MUST be absolutely positioned, and the shadow does not provide any shimming.  This\n * should be used only in simple cases - for more advanced functionality that can also\n * provide the same shadow effect, see the {@link Ext.Layer} class.\n */\nExt.define('Ext.Shadow', {\n    requires: ['Ext.ShadowPool'],\n\n    /**\n     * Creates new Shadow.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        var me = this,\n            adjusts,\n            offset,\n            rad;\n        \n        Ext.apply(me, config);\n        if (!Ext.isString(me.mode)) {\n            me.mode = me.defaultMode;\n        }\n        offset = me.offset;\n        rad = Math.floor(offset / 2);\n        me.opacity = 50;\n        switch (me.mode.toLowerCase()) {\n            // all this hideous nonsense calculates the various offsets for shadows\n            case \"drop\":\n                if (Ext.supports.CSS3BoxShadow) {\n                    adjusts = {\n                        t: offset,\n                        l: offset,\n                        h: -offset,\n                        w: -offset\n                    };\n                }\n                else {\n                    adjusts = {\n                        t: -rad,\n                        l: -rad,\n                        h: -rad,\n                        w: -rad\n                    };\n                }\n                break;\n            case \"sides\":\n                if (Ext.supports.CSS3BoxShadow) {\n                    adjusts = {\n                        t: offset,\n                        l: 0,\n                        h: -offset,\n                        w: 0\n                    };\n                }\n                else {\n                    adjusts = {\n                        t: - (1 + rad),\n                        l: 1 + rad - 2 * offset,\n                        h: -1,\n                        w: rad - 1\n                    };\n                }\n                break;\n            case \"frame\":\n                if (Ext.supports.CSS3BoxShadow) {\n                    adjusts = {\n                        t: 0,\n                        l: 0,\n                        h: 0,\n                        w: 0\n                    };\n                }\n                else {\n                    adjusts = {\n                        t: 1 + rad - 2 * offset,\n                        l: 1 + rad - 2 * offset,\n                        h: offset - rad - 1,\n                        w: offset - rad - 1\n                    };\n                }\n                break;\n        }\n        me.adjusts = adjusts;\n    },\n\n    /**\n     * @private\n     * Returns the shadow size on each side of the element in standard CSS order: top, right, bottom, left;\n     * @return {Number[]} Top, right, bottom and left shadow size.\n     */\n    getShadowSize: function() {\n        var me = this,\n            offset = me.el ? me.offset : 0,\n            result = [offset, offset, offset, offset],\n            mode = me.mode.toLowerCase();\n\n        // There are only offsets if the shadow element is present.\n        if (me.el && mode !== 'frame') {\n            result[0] = 0;\n            if (mode == 'drop') {\n                result[3] = 0;\n            }\n        }\n        return result;\n    },\n\n    /**\n     * @cfg {String} mode\n     * The shadow display mode.  Supports the following options:\n     *\n     * - sides : Shadow displays on both sides and bottom only</li>\n     * - frame : Shadow displays equally on all four sides</li>\n     * - drop : Traditional bottom-right drop shadow</li>\n     */\n\n    /**\n     * @cfg {Number} offset\n     * The number of pixels to offset the shadow from the element\n     */\n    offset: 4,\n\n    // private\n    defaultMode: \"drop\",\n\n    // private - CSS property to use to set the box shadow\n    boxShadowProperty: (function() {\n        var property = 'boxShadow',\n            style = document.documentElement.style;\n\n        if (!('boxShadow' in style)) {\n            if ('WebkitBoxShadow' in style) {\n                // Safari prior to version 5.1 and Chrome prior to version 10\n                property = 'WebkitBoxShadow';\n            }\n            else if ('MozBoxShadow' in style) {\n                // FF 3.5 & 3.6\n                property = 'MozBoxShadow';\n            }\n        }\n\n        return property;\n    }()),\n\n    /**\n     * Displays the shadow under the target element\n     * @param {String/HTMLElement/Ext.Element} targetEl The id or element under which the shadow should display\n     */\n    show: function(target) {\n        var me = this,\n            index;\n        \n        target = Ext.get(target);\n        if (!me.el) {\n            me.el = Ext.ShadowPool.pull();\n            if (me.el.dom.nextSibling != target.dom) {\n                me.el.insertBefore(target);\n            }\n        }\n        index = (parseInt(target.getStyle(\"z-index\"), 10) - 1) || 0;\n        me.el.setStyle(\"z-index\", me.zIndex || index);\n        if (Ext.isIE && !Ext.supports.CSS3BoxShadow) {\n            me.el.dom.style.filter = \"progid:DXImageTransform.Microsoft.alpha(opacity=\" + me.opacity + \") progid:DXImageTransform.Microsoft.Blur(pixelradius=\" + (me.offset) + \")\";\n        }\n        me.realign(\n            target.getLocalX(),\n            target.getLocalY(),\n            target.dom.offsetWidth,\n            target.dom.offsetHeight\n        );\n        me.el.dom.style.display = \"block\";\n    },\n\n    /**\n     * Returns true if the shadow is visible, else false\n     */\n    isVisible: function() {\n        return this.el ? true: false;\n    },\n\n    /**\n     * Direct alignment when values are already available. Show must be called at least once before\n     * calling this method to ensure it is initialized.\n     * @param {Number} left The target element left position\n     * @param {Number} top The target element top position\n     * @param {Number} width The target element width\n     * @param {Number} height The target element height\n     */\n    realign: function(l, t, targetWidth, targetHeight) {\n        if (!this.el) {\n            return;\n        }\n        var adjusts = this.adjusts,\n            d = this.el.dom,\n            targetStyle = d.style,\n            shadowWidth,\n            shadowHeight,\n            sws,\n            shs;\n\n        targetStyle.left = (l + adjusts.l) + \"px\";\n        targetStyle.top = (t + adjusts.t) + \"px\";\n        shadowWidth = Math.max(targetWidth + adjusts.w, 0);\n        shadowHeight = Math.max(targetHeight + adjusts.h, 0);\n        sws = shadowWidth + \"px\";\n        shs = shadowHeight + \"px\";\n        if (targetStyle.width != sws || targetStyle.height != shs) {\n            targetStyle.width = sws;\n            targetStyle.height = shs;\n\n            if (Ext.supports.CSS3BoxShadow) {\n                targetStyle[this.boxShadowProperty] = '0 0 ' + this.offset + 'px #888';\n            }\n        }\n    },\n\n    /**\n     * Hides this shadow\n     */\n    hide: function() {\n        var me = this;\n        \n        if (me.el) {\n            me.el.dom.style.display = \"none\";\n            Ext.ShadowPool.push(me.el);\n            delete me.el;\n        }\n    },\n\n    /**\n     * Adjust the z-index of this shadow\n     * @param {Number} zindex The new z-index\n     */\n    setZIndex: function(z) {\n        this.zIndex = z;\n        if (this.el) {\n            this.el.setStyle(\"z-index\", z);\n        }\n    },\n    \n    /**\n     * Sets the opacity of the shadow\n     * @param {Number} opacity The opacity\n     */\n    setOpacity: function(opacity){\n        if (this.el) {\n            if (Ext.isIE && !Ext.supports.CSS3BoxShadow) {\n                opacity = Math.floor(opacity * 100 / 2) / 100;\n            }\n            this.opacity = opacity;\n            this.el.setOpacity(opacity);\n        }\n    }\n});\n\n/**\n * Controllers are the glue that binds an application together. All they really do is listen for events (usually from\n * views) and take some action. Here's how we might create a Controller to manage Users:\n *\n *     Ext.define('MyApp.controller.Users', {\n *         extend: 'Ext.app.Controller',\n *\n *         init: function() {\n *             console.log('Initialized Users! This happens before the Application launch function is called');\n *         }\n *     });\n *\n * The init function is a special method that is called when your application boots. It is called before the\n * {@link Ext.app.Application Application}'s launch function is executed so gives a hook point to run any code before\n * your Viewport is created.\n *\n * The init function is a great place to set up how your controller interacts with the view, and is usually used in\n * conjunction with another Controller function - {@link Ext.app.Controller#control control}. The control function\n * makes it easy to listen to events on your view classes and take some action with a handler function. Let's update\n * our Users controller to tell us when the panel is rendered:\n *\n *     Ext.define('MyApp.controller.Users', {\n *         extend: 'Ext.app.Controller',\n *\n *         init: function() {\n *             this.control({\n *                 'viewport > panel': {\n *                     render: this.onPanelRendered\n *                 }\n *             });\n *         },\n *\n *         onPanelRendered: function() {\n *             console.log('The panel was rendered');\n *         }\n *     });\n *\n * We've updated the init function to use this.control to set up listeners on views in our application. The control\n * function uses the new ComponentQuery engine to quickly and easily get references to components on the page. If you\n * are not familiar with ComponentQuery yet, be sure to check out the {@link Ext.ComponentQuery documentation}. In brief though,\n * it allows us to pass a CSS-like selector that will find every matching component on the page.\n *\n * In our init function above we supplied 'viewport > panel', which translates to \"find me every Panel that is a direct\n * child of a Viewport\". We then supplied an object that maps event names (just 'render' in this case) to handler\n * functions. The overall effect is that whenever any component that matches our selector fires a 'render' event, our\n * onPanelRendered function is called.\n *\n * ## Using refs\n *\n * One of the most useful parts of Controllers is the new ref system. These use the new {@link Ext.ComponentQuery} to\n * make it really easy to get references to Views on your page. Let's look at an example of this now:\n *\n *     Ext.define('MyApp.controller.Users', {\n *         extend: 'Ext.app.Controller',\n *\n *         refs: [\n *             {\n *                 ref: 'list',\n *                 selector: 'grid'\n *             }\n *         ],\n *\n *         init: function() {\n *             this.control({\n *                 'button': {\n *                     click: this.refreshGrid\n *                 }\n *             });\n *         },\n *\n *         refreshGrid: function() {\n *             this.getList().store.load();\n *         }\n *     });\n *\n * This example assumes the existence of a {@link Ext.grid.Panel Grid} on the page, which contains a single button to\n * refresh the Grid when clicked. In our refs array, we set up a reference to the grid. There are two parts to this -\n * the 'selector', which is a {@link Ext.ComponentQuery ComponentQuery} selector which finds any grid on the page and\n * assigns it to the reference 'list'.\n *\n * By giving the reference a name, we get a number of things for free. The first is the getList function that we use in\n * the refreshGrid method above. This is generated automatically by the Controller based on the name of our ref, which\n * was capitalized and prepended with get to go from 'list' to 'getList'.\n *\n * The way this works is that the first time getList is called by your code, the ComponentQuery selector is run and the\n * first component that matches the selector ('grid' in this case) will be returned. All future calls to getList will\n * use a cached reference to that grid. Usually it is advised to use a specific ComponentQuery selector that will only\n * match a single View in your application (in the case above our selector will match any grid on the page).\n *\n * Bringing it all together, our init function is called when the application boots, at which time we call this.control\n * to listen to any click on a {@link Ext.button.Button button} and call our refreshGrid function (again, this will\n * match any button on the page so we advise a more specific selector than just 'button', but have left it this way for\n * simplicity). When the button is clicked we use out getList function to refresh the grid.\n *\n * You can create any number of refs and control any number of components this way, simply adding more functions to\n * your Controller as you go. For an example of real-world usage of Controllers see the Feed Viewer example in the\n * examples/app/feed-viewer folder in the SDK download.\n *\n * ## Generated getter methods\n *\n * Refs aren't the only thing that generate convenient getter methods. Controllers often have to deal with Models and\n * Stores so the framework offers a couple of easy ways to get access to those too. Let's look at another example:\n *\n *     Ext.define('MyApp.controller.Users', {\n *         extend: 'Ext.app.Controller',\n *\n *         models: ['User'],\n *         stores: ['AllUsers', 'AdminUsers'],\n *\n *         init: function() {\n *             var User = this.getUserModel(),\n *                 allUsers = this.getAllUsersStore();\n *\n *             var ed = new User({name: 'Ed'});\n *             allUsers.add(ed);\n *         }\n *     });\n *\n * By specifying Models and Stores that the Controller cares about, it again dynamically loads them from the appropriate\n * locations (app/model/User.js, app/store/AllUsers.js and app/store/AdminUsers.js in this case) and creates getter\n * functions for them all. The example above will create a new User model instance and add it to the AllUsers Store.\n * Of course, you could do anything in this function but in this case we just did something simple to demonstrate the\n * functionality.\n *\n * ## Further Reading\n *\n * For more information about writing Ext JS 4 applications, please see the\n * [application architecture guide](#/guide/application_architecture). Also see the {@link Ext.app.Application} documentation.\n *\n * @docauthor Ed Spencer\n */\nExt.define('Ext.app.Controller', {\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @cfg {String} id The id of this controller. You can use this id when dispatching.\n     */\n    \n    /**\n     * @cfg {String[]} models\n     * Array of models to require from AppName.model namespace. For example:\n     * \n     *     Ext.define(\"MyApp.controller.Foo\", {\n     *         extend: \"Ext.app.Controller\",\n     *         models: ['User', 'Vehicle']\n     *     });\n     * \n     * This is equivalent of:\n     * \n     *     Ext.define(\"MyApp.controller.Foo\", {\n     *         extend: \"Ext.app.Controller\",\n     *         requires: ['MyApp.model.User', 'MyApp.model.Vehicle'],\n     *         getUserModel: function() {\n     *             return this.getModel(\"User\");\n     *         },\n     *         getVehicleModel: function() {\n     *             return this.getModel(\"Vehicle\");\n     *         }\n     *     });\n     * \n     */\n\n    /**\n     * @cfg {String[]} views\n     * Array of views to require from AppName.view namespace and to generate getter methods for.\n     * For example:\n     * \n     *     Ext.define(\"MyApp.controller.Foo\", {\n     *         extend: \"Ext.app.Controller\",\n     *         views: ['List', 'Detail']\n     *     });\n     * \n     * This is equivalent of:\n     * \n     *     Ext.define(\"MyApp.controller.Foo\", {\n     *         extend: \"Ext.app.Controller\",\n     *         requires: ['MyApp.view.List', 'MyApp.view.Detail'],\n     *         getListView: function() {\n     *             return this.getView(\"List\");\n     *         },\n     *         getDetailView: function() {\n     *             return this.getView(\"Detail\");\n     *         }\n     *     });\n     *\n     */\n\n    /**\n     * @cfg {String[]} stores\n     * Array of stores to require from AppName.store namespace and to generate getter methods for.\n     * For example:\n     * \n     *     Ext.define(\"MyApp.controller.Foo\", {\n     *         extend: \"Ext.app.Controller\",\n     *         stores: ['Users', 'Vehicles']\n     *     });\n     * \n     * This is equivalent of:\n     * \n     *     Ext.define(\"MyApp.controller.Foo\", {\n     *         extend: \"Ext.app.Controller\",\n     *         requires: ['MyApp.store.Users', 'MyApp.store.Vehicles']\n     *         getUsersStore: function() {\n     *             return this.getView(\"Users\");\n     *         },\n     *         getVehiclesStore: function() {\n     *             return this.getView(\"Vehicles\");\n     *         }\n     *     });\n     *\n     */\n\n    /**\n     * @cfg {Object[]} refs\n     * Array of configs to build up references to views on page. For example:\n     * \n     *     Ext.define(\"MyApp.controller.Foo\", {\n     *         extend: \"Ext.app.Controller\",\n     *         refs: [\n     *             {\n     *                 ref: 'list',\n     *                 selector: 'grid'\n     *             }\n     *         ],\n     *     });\n     * \n     * This will add method `getList` to the controller which will internally use\n     * Ext.ComponentQuery to reference the grid component on page.\n     *\n     * The following fields can be used in ref definition:\n     *\n     * - `ref` - name of the reference.\n     * - `selector` - Ext.ComponentQuery selector to access the component.\n     * - `autoCreate` - True to create the component automatically if not found on page.\n     * - `forceCreate` - Forces the creation of the component every time reference is accessed\n     *   (when `get<REFNAME>` is called).\n     */\n\n    onClassExtended: function(cls, data, hooks) {\n        var className = Ext.getClassName(cls),\n            match = className.match(/^(.*)\\.controller\\./),\n            namespace,\n            onBeforeClassCreated,\n            requires,\n            modules,\n            namespaceAndModule;\n        \n        if (match !== null) {\n            namespace = Ext.Loader.getPrefix(className) || match[1];\n            onBeforeClassCreated = hooks.onBeforeCreated;\n            requires = [];\n            modules = ['model', 'view', 'store'];\n\n            hooks.onBeforeCreated = function(cls, data) {\n                var i, ln, module,\n                    items, j, subLn, item;\n\n                for (i = 0,ln = modules.length; i < ln; i++) {\n                    module = modules[i];\n                    namespaceAndModule = namespace + '.' + module + '.';\n\n                    items = Ext.Array.from(data[module + 's']);\n\n                    for (j = 0,subLn = items.length; j < subLn; j++) {\n                        item = items[j];\n                        // Deciding if a class name must be qualified:\n                        // 1 - if the name doesn't contains at least one dot, we must definitely qualify it\n                        // 2 - the name may be a qualified name of a known class, but:\n                        // 2.1 - in runtime, the loader may not know the class - specially in production - so we must check the class manager\n                        // 2.2 - in build time, the class manager may not know the class, but the loader does, so we check the second one\n                        //       (the loader check assures it's really a class, and not a namespace, so we can have 'Books.controller.Books',\n                        //       and requesting a controller called Books will not be underqualified)\n                        if (item.indexOf('.') !== -1 && (Ext.ClassManager.isCreated(item) || Ext.Loader.isAClassNameWithAKnownPrefix(item))) {\n                            requires.push(item);\n                        } else {\n                            requires.push(namespaceAndModule + item);\n                        }\n                    }\n                }\n\n                Ext.require(requires, Ext.Function.pass(onBeforeClassCreated, arguments, this));\n            };\n        }\n    },\n\n    /**\n     * Creates new Controller.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        this.mixins.observable.constructor.call(this, config);\n\n        Ext.apply(this, config || {});\n        this.createGetters('model', this.models);\n        this.createGetters('store', this.stores);\n        this.createGetters('view', this.views);\n\n        if (this.refs) {\n            this.ref(this.refs);\n        }\n    },\n\n    /**\n     * A template method that is called when your application boots. It is called before the\n     * {@link Ext.app.Application Application}'s launch function is executed so gives a hook point to run any code before\n     * your Viewport is created.\n     *\n     * @param {Ext.app.Application} application\n     * @template\n     */\n    init: Ext.emptyFn,\n\n    /**\n     * A template method like {@link #init}, but called after the viewport is created.\n     * This is called after the {@link Ext.app.Application#launch launch} method of Application is executed.\n     *\n     * @param {Ext.app.Application} application\n     * @template\n     */\n    onLaunch: Ext.emptyFn,\n\n    createGetters: function(type, refs) {\n        type = Ext.String.capitalize(type);\n\n        var i      = 0,\n            length = (refs) ? refs.length : 0,\n            fn, ref, parts, x, numParts;\n\n        for (; i < length; i++) {\n            fn    = 'get';\n            ref   = refs[i];\n            parts = ref.split('.');\n            numParts = parts.length;\n\n            // Handle namespaced class names. E.g. feed.Add becomes getFeedAddView etc.\n            for (x = 0 ; x < numParts; x++) {\n                fn += Ext.String.capitalize(parts[x]);\n            }\n\n            fn += type;\n\n            if (!this[fn]) {\n                this[fn] = Ext.Function.pass(this['get' + type], [ref], this);\n            }\n            // Execute it right away\n            this[fn](ref);\n        }\n    },\n\n    ref: function(refs) {\n        refs = Ext.Array.from(refs);\n        \n        var me = this,\n            i = 0,\n            length = refs.length,\n            info, ref, fn;\n        \n        me.references = me.references || [];\n\n        for (; i < length; i++) {\n            info = refs[i];\n            ref  = info.ref;\n            fn   = 'get' + Ext.String.capitalize(ref);\n\n            if (!me[fn]) {\n                me[fn] = Ext.Function.pass(me.getRef, [ref, info], me);\n            }\n            me.references.push(ref.toLowerCase());\n        }\n    },\n\n    /**\n     * Registers a {@link #refs reference}.\n     * @param {Object} ref\n     */\n    addRef: function(ref) {\n        return this.ref([ref]);\n    },\n\n    getRef: function(ref, info, config) {\n        this.refCache = this.refCache || {};\n        info = info || {};\n        config = config || {};\n\n        Ext.apply(info, config);\n\n        if (info.forceCreate) {\n            return Ext.ComponentManager.create(info, 'component');\n        }\n\n        var me = this,\n            cached = me.refCache[ref];\n\n        if (!cached) {\n            me.refCache[ref] = cached = Ext.ComponentQuery.query(info.selector)[0];\n            if (!cached && info.autoCreate) {\n                me.refCache[ref] = cached = Ext.ComponentManager.create(info, 'component');\n            }\n            if (cached) {\n                cached.on('beforedestroy', function() {\n                    me.refCache[ref] = null;\n                });\n            }\n        }\n\n        return cached;\n    },\n\n    /**\n     * Returns true if a {@link #refs reference} is registered.\n     * @return {Boolean}\n     */\n    hasRef: function(ref) {\n        return this.references && this.references.indexOf(ref.toLowerCase()) !== -1;\n    },\n\n    /**\n     * Adds listeners to components selected via {@link Ext.ComponentQuery}. Accepts an\n     * object containing component paths mapped to a hash of listener functions.\n     *\n     * In the following example the `updateUser` function is mapped to to the `click`\n     * event on a button component, which is a child of the `useredit` component.\n     *\n     *     Ext.define('AM.controller.Users', {\n     *         init: function() {\n     *             this.control({\n     *                 'useredit button[action=save]': {\n     *                     click: this.updateUser\n     *                 }\n     *             });\n     *         },\n     *\n     *         updateUser: function(button) {\n     *             console.log('clicked the Save button');\n     *         }\n     *     });\n     *\n     * See {@link Ext.ComponentQuery} for more information on component selectors.\n     *\n     * @param {String/Object} selectors If a String, the second argument is used as the\n     * listeners, otherwise an object of selectors -> listeners is assumed\n     * @param {Object} listeners\n     */\n    control: function(selectors, listeners) {\n        this.application.control(selectors, listeners, this);\n    },\n\n    /**\n     * Returns instance of a {@link Ext.app.Controller controller} with the given name.\n     * When controller doesn't exist yet, it's created.\n     * @param {String} name\n     * @return {Ext.app.Controller} a controller instance.\n     */\n    getController: function(name) {\n        return this.application.getController(name);\n    },\n\n    /**\n     * Returns instance of a {@link Ext.data.Store Store} with the given name.\n     * When store doesn't exist yet, it's created.\n     * @param {String} name\n     * @return {Ext.data.Store} a store instance.\n     */\n    getStore: function(name) {\n        return this.application.getStore(name);\n    },\n\n    /**\n     * Returns a {@link Ext.data.Model Model} class with the given name.\n     * A shorthand for using {@link Ext.ModelManager#getModel}.\n     * @param {String} name\n     * @return {Ext.data.Model} a model class.\n     */\n    getModel: function(model) {\n        return this.application.getModel(model);\n    },\n\n    /**\n     * Returns a View class with the given name.  To create an instance of the view,\n     * you can use it like it's used by Application to create the Viewport:\n     *\n     *     this.getView('Viewport').create();\n     *\n     * @param {String} name\n     * @return {Ext.Base} a view class.\n     */\n    getView: function(view) {\n        return this.application.getView(view);\n    }\n});\n\n/**\n * @author Don Griffin\n *\n * This class is a base for all id generators. It also provides lookup of id generators by\n * their id.\n * \n * Generally, id generators are used to generate a primary key for new model instances. There\n * are different approaches to solving this problem, so this mechanism has both simple use\n * cases and is open to custom implementations. A {@link Ext.data.Model} requests id generation\n * using the {@link Ext.data.Model#idgen} property.\n *\n * # Identity, Type and Shared IdGenerators\n *\n * It is often desirable to share IdGenerators to ensure uniqueness or common configuration.\n * This is done by giving IdGenerator instances an id property by which they can be looked\n * up using the {@link #get} method. To configure two {@link Ext.data.Model Model} classes\n * to share one {@link Ext.data.SequentialIdGenerator sequential} id generator, you simply\n * assign them the same id:\n *\n *     Ext.define('MyApp.data.MyModelA', {\n *         extend: 'Ext.data.Model',\n *         idgen: {\n *             type: 'sequential',\n *             id: 'foo'\n *         }\n *     });\n *\n *     Ext.define('MyApp.data.MyModelB', {\n *         extend: 'Ext.data.Model',\n *         idgen: {\n *             type: 'sequential',\n *             id: 'foo'\n *         }\n *     });\n *\n * To make this as simple as possible for generator types that are shared by many (or all)\n * Models, the IdGenerator types (such as 'sequential' or 'uuid') are also reserved as\n * generator id's. This is used by the {@link Ext.data.UuidGenerator} which has an id equal\n * to its type ('uuid'). In other words, the following Models share the same generator:\n *\n *     Ext.define('MyApp.data.MyModelX', {\n *         extend: 'Ext.data.Model',\n *         idgen: 'uuid'\n *     });\n *\n *     Ext.define('MyApp.data.MyModelY', {\n *         extend: 'Ext.data.Model',\n *         idgen: 'uuid'\n *     });\n *\n * This can be overridden (by specifying the id explicitly), but there is no particularly\n * good reason to do so for this generator type.\n *\n * # Creating Custom Generators\n * \n * An id generator should derive from this class and implement the {@link #generate} method.\n * The constructor will apply config properties on new instances, so a constructor is often\n * not necessary.\n *\n * To register an id generator type, a derived class should provide an `alias` like so:\n *\n *     Ext.define('MyApp.data.CustomIdGenerator', {\n *         extend: 'Ext.data.IdGenerator',\n *         alias: 'idgen.custom',\n *\n *         configProp: 42, // some config property w/default value\n *\n *         generate: function () {\n *             return ... // a new id\n *         }\n *     });\n *\n * Using the custom id generator is then straightforward:\n *\n *     Ext.define('MyApp.data.MyModel', {\n *         extend: 'Ext.data.Model',\n *         idgen: 'custom'\n *     });\n *     // or...\n *\n *     Ext.define('MyApp.data.MyModel', {\n *         extend: 'Ext.data.Model',\n *         idgen: {\n *             type: 'custom',\n *             configProp: value\n *         }\n *     });\n *\n * It is not recommended to mix shared generators with generator configuration. This leads\n * to unpredictable results unless all configurations match (which is also redundant). In\n * such cases, a custom generator with a default id is the best approach.\n *\n *     Ext.define('MyApp.data.CustomIdGenerator', {\n *         extend: 'Ext.data.SequentialIdGenerator',\n *         alias: 'idgen.custom',\n *\n *         id: 'custom', // shared by default\n *\n *         prefix: 'ID_',\n *         seed: 1000\n *     });\n *\n *     Ext.define('MyApp.data.MyModelX', {\n *         extend: 'Ext.data.Model',\n *         idgen: 'custom'\n *     });\n *\n *     Ext.define('MyApp.data.MyModelY', {\n *         extend: 'Ext.data.Model',\n *         idgen: 'custom'\n *     });\n *\n *     // the above models share a generator that produces ID_1000, ID_1001, etc..\n *\n */\nExt.define('Ext.data.IdGenerator', {\n\n    /**\n     * @property {Boolean} isGenerator\n     * `true` in this class to identify an object as an instantiated IdGenerator, or subclass thereof.\n     */\n    isGenerator: true,\n\n    /**\n     * Initializes a new instance.\n     * @param {Object} config (optional) Configuration object to be applied to the new instance.\n     */\n    constructor: function(config) {\n        var me = this;\n\n        Ext.apply(me, config);\n\n        if (me.id) {\n            Ext.data.IdGenerator.all[me.id] = me;\n        }\n    },\n\n    /**\n     * @cfg {String} id\n     * The id by which to register a new instance. This instance can be found using the\n     * {@link Ext.data.IdGenerator#get} static method.\n     */\n\n    getRecId: function (rec) {\n        return rec.modelName + '-' + rec.internalId;\n    },\n\n    /**\n     * Generates and returns the next id. This method must be implemented by the derived\n     * class.\n     *\n     * @return {String} The next id.\n     * @method generate\n     * @abstract\n     */\n\n    statics: {\n        /**\n         * @property {Object} all\n         * This object is keyed by id to lookup instances.\n         * @private\n         * @static\n         */\n        all: {},\n\n        /**\n         * Returns the IdGenerator given its config description.\n         * @param {String/Object} config If this parameter is an IdGenerator instance, it is\n         * simply returned. If this is a string, it is first used as an id for lookup and\n         * then, if there is no match, as a type to create a new instance. This parameter\n         * can also be a config object that contains a `type` property (among others) that\n         * are used to create and configure the instance.\n         * @static\n         */\n        get: function (config) {\n            var generator,\n                id,\n                type;\n\n            if (typeof config == 'string') {\n                id = type = config;\n                config = null;\n            } else if (config.isGenerator) {\n                return config;\n            } else {\n                id = config.id || config.type;\n                type = config.type;\n            }\n\n            generator = this.all[id];\n            if (!generator) {\n                generator = Ext.create('idgen.' + type, config);\n            }\n\n            return generator;\n        }\n    }\n});\n\n/**\n * @class Ext.data.SortTypes\n * This class defines a series of static methods that are used on a\n * {@link Ext.data.Field} for performing sorting. The methods cast the \n * underlying values into a data type that is appropriate for sorting on\n * that particular field.  If a {@link Ext.data.Field#type} is specified, \n * the sortType will be set to a sane default if the sortType is not \n * explicitly defined on the field. The sortType will make any necessary\n * modifications to the value and return it.\n * <ul>\n * <li><b>asText</b> - Removes any tags and converts the value to a string</li>\n * <li><b>asUCText</b> - Removes any tags and converts the value to an uppercase string</li>\n * <li><b>asUCText</b> - Converts the value to an uppercase string</li>\n * <li><b>asDate</b> - Converts the value into Unix epoch time</li>\n * <li><b>asFloat</b> - Converts the value to a floating point number</li>\n * <li><b>asInt</b> - Converts the value to an integer number</li>\n * </ul>\n * <p>\n * It is also possible to create a custom sortType that can be used throughout\n * an application.\n * <pre><code>\nExt.apply(Ext.data.SortTypes, {\n    asPerson: function(person){\n        // expects an object with a first and last name property\n        return person.lastName.toUpperCase() + person.firstName.toLowerCase();\n    }    \n});\n\nExt.define('Employee', {\n    extend: 'Ext.data.Model',\n    fields: [{\n        name: 'person',\n        sortType: 'asPerson'\n    }, {\n        name: 'salary',\n        type: 'float' // sortType set to asFloat\n    }]\n});\n * </code></pre>\n * </p>\n * @singleton\n * @docauthor Evan Trimboli <evan@sencha.com>\n */\nExt.define('Ext.data.SortTypes', {\n    \n    singleton: true,\n    \n    /**\n     * Default sort that does nothing\n     * @param {Object} s The value being converted\n     * @return {Object} The comparison value\n     */\n    none : function(s) {\n        return s;\n    },\n\n    /**\n     * The regular expression used to strip tags\n     * @type {RegExp}\n     * @property\n     */\n    stripTagsRE : /<\\/?[^>]+>/gi,\n\n    /**\n     * Strips all HTML tags to sort on text only\n     * @param {Object} s The value being converted\n     * @return {String} The comparison value\n     */\n    asText : function(s) {\n        return String(s).replace(this.stripTagsRE, \"\");\n    },\n\n    /**\n     * Strips all HTML tags to sort on text only - Case insensitive\n     * @param {Object} s The value being converted\n     * @return {String} The comparison value\n     */\n    asUCText : function(s) {\n        return String(s).toUpperCase().replace(this.stripTagsRE, \"\");\n    },\n\n    /**\n     * Case insensitive string\n     * @param {Object} s The value being converted\n     * @return {String} The comparison value\n     */\n    asUCString : function(s) {\n        return String(s).toUpperCase();\n    },\n\n    /**\n     * Date sorting\n     * @param {Object} s The value being converted\n     * @return {Number} The comparison value\n     */\n    asDate : function(s) {\n        if(!s){\n            return 0;\n        }\n        if(Ext.isDate(s)){\n            return s.getTime();\n        }\n        return Date.parse(String(s));\n    },\n\n    /**\n     * Float sorting\n     * @param {Object} s The value being converted\n     * @return {Number} The comparison value\n     */\n    asFloat : function(s) {\n        var val = parseFloat(String(s).replace(/,/g, \"\"));\n        return isNaN(val) ? 0 : val;\n    },\n\n    /**\n     * Integer sorting\n     * @param {Object} s The value being converted\n     * @return {Number} The comparison value\n     */\n    asInt : function(s) {\n        var val = parseInt(String(s).replace(/,/g, \"\"), 10);\n        return isNaN(val) ? 0 : val;\n    }\n});\n\n/**\n * @class Ext.data.Types\n * <p>This is a static class containing the system-supplied data types which may be given to a {@link Ext.data.Field Field}.<p/>\n * <p>The properties in this class are used as type indicators in the {@link Ext.data.Field Field} class, so to\n * test whether a Field is of a certain type, compare the {@link Ext.data.Field#type type} property against properties\n * of this class.</p>\n * <p>Developers may add their own application-specific data types to this class. Definition names must be UPPERCASE.\n * each type definition must contain three properties:</p>\n * <div class=\"mdetail-params\"><ul>\n * <li><code>convert</code> : <i>Function</i><div class=\"sub-desc\">A function to convert raw data values from a data block into the data\n * to be stored in the Field. The function is passed the collowing parameters:\n * <div class=\"mdetail-params\"><ul>\n * <li><b>v</b> : Mixed<div class=\"sub-desc\">The data value as read by the Reader, if undefined will use\n * the configured <tt>{@link Ext.data.Field#defaultValue defaultValue}</tt>.</div></li>\n * <li><b>rec</b> : Mixed<div class=\"sub-desc\">The data object containing the row as read by the Reader.\n * Depending on the Reader type, this could be an Array ({@link Ext.data.reader.Array ArrayReader}), an object\n * ({@link Ext.data.reader.Json JsonReader}), or an XML element.</div></li>\n * </ul></div></div></li>\n * <li><code>sortType</code> : <i>Function</i> <div class=\"sub-desc\">A function to convert the stored data into comparable form, as defined by {@link Ext.data.SortTypes}.</div></li>\n * <li><code>type</code> : <i>String</i> <div class=\"sub-desc\">A textual data type name.</div></li>\n * </ul></div>\n * <p>For example, to create a VELatLong field (See the Microsoft Bing Mapping API) containing the latitude/longitude value of a datapoint on a map from a JsonReader data block\n * which contained the properties <code>lat</code> and <code>long</code>, you would define a new data type like this:</p>\n *<pre><code>\n// Add a new Field data type which stores a VELatLong object in the Record.\nExt.data.Types.VELATLONG = {\n    convert: function(v, data) {\n        return new VELatLong(data.lat, data.long);\n    },\n    sortType: function(v) {\n        return v.Latitude;  // When sorting, order by latitude\n    },\n    type: 'VELatLong'\n};\n</code></pre>\n * <p>Then, when declaring a Model, use: <pre><code>\nvar types = Ext.data.Types; // allow shorthand type access\nExt.define('Unit',\n    extend: 'Ext.data.Model',\n    fields: [\n        { name: 'unitName', mapping: 'UnitName' },\n        { name: 'curSpeed', mapping: 'CurSpeed', type: types.INT },\n        { name: 'latitude', mapping: 'lat', type: types.FLOAT },\n        { name: 'longitude', mapping: 'long', type: types.FLOAT },\n        { name: 'position', type: types.VELATLONG }\n    ]\n});\n</code></pre>\n * @singleton\n */\nExt.define('Ext.data.Types', {\n    singleton: true,\n    requires: ['Ext.data.SortTypes']\n}, function() {\n    var st = Ext.data.SortTypes;\n\n    Ext.apply(Ext.data.Types, {\n        /**\n         * @property {RegExp} stripRe\n         * A regular expression for stripping non-numeric characters from a numeric value. Defaults to <tt>/[\\$,%]/g</tt>.\n         * This should be overridden for localization.\n         */\n        stripRe: /[\\$,%]/g,\n\n        /**\n         * @property {Object} AUTO\n         * This data type means that no conversion is applied to the raw data before it is placed into a Record.\n         */\n        AUTO: {\n            sortType: st.none,\n            type: 'auto'\n        },\n\n        /**\n         * @property {Object} STRING\n         * This data type means that the raw data is converted into a String before it is placed into a Record.\n         */\n        STRING: {\n            convert: function(v) {\n                var defaultValue = this.useNull ? null : '';\n                return (v === undefined || v === null) ? defaultValue : String(v);\n            },\n            sortType: st.asUCString,\n            type: 'string'\n        },\n\n        /**\n         * @property {Object} INT\n         * This data type means that the raw data is converted into an integer before it is placed into a Record.\n         * <p>The synonym <code>INTEGER</code> is equivalent.</p>\n         */\n        INT: {\n            convert: function(v) {\n                return v !== undefined && v !== null && v !== '' ?\n                    parseInt(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0);\n            },\n            sortType: st.none,\n            type: 'int'\n        },\n\n        /**\n         * @property {Object} FLOAT\n         * This data type means that the raw data is converted into a number before it is placed into a Record.\n         * <p>The synonym <code>NUMBER</code> is equivalent.</p>\n         */\n        FLOAT: {\n            convert: function(v) {\n                return v !== undefined && v !== null && v !== '' ?\n                    parseFloat(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0);\n            },\n            sortType: st.none,\n            type: 'float'\n        },\n\n        /**\n         * @property {Object} BOOL\n         * <p>This data type means that the raw data is converted into a boolean before it is placed into\n         * a Record. The string \"true\" and the number 1 are converted to boolean <code>true</code>.</p>\n         * <p>The synonym <code>BOOLEAN</code> is equivalent.</p>\n         */\n        BOOL: {\n            convert: function(v) {\n                if (this.useNull && (v === undefined || v === null || v === '')) {\n                    return null;\n                }\n                return v === true || v === 'true' || v == 1;\n            },\n            sortType: st.none,\n            type: 'bool'\n        },\n\n        /**\n         * @property {Object} DATE\n         * This data type means that the raw data is converted into a Date before it is placed into a Record.\n         * The date format is specified in the constructor of the {@link Ext.data.Field} to which this type is\n         * being applied.\n         */\n        DATE: {\n            convert: function(v) {\n                var df = this.dateFormat,\n                    parsed;\n\n                if (!v) {\n                    return null;\n                }\n                if (Ext.isDate(v)) {\n                    return v;\n                }\n                if (df) {\n                    if (df == 'timestamp') {\n                        return new Date(v*1000);\n                    }\n                    if (df == 'time') {\n                        return new Date(parseInt(v, 10));\n                    }\n                    return Ext.Date.parse(v, df);\n                }\n\n                parsed = Date.parse(v);\n                return parsed ? new Date(parsed) : null;\n            },\n            sortType: st.asDate,\n            type: 'date'\n        }\n    });\n\n    Ext.apply(Ext.data.Types, {\n        /**\n         * @property {Object} BOOLEAN\n         * <p>This data type means that the raw data is converted into a boolean before it is placed into\n         * a Record. The string \"true\" and the number 1 are converted to boolean <code>true</code>.</p>\n         * <p>The synonym <code>BOOL</code> is equivalent.</p>\n         */\n        BOOLEAN: this.BOOL,\n\n        /**\n         * @property {Object} INTEGER\n         * This data type means that the raw data is converted into an integer before it is placed into a Record.\n         * <p>The synonym <code>INT</code> is equivalent.</p>\n         */\n        INTEGER: this.INT,\n\n        /**\n         * @property {Object} NUMBER\n         * This data type means that the raw data is converted into a number before it is placed into a Record.\n         * <p>The synonym <code>FLOAT</code> is equivalent.</p>\n         */\n        NUMBER: this.FLOAT\n    });\n});\n\n/**\n * @author Ed Spencer\n *\n * Fields are used to define what a Model is. They aren't instantiated directly - instead, when we create a class that\n * extends {@link Ext.data.Model}, it will automatically create a Field instance for each field configured in a {@link\n * Ext.data.Model Model}. For example, we might set up a model like this:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             'name', 'email',\n *             {name: 'age', type: 'int'},\n *             {name: 'gender', type: 'string', defaultValue: 'Unknown'}\n *         ]\n *     });\n *\n * Four fields will have been created for the User Model - name, email, age and gender. Note that we specified a couple\n * of different formats here; if we only pass in the string name of the field (as with name and email), the field is set\n * up with the 'auto' type. It's as if we'd done this instead:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             {name: 'name', type: 'auto'},\n *             {name: 'email', type: 'auto'},\n *             {name: 'age', type: 'int'},\n *             {name: 'gender', type: 'string', defaultValue: 'Unknown'}\n *         ]\n *     });\n *\n * # Types and conversion\n *\n * The {@link #type} is important - it's used to automatically convert data passed to the field into the correct format.\n * In our example above, the name and email fields used the 'auto' type and will just accept anything that is passed\n * into them. The 'age' field had an 'int' type however, so if we passed 25.4 this would be rounded to 25.\n *\n * Sometimes a simple type isn't enough, or we want to perform some processing when we load a Field's data. We can do\n * this using a {@link #convert} function. Here, we're going to create a new field based on another:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             {\n *                 name: 'firstName',\n *                 convert: function(value, record) {\n *                     var fullName  = record.get('name'),\n *                         splits    = fullName.split(\" \"),\n *                         firstName = splits[0];\n *\n *                     return firstName;\n *                 }\n *             },\n *             'name', 'email',\n *             {name: 'age', type: 'int'},\n *             {name: 'gender', type: 'string', defaultValue: 'Unknown'}\n *         ]\n *     });\n *\n * Now when we create a new User, the firstName is populated automatically based on the name:\n *\n *     var ed = Ext.create('User', {name: 'Ed Spencer'});\n *\n *     console.log(ed.get('firstName')); //logs 'Ed', based on our convert function\n *     \n * Fields which are configured with a custom ```convert``` function are read *after* all other fields\n * when constructing and reading records, so that if convert functions rely on other, non-converted fields\n * (as in this example), they can be sure of those fields being present.\n *\n * In fact, if we log out all of the data inside ed, we'll see this:\n *\n *     console.log(ed.data);\n *\n *     //outputs this:\n *     {\n *         age: 0,\n *         email: \"\",\n *         firstName: \"Ed\",\n *         gender: \"Unknown\",\n *         name: \"Ed Spencer\"\n *     }\n *\n * The age field has been given a default of zero because we made it an int type. As an auto field, email has defaulted\n * to an empty string. When we registered the User model we set gender's {@link #defaultValue} to 'Unknown' so we see\n * that now. Let's correct that and satisfy ourselves that the types work as we expect:\n *\n *     ed.set('gender', 'Male');\n *     ed.get('gender'); //returns 'Male'\n *\n *     ed.set('age', 25.4);\n *     ed.get('age'); //returns 25 - we wanted an int, not a float, so no decimal places allowed\n */\nExt.define('Ext.data.Field', {\n    requires: ['Ext.data.Types', 'Ext.data.SortTypes'],\n    alias: 'data.field',\n\n    isField: true,\n    \n    constructor : function(config) {\n        var me = this,\n            types = Ext.data.Types,\n            st;\n        \n        if (Ext.isString(config)) {\n            config = {name: config};\n        }\n        Ext.apply(me, config);\n\n        st = me.sortType;\n\n        if (me.type) {\n            if (Ext.isString(me.type)) {\n                me.type = types[me.type.toUpperCase()] || types.AUTO;\n            }\n        } else {\n            me.type = types.AUTO;\n        }\n\n        // named sortTypes are supported, here we look them up\n        if (Ext.isString(st)) {\n            me.sortType = Ext.data.SortTypes[st];\n        } else if(Ext.isEmpty(st)) {\n            me.sortType = me.type.sortType;\n        }\n\n        // Reference this type's default converter if we did not recieve one in configuration.\n        if (!config.hasOwnProperty('convert')) {\n            me.convert = me.type.convert; // this may be undefined (e.g., AUTO)\n        } else if (!me.convert && me.type.convert && !config.hasOwnProperty('defaultValue')) {\n            // If the converter has been nulled out, and we have not been configured\n            // with a field-specific defaultValue, then coerce the inherited defaultValue into our data type.\n            me.defaultValue = me.type.convert(me.defaultValue);\n        }\n\n        if (config.convert) {\n            me.hasCustomConvert = true;\n        }\n    },\n    \n    /**\n     * @cfg {String} name\n     *\n     * The name by which the field is referenced within the Model. This is referenced by, for example, the `dataIndex`\n     * property in column definition objects passed to {@link Ext.grid.property.HeaderContainer}.\n     *\n     * Note: In the simplest case, if no properties other than `name` are required, a field definition may consist of\n     * just a String for the field name.\n     */\n    \n    /**\n     * @cfg {String/Object} type\n     *\n     * The data type for automatic conversion from received data to the *stored* value if\n     * `{@link Ext.data.Field#convert convert}` has not been specified. This may be specified as a string value.\n     * Possible values are\n     *\n     * - auto (Default, implies no conversion)\n     * - string\n     * - int\n     * - float\n     * - boolean\n     * - date\n     *\n     * This may also be specified by referencing a member of the {@link Ext.data.Types} class.\n     *\n     * Developers may create their own application-specific data types by defining new members of the {@link\n     * Ext.data.Types} class.\n     */\n\n    /**\n     * @cfg {Function} [convert]\n     *\n     * A function which converts the value provided by the Reader into an object that will be stored in the Model.\n     * \n     * If configured as `null`, then no conversion will be applied to the raw data property when this Field\n     * is read. This will increase performance. but you must ensure that the data is of the correct type and does\n     * not *need* converting.\n     * \n     * It is passed the following parameters:\n     *\n     * - **v** : Mixed\n     *\n     *   The data value as read by the Reader, if undefined will use the configured `{@link Ext.data.Field#defaultValue\n     *   defaultValue}`.\n     *\n     * - **rec** : Ext.data.Model\n     *\n     *   The data object containing the Model as read so far by the Reader. Note that the Model may not be fully populated\n     *   at this point as the fields are read in the order that they are defined in your\n     *   {@link Ext.data.Model#cfg-fields fields} array.\n     *\n     * Example of convert functions:\n     *\n     *     function fullName(v, record){\n     *         return record.data.last + ', ' + record.data.first;\n     *     }\n     *\n     *     function location(v, record){\n     *         return !record.data.city ? '' : (record.data.city + ', ' + record.data.state);\n     *     }\n     *\n     *     Ext.define('Dude', {\n     *         extend: 'Ext.data.Model',\n     *         fields: [\n     *             {name: 'fullname',  convert: fullName},\n     *             {name: 'firstname', mapping: 'name.first'},\n     *             {name: 'lastname',  mapping: 'name.last'},\n     *             {name: 'city', defaultValue: 'homeless'},\n     *             'state',\n     *             {name: 'location',  convert: location}\n     *         ]\n     *     });\n     *\n     *     // create the data store\n     *     var store = Ext.create('Ext.data.Store', {\n     *         reader: {\n     *             type: 'json',\n     *             model: 'Dude',\n     *             idProperty: 'key',\n     *             root: 'daRoot',\n     *             totalProperty: 'total'\n     *         }\n     *     });\n     *\n     *     var myData = [\n     *         { key: 1,\n     *           name: { first: 'Fat',    last:  'Albert' }\n     *           // notice no city, state provided in data object\n     *         },\n     *         { key: 2,\n     *           name: { first: 'Barney', last:  'Rubble' },\n     *           city: 'Bedrock', state: 'Stoneridge'\n     *         },\n     *         { key: 3,\n     *           name: { first: 'Cliff',  last:  'Claven' },\n     *           city: 'Boston',  state: 'MA'\n     *         }\n     *     ];\n     */\n\n    /**\n     * @cfg {Function} [serialize]\n     * A function which converts the Model's value for this Field into a form which can be used by whatever {@link Ext.data.writer.Writer Writer}\n     * is being used to sync data with the server.\n     * \n     * The function should return a string which represents the Field's value.\n     *\n     * It is passed the following parameters:\n     *\n     * - **v** : Mixed\n     *\n     *   The Field's value - the value to be serialized.\n     *\n     * - **rec** : Ext.data.Model\n     *\n     *   The record being serialized.\n     *\n     */\n\n    /**\n     * @cfg {String} dateFormat\n     *\n     * Used when converting received data into a Date when the {@link #type} is specified as `\"date\"`.\n     * \n     * The format dtring is also used when serializing Date fields for use by {@link Ext.data.writer.Writer Writers}.\n     *\n     * A format string for the {@link Ext.Date#parse Ext.Date.parse} function, or \"timestamp\" if the value provided by\n     * the Reader is a UNIX timestamp, or \"time\" if the value provided by the Reader is a javascript millisecond\n     * timestamp. See {@link Ext.Date}.\n     */\n    dateFormat: null,\n    \n    /**\n     * @cfg {Boolean} useNull\n     *\n     * Use when converting received data into a INT, FLOAT, BOOL or STRING type. If the value cannot be\n     * parsed, `null` will be used if useNull is true, otherwise a default value for that type will be used:\n     *\n     * - for INT and FLOAT - `0`.\n     * - for STRING - `\"\"`.\n     * - for BOOL - `false`.\n     *\n     * Note that when parsing of DATE type fails, the value will be `null` regardless of this setting.\n     */\n    useNull: false,\n    \n    /**\n     * @cfg {Object} [defaultValue=\"\"]\n     *\n     * The default value used when the creating an instance from a raw data object, and the property referenced by the\n     * `{@link Ext.data.Field#mapping mapping}` does not exist in that data object.\n     * \n     * May be specified as `undefined` to prevent defaulting in a value.\n     */\n    defaultValue: \"\",\n\n    /**\n     * @cfg {String/Number} mapping\n     *\n     * (Optional) A path expression for use by the {@link Ext.data.reader.Reader} implementation that is creating the\n     * {@link Ext.data.Model Model} to extract the Field value from the data object. If the path expression is the same\n     * as the field name, the mapping may be omitted.\n     *\n     * The form of the mapping expression depends on the Reader being used.\n     *\n     * - {@link Ext.data.reader.Json}\n     *\n     *   The mapping is a string containing the javascript expression to reference the data from an element of the data\n     *   item's {@link Ext.data.reader.Json#cfg-root root} Array. Defaults to the field name.\n     *\n     * - {@link Ext.data.reader.Xml}\n     *\n     *   The mapping is an {@link Ext.DomQuery} path to the data item relative to the DOM element that represents the\n     *   {@link Ext.data.reader.Xml#record record}. Defaults to the field name.\n     *\n     * - {@link Ext.data.reader.Array}\n     *\n     *   The mapping is a number indicating the Array index of the field's value. Defaults to the field specification's\n     *   Array position.\n     *\n     * If a more complex value extraction strategy is required, then configure the Field with a {@link #convert}\n     * function. This is passed the whole row object, and may interrogate it in whatever way is necessary in order to\n     * return the desired data.\n     */\n    mapping: null,\n\n    /**\n     * @cfg {Function} sortType\n     *\n     * A function which converts a Field's value to a comparable value in order to ensure correct sort ordering.\n     * Predefined functions are provided in {@link Ext.data.SortTypes}. A custom sort example:\n     *\n     *     // current sort     after sort we want\n     *     // +-+------+          +-+------+\n     *     // |1|First |          |1|First |\n     *     // |2|Last  |          |3|Second|\n     *     // |3|Second|          |2|Last  |\n     *     // +-+------+          +-+------+\n     *\n     *     sortType: function(value) {\n     *        switch (value.toLowerCase()) // native toLowerCase():\n     *        {\n     *           case 'first': return 1;\n     *           case 'second': return 2;\n     *           default: return 3;\n     *        }\n     *     }\n     */\n    sortType : null,\n\n    /**\n     * @cfg {String} sortDir\n     *\n     * Initial direction to sort (`\"ASC\"` or `\"DESC\"`). Defaults to `\"ASC\"`.\n     */\n    sortDir : \"ASC\",\n\n    /**\n     * @cfg {Boolean} allowBlank\n     * @private\n     *\n     * Used for validating a {@link Ext.data.Model model}. Defaults to true. An empty value here will cause\n     * {@link Ext.data.Model}.{@link Ext.data.Model#isValid isValid} to evaluate to false.\n     */\n    allowBlank : true,\n\n    /**\n     * @cfg {Boolean} persist\n     *\n     * False to exclude this field from the {@link Ext.data.Model#modified} fields in a model. This will also exclude\n     * the field from being written using a {@link Ext.data.writer.Writer}. This option is useful when model fields are\n     * used to keep state on the client but do not need to be persisted to the server. Defaults to true.\n     */\n    persist: true\n});\n\n/**\n * @author Ed Spencer\n * @class Ext.data.Errors\n *\n * <p>Wraps a collection of validation error responses and provides convenient functions for\n * accessing and errors for specific fields.</p>\n *\n * <p>Usually this class does not need to be instantiated directly - instances are instead created\n * automatically when {@link Ext.data.Model#validate validate} on a model instance:</p>\n *\n<pre><code>\n//validate some existing model instance - in this case it returned 2 failures messages\nvar errors = myModel.validate();\n\nerrors.isValid(); //false\n\nerrors.length; //2\nerrors.getByField('name');  // [{field: 'name',  message: 'must be present'}]\nerrors.getByField('title'); // [{field: 'title', message: 'is too short'}]\n</code></pre>\n */\nExt.define('Ext.data.Errors', {\n    extend: 'Ext.util.MixedCollection',\n\n    /**\n     * Returns true if there are no errors in the collection\n     * @return {Boolean}\n     */\n    isValid: function() {\n        return this.length === 0;\n    },\n\n    /**\n     * Returns all of the errors for the given field\n     * @param {String} fieldName The field to get errors for\n     * @return {Object[]} All errors for the given field\n     */\n    getByField: function(fieldName) {\n        var errors = [],\n            error, field, i;\n\n        for (i = 0; i < this.length; i++) {\n            error = this.items[i];\n\n            if (error.field == fieldName) {\n                errors.push(error);\n            }\n        }\n\n        return errors;\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * Represents a single read or write operation performed by a {@link Ext.data.proxy.Proxy Proxy}. Operation objects are\n * used to enable communication between Stores and Proxies. Application developers should rarely need to interact with\n * Operation objects directly.\n *\n * Several Operations can be batched together in a {@link Ext.data.Batch batch}.\n */\nExt.define('Ext.data.Operation', {\n    /**\n     * @cfg {Boolean} synchronous\n     * True if this Operation is to be executed synchronously. This property is inspected by a\n     * {@link Ext.data.Batch Batch} to see if a series of Operations can be executed in parallel or not.\n     */\n    synchronous: true,\n\n    /**\n     * @cfg {String} action\n     * The action being performed by this Operation. Should be one of 'create', 'read', 'update' or 'destroy'.\n     */\n    action: undefined,\n\n    /**\n     * @cfg {Ext.util.Filter[]} filters\n     * Optional array of filter objects. Only applies to 'read' actions.\n     */\n    filters: undefined,\n\n    /**\n     * @cfg {Ext.util.Sorter[]} sorters\n     * Optional array of sorter objects. Only applies to 'read' actions.\n     */\n    sorters: undefined,\n\n    /**\n     * @cfg {Ext.util.Grouper[]} groupers\n     * Optional grouping configuration. Only applies to 'read' actions where grouping is desired.\n     */\n    groupers: undefined,\n\n    /**\n     * @cfg {Number} start\n     * The start index (offset), used in paging when running a 'read' action.\n     */\n    start: undefined,\n\n    /**\n     * @cfg {Number} limit\n     * The number of records to load. Used on 'read' actions when paging is being used.\n     */\n    limit: undefined,\n\n    /**\n     * @cfg {Ext.data.Batch} batch\n     * The batch that this Operation is a part of.\n     */\n    batch: undefined,\n    \n    /**\n     * @cfg {Object} params\n     * Parameters to pass along with the request when performing the operation.\n     */\n\n    /**\n     * @cfg {Function} callback\n     * Function to execute when operation completed.\n     * @cfg {Ext.data.Model[]} callback.records Array of records.\n     * @cfg {Ext.data.Operation} callback.operation The Operation itself.\n     * @cfg {Boolean} callback.success True when operation completed successfully.\n     */\n    callback: undefined,\n\n    /**\n     * @cfg {Object} scope\n     * Scope for the {@link #callback} function.\n     */\n    scope: undefined,\n\n    /**\n     * @property {Boolean} started\n     * The start status of this Operation. Use {@link #isStarted}.\n     * @readonly\n     * @private\n     */\n    started: false,\n\n    /**\n     * @property {Boolean} running\n     * The run status of this Operation. Use {@link #isRunning}.\n     * @readonly\n     * @private\n     */\n    running: false,\n\n    /**\n     * @property {Boolean} complete\n     * The completion status of this Operation. Use {@link #isComplete}.\n     * @readonly\n     * @private\n     */\n    complete: false,\n\n    /**\n     * @property {Boolean} success\n     * Whether the Operation was successful or not. This starts as undefined and is set to true\n     * or false by the Proxy that is executing the Operation. It is also set to false by {@link #setException}. Use\n     * {@link #wasSuccessful} to query success status.\n     * @readonly\n     * @private\n     */\n    success: undefined,\n\n    /**\n     * @property {Boolean} exception\n     * The exception status of this Operation. Use {@link #hasException} and see {@link #getError}.\n     * @readonly\n     * @private\n     */\n    exception: false,\n\n    /**\n     * @property {String/Object} error\n     * The error object passed when {@link #setException} was called. This could be any object or primitive.\n     * @private\n     */\n    error: undefined,\n\n    /**\n     * @property {RegExp} actionCommitRecordsRe\n     * The RegExp used to categorize actions that require record commits.\n     */\n    actionCommitRecordsRe: /^(?:create|update)$/i,\n\n    /**\n     * @property {RegExp} actionSkipSyncRe\n     * The RegExp used to categorize actions that skip local record synchronization. This defaults\n     * to match 'destroy'.\n     */\n    actionSkipSyncRe: /^destroy$/i,\n\n    /**\n     * Creates new Operation object.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        Ext.apply(this, config || {});\n    },\n\n    /**\n     * This method is called to commit data to this instance's records given the records in\n     * the server response. This is followed by calling {@link Ext.data.Model#commit} on all\n     * those records (for 'create' and 'update' actions).\n     *\n     * If this {@link #action} is 'destroy', any server records are ignored and the\n     * {@link Ext.data.Model#commit} method is not called.\n     *\n     * @param {Ext.data.Model[]} serverRecords An array of {@link Ext.data.Model} objects returned by\n     * the server.\n     * @markdown\n     */\n    commitRecords: function (serverRecords) {\n        var me = this,\n            mc, index, clientRecords, serverRec, clientRec, i, len;\n\n        if (!me.actionSkipSyncRe.test(me.action)) {\n            clientRecords = me.records;\n\n            if (clientRecords && clientRecords.length) {\n                if (clientRecords.length > 1) {\n                    // If this operation has multiple records, client records need to be matched up with server records\n                    // so that any data returned from the server can be updated in the client records. If we don't have\n                    // a clientIdProperty specified on the model and we've done a create, just assume the data is returned in order.\n                    // If it's an update, the records should already have an id which should match what the server returns.\n                    if (me.action == 'update' || clientRecords[0].clientIdProperty) {\n                        mc = new Ext.util.MixedCollection();\n                        mc.addAll(serverRecords);\n\n                        for (index = clientRecords.length; index--; ) {\n                            clientRec = clientRecords[index];\n                            serverRec = mc.findBy(me.matchClientRec, clientRec);\n\n                            // Replace client record data with server record data\n                            clientRec.copyFrom(serverRec);\n                        }\n                    } else {\n                        for (i = 0, len = clientRecords.length; i < len; ++i) {\n                            clientRec = clientRecords[i];\n                            serverRec = serverRecords[i];\n                            if (clientRec && serverRec) {\n                                me.updateRecord(clientRec, serverRec);\n                            }\n                        }\n                    }\n                } else {\n                    // operation only has one record, so just match the first client record up with the first server record\n                    this.updateRecord(clientRecords[0], serverRecords[0]);   \n                }\n\n                if (me.actionCommitRecordsRe.test(me.action)) {\n                    for (index = clientRecords.length; index--; ) {\n                        clientRecords[index].commit();\n                    }\n                }\n            }\n        }\n    },\n    \n    updateRecord: function(clientRec, serverRec) {\n        // if the client record is not a phantom, make sure the ids match before replacing the client data with server data.\n        if(serverRec && (clientRec.phantom || clientRec.getId() === serverRec.getId())) {\n            clientRec.copyFrom(serverRec);\n        }\n    },\n\n    // Private.\n    // Record matching function used by commitRecords\n    // IMPORTANT: This is called in the scope of the clientRec being matched\n    matchClientRec: function(record) {\n        var clientRec = this,\n            clientRecordId = clientRec.getId();\n\n        if(clientRecordId && record.getId() === clientRecordId) {\n            return true;\n        }\n        // if the server record cannot be found by id, find by internalId.\n        // this allows client records that did not previously exist on the server\n        // to be updated with the correct server id and data.\n        return record.internalId === clientRec.internalId;\n    },\n\n    /**\n     * Marks the Operation as started.\n     */\n    setStarted: function() {\n        this.started = true;\n        this.running = true;\n    },\n\n    /**\n     * Marks the Operation as completed.\n     */\n    setCompleted: function() {\n        this.complete = true;\n        this.running  = false;\n    },\n\n    /**\n     * Marks the Operation as successful.\n     */\n    setSuccessful: function() {\n        this.success = true;\n    },\n\n    /**\n     * Marks the Operation as having experienced an exception. Can be supplied with an option error message/object.\n     * @param {String/Object} error (optional) error string/object\n     */\n    setException: function(error) {\n        this.exception = true;\n        this.success = false;\n        this.running = false;\n        this.error = error;\n    },\n\n    /**\n     * Returns true if this Operation encountered an exception (see also {@link #getError})\n     * @return {Boolean} True if there was an exception\n     */\n    hasException: function() {\n        return this.exception === true;\n    },\n\n    /**\n     * Returns the error string or object that was set using {@link #setException}\n     * @return {String/Object} The error object\n     */\n    getError: function() {\n        return this.error;\n    },\n\n    /**\n     * Returns the {@link Ext.data.Model record}s associated with this operation.  For read operations the records as set by the {@link Ext.data.proxy.Proxy Proxy} will be returned (returns `null` if the proxy has not yet set the records).\n     * For create, update, and destroy operations the operation's initially configured records will be returned, although the proxy may modify these records' data at some point after the operation is initialized.\n     * @return {Ext.data.Model[]}\n     */\n    getRecords: function() {\n        var resultSet = this.getResultSet();\n        return this.records || (resultSet ? resultSet.records : null);\n    },\n\n    /**\n     * Returns the ResultSet object (if set by the Proxy). This object will contain the {@link Ext.data.Model model}\n     * instances as well as meta data such as number of instances fetched, number available etc\n     * @return {Ext.data.ResultSet} The ResultSet object\n     */\n    getResultSet: function() {\n        return this.resultSet;\n    },\n\n    /**\n     * Returns true if the Operation has been started. Note that the Operation may have started AND completed, see\n     * {@link #isRunning} to test if the Operation is currently running.\n     * @return {Boolean} True if the Operation has started\n     */\n    isStarted: function() {\n        return this.started === true;\n    },\n\n    /**\n     * Returns true if the Operation has been started but has not yet completed.\n     * @return {Boolean} True if the Operation is currently running\n     */\n    isRunning: function() {\n        return this.running === true;\n    },\n\n    /**\n     * Returns true if the Operation has been completed\n     * @return {Boolean} True if the Operation is complete\n     */\n    isComplete: function() {\n        return this.complete === true;\n    },\n\n    /**\n     * Returns true if the Operation has completed and was successful\n     * @return {Boolean} True if successful\n     */\n    wasSuccessful: function() {\n        return this.isComplete() && this.success === true;\n    },\n\n    /**\n     * @private\n     * Associates this Operation with a Batch\n     * @param {Ext.data.Batch} batch The batch\n     */\n    setBatch: function(batch) {\n        this.batch = batch;\n    },\n\n    /**\n     * Checks whether this operation should cause writing to occur.\n     * @return {Boolean} Whether the operation should cause a write to occur.\n     */\n    allowWrite: function() {\n        return this.action != 'read';\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * This singleton contains a set of validation functions that can be used to validate any type of data. They are most\n * often used in {@link Ext.data.Model Models}, where they are automatically set up and executed.\n */\nExt.define('Ext.data.validations', {\n    singleton: true,\n    \n    /**\n     * @property {String} presenceMessage\n     * The default error message used when a presence validation fails.\n     */\n    presenceMessage: 'must be present',\n    \n    /**\n     * @property {String} lengthMessage\n     * The default error message used when a length validation fails.\n     */\n    lengthMessage: 'is the wrong length',\n    \n    /**\n     * @property {String} formatMessage\n     * The default error message used when a format validation fails.\n     */\n    formatMessage: 'is the wrong format',\n    \n    /**\n     * @property {String} inclusionMessage\n     * The default error message used when an inclusion validation fails.\n     */\n    inclusionMessage: 'is not included in the list of acceptable values',\n    \n    /**\n     * @property {String} exclusionMessage\n     * The default error message used when an exclusion validation fails.\n     */\n    exclusionMessage: 'is not an acceptable value',\n    \n    /**\n     * @property {String} emailMessage\n     * The default error message used when an email validation fails\n     */\n    emailMessage: 'is not a valid email address',\n    \n    /**\n     * @property {RegExp} emailRe\n     * The regular expression used to validate email addresses\n     */\n    emailRe: /^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$/,\n    \n    /**\n     * Validates that the given value is present.\n     * For example:\n     *\n     *     validations: [{type: 'presence', field: 'age'}]\n     *\n     * @param {Object} config Config object\n     * @param {Object} value The value to validate\n     * @return {Boolean} True if validation passed\n     */\n    presence: function(config, value) {\n        // No configs read, so allow just value to be passed\n        if (arguments.length === 1) {\n            value = config;\n        }\n        \n        //we need an additional check for zero here because zero is an acceptable form of present data\n        return !!value || value === 0;\n    },\n    \n    /**\n     * Returns true if the given value is between the configured min and max values.\n     * For example:\n     *\n     *     validations: [{type: 'length', field: 'name', min: 2}]\n     *\n     * @param {Object} config Config object\n     * @param {String} value The value to validate\n     * @return {Boolean} True if the value passes validation\n     */\n    length: function(config, value) {\n        if (value === undefined || value === null) {\n            return false;\n        }\n        \n        var length = value.length,\n            min    = config.min,\n            max    = config.max;\n        \n        if ((min && length < min) || (max && length > max)) {\n            return false;\n        } else {\n            return true;\n        }\n    },\n    \n    /**\n     * Validates that an email string is in the correct format\n     * @param {Object} config Config object\n     * @param {String} email The email address\n     * @return {Boolean} True if the value passes validation\n     */\n    email: function(config, email) {\n        return Ext.data.validations.emailRe.test(email);\n    },\n    \n    /**\n     * Returns true if the given value passes validation against the configured `matcher` regex.\n     * For example:\n     *\n     *     validations: [{type: 'format', field: 'username', matcher: /([a-z]+)[0-9]{2,3}/}]\n     *\n     * @param {Object} config Config object\n     * @param {String} value The value to validate\n     * @return {Boolean} True if the value passes the format validation\n     */\n    format: function(config, value) {\n        return !!(config.matcher && config.matcher.test(value));\n    },\n    \n    /**\n     * Validates that the given value is present in the configured `list`.\n     * For example:\n     *\n     *     validations: [{type: 'inclusion', field: 'gender', list: ['Male', 'Female']}]\n     *\n     * @param {Object} config Config object\n     * @param {String} value The value to validate\n     * @return {Boolean} True if the value is present in the list\n     */\n    inclusion: function(config, value) {\n        return config.list && Ext.Array.indexOf(config.list,value) != -1;\n    },\n    \n    /**\n     * Validates that the given value is not present in the configured `list`.\n     * For example:\n     *\n     *     validations: [{type: 'exclusion', field: 'username', list: ['Admin', 'Operator']}]\n     *\n     * @param {Object} config Config object\n     * @param {String} value The value to validate\n     * @return {Boolean} True if the value is not present in the list\n     */\n    exclusion: function(config, value) {\n        return config.list && Ext.Array.indexOf(config.list,value) == -1;\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * A Model represents some object that your application manages. For example, one might define a Model for Users,\n * Products, Cars, or any other real-world object that we want to model in the system. Models are registered via the\n * {@link Ext.ModelManager model manager}, and are used by {@link Ext.data.Store stores}, which are in turn used by many\n * of the data-bound components in Ext.\n *\n * Models are defined as a set of fields and any arbitrary methods and properties relevant to the model. For example:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             {name: 'name',  type: 'string'},\n *             {name: 'age',   type: 'int', convert: null},\n *             {name: 'phone', type: 'string'},\n *             {name: 'alive', type: 'boolean', defaultValue: true, convert: null}\n *         ],\n *\n *         changeName: function() {\n *             var oldName = this.get('name'),\n *                 newName = oldName + \" The Barbarian\";\n *\n *             this.set('name', newName);\n *         }\n *     });\n *\n * The fields array is turned into a {@link Ext.util.MixedCollection MixedCollection} automatically by the {@link\n * Ext.ModelManager ModelManager}, and all other functions and properties are copied to the new Model's prototype.\n * \n * By default, the built in numeric and boolean field types have a (@link Ext.data.Field#convert} function which coerces string\n * values in raw data into the field's type. For better performance with {@link Ext.data.reader.Json Json} or {@link Ext.data.reader.Array Array}\n * readers *if you are in control of the data fed into this Model*, you can null out the default convert function which will cause\n * the raw property to be copied directly into the Field's value.\n *\n * Now we can create instances of our User model and call any model logic we defined:\n *\n *     var user = Ext.create('User', {\n *         name : 'Conan',\n *         age  : 24,\n *         phone: '555-555-5555'\n *     });\n *\n *     user.changeName();\n *     user.get('name'); //returns \"Conan The Barbarian\"\n *\n * # Validations\n *\n * Models have built-in support for validations, which are executed against the validator functions in {@link\n * Ext.data.validations} ({@link Ext.data.validations see all validation functions}). Validations are easy to add to\n * models:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             {name: 'name',     type: 'string'},\n *             {name: 'age',      type: 'int'},\n *             {name: 'phone',    type: 'string'},\n *             {name: 'gender',   type: 'string'},\n *             {name: 'username', type: 'string'},\n *             {name: 'alive',    type: 'boolean', defaultValue: true}\n *         ],\n *\n *         validations: [\n *             {type: 'presence',  field: 'age'},\n *             {type: 'length',    field: 'name',     min: 2},\n *             {type: 'inclusion', field: 'gender',   list: ['Male', 'Female']},\n *             {type: 'exclusion', field: 'username', list: ['Admin', 'Operator']},\n *             {type: 'format',    field: 'username', matcher: /([a-z]+)[0-9]{2,3}/}\n *         ]\n *     });\n *\n * The validations can be run by simply calling the {@link #validate} function, which returns a {@link Ext.data.Errors}\n * object:\n *\n *     var instance = Ext.create('User', {\n *         name: 'Ed',\n *         gender: 'Male',\n *         username: 'edspencer'\n *     });\n *\n *     var errors = instance.validate();\n *\n * # Associations\n *\n * Models can have associations with other Models via {@link Ext.data.association.HasOne},\n * {@link Ext.data.association.BelongsTo belongsTo} and {@link Ext.data.association.HasMany hasMany} associations.\n * For example, let's say we're writing a blog administration application which deals with Users, Posts and Comments.\n * We can express the relationships between these models like this:\n *\n *     Ext.define('Post', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'user_id'],\n *\n *         belongsTo: 'User',\n *         hasMany  : {model: 'Comment', name: 'comments'}\n *     });\n *\n *     Ext.define('Comment', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'user_id', 'post_id'],\n *\n *         belongsTo: 'Post'\n *     });\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id'],\n *\n *         hasMany: [\n *             'Post',\n *             {model: 'Comment', name: 'comments'}\n *         ]\n *     });\n *\n * See the docs for {@link Ext.data.association.HasOne}, {@link Ext.data.association.BelongsTo} and\n * {@link Ext.data.association.HasMany} for details on the usage and configuration of associations.\n * Note that associations can also be specified like this:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id'],\n *\n *         associations: [\n *             {type: 'hasMany', model: 'Post',    name: 'posts'},\n *             {type: 'hasMany', model: 'Comment', name: 'comments'}\n *         ]\n *     });\n *\n * # Using a Proxy\n *\n * Models are great for representing types of data and relationships, but sooner or later we're going to want to load or\n * save that data somewhere. All loading and saving of data is handled via a {@link Ext.data.proxy.Proxy Proxy}, which\n * can be set directly on the Model:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'name', 'email'],\n *\n *         proxy: {\n *             type: 'rest',\n *             url : '/users'\n *         }\n *     });\n *\n * Here we've set up a {@link Ext.data.proxy.Rest Rest Proxy}, which knows how to load and save data to and from a\n * RESTful backend. Let's see how this works:\n *\n *     var user = Ext.create('User', {name: 'Ed Spencer', email: 'ed@sencha.com'});\n *\n *     user.save(); //POST /users\n *\n * Calling {@link #save} on the new Model instance tells the configured RestProxy that we wish to persist this Model's\n * data onto our server. RestProxy figures out that this Model hasn't been saved before because it doesn't have an id,\n * and performs the appropriate action - in this case issuing a POST request to the url we configured (/users). We\n * configure any Proxy on any Model and always follow this API - see {@link Ext.data.proxy.Proxy} for a full list.\n *\n * Loading data via the Proxy is equally easy:\n *\n *     //get a reference to the User model class\n *     var User = Ext.ModelManager.getModel('User');\n *\n *     //Uses the configured RestProxy to make a GET request to /users/123\n *     User.load(123, {\n *         success: function(user) {\n *             console.log(user.getId()); //logs 123\n *         }\n *     });\n *\n * Models can also be updated and destroyed easily:\n *\n *     //the user Model we loaded in the last snippet:\n *     user.set('name', 'Edward Spencer');\n *\n *     //tells the Proxy to save the Model. In this case it will perform a PUT request to /users/123 as this Model already has an id\n *     user.save({\n *         success: function() {\n *             console.log('The User was updated');\n *         }\n *     });\n *\n *     //tells the Proxy to destroy the Model. Performs a DELETE request to /users/123\n *     user.destroy({\n *         success: function() {\n *             console.log('The User was destroyed!');\n *         }\n *     });\n *\n * # Usage in Stores\n *\n * It is very common to want to load a set of Model instances to be displayed and manipulated in the UI. We do this by\n * creating a {@link Ext.data.Store Store}:\n *\n *     var store = Ext.create('Ext.data.Store', {\n *         model: 'User'\n *     });\n *\n *     //uses the Proxy we set up on Model to load the Store data\n *     store.load();\n *\n * A Store is just a collection of Model instances - usually loaded from a server somewhere. Store can also maintain a\n * set of added, updated and removed Model instances to be synchronized with the server via the Proxy. See the {@link\n * Ext.data.Store Store docs} for more information on Stores.\n */\nExt.define('Ext.data.Model', {\n    alternateClassName: 'Ext.data.Record',\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n    \n    requires: [\n        'Ext.ModelManager',\n        'Ext.data.IdGenerator',\n        'Ext.data.Field',\n        'Ext.data.Errors',\n        'Ext.data.Operation',\n        'Ext.data.validations',\n        'Ext.util.MixedCollection'\n    ],\n\n    compareConvertFields: function(f1, f2) {\n        var f1SpecialConvert = f1.convert && f1.type && f1.convert !== f1.type.convert,\n            f2SpecialConvert = f2.convert && f2.type && f2.convert !== f2.type.convert;\n\n        if (f1SpecialConvert && !f2SpecialConvert) {\n            return 1;\n        }\n\n        if (!f1SpecialConvert && f2SpecialConvert) {\n            return -1;\n        }\n        return 0;\n    },\n\n    itemNameFn: function(item) {\n        return item.name;\n    },\n\n    onClassExtended: function(cls, data, hooks) {\n        var onBeforeClassCreated = hooks.onBeforeCreated;\n\n        hooks.onBeforeCreated = function(cls, data) {\n            var me = this,\n                name = Ext.getClassName(cls),\n                prototype = cls.prototype,\n                superCls = cls.prototype.superclass,\n\n                validations = data.validations || [],\n                fields = data.fields || [],\n                field,\n                associationsConfigs = data.associations || [],\n                addAssociations = function(items, type) {\n                    var i = 0,\n                        len,\n                        item;\n\n                    if (items) {\n                        items = Ext.Array.from(items);\n\n                        for (len = items.length; i < len; ++i) {\n                            item = items[i];\n\n                            if (!Ext.isObject(item)) {\n                                item = {model: item};\n                            }\n\n                            item.type = type;\n                            associationsConfigs.push(item);\n                        }\n                    }\n                },\n                idgen = data.idgen,\n\n                fieldsMixedCollection = new Ext.util.MixedCollection(false, prototype.itemNameFn),\n\n                associationsMixedCollection = new Ext.util.MixedCollection(false, prototype.itemNameFn),\n\n                superValidations = superCls.validations,\n                superFields = superCls.fields,\n                superAssociations = superCls.associations,\n\n                associationConfig, i, ln,\n                dependencies = [],\n                idProperty = data.idProperty || cls.prototype.idProperty,\n\n                // Process each Field upon add into the collection\n                onFieldAddReplace = function(arg0, arg1, arg2) {\n                    var newField,\n                        pos;\n\n                    if (fieldsMixedCollection.events.add.firing) {\n                        // Add event signature is (position, value, key);\n                        pos = arg0;\n                        newField  = arg1;\n                    } else {\n                        // Replace event signature is (key, oldValue, newValue);\n                        newField = arg2;\n                        pos = arg1.originalIndex;\n                    }\n\n                    // Set the originalIndex for ArrayReader to get the default mapping from in case\n                    // compareConvertFields changes the order due to some fields having custom convert functions.\n                    newField.originalIndex = pos;\n\n                    // The field(s) which encapsulates the idProperty must never have a default value set\n                    // if no value arrives from the server side. So override any possible prototype-provided\n                    // defaultValue with undefined which will inhibit generation of defaulting code in Reader.buildRecordDataExtractor\n                    if (newField.mapping === idProperty || (newField.mapping == null && newField.name === idProperty)) {\n                        newField.defaultValue = undefined;\n                    }\n                },\n\n                // Use the proxy from the class definition object if present, otherwise fall back to the inherited one, or the default    \n                clsProxy = data.proxy || cls.prototype.proxy || cls.prototype.defaultProxyType,\n\n                // Sort upon add function to be used in case of dynamically added Fields\n                fieldConvertSortFn = function() {\n                    fieldsMixedCollection.sortBy(prototype.compareConvertFields);\n                };\n\n            // Save modelName on class and its prototype\n            cls.modelName = name;\n            prototype.modelName = name;\n\n            // Merge the validations of the superclass and the new subclass\n            if (superValidations) {\n                validations = superValidations.concat(validations);\n            }\n\n            data.validations = validations;\n\n            // Merge the fields of the superclass and the new subclass\n            if (superFields) {\n                fields = superFields.items.concat(fields);\n            }\n\n            fieldsMixedCollection.on({\n                add:     onFieldAddReplace,\n                replace: onFieldAddReplace\n            });  \n\n            for (i = 0, ln = fields.length; i < ln; ++i) {\n                field = fields[i];\n                fieldsMixedCollection.add(field.isField ? field : new Ext.data.Field(field));\n            }\n            if (!fieldsMixedCollection.get(idProperty)) {\n                fieldsMixedCollection.add(new Ext.data.Field(idProperty));\n            }\n\n            // Ensure the Fields are on correct order: Fields with custom convert function last\n            fieldConvertSortFn();\n            fieldsMixedCollection.on({\n                add:     fieldConvertSortFn,\n                replace: fieldConvertSortFn\n            });\n\n            data.fields = fieldsMixedCollection;\n\n            if (idgen) {\n                data.idgen = Ext.data.IdGenerator.get(idgen);\n            }\n\n            //associations can be specified in the more convenient format (e.g. not inside an 'associations' array).\n            //we support that here\n            addAssociations(data.belongsTo, 'belongsTo');\n            delete data.belongsTo;\n            addAssociations(data.hasMany, 'hasMany');\n            delete data.hasMany;\n            addAssociations(data.hasOne, 'hasOne');\n            delete data.hasOne;\n\n            if (superAssociations) {\n                associationsConfigs = superAssociations.items.concat(associationsConfigs);\n            }\n\n            for (i = 0, ln = associationsConfigs.length; i < ln; ++i) {\n                dependencies.push('association.' + associationsConfigs[i].type.toLowerCase());\n            }\n\n            // If we have not been supplied with a Proxy *instance*, then add the proxy type to our dependency list\n            if (clsProxy && !clsProxy.isProxy) {\n                if (typeof clsProxy !== 'string' && !clsProxy.type) {\n                    Ext.log.warn(name + ': proxy type is ' + clsProxy.type);\n                }\n\n                dependencies.push('proxy.' + (typeof clsProxy === 'string' ? clsProxy : clsProxy.type));\n            }\n\n            Ext.require(dependencies, function() {\n                Ext.ModelManager.registerType(name, cls);\n\n                for (i = 0, ln = associationsConfigs.length; i < ln; ++i) {\n                    associationConfig = associationsConfigs[i];\n                    if (associationConfig.isAssociation) {\n                        associationConfig = Ext.applyIf({\n                            ownerModel: name,\n                            associatedModel: associationConfig.model\n                        }, associationConfig.initialConfig);\n                    } else {\n                        Ext.apply(associationConfig, {\n                            ownerModel: name,\n                            associatedModel: associationConfig.model\n                        });\n                    }\n\n                    if (Ext.ModelManager.getModel(associationConfig.model) === undefined) {\n                        Ext.ModelManager.registerDeferredAssociation(associationConfig);\n                    } else {\n                        associationsMixedCollection.add(Ext.data.association.Association.create(associationConfig));\n                    }\n                }\n\n                data.associations = associationsMixedCollection;\n\n                // onBeforeCreated may get called *asynchronously* if any of those required classes caused\n                // an asynchronous script load. This would mean that the class definition object\n                // has not been applied to the prototype when the Model definition has returned.\n                // The Reader constructor does not attempt to buildExtractors if the fields MixedCollection\n                // has not yet been set. The cls.setProxy call triggers a build of extractor methods.\n                onBeforeClassCreated.call(me, cls, data, hooks);\n\n                cls.setProxy(clsProxy);\n\n                // Fire the onModelDefined template method on ModelManager\n                Ext.ModelManager.onModelDefined(cls);\n            });\n        };\n    },\n\n    inheritableStatics: {\n        /**\n         * Sets the Proxy to use for this model. Accepts any options that can be accepted by\n         * {@link Ext#createByAlias Ext.createByAlias}.\n         * @param {String/Object/Ext.data.proxy.Proxy} proxy The proxy\n         * @return {Ext.data.proxy.Proxy}\n         * @static\n         * @inheritable\n         */\n        setProxy: function(proxy) {\n            //make sure we have an Ext.data.proxy.Proxy object\n            if (!proxy.isProxy) {\n                if (typeof proxy == \"string\") {\n                    proxy = {\n                        type: proxy\n                    };\n                }\n                proxy = Ext.createByAlias(\"proxy.\" + proxy.type, proxy);\n            }\n            proxy.setModel(this);\n            this.proxy = this.prototype.proxy = proxy;\n\n            return proxy;\n        },\n\n        /**\n         * Returns the configured Proxy for this Model\n         * @return {Ext.data.proxy.Proxy} The proxy\n         * @static\n         * @inheritable\n         */\n        getProxy: function() {\n            return this.proxy;\n        },\n\n        /**\n         * Apply a new set of field and/or property definitions to the existing model. This will replace any existing\n         * fields, including fields inherited from superclasses. Mainly for reconfiguring the\n         * model based on changes in meta data (called from Reader's onMetaChange method).\n         * @static\n         * @inheritable\n         */\n        setFields: function(fields, idProperty, clientIdProperty) {\n            var me = this,\n                proto = me.prototype,\n                prototypeFields = proto.fields,\n                len = fields ? fields.length : 0,\n                i = 0;\n\n\n            if (idProperty) {\n                proto.idProperty = idProperty;\n            }\n            if (clientIdProperty) {\n                proto.clientIdProperty = clientIdProperty;\n            }\n\n            if (prototypeFields) {\n                prototypeFields.clear();\n            }\n            else {\n                prototypeFields = me.prototype.fields = new Ext.util.MixedCollection(false, function(field) {\n                    return field.name;\n                });\n            }\n\n            for (; i < len; i++) {\n                prototypeFields.add(new Ext.data.Field(fields[i]));\n            }\n            if (!prototypeFields.get(proto.idProperty)) {\n                prototypeFields.add(new Ext.data.Field(proto.idProperty));\n            }\n\n            me.fields = prototypeFields;\n\n            return prototypeFields;\n        },\n\n        /**\n         * Returns an Array of {@link Ext.data.Field Field} definitions which define this Model's structure\n         *\n         * Fields are sorted upon Model class definition. Fields with custom {@link Ext.data.Field#convert convert} functions\n         * are moved to *after* fields with no convert functions. This is so that convert functions which rely on existing\n         * field values will be able to read those field values.\n         *\n         * @return {Ext.data.Field[]} The defined Fields for this Model.\n         *\n         */\n        getFields: function() {\n            return this.prototype.fields.items;\n        },\n\n        /**\n         * Asynchronously loads a model instance by id. Sample usage:\n         *\n         *     Ext.define('MyApp.User', {\n         *         extend: 'Ext.data.Model',\n         *         fields: [\n         *             {name: 'id', type: 'int'},\n         *             {name: 'name', type: 'string'}\n         *         ]\n         *     });\n         *\n         *     MyApp.User.load(10, {\n         *         scope: this,\n         *         failure: function(record, operation) {\n         *             //do something if the load failed\n         *         },\n         *         success: function(record, operation) {\n         *             //do something if the load succeeded\n         *         },\n         *         callback: function(record, operation) {\n         *             //do something whether the load succeeded or failed\n         *         }\n         *     });\n         *\n         * @param {Number/String} id The id of the model to load\n         * @param {Object} config (optional) config object containing success, failure and callback functions, plus\n         * optional scope\n         * @static\n         * @inheritable\n         */\n        load: function(id, config) {\n            config = Ext.apply({}, config);\n            config = Ext.applyIf(config, {\n                action: 'read',\n                id    : id\n            });\n\n            var operation  = new Ext.data.Operation(config),\n                scope      = config.scope || this,\n                record     = null,\n                callback;\n\n            callback = function(operation) {\n                if (operation.wasSuccessful()) {\n                    record = operation.getRecords()[0];\n                    Ext.callback(config.success, scope, [record, operation]);\n                } else {\n                    Ext.callback(config.failure, scope, [record, operation]);\n                }\n                Ext.callback(config.callback, scope, [record, operation]);\n            };\n\n            this.proxy.read(operation, callback, this);\n        }\n    },\n\n    statics: {\n        /**\n         * @property\n         * @static\n         * @private\n         */\n        PREFIX : 'ext-record',\n        /**\n         * @property\n         * @static\n         * @private\n         */\n        AUTO_ID: 1,\n        /**\n         * @property\n         * @static\n         * The update operation of type 'edit'. Used by {@link Ext.data.Store#update Store.update} event.\n         */\n        EDIT   : 'edit',\n        /**\n         * @property\n         * @static\n         * The update operation of type 'reject'. Used by {@link Ext.data.Store#update Store.update} event.\n         */\n        REJECT : 'reject',\n        /**\n         * @property\n         * @static\n         * The update operation of type 'commit'. Used by {@link Ext.data.Store#update Store.update} event.\n         */\n        COMMIT : 'commit',\n\n        /**\n         * Generates a sequential id. This method is typically called when a record is {@link Ext#create\n         * create}d and {@link #constructor no id has been specified}. The id will automatically be assigned to the\n         * record. The returned id takes the form: {PREFIX}-{AUTO_ID}.\n         *\n         * - **PREFIX** : String - Ext.data.Model.PREFIX (defaults to 'ext-record')\n         * - **AUTO_ID** : String - Ext.data.Model.AUTO_ID (defaults to 1 initially)\n         *\n         * @param {Ext.data.Model} rec The record being created. The record does not exist, it's a {@link #phantom}.\n         * @return {String} auto-generated string id, `\"ext-record-i++\"`;\n         * @static\n         */\n        id: function(rec) {\n            var id = [this.PREFIX, '-', this.AUTO_ID++].join('');\n            rec.phantom = true;\n            rec.internalId = id;\n            return id;\n        }\n    },\n\n    /**\n     * @cfg {String/Object} idgen\n     * The id generator to use for this model. The default id generator does not generate\n     * values for the {@link #idProperty}.\n     *\n     * This can be overridden at the model level to provide a custom generator for a model.\n     * The simplest form of this would be:\n     *\n     *      Ext.define('MyApp.data.MyModel', {\n     *          extend: 'Ext.data.Model',\n     *          requires: ['Ext.data.SequentialIdGenerator'],\n     *          idgen: 'sequential',\n     *          ...\n     *      });\n     *\n     * The above would generate {@link Ext.data.SequentialIdGenerator sequential} id's such\n     * as 1, 2, 3 etc..\n     *\n     * Another useful id generator is {@link Ext.data.UuidGenerator}:\n     *\n     *      Ext.define('MyApp.data.MyModel', {\n     *          extend: 'Ext.data.Model',\n     *          requires: ['Ext.data.UuidGenerator'],\n     *          idgen: 'uuid',\n     *          ...\n     *      });\n     *\n     * An id generation can also be further configured:\n     *\n     *      Ext.define('MyApp.data.MyModel', {\n     *          extend: 'Ext.data.Model',\n     *          idgen: {\n     *              type: 'sequential',\n     *              seed: 1000,\n     *              prefix: 'ID_'\n     *          }\n     *      });\n     *\n     * The above would generate id's such as ID_1000, ID_1001, ID_1002 etc..\n     *\n     * If multiple models share an id space, a single generator can be shared:\n     *\n     *      Ext.define('MyApp.data.MyModelX', {\n     *          extend: 'Ext.data.Model',\n     *          idgen: {\n     *              type: 'sequential',\n     *              id: 'xy'\n     *          }\n     *      });\n     *\n     *      Ext.define('MyApp.data.MyModelY', {\n     *          extend: 'Ext.data.Model',\n     *          idgen: {\n     *              type: 'sequential',\n     *              id: 'xy'\n     *          }\n     *      });\n     *\n     * For more complex, shared id generators, a custom generator is the best approach.\n     * See {@link Ext.data.IdGenerator} for details on creating custom id generators.\n     *\n     * @markdown\n     */\n    idgen: {\n        isGenerator: true,\n        type: 'default',\n\n        generate: function () {\n            return null;\n        },\n        getRecId: function (rec) {\n            return rec.modelName + '-' + rec.internalId;\n        }\n    },\n\n    /**\n     * @property {Boolean} editing\n     * Internal flag used to track whether or not the model instance is currently being edited.\n     * @readonly\n     */\n    editing : false,\n\n    /**\n     * @property {Boolean} dirty\n     * True if this Record has been modified.\n     * @readonly\n     */\n    dirty : false,\n\n    /**\n     * @cfg {String} persistenceProperty\n     * The name of the property on this Persistable object that its data is saved to. Defaults to 'data'\n     * (i.e: all persistable data resides in `this.data`.)\n     */\n    persistenceProperty: 'data',\n\n    evented: false,\n\n    /**\n     * @property {Boolean} isModel\n     * `true` in this class to identify an object as an instantiated Model, or subclass thereof.\n     */\n    isModel: true,\n\n    /**\n     * @property {Boolean} phantom\n     * True when the record does not yet exist in a server-side database (see {@link #setDirty}).\n     * Any record which has a real database pk set as its id property is NOT a phantom -- it's real.\n     */\n    phantom : false,\n\n    /**\n     * @cfg {String} idProperty\n     * The name of the field treated as this Model's unique id. Defaults to 'id'.\n     */\n    idProperty: 'id',\n\n    /**\n     * @cfg {String} [clientIdProperty]\n     * The name of a property that is used for submitting this Model's unique client-side identifier\n     * to the server when multiple phantom records are saved as part of the same {@link Ext.data.Operation Operation}.\n     * In such a case, the server response should include the client id for each record\n     * so that the server response data can be used to update the client-side records if necessary.\n     * This property cannot have the same name as any of this Model's fields.\n     */\n    clientIdProperty: null,\n\n    /**\n     * @cfg {String} defaultProxyType\n     * The string type of the default Model Proxy. Defaults to 'ajax'.\n     */\n    defaultProxyType: 'ajax',\n\n    // Fields config and property\n    /**\n     * @cfg {Object[]/String[]} fields\n     * The fields for this model. This is an Array of **{@link Ext.data.Field Field}** definition objects. A Field\n     * definition may simply be the *name* of the Field, but a Field encapsulates {@link Ext.data.Field#type data type},\n     * {@link Ext.data.Field#convert custom conversion} of raw data, and a {@link Ext.data.Field#mapping mapping}\n     * property to specify by name of index, how to extract a field's value from a raw data object, so it is best practice\n     * to specify a full set of {@link Ext.data.Field Field} config objects.\n     */\n    /**\n     * @property {Ext.util.MixedCollection} fields\n     * A {@link Ext.util.MixedCollection Collection} of the fields defined for this Model (including fields defined in superclasses)\n     *\n     * This is a collection of {@link Ext.data.Field} instances, each of which encapsulates information that the field was configured with.\n     * By default, you can specify a field as simply a String, representing the *name* of the field, but a Field encapsulates\n     * {@link Ext.data.Field#type data type}, {@link Ext.data.Field#convert custom conversion} of raw data, and a {@link Ext.data.Field#mapping mapping}\n     * property to specify by name of index, how to extract a field's value from a raw data object.\n     */\n\n    /**\n     * @cfg {Object[]} validations\n     * An array of {@link Ext.data.validations validations} for this model.\n     */\n\n    // Associations configs and properties\n    /**\n     * @cfg {Object[]} associations\n     * An array of {@link Ext.data.Association associations} for this model.\n     */\n    /**\n     * @cfg {String/Object/String[]/Object[]} hasMany\n     * One or more {@link Ext.data.HasManyAssociation HasMany associations} for this model.\n     */\n    /**\n     * @cfg {String/Object/String[]/Object[]} belongsTo\n     * One or more {@link Ext.data.BelongsToAssociation BelongsTo associations} for this model.\n     */\n    /**\n     * @cfg {String/Object/Ext.data.proxy.Proxy} proxy\n     * The {@link Ext.data.proxy.Proxy proxy} to use for this model.\n     */\n\n    /**\n     * @event idchanged\n     * Fired when this model's id changes\n     * @param {Ext.data.Model} this\n     * @param {Number/String} oldId The old id\n     * @param {Number/String} newId The new id\n     */\n\n    /**\n     * Creates new Model instance.\n     * @param {Object} data An object containing keys corresponding to this model's fields, and their associated values\n     */\n    constructor: function(data, id, raw, convertedData) {\n        // id, raw and convertedData not documented intentionally, meant to be used internally.\n        // TODO: find where \"raw\" is used and remove it. The first parameter, \"data\" is raw, unconverted data. \"raw\" is redundant.\n        // The \"convertedData\" parameter is a converted object hash with all properties corresponding to defined Fields\n        // and all values of the defined type. It is used directly as this record's data property.\n        data = data || {};\n\n        var me = this,\n            fields,\n            length,\n            field,\n            name,\n            value,\n            newId,\n            persistenceProperty,\n            i;\n\n\n        /**\n         * @property {Number/String} internalId\n         * An internal unique ID for each Model instance, used to identify Models that don't have an ID yet\n         * @private\n         */\n        me.internalId = (id || id === 0) ? id : Ext.data.Model.id(me);\n\n        /**\n         * @property {Object} raw The raw data used to create this model if created via a reader.\n         */\n        me.raw = raw || data; // If created using data in constructor, use data\n\n        if (!me.data) {\n            me.data = {};\n        }\n\n        /**\n         * @property {Object} modified Key: value pairs of all fields whose values have changed\n         */\n        me.modified = {};\n\n        // Deal with spelling error in previous releases\n        if (me.persistanceProperty) {\n            Ext.log.warn('Ext.data.Model: persistanceProperty has been deprecated. Use persistenceProperty instead.');\n            me.persistenceProperty = me.persistanceProperty;\n        }\n\n        me[me.persistenceProperty] = convertedData || {};\n\n        me.mixins.observable.constructor.call(me);\n\n        if (!convertedData) {\n            //add default field values if present\n            fields = me.fields.items;\n            length = fields.length;\n            i = 0;\n            persistenceProperty = me[me.persistenceProperty];\n\n            if (Ext.isArray(data)) {\n                for (; i < length; i++) {\n                    field = fields[i];\n                    name  = field.name;\n\n                    // Use the original ordinal position at which the Model inserted the field into its collection.\n                    // Fields are sorted to place fields with a *convert* function last.\n                    value = data[field.originalIndex];\n\n                    if (value === undefined) {\n                        value = field.defaultValue;\n                    }\n                    // Have to map array data so the values get assigned to the named fields\n                    // rather than getting set as the field names with undefined values.\n                    if (field.convert) {\n                        value = field.convert(value, me);\n                    }\n                    // On instance construction, do not create data properties based on undefined input properties\n                    if (value !== undefined) {\n                        persistenceProperty[name] = value;\n                    }\n                }\n\n            } else {\n               for (; i < length; i++) {\n                    field = fields[i];\n                    name  = field.name;\n                    value = data[name];\n                    if (value === undefined) {\n                        value = field.defaultValue;\n                    }\n                    if (field.convert) {\n                        value = field.convert(value, me);\n                    }\n                    // On instance construction, do not create data properties based on undefined input properties\n                    if (value !== undefined) {\n                        persistenceProperty[name] = value;\n                    }\n               }\n            }\n        }\n\n        /**\n         * @property {Ext.data.Store[]} stores\n         * The {@link Ext.data.Store Stores} to which this instance is bound.\n         */\n        me.stores = [];\n\n        if (me.getId()) {\n            me.phantom = false;\n        } else if (me.phantom) {\n            newId = me.idgen.generate();\n            if (newId !== null) {\n                me.setId(newId);\n            }\n        }\n\n        // clear any dirty/modified since we're initializing\n        me.dirty = false;\n        me.modified = {};\n\n        if (typeof me.init == 'function') {\n            me.init();\n        }\n\n        me.id = me.idgen.getRecId(me);\n    },\n\n    /**\n     * Returns the value of the given field\n     * @param {String} fieldName The field to fetch the value for\n     * @return {Object} The value\n     */\n    get: function(field) {\n        return this[this.persistenceProperty][field];\n    },\n\n    // This object is used whenever the set() method is called and given a string as the\n    // first argument. This approach saves memory (and GC costs) since we could be called\n    // a lot.\n    _singleProp: {},\n\n    /**\n     * Sets the given field to the given value, marks the instance as dirty\n     * @param {String/Object} fieldName The field to set, or an object containing key/value pairs\n     * @param {Object} newValue The value to set\n     * @return {String[]} The array of modified field names or null if nothing was modified.\n     */\n    set: function (fieldName, newValue) {\n        var me = this,\n            data = me[me.persistenceProperty],\n            fields = me.fields,\n            modified = me.modified,\n            single = (typeof fieldName == 'string'),\n            currentValue, field, idChanged, key, modifiedFieldNames, name, oldId,\n            newId, value, values;\n\n        if (single) {\n            values = me._singleProp;\n            values[fieldName] = newValue;\n        } else {\n            values = fieldName;\n        }\n\n        for (name in values) {\n            if (values.hasOwnProperty(name)) {\n                value = values[name];\n\n                if (fields && (field = fields.get(name)) && field.convert) {\n                    value = field.convert(value, me);\n                }\n\n                currentValue = data[name];\n                if (me.isEqual(currentValue, value)) {\n                    continue; // new value is the same, so no change...\n                }\n\n                data[name] = value;\n                (modifiedFieldNames || (modifiedFieldNames = [])).push(name);\n\n                if (field && field.persist) {\n                    if (modified.hasOwnProperty(name)) {\n                        if (me.isEqual(modified[name], value)) {\n                            // The original value in me.modified equals the new value, so\n                            // the field is no longer modified:\n                            delete modified[name];\n\n                            // We might have removed the last modified field, so check to\n                            // see if there are any modified fields remaining and correct\n                            // me.dirty:\n                            me.dirty = false;\n                            for (key in modified) {\n                                if (modified.hasOwnProperty(key)){\n                                    me.dirty = true;\n                                    break;\n                                }\n                            }\n                        }\n                    } else {\n                        me.dirty = true;\n                        modified[name] = currentValue;\n                    }\n                }\n\n                if (name == me.idProperty) {\n                    idChanged = true;\n                    oldId = currentValue;\n                    newId = value;\n                }\n            }\n        }\n\n        if (single) {\n            // cleanup our reused object for next time... important to do this before\n            // we fire any events or call anyone else (like afterEdit)!\n            delete values[fieldName];\n        }\n\n        if (idChanged) {\n            me.fireEvent('idchanged', me, oldId, newId);\n        }\n\n        if (!me.editing && modifiedFieldNames) {\n            me.afterEdit(modifiedFieldNames);\n        }\n\n        return modifiedFieldNames || null;\n    },\n\n    /**\n     * @private\n     * Copies data from the passed record into this record. If the passed record is undefined, does nothing.\n     *\n     * If this is a phantom record (represented only in the client, with no corresponding database entry), and\n     * the source record is not a phantom, then this record acquires the id of the source record.\n     *\n     * @param {Ext.data.Model} sourceRecord The record to copy data from.\n     */\n    copyFrom: function(sourceRecord) {\n        if (sourceRecord) {\n\n            var me = this,\n                fields = me.fields.items,\n                fieldCount = fields.length,\n                field, i = 0,\n                myData = me[me.persistenceProperty],\n                sourceData = sourceRecord[sourceRecord.persistenceProperty],\n                value;\n\n            for (; i < fieldCount; i++) {\n                field = fields[i];\n\n                // Do not use setters.\n                // Copy returned values in directly from the data object.\n                // Converters have already been called because new Records\n                // have been created to copy from.\n                // This is a direct record-to-record value copy operation.\n                value = sourceData[field.name];\n                if (value !== undefined) {\n                    myData[field.name] = value;\n                }\n            }\n\n            // If this is a phantom record being updated from a concrete record, copy the ID in.\n            if (me.phantom && !sourceRecord.phantom) {\n                me.setId(sourceRecord.getId());\n            }\n        }\n    },\n\n    /**\n     * Checks if two values are equal, taking into account certain\n     * special factors, for example dates.\n     * @private\n     * @param {Object} a The first value\n     * @param {Object} b The second value\n     * @return {Boolean} True if the values are equal\n     */\n    isEqual: function(a, b){\n        if (Ext.isDate(a) && Ext.isDate(b)) {\n            return Ext.Date.isEqual(a, b);\n        }\n        return a === b;\n    },\n\n    /**\n     * Begins an edit. While in edit mode, no events (e.g.. the `update` event) are relayed to the containing store.\n     * When an edit has begun, it must be followed by either {@link #endEdit} or {@link #cancelEdit}.\n     */\n    beginEdit : function(){\n        var me = this;\n        if (!me.editing) {\n            me.editing = true;\n            me.dirtySave = me.dirty;\n            me.dataSave = Ext.apply({}, me[me.persistenceProperty]);\n            me.modifiedSave = Ext.apply({}, me.modified);\n        }\n    },\n\n    /**\n     * Cancels all changes made in the current edit operation.\n     */\n    cancelEdit : function(){\n        var me = this;\n        if (me.editing) {\n            me.editing = false;\n            // reset the modified state, nothing changed since the edit began\n            me.modified = me.modifiedSave;\n            me[me.persistenceProperty] = me.dataSave;\n            me.dirty = me.dirtySave;\n            delete me.modifiedSave;\n            delete me.dataSave;\n            delete me.dirtySave;\n        }\n    },\n\n    /**\n     * Ends an edit. If any data was modified, the containing store is notified (ie, the store's `update` event will\n     * fire).\n     * @param {Boolean} silent True to not notify the store of the change\n     * @param {String[]} modifiedFieldNames Array of field names changed during edit.\n     */\n    endEdit : function(silent, modifiedFieldNames){\n        var me = this,\n            changed;\n        if (me.editing) {\n            me.editing = false;\n            if(!modifiedFieldNames) {\n                modifiedFieldNames = me.getModifiedFieldNames();\n            }\n            changed = me.dirty || modifiedFieldNames.length > 0;\n            delete me.modifiedSave;\n            delete me.dataSave;\n            delete me.dirtySave;\n            if (changed && silent !== true) {\n                me.afterEdit(modifiedFieldNames);\n            }\n        }\n    },\n\n    /**\n     * Gets the names of all the fields that were modified during an edit\n     * @private\n     * @return {String[]} An array of modified field names\n     */\n    getModifiedFieldNames: function(){\n        var me = this,\n            saved = me.dataSave,\n            data = me[me.persistenceProperty],\n            modified = [],\n            key;\n\n        for (key in data) {\n            if (data.hasOwnProperty(key)) {\n                if (!me.isEqual(data[key], saved[key])) {\n                    modified.push(key);\n                }\n            }\n        }\n        return modified; \n    },\n\n    /**\n     * Gets a hash of only the fields that have been modified since this Model was created or commited.\n     * @return {Object}\n     */\n    getChanges : function(){\n        var modified = this.modified,\n            changes  = {},\n            field;\n\n        for (field in modified) {\n            if (modified.hasOwnProperty(field)){\n                changes[field] = this.get(field);\n            }\n        }\n\n        return changes;\n    },\n\n    /**\n     * Returns true if the passed field name has been `{@link #modified}` since the load or last commit.\n     * @param {String} fieldName {@link Ext.data.Field#name}\n     * @return {Boolean}\n     */\n    isModified : function(fieldName) {\n        return this.modified.hasOwnProperty(fieldName);\n    },\n\n    /**\n     * Marks this **Record** as `{@link #dirty}`. This method is used interally when adding `{@link #phantom}` records\n     * to a {@link Ext.data.proxy.Server#writer writer enabled store}.\n     *\n     * Marking a record `{@link #dirty}` causes the phantom to be returned by {@link Ext.data.Store#getUpdatedRecords}\n     * where it will have a create action composed for it during {@link Ext.data.Model#save model save} operations.\n     */\n    setDirty : function() {\n        var me     = this,\n            fields = me.fields.items,\n            fLen   = fields.length,\n            field, name, f;\n\n        me.dirty = true;\n\n        for (f = 0; f < fLen; f++) {\n            field = fields[f];\n\n            if (field.persist) {\n                name  = field.name;\n                me.modified[name] = me.get(name);\n            }\n        }\n    },\n\n    markDirty : function() {\n        Ext.log.warn('Ext.data.Model: markDirty has been deprecated. Use setDirty instead.');\n\n        return this.setDirty.apply(this, arguments);\n    },\n\n    /**\n     * Usually called by the {@link Ext.data.Store} to which this model instance has been {@link #join joined}. Rejects\n     * all changes made to the model instance since either creation, or the last commit operation. Modified fields are\n     * reverted to their original values.\n     *\n     * Developers should subscribe to the {@link Ext.data.Store#event-update} event to have their code notified of reject\n     * operations.\n     *\n     * @param {Boolean} silent (optional) True to skip notification of the owning store of the change.\n     * Defaults to false.\n     */\n    reject : function(silent) {\n        var me = this,\n            modified = me.modified,\n            field;\n\n        for (field in modified) {\n            if (modified.hasOwnProperty(field)) {\n                if (typeof modified[field] != \"function\") {\n                    me[me.persistenceProperty][field] = modified[field];\n                }\n            }\n        }\n\n        me.dirty = false;\n        me.editing = false;\n        me.modified = {};\n\n        if (silent !== true) {\n            me.afterReject();\n        }\n    },\n\n    /**\n     * Usually called by the {@link Ext.data.Store} which owns the model instance. Commits all changes made to the\n     * instance since either creation or the last commit operation.\n     *\n     * Developers should subscribe to the {@link Ext.data.Store#event-update} event to have their code notified of commit\n     * operations.\n     *\n     * @param {Boolean} silent (optional) True to skip notification of the owning store of the change.\n     * Defaults to false.\n     */\n    commit : function(silent) {\n        var me = this;\n\n        me.phantom = me.dirty = me.editing = false;\n        me.modified = {};\n\n        if (silent !== true) {\n            me.afterCommit();\n        }\n    },\n\n    /**\n     * Creates a copy (clone) of this Model instance.\n     *\n     * @param {String} [id] A new id, defaults to the id of the instance being copied.\n     * See `{@link Ext.data.Model#id id}`. To generate a phantom instance with a new id use:\n     *\n     *     var rec = record.copy(); // clone the record\n     *     Ext.data.Model.id(rec); // automatically generate a unique sequential id\n     *\n     * @return {Ext.data.Model}\n     */\n    copy : function(newId) {\n        var me = this;\n\n        // Use raw data as the data param.\n        // Pass a copy iof our converted data in to be used as the new record's convertedData\n        return new me.self(me.raw, newId, null, Ext.apply({}, me[me.persistenceProperty]));\n    },\n\n    /**\n     * Sets the Proxy to use for this model. Accepts any options that can be accepted by\n     * {@link Ext#createByAlias Ext.createByAlias}.\n     *\n     * @param {String/Object/Ext.data.proxy.Proxy} proxy The proxy\n     * @return {Ext.data.proxy.Proxy}\n     */\n    setProxy: function(proxy) {\n        //make sure we have an Ext.data.proxy.Proxy object\n        if (!proxy.isProxy) {\n            if (typeof proxy === \"string\") {\n                proxy = {\n                    type: proxy\n                };\n            }\n            proxy = Ext.createByAlias(\"proxy.\" + proxy.type, proxy);\n        }\n        proxy.setModel(this.self);\n        this.proxy = proxy;\n\n        return proxy;\n    },\n\n    /**\n     * Returns the configured Proxy for this Model.\n     * @return {Ext.data.proxy.Proxy} The proxy\n     */\n    getProxy: function() {\n        return this.proxy;\n    },\n\n    /**\n     * Validates the current data against all of its configured {@link #validations}.\n     * @return {Ext.data.Errors} The errors object\n     */\n    validate: function() {\n        var errors      = new Ext.data.Errors(),\n            validations = this.validations,\n            validators  = Ext.data.validations,\n            length, validation, field, valid, type, i;\n\n        if (validations) {\n            length = validations.length;\n\n            for (i = 0; i < length; i++) {\n                validation = validations[i];\n                field = validation.field || validation.name;\n                type  = validation.type;\n                valid = validators[type](validation, this.get(field));\n\n                if (!valid) {\n                    errors.add({\n                        field  : field,\n                        message: validation.message || validators[type + 'Message']\n                    });\n                }\n            }\n        }\n\n        return errors;\n    },\n\n    /**\n     * Checks if the model is valid. See {@link #validate}.\n     * @return {Boolean} True if the model is valid.\n     */\n    isValid: function(){\n        return this.validate().isValid();\n    },\n\n    /**\n     * Saves the model instance using the configured proxy.\n     * @param {Object} options Options to pass to the proxy. Config object for {@link Ext.data.Operation}.\n     * @return {Ext.data.Model} The Model instance\n     */\n    save: function(options) {\n        options = Ext.apply({}, options);\n\n        var me     = this,\n            action = me.phantom ? 'create' : 'update',\n            scope  = options.scope || me,\n            stores = me.stores,\n            i = 0,\n            storeCount,\n            store,\n            args,\n            operation,\n            callback;\n\n        Ext.apply(options, {\n            records: [me],\n            action : action\n        });\n\n        operation = new Ext.data.Operation(options);\n\n        callback = function(operation) {\n            args = [me, operation];\n            if (operation.wasSuccessful()) {\n                for(storeCount = stores.length; i < storeCount; i++) {\n                    store = stores[i];\n                    store.fireEvent('write', store, operation);\n                    store.fireEvent('datachanged', store);\n                    // Not firing refresh here, since it's a single record\n                }\n                Ext.callback(options.success, scope, args);\n            } else {\n                Ext.callback(options.failure, scope, args);\n            }\n\n            Ext.callback(options.callback, scope, args);\n        };\n\n        me.getProxy()[action](operation, callback, me);\n\n        return me;\n    },\n\n    /**\n     * Destroys the model using the configured proxy.\n     * @param {Object} options Options to pass to the proxy. Config object for {@link Ext.data.Operation}.\n     * @return {Ext.data.Model} The Model instance\n     */\n    destroy: function(options){\n        options = Ext.apply({}, options);\n\n        var me     = this,\n            scope  = options.scope || me,\n            stores = me.stores,\n            i = 0,\n            storeCount,\n            store,\n            args,\n            operation,\n            callback;\n\n        Ext.apply(options, {\n            records: [me],\n            action : 'destroy'\n        });\n\n        operation = new Ext.data.Operation(options);\n        callback = function(operation) {\n            args = [me, operation];\n            if (operation.wasSuccessful()) {\n                for(storeCount = stores.length; i < storeCount; i++) {\n                    store = stores[i];\n                    store.fireEvent('write', store, operation);\n                    store.fireEvent('datachanged', store);\n                    // Not firing refresh here, since it's a single record\n                }\n                me.clearListeners();\n                Ext.callback(options.success, scope, args);\n            } else {\n                Ext.callback(options.failure, scope, args);\n            }\n            Ext.callback(options.callback, scope, args);\n        };\n\n        me.getProxy().destroy(operation, callback, me);\n        return me;\n    },\n\n    /**\n     * Returns the unique ID allocated to this model instance as defined by {@link #idProperty}.\n     * @return {Number/String} The id\n     */\n    getId: function() {\n        return this.get(this.idProperty);\n    },\n\n    /**\n     * @private\n     */\n    getObservableId: function() {\n        return this.id;\n    },\n\n    /**\n     * Sets the model instance's id field to the given id.\n     * @param {Number/String} id The new id\n     */\n    setId: function(id) {\n        this.set(this.idProperty, id);\n        this.phantom  = !(id || id === 0);\n    },\n\n    /**\n     * Tells this model instance that it has been added to a store.\n     * @param {Ext.data.Store} store The store to which this model has been added.\n     */\n    join : function(store) {\n        Ext.Array.include(this.stores, store);\n\n        /**\n         * @property {Ext.data.Store} store\n         * The {@link Ext.data.Store Store} to which this instance belongs. NOTE: If this\n         * instance is bound to multiple stores, this property will reference only the\n         * first. To examine all the stores, use the {@link #stores} property instead.\n         */\n        this.store = this.stores[0]; // compat w/all releases ever\n    },\n\n    /**\n     * Tells this model instance that it has been removed from the store.\n     * @param {Ext.data.Store} store The store from which this model has been removed.\n     */\n    unjoin: function(store) {\n        Ext.Array.remove(this.stores, store);\n        this.store = this.stores[0] || null; // compat w/all releases ever\n    },\n\n    /**\n     * @private\n     * If this Model instance has been {@link #join joined} to a {@link Ext.data.Store store}, the store's\n     * afterEdit method is called\n     * @param {String[]} modifiedFieldNames Array of field names changed during edit.\n     */\n    afterEdit : function(modifiedFieldNames) {\n        this.callStore('afterEdit', modifiedFieldNames);\n    },\n\n    /**\n     * @private\n     * If this Model instance has been {@link #join joined} to a {@link Ext.data.Store store}, the store's\n     * afterReject method is called\n     */\n    afterReject : function() {\n        this.callStore(\"afterReject\");\n    },\n\n    /**\n     * @private\n     * If this Model instance has been {@link #join joined} to a {@link Ext.data.Store store}, the store's\n     * afterCommit method is called\n     */\n    afterCommit: function() {\n        this.callStore('afterCommit');\n    },\n\n    /**\n     * @private\n     * Helper function used by afterEdit, afterReject and afterCommit. Calls the given method on the\n     * {@link Ext.data.Store store} that this instance has {@link #join joined}, if any. The store function\n     * will always be called with the model instance as its single argument. If this model is joined to \n     * a Ext.data.NodeStore, then this method calls the given method on the NodeStore and the associated Ext.data.TreeStore\n     * @param {String} fn The function to call on the store\n     */\n    callStore: function(fn) {\n        var args = Ext.Array.clone(arguments),\n            stores = this.stores,\n            i = 0,\n            len = stores.length,\n            store, treeStore;\n\n        args[0] = this;\n        for (; i < len; ++i) {\n            store = stores[i];\n            if (store && typeof store[fn] == \"function\") {\n                store[fn].apply(store, args);\n            }\n            // if the record is bound to a NodeStore call the TreeStore's method as well\n            treeStore = store.treeStore;\n            if (treeStore && typeof treeStore[fn] == \"function\") {\n                treeStore[fn].apply(treeStore, args);\n            }\n        }\n    },\n\n    /**\n     * Gets all values for each field in this model and returns an object\n     * containing the current data.\n     * @param {Boolean} includeAssociated True to also include associated data. Defaults to false.\n     * @return {Object} An object hash containing all the values in this model\n     */\n    getData: function(includeAssociated){\n        var me     = this,\n            fields = me.fields.items,\n            fLen   = fields.length,\n            data   = {},\n            name, f;\n\n        for (f = 0; f < fLen; f++) {\n            name = fields[f].name;\n            data[name] = me.get(name);\n        }\n\n        if (includeAssociated === true) {\n            Ext.apply(data, me.getAssociatedData());\n        }\n        return data;\n    },\n\n    /**\n     * Gets all of the data from this Models *loaded* associations. It does this recursively - for example if we have a\n     * User which hasMany Orders, and each Order hasMany OrderItems, it will return an object like this:\n     *\n     *     {\n     *         orders: [\n     *             {\n     *                 id: 123,\n     *                 status: 'shipped',\n     *                 orderItems: [\n     *                     ...\n     *                 ]\n     *             }\n     *         ]\n     *     }\n     *\n     * @return {Object} The nested data set for the Model's loaded associations\n     */\n    getAssociatedData: function(){\n        return this.prepareAssociatedData({}, 1);\n    },\n\n    /**\n     * @private\n     * This complex-looking method takes a given Model instance and returns an object containing all data from\n     * all of that Model's *loaded* associations. See {@link #getAssociatedData}\n     * @param {Object} seenKeys A hash of all the associations we've already seen\n     * @param {Number} depth The current depth\n     * @return {Object} The nested data set for the Model's loaded associations\n     */\n    prepareAssociatedData: function(seenKeys, depth) {\n        /*\n         * In this method we use a breadth first strategy instead of depth\n         * first. The reason for doing so is that it prevents messy & difficult\n         * issues when figuring out which associations we've already processed\n         * & at what depths.\n         */\n        var me               = this,\n            associations     = me.associations.items,\n            associationCount = associations.length,\n            associationData  = {},\n            // We keep 3 lists at the same index instead of using an array of objects.\n            // The reasoning behind this is that this method gets called a lot\n            // So we want to minimize the amount of objects we create for GC.\n            toRead           = [],\n            toReadKey        = [],\n            toReadIndex      = [],\n            associatedStore, associatedRecords, associatedRecord, o, index, result, seenDepth,\n            associationId, associatedRecordCount, association, i, j, type, name;\n\n        for (i = 0; i < associationCount; i++) {\n            association = associations[i];\n            associationId = association.associationId;\n            \n            seenDepth = seenKeys[associationId];\n            if (seenDepth && seenDepth !== depth) {\n                continue;\n            }\n            seenKeys[associationId] = depth;\n\n            type = association.type;\n            name = association.name;\n            if (type == 'hasMany') {\n                //this is the hasMany store filled with the associated data\n                associatedStore = me[association.storeName];\n\n                //we will use this to contain each associated record's data\n                associationData[name] = [];\n\n                //if it's loaded, put it into the association data\n                if (associatedStore && associatedStore.getCount() > 0) {\n                    associatedRecords = associatedStore.data.items;\n                    associatedRecordCount = associatedRecords.length;\n\n                    //now we're finally iterating over the records in the association. Get\n                    // all the records so we can process them\n                    for (j = 0; j < associatedRecordCount; j++) {\n                        associatedRecord = associatedRecords[j];\n                        associationData[name][j] = associatedRecord.getData();\n                        toRead.push(associatedRecord);\n                        toReadKey.push(name);\n                        toReadIndex.push(j);\n                    }\n                }\n            } else if (type == 'belongsTo' || type == 'hasOne') {\n                associatedRecord = me[association.instanceName];\n                // If we have a record, put it onto our list\n                if (associatedRecord !== undefined) {\n                    associationData[name] = associatedRecord.getData();\n                    toRead.push(associatedRecord);\n                    toReadKey.push(name);\n                    toReadIndex.push(-1);\n                }\n            }\n        }\n        \n        for (i = 0, associatedRecordCount = toRead.length; i < associatedRecordCount; ++i) {\n            associatedRecord = toRead[i];\n            o = associationData[toReadKey[i]];\n            index = toReadIndex[i];\n            result = associatedRecord.prepareAssociatedData(seenKeys, depth + 1);\n            if (index === -1) {\n                Ext.apply(o, result);\n            } else {\n                Ext.apply(o[index], result);\n            }\n        }\n\n        return associationData;\n    }\n});\n\n/**\n * @docauthor Evan Trimboli <evan@sencha.com>\n *\n * Contains a collection of all stores that are created that have an identifier. An identifier can be assigned by\n * setting the {@link Ext.data.AbstractStore#storeId storeId} property. When a store is in the StoreManager, it can be\n * referred to via it's identifier:\n *\n *     Ext.create('Ext.data.Store', {\n *         model: 'SomeModel',\n *         storeId: 'myStore'\n *     });\n *\n *     var store = Ext.data.StoreManager.lookup('myStore');\n *\n * Also note that the {@link #lookup} method is aliased to {@link Ext#getStore} for convenience.\n *\n * If a store is registered with the StoreManager, you can also refer to the store by it's identifier when registering\n * it with any Component that consumes data from a store:\n *\n *     Ext.create('Ext.data.Store', {\n *         model: 'SomeModel',\n *         storeId: 'myStore'\n *     });\n *\n *     Ext.create('Ext.view.View', {\n *         store: 'myStore',\n *         // other configuration here\n *     });\n *\n */\nExt.define('Ext.data.StoreManager', {\n    extend: 'Ext.util.MixedCollection',\n    alternateClassName: ['Ext.StoreMgr', 'Ext.data.StoreMgr', 'Ext.StoreManager'],\n    singleton: true,\n    uses: ['Ext.data.ArrayStore'],\n    \n    /**\n     * @cfg {Object} listeners\n     * @private\n     */\n\n    /**\n     * Registers one or more Stores with the StoreManager. You do not normally need to register stores manually. Any\n     * store initialized with a {@link Ext.data.Store#storeId} will be auto-registered.\n     * @param {Ext.data.Store...} stores Any number of Store instances\n     */\n    register : function() {\n        for (var i = 0, s; (s = arguments[i]); i++) {\n            this.add(s);\n        }\n    },\n\n    /**\n     * Unregisters one or more Stores with the StoreManager\n     * @param {String/Object...} stores Any number of Store instances or ID-s\n     */\n    unregister : function() {\n        for (var i = 0, s; (s = arguments[i]); i++) {\n            this.remove(this.lookup(s));\n        }\n    },\n\n    /**\n     * Gets a registered Store by id\n     * @param {String/Object} store The id of the Store, or a Store instance, or a store configuration\n     * @return {Ext.data.Store}\n     */\n    lookup : function(store) {\n        // handle the case when we are given an array or an array of arrays.\n        if (Ext.isArray(store)) {\n            var fields = ['field1'], \n                expand = !Ext.isArray(store[0]),\n                data = store,\n                i,\n                len;\n                \n            if(expand){\n                data = [];\n                for (i = 0, len = store.length; i < len; ++i) {\n                    data.push([store[i]]);\n                }\n            } else {\n                for(i = 2, len = store[0].length; i <= len; ++i){\n                    fields.push('field' + i);\n                }\n            }\n            return new Ext.data.ArrayStore({\n                data  : data,\n                fields: fields,\n                autoDestroy: true,\n                autoCreated: true,\n                expanded: expand\n            });\n        }\n        \n        if (Ext.isString(store)) {\n            // store id\n            return this.get(store);\n        } else {\n            // store instance or store config\n            return Ext.data.AbstractStore.create(store);\n        }\n    },\n\n    // getKey implementation for MixedCollection\n    getKey : function(o) {\n         return o.storeId;\n    }\n}, function() {    \n    /**\n     * Creates a new store for the given id and config, then registers it with the {@link Ext.data.StoreManager Store Manager}. \n     * Sample usage:\n     *\n     *     Ext.regStore('AllUsers', {\n     *         model: 'User'\n     *     });\n     *\n     *     // the store can now easily be used throughout the application\n     *     new Ext.List({\n     *         store: 'AllUsers',\n     *         ... other config\n     *     });\n     *\n     * @param {String} id The id to set on the new store\n     * @param {Object} config The store config\n     * @member Ext\n     * @method regStore\n     */\n    Ext.regStore = function(name, config) {\n        var store;\n\n        if (Ext.isObject(name)) {\n            config = name;\n        } else {\n            config.storeId = name;\n        }\n\n        if (config instanceof Ext.data.Store) {\n            store = config;\n        } else {\n            store = new Ext.data.Store(config);\n        }\n\n        return Ext.data.StoreManager.register(store);\n    };\n\n    /**\n     * Shortcut to {@link Ext.data.StoreManager#lookup}.\n     * @member Ext\n     * @method getStore\n     * @inheritdoc Ext.data.StoreManager#lookup\n     */\n    Ext.getStore = function(name) {\n        return Ext.data.StoreManager.lookup(name);\n    };\n});\n\n/**\n * This ComponentLayout handles docking for Panels. It takes care of panels that are\n * part of a ContainerLayout that sets this Panel's size and Panels that are part of\n * an AutoContainerLayout in which this panel get his height based of the CSS or\n * or its content.\n * @private\n */\nExt.define('Ext.layout.component.Dock', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.layout.component.Component',\n\n    alias: 'layout.dock',\n\n    alternateClassName: 'Ext.layout.component.AbstractDock',\n\n    /* End Definitions */\n\n    type: 'dock',\n\n    initializedBorders: -1,\n\n    horizontalCollapsePolicy: { width: true, x: true },\n\n    verticalCollapsePolicy: { height: true, y: true },\n\n    finishRender: function () {\n        var me = this,\n            target, items;\n\n        me.callParent();\n\n        target = me.getRenderTarget();\n        items = me.getDockedItems();\n\n        me.finishRenderItems(target, items);\n    },\n\n    isItemBoxParent: function (itemContext) {\n        return true;\n    },\n\n    isItemShrinkWrap: function (item) {\n        return true;\n    },\n\n    dockOpposites: {\n        top: 'bottom',\n        right: 'left',\n        bottom: 'top',\n        left: 'right'\n    },\n\n    handleItemBorders: function() {\n        var me = this,\n            owner = me.owner,\n            borders, docked,\n            oldBorders = me.borders,\n            opposites = me.dockOpposites,\n            currentGeneration = owner.dockedItems.generation,\n            i, ln, item, dock, side, borderItem,\n            collapsed = me.collapsed;\n\n        if (me.initializedBorders == currentGeneration || (owner.border && !owner.manageBodyBorders)) {\n            return;\n        }\n\n        me.initializedBorders = currentGeneration;\n\n        // Borders have to be calculated using expanded docked item collection.\n        me.collapsed = false;\n        docked = me.getLayoutItems();\n        me.collapsed = collapsed;\n\n        borders = { top: [], right: [], bottom: [], left: [] };\n\n        for (i = 0, ln = docked.length; i < ln; i++) {\n            item = docked[i];\n            dock = item.dock;\n\n            if (item.ignoreBorderManagement) {\n                continue;\n            }\n\n            if (!borders[dock].satisfied) {\n                borders[dock].push(item);\n                borders[dock].satisfied = true;\n            }\n\n            if (!borders.top.satisfied && opposites[dock] !== 'top') {\n                borders.top.push(item);\n            }\n            if (!borders.right.satisfied && opposites[dock] !== 'right') {\n                borders.right.push(item);\n            }\n            if (!borders.bottom.satisfied && opposites[dock] !== 'bottom') {\n                borders.bottom.push(item);\n            }\n            if (!borders.left.satisfied && opposites[dock] !== 'left') {\n                borders.left.push(item);\n            }\n        }\n\n        if (oldBorders) {\n            for (side in oldBorders) {\n                if (oldBorders.hasOwnProperty(side)) {\n                    ln = oldBorders[side].length;\n                    if (!owner.manageBodyBorders) {\n                        for (i = 0; i < ln; i++) {\n                            borderItem = oldBorders[side][i];\n                            if (!borderItem.isDestroyed) {\n                                borderItem.removeCls(Ext.baseCSSPrefix + 'docked-noborder-' + side);\n                            }\n                        }\n                        if (!oldBorders[side].satisfied && !owner.bodyBorder) {\n                            owner.removeBodyCls(Ext.baseCSSPrefix + 'docked-noborder-' + side);\n                        }\n                    }\n                    else if (oldBorders[side].satisfied) {\n                        owner.setBodyStyle('border-' + side + '-width', '');\n                    }\n                }\n            }\n        }\n\n        for (side in borders) {\n            if (borders.hasOwnProperty(side)) {\n                ln = borders[side].length;\n                if (!owner.manageBodyBorders) {\n                    for (i = 0; i < ln; i++) {\n                        borders[side][i].addCls(Ext.baseCSSPrefix + 'docked-noborder-' + side);\n                    }\n                    if ((!borders[side].satisfied && !owner.bodyBorder) || owner.bodyBorder === false) {\n                        owner.addBodyCls(Ext.baseCSSPrefix + 'docked-noborder-' + side);\n                    }\n                }\n                else if (borders[side].satisfied) {\n                    owner.setBodyStyle('border-' + side + '-width', '1px');\n                }\n            }\n        }\n\n        me.borders = borders;\n    },\n\n    beforeLayoutCycle: function (ownerContext) {\n        var me = this,\n            owner = me.owner,\n            shrinkWrap = me.sizeModels.shrinkWrap,\n            collapsedHorz, collapsedVert;\n\n        if (owner.collapsed) {\n            if (owner.collapsedVertical()) {\n                collapsedVert = true;\n                ownerContext.measureDimensions = 1;\n            } else {\n                collapsedHorz = true;\n                ownerContext.measureDimensions = 2;\n            }\n        }\n\n        ownerContext.collapsedVert = collapsedVert;\n        ownerContext.collapsedHorz = collapsedHorz;\n\n        // If we are collapsed, we want to auto-layout using the placeholder/expander\n        // instead of the normal items/dockedItems. This must be done here since we could\n        // be in a box layout w/stretchmax which sets the width/heightModel to allow it to\n        // control the size.\n        if (collapsedVert) {\n            ownerContext.heightModel = shrinkWrap;\n        } else if (collapsedHorz) {\n            ownerContext.widthModel = shrinkWrap;\n        }\n    },\n\n    beginLayout: function(ownerContext) {\n        var me = this,\n            owner = me.owner,\n            docked = me.getLayoutItems(),\n            layoutContext = ownerContext.context,\n            dockedItemCount = docked.length,\n            dockedItems, i, item, itemContext, offsets,\n            collapsed;\n\n        me.callParent(arguments);\n\n        me.handleItemBorders();\n\n        // Cache the children as ContextItems (like a Container). Also setup to handle\n        // collapsed state:\n        collapsed = owner.getCollapsed();\n        if (collapsed !== me.lastCollapsedState && Ext.isDefined(me.lastCollapsedState)) {\n            // If we are collapsing...\n            if (me.owner.collapsed) {\n                ownerContext.isCollapsingOrExpanding = 1;\n                // Add the collapsed class now, so that collapsed CSS rules are applied before measurements are taken by the layout.\n                owner.addClsWithUI(owner.collapsedCls);\n            } else {\n                ownerContext.isCollapsingOrExpanding = 2;\n                // Remove the collapsed class now, before layout calculations are done.\n                owner.removeClsWithUI(owner.collapsedCls);\n                ownerContext.lastCollapsedState = me.lastCollapsedState;\n            }\n        }\n        me.lastCollapsedState = collapsed;\n\n        ownerContext.dockedItems = dockedItems = [];\n\n        for (i = 0; i < dockedItemCount; i++) {\n            item = docked[i];\n            if (item.rendered) {\n                itemContext = layoutContext.getCmp(item);\n                itemContext.dockedAt = { x: 0, y: 0 };\n                itemContext.offsets = offsets = Ext.Element.parseBox(item.offsets || {});\n                offsets.width = offsets.left + offsets.right;\n                offsets.height = offsets.top + offsets.bottom;\n                dockedItems.push(itemContext);\n            }\n        }\n\n        ownerContext.bodyContext = ownerContext.getEl('body');\n    },\n\n    beginLayoutCycle: function(ownerContext) {\n        var me = this,\n            docked = ownerContext.dockedItems,\n            len = docked.length,\n            owner = me.owner,\n            frameBody = owner.frameBody,\n            lastHeightModel = me.lastHeightModel,\n            i, item, dock;\n\n        me.callParent(arguments);\n\n        if (lastHeightModel && lastHeightModel.shrinkWrap &&\n                    !ownerContext.heightModel.shrinkWrap && !me.owner.manageHeight) {\n            owner.body.dom.style.marginBottom = '';\n        }\n\n        if (ownerContext.widthModel.auto) {\n            if (ownerContext.widthModel.shrinkWrap) {\n                owner.el.setWidth(null);\n            }\n            owner.body.setWidth(null);\n            if (frameBody) {\n                frameBody.setWidth(null);\n            }\n        }\n        if (ownerContext.heightModel.auto) {\n            owner.body.setHeight(null);\n            //owner.el.setHeight(null); Disable this for now\n            if (frameBody) {\n                frameBody.setHeight(null);\n            }\n        }\n\n        // Each time we begin (2nd+ would be due to invalidate) we need to publish the\n        // known contentWidth/Height if we are collapsed:\n        if (ownerContext.collapsedVert) {\n            ownerContext.setContentHeight(0);\n        } else if (ownerContext.collapsedHorz) {\n            ownerContext.setContentWidth(0);\n        }\n\n        // dock: 'right' items, when a panel gets narrower get \"squished\". Moving them to\n        // left:0px avoids this!\n        for (i = 0; i < len; i++) {\n            item = docked[i].target;\n            dock = item.dock;\n\n            if (dock == 'right') {\n                item.el.setLeft(0);\n            } else if (dock != 'left') {\n                continue;\n            }\n\n            // TODO - clear width/height?\n        }\n    },\n\n    calculate: function (ownerContext) {\n        var me = this,\n            measure = me.measureAutoDimensions(ownerContext, ownerContext.measureDimensions),\n            state = ownerContext.state,\n            horzDone = state.horzDone,\n            vertDone = state.vertDone,\n            bodyContext = ownerContext.bodyContext,\n            horz, vert, forward, backward;\n\n        // make sure we can use these value w/o calling methods to get them\n        ownerContext.borderInfo  || ownerContext.getBorderInfo();\n        ownerContext.paddingInfo || ownerContext.getPaddingInfo();\n        ownerContext.framingInfo || ownerContext.getFraming();\n        bodyContext.borderInfo   || bodyContext.getBorderInfo();\n        bodyContext.paddingInfo  || bodyContext.getPaddingInfo();\n\n        // Start the axes so they are ready to proceed inwards (fixed-size) or outwards\n        // (shrinkWrap) and stash key property names as well:\n        horz = !horzDone &&\n               me.createAxis(ownerContext, measure.contentWidth, ownerContext.widthModel,\n                             'left', 'right', 'x', 'width', 'Width', ownerContext.collapsedHorz);\n        vert = !vertDone &&\n               me.createAxis(ownerContext, measure.contentHeight, ownerContext.heightModel,\n                             'top', 'bottom', 'y', 'height', 'Height', ownerContext.collapsedVert);\n\n        // We iterate forward and backward over the dockedItems at the same time based on\n        // whether an axis is shrinkWrap or fixed-size. For a fixed-size axis, the outer box\n        // axis is allocated to docked items in forward order and is reduced accordingly.\n        // To handle a shrinkWrap axis, the box starts at the inner (body) size and is used to\n        // size docked items in backwards order. This is because the last docked item shares\n        // an edge with the body. The item size is used to adjust the shrinkWrap axis outwards\n        // until the first docked item (at the outermost edge) is processed. This backwards\n        // order ensures that docked items never get an incorrect size for any dimension.\n        for (forward = 0, backward = ownerContext.dockedItems.length; backward--; ++forward) {\n            if (horz) {\n                me.dockChild(ownerContext, horz, backward, forward);\n            }\n            if (vert) {\n                me.dockChild(ownerContext, vert, backward, forward);\n            }\n        }\n\n        if (horz && me.finishAxis(ownerContext, horz)) {\n            state.horzDone = horzDone = horz;\n        }\n\n        if (vert && me.finishAxis(ownerContext, vert)) {\n            state.vertDone = vertDone = vert;\n        }\n\n        // Once all items are docked, the final size of the outer panel or inner body can\n        // be determined. If we can determine both width and height, we are done.\n        if (horzDone && vertDone && me.finishConstraints(ownerContext, horzDone, vertDone)) {\n            // Size information is published as we dock items but position is hard to do\n            // that way (while avoiding published multiple times) so we publish all the\n            // positions at the end.\n            me.finishPositions(ownerContext, horzDone, vertDone);\n        } else {\n            me.done = false;\n        }\n    },\n\n    /**\n     * Creates an axis object given the particulars.\n     * @private\n     */\n    createAxis: function (ownerContext, contentSize, sizeModel, dockBegin, dockEnd, posProp,\n                          sizeProp, sizePropCap, collapsedAxis) {\n        var begin = 0,\n            owner = this.owner,\n            maxSize = owner['max' + sizePropCap],\n            minSize = owner['min' + sizePropCap] || 0,\n            hasMaxSize = maxSize != null, // exactly the same as \"maxSize !== null && maxSize !== undefined\"\n            setSize = 'set' + sizePropCap,\n            border, bodyContext, frameSize, padding, end;\n\n        if (sizeModel.shrinkWrap) {\n            // End position before adding docks around the content is content size plus the body borders in this axis.\n            // If collapsed in this axis, the body borders will not be shown.\n            if (collapsedAxis) {\n                end = 0;\n            } else {\n                bodyContext = ownerContext.bodyContext;\n                end = contentSize + bodyContext.borderInfo[sizeProp];\n            }\n        } else {\n            border    = ownerContext.borderInfo;\n            frameSize = ownerContext.framingInfo;\n            padding   = ownerContext.paddingInfo;\n\n            end = ownerContext.getProp(sizeProp);\n            end -= border[dockEnd] + padding[dockEnd] + frameSize[dockEnd];\n\n            begin = border[dockBegin] + padding[dockBegin] + frameSize[dockBegin];\n        }\n\n        return {\n            shrinkWrap: sizeModel.shrinkWrap,\n            sizeModel: sizeModel,\n            // An axis tracks start and end+1 px positions. eg 0 to 10 for 10px high\n            begin: begin,\n            end: end,\n            collapsed: collapsedAxis,\n            horizontal: posProp == 'x',\n            ignoreFrameBegin: false,\n            ignoreFrameEnd: false,\n            initialSize: end - begin,\n            hasMinMaxConstraints: (minSize || hasMaxSize) && sizeModel.shrinkWrap,\n            minSize: minSize,\n            maxSize: hasMaxSize ? maxSize : 1e9,\n            bodyPosProp: this.owner.manageHeight ? posProp : ('margin-' + dockBegin), // 'margin-left' or 'margin-top'\n            dockBegin: dockBegin,    // 'left' or 'top'\n            dockEnd: dockEnd,        // 'right' or 'end'\n            posProp: posProp,        // 'x' or 'y'\n            sizeProp: sizeProp,      // 'width' or 'height'\n            sizePropCap: sizePropCap, // 'Width' or 'Height'\n            setSize: setSize,\n            dockedPixelsEnd: 0\n        };\n    },\n\n    /**\n     * Docks a child item on the specified axis. This boils down to determining if the item\n     * is docked at the \"beginning\" of the axis (\"left\" if horizontal, \"top\" if vertical),\n     * the \"end\" of the axis (\"right\" if horizontal, \"bottom\" if vertical) or stretches\n     * along the axis (\"top\" or \"bottom\" if horizontal, \"left\" or \"right\" if vertical). It\n     * also has to differentiate between fixed and shrinkWrap sized dimensions.\n     * @private\n     */\n    dockChild: function (ownerContext, axis, backward, forward) {\n        var me = this,\n            itemContext = ownerContext.dockedItems[axis.shrinkWrap ? backward : forward],\n            item = itemContext.target,\n            dock = item.dock, // left/top/right/bottom\n            pos;\n\n        if(item.ignoreParentFrame && ownerContext.isCollapsingOrExpanding) {\n            // collapsed window header margins may differ from expanded window header margins\n            // so we need to make sure the old cached values are not used in axis calculations\n            itemContext.clearMarginCache();\n        }\n\n        if (dock == axis.dockBegin) {\n            if (axis.shrinkWrap) {\n                pos = me.dockOutwardBegin(ownerContext, itemContext, item, axis);\n            } else {\n                pos = me.dockInwardBegin(ownerContext, itemContext, item, axis);\n            }\n        } else if (dock == axis.dockEnd) {\n            if (axis.shrinkWrap) {\n                pos = me.dockOutwardEnd(ownerContext, itemContext, item, axis);\n            } else {\n                pos = me.dockInwardEnd(ownerContext, itemContext, item, axis);\n            }\n        } else {\n            pos = me.dockStretch(ownerContext, itemContext, item, axis);\n        }\n\n        itemContext.dockedAt[axis.posProp] = pos;\n    },\n\n    /**\n     * Docks an item on a fixed-size axis at the \"beginning\". The \"beginning\" of the horizontal\n     * axis is \"left\" and the vertical is \"top\". For a fixed-size axis, the size works from\n     * the outer element (the panel) towards the body.\n     * @private\n     */\n    dockInwardBegin: function (ownerContext, itemContext, item, axis) {\n        var pos = axis.begin,\n            sizeProp = axis.sizeProp,\n            size, \n            dock;\n\n        if (item.ignoreParentFrame) {\n            dock = item.dock;\n            pos -= ownerContext.borderInfo[dock] + ownerContext.paddingInfo[dock] +\n                   ownerContext.framingInfo[dock];\n        }\n\n        if (!item.overlay) {\n            size = itemContext.getProp(sizeProp) + itemContext.getMarginInfo()[sizeProp];\n            axis.begin += size;\n        }\n\n        return pos;\n    },\n\n    /**\n     * Docks an item on a fixed-size axis at the \"end\". The \"end\" of the horizontal axis is\n     * \"right\" and the vertical is \"bottom\".\n     * @private\n     */\n    dockInwardEnd: function (ownerContext, itemContext, item, axis) {\n        var sizeProp = axis.sizeProp,\n            size = itemContext.getProp(sizeProp) + itemContext.getMarginInfo()[sizeProp],\n            pos = axis.end - size;\n\n        if (!item.overlay) {\n            axis.end = pos;\n        }\n\n        if (item.ignoreParentFrame) {\n            pos += ownerContext.borderInfo[item.dock] + ownerContext.paddingInfo[item.dock] +\n                   ownerContext.framingInfo[item.dock];\n        }\n\n        return pos;\n    },\n\n    /**\n     * Docks an item on a shrinkWrap axis at the \"beginning\". The \"beginning\" of the horizontal\n     * axis is \"left\" and the vertical is \"top\". For a shrinkWrap axis, the size works from\n     * the body outward to the outermost element (the panel).\n     * \n     * During the docking process, coordinates are allowed to be negative. We start with the\n     * body at (0,0) so items docked \"top\" or \"left\" will simply be assigned negative x/y. In\n     * the {@link #finishPositions} method these are corrected and framing is added. This way\n     * the correction is applied as a simple translation of delta x/y on all coordinates to\n     * bring the origin back to (0,0).\n     * @private\n     */\n    dockOutwardBegin: function (ownerContext, itemContext, item, axis) {\n        var pos = axis.begin,\n            sizeProp = axis.sizeProp,\n            dock, size;\n\n        if (axis.collapsed) {\n            axis.ignoreFrameBegin = axis.ignoreFrameEnd = true;\n        } else if (item.ignoreParentFrame) {\n            dock = item.dock;\n            pos -= ownerContext.borderInfo[dock] + ownerContext.paddingInfo[dock] +\n                   ownerContext.framingInfo[dock];\n\n            axis.ignoreFrameBegin = true;\n        }\n\n        if (!item.overlay) {\n            size = itemContext.getProp(sizeProp) + itemContext.getMarginInfo()[sizeProp];\n            pos -= size;\n            axis.begin = pos;\n        }\n\n        return pos;\n    },\n\n    /**\n     * Docks an item on a shrinkWrap axis at the \"end\". The \"end\" of the horizontal axis is\n     * \"right\" and the vertical is \"bottom\".\n     * @private\n     */\n    dockOutwardEnd: function (ownerContext, itemContext, item, axis) {\n        var pos = axis.end,\n            sizeProp = axis.sizeProp,\n            dock, size;\n\n        size = itemContext.getProp(sizeProp) + itemContext.getMarginInfo()[sizeProp];\n\n        if (axis.collapsed) {\n            axis.ignoreFrameBegin = axis.ignoreFrameEnd = true;\n        } else if (item.ignoreParentFrame) {\n            dock = item.dock;\n            pos += ownerContext.borderInfo[dock] + ownerContext.paddingInfo[dock] +\n                   ownerContext.framingInfo[dock];\n\n            axis.ignoreFrameEnd = true;\n        }\n\n        if (!item.overlay) {\n            axis.end = pos + size;\n            axis.dockedPixelsEnd += size;\n        }\n\n        return pos;\n    },\n\n    /**\n     * Docks an item that might stretch across an axis. This is done for dock \"top\" and\n     * \"bottom\" items on the horizontal axis and dock \"left\" and \"right\" on the vertical.\n     * @private\n     */\n    dockStretch: function (ownerContext, itemContext, item, axis) {\n        var dock = item.dock, // left/top/right/bottom (also used to index padding/border)\n            sizeProp = axis.sizeProp, // 'width' or 'height'\n            horizontal = dock == 'top' || dock == 'bottom',\n            offsets = itemContext.offsets,\n            border = ownerContext.borderInfo,\n            padding = ownerContext.paddingInfo,\n            endProp = horizontal ? 'right' : 'bottom',\n            startProp = horizontal ? 'left' : 'top',\n            pos = axis.begin + offsets[startProp],\n            margin, size, framing;\n\n        if (item.stretch !== false) {\n            size = axis.end - pos - offsets[endProp];\n\n            if (item.ignoreParentFrame) {\n                framing = ownerContext.framingInfo;\n                pos -= border[startProp] + padding[startProp] + framing[startProp];\n                size += border[sizeProp] + padding[sizeProp] + framing[sizeProp];\n            }\n\n            margin = itemContext.getMarginInfo();\n            size -= margin[sizeProp];\n\n            itemContext[axis.setSize](size);\n        }\n\n        return pos;\n    },\n\n    /**\n     * Finishes the calculation of an axis by determining its size. In non-shrink-wrap\n     * cases, this is also where we set the body size.\n     * @private\n     */\n    finishAxis: function (ownerContext, axis) {\n        var size = axis.end - axis.begin,\n            setSizeMethod = axis.setSize,\n            beginName = axis.dockBegin, // left or top\n            endName = axis.dockEnd, // right or bottom\n            border = ownerContext.borderInfo,\n            padding = ownerContext.paddingInfo,\n            framing = ownerContext.framingInfo,\n            frameSize = padding[beginName] + border[beginName] + framing[beginName],\n            bodyContext = ownerContext.bodyContext,\n            bodyPos, bodySize, dirty;\n\n        if (axis.shrinkWrap) {\n            // Since items docked left/top on a shrinkWrap axis go into negative coordinates,\n            // we apply a delta to all coordinates to adjust their relative origin back to\n            // (0,0).\n            axis.delta = -axis.begin;  // either 0 or a positive number\n\n            bodySize = axis.initialSize;\n\n            if (axis.ignoreFrameBegin) {\n                axis.delta -= border[beginName];\n                bodyPos = -axis.begin - frameSize;\n            } else {\n                size += frameSize;\n                axis.delta += padding[beginName] + framing[beginName];\n                bodyPos = -axis.begin;\n            }\n\n            if (!axis.ignoreFrameEnd) {\n                size += padding[endName] + border[endName] + framing[endName];\n            }\n\n            axis.size = size; // we have to wait for min/maxWidth/Height processing\n\n            if (!axis.horizontal && !this.owner.manageHeight) {\n                // the height of the bodyEl will give the proper height to the outerEl so\n                // we don't need to set heights in the DOM\n                dirty = false;\n            }\n        } else {\n            // For a fixed-size axis, we started at the outer box and already have the\n            // proper origin... almost... except for the owner's border.\n            axis.delta = -border[axis.dockBegin]; // 'left' or 'top'\n\n            // Body size is remaining space between ends of Axis.\n            bodySize = size;\n            bodyPos = axis.begin - frameSize;\n        }\n\n        bodyContext[setSizeMethod](bodySize, dirty);\n        bodyContext.setProp(axis.bodyPosProp, bodyPos);\n\n        return !isNaN(size);\n    },\n\n    /**\n     * Finishes processing of each axis by applying the min/max size constraints.\n     * @private\n     */\n    finishConstraints: function (ownerContext, horz, vert) {\n        var sizeModels = this.sizeModels,\n            publishWidth = horz.shrinkWrap,\n            publishHeight = vert.shrinkWrap,\n            dirty, height, width, heightModel, widthModel, size;\n\n        if (publishWidth) {\n            size = horz.size;\n\n            if (size < horz.minSize) {\n                widthModel = sizeModels.constrainedMin;\n                width = horz.minSize;\n            } else if (size > horz.maxSize) {\n                widthModel = sizeModels.constrainedMax;\n                width = horz.maxSize;\n            } else {\n                width = size;\n            }\n        }\n\n        if (publishHeight) {\n            size = vert.size;\n\n            if (size < vert.minSize) {\n                heightModel = sizeModels.constrainedMin;\n                height = vert.minSize;\n            } else if (size > vert.maxSize) {\n                heightModel = sizeModels.constrainedMax;\n                height = vert.maxSize;\n            } else {\n                if (!ownerContext.collapsedVert && !this.owner.manageHeight) {\n                    // height of the outerEl is provided by the height (including margins)\n                    // of the bodyEl, so this value does not need to be written to the DOM\n                    dirty = false;\n\n                    // so long as we set top and bottom margins on the bodyEl!\n                    ownerContext.bodyContext.setProp('margin-bottom', vert.dockedPixelsEnd);\n                }\n\n                height = size;\n            }\n        }\n\n        // Handle the constraints...\n\n        if (widthModel || heightModel) {\n            // See ContextItem#init for an analysis of why this case is special. Basically,\n            // in this case, we only know the width and the height could be anything.\n            if (widthModel && heightModel &&\n                        widthModel.constrainedMax &&  heightModel.constrainedMin) {\n                ownerContext.invalidate({ widthModel: widthModel });\n                return false;\n            }\n\n            // To process a width or height other than that to which we have shrinkWrapped,\n            // we need to invalidate our component and carry forward w/these constrains...\n            // unless the ownerLayout wants these results and will invalidate us anyway.\n            if (!ownerContext.widthModel.calculatedFromShrinkWrap &&\n                        !ownerContext.heightModel.calculatedFromShrinkWrap) {\n                // nope, just us to handle the constraint...\n                ownerContext.invalidate({ widthModel: widthModel, heightModel: heightModel });\n                return false;\n            }\n\n            // We have a constraint to deal with, so we just adjust the size models and\n            // allow the ownerLayout to invalidate us with its contribution to our final\n            // size...\n        }\n\n        // we only publish the sizes if we are not invalidating the result...\n\n        if (publishWidth) {\n            ownerContext.setWidth(width);\n            if (widthModel) {\n                ownerContext.widthModel = widthModel; // important to the ownerLayout\n            }\n        }\n        if (publishHeight) {\n            ownerContext.setHeight(height, dirty);\n            if (heightModel) {\n                ownerContext.heightModel = heightModel; // important to the ownerLayout\n            }\n        }\n\n        return true;\n    },\n\n    /**\n     * Finishes the calculation by setting positions on the body and all of the items.\n     * @private\n     */\n    finishPositions: function (ownerContext, horz, vert) {\n        var dockedItems = ownerContext.dockedItems,\n            length = dockedItems.length,\n            deltaX = horz.delta,\n            deltaY = vert.delta,\n            index, itemContext;\n\n        for (index = 0; index < length; ++index) {\n            itemContext = dockedItems[index];\n\n            itemContext.setProp('x', deltaX + itemContext.dockedAt.x);\n            itemContext.setProp('y', deltaY + itemContext.dockedAt.y);\n        }\n    },\n\n    finishedLayout: function(ownerContext) {\n        var me = this,\n            target = ownerContext.target;\n\n        me.callParent(arguments);\n\n        if (!ownerContext.animatePolicy) {\n            if (ownerContext.isCollapsingOrExpanding === 1) {\n                target.afterCollapse(false);\n            } else if (ownerContext.isCollapsingOrExpanding === 2) {\n                target.afterExpand(false);\n            }\n        }\n    },\n\n    getAnimatePolicy: function(ownerContext) {\n        var me = this,\n            lastCollapsedState, policy;\n\n        if (ownerContext.isCollapsingOrExpanding == 1) {\n            lastCollapsedState = me.lastCollapsedState;\n        } else if (ownerContext.isCollapsingOrExpanding == 2) {\n            lastCollapsedState = ownerContext.lastCollapsedState;\n        }\n\n        if (lastCollapsedState == 'left' || lastCollapsedState == 'right') {\n            policy = me.horizontalCollapsePolicy;\n        } else if (lastCollapsedState == 'top' || lastCollapsedState == 'bottom') {\n            policy = me.verticalCollapsePolicy;\n        }\n\n        return policy;\n    },\n\n    /**\n     * Retrieve an ordered and/or filtered array of all docked Components.\n     * @param {String} [order='render'] The desired ordering of the items ('render' or 'visual').\n     * @param {Boolean} [beforeBody] An optional flag to limit the set of items to only those\n     *  before the body (true) or after the body (false). All components are returned by\n     *  default.\n     * @return {Ext.Component[]} An array of components.\n     * @protected\n     */\n    getDockedItems: function(order, beforeBody) {\n        var me = this,\n            renderedOnly = (order === 'visual'),\n            all = renderedOnly ? Ext.ComponentQuery.query('[rendered]', me.owner.dockedItems.items) : me.owner.dockedItems.items,\n            sort = all && all.length && order !== false,\n            renderOrder,\n            dock, dockedItems, i, isBefore, length;\n\n        if (beforeBody == null) {\n            dockedItems = sort && !renderedOnly ? all.slice() : all;\n        } else {\n            dockedItems = [];\n\n            for (i = 0, length = all.length; i < length; ++i) {\n                dock = all[i].dock;\n                isBefore = (dock == 'top' || dock == 'left');\n                if (beforeBody ? isBefore : !isBefore) {\n                    dockedItems.push(all[i]);\n                }\n            }\n\n            sort = sort && dockedItems.length;\n        }\n\n        if (sort) {\n            renderOrder = (order = order || 'render') == 'render';\n            Ext.Array.sort(dockedItems, function(a, b) {\n                var aw,\n                    bw;\n\n                // If the two items are on opposite sides of the body, they must not be sorted by any weight value:\n                // For rendering purposes, left/top *always* sorts before right/bottom\n                if (renderOrder && ((aw = me.owner.dockOrder[a.dock]) !== (bw = me.owner.dockOrder[b.dock]))) {\n\n                    // The two dockOrder values cancel out when two items are on opposite sides.\n                    if (!(aw + bw)) {\n                        return aw - bw;\n                    }\n                }\n\n                aw = me.getItemWeight(a, order);\n                bw = me.getItemWeight(b, order);\n                if ((aw !== undefined) && (bw !== undefined)) {\n                    return aw - bw;\n                }\n                return 0;\n            });\n        }\n\n        return dockedItems || [];\n    },\n\n    getItemWeight: function (item, order) {\n        var weight = item.weight || this.owner.defaultDockWeights[item.dock];\n        return weight[order] || weight;\n    },\n\n    /**\n     * @protected\n     * Returns an array containing all the **visible** docked items inside this layout's owner Panel\n     * @return {Array} An array containing all the **visible** docked items of the Panel\n     */\n    getLayoutItems : function() {\n        var me = this,\n            items,\n            itemCount,\n            item,\n            i,\n            result;\n\n        if (me.owner.collapsed) {\n            result = me.owner.getCollapsedDockedItems();\n        } else {\n            items = me.getDockedItems('visual');\n            itemCount = items.length;\n            result = [];\n            for (i = 0; i < itemCount; i++) {\n                item = items[i];\n                if (!item.hidden) {\n                    result.push(item);\n                }\n            }\n        }\n        return result;\n    },\n\n    // Content size includes padding but not borders, so subtract them off\n    measureContentWidth: function (ownerContext) {\n        var bodyContext = ownerContext.bodyContext;\n        return bodyContext.el.getWidth() - bodyContext.getBorderInfo().width;\n    },\n\n    measureContentHeight: function (ownerContext) {\n        var bodyContext = ownerContext.bodyContext;\n        return bodyContext.el.getHeight() - bodyContext.getBorderInfo().height;\n    },\n    \n    redoLayout: function(ownerContext) {\n        var me = this,\n            owner = me.owner;\n        \n        // If we are collapsing...\n        if (ownerContext.isCollapsingOrExpanding == 1) {\n            if (owner.reExpander) {\n                owner.reExpander.el.show();\n            }\n            // Add the collapsed class now, so that collapsed CSS rules are applied before measurements are taken by the layout.\n            owner.addClsWithUI(owner.collapsedCls);\n            ownerContext.redo(true);\n        } else if (ownerContext.isCollapsingOrExpanding == 2) {\n            // Remove the collapsed class now, before layout calculations are done.\n            owner.removeClsWithUI(owner.collapsedCls);\n            ownerContext.bodyContext.redo();\n        } \n    },\n\n    // @private override inherited.\n    // We need to render in the correct order, top/left before bottom/right\n    renderChildren: function() {\n        var me = this,\n            items = me.getDockedItems(),\n            target = me.getRenderTarget();\n\n        me.renderItems(items, target);\n    },\n\n    /**\n     * @protected\n     * Render the top and left docked items before any existing DOM nodes in our render target,\n     * and then render the right and bottom docked items after. This is important, for such things\n     * as tab stops and ARIA readers, that the DOM nodes are in a meaningful order.\n     * Our collection of docked items will already be ordered via Panel.getDockedItems().\n     */\n    renderItems: function(items, target) {\n        var me = this,\n            dockedItemCount = items.length,\n            itemIndex = 0,\n            correctPosition = 0,\n            staticNodeCount = 0,\n            targetNodes = me.getRenderTarget().dom.childNodes,\n            targetChildCount = targetNodes.length,\n            i, j, targetChildNode, item;\n\n        // Calculate the number of DOM nodes in our target that are not our docked items\n        for (i = 0, j = 0; i < targetChildCount; i++) {\n            targetChildNode = targetNodes[i];\n            if (Ext.fly(targetChildNode).hasCls('x-resizable-handle')) {\n                break;\n            }\n            for (j = 0; j < dockedItemCount; j++) {\n                item = items[j];\n                if (item.rendered && item.el.dom === targetChildNode) {\n                    break;\n                }\n            }\n            // Walked off the end of the docked items without matching the found child node;\n            // Then it's a static node.\n            if (j === dockedItemCount) {\n                staticNodeCount++;\n            }\n        }\n\n        // Now we go through our docked items and render/move them\n        for (; itemIndex < dockedItemCount; itemIndex++, correctPosition++) {\n            item = items[itemIndex];\n\n            // If we're now at the first right/bottom docked item, we jump over the body element.\n            //\n            // TODO: This is affected if users provide custom weight values to their\n            // docked items, which puts it out of (t,l,r,b) order. Avoiding a second\n            // sort operation here, for now, in the name of performance. getDockedItems()\n            // needs the sort operation not just for this layout-time rendering, but\n            // also for getRefItems() to return a logical ordering (FocusManager, CQ, et al).\n            if (itemIndex === correctPosition && (item.dock === 'right' || item.dock === 'bottom')) {\n                correctPosition += staticNodeCount;\n            }\n\n            // Same logic as Layout.renderItems()\n            if (item && !item.rendered) {\n                me.renderItem(item, target, correctPosition);\n            }\n            else if (!me.isValidParent(item, target, correctPosition)) {\n                me.moveItem(item, target, correctPosition);\n            }\n        }\n    },\n\n    undoLayout: function(ownerContext) {\n        var me = this,\n            owner = me.owner;\n        \n        // If we are collapsing...\n        if (ownerContext.isCollapsingOrExpanding == 1) {\n\n            // We do not want to see the re-expander header until the final collapse is complete\n            if (owner.reExpander) {\n                owner.reExpander.el.hide();\n            }\n            // Add the collapsed class now, so that collapsed CSS rules are applied before measurements are taken by the layout.\n            owner.removeClsWithUI(owner.collapsedCls);\n            ownerContext.undo(true);\n        } else if (ownerContext.isCollapsingOrExpanding == 2) {\n            // Remove the collapsed class now, before layout calculations are done.\n            owner.addClsWithUI(owner.collapsedCls);\n            ownerContext.bodyContext.undo();\n        } \n    },\n\n    sizePolicy: {\n        nostretch: {\n            setsWidth: 0,\n            setsHeight: 0\n        },\n        stretchH: {\n            setsWidth: 1,\n            setsHeight: 0\n        },\n        stretchV: {\n            setsWidth: 0,\n            setsHeight: 1\n        },\n\n        // Circular dependency with partial auto-sized panels:\n        //\n        // If we have an autoHeight docked item being stretched horizontally (top/bottom),\n        // that stretching will determine its width and its width must be set before its\n        // autoHeight can be determined. If that item is docked in an autoWidth panel, the\n        // body will need its height set before it can determine its width, but the height\n        // of the docked item is needed to subtract from the panel height in order to set\n        // the body height.\n        //\n        // This same pattern occurs with autoHeight panels with autoWidth docked items on\n        // left or right. If the panel is fully auto or fully fixed, these problems don't\n        // come up because there is no dependency between the dimensions.\n        //\n        // Cutting the Gordian Knot: In these cases, we have to allow something to measure\n        // itself without full context. This is OK as long as the managed dimension doesn't\n        // effect the auto-dimension, which is often the case for things like toolbars. The\n        // managed dimension only effects overflow handlers and such and does not change the\n        // auto-dimension. To encourage the item to measure itself without waiting for the\n        // managed dimension, we have to tell it that the layout will also be reading that\n        // dimension. This is similar to how stretchmax works.\n\n        autoStretchH: {\n            readsWidth: 1,\n            setsWidth: 1,\n            setsHeight: 0\n        },\n        autoStretchV: {\n            readsHeight: 1,\n            setsWidth: 0,\n            setsHeight: 1\n        }\n    },\n\n    getItemSizePolicy: function (item) {\n        var policy = this.sizePolicy,\n            dock, vertical;\n\n        if (item.stretch === false) {\n            return policy.nostretch;\n        }\n\n        dock = item.dock;\n        vertical = (dock == 'left' || dock == 'right');\n\n        /*\n        owner = this.owner;\n        autoWidth = !owner.isFixedWidth();\n        autoHeight = !owner.isFixedHeight();\n        if (autoWidth !== autoHeight) { // if (partial auto)\n            // see above...\n            if (vertical) {\n                if (autoHeight) {\n                    return policy.autoStretchV;\n                }\n            } else if (autoWidth) {\n                return policy.autoStretchH;\n            }\n        }*/\n\n        if (vertical) {\n            return policy.stretchV;\n        }\n\n        return policy.stretchH;\n    },\n\n    /**\n     * @protected\n     * We are overriding the Ext.layout.Layout configureItem method to also add a class that\n     * indicates the position of the docked item. We use the itemCls (x-docked) as a prefix.\n     * An example of a class added to a dock: right item is x-docked-right\n     * @param {Ext.Component} item The item we are configuring\n     */\n    configureItem : function(item, pos) {\n        this.callParent(arguments);\n\n        item.addCls(Ext.baseCSSPrefix + 'docked');\n        item.addClsWithUI('docked-' + item.dock);\n    },\n\n    afterRemove : function(item) {\n        this.callParent(arguments);\n        if (this.itemCls) {\n            item.el.removeCls(this.itemCls + '-' + item.dock);\n        }\n        var dom = item.el.dom;\n\n        if (!item.destroying && dom) {\n            dom.parentNode.removeChild(dom);\n        }\n        this.childrenChanged = true;\n    }\n});\n\n/**\n * A non-rendering placeholder item which instructs the Toolbar's Layout to begin using\n * the right-justified button container.\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *          title: 'Toolbar Fill Example',\n *          width: 300,\n *          height: 200,\n *          tbar : [\n *              'Item 1',\n *              { xtype: 'tbfill' },\n *              'Item 2'\n *          ],\n *          renderTo: Ext.getBody()\n *      });\n */\nExt.define('Ext.toolbar.Fill', {\n    extend: 'Ext.Component',\n    alias: 'widget.tbfill',\n    alternateClassName: 'Ext.Toolbar.Fill',\n    /**\n     * @property {Boolean} isFill\n     * `true` in this class to identify an object as an instantiated Fill, or subclass thereof.\n     */\n    isFill : true,\n    flex: 1\n});\n\n/**\n * @private\n * Base class for Box Layout overflow handlers. These specialized classes are invoked when a Box Layout\n * (either an HBox or a VBox) has child items that are either too wide (for HBox) or too tall (for VBox)\n * for its container.\n */\nExt.define('Ext.layout.container.boxOverflow.None', {\n    alternateClassName: 'Ext.layout.boxOverflow.None',\n    \n    constructor: function(layout, config) {\n        this.layout = layout;\n        Ext.apply(this, config);\n    },\n\n    handleOverflow: Ext.emptyFn,\n\n    clearOverflow: Ext.emptyFn,\n\n    beginLayout: Ext.emptyFn,\n    beginLayoutCycle: Ext.emptyFn,\n    finishedLayout: Ext.emptyFn,\n\n    completeLayout: function (ownerContext) {\n        var me = this,\n            plan = ownerContext.state.boxPlan,\n            overflow;\n\n        if (plan && plan.tooNarrow) {\n            overflow = me.handleOverflow(ownerContext);\n\n            if (overflow) {\n                if (overflow.reservedSpace) {\n                    me.layout.publishInnerCtSize(ownerContext, overflow.reservedSpace);\n                }\n\n                // TODO: If we need to use the code below then we will need to pass along\n                // the new targetSize as state and use it calculate somehow...\n                //\n                //if (overflow.recalculate) {\n                //    ownerContext.invalidate({\n                //        state: {\n                //            overflow: overflow\n                //        }\n                //    });\n                //}\n            }\n        } else {\n            me.clearOverflow();\n        }\n    },\n\n    onRemove: Ext.emptyFn,\n\n    /**\n     * @private\n     * Normalizes an item reference, string id or numerical index into a reference to the item\n     * @param {Ext.Component/String/Number} item The item reference, id or index\n     * @return {Ext.Component} The item\n     */\n    getItem: function(item) {\n        return this.layout.owner.getComponent(item);\n    },\n    \n    getOwnerType: function(owner){\n        var type;\n        if (owner.isToolbar) {\n            type = 'toolbar';\n        } else if (owner.isTabBar) {\n            type = 'tabbar';\n        } else if (owner.isMenu) {\n            type = 'menu';\n        } else {\n            type = owner.getXType();\n        }\n        \n        return type;\n    },\n\n    getPrefixConfig: Ext.emptyFn,\n    getSuffixConfig: Ext.emptyFn,\n    getOverflowCls: function() {\n        return '';\n    }\n});\n\n/**\n * The base class that other non-interacting Toolbar Item classes should extend in order to\n * get some basic common toolbar item functionality.\n */\nExt.define('Ext.toolbar.Item', {\n    extend: 'Ext.Component',\n    alias: 'widget.tbitem',\n    alternateClassName: 'Ext.Toolbar.Item',\n    enable:Ext.emptyFn,\n    disable:Ext.emptyFn,\n    focus:Ext.emptyFn\n    /**\n     * @cfg {String} overflowText\n     * Text to be used for the menu if the item is overflowed.\n     */\n});\n\n/**\n * A simple class that adds a vertical separator bar between toolbar items (css class: 'x-toolbar-separator').\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Toolbar Separator Example',\n *         width: 300,\n *         height: 200,\n *         tbar : [\n *             'Item 1',\n *             { xtype: 'tbseparator' },\n *             'Item 2'\n *         ],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.toolbar.Separator', {\n    extend: 'Ext.toolbar.Item',\n    alias: 'widget.tbseparator',\n    alternateClassName: 'Ext.Toolbar.Separator',\n    baseCls: Ext.baseCSSPrefix + 'toolbar-separator',\n    focusable: false,\n    // Force border: true so container border is not set on this\n    border: true\n});\n\n/**\n * Component layout for buttons\n * @private\n */\nExt.define('Ext.layout.component.Button', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.button'],\n\n    extend: 'Ext.layout.component.Auto',\n\n    /* End Definitions */\n\n    type: 'button',\n\n    cellClsRE: /-btn-(tl|br)\\b/,\n    htmlRE: /<.*>/,\n\n    constructor: function () {\n        this.callParent(arguments);\n\n        this.hackWidth = Ext.isIE && (!Ext.isStrict || Ext.isIE6 || Ext.isIE7 || Ext.isIE8);\n        this.heightIncludesPadding = Ext.isIE6 && Ext.isStrict;\n    },\n\n    // TODO - use last run results if text has not changed?\n\n    beginLayout: function (ownerContext) {\n        this.callParent(arguments);\n\n        this.cacheTargetInfo(ownerContext);\n    },\n\n    beginLayoutCycle: function(ownerContext) {\n        var me = this,\n            empty = '',\n            owner = me.owner,\n            btnEl = owner.btnEl,\n            btnInnerEl = owner.btnInnerEl,\n            text = owner.text,\n            htmlAutoHeight;\n\n        me.callParent(arguments);\n\n        btnInnerEl.setStyle('overflow', empty);\n\n        // Clear all element widths\n        if (!ownerContext.widthModel.natural) {\n            owner.el.setStyle('width', empty);\n        }\n\n        // If the text is HTML we need to let the browser automatically size things to cope with the case where the text\n        // is multi-line. This incurs a cost as we then have to measure those elements to derive other sizes\n        htmlAutoHeight = ownerContext.heightModel.shrinkWrap && text && me.htmlRE.test(text);\n\n        btnEl.setStyle('width', empty);\n        btnEl.setStyle('height', htmlAutoHeight ? 'auto' : empty);\n        btnInnerEl.setStyle('width', empty);\n        btnInnerEl.setStyle('height', htmlAutoHeight ? 'auto' : empty);\n        btnInnerEl.setStyle('line-height', htmlAutoHeight ? 'normal' : empty);\n        btnInnerEl.setStyle('padding-top', empty);\n        owner.btnIconEl.setStyle('width', empty);\n    },\n\n    calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {\n        return contentHeight;\n    },\n\n    calculateOwnerWidthFromContentWidth: function (ownerContext, contentWidth) {\n        return contentWidth;\n    },\n\n    measureContentWidth: function (ownerContext) {\n        var me = this,\n            owner = me.owner,\n            btnEl = owner.btnEl,\n            btnInnerEl = owner.btnInnerEl,\n            text = owner.text,\n            btnFrameWidth, metrics, sizeIconEl, width, btnElContext, btnInnerElContext;\n\n        // IE suffers from various sizing problems, usually caused by relying on it to size elements automatically. Even\n        // if an element is sized correctly it can prove necessary to set that size explicitly on the element to get it\n        // to size and position its children correctly. While the exact nature of the problems varies depending on the\n        // browser version, doctype and button configuration there is a common solution: set the sizes manually.\n        if (owner.text && me.hackWidth && btnEl) {\n            btnFrameWidth = me.btnFrameWidth;\n\n            // If the button text is something like '<' or '<<' then we need to escape it or it won't be measured\n            // correctly. The button text is supposed to be HTML and strictly speaking '<' and '<<' aren't valid HTML.\n            // However in practice they are commonly used and have worked 'correctly' in previous versions.\n            if (text.indexOf('>') === -1) {\n                text = text.replace(/</g, '&lt;');\n            }\n\n            metrics = Ext.util.TextMetrics.measure(btnInnerEl, text);\n\n            width = metrics.width + btnFrameWidth + me.adjWidth;\n\n            btnElContext = ownerContext.getEl('btnEl');\n            btnInnerElContext = ownerContext.getEl('btnInnerEl');\n            sizeIconEl = (owner.icon || owner.iconCls) && \n                    (owner.iconAlign == \"top\" || owner.iconAlign == \"bottom\");\n\n            // This cheat works (barely) with publishOwnerWidth which calls setProp also\n            // to publish the width. Since it is the same value we set here, the dirty bit\n            // we set true will not be cleared by publishOwnerWidth.\n            ownerContext.setWidth(width); // not setWidth (no framing)\n\n            btnElContext.setWidth(metrics.width + btnFrameWidth);\n            btnInnerElContext.setWidth(metrics.width + btnFrameWidth);\n\n            if (sizeIconEl) {\n                owner.btnIconEl.setWidth(metrics.width + btnFrameWidth);\n            }\n        } else {\n            width = ownerContext.el.getWidth();\n        }\n\n        return width;\n    },\n\n    measureContentHeight: function (ownerContext) {\n        var me = this,\n            owner = me.owner,\n            btnInnerEl = owner.btnInnerEl,\n            btnItem = ownerContext.getEl('btnEl'),\n            btnInnerItem = ownerContext.getEl('btnInnerEl'),\n            minTextHeight = me.minTextHeight,\n            adjHeight = me.adjHeight,\n            text = owner.getText(),\n            height,\n            textHeight,\n            topPadding;\n\n        if (owner.vertical) {\n            height = Ext.util.TextMetrics.measure(btnInnerEl, owner.text).width;\n            height += me.btnFrameHeight + adjHeight;\n\n            // Vertical buttons need height explicitly set\n            ownerContext.setHeight(height, /*dirty=*/true, /*force=*/true);\n        }\n        else {\n            // If the button text is HTML we have to handle it specially as it could contain multiple lines\n            if (text && me.htmlRE.test(text)) {\n                textHeight = btnInnerEl.getHeight();\n\n                // HTML content doesn't guarantee multiple lines: in the single line case it could now be too short for the icon\n                if (textHeight < minTextHeight) {\n                    topPadding = Math.floor((minTextHeight - textHeight) / 2);\n\n                    // Resize the span and use padding to center the text vertically. The hack to remove the padding\n                    // from the height on IE6 is especially needed for link buttons\n                    btnInnerItem.setHeight(minTextHeight - (me.heightIncludesPadding ? topPadding : 0));\n                    btnInnerItem.setProp('padding-top', topPadding);\n\n                    textHeight = minTextHeight;\n                }\n\n                // Calculate the height relative to the text span, auto can't be trusted in IE quirks\n                height = textHeight + adjHeight;\n            }\n            else {\n                height = ownerContext.el.getHeight();\n            }\n        }\n\n        // IE quirks needs the button height setting using style or it won't position the icon correctly (even if the height was already correct)\n        btnItem.setHeight(height - adjHeight);\n\n        return height;\n    },\n\n    publishInnerHeight: function(ownerContext, height) {\n        var me = this,\n            owner = me.owner,\n            isNum = Ext.isNumber,\n            btnItem = ownerContext.getEl('btnEl'),\n            btnInnerEl = owner.btnInnerEl,\n            btnInnerItem = ownerContext.getEl('btnInnerEl'),\n            btnHeight = isNum(height) ? height - me.adjHeight : height,\n            btnFrameHeight = me.btnFrameHeight,\n            text = owner.getText(),\n            textHeight,\n            paddingTop;\n\n        btnItem.setHeight(btnHeight);\n        btnInnerItem.setHeight(btnHeight);\n\n        // Only need the line-height setting for regular, horizontal Buttons\n        if (!owner.vertical && btnHeight >= 0) {\n            btnInnerItem.setProp('line-height', btnHeight - btnFrameHeight + 'px');\n        }\n\n        // Button text may contain markup that would force it to wrap to more than one line (e.g. 'Button<br>Label').\n        // When this happens, we cannot use the line-height set above for vertical centering; we instead reset the\n        // line-height to normal, measure the rendered text height, and add padding-top to center the text block\n        // vertically within the button's height. This is more expensive than the basic line-height approach so\n        // we only do it if the text contains markup.\n        if (text && me.htmlRE.test(text)) {\n            btnInnerItem.setProp('line-height', 'normal');\n            btnInnerEl.setStyle('line-height', 'normal');\n            textHeight = Ext.util.TextMetrics.measure(btnInnerEl, text).height;\n            paddingTop = Math.floor(Math.max(btnHeight - btnFrameHeight - textHeight, 0) / 2);\n            btnInnerItem.setProp('padding-top', me.btnFrameTop + paddingTop);\n            btnInnerItem.setHeight(btnHeight - (me.heightIncludesPadding ? paddingTop : 0));\n        }\n    },\n\n    publishInnerWidth: function(ownerContext, width) {\n        var me = this,\n            isNum = Ext.isNumber,\n            btnItem = ownerContext.getEl('btnEl'),\n            btnInnerItem = ownerContext.getEl('btnInnerEl'),\n            btnWidth = isNum(width) ? width - me.adjWidth : width;\n\n        btnItem.setWidth(btnWidth);\n        btnInnerItem.setWidth(btnWidth);\n    },\n    \n    clearTargetCache: function(){\n        delete this.adjWidth;    \n    },\n\n    cacheTargetInfo: function(ownerContext) {\n        var me = this,\n            owner = me.owner,\n            scale = owner.scale,\n            padding, frameSize, btnWrapPadding, btnInnerEl, innerFrameSize;\n\n        // The cache is only valid for a particular scale\n        if (!('adjWidth' in me) || me.lastScale !== scale) {\n            // If there has been a previous layout run it could have sullied the line-height\n            if (me.lastScale) {\n                owner.btnInnerEl.setStyle('line-height', '');\n            }\n\n            me.lastScale = scale;\n\n            padding = ownerContext.getPaddingInfo();\n            frameSize = ownerContext.getFrameInfo();\n            btnWrapPadding = ownerContext.getEl('btnWrap').getPaddingInfo();\n            btnInnerEl = ownerContext.getEl('btnInnerEl');\n            innerFrameSize = btnInnerEl.getPaddingInfo();\n\n            Ext.apply(me, {\n                // Width adjustment must take into account the arrow area. The btnWrap is the <em> which has padding to accommodate the arrow.\n                adjWidth       : btnWrapPadding.width + frameSize.width + padding.width,\n                adjHeight      : btnWrapPadding.height + frameSize.height + padding.height,\n                btnFrameWidth  : innerFrameSize.width,\n                btnFrameHeight : innerFrameSize.height,\n                btnFrameTop    : innerFrameSize.top,\n\n                // Use the line-height rather than height because if the text is multi-line then the height will be 'wrong'\n                minTextHeight  : parseInt(btnInnerEl.getStyle('line-height'), 10)\n            });\n        }\n\n        me.callParent(arguments);\n    },\n    \n    finishedLayout: function(){\n        var owner = this.owner;\n        this.callParent(arguments);\n        // Fixes issue EXTJSIV-5989. Looks like a browser repaint bug\n        // This hack can be removed once it is resolved.\n        if (Ext.isWebKit) {\n            owner.el.dom.offsetWidth;\n        }\n    }\n});\n\n/**\n * Provides a common registry of all menus on a page.\n * @singleton\n */\nExt.define('Ext.menu.Manager', {\n    singleton: true,\n    requires: [\n        'Ext.util.MixedCollection',\n        'Ext.util.KeyMap'\n    ],\n    alternateClassName: 'Ext.menu.MenuMgr',\n\n    uses: ['Ext.menu.Menu'],\n\n    menus: {},\n    groups: {},\n    attached: false,\n    lastShow: new Date(),\n\n    init: function() {\n        var me = this;\n        \n        me.active = new Ext.util.MixedCollection();\n        Ext.getDoc().addKeyListener(27, function() {\n            if (me.active.length > 0) {\n                me.hideAll();\n            }\n        }, me);\n    },\n\n    /**\n     * Hides all menus that are currently visible\n     * @return {Boolean} success True if any active menus were hidden.\n     */\n    hideAll: function() {\n        var active = this.active,\n        clone, menus, m, mLen;\n\n        if (active && active.length > 0) {\n            clone = active.clone();\n            menus = clone.items;\n            mLen  = menus.length;\n\n            for (m = 0; m < mLen; m++) {\n                menus[m].hide();\n            }\n\n            return true;\n        }\n        return false;\n    },\n\n    onHide: function(m) {\n        var me = this,\n            active = me.active;\n        active.remove(m);\n        if (active.length < 1) {\n            Ext.getDoc().un('mousedown', me.onMouseDown, me);\n            me.attached = false;\n        }\n    },\n\n    onShow: function(m) {\n        var me = this,\n            active   = me.active,\n            last     = active.last(),\n            attached = me.attached,\n            menuEl   = m.getEl(),\n            zIndex;\n\n        me.lastShow = new Date();\n        active.add(m);\n        if (!attached) {\n            Ext.getDoc().on('mousedown', me.onMouseDown, me, {\n                // On IE we have issues with the menu stealing focus at certain points\n                // during the head, so give it a short buffer\n                buffer: Ext.isIE ? 10 : undefined\n            });\n            me.attached = true;\n        }\n        m.toFront();\n    },\n\n    onBeforeHide: function(m) {\n        if (m.activeChild) {\n            m.activeChild.hide();\n        }\n        if (m.autoHideTimer) {\n            clearTimeout(m.autoHideTimer);\n            delete m.autoHideTimer;\n        }\n    },\n\n    onBeforeShow: function(m) {\n        var active = this.active,\n            parentMenu = m.parentMenu;\n            \n        active.remove(m);\n        if (!parentMenu && !m.allowOtherMenus) {\n            this.hideAll();\n        }\n        else if (parentMenu && parentMenu.activeChild && m != parentMenu.activeChild) {\n            parentMenu.activeChild.hide();\n        }\n    },\n\n    // private\n    onMouseDown: function(e) {\n        var me = this,\n            active = me.active,\n            lastShow = me.lastShow;\n\n        if (Ext.Date.getElapsed(lastShow) > 50 && active.length > 0 && !e.getTarget('.' + Ext.baseCSSPrefix + 'menu')) {\n            me.hideAll();\n        }\n    },\n\n    // private\n    register: function(menu) {\n        var me = this;\n\n        if (!me.active) {\n            me.init();\n        }\n\n        if (menu.floating) {\n            me.menus[menu.id] = menu;\n            menu.on({\n                beforehide: me.onBeforeHide,\n                hide: me.onHide,\n                beforeshow: me.onBeforeShow,\n                show: me.onShow,\n                scope: me\n            });\n        }\n    },\n\n    /**\n     * Returns a {@link Ext.menu.Menu} object\n     * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will\n     * be used to generate and return a new Menu this.\n     * @return {Ext.menu.Menu} The specified menu, or null if none are found\n     */\n    get: function(menu) {\n        var menus = this.menus;\n        \n        if (typeof menu == 'string') { // menu id\n            if (!menus) {  // not initialized, no menus to return\n                return null;\n            }\n            return menus[menu];\n        } else if (menu.isMenu) {  // menu instance\n            return menu;\n        } else if (Ext.isArray(menu)) { // array of menu items\n            return new Ext.menu.Menu({items:menu});\n        } else { // otherwise, must be a config\n            return Ext.ComponentManager.create(menu, 'menu');\n        }\n    },\n\n    // private\n    unregister: function(menu) {\n        var me = this,\n            menus = me.menus,\n            active = me.active;\n\n        delete menus[menu.id];\n        active.remove(menu);\n        menu.un({\n            beforehide: me.onBeforeHide,\n            hide: me.onHide,\n            beforeshow: me.onBeforeShow,\n            show: me.onShow,\n            scope: me\n        });\n    },\n\n    // private\n    registerCheckable: function(menuItem) {\n        var groups  = this.groups,\n            groupId = menuItem.group;\n\n        if (groupId) {\n            if (!groups[groupId]) {\n                groups[groupId] = [];\n            }\n\n            groups[groupId].push(menuItem);\n        }\n    },\n\n    // private\n    unregisterCheckable: function(menuItem) {\n        var groups  = this.groups,\n            groupId = menuItem.group;\n\n        if (groupId) {\n            Ext.Array.remove(groups[groupId], menuItem);\n        }\n    },\n\n    onCheckChange: function(menuItem, state) {\n        var groups  = this.groups,\n            groupId = menuItem.group,\n            i       = 0,\n            group, ln, curr;\n\n        if (groupId && state) {\n            group = groups[groupId];\n            ln = group.length;\n            for (; i < ln; i++) {\n                curr = group[i];\n                if (curr != menuItem) {\n                    curr.setChecked(false);\n                }\n            }\n        }\n    }\n});\n\n/**\n * A wrapper class which can be applied to any element. Fires a \"click\" event while the\n * mouse is pressed. The interval between firings may be specified in the config but\n * defaults to 20 milliseconds.\n *\n * Optionally, a CSS class may be applied to the element during the time it is pressed.\n */\nExt.define('Ext.util.ClickRepeater', {\n    extend: 'Ext.util.Observable',\n\n    /**\n     * Creates new ClickRepeater.\n     * @param {String/HTMLElement/Ext.Element} el The element or its ID to listen on\n     * @param {Object} [config] Config object.\n     */\n    constructor : function(el, config){\n        var me = this;\n\n        me.el = Ext.get(el);\n        me.el.unselectable();\n\n        Ext.apply(me, config);\n\n        me.callParent();\n\n        me.addEvents(\n        /**\n         * @event mousedown\n         * Fires when the mouse button is depressed.\n         * @param {Ext.util.ClickRepeater} this\n         * @param {Ext.EventObject} e\n         */\n        \"mousedown\",\n        /**\n         * @event click\n         * Fires on a specified interval during the time the element is pressed.\n         * @param {Ext.util.ClickRepeater} this\n         * @param {Ext.EventObject} e\n         */\n        \"click\",\n        /**\n         * @event mouseup\n         * Fires when the mouse key is released.\n         * @param {Ext.util.ClickRepeater} this\n         * @param {Ext.EventObject} e\n         */\n        \"mouseup\"\n        );\n\n        if(!me.disabled){\n            me.disabled = true;\n            me.enable();\n        }\n\n        // allow inline handler\n        if(me.handler){\n            me.on(\"click\", me.handler,  me.scope || me);\n        }\n    },\n\n    /**\n     * @cfg {String/HTMLElement/Ext.Element} el\n     * The element to act as a button.\n     */\n\n    /**\n     * @cfg {String} pressedCls\n     * A CSS class name to be applied to the element while pressed.\n     */\n\n    /**\n     * @cfg {Boolean} accelerate\n     * True if autorepeating should start slowly and accelerate.\n     * \"interval\" and \"delay\" are ignored.\n     */\n\n    /**\n     * @cfg {Number} interval\n     * The interval between firings of the \"click\" event (in milliseconds).\n     */\n    interval : 20,\n\n    /**\n     * @cfg {Number} delay\n     * The initial delay before the repeating event begins firing.\n     * Similar to an autorepeat key delay.\n     */\n    delay: 250,\n\n    /**\n     * @cfg {Boolean} preventDefault\n     * True to prevent the default click event\n     */\n    preventDefault : true,\n\n    /**\n     * @cfg {Boolean} stopDefault\n     * True to stop the default click event\n     */\n    stopDefault : false,\n\n    timer : 0,\n\n    /**\n     * Enables the repeater and allows events to fire.\n     */\n    enable: function(){\n        if(this.disabled){\n            this.el.on('mousedown', this.handleMouseDown, this);\n            // IE versions will detect clicks as in sequence as dblclicks\n            // if they happen in quick succession\n            if (Ext.isIE && !(Ext.isStrict && Ext.isIE9)){\n                this.el.on('dblclick', this.handleDblClick, this);\n            }\n            if(this.preventDefault || this.stopDefault){\n                this.el.on('click', this.eventOptions, this);\n            }\n        }\n        this.disabled = false;\n    },\n\n    /**\n     * Disables the repeater and stops events from firing.\n     */\n    disable: function(/* private */ force){\n        if(force || !this.disabled){\n            clearTimeout(this.timer);\n            if(this.pressedCls){\n                this.el.removeCls(this.pressedCls);\n            }\n            Ext.getDoc().un('mouseup', this.handleMouseUp, this);\n            this.el.removeAllListeners();\n        }\n        this.disabled = true;\n    },\n\n    /**\n     * Convenience function for setting disabled/enabled by boolean.\n     * @param {Boolean} disabled\n     */\n    setDisabled: function(disabled){\n        this[disabled ? 'disable' : 'enable']();\n    },\n\n    eventOptions: function(e){\n        if(this.preventDefault){\n            e.preventDefault();\n        }\n        if(this.stopDefault){\n            e.stopEvent();\n        }\n    },\n\n    // private\n    destroy : function() {\n        this.disable(true);\n        Ext.destroy(this.el);\n        this.clearListeners();\n    },\n\n    handleDblClick : function(e){\n        clearTimeout(this.timer);\n        this.el.blur();\n\n        this.fireEvent(\"mousedown\", this, e);\n        this.fireEvent(\"click\", this, e);\n    },\n\n    // private\n    handleMouseDown : function(e){\n        clearTimeout(this.timer);\n        this.el.blur();\n        if(this.pressedCls){\n            this.el.addCls(this.pressedCls);\n        }\n        this.mousedownTime = new Date();\n\n        Ext.getDoc().on(\"mouseup\", this.handleMouseUp, this);\n        this.el.on(\"mouseout\", this.handleMouseOut, this);\n\n        this.fireEvent(\"mousedown\", this, e);\n        this.fireEvent(\"click\", this, e);\n\n        // Do not honor delay or interval if acceleration wanted.\n        if (this.accelerate) {\n            this.delay = 400;\n        }\n\n        // Re-wrap the event object in a non-shared object, so it doesn't lose its context if\n        // the global shared EventObject gets a new Event put into it before the timer fires.\n        e = new Ext.EventObjectImpl(e);\n\n        this.timer =  Ext.defer(this.click, this.delay || this.interval, this, [e]);\n    },\n\n    // private\n    click : function(e){\n        this.fireEvent(\"click\", this, e);\n        this.timer =  Ext.defer(this.click, this.accelerate ?\n            this.easeOutExpo(Ext.Date.getElapsed(this.mousedownTime),\n                400,\n                -390,\n                12000) :\n            this.interval, this, [e]);\n    },\n\n    easeOutExpo : function (t, b, c, d) {\n        return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;\n    },\n\n    // private\n    handleMouseOut : function(){\n        clearTimeout(this.timer);\n        if(this.pressedCls){\n            this.el.removeCls(this.pressedCls);\n        }\n        this.el.on(\"mouseover\", this.handleMouseReturn, this);\n    },\n\n    // private\n    handleMouseReturn : function(){\n        this.el.un(\"mouseover\", this.handleMouseReturn, this);\n        if(this.pressedCls){\n            this.el.addCls(this.pressedCls);\n        }\n        this.click();\n    },\n\n    // private\n    handleMouseUp : function(e){\n        clearTimeout(this.timer);\n        this.el.un(\"mouseover\", this.handleMouseReturn, this);\n        this.el.un(\"mouseout\", this.handleMouseOut, this);\n        Ext.getDoc().un(\"mouseup\", this.handleMouseUp, this);\n        if(this.pressedCls){\n            this.el.removeCls(this.pressedCls);\n        }\n        this.fireEvent(\"mouseup\", this, e);\n    }\n});\n\n/**\n * Provides precise pixel measurements for blocks of text so that you can determine exactly how high and\n * wide, in pixels, a given block of text will be. Note that when measuring text, it should be plain text and\n * should not contain any HTML, otherwise it may not be measured correctly.\n *\n * The measurement works by copying the relevant CSS styles that can affect the font related display, \n * then checking the size of an element that is auto-sized. Note that if the text is multi-lined, you must \n * provide a **fixed width** when doing the measurement.\n *\n * If multiple measurements are being done on the same element, you create a new instance to initialize \n * to avoid the overhead of copying the styles to the element repeatedly.\n */\nExt.define('Ext.util.TextMetrics', {\n    statics: {\n        shared: null,\n        /**\n         * Measures the size of the specified text\n         * @param {String/HTMLElement} el The element, dom node or id from which to copy existing CSS styles\n         * that can affect the size of the rendered text\n         * @param {String} text The text to measure\n         * @param {Number} fixedWidth (optional) If the text will be multiline, you have to set a fixed width\n         * in order to accurately measure the text height\n         * @return {Object} An object containing the text's size `{width: (width), height: (height)}`\n         * @static\n         */\n        measure: function(el, text, fixedWidth){\n            var me = this,\n                shared = me.shared;\n            \n            if(!shared){\n                shared = me.shared = new me(el, fixedWidth);\n            }\n            shared.bind(el);\n            shared.setFixedWidth(fixedWidth || 'auto');\n            return shared.getSize(text);\n        },\n        \n        /**\n         * Destroy the TextMetrics instance created by {@link #measure}.\n         * @static\n         */\n        destroy: function(){\n            var me = this;\n            Ext.destroy(me.shared);\n            me.shared = null;\n        }\n    },\n    \n    /**\n     * Creates new TextMetrics.\n     * @param {String/HTMLElement/Ext.Element} bindTo The element or its ID to bind to.\n     * @param {Number} [fixedWidth] A fixed width to apply to the measuring element.\n     */\n    constructor: function(bindTo, fixedWidth){\n        var measure = this.measure = Ext.getBody().createChild({\n            cls: Ext.baseCSSPrefix + 'textmetrics'\n        });\n        this.el = Ext.get(bindTo);\n        \n        measure.position('absolute');\n        measure.setLeftTop(-1000, -1000);\n        measure.hide();\n\n        if (fixedWidth) {\n           measure.setWidth(fixedWidth);\n        }\n    },\n    \n    /**\n     * Returns the size of the specified text based on the internal element's style and width properties\n     * @param {String} text The text to measure\n     * @return {Object} An object containing the text's size `{width: (width), height: (height)}`\n     */\n    getSize: function(text){\n        var measure = this.measure,\n            size;\n        \n        measure.update(text);\n        size = measure.getSize();\n        measure.update('');\n        return size;\n    },\n    \n    /**\n     * Binds this TextMetrics instance to a new element\n     * @param {String/HTMLElement/Ext.Element} el The element or its ID.\n     */\n    bind: function(el){\n        var me = this;\n        \n        me.el = Ext.get(el);\n        me.measure.setStyle(\n            me.el.getStyles('font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing')\n        );\n    },\n    \n    /**\n     * Sets a fixed width on the internal measurement element.  If the text will be multiline, you have\n     * to set a fixed width in order to accurately measure the text height.\n     * @param {Number} width The width to set on the element\n     */\n     setFixedWidth : function(width){\n         this.measure.setWidth(width);\n     },\n     \n     /**\n      * Returns the measured width of the specified text\n      * @param {String} text The text to measure\n      * @return {Number} width The width in pixels\n      */\n     getWidth : function(text){\n         this.measure.dom.style.width = 'auto';\n         return this.getSize(text).width;\n     },\n     \n     /**\n      * Returns the measured height of the specified text\n      * @param {String} text The text to measure\n      * @return {Number} height The height in pixels\n      */\n     getHeight : function(text){\n         return this.getSize(text).height;\n     },\n     \n     /**\n      * Destroy this instance\n      */\n     destroy: function(){\n         var me = this;\n         me.measure.remove();\n         delete me.el;\n         delete me.measure;\n     }\n}, function(){\n    Ext.Element.addMethods({\n        /**\n         * Returns the width in pixels of the passed text, or the width of the text in this Element.\n         * @param {String} text The text to measure. Defaults to the innerHTML of the element.\n         * @param {Number} [min] The minumum value to return.\n         * @param {Number} [max] The maximum value to return.\n         * @return {Number} The text width in pixels.\n         * @member Ext.dom.Element\n         */\n        getTextWidth : function(text, min, max){\n            return Ext.Number.constrain(Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width, min || 0, max || 1000000);\n        }\n    });\n});\n\n/**\n * @docauthor Robert Dougan <rob@sencha.com>\n *\n * Create simple buttons with this component. Customisations include {@link #iconAlign aligned}\n * {@link #iconCls icons}, {@link #cfg-menu dropdown menus}, {@link #tooltip tooltips}\n * and {@link #scale sizing options}. Specify a {@link #handler handler} to run code when\n * a user clicks the button, or use {@link #listeners listeners} for other events such as\n * {@link #mouseover mouseover}. Example usage:\n *\n *     @example\n *     Ext.create('Ext.Button', {\n *         text: 'Click me',\n *         renderTo: Ext.getBody(),\n *         handler: function() {\n *             alert('You clicked the button!');\n *         }\n *     });\n *\n * The {@link #handler} configuration can also be updated dynamically using the {@link #setHandler}\n * method.  Example usage:\n *\n *     @example\n *     Ext.create('Ext.Button', {\n *         text    : 'Dynamic Handler Button',\n *         renderTo: Ext.getBody(),\n *         handler : function() {\n *             // this button will spit out a different number every time you click it.\n *             // so firstly we must check if that number is already set:\n *             if (this.clickCount) {\n *                 // looks like the property is already set, so lets just add 1 to that number and alert the user\n *                 this.clickCount++;\n *                 alert('You have clicked the button \"' + this.clickCount + '\" times.\\n\\nTry clicking it again..');\n *             } else {\n *                 // if the clickCount property is not set, we will set it and alert the user\n *                 this.clickCount = 1;\n *                 alert('You just clicked the button for the first time!\\n\\nTry pressing it again..');\n *             }\n *         }\n *     });\n *\n * A button within a container:\n *\n *     @example\n *     Ext.create('Ext.Container', {\n *         renderTo: Ext.getBody(),\n *         items   : [\n *             {\n *                 xtype: 'button',\n *                 text : 'My Button'\n *             }\n *         ]\n *     });\n *\n * A useful option of Button is the {@link #scale} configuration. This configuration has three different options:\n *\n * - `'small'`\n * - `'medium'`\n * - `'large'`\n *\n * Example usage:\n *\n *     @example\n *     Ext.create('Ext.Button', {\n *         renderTo: document.body,\n *         text    : 'Click me',\n *         scale   : 'large'\n *     });\n *\n * Buttons can also be toggled. To enable this, you simple set the {@link #enableToggle} property to `true`.\n * Example usage:\n *\n *     @example\n *     Ext.create('Ext.Button', {\n *         renderTo: Ext.getBody(),\n *         text: 'Click Me',\n *         enableToggle: true\n *     });\n *\n * You can assign a menu to a button by using the {@link #cfg-menu} configuration. This standard configuration\n * can either be a reference to a {@link Ext.menu.Menu menu} object, a {@link Ext.menu.Menu menu} id or a\n * {@link Ext.menu.Menu menu} config blob. When assigning a menu to a button, an arrow is automatically\n * added to the button.  You can change the alignment of the arrow using the {@link #arrowAlign} configuration\n * on button.  Example usage:\n *\n *     @example\n *     Ext.create('Ext.Button', {\n *         text      : 'Menu button',\n *         renderTo  : Ext.getBody(),\n *         arrowAlign: 'bottom',\n *         menu      : [\n *             {text: 'Item 1'},\n *             {text: 'Item 2'},\n *             {text: 'Item 3'},\n *             {text: 'Item 4'}\n *         ]\n *     });\n *\n * Using listeners, you can easily listen to events fired by any component, using the {@link #listeners}\n * configuration or using the {@link #addListener} method.  Button has a variety of different listeners:\n *\n * - `click`\n * - `toggle`\n * - `mouseover`\n * - `mouseout`\n * - `mouseshow`\n * - `menuhide`\n * - `menutriggerover`\n * - `menutriggerout`\n *\n * Example usage:\n *\n *     @example\n *     Ext.create('Ext.Button', {\n *         text     : 'Button',\n *         renderTo : Ext.getBody(),\n *         listeners: {\n *             click: function() {\n *                 // this == the button, as we are in the local scope\n *                 this.setText('I was clicked!');\n *             },\n *             mouseover: function() {\n *                 // set a new config which says we moused over, if not already set\n *                 if (!this.mousedOver) {\n *                     this.mousedOver = true;\n *                     alert('You moused over a button!\\n\\nI wont do this again.');\n *                 }\n *             }\n *         }\n *     });\n */\nExt.define('Ext.button.Button', {\n\n    /* Begin Definitions */\n    alias: 'widget.button',\n    extend: 'Ext.Component',\n\n    requires: [\n        'Ext.menu.Manager',\n        'Ext.util.ClickRepeater',\n        'Ext.layout.component.Button',\n        'Ext.util.TextMetrics',\n        'Ext.util.KeyMap'\n    ],\n\n    alternateClassName: 'Ext.Button',\n    /* End Definitions */\n\n    /*\n     * @property {Boolean} isAction\n     * `true` in this class to identify an object as an instantiated Button, or subclass thereof.\n     */\n    isButton: true,\n    componentLayout: 'button',\n\n    /**\n     * @property {Boolean} hidden\n     * True if this button is hidden.\n     * @readonly\n     */\n    hidden: false,\n\n    /**\n     * @property {Boolean} disabled\n     * True if this button is disabled.\n     * @readonly\n     */\n    disabled: false,\n\n    /**\n     * @property {Boolean} pressed\n     * True if this button is pressed (only if enableToggle = true).\n     * @readonly\n     */\n    pressed: false,\n\n    /**\n     * @cfg {String} text\n     * The button text to be used as innerHTML (html tags are accepted).\n     */\n\n    /**\n     * @cfg {String} icon\n     * The path to an image to display in the button.\n     */\n\n    /**\n     * @cfg {Function} handler\n     * A function called when the button is clicked (can be used instead of click event).\n     * @cfg {Ext.button.Button} handler.button This button.\n     * @cfg {Ext.EventObject} handler.e The click event.\n     */\n\n    /**\n     * @cfg {Number} minWidth\n     * The minimum width for this button (used to give a set of buttons a common width).\n     * See also {@link Ext.panel.Panel}.{@link Ext.panel.Panel#minButtonWidth minButtonWidth}.\n     */\n\n    /**\n     * @cfg {String/Object} tooltip\n     * The tooltip for the button - can be a string to be used as innerHTML (html tags are accepted) or\n     * QuickTips config object.\n     */\n\n    /**\n     * @cfg {Boolean} [hidden=false]\n     * True to start hidden.\n     */\n\n    /**\n     * @cfg {Boolean} [disabled=false]\n     * True to start disabled.\n     */\n\n    /**\n     * @cfg {Boolean} [pressed=false]\n     * True to start pressed (only if enableToggle = true)\n     */\n\n    /**\n     * @cfg {String} toggleGroup\n     * The group this toggle button is a member of (only 1 per group can be pressed). If a toggleGroup\n     * is specified, the {@link #enableToggle} configuration will automatically be set to true.\n     */\n\n    /**\n     * @cfg {Boolean/Object} [repeat=false]\n     * True to repeat fire the click event while the mouse is down. This can also be a\n     * {@link Ext.util.ClickRepeater ClickRepeater} config object.\n     */\n\n    /**\n     * @cfg {Number} tabIndex\n     * Set a DOM tabIndex for this button.\n     */\n\n    /**\n     * @cfg {Boolean} [allowDepress=true]\n     * False to not allow a pressed Button to be depressed. Only valid when {@link #enableToggle} is true.\n     */\n\n    /**\n     * @cfg {Boolean} [enableToggle=false]\n     * True to enable pressed/not pressed toggling. If a {@link #toggleGroup} is specified, this\n     * option will be set to true.\n     */\n    enableToggle: false,\n\n    /**\n     * @cfg {Function} toggleHandler\n     * Function called when a Button with {@link #enableToggle} set to true is clicked.\n     * @cfg {Ext.button.Button} toggleHandler.button This button.\n     * @cfg {Boolean} toggleHandler.state The next state of the Button, true means pressed.\n     */\n\n    /**\n     * @cfg {Ext.menu.Menu/String/Object} menu\n     * Standard menu attribute consisting of a reference to a menu object, a menu id or a menu config blob.\n     */\n\n    /**\n     * @cfg {String} menuAlign\n     * The position to align the menu to (see {@link Ext.Element#alignTo} for more details).\n     */\n    menuAlign: 'tl-bl?',\n\n    /**\n     * @cfg {String} textAlign\n     * The text alignment for this button (center, left, right).\n     */\n    textAlign: 'center',\n\n    /**\n     * @cfg {String} overflowText\n     * If used in a {@link Ext.toolbar.Toolbar Toolbar}, the text to be used if this item is shown in the overflow menu.\n     * See also {@link Ext.toolbar.Item}.`{@link Ext.toolbar.Item#overflowText overflowText}`.\n     */\n\n    /**\n     * @cfg {String} iconCls\n     * A css class which sets a background image to be used as the icon for this button.\n     */\n\n    /**\n     * @cfg {String} type\n     * The type of `<input>` to create: submit, reset or button.\n     */\n    type: 'button',\n\n    /**\n     * @cfg {String} clickEvent\n     * The DOM event that will fire the handler of the button. This can be any valid event name (dblclick, contextmenu).\n     */\n    clickEvent: 'click',\n\n    /**\n     * @cfg {Boolean} preventDefault\n     * True to prevent the default action when the {@link #clickEvent} is processed.\n     */\n    preventDefault: true,\n\n    /**\n     * @cfg {Boolean} handleMouseEvents\n     * False to disable visual cues on mouseover, mouseout and mousedown.\n     */\n    handleMouseEvents: true,\n\n    /**\n     * @cfg {String} tooltipType\n     * The type of tooltip to use. Either 'qtip' for QuickTips or 'title' for title attribute.\n     */\n    tooltipType: 'qtip',\n\n    /**\n     * @cfg {String} [baseCls='x-btn']\n     * The base CSS class to add to all buttons.\n     */\n    baseCls: Ext.baseCSSPrefix + 'btn',\n\n    /**\n     * @cfg {String} pressedCls\n     * The CSS class to add to a button when it is in the pressed state.\n     */\n    pressedCls: 'pressed',\n\n    /**\n     * @cfg {String} overCls\n     * The CSS class to add to a button when it is in the over (hovered) state.\n     */\n    overCls: 'over',\n\n    /**\n     * @cfg {String} focusCls\n     * The CSS class to add to a button when it is in the focussed state.\n     */\n    focusCls: 'focus',\n\n    /**\n     * @cfg {String} menuActiveCls\n     * The CSS class to add to a button when it's menu is active.\n     */\n    menuActiveCls: 'menu-active',\n\n    /**\n     * @cfg {String} href\n     * The URL to open when the button is clicked. Specifying this config causes the Button to be\n     * rendered with an anchor (An `<a>` element) as its active element, referencing the specified URL.\n     *\n     * This is better than specifying a click handler of\n     *\n     *     function() { window.location = \"http://www.sencha.com\" }\n     *\n     * because the UI will provide meaningful hints to the user as to what to expect upon clicking\n     * the button, and will also allow the user to open in a new tab or window, bookmark or drag the URL, or directly save\n     * the URL stream to disk.\n     *\n     * See also the {@link #hrefTarget} config.\n     */\n    \n    /**\n      * @cfg {String} [hrefTarget=\"_blank\"]\n      * The target attribute to use for the underlying anchor. Only used if the {@link #href}\n      * property is specified.\n      */\n     hrefTarget: '_blank',\n     \n     border: true,\n\n    /**\n     * @cfg {Object} baseParams\n     * An object literal of parameters to pass to the url when the {@link #href} property is specified.\n     */\n\n    /**\n     * @cfg {Object} params\n     * An object literal of parameters to pass to the url when the {@link #href} property is specified. Any params\n     * override {@link #baseParams}. New params can be set using the {@link #setParams} method.\n     */\n\n    childEls: [\n        'btnEl', 'btnWrap', 'btnInnerEl', 'btnIconEl'\n    ],\n\n    renderTpl: [\n        '<em id=\"{id}-btnWrap\"<tpl if=\"splitCls\"> class=\"{splitCls}\"</tpl>>',\n            '<tpl if=\"href\">',\n                '<a id=\"{id}-btnEl\" href=\"{href}\" class=\"{btnCls}\" target=\"{hrefTarget}\"',\n                    '<tpl if=\"tabIndex\"> tabIndex=\"{tabIndex}\"</tpl>',\n                    '<tpl if=\"disabled\"> disabled=\"disabled\"</tpl>',\n                    ' role=\"link\">',\n                    '<span id=\"{id}-btnInnerEl\" class=\"{baseCls}-inner\">',\n                        '{text}',\n                    '</span>',\n                    '<span id=\"{id}-btnIconEl\" class=\"{baseCls}-icon {iconCls}\"<tpl if=\"iconUrl\"> style=\"background-image:url({iconUrl})\"</tpl>></span>',\n                '</a>',\n            '<tpl else>',\n                '<button id=\"{id}-btnEl\" type=\"{type}\" class=\"{btnCls}\" hidefocus=\"true\"',\n                    // the autocomplete=\"off\" is required to prevent Firefox from remembering\n                    // the button's disabled state between page reloads.\n                    '<tpl if=\"tabIndex\"> tabIndex=\"{tabIndex}\"</tpl>',\n                    '<tpl if=\"disabled\"> disabled=\"disabled\"</tpl>',\n                    ' role=\"button\" autocomplete=\"off\">',\n                    '<span id=\"{id}-btnInnerEl\" class=\"{baseCls}-inner\" style=\"{innerSpanStyle}\">',\n                        '{text}',\n                    '</span>',\n                    '<span id=\"{id}-btnIconEl\" class=\"{baseCls}-icon {iconCls}\"<tpl if=\"iconUrl\"> style=\"background-image:url({iconUrl})\"</tpl>></span>',\n                '</button>',\n            '</tpl>',\n        '</em>',\n        '<tpl if=\"closable\">',\n            '<a id=\"{id}-closeEl\" href=\"#\" class=\"{baseCls}-close-btn\" title=\"{closeText}\"></a>',\n        '</tpl>'\n    ],\n\n    /**\n     * @cfg {String} scale\n     * The size of the Button. Three values are allowed:\n     *\n     * - 'small' - Results in the button element being 16px high.\n     * - 'medium' - Results in the button element being 24px high.\n     * - 'large' - Results in the button element being 32px high.\n     */\n    scale: 'small',\n\n    /**\n     * @private\n     * An array of allowed scales.\n     */\n    allowedScales: ['small', 'medium', 'large'],\n\n    /**\n     * @cfg {Object} scope\n     * The scope (**this** reference) in which the `{@link #handler}` and `{@link #toggleHandler}` is executed.\n     * Defaults to this Button.\n     */\n\n    /**\n     * @cfg {String} iconAlign\n     * The side of the Button box to render the icon. Four values are allowed:\n     *\n     * - 'top'\n     * - 'right'\n     * - 'bottom'\n     * - 'left'\n     */\n    iconAlign: 'left',\n\n    /**\n     * @cfg {String} arrowAlign\n     * The side of the Button box to render the arrow if the button has an associated {@link #cfg-menu}. Two\n     * values are allowed:\n     *\n     * - 'right'\n     * - 'bottom'\n     */\n    arrowAlign: 'right',\n\n    /**\n     * @cfg {String} arrowCls\n     * The className used for the inner arrow element if the button has a menu.\n     */\n    arrowCls: 'arrow',\n\n    /**\n     * @property {Ext.Template} template\n     * A {@link Ext.Template Template} used to create the Button's DOM structure.\n     *\n     * Instances, or subclasses which need a different DOM structure may provide a different template layout in\n     * conjunction with an implementation of {@link #getTemplateArgs}.\n     */\n\n    /**\n     * @cfg {String} cls\n     * A CSS class string to apply to the button's main element.\n     */\n\n    /**\n     * @property {Ext.menu.Menu} menu\n     * The {@link Ext.menu.Menu Menu} object associated with this Button when configured with the {@link #cfg-menu} config\n     * option.\n     */\n\n    maskOnDisable: false,\n    \n    /**\n     * @private\n     * @property persistentPadding\n     * The padding spuriously added to a &lt;button> element which must be accounted for in the margins of the innerEl.\n     * This is calculated at first render time by creating a hidden button and measuring its insides.\n     */\n    persistentPadding: undefined,\n\n    shrinkWrap: 3,\n\n    frame: true,\n\n    // inherit docs\n    initComponent: function() {\n        var me = this;\n        me.callParent(arguments);\n\n        me.addEvents(\n            /**\n             * @event click\n             * Fires when this button is clicked, before the configured {@link #handler} is invoked. Execution of the\n             * {@link #handler} may be vetoed by returning <code>false</code> to this event.\n             * @param {Ext.button.Button} this\n             * @param {Event} e The click event\n             */\n            'click',\n\n            /**\n             * @event toggle\n             * Fires when the 'pressed' state of this button changes (only if enableToggle = true)\n             * @param {Ext.button.Button} this\n             * @param {Boolean} pressed\n             */\n            'toggle',\n\n            /**\n             * @event mouseover\n             * Fires when the mouse hovers over the button\n             * @param {Ext.button.Button} this\n             * @param {Event} e The event object\n             */\n            'mouseover',\n\n            /**\n             * @event mouseout\n             * Fires when the mouse exits the button\n             * @param {Ext.button.Button} this\n             * @param {Event} e The event object\n             */\n            'mouseout',\n\n            /**\n             * @event menushow\n             * If this button has a menu, this event fires when it is shown\n             * @param {Ext.button.Button} this\n             * @param {Ext.menu.Menu} menu\n             */\n            'menushow',\n\n            /**\n             * @event menuhide\n             * If this button has a menu, this event fires when it is hidden\n             * @param {Ext.button.Button} this\n             * @param {Ext.menu.Menu} menu\n             */\n            'menuhide',\n\n            /**\n             * @event menutriggerover\n             * If this button has a menu, this event fires when the mouse enters the menu triggering element\n             * @param {Ext.button.Button} this\n             * @param {Ext.menu.Menu} menu\n             * @param {Event} e\n             */\n            'menutriggerover',\n\n            /**\n             * @event menutriggerout\n             * If this button has a menu, this event fires when the mouse leaves the menu triggering element\n             * @param {Ext.button.Button} this\n             * @param {Ext.menu.Menu} menu\n             * @param {Event} e\n             */\n            'menutriggerout'\n        );\n\n        if (me.menu) {\n            // Flag that we'll have a splitCls\n            me.split = true;\n\n            // retrieve menu by id or instantiate instance if needed\n            me.menu = Ext.menu.Manager.get(me.menu);\n            me.menu.ownerButton = me;\n        }\n\n        // Accept url as a synonym for href\n        if (me.url) {\n            me.href = me.url;\n        }\n\n        // preventDefault defaults to false for links\n        if (me.href && !me.hasOwnProperty('preventDefault')) {\n            me.preventDefault = false;\n        }\n\n        if (Ext.isString(me.toggleGroup) && me.toggleGroup !== '') {\n            me.enableToggle = true;\n        }\n        \n        if (me.html && !me.text) {\n            me.text = me.html;\n            delete me.html;\n        }\n\n    },\n\n    // inherit docs\n    getActionEl: function() {\n        return this.btnEl;\n    },\n\n    // inherit docs\n    getFocusEl: function() {\n        return this.useElForFocus ? this.el : this.btnEl;\n    },\n\n    // Buttons add the focus class to the *outermost element*, not the focusEl!\n    onFocus: function(e) {\n        var me = this;\n\n        // Set this flag, so that when AbstractComponent's onFocus gets the focusEl to add the focusCls\n        // to, it will get the encapsulating element - that's what the CSS rules for Button need right now\n        me.useElForFocus = true;\n        me.callParent(arguments);\n        me.useElForFocus = false;\n    },\n\n    // See comments in onFocus\n    onBlur : function(e) {\n        this.useElForFocus = true;\n        this.callParent(arguments);\n        this.useElForFocus = false;\n    },\n    \n    // See comments in onFocus\n    onDisable: function(){\n        this.useElForFocus = true;\n        this.callParent(arguments);\n        this.useElForFocus = false;\n    },\n\n    // private\n    setComponentCls: function() {\n        var me = this,\n            cls = me.getComponentCls();\n\n        if (!Ext.isEmpty(me.oldCls)) {\n            me.removeClsWithUI(me.oldCls);\n            me.removeClsWithUI(me.pressedCls);\n        }\n\n        me.oldCls = cls;\n        me.addClsWithUI(cls);\n    },\n\n    getComponentCls: function() {\n        var me = this,\n            cls = [];\n\n        // Check whether the button has an icon or not, and if it has an icon, what is the alignment\n        if (me.iconCls || me.icon) {\n            if (me.text) {\n                cls.push('icon-text-' + me.iconAlign);\n            } else {\n                cls.push('icon');\n            }\n        } else if (me.text) {\n            cls.push('noicon');\n        }\n\n        if (me.pressed) {\n            cls.push(me.pressedCls);\n        }\n        return cls;\n    },\n\n    beforeRender: function () {\n        var me = this;\n\n        me.callParent();\n\n        // Add all needed classes to the protoElement.\n        me.oldCls = me.getComponentCls();\n        me.addClsWithUI(me.oldCls);\n\n        // Apply the renderData to the template args\n        Ext.applyIf(me.renderData, me.getTemplateArgs());\n\n        if (me.scale) {\n            me.setScale(me.scale);\n        }\n    },\n\n    // private\n    onRender: function() {\n        var me = this,\n            addOnclick,\n            btn,\n            btnListeners;\n\n        me.doc = Ext.getDoc();\n        me.callParent(arguments);\n\n        // If it is a split button + has a toolip for the arrow\n        if (me.split && me.arrowTooltip) {\n            me.arrowEl.dom.setAttribute(me.getTipAttr(), me.arrowTooltip);\n        }\n\n        // Set btn as a local variable for easy access\n        btn = me.el;\n\n        if (me.tooltip) {\n            me.setTooltip(me.tooltip, true);\n        }\n\n        // Add the mouse events to the button\n        if (me.handleMouseEvents) {\n            btnListeners = {\n                scope: me,\n                mouseover: me.onMouseOver,\n                mouseout: me.onMouseOut,\n                mousedown: me.onMouseDown\n            };\n            if (me.split) {\n                btnListeners.mousemove = me.onMouseMove;\n            }\n        } else {\n            btnListeners = {\n                scope: me\n            };\n        }\n\n        // Check if the button has a menu\n        if (me.menu) {\n            me.mon(me.menu, {\n                scope: me,\n                show: me.onMenuShow,\n                hide: me.onMenuHide\n            });\n\n            me.keyMap = new Ext.util.KeyMap({\n                target: me.el,\n                key: Ext.EventObject.DOWN,\n                handler: me.onDownKey,\n                scope: me\n            });\n        }\n\n        // Check if it is a repeat button\n        if (me.repeat) {\n            me.mon(new Ext.util.ClickRepeater(btn, Ext.isObject(me.repeat) ? me.repeat: {}), 'click', me.onRepeatClick, me);\n        } else {\n\n            // If the activation event already has a handler, make a note to add the handler later\n            if (btnListeners[me.clickEvent]) {\n                addOnclick = true;\n            } else {\n                btnListeners[me.clickEvent] = me.onClick;\n            }\n        }\n\n        // Add whatever button listeners we need\n        me.mon(btn, btnListeners);\n\n        // If the listeners object had an entry for our clickEvent, add a listener now\n        if (addOnclick) {\n            me.mon(btn, me.clickEvent, me.onClick, me);\n        }\n\n        // Register the button in the toggle manager\n        Ext.ButtonToggleManager.register(me);\n    },\n\n    /**\n     * This method returns an object which provides substitution parameters for the {@link #renderTpl XTemplate} used to\n     * create this Button's DOM structure.\n     *\n     * Instances or subclasses which use a different Template to create a different DOM structure may need to provide\n     * their own implementation of this method.\n     *\n     * @return {Object} Substitution data for a Template. The default implementation which provides data for the default\n     * {@link #template} returns an Object containing the following properties:\n     * @return {String} return.type The `<button>`'s {@link #type}\n     * @return {String} return.splitCls A CSS class to determine the presence and position of an arrow icon.\n     * (`'x-btn-arrow'` or `'x-btn-arrow-bottom'` or `''`)\n     * @return {String} return.cls A CSS class name applied to the Button's main `<tbody>` element which determines the\n     * button's scale and icon alignment.\n     * @return {String} return.text The {@link #text} to display ion the Button.\n     * @return {Number} return.tabIndex The tab index within the input flow.\n     */\n    getTemplateArgs: function() {\n        var me = this,\n            persistentPadding = me.getPersistentPadding(),\n            innerSpanStyle = '';\n\n        // Create negative margin offsets to counteract persistent button padding if needed\n        if (Math.max.apply(Math, persistentPadding) > 0) {\n            innerSpanStyle = 'margin:' + Ext.Array.map(persistentPadding, function(pad) {\n                return -pad + 'px';\n            }).join(' ');\n        }\n\n        return {\n            href     : me.getHref(),\n            disabled : me.disabled,\n            hrefTarget: me.hrefTarget,\n            type     : me.type,\n            btnCls   : me.getBtnCls(),\n            splitCls : me.getSplitCls(),\n            iconUrl  : me.icon,\n            iconCls  : me.iconCls,\n            text     : me.text || '&#160;',\n            tabIndex : me.tabIndex,\n            innerSpanStyle: innerSpanStyle\n        };\n    },\n\n    /**\n     * @private\n     * If there is a configured href for this Button, returns the href with parameters appended.\n     * @returns The href string with parameters appended.\n     */\n    getHref: function() {\n        var me = this,\n            params = Ext.apply({}, me.baseParams);\n\n        // write baseParams first, then write any params\n        params = Ext.apply(params, me.params);\n        return me.href ? Ext.urlAppend(me.href, Ext.Object.toQueryString(params)) : false;\n    },\n\n    /**\n     * Sets the href of the link dynamically according to the params passed, and any {@link #baseParams} configured.\n     *\n     * **Only valid if the Button was originally configured with a {@link #href}**\n     *\n     * @param {Object} params Parameters to use in the href URL.\n     */\n    setParams: function(params) {\n        this.params = params;\n        this.btnEl.dom.href = this.getHref();\n    },\n\n    getSplitCls: function() {\n        var me = this;\n        return me.split ? (me.baseCls + '-' + me.arrowCls) + ' ' + (me.baseCls + '-' + me.arrowCls + '-' + me.arrowAlign) : '';\n    },\n\n    getBtnCls: function() {\n        return this.textAlign ? this.baseCls + '-' + this.textAlign : '';\n    },\n\n    /**\n     * Sets the CSS class that provides a background image to use as the button's icon. This method also changes the\n     * value of the {@link #iconCls} config internally.\n     * @param {String} cls The CSS class providing the icon image\n     * @return {Ext.button.Button} this\n     */\n    setIconCls: function(cls) {\n        var me = this,\n            btnIconEl = me.btnIconEl,\n            oldCls = me.iconCls;\n            \n        me.iconCls = cls;\n        if (btnIconEl) {\n            // Remove the previous iconCls from the button\n            btnIconEl.removeCls(oldCls);\n            btnIconEl.addCls(cls || '');\n            me.setComponentCls();\n            if (me.didIconStateChange(oldCls, cls)) {\n                me.updateLayout();\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Sets the tooltip for this Button.\n     *\n     * @param {String/Object} tooltip This may be:\n     *\n     *   - **String** : A string to be used as innerHTML (html tags are accepted) to show in a tooltip\n     *   - **Object** : A configuration object for {@link Ext.tip.QuickTipManager#register}.\n     *\n     * @return {Ext.button.Button} this\n     */\n    setTooltip: function(tooltip, initial) {\n        var me = this;\n\n        if (me.rendered) {\n            if (!initial) {\n                me.clearTip();\n            }\n            if (Ext.isObject(tooltip)) {\n                Ext.tip.QuickTipManager.register(Ext.apply({\n                    target: me.btnEl.id\n                },\n                tooltip));\n                me.tooltip = tooltip;\n            } else {\n                me.btnEl.dom.setAttribute(me.getTipAttr(), tooltip);\n            }\n        } else {\n            me.tooltip = tooltip;\n        }\n        return me;\n    },\n\n    /**\n     * Sets the text alignment for this button.\n     * @param {String} align The new alignment of the button text. See {@link #textAlign}.\n     */\n    setTextAlign: function(align) {\n        var me = this,\n            btnEl = me.btnEl;\n\n        if (btnEl) {\n            btnEl.removeCls(me.baseCls + '-' + me.textAlign);\n            btnEl.addCls(me.baseCls + '-' + align);\n        }\n        me.textAlign = align;\n        return me;\n    },\n\n    getTipAttr: function(){\n        return this.tooltipType == 'qtip' ? 'data-qtip' : 'title';\n    },\n\n    // private\n    getRefItems: function(deep){\n        var menu = this.menu,\n            items;\n        \n        if (menu) {\n            items = menu.getRefItems(deep);\n            items.unshift(menu);\n        }\n        return items || [];\n    },\n\n    // private\n    clearTip: function() {\n        if (Ext.isObject(this.tooltip)) {\n            Ext.tip.QuickTipManager.unregister(this.btnEl);\n        }\n    },\n\n    // private\n    beforeDestroy: function() {\n        var me = this;\n        if (me.rendered) {\n            me.clearTip();\n        }\n        if (me.menu && me.destroyMenu !== false) {\n            Ext.destroy(me.menu);\n        }\n        Ext.destroy(me.btnInnerEl, me.repeater);\n        me.callParent();\n    },\n\n    // private\n    onDestroy: function() {\n        var me = this;\n        if (me.rendered) {\n            me.doc.un('mouseover', me.monitorMouseOver, me);\n            me.doc.un('mouseup', me.onMouseUp, me);\n            delete me.doc;\n            Ext.ButtonToggleManager.unregister(me);\n\n            Ext.destroy(me.keyMap);\n            delete me.keyMap;\n        }\n        me.callParent();\n    },\n\n    /**\n     * Assigns this Button's click handler\n     * @param {Function} handler The function to call when the button is clicked\n     * @param {Object} [scope] The scope (`this` reference) in which the handler function is executed.\n     * Defaults to this Button.\n     * @return {Ext.button.Button} this\n     */\n    setHandler: function(handler, scope) {\n        this.handler = handler;\n        this.scope = scope;\n        return this;\n    },\n\n    /**\n     * Sets this Button's text\n     * @param {String} text The button text\n     * @return {Ext.button.Button} this\n     */\n    setText: function(text) {\n        var me = this;\n        me.text = text;\n        if (me.rendered) {\n            me.btnInnerEl.update(text || '&#160;');\n            me.setComponentCls();\n            if (Ext.isStrict && Ext.isIE8) {\n                // weird repaint issue causes it to not resize\n                me.el.repaint();\n            }\n            me.updateLayout();\n        }\n        return me;\n    },\n\n    /**\n     * Sets the background image (inline style) of the button. This method also changes the value of the {@link #icon}\n     * config internally.\n     * @param {String} icon The path to an image to display in the button\n     * @return {Ext.button.Button} this\n     */\n    setIcon: function(icon) {\n        var me = this,\n            btnIconEl = me.btnIconEl,\n            oldIcon = me.icon;\n            \n        me.icon = icon;\n        if (btnIconEl) {\n            btnIconEl.setStyle('background-image', icon ? 'url(' + icon + ')': '');\n            me.setComponentCls();\n            if (me.didIconStateChange(oldIcon, icon)) {\n                me.updateLayout();\n            }\n        }\n        return me;\n    },\n    \n    /**\n     * Checks if the icon/iconCls changed from being empty to having a value, or having a value to being empty.\n     * @private\n     * @param {String} old The old icon/iconCls\n     * @param {String} current The current icon/iconCls\n     * @return {Boolean} True if the icon state changed\n     */\n    didIconStateChange: function(old, current) {\n        var currentEmpty = Ext.isEmpty(current);\n        return Ext.isEmpty(old) ? !currentEmpty : currentEmpty;\n    },\n\n    /**\n     * Gets the text for this Button\n     * @return {String} The button text\n     */\n    getText: function() {\n        return this.text;\n    },\n\n    /**\n     * If a state it passed, it becomes the pressed state otherwise the current state is toggled.\n     * @param {Boolean} [state] Force a particular state\n     * @param {Boolean} [suppressEvent=false] True to stop events being fired when calling this method.\n     * @return {Ext.button.Button} this\n     */\n    toggle: function(state, suppressEvent) {\n        var me = this;\n        state = state === undefined ? !me.pressed: !!state;\n        if (state !== me.pressed) {\n            if (me.rendered) {\n                me[state ? 'addClsWithUI': 'removeClsWithUI'](me.pressedCls);\n            }\n            me.pressed = state;\n            if (!suppressEvent) {\n                me.fireEvent('toggle', me, state);\n                Ext.callback(me.toggleHandler, me.scope || me, [me, state]);\n            }\n        }\n        return me;\n    },\n    \n    maybeShowMenu: function(){\n        var me = this;\n        if (me.menu && !me.hasVisibleMenu() && !me.ignoreNextClick) {\n            me.showMenu();\n        }\n    },\n\n    /**\n     * Shows this button's menu (if it has one)\n     */\n    showMenu: function() {\n        var me = this;\n        if (me.rendered && me.menu) {\n            if (me.tooltip && me.getTipAttr() != 'title') {\n                Ext.tip.QuickTipManager.getQuickTip().cancelShow(me.btnEl);\n            }\n            if (me.menu.isVisible()) {\n                me.menu.hide();\n            }\n\n            me.menu.showBy(me.el, me.menuAlign, ((!Ext.isStrict && Ext.isIE) || Ext.isIE6) ? [-2, -2] : undefined);\n        }\n        return me;\n    },\n\n    /**\n     * Hides this button's menu (if it has one)\n     */\n    hideMenu: function() {\n        if (this.hasVisibleMenu()) {\n            this.menu.hide();\n        }\n        return this;\n    },\n\n    /**\n     * Returns true if the button has a menu and it is visible\n     * @return {Boolean}\n     */\n    hasVisibleMenu: function() {\n        var menu = this.menu;\n        return menu && menu.rendered && menu.isVisible();\n    },\n\n    // private\n    onRepeatClick: function(repeat, e) {\n        this.onClick(e);\n    },\n\n    // private\n    onClick: function(e) {\n        var me = this;\n        if (me.preventDefault || (me.disabled && me.getHref()) && e) {\n            e.preventDefault();\n        }\n        if (e.button !== 0) {\n            return;\n        }\n        if (!me.disabled) {\n            me.doToggle();\n            me.maybeShowMenu();\n            me.fireHandler(e);\n        }\n    },\n    \n    fireHandler: function(e){\n        var me = this,\n            handler = me.handler;\n            \n        if (me.fireEvent('click', me, e) !== false) {\n            if (handler) {\n                handler.call(me.scope || me, me, e);\n            }\n            me.blur();\n        }\n    },\n    \n    doToggle: function(){\n        var me = this;    \n        if (me.enableToggle && (me.allowDepress !== false || !me.pressed)) {\n            me.toggle();\n        }\n    },\n\n    /**\n     * @private mouseover handler called when a mouseover event occurs anywhere within the encapsulating element.\n     * The targets are interrogated to see what is being entered from where.\n     * @param e\n     */\n    onMouseOver: function(e) {\n        var me = this;\n        if (!me.disabled && !e.within(me.el, true, true)) {\n            me.onMouseEnter(e);\n        }\n    },\n\n    /**\n     * @private\n     * mouseout handler called when a mouseout event occurs anywhere within the encapsulating element -\n     * or the mouse leaves the encapsulating element.\n     * The targets are interrogated to see what is being exited to where.\n     * @param e\n     */\n    onMouseOut: function(e) {\n        var me = this;\n        if (!e.within(me.el, true, true)) {\n            if (me.overMenuTrigger) {\n                me.onMenuTriggerOut(e);\n            }\n            me.onMouseLeave(e);\n        }\n    },\n\n    /**\n     * @private\n     * mousemove handler called when the mouse moves anywhere within the encapsulating element.\n     * The position is checked to determine if the mouse is entering or leaving the trigger area. Using\n     * mousemove to check this is more resource intensive than we'd like, but it is necessary because\n     * the trigger area does not line up exactly with sub-elements so we don't always get mouseover/out\n     * events when needed. In the future we should consider making the trigger a separate element that\n     * is absolutely positioned and sized over the trigger area.\n     */\n    onMouseMove: function(e) {\n        var me = this,\n            el = me.el,\n            over = me.overMenuTrigger,\n            overlap, btnSize;\n\n        if (me.split) {\n            if (me.arrowAlign === 'right') {\n                overlap = e.getX() - el.getX();\n                btnSize = el.getWidth();\n            } else {\n                overlap = e.getY() - el.getY();\n                btnSize = el.getHeight();\n            }\n\n            if (overlap > (btnSize - me.getTriggerSize())) {\n                if (!over) {\n                    me.onMenuTriggerOver(e);\n                }\n            } else {\n                if (over) {\n                    me.onMenuTriggerOut(e);\n                }\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Measures the size of the trigger area for menu and split buttons. Will be a width for\n     * a right-aligned trigger and a height for a bottom-aligned trigger. Cached after first measurement.\n     */\n    getTriggerSize: function() {\n        var me = this,\n            size = me.triggerSize,\n            side, sideFirstLetter, undef;\n\n        if (size === undef) {\n            side = me.arrowAlign;\n            sideFirstLetter = side.charAt(0);\n            size = me.triggerSize = me.el.getFrameWidth(sideFirstLetter) + me.btnWrap.getFrameWidth(sideFirstLetter) + me.frameSize[side];\n        }\n        return size;\n    },\n\n    /**\n     * @private\n     * virtual mouseenter handler called when it is detected that the mouseout event\n     * signified the mouse entering the encapsulating element.\n     * @param e\n     */\n    onMouseEnter: function(e) {\n        var me = this;\n        me.addClsWithUI(me.overCls);\n        me.fireEvent('mouseover', me, e);\n    },\n\n    /**\n     * @private\n     * virtual mouseleave handler called when it is detected that the mouseover event\n     * signified the mouse entering the encapsulating element.\n     * @param e\n     */\n    onMouseLeave: function(e) {\n        var me = this;\n        me.removeClsWithUI(me.overCls);\n        me.fireEvent('mouseout', me, e);\n    },\n\n    /**\n     * @private\n     * virtual mouseenter handler called when it is detected that the mouseover event\n     * signified the mouse entering the arrow area of the button - the `<em>`.\n     * @param e\n     */\n    onMenuTriggerOver: function(e) {\n        var me = this;\n        me.overMenuTrigger = true;\n        me.fireEvent('menutriggerover', me, me.menu, e);\n    },\n\n    /**\n     * @private\n     * virtual mouseleave handler called when it is detected that the mouseout event\n     * signified the mouse leaving the arrow area of the button - the `<em>`.\n     * @param e\n     */\n    onMenuTriggerOut: function(e) {\n        var me = this;\n        delete me.overMenuTrigger;\n        me.fireEvent('menutriggerout', me, me.menu, e);\n    },\n\n    // inherit docs\n    enable : function(silent) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        if (me.btnEl) {\n            me.btnEl.dom.disabled = false;\n        }\n        me.removeClsWithUI('disabled');\n\n        return me;\n    },\n\n    // inherit docs\n    disable : function(silent) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        if (me.btnEl) {\n            me.btnEl.dom.disabled = true;\n        }\n        me.addClsWithUI('disabled');\n        me.removeClsWithUI(me.overCls);\n\n        // IE renders disabled text by layering gray text on top of white text, offset by 1 pixel. Normally this is fine\n        // but in some circumstances (such as using formBind) it gets confused and renders them side by side instead.\n        if (me.btnInnerEl && (Ext.isIE6 || Ext.isIE7)) {\n            me.btnInnerEl.repaint();\n        }\n\n        return me;\n    },\n\n    /**\n     * Method to change the scale of the button. See {@link #scale} for allowed configurations.\n     * @param {String} scale The scale to change to.\n     */\n    setScale: function(scale) {\n        var me = this,\n            ui = me.ui.replace('-' + me.scale, '');\n\n        //check if it is an allowed scale\n        if (!Ext.Array.contains(me.allowedScales, scale)) {\n            throw('#setScale: scale must be an allowed scale (' + me.allowedScales.join(', ') + ')');\n        }\n\n        me.scale = scale;\n        me.setUI(ui);\n    },\n\n    // inherit docs\n    setUI: function(ui) {\n        var me = this;\n\n        //we need to append the scale to the UI, if not already done\n        if (me.scale && !ui.match(me.scale)) {\n            ui = ui + '-' + me.scale;\n        }\n\n        me.callParent([ui]);\n\n        // Set all the state classNames, as they need to include the UI\n        // me.disabledCls += ' ' + me.baseCls + '-' + me.ui + '-disabled';\n    },\n\n    // private\n    onMouseDown: function(e) {\n        var me = this;\n        if (!me.disabled && e.button === 0) {\n            me.addClsWithUI(me.pressedCls);\n            me.doc.on('mouseup', me.onMouseUp, me);\n        }\n    },\n    // private\n    onMouseUp: function(e) {\n        var me = this;\n        if (e.button === 0) {\n            if (!me.pressed) {\n                me.removeClsWithUI(me.pressedCls);\n            }\n            me.doc.un('mouseup', me.onMouseUp, me);\n        }\n    },\n    // private\n    onMenuShow: function(e) {\n        var me = this;\n        me.ignoreNextClick = 0;\n        me.addClsWithUI(me.menuActiveCls);\n        me.fireEvent('menushow', me, me.menu);\n    },\n\n    // private\n    onMenuHide: function(e) {\n        var me = this;\n        me.removeClsWithUI(me.menuActiveCls);\n        me.ignoreNextClick = Ext.defer(me.restoreClick, 250, me);\n        me.fireEvent('menuhide', me, me.menu);\n    },\n\n    // private\n    restoreClick: function() {\n        this.ignoreNextClick = 0;\n    },\n\n    // private\n    onDownKey: function() {\n        var me = this;\n\n        if (!me.disabled) {\n            if (me.menu) {\n                me.showMenu();\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Some browsers (notably Safari and older Chromes on Windows) add extra \"padding\" inside the button\n     * element that cannot be removed. This method returns the size of that padding with a one-time detection.\n     * @return {Number[]} [top, right, bottom, left]\n     */\n    getPersistentPadding: function() {\n        var me = this,\n            reset = Ext.scopeResetCSS,\n            padding = me.persistentPadding,\n            btn, leftTop, btnEl, btnInnerEl, wrap;\n\n        // Create auto-size button offscreen and measure its insides\n        // Short-circuit IE as it sometimes gives false positive for padding\n        if (!padding) {\n            padding = me.self.prototype.persistentPadding = [0, 0, 0, 0];\n            if (!Ext.isIE) {\n                btn = new Ext.button.Button({\n                    text: 'test',\n                    style: 'position:absolute;top:-999px;'\n                });\n                btn.el = Ext.DomHelper.append(Ext.resetElement, btn.getRenderTree(), true);\n                btn.applyChildEls(btn.el);\n                btnEl = btn.btnEl;\n                btnInnerEl = btn.btnInnerEl;\n                btnEl.setSize(null, null); //clear any hard dimensions on the button el to see what it does naturally\n                leftTop = btnInnerEl.getOffsetsTo(btnEl);\n                padding[0] = leftTop[1];\n                padding[1] = btnEl.getWidth() - btnInnerEl.getWidth() - leftTop[0];\n                padding[2] = btnEl.getHeight() - btnInnerEl.getHeight() - leftTop[1];\n                padding[3] = leftTop[0];\n                \n                btn.destroy();\n                btn.el.remove();\n            }\n        }\n        return padding;\n    }\n}, function() {\n    var groups = {},\n        toggleGroup = function(btn, state) {\n            if (state) {\n                var g = groups[btn.toggleGroup],\n                    length = g.length,\n                    i;\n\n                for (i = 0; i < length; i++) {\n                    if (g[i] !== btn) {\n                        g[i].toggle(false);\n                    }\n                }\n            }\n        };\n\n    // Private utility class used by Button\n    Ext.ButtonToggleManager = {\n        register: function(btn) {\n            if (!btn.toggleGroup) {\n                return;\n            }\n            var group = groups[btn.toggleGroup];\n            if (!group) {\n                group = groups[btn.toggleGroup] = [];\n            }\n            group.push(btn);\n            btn.on('toggle', toggleGroup);\n        },\n\n        unregister: function(btn) {\n            if (!btn.toggleGroup) {\n                return;\n            }\n            var group = groups[btn.toggleGroup];\n            if (group) {\n                Ext.Array.remove(group, btn);\n                btn.un('toggle', toggleGroup);\n            }\n        },\n\n        // Gets the pressed button in the passed group or null\n        // @param {String} group\n        // @return {Ext.button.Button}\n        getPressed: function(group) {\n            var g = groups[group],\n                i = 0,\n                len;\n            if (g) {\n                for (len = g.length; i < len; i++) {\n                    if (g[i].pressed === true) {\n                        return g[i];\n                    }\n                }\n            }\n            return null;\n        }\n    };\n});\n\n/**\n * @private\n */\nExt.define('Ext.layout.container.boxOverflow.Menu', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.layout.container.boxOverflow.None',\n    requires: ['Ext.toolbar.Separator', 'Ext.button.Button'],\n    alternateClassName: 'Ext.layout.boxOverflow.Menu',\n    \n    /* End Definitions */\n\n    /**\n     * @cfg {String} triggerButtonCls\n     * CSS class added to the Button which shows the overflow menu.\n     */\n\n    /**\n     * @property {String} noItemsMenuText\n     * HTML fragment to render into the toolbar overflow menu if there are no items to display\n     */\n    noItemsMenuText : '<div class=\"' + Ext.baseCSSPrefix + 'toolbar-no-items\">(None)</div>',\n\n    constructor: function(layout) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        me.triggerButtonCls = me.triggerButtonCls || Ext.baseCSSPrefix + 'box-menu-' + layout.getNames().right;\n        /**\n         * @property {Array} menuItems\n         * Array of all items that are currently hidden and should go into the dropdown menu\n         */\n        me.menuItems = [];\n    },\n\n    beginLayout: function (ownerContext) {\n        this.callParent(arguments);\n\n        // Before layout, we need to re-show all items which we may have hidden due to a\n        // previous overflow...\n        this.clearOverflow(ownerContext);\n    },\n\n    beginLayoutCycle: function (ownerContext, firstCycle) {\n        this.callParent(arguments);\n\n        if (!firstCycle) {\n            // if we are being re-run, we need to clear any overflow from the last run and\n            // recache the childItems collection\n            this.clearOverflow(ownerContext);\n\n            this.layout.cacheChildItems(ownerContext);\n        }\n    },\n\n    onRemove: function(comp){\n        Ext.Array.remove(this.menuItems, comp);\n    },\n\n    // We don't define a prefix in menu overflow.\n    getSuffixConfig: function() {\n        var me = this,\n            layout = me.layout,\n            oid = layout.owner.id;\n\n        /**\n         * @private\n         * @property {Ext.menu.Menu} menu\n         * The expand menu - holds items for every item that cannot be shown\n         * because the container is currently not large enough.\n         */\n        me.menu = new Ext.menu.Menu({\n            listeners: {\n                scope: me,\n                beforeshow: me.beforeMenuShow\n            }\n        });\n\n        /**\n         * @private\n         * @property {Ext.button.Button} menuTrigger\n         * The expand button which triggers the overflow menu to be shown\n         */\n        me.menuTrigger = new Ext.button.Button({\n            id      : oid + '-menu-trigger',\n            cls     : Ext.layout.container.Box.prototype.innerCls + ' ' + me.triggerButtonCls,\n            hidden  : true,\n            ownerCt : layout.owner, // To enable the Menu to ascertain a valid zIndexManager owner in the same tree\n            ownerLayout: layout,\n            iconCls : Ext.baseCSSPrefix + me.getOwnerType(layout.owner) + '-more-icon',\n            ui      : layout.owner instanceof Ext.toolbar.Toolbar ? 'default-toolbar' : 'default',\n            menu    : me.menu,\n            getSplitCls: function() { return '';}\n        });\n\n        return me.menuTrigger.getRenderTree();\n    },\n    \n    getOverflowCls: function() {\n        return Ext.baseCSSPrefix + this.layout.direction + '-box-overflow-body';\n    },\n\n    handleOverflow: function(ownerContext) {\n        var me = this,\n            layout = me.layout,\n            names = layout.getNames(),\n            plan = ownerContext.state.boxPlan,\n            posArgs = [null, null];\n\n        me.showTrigger(ownerContext);\n\n        // Center the menuTrigger button.\n        // TODO: Should we emulate align: 'middle' like this, or should we 'stretchmax' the menuTrigger?\n        posArgs[names.heightIndex] = (plan.maxSize - me.menuTrigger[names.getHeight]()) / 2;\n        me.menuTrigger.setPosition.apply(me.menuTrigger, posArgs);\n\n        return {\n            reservedSpace: me.menuTrigger[names.getWidth]()\n        };\n    },\n\n    /**\n     * Finishes the render operation of the trigger Button.\n     * @private\n     */\n    captureChildElements: function() {\n        var menuTrigger = this.menuTrigger;\n        if (menuTrigger.rendering) {\n            menuTrigger.finishRender();\n        }\n    },\n\n    _asLayoutRoot: { isRoot: true },\n\n    /**\n     * @private\n     * Called by the layout, when it determines that there is no overflow.\n     * Also called as an interceptor to the layout's onLayout method to reshow\n     * previously hidden overflowing items.\n     */\n    clearOverflow: function(ownerContext) {\n        var me = this,\n            items = me.menuItems,\n            item,\n            i = 0,\n            length = items.length,\n            owner = me.layout.owner,\n            asLayoutRoot = me._asLayoutRoot;\n\n        owner.suspendLayouts();\n        me.captureChildElements();\n        me.hideTrigger();\n        owner.resumeLayouts();\n\n        for (; i < length; i++) {\n            item = items[i];\n\n            // What we are doing here is preventing the layout bubble from invalidating our\n            // owner component. We need just the button to be added to the layout run.\n            item.suspendLayouts();\n            item.show();\n            item.resumeLayouts(asLayoutRoot);\n        }\n\n        items.length = 0;\n    },\n\n    /**\n     * @private\n     * Shows the overflow trigger when enableOverflow is set to true and the items\n     * in the layout are too wide to fit in the space available\n     */\n    showTrigger: function(ownerContext) {\n        var me = this,\n            layout = me.layout,\n            owner = layout.owner,\n            names = layout.getNames(),\n            startProp = names.x,\n            sizeProp = names.width,\n            plan = ownerContext.state.boxPlan,\n            available = plan.targetSize[sizeProp],\n            childItems = ownerContext.childItems,\n            len = childItems.length,\n            menuTrigger = me.menuTrigger,\n            childContext,\n            comp, i, props;\n\n        // We don't want the menuTrigger.show to cause owner's layout to be invalidated, so\n        // we force just the button to be invalidated and added to the current run.\n        menuTrigger.suspendLayouts();\n        menuTrigger.show();\n        menuTrigger.resumeLayouts(me._asLayoutRoot);\n\n        available -= me.menuTrigger.getWidth();\n\n        owner.suspendLayouts();\n\n        // Hide all items which are off the end, and store them to allow them to be restored\n        // before each layout operation.\n        me.menuItems.length = 0;\n        for (i = 0; i < len; i++) {\n            childContext = childItems[i];\n            props = childContext.props;\n            if (props[startProp] + props[sizeProp] > available) {\n                comp = childContext.target;\n                me.menuItems.push(comp);\n                comp.hide();\n            }\n        }\n\n        owner.resumeLayouts();\n    },\n\n    /**\n     * @private\n     */\n    hideTrigger: function() {\n        var menuTrigger = this.menuTrigger;\n        if (menuTrigger) {\n            menuTrigger.hide();\n        }\n    },\n\n    /**\n     * @private\n     * Called before the overflow menu is shown. This constructs the menu's items, caching them for as long as it can.\n     */\n    beforeMenuShow: function(menu) {\n        var me = this,\n            items = me.menuItems,\n            i = 0,\n            len   = items.length,\n            item,\n            prev,\n            needsSep = function(group, prev){\n                return group.isXType('buttongroup') && !(prev instanceof Ext.toolbar.Separator);\n            };\n\n        menu.suspendLayouts();\n        me.clearMenu();\n        menu.removeAll();\n\n        for (; i < len; i++) {\n            item = items[i];\n\n            // Do not show a separator as a first item\n            if (!i && (item instanceof Ext.toolbar.Separator)) {\n                continue;\n            }\n            if (prev && (needsSep(item, prev) || needsSep(prev, item))) {\n                menu.add('-');\n            }\n\n            me.addComponentToMenu(menu, item);\n            prev = item;\n        }\n\n        // put something so the menu isn't empty if no compatible items found\n        if (menu.items.length < 1) {\n            menu.add(me.noItemsMenuText);\n        }\n        menu.resumeLayouts();\n    },\n    \n    /**\n     * @private\n     * Returns a menu config for a given component. This config is used to create a menu item\n     * to be added to the expander menu\n     * @param {Ext.Component} component The component to create the config for\n     * @param {Boolean} hideOnClick Passed through to the menu item\n     */\n    createMenuConfig : function(component, hideOnClick) {\n        var config = Ext.apply({}, component.initialConfig),\n            group  = component.toggleGroup;\n\n        Ext.copyTo(config, component, [\n            'iconCls', 'icon', 'itemId', 'disabled', 'handler', 'scope', 'menu'\n        ]);\n\n        Ext.apply(config, {\n            text       : component.overflowText || component.text,\n            hideOnClick: hideOnClick,\n            destroyMenu: false\n        });\n\n        // Clone must have same value, and must sync original's value on change\n        if (component.isFormField) {\n            config.value = component.getValue();\n\n            // We're going to add a listener\n            if (!config.listeners) {\n                config.listeners = {};\n            }\n\n            // Sync the original component's value when the clone changes value.\n            // This intentionally overwrites any developer-configured change listener on the clone.\n            // That's because we monitor the clone's change event, and sync the\n            // original field by calling setValue, so the original field's change\n            // event will still fire.\n            config.listeners.change = function(c, newVal, oldVal) {                            \n                component.setValue(newVal);\n            }\n        }\n\n        // ToggleButtons become CheckItems\n        else if (group || component.enableToggle) {\n            Ext.apply(config, {\n                iconAlign: 'right',\n                hideOnClick: false,\n                group  : group,\n                checked: component.pressed,\n                listeners: {\n                    checkchange: function(item, checked) {\n                        component.toggle(checked);\n                    }\n                }\n            });\n        }\n\n        delete config.ownerCt;\n        delete config.xtype;\n        delete config.id;\n        return config;\n    },\n\n    /**\n     * @private\n     * Adds the given Toolbar item to the given menu. Buttons inside a buttongroup are added individually.\n     * @param {Ext.menu.Menu} menu The menu to add to\n     * @param {Ext.Component} component The component to add\n     * TODO: Implement overrides in Ext.layout.container.boxOverflow which create overrides\n     * for SplitButton, Button, ButtonGroup, and TextField. And a generic one for Component\n     * which create clones suitable for use in an overflow menu.\n     */\n    addComponentToMenu : function(menu, component) {\n        var me = this,\n        i, items, iLen;\n\n        if (component instanceof Ext.toolbar.Separator) {\n            menu.add('-');\n        } else if (component.isComponent) {\n            if (component.isXType('splitbutton')) {\n                menu.add(me.createMenuConfig(component, true));\n\n            } else if (component.isXType('button')) {\n                menu.add(me.createMenuConfig(component, !component.menu));\n\n            } else if (component.isXType('buttongroup')) {\n                items = component.items.items;\n                iLen  = items.length;\n\n                for (i = 0; i < iLen; i++) {\n                    me.addComponentToMenu(menu, items[i]);\n                }\n            } else {\n                menu.add(Ext.create(Ext.getClassName(component), me.createMenuConfig(component)));\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Deletes the sub-menu of each item in the expander menu. Submenus are created for items such as\n     * splitbuttons and buttongroups, where the Toolbar item cannot be represented by a single menu item\n     */\n    clearMenu : function() {\n        var menu = this.menu,\n            items, i, iLen, item;\n        \n        if (menu && menu.items) {\n            items = menu.items.items;\n            iLen  = items.length;\n            \n            for (i = 0; i < iLen; i++) {\n                item = items[i];\n                if (item.setMenu) {\n                    item.setMenu(null);\n                }\n            }\n        }\n    },\n\n    /**\n     * @private\n     */\n    destroy: function() {\n        var trigger = this.menuTrigger;\n            \n        if (trigger && !this.layout.owner.items.contains(trigger)) {\n            // Ensure we delete the ownerCt if it's not in the items\n            // so we don't get spurious container remove warnings.\n            delete trigger.ownerCt;\n        }\n        Ext.destroy(this.menu, trigger);\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.layout.container.boxOverflow.Scroller', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.layout.container.boxOverflow.None',\n    requires: ['Ext.util.ClickRepeater', 'Ext.Element'],\n    alternateClassName: 'Ext.layout.boxOverflow.Scroller',\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n    \n    /* End Definitions */\n\n    /**\n     * @cfg {Boolean} animateScroll\n     * True to animate the scrolling of items within the layout (ignored if enableScroll is false)\n     */\n    animateScroll: false,\n\n    /**\n     * @cfg {Number} scrollIncrement\n     * The number of pixels to scroll by on scroller click\n     */\n    scrollIncrement: 20,\n\n    /**\n     * @cfg {Number} wheelIncrement\n     * The number of pixels to increment on mouse wheel scrolling.\n     */\n    wheelIncrement: 10,\n\n    /**\n     * @cfg {Number} scrollRepeatInterval\n     * Number of milliseconds between each scroll while a scroller button is held down\n     */\n    scrollRepeatInterval: 60,\n\n    /**\n     * @cfg {Number} scrollDuration\n     * Number of milliseconds that each scroll animation lasts\n     */\n    scrollDuration: 400,\n\n    /**\n     * @cfg {String} beforeCtCls\n     * CSS class added to the beforeCt element. This is the element that holds any special items such as scrollers,\n     * which must always be present at the leftmost edge of the Container\n     */\n\n    /**\n     * @cfg {String} afterCtCls\n     * CSS class added to the afterCt element. This is the element that holds any special items such as scrollers,\n     * which must always be present at the rightmost edge of the Container\n     */\n\n    /**\n     * @cfg {String} [scrollerCls='x-box-scroller']\n     * CSS class added to both scroller elements if enableScroll is used\n     */\n    scrollerCls: Ext.baseCSSPrefix + 'box-scroller',\n\n    /**\n     * @cfg {String} beforeScrollerCls\n     * CSS class added to the left scroller element if enableScroll is used\n     */\n\n    /**\n     * @cfg {String} afterScrollerCls\n     * CSS class added to the right scroller element if enableScroll is used\n     */\n\n    constructor: function(layout, config) {\n        var me = this;\n\n        me.layout = layout;\n        Ext.apply(me, config || {});\n\n        // Dont pass the config so that it is not applied to 'this' again\n        me.mixins.observable.constructor.call(me);\n\n        me.addEvents(\n            /**\n             * @event scroll\n             * @param {Ext.layout.container.boxOverflow.Scroller} scroller The layout scroller\n             * @param {Number} newPosition The new position of the scroller\n             * @param {Boolean/Object} animate If animating or not. If true, it will be a animation configuration, else it will be false\n             */\n            'scroll'\n        );\n        me.scrollPosition = 0;\n        me.scrollSize = 0;\n    },\n\n    getPrefixConfig: function() {\n        var me = this;\n        me.initCSSClasses();\n        return {\n            cls: Ext.layout.container.Box.prototype.innerCls + ' ' + me.beforeCtCls,\n            cn : {\n                id : me.layout.owner.id + '-before-scroller',\n                cls: me.scrollerCls + ' ' + me.beforeScrollerCls,\n                style: 'display:none'\n            }\n        };\n    },\n\n    getSuffixConfig: function() {\n        var me = this;\n        return {\n            cls: Ext.layout.container.Box.prototype.innerCls + ' ' + me.afterCtCls,\n            cn : {\n                id : me.layout.owner.id + '-after-scroller',\n                cls: me.scrollerCls + ' ' + me.afterScrollerCls,\n                style: 'display:none'\n            }\n        };\n    },\n\n    getOverflowCls: function() {\n        return Ext.baseCSSPrefix + this.layout.direction + '-box-overflow-body';\n    },\n\n    initCSSClasses: function() {\n        var me = this,\n            prefix = Ext.baseCSSPrefix,\n            layout = me.layout,\n            names = layout.getNames(),\n            leftName = names.left,\n            rightName = names.right,\n            type = me.getOwnerType(layout.owner);\n\n        me.beforeCtCls = me.beforeCtCls || prefix + 'box-scroller-' + leftName;\n        me.afterCtCls  = me.afterCtCls  || prefix + 'box-scroller-' + rightName;\n        \n        me.beforeScrollerCls = me.beforeScrollerCls || prefix + type + '-scroll-' + leftName;\n        me.afterScrollerCls  = me.afterScrollerCls  || prefix + type + '-scroll-' + rightName;\n    },\n\n    beginLayout: function (ownerContext) {\n        var layout = this.layout,\n            names = layout.getNames();\n\n        ownerContext.innerCtScrollPos = layout.innerCt.dom['scroll' + names.leftCap];\n\n        this.callParent(arguments);\n    },\n\n    completeLayout: function (ownerContext) {\n        // capture this before callParent since it calls handle/clearOverflow:\n        this.scrollSize = ownerContext.props['content'+this.layout.getNames().widthCap];\n\n        this.callParent(arguments);\n    },\n    \n    finishedLayout: function(ownerContext) {\n        var me = this,\n            layout = me.layout,\n            names = layout.getNames(),\n            scrollPos = Math.min(me.getMaxScrollPosition(), ownerContext.innerCtScrollPos);\n\n        layout.innerCt.dom['scroll' + names.leftCap] = scrollPos;\n    },\n\n    handleOverflow: function(ownerContext) {\n        var me = this,\n            layout = me.layout,\n            names = layout.getNames(),\n            methodName = 'get' + names.widthCap;\n\n        me.captureChildElements();\n        me.showScrollers();\n\n        return {\n            reservedSpace: me.beforeCt[methodName]() + me.afterCt[methodName]()\n        };\n    },\n\n    /**\n     * @private\n     * Gets references to the beforeCt and afterCt elements if they have not already been captured\n     * and creates click handlers for them.\n     */\n    captureChildElements: function() {\n        var me = this,\n            el = me.layout.owner.el,\n            before,\n            after;\n\n        // Grab the scroll click receiving elements\n        if (!me.beforeCt) {\n            before = me.beforeScroller = el.getById(me.layout.owner.id + '-before-scroller');\n            after = me.afterScroller = el.getById(me.layout.owner.id + '-after-scroller');\n            me.beforeCt = before.up('');\n            me.afterCt = after.up('');\n            me.createWheelListener();\n\n            before.addClsOnOver(me.beforeScrollerCls + '-hover');\n            after.addClsOnOver(me.afterScrollerCls + '-hover');\n\n            before.setVisibilityMode(Ext.Element.DISPLAY);\n            after.setVisibilityMode(Ext.Element.DISPLAY);\n\n            me.beforeRepeater = new Ext.util.ClickRepeater(before, {\n                interval: me.scrollRepeatInterval,\n                handler : me.scrollLeft,\n                scope   : me\n            });\n\n            me.afterRepeater = new Ext.util.ClickRepeater(after, {\n                interval: me.scrollRepeatInterval,\n                handler : me.scrollRight,\n                scope   : me\n            });\n        }\n    },\n\n    /**\n     * @private\n     * Sets up an listener to scroll on the layout's innerCt mousewheel event\n     */\n    createWheelListener: function() {\n        this.layout.innerCt.on({\n            mousewheel: function(e) {\n                this.scrollBy(e.getWheelDelta() * this.wheelIncrement * -1, false);\n            },\n            stopEvent: true,\n            scope: this\n        });\n    },\n\n    /**\n     * @private\n     */\n    clearOverflow: function () {\n        var layout = this.layout;\n\n        this.hideScrollers();\n    },\n\n    /**\n     * @private\n     * Shows the scroller elements in the beforeCt and afterCt. Creates the scrollers first if they are not already\n     * present. \n     */\n    showScrollers: function() {\n        var me = this;\n\n        me.captureChildElements();\n        me.beforeScroller.show();\n        me.afterScroller.show();\n        me.updateScrollButtons();\n        me.layout.owner.addClsWithUI('scroller');\n        // TODO - this may invalidates data in the ContextItem's styleCache\n    },\n\n    /**\n     * @private\n     * Hides the scroller elements in the beforeCt and afterCt\n     */\n    hideScrollers: function() {\n        var me = this;\n\n        if (me.beforeScroller !== undefined) {\n            me.beforeScroller.hide();\n            me.afterScroller.hide();\n            me.layout.owner.removeClsWithUI('scroller');\n            // TODO - this may invalidates data in the ContextItem's styleCache\n        }\n    },\n\n    /**\n     * @private\n     */\n    destroy: function() {\n        var me = this;\n\n        Ext.destroy(me.beforeRepeater, me.afterRepeater, me.beforeScroller, me.afterScroller, me.beforeCt, me.afterCt);\n    },\n\n    /**\n     * @private\n     * Scrolls left or right by the number of pixels specified\n     * @param {Number} delta Number of pixels to scroll to the right by. Use a negative number to scroll left\n     */\n    scrollBy: function(delta, animate) {\n        this.scrollTo(this.getScrollPosition() + delta, animate);\n    },\n\n    /**\n     * @private\n     * @return {Object} Object passed to scrollTo when scrolling\n     */\n    getScrollAnim: function() {\n        return {\n            duration: this.scrollDuration, \n            callback: this.updateScrollButtons, \n            scope   : this\n        };\n    },\n\n    /**\n     * @private\n     * Enables or disables each scroller button based on the current scroll position\n     */\n    updateScrollButtons: function() {\n        var me = this,\n            beforeMeth,\n            afterMeth,\n            beforeCls,\n            afterCls;\n            \n        if (me.beforeScroller === undefined || me.afterScroller === undefined) {\n            return;\n        }\n\n        beforeMeth = me.atExtremeBefore()  ? 'addCls' : 'removeCls';\n        afterMeth  = me.atExtremeAfter() ? 'addCls' : 'removeCls';\n        beforeCls  = me.beforeScrollerCls + '-disabled';\n        afterCls   = me.afterScrollerCls  + '-disabled';\n\n        me.beforeScroller[beforeMeth](beforeCls);\n        me.afterScroller[afterMeth](afterCls);\n        me.scrolling = false;\n    },\n\n    /**\n     * @private\n     * Returns true if the innerCt scroll is already at its left-most point\n     * @return {Boolean} True if already at furthest left point\n     */\n    atExtremeBefore: function() {\n        return !this.getScrollPosition();\n    },\n\n    /**\n     * @private\n     * Scrolls to the left by the configured amount\n     */\n    scrollLeft: function() {\n        this.scrollBy(-this.scrollIncrement, false);\n    },\n\n    /**\n     * @private\n     * Scrolls to the right by the configured amount\n     */\n    scrollRight: function() {\n        this.scrollBy(this.scrollIncrement, false);\n    },\n\n    /**\n     * Returns the current scroll position of the innerCt element\n     * @return {Number} The current scroll position\n     */\n    getScrollPosition: function(){\n        var me = this,\n            layout = me.layout,\n            result;\n\n        // Until we actually scroll, the scroll[Top|Left] is stored as zero to avoid DOM hits.\n        if (me.hasOwnProperty('scrollPosition')) {\n            result = me.scrollPosition;\n        } else {\n            result = parseInt(layout.innerCt.dom['scroll' + layout.getNames().leftCap], 10) || 0;\n        }\n        return result;\n    },\n\n    /**\n     * @private\n     * Returns the maximum value we can scrollTo\n     * @return {Number} The max scroll value\n     */\n    getMaxScrollPosition: function() {\n        var me = this,\n            layout = me.layout,\n            names = layout.getNames(),\n            maxScrollPos = me.scrollSize - layout.innerCt['get'+names.widthCap]();\n\n        return (maxScrollPos < 0) ? 0 : maxScrollPos;\n    },\n\n    /**\n     * @private\n     * Returns true if the innerCt scroll is already at its right-most point\n     * @return {Boolean} True if already at furthest right point\n     */\n    atExtremeAfter: function() {\n        return this.getScrollPosition() >= this.getMaxScrollPosition();\n    },\n\n    /**\n     * @private\n     * Scrolls to the given position. Performs bounds checking.\n     * @param {Number} position The position to scroll to. This is constrained.\n     * @param {Boolean} animate True to animate. If undefined, falls back to value of this.animateScroll\n     */\n    scrollTo: function(position, animate) {\n        var me = this,\n            layout = me.layout,\n            names = layout.getNames(),\n            oldPosition = me.getScrollPosition(),\n            newPosition = Ext.Number.constrain(position, 0, me.getMaxScrollPosition());\n\n        if (newPosition != oldPosition && !me.scrolling) {\n            delete me.scrollPosition;\n            if (animate === undefined) {\n                animate = me.animateScroll;\n            }\n\n            layout.innerCt.scrollTo(names.left, newPosition, animate ? me.getScrollAnim() : false);\n            if (animate) {\n                me.scrolling = true;\n            } else {\n                me.updateScrollButtons();\n            }\n            me.fireEvent('scroll', me, newPosition, animate ? me.getScrollAnim() : false);\n        }\n    },\n\n    /**\n     * Scrolls to the given component.\n     * @param {String/Number/Ext.Component} item The item to scroll to. Can be a numerical index, component id \n     * or a reference to the component itself.\n     * @param {Boolean} animate True to animate the scrolling\n     */\n    scrollToItem: function(item, animate) {\n        var me = this,\n            layout = me.layout,\n            names = layout.getNames(),\n            visibility,\n            box,\n            newPos;\n\n        item = me.getItem(item);\n        if (item !== undefined) {\n            visibility = me.getItemVisibility(item);\n            if (!visibility.fullyVisible) {\n                box  = item.getBox(true, true);\n                newPos = box[names.x];\n                if (visibility.hiddenEnd) {\n                    newPos -= (me.layout.innerCt['get' + names.widthCap]() - box[names.width]);\n                }\n                me.scrollTo(newPos, animate);\n            }\n        }\n    },\n\n    /**\n     * @private\n     * For a given item in the container, return an object with information on whether the item is visible\n     * with the current innerCt scroll value.\n     * @param {Ext.Component} item The item\n     * @return {Object} Values for fullyVisible, hiddenStart and hiddenEnd\n     */\n    getItemVisibility: function(item) {\n        var me          = this,\n            box         = me.getItem(item).getBox(true, true),\n            layout      = me.layout,\n            names       = layout.getNames(),\n            itemStart   = box[names.x],\n            itemEnd     = itemStart + box[names.width],\n            scrollStart = me.getScrollPosition(),\n            scrollEnd   = scrollStart + layout.innerCt['get' + names.widthCap]();\n\n        return {\n            hiddenStart : itemStart < scrollStart,\n            hiddenEnd   : itemEnd > scrollEnd,\n            fullyVisible: itemStart > scrollStart && itemEnd < scrollEnd\n        };\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.util.Offset', {\n\n    /* Begin Definitions */\n\n    statics: {\n        fromObject: function(obj) {\n            return new this(obj.x, obj.y);\n        }\n    },\n\n    /* End Definitions */\n\n    constructor: function(x, y) {\n        this.x = (x != null && !isNaN(x)) ? x : 0;\n        this.y = (y != null && !isNaN(y)) ? y : 0;\n\n        return this;\n    },\n\n    copy: function() {\n        return new Ext.util.Offset(this.x, this.y);\n    },\n\n    copyFrom: function(p) {\n        this.x = p.x;\n        this.y = p.y;\n    },\n\n    toString: function() {\n        return \"Offset[\" + this.x + \",\" + this.y + \"]\";\n    },\n\n    equals: function(offset) {\n        if(!(offset instanceof this.statics())) {\n            Ext.Error.raise('Offset must be an instance of Ext.util.Offset');\n        }\n\n        return (this.x == offset.x && this.y == offset.y);\n    },\n\n    round: function(to) {\n        if (!isNaN(to)) {\n            var factor = Math.pow(10, to);\n            this.x = Math.round(this.x * factor) / factor;\n            this.y = Math.round(this.y * factor) / factor;\n        } else {\n            this.x = Math.round(this.x);\n            this.y = Math.round(this.y);\n        }\n    },\n\n    isZero: function() {\n        return this.x == 0 && this.y == 0;\n    }\n});\n\n/**\n * This class represents a rectangular region in X,Y space, and performs geometric\n * transformations or tests upon the region.\n *\n * This class may be used to compare the document regions occupied by elements.\n */\nExt.define('Ext.util.Region', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.util.Offset'],\n\n    statics: {\n        /**\n         * @static\n         * Retrieves an Ext.util.Region for a particular element.\n         * @param {String/HTMLElement/Ext.Element} el An element ID, htmlElement or Ext.Element representing an element in the document.\n         * @returns {Ext.util.Region} region\n         */\n        getRegion: function(el) {\n            return Ext.fly(el).getPageBox(true);\n        },\n\n        /**\n         * @static\n         * Creates a Region from a \"box\" Object which contains four numeric properties `top`, `right`, `bottom` and `left`.\n         * @param {Object} o An object with `top`, `right`, `bottom` and `left` properties.\n         * @return {Ext.util.Region} region The Region constructed based on the passed object\n         */\n        from: function(o) {\n            return new this(o.top, o.right, o.bottom, o.left);\n        }\n    },\n\n    /* End Definitions */\n\n    /**\n     * Creates a region from the bounding sides.\n     * @param {Number} top Top The topmost pixel of the Region.\n     * @param {Number} right Right The rightmost pixel of the Region.\n     * @param {Number} bottom Bottom The bottom pixel of the Region.\n     * @param {Number} left Left The leftmost pixel of the Region.\n     */\n    constructor : function(t, r, b, l) {\n        var me = this;\n        me.y = me.top = me[1] = t;\n        me.right = r;\n        me.bottom = b;\n        me.x = me.left = me[0] = l;\n    },\n\n    /**\n     * Checks if this region completely contains the region that is passed in.\n     * @param {Ext.util.Region} region\n     * @return {Boolean}\n     */\n    contains : function(region) {\n        var me = this;\n        return (region.x >= me.x &&\n                region.right <= me.right &&\n                region.y >= me.y &&\n                region.bottom <= me.bottom);\n\n    },\n\n    /**\n     * Checks if this region intersects the region passed in.\n     * @param {Ext.util.Region} region\n     * @return {Ext.util.Region/Boolean} Returns the intersected region or false if there is no intersection.\n     */\n    intersect : function(region) {\n        var me = this,\n            t = Math.max(me.y, region.y),\n            r = Math.min(me.right, region.right),\n            b = Math.min(me.bottom, region.bottom),\n            l = Math.max(me.x, region.x);\n\n        if (b > t && r > l) {\n            return new this.self(t, r, b, l);\n        }\n        else {\n            return false;\n        }\n    },\n\n    /**\n     * Returns the smallest region that contains the current AND targetRegion.\n     * @param {Ext.util.Region} region\n     * @return {Ext.util.Region} a new region\n     */\n    union : function(region) {\n        var me = this,\n            t = Math.min(me.y, region.y),\n            r = Math.max(me.right, region.right),\n            b = Math.max(me.bottom, region.bottom),\n            l = Math.min(me.x, region.x);\n\n        return new this.self(t, r, b, l);\n    },\n\n    /**\n     * Modifies the current region to be constrained to the targetRegion.\n     * @param {Ext.util.Region} targetRegion\n     * @return {Ext.util.Region} this\n     */\n    constrainTo : function(r) {\n        var me = this,\n            constrain = Ext.Number.constrain;\n        me.top = me.y = constrain(me.top, r.y, r.bottom);\n        me.bottom = constrain(me.bottom, r.y, r.bottom);\n        me.left = me.x = constrain(me.left, r.x, r.right);\n        me.right = constrain(me.right, r.x, r.right);\n        return me;\n    },\n\n    /**\n     * Modifies the current region to be adjusted by offsets.\n     * @param {Number} top top offset\n     * @param {Number} right right offset\n     * @param {Number} bottom bottom offset\n     * @param {Number} left left offset\n     * @return {Ext.util.Region} this\n     */\n    adjust : function(t, r, b, l) {\n        var me = this;\n        me.top = me.y += t;\n        me.left = me.x += l;\n        me.right += r;\n        me.bottom += b;\n        return me;\n    },\n\n    /**\n     * Get the offset amount of a point outside the region\n     * @param {String} [axis]\n     * @param {Ext.util.Point} [p] the point\n     * @return {Ext.util.Offset}\n     */\n    getOutOfBoundOffset: function(axis, p) {\n        if (!Ext.isObject(axis)) {\n            if (axis == 'x') {\n                return this.getOutOfBoundOffsetX(p);\n            } else {\n                return this.getOutOfBoundOffsetY(p);\n            }\n        } else {\n            p = axis;\n            var d = new Ext.util.Offset();\n            d.x = this.getOutOfBoundOffsetX(p.x);\n            d.y = this.getOutOfBoundOffsetY(p.y);\n            return d;\n        }\n\n    },\n\n    /**\n     * Get the offset amount on the x-axis\n     * @param {Number} p the offset\n     * @return {Number}\n     */\n    getOutOfBoundOffsetX: function(p) {\n        if (p <= this.x) {\n            return this.x - p;\n        } else if (p >= this.right) {\n            return this.right - p;\n        }\n\n        return 0;\n    },\n\n    /**\n     * Get the offset amount on the y-axis\n     * @param {Number} p the offset\n     * @return {Number}\n     */\n    getOutOfBoundOffsetY: function(p) {\n        if (p <= this.y) {\n            return this.y - p;\n        } else if (p >= this.bottom) {\n            return this.bottom - p;\n        }\n\n        return 0;\n    },\n\n    /**\n     * Check whether the point / offset is out of bound\n     * @param {String} [axis]\n     * @param {Ext.util.Point/Number} [p] the point / offset\n     * @return {Boolean}\n     */\n    isOutOfBound: function(axis, p) {\n        if (!Ext.isObject(axis)) {\n            if (axis == 'x') {\n                return this.isOutOfBoundX(p);\n            } else {\n                return this.isOutOfBoundY(p);\n            }\n        } else {\n            p = axis;\n            return (this.isOutOfBoundX(p.x) || this.isOutOfBoundY(p.y));\n        }\n    },\n\n    /**\n     * Check whether the offset is out of bound in the x-axis\n     * @param {Number} p the offset\n     * @return {Boolean}\n     */\n    isOutOfBoundX: function(p) {\n        return (p < this.x || p > this.right);\n    },\n\n    /**\n     * Check whether the offset is out of bound in the y-axis\n     * @param {Number} p the offset\n     * @return {Boolean}\n     */\n    isOutOfBoundY: function(p) {\n        return (p < this.y || p > this.bottom);\n    },\n\n    /**\n     * Restrict a point within the region by a certain factor.\n     * @param {String} [axis]\n     * @param {Ext.util.Point/Ext.util.Offset/Object} [p]\n     * @param {Number} [factor]\n     * @return {Ext.util.Point/Ext.util.Offset/Object/Number}\n     * @private\n     */\n    restrict: function(axis, p, factor) {\n        if (Ext.isObject(axis)) {\n            var newP;\n\n            factor = p;\n            p = axis;\n\n            if (p.copy) {\n                newP = p.copy();\n            }\n            else {\n                newP = {\n                    x: p.x,\n                    y: p.y\n                };\n            }\n\n            newP.x = this.restrictX(p.x, factor);\n            newP.y = this.restrictY(p.y, factor);\n            return newP;\n        } else {\n            if (axis == 'x') {\n                return this.restrictX(p, factor);\n            } else {\n                return this.restrictY(p, factor);\n            }\n        }\n    },\n\n    /**\n     * Restrict an offset within the region by a certain factor, on the x-axis\n     * @param {Number} p\n     * @param {Number} [factor=1] The factor.\n     * @return {Number}\n     * @private\n     */\n    restrictX : function(p, factor) {\n        if (!factor) {\n            factor = 1;\n        }\n\n        if (p <= this.x) {\n            p -= (p - this.x) * factor;\n        }\n        else if (p >= this.right) {\n            p -= (p - this.right) * factor;\n        }\n        return p;\n    },\n\n    /**\n     * Restrict an offset within the region by a certain factor, on the y-axis\n     * @param {Number} p\n     * @param {Number} [factor] The factor, defaults to 1\n     * @return {Number}\n     * @private\n     */\n    restrictY : function(p, factor) {\n        if (!factor) {\n            factor = 1;\n        }\n\n        if (p <= this.y) {\n            p -= (p - this.y) * factor;\n        }\n        else if (p >= this.bottom) {\n            p -= (p - this.bottom) * factor;\n        }\n        return p;\n    },\n\n    /**\n     * Get the width / height of this region\n     * @return {Object} an object with width and height properties\n     * @private\n     */\n    getSize: function() {\n        return {\n            width: this.right - this.x,\n            height: this.bottom - this.y\n        };\n    },\n\n    /**\n     * Create a copy of this Region.\n     * @return {Ext.util.Region}\n     */\n    copy: function() {\n        return new this.self(this.y, this.right, this.bottom, this.x);\n    },\n\n    /**\n     * Copy the values of another Region to this Region\n     * @param {Ext.util.Region} p The region to copy from.\n     * @return {Ext.util.Region} This Region\n     */\n    copyFrom: function(p) {\n        var me = this;\n        me.top = me.y = me[1] = p.y;\n        me.right = p.right;\n        me.bottom = p.bottom;\n        me.left = me.x = me[0] = p.x;\n\n        return this;\n    },\n\n    /*\n     * Dump this to an eye-friendly string, great for debugging\n     * @return {String}\n     */\n    toString: function() {\n        return \"Region[\" + this.top + \",\" + this.right + \",\" + this.bottom + \",\" + this.left + \"]\";\n    },\n\n    /**\n     * Translate this region by the given offset amount\n     * @param {Ext.util.Offset/Object} x Object containing the `x` and `y` properties.\n     * Or the x value is using the two argument form.\n     * @param {Number} y The y value unless using an Offset object.\n     * @return {Ext.util.Region} this This Region\n     */\n    translateBy: function(x, y) {\n        if (arguments.length == 1) {\n            y = x.y;\n            x = x.x;\n        }\n        var me = this;\n        me.top = me.y += y;\n        me.right += x;\n        me.bottom += y;\n        me.left = me.x += x;\n\n        return me;\n    },\n\n    /**\n     * Round all the properties of this region\n     * @return {Ext.util.Region} this This Region\n     */\n    round: function() {\n        var me = this;\n        me.top = me.y = Math.round(me.y);\n        me.right = Math.round(me.right);\n        me.bottom = Math.round(me.bottom);\n        me.left = me.x = Math.round(me.x);\n\n        return me;\n    },\n\n    /**\n     * Check whether this region is equivalent to the given region\n     * @param {Ext.util.Region} region The region to compare with\n     * @return {Boolean}\n     */\n    equals: function(region) {\n        return (this.top == region.top && this.right == region.right && this.bottom == region.bottom && this.left == region.left);\n    }\n});\n\n/*\n * This is a derivative of the similarly named class in the YUI Library.\n * The original license:\n * Copyright (c) 2006, Yahoo! Inc. All rights reserved.\n * Code licensed under the BSD License:\n * http://developer.yahoo.net/yui/license.txt\n */\n\n\n/**\n * DragDropManager is a singleton that tracks the element interaction for\n * all DragDrop items in the window.  Generally, you will not call\n * this class directly, but it does have helper methods that could\n * be useful in your DragDrop implementations.\n */\nExt.define('Ext.dd.DragDropManager', {\n    singleton: true,\n\n    requires: ['Ext.util.Region'],\n\n    uses: ['Ext.tip.QuickTipManager'],\n\n    // shorter ClassName, to save bytes and use internally\n    alternateClassName: ['Ext.dd.DragDropMgr', 'Ext.dd.DDM'],\n\n    /**\n     * @property {String[]} ids\n     * Two dimensional Array of registered DragDrop objects.  The first\n     * dimension is the DragDrop item group, the second the DragDrop\n     * object.\n     * @private\n     */\n    ids: {},\n\n    /**\n     * @property {String[]} handleIds\n     * Array of element ids defined as drag handles.  Used to determine\n     * if the element that generated the mousedown event is actually the\n     * handle and not the html element itself.\n     * @private\n     */\n    handleIds: {},\n\n    /**\n     * @property {Ext.dd.DragDrop} dragCurrent\n     * the DragDrop object that is currently being dragged\n     * @private\n     */\n    dragCurrent: null,\n\n    /**\n     * @property {Ext.dd.DragDrop[]} dragOvers\n     * the DragDrop object(s) that are being hovered over\n     * @private\n     */\n    dragOvers: {},\n\n    /**\n     * @property {Number} deltaX\n     * the X distance between the cursor and the object being dragged\n     * @private\n     */\n    deltaX: 0,\n\n    /**\n     * @property {Number} deltaY\n     * the Y distance between the cursor and the object being dragged\n     * @private\n     */\n    deltaY: 0,\n\n    /**\n     * @property {Boolean} preventDefault\n     * Flag to determine if we should prevent the default behavior of the\n     * events we define. By default this is true, but this can be set to\n     * false if you need the default behavior (not recommended)\n     */\n    preventDefault: true,\n\n    /**\n     * @property {Boolean} stopPropagation\n     * Flag to determine if we should stop the propagation of the events\n     * we generate. This is true by default but you may want to set it to\n     * false if the html element contains other features that require the\n     * mouse click.\n     */\n    stopPropagation: true,\n\n    /**\n     * Internal flag that is set to true when drag and drop has been\n     * intialized\n     * @property initialized\n     * @private\n     */\n    initialized: false,\n\n    /**\n     * All drag and drop can be disabled.\n     * @property locked\n     * @private\n     */\n    locked: false,\n\n    /**\n     * Called the first time an element is registered.\n     * @private\n     */\n    init: function() {\n        this.initialized = true;\n    },\n\n    /**\n     * @property {Number} POINT\n     * In point mode, drag and drop interaction is defined by the\n     * location of the cursor during the drag/drop\n     */\n    POINT: 0,\n\n    /**\n     * @property {Number} INTERSECT\n     * In intersect mode, drag and drop interaction is defined by the\n     * overlap of two or more drag and drop objects.\n     */\n    INTERSECT: 1,\n\n    /**\n     * @property {Number} mode\n     * The current drag and drop mode.  Default: POINT\n     */\n    mode: 0,\n\n    /**\n     * @property {Boolean} [notifyOccluded=false]\n     * This config is only provided to provide old, usually unwanted drag/drop behaviour.\n     *\n     * From ExtJS 4.1.0 onwards, when drop targets are contained in floating, absolutely positioned elements\n     * such as in {@link Ext.window.Window Windows}, which may overlap each other, `over` and `drop` events\n     * are only delivered to the topmost drop target at the mouse position.\n     *\n     * If all targets below that in zIndex order should also receive notifications, set\n     * `notifyOccluded` to `true`.\n     */\n    notifyOccluded: false,\n\n    /**\n     * Runs method on all drag and drop objects\n     * @private\n     */\n    _execOnAll: function(sMethod, args) {\n        var i, j, oDD;\n        for (i in this.ids) {\n            for (j in this.ids[i]) {\n                oDD = this.ids[i][j];\n                if (! this.isTypeOfDD(oDD)) {\n                    continue;\n                }\n                oDD[sMethod].apply(oDD, args);\n            }\n        }\n    },\n\n    /**\n     * Drag and drop initialization.  Sets up the global event handlers\n     * @private\n     */\n    _onLoad: function() {\n\n        this.init();\n\n        var Event = Ext.EventManager;\n        Event.on(document, \"mouseup\",   this.handleMouseUp, this, true);\n        Event.on(document, \"mousemove\", this.handleMouseMove, this, true);\n        Event.on(window,   \"unload\",    this._onUnload, this, true);\n        Event.on(window,   \"resize\",    this._onResize, this, true);\n        // Event.on(window,   \"mouseout\",    this._test);\n\n    },\n\n    /**\n     * Reset constraints on all drag and drop objs\n     * @private\n     */\n    _onResize: function(e) {\n        this._execOnAll(\"resetConstraints\", []);\n    },\n\n    /**\n     * Lock all drag and drop functionality\n     */\n    lock: function() { this.locked = true; },\n\n    /**\n     * Unlock all drag and drop functionality\n     */\n    unlock: function() { this.locked = false; },\n\n    /**\n     * Is drag and drop locked?\n     * @return {Boolean} True if drag and drop is locked, false otherwise.\n     */\n    isLocked: function() { return this.locked; },\n\n    /**\n     * @property {Object} locationCache\n     * Location cache that is set for all drag drop objects when a drag is\n     * initiated, cleared when the drag is finished.\n     * @private\n     */\n    locationCache: {},\n\n    /**\n     * @property {Boolean} useCache\n     * Set useCache to false if you want to force object the lookup of each\n     * drag and drop linked element constantly during a drag.\n     */\n    useCache: true,\n\n    /**\n     * @property {Number} clickPixelThresh\n     * The number of pixels that the mouse needs to move after the\n     * mousedown before the drag is initiated.  Default=3;\n     */\n    clickPixelThresh: 3,\n\n    /**\n     * @property {Number} clickTimeThresh\n     * The number of milliseconds after the mousedown event to initiate the\n     * drag if we don't get a mouseup event. Default=350\n     */\n    clickTimeThresh: 350,\n\n    /**\n     * @property {Boolean} dragThreshMet\n     * Flag that indicates that either the drag pixel threshold or the\n     * mousdown time threshold has been met\n     * @private\n     */\n    dragThreshMet: false,\n\n    /**\n     * @property {Object} clickTimeout\n     * Timeout used for the click time threshold\n     * @private\n     */\n    clickTimeout: null,\n\n    /**\n     * @property {Number} startX\n     * The X position of the mousedown event stored for later use when a\n     * drag threshold is met.\n     * @private\n     */\n    startX: 0,\n\n    /**\n     * @property {Number} startY\n     * The Y position of the mousedown event stored for later use when a\n     * drag threshold is met.\n     * @private\n     */\n    startY: 0,\n\n    /**\n     * Each DragDrop instance must be registered with the DragDropManager.\n     * This is executed in DragDrop.init()\n     * @param {Ext.dd.DragDrop} oDD the DragDrop object to register\n     * @param {String} sGroup the name of the group this element belongs to\n     */\n    regDragDrop: function(oDD, sGroup) {\n        if (!this.initialized) { this.init(); }\n\n        if (!this.ids[sGroup]) {\n            this.ids[sGroup] = {};\n        }\n        this.ids[sGroup][oDD.id] = oDD;\n    },\n\n    /**\n     * Removes the supplied dd instance from the supplied group. Executed\n     * by DragDrop.removeFromGroup, so don't call this function directly.\n     * @private\n     */\n    removeDDFromGroup: function(oDD, sGroup) {\n        if (!this.ids[sGroup]) {\n            this.ids[sGroup] = {};\n        }\n\n        var obj = this.ids[sGroup];\n        if (obj && obj[oDD.id]) {\n            delete obj[oDD.id];\n        }\n    },\n\n    /**\n     * Unregisters a drag and drop item.  This is executed in\n     * DragDrop.unreg, use that method instead of calling this directly.\n     * @private\n     */\n    _remove: function(oDD) {\n        for (var g in oDD.groups) {\n            if (g && this.ids[g] && this.ids[g][oDD.id]) {\n                delete this.ids[g][oDD.id];\n            }\n        }\n        delete this.handleIds[oDD.id];\n    },\n\n    /**\n     * Each DragDrop handle element must be registered.  This is done\n     * automatically when executing DragDrop.setHandleElId()\n     * @param {String} sDDId the DragDrop id this element is a handle for\n     * @param {String} sHandleId the id of the element that is the drag\n     * handle\n     */\n    regHandle: function(sDDId, sHandleId) {\n        if (!this.handleIds[sDDId]) {\n            this.handleIds[sDDId] = {};\n        }\n        this.handleIds[sDDId][sHandleId] = sHandleId;\n    },\n\n    /**\n     * Utility function to determine if a given element has been\n     * registered as a drag drop item.\n     * @param {String} id the element id to check\n     * @return {Boolean} true if this element is a DragDrop item,\n     * false otherwise\n     */\n    isDragDrop: function(id) {\n        return ( this.getDDById(id) ) ? true : false;\n    },\n\n    /**\n     * Returns the drag and drop instances that are in all groups the\n     * passed in instance belongs to.\n     * @param {Ext.dd.DragDrop} p_oDD the obj to get related data for\n     * @param {Boolean} bTargetsOnly if true, only return targetable objs\n     * @return {Ext.dd.DragDrop[]} the related instances\n     */\n    getRelated: function(p_oDD, bTargetsOnly) {\n        var oDDs = [],\n            i, j, dd;\n        for (i in p_oDD.groups) {\n            for (j in this.ids[i]) {\n                dd = this.ids[i][j];\n                if (! this.isTypeOfDD(dd)) {\n                    continue;\n                }\n                if (!bTargetsOnly || dd.isTarget) {\n                    oDDs[oDDs.length] = dd;\n                }\n            }\n        }\n\n        return oDDs;\n    },\n\n    /**\n     * Returns true if the specified dd target is a legal target for\n     * the specifice drag obj\n     * @param {Ext.dd.DragDrop} oDD the drag obj\n     * @param {Ext.dd.DragDrop} oTargetDD the target\n     * @return {Boolean} true if the target is a legal target for the\n     * dd obj\n     */\n    isLegalTarget: function (oDD, oTargetDD) {\n        var targets = this.getRelated(oDD, true),\n            i, len;\n        for (i=0, len=targets.length;i<len;++i) {\n            if (targets[i].id == oTargetDD.id) {\n                return true;\n            }\n        }\n\n        return false;\n    },\n\n    /**\n     * My goal is to be able to transparently determine if an object is\n     * typeof DragDrop, and the exact subclass of DragDrop.  typeof\n     * returns \"object\", oDD.constructor.toString() always returns\n     * \"DragDrop\" and not the name of the subclass.  So for now it just\n     * evaluates a well-known variable in DragDrop.\n     * @param {Object} the object to evaluate\n     * @return {Boolean} true if typeof oDD = DragDrop\n     */\n    isTypeOfDD: function (oDD) {\n        return (oDD && oDD.__ygDragDrop);\n    },\n\n    /**\n     * Utility function to determine if a given element has been\n     * registered as a drag drop handle for the given Drag Drop object.\n     * @param {String} id the element id to check\n     * @return {Boolean} true if this element is a DragDrop handle, false\n     * otherwise\n     */\n    isHandle: function(sDDId, sHandleId) {\n        return ( this.handleIds[sDDId] &&\n                        this.handleIds[sDDId][sHandleId] );\n    },\n\n    /**\n     * Returns the DragDrop instance for a given id\n     * @param {String} id the id of the DragDrop object\n     * @return {Ext.dd.DragDrop} the drag drop object, null if it is not found\n     */\n    getDDById: function(id) {\n        var me = this,\n            i, dd;\n        for (i in this.ids) {\n            dd = this.ids[i][id];\n            if (dd instanceof Ext.dd.DDTarget) {\n                return dd;\n            }\n        }\n        return null;\n    },\n\n    /**\n     * Fired after a registered DragDrop object gets the mousedown event.\n     * Sets up the events required to track the object being dragged\n     * @param {Event} e the event\n     * @param {Ext.dd.DragDrop} oDD the DragDrop object being dragged\n     * @private\n     */\n    handleMouseDown: function(e, oDD) {\n        if(Ext.tip.QuickTipManager){\n            Ext.tip.QuickTipManager.ddDisable();\n        }\n        if(this.dragCurrent){\n            // the original browser mouseup wasn't handled (e.g. outside FF browser window)\n            // so clean up first to avoid breaking the next drag\n            this.handleMouseUp(e);\n        }\n\n        this.currentTarget = e.getTarget();\n        this.dragCurrent = oDD;\n\n        var el = oDD.getEl();\n        \n        // We use this to handle an issu where a mouseup will not be detected \n        // if the mouseup event happens outside of the browser window. When the \n        // mouse comes back, any drag will still be active\n        // http://msdn.microsoft.com/en-us/library/ms537630(VS.85).aspx\n        if (Ext.isIE && el.setCapture) {\n            el.setCapture();\n        }\n\n        // track start position\n        this.startX = e.getPageX();\n        this.startY = e.getPageY();\n\n        this.deltaX = this.startX - el.offsetLeft;\n        this.deltaY = this.startY - el.offsetTop;\n\n        this.dragThreshMet = false;\n\n        this.clickTimeout = setTimeout(\n                function() {\n                    var DDM = Ext.dd.DragDropManager;\n                    DDM.startDrag(DDM.startX, DDM.startY);\n                },\n                this.clickTimeThresh );\n    },\n\n    /**\n     * Fired when either the drag pixel threshol or the mousedown hold\n     * time threshold has been met.\n     * @param {Number} x the X position of the original mousedown\n     * @param {Number} y the Y position of the original mousedown\n     */\n    startDrag: function(x, y) {\n        clearTimeout(this.clickTimeout);\n        if (this.dragCurrent) {\n            this.dragCurrent.b4StartDrag(x, y);\n            this.dragCurrent.startDrag(x, y);\n        }\n        this.dragThreshMet = true;\n    },\n\n    /**\n     * Internal function to handle the mouseup event.  Will be invoked\n     * from the context of the document.\n     * @param {Event} e the event\n     * @private\n     */\n    handleMouseUp: function(e) {\n        var current = this.dragCurrent;\n        \n        if(Ext.tip && Ext.tip.QuickTipManager){\n            Ext.tip.QuickTipManager.ddEnable();\n        }\n        if (!current) {\n            return;\n        }\n        \n        // See setCapture call in handleMouseDown\n        if (Ext.isIE && document.releaseCapture) {\n            document.releaseCapture();\n        }\n\n        clearTimeout(this.clickTimeout);\n\n        if (this.dragThreshMet) {\n            this.fireEvents(e, true);\n        }\n\n        this.stopDrag(e);\n\n        this.stopEvent(e);\n    },\n\n    /**\n     * Utility to stop event propagation and event default, if these\n     * features are turned on.\n     * @param {Event} e the event as returned by this.getEvent()\n     */\n    stopEvent: function(e){\n        if(this.stopPropagation) {\n            e.stopPropagation();\n        }\n\n        if (this.preventDefault) {\n            e.preventDefault();\n        }\n    },\n\n    /**\n     * Internal function to clean up event handlers after the drag\n     * operation is complete\n     * @param {Event} e the event\n     * @private\n     */\n    stopDrag: function(e) {\n        // Fire the drag end event for the item that was dragged\n        if (this.dragCurrent) {\n            if (this.dragThreshMet) {\n                this.dragCurrent.b4EndDrag(e);\n                this.dragCurrent.endDrag(e);\n            }\n\n            this.dragCurrent.onMouseUp(e);\n        }\n\n        this.dragCurrent = null;\n        this.dragOvers = {};\n    },\n\n    /**\n     * Internal function to handle the mousemove event.  Will be invoked\n     * from the context of the html element.\n     *\n     * @TODO figure out what we can do about mouse events lost when the\n     * user drags objects beyond the window boundary.  Currently we can\n     * detect this in internet explorer by verifying that the mouse is\n     * down during the mousemove event.  Firefox doesn't give us the\n     * button state on the mousemove event.\n     *\n     * @param {Event} e the event\n     * @private\n     */\n    handleMouseMove: function(e) {\n        var me = this,\n            diffX,\n            diffY;\n            \n        if (!me.dragCurrent) {\n            return true;\n        }\n\n        if (!me.dragThreshMet) {\n            diffX = Math.abs(me.startX - e.getPageX());\n            diffY = Math.abs(me.startY - e.getPageY());\n            if (diffX > me.clickPixelThresh ||\n                        diffY > me.clickPixelThresh) {\n                me.startDrag(me.startX, me.startY);\n            }\n        }\n\n        if (me.dragThreshMet) {\n            me.dragCurrent.b4Drag(e);\n            me.dragCurrent.onDrag(e);\n            if(!me.dragCurrent.moveOnly){\n                me.fireEvents(e, false);\n            }\n        }\n\n        me.stopEvent(e);\n\n        return true;\n    },\n\n    /**\n     * Iterates over all of the DragDrop elements to find ones we are\n     * hovering over or dropping on\n     * @param {Event} e the event\n     * @param {Boolean} isDrop is this a drop op or a mouseover op?\n     * @private\n     */\n    fireEvents: function(e, isDrop) {\n        var me = this,\n            dragCurrent = me.dragCurrent,\n            mousePoint = e.getPoint(),\n            overTarget,\n            overTargetEl,\n            allTargets = [],\n            oldOvers  = [],  // cache the previous dragOver array\n            outEvts   = [],\n            overEvts  = [],\n            dropEvts  = [],\n            enterEvts = [],\n            needsSort,\n            i,\n            len,\n            sGroup;\n\n        // If the user did the mouse up outside of the window, we could\n        // get here even though we have ended the drag.\n        if (!dragCurrent || dragCurrent.isLocked()) {\n            return;\n        }\n\n        // Check to see if the object(s) we were hovering over is no longer\n        // being hovered over so we can fire the onDragOut event\n        for (i in me.dragOvers) {\n\n            overTarget = me.dragOvers[i];\n\n            if (! me.isTypeOfDD(overTarget)) {\n                continue;\n            }\n\n            if (! this.isOverTarget(mousePoint, overTarget, me.mode)) {\n                outEvts.push( overTarget );\n            }\n\n            oldOvers[i] = true;\n            delete me.dragOvers[i];\n        }\n\n        // Collect all targets which are members of the same ddGoups that the dragCurrent is a member of, and which may recieve mouseover and drop notifications.\n        // This is preparatory to seeing which one(s) we are currently over\n        // Begin by iterating through the ddGroups of which the dragCurrent is a member\n        for (sGroup in dragCurrent.groups) {\n\n            if (\"string\" != typeof sGroup) {\n                continue;\n            }\n\n            // Loop over the registered members of each group, testing each as a potential target\n            for (i in me.ids[sGroup]) {\n                overTarget = me.ids[sGroup][i];\n\n                // The target is valid if it is a DD type\n                // And it's got a DOM element\n                // And it's configured to be a drop target\n                // And it's not locked\n                // And the DOM element is fully visible with no hidden ancestors\n                // And it's either not the dragCurrent, or, if it is, tha dragCurrent is configured to not ignore itself.\n                if (me.isTypeOfDD(overTarget) &&\n                        (overTargetEl = overTarget.getEl()) &&\n                        (overTarget.isTarget) &&\n                        (!overTarget.isLocked()) &&\n                        (Ext.fly(overTargetEl).isVisible(true)) &&\n                        ((overTarget != dragCurrent) || (dragCurrent.ignoreSelf === false))) {\n\n                    // Only sort by zIndex if there were some which had a floating zIndex value\n                    if ((overTarget.zIndex = me.getZIndex(overTargetEl)) !== -1) {\n                        needsSort = true;\n                    }\n                    allTargets.push(overTarget);\n                }\n            }\n        }\n\n        // If there were floating targets, sort the highest zIndex to the top\n        if (needsSort) {\n            Ext.Array.sort(allTargets, me.byZIndex);\n        }\n\n        // Loop through possible targets, notifying the one(s) we are over.\n        // Usually we only deliver events to the topmost.\n        for (i = 0, len = allTargets.length; i < len; i++) {\n            overTarget = allTargets[i];\n\n            // If we are over the overTarget, queue it up to recieve an event of whatever type we are handling\n            if (me.isOverTarget(mousePoint, overTarget, me.mode)) {\n                // look for drop interactions\n                if (isDrop) {\n                    dropEvts.push( overTarget );\n                // look for drag enter and drag over interactions\n                } else {\n\n                    // initial drag over: dragEnter fires\n                    if (!oldOvers[overTarget.id]) {\n                        enterEvts.push( overTarget );\n                    // subsequent drag overs: dragOver fires\n                    } else {\n                        overEvts.push( overTarget );\n                    }\n                    me.dragOvers[overTarget.id] = overTarget;\n                }\n\n                // Unless this DragDropManager has been explicitly configured to deliver events to multiple targets, then we are done.\n                if (!me.notifyOccluded) {\n                    break;\n                }\n            }\n        }\n\n        if (me.mode) {\n            if (outEvts.length) {\n                dragCurrent.b4DragOut(e, outEvts);\n                dragCurrent.onDragOut(e, outEvts);\n            }\n\n            if (enterEvts.length) {\n                dragCurrent.onDragEnter(e, enterEvts);\n            }\n\n            if (overEvts.length) {\n                dragCurrent.b4DragOver(e, overEvts);\n                dragCurrent.onDragOver(e, overEvts);\n            }\n\n            if (dropEvts.length) {\n                dragCurrent.b4DragDrop(e, dropEvts);\n                dragCurrent.onDragDrop(e, dropEvts);\n            }\n\n        } else {\n            // fire dragout events\n            for (i=0, len=outEvts.length; i<len; ++i) {\n                dragCurrent.b4DragOut(e, outEvts[i].id);\n                dragCurrent.onDragOut(e, outEvts[i].id);\n            }\n\n            // fire enter events\n            for (i=0,len=enterEvts.length; i<len; ++i) {\n                // dc.b4DragEnter(e, oDD.id);\n                dragCurrent.onDragEnter(e, enterEvts[i].id);\n            }\n\n            // fire over events\n            for (i=0,len=overEvts.length; i<len; ++i) {\n                dragCurrent.b4DragOver(e, overEvts[i].id);\n                dragCurrent.onDragOver(e, overEvts[i].id);\n            }\n\n            // fire drop events\n            for (i=0, len=dropEvts.length; i<len; ++i) {\n                dragCurrent.b4DragDrop(e, dropEvts[i].id);\n                dragCurrent.onDragDrop(e, dropEvts[i].id);\n            }\n\n        }\n\n        // notify about a drop that did not find a target\n        if (isDrop && !dropEvts.length) {\n            dragCurrent.onInvalidDrop(e);\n        }\n\n    },\n\n    /**\n     * @private\n     * Collects the z-index of the passed element, looking up the parentNode axis to find an absolutely positioned ancestor\n     * which is able to yield a z-index. If found to be not absolutely positionedm returns -1.\n     *\n     * This is used when sorting potential drop targets into z-index order so that only the topmost receives `over` and `drop` events.\n     *\n     * @return {Number} The z-index of the element, or of its topmost absolutely positioned ancestor. Returns -1 if the element is not\n     * absolutely positioned.\n     */\n    getZIndex: function(element) {\n        var body = document.body,\n            z,\n            zIndex = -1;\n\n        element = Ext.getDom(element);\n        while (element !== body) {\n            if (!isNaN(z = Number(Ext.fly(element).getStyle('zIndex')))) {\n                zIndex = z;\n            }\n            element = element.parentNode;\n        }\n        return zIndex;\n    },\n\n    /**\n     * @private\n     * Utility method to pass to {@link Ext.Array#sort} when sorting potential drop targets by z-index.\n     */\n    byZIndex: function(d1, d2) {\n        return d1.zIndex < d2.zIndex;\n    },\n\n    /**\n     * Helper function for getting the best match from the list of drag\n     * and drop objects returned by the drag and drop events when we are\n     * in INTERSECT mode.  It returns either the first object that the\n     * cursor is over, or the object that has the greatest overlap with\n     * the dragged element.\n     * @param  {Ext.dd.DragDrop[]} dds The array of drag and drop objects\n     * targeted\n     * @return {Ext.dd.DragDrop}       The best single match\n     */\n    getBestMatch: function(dds) {\n        var winner = null,\n            len = dds.length,\n            i, dd;\n        // Return null if the input is not what we expect\n        //if (!dds || !dds.length || dds.length == 0) {\n           // winner = null;\n        // If there is only one item, it wins\n        //} else if (dds.length == 1) {\n\n\n        if (len == 1) {\n            winner = dds[0];\n        } else {\n            // Loop through the targeted items\n            for (i=0; i<len; ++i) {\n                dd = dds[i];\n                // If the cursor is over the object, it wins.  If the\n                // cursor is over multiple matches, the first one we come\n                // to wins.\n                if (dd.cursorIsOver) {\n                    winner = dd;\n                    break;\n                // Otherwise the object with the most overlap wins\n                } else {\n                    if (!winner ||\n                        winner.overlap.getArea() < dd.overlap.getArea()) {\n                        winner = dd;\n                    }\n                }\n            }\n        }\n\n        return winner;\n    },\n\n    /**\n     * Refreshes the cache of the top-left and bottom-right points of the\n     * drag and drop objects in the specified group(s).  This is in the\n     * format that is stored in the drag and drop instance, so typical\n     * usage is:\n     *\n     *     Ext.dd.DragDropManager.refreshCache(ddinstance.groups);\n     *\n     * Alternatively:\n     *\n     *     Ext.dd.DragDropManager.refreshCache({group1:true, group2:true});\n     *\n     * @TODO this really should be an indexed array.  Alternatively this\n     * method could accept both.\n     *\n     * @param {Object} groups an associative array of groups to refresh\n     */\n    refreshCache: function(groups) {\n        var sGroup, i, oDD, loc;\n        for (sGroup in groups) {\n            if (\"string\" != typeof sGroup) {\n                continue;\n            }\n            for (i in this.ids[sGroup]) {\n                oDD = this.ids[sGroup][i];\n\n                if (this.isTypeOfDD(oDD)) {\n                // if (this.isTypeOfDD(oDD) && oDD.isTarget) {\n                    loc = this.getLocation(oDD);\n                    if (loc) {\n                        this.locationCache[oDD.id] = loc;\n                    } else {\n                        delete this.locationCache[oDD.id];\n                        // this will unregister the drag and drop object if\n                        // the element is not in a usable state\n                        // oDD.unreg();\n                    }\n                }\n            }\n        }\n    },\n\n    /**\n     * This checks to make sure an element exists and is in the DOM.  The\n     * main purpose is to handle cases where innerHTML is used to remove\n     * drag and drop objects from the DOM.  IE provides an 'unspecified\n     * error' when trying to access the offsetParent of such an element\n     * @param {HTMLElement} el the element to check\n     * @return {Boolean} true if the element looks usable\n     */\n    verifyEl: function(el) {\n        if (el) {\n            var parent;\n            if(Ext.isIE){\n                try{\n                    parent = el.offsetParent;\n                }catch(e){}\n            }else{\n                parent = el.offsetParent;\n            }\n            if (parent) {\n                return true;\n            }\n        }\n\n        return false;\n    },\n\n    /**\n     * Returns a Region object containing the drag and drop element's position\n     * and size, including the padding configured for it\n     * @param {Ext.dd.DragDrop} oDD the drag and drop object to get the location for.\n     * @return {Ext.util.Region} a Region object representing the total area\n     * the element occupies, including any padding\n     * the instance is configured for.\n     */\n    getLocation: function(oDD) {\n        if (! this.isTypeOfDD(oDD)) {\n            return null;\n        }\n\n        //delegate getLocation method to the\n        //drag and drop target.\n        if (oDD.getRegion) {\n            return oDD.getRegion();\n        }\n\n        var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;\n\n        try {\n            pos= Ext.Element.getXY(el);\n        } catch (e) { }\n\n        if (!pos) {\n            return null;\n        }\n\n        x1 = pos[0];\n        x2 = x1 + el.offsetWidth;\n        y1 = pos[1];\n        y2 = y1 + el.offsetHeight;\n\n        t = y1 - oDD.padding[0];\n        r = x2 + oDD.padding[1];\n        b = y2 + oDD.padding[2];\n        l = x1 - oDD.padding[3];\n\n        return new Ext.util.Region(t, r, b, l);\n    },\n\n    /**\n     * Checks the cursor location to see if it over the target\n     * @param {Ext.util.Point} pt The point to evaluate\n     * @param {Ext.dd.DragDrop} oTarget the DragDrop object we are inspecting\n     * @return {Boolean} true if the mouse is over the target\n     * @private\n     */\n    isOverTarget: function(pt, oTarget, intersect) {\n        // use cache if available\n        var loc = this.locationCache[oTarget.id],\n            dc, pos, el, curRegion, overlap;\n        if (!loc || !this.useCache) {\n            loc = this.getLocation(oTarget);\n            this.locationCache[oTarget.id] = loc;\n\n        }\n\n        if (!loc) {\n            return false;\n        }\n\n        oTarget.cursorIsOver = loc.contains( pt );\n\n        // DragDrop is using this as a sanity check for the initial mousedown\n        // in this case we are done.  In POINT mode, if the drag obj has no\n        // contraints, we are also done. Otherwise we need to evaluate the\n        // location of the target as related to the actual location of the\n        // dragged element.\n        dc = this.dragCurrent;\n        if (!dc || !dc.getTargetCoord ||\n                (!intersect && !dc.constrainX && !dc.constrainY)) {\n            return oTarget.cursorIsOver;\n        }\n\n        oTarget.overlap = null;\n\n        // Get the current location of the drag element, this is the\n        // location of the mouse event less the delta that represents\n        // where the original mousedown happened on the element.  We\n        // need to consider constraints and ticks as well.\n        pos = dc.getTargetCoord(pt.x, pt.y);\n\n        el = dc.getDragEl();\n        curRegion = new Ext.util.Region(pos.y,\n                                               pos.x + el.offsetWidth,\n                                               pos.y + el.offsetHeight,\n                                               pos.x );\n\n        overlap = curRegion.intersect(loc);\n\n        if (overlap) {\n            oTarget.overlap = overlap;\n            return (intersect) ? true : oTarget.cursorIsOver;\n        } else {\n            return false;\n        }\n    },\n\n    /**\n     * unload event handler\n     * @private\n     */\n    _onUnload: function(e, me) {\n        Ext.dd.DragDropManager.unregAll();\n    },\n\n    /**\n     * Cleans up the drag and drop events and objects.\n     * @private\n     */\n    unregAll: function() {\n\n        if (this.dragCurrent) {\n            this.stopDrag();\n            this.dragCurrent = null;\n        }\n\n        this._execOnAll(\"unreg\", []);\n\n        for (var i in this.elementCache) {\n            delete this.elementCache[i];\n        }\n\n        this.elementCache = {};\n        this.ids = {};\n    },\n\n    /**\n     * @property {Object} elementCache\n     * A cache of DOM elements\n     * @private\n     */\n    elementCache: {},\n\n    /**\n     * Get the wrapper for the DOM element specified\n     * @param {String} id the id of the element to get\n     * @return {Ext.dd.DragDropManager.ElementWrapper} the wrapped element\n     * @private\n     * @deprecated This wrapper isn't that useful\n     */\n    getElWrapper: function(id) {\n        var oWrapper = this.elementCache[id];\n        if (!oWrapper || !oWrapper.el) {\n            oWrapper = this.elementCache[id] =\n                new this.ElementWrapper(Ext.getDom(id));\n        }\n        return oWrapper;\n    },\n\n    /**\n     * Returns the actual DOM element\n     * @param {String} id the id of the elment to get\n     * @return {Object} The element\n     * @deprecated use Ext.lib.Ext.getDom instead\n     */\n    getElement: function(id) {\n        return Ext.getDom(id);\n    },\n\n    /**\n     * Returns the style property for the DOM element (i.e.,\n     * document.getElById(id).style)\n     * @param {String} id the id of the elment to get\n     * @return {Object} The style property of the element\n     */\n    getCss: function(id) {\n        var el = Ext.getDom(id);\n        return (el) ? el.style : null;\n    },\n\n    /**\n     * @class Ext.dd.DragDropManager.ElementWrapper\n     * Deprecated inner class for cached elements.\n     * @private\n     * @deprecated This wrapper isn't that useful\n     */\n    ElementWrapper: function(el) {\n        /** The element */\n        this.el = el || null;\n        /** The element id */\n        this.id = this.el && el.id;\n        /** A reference to the style property */\n        this.css = this.el && el.style;\n    },\n\n    // Continue class docs\n    /** @class Ext.dd.DragDropElement */\n\n    /**\n     * Returns the X position of an html element\n     * @param {HTMLElement} el the element for which to get the position\n     * @return {Number} the X coordinate\n     */\n    getPosX: function(el) {\n        return Ext.Element.getX(el);\n    },\n\n    /**\n     * Returns the Y position of an html element\n     * @param {HTMLElement} el the element for which to get the position\n     * @return {Number} the Y coordinate\n     */\n    getPosY: function(el) {\n        return Ext.Element.getY(el);\n    },\n\n    /**\n     * Swap two nodes.  In IE, we use the native method, for others we\n     * emulate the IE behavior\n     * @param {HTMLElement} n1 the first node to swap\n     * @param {HTMLElement} n2 the other node to swap\n     */\n    swapNode: function(n1, n2) {\n        if (n1.swapNode) {\n            n1.swapNode(n2);\n        } else {\n            var p = n2.parentNode,\n                s = n2.nextSibling;\n\n            if (s == n1) {\n                p.insertBefore(n1, n2);\n            } else if (n2 == n1.nextSibling) {\n                p.insertBefore(n2, n1);\n            } else {\n                n1.parentNode.replaceChild(n2, n1);\n                p.insertBefore(n1, s);\n            }\n        }\n    },\n\n    /**\n     * Returns the current scroll position\n     * @private\n     */\n    getScroll: function () {\n        var doc   = window.document,\n            docEl = doc.documentElement,\n            body  = doc.body,\n            top   = 0,\n            left  = 0;\n\n        if (Ext.isGecko4) {\n            top  = window.scrollYOffset;\n            left = window.scrollXOffset;\n        } else {\n            if (docEl && (docEl.scrollTop || docEl.scrollLeft)) {\n                top  = docEl.scrollTop;\n                left = docEl.scrollLeft;\n            } else if (body) {\n                top  = body.scrollTop;\n                left = body.scrollLeft;\n            }\n        }\n        return {\n            top: top,\n            left: left\n        };\n    },\n\n    /**\n     * Returns the specified element style property\n     * @param {HTMLElement} el          the element\n     * @param {String}      styleProp   the style property\n     * @return {String} The value of the style property\n     */\n    getStyle: function(el, styleProp) {\n        return Ext.fly(el).getStyle(styleProp);\n    },\n\n    /**\n     * Gets the scrollTop\n     * @return {Number} the document's scrollTop\n     */\n    getScrollTop: function () {\n        return this.getScroll().top;\n    },\n\n    /**\n     * Gets the scrollLeft\n     * @return {Number} the document's scrollTop\n     */\n    getScrollLeft: function () {\n        return this.getScroll().left;\n    },\n\n    /**\n     * Sets the x/y position of an element to the location of the\n     * target element.\n     * @param {HTMLElement} moveEl      The element to move\n     * @param {HTMLElement} targetEl    The position reference element\n     */\n    moveToEl: function (moveEl, targetEl) {\n        var aCoord = Ext.Element.getXY(targetEl);\n        Ext.Element.setXY(moveEl, aCoord);\n    },\n\n    /**\n     * Numeric array sort function\n     * @param {Number} a\n     * @param {Number} b\n     * @returns {Number} positive, negative or 0\n     */\n    numericSort: function(a, b) {\n        return (a - b);\n    },\n\n    /**\n     * @property {Number} _timeoutCount\n     * Internal counter\n     * @private\n     */\n    _timeoutCount: 0,\n\n    /**\n     * Trying to make the load order less important.  Without this we get\n     * an error if this file is loaded before the Event Utility.\n     * @private\n     */\n    _addListeners: function() {\n        if ( document ) {\n            this._onLoad();\n        } else {\n            if (this._timeoutCount <= 2000) {\n                setTimeout(this._addListeners, 10);\n                if (document && document.body) {\n                    this._timeoutCount += 1;\n                }\n            }\n        }\n    },\n\n    /**\n     * Recursively searches the immediate parent and all child nodes for\n     * the handle element in order to determine wheter or not it was\n     * clicked.\n     * @param {HTMLElement} node the html element to inspect\n     */\n    handleWasClicked: function(node, id) {\n        if (this.isHandle(id, node.id)) {\n            return true;\n        } else {\n            // check to see if this is a text node child of the one we want\n            var p = node.parentNode;\n\n            while (p) {\n                if (this.isHandle(id, p.id)) {\n                    return true;\n                } else {\n                    p = p.parentNode;\n                }\n            }\n        }\n\n        return false;\n    }\n}, function() {\n    this._addListeners();\n});\n\n/**\n * Base Class for HBoxLayout and VBoxLayout Classes. Generally it should not need to be used directly.\n */\nExt.define('Ext.layout.container.Box', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.box'],\n    extend: 'Ext.layout.container.Container',\n    alternateClassName: 'Ext.layout.BoxLayout',\n\n    requires: [\n        'Ext.layout.container.boxOverflow.None',\n        'Ext.layout.container.boxOverflow.Menu',\n        'Ext.layout.container.boxOverflow.Scroller',\n        'Ext.util.Format',\n        'Ext.dd.DragDropManager'\n    ],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Object} defaultMargins\n     * If the individual contained items do not have a margins property specified or margin specified via CSS, the\n     * default margins from this property will be applied to each item.\n     *\n     * This property may be specified as an object containing margins to apply in the format:\n     *\n     *     {\n     *         top: (top margin),\n     *         right: (right margin),\n     *         bottom: (bottom margin),\n     *         left: (left margin)\n     *     }\n     *\n     * This property may also be specified as a string containing space-separated, numeric margin values. The order of\n     * the sides associated with each value matches the way CSS processes margin values:\n     *\n     *   - If there is only one value, it applies to all sides.\n     *   - If there are two values, the top and bottom borders are set to the first value and the right and left are\n     *     set to the second.\n     *   - If there are three values, the top is set to the first value, the left and right are set to the second,\n     *     and the bottom is set to the third.\n     *   - If there are four values, they apply to the top, right, bottom, and left, respectively.\n     */\n    defaultMargins: {\n        top: 0,\n        right: 0,\n        bottom: 0,\n        left: 0\n    },\n\n    /**\n     * @cfg {String} padding\n     * Sets the padding to be applied to all child items managed by this layout.\n     *\n     * This property must be specified as a string containing space-separated, numeric padding values. The order of the\n     * sides associated with each value matches the way CSS processes padding values:\n     *\n     *   - If there is only one value, it applies to all sides.\n     *   - If there are two values, the top and bottom borders are set to the first value and the right and left are\n     *     set to the second.\n     *   - If there are three values, the top is set to the first value, the left and right are set to the second,\n     *     and the bottom is set to the third.\n     *   - If there are four values, they apply to the top, right, bottom, and left, respectively.\n     */\n    padding: 0,\n\n    /**\n     * @cfg {String} pack\n     * Controls how the child items of the container are packed together. Acceptable configuration values for this\n     * property are:\n     *\n     *   - **start** - child items are packed together at **left** (HBox) or **top** (VBox) side of container (*default**)\n     *   - **center** - child items are packed together at **mid-width** (HBox) or **mid-height** (VBox) of container\n     *   - **end** - child items are packed together at **right** (HBox) or **bottom** (VBox) side of container\n     */\n    pack: 'start',\n\n    /**\n     * @cfg {Number} flex\n     * This configuration option is to be applied to **child items** of the container managed by this layout. Each child\n     * item with a flex property will be flexed (horizontally in `hbox`, vertically in `vbox`) according to each item's\n     * **relative** flex value compared to the sum of all items with a flex value specified. Any child items that have\n     * either a `flex = 0` or `flex = undefined` will not be 'flexed' (the initial size will not be changed).\n     */\n    flex: undefined,\n\n    /**\n     * @cfg {String/Ext.Component} stretchMaxPartner\n     * Allows stretchMax calculation to take into account the max perpendicular size (height for HBox layout and width\n     * for VBox layout) of another Box layout when calculating its maximum perpendicular child size.\n     *\n     * If specified as a string, this may be either a known Container ID, or a ComponentQuery selector which is rooted\n     * at this layout's Container (ie, to find a sibling, use `\"^>#siblingItemId`).\n     */\n    stretchMaxPartner: undefined,\n\n    type: 'box',\n    scrollOffset: 0,\n    itemCls: Ext.baseCSSPrefix + 'box-item',\n    targetCls: Ext.baseCSSPrefix + 'box-layout-ct',\n    innerCls: Ext.baseCSSPrefix + 'box-inner',\n\n    // availableSpaceOffset is used to adjust the availableWidth, typically used\n    // to reserve space for a scrollbar\n    availableSpaceOffset: 0,\n\n    // whether or not to reserve the availableSpaceOffset in layout calculations\n    reserveOffset: true,\n\n    manageMargins: true,\n\n    childEls: [\n        'innerCt',\n        'targetEl'\n    ],\n\n    renderTpl: [\n        '{%var oc,l=values.$comp.layout,oh=l.overflowHandler;',\n        'if (oh.getPrefixConfig!==Ext.emptyFn) {',\n            'if(oc=oh.getPrefixConfig())dh.generateMarkup(oc, out)',\n        '}%}',\n        '<div id=\"{ownerId}-innerCt\" class=\"{[l.innerCls]} {[oh.getOverflowCls()]}\" role=\"presentation\">',\n            '<div id=\"{ownerId}-targetEl\" style=\"position:absolute;',\n                    // This width for the \"CSS container box\" of the box child items gives\n                    // them the room they need to avoid being \"crushed\" (aka, \"wrapped\").\n                    // On Opera, elements cannot be wider than 32767px or else they break\n                    // the scrollWidth (it becomes == offsetWidth) and you cannot scroll\n                    // the content.\n                    'width:20000px;',\n                    // On IE quirks and IE6/7 strict, a text-align:center style trickles\n                    // down to this el at times and will cause it to move off the left edge.\n                    // The easy fix is to just always set left:0px here. The top:0px part\n                    // is just being paranoid. The requirement for targetEl is that its\n                    // origin align with innerCt... this ensures that it does!\n                    'left:0px;top:0px;',\n                    // If we don't give the element a height, it does not always participate\n                    // in the scrollWidth.\n                    'height:1px\">',\n                '{%this.renderBody(out, values)%}',\n            '</div>',\n        '</div>',\n        '{%if (oh.getSuffixConfig!==Ext.emptyFn) {',\n            'if(oc=oh.getSuffixConfig())dh.generateMarkup(oc, out)',\n        '}%}',\n        {\n            disableFormats: true,\n            definitions: 'var dh=Ext.DomHelper;'\n        }\n    ],\n\n    constructor: function(config) {\n        var me = this,\n            type;\n\n        me.callParent(arguments);\n\n        // The sort function needs access to properties in this, so must be bound.\n        me.flexSortFn = Ext.Function.bind(me.flexSort, me);\n\n        me.initOverflowHandler();\n\n        type = typeof me.padding;\n        if (type == 'string' || type == 'number') {\n            me.padding = Ext.util.Format.parseBox(me.padding);\n            me.padding.height = me.padding.top  + me.padding.bottom;\n            me.padding.width  = me.padding.left + me.padding.right;\n        }\n    },\n\n    getNames: function () {\n        return this.names;\n    },\n\n    // Matches: <spaces>digits[.digits]<spaces>%<spaces>\n    // Captures: digits[.digits]\n    _percentageRe: /^\\s*(\\d+(?:\\.\\d*)?)\\s*[%]\\s*$/,\n\n    getItemSizePolicy: function (item, ownerSizeModel) {\n        var me = this,\n            policy = me.sizePolicy,\n            align = me.align,\n            flex = item.flex,\n            key = align,\n            names = me.names,\n            width = item[names.width],\n            height = item[names.height],\n            percentageRe = me._percentageRe,\n            percentageWidth = percentageRe.test(width),\n            isStretch = (align == 'stretch');\n            \n        if ((isStretch || flex || percentageWidth) && !ownerSizeModel) {\n            ownerSizeModel = me.owner.getSizeModel();\n        }\n\n        if (isStretch) {\n            // If we are height.shrinkWrap, we behave as if we were stretchmax (for more\n            // details, see beginLayoutCycle)...\n            if (!percentageRe.test(height) && ownerSizeModel[names.height].shrinkWrap) {\n                key = 'stretchmax';\n                // We leave %age height as stretch since it will not participate in the\n                // stretchmax size calculation. This avoid running such a child in its\n                // shrinkWrap mode prior to supplying the calculated size.\n            }\n        } else if (align != 'stretchmax') {\n            if (percentageRe.test(height)) {\n                // Height %ages are calculated based on container size, so they are the\n                // same as align=stretch for this purpose...\n                key = 'stretch';\n            } else {\n                key = '';\n            }\n        }\n\n        if (flex || percentageWidth) {\n            // If we are width.shrinkWrap, we won't be flexing since that requires a\n            // container width...\n            if (!ownerSizeModel[names.width].shrinkWrap) {\n                policy = policy.flex; // both flex and %age width are calculated\n            }\n        }\n\n        return policy[key];\n    },\n\n    flexSort: function (a, b) {\n        var maxWidthName = this.getNames().maxWidth,\n            infiniteValue = Infinity;\n\n        a = a.target[maxWidthName] || infiniteValue;\n        b = b.target[maxWidthName] || infiniteValue;\n\n        // IE 6/7 Don't like Infinity - Infinity...\n        if (!isFinite(a) && !isFinite(b)) {\n            return 0;\n        }\n\n        return a - b;\n    },\n\n    isItemBoxParent: function (itemContext) {\n        return true;\n    },\n\n    isItemShrinkWrap: function (item) {\n        return true;\n    },\n\n    // Sort into *descending* order.\n    minSizeSortFn: function(a, b) {\n        return b.available - a.available;\n    },\n\n    roundFlex: function(width) {\n        return Math.ceil(width);\n    },\n\n    /**\n     * @private\n     * Called by an owning Panel before the Panel begins its collapse process.\n     * Most layouts will not need to override the default Ext.emptyFn implementation.\n     */\n    beginCollapse: function(child) {\n        var me = this;\n\n        if (me.direction === 'vertical' && child.collapsedVertical()) {\n            child.collapseMemento.capture(['flex']);\n            delete child.flex;\n        } else if (me.direction === 'horizontal' && child.collapsedHorizontal()) {\n            child.collapseMemento.capture(['flex']);\n            delete child.flex;\n        }\n    },\n\n    /**\n     * @private\n     * Called by an owning Panel before the Panel begins its expand process.\n     * Most layouts will not need to override the default Ext.emptyFn implementation.\n     */\n    beginExpand: function(child) {\n\n        // Restores the flex if we used to be flexed before\n        child.collapseMemento.restore(['flex']);\n    },\n\n    beginLayout: function (ownerContext) {\n        var me = this,\n            smp = me.owner.stretchMaxPartner,\n            style = me.innerCt.dom.style,\n            names = me.getNames();\n\n        ownerContext.boxNames = names;\n\n        // this must happen before callParent to allow the overflow handler to do its work\n        // that can effect the childItems collection...\n        me.overflowHandler.beginLayout(ownerContext);\n\n        // get the contextItem for our stretchMax buddy:\n        if (typeof smp === 'string') {\n            smp = Ext.getCmp(smp) || me.owner.query(smp)[0];\n        }\n\n        ownerContext.stretchMaxPartner = smp && ownerContext.context.getCmp(smp);\n\n        me.callParent(arguments);\n\n        ownerContext.innerCtContext = ownerContext.getEl('innerCt', me);\n\n        // Capture whether the owning Container is scrolling in the parallel direction\n        me.scrollParallel = !!(me.owner.autoScroll || me.owner[names.overflowX]);\n\n        // Capture whether the owning Container is scrolling in the perpendicular direction\n        me.scrollPerpendicular = !!(me.owner.autoScroll || me.owner[names.overflowY]);\n\n        // If we *are* scrolling parallel, capture the scroll position of the encapsulating element\n        if (me.scrollParallel) {\n            me.scrollPos = me.owner.getTargetEl().dom[names.scrollLeft];\n        }\n\n        // Don't allow sizes burned on to the innerCt to influence measurements.\n        style.width = '';\n        style.height = '';\n    },\n\n    beginLayoutCycle: function (ownerContext, firstCycle) {\n        var me = this,\n            align = me.align,\n            names = ownerContext.boxNames,\n            pack = me.pack,\n            heightModelName = names.heightModel;\n\n        // this must happen before callParent to allow the overflow handler to do its work\n        // that can effect the childItems collection...\n        me.overflowHandler.beginLayoutCycle(ownerContext, firstCycle);\n\n        me.callParent(arguments);\n\n        // Cache several of our string concat/compare results (since width/heightModel can\n        // change if we are invalidated, we cannot do this in beginLayout)\n\n        ownerContext.parallelSizeModel      = ownerContext[names.widthModel];\n        ownerContext.perpendicularSizeModel = ownerContext[heightModelName];\n\n        ownerContext.boxOptions = {\n            align: align = {\n                stretch:    align == 'stretch',\n                stretchmax: align == 'stretchmax',\n                center:     align == names.center\n            },\n            pack: pack = {\n                center: pack == 'center',\n                end:    pack == 'end'\n            }\n        };\n\n        // Consider an hbox w/stretch which means \"assign all items the container's height\".\n        // The spirit of this request is make all items the same height, but when shrinkWrap\n        // height is also requested, the height of the tallest item determines the height.\n        // This is exactly what the stretchmax option does, so we jiggle the flags here to\n        // act as if stretchmax were requested.\n\n        if (align.stretch && ownerContext.perpendicularSizeModel.shrinkWrap) {\n            align.stretchmax = true;\n            align.stretch = false;\n        }\n\n        // This is handy for knowing that we might need to apply height %ages\n        align.nostretch = !(align.stretch || align.stretchmax);\n\n        // In our example hbox, packing items to the right (end) or center can only work if\n        // there is a container width. So, if we are shrinkWrap, we just turn off the pack\n        // options for the run.\n\n        if (ownerContext.parallelSizeModel.shrinkWrap) {\n            pack.center = pack.end = false;\n        }\n\n        me.cacheFlexes(ownerContext);\n\n        // In webkit we set the width of the target el equal to the width of the innerCt\n        // when the layout cycle is finished, so we need to set it back to 20000px here\n        // to prevent the children from being crushed. \n        if (Ext.isWebKit) {\n            me.targetEl.setWidth(20000);\n        }\n    },\n\n    /**\n     * This method is called to (re)cache our understanding of flexes. This happens during beginLayout and may need to\n     * be called again if the flexes are changed during the layout (e.g., like ColumnLayout).\n     * @param {Object} ownerContext\n     * @protected\n     */\n    cacheFlexes: function (ownerContext) {\n        var me = this,\n            names = ownerContext.boxNames,\n            widthModelName = names.widthModel,\n            heightModelName = names.heightModel,\n            nostretch = ownerContext.boxOptions.align.nostretch,\n            totalFlex = 0,\n            childItems = ownerContext.childItems,\n            i = childItems.length,\n            flexedItems = [],\n            minWidth = 0,\n            minWidthName = names.minWidth,\n            percentageRe = me._percentageRe,\n            percentageWidths = 0,\n            percentageHeights = 0,\n            child, childContext, flex, match;\n\n        while (i--) {\n            childContext = childItems[i];\n            child = childContext.target;\n\n            // check widthModel to see if we are the sizing layout. If so, copy the flex\n            // from the item to the contextItem and add it to totalFlex\n            //\n            if (childContext[widthModelName].calculated) {\n                childContext.flex = flex = child.flex;\n                if (flex) {\n                    totalFlex += flex;\n                    flexedItems.push(childContext);\n                    minWidth += child[minWidthName] || 0;\n                } else { // a %age width...\n                    match = percentageRe.exec(child[names.width]);\n                    childContext.percentageParallel = parseFloat(match[1]) / 100;\n                    ++percentageWidths;\n                }\n            }\n            // the above means that \"childContext.flex\" is properly truthy/falsy, which is\n            // often times quite convenient...\n\n            if (nostretch && childContext[heightModelName].calculated) {\n                // the only reason we would be calculated height in this case is due to a\n                // height %age...\n                match = percentageRe.exec(child[names.height]);\n                childContext.percentagePerpendicular = parseFloat(match[1]) / 100;\n                ++percentageHeights;\n            }\n        }\n\n        ownerContext.flexedItems = flexedItems;\n        ownerContext.flexedMinSize = minWidth;\n        ownerContext.totalFlex = totalFlex;\n        ownerContext.percentageWidths = percentageWidths;\n        ownerContext.percentageHeights = percentageHeights;\n\n        // The flexed boxes need to be sorted in ascending order of maxSize to work properly\n        // so that unallocated space caused by maxWidth being less than flexed width can be\n        // reallocated to subsequent flexed boxes.\n        Ext.Array.sort(flexedItems, me.flexSortFn);\n    },\n\n    calculate: function(ownerContext) {\n        var me = this,\n            targetSize = me.getContainerSize(ownerContext),\n            names = ownerContext.boxNames,\n            state = ownerContext.state,\n            plan = state.boxPlan || (state.boxPlan = {});\n\n        plan.targetSize = targetSize;\n\n        // If we are not widthModel.shrinkWrap, we need the width before we can lay out boxes:\n        if (!ownerContext.parallelSizeModel.shrinkWrap && !targetSize[names.gotWidth]) {\n            me.done = false;\n            return;\n        }\n\n        if (!state.parallelDone) {\n            state.parallelDone = me.calculateParallel(ownerContext, names, plan);\n        }\n\n        if (!state.perpendicularDone) {\n            state.perpendicularDone = me.calculatePerpendicular(ownerContext, names, plan);\n        }\n\n        if (state.parallelDone && state.perpendicularDone) {\n            // Fix for left and right docked Components in a dock component layout. This is for docked Headers and docked Toolbars.\n            // Older Microsoft browsers do not size a position:absolute element's width to match its content.\n            // So in this case, in the publishInnerCtSize method we may need to adjust the size of the owning Container's element explicitly based upon\n            // the discovered max width. So here we put a calculatedWidth property in the metadata to facilitate this.\n            if (me.owner.dock && (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks) && !me.owner.width && !me.horizontal) {\n                plan.isIEVerticalDock = true;\n                plan.calculatedWidth = plan.maxSize + ownerContext.getPaddingInfo().width + ownerContext.getFrameInfo().width;\n            }\n\n            me.publishInnerCtSize(ownerContext, me.reserveOffset ? me.availableSpaceOffset : 0);\n\n            // Calculate stretchmax only if there is >1 child item\n            if (me.done && ownerContext.childItems.length > 1 && ownerContext.boxOptions.align.stretchmax && !state.stretchMaxDone) {\n                me.calculateStretchMax(ownerContext, names, plan);\n                state.stretchMaxDone = true;\n            }\n        } else {\n            me.done = false;\n        }\n    },\n\n    calculateParallel: function(ownerContext, names, plan) {\n        var me = this,\n            widthName = names.width,\n            childItems = ownerContext.childItems,\n            leftName = names.left,\n            rightName = names.right,\n            setWidthName = names.setWidth,\n            childItemsLength = childItems.length,\n            flexedItems = ownerContext.flexedItems,\n            flexedItemsLength = flexedItems.length,\n            pack = ownerContext.boxOptions.pack,\n            padding = me.padding,\n            containerWidth = plan.targetSize[widthName],\n            totalMargin = 0,\n            left = padding[leftName],\n            nonFlexWidth = left + padding[rightName] + me.scrollOffset +\n                                    (me.reserveOffset ? me.availableSpaceOffset : 0),\n            scrollbarWidth = Ext.getScrollbarSize()[names.width],\n            i, childMargins, remainingWidth, remainingFlex, childContext, flex, flexedWidth,\n            contentWidth, mayNeedScrollbarAdjust, childWidth, percentageSpace;\n\n        // We may need to add scrollbar size to parallel size if\n        //     Scrollbars take up space\n        //     and we are scrolling in the perpendicular direction\n        //     and shrinkWrapping in the parallel direction,\n        //     and NOT stretching perpendicular dimensions to fit\n        //     and NOT shrinkWrapping in the perpendicular direction\n        if (scrollbarWidth &&\n            me.scrollPerpendicular &&\n            ownerContext.parallelSizeModel.shrinkWrap &&\n            !ownerContext.boxOptions.align.stretch &&\n            !ownerContext.perpendicularSizeModel.shrinkWrap) {\n\n            // If its possible that we may need to add scrollbar size to the parallel size\n            // then we need to wait until the perpendicular size has been determined,\n            // so that we know if there is a scrollbar.\n            if (!ownerContext.state.perpendicularDone) {\n                return false;\n            }\n            mayNeedScrollbarAdjust = true;\n        }\n\n        // Gather the total size taken up by non-flexed items:\n        for (i = 0; i < childItemsLength; ++i) {\n            childContext = childItems[i];\n            childMargins = childContext.marginInfo || childContext.getMarginInfo();\n\n            totalMargin += childMargins[widthName];\n\n            if (!childContext[names.widthModel].calculated) {\n                childWidth = childContext.getProp(widthName);\n                nonFlexWidth += childWidth; // min/maxWidth safe\n                if (isNaN(nonFlexWidth)) {\n                    return false;\n                }\n            }\n        }\n\n        nonFlexWidth += totalMargin;\n        if (ownerContext.percentageWidths) {\n            percentageSpace = containerWidth - totalMargin;\n            if (isNaN(percentageSpace)) {\n                return false;\n            }\n\n            for (i = 0; i < childItemsLength; ++i) {\n                childContext = childItems[i];\n                if (childContext.percentageParallel) {\n                    childWidth = Math.ceil(percentageSpace * childContext.percentageParallel);\n                    childWidth = childContext.setWidth(childWidth);\n                    nonFlexWidth += childWidth;\n                }\n            }\n        }\n\n        // if we get here, we have all the childWidths for non-flexed items...\n\n        if (ownerContext.parallelSizeModel.shrinkWrap) {\n            plan.availableSpace = 0;\n            plan.tooNarrow = false;\n        } else {\n            plan.availableSpace = containerWidth - nonFlexWidth;\n\n            // If we're going to need space for a parallel scrollbar, then we need to redo the perpendicular measurements\n            plan.tooNarrow = plan.availableSpace < ownerContext.flexedMinSize;\n            if (plan.tooNarrow && Ext.getScrollbarSize()[names.height] && me.scrollParallel && ownerContext.state.perpendicularDone) {\n                ownerContext.state.perpendicularDone = false;\n                for (i = 0; i < childItemsLength; ++i) {\n                    childItems[i].invalidate();\n                }\n            }\n        }\n\n        contentWidth = nonFlexWidth;\n        remainingWidth = plan.availableSpace;\n        remainingFlex = ownerContext.totalFlex;\n\n        // Calculate flexed item sizes:\n        for (i = 0; i < flexedItemsLength; i++) {\n            childContext = flexedItems[i];\n            flex         = childContext.flex;\n            flexedWidth  = me.roundFlex((flex / remainingFlex) * remainingWidth);\n            flexedWidth  = childContext[setWidthName](flexedWidth); // constrained\n\n            // due to minWidth constraints, it may be that flexedWidth > remainingWidth\n\n            contentWidth   += flexedWidth;\n            // Remaining space has already had margins subtracted, so just subtract size\n            remainingWidth  = Math.max(0, remainingWidth - flexedWidth); // no negatives!\n            remainingFlex  -= flex;\n        }\n\n        if (pack.center) {\n            left += remainingWidth / 2;\n\n            // If content is too wide to pack to center, do not allow the centering calculation to place it off the left edge.\n            if (left < 0) {\n                left = 0;\n            }\n        } else if (pack.end) {\n            left += remainingWidth;\n        }\n\n        // Assign parallel position for the boxes:\n        for (i = 0; i < childItemsLength; ++i) {\n            childContext = childItems[i];\n            childMargins = childContext.marginInfo; // already cached by first loop\n\n            left += childMargins[leftName];\n\n            childContext.setProp(names.x, left);\n\n            // We can read directly from \"props.width\" because we have already properly\n            // requested it in the calculation of nonFlexedWidths or we calculated it.\n            // We cannot call getProp because that would be inappropriate for flexed items\n            // and we don't need any extra function call overhead:\n            left += childMargins[rightName] + childContext.props[widthName];\n        }\n\n        contentWidth += ownerContext.targetContext.getPaddingInfo()[widthName];\n\n        // Stash the contentWidth on the state so that it can always be accessed later in the calculation\n        ownerContext.state.contentWidth = contentWidth; \n\n        // if there is perpendicular overflow, the published parallel content size includes\n        // the size of the perpendicular scrollbar.\n        if (mayNeedScrollbarAdjust &&\n            (ownerContext.peek(names.contentHeight) > plan.targetSize[names.height])) {\n            contentWidth += scrollbarWidth;\n            ownerContext[names.hasOverflowY] = true;\n\n            // tell the component layout to set the parallel size in the dom\n            ownerContext.target.componentLayout[names.setWidthInDom] = true;\n\n            // IE8 in what passes for \"strict\" mode will not create a scrollbar if \n            // there is just the *exactly correct* spare space created for it. We\n            // have to force that to happen once all the styles have been flushed\n            // to the DOM (see completeLayout):\n            ownerContext[names.invalidateScrollY] = (Ext.isStrict && Ext.isIE8);\n        }\n        ownerContext[names.setContentWidth](contentWidth);\n\n        return true;\n    },\n\n    calculatePerpendicular: function(ownerContext, names, plan) {\n        var me = this,\n            heightShrinkWrap = ownerContext.perpendicularSizeModel.shrinkWrap,\n            targetSize = plan.targetSize,\n            childItems = ownerContext.childItems,\n            childItemsLength = childItems.length,\n            mmax = Math.max,\n            heightName = names.height,\n            setHeightName = names.setHeight,\n            topName = names.top,\n            topPositionName = names.y,\n            padding = me.padding,\n            top = padding[topName],\n            availHeight = targetSize[heightName] - top - padding[names.bottom],\n            align = ownerContext.boxOptions.align,\n            isStretch    = align.stretch, // never true if heightShrinkWrap (see beginLayoutCycle)\n            isStretchMax = align.stretchmax,\n            isCenter     = align.center,\n            maxHeight = 0,\n            hasPercentageSizes = 0,\n            scrollbarHeight = Ext.getScrollbarSize().height,\n            childTop, i, childHeight, childMargins, diff, height, childContext,\n            stretchMaxPartner, stretchMaxChildren, shrinkWrapParallelOverflow, \n            percentagePerpendicular;\n\n        if (isStretch || (isCenter && !heightShrinkWrap)) {\n            if (isNaN(availHeight)) {\n                return false;\n            }\n        }\n\n        // If the intention is to horizontally scroll child components, but the container is too narrow,\n        // then:\n        //     if we are shrinkwrapping height:\n        //         Set a flag because we are going to expand the height taken by the perpendicular dimension to accommodate the scrollbar\n        //     else\n        //         We must allow for the parallel scrollbar to intrude into the height\n        if (me.scrollParallel && plan.tooNarrow) {\n            if (heightShrinkWrap) {\n                shrinkWrapParallelOverflow = true;\n            } else {\n                availHeight -= scrollbarHeight;\n                plan.targetSize[heightName] -= scrollbarHeight;\n            }\n        }\n\n        if (isStretch) {\n            height = availHeight; // never heightShrinkWrap...\n        } else {\n            for (i = 0; i < childItemsLength; i++) {\n                childContext = childItems[i];\n                childMargins = (childContext.marginInfo || childContext.getMarginInfo())[heightName];\n\n                if (!(percentagePerpendicular = childContext.percentagePerpendicular)) {\n                    childHeight = childContext.getProp(heightName);\n                } else {\n                    ++hasPercentageSizes;\n                    if (heightShrinkWrap) {\n                        // height %age items cannot contribute to maxHeight... they are going\n                        // to be a %age of that maxHeight!\n                        continue;\n                    } else {\n                        childHeight = percentagePerpendicular * availHeight - childMargins;\n                        childHeight = childContext[names.setHeight](childHeight);\n                    }\n                }\n\n                // Max perpendicular measurement (used for stretchmax) must take the min perpendicular size of each child into account in case any fall short.\n                if (isNaN(maxHeight = mmax(maxHeight, childHeight + childMargins,\n                                           childContext.target[names.minHeight] || 0))) {\n                    return false; // heightShrinkWrap || isCenter || isStretchMax ??\n                }\n            }\n\n            // If there is going to be a parallel scrollbar maxHeight must include it to the outside world.\n            // ie: a stretchmaxPartner, and the setContentHeight\n            if (shrinkWrapParallelOverflow) {\n                maxHeight += scrollbarHeight;\n                ownerContext[names.hasOverflowX] = true;\n\n                // tell the component layout to set the perpendicular size in the dom\n                ownerContext.target.componentLayout[names.setHeightInDom] = true;\n\n                // IE8 in what passes for \"strict\" mode will not create a scrollbar if \n                // there is just the *exactly correct* spare space created for it. We\n                // have to force that to happen once all the styles have been flushed\n                // to the DOM (see completeLayout):\n                ownerContext[names.invalidateScrollX] = (Ext.isStrict && Ext.isIE8);\n            }\n\n            // If we are associated with another box layout, grab its maxChildHeight\n            // This must happen before we calculate and publish our contentHeight\n            stretchMaxPartner = ownerContext.stretchMaxPartner;\n            if (stretchMaxPartner) {\n                // Publish maxChildHeight as soon as it has been calculated for our partner:\n                ownerContext.setProp('maxChildHeight', maxHeight);\n                stretchMaxChildren = stretchMaxPartner.childItems;\n                // Only wait for maxChildHeight if our partner has visible items:\n                if (stretchMaxChildren && stretchMaxChildren.length) {\n                    maxHeight = mmax(maxHeight, stretchMaxPartner.getProp('maxChildHeight'));\n                    if (isNaN(maxHeight)) {\n                        return false;\n                    }\n                }\n            }\n\n            ownerContext[names.setContentHeight](maxHeight + me.padding[heightName] +\n                    ownerContext.targetContext.getPaddingInfo()[heightName]);\n\n            // We have to publish the contentHeight with the additional scrollbarHeight\n            // to encourage our container to accomodate it, but we must remove the height\n            // of the scrollbar as we go to sizing or centering the children.\n            if (shrinkWrapParallelOverflow) {\n                maxHeight -= scrollbarHeight;\n            }\n            plan.maxSize = maxHeight;\n\n            if (isStretchMax) {\n                height = maxHeight;\n            } else if (isCenter || hasPercentageSizes) {\n                height = heightShrinkWrap ? maxHeight : mmax(availHeight, maxHeight);\n\n                // When calculating a centered position within the content box of the innerCt,\n                // the width of the borders must be subtracted from the size to yield the\n                // space available to center within. The publishInnerCtSize method explicitly\n                // adds the border widths to the set size of the innerCt.\n                height -= ownerContext.innerCtContext.getBorderInfo()[heightName];\n            }\n        }\n\n        for (i = 0; i < childItemsLength; i++) {\n            childContext = childItems[i];\n            childMargins = childContext.marginInfo || childContext.getMarginInfo();\n\n            childTop = top + childMargins[topName];\n\n            if (isStretch) {\n                childContext[setHeightName](height - childMargins[heightName]);\n            } else {\n                percentagePerpendicular = childContext.percentagePerpendicular;\n                if (heightShrinkWrap && percentagePerpendicular) {\n                    childMargins = childContext.marginInfo || childContext.getMarginInfo();\n                    childHeight = percentagePerpendicular * height - childMargins[heightName];\n                    childHeight = childContext.setHeight(childHeight);\n                }\n\n                if (isCenter) {\n                    diff = height - childContext.props[heightName];\n                    if (diff > 0) {\n                        childTop = top + Math.round(diff / 2);\n                    }\n                }\n            }\n\n            childContext.setProp(topPositionName, childTop);\n        }\n\n        return true;\n    },\n\n    calculateStretchMax: function (ownerContext, names, plan) {\n        var me = this,\n            heightName = names.height,\n            widthName = names.width,\n            childItems = ownerContext.childItems,\n            length = childItems.length,\n            height = plan.maxSize,\n            onBeforeInvalidateChild = me.onBeforeInvalidateChild,\n            onAfterInvalidateChild = me.onAfterInvalidateChild,\n            childContext, props, i, childHeight;\n\n        for (i = 0; i < length; ++i) {\n            childContext = childItems[i];\n\n            props = childContext.props;\n            childHeight = height - childContext.getMarginInfo()[heightName];\n\n            if (childHeight != props[heightName] ||   // if (wrong height ...\n                childContext[names.heightModel].constrained) { // ...or needs invalidation)\n                // When we invalidate a child, since we won't be around to size or position\n                // it, we include an after callback that will be run after the invalidate\n                // that will (re)do that work. The good news here is that we can read the\n                // results of all that from the childContext props.\n                //\n                // We also include a before callback to change the sizeModel to calculated\n                // prior to the layout being invoked.\n                childContext.invalidate({\n                    before: onBeforeInvalidateChild,\n                    after: onAfterInvalidateChild,\n                    layout: me,\n                    // passing this data avoids a 'scope' and its Function.bind\n                    childWidth: props[widthName],\n                    // subtract margins from the maximum value\n                    childHeight: childHeight,\n                    childX: props.x,\n                    childY: props.y,\n                    names: names\n                });\n            }\n        }\n    },\n\n    completeLayout: function(ownerContext) {\n        var me = this,\n            names = ownerContext.boxNames,\n            invalidateScrollX = ownerContext.invalidateScrollX,\n            invalidateScrollY = ownerContext.invalidateScrollY,\n            dom, el, overflowX, overflowY, styles;\n\n        me.overflowHandler.completeLayout(ownerContext);\n\n        if (invalidateScrollX || invalidateScrollY) {\n            el = me.getTarget();\n            dom = el.dom;\n            styles = dom.style;\n\n            if (invalidateScrollX) {\n                // get computed style to see if we are 'auto'\n                overflowX = el.getStyle('overflowX');\n                if (overflowX == 'auto') {\n                    // capture the inline style (if any) so we can restore it later:\n                    overflowX = styles.overflowX;\n                    styles.overflowX = 'scroll'; // force the scrollbar to appear\n                } else {\n                    invalidateScrollX = false; // no work really since not 'auto'\n                }\n            }\n\n            if (invalidateScrollY) {\n                // get computed style to see if we are 'auto'\n                overflowY = el.getStyle('overflowY');\n                if (overflowY == 'auto') {\n                    // capture the inline style (if any) so we can restore it later:\n                    overflowY = styles.overflowY;\n                    styles.overflowY = 'scroll'; // force the scrollbar to appear\n                } else {\n                    invalidateScrollY = false; // no work really since not 'auto'\n                }\n            }\n\n            if (invalidateScrollX || invalidateScrollY) { // if (some form of 'auto' in play)\n                // force a reflow...\n                dom.scrollWidth;\n\n                if (invalidateScrollX) {\n                    styles.overflowX = overflowX; // restore inline style\n                }\n                if (invalidateScrollY) {\n                    styles.overflowY = overflowY; // restore inline style\n                }\n            }\n        }\n\n        // If we are scrolling parallel, restore the saved scroll position\n        if (me.scrollParallel) {\n            me.owner.getTargetEl().dom[names.scrollLeft] = me.scrollPos;\n        }\n    },\n\n    finishedLayout: function(ownerContext) {\n        this.overflowHandler.finishedLayout(ownerContext);\n        this.callParent(arguments);\n\n        // Fix for an obscure webkit bug (EXTJSIV-5962) caused by the targetEl's 20000px\n        // width.  We set a very large width on the targetEl at the beginning of the \n        // layout cycle to prevent any \"crushing\" effect on the child items, however\n        // in some cases the very large width makes it possible to scroll the innerCt\n        // by dragging on certain child elements. To prevent this from happening we ensure\n        // that the targetEl's width is the same as the innerCt.\n        if (Ext.isWebKit) {\n            this.targetEl.setWidth(ownerContext.innerCtContext.props.width);\n        }\n    },\n\n    onBeforeInvalidateChild: function (childContext, options) {\n        // NOTE: No \"this\" pointer in here...\n        var heightModelName = options.names.heightModel;\n\n        // Change the childItem to calculated (i.e., \"set by ownerCt\"). The component layout\n        // of the child can course-correct (like dock layout does for a collapsed panel),\n        // so we must make these changes here before that layout's beginLayoutCycle is\n        // called.\n        if (!childContext[heightModelName].constrainedMax) {\n            // if the child hit a max constraint, it needs to be at its configured size, so\n            // we leave the sizeModel alone...\n            childContext[heightModelName] = Ext.layout.SizeModel.calculated;\n        }\n    },\n\n    onAfterInvalidateChild: function (childContext, options) {\n        // NOTE: No \"this\" pointer in here...\n        var names = options.names,\n            scrollbarSize = Ext.getScrollbarSize(),\n            childHeight = options.childHeight,\n            childWidth = options.childWidth;\n\n        childContext.setProp('x', options.childX);\n        childContext.setProp('y', options.childY);\n\n        if (childContext[names.heightModel].calculated) {\n            // We need to respect a child that is still not calculated (such as a collapsed\n            // panel)...\n            childContext[names.setHeight](childHeight);\n        }\n\n        if (childContext[names.widthModel].calculated) {\n            childContext[names.setWidth](childWidth);\n        }\n    },\n\n    publishInnerCtSize: function(ownerContext, reservedSpace) {\n        var me = this,\n            names = ownerContext.boxNames,\n            heightName = names.height,\n            widthName = names.width,\n            align = ownerContext.boxOptions.align,\n            dock = me.owner.dock,\n            padding = me.padding,\n            plan = ownerContext.state.boxPlan,\n            targetSize = plan.targetSize,\n            height = targetSize[heightName],\n            innerCtContext = ownerContext.innerCtContext,\n            innerCtWidth = (ownerContext.parallelSizeModel.shrinkWrap || (plan.tooNarrow && me.scrollParallel)\n                    ? ownerContext.state.contentWidth\n                    : targetSize[widthName]) - (reservedSpace || 0),\n            innerCtHeight;\n\n        if (align.stretch) {\n            innerCtHeight = height;\n        } else {\n            innerCtHeight = plan.maxSize + padding[names.top] + padding[names.bottom] + innerCtContext.getBorderInfo()[heightName];\n\n            if (!ownerContext.perpendicularSizeModel.shrinkWrap && align.center) {\n                innerCtHeight = Math.max(height, innerCtHeight);\n            }\n        }\n\n        innerCtContext[names.setWidth](innerCtWidth);\n        innerCtContext[names.setHeight](innerCtHeight);\n\n        // If unable to publish both dimensions, this layout needs to run again\n        if (isNaN(innerCtWidth + innerCtHeight)) {\n            me.done = false;\n        }\n\n        // If a calculated width has been found (this only happens for widthModel.shrinkWrap\n        // vertical docked Components in old Microsoft browsers) then, if the Component has\n        // not assumed the size of its content, set it to do so.\n        //\n        // We MUST pass the dirty flag to get that into the DOM, and because we are a Container\n        // layout, and not really supposed to perform sizing, we must also use the force flag.\n        if (plan.calculatedWidth && (dock == 'left' || dock == 'right')) {\n            // TODO: setting the owner size should be the job of the component layout.\n            ownerContext.setWidth(plan.calculatedWidth, true, true);\n        }\n    },\n\n    onRemove: function(comp){\n        var me = this;\n        me.callParent(arguments);\n        if (me.overflowHandler) {\n            me.overflowHandler.onRemove(comp);\n        }\n        if (comp.layoutMarginCap == me.id) {\n            delete comp.layoutMarginCap;\n        }\n    },\n\n    /**\n     * @private\n     */\n    initOverflowHandler: function() {\n        var me = this,\n            handler = me.overflowHandler,\n            handlerType,\n            constructor;\n\n        if (typeof handler == 'string') {\n            handler = {\n                type: handler\n            };\n        }\n\n        handlerType = 'None';\n        if (handler && handler.type !== undefined) {\n            handlerType = handler.type;\n        }\n\n        constructor = Ext.layout.container.boxOverflow[handlerType];\n        if (constructor[me.type]) {\n            constructor = constructor[me.type];\n        }\n\n        me.overflowHandler = Ext.create('Ext.layout.container.boxOverflow.' + handlerType, me, handler);\n    },\n\n    // Overridden method from Ext.layout.container.Container.\n    // Used in the beforeLayout method to render all items into.\n    getRenderTarget: function() {\n        return this.targetEl;\n    },\n\n    // Overridden method from Ext.layout.container.Container.\n    // Used by Container classes to insert special DOM elements which must exist in addition to the child components\n    getElementTarget: function() {\n        return this.innerCt;\n    },\n\n    calculateChildBox: Ext.deprecated(),\n    calculateChildBoxes: Ext.deprecated(),\n    updateChildBoxes: Ext.deprecated(),\n\n    /**\n     * @private\n     */\n    destroy: function() {\n        Ext.destroy(this.innerCt, this.overflowHandler);\n        this.callParent(arguments);\n    }\n});\n\n/**\n * A layout that arranges items horizontally across a Container. This layout optionally divides available horizontal\n * space between child items containing a numeric `flex` configuration.\n *\n * This layout may also be used to set the heights of child items by configuring it with the {@link #align} option.\n *\n *     @example\n *     Ext.create('Ext.Panel', {\n *         width: 500,\n *         height: 300,\n *         title: \"HBoxLayout Panel\",\n *         layout: {\n *             type: 'hbox',\n *             align: 'stretch'\n *         },\n *         renderTo: document.body,\n *         items: [{\n *             xtype: 'panel',\n *             title: 'Inner Panel One',\n *             flex: 2\n *         },{\n *             xtype: 'panel',\n *             title: 'Inner Panel Two',\n *             flex: 1\n *         },{\n *             xtype: 'panel',\n *             title: 'Inner Panel Three',\n *             flex: 1\n *         }]\n *     });\n */\nExt.define('Ext.layout.container.HBox', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.hbox'],\n    extend: 'Ext.layout.container.Box',\n    alternateClassName: 'Ext.layout.HBoxLayout',\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String} align\n     * Controls how the child items of the container are aligned. Acceptable configuration values for this property are:\n     *\n     * - **top** : **Default** child items are aligned vertically at the **top** of the container\n     * - **middle** : child items are aligned vertically in the **middle** of the container\n     * - **stretch** : child items are stretched vertically to fill the height of the container\n     * - **stretchmax** : child items are stretched vertically to the height of the largest item.\n     */\n    align: 'top', // top, middle, stretch, strechmax\n\n    type : 'hbox',\n\n    direction: 'horizontal',\n\n    horizontal: true,\n\n    names: {\n        // parallel\n        lr: 'lr',\n        left: 'left',// 'before',\n        leftCap: 'Left',\n        right: 'right',// 'after',\n        position: 'left',\n        width: 'width',\n        contentWidth: 'contentWidth',\n        minWidth: 'minWidth',\n        maxWidth: 'maxWidth',\n        widthCap: 'Width',\n        widthModel: 'widthModel',\n        widthIndex: 0,\n        x: 'x',\n        scrollLeft: 'scrollLeft',\n        overflowX: 'overflowX',\n        hasOverflowX: 'hasOverflowX',\n        invalidateScrollX: 'invalidateScrollX',\n\n        // perpendicular\n        center: 'middle',\n        top: 'top',\n        topPosition: 'top',\n        bottom: 'bottom',\n        height: 'height',\n        contentHeight: 'contentHeight',\n        minHeight: 'minHeight',\n        maxHeight: 'maxHeight',\n        heightCap: 'Height',\n        heightModel: 'heightModel',\n        heightIndex: 1,\n        y: 'y',\n        scrollTop: 'scrollTop',\n        overflowY: 'overflowY',\n        hasOverflowY: 'hasOverflowY',\n        invalidateScrollY: 'invalidateScrollY',\n\n        // Methods\n        getWidth: 'getWidth',\n        getHeight: 'getHeight',\n        setWidth: 'setWidth',\n        setHeight: 'setHeight',\n        gotWidth: 'gotWidth',\n        gotHeight: 'gotHeight',\n        setContentWidth: 'setContentWidth',\n        setContentHeight: 'setContentHeight',\n        setWidthInDom: 'setWidthInDom',\n        setHeightInDom: 'setHeightInDom'\n    },\n\n    sizePolicy: {\n        flex: {\n            '': {\n                setsWidth: 1,\n                setsHeight: 0\n            },\n            stretch: {\n                setsWidth: 1,\n                setsHeight: 1\n            },\n            stretchmax: {\n                readsHeight: 1,\n                setsWidth: 1,\n                setsHeight: 1\n            }\n        },\n        '': {\n            setsWidth: 0,\n            setsHeight: 0\n        },\n        stretch: {\n            setsWidth: 0,\n            setsHeight: 1\n        },\n        stretchmax: {\n            readsHeight: 1,\n            setsWidth: 0,\n            setsHeight: 1\n        }\n    }            \n});\n\n/**\n * A layout that arranges items vertically down a Container. This layout optionally divides available vertical space\n * between child items containing a numeric `flex` configuration.\n *\n * This layout may also be used to set the widths of child items by configuring it with the {@link #align} option.\n *\n *     @example\n *     Ext.create('Ext.Panel', {\n *         width: 500,\n *         height: 400,\n *         title: \"VBoxLayout Panel\",\n *         layout: {\n *             type: 'vbox',\n *             align: 'center'\n *         },\n *         renderTo: document.body,\n *         items: [{\n *             xtype: 'panel',\n *             title: 'Inner Panel One',\n *             width: 250,\n *             flex: 2\n *         },\n *         {\n *             xtype: 'panel',\n *             title: 'Inner Panel Two',\n *             width: 250,\n *             flex: 4\n *         },\n *         {\n *             xtype: 'panel',\n *             title: 'Inner Panel Three',\n *             width: '50%',\n *             flex: 4\n *         }]\n *     });\n */\nExt.define('Ext.layout.container.VBox', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.vbox'],\n    extend: 'Ext.layout.container.Box',\n    alternateClassName: 'Ext.layout.VBoxLayout',\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String} align\n     * Controls how the child items of the container are aligned. Acceptable configuration values for this property are:\n     *\n     * - **left** : **Default** child items are aligned horizontally at the **left** side of the container\n     * - **center** : child items are aligned horizontally at the **mid-width** of the container\n     * - **stretch** : child items are stretched horizontally to fill the width of the container\n     * - **stretchmax** : child items are stretched horizontally to the size of the largest item.\n     */\n    align : 'left', // left, center, stretch, strechmax\n\n    type: 'vbox',\n\n    direction: 'vertical',\n\n    horizontal: false,\n\n    names: {\n        // parallel\n        lr: 'tb',\n        left: 'top',\n        leftCap: 'Top',\n        right: 'bottom',\n        position: 'top',\n        width: 'height',\n        contentWidth: 'contentHeight',\n        minWidth: 'minHeight',\n        maxWidth: 'maxHeight',\n        widthCap: 'Height',\n        widthModel: 'heightModel',\n        widthIndex: 1,\n        x: 'y',\n        scrollLeft: 'scrollTop',\n        overflowX: 'overflowY',\n        hasOverflowX: 'hasOverflowY',\n        invalidateScrollX: 'invalidateScrollY',\n\n        // perpendicular\n        center: 'center',\n        top: 'left',// 'before',\n        topPosition: 'left',\n        bottom: 'right',// 'after',\n        height: 'width',\n        contentHeight: 'contentWidth',\n        minHeight: 'minWidth',\n        maxHeight: 'maxWidth',\n        heightCap: 'Width',\n        heightModel: 'widthModel',\n        heightIndex: 0,\n        y: 'x',\n        scrollTop: 'scrollLeft',\n        overflowY: 'overflowX',\n        hasOverflowY: 'hasOverflowX',\n        invalidateScrollY: 'invalidateScrollX',\n\n        // Methods\n        getWidth: 'getHeight',\n        getHeight: 'getWidth',\n        setWidth: 'setHeight',\n        setHeight: 'setWidth',\n        gotWidth: 'gotHeight',\n        gotHeight: 'gotWidth',\n        setContentWidth: 'setContentHeight',\n        setContentHeight: 'setContentWidth',\n        setWidthInDom: 'setHeightInDom',\n        setHeightInDom: 'setWidthInDom'\n    },\n\n    sizePolicy: {\n        flex: {\n            '': {\n                setsWidth: 0,\n                setsHeight: 1\n            },\n            stretch: {\n                setsWidth: 1,\n                setsHeight: 1\n            },\n            stretchmax: {\n                readsWidth: 1,\n                setsWidth: 1,\n                setsHeight: 1\n            }\n        },\n        '': {\n            setsWidth: 0,\n            setsHeight: 0\n        },\n        stretch: {\n            setsWidth: 1,\n            setsHeight: 0\n        },\n        stretchmax: {\n            readsWidth: 1,\n            setsWidth: 1,\n            setsHeight: 0\n        }\n    }\n});\n\n/**\n * Basic Toolbar class. Although the {@link Ext.container.Container#defaultType defaultType} for\n * Toolbar is {@link Ext.button.Button button}, Toolbar elements (child items for the Toolbar container)\n * may be virtually any type of Component. Toolbar elements can be created explicitly via their\n * constructors, or implicitly via their xtypes, and can be {@link #method-add}ed dynamically.\n *\n * ## Some items have shortcut strings for creation:\n *\n * | Shortcut | xtype         | Class                         | Description\n * |:---------|:--------------|:------------------------------|:---------------------------------------------------\n * | `->`     | `tbfill`      | {@link Ext.toolbar.Fill}      | begin using the right-justified button container\n * | `-`      | `tbseparator` | {@link Ext.toolbar.Separator} | add a vertical separator bar between toolbar items\n * | ` `      | `tbspacer`    | {@link Ext.toolbar.Spacer}    | add horiztonal space between elements\n *\n *     @example\n *     Ext.create('Ext.toolbar.Toolbar', {\n *         renderTo: document.body,\n *         width   : 500,\n *         items: [\n *             {\n *                 // xtype: 'button', // default for Toolbars\n *                 text: 'Button'\n *             },\n *             {\n *                 xtype: 'splitbutton',\n *                 text : 'Split Button'\n *             },\n *             // begin using the right-justified button container\n *             '->', // same as { xtype: 'tbfill' }\n *             {\n *                 xtype    : 'textfield',\n *                 name     : 'field1',\n *                 emptyText: 'enter search term'\n *             },\n *             // add a vertical separator bar between toolbar items\n *             '-', // same as {xtype: 'tbseparator'} to create Ext.toolbar.Separator\n *             'text 1', // same as {xtype: 'tbtext', text: 'text1'} to create Ext.toolbar.TextItem\n *             { xtype: 'tbspacer' },// same as ' ' to create Ext.toolbar.Spacer\n *             'text 2',\n *             { xtype: 'tbspacer', width: 50 }, // add a 50px space\n *             'text 3'\n *         ]\n *     });\n *\n * Toolbars have {@link #method-enable} and {@link #method-disable} methods which when called, will\n * enable/disable all items within your toolbar.\n *\n *     @example\n *     Ext.create('Ext.toolbar.Toolbar', {\n *         renderTo: document.body,\n *         width   : 400,\n *         items: [\n *             {\n *                 text: 'Button'\n *             },\n *             {\n *                 xtype: 'splitbutton',\n *                 text : 'Split Button'\n *             },\n *             '->',\n *             {\n *                 xtype    : 'textfield',\n *                 name     : 'field1',\n *                 emptyText: 'enter search term'\n *             }\n *         ]\n *     });\n *\n * Example\n *\n *     @example\n *     var enableBtn = Ext.create('Ext.button.Button', {\n *         text    : 'Enable All Items',\n *         disabled: true,\n *         scope   : this,\n *         handler : function() {\n *             //disable the enable button and enable the disable button\n *             enableBtn.disable();\n *             disableBtn.enable();\n *\n *             //enable the toolbar\n *             toolbar.enable();\n *         }\n *     });\n *\n *     var disableBtn = Ext.create('Ext.button.Button', {\n *         text    : 'Disable All Items',\n *         scope   : this,\n *         handler : function() {\n *             //enable the enable button and disable button\n *             disableBtn.disable();\n *             enableBtn.enable();\n *\n *             //disable the toolbar\n *             toolbar.disable();\n *         }\n *     });\n *\n *     var toolbar = Ext.create('Ext.toolbar.Toolbar', {\n *         renderTo: document.body,\n *         width   : 400,\n *         margin  : '5 0 0 0',\n *         items   : [enableBtn, disableBtn]\n *     });\n *\n * Adding items to and removing items from a toolbar is as simple as calling the {@link #method-add}\n * and {@link #method-remove} methods. There is also a {@link #removeAll} method\n * which remove all items within the toolbar.\n *\n *     @example\n *     var toolbar = Ext.create('Ext.toolbar.Toolbar', {\n *         renderTo: document.body,\n *         width   : 700,\n *         items: [\n *             {\n *                 text: 'Example Button'\n *             }\n *         ]\n *     });\n *\n *     var addedItems = [];\n *\n *     Ext.create('Ext.toolbar.Toolbar', {\n *         renderTo: document.body,\n *         width   : 700,\n *         margin  : '5 0 0 0',\n *         items   : [\n *             {\n *                 text   : 'Add a button',\n *                 scope  : this,\n *                 handler: function() {\n *                     var text = prompt('Please enter the text for your button:');\n *                     addedItems.push(toolbar.add({\n *                         text: text\n *                     }));\n *                 }\n *             },\n *             {\n *                 text   : 'Add a text item',\n *                 scope  : this,\n *                 handler: function() {\n *                     var text = prompt('Please enter the text for your item:');\n *                     addedItems.push(toolbar.add(text));\n *                 }\n *             },\n *             {\n *                 text   : 'Add a toolbar separator',\n *                 scope  : this,\n *                 handler: function() {\n *                     addedItems.push(toolbar.add('-'));\n *                 }\n *             },\n *             {\n *                 text   : 'Add a toolbar spacer',\n *                 scope  : this,\n *                 handler: function() {\n *                     addedItems.push(toolbar.add('->'));\n *                 }\n *             },\n *             '->',\n *             {\n *                 text   : 'Remove last inserted item',\n *                 scope  : this,\n *                 handler: function() {\n *                     if (addedItems.length) {\n *                         toolbar.remove(addedItems.pop());\n *                     } else if (toolbar.items.length) {\n *                         toolbar.remove(toolbar.items.last());\n *                     } else {\n *                         alert('No items in the toolbar');\n *                     }\n *                 }\n *             },\n *             {\n *                 text   : 'Remove all items',\n *                 scope  : this,\n *                 handler: function() {\n *                     toolbar.removeAll();\n *                 }\n *             }\n *         ]\n *     });\n *\n * @constructor\n * Creates a new Toolbar\n * @param {Object/Object[]} config A config object or an array of buttons to {@link #method-add}\n * @docauthor Robert Dougan <rob@sencha.com>\n */\nExt.define('Ext.toolbar.Toolbar', {\n    extend: 'Ext.container.Container',\n    requires: [\n        'Ext.toolbar.Fill',\n        'Ext.layout.container.HBox',\n        'Ext.layout.container.VBox'\n    ],\n    uses: [\n        'Ext.toolbar.Separator'\n    ],\n    alias: 'widget.toolbar',\n    alternateClassName: 'Ext.Toolbar',\n\n    /**\n     * @property {Boolean} isToolbar\n     * `true` in this class to identify an object as an instantiated Toolbar, or subclass thereof.\n     */\n    isToolbar: true,\n    baseCls  : Ext.baseCSSPrefix + 'toolbar',\n    ariaRole : 'toolbar',\n\n    defaultType: 'button',\n\n    /**\n     * @cfg {Boolean} vertical\n     * Set to `true` to make the toolbar vertical. The layout will become a `vbox`.\n     */\n    vertical: false,\n\n    /**\n     * @cfg {String/Object} layout\n     * This class assigns a default layout (`layout: 'hbox'`).\n     * Developers _may_ override this configuration option if another layout\n     * is required (the constructor must be passed a configuration object in this\n     * case instead of an array).\n     * See {@link Ext.container.Container#layout} for additional information.\n     */\n\n    /**\n     * @cfg {Boolean} enableOverflow\n     * Configure true to make the toolbar provide a button which activates a dropdown Menu to show\n     * items which overflow the Toolbar's width.\n     */\n    enableOverflow: false,\n\n    /**\n     * @cfg {String} menuTriggerCls\n     * Configure the icon class of the overflow button.\n     */\n    menuTriggerCls: Ext.baseCSSPrefix + 'toolbar-more-icon',\n    \n    // private\n    trackMenus: true,\n\n    itemCls: Ext.baseCSSPrefix + 'toolbar-item',\n\n    statics: {\n        shortcuts: {\n            '-' : 'tbseparator',\n            ' ' : 'tbspacer'\n        },\n\n        shortcutsHV: {\n            // horizontal\n            0: {\n                '->': { xtype: 'tbfill', height: 0 }\n            },\n            // vertical\n            1: {\n                '->': { xtype: 'tbfill', width: 0 }\n            }\n        }\n    },\n\n    initComponent: function() {\n        var me = this,\n            keys;\n\n        // check for simplified (old-style) overflow config:\n        if (!me.layout && me.enableOverflow) {\n            me.layout = { overflowHandler: 'Menu' };\n        }\n\n        if (me.dock === 'right' || me.dock === 'left') {\n            me.vertical = true;\n        }\n\n        me.layout = Ext.applyIf(Ext.isString(me.layout) ? {\n            type: me.layout\n        } : me.layout || {}, {\n            type: me.vertical ? 'vbox' : 'hbox',\n            align: me.vertical ? 'stretchmax' : 'middle'\n        });\n\n        if (me.vertical) {\n            me.addClsWithUI('vertical');\n        }\n\n        // @TODO: remove this hack and implement a more general solution\n        if (me.ui === 'footer') {\n            me.ignoreBorderManagement = true;\n        }\n\n        me.callParent();\n\n        /**\n         * @event overflowchange\n         * Fires after the overflow state has changed.\n         * @param {Object} c The Container\n         * @param {Boolean} lastOverflow overflow state\n         */\n        me.addEvents('overflowchange');\n    },\n\n    getRefItems: function(deep) {\n        var me = this,\n            items = me.callParent(arguments),\n            layout = me.layout,\n            handler;\n\n        if (deep && me.enableOverflow) {\n            handler = layout.overflowHandler;\n            if (handler && handler.menu) {\n                items = items.concat(handler.menu.getRefItems(deep));\n            }\n        }\n        return items;\n    },\n\n    /**\n     * Adds element(s) to the toolbar -- this function takes a variable number of\n     * arguments of mixed type and adds them to the toolbar.\n     *\n     * **Note**: See the notes within {@link Ext.container.Container#method-add}.\n     *\n     * @param {Object...} args The following types of arguments are all valid:\n     *\n     *  - `{@link Ext.button.Button config}`: A valid button config object\n     *  - `HtmlElement`: Any standard HTML element\n     *  - `Field`: Any form field\n     *  - `Item`: Any subclass of {@link Ext.toolbar.Item}\n     *  - `String`: Any generic string (gets wrapped in a {@link Ext.toolbar.TextItem}).\n     *\n     *    Note that there are a few special strings that are treated differently as explained next:\n     *\n     *      - `'-'`: Creates a separator element\n     *      - `' '`: Creates a spacer element\n     *      - `'->'`: Creates a fill element\n     *\n     * @method add\n     */\n\n    // private\n    lookupComponent: function(c) {\n        if (typeof c == 'string') {\n            var T = Ext.toolbar.Toolbar,\n                shortcut = T.shortcutsHV[this.vertical ? 1 : 0][c] || T.shortcuts[c];\n\n            if (typeof shortcut == 'string') {\n                c = {\n                    xtype: shortcut\n                };\n            } else if (shortcut) {\n                c = Ext.apply({}, shortcut);\n            } else {\n                c = {\n                    xtype: 'tbtext',\n                    text: c\n                };\n            }\n\n            this.applyDefaults(c);\n        }\n\n        return this.callParent(arguments);\n    },\n\n    // private\n    applyDefaults: function(c) {\n        if (!Ext.isString(c)) {\n            c = this.callParent(arguments);\n        }\n        return c;\n    },\n\n    // private\n    trackMenu: function(item, remove) {\n        if (this.trackMenus && item.menu) {\n            var method = remove ? 'mun' : 'mon',\n                me = this;\n\n            me[method](item, 'mouseover', me.onButtonOver, me);\n            me[method](item, 'menushow', me.onButtonMenuShow, me);\n            me[method](item, 'menuhide', me.onButtonMenuHide, me);\n        }\n    },\n\n    // private\n    constructButton: function(item) {\n        return item.events ? item\n                : Ext.widget(item.split ? 'splitbutton' : this.defaultType, item);\n    },\n\n    // private\n    onBeforeAdd: function(component) {\n        if (component.is('field') || (component.is('button') && this.ui != 'footer')) {\n            component.ui = component.ui + '-toolbar';\n        }\n\n        // Any separators needs to know if is vertical or not\n        if (component instanceof Ext.toolbar.Separator) {\n            component.setUI((this.vertical) ? 'vertical' : 'horizontal');\n        }\n\n        this.callParent(arguments);\n    },\n\n    // private\n    onAdd: function(component) {\n        this.callParent(arguments);\n        this.trackMenu(component);\n    },\n    \n    // private\n    onRemove: function(c) {\n        this.callParent(arguments);\n        this.trackMenu(c, true);\n    },\n    \n    getChildItemsToDisable: function() {\n        return this.items.getRange();   \n    },\n\n    // private\n    onButtonOver: function(btn){\n        if (this.activeMenuBtn && this.activeMenuBtn != btn) {\n            this.activeMenuBtn.hideMenu();\n            btn.showMenu();\n            this.activeMenuBtn = btn;\n        }\n    },\n\n    // private\n    onButtonMenuShow: function(btn) {\n        this.activeMenuBtn = btn;\n    },\n\n    // private\n    onButtonMenuHide: function(btn) {\n        delete this.activeMenuBtn;\n    }\n});\n\n/**\n *\n */\nExt.define('Ext.container.DockingContainer', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.util.MixedCollection', 'Ext.Element' ],\n\n    /* End Definitions */\n\n    isDockingContainer: true,\n\n    /**\n     * @cfg {Object} defaultDockWeights\n     * This object holds the default weights applied to dockedItems that have no weight. These start with a\n     * weight of 1, to allow negative weights to insert before top items and are odd numbers\n     * so that even weights can be used to get between different dock orders.\n     *\n     * To make default docking order match border layout, do this:\n     *\n     *      Ext.panel.AbstractPanel.prototype.defaultDockWeights = { top: 1, bottom: 3, left: 5, right: 7 };\n     *\n     * Changing these defaults as above or individually on this object will effect all Panels.\n     * To change the defaults on a single panel, you should replace the entire object:\n     *\n     *      initComponent: function () {\n     *          // NOTE: Don't change members of defaultDockWeights since the object is shared.\n     *          this.defaultDockWeights = { top: 1, bottom: 3, left: 5, right: 7 };\n     *\n     *          this.callParent();\n     *      }\n     *\n     * To change only one of the default values, you do this:\n     *\n     *      initComponent: function () {\n     *          // NOTE: Don't change members of defaultDockWeights since the object is shared.\n     *          this.defaultDockWeights = Ext.applyIf({ top: 10 }, this.defaultDockWeights);\n     * \n     *          this.callParent();\n     *      }\n     */\n    defaultDockWeights: {\n        top:    { render: 1, visual: 1 },\n        left:   { render: 3, visual: 5 },\n        right:  { render: 5, visual: 7 },\n        bottom: { render: 7, visual: 3 }\n    },\n\n    // @private\n    // Values to decide which side of the body element docked items must go\n    // This overides any weight. A left/top will *always* sort before a right/bottom\n    // regardless of any weight value. Weights sort at either side of the \"body\" dividing point.\n    dockOrder: {\n        top: -1,\n        left: -1,\n        right: 1,\n        bottom: 1\n    },\n\n    /**\n     * Adds docked item(s) to the container.\n     *\n     * @param {Object/Object[]} component The Component or array of components to add. The components\n     * must include a 'dock' parameter on each component to indicate where it should be docked\n     * ('top', 'right', 'bottom', 'left').\n     * @param {Number} [pos] The index at which the Component will be added\n     * @return {Ext.Component[]} The added components.\n     */\n    addDocked : function(items, pos) {\n        var me = this,\n            i = 0,\n            item, length;\n\n        items = me.prepareItems(items);\n        length = items.length;\n\n        for (; i < length; i++) {\n            item = items[i];\n            item.dock = item.dock || 'top';\n\n            if (pos !== undefined) {\n                me.dockedItems.insert(pos + i, item);\n            } else {\n                me.dockedItems.add(item);\n            }\n            if (item.onAdded !== Ext.emptyFn) {\n                item.onAdded(me, i);\n            }\n            if (me.onDockedAdd !== Ext.emptyFn) {\n                me.onDockedAdd(item);\n            }\n        }\n\n        if (me.rendered && !me.suspendLayout) {\n            me.updateLayout();\n        }\n        return items;\n    },\n\n    destroyDockedItems: function(){\n        var dockedItems = this.dockedItems,\n            c;\n\n        if (dockedItems) {\n            while ((c = dockedItems.first())) {\n                this.removeDocked(c, true);\n            }\n        }\n    },\n\n    doRenderDockedItems: function (out, renderData, after) {\n        // Careful! This method is bolted on to the frameTpl and renderTpl so all we get for\n        // context is the renderData! The \"this\" pointer is either the frameTpl or the\n        // renderTpl instance!\n\n        // Due to framing, we will be called in two different ways: in the frameTpl or in\n        // the renderTpl. The frameTpl version enters via doRenderFramingDockedItems which\n        // sets \"$skipDockedItems\" on the renderTpl's renderData.\n        //\n        var me = renderData.$comp,\n            layout = me.componentLayout,\n            items,\n            tree;\n\n        if (layout.getDockedItems && !renderData.$skipDockedItems) {\n            items = layout.getDockedItems('render', !after);\n            tree = items && layout.getItemsRenderTree(items);\n\n            if (tree) {\n                Ext.DomHelper.generateMarkup(tree, out);\n            }\n        }\n    },\n\n    /**\n     * Finds a docked component by id, itemId or position. Also see {@link #getDockedItems}\n     * @param {String/Number} comp The id, itemId or position of the docked component (see {@link Ext.panel.AbstractPanel#getComponent getComponent} for details)\n     * @return {Ext.Component} The docked component (if found)\n     */\n    getDockedComponent: function(comp) {\n        if (Ext.isObject(comp)) {\n            comp = comp.getItemId();\n        }\n        return this.dockedItems.get(comp);\n    },\n\n    /**\n     * Retrieves an array of all currently docked Components.\n     *\n     * For example to find a toolbar that has been docked at top:\n     *\n     *     panel.getDockedItems('toolbar[dock=\"top\"]');\n     *\n     * @param {String} selector A {@link Ext.ComponentQuery ComponentQuery} selector string to filter the returned items.\n     * @param {Boolean} beforeBody An optional flag to limit the set of items to only those\n     *  before the body (true) or after the body (false). All components are returned by\n     *  default.\n     * @return {Ext.Component[]} The array of docked components meeting the specified criteria.\n     */\n    getDockedItems : function(selector, beforeBody) {\n        var dockedItems = this.getComponentLayout().getDockedItems('render', beforeBody);\n\n        if (selector && dockedItems.length) {\n            dockedItems = Ext.ComponentQuery.query(selector, dockedItems);\n        }\n\n        return dockedItems;\n    },\n\n    getDockingRefItems: function(deep, containerItems) {\n        // deep fetches the docked items and their descendants using '*' and then '* *'\n        var selector = deep && '*,* *',\n            // start with only the top/left docked items (and maybe their children)\n            dockedItems = this.getDockedItems(selector, true),\n            items;\n\n        // push container items (and maybe their children) after top/left docked items:\n        dockedItems.push.apply(dockedItems, containerItems);\n\n        // push right/bottom docked items (and maybe their children) after container items:\n        items = this.getDockedItems(selector, false);\n        dockedItems.push.apply(dockedItems, items);\n\n        return dockedItems;\n    },\n\n    initDockingItems: function() {\n        var me = this,\n            items = me.dockedItems;\n\n        me.dockedItems = new Ext.util.AbstractMixedCollection(false, me.getComponentId);\n        if (items) {\n            me.addDocked(items);\n        }\n    },\n\n    /**\n     * Inserts docked item(s) to the panel at the indicated position.\n     * @param {Number} pos The index at which the Component will be inserted\n     * @param {Object/Object[]} component. The Component or array of components to add. The components\n     * must include a 'dock' paramater on each component to indicate where it should be docked ('top', 'right',\n     * 'bottom', 'left').\n     */\n    insertDocked : function(pos, items) {\n        this.addDocked(items, pos);\n    },\n\n    // Placeholder empty functions\n    /**\n     * Invoked after a docked item is added to the Panel.\n     * @param {Ext.Component} component\n     * @template\n     * @protected\n     */\n    onDockedAdd : Ext.emptyFn,\n    /**\n     * Invoked after a docked item is removed from the Panel.\n     * @param {Ext.Component} component\n     * @template\n     * @protected\n     */\n    onDockedRemove : Ext.emptyFn,\n\n    /**\n     * Removes the docked item from the panel.\n     * @param {Ext.Component} item. The Component to remove.\n     * @param {Boolean} autoDestroy (optional) Destroy the component after removal.\n     */\n    removeDocked : function(item, autoDestroy) {\n        var me = this,\n            layout,\n            hasLayout;\n\n        if (!me.dockedItems.contains(item)) {\n            return item;\n        }\n\n        layout = me.componentLayout;\n        hasLayout = layout && me.rendered;\n\n        if (hasLayout) {\n            layout.onRemove(item);\n        }\n\n        me.dockedItems.remove(item);\n        item.onRemoved();\n        me.onDockedRemove(item);\n\n        if (autoDestroy === true || (autoDestroy !== false && me.autoDestroy)) {\n            item.destroy();\n        } else if (hasLayout) {\n            // not destroying, make any layout related removals\n            layout.afterRemove(item);\n        }\n\n        if (!me.destroying && !me.suspendLayout) {\n            me.updateLayout();\n        }\n\n        return item;\n    },\n\n    setupDockingRenderTpl: function (renderTpl) {\n        renderTpl.renderDockedItems = this.doRenderDockedItems;\n    }\n});\n\n/**\n * @class Ext.panel.AbstractPanel\n * @private\n *\n * A base class which provides methods common to Panel classes across the Sencha product range.\n *\n * Please refer to sub class's documentation\n */\nExt.define('Ext.panel.AbstractPanel', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.container.Container',\n\n    mixins: {\n        docking: 'Ext.container.DockingContainer'\n    },\n\n    requires: ['Ext.util.MixedCollection', 'Ext.Element', 'Ext.toolbar.Toolbar'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String} [baseCls=x-panel]\n     * The base CSS class to apply to this panel's element.\n     */\n    baseCls : Ext.baseCSSPrefix + 'panel',\n\n    /**\n     * @cfg {Number/String} bodyPadding\n     * A shortcut for setting a padding style on the body element. The value can either be\n     * a number to be applied to all sides, or a normal css string describing padding.\n     * Defaults to <code>undefined</code>.\n     */\n\n    /**\n     * @cfg {Boolean} bodyBorder\n     * A shortcut to add or remove the border on the body of a panel. This only applies to a panel which has the {@link #frame} configuration set to `true`.\n     * Defaults to <code>undefined</code>.\n     */\n\n    /**\n     * @cfg {String/Object/Function} bodyStyle\n     * Custom CSS styles to be applied to the panel's body element, which can be supplied as a valid CSS style string,\n     * an object containing style property name/value pairs or a function that returns such a string or object.\n     * For example, these two formats are interpreted to be equivalent:<pre><code>\nbodyStyle: 'background:#ffc; padding:10px;'\n\nbodyStyle: {\n    background: '#ffc',\n    padding: '10px'\n}\n     * </code></pre>\n     */\n\n    /**\n     * @cfg {String/String[]} bodyCls\n     * A CSS class, space-delimited string of classes, or array of classes to be applied to the panel's body element.\n     * The following examples are all valid:<pre><code>\nbodyCls: 'foo'\nbodyCls: 'foo bar'\nbodyCls: ['foo', 'bar']\n     * </code></pre>\n     */\n\n    /**\n     * @property {Boolean} isPanel\n     * `true` in this class to identify an object as an instantiated Panel, or subclass thereof.\n     */\n    isPanel: true,\n\n    componentLayout: 'dock',\n\n    childEls: [\n        'body'\n    ],\n\n    renderTpl: [\n        // If this Panel is framed, the framing template renders the docked items round the frame\n        '{% this.renderDockedItems(out,values,0); %}',\n        // This empty div solves an IE6/7/Quirks problem where the margin-top on the bodyEl\n        // is ignored. Best we can figure, this is triggered by the previousSibling being\n        // position absolute (a docked item). The goal is to use margins to position the\n        // bodyEl rather than left/top since that allows us to avoid writing a height on the\n        // panel and the body. This in turn allows CSS height to expand or contract the\n        // panel during things like portlet dragging where we want to avoid running a ton\n        // of layouts during the drag operation.\n        (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks) ? '<div></div>' : '',\n        '<div id=\"{id}-body\" class=\"{baseCls}-body<tpl if=\"bodyCls\"> {bodyCls}</tpl>',\n            ' {baseCls}-body-{ui}<tpl if=\"uiCls\">',\n                '<tpl for=\"uiCls\"> {parent.baseCls}-body-{parent.ui}-{.}</tpl>',\n            '</tpl>\"<tpl if=\"bodyStyle\"> style=\"{bodyStyle}\"</tpl>>',\n            '{%this.renderContainer(out,values);%}',\n        '</div>',\n        '{% this.renderDockedItems(out,values,1); %}'\n    ],\n\n    bodyPosProps: {\n        x: 'x',\n        y: 'y'\n    },\n\n    // TODO: Move code examples into product-specific files. The code snippet below is Touch only.\n    /**\n     * @cfg {Object/Object[]} dockedItems\n     * A component or series of components to be added as docked items to this panel.\n     * The docked items can be docked to either the top, right, left or bottom of a panel.\n     * This is typically used for things like toolbars or tab bars:\n     * <pre><code>\nvar panel = new Ext.panel.Panel({\n    fullscreen: true,\n    dockedItems: [{\n        xtype: 'toolbar',\n        dock: 'top',\n        items: [{\n            text: 'Docked to the top'\n        }]\n    }]\n});</code></pre>\n     */\n\n    border: true,\n\n    /**\n     * @private\n     */\n    emptyArray: [],\n\n    initComponent : function() {\n        var me = this;\n\n        //!frame\n        //!border\n\n        if (me.frame && me.border && me.bodyBorder === undefined) {\n            me.bodyBorder = false;\n        }\n        if (me.frame && me.border && (me.bodyBorder === false || me.bodyBorder === 0)) {\n            me.manageBodyBorders = true;\n        }\n\n        me.callParent();\n    },\n\n    beforeDestroy: function(){\n        this.destroyDockedItems();\n        this.callParent();\n    },\n\n    // @private\n    initItems : function() {\n        this.callParent();\n        this.initDockingItems();\n    },\n\n    /**\n     * Initialized the renderData to be used when rendering the renderTpl.\n     * @return {Object} Object with keys and values that are going to be applied to the renderTpl\n     * @private\n     */\n    initRenderData: function() {\n        var me = this,\n            data = me.callParent();\n\n        me.initBodyStyles();\n        me.protoBody.writeTo(data);\n        delete me.protoBody;\n\n        return data;\n    },\n\n    /**\n     * Attempts a default component lookup (see {@link Ext.container.Container#getComponent}). If the component is not found in the normal\n     * items, the dockedItems are searched and the matched component (if any) returned (see {@link #getDockedComponent}). Note that docked\n     * items will only be matched by component id or itemId -- if you pass a numeric index only non-docked child components will be searched.\n     * @param {String/Number} comp The component id, itemId or position to find\n     * @return {Ext.Component} The component (if found)\n     */\n    getComponent: function(comp) {\n        var component = this.callParent(arguments);\n        if (component === undefined && !Ext.isNumber(comp)) {\n            // If the arg is a numeric index skip docked items\n            component = this.getDockedComponent(comp);\n        }\n        return component;\n    },\n\n    getProtoBody: function () {\n        var me = this,\n            body = me.protoBody;\n\n        if (!body) {\n            me.protoBody = body = new Ext.util.ProtoElement({\n                cls: me.bodyCls,\n                style: me.bodyStyle,\n                clsProp: 'bodyCls',\n                styleProp: 'bodyStyle',\n                styleIsText: true\n            });\n        }\n\n        return body;\n    },\n\n    /**\n     * Parses the {@link #bodyStyle} config if available to create a style string that will be applied to the body element.\n     * This also includes {@link #bodyPadding} and {@link #bodyBorder} if available.\n     * @return {String} A CSS style string with body styles, padding and border.\n     * @private\n     */\n    initBodyStyles: function() {\n        var me = this,\n            body = me.getProtoBody(),\n            Element = Ext.Element;\n\n        if (me.bodyPadding !== undefined) {\n            body.setStyle('padding', Element.unitizeBox((me.bodyPadding === true) ? 5 : me.bodyPadding));\n        }\n        if (me.frame && me.bodyBorder) {\n            if (!Ext.isNumber(me.bodyBorder)) {\n                me.bodyBorder = 1;\n            }\n            body.setStyle('border-width', Element.unitizeBox(me.bodyBorder));\n        }\n    },\n\n    getCollapsedDockedItems: function () {\n        var me = this;\n        return me.collapseMode == 'placeholder' ? me.emptyArray : [ me.getReExpander() ];\n    },\n\n    /**\n     * Sets the body style according to the passed parameters.\n     * @param {Mixed} style A full style specification string, or object, or the name of a style property to set.\n     * @param {String} value If the first param was a style property name, the style property value.\n     * @return {Ext.panel.Panel} this\n     */\n    setBodyStyle: function(style, value) {\n        var me = this,\n            body = me.rendered ? me.body : me.getProtoBody();\n\n        if (Ext.isFunction(style)) {\n            style = style();\n        }\n        if (arguments.length == 1) {\n            if (Ext.isString(style)) {\n                style = Ext.Element.parseStyles(style);     \n            }\n            body.setStyle(style);\n        } else {\n            body.setStyle(style, value);\n        }\n        return me;\n    },\n\n    /**\n     * Adds a CSS class to the body element. If not rendered, the class will\n     * be added when the panel is rendered. \n     * @param {String} cls The class to add\n     * @return {Ext.panel.Panel} this\n     */\n    addBodyCls: function(cls) {\n        var me = this,\n            body = me.rendered ? me.body : me.getProtoBody();\n\n        body.addCls(cls);\n        return me;\n    },\n\n    /**\n     * Removes a CSS class from the body element.\n     * @param {String} cls The class to remove\n     * @return {Ext.panel.Panel} this\n     */\n    removeBodyCls: function(cls) {\n        var me = this,\n            body = me.rendered ? me.body : me.getProtoBody();\n\n        body.removeCls(cls);\n        return me;\n    },\n\n    // inherit docs\n    addUIClsToElement: function(cls) {\n        var me = this,\n            result = me.callParent(arguments);\n\n        me.addBodyCls([Ext.baseCSSPrefix + cls, me.baseCls + '-body-' + cls, me.baseCls + '-body-' + me.ui + '-' + cls]);\n        return result;\n    },\n\n    // inherit docs\n    removeUIClsFromElement: function(cls) {\n        var me = this,\n            result = me.callParent(arguments);\n\n        me.removeBodyCls([Ext.baseCSSPrefix + cls, me.baseCls + '-body-' + cls, me.baseCls + '-body-' + me.ui + '-' + cls]);\n        return result;\n    },\n\n    // inherit docs\n    addUIToElement: function() {\n        var me = this;\n\n        me.callParent(arguments);\n        me.addBodyCls(me.baseCls + '-body-' + me.ui);\n    },\n\n    // inherit docs\n    removeUIFromElement: function() {\n        var me = this;\n\n        me.callParent(arguments);\n        me.removeBodyCls(me.baseCls + '-body-' + me.ui);\n    },\n\n    // @private\n    getTargetEl : function() {\n        return this.body;\n    },\n\n    getRefItems: function(deep) {\n        var items = this.callParent(arguments);\n\n        return this.getDockingRefItems(deep, items);\n    },\n\n    setupRenderTpl: function (renderTpl) {\n        this.callParent(arguments);\n        this.setupDockingRenderTpl(renderTpl);\n    }\n});\n\n/**\n * Component layout for components which maintain an inner body element which must be resized to synchronize with the\n * Component size.\n * @private\n */\nExt.define('Ext.layout.component.Body', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.body'],\n\n    extend: 'Ext.layout.component.Auto',\n\n    /* End Definitions */\n\n    type: 'body',\n\n    beginLayout: function (ownerContext) {\n        this.callParent(arguments);\n\n        ownerContext.bodyContext = ownerContext.getEl('body');\n    },\n\n    // Padding is exciting here because we have 2 el's: owner.el and owner.body. Content\n    // size always includes the padding of the targetEl, which should be owner.body. But\n    // it is common to have padding on owner.el also (such as a panel header), so we need\n    // to do some more padding work if targetContext is not owner.el. The base class has\n    // already handled the ownerContext's frameInfo (border+framing) so all that is left\n    // is padding.\n\n    calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {\n        var height = this.callParent(arguments);\n\n        if (ownerContext.targetContext != ownerContext) {\n            height += ownerContext.getPaddingInfo().height;\n        }\n\n        return height;\n    },\n\n    calculateOwnerWidthFromContentWidth: function (ownerContext, contentWidth) {\n        var width = this.callParent(arguments);\n\n        if (ownerContext.targetContext != ownerContext) {\n            width += ownerContext.getPaddingInfo().width;\n        }\n\n        return width;\n    },\n\n    measureContentWidth: function (ownerContext) {\n        return ownerContext.bodyContext.setWidth(ownerContext.bodyContext.el.dom.offsetWidth, false);\n    },\n\n    measureContentHeight: function (ownerContext) {\n        return ownerContext.bodyContext.setHeight(ownerContext.bodyContext.el.dom.offsetHeight, false);\n    },\n\n    publishInnerHeight: function (ownerContext, height) {\n        var innerHeight = height - ownerContext.getFrameInfo().height,\n            targetContext = ownerContext.targetContext;\n\n        if (targetContext != ownerContext) {\n            innerHeight -= ownerContext.getPaddingInfo().height;\n        }\n\n        // return the value here, it may get used in a subclass\n        return ownerContext.bodyContext.setHeight(innerHeight, !ownerContext.heightModel.natural);\n    },\n\n    publishInnerWidth: function (ownerContext, width) {\n        var innerWidth = width - ownerContext.getFrameInfo().width,\n            targetContext = ownerContext.targetContext;\n\n        if (targetContext != ownerContext) {\n            innerWidth -= ownerContext.getPaddingInfo().width;\n        }\n\n        ownerContext.bodyContext.setWidth(innerWidth, !ownerContext.widthModel.natural);\n    }\n});\n\n/**\n * Simple header class which is used for on {@link Ext.panel.Panel} and {@link Ext.window.Window}.\n */\nExt.define('Ext.panel.Header', {\n    extend: 'Ext.container.Container',\n    uses: ['Ext.panel.Tool', 'Ext.draw.Component', 'Ext.util.CSS', 'Ext.layout.component.Body', 'Ext.Img'],\n    alias: 'widget.header',\n\n    /**\n     * @property {Boolean} isHeader\n     * `true` in this class to identify an objact as an instantiated Header, or subclass thereof.\n     */\n    isHeader       : true,\n    defaultType    : 'tool',\n    indicateDrag   : false,\n    weight         : -1,\n    componentLayout: 'body',\n\n    /**\n     * @cfg {String} [titleAlign='left']\n     * May be `\"left\"`, `\"right\"` or `\"center\"`.\n     *\n     * The alignment of the title text within the available space between the icon and the tools.\n     */\n    titleAlign: 'left',\n\n    childEls: [\n        'body'\n    ],\n\n    renderTpl: [\n        '<div id=\"{id}-body\" class=\"{baseCls}-body {bodyCls}',\n        '<tpl for=\"uiCls\"> {parent.baseCls}-body-{parent.ui}-{.}</tpl>\"',\n        '<tpl if=\"bodyStyle\"> style=\"{bodyStyle}\"</tpl>>',\n            '{%this.renderContainer(out,values)%}',\n        '</div>'\n    ],\n\n    headingTpl: '<span id=\"{id}-textEl\" class=\"{cls}-text {cls}-text-{ui}\">{title}</span>',\n\n    shrinkWrap: 3,\n\n    /**\n     * @cfg {String} title\n     * The title text to display.\n     */\n\n    /**\n     * @cfg {String} iconCls\n     * CSS class for an icon in the header. Used for displaying an icon to the left of a title.\n     */\n    \n    /**\n     * @cfg {String} icon\n     * Path to image for an icon in the header. Used for displaying an icon to the left of a title.\n     */\n\n    initComponent: function() {\n        var me = this,\n            ruleStyle,\n            rule,\n            style,\n            ui,\n            tempEl;\n            \n        me.addEvents(\n            /**\n             * @event click\n             * Fires when the header is clicked. This event will not be fired \n             * if the click was on a {@link Ext.panel.Tool}\n             * @param {Ext.panel.Header} this\n             * @param {Ext.EventObject} e\n             */\n            'click',\n            \n            /**\n             * @event dblclick\n             * Fires when the header is double clicked. This event will not \n             * be fired if the click was on a {@link Ext.panel.Tool}\n             * @param {Ext.panel.Header} this\n             * @param {Ext.EventObject} e\n             */\n            'dblclick'\n        );\n\n        me.indicateDragCls = me.baseCls + '-draggable';\n        me.title = me.title || '&#160;';\n        me.tools = me.tools || [];\n        me.items = me.items || [];\n        me.orientation = me.orientation || 'horizontal';\n        me.dock = (me.dock) ? me.dock : (me.orientation == 'horizontal') ? 'top' : 'left';\n\n        //add the dock as a ui\n        //this is so we support top/right/left/bottom headers\n        me.addClsWithUI([me.orientation, me.dock]);\n\n        if (me.indicateDrag) {\n            me.addCls(me.indicateDragCls);\n        }\n\n        // Add Icon\n        if (!Ext.isEmpty(me.iconCls) || !Ext.isEmpty(me.icon)) {\n            me.initIconCmp();\n            me.items.push(me.iconCmp);\n        }\n\n        // Add Title\n        if (me.orientation == 'vertical') {\n            me.layout = {\n                type : 'vbox',\n                align: 'center'\n            };\n            me.textConfig = {\n                width: 16,\n                cls: me.baseCls + '-text',\n                type: 'text',\n                text: me.title,\n                rotate: {\n                    degrees: 90\n                }\n            };\n            ui = me.ui;\n            if (Ext.isArray(ui)) {\n                ui = ui[0];\n            }\n            ruleStyle = '.' + me.baseCls + '-text-' + ui;\n            if (Ext.scopeResetCSS) {\n                ruleStyle = '.' + Ext.baseCSSPrefix + 'reset ' + ruleStyle;\n            }\n            rule = Ext.util.CSS.getRule(ruleStyle);\n\n            // We might have been disallowed access to the stylesheet: https://sencha.jira.com/browse/EXTJSIV-5084\n            if (rule) {\n                style = rule.style;\n            } else {\n                style = (tempEl = Ext.resetElement.createChild({style: 'position:absolute', cls: me.baseCls + '-text-' + ui})).getStyles('fontFamily', 'fontWeight', 'fontSize', 'color');\n                tempEl.remove();\n            }\n            if (style) {\n                Ext.apply(me.textConfig, {\n                    'font-family': style.fontFamily,\n                    'font-weight': style.fontWeight,\n                    'font-size': style.fontSize,\n                    fill: style.color\n                });\n            }\n            me.titleCmp = new Ext.draw.Component({\n                width     : 16,\n                ariaRole  : 'heading',\n                focusable : false,\n                viewBox   : false,\n                flex      : 1,\n                id        : me.id + '_hd',\n                autoSize  : true,\n                items     : me.textConfig,\n                xhooks: {\n                    setSize: function (width) {\n                        // don't pass 2nd arg (height) on to setSize or we break 'flex:1'\n                        this.callParent([width]);\n                    }\n                },\n                // this is a bit of a cheat: we are not selecting an element of titleCmp\n                // but rather of titleCmp.items[0]\n                childEls  : [\n                    { name: 'textEl', select: '.' + me.baseCls + '-text' }\n                ]\n            });\n        } else {\n            me.layout = {\n                type : 'hbox',\n                align: 'middle'\n            };\n            me.titleCmp = new Ext.Component({\n                ariaRole  : 'heading',\n                focusable : false,\n                noWrap    : true,\n                flex      : 1,\n                id        : me.id + '_hd',\n                style     : 'text-align:' + me.titleAlign,\n                cls       : me.baseCls + '-text-container',\n                renderTpl : me.getTpl('headingTpl'),\n                renderData: {\n                    title: me.title,\n                    cls  : me.baseCls,\n                    ui   : me.ui\n                },\n                childEls  : ['textEl']\n            });\n        }\n        me.items.push(me.titleCmp);\n\n        // Add Tools\n        me.items = me.items.concat(me.tools);\n        me.callParent();\n        \n        me.on({\n            dblclick: me.onDblClick,\n            click: me.onClick,\n            element: 'el',\n            scope: me\n        });\n    },\n\n    initIconCmp: function() {\n        var me = this,\n            cfg = {\n                focusable: false,\n                src: Ext.BLANK_IMAGE_URL,\n                cls: [me.baseCls + '-icon', me.iconCls],\n                id: me.id + '-iconEl',\n                iconCls: me.iconCls\n            };\n            \n        if (!Ext.isEmpty(me.icon)) {\n            delete cfg.iconCls;\n            cfg.src = me.icon;\n        }\n        \n        me.iconCmp = new Ext.Img(cfg);\n    },\n\n    afterRender: function() {\n        this.el.unselectable();\n        this.callParent();\n    },\n\n    // inherit docs\n    addUIClsToElement: function(cls) {\n        var me = this,\n            result = me.callParent(arguments),\n            classes = [me.baseCls + '-body-' + cls, me.baseCls + '-body-' + me.ui + '-' + cls],\n            array, i;\n\n        if (me.bodyCls) {\n            array = me.bodyCls.split(' ');\n\n            for (i = 0; i < classes.length; i++) {\n                if (!Ext.Array.contains(array, classes[i])) {\n                    array.push(classes[i]);\n                }\n            }\n\n            me.bodyCls = array.join(' ');\n        } else {\n            me.bodyCls = classes.join(' ');\n        }\n\n        return result;\n    },\n\n    // inherit docs\n    removeUIClsFromElement: function(cls) {\n        var me = this,\n            result = me.callParent(arguments),\n            classes = [me.baseCls + '-body-' + cls, me.baseCls + '-body-' + me.ui + '-' + cls],\n            array, i;\n\n        if (me.bodyCls) {\n            array = me.bodyCls.split(' ');\n\n            for (i = 0; i < classes.length; i++) {\n                Ext.Array.remove(array, classes[i]);\n            }\n\n            me.bodyCls = array.join(' ');\n        }\n\n        return result;\n    },\n\n    // inherit docs\n    addUIToElement: function() {\n        var me = this,\n            array, cls;\n\n        me.callParent(arguments);\n\n        cls = me.baseCls + '-body-' + me.ui;\n        if (me.rendered) {\n            if (me.bodyCls) {\n                me.body.addCls(me.bodyCls);\n            } else {\n                me.body.addCls(cls);\n            }\n        } else {\n            if (me.bodyCls) {\n                array = me.bodyCls.split(' ');\n\n                if (!Ext.Array.contains(array, cls)) {\n                    array.push(cls);\n                }\n\n                me.bodyCls = array.join(' ');\n            } else {\n                me.bodyCls = cls;\n            }\n        }\n\n        if (me.titleCmp && me.titleCmp.rendered && me.titleCmp.textEl) {\n            me.titleCmp.textEl.addCls(me.baseCls + '-text-' + me.ui);\n        }\n    },\n\n    // inherit docs\n    removeUIFromElement: function() {\n        var me = this,\n            array, cls;\n\n        me.callParent(arguments);\n\n        cls = me.baseCls + '-body-' + me.ui;\n        if (me.rendered) {\n            if (me.bodyCls) {\n                me.body.removeCls(me.bodyCls);\n            } else {\n                me.body.removeCls(cls);\n            }\n        } else {\n            if (me.bodyCls) {\n                array = me.bodyCls.split(' ');\n                Ext.Array.remove(array, cls);\n                me.bodyCls = array.join(' ');\n            } else {\n                me.bodyCls = cls;\n            }\n        }\n\n        if (me.titleCmp && me.titleCmp.rendered && me.titleCmp.textEl) {\n            me.titleCmp.textEl.removeCls(me.baseCls + '-text-' + me.ui);\n        }\n    },\n\n    onClick: function(e) {\n        this.fireClickEvent('click', e);\n    },\n    \n    onDblClick: function(e){\n        this.fireClickEvent('dblclick', e);\n    },\n    \n    fireClickEvent: function(type, e){\n        var toolCls = '.' + Ext.panel.Tool.prototype.baseCls;\n        if (!e.getTarget(toolCls)) {\n            this.fireEvent(type, this, e);\n        }    \n    },\n\n    getFocusEl: function() {\n        return this.el;\n    },\n\n    getTargetEl: function() {\n        return this.body || this.frameBody || this.el;\n    },\n\n    /**\n     * Sets the title of the header.\n     * @param {String} title The title to be set\n     */\n    setTitle: function(title) {\n        var me = this,\n            sprite,\n            surface;\n        if (me.rendered) {\n            if (me.titleCmp.rendered) {\n                if (me.titleCmp.surface) {\n                    me.title = title || '';\n                    sprite = me.titleCmp.surface.items.items[0];\n                    surface = me.titleCmp.surface;\n\n                    surface.remove(sprite);\n                    me.textConfig.type = 'text';\n                    me.textConfig.text = title;\n                    sprite = surface.add(me.textConfig);\n                    sprite.setAttributes({\n                        rotate: {\n                            degrees: 90\n                        }\n                    }, true);\n                    me.titleCmp.autoSizeSurface();\n                } else {\n                    me.title = title;\n                    me.titleCmp.textEl.update(me.title || '&#160;');\n                }\n                me.titleCmp.updateLayout();\n            } else {\n                me.titleCmp.on({\n                    render: function() {\n                        me.setTitle(title);\n                    },\n                    single: true\n                });\n            }\n        } else {\n            me.title = title;\n        }\n    },\n\n    /**\n     * @private\n     * Used when shrink wrapping a Panel to either content width or header width.\n     * This returns the minimum width required to display the header, icon and tools.\n     * **This is only intended for use with horizontal headers.**\n     */\n    getMinWidth: function() {\n        var me = this,\n            textEl = me.titleCmp.textEl.dom,\n            result,\n            tools = me.tools,\n            l, i;\n\n        // Measure text width as inline element so it doesn't stretch\n        textEl.style.display = 'inline';\n        result = textEl.offsetWidth;\n        textEl.style.display = '';\n\n        // Add tools width\n        if (tools && (l = tools.length)) {\n            for (i = 0; i < l; i++) {\n                if (tools[i].el) {\n                    result += tools[i].el.dom.offsetWidth;\n                }\n            }\n        }\n\n        // Add iconWidth\n        if (me.iconCmp) {\n            result += me.iconCmp.el.dom.offsetWidth;\n        }\n\n        // Return with some space between title and tools/end of header.\n        return result + 10;\n    },\n\n    /**\n     * Sets the CSS class that provides the icon image for this header.  This method will replace any existing\n     * icon class if one has already been set.\n     * @param {String} cls The new CSS class name\n     */\n    setIconCls: function(cls) {\n        var me = this,\n            isEmpty = !cls || !cls.length,\n            iconCmp = me.iconCmp;\n        \n        me.iconCls = cls;\n        if (!me.iconCmp && !isEmpty) {\n            me.initIconCmp();\n            me.insert(0, me.iconCmp);\n        } else if (iconCmp) {\n            if (isEmpty) {\n                me.iconCmp.destroy();\n                delete me.iconCmp;\n            } else {\n                iconCmp.removeCls(iconCmp.iconCls);\n                iconCmp.addCls(cls);\n                iconCmp.iconCls = cls;\n            }\n        }\n    },\n    \n    /**\n     * Sets the image path that provides the icon image for this header.  This method will replace any existing\n     * icon if one has already been set.\n     * @param {String} icon The new icon path\n     */\n    setIcon: function(icon) {\n        var me = this,\n            isEmpty = !icon || !icon.length,\n            iconCmp = me.iconCmp;\n        \n        me.icon = icon;\n        if (!me.iconCmp && !isEmpty) {\n            me.initIconCmp();\n            me.insert(0, me.iconCmp);\n        } else if (iconCmp) {\n            if (isEmpty) {\n                me.iconCmp.destroy();\n                delete me.iconCmp;\n            } else {\n                iconCmp.setSrc(me.icon);\n            }\n        }\n    },\n\n    /**\n     * Add a tool to the header\n     * @param {Object} tool\n     */\n    addTool: function(tool) {\n        this.tools.push(this.add(tool));\n    },\n\n    /**\n     * @protected\n     * Set up the `tools.<tool type>` link in the owning Panel.\n     * Bind the tool to its owning Panel.\n     * @param component\n     * @param index\n     */\n    onAdd: function(component, index) {\n        this.callParent(arguments);\n        if (component instanceof Ext.panel.Tool) {\n            component.bindTo(this.ownerCt);\n            this.tools[component.type] = component;\n        }\n    },\n\n    /**\n     * Add bodyCls to the renderData object\n     * @return {Object} Object with keys and values that are going to be applied to the renderTpl\n     * @private\n     */\n    initRenderData: function() {\n        return Ext.applyIf(this.callParent(), {\n            bodyCls: this.bodyCls\n        });\n    }\n});\n\n/**\n * @class Ext.fx.target.Target\n\nThis class specifies a generic target for an animation. It provides a wrapper around a\nseries of different types of objects to allow for a generic animation API.\nA target can be a single object or a Composite object containing other objects that are \nto be animated. This class and it's subclasses are generally not created directly, the \nunderlying animation will create the appropriate Ext.fx.target.Target object by passing \nthe instance to be animated.\n\nThe following types of objects can be animated:\n\n- {@link Ext.fx.target.Component Components}\n- {@link Ext.fx.target.Element Elements}\n- {@link Ext.fx.target.Sprite Sprites}\n\n * @markdown\n * @abstract\n */\nExt.define('Ext.fx.target.Target', {\n\n    isAnimTarget: true,\n\n    /**\n     * Creates new Target.\n     * @param {Ext.Component/Ext.Element/Ext.draw.Sprite} target The object to be animated\n     */\n    constructor: function(target) {\n        this.target = target;\n        this.id = this.getId();\n    },\n    \n    getId: function() {\n        return this.target.id;\n    }\n});\n\n/**\n * @class Ext.fx.target.Element\n * \n * This class represents a animation target for an {@link Ext.Element}. In general this class will not be\n * created directly, the {@link Ext.Element} will be passed to the animation and\n * and the appropriate target will be created.\n */\nExt.define('Ext.fx.target.Element', {\n\n    /* Begin Definitions */\n    \n    extend: 'Ext.fx.target.Target',\n    \n    /* End Definitions */\n\n    type: 'element',\n\n    getElVal: function(el, attr, val) {\n        if (val == undefined) {\n            if (attr === 'x') {\n                val = el.getX();\n            }\n            else if (attr === 'y') {\n                val = el.getY();\n            }\n            else if (attr === 'scrollTop') {\n                val = el.getScroll().top;\n            }\n            else if (attr === 'scrollLeft') {\n                val = el.getScroll().left;\n            }\n            else if (attr === 'height') {\n                val = el.getHeight();\n            }\n            else if (attr === 'width') {\n                val = el.getWidth();\n            }\n            else {\n                val = el.getStyle(attr);\n            }\n        }\n        return val;\n    },\n\n    getAttr: function(attr, val) {\n        var el = this.target;\n        return [[ el, this.getElVal(el, attr, val)]];\n    },\n\n    setAttr: function(targetData) {\n        var target = this.target,\n            ln = targetData.length,\n            attrs, attr, o, i, j, ln2, element, value;\n        for (i = 0; i < ln; i++) {\n            attrs = targetData[i].attrs;\n            for (attr in attrs) {\n                if (attrs.hasOwnProperty(attr)) {\n                    ln2 = attrs[attr].length;\n                    for (j = 0; j < ln2; j++) {\n                        o = attrs[attr][j];\n                        element = o[0];\n                        value = o[1];\n                        if (attr === 'x') {\n                            element.setX(value);\n                        } else if (attr === 'y') {\n                            element.setY(value);\n                        } else if (attr === 'scrollTop') {\n                            element.scrollTo('top', value);\n                        } else if (attr === 'scrollLeft') {\n                            element.scrollTo('left',value);\n                        } else if (attr === 'width') {\n                            element.setWidth(value);\n                        } else if (attr === 'height') {\n                            element.setHeight(value);\n                        } else {\n                            element.setStyle(attr, value);\n                        }\n                    }\n                }\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.fx.target.ElementCSS\n * \n * This class represents a animation target for an {@link Ext.Element} that supports CSS\n * based animation. In general this class will not be created directly, the {@link Ext.Element} \n * will be passed to the animation and the appropriate target will be created.\n */\nExt.define('Ext.fx.target.ElementCSS', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.fx.target.Element',\n\n    /* End Definitions */\n\n    setAttr: function(targetData, isFirstFrame) {\n        var cssArr = {\n                attrs: [],\n                duration: [],\n                easing: []\n            },\n            ln = targetData.length,\n            attributes,\n            attrs,\n            attr,\n            easing,\n            duration,\n            o,\n            i,\n            j,\n            ln2;\n        for (i = 0; i < ln; i++) {\n            attrs = targetData[i];\n            duration = attrs.duration;\n            easing = attrs.easing;\n            attrs = attrs.attrs;\n            for (attr in attrs) {\n                if (Ext.Array.indexOf(cssArr.attrs, attr) == -1) {\n                    cssArr.attrs.push(attr.replace(/[A-Z]/g, function(v) {\n                        return '-' + v.toLowerCase();\n                    }));\n                    cssArr.duration.push(duration + 'ms');\n                    cssArr.easing.push(easing);\n                }\n            }\n        }\n        attributes = cssArr.attrs.join(',');\n        duration = cssArr.duration.join(',');\n        easing = cssArr.easing.join(', ');\n        for (i = 0; i < ln; i++) {\n            attrs = targetData[i].attrs;\n            for (attr in attrs) {\n                ln2 = attrs[attr].length;\n                for (j = 0; j < ln2; j++) {\n                    o = attrs[attr][j];\n                    o[0].setStyle(Ext.supports.CSS3Prefix + 'TransitionProperty', isFirstFrame ? '' : attributes);\n                    o[0].setStyle(Ext.supports.CSS3Prefix + 'TransitionDuration', isFirstFrame ? '' : duration);\n                    o[0].setStyle(Ext.supports.CSS3Prefix + 'TransitionTimingFunction', isFirstFrame ? '' : easing);\n                    o[0].setStyle(attr, o[1]);\n\n                    // Must trigger reflow to make this get used as the start point for the transition that follows\n                    if (isFirstFrame) {\n                        o = o[0].dom.offsetWidth;\n                    }\n                    else {\n                        // Remove transition properties when completed.\n                        o[0].on(Ext.supports.CSS3TransitionEnd, function() {\n                            this.setStyle(Ext.supports.CSS3Prefix + 'TransitionProperty', null);\n                            this.setStyle(Ext.supports.CSS3Prefix + 'TransitionDuration', null);\n                            this.setStyle(Ext.supports.CSS3Prefix + 'TransitionTimingFunction', null);\n                        }, o[0], { single: true });\n                    }\n                }\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.fx.target.CompositeElement\n * \n * This class represents a animation target for a {@link Ext.CompositeElement}. It allows\n * each {@link Ext.Element} in the group to be animated as a whole. In general this class will not be\n * created directly, the {@link Ext.CompositeElement} will be passed to the animation and\n * and the appropriate target will be created.\n */\nExt.define('Ext.fx.target.CompositeElement', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.fx.target.Element',\n\n    /* End Definitions */\n\n    /**\n     * @property {Boolean} isComposite\n     * `true` in this class to identify an object as an instantiated CompositeElement, or subclass thereof.\n     */\n    isComposite: true,\n    \n    constructor: function(target) {\n        target.id = target.id || Ext.id(null, 'ext-composite-');\n        this.callParent([target]);\n    },\n\n    getAttr: function(attr, val) {\n        var out      = [],\n            elements = this.target.elements,\n            length   = elements.length,\n            i,\n            el;\n\n        for (i = 0; i < length; i++) {\n            el = elements[i];\n\n            if (el) {\n                el = this.target.getElement(el);\n                out.push([el, this.getElVal(el, attr, val)]);\n            }\n        }\n\n        return out;\n    }\n});\n\n/**\n * @class Ext.fx.target.CompositeElementCSS\n * \n * This class represents a animation target for a {@link Ext.CompositeElement}, where the\n * constituent elements support CSS based animation. It allows each {@link Ext.Element} in \n * the group to be animated as a whole. In general this class will not be created directly, \n * the {@link Ext.CompositeElement} will be passed to the animation and the appropriate target \n * will be created.\n */\nExt.define('Ext.fx.target.CompositeElementCSS', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.fx.target.CompositeElement',\n\n    requires: ['Ext.fx.target.ElementCSS'],\n\n    /* End Definitions */\n    setAttr: function() {\n        return Ext.fx.target.ElementCSS.prototype.setAttr.apply(this, arguments);\n    }\n});\n\n/**\n * @class Ext.fx.target.Sprite\n\n This class represents an animation target for a {@link Ext.draw.Sprite}. In general this class will not be\n created directly, the {@link Ext.draw.Sprite} will be passed to the animation and\n and the appropriate target will be created.\n\n * @markdown\n */\n\nExt.define('Ext.fx.target.Sprite', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.fx.target.Target',\n\n    /* End Definitions */\n\n    type: 'draw',\n\n    getFromPrim: function (sprite, attr) {\n        var obj;\n        switch (attr) {\n            case 'rotate':\n            case 'rotation':\n                obj = sprite.attr.rotation;\n                return {\n                    x: obj.x || 0,\n                    y: obj.y || 0,\n                    degrees: obj.degrees || 0\n                };\n            case 'scale':\n            case 'scaling':\n                obj = sprite.attr.scaling;\n                return {\n                    x: obj.x || 1,\n                    y: obj.y || 1,\n                    cx: obj.cx || 0,\n                    cy: obj.cy || 0\n                };\n            case 'translate':\n            case 'translation':\n                obj = sprite.attr.translation;\n                return {\n                    x: obj.x || 0,\n                    y: obj.y || 0\n                };\n            default:\n                return sprite.attr[attr];\n        }\n    },\n\n    getAttr: function (attr, val) {\n        return [\n            [this.target, val != undefined ? val : this.getFromPrim(this.target, attr)]\n        ];\n    },\n\n    setAttr: function (targetData) {\n        var ln = targetData.length,\n            spriteArr = [],\n            attrsConf, attr, attrArr, attrs, sprite, idx, value, i, j, x, y, ln2;\n        for (i = 0; i < ln; i++) {\n            attrsConf = targetData[i].attrs;\n            for (attr in attrsConf) {\n                attrArr = attrsConf[attr];\n                ln2 = attrArr.length;\n                for (j = 0; j < ln2; j++) {\n                    sprite = attrArr[j][0];\n                    attrs = attrArr[j][1];\n                    if (attr === 'translate' || attr === 'translation') {\n                        value = {\n                            x: attrs.x,\n                            y: attrs.y\n                        };\n                    }\n                    else if (attr === 'rotate' || attr === 'rotation') {\n                        x = attrs.x;\n                        if (isNaN(x)) {\n                            x = null;\n                        }\n                        y = attrs.y;\n                        if (isNaN(y)) {\n                            y = null;\n                        }\n                        value = {\n                            degrees: attrs.degrees,\n                            x: x,\n                            y: y\n                        };\n                    } else if (attr === 'scale' || attr === 'scaling') {\n                        x = attrs.x;\n                        if (isNaN(x)) {\n                            x = null;\n                        }\n                        y = attrs.y;\n                        if (isNaN(y)) {\n                            y = null;\n                        }\n                        value = {\n                            x: x,\n                            y: y,\n                            cx: attrs.cx,\n                            cy: attrs.cy\n                        };\n                    }\n                    else if (attr === 'width' || attr === 'height' || attr === 'x' || attr === 'y') {\n                        value = parseFloat(attrs);\n                    }\n                    else {\n                        value = attrs;\n                    }\n                    idx = Ext.Array.indexOf(spriteArr, sprite);\n                    if (idx == -1) {\n                        spriteArr.push([sprite, {}]);\n                        idx = spriteArr.length - 1;\n                    }\n                    spriteArr[idx][1][attr] = value;\n                }\n            }\n        }\n        ln = spriteArr.length;\n        for (i = 0; i < ln; i++) {\n            spriteArr[i][0].setAttributes(spriteArr[i][1]);\n        }\n        this.target.redraw();\n    }\n});\n\n/**\n * @class Ext.fx.target.CompositeSprite\n\nThis class represents a animation target for a {@link Ext.draw.CompositeSprite}. It allows\neach {@link Ext.draw.Sprite} in the group to be animated as a whole. In general this class will not be\ncreated directly, the {@link Ext.draw.CompositeSprite} will be passed to the animation and\nand the appropriate target will be created.\n\n * @markdown\n */\n\nExt.define('Ext.fx.target.CompositeSprite', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.fx.target.Sprite',\n\n    /* End Definitions */\n\n    getAttr: function(attr, val) {\n        var out     = [],\n            sprites = [].concat(this.target.items),\n            length  = sprites.length,\n            i,\n            sprite;\n\n        for (i = 0; i < length; i++) {\n            sprite = sprites[i];\n            out.push([sprite, val != undefined ? val : this.getFromPrim(sprite, attr)]);\n        }\n\n        return out;\n    }\n});\n\n/**\n * @class Ext.fx.target.Component\n * \n * This class represents a animation target for a {@link Ext.Component}. In general this class will not be\n * created directly, the {@link Ext.Component} will be passed to the animation and\n * and the appropriate target will be created.\n */\nExt.define('Ext.fx.target.Component', {\n\n    /* Begin Definitions */\n   \n    extend: 'Ext.fx.target.Target',\n    \n    /* End Definitions */\n\n    type: 'component',\n\n    // Methods to call to retrieve unspecified \"from\" values from a target Component\n    getPropMethod: {\n        top: function() {\n            return this.getPosition(true)[1];\n        },\n        left: function() {\n            return this.getPosition(true)[0];\n        },\n        x: function() {\n            return this.getPosition()[0];\n        },\n        y: function() {\n            return this.getPosition()[1];\n        },\n        height: function() {\n            return this.getHeight();\n        },\n        width: function() {\n            return this.getWidth();\n        },\n        opacity: function() {\n            return this.el.getStyle('opacity');\n        }\n    },\n\n    compMethod: {\n        top: 'setPosition',\n        left: 'setPosition',\n        x: 'setPagePosition',\n        y: 'setPagePosition',\n        height: 'setSize',\n        width: 'setSize',\n        opacity: 'setOpacity'\n    },\n\n    // Read the named attribute from the target Component. Use the defined getter for the attribute\n    getAttr: function(attr, val) {\n        return [[this.target, val !== undefined ? val : this.getPropMethod[attr].call(this.target)]];\n    },\n\n    setAttr: function(targetData, isFirstFrame, isLastFrame) {\n        var me = this,\n            target = me.target,\n            ln = targetData.length,\n            attrs, attr, o, i, j, meth, targets, left, top, w, h;\n        for (i = 0; i < ln; i++) {\n            attrs = targetData[i].attrs;\n            for (attr in attrs) {\n                targets = attrs[attr].length;\n                meth = {\n                    setPosition: {},\n                    setPagePosition: {},\n                    setSize: {},\n                    setOpacity: {}\n                };\n                for (j = 0; j < targets; j++) {\n                    o = attrs[attr][j];\n                    // We REALLY want a single function call, so push these down to merge them: eg\n                    // meth.setPagePosition.target = <targetComponent>\n                    // meth.setPagePosition['x'] = 100\n                    // meth.setPagePosition['y'] = 100\n                    meth[me.compMethod[attr]].target = o[0];\n                    meth[me.compMethod[attr]][attr] = o[1];\n                }\n                if (meth.setPosition.target) {\n                    o = meth.setPosition;\n                    left = (o.left === undefined) ? undefined : parseFloat(o.left);\n                    top = (o.top === undefined) ? undefined : parseFloat(o.top);\n                    o.target.setPosition(left, top);\n                }\n                if (meth.setPagePosition.target) {\n                    o = meth.setPagePosition;\n                    o.target.setPagePosition(o.x, o.y);\n                }\n                if (meth.setSize.target) {\n                    o = meth.setSize;\n                    // Dimensions not being animated MUST NOT be autosized. They must remain at current value.\n                    w = (o.width === undefined) ? o.target.getWidth() : parseFloat(o.width);\n                    h = (o.height === undefined) ? o.target.getHeight() : parseFloat(o.height);\n\n                    // Only set the size of the Component on the last frame, or if the animation was\n                    // configured with dynamic: true.\n                    // In other cases, we just set the target element size.\n                    // This will result in either clipping if animating a reduction in size, or the revealing of\n                    // the inner elements of the Component if animating an increase in size.\n                    // Component's animate function initially resizes to the larger size before resizing the\n                    // outer element to clip the contents.\n                    if (isLastFrame || me.dynamic) {\n                        o.target.setSize(w, h);\n                    } else {\n                        o.target.el.setSize(w, h);\n                    }\n                }\n                if (meth.setOpacity.target) {\n                    o = meth.setOpacity;\n                    o.target.el.setStyle('opacity', o.opacity);\n                }\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.fx.Queue\n * Animation Queue mixin to handle chaining and queueing by target.\n * @private\n */\n\nExt.define('Ext.fx.Queue', {\n\n    requires: ['Ext.util.HashMap'],\n\n    constructor: function() {\n        this.targets = new Ext.util.HashMap();\n        this.fxQueue = {};\n    },\n\n    // @private\n    getFxDefaults: function(targetId) {\n        var target = this.targets.get(targetId);\n        if (target) {\n            return target.fxDefaults;\n        }\n        return {};\n    },\n\n    // @private\n    setFxDefaults: function(targetId, obj) {\n        var target = this.targets.get(targetId);\n        if (target) {\n            target.fxDefaults = Ext.apply(target.fxDefaults || {}, obj);\n        }\n    },\n\n    // @private\n    stopAnimation: function(targetId) {\n        var me = this,\n            queue = me.getFxQueue(targetId),\n            ln = queue.length;\n        while (ln) {\n            queue[ln - 1].end();\n            ln--;\n        }\n    },\n\n    /**\n     * @private\n     * Returns current animation object if the element has any effects actively running or queued, else returns false.\n     */\n    getActiveAnimation: function(targetId) {\n        var queue = this.getFxQueue(targetId);\n        return (queue && !!queue.length) ? queue[0] : false;\n    },\n\n    // @private\n    hasFxBlock: function(targetId) {\n        var queue = this.getFxQueue(targetId);\n        return queue && queue[0] && queue[0].block;\n    },\n\n    // @private get fx queue for passed target, create if needed.\n    getFxQueue: function(targetId) {\n        if (!targetId) {\n            return false;\n        }\n        var me = this,\n            queue = me.fxQueue[targetId],\n            target = me.targets.get(targetId);\n\n        if (!target) {\n            return false;\n        }\n\n        if (!queue) {\n            me.fxQueue[targetId] = [];\n            // GarbageCollector will need to clean up Elements since they aren't currently observable\n            if (target.type != 'element') {\n                target.target.on('destroy', function() {\n                    me.fxQueue[targetId] = [];\n                });\n            }\n        }\n        return me.fxQueue[targetId];\n    },\n\n    // @private\n    queueFx: function(anim) {\n        var me = this,\n            target = anim.target,\n            queue, ln;\n\n        if (!target) {\n            return;\n        }\n\n        queue = me.getFxQueue(target.getId());\n        ln = queue.length;\n\n        if (ln) {\n            if (anim.concurrent) {\n                anim.paused = false;\n            }\n            else {\n                queue[ln - 1].on('afteranimate', function() {\n                    anim.paused = false;\n                });\n            }\n        }\n        else {\n            anim.paused = false;\n        }\n        anim.on('afteranimate', function() {\n            Ext.Array.remove(queue, anim);\n            if (anim.remove) {\n                if (target.type == 'element') {\n                    var el = Ext.get(target.id);\n                    if (el) {\n                        el.remove();\n                    }\n                }\n            }\n        }, this);\n        queue.push(anim);\n    }\n});\n\n/**\n * @class Ext.fx.Manager\n * Animation Manager which keeps track of all current animations and manages them on a frame by frame basis.\n * @private\n * @singleton\n */\n\nExt.define('Ext.fx.Manager', {\n\n    /* Begin Definitions */\n\n    singleton: true,\n\n    requires: ['Ext.util.MixedCollection',\n               'Ext.fx.target.Element',\n               'Ext.fx.target.ElementCSS',\n               'Ext.fx.target.CompositeElement',\n               'Ext.fx.target.CompositeElementCSS',\n               'Ext.fx.target.Sprite',\n               'Ext.fx.target.CompositeSprite',\n               'Ext.fx.target.Component'],\n\n    mixins: {\n        queue: 'Ext.fx.Queue'\n    },\n\n    /* End Definitions */\n\n    constructor: function() {\n        this.items = new Ext.util.MixedCollection();\n        this.mixins.queue.constructor.call(this);\n\n        // this.requestAnimFrame = (function() {\n        //     var raf = window.requestAnimationFrame ||\n        //               window.webkitRequestAnimationFrame ||\n        //               window.mozRequestAnimationFrame ||\n        //               window.oRequestAnimationFrame ||\n        //               window.msRequestAnimationFrame;\n        //     if (raf) {\n        //         return function(callback, element) {\n        //             raf(callback);\n        //         };\n        //     }\n        //     else {\n        //         return function(callback, element) {\n        //             window.setTimeout(callback, Ext.fx.Manager.interval);\n        //         };\n        //     }\n        // })();\n    },\n\n    /**\n     * @cfg {Number} interval Default interval in miliseconds to calculate each frame.  Defaults to 16ms (~60fps)\n     */\n    interval: 16,\n\n    /**\n     * @cfg {Boolean} forceJS Force the use of JavaScript-based animation instead of CSS3 animation, even when CSS3\n     * animation is supported by the browser. This defaults to true currently, as CSS3 animation support is still\n     * considered experimental at this time, and if used should be thouroughly tested across all targeted browsers.\n     * @protected\n     */\n    forceJS: true,\n\n    // @private Target factory\n    createTarget: function(target) {\n        var me = this,\n            useCSS3 = !me.forceJS && Ext.supports.Transitions,\n            targetObj;\n\n        me.useCSS3 = useCSS3;\n\n        if (target) {\n            // dom element, string or fly\n            if (target.tagName || Ext.isString(target) || target.isFly) {\n                target = Ext.get(target);\n                targetObj = new Ext.fx.target['Element' + (useCSS3 ? 'CSS' : '')](target);\n            }\n            // Element\n            else if (target.dom) {\n                targetObj = new Ext.fx.target['Element' + (useCSS3 ? 'CSS' : '')](target);\n            }\n            // Element Composite\n            else if (target.isComposite) {\n                targetObj = new Ext.fx.target['CompositeElement' + (useCSS3 ? 'CSS' : '')](target);\n            }\n            // Draw Sprite\n            else if (target.isSprite) {\n                targetObj = new Ext.fx.target.Sprite(target);\n            }\n            // Draw Sprite Composite\n            else if (target.isCompositeSprite) {\n                targetObj = new Ext.fx.target.CompositeSprite(target);\n            }\n            // Component\n            else if (target.isComponent) {\n                targetObj = new Ext.fx.target.Component(target);\n            }\n            else if (target.isAnimTarget) {\n                return target;\n            }\n            else {\n                return null;\n            }\n            me.targets.add(targetObj);\n            return targetObj;\n        }\n        else {\n            return null;\n        }\n    },\n\n    /**\n     * Add an Anim to the manager. This is done automatically when an Anim instance is created.\n     * @param {Ext.fx.Anim} anim\n     */\n    addAnim: function(anim) {\n        var items = this.items,\n            task = this.task;\n\n        // Make sure we use the anim's id, not the anim target's id here. The anim id will be unique on\n        // each call to addAnim. `anim.target` is the DOM element being targeted, and since multiple animations\n        // can target a single DOM node concurrently, the target id cannot be assumned to be unique.\n        items.add(anim.id, anim);\n        //Ext.log('+     added anim ', anim.id, ', target: ', anim.target.getId(), ', duration: ', anim.duration);\n\n        // Start the timer if not already running\n        if (!task && items.length) {\n            task = this.task = {\n                run: this.runner,\n                interval: this.interval,\n                scope: this\n            };\n            //Ext.log('--->> Starting task');\n            Ext.TaskManager.start(task);\n        }\n    },\n\n    /**\n     * Remove an Anim from the manager. This is done automatically when an Anim ends.\n     * @param {Ext.fx.Anim} anim\n     */\n    removeAnim: function(anim) {\n        var me = this,\n            items = me.items,\n            task = me.task;\n                \n        items.removeAtKey(anim.id);\n        //Ext.log('    X removed anim ', anim.id, ', target: ', anim.target.getId(), ', frames: ', anim.frameCount, ', item count: ', items.length);\n        \n        // Stop the timer if there are no more managed Anims\n        if (task && !items.length) {\n            //Ext.log('[]--- Stopping task');\n            Ext.TaskManager.stop(task);\n            delete me.task;\n        }\n    },\n\n    /**\n     * @private\n     * Runner function being called each frame\n     */\n    runner: function() {\n        var me = this,\n            items = me.items.getRange(),\n            i = 0,\n            len = items.length,\n            anim;\n\n        //Ext.log('      executing anim runner task with ', len, ' items');\n        me.targetArr = {};\n\n        // Single timestamp for all animations this interval\n        me.timestamp = new Date();\n        \n        // Loop to start any new animations first before looping to\n        // execute running animations (which will also include all animations\n        // started in this loop). This is a subtle difference from simply\n        // iterating in one loop and starting then running each animation,\n        // but separating the loops is necessary to ensure that all new animations\n        // actually kick off prior to existing ones regardless of array order.\n        // Otherwise in edge cases when there is excess latency in overall\n        // performance, allowing existing animations to run before new ones can\n        // lead to dropped frames and subtle race conditions when they are\n        // interdependent, which is often the case with certain Element fx.\n        for (; i < len; i++) {\n            anim = items[i];\n            \n            if (anim.isReady()) {\n                //Ext.log('      starting anim ', anim.id, ', target: ', anim.target.id);\n                me.startAnim(anim);\n            }\n        }\n        \n        for (i = 0; i < len; i++) {\n            anim = items[i];\n            \n            if (anim.isRunning()) {\n                //Ext.log('      running anim ', anim.target.id);\n                me.runAnim(anim);\n            } else if (!me.useCSS3) {\n                // When using CSS3 transitions the animations get paused since they are not\n                // needed once the transition is handed over to the browser, so we can\n                // ignore this case. However if we are doing JS animations and something is\n                // paused here it's possibly unintentional.\n                //Ext.log(' (i)  anim ', anim.id, ' is active but not running...');\n            }\n        }\n\n        // Apply all the pending changes to their targets\n        me.applyPendingAttrs();\n    },\n\n    /**\n     * @private\n     * Start the individual animation (initialization)\n     */\n    startAnim: function(anim) {\n        anim.start(this.timestamp);\n    },\n\n    /**\n     * @private\n     * Run the individual animation for this frame\n     */\n    runAnim: function(anim) {\n        if (!anim) {\n            return;\n        }\n        var me = this,\n            targetId = anim.target.getId(),\n            useCSS3 = me.useCSS3 && anim.target.type == 'element',\n            elapsedTime = me.timestamp - anim.startTime,\n            lastFrame = (elapsedTime >= anim.duration),\n            target, o;\n\n        target = this.collectTargetData(anim, elapsedTime, useCSS3, lastFrame);\n        \n        // For CSS3 animation, we need to immediately set the first frame's attributes without any transition\n        // to get a good initial state, then add the transition properties and set the final attributes.\n        if (useCSS3) {\n            //Ext.log(' (i)  using CSS3 transitions');\n            \n            // Flush the collected attributes, without transition\n            anim.target.setAttr(target.anims[anim.id].attributes, true);\n\n            // Add the end frame data\n            me.collectTargetData(anim, anim.duration, useCSS3, lastFrame);\n\n            // Pause the animation so runAnim doesn't keep getting called\n            anim.paused = true;\n\n            target = anim.target.target;\n            // We only want to attach an event on the last element in a composite\n            if (anim.target.isComposite) {\n                target = anim.target.target.last();\n            }\n\n            // Listen for the transitionend event\n            o = {};\n            o[Ext.supports.CSS3TransitionEnd] = anim.lastFrame;\n            o.scope = anim;\n            o.single = true;\n            target.on(o);\n        }\n    },\n\n    /**\n     * @private\n     * Collect target attributes for the given Anim object at the given timestamp\n     * @param {Ext.fx.Anim} anim The Anim instance\n     * @param {Number} timestamp Time after the anim's start time\n     * @param {Boolean} [useCSS3=false] True if using CSS3-based animation, else false\n     * @param {Boolean} [isLastFrame=false] True if this is the last frame of animation to be run, else false\n     * @return {Object} The animation target wrapper object containing the passed animation along with the\n     * new attributes to set on the target's element in the next animation frame.\n     */\n    collectTargetData: function(anim, elapsedTime, useCSS3, isLastFrame) {\n        var targetId = anim.target.getId(),\n            target = this.targetArr[targetId];\n        \n        if (!target) {\n            // Create a thin wrapper around the target so that we can create a link between the\n            // target element and its associated animations. This is important later when applying\n            // attributes to the target so that each animation can be independently run with its own\n            // duration and stopped at any point without affecting other animations for the same target.\n            target = this.targetArr[targetId] = {\n                id: targetId,\n                el: anim.target,\n                anims: {}\n            };\n        }\n\n        // This is a wrapper for the animation so that we can also save state along with it,\n        // including the current elapsed time and lastFrame status. Even though this method only\n        // adds a single anim object per call, each target element could have multiple animations\n        // associated with it, which is why the anim is added to the target's `anims` hash by id.\n        target.anims[anim.id] = {\n            id: anim.id,\n            anim: anim,\n            elapsed: elapsedTime,\n            isLastFrame: isLastFrame,\n            // This is the object that gets applied to the target element below in applyPendingAttrs():\n            attributes: [{\n                duration: anim.duration,\n                easing: (useCSS3 && anim.reverse) ? anim.easingFn.reverse().toCSS3() : anim.easing,\n                // This is where the magic happens. The anim calculates what its new attributes should\n                // be based on the current frame and returns those as a hash of values.\n                attrs: anim.runAnim(elapsedTime)\n            }]\n        };\n        \n        return target;\n    },\n    \n    /**\n     * @private\n     * Apply all pending attribute changes to their targets\n     */\n    applyPendingAttrs: function() {\n        var targetArr = this.targetArr,\n            target, targetId, animWrap, anim, animId;\n        \n        // Loop through each target\n        for (targetId in targetArr) {\n            if (targetArr.hasOwnProperty(targetId)) {\n                target = targetArr[targetId];\n                \n                // Each target could have multiple associated animations, so iterate those\n                for (animId in target.anims) {\n                    if (target.anims.hasOwnProperty(animId)) {\n                        animWrap = target.anims[animId];\n                        anim = animWrap.anim;\n                        \n                        // If the animation has valid attributes, set them on the target\n                        if (animWrap.attributes && anim.isRunning()) {\n                            //Ext.log('  >   applying attributes for anim ', animWrap.id, ', target: ', target.id, ', elapsed: ', animWrap.elapsed);\n                            target.el.setAttr(animWrap.attributes, false, animWrap.isLastFrame);\n                            \n                            // If this particular anim is at the last frame end it\n                            if (animWrap.isLastFrame) {\n                                //Ext.log('      running last frame for ', animWrap.id, ', target: ', targetId);\n                                anim.lastFrame();\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.fx.Animator\n *\n * This class is used to run keyframe based animations, which follows the CSS3 based animation structure.\n * Keyframe animations differ from typical from/to animations in that they offer the ability to specify values\n * at various points throughout the animation.\n *\n * ## Using Keyframes\n *\n * The {@link #keyframes} option is the most important part of specifying an animation when using this\n * class. A key frame is a point in a particular animation. We represent this as a percentage of the\n * total animation duration. At each key frame, we can specify the target values at that time. Note that\n * you *must* specify the values at 0% and 100%, the start and ending values. There is also a {@link #keyframe}\n * event that fires after each key frame is reached.\n *\n * ## Example\n *\n * In the example below, we modify the values of the element at each fifth throughout the animation.\n *\n *     @example\n *     Ext.create('Ext.fx.Animator', {\n *         target: Ext.getBody().createChild({\n *             style: {\n *                 width: '100px',\n *                 height: '100px',\n *                 'background-color': 'red'\n *             }\n *         }),\n *         duration: 10000, // 10 seconds\n *         keyframes: {\n *             0: {\n *                 opacity: 1,\n *                 backgroundColor: 'FF0000'\n *             },\n *             20: {\n *                 x: 30,\n *                 opacity: 0.5\n *             },\n *             40: {\n *                 x: 130,\n *                 backgroundColor: '0000FF'\n *             },\n *             60: {\n *                 y: 80,\n *                 opacity: 0.3\n *             },\n *             80: {\n *                 width: 200,\n *                 y: 200\n *             },\n *             100: {\n *                 opacity: 1,\n *                 backgroundColor: '00FF00'\n *             }\n *         }\n *     });\n */\nExt.define('Ext.fx.Animator', {\n\n    /* Begin Definitions */\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    requires: ['Ext.fx.Manager'],\n\n    /* End Definitions */\n\n    /**\n     * @property {Boolean} isAnimator\n     * `true` in this class to identify an object as an instantiated Animator, or subclass thereof.\n     */\n    isAnimator: true,\n\n    /**\n     * @cfg {Number} duration\n     * Time in milliseconds for the animation to last. Defaults to 250.\n     */\n    duration: 250,\n\n    /**\n     * @cfg {Number} delay\n     * Time to delay before starting the animation. Defaults to 0.\n     */\n    delay: 0,\n\n    /* private used to track a delayed starting time */\n    delayStart: 0,\n\n    /**\n     * @cfg {Boolean} dynamic\n     * Currently only for Component Animation: Only set a component's outer element size bypassing layouts.  Set to true to do full layouts for every frame of the animation.  Defaults to false.\n     */\n    dynamic: false,\n\n    /**\n     * @cfg {String} easing\n     *\n     * This describes how the intermediate values used during a transition will be calculated. It allows for a transition to change\n     * speed over its duration.\n     *\n     *  - backIn\n     *  - backOut\n     *  - bounceIn\n     *  - bounceOut\n     *  - ease\n     *  - easeIn\n     *  - easeOut\n     *  - easeInOut\n     *  - elasticIn\n     *  - elasticOut\n     *  - cubic-bezier(x1, y1, x2, y2)\n     *\n     * Note that cubic-bezier will create a custom easing curve following the CSS3 [transition-timing-function][0]\n     * specification.  The four values specify points P1 and P2 of the curve as (x1, y1, x2, y2). All values must\n     * be in the range [0, 1] or the definition is invalid.\n     *\n     * [0]: http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag\n     */\n    easing: 'ease',\n\n    /**\n     * Flag to determine if the animation has started\n     * @property running\n     * @type Boolean\n     */\n    running: false,\n\n    /**\n     * Flag to determine if the animation is paused. Only set this to true if you need to\n     * keep the Anim instance around to be unpaused later; otherwise call {@link #end}.\n     * @property paused\n     * @type Boolean\n     */\n    paused: false,\n\n    /**\n     * @private\n     */\n    damper: 1,\n\n    /**\n     * @cfg {Number} iterations\n     * Number of times to execute the animation. Defaults to 1.\n     */\n    iterations: 1,\n\n    /**\n     * Current iteration the animation is running.\n     * @property currentIteration\n     * @type Number\n     */\n    currentIteration: 0,\n\n    /**\n     * Current keyframe step of the animation.\n     * @property keyframeStep\n     * @type Number\n     */\n    keyframeStep: 0,\n\n    /**\n     * @private\n     */\n    animKeyFramesRE: /^(from|to|\\d+%?)$/,\n\n    /**\n     * @cfg {Ext.fx.target.Target} target\n     * The Ext.fx.target to apply the animation to.  If not specified during initialization, this can be passed to the applyAnimator\n     * method to apply the same animation to many targets.\n     */\n\n     /**\n      * @cfg {Object} keyframes\n      * Animation keyframes follow the CSS3 Animation configuration pattern. 'from' is always considered '0%' and 'to'\n      * is considered '100%'.<b>Every keyframe declaration must have a keyframe rule for 0% and 100%, possibly defined using\n      * \"from\" or \"to\"</b>.  A keyframe declaration without these keyframe selectors is invalid and will not be available for\n      * animation.  The keyframe declaration for a keyframe rule consists of properties and values. Properties that are unable to\n      * be animated are ignored in these rules, with the exception of 'easing' which can be changed at each keyframe. For example:\n <pre><code>\nkeyframes : {\n    '0%': {\n        left: 100\n    },\n    '40%': {\n        left: 150\n    },\n    '60%': {\n        left: 75\n    },\n    '100%': {\n        left: 100\n    }\n}\n </code></pre>\n      */\n    constructor: function(config) {\n        var me = this;\n        config = Ext.apply(me, config || {});\n        me.config = config;\n        me.id = Ext.id(null, 'ext-animator-');\n        me.addEvents(\n            /**\n             * @event beforeanimate\n             * Fires before the animation starts. A handler can return false to cancel the animation.\n             * @param {Ext.fx.Animator} this\n             */\n            'beforeanimate',\n            /**\n              * @event keyframe\n              * Fires at each keyframe.\n              * @param {Ext.fx.Animator} this\n              * @param {Number} keyframe step number\n              */\n            'keyframe',\n            /**\n             * @event afteranimate\n             * Fires when the animation is complete.\n             * @param {Ext.fx.Animator} this\n             * @param {Date} startTime\n             */\n            'afteranimate'\n        );\n        me.mixins.observable.constructor.call(me, config);\n        me.timeline = [];\n        me.createTimeline(me.keyframes);\n        if (me.target) {\n            me.applyAnimator(me.target);\n            Ext.fx.Manager.addAnim(me);\n        }\n    },\n\n    /**\n     * @private\n     */\n    sorter: function (a, b) {\n        return a.pct - b.pct;\n    },\n\n    /**\n     * @private\n     * Takes the given keyframe configuration object and converts it into an ordered array with the passed attributes per keyframe\n     * or applying the 'to' configuration to all keyframes.  Also calculates the proper animation duration per keyframe.\n     */\n    createTimeline: function(keyframes) {\n        var me = this,\n            attrs = [],\n            to = me.to || {},\n            duration = me.duration,\n            prevMs, ms, i, ln, pct, anim, nextAnim, attr;\n\n        for (pct in keyframes) {\n            if (keyframes.hasOwnProperty(pct) && me.animKeyFramesRE.test(pct)) {\n                attr = {attrs: Ext.apply(keyframes[pct], to)};\n                // CSS3 spec allow for from/to to be specified.\n                if (pct == \"from\") {\n                    pct = 0;\n                }\n                else if (pct == \"to\") {\n                    pct = 100;\n                }\n                // convert % values into integers\n                attr.pct = parseInt(pct, 10);\n                attrs.push(attr);\n            }\n        }\n        // Sort by pct property\n        Ext.Array.sort(attrs, me.sorter);\n        // Only an end\n        //if (attrs[0].pct) {\n        //    attrs.unshift({pct: 0, attrs: element.attrs});\n        //}\n\n        ln = attrs.length;\n        for (i = 0; i < ln; i++) {\n            prevMs = (attrs[i - 1]) ? duration * (attrs[i - 1].pct / 100) : 0;\n            ms = duration * (attrs[i].pct / 100);\n            me.timeline.push({\n                duration: ms - prevMs,\n                attrs: attrs[i].attrs\n            });\n        }\n    },\n\n    /**\n     * Applies animation to the Ext.fx.target\n     * @private\n     * @param target\n     * @type String/Object\n     */\n    applyAnimator: function(target) {\n        var me = this,\n            anims = [],\n            timeline = me.timeline,\n            reverse = me.reverse,\n            ln = timeline.length,\n            anim, easing, damper, initial, attrs, lastAttrs, i;\n\n        if (me.fireEvent('beforeanimate', me) !== false) {\n            for (i = 0; i < ln; i++) {\n                anim = timeline[i];\n                attrs = anim.attrs;\n                easing = attrs.easing || me.easing;\n                damper = attrs.damper || me.damper;\n                delete attrs.easing;\n                delete attrs.damper;\n                anim = new Ext.fx.Anim({\n                    target: target,\n                    easing: easing,\n                    damper: damper,\n                    duration: anim.duration,\n                    paused: true,\n                    to: attrs\n                });\n                anims.push(anim);\n            }\n            me.animations = anims;\n            me.target = anim.target;\n            for (i = 0; i < ln - 1; i++) {\n                anim = anims[i];\n                anim.nextAnim = anims[i + 1];\n                anim.on('afteranimate', function() {\n                    this.nextAnim.paused = false;\n                });\n                anim.on('afteranimate', function() {\n                    this.fireEvent('keyframe', this, ++this.keyframeStep);\n                }, me);\n            }\n            anims[ln - 1].on('afteranimate', function() {\n                this.lastFrame();\n            }, me);\n        }\n    },\n\n    /**\n     * @private\n     * Fires beforeanimate and sets the running flag.\n     */\n    start: function(startTime) {\n        var me = this,\n            delay = me.delay,\n            delayStart = me.delayStart,\n            delayDelta;\n        if (delay) {\n            if (!delayStart) {\n                me.delayStart = startTime;\n                return;\n            }\n            else {\n                delayDelta = startTime - delayStart;\n                if (delayDelta < delay) {\n                    return;\n                }\n                else {\n                    // Compensate for frame delay;\n                    startTime = new Date(delayStart.getTime() + delay);\n                }\n            }\n        }\n        if (me.fireEvent('beforeanimate', me) !== false) {\n            me.startTime = startTime;\n            me.running = true;\n            me.animations[me.keyframeStep].paused = false;\n        }\n    },\n\n    /**\n     * @private\n     * Perform lastFrame cleanup and handle iterations\n     * @returns a hash of the new attributes.\n     */\n    lastFrame: function() {\n        var me = this,\n            iter = me.iterations,\n            iterCount = me.currentIteration;\n\n        iterCount++;\n        if (iterCount < iter) {\n            me.startTime = new Date();\n            me.currentIteration = iterCount;\n            me.keyframeStep = 0;\n            me.applyAnimator(me.target);\n            me.animations[me.keyframeStep].paused = false;\n        }\n        else {\n            me.currentIteration = 0;\n            me.end();\n        }\n    },\n\n    /**\n     * Fire afteranimate event and end the animation. Usually called automatically when the\n     * animation reaches its final frame, but can also be called manually to pre-emptively\n     * stop and destroy the running animation.\n     */\n    end: function() {\n        var me = this;\n        me.fireEvent('afteranimate', me, me.startTime, new Date() - me.startTime);\n    },\n    \n    isReady: function() {\n        return this.paused === false && this.running === false && this.iterations > 0;\n    },\n    \n    isRunning: function() {\n        // Explicitly return false, we don't want to be run continuously by the manager\n        return false;\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.fx.CubicBezier', {\n\n    /* Begin Definitions */\n\n    singleton: true,\n\n    /* End Definitions */\n\n    cubicBezierAtTime: function(t, p1x, p1y, p2x, p2y, duration) {\n        var cx = 3 * p1x,\n            bx = 3 * (p2x - p1x) - cx,\n            ax = 1 - cx - bx,\n            cy = 3 * p1y,\n            by = 3 * (p2y - p1y) - cy,\n            ay = 1 - cy - by;\n        function sampleCurveX(t) {\n            return ((ax * t + bx) * t + cx) * t;\n        }\n        function solve(x, epsilon) {\n            var t = solveCurveX(x, epsilon);\n            return ((ay * t + by) * t + cy) * t;\n        }\n        function solveCurveX(x, epsilon) {\n            var t0, t1, t2, x2, d2, i;\n            for (t2 = x, i = 0; i < 8; i++) {\n                x2 = sampleCurveX(t2) - x;\n                if (Math.abs(x2) < epsilon) {\n                    return t2;\n                }\n                d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;\n                if (Math.abs(d2) < 1e-6) {\n                    break;\n                }\n                t2 = t2 - x2 / d2;\n            }\n            t0 = 0;\n            t1 = 1;\n            t2 = x;\n            if (t2 < t0) {\n                return t0;\n            }\n            if (t2 > t1) {\n                return t1;\n            }\n            while (t0 < t1) {\n                x2 = sampleCurveX(t2);\n                if (Math.abs(x2 - x) < epsilon) {\n                    return t2;\n                }\n                if (x > x2) {\n                    t0 = t2;\n                } else {\n                    t1 = t2;\n                }\n                t2 = (t1 - t0) / 2 + t0;\n            }\n            return t2;\n        }\n        return solve(t, 1 / (200 * duration));\n    },\n\n    cubicBezier: function(x1, y1, x2, y2) {\n        var fn = function(pos) {\n            return Ext.fx.CubicBezier.cubicBezierAtTime(pos, x1, y1, x2, y2, 1);\n        };\n        fn.toCSS3 = function() {\n            return 'cubic-bezier(' + [x1, y1, x2, y2].join(',') + ')';\n        };\n        fn.reverse = function() {\n            return Ext.fx.CubicBezier.cubicBezier(1 - x2, 1 - y2, 1 - x1, 1 - y1);\n        };\n        return fn;\n    }\n});\n\n//@define Ext.fx.Easing\n/**\n * @class Ext.fx.Easing\n *\n * This class contains a series of function definitions used to modify values during an animation.\n * They describe how the intermediate values used during a transition will be calculated. It allows for a transition to change\n * speed over its duration. The following options are available: \n *\n * - linear The default easing type\n * - backIn\n * - backOut\n * - bounceIn\n * - bounceOut\n * - ease\n * - easeIn\n * - easeOut\n * - easeInOut\n * - elasticIn\n * - elasticOut\n * - cubic-bezier(x1, y1, x2, y2)\n *\n * Note that cubic-bezier will create a custom easing curve following the CSS3 [transition-timing-function][0]\n * specification.  The four values specify points P1 and P2 of the curve as (x1, y1, x2, y2). All values must\n * be in the range [0, 1] or the definition is invalid.\n *\n * [0]: http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag\n *\n * @singleton\n */\nExt.ns('Ext.fx');\n\nExt.require('Ext.fx.CubicBezier', function() {\n    var math = Math,\n        pi = math.PI,\n        pow = math.pow,\n        sin = math.sin,\n        sqrt = math.sqrt,\n        abs = math.abs,\n        backInSeed = 1.70158;\n    Ext.fx.Easing = {\n        // ease: Ext.fx.CubicBezier.cubicBezier(0.25, 0.1, 0.25, 1),\n        // linear: Ext.fx.CubicBezier.cubicBezier(0, 0, 1, 1),\n        // 'ease-in': Ext.fx.CubicBezier.cubicBezier(0.42, 0, 1, 1),\n        // 'ease-out': Ext.fx.CubicBezier.cubicBezier(0, 0.58, 1, 1),\n        // 'ease-in-out': Ext.fx.CubicBezier.cubicBezier(0.42, 0, 0.58, 1),\n        // 'easeIn': Ext.fx.CubicBezier.cubicBezier(0.42, 0, 1, 1),\n        // 'easeOut': Ext.fx.CubicBezier.cubicBezier(0, 0.58, 1, 1),\n        // 'easeInOut': Ext.fx.CubicBezier.cubicBezier(0.42, 0, 0.58, 1)\n    };\n\n    Ext.apply(Ext.fx.Easing, {\n        linear: function(n) {\n            return n;\n        },\n        ease: function(n) {\n            var q = 0.07813 - n / 2,\n                alpha = -0.25,\n                Q = sqrt(0.0066 + q * q),\n                x = Q - q,\n                X = pow(abs(x), 1/3) * (x < 0 ? -1 : 1),\n                y = -Q - q,\n                Y = pow(abs(y), 1/3) * (y < 0 ? -1 : 1),\n                t = X + Y + 0.25;\n            return pow(1 - t, 2) * 3 * t * 0.1 + (1 - t) * 3 * t * t + t * t * t;\n        },\n        easeIn: function (n) {\n            return pow(n, 1.7);\n        },\n        easeOut: function (n) {\n            return pow(n, 0.48);\n        },\n        easeInOut: function(n) {\n            var q = 0.48 - n / 1.04,\n                Q = sqrt(0.1734 + q * q),\n                x = Q - q,\n                X = pow(abs(x), 1/3) * (x < 0 ? -1 : 1),\n                y = -Q - q,\n                Y = pow(abs(y), 1/3) * (y < 0 ? -1 : 1),\n                t = X + Y + 0.5;\n            return (1 - t) * 3 * t * t + t * t * t;\n        },\n        backIn: function (n) {\n            return n * n * ((backInSeed + 1) * n - backInSeed);\n        },\n        backOut: function (n) {\n            n = n - 1;\n            return n * n * ((backInSeed + 1) * n + backInSeed) + 1;\n        },\n        elasticIn: function (n) {\n            if (n === 0 || n === 1) {\n                return n;\n            }\n            var p = 0.3,\n                s = p / 4;\n            return pow(2, -10 * n) * sin((n - s) * (2 * pi) / p) + 1;\n        },\n        elasticOut: function (n) {\n            return 1 - Ext.fx.Easing.elasticIn(1 - n);\n        },\n        bounceIn: function (n) {\n            return 1 - Ext.fx.Easing.bounceOut(1 - n);\n        },\n        bounceOut: function (n) {\n            var s = 7.5625,\n                p = 2.75,\n                l;\n            if (n < (1 / p)) {\n                l = s * n * n;\n            } else {\n                if (n < (2 / p)) {\n                    n -= (1.5 / p);\n                    l = s * n * n + 0.75;\n                } else {\n                    if (n < (2.5 / p)) {\n                        n -= (2.25 / p);\n                        l = s * n * n + 0.9375;\n                    } else {\n                        n -= (2.625 / p);\n                        l = s * n * n + 0.984375;\n                    }\n                }\n            }\n            return l;\n        }\n    });\n    Ext.apply(Ext.fx.Easing, {\n        'back-in': Ext.fx.Easing.backIn,\n        'back-out': Ext.fx.Easing.backOut,\n        'ease-in': Ext.fx.Easing.easeIn,\n        'ease-out': Ext.fx.Easing.easeOut,\n        'elastic-in': Ext.fx.Easing.elasticIn,\n        'elastic-out': Ext.fx.Easing.elasticIn,\n        'bounce-in': Ext.fx.Easing.bounceIn,\n        'bounce-out': Ext.fx.Easing.bounceOut,\n        'ease-in-out': Ext.fx.Easing.easeInOut\n    });\n});\n\n/**\n * Represents an RGB color and provides helper functions get\n * color components in HSL color space.\n */\nExt.define('Ext.draw.Color', {\n\n    /* Begin Definitions */\n\n    /* End Definitions */\n\n    colorToHexRe: /(.*?)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)/,\n    rgbRe: /\\s*rgb\\s*\\(\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*\\)\\s*/,\n    hexRe: /\\s*#([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)\\s*/,\n\n    /**\n     * @cfg {Number} lightnessFactor\n     *\n     * The default factor to compute the lighter or darker color. Defaults to 0.2.\n     */\n    lightnessFactor: 0.2,\n\n    /**\n     * Creates new Color.\n     * @param {Number} red Red component (0..255)\n     * @param {Number} green Green component (0..255)\n     * @param {Number} blue Blue component (0..255)\n     */\n    constructor : function(red, green, blue) {\n        var me = this,\n            clamp = Ext.Number.constrain;\n        me.r = clamp(red, 0, 255);\n        me.g = clamp(green, 0, 255);\n        me.b = clamp(blue, 0, 255);\n    },\n\n    /**\n     * Get the red component of the color, in the range 0..255.\n     * @return {Number}\n     */\n    getRed: function() {\n        return this.r;\n    },\n\n    /**\n     * Get the green component of the color, in the range 0..255.\n     * @return {Number}\n     */\n    getGreen: function() {\n        return this.g;\n    },\n\n    /**\n     * Get the blue component of the color, in the range 0..255.\n     * @return {Number}\n     */\n    getBlue: function() {\n        return this.b;\n    },\n\n    /**\n     * Get the RGB values.\n     * @return {Number[]}\n     */\n    getRGB: function() {\n        var me = this;\n        return [me.r, me.g, me.b];\n    },\n\n    /**\n     * Get the equivalent HSL components of the color.\n     * @return {Number[]}\n     */\n    getHSL: function() {\n        var me = this,\n            r = me.r / 255,\n            g = me.g / 255,\n            b = me.b / 255,\n            max = Math.max(r, g, b),\n            min = Math.min(r, g, b),\n            delta = max - min,\n            h,\n            s = 0,\n            l = 0.5 * (max + min);\n\n        // min==max means achromatic (hue is undefined)\n        if (min != max) {\n            s = (l < 0.5) ? delta / (max + min) : delta / (2 - max - min);\n            if (r == max) {\n                h = 60 * (g - b) / delta;\n            } else if (g == max) {\n                h = 120 + 60 * (b - r) / delta;\n            } else {\n                h = 240 + 60 * (r - g) / delta;\n            }\n            if (h < 0) {\n                h += 360;\n            }\n            if (h >= 360) {\n                h -= 360;\n            }\n        }\n        return [h, s, l];\n    },\n\n    /**\n     * Return a new color that is lighter than this color.\n     * @param {Number} factor Lighter factor (0..1), default to 0.2\n     * @return Ext.draw.Color\n     */\n    getLighter: function(factor) {\n        var hsl = this.getHSL();\n        factor = factor || this.lightnessFactor;\n        hsl[2] = Ext.Number.constrain(hsl[2] + factor, 0, 1);\n        return this.fromHSL(hsl[0], hsl[1], hsl[2]);\n    },\n\n    /**\n     * Return a new color that is darker than this color.\n     * @param {Number} factor Darker factor (0..1), default to 0.2\n     * @return Ext.draw.Color\n     */\n    getDarker: function(factor) {\n        factor = factor || this.lightnessFactor;\n        return this.getLighter(-factor);\n    },\n\n    /**\n     * Return the color in the hex format, i.e. '#rrggbb'.\n     * @return {String}\n     */\n    toString: function() {\n        var me = this,\n            round = Math.round,\n            r = round(me.r).toString(16),\n            g = round(me.g).toString(16),\n            b = round(me.b).toString(16);\n        r = (r.length == 1) ? '0' + r : r;\n        g = (g.length == 1) ? '0' + g : g;\n        b = (b.length == 1) ? '0' + b : b;\n        return ['#', r, g, b].join('');\n    },\n\n    /**\n     * Convert a color to hexadecimal format.\n     *\n     * **Note:** This method is both static and instance.\n     *\n     * @param {String/String[]} color The color value (i.e 'rgb(255, 255, 255)', 'color: #ffffff').\n     * Can also be an Array, in this case the function handles the first member.\n     * @returns {String} The color in hexadecimal format.\n     * @static\n     */\n    toHex: function(color) {\n        if (Ext.isArray(color)) {\n            color = color[0];\n        }\n        if (!Ext.isString(color)) {\n            return '';\n        }\n        if (color.substr(0, 1) === '#') {\n            return color;\n        }\n        var digits = this.colorToHexRe.exec(color),\n            red,\n            green,\n            blue,\n            rgb;\n\n        if (Ext.isArray(digits)) {\n            red = parseInt(digits[2], 10);\n            green = parseInt(digits[3], 10);\n            blue = parseInt(digits[4], 10);\n            rgb = blue | (green << 8) | (red << 16);\n            return digits[1] + '#' + (\"000000\" + rgb.toString(16)).slice(-6);\n        }\n        else {\n            return color;\n        }\n    },\n\n    /**\n     * Parse the string and create a new color.\n     *\n     * Supported formats: '#rrggbb', '#rgb', and 'rgb(r,g,b)'.\n     *\n     * If the string is not recognized, an undefined will be returned instead.\n     *\n     * **Note:** This method is both static and instance.\n     *\n     * @param {String} str Color in string.\n     * @returns Ext.draw.Color\n     * @static\n     */\n    fromString: function(str) {\n        var values, r, g, b,\n            parse = parseInt;\n\n        if ((str.length == 4 || str.length == 7) && str.substr(0, 1) === '#') {\n            values = str.match(this.hexRe);\n            if (values) {\n                r = parse(values[1], 16) >> 0;\n                g = parse(values[2], 16) >> 0;\n                b = parse(values[3], 16) >> 0;\n                if (str.length == 4) {\n                    r += (r * 16);\n                    g += (g * 16);\n                    b += (b * 16);\n                }\n            }\n        }\n        else {\n            values = str.match(this.rgbRe);\n            if (values) {\n                r = values[1];\n                g = values[2];\n                b = values[3];\n            }\n        }\n\n        return (typeof r == 'undefined') ? undefined : new Ext.draw.Color(r, g, b);\n    },\n\n    /**\n     * Returns the gray value (0 to 255) of the color.\n     *\n     * The gray value is calculated using the formula r*0.3 + g*0.59 + b*0.11.\n     *\n     * @returns {Number}\n     */\n    getGrayscale: function() {\n        // http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale\n        return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;\n    },\n\n    /**\n     * Create a new color based on the specified HSL values.\n     *\n     * **Note:** This method is both static and instance.\n     *\n     * @param {Number} h Hue component (0..359)\n     * @param {Number} s Saturation component (0..1)\n     * @param {Number} l Lightness component (0..1)\n     * @returns Ext.draw.Color\n     * @static\n     */\n    fromHSL: function(h, s, l) {\n        var C, X, m, i, rgb = [],\n            abs = Math.abs,\n            floor = Math.floor;\n\n        if (s == 0 || h == null) {\n            // achromatic\n            rgb = [l, l, l];\n        }\n        else {\n            // http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL\n            // C is the chroma\n            // X is the second largest component\n            // m is the lightness adjustment\n            h /= 60;\n            C = s * (1 - abs(2 * l - 1));\n            X = C * (1 - abs(h - 2 * floor(h / 2) - 1));\n            m = l - C / 2;\n            switch (floor(h)) {\n                case 0:\n                    rgb = [C, X, 0];\n                    break;\n                case 1:\n                    rgb = [X, C, 0];\n                    break;\n                case 2:\n                    rgb = [0, C, X];\n                    break;\n                case 3:\n                    rgb = [0, X, C];\n                    break;\n                case 4:\n                    rgb = [X, 0, C];\n                    break;\n                case 5:\n                    rgb = [C, 0, X];\n                    break;\n            }\n            rgb = [rgb[0] + m, rgb[1] + m, rgb[2] + m];\n        }\n        return new Ext.draw.Color(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255);\n    }\n}, function() {\n    var prototype = this.prototype;\n\n    //These functions are both static and instance. TODO: find a more elegant way of copying them\n    this.addStatics({\n        fromHSL: function() {\n            return prototype.fromHSL.apply(prototype, arguments);\n        },\n        fromString: function() {\n            return prototype.fromString.apply(prototype, arguments);\n        },\n        toHex: function() {\n            return prototype.toHex.apply(prototype, arguments);\n        }\n    });\n});\n\n/**\n * @class Ext.draw.Draw\n * Base Drawing class.  Provides base drawing functions.\n * @private\n */\nExt.define('Ext.draw.Draw', {\n    /* Begin Definitions */\n\n    singleton: true,\n\n    requires: ['Ext.draw.Color'],\n\n    /* End Definitions */\n\n    pathToStringRE: /,?([achlmqrstvxz]),?/gi,\n    pathCommandRE: /([achlmqstvz])[\\s,]*((-?\\d*\\.?\\d*(?:e[-+]?\\d+)?\\s*,?\\s*)+)/ig,\n    pathValuesRE: /(-?\\d*\\.?\\d*(?:e[-+]?\\d+)?)\\s*,?\\s*/ig,\n    stopsRE: /^(\\d+%?)$/,\n    radian: Math.PI / 180,\n\n    availableAnimAttrs: {\n        along: \"along\",\n        blur: null,\n        \"clip-rect\": \"csv\",\n        cx: null,\n        cy: null,\n        fill: \"color\",\n        \"fill-opacity\": null,\n        \"font-size\": null,\n        height: null,\n        opacity: null,\n        path: \"path\",\n        r: null,\n        rotation: \"csv\",\n        rx: null,\n        ry: null,\n        scale: \"csv\",\n        stroke: \"color\",\n        \"stroke-opacity\": null,\n        \"stroke-width\": null,\n        translation: \"csv\",\n        width: null,\n        x: null,\n        y: null\n    },\n\n    is: function(o, type) {\n        type = String(type).toLowerCase();\n        return (type == \"object\" && o === Object(o)) ||\n            (type == \"undefined\" && typeof o == type) ||\n            (type == \"null\" && o === null) ||\n            (type == \"array\" && Array.isArray && Array.isArray(o)) ||\n            (Object.prototype.toString.call(o).toLowerCase().slice(8, -1)) == type;\n    },\n\n    ellipsePath: function(sprite) {\n        var attr = sprite.attr;\n        return Ext.String.format(\"M{0},{1}A{2},{3},0,1,1,{0},{4}A{2},{3},0,1,1,{0},{1}z\", attr.x, attr.y - attr.ry, attr.rx, attr.ry, attr.y + attr.ry);\n    },\n\n    rectPath: function(sprite) {\n        var attr = sprite.attr;\n        if (attr.radius) {\n            return Ext.String.format(\"M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z\", attr.x + attr.radius, attr.y, attr.width - attr.radius * 2, attr.radius, -attr.radius, attr.height - attr.radius * 2, attr.radius * 2 - attr.width, attr.radius * 2 - attr.height);\n        }\n        else {\n            return Ext.String.format(\"M{0},{1}L{2},{1},{2},{3},{0},{3}z\", attr.x, attr.y, attr.width + attr.x, attr.height + attr.y);\n        }\n    },\n\n    // To be deprecated, converts itself (an arrayPath) to a proper SVG path string\n    path2string: function () {\n        return this.join(\",\").replace(Ext.draw.Draw.pathToStringRE, \"$1\");\n    },\n\n    // Convert the passed arrayPath to a proper SVG path string (d attribute)\n    pathToString: function(arrayPath) {\n        return arrayPath.join(\",\").replace(Ext.draw.Draw.pathToStringRE, \"$1\");\n    },\n\n    parsePathString: function (pathString) {\n        if (!pathString) {\n            return null;\n        }\n        var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0},\n            data = [],\n            me = this;\n        if (me.is(pathString, \"array\") && me.is(pathString[0], \"array\")) { // rough assumption\n            data = me.pathClone(pathString);\n        }\n        if (!data.length) {\n            String(pathString).replace(me.pathCommandRE, function (a, b, c) {\n                var params = [],\n                    name = b.toLowerCase();\n                c.replace(me.pathValuesRE, function (a, b) {\n                    b && params.push(+b);\n                });\n                if (name == \"m\" && params.length > 2) {\n                    data.push([b].concat(Ext.Array.splice(params, 0, 2)));\n                    name = \"l\";\n                    b = (b == \"m\") ? \"l\" : \"L\";\n                }\n                while (params.length >= paramCounts[name]) {\n                    data.push([b].concat(Ext.Array.splice(params, 0, paramCounts[name])));\n                    if (!paramCounts[name]) {\n                        break;\n                    }\n                }\n            });\n        }\n        data.toString = me.path2string;\n        return data;\n    },\n\n    mapPath: function (path, matrix) {\n        if (!matrix) {\n            return path;\n        }\n        var x, y, i, ii, j, jj, pathi;\n        path = this.path2curve(path);\n        for (i = 0, ii = path.length; i < ii; i++) {\n            pathi = path[i];\n            for (j = 1, jj = pathi.length; j < jj-1; j += 2) {\n                x = matrix.x(pathi[j], pathi[j + 1]);\n                y = matrix.y(pathi[j], pathi[j + 1]);\n                pathi[j] = x;\n                pathi[j + 1] = y;\n            }\n        }\n        return path;\n    },\n\n    pathClone: function(pathArray) {\n        var res = [],\n            j, jj, i, ii;\n        if (!this.is(pathArray, \"array\") || !this.is(pathArray && pathArray[0], \"array\")) { // rough assumption\n            pathArray = this.parsePathString(pathArray);\n        }\n        for (i = 0, ii = pathArray.length; i < ii; i++) {\n            res[i] = [];\n            for (j = 0, jj = pathArray[i].length; j < jj; j++) {\n                res[i][j] = pathArray[i][j];\n            }\n        }\n        res.toString = this.path2string;\n        return res;\n    },\n\n    pathToAbsolute: function (pathArray) {\n        if (!this.is(pathArray, \"array\") || !this.is(pathArray && pathArray[0], \"array\")) { // rough assumption\n            pathArray = this.parsePathString(pathArray);\n        }\n        var res = [],\n            x = 0,\n            y = 0,\n            mx = 0,\n            my = 0,\n            i = 0,\n            ln = pathArray.length,\n            r, pathSegment, j, ln2;\n        // MoveTo initial x/y position\n        if (ln && pathArray[0][0] == \"M\") {\n            x = +pathArray[0][1];\n            y = +pathArray[0][2];\n            mx = x;\n            my = y;\n            i++;\n            res[0] = [\"M\", x, y];\n        }\n        for (; i < ln; i++) {\n            r = res[i] = [];\n            pathSegment = pathArray[i];\n            if (pathSegment[0] != pathSegment[0].toUpperCase()) {\n                r[0] = pathSegment[0].toUpperCase();\n                switch (r[0]) {\n                    // Elliptical Arc\n                    case \"A\":\n                        r[1] = pathSegment[1];\n                        r[2] = pathSegment[2];\n                        r[3] = pathSegment[3];\n                        r[4] = pathSegment[4];\n                        r[5] = pathSegment[5];\n                        r[6] = +(pathSegment[6] + x);\n                        r[7] = +(pathSegment[7] + y);\n                        break;\n                    // Vertical LineTo\n                    case \"V\":\n                        r[1] = +pathSegment[1] + y;\n                        break;\n                    // Horizontal LineTo\n                    case \"H\":\n                        r[1] = +pathSegment[1] + x;\n                        break;\n                    case \"M\":\n                    // MoveTo\n                        mx = +pathSegment[1] + x;\n                        my = +pathSegment[2] + y;\n                    default:\n                        j = 1;\n                        ln2 = pathSegment.length;\n                        for (; j < ln2; j++) {\n                            r[j] = +pathSegment[j] + ((j % 2) ? x : y);\n                        }\n                }\n            }\n            else {\n                j = 0;\n                ln2 = pathSegment.length;\n                for (; j < ln2; j++) {\n                    res[i][j] = pathSegment[j];\n                }\n            }\n            switch (r[0]) {\n                // ClosePath\n                case \"Z\":\n                    x = mx;\n                    y = my;\n                    break;\n                // Horizontal LineTo\n                case \"H\":\n                    x = r[1];\n                    break;\n                // Vertical LineTo\n                case \"V\":\n                    y = r[1];\n                    break;\n                // MoveTo\n                case \"M\":\n                    pathSegment = res[i];\n                    ln2 = pathSegment.length;\n                    mx = pathSegment[ln2 - 2];\n                    my = pathSegment[ln2 - 1];\n                default:\n                    pathSegment = res[i];\n                    ln2 = pathSegment.length;\n                    x = pathSegment[ln2 - 2];\n                    y = pathSegment[ln2 - 1];\n            }\n        }\n        res.toString = this.path2string;\n        return res;\n    },\n\n    // TO BE DEPRECATED\n    pathToRelative: function (pathArray) {\n        if (!this.is(pathArray, \"array\") || !this.is(pathArray && pathArray[0], \"array\")) {\n            pathArray = this.parsePathString(pathArray);\n        }\n        var res = [],\n            x = 0,\n            y = 0,\n            mx = 0,\n            my = 0,\n            start = 0,\n            r,\n            pa,\n            i,\n            j,\n            k,\n            len,\n            ii,\n            jj,\n            kk;\n        \n        if (pathArray[0][0] == \"M\") {\n            x = pathArray[0][1];\n            y = pathArray[0][2];\n            mx = x;\n            my = y;\n            start++;\n            res.push([\"M\", x, y]);\n        }\n        for (i = start, ii = pathArray.length; i < ii; i++) {\n            r = res[i] = [];\n            pa = pathArray[i];\n            if (pa[0] != pa[0].toLowerCase()) {\n                r[0] = pa[0].toLowerCase();\n                switch (r[0]) {\n                    case \"a\":\n                        r[1] = pa[1];\n                        r[2] = pa[2];\n                        r[3] = pa[3];\n                        r[4] = pa[4];\n                        r[5] = pa[5];\n                        r[6] = +(pa[6] - x).toFixed(3);\n                        r[7] = +(pa[7] - y).toFixed(3);\n                        break;\n                    case \"v\":\n                        r[1] = +(pa[1] - y).toFixed(3);\n                        break;\n                    case \"m\":\n                        mx = pa[1];\n                        my = pa[2];\n                    default:\n                        for (j = 1, jj = pa.length; j < jj; j++) {\n                            r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);\n                        }\n                }\n            } else {\n                r = res[i] = [];\n                if (pa[0] == \"m\") {\n                    mx = pa[1] + x;\n                    my = pa[2] + y;\n                }\n                for (k = 0, kk = pa.length; k < kk; k++) {\n                    res[i][k] = pa[k];\n                }\n            }\n            len = res[i].length;\n            switch (res[i][0]) {\n                case \"z\":\n                    x = mx;\n                    y = my;\n                    break;\n                case \"h\":\n                    x += +res[i][len - 1];\n                    break;\n                case \"v\":\n                    y += +res[i][len - 1];\n                    break;\n                default:\n                    x += +res[i][len - 2];\n                    y += +res[i][len - 1];\n            }\n        }\n        res.toString = this.path2string;\n        return res;\n    },\n\n    // Returns a path converted to a set of curveto commands\n    path2curve: function (path) {\n        var me = this,\n            points = me.pathToAbsolute(path),\n            ln = points.length,\n            attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},\n            i, seg, segLn, point;\n            \n        for (i = 0; i < ln; i++) {\n            points[i] = me.command2curve(points[i], attrs);\n            if (points[i].length > 7) {\n                    points[i].shift();\n                    point = points[i];\n                    while (point.length) {\n                        Ext.Array.splice(points, i++, 0, [\"C\"].concat(Ext.Array.splice(point, 0, 6)));\n                    }\n                    Ext.Array.erase(points, i, 1);\n                    ln = points.length;\n                    i--;\n                }\n            seg = points[i];\n            segLn = seg.length;\n            attrs.x = seg[segLn - 2];\n            attrs.y = seg[segLn - 1];\n            attrs.bx = parseFloat(seg[segLn - 4]) || attrs.x;\n            attrs.by = parseFloat(seg[segLn - 3]) || attrs.y;\n        }\n        return points;\n    },\n    \n    interpolatePaths: function (path, path2) {\n        var me = this,\n            p = me.pathToAbsolute(path),\n            p2 = me.pathToAbsolute(path2),\n            attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},\n            attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},\n            fixArc = function (pp, i) {\n                if (pp[i].length > 7) {\n                    pp[i].shift();\n                    var pi = pp[i];\n                    while (pi.length) {\n                        Ext.Array.splice(pp, i++, 0, [\"C\"].concat(Ext.Array.splice(pi, 0, 6)));\n                    }\n                    Ext.Array.erase(pp, i, 1);\n                    ii = Math.max(p.length, p2.length || 0);\n                }\n            },\n            fixM = function (path1, path2, a1, a2, i) {\n                if (path1 && path2 && path1[i][0] == \"M\" && path2[i][0] != \"M\") {\n                    Ext.Array.splice(path2, i, 0, [\"M\", a2.x, a2.y]);\n                    a1.bx = 0;\n                    a1.by = 0;\n                    a1.x = path1[i][1];\n                    a1.y = path1[i][2];\n                    ii = Math.max(p.length, p2.length || 0);\n                }\n            },\n            i, ii,\n            seg, seg2, seglen, seg2len;\n        for (i = 0, ii = Math.max(p.length, p2.length || 0); i < ii; i++) {\n            p[i] = me.command2curve(p[i], attrs);\n            fixArc(p, i);\n            (p2[i] = me.command2curve(p2[i], attrs2));\n            fixArc(p2, i);\n            fixM(p, p2, attrs, attrs2, i);\n            fixM(p2, p, attrs2, attrs, i);\n            seg = p[i];\n            seg2 = p2[i];\n            seglen = seg.length;\n            seg2len = seg2.length;\n            attrs.x = seg[seglen - 2];\n            attrs.y = seg[seglen - 1];\n            attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;\n            attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;\n            attrs2.bx = (parseFloat(seg2[seg2len - 4]) || attrs2.x);\n            attrs2.by = (parseFloat(seg2[seg2len - 3]) || attrs2.y);\n            attrs2.x = seg2[seg2len - 2];\n            attrs2.y = seg2[seg2len - 1];\n        }\n        return [p, p2];\n    },\n    \n    //Returns any path command as a curveto command based on the attrs passed\n    command2curve: function (pathCommand, d) {\n        var me = this;\n        if (!pathCommand) {\n            return [\"C\", d.x, d.y, d.x, d.y, d.x, d.y];\n        }\n        if (pathCommand[0] != \"T\" && pathCommand[0] != \"Q\") {\n            d.qx = d.qy = null;\n        }\n        switch (pathCommand[0]) {\n            case \"M\":\n                d.X = pathCommand[1];\n                d.Y = pathCommand[2];\n                break;\n            case \"A\":\n                pathCommand = [\"C\"].concat(me.arc2curve.apply(me, [d.x, d.y].concat(pathCommand.slice(1))));\n                break;\n            case \"S\":\n                pathCommand = [\"C\", d.x + (d.x - (d.bx || d.x)), d.y + (d.y - (d.by || d.y))].concat(pathCommand.slice(1));\n                break;\n            case \"T\":\n                d.qx = d.x + (d.x - (d.qx || d.x));\n                d.qy = d.y + (d.y - (d.qy || d.y));\n                pathCommand = [\"C\"].concat(me.quadratic2curve(d.x, d.y, d.qx, d.qy, pathCommand[1], pathCommand[2]));\n                break;\n            case \"Q\":\n                d.qx = pathCommand[1];\n                d.qy = pathCommand[2];\n                pathCommand = [\"C\"].concat(me.quadratic2curve(d.x, d.y, pathCommand[1], pathCommand[2], pathCommand[3], pathCommand[4]));\n                break;\n            case \"L\":\n                pathCommand = [\"C\"].concat(d.x, d.y, pathCommand[1], pathCommand[2], pathCommand[1], pathCommand[2]);\n                break;\n            case \"H\":\n                pathCommand = [\"C\"].concat(d.x, d.y, pathCommand[1], d.y, pathCommand[1], d.y);\n                break;\n            case \"V\":\n                pathCommand = [\"C\"].concat(d.x, d.y, d.x, pathCommand[1], d.x, pathCommand[1]);\n                break;\n            case \"Z\":\n                pathCommand = [\"C\"].concat(d.x, d.y, d.X, d.Y, d.X, d.Y);\n                break;\n        }\n        return pathCommand;\n    },\n\n    quadratic2curve: function (x1, y1, ax, ay, x2, y2) {\n        var _13 = 1 / 3,\n            _23 = 2 / 3;\n        return [\n                _13 * x1 + _23 * ax,\n                _13 * y1 + _23 * ay,\n                _13 * x2 + _23 * ax,\n                _13 * y2 + _23 * ay,\n                x2,\n                y2\n            ];\n    },\n    \n    rotate: function (x, y, rad) {\n        var cos = Math.cos(rad),\n            sin = Math.sin(rad),\n            X = x * cos - y * sin,\n            Y = x * sin + y * cos;\n        return {x: X, y: Y};\n    },\n\n    arc2curve: function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {\n        // for more information of where this Math came from visit:\n        // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n        var me = this,\n            PI = Math.PI,\n            radian = me.radian,\n            _120 = PI * 120 / 180,\n            rad = radian * (+angle || 0),\n            res = [],\n            math = Math,\n            mcos = math.cos,\n            msin = math.sin,\n            msqrt = math.sqrt,\n            mabs = math.abs,\n            masin = math.asin,\n            xy, cos, sin, x, y, h, rx2, ry2, k, cx, cy, f1, f2, df, c1, s1, c2, s2,\n            t, hx, hy, m1, m2, m3, m4, newres, i, ln, f2old, x2old, y2old;\n        if (!recursive) {\n            xy = me.rotate(x1, y1, -rad);\n            x1 = xy.x;\n            y1 = xy.y;\n            xy = me.rotate(x2, y2, -rad);\n            x2 = xy.x;\n            y2 = xy.y;\n            cos = mcos(radian * angle);\n            sin = msin(radian * angle);\n            x = (x1 - x2) / 2;\n            y = (y1 - y2) / 2;\n            h = (x * x) / (rx * rx) + (y * y) / (ry * ry);\n            if (h > 1) {\n                h = msqrt(h);\n                rx = h * rx;\n                ry = h * ry;\n            }\n            rx2 = rx * rx;\n            ry2 = ry * ry;\n            k = (large_arc_flag == sweep_flag ? -1 : 1) *\n                    msqrt(mabs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));\n            cx = k * rx * y / ry + (x1 + x2) / 2;\n            cy = k * -ry * x / rx + (y1 + y2) / 2;\n            f1 = masin(((y1 - cy) / ry).toFixed(7));\n            f2 = masin(((y2 - cy) / ry).toFixed(7));\n\n            f1 = x1 < cx ? PI - f1 : f1;\n            f2 = x2 < cx ? PI - f2 : f2;\n            if (f1 < 0) {\n                f1 = PI * 2 + f1;\n            }\n            if (f2 < 0) {\n                f2 = PI * 2 + f2;\n            }\n            if (sweep_flag && f1 > f2) {\n                f1 = f1 - PI * 2;\n            }\n            if (!sweep_flag && f2 > f1) {\n                f2 = f2 - PI * 2;\n            }\n        }\n        else {\n            f1 = recursive[0];\n            f2 = recursive[1];\n            cx = recursive[2];\n            cy = recursive[3];\n        }\n        df = f2 - f1;\n        if (mabs(df) > _120) {\n            f2old = f2;\n            x2old = x2;\n            y2old = y2;\n            f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);\n            x2 = cx + rx * mcos(f2);\n            y2 = cy + ry * msin(f2);\n            res = me.arc2curve(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);\n        }\n        df = f2 - f1;\n        c1 = mcos(f1);\n        s1 = msin(f1);\n        c2 = mcos(f2);\n        s2 = msin(f2);\n        t = math.tan(df / 4);\n        hx = 4 / 3 * rx * t;\n        hy = 4 / 3 * ry * t;\n        m1 = [x1, y1];\n        m2 = [x1 + hx * s1, y1 - hy * c1];\n        m3 = [x2 + hx * s2, y2 - hy * c2];\n        m4 = [x2, y2];\n        m2[0] = 2 * m1[0] - m2[0];\n        m2[1] = 2 * m1[1] - m2[1];\n        if (recursive) {\n            return [m2, m3, m4].concat(res);\n        }\n        else {\n            res = [m2, m3, m4].concat(res).join().split(\",\");\n            newres = [];\n            ln = res.length;\n            for (i = 0;  i < ln; i++) {\n                newres[i] = i % 2 ? me.rotate(res[i - 1], res[i], rad).y : me.rotate(res[i], res[i + 1], rad).x;\n            }\n            return newres;\n        }\n    },\n\n    // TO BE DEPRECATED\n    rotateAndTranslatePath: function (sprite) {\n        var alpha = sprite.rotation.degrees,\n            cx = sprite.rotation.x,\n            cy = sprite.rotation.y,\n            dx = sprite.translation.x,\n            dy = sprite.translation.y,\n            path,\n            i,\n            p,\n            xy,\n            j,\n            res = [];\n        if (!alpha && !dx && !dy) {\n            return this.pathToAbsolute(sprite.attr.path);\n        }\n        dx = dx || 0;\n        dy = dy || 0;\n        path = this.pathToAbsolute(sprite.attr.path);\n        for (i = path.length; i--;) {\n            p = res[i] = path[i].slice();\n            if (p[0] == \"A\") {\n                xy = this.rotatePoint(p[6], p[7], alpha, cx, cy);\n                p[6] = xy.x + dx;\n                p[7] = xy.y + dy;\n            } else {\n                j = 1;\n                while (p[j + 1] != null) {\n                    xy = this.rotatePoint(p[j], p[j + 1], alpha, cx, cy);\n                    p[j] = xy.x + dx;\n                    p[j + 1] = xy.y + dy;\n                    j += 2;\n                }\n            }\n        }\n        return res;\n    },\n\n    // TO BE DEPRECATED\n    rotatePoint: function (x, y, alpha, cx, cy) {\n        if (!alpha) {\n            return {\n                x: x,\n                y: y\n            };\n        }\n        cx = cx || 0;\n        cy = cy || 0;\n        x = x - cx;\n        y = y - cy;\n        alpha = alpha * this.radian;\n        var cos = Math.cos(alpha),\n            sin = Math.sin(alpha);\n        return {\n            x: x * cos - y * sin + cx,\n            y: x * sin + y * cos + cy\n        };\n    },\n\n    pathDimensions: function (path) {\n        if (!path || !(path + \"\")) {\n            return {x: 0, y: 0, width: 0, height: 0};\n        }\n        path = this.path2curve(path);\n        var x = 0, \n            y = 0,\n            X = [],\n            Y = [],\n            i = 0,\n            ln = path.length,\n            p, xmin, ymin, dim;\n        for (; i < ln; i++) {\n            p = path[i];\n            if (p[0] == \"M\") {\n                x = p[1];\n                y = p[2];\n                X.push(x);\n                Y.push(y);\n            }\n            else {\n                dim = this.curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);\n                X = X.concat(dim.min.x, dim.max.x);\n                Y = Y.concat(dim.min.y, dim.max.y);\n                x = p[5];\n                y = p[6];\n            }\n        }\n        xmin = Math.min.apply(0, X);\n        ymin = Math.min.apply(0, Y);\n        return {\n            x: xmin,\n            y: ymin,\n            path: path,\n            width: Math.max.apply(0, X) - xmin,\n            height: Math.max.apply(0, Y) - ymin\n        };\n    },\n\n    intersectInside: function(path, cp1, cp2) {\n        return (cp2[0] - cp1[0]) * (path[1] - cp1[1]) > (cp2[1] - cp1[1]) * (path[0] - cp1[0]);\n    },\n\n    intersectIntersection: function(s, e, cp1, cp2) {\n        var p = [],\n            dcx = cp1[0] - cp2[0],\n            dcy = cp1[1] - cp2[1],\n            dpx = s[0] - e[0],\n            dpy = s[1] - e[1],\n            n1 = cp1[0] * cp2[1] - cp1[1] * cp2[0],\n            n2 = s[0] * e[1] - s[1] * e[0],\n            n3 = 1 / (dcx * dpy - dcy * dpx);\n\n        p[0] = (n1 * dpx - n2 * dcx) * n3;\n        p[1] = (n1 * dpy - n2 * dcy) * n3;\n        return p;\n    },\n\n    intersect: function(subjectPolygon, clipPolygon) {\n        var me = this,\n            i = 0,\n            ln = clipPolygon.length,\n            cp1 = clipPolygon[ln - 1],\n            outputList = subjectPolygon,\n            cp2, s, e, point, ln2, inputList, j;\n        for (; i < ln; ++i) {\n            cp2 = clipPolygon[i];\n            inputList = outputList;\n            outputList = [];\n            s = inputList[inputList.length - 1];\n            j = 0;\n            ln2 = inputList.length;\n            for (; j < ln2; j++) {\n                e = inputList[j];\n                if (me.intersectInside(e, cp1, cp2)) {\n                    if (!me.intersectInside(s, cp1, cp2)) {\n                        outputList.push(me.intersectIntersection(s, e, cp1, cp2));\n                    }\n                    outputList.push(e);\n                }\n                else if (me.intersectInside(s, cp1, cp2)) {\n                    outputList.push(me.intersectIntersection(s, e, cp1, cp2));\n                }\n                s = e;\n            }\n            cp1 = cp2;\n        }\n        return outputList;\n    },\n    \n    bezier : function (a, b, c, d, x) {\n        if (x === 0) {\n            return a;\n        } \n        else if (x === 1) {\n            return d;\n        }\n        var du = 1 - x,\n            d3 = du * du * du,\n            r = x / du;\n        return d3 * (a + r * (3 * b + r * (3 * c + d * r)));\n    },\n    \n    bezierDim : function (a, b, c, d) {\n        var points = [], r,\n            A, top, C, delta, bottom, s,\n            min, max, i;\n        // The min and max happens on boundary or b' == 0\n        if (a + 3 * c == d + 3 * b) {   \n            r = a - b;\n            r /= 2 * (a - b - b + c);\n            if ( r < 1 && r > 0) {\n                points.push(r);\n            }\n        } else {\n            // b'(x) / -3 = (a-3b+3c-d)x^2+ (-2a+4b-2c)x + (a-b)\n            // delta = -4 (-b^2+a c+b c-c^2-a d+b d)\n            A = a - 3 * b + 3 * c - d;\n            top = 2 * (a - b - b + c);\n            C = a - b;\n            delta = top * top - 4 * A * C;\n            bottom = A + A;\n            if (delta === 0) {\n                r = top / bottom;\n                if (r < 1 && r > 0) {\n                    points.push(r);\n                }\n            } else if (delta > 0) {\n                s = Math.sqrt(delta);\n                r = (s + top) / bottom;\n                \n                if (r < 1 && r > 0) {\n                    points.push(r);\n                }\n                \n                r = (top - s) / bottom;\n                \n                if (r < 1 && r > 0) {\n                    points.push(r);\n                }\n            }\n        }\n        min = Math.min(a, d);\n        max = Math.max(a, d);\n        for (i = 0; i < points.length; i++) {\n            min = Math.min(min, this.bezier(a, b, c, d, points[i]));\n            max = Math.max(max, this.bezier(a, b, c, d, points[i]));\n        }\n        return [min, max];\n    },\n    \n    curveDim: function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {\n        var x = this.bezierDim(p1x, c1x, c2x, p2x),\n            y = this.bezierDim(p1y, c1y, c2y, p2y);\n        return {\n            min: {\n                x: x[0],\n                y: y[0]\n            },\n            max: {\n                x: x[1],\n                y: y[1]\n            }\n        };\n    },\n\n    /**\n     * @private\n     *\n     * Calculates bezier curve control anchor points for a particular point in a path, with a\n     * smoothing curve applied. The smoothness of the curve is controlled by the 'value' parameter.\n     * Note that this algorithm assumes that the line being smoothed is normalized going from left\n     * to right; it makes special adjustments assuming this orientation.\n     *\n     * @param {Number} prevX X coordinate of the previous point in the path\n     * @param {Number} prevY Y coordinate of the previous point in the path\n     * @param {Number} curX X coordinate of the current point in the path\n     * @param {Number} curY Y coordinate of the current point in the path\n     * @param {Number} nextX X coordinate of the next point in the path\n     * @param {Number} nextY Y coordinate of the next point in the path\n     * @param {Number} value A value to control the smoothness of the curve; this is used to\n     *                 divide the distance between points, so a value of 2 corresponds to\n     *                 half the distance between points (a very smooth line) while higher values\n     *                 result in less smooth curves. Defaults to 4.\n     * @return {Object} Object containing x1, y1, x2, y2 bezier control anchor points; x1 and y1\n     *                  are the control point for the curve toward the previous path point, and\n     *                  x2 and y2 are the control point for the curve toward the next path point.\n     */\n    getAnchors: function (prevX, prevY, curX, curY, nextX, nextY, value) {\n        value = value || 4;\n        var M = Math,\n            PI = M.PI,\n            halfPI = PI / 2,\n            abs = M.abs,\n            sin = M.sin,\n            cos = M.cos,\n            atan = M.atan,\n            control1Length, control2Length, control1Angle, control2Angle,\n            control1X, control1Y, control2X, control2Y, alpha;\n\n        // Find the length of each control anchor line, by dividing the horizontal distance\n        // between points by the value parameter.\n        control1Length = (curX - prevX) / value;\n        control2Length = (nextX - curX) / value;\n\n        // Determine the angle of each control anchor line. If the middle point is a vertical\n        // turnaround then we force it to a flat horizontal angle to prevent the curve from\n        // dipping above or below the middle point. Otherwise we use an angle that points\n        // toward the previous/next target point.\n        if ((curY >= prevY && curY >= nextY) || (curY <= prevY && curY <= nextY)) {\n            control1Angle = control2Angle = halfPI;\n        } else {\n            control1Angle = atan((curX - prevX) / abs(curY - prevY));\n            if (prevY < curY) {\n                control1Angle = PI - control1Angle;\n            }\n            control2Angle = atan((nextX - curX) / abs(curY - nextY));\n            if (nextY < curY) {\n                control2Angle = PI - control2Angle;\n            }\n        }\n\n        // Adjust the calculated angles so they point away from each other on the same line\n        alpha = halfPI - ((control1Angle + control2Angle) % (PI * 2)) / 2;\n        if (alpha > halfPI) {\n            alpha -= PI;\n        }\n        control1Angle += alpha;\n        control2Angle += alpha;\n\n        // Find the control anchor points from the angles and length\n        control1X = curX - control1Length * sin(control1Angle);\n        control1Y = curY + control1Length * cos(control1Angle);\n        control2X = curX + control2Length * sin(control2Angle);\n        control2Y = curY + control2Length * cos(control2Angle);\n\n        // One last adjustment, make sure that no control anchor point extends vertically past\n        // its target prev/next point, as that results in curves dipping above or below and\n        // bending back strangely. If we find this happening we keep the control angle but\n        // reduce the length of the control line so it stays within bounds.\n        if ((curY > prevY && control1Y < prevY) || (curY < prevY && control1Y > prevY)) {\n            control1X += abs(prevY - control1Y) * (control1X - curX) / (control1Y - curY);\n            control1Y = prevY;\n        }\n        if ((curY > nextY && control2Y < nextY) || (curY < nextY && control2Y > nextY)) {\n            control2X -= abs(nextY - control2Y) * (control2X - curX) / (control2Y - curY);\n            control2Y = nextY;\n        }\n        \n        return {\n            x1: control1X,\n            y1: control1Y,\n            x2: control2X,\n            y2: control2Y\n        };\n    },\n\n    /* Smoothing function for a path.  Converts a path into cubic beziers.  Value defines the divider of the distance between points.\n     * Defaults to a value of 4.\n     */\n    smooth: function (originalPath, value) {\n        var path = this.path2curve(originalPath),\n            newp = [path[0]],\n            x = path[0][1],\n            y = path[0][2],\n            j,\n            points,\n            i = 1,\n            ii = path.length,\n            beg = 1,\n            mx = x,\n            my = y,\n            cx = 0,\n            cy = 0,\n            pathi,\n            pathil,\n            pathim,\n            pathiml,\n            pathip,\n            pathipl,\n            begl;\n        \n        for (; i < ii; i++) {\n            pathi = path[i];\n            pathil = pathi.length;\n            pathim = path[i - 1];\n            pathiml = pathim.length;\n            pathip = path[i + 1];\n            pathipl = pathip && pathip.length;\n            if (pathi[0] == \"M\") {\n                mx = pathi[1];\n                my = pathi[2];\n                j = i + 1;\n                while (path[j][0] != \"C\") {\n                    j++;\n                }\n                cx = path[j][5];\n                cy = path[j][6];\n                newp.push([\"M\", mx, my]);\n                beg = newp.length;\n                x = mx;\n                y = my;\n                continue;\n            }\n            if (pathi[pathil - 2] == mx && pathi[pathil - 1] == my && (!pathip || pathip[0] == \"M\")) {\n                begl = newp[beg].length;\n                points = this.getAnchors(pathim[pathiml - 2], pathim[pathiml - 1], mx, my, newp[beg][begl - 2], newp[beg][begl - 1], value);\n                newp[beg][1] = points.x2;\n                newp[beg][2] = points.y2;\n            }\n            else if (!pathip || pathip[0] == \"M\") {\n                points = {\n                    x1: pathi[pathil - 2],\n                    y1: pathi[pathil - 1]\n                };\n            } else {\n                points = this.getAnchors(pathim[pathiml - 2], pathim[pathiml - 1], pathi[pathil - 2], pathi[pathil - 1], pathip[pathipl - 2], pathip[pathipl - 1], value);\n            }\n            newp.push([\"C\", x, y, points.x1, points.y1, pathi[pathil - 2], pathi[pathil - 1]]);\n            x = points.x2;\n            y = points.y2;\n        }\n        return newp;\n    },\n\n    findDotAtSegment: function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {\n        var t1 = 1 - t;\n        return {\n            x: Math.pow(t1, 3) * p1x + Math.pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + Math.pow(t, 3) * p2x,\n            y: Math.pow(t1, 3) * p1y + Math.pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + Math.pow(t, 3) * p2y\n        };\n    },\n\n    /**\n     * @private\n     */\n    snapEnds: function (from, to, stepsMax, prettyNumbers) {\n        if (Ext.isDate(from)) {\n            return this.snapEndsByDate(from, to, stepsMax);\n        }\n        var step = (to - from) / stepsMax,\n            level = Math.floor(Math.log(step) / Math.LN10) + 1,\n            m = Math.pow(10, level),\n            cur,\n            modulo = Math.round((step % m) * Math.pow(10, 2 - level)),\n            interval = [[0, 15], [20, 4], [30, 2], [40, 4], [50, 9], [60, 4], [70, 2], [80, 4], [100, 15]],\n            stepCount = 0,\n            value,\n            weight,\n            i,\n            topValue,\n            topWeight = 1e9,\n            ln = interval.length;\n        cur = from = Math.floor(from / m) * m;\n        \n        if(prettyNumbers){\n            for (i = 0; i < ln; i++) {\n                value = interval[i][0];\n                weight = (value - modulo) < 0 ? 1e6 : (value - modulo) / interval[i][1];\n                if (weight < topWeight) {\n                    topValue = value;\n                    topWeight = weight;\n                }\n            }\n            step = Math.floor(step * Math.pow(10, -level)) * Math.pow(10, level) + topValue * Math.pow(10, level - 2);\n            while (cur < to) {\n                cur += step;\n                stepCount++;\n            }\n            to = +cur.toFixed(10);\n        }else{\n            stepCount = stepsMax;\n        }\n        \n        return {\n            from: from,\n            to: to,\n            power: level,\n            step: step,\n            steps: stepCount\n        };\n    },\n\n    /**\n     * snapEndsByDate is a utility method to deduce an appropriate tick configuration for the data set of given\n     * feature. Refer to {@link #snapEnds}.\n     *\n     * @param {Date} from The minimum value in the data\n     * @param {Date} to The maximum value in the data\n     * @param {Number} stepsMax The maximum number of ticks\n     * @param {Boolean} lockEnds If true, the 'from' and 'to' parameters will be used as fixed end values\n     *        and will not be adjusted\n     * @return {Object} The calculated step and ends info; properties are:\n     *     - from: The result start value, which may be lower than the original start value\n     *     - to: The result end value, which may be higher than the original end value\n     *     - step: The value size of each step\n     *     - steps: The number of steps. NOTE: the steps may not divide the from/to range perfectly evenly;\n     *              there may be a smaller distance between the last step and the end value than between prior\n     *              steps, particularly when the `endsLocked` param is true. Therefore it is best to not use\n     *              the `steps` result when finding the axis tick points, instead use the `step`, `to`, and\n     *              `from` to find the correct point for each tick.\n     */\n    snapEndsByDate: function (from, to, stepsMax, lockEnds) {\n        var selectedStep = false,\n            scales       = [\n                [Ext.Date.MILLI, [1, 2, 3, 5, 10, 20, 30, 50, 100, 200, 300, 500]],\n                [Ext.Date.SECOND, [1, 2, 3, 5, 10, 15, 30]],\n                [Ext.Date.MINUTE, [1, 2, 3, 5, 10, 20, 30]],\n                [Ext.Date.HOUR, [1, 2, 3, 4, 6, 12]],\n                [Ext.Date.DAY, [1, 2, 3, 7, 14]],\n                [Ext.Date.MONTH, [1, 2, 3, 4, 6]]\n            ],\n            sLen         = scales.length,\n            stop         = false,\n            scale, j, yearDiff, s;\n\n        // Find the most desirable scale\n        for (s = 0; s < sLen; s++) {\n            scale = scales[s];\n            if (!stop) {\n                for (j = 0; j < scale[1].length; j++) {\n                    if (to < Ext.Date.add(from, scale[0], scale[1][j] * stepsMax)) {\n                        selectedStep = [scale[0], scale[1][j]];\n                        stop         = true;\n                        break;\n                    }\n                }\n            }\n        }\n\n        if (!selectedStep) {\n            yearDiff = this.snapEnds(from.getFullYear(), to.getFullYear() + 1, stepsMax, lockEnds);\n            selectedStep = [Date.YEAR, Math.round(yearDiff.step)];\n        }\n        return this.snapEndsByDateAndStep(from, to, selectedStep, lockEnds);\n    },\n\n\n    /**\n     * snapEndsByDateAndStep is a utility method to deduce an appropriate tick configuration for the data set of given\n     * feature and specific step size.\n     * @param {Date} from The minimum value in the data\n     * @param {Date} to The maximum value in the data\n     * @param {Array} step An array with two components: The first is the unit of the step (day, month, year, etc). The second one is the number of units for the step (1, 2, etc.).\n     * @param {Boolean} lockEnds If true, the 'from' and 'to' parameters will be used as fixed end values\n     *        and will not be adjusted\n     */\n    snapEndsByDateAndStep: function(from, to, step, lockEnds) {\n        var fromStat = [from.getFullYear(), from.getMonth(), from.getDate(),\n                from.getHours(), from.getMinutes(), from.getSeconds(), from.getMilliseconds()],\n            steps = 0, testFrom, testTo;\n        if (lockEnds) {\n            testFrom = from;\n        } else {\n            switch (step[0]) {\n                case Ext.Date.MILLI:\n                    testFrom = new Date(fromStat[0], fromStat[1], fromStat[2], fromStat[3],\n                            fromStat[4], fromStat[5], Math.floor(fromStat[6] / step[1]) * step[1]);\n                    break;\n                case Ext.Date.SECOND:\n                    testFrom = new Date(fromStat[0], fromStat[1], fromStat[2], fromStat[3],\n                            fromStat[4], Math.floor(fromStat[5] / step[1]) * step[1], 0);\n                    break;\n                case Ext.Date.MINUTE:\n                    testFrom = new Date(fromStat[0], fromStat[1], fromStat[2], fromStat[3],\n                            Math.floor(fromStat[4] / step[1]) * step[1], 0, 0);\n                    break;\n                case Ext.Date.HOUR:\n                    testFrom = new Date(fromStat[0], fromStat[1], fromStat[2],\n                            Math.floor(fromStat[3] / step[1]) * step[1], 0, 0, 0);\n                    break;\n                case Ext.Date.DAY:\n                    testFrom = new Date(fromStat[0], fromStat[1],\n                            Math.floor(fromStat[2] - 1 / step[1]) * step[1] + 1, 0, 0, 0, 0);\n                    break;\n                case Ext.Date.MONTH:\n                    testFrom = new Date(fromStat[0], Math.floor(fromStat[1] / step[1]) * step[1], 1, 0, 0, 0, 0);\n                    break;\n                default: // Ext.Date.YEAR\n                    testFrom = new Date(Math.floor(fromStat[0] / step[1]) * step[1], 0, 1, 0, 0, 0, 0);\n                    break;\n            }\n        }\n\n        testTo = testFrom;\n        // TODO(zhangbei) : We can do it better somehow...\n        while (testTo < to) {\n            testTo = Ext.Date.add(testTo, step[0], step[1]);\n            steps++;\n        }\n\n        if (lockEnds) {\n            testTo = to;\n        }\n        return {\n            from : +testFrom,\n            to : +testTo,\n            step : (testTo - testFrom) / steps,\n            steps : steps\n        };\n    },\n\n    sorter: function (a, b) {\n        return a.offset - b.offset;\n    },\n\n    rad: function(degrees) {\n        return degrees % 360 * Math.PI / 180;\n    },\n\n    degrees: function(radian) {\n        return radian * 180 / Math.PI % 360;\n    },\n\n    withinBox: function(x, y, bbox) {\n        bbox = bbox || {};\n        return (x >= bbox.x && x <= (bbox.x + bbox.width) && y >= bbox.y && y <= (bbox.y + bbox.height));\n    },\n\n    parseGradient: function(gradient) {\n        var me = this,\n            type = gradient.type || 'linear',\n            angle = gradient.angle || 0,\n            radian = me.radian,\n            stops = gradient.stops,\n            stopsArr = [],\n            stop,\n            vector,\n            max,\n            stopObj;\n\n        if (type == 'linear') {\n            vector = [0, 0, Math.cos(angle * radian), Math.sin(angle * radian)];\n            max = 1 / (Math.max(Math.abs(vector[2]), Math.abs(vector[3])) || 1);\n            vector[2] *= max;\n            vector[3] *= max;\n            if (vector[2] < 0) {\n                vector[0] = -vector[2];\n                vector[2] = 0;\n            }\n            if (vector[3] < 0) {\n                vector[1] = -vector[3];\n                vector[3] = 0;\n            }\n        }\n\n        for (stop in stops) {\n            if (stops.hasOwnProperty(stop) && me.stopsRE.test(stop)) {\n                stopObj = {\n                    offset: parseInt(stop, 10),\n                    color: Ext.draw.Color.toHex(stops[stop].color) || '#ffffff',\n                    opacity: stops[stop].opacity || 1\n                };\n                stopsArr.push(stopObj);\n            }\n        }\n        // Sort by pct property\n        Ext.Array.sort(stopsArr, me.sorter);\n        if (type == 'linear') {\n            return {\n                id: gradient.id,\n                type: type,\n                vector: vector,\n                stops: stopsArr\n            };\n        }\n        else {\n            return {\n                id: gradient.id,\n                type: type,\n                centerX: gradient.centerX,\n                centerY: gradient.centerY,\n                focalX: gradient.focalX,\n                focalY: gradient.focalY,\n                radius: gradient.radius,\n                vector: vector,\n                stops: stopsArr\n            };\n        }\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.fx.PropertyHandler', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.draw.Draw'],\n\n    statics: {\n        defaultHandler: {\n            pixelDefaultsRE: /width|height|top$|bottom$|left$|right$/i,\n            unitRE: /^(-?\\d*\\.?\\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/,\n            scrollRE: /^scroll/i,\n\n            computeDelta: function(from, end, damper, initial, attr) {\n                damper = (typeof damper == 'number') ? damper : 1;\n                var unitRE = this.unitRE,\n                    match = unitRE.exec(from),\n                    start, units;\n                if (match) {\n                    from = match[1];\n                    units = match[2];\n                    if (!this.scrollRE.test(attr) && !units && this.pixelDefaultsRE.test(attr)) {\n                        units = 'px';\n                    }\n                }\n                from = +from || 0;\n\n                match = unitRE.exec(end);\n                if (match) {\n                    end = match[1];\n                    units = match[2] || units;\n                }\n                end = +end || 0;\n                start = (initial != null) ? initial : from;\n                return {\n                    from: from,\n                    delta: (end - start) * damper,\n                    units: units\n                };\n            },\n\n            get: function(from, end, damper, initialFrom, attr) {\n                var ln = from.length,\n                    out = [],\n                    i, initial, res, j, len;\n                for (i = 0; i < ln; i++) {\n                    if (initialFrom) {\n                        initial = initialFrom[i][1].from;\n                    }\n                    if (Ext.isArray(from[i][1]) && Ext.isArray(end)) {\n                        res = [];\n                        j = 0;\n                        len = from[i][1].length;\n                        for (; j < len; j++) {\n                            res.push(this.computeDelta(from[i][1][j], end[j], damper, initial, attr));\n                        }\n                        out.push([from[i][0], res]);\n                    }\n                    else {\n                        out.push([from[i][0], this.computeDelta(from[i][1], end, damper, initial, attr)]);\n                    }\n                }\n                return out;\n            },\n\n            set: function(values, easing) {\n                var ln = values.length,\n                    out = [],\n                    i, val, res, len, j;\n                for (i = 0; i < ln; i++) {\n                    val  = values[i][1];\n                    if (Ext.isArray(val)) {\n                        res = [];\n                        j = 0;\n                        len = val.length;\n                        for (; j < len; j++) {\n                            res.push(val[j].from + val[j].delta * easing + (val[j].units || 0));\n                        }\n                        out.push([values[i][0], res]);\n                    } else {\n                        out.push([values[i][0], val.from + val.delta * easing + (val.units || 0)]);\n                    }\n                }\n                return out;\n            }\n        },\n        stringHandler: {\n            computeDelta: function(from, end, damper, initial, attr) {\n                return {\n                    from: from,\n                    delta: end\n                };\n            },\n\n            get: function(from, end, damper, initialFrom, attr) {\n                var ln = from.length,\n                    out = [],\n                    i, initial, res, j, len;\n                for (i = 0; i < ln; i++) {\n                    out.push([from[i][0], this.computeDelta(from[i][1], end, damper, initial, attr)]);\n                }\n                return out;\n            },\n\n            set: function(values, easing) {\n                var ln = values.length,\n                    out = [],\n                    i, val, res, len, j;\n                for (i = 0; i < ln; i++) {\n                    val  = values[i][1];\n                    out.push([values[i][0], val.delta]);\n                }\n                return out;\n            }\n        },\n        color: {\n            rgbRE: /^rgb\\(([0-9]+)\\s*,\\s*([0-9]+)\\s*,\\s*([0-9]+)\\)$/i,\n            hexRE: /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,\n            hex3RE: /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,\n\n            parseColor : function(color, damper) {\n                damper = (typeof damper == 'number') ? damper : 1;\n                var out    = false,\n                    reList = [this.hexRE, this.rgbRE, this.hex3RE],\n                    length = reList.length,\n                    match, base, re, i;\n\n                for (i = 0; i < length; i++) {\n                    re = reList[i];\n\n                    base = (i % 2 === 0) ? 16 : 10;\n                    match = re.exec(color);\n                    if (match && match.length === 4) {\n                        if (i === 2) {\n                            match[1] += match[1];\n                            match[2] += match[2];\n                            match[3] += match[3];\n                        }\n                        out = {\n                            red: parseInt(match[1], base),\n                            green: parseInt(match[2], base),\n                            blue: parseInt(match[3], base)\n                        };\n                        break;\n                    }\n                }\n\n                return out || color;\n            },\n\n            computeDelta: function(from, end, damper, initial) {\n                from = this.parseColor(from);\n                end = this.parseColor(end, damper);\n                var start = initial ? initial : from,\n                    tfrom = typeof start,\n                    tend = typeof end;\n                //Extra check for when the color string is not recognized.\n                if (tfrom == 'string' ||  tfrom == 'undefined'\n                  || tend == 'string' || tend == 'undefined') {\n                    return end || start;\n                }\n                return {\n                    from:  from,\n                    delta: {\n                        red: Math.round((end.red - start.red) * damper),\n                        green: Math.round((end.green - start.green) * damper),\n                        blue: Math.round((end.blue - start.blue) * damper)\n                    }\n                };\n            },\n\n            get: function(start, end, damper, initialFrom) {\n                var ln = start.length,\n                    out = [],\n                    i, initial;\n                for (i = 0; i < ln; i++) {\n                    if (initialFrom) {\n                        initial = initialFrom[i][1].from;\n                    }\n                    out.push([start[i][0], this.computeDelta(start[i][1], end, damper, initial)]);\n                }\n                return out;\n            },\n\n            set: function(values, easing) {\n                var ln = values.length,\n                    out = [],\n                    i, val, parsedString, from, delta;\n                for (i = 0; i < ln; i++) {\n                    val = values[i][1];\n                    if (val) {\n                        from = val.from;\n                        delta = val.delta;\n                        //multiple checks to reformat the color if it can't recognized by computeDelta.\n                        val = (typeof val == 'object' && 'red' in val)? \n                                'rgb(' + val.red + ', ' + val.green + ', ' + val.blue + ')' : val;\n                        val = (typeof val == 'object' && val.length)? val[0] : val;\n                        if (typeof val == 'undefined') {\n                            return [];\n                        }\n                        parsedString = typeof val == 'string'? val :\n                            'rgb(' + [\n                                  (from.red + Math.round(delta.red * easing)) % 256,\n                                  (from.green + Math.round(delta.green * easing)) % 256,\n                                  (from.blue + Math.round(delta.blue * easing)) % 256\n                              ].join(',') + ')';\n                        out.push([\n                            values[i][0],\n                            parsedString\n                        ]);\n                    }\n                }\n                return out;\n            }\n        },\n        object: {\n            interpolate: function(prop, damper) {\n                damper = (typeof damper == 'number') ? damper : 1;\n                var out = {},\n                    p;\n                for(p in prop) {\n                    out[p] = parseFloat(prop[p]) * damper;\n                }\n                return out;\n            },\n\n            computeDelta: function(from, end, damper, initial) {\n                from = this.interpolate(from);\n                end = this.interpolate(end, damper);\n                var start = initial ? initial : from,\n                    delta = {},\n                    p;\n\n                for(p in end) {\n                    delta[p] = end[p] - start[p];\n                }\n                return {\n                    from:  from,\n                    delta: delta\n                };\n            },\n\n            get: function(start, end, damper, initialFrom) {\n                var ln = start.length,\n                    out = [],\n                    i, initial;\n                for (i = 0; i < ln; i++) {\n                    if (initialFrom) {\n                        initial = initialFrom[i][1].from;\n                    }\n                    out.push([start[i][0], this.computeDelta(start[i][1], end, damper, initial)]);\n                }\n                return out;\n            },\n\n            set: function(values, easing) {\n                var ln = values.length,\n                    out = [],\n                    outObject = {},\n                    i, from, delta, val, p;\n                for (i = 0; i < ln; i++) {\n                    val  = values[i][1];\n                    from = val.from;\n                    delta = val.delta;\n                    for (p in from) {\n                        outObject[p] = from[p] + delta[p] * easing;\n                    }\n                    out.push([\n                        values[i][0],\n                        outObject\n                    ]);\n                }\n                return out;\n            }\n        },\n\n        path: {\n            computeDelta: function(from, end, damper, initial) {\n                damper = (typeof damper == 'number') ? damper : 1;\n                var start;\n                from = +from || 0;\n                end = +end || 0;\n                start = (initial != null) ? initial : from;\n                return {\n                    from: from,\n                    delta: (end - start) * damper\n                };\n            },\n\n            forcePath: function(path) {\n                if (!Ext.isArray(path) && !Ext.isArray(path[0])) {\n                    path = Ext.draw.Draw.parsePathString(path);\n                }\n                return path;\n            },\n\n            get: function(start, end, damper, initialFrom) {\n                var endPath = this.forcePath(end),\n                    out = [],\n                    startLn = start.length,\n                    startPathLn, pointsLn, i, deltaPath, initial, j, k, path, startPath;\n                for (i = 0; i < startLn; i++) {\n                    startPath = this.forcePath(start[i][1]);\n\n                    deltaPath = Ext.draw.Draw.interpolatePaths(startPath, endPath);\n                    startPath = deltaPath[0];\n                    endPath = deltaPath[1];\n\n                    startPathLn = startPath.length;\n                    path = [];\n                    for (j = 0; j < startPathLn; j++) {\n                        deltaPath = [startPath[j][0]];\n                        pointsLn = startPath[j].length;\n                        for (k = 1; k < pointsLn; k++) {\n                            initial = initialFrom && initialFrom[0][1][j][k].from;\n                            deltaPath.push(this.computeDelta(startPath[j][k], endPath[j][k], damper, initial));\n                        }\n                        path.push(deltaPath);\n                    }\n                    out.push([start[i][0], path]);\n                }\n                return out;\n            },\n\n            set: function(values, easing) {\n                var ln = values.length,\n                    out = [],\n                    i, j, k, newPath, calcPath, deltaPath, deltaPathLn, pointsLn;\n                for (i = 0; i < ln; i++) {\n                    deltaPath = values[i][1];\n                    newPath = [];\n                    deltaPathLn = deltaPath.length;\n                    for (j = 0; j < deltaPathLn; j++) {\n                        calcPath = [deltaPath[j][0]];\n                        pointsLn = deltaPath[j].length;\n                        for (k = 1; k < pointsLn; k++) {\n                            calcPath.push(deltaPath[j][k].from + deltaPath[j][k].delta * easing);\n                        }\n                        newPath.push(calcPath.join(','));\n                    }\n                    out.push([values[i][0], newPath.join(',')]);\n                }\n                return out;\n            }\n        }\n        /* End Definitions */\n    }\n}, function() {\n    //set color properties to color interpolator\n    var props  = [\n            'outlineColor',\n            'backgroundColor',\n            'borderColor',\n            'borderTopColor',\n            'borderRightColor',\n            'borderBottomColor',\n            'borderLeftColor',\n            'fill',\n            'stroke'\n        ],\n        length = props.length,\n        i      = 0,\n        prop;\n\n    for (; i<length; i++) {\n        prop = props[i];\n        this[prop] = this.color;\n    }\n    \n    //set string properties to string\n    props  = ['cursor'];\n    length = props.length;\n    i      = 0;\n\n    for (; i<length; i++) {\n        prop = props[i];\n        this[prop] = this.stringHandler;\n    }\n});\n\n/**\n * This class manages animation for a specific {@link #target}. The animation allows\n * animation of various properties on the target, such as size, position, color and others.\n *\n * ## Starting Conditions\n *\n * The starting conditions for the animation are provided by the {@link #from} configuration.\n * Any/all of the properties in the {@link #from} configuration can be specified. If a particular\n * property is not defined, the starting value for that property will be read directly from the target.\n *\n * ## End Conditions\n *\n * The ending conditions for the animation are provided by the {@link #to} configuration. These mark\n * the final values once the animations has finished. The values in the {@link #from} can mirror\n * those in the {@link #to} configuration to provide a starting point.\n *\n * ## Other Options\n *\n *  - {@link #duration}: Specifies the time period of the animation.\n *  - {@link #easing}: Specifies the easing of the animation.\n *  - {@link #iterations}: Allows the animation to repeat a number of times.\n *  - {@link #alternate}: Used in conjunction with {@link #iterations}, reverses the direction every second iteration.\n *\n * ## Example Code\n *\n *     @example\n *     var myComponent = Ext.create('Ext.Component', {\n *         renderTo: document.body,\n *         width: 200,\n *         height: 200,\n *         style: 'border: 1px solid red;'\n *     });\n *\n *     Ext.create('Ext.fx.Anim', {\n *         target: myComponent,\n *         duration: 1000,\n *         from: {\n *             width: 400 //starting width 400\n *         },\n *         to: {\n *             width: 300, //end width 300\n *             height: 300 // end height 300\n *         }\n *     });\n */\nExt.define('Ext.fx.Anim', {\n\n    /* Begin Definitions */\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    requires: ['Ext.fx.Manager', 'Ext.fx.Animator', 'Ext.fx.Easing', 'Ext.fx.CubicBezier', 'Ext.fx.PropertyHandler'],\n\n    /* End Definitions */\n\n    /**\n     * @property {Boolean} isAnimation\n     * `true` in this class to identify an object as an instantiated Anim, or subclass thereof.\n     */\n    isAnimation: true,\n\n    /**\n     * @cfg {Function} callback\n     * A function to be run after the animation has completed.\n     */\n\n    /**\n     * @cfg {Function} scope\n     * The scope that the {@link #callback} function will be called with\n     */\n\n    /**\n     * @cfg {Number} duration\n     * Time in milliseconds for a single animation to last. If the {@link #iterations} property is\n     * specified, then each animate will take the same duration for each iteration.\n     */\n    duration: 250,\n\n    /**\n     * @cfg {Number} delay\n     * Time to delay before starting the animation.\n     */\n    delay: 0,\n\n    /* @private used to track a delayed starting time */\n    delayStart: 0,\n\n    /**\n     * @cfg {Boolean} dynamic\n     * Currently only for Component Animation: Only set a component's outer element size bypassing layouts.\n     * Set to true to do full layouts for every frame of the animation.\n     */\n    dynamic: false,\n\n    /**\n     * @cfg {String} easing\n     * This describes how the intermediate values used during a transition will be calculated.\n     * It allows for a transition to change speed over its duration.\n     *\n     * - backIn\n     * - backOut\n     * - bounceIn\n     * - bounceOut\n     * - ease\n     * - easeIn\n     * - easeOut\n     * - easeInOut\n     * - elasticIn\n     * - elasticOut\n     * - cubic-bezier(x1, y1, x2, y2)\n     *\n     * Note that cubic-bezier will create a custom easing curve following the CSS3 [transition-timing-function][0]\n     * specification.  The four values specify points P1 and P2 of the curve as (x1, y1, x2, y2). All values must\n     * be in the range [0, 1] or the definition is invalid.\n     *\n     * [0]: http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag\n     */\n    easing: 'ease',\n\n    /**\n     * @cfg {Object} keyframes\n     * Animation keyframes follow the CSS3 Animation configuration pattern. 'from' is always considered '0%' and 'to'\n     * is considered '100%'. **Every keyframe declaration must have a keyframe rule for 0% and 100%, possibly defined using\n     * \"from\" or \"to\".**  A keyframe declaration without these keyframe selectors is invalid and will not be available for\n     * animation.  The keyframe declaration for a keyframe rule consists of properties and values. Properties that are unable to\n     * be animated are ignored in these rules, with the exception of 'easing' which can be changed at each keyframe. For example:\n     *\n     *     keyframes : {\n     *         '0%': {\n     *             left: 100\n     *         },\n     *         '40%': {\n     *             left: 150\n     *         },\n     *         '60%': {\n     *             left: 75\n     *         },\n     *         '100%': {\n     *             left: 100\n     *         }\n     *     }\n     */\n\n    /**\n     * @private\n     */\n    damper: 1,\n\n    /**\n     * @private\n     */\n    bezierRE: /^(?:cubic-)?bezier\\(([^,]+),([^,]+),([^,]+),([^\\)]+)\\)/,\n\n    /**\n     * Run the animation from the end to the beginning\n     * Defaults to false.\n     * @cfg {Boolean} reverse\n     */\n    reverse: false,\n\n    /**\n     * Flag to determine if the animation has started\n     * @property running\n     * @type Boolean\n     */\n    running: false,\n\n    /**\n     * Flag to determine if the animation is paused. Only set this to true if you need to\n     * keep the Anim instance around to be unpaused later; otherwise call {@link #end}.\n     * @property paused\n     * @type Boolean\n     */\n    paused: false,\n\n    /**\n     * @cfg {Number} iterations\n     * Number of times to execute the animation.\n     */\n    iterations: 1,\n\n    /**\n     * @cfg {Boolean} alternate\n     * Used in conjunction with iterations to reverse the animation each time an iteration completes.\n     */\n    alternate: false,\n\n    /**\n     * Current iteration the animation is running.\n     * @property currentIteration\n     * @type Number\n     */\n    currentIteration: 0,\n\n    /**\n     * Starting time of the animation.\n     * @property startTime\n     * @type Date\n     */\n    startTime: 0,\n\n    /**\n     * Contains a cache of the interpolators to be used.\n     * @private\n     * @property propHandlers\n     * @type Object\n     */\n\n    /**\n     * @cfg {String/Object} target\n     * The {@link Ext.fx.target.Target} to apply the animation to.  This should only be specified when creating an Ext.fx.Anim directly.\n     * The target does not need to be a {@link Ext.fx.target.Target} instance, it can be the underlying object. For example, you can\n     * pass a Component, Element or Sprite as the target and the Anim will create the appropriate {@link Ext.fx.target.Target} object\n     * automatically.\n     */\n\n    /**\n     * @cfg {Object} from\n     * An object containing property/value pairs for the beginning of the animation.  If not specified, the current state of the\n     * Ext.fx.target will be used. For example:\n     *\n     *     from: {\n     *         opacity: 0,       // Transparent\n     *         color: '#ffffff', // White\n     *         left: 0\n     *     }\n     *\n     */\n\n    /**\n     * @cfg {Object} to (required)\n     * An object containing property/value pairs for the end of the animation. For example:\n     *\n     *     to: {\n     *         opacity: 1,       // Opaque\n     *         color: '#00ff00', // Green\n     *         left: 500\n     *     }\n     *\n     */\n    \n    // @private\n    frameCount: 0,\n\n    // @private\n    constructor: function(config) {\n        var me = this,\n            curve;\n            \n        config = config || {};\n        // If keyframes are passed, they really want an Animator instead.\n        if (config.keyframes) {\n            return new Ext.fx.Animator(config);\n        }\n        Ext.apply(me, config);\n        if (me.from === undefined) {\n            me.from = {};\n        }\n        me.propHandlers = {};\n        me.config = config;\n        me.target = Ext.fx.Manager.createTarget(me.target);\n        me.easingFn = Ext.fx.Easing[me.easing];\n        me.target.dynamic = me.dynamic;\n\n        // If not a pre-defined curve, try a cubic-bezier\n        if (!me.easingFn) {\n            me.easingFn = String(me.easing).match(me.bezierRE);\n            if (me.easingFn && me.easingFn.length == 5) {\n                curve = me.easingFn;\n                me.easingFn = Ext.fx.CubicBezier.cubicBezier(+curve[1], +curve[2], +curve[3], +curve[4]);\n            }\n        }\n        me.id = Ext.id(null, 'ext-anim-');\n        me.addEvents(\n            /**\n             * @event beforeanimate\n             * Fires before the animation starts. A handler can return false to cancel the animation.\n             * @param {Ext.fx.Anim} this\n             */\n            'beforeanimate',\n             /**\n              * @event afteranimate\n              * Fires when the animation is complete.\n              * @param {Ext.fx.Anim} this\n              * @param {Date} startTime\n              */\n            'afteranimate',\n             /**\n              * @event lastframe\n              * Fires when the animation's last frame has been set.\n              * @param {Ext.fx.Anim} this\n              * @param {Date} startTime\n              */\n            'lastframe'\n        );\n        me.mixins.observable.constructor.call(me);\n        Ext.fx.Manager.addAnim(me);\n    },\n\n    /**\n     * @private\n     * Helper to the target\n     */\n    setAttr: function(attr, value) {\n        return Ext.fx.Manager.items.get(this.id).setAttr(this.target, attr, value);\n    },\n\n    /**\n     * @private\n     * Set up the initial currentAttrs hash.\n     */\n    initAttrs: function() {\n        var me = this,\n            from = me.from,\n            to = me.to,\n            initialFrom = me.initialFrom || {},\n            out = {},\n            start, end, propHandler, attr;\n\n        for (attr in to) {\n            if (to.hasOwnProperty(attr)) {\n                start = me.target.getAttr(attr, from[attr]);\n                end = to[attr];\n                // Use default (numeric) property handler\n                if (!Ext.fx.PropertyHandler[attr]) {\n                    if (Ext.isObject(end)) {\n                        propHandler = me.propHandlers[attr] = Ext.fx.PropertyHandler.object;\n                    } else {\n                        propHandler = me.propHandlers[attr] = Ext.fx.PropertyHandler.defaultHandler;\n                    }\n                }\n                // Use custom handler\n                else {\n                    propHandler = me.propHandlers[attr] = Ext.fx.PropertyHandler[attr];\n                }\n                out[attr] = propHandler.get(start, end, me.damper, initialFrom[attr], attr);\n            }\n        }\n        me.currentAttrs = out;\n    },\n\n    /**\n     * @private\n     * Fires beforeanimate and sets the running flag.\n     */\n    start: function(startTime) {\n        var me = this,\n            delay = me.delay,\n            delayStart = me.delayStart,\n            delayDelta;\n        \n        if (delay) {\n            if (!delayStart) {\n                me.delayStart = startTime;\n                return;\n            }\n            else {\n                delayDelta = startTime - delayStart;\n                if (delayDelta < delay) {\n                    return;\n                }\n                else {\n                    // Compensate for frame delay;\n                    startTime = new Date(delayStart.getTime() + delay);\n                }\n            }\n        }\n        if (me.fireEvent('beforeanimate', me) !== false) {\n            me.startTime = startTime;\n            if (!me.paused && !me.currentAttrs) {\n                me.initAttrs();\n            }\n            me.running = true;\n            me.frameCount = 0;\n        }\n    },\n\n    /**\n     * @private\n     * Calculate attribute value at the passed timestamp.\n     * @returns a hash of the new attributes.\n     */\n    runAnim: function(elapsedTime) {\n        var me = this,\n            attrs = me.currentAttrs,\n            duration = me.duration,\n            easingFn = me.easingFn,\n            propHandlers = me.propHandlers,\n            ret = {},\n            easing, values, attr, lastFrame;\n\n        if (elapsedTime >= duration) {\n            elapsedTime = duration;\n            lastFrame = true;\n        }\n        if (me.reverse) {\n            elapsedTime = duration - elapsedTime;\n        }\n\n        for (attr in attrs) {\n            if (attrs.hasOwnProperty(attr)) {\n                values = attrs[attr];\n                easing = lastFrame ? 1 : easingFn(elapsedTime / duration);\n                ret[attr] = propHandlers[attr].set(values, easing);\n            }\n        }\n        me.frameCount++;\n            \n        return ret;\n    },\n\n    /**\n     * @private\n     * Perform lastFrame cleanup and handle iterations\n     * @returns a hash of the new attributes.\n     */\n    lastFrame: function() {\n        var me = this,\n            iter = me.iterations,\n            iterCount = me.currentIteration;\n\n        iterCount++;\n        if (iterCount < iter) {\n            if (me.alternate) {\n                me.reverse = !me.reverse;\n            }\n            me.startTime = new Date();\n            me.currentIteration = iterCount;\n            // Turn off paused for CSS3 Transitions\n            me.paused = false;\n        }\n        else {\n            me.currentIteration = 0;\n            me.end();\n            me.fireEvent('lastframe', me, me.startTime);\n        }\n    },\n\n    endWasCalled: 0,\n\n    /**\n     * Fire afteranimate event and end the animation. Usually called automatically when the\n     * animation reaches its final frame, but can also be called manually to pre-emptively\n     * stop and destroy the running animation.\n     */\n    end: function() {\n        if (this.endWasCalled++) {\n            return;\n        }\n        var me = this;\n        me.startTime = 0;\n        me.paused = false;\n        me.running = false;\n        Ext.fx.Manager.removeAnim(me);\n        me.fireEvent('afteranimate', me, me.startTime);\n        Ext.callback(me.callback, me.scope, [me, me.startTime]);\n    },\n    \n    isReady: function() {\n        return this.paused === false && this.running === false && this.iterations > 0;\n    },\n    \n    isRunning: function() {\n        return this.paused === false && this.running === true && this.isAnimator !== true;\n    }\n});\n// Set flag to indicate that Fx is available. Class might not be available immediately.\nExt.enableFx = true;\n\n/*\n * This is a derivative of the similarly named class in the YUI Library.\n * The original license:\n * Copyright (c) 2006, Yahoo! Inc. All rights reserved.\n * Code licensed under the BSD License:\n * http://developer.yahoo.net/yui/license.txt\n */\n\n\n/**\n * Defines the interface and base operation of items that that can be\n * dragged or can be drop targets.  It was designed to be extended, overriding\n * the event handlers for startDrag, onDrag, onDragOver and onDragOut.\n * Up to three html elements can be associated with a DragDrop instance:\n *\n * - linked element: the element that is passed into the constructor.\n *   This is the element which defines the boundaries for interaction with\n *   other DragDrop objects.\n *\n * - handle element(s): The drag operation only occurs if the element that\n *   was clicked matches a handle element.  By default this is the linked\n *   element, but there are times that you will want only a portion of the\n *   linked element to initiate the drag operation, and the setHandleElId()\n *   method provides a way to define this.\n *\n * - drag element: this represents the element that would be moved along\n *   with the cursor during a drag operation.  By default, this is the linked\n *   element itself as in {@link Ext.dd.DD}.  setDragElId() lets you define\n *   a separate element that would be moved, as in {@link Ext.dd.DDProxy}.\n *\n * This class should not be instantiated until the onload event to ensure that\n * the associated elements are available.\n * The following would define a DragDrop obj that would interact with any\n * other DragDrop obj in the \"group1\" group:\n *\n *     dd = new Ext.dd.DragDrop(\"div1\", \"group1\");\n *\n * Since none of the event handlers have been implemented, nothing would\n * actually happen if you were to run the code above.  Normally you would\n * override this class or one of the default implementations, but you can\n * also override the methods you want on an instance of the class...\n *\n *     dd.onDragDrop = function(e, id) {\n *         alert(\"dd was dropped on \" + id);\n *     }\n *\n */\nExt.define('Ext.dd.DragDrop', {\n    requires: ['Ext.dd.DragDropManager'],\n\n    /**\n     * Creates new DragDrop.\n     * @param {String} id of the element that is linked to this instance\n     * @param {String} sGroup the group of related DragDrop objects\n     * @param {Object} config an object containing configurable attributes.\n     * Valid properties for DragDrop:\n     *\n     * - padding\n     * - isTarget\n     * - maintainOffset\n     * - primaryButtonOnly\n     */\n    constructor: function(id, sGroup, config) {\n        if(id) {\n            this.init(id, sGroup, config);\n        }\n    },\n\n    /**\n     * @property {Boolean} ignoreSelf\n     * Set to false to enable a DragDrop object to fire drag events while dragging\n     * over its own Element. Defaults to true - DragDrop objects do not by default\n     * fire drag events to themselves.\n     */\n\n    /**\n     * @property {String} id\n     * The id of the element associated with this object.  This is what we\n     * refer to as the \"linked element\" because the size and position of\n     * this element is used to determine when the drag and drop objects have\n     * interacted.\n     */\n    id: null,\n\n    /**\n     * @property {Object} config\n     * Configuration attributes passed into the constructor\n     */\n    config: null,\n\n    /**\n     * @property {String} dragElId\n     * The id of the element that will be dragged.  By default this is same\n     * as the linked element, but could be changed to another element. Ex:\n     * Ext.dd.DDProxy\n     * @private\n     */\n    dragElId: null,\n\n    /**\n     * @property {String} handleElId\n     * The ID of the element that initiates the drag operation.  By default\n     * this is the linked element, but could be changed to be a child of this\n     * element.  This lets us do things like only starting the drag when the\n     * header element within the linked html element is clicked.\n     * @private\n     */\n    handleElId: null,\n\n    /**\n     * @property {Object} invalidHandleTypes\n     * An object who's property names identify HTML tags to be considered invalid as drag handles.\n     * A non-null property value identifies the tag as invalid. Defaults to the\n     * following value which prevents drag operations from being initiated by `<a>` elements:\n     *\n     *     {\n     *         A: \"A\"\n     *     }\n     */\n    invalidHandleTypes: null,\n\n    /**\n     * @property {Object} invalidHandleIds\n     * An object who's property names identify the IDs of elements to be considered invalid as drag handles.\n     * A non-null property value identifies the ID as invalid. For example, to prevent\n     * dragging from being initiated on element ID \"foo\", use:\n     *\n     *     {\n     *         foo: true\n     *     }\n     */\n    invalidHandleIds: null,\n\n    /**\n     * @property {String[]} invalidHandleClasses\n     * An Array of CSS class names for elements to be considered in valid as drag handles.\n     */\n    invalidHandleClasses: null,\n\n    /**\n     * @property {Number} startPageX\n     * The linked element's absolute X position at the time the drag was\n     * started\n     * @private\n     */\n    startPageX: 0,\n\n    /**\n     * @property {Number} startPageY\n     * The linked element's absolute X position at the time the drag was\n     * started\n     * @private\n     */\n    startPageY: 0,\n\n    /**\n     * @property {Object} groups\n     * The group defines a logical collection of DragDrop objects that are\n     * related.  Instances only get events when interacting with other\n     * DragDrop object in the same group.  This lets us define multiple\n     * groups using a single DragDrop subclass if we want.\n     *\n     * An object in the format {'group1':true, 'group2':true}\n     */\n    groups: null,\n\n    /**\n     * @property {Boolean} locked\n     * Individual drag/drop instances can be locked.  This will prevent\n     * onmousedown start drag.\n     * @private\n     */\n    locked: false,\n\n    /**\n     * Locks this instance\n     */\n    lock: function() {\n        this.locked = true;\n    },\n\n    /**\n     * @property {Boolean} moveOnly\n     * When set to true, other DD objects in cooperating DDGroups do not receive\n     * notification events when this DD object is dragged over them.\n     */\n    moveOnly: false,\n\n    /**\n     * Unlocks this instace\n     */\n    unlock: function() {\n        this.locked = false;\n    },\n\n    /**\n     * @property {Boolean} isTarget\n     * By default, all instances can be a drop target.  This can be disabled by\n     * setting isTarget to false.\n     */\n    isTarget: true,\n\n    /**\n     * @property {Number[]} padding\n     * The padding configured for this drag and drop object for calculating\n     * the drop zone intersection with this object.\n     * An array containing the 4 padding values: [top, right, bottom, left]\n     */\n    padding: null,\n\n    /**\n     * @property _domRef\n     * Cached reference to the linked element\n     * @private\n     */\n    _domRef: null,\n\n    /**\n     * @property __ygDragDrop\n     * Internal typeof flag\n     * @private\n     */\n    __ygDragDrop: true,\n\n    /**\n     * @property {Boolean} constrainX\n     * Set to true when horizontal contraints are applied\n     * @private\n     */\n    constrainX: false,\n\n    /**\n     * @property {Boolean} constrainY\n     * Set to true when vertical contraints are applied\n     * @private\n     */\n    constrainY: false,\n\n    /**\n     * @property {Number} minX\n     * The left constraint\n     * @private\n     */\n    minX: 0,\n\n    /**\n     * @property {Number} maxX\n     * The right constraint\n     * @private\n     */\n    maxX: 0,\n\n    /**\n     * @property {Number} minY\n     * The up constraint\n     * @private\n     */\n    minY: 0,\n\n    /**\n     * @property {Number} maxY\n     * The down constraint\n     * @private\n     */\n    maxY: 0,\n\n    /**\n     * @property {Boolean} maintainOffset\n     * Maintain offsets when we resetconstraints.  Set to true when you want\n     * the position of the element relative to its parent to stay the same\n     * when the page changes\n     */\n    maintainOffset: false,\n\n    /**\n     * @property {Number[]} xTicks\n     * Array of pixel locations the element will snap to if we specified a\n     * horizontal graduation/interval.  This array is generated automatically\n     * when you define a tick interval.\n     */\n    xTicks: null,\n\n    /**\n     * @property {Number[]} yTicks\n     * Array of pixel locations the element will snap to if we specified a\n     * vertical graduation/interval.  This array is generated automatically\n     * when you define a tick interval.\n     */\n    yTicks: null,\n\n    /**\n     * @property {Boolean} primaryButtonOnly\n     * By default the drag and drop instance will only respond to the primary\n     * button click (left button for a right-handed mouse).  Set to true to\n     * allow drag and drop to start with any mouse click that is propogated\n     * by the browser\n     */\n    primaryButtonOnly: true,\n\n    /**\n     * @property {Boolean} available\n     * The available property is false until the linked dom element is accessible.\n     */\n    available: false,\n\n    /**\n     * @property {Boolean} hasOuterHandles\n     * By default, drags can only be initiated if the mousedown occurs in the\n     * region the linked element is.  This is done in part to work around a\n     * bug in some browsers that mis-report the mousedown if the previous\n     * mouseup happened outside of the window.  This property is set to true\n     * if outer handles are defined. Defaults to false.\n     */\n    hasOuterHandles: false,\n\n    /**\n     * Code that executes immediately before the startDrag event\n     * @private\n     */\n    b4StartDrag: function(x, y) { },\n\n    /**\n     * Abstract method called after a drag/drop object is clicked\n     * and the drag or mousedown time thresholds have beeen met.\n     * @param {Number} X click location\n     * @param {Number} Y click location\n     */\n    startDrag: function(x, y) { /* override this */ },\n\n    /**\n     * Code that executes immediately before the onDrag event\n     * @private\n     */\n    b4Drag: function(e) { },\n\n    /**\n     * Abstract method called during the onMouseMove event while dragging an\n     * object.\n     * @param {Event} e the mousemove event\n     */\n    onDrag: function(e) { /* override this */ },\n\n    /**\n     * Abstract method called when this element fist begins hovering over\n     * another DragDrop obj\n     * @param {Event} e the mousemove event\n     * @param {String/Ext.dd.DragDrop[]} id In POINT mode, the element\n     * id this is hovering over.  In INTERSECT mode, an array of one or more\n     * dragdrop items being hovered over.\n     */\n    onDragEnter: function(e, id) { /* override this */ },\n\n    /**\n     * Code that executes immediately before the onDragOver event\n     * @private\n     */\n    b4DragOver: function(e) { },\n\n    /**\n     * Abstract method called when this element is hovering over another\n     * DragDrop obj\n     * @param {Event} e the mousemove event\n     * @param {String/Ext.dd.DragDrop[]} id In POINT mode, the element\n     * id this is hovering over.  In INTERSECT mode, an array of dd items\n     * being hovered over.\n     */\n    onDragOver: function(e, id) { /* override this */ },\n\n    /**\n     * Code that executes immediately before the onDragOut event\n     * @private\n     */\n    b4DragOut: function(e) { },\n\n    /**\n     * Abstract method called when we are no longer hovering over an element\n     * @param {Event} e the mousemove event\n     * @param {String/Ext.dd.DragDrop[]} id In POINT mode, the element\n     * id this was hovering over.  In INTERSECT mode, an array of dd items\n     * that the mouse is no longer over.\n     */\n    onDragOut: function(e, id) { /* override this */ },\n\n    /**\n     * Code that executes immediately before the onDragDrop event\n     * @private\n     */\n    b4DragDrop: function(e) { },\n\n    /**\n     * Abstract method called when this item is dropped on another DragDrop\n     * obj\n     * @param {Event} e the mouseup event\n     * @param {String/Ext.dd.DragDrop[]} id In POINT mode, the element\n     * id this was dropped on.  In INTERSECT mode, an array of dd items this\n     * was dropped on.\n     */\n    onDragDrop: function(e, id) { /* override this */ },\n\n    /**\n     * Abstract method called when this item is dropped on an area with no\n     * drop target\n     * @param {Event} e the mouseup event\n     */\n    onInvalidDrop: function(e) { /* override this */ },\n\n    /**\n     * Code that executes immediately before the endDrag event\n     * @private\n     */\n    b4EndDrag: function(e) { },\n\n    /**\n     * Called when we are done dragging the object\n     * @param {Event} e the mouseup event\n     */\n    endDrag: function(e) { /* override this */ },\n\n    /**\n     * Code executed immediately before the onMouseDown event\n     * @param {Event} e the mousedown event\n     * @private\n     */\n    b4MouseDown: function(e) {  },\n\n    /**\n     * Called when a drag/drop obj gets a mousedown\n     * @param {Event} e the mousedown event\n     */\n    onMouseDown: function(e) { /* override this */ },\n\n    /**\n     * Called when a drag/drop obj gets a mouseup\n     * @param {Event} e the mouseup event\n     */\n    onMouseUp: function(e) { /* override this */ },\n\n    /**\n     * Override the onAvailable method to do what is needed after the initial\n     * position was determined.\n     */\n    onAvailable: function () {\n    },\n\n    /**\n     * @property {Object} defaultPadding\n     * Provides default constraint padding to \"constrainTo\" elements.\n     */\n    defaultPadding: {\n        left: 0,\n        right: 0,\n        top: 0,\n        bottom: 0\n    },\n\n    /**\n     * Initializes the drag drop object's constraints to restrict movement to a certain element.\n     *\n     * Usage:\n     *\n     *     var dd = new Ext.dd.DDProxy(\"dragDiv1\", \"proxytest\",\n     *                    { dragElId: \"existingProxyDiv\" });\n     *     dd.startDrag = function(){\n     *         this.constrainTo(\"parent-id\");\n     *     };\n     *\n     * Or you can initalize it using the {@link Ext.Element} object:\n     *\n     *     Ext.get(\"dragDiv1\").initDDProxy(\"proxytest\", {dragElId: \"existingProxyDiv\"}, {\n     *         startDrag : function(){\n     *             this.constrainTo(\"parent-id\");\n     *         }\n     *     });\n     *\n     * @param {String/HTMLElement/Ext.Element} constrainTo The element or element ID to constrain to.\n     * @param {Object/Number} pad (optional) Pad provides a way to specify \"padding\" of the constraints,\n     * and can be either a number for symmetrical padding (4 would be equal to `{left:4, right:4, top:4, bottom:4}`) or\n     * an object containing the sides to pad. For example: `{right:10, bottom:10}`\n     * @param {Boolean} inContent (optional) Constrain the draggable in the content box of the element (inside padding and borders)\n     */\n    constrainTo : function(constrainTo, pad, inContent){\n        if(Ext.isNumber(pad)){\n            pad = {left: pad, right:pad, top:pad, bottom:pad};\n        }\n        pad = pad || this.defaultPadding;\n        var b = Ext.get(this.getEl()).getBox(),\n            ce = Ext.get(constrainTo),\n            s = ce.getScroll(),\n            c,\n            cd = ce.dom,\n            xy,\n            topSpace,\n            leftSpace;\n        if(cd == document.body){\n            c = { x: s.left, y: s.top, width: Ext.Element.getViewWidth(), height: Ext.Element.getViewHeight()};\n        }else{\n            xy = ce.getXY();\n            c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};\n        }\n\n        topSpace = b.y - c.y;\n        leftSpace = b.x - c.x;\n\n        this.resetConstraints();\n        this.setXConstraint(leftSpace - (pad.left||0), // left\n                c.width - leftSpace - b.width - (pad.right||0), //right\n        this.xTickSize\n        );\n        this.setYConstraint(topSpace - (pad.top||0), //top\n                c.height - topSpace - b.height - (pad.bottom||0), //bottom\n        this.yTickSize\n        );\n    },\n\n    /**\n     * Returns a reference to the linked element\n     * @return {HTMLElement} the html element\n     */\n    getEl: function() {\n        if (!this._domRef) {\n            this._domRef = Ext.getDom(this.id);\n        }\n\n        return this._domRef;\n    },\n\n    /**\n     * Returns a reference to the actual element to drag.  By default this is\n     * the same as the html element, but it can be assigned to another\n     * element. An example of this can be found in Ext.dd.DDProxy\n     * @return {HTMLElement} the html element\n     */\n    getDragEl: function() {\n        return Ext.getDom(this.dragElId);\n    },\n\n    /**\n     * Sets up the DragDrop object.  Must be called in the constructor of any\n     * Ext.dd.DragDrop subclass\n     * @param {String} id the id of the linked element\n     * @param {String} sGroup the group of related items\n     * @param {Object} config configuration attributes\n     */\n    init: function(id, sGroup, config) {\n        this.initTarget(id, sGroup, config);\n        Ext.EventManager.on(this.id, \"mousedown\", this.handleMouseDown, this);\n        // Ext.EventManager.on(this.id, \"selectstart\", Event.preventDefault);\n    },\n\n    /**\n     * Initializes Targeting functionality only... the object does not\n     * get a mousedown handler.\n     * @param {String} id the id of the linked element\n     * @param {String} sGroup the group of related items\n     * @param {Object} config configuration attributes\n     */\n    initTarget: function(id, sGroup, config) {\n        // configuration attributes\n        this.config = config || {};\n\n        // create a local reference to the drag and drop manager\n        this.DDMInstance = Ext.dd.DragDropManager;\n        // initialize the groups array\n        this.groups = {};\n\n        // assume that we have an element reference instead of an id if the\n        // parameter is not a string\n        if (typeof id !== \"string\") {\n            id = Ext.id(id);\n        }\n\n        // set the id\n        this.id = id;\n\n        // add to an interaction group\n        this.addToGroup((sGroup) ? sGroup : \"default\");\n\n        // We don't want to register this as the handle with the manager\n        // so we just set the id rather than calling the setter.\n        this.handleElId = id;\n\n        // the linked element is the element that gets dragged by default\n        this.setDragElId(id);\n\n        // by default, clicked anchors will not start drag operations.\n        this.invalidHandleTypes = { A: \"A\" };\n        this.invalidHandleIds = {};\n        this.invalidHandleClasses = [];\n\n        this.applyConfig();\n\n        this.handleOnAvailable();\n    },\n\n    /**\n     * Applies the configuration parameters that were passed into the constructor.\n     * This is supposed to happen at each level through the inheritance chain.  So\n     * a DDProxy implentation will execute apply config on DDProxy, DD, and\n     * DragDrop in order to get all of the parameters that are available in\n     * each object.\n     */\n    applyConfig: function() {\n\n        // configurable properties:\n        //    padding, isTarget, maintainOffset, primaryButtonOnly\n        this.padding           = this.config.padding || [0, 0, 0, 0];\n        this.isTarget          = (this.config.isTarget !== false);\n        this.maintainOffset    = (this.config.maintainOffset);\n        this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);\n\n    },\n\n    /**\n     * Executed when the linked element is available\n     * @private\n     */\n    handleOnAvailable: function() {\n        this.available = true;\n        this.resetConstraints();\n        this.onAvailable();\n    },\n\n    /**\n     * Configures the padding for the target zone in px.  Effectively expands\n     * (or reduces) the virtual object size for targeting calculations.\n     * Supports css-style shorthand; if only one parameter is passed, all sides\n     * will have that padding, and if only two are passed, the top and bottom\n     * will have the first param, the left and right the second.\n     * @param {Number} iTop    Top pad\n     * @param {Number} iRight  Right pad\n     * @param {Number} iBot    Bot pad\n     * @param {Number} iLeft   Left pad\n     */\n    setPadding: function(iTop, iRight, iBot, iLeft) {\n        // this.padding = [iLeft, iRight, iTop, iBot];\n        if (!iRight && 0 !== iRight) {\n            this.padding = [iTop, iTop, iTop, iTop];\n        } else if (!iBot && 0 !== iBot) {\n            this.padding = [iTop, iRight, iTop, iRight];\n        } else {\n            this.padding = [iTop, iRight, iBot, iLeft];\n        }\n    },\n\n    /**\n     * Stores the initial placement of the linked element.\n     * @param {Number} diffX   the X offset, default 0\n     * @param {Number} diffY   the Y offset, default 0\n     */\n    setInitPosition: function(diffX, diffY) {\n        var el = this.getEl(),\n            dx, dy, p;\n\n        if (!this.DDMInstance.verifyEl(el)) {\n            return;\n        }\n\n        dx = diffX || 0;\n        dy = diffY || 0;\n\n        p = Ext.Element.getXY( el );\n\n        this.initPageX = p[0] - dx;\n        this.initPageY = p[1] - dy;\n\n        this.lastPageX = p[0];\n        this.lastPageY = p[1];\n\n        this.setStartPosition(p);\n    },\n\n    /**\n     * Sets the start position of the element.  This is set when the obj\n     * is initialized, the reset when a drag is started.\n     * @param pos current position (from previous lookup)\n     * @private\n     */\n    setStartPosition: function(pos) {\n        var p = pos || Ext.Element.getXY( this.getEl() );\n        this.deltaSetXY = null;\n\n        this.startPageX = p[0];\n        this.startPageY = p[1];\n    },\n\n    /**\n     * Adds this instance to a group of related drag/drop objects.  All\n     * instances belong to at least one group, and can belong to as many\n     * groups as needed.\n     * @param {String} sGroup the name of the group\n     */\n    addToGroup: function(sGroup) {\n        this.groups[sGroup] = true;\n        this.DDMInstance.regDragDrop(this, sGroup);\n    },\n\n    /**\n     * Removes this instance from the supplied interaction group\n     * @param {String} sGroup  The group to drop\n     */\n    removeFromGroup: function(sGroup) {\n        if (this.groups[sGroup]) {\n            delete this.groups[sGroup];\n        }\n\n        this.DDMInstance.removeDDFromGroup(this, sGroup);\n    },\n\n    /**\n     * Allows you to specify that an element other than the linked element\n     * will be moved with the cursor during a drag\n     * @param {String} id the id of the element that will be used to initiate the drag\n     */\n    setDragElId: function(id) {\n        this.dragElId = id;\n    },\n\n    /**\n     * Allows you to specify a child of the linked element that should be\n     * used to initiate the drag operation.  An example of this would be if\n     * you have a content div with text and links.  Clicking anywhere in the\n     * content area would normally start the drag operation.  Use this method\n     * to specify that an element inside of the content div is the element\n     * that starts the drag operation.\n     * @param {String} id the id of the element that will be used to\n     * initiate the drag.\n     */\n    setHandleElId: function(id) {\n        if (typeof id !== \"string\") {\n            id = Ext.id(id);\n        }\n        this.handleElId = id;\n        this.DDMInstance.regHandle(this.id, id);\n    },\n\n    /**\n     * Allows you to set an element outside of the linked element as a drag\n     * handle\n     * @param {String} id the id of the element that will be used to initiate the drag\n     */\n    setOuterHandleElId: function(id) {\n        if (typeof id !== \"string\") {\n            id = Ext.id(id);\n        }\n        Ext.EventManager.on(id, \"mousedown\", this.handleMouseDown, this);\n        this.setHandleElId(id);\n\n        this.hasOuterHandles = true;\n    },\n\n    /**\n     * Removes all drag and drop hooks for this element\n     */\n    unreg: function() {\n        Ext.EventManager.un(this.id, \"mousedown\", this.handleMouseDown, this);\n        this._domRef = null;\n        this.DDMInstance._remove(this);\n    },\n\n    destroy : function(){\n        this.unreg();\n    },\n\n    /**\n     * Returns true if this instance is locked, or the drag drop mgr is locked\n     * (meaning that all drag/drop is disabled on the page.)\n     * @return {Boolean} true if this obj or all drag/drop is locked, else\n     * false\n     */\n    isLocked: function() {\n        return (this.DDMInstance.isLocked() || this.locked);\n    },\n\n    /**\n     * Called when this object is clicked\n     * @param {Event} e\n     * @param {Ext.dd.DragDrop} oDD the clicked dd object (this dd obj)\n     * @private\n     */\n    handleMouseDown: function(e, oDD){\n        if (this.primaryButtonOnly && e.button != 0) {\n            return;\n        }\n\n        if (this.isLocked()) {\n            return;\n        }\n\n        this.DDMInstance.refreshCache(this.groups);\n\n        if (this.hasOuterHandles || this.DDMInstance.isOverTarget(e.getPoint(), this) )  {\n            if (this.clickValidator(e)) {\n                // set the initial element position\n                this.setStartPosition();\n                this.b4MouseDown(e);\n                this.onMouseDown(e);\n\n                this.DDMInstance.handleMouseDown(e, this);\n\n                this.DDMInstance.stopEvent(e);\n            }\n        }\n    },\n\n    clickValidator: function(e) {\n        var target = e.getTarget();\n        return ( this.isValidHandleChild(target) &&\n                    (this.id == this.handleElId ||\n                        this.DDMInstance.handleWasClicked(target, this.id)) );\n    },\n\n    /**\n     * Allows you to specify a tag name that should not start a drag operation\n     * when clicked.  This is designed to facilitate embedding links within a\n     * drag handle that do something other than start the drag.\n     * @method addInvalidHandleType\n     * @param {String} tagName the type of element to exclude\n     */\n    addInvalidHandleType: function(tagName) {\n        var type = tagName.toUpperCase();\n        this.invalidHandleTypes[type] = type;\n    },\n\n    /**\n     * Lets you to specify an element id for a child of a drag handle\n     * that should not initiate a drag\n     * @method addInvalidHandleId\n     * @param {String} id the element id of the element you wish to ignore\n     */\n    addInvalidHandleId: function(id) {\n        if (typeof id !== \"string\") {\n            id = Ext.id(id);\n        }\n        this.invalidHandleIds[id] = id;\n    },\n\n    /**\n     * Lets you specify a css class of elements that will not initiate a drag\n     * @param {String} cssClass the class of the elements you wish to ignore\n     */\n    addInvalidHandleClass: function(cssClass) {\n        this.invalidHandleClasses.push(cssClass);\n    },\n\n    /**\n     * Unsets an excluded tag name set by addInvalidHandleType\n     * @param {String} tagName the type of element to unexclude\n     */\n    removeInvalidHandleType: function(tagName) {\n        var type = tagName.toUpperCase();\n        // this.invalidHandleTypes[type] = null;\n        delete this.invalidHandleTypes[type];\n    },\n\n    /**\n     * Unsets an invalid handle id\n     * @param {String} id the id of the element to re-enable\n     */\n    removeInvalidHandleId: function(id) {\n        if (typeof id !== \"string\") {\n            id = Ext.id(id);\n        }\n        delete this.invalidHandleIds[id];\n    },\n\n    /**\n     * Unsets an invalid css class\n     * @param {String} cssClass the class of the element(s) you wish to\n     * re-enable\n     */\n    removeInvalidHandleClass: function(cssClass) {\n        for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {\n            if (this.invalidHandleClasses[i] == cssClass) {\n                delete this.invalidHandleClasses[i];\n            }\n        }\n    },\n\n    /**\n     * Checks the tag exclusion list to see if this click should be ignored\n     * @param {HTMLElement} node the HTMLElement to evaluate\n     * @return {Boolean} true if this is a valid tag type, false if not\n     */\n    isValidHandleChild: function(node) {\n\n        var valid = true,\n            nodeName,\n            i, len;\n        // var n = (node.nodeName == \"#text\") ? node.parentNode : node;\n        try {\n            nodeName = node.nodeName.toUpperCase();\n        } catch(e) {\n            nodeName = node.nodeName;\n        }\n        valid = valid && !this.invalidHandleTypes[nodeName];\n        valid = valid && !this.invalidHandleIds[node.id];\n\n        for (i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {\n            valid = !Ext.fly(node).hasCls(this.invalidHandleClasses[i]);\n        }\n\n\n        return valid;\n\n    },\n\n    /**\n     * Creates the array of horizontal tick marks if an interval was specified\n     * in setXConstraint().\n     * @private\n     */\n    setXTicks: function(iStartX, iTickSize) {\n        this.xTicks = [];\n        this.xTickSize = iTickSize;\n\n        var tickMap = {},\n            i;\n\n        for (i = this.initPageX; i >= this.minX; i = i - iTickSize) {\n            if (!tickMap[i]) {\n                this.xTicks[this.xTicks.length] = i;\n                tickMap[i] = true;\n            }\n        }\n\n        for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {\n            if (!tickMap[i]) {\n                this.xTicks[this.xTicks.length] = i;\n                tickMap[i] = true;\n            }\n        }\n\n        Ext.Array.sort(this.xTicks, this.DDMInstance.numericSort);\n    },\n\n    /**\n     * Creates the array of vertical tick marks if an interval was specified in\n     * setYConstraint().\n     * @private\n     */\n    setYTicks: function(iStartY, iTickSize) {\n        this.yTicks = [];\n        this.yTickSize = iTickSize;\n\n        var tickMap = {},\n            i;\n\n        for (i = this.initPageY; i >= this.minY; i = i - iTickSize) {\n            if (!tickMap[i]) {\n                this.yTicks[this.yTicks.length] = i;\n                tickMap[i] = true;\n            }\n        }\n\n        for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {\n            if (!tickMap[i]) {\n                this.yTicks[this.yTicks.length] = i;\n                tickMap[i] = true;\n            }\n        }\n\n        Ext.Array.sort(this.yTicks, this.DDMInstance.numericSort);\n    },\n\n    /**\n     * By default, the element can be dragged any place on the screen.  Use\n     * this method to limit the horizontal travel of the element.  Pass in\n     * 0,0 for the parameters if you want to lock the drag to the y axis.\n     * @param {Number} iLeft the number of pixels the element can move to the left\n     * @param {Number} iRight the number of pixels the element can move to the\n     * right\n     * @param {Number} iTickSize (optional) parameter for specifying that the\n     * element should move iTickSize pixels at a time.\n     */\n    setXConstraint: function(iLeft, iRight, iTickSize) {\n        this.leftConstraint = iLeft;\n        this.rightConstraint = iRight;\n\n        this.minX = this.initPageX - iLeft;\n        this.maxX = this.initPageX + iRight;\n        if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }\n\n        this.constrainX = true;\n    },\n\n    /**\n     * Clears any constraints applied to this instance.  Also clears ticks\n     * since they can't exist independent of a constraint at this time.\n     */\n    clearConstraints: function() {\n        this.constrainX = false;\n        this.constrainY = false;\n        this.clearTicks();\n    },\n\n    /**\n     * Clears any tick interval defined for this instance\n     */\n    clearTicks: function() {\n        this.xTicks = null;\n        this.yTicks = null;\n        this.xTickSize = 0;\n        this.yTickSize = 0;\n    },\n\n    /**\n     * By default, the element can be dragged any place on the screen.  Set\n     * this to limit the vertical travel of the element.  Pass in 0,0 for the\n     * parameters if you want to lock the drag to the x axis.\n     * @param {Number} iUp the number of pixels the element can move up\n     * @param {Number} iDown the number of pixels the element can move down\n     * @param {Number} iTickSize (optional) parameter for specifying that the\n     * element should move iTickSize pixels at a time.\n     */\n    setYConstraint: function(iUp, iDown, iTickSize) {\n        this.topConstraint = iUp;\n        this.bottomConstraint = iDown;\n\n        this.minY = this.initPageY - iUp;\n        this.maxY = this.initPageY + iDown;\n        if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }\n\n        this.constrainY = true;\n\n    },\n\n    /**\n     * Must be called if you manually reposition a dd element.\n     * @param {Boolean} maintainOffset\n     */\n    resetConstraints: function() {\n        // Maintain offsets if necessary\n        if (this.initPageX || this.initPageX === 0) {\n            // figure out how much this thing has moved\n            var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0,\n                dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;\n\n            this.setInitPosition(dx, dy);\n\n        // This is the first time we have detected the element's position\n        } else {\n            this.setInitPosition();\n        }\n\n        if (this.constrainX) {\n            this.setXConstraint( this.leftConstraint,\n                                 this.rightConstraint,\n                                 this.xTickSize        );\n        }\n\n        if (this.constrainY) {\n            this.setYConstraint( this.topConstraint,\n                                 this.bottomConstraint,\n                                 this.yTickSize         );\n        }\n    },\n\n    /**\n     * Normally the drag element is moved pixel by pixel, but we can specify\n     * that it move a number of pixels at a time.  This method resolves the\n     * location when we have it set up like this.\n     * @param {Number} val where we want to place the object\n     * @param {Number[]} tickArray sorted array of valid points\n     * @return {Number} the closest tick\n     * @private\n     */\n    getTick: function(val, tickArray) {\n        if (!tickArray) {\n            // If tick interval is not defined, it is effectively 1 pixel,\n            // so we return the value passed to us.\n            return val;\n        } else if (tickArray[0] >= val) {\n            // The value is lower than the first tick, so we return the first\n            // tick.\n            return tickArray[0];\n        } else {\n            var i, len, next, diff1, diff2;\n            for (i=0, len=tickArray.length; i<len; ++i) {\n                next = i + 1;\n                if (tickArray[next] && tickArray[next] >= val) {\n                    diff1 = val - tickArray[i];\n                    diff2 = tickArray[next] - val;\n                    return (diff2 > diff1) ? tickArray[i] : tickArray[next];\n                }\n            }\n\n            // The value is larger than the last tick, so we return the last\n            // tick.\n            return tickArray[tickArray.length - 1];\n        }\n    },\n\n    /**\n     * toString method\n     * @return {String} string representation of the dd obj\n     */\n    toString: function() {\n        return (\"DragDrop \" + this.id);\n    }\n\n});\n\n/*\n * This is a derivative of the similarly named class in the YUI Library.\n * The original license:\n * Copyright (c) 2006, Yahoo! Inc. All rights reserved.\n * Code licensed under the BSD License:\n * http://developer.yahoo.net/yui/license.txt\n */\n\n\n/**\n * A DragDrop implementation where the linked element follows the\n * mouse cursor during a drag.\n */\nExt.define('Ext.dd.DD', {\n    extend: 'Ext.dd.DragDrop',\n    requires: ['Ext.dd.DragDropManager'],\n\n    /**\n     * Creates new DD instance.\n     * @param {String} id the id of the linked element\n     * @param {String} sGroup the group of related DragDrop items\n     * @param {Object} config an object containing configurable attributes.\n     * Valid properties for DD: scroll\n     */\n    constructor: function(id, sGroup, config) {\n        if (id) {\n            this.init(id, sGroup, config);\n        }\n    },\n\n    /**\n     * @property {Boolean} scroll\n     * When set to true, the utility automatically tries to scroll the browser\n     * window when a drag and drop element is dragged near the viewport boundary.\n     */\n    scroll: true,\n\n    /**\n     * Sets the pointer offset to the distance between the linked element's top\n     * left corner and the location the element was clicked.\n     * @param {Number} iPageX the X coordinate of the click\n     * @param {Number} iPageY the Y coordinate of the click\n     */\n    autoOffset: function(iPageX, iPageY) {\n        var x = iPageX - this.startPageX,\n            y = iPageY - this.startPageY;\n        this.setDelta(x, y);\n    },\n\n    /**\n     * Sets the pointer offset.  You can call this directly to force the\n     * offset to be in a particular location (e.g., pass in 0,0 to set it\n     * to the center of the object)\n     * @param {Number} iDeltaX the distance from the left\n     * @param {Number} iDeltaY the distance from the top\n     */\n    setDelta: function(iDeltaX, iDeltaY) {\n        this.deltaX = iDeltaX;\n        this.deltaY = iDeltaY;\n    },\n\n    /**\n     * Sets the drag element to the location of the mousedown or click event,\n     * maintaining the cursor location relative to the location on the element\n     * that was clicked.  Override this if you want to place the element in a\n     * location other than where the cursor is.\n     * @param {Number} iPageX the X coordinate of the mousedown or drag event\n     * @param {Number} iPageY the Y coordinate of the mousedown or drag event\n     */\n    setDragElPos: function(iPageX, iPageY) {\n        // the first time we do this, we are going to check to make sure\n        // the element has css positioning\n\n        var el = this.getDragEl();\n        this.alignElWithMouse(el, iPageX, iPageY);\n    },\n\n    /**\n     * Sets the element to the location of the mousedown or click event,\n     * maintaining the cursor location relative to the location on the element\n     * that was clicked.  Override this if you want to place the element in a\n     * location other than where the cursor is.\n     * @param {HTMLElement} el the element to move\n     * @param {Number} iPageX the X coordinate of the mousedown or drag event\n     * @param {Number} iPageY the Y coordinate of the mousedown or drag event\n     */\n    alignElWithMouse: function(el, iPageX, iPageY) {\n        var oCoord = this.getTargetCoord(iPageX, iPageY),\n            fly = el.dom ? el : Ext.fly(el, '_dd'),\n            elSize = fly.getSize(),\n            EL = Ext.Element,\n            vpSize,\n            aCoord,\n            newLeft,\n            newTop;\n\n        if (!this.deltaSetXY) {\n            vpSize = this.cachedViewportSize = { width: EL.getDocumentWidth(), height: EL.getDocumentHeight() };\n            aCoord = [\n                Math.max(0, Math.min(oCoord.x, vpSize.width - elSize.width)),\n                Math.max(0, Math.min(oCoord.y, vpSize.height - elSize.height))\n            ];\n            fly.setXY(aCoord);\n            newLeft = fly.getLocalX();\n            newTop  = fly.getLocalY();\n            this.deltaSetXY = [newLeft - oCoord.x, newTop - oCoord.y];\n        } else {\n            vpSize = this.cachedViewportSize;\n            fly.setLeftTop(\n                Math.max(0, Math.min(oCoord.x + this.deltaSetXY[0], vpSize.width - elSize.width)),\n                Math.max(0, Math.min(oCoord.y + this.deltaSetXY[1], vpSize.height - elSize.height))\n            );\n        }\n\n        this.cachePosition(oCoord.x, oCoord.y);\n        this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);\n        return oCoord;\n    },\n\n    /**\n     * Saves the most recent position so that we can reset the constraints and\n     * tick marks on-demand.  We need to know this so that we can calculate the\n     * number of pixels the element is offset from its original position.\n     *\n     * @param {Number} [iPageX] the current x position (this just makes it so we\n     * don't have to look it up again)\n     * @param {Number} [iPageY] the current y position (this just makes it so we\n     * don't have to look it up again)\n     */\n    cachePosition: function(iPageX, iPageY) {\n        if (iPageX) {\n            this.lastPageX = iPageX;\n            this.lastPageY = iPageY;\n        } else {\n            var aCoord = Ext.Element.getXY(this.getEl());\n            this.lastPageX = aCoord[0];\n            this.lastPageY = aCoord[1];\n        }\n    },\n\n    /**\n     * Auto-scroll the window if the dragged object has been moved beyond the\n     * visible window boundary.\n     * @param {Number} x the drag element's x position\n     * @param {Number} y the drag element's y position\n     * @param {Number} h the height of the drag element\n     * @param {Number} w the width of the drag element\n     * @private\n     */\n    autoScroll: function(x, y, h, w) {\n\n        if (this.scroll) {\n            // The client height\n            var clientH = Ext.Element.getViewHeight(),\n                // The client width\n                clientW = Ext.Element.getViewWidth(),\n                // The amt scrolled down\n                st = this.DDMInstance.getScrollTop(),\n                // The amt scrolled right\n                sl = this.DDMInstance.getScrollLeft(),\n                // Location of the bottom of the element\n                bot = h + y,\n                // Location of the right of the element\n                right = w + x,\n                // The distance from the cursor to the bottom of the visible area,\n                // adjusted so that we don't scroll if the cursor is beyond the\n                // element drag constraints\n                toBot = (clientH + st - y - this.deltaY),\n                // The distance from the cursor to the right of the visible area\n                toRight = (clientW + sl - x - this.deltaX),\n                // How close to the edge the cursor must be before we scroll\n                // var thresh = (document.all) ? 100 : 40;\n                thresh = 40,\n                // How many pixels to scroll per autoscroll op.  This helps to reduce\n                // clunky scrolling. IE is more sensitive about this ... it needs this\n                // value to be higher.\n                scrAmt = (document.all) ? 80 : 30;\n\n            // Scroll down if we are near the bottom of the visible page and the\n            // obj extends below the crease\n            if ( bot > clientH && toBot < thresh ) {\n                window.scrollTo(sl, st + scrAmt);\n            }\n\n            // Scroll up if the window is scrolled down and the top of the object\n            // goes above the top border\n            if ( y < st && st > 0 && y - st < thresh ) {\n                window.scrollTo(sl, st - scrAmt);\n            }\n\n            // Scroll right if the obj is beyond the right border and the cursor is\n            // near the border.\n            if ( right > clientW && toRight < thresh ) {\n                window.scrollTo(sl + scrAmt, st);\n            }\n\n            // Scroll left if the window has been scrolled to the right and the obj\n            // extends past the left border\n            if ( x < sl && sl > 0 && x - sl < thresh ) {\n                window.scrollTo(sl - scrAmt, st);\n            }\n        }\n    },\n\n    /**\n     * Finds the location the element should be placed if we want to move\n     * it to where the mouse location less the click offset would place us.\n     * @param {Number} iPageX the X coordinate of the click\n     * @param {Number} iPageY the Y coordinate of the click\n     * @return an object that contains the coordinates (Object.x and Object.y)\n     * @private\n     */\n    getTargetCoord: function(iPageX, iPageY) {\n        var x = iPageX - this.deltaX,\n            y = iPageY - this.deltaY;\n\n        if (this.constrainX) {\n            if (x < this.minX) {\n                x = this.minX;\n            }\n            if (x > this.maxX) {\n                x = this.maxX;\n            }\n        }\n\n        if (this.constrainY) {\n            if (y < this.minY) {\n                y = this.minY;\n            }\n            if (y > this.maxY) {\n                y = this.maxY;\n            }\n        }\n\n        x = this.getTick(x, this.xTicks);\n        y = this.getTick(y, this.yTicks);\n\n\n        return {x: x, y: y};\n    },\n\n    /**\n     * Sets up config options specific to this class. Overrides\n     * Ext.dd.DragDrop, but all versions of this method through the\n     * inheritance chain are called\n     */\n    applyConfig: function() {\n        this.callParent();\n        this.scroll = (this.config.scroll !== false);\n    },\n\n    /**\n     * Event that fires prior to the onMouseDown event.  Overrides\n     * Ext.dd.DragDrop.\n     */\n    b4MouseDown: function(e) {\n        // this.resetConstraints();\n        this.autoOffset(e.getPageX(), e.getPageY());\n    },\n\n    /**\n     * Event that fires prior to the onDrag event.  Overrides\n     * Ext.dd.DragDrop.\n     */\n    b4Drag: function(e) {\n        this.setDragElPos(e.getPageX(), e.getPageY());\n    },\n\n    toString: function() {\n        return (\"DD \" + this.id);\n    }\n\n    //////////////////////////////////////////////////////////////////////////\n    // Debugging ygDragDrop events that can be overridden\n    //////////////////////////////////////////////////////////////////////////\n    /*\n    startDrag: function(x, y) {\n    },\n\n    onDrag: function(e) {\n    },\n\n    onDragEnter: function(e, id) {\n    },\n\n    onDragOver: function(e, id) {\n    },\n\n    onDragOut: function(e, id) {\n    },\n\n    onDragDrop: function(e, id) {\n    },\n\n    endDrag: function(e) {\n    }\n\n    */\n\n});\n\n/*\n * This is a derivative of the similarly named class in the YUI Library.\n * The original license:\n * Copyright (c) 2006, Yahoo! Inc. All rights reserved.\n * Code licensed under the BSD License:\n * http://developer.yahoo.net/yui/license.txt\n */\n\n/**\n * A DragDrop implementation that inserts an empty, bordered div into\n * the document that follows the cursor during drag operations.  At the time of\n * the click, the frame div is resized to the dimensions of the linked html\n * element, and moved to the exact location of the linked element.\n *\n * References to the \"frame\" element refer to the single proxy element that\n * was created to be dragged in place of all DDProxy elements on the\n * page.\n */\nExt.define('Ext.dd.DDProxy', {\n    extend: 'Ext.dd.DD',\n\n    statics: {\n        /**\n         * The default drag frame div id\n         * @static\n         */\n        dragElId: \"ygddfdiv\"\n    },\n\n    /**\n     * Creates new DDProxy.\n     * @param {String} id the id of the linked html element\n     * @param {String} sGroup the group of related DragDrop objects\n     * @param {Object} config an object containing configurable attributes.\n     * Valid properties for DDProxy in addition to those in DragDrop:\n     * \n     * - resizeFrame\n     * - centerFrame\n     * - dragElId\n     */\n    constructor: function(id, sGroup, config) {\n        if (id) {\n            this.init(id, sGroup, config);\n            this.initFrame();\n        }\n    },\n\n    /**\n     * @property {Boolean} resizeFrame\n     * By default we resize the drag frame to be the same size as the element\n     * we want to drag (this is to get the frame effect).  We can turn it off\n     * if we want a different behavior.\n     */\n    resizeFrame: true,\n\n    /**\n     * @property {Boolean} centerFrame\n     * By default the frame is positioned exactly where the drag element is, so\n     * we use the cursor offset provided by Ext.dd.DD.  Another option that works only if\n     * you do not have constraints on the obj is to have the drag frame centered\n     * around the cursor.  Set centerFrame to true for this effect.\n     */\n    centerFrame: false,\n\n    /**\n     * Creates the proxy element if it does not yet exist\n     */\n    createFrame: function() {\n        var self = this,\n            body = document.body,\n            div,\n            s;\n\n        if (!body || !body.firstChild) {\n            setTimeout( function() { self.createFrame(); }, 50 );\n            return;\n        }\n\n        div = this.getDragEl();\n\n        if (!div) {\n            div    = document.createElement(\"div\");\n            div.id = this.dragElId;\n            s  = div.style;\n\n            s.position   = \"absolute\";\n            s.visibility = \"hidden\";\n            s.cursor     = \"move\";\n            s.border     = \"2px solid #aaa\";\n            s.zIndex     = 999;\n\n            // appendChild can blow up IE if invoked prior to the window load event\n            // while rendering a table.  It is possible there are other scenarios\n            // that would cause this to happen as well.\n            body.insertBefore(div, body.firstChild);\n        }\n    },\n\n    /**\n     * Initialization for the drag frame element.  Must be called in the\n     * constructor of all subclasses\n     */\n    initFrame: function() {\n        this.createFrame();\n    },\n\n    applyConfig: function() {\n        this.callParent();\n\n        this.resizeFrame = (this.config.resizeFrame !== false);\n        this.centerFrame = (this.config.centerFrame);\n        this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);\n    },\n\n    /**\n     * Resizes the drag frame to the dimensions of the clicked object, positions\n     * it over the object, and finally displays it\n     * @param {Number} iPageX X click position\n     * @param {Number} iPageY Y click position\n     * @private\n     */\n    showFrame: function(iPageX, iPageY) {\n        var el = this.getEl(),\n            dragEl = this.getDragEl(),\n            s = dragEl.style;\n\n        this._resizeProxy();\n\n        if (this.centerFrame) {\n            this.setDelta( Math.round(parseInt(s.width,  10)/2),\n                           Math.round(parseInt(s.height, 10)/2) );\n        }\n\n        this.setDragElPos(iPageX, iPageY);\n\n        Ext.fly(dragEl).show();\n    },\n\n    /**\n     * The proxy is automatically resized to the dimensions of the linked\n     * element when a drag is initiated, unless resizeFrame is set to false\n     * @private\n     */\n    _resizeProxy: function() {\n        if (this.resizeFrame) {\n            var el = this.getEl();\n            Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);\n        }\n    },\n\n    // overrides Ext.dd.DragDrop\n    b4MouseDown: function(e) {\n        var x = e.getPageX(),\n            y = e.getPageY();\n        this.autoOffset(x, y);\n        this.setDragElPos(x, y);\n    },\n\n    // overrides Ext.dd.DragDrop\n    b4StartDrag: function(x, y) {\n        // show the drag frame\n        this.showFrame(x, y);\n    },\n\n    // overrides Ext.dd.DragDrop\n    b4EndDrag: function(e) {\n        Ext.fly(this.getDragEl()).hide();\n    },\n\n    // overrides Ext.dd.DragDrop\n    // By default we try to move the element to the last location of the frame.\n    // This is so that the default behavior mirrors that of Ext.dd.DD.\n    endDrag: function(e) {\n\n        var lel = this.getEl(),\n            del = this.getDragEl();\n\n        // Show the drag frame briefly so we can get its position\n        del.style.visibility = \"\";\n\n        this.beforeMove();\n        // Hide the linked element before the move to get around a Safari\n        // rendering bug.\n        lel.style.visibility = \"hidden\";\n        Ext.dd.DDM.moveToEl(lel, del);\n        del.style.visibility = \"hidden\";\n        lel.style.visibility = \"\";\n\n        this.afterDrag();\n    },\n\n    beforeMove : function(){\n\n    },\n\n    afterDrag : function(){\n\n    },\n\n    toString: function() {\n        return (\"DDProxy \" + this.id);\n    }\n\n});\n\n/**\n * A specialized floating Component that supports a drop status icon, {@link Ext.Layer} styles\n * and auto-repair.  This is the default drag proxy used by all Ext.dd components.\n */\nExt.define('Ext.dd.StatusProxy', {\n    extend: 'Ext.Component',\n    animRepair: false,\n\n    childEls: [\n        'ghost'\n    ],\n\n    renderTpl: [\n        '<div class=\"' + Ext.baseCSSPrefix + 'dd-drop-icon\"></div>' +\n        '<div id=\"{id}-ghost\" class=\"' + Ext.baseCSSPrefix + 'dd-drag-ghost\"></div>'\n    ],\n\n    /**\n     * Creates new StatusProxy.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        var me = this;\n\n        config = config || {};\n\n        Ext.apply(me, {\n            hideMode: 'visibility',\n            hidden: true,\n            floating: true,\n            id: me.id || Ext.id(),\n            cls: Ext.baseCSSPrefix + 'dd-drag-proxy ' + this.dropNotAllowed,\n            shadow: config.shadow || false,\n            renderTo: Ext.getDetachedBody()\n        });\n        me.callParent(arguments);\n        this.dropStatus = this.dropNotAllowed;\n    },\n\n    /**\n     * @cfg {String} dropAllowed\n     * The CSS class to apply to the status element when drop is allowed.\n     */\n    dropAllowed : Ext.baseCSSPrefix + 'dd-drop-ok',\n\n    /**\n     * @cfg {String} dropNotAllowed\n     * The CSS class to apply to the status element when drop is not allowed.\n     */\n    dropNotAllowed : Ext.baseCSSPrefix + 'dd-drop-nodrop',\n\n    /**\n     * Updates the proxy's visual element to indicate the status of whether or not drop is allowed\n     * over the current target element.\n     * @param {String} cssClass The css class for the new drop status indicator image\n     */\n    setStatus : function(cssClass){\n        cssClass = cssClass || this.dropNotAllowed;\n        if (this.dropStatus != cssClass) {\n            this.el.replaceCls(this.dropStatus, cssClass);\n            this.dropStatus = cssClass;\n        }\n    },\n\n    /**\n     * Resets the status indicator to the default dropNotAllowed value\n     * @param {Boolean} clearGhost True to also remove all content from the ghost, false to preserve it\n     */\n    reset : function(clearGhost){\n        var me = this,\n            clsPrefix = Ext.baseCSSPrefix + 'dd-drag-proxy ';\n\n        me.el.replaceCls(clsPrefix + me.dropAllowed, clsPrefix + me.dropNotAllowed);\n        me.dropStatus = me.dropNotAllowed;\n        if (clearGhost) {\n            me.ghost.update('');\n        }\n    },\n\n    /**\n     * Updates the contents of the ghost element\n     * @param {String/HTMLElement} html The html that will replace the current innerHTML of the ghost element, or a\n     * DOM node to append as the child of the ghost element (in which case the innerHTML will be cleared first).\n     */\n    update : function(html){\n        if (typeof html == \"string\") {\n            this.ghost.update(html);\n        } else {\n            this.ghost.update(\"\");\n            html.style.margin = \"0\";\n            this.ghost.dom.appendChild(html);\n        }\n        var el = this.ghost.dom.firstChild;\n        if (el) {\n            Ext.fly(el).setStyle('float', 'none');\n        }\n    },\n\n    /**\n     * Returns the ghost element\n     * @return {Ext.Element} el\n     */\n    getGhost : function(){\n        return this.ghost;\n    },\n\n    /**\n     * Hides the proxy\n     * @param {Boolean} clear True to reset the status and clear the ghost contents,\n     * false to preserve them\n     */\n    hide : function(clear) {\n        this.callParent();\n        if (clear) {\n            this.reset(true);\n        }\n    },\n\n    /**\n     * Stops the repair animation if it's currently running\n     */\n    stop : function(){\n        if (this.anim && this.anim.isAnimated && this.anim.isAnimated()) {\n            this.anim.stop();\n        }\n    },\n\n    /**\n     * Force the Layer to sync its shadow and shim positions to the element\n     */\n    sync : function(){\n        this.el.sync();\n    },\n\n    /**\n     * Causes the proxy to return to its position of origin via an animation.\n     * Should be called after an invalid drop operation by the item being dragged.\n     * @param {Number[]} xy The XY position of the element ([x, y])\n     * @param {Function} callback The function to call after the repair is complete.\n     * @param {Object} scope The scope (`this` reference) in which the callback function is executed.\n     * Defaults to the browser window.\n     */\n    repair : function(xy, callback, scope) {\n        var me = this;\n\n        me.callback = callback;\n        me.scope = scope;\n        if (xy && me.animRepair !== false) {\n            me.el.addCls(Ext.baseCSSPrefix + 'dd-drag-repair');\n            me.el.hideUnders(true);\n            me.anim = me.el.animate({\n                duration: me.repairDuration || 500,\n                easing: 'ease-out',\n                to: {\n                    x: xy[0],\n                    y: xy[1]\n                },\n                stopAnimation: true,\n                callback: me.afterRepair,\n                scope: me\n            });\n        } else {\n            me.afterRepair();\n        }\n    },\n\n    // private\n    afterRepair : function() {\n        var me = this;\n    \n        me.hide(true);\n        me.el.removeCls(Ext.baseCSSPrefix + 'dd-drag-repair');\n        if (typeof me.callback == \"function\") {\n            me.callback.call(me.scope || me);\n        }\n        delete me.callback;\n        delete me.scope;\n    }\n});\n\n/**\n * A simple class that provides the basic implementation needed to make any element draggable.\n */\nExt.define('Ext.dd.DragSource', {\n    extend: 'Ext.dd.DDProxy',\n    requires: [\n        'Ext.dd.StatusProxy',\n        'Ext.dd.DragDropManager'\n    ],\n\n    /**\n     * @cfg {String} ddGroup\n     * A named drag drop group to which this object belongs.  If a group is specified, then this object will only\n     * interact with other drag drop objects in the same group.\n     */\n\n    /**\n     * @cfg {String} dropAllowed\n     * The CSS class returned to the drag source when drop is allowed.\n     */\n    dropAllowed : Ext.baseCSSPrefix + 'dd-drop-ok',\n    /**\n     * @cfg {String} dropNotAllowed\n     * The CSS class returned to the drag source when drop is not allowed.\n     */\n    dropNotAllowed : Ext.baseCSSPrefix + 'dd-drop-nodrop',\n\n    /**\n     * @cfg {Boolean} animRepair\n     * If true, animates the proxy element back to the position of the handle element used to trigger the drag.\n     */\n    animRepair: true,\n\n    /**\n     * @cfg {String} repairHighlightColor\n     * The color to use when visually highlighting the drag source in the afterRepair\n     * method after a failed drop (defaults to light blue). The color must be a 6 digit hex value, without\n     * a preceding '#'.\n     */\n    repairHighlightColor: 'c3daf9',\n\n    /**\n     * Creates new drag-source.\n     * @param {String/HTMLElement/Ext.Element} el The container element or ID of it.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(el, config) {\n        this.el = Ext.get(el);\n        if(!this.dragData){\n            this.dragData = {};\n        }\n\n        Ext.apply(this, config);\n\n        if(!this.proxy){\n            this.proxy = new Ext.dd.StatusProxy({\n                id: this.el.id + '-drag-status-proxy',\n                animRepair: this.animRepair\n            });\n        }\n        this.callParent([this.el.dom, this.ddGroup || this.group,\n              {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true}]);\n\n        this.dragging = false;\n    },\n\n    /**\n     * Returns the data object associated with this drag source\n     * @return {Object} data An object containing arbitrary data\n     */\n    getDragData : function(e){\n        return this.dragData;\n    },\n\n    // private\n    onDragEnter : function(e, id){\n        var target = Ext.dd.DragDropManager.getDDById(id),\n            status;\n        this.cachedTarget = target;\n        if (this.beforeDragEnter(target, e, id) !== false) {\n            if (target.isNotifyTarget) {\n                status = target.notifyEnter(this, e, this.dragData);\n                this.proxy.setStatus(status);\n            } else {\n                this.proxy.setStatus(this.dropAllowed);\n            }\n\n            if (this.afterDragEnter) {\n                /**\n                 * An empty function by default, but provided so that you can perform a custom action\n                 * when the dragged item enters the drop target by providing an implementation.\n                 * @param {Ext.dd.DragDrop} target The drop target\n                 * @param {Event} e The event object\n                 * @param {String} id The id of the dragged element\n                 * @method afterDragEnter\n                 */\n                this.afterDragEnter(target, e, id);\n            }\n        }\n    },\n\n    /**\n     * An empty function by default, but provided so that you can perform a custom action\n     * before the dragged item enters the drop target and optionally cancel the onDragEnter.\n     * @param {Ext.dd.DragDrop} target The drop target\n     * @param {Event} e The event object\n     * @param {String} id The id of the dragged element\n     * @return {Boolean} isValid True if the drag event is valid, else false to cancel\n     * @template\n     */\n    beforeDragEnter: function(target, e, id) {\n        return true;\n    },\n\n    // private\n    onDragOver: function(e, id) {\n        var target = this.cachedTarget || Ext.dd.DragDropManager.getDDById(id),\n            status;\n        if (this.beforeDragOver(target, e, id) !== false) {\n            if(target.isNotifyTarget){\n                status = target.notifyOver(this, e, this.dragData);\n                this.proxy.setStatus(status);\n            }\n\n            if (this.afterDragOver) {\n                /**\n                 * An empty function by default, but provided so that you can perform a custom action\n                 * while the dragged item is over the drop target by providing an implementation.\n                 * @param {Ext.dd.DragDrop} target The drop target\n                 * @param {Event} e The event object\n                 * @param {String} id The id of the dragged element\n                 * @method afterDragOver\n                 */\n                this.afterDragOver(target, e, id);\n            }\n        }\n    },\n\n    /**\n     * An empty function by default, but provided so that you can perform a custom action\n     * while the dragged item is over the drop target and optionally cancel the onDragOver.\n     * @param {Ext.dd.DragDrop} target The drop target\n     * @param {Event} e The event object\n     * @param {String} id The id of the dragged element\n     * @return {Boolean} isValid True if the drag event is valid, else false to cancel\n     * @template\n     */\n    beforeDragOver: function(target, e, id) {\n        return true;\n    },\n\n    // private\n    onDragOut: function(e, id) {\n        var target = this.cachedTarget || Ext.dd.DragDropManager.getDDById(id);\n        if (this.beforeDragOut(target, e, id) !== false) {\n            if (target.isNotifyTarget) {\n                target.notifyOut(this, e, this.dragData);\n            }\n            this.proxy.reset();\n            if (this.afterDragOut) {\n                /**\n                 * An empty function by default, but provided so that you can perform a custom action\n                 * after the dragged item is dragged out of the target without dropping.\n                 * @param {Ext.dd.DragDrop} target The drop target\n                 * @param {Event} e The event object\n                 * @param {String} id The id of the dragged element\n                 * @method afterDragOut\n                 */\n                this.afterDragOut(target, e, id);\n            }\n        }\n        this.cachedTarget = null;\n    },\n\n    /**\n     * An empty function by default, but provided so that you can perform a custom action before the dragged\n     * item is dragged out of the target without dropping, and optionally cancel the onDragOut.\n     * @param {Ext.dd.DragDrop} target The drop target\n     * @param {Event} e The event object\n     * @param {String} id The id of the dragged element\n     * @return {Boolean} isValid True if the drag event is valid, else false to cancel\n     * @template\n     */\n    beforeDragOut: function(target, e, id){\n        return true;\n    },\n\n    // private\n    onDragDrop: function(e, id){\n        var target = this.cachedTarget || Ext.dd.DragDropManager.getDDById(id);\n        if (this.beforeDragDrop(target, e, id) !== false) {\n            if (target.isNotifyTarget) {\n                if (target.notifyDrop(this, e, this.dragData) !== false) { // valid drop?\n                    this.onValidDrop(target, e, id);\n                } else {\n                    this.onInvalidDrop(target, e, id);\n                }\n            } else {\n                this.onValidDrop(target, e, id);\n            }\n\n            if (this.afterDragDrop) {\n                /**\n                 * An empty function by default, but provided so that you can perform a custom action\n                 * after a valid drag drop has occurred by providing an implementation.\n                 * @param {Ext.dd.DragDrop} target The drop target\n                 * @param {Event} e The event object\n                 * @param {String} id The id of the dropped element\n                 * @method afterDragDrop\n                 */\n                this.afterDragDrop(target, e, id);\n            }\n        }\n        delete this.cachedTarget;\n    },\n\n    /**\n     * An empty function by default, but provided so that you can perform a custom action before the dragged\n     * item is dropped onto the target and optionally cancel the onDragDrop.\n     * @param {Ext.dd.DragDrop} target The drop target\n     * @param {Event} e The event object\n     * @param {String} id The id of the dragged element\n     * @return {Boolean} isValid True if the drag drop event is valid, else false to cancel\n     * @template\n     */\n    beforeDragDrop: function(target, e, id){\n        return true;\n    },\n\n    // private\n    onValidDrop: function(target, e, id){\n        this.hideProxy();\n        if(this.afterValidDrop){\n            /**\n             * An empty function by default, but provided so that you can perform a custom action\n             * after a valid drop has occurred by providing an implementation.\n             * @param {Object} target The target DD\n             * @param {Event} e The event object\n             * @param {String} id The id of the dropped element\n             * @method afterValidDrop\n             */\n            this.afterValidDrop(target, e, id);\n        }\n    },\n\n    // private\n    getRepairXY: function(e, data){\n        return this.el.getXY();\n    },\n\n    // private\n    onInvalidDrop: function(target, e, id) {\n        // This method may be called by the DragDropManager.\n        // To preserve backwards compat, it only passes the event object\n        // Here we correct the arguments.\n        if (!e) {\n            e = target;\n            target = null;\n            id = e.getTarget().id;\n        }\n        this.beforeInvalidDrop(target, e, id);\n        if (this.cachedTarget) {\n            if(this.cachedTarget.isNotifyTarget){\n                this.cachedTarget.notifyOut(this, e, this.dragData);\n            }\n            this.cacheTarget = null;\n        }\n        this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);\n\n        if (this.afterInvalidDrop) {\n            /**\n             * An empty function by default, but provided so that you can perform a custom action\n             * after an invalid drop has occurred by providing an implementation.\n             * @param {Event} e The event object\n             * @param {String} id The id of the dropped element\n             * @method afterInvalidDrop\n             */\n            this.afterInvalidDrop(e, id);\n        }\n    },\n\n    // private\n    afterRepair: function() {\n        var me = this;\n        if (Ext.enableFx) {\n            me.el.highlight(me.repairHighlightColor);\n        }\n        me.dragging = false;\n    },\n\n    /**\n     * An empty function by default, but provided so that you can perform a custom action after an invalid\n     * drop has occurred.\n     * @param {Ext.dd.DragDrop} target The drop target\n     * @param {Event} e The event object\n     * @param {String} id The id of the dragged element\n     * @return {Boolean} isValid True if the invalid drop should proceed, else false to cancel\n     * @template\n     */\n    beforeInvalidDrop: function(target, e, id) {\n        return true;\n    },\n\n    // private\n    handleMouseDown: function(e) {\n        if (this.dragging) {\n            return;\n        }\n        var data = this.getDragData(e);\n        if (data && this.onBeforeDrag(data, e) !== false) {\n            this.dragData = data;\n            this.proxy.stop();\n            this.callParent(arguments);\n        }\n    },\n\n    /**\n     * An empty function by default, but provided so that you can perform a custom action before the initial\n     * drag event begins and optionally cancel it.\n     * @param {Object} data An object containing arbitrary data to be shared with drop targets\n     * @param {Event} e The event object\n     * @return {Boolean} isValid True if the drag event is valid, else false to cancel\n     * @template\n     */\n    onBeforeDrag: function(data, e){\n        return true;\n    },\n\n    /**\n     * An empty function by default, but provided so that you can perform a custom action once the initial\n     * drag event has begun.  The drag cannot be canceled from this function.\n     * @param {Number} x The x position of the click on the dragged object\n     * @param {Number} y The y position of the click on the dragged object\n     * @method\n     * @template\n     */\n    onStartDrag: Ext.emptyFn,\n\n    alignElWithMouse: function() {\n        this.proxy.ensureAttachedToBody(true);\n        return this.callParent(arguments);\n    },\n\n    // private override\n    startDrag: function(x, y) {\n        this.proxy.reset();\n        this.proxy.hidden = false;\n        this.dragging = true;\n        this.proxy.update(\"\");\n        this.onInitDrag(x, y);\n        this.proxy.show();\n    },\n\n    // private\n    onInitDrag: function(x, y) {\n        var clone = this.el.dom.cloneNode(true);\n        clone.id = Ext.id(); // prevent duplicate ids\n        this.proxy.update(clone);\n        this.onStartDrag(x, y);\n        return true;\n    },\n\n    /**\n     * Returns the drag source's underlying {@link Ext.dd.StatusProxy}\n     * @return {Ext.dd.StatusProxy} proxy The StatusProxy\n     */\n    getProxy: function() {\n        return this.proxy;\n    },\n\n    /**\n     * Hides the drag source's {@link Ext.dd.StatusProxy}\n     */\n    hideProxy: function() {\n        this.proxy.hide();\n        this.proxy.reset(true);\n        this.dragging = false;\n    },\n\n    // private\n    triggerCacheRefresh: function() {\n        Ext.dd.DDM.refreshCache(this.groups);\n    },\n\n    // private - override to prevent hiding\n    b4EndDrag: function(e) {\n    },\n\n    // private - override to prevent moving\n    endDrag : function(e){\n        this.onEndDrag(this.dragData, e);\n    },\n\n    // private\n    onEndDrag : function(data, e){\n    },\n\n    // private - pin to cursor\n    autoOffset : function(x, y) {\n        this.setDelta(-12, -20);\n    },\n\n    destroy: function(){\n        this.callParent();\n        Ext.destroy(this.proxy);\n    }\n});\n\n/**\n * A custom drag proxy implementation specific to {@link Ext.panel.Panel}s. This class\n * is primarily used internally for the Panel's drag drop implementation, and\n * should never need to be created directly.\n * @private\n */\nExt.define('Ext.panel.Proxy', {\n\n    alternateClassName: 'Ext.dd.PanelProxy',\n    \n    /**\n     * @cfg {Boolean} [moveOnDrag=true]\n     * True to move the panel to the dragged position when dropped\n     */\n    moveOnDrag: true,\n\n    /**\n     * Creates new panel proxy.\n     * @param {Ext.panel.Panel} panel The {@link Ext.panel.Panel} to proxy for\n     * @param {Object} [config] Config object\n     */\n    constructor: function(panel, config){\n        var me = this;\n        \n        /**\n         * @property panel\n         * @type Ext.panel.Panel\n         */\n        me.panel = panel;\n        me.id = me.panel.id +'-ddproxy';\n        Ext.apply(me, config);\n    },\n\n    /**\n     * @cfg {Boolean} insertProxy\n     * True to insert a placeholder proxy element while dragging the panel, false to drag with no proxy.\n     * Most Panels are not absolute positioned and therefore we need to reserve this space.\n     */\n    insertProxy: true,\n\n    // private overrides\n    setStatus: Ext.emptyFn,\n    reset: Ext.emptyFn,\n    update: Ext.emptyFn,\n    stop: Ext.emptyFn,\n    sync: Ext.emptyFn,\n\n    /**\n     * Gets the proxy's element\n     * @return {Ext.Element} The proxy's element\n     */\n    getEl: function(){\n        return this.ghost.el;\n    },\n\n    /**\n     * Gets the proxy's ghost Panel\n     * @return {Ext.panel.Panel} The proxy's ghost Panel\n     */\n    getGhost: function(){\n        return this.ghost;\n    },\n\n    /**\n     * Gets the proxy element. This is the element that represents where the\n     * Panel was before we started the drag operation.\n     * @return {Ext.Element} The proxy's element\n     */\n    getProxy: function(){\n        return this.proxy;\n    },\n\n    /**\n     * Hides the proxy\n     */\n    hide : function(){\n        var me = this;\n        \n        if (me.ghost) {\n            if (me.proxy) {\n                me.proxy.remove();\n                delete me.proxy;\n            }\n\n            // Unghost the Panel, do not move the Panel to where the ghost was\n            me.panel.unghost(null, me.moveOnDrag);\n            delete me.ghost;\n        }\n    },\n\n    /**\n     * Shows the proxy\n     */\n    show: function(){\n        var me = this,\n            panelSize;\n            \n        if (!me.ghost) {\n            panelSize = me.panel.getSize();\n            me.panel.el.setVisibilityMode(Ext.Element.DISPLAY);\n            me.ghost = me.panel.ghost();\n            if (me.insertProxy) {\n                // bc Panels aren't absolute positioned we need to take up the space\n                // of where the panel previously was\n                me.proxy = me.panel.el.insertSibling({cls: Ext.baseCSSPrefix + 'panel-dd-spacer'});\n                me.proxy.setSize(panelSize);\n            }\n        }\n    },\n\n    // private\n    repair: function(xy, callback, scope) {\n        this.hide();\n        Ext.callback(callback, scope || this);\n    },\n\n    /**\n     * Moves the proxy to a different position in the DOM.  This is typically\n     * called while dragging the Panel to keep the proxy sync'd to the Panel's\n     * location.\n     * @param {HTMLElement} parentNode The proxy's parent DOM node\n     * @param {HTMLElement} [before] The sibling node before which the\n     * proxy should be inserted. Defaults to the parent's last child if not\n     * specified.\n     */\n    moveProxy : function(parentNode, before){\n        if (this.proxy) {\n            parentNode.insertBefore(this.proxy.dom, before);\n        }\n    }\n});\n\n/**\n * DD implementation for Panels.\n * @private\n */\nExt.define('Ext.panel.DD', {\n    extend: 'Ext.dd.DragSource',\n    requires: ['Ext.panel.Proxy'],\n\n    constructor : function(panel, cfg){\n        var me = this;\n        \n        me.panel = panel;\n        me.dragData = {panel: panel};\n        me.panelProxy = new Ext.panel.Proxy(panel, cfg);\n        me.proxy = me.panelProxy.proxy;\n\n        me.callParent([panel.el, cfg]);\n        me.setupEl(panel);\n    },\n    \n    setupEl: function(panel){\n        var me = this,\n            header = panel.header,\n            el = panel.body;\n            \n        if (header) {\n            me.setHandleElId(header.id);\n            el = header.el;\n        }\n        if (el) {\n            el.setStyle('cursor', 'move');\n            me.scroll = false;\n        } else {\n            // boxready fires after first layout, so we'll definitely be rendered\n            panel.on('boxready', me.setupEl, me, {single: true});\n        }\n    },\n\n    showFrame: Ext.emptyFn,\n    startDrag: Ext.emptyFn,\n    \n    b4StartDrag: function(x, y) {\n        this.panelProxy.show();\n    },\n    \n    b4MouseDown: function(e) {\n        var x = e.getPageX(),\n            y = e.getPageY();\n            \n        this.autoOffset(x, y);\n    },\n    \n    onInitDrag : function(x, y){\n        this.onStartDrag(x, y);\n        return true;\n    },\n    \n    createFrame : Ext.emptyFn,\n    \n    getDragEl : function(e){\n        return this.panelProxy.ghost.el.dom;\n    },\n    \n    endDrag : function(e){\n        this.panelProxy.hide();\n        this.panel.saveState();\n    },\n\n    autoOffset : function(x, y) {\n        x -= this.startPageX;\n        y -= this.startPageY;\n        this.setDelta(x, y);\n    },\n    \n    // Override this, we don't want to repair on an \"invalid\" drop, the panel\n    // should main it's position\n    onInvalidDrop: function(target, e, id) {\n        var me = this;\n        \n        me.beforeInvalidDrop(target, e, id);\n        if (me.cachedTarget) {\n            if(me.cachedTarget.isNotifyTarget){\n                me.cachedTarget.notifyOut(me, e, me.dragData);\n            }\n            me.cacheTarget = null;\n        }\n\n        if (me.afterInvalidDrop) {\n            /**\n             * An empty function by default, but provided so that you can perform a custom action\n             * after an invalid drop has occurred by providing an implementation.\n             * @param {Event} e The event object\n             * @param {String} id The id of the dropped element\n             * @method afterInvalidDrop\n             */\n            me.afterInvalidDrop(e, id);\n        }\n    }\n});\n\n/**\n * @class Ext.util.Memento\n * This class manages a set of captured properties from an object. These captured properties\n * can later be restored to an object.\n */\nExt.define('Ext.util.Memento', (function () {\n\n    function captureOne (src, target, prop, prefix) {\n        src[prefix ? prefix + prop : prop] = target[prop];\n    }\n\n    function removeOne (src, target, prop) {\n        delete src[prop];\n    }\n\n    function restoreOne (src, target, prop, prefix) {\n        var name = prefix ? prefix + prop : prop,\n            value = src[name];\n\n        if (value || src.hasOwnProperty(name)) {\n            restoreValue(target, prop, value);\n        }\n    }\n\n    function restoreValue (target, prop, value) {\n        if (Ext.isDefined(value)) {\n            target[prop] = value;\n        } else {\n            delete target[prop];\n        }\n    }\n\n    function doMany (doOne, src, target, props, prefix) {\n        if (src) {\n            if (Ext.isArray(props)) {\n                var p, pLen = props.length;\n                for (p = 0; p < pLen; p++) {\n                    doOne(src, target, props[p], prefix);\n                }\n            } else {\n                doOne(src, target, props, prefix);\n            }\n        }\n    }\n\n    return {\n        /**\n         * @property data\n         * The collection of captured properties.\n         * @private\n         */\n        data: null,\n\n        /**\n         * @property target\n         * The default target object for capture/restore (passed to the constructor).\n         */\n        target: null,\n\n        /**\n         * Creates a new memento and optionally captures properties from the target object.\n         * @param {Object} target The target from which to capture properties. If specified in the\n         * constructor, this target becomes the default target for all other operations.\n         * @param {String/String[]} props The property or array of properties to capture.\n         */\n        constructor: function (target, props) {\n            if (target) {\n                this.target = target;\n                if (props) {\n                    this.capture(props);\n                }\n            }\n        },\n\n        /**\n         * Captures the specified properties from the target object in this memento.\n         * @param {String/String[]} props The property or array of properties to capture.\n         * @param {Object} target The object from which to capture properties.\n         */\n        capture: function (props, target, prefix) {\n            var me = this;\n            doMany(captureOne, me.data || (me.data = {}), target || me.target, props, prefix);\n        },\n\n        /**\n         * Removes the specified properties from this memento. These properties will not be\n         * restored later without re-capturing their values.\n         * @param {String/String[]} props The property or array of properties to remove.\n         */\n        remove: function (props) {\n            doMany(removeOne, this.data, null, props);\n        },\n\n        /**\n         * Restores the specified properties from this memento to the target object.\n         * @param {String/String[]} props The property or array of properties to restore.\n         * @param {Boolean} clear True to remove the restored properties from this memento or\n         * false to keep them (default is true).\n         * @param {Object} target The object to which to restore properties.\n         */\n        restore: function (props, clear, target, prefix) {\n            doMany(restoreOne, this.data, target || this.target, props, prefix);\n            if (clear !== false) {\n                this.remove(props);\n            }\n        },\n\n        /**\n         * Restores all captured properties in this memento to the target object.\n         * @param {Boolean} clear True to remove the restored properties from this memento or\n         * false to keep them (default is true).\n         * @param {Object} target The object to which to restore properties.\n         */\n        restoreAll: function (clear, target) {\n            var me   = this,\n                t    = target || this.target,\n                data = me.data,\n                prop;\n\n            for (prop in data) {\n                if (data.hasOwnProperty(prop)) {\n                    restoreValue(t, prop, data[prop]);\n                }\n            }\n\n            if (clear !== false) {\n                delete me.data;\n            }\n        }\n    };\n}()));\n\n/**\n * Panel is a container that has specific functionality and structural components that make it the perfect building\n * block for application-oriented user interfaces.\n *\n * Panels are, by virtue of their inheritance from {@link Ext.container.Container}, capable of being configured with a\n * {@link Ext.container.Container#layout layout}, and containing child Components.\n *\n * When either specifying child {@link #cfg-items} of a Panel, or dynamically {@link Ext.container.Container#method-add adding}\n * Components to a Panel, remember to consider how you wish the Panel to arrange those child elements, and whether those\n * child elements need to be sized using one of Ext's built-in `{@link Ext.container.Container#layout layout}`\n * schemes. By default, Panels use the {@link Ext.layout.container.Auto Auto} scheme. This simply renders child\n * components, appending them one after the other inside the Container, and **does not apply any sizing** at all.\n *\n * {@img Ext.panel.Panel/panel.png Panel components}\n *\n * A Panel may also contain {@link #bbar bottom} and {@link #tbar top} toolbars, along with separate {@link\n * Ext.panel.Header header}, {@link #fbar footer} and body sections.\n *\n * Panel also provides built-in {@link #collapsible collapsible, expandable} and {@link #closable} behavior. Panels can\n * be easily dropped into any {@link Ext.container.Container Container} or layout, and the layout and rendering pipeline\n * is {@link Ext.container.Container#method-add completely managed by the framework}.\n *\n * **Note:** By default, the `{@link #closable close}` header tool _destroys_ the Panel resulting in removal of the\n * Panel and the destruction of any descendant Components. This makes the Panel object, and all its descendants\n * **unusable**. To enable the close tool to simply _hide_ a Panel for later re-use, configure the Panel with\n * `{@link #closeAction closeAction}: 'hide'`.\n *\n * Usually, Panels are used as constituents within an application, in which case, they would be used as child items of\n * Containers, and would themselves use Ext.Components as child {@link #cfg-items}. However to illustrate simply rendering a\n * Panel into the document, here's how to do it:\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Hello',\n *         width: 200,\n *         html: '<p>World!</p>',\n *         renderTo: Ext.getBody()\n *     });\n *\n * A more realistic scenario is a Panel created to house input fields which will not be rendered, but used as a\n * constituent part of a Container:\n *\n *     @example\n *     var filterPanel = Ext.create('Ext.panel.Panel', {\n *         bodyPadding: 5,  // Don't want content to crunch against the borders\n *         width: 300,\n *         title: 'Filters',\n *         items: [{\n *             xtype: 'datefield',\n *             fieldLabel: 'Start date'\n *         }, {\n *             xtype: 'datefield',\n *             fieldLabel: 'End date'\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n *\n * Note that the Panel above is configured to render into the document and assigned a size. In a real world scenario,\n * the Panel will often be added inside a Container which will use a {@link #layout} to render, size and position its\n * child Components.\n *\n * Panels will often use specific {@link #layout}s to provide an application with shape and structure by containing and\n * arranging child Components:\n *\n *     @example\n *     var resultsPanel = Ext.create('Ext.panel.Panel', {\n *         title: 'Results',\n *         width: 600,\n *         height: 400,\n *         renderTo: Ext.getBody(),\n *         layout: {\n *             type: 'vbox',       // Arrange child items vertically\n *             align: 'stretch',    // Each takes up full width\n *             padding: 5\n *         },\n *         items: [{               // Results grid specified as a config object with an xtype of 'grid'\n *             xtype: 'grid',\n *             columns: [{header: 'Column One'}],            // One header just for show. There's no data,\n *             store: Ext.create('Ext.data.ArrayStore', {}), // A dummy empty data store\n *             flex: 1                                       // Use 1/3 of Container's height (hint to Box layout)\n *         }, {\n *             xtype: 'splitter'   // A splitter between the two child items\n *         }, {                    // Details Panel specified as a config object (no xtype defaults to 'panel').\n *             title: 'Details',\n *             bodyPadding: 5,\n *             items: [{\n *                 fieldLabel: 'Data item',\n *                 xtype: 'textfield'\n *             }], // An array of form fields\n *             flex: 2             // Use 2/3 of Container's height (hint to Box layout)\n *         }]\n *     });\n *\n * The example illustrates one possible method of displaying search results. The Panel contains a grid with the\n * resulting data arranged in rows. Each selected row may be displayed in detail in the Panel below. The {@link\n * Ext.layout.container.VBox vbox} layout is used to arrange the two vertically. It is configured to stretch child items\n * horizontally to full width. Child items may either be configured with a numeric height, or with a `flex` value to\n * distribute available space proportionately.\n *\n * This Panel itself may be a child item of, for exaple, a {@link Ext.tab.Panel} which will size its child items to fit\n * within its content area.\n *\n * Using these techniques, as long as the **layout** is chosen and configured correctly, an application may have any\n * level of nested containment, all dynamically sized according to configuration, the user's preference and available\n * browser size.\n */\nExt.define('Ext.panel.Panel', {\n    extend: 'Ext.panel.AbstractPanel',\n    requires: [\n        'Ext.panel.Header',\n        'Ext.fx.Anim',\n        'Ext.util.KeyMap',\n        'Ext.panel.DD',\n        'Ext.XTemplate',\n        'Ext.layout.component.Dock',\n        'Ext.util.Memento'\n    ],\n    alias: 'widget.panel',\n    alternateClassName: 'Ext.Panel',\n\n    /**\n     * @cfg {String} collapsedCls\n     * A CSS class to add to the panel's element after it has been collapsed.\n     */\n    collapsedCls: 'collapsed',\n\n    /**\n     * @cfg {Boolean} animCollapse\n     * `true` to animate the transition when the panel is collapsed, `false` to skip the animation (defaults to `true`\n     * if the {@link Ext.fx.Anim} class is available, otherwise `false`). May also be specified as the animation\n     * duration in milliseconds.\n     */\n    animCollapse: Ext.enableFx,\n\n    /**\n     * @cfg {Number} minButtonWidth\n     * Minimum width of all footer toolbar buttons in pixels. If set, this will be used as the default\n     * value for the {@link Ext.button.Button#minWidth} config of each Button added to the **footer toolbar** via the\n     * {@link #fbar} or {@link #buttons} configurations. It will be ignored for buttons that have a minWidth configured\n     * some other way, e.g. in their own config object or via the {@link Ext.container.Container#defaults defaults} of\n     * their parent container.\n     */\n    minButtonWidth: 75,\n\n    /**\n     * @cfg {Boolean} collapsed\n     * `true` to render the panel collapsed, `false` to render it expanded.\n     */\n    collapsed: false,\n\n    /**\n     * @cfg {Boolean} collapseFirst\n     * `true` to make sure the collapse/expand toggle button always renders first (to the left of) any other tools in\n     * the panel's title bar, `false` to render it last.\n     */\n    collapseFirst: true,\n\n    /**\n     * @cfg {Boolean} hideCollapseTool\n     * `true` to hide the expand/collapse toggle button when `{@link #collapsible} == true`, `false` to display it.\n     */\n    hideCollapseTool: false,\n\n    /**\n     * @cfg {Boolean} titleCollapse\n     * `true` to allow expanding and collapsing the panel (when `{@link #collapsible} = true`) by clicking anywhere in\n     * the header bar, `false`) to allow it only by clicking to tool button).\n     */\n    titleCollapse: false,\n\n    /**\n     * @cfg {String} collapseMode\n     * **Important: this config is only effective for {@link #collapsible} Panels which are direct child items of a\n     * {@link Ext.layout.container.Border border layout}.**\n     *\n     * When _not_ a direct child item of a {@link Ext.layout.container.Border border layout}, then the Panel's header\n     * remains visible, and the body is collapsed to zero dimensions. If the Panel has no header, then a new header\n     * (orientated correctly depending on the {@link #collapseDirection}) will be inserted to show a the title and a re-\n     * expand tool.\n     *\n     * When a child item of a {@link Ext.layout.container.Border border layout}, this config has three possible values:\n     *\n     * - `undefined` - When collapsed, a placeholder {@link Ext.panel.Header Header} is injected into the layout to\n     *   represent the Panel and to provide a UI with a Tool to allow the user to re-expand the Panel.\n     *\n     * - `\"header\"` - The Panel collapses to leave its header visible as when not inside a\n     *   {@link Ext.layout.container.Border border layout}.\n     *\n     * - `\"mini\"` - The Panel collapses without a visible header.\n     */\n\n    /**\n     * @cfg {Ext.Component/Object} placeholder\n     * **Important: This config is only effective for {@link #collapsible} Panels which are direct child items of a\n     * {@link Ext.layout.container.Border border layout} when not using the `'header'` {@link #collapseMode}.**\n     *\n     * **Optional.** A Component (or config object for a Component) to show in place of this Panel when this Panel is\n     * collapsed by a {@link Ext.layout.container.Border border layout}. Defaults to a generated {@link Ext.panel.Header\n     * Header} containing a {@link Ext.panel.Tool Tool} to re-expand the Panel.\n     */\n\n    /**\n     * @cfg {Boolean} floatable\n     * **Important: This config is only effective for {@link #collapsible} Panels which are direct child items of a\n     * {@link Ext.layout.container.Border border layout}.**\n     *\n     * true to allow clicking a collapsed Panel's {@link #placeholder} to display the Panel floated above the layout,\n     * false to force the user to fully expand a collapsed region by clicking the expand button to see it again.\n     */\n    floatable: true,\n\n    /**\n     * @cfg {Boolean} overlapHeader\n     * True to overlap the header in a panel over the framing of the panel itself. This is needed when frame:true (and\n     * is done automatically for you). Otherwise it is undefined. If you manually add rounded corners to a panel header\n     * which does not have frame:true, this will need to be set to true.\n     */\n\n    /**\n     * @cfg {Boolean} collapsible\n     * True to make the panel collapsible and have an expand/collapse toggle Tool added into the header tool button\n     * area. False to keep the panel sized either statically, or by an owning layout manager, with no toggle Tool.\n     *\n     * See {@link #collapseMode} and {@link #collapseDirection}\n     */\n    collapsible: false,\n\n    /**\n     * @cfg {String} collapseDirection\n     * The direction to collapse the Panel when the toggle button is clicked.\n     *\n     * Defaults to the {@link #headerPosition}\n     *\n     * **Important: This config is _ignored_ for {@link #collapsible} Panels which are direct child items of a {@link\n     * Ext.layout.container.Border border layout}.**\n     *\n     * Specify as `'top'`, `'bottom'`, `'left'` or `'right'`.\n     */\n\n    /**\n     * @cfg {Boolean} closable\n     * True to display the 'close' tool button and allow the user to close the window, false to hide the button and\n     * disallow closing the window.\n     *\n     * By default, when close is requested by clicking the close button in the header, the {@link #method-close} method will be\n     * called. This will _{@link Ext.Component#method-destroy destroy}_ the Panel and its content meaning that it may not be\n     * reused.\n     *\n     * To make closing a Panel _hide_ the Panel so that it may be reused, set {@link #closeAction} to 'hide'.\n     */\n    closable: false,\n\n    /**\n     * @cfg {String} closeAction\n     * The action to take when the close header tool is clicked:\n     *\n     * - **`'{@link #method-destroy}'`** :\n     *\n     *   {@link #method-remove remove} the window from the DOM and {@link Ext.Component#method-destroy destroy} it and all descendant\n     *   Components. The window will **not** be available to be redisplayed via the {@link #method-show} method.\n     *\n     * - **`'{@link #method-hide}'`** :\n     *\n     *   {@link #method-hide} the window by setting visibility to hidden and applying negative offsets. The window will be\n     *   available to be redisplayed via the {@link #method-show} method.\n     *\n     * **Note:** This behavior has changed! setting *does* affect the {@link #method-close} method which will invoke the\n     * approriate closeAction.\n     */\n    closeAction: 'destroy',\n\n    /**\n     * @cfg {Object/Object[]} dockedItems\n     * A component or series of components to be added as docked items to this panel. The docked items can be docked to\n     * either the top, right, left or bottom of a panel. This is typically used for things like toolbars or tab bars:\n     *\n     *     var panel = new Ext.panel.Panel({\n     *         dockedItems: [{\n     *             xtype: 'toolbar',\n     *             dock: 'top',\n     *             items: [{\n     *                 text: 'Docked to the top'\n     *             }]\n     *         }]\n     *     });\n     */\n\n    /**\n     * @cfg {Number} placeholderCollapseHideMode\n     * The {@link Ext.dom.Element#setVisibilityMode mode} for hiding collapsed panels when\n     * using {@link #collapseMode} \"placeholder\".\n     */\n    placeholderCollapseHideMode: Ext.Element.VISIBILITY,\n\n    /**\n     * @cfg {Boolean} preventHeader\n     * @deprecated 4.1.0 Use {@link #header} instead.\n     * Prevent a Header from being created and shown.\n     */\n     preventHeader: false,\n\n    /**\n     * @cfg {Boolean/Object} header\n     * Pass as `false` to prevent a Header from being created and shown.\n     *\n     * Pass as a config object (optionally containing an `xtype`) to custom-configure this Panel's header.\n     *\n     */\n    header: undefined,\n\n    /**\n     * @cfg {String} headerPosition\n     * Specify as `'top'`, `'bottom'`, `'left'` or `'right'`.\n     */\n    headerPosition: 'top',\n\n    /**\n     * @cfg {Boolean} frame\n     * True to apply a frame to the panel.\n     */\n    frame: false,\n\n    /**\n     * @cfg {Boolean} frameHeader\n     * True to apply a frame to the panel panels header (if 'frame' is true).\n     */\n    frameHeader: true,\n\n    /**\n     * @cfg {Object[]/Ext.panel.Tool[]} tools\n     * An array of {@link Ext.panel.Tool} configs/instances to be added to the header tool area. The tools are stored as\n     * child components of the header container. They can be accessed using {@link #down} and {#query}, as well as the\n     * other component methods. The toggle tool is automatically created if {@link #collapsible} is set to true.\n     *\n     * Note that, apart from the toggle tool which is provided when a panel is collapsible, these tools only provide the\n     * visual button. Any required functionality must be provided by adding handlers that implement the necessary\n     * behavior.\n     *\n     * Example usage:\n     *\n     *     tools:[{\n     *         type:'refresh',\n     *         tooltip: 'Refresh form Data',\n     *         // hidden:true,\n     *         handler: function(event, toolEl, panel){\n     *             // refresh logic\n     *         }\n     *     },\n     *     {\n     *         type:'help',\n     *         tooltip: 'Get Help',\n     *         handler: function(event, toolEl, panel){\n     *             // show help here\n     *         }\n     *     }]\n     */\n\n    /**\n     * @cfg {String} [title='']\n     * The title text to be used to display in the {@link Ext.panel.Header panel header}. When a\n     * `title` is specified the {@link Ext.panel.Header} will automatically be created and displayed unless\n     * {@link #header} is set to `false`.\n     */\n\n    /**\n     * @cfg {String} [titleAlign='left']\n     * May be `\"left\"`, `\"right\"` or `\"center\"`.\n     *\n     * The alignment of the title text within the available space between the icon and the tools.\n     */\n    titleAlign: 'left',\n\n    /**\n     * @cfg {Boolean} [manageHeight=true]: When true, the dock component layout writes\n     * height information to the panel's DOM elements based on its shrink wrap height\n     * calculation. This ensures that the browser respects the calculated height.\n     * When false, the dock component layout will not write heights on the panel or its\n     * body element. In some simple layout cases, not writing the heights to the DOM may\n     * be desired because this allows the browser to respond to direct DOM manipulations\n     * (like animations).\n     */\n    manageHeight: true,\n\n    /**\n     * @cfg {String} iconCls\n     * CSS class for an icon in the header. Used for displaying an icon to the left of a title.\n     */\n    \n    /**\n     * @cfg {String} icon\n     * Path to image for an icon in the header. Used for displaying an icon to the left of a title.\n     */\n\n    initComponent: function() {\n        var me = this;\n\n        me.addEvents(\n\n            /**\n             * @event beforeclose\n             * Fires before the user closes the panel. Return false from any listener to stop the close event being\n             * fired\n             * @param {Ext.panel.Panel} panel The Panel object\n             */\n            'beforeclose',\n            \n            /**\n             * @event close\n             * Fires when the user closes the panel.\n             * @param {Ext.panel.Panel} panel The Panel object\n             */\n            'close',\n\n            /**\n             * @event beforeexpand\n             * Fires before this panel is expanded. Return false to prevent the expand.\n             * @param {Ext.panel.Panel} p The Panel being expanded.\n             * @param {Boolean} animate True if the expand is animated, else false.\n             */\n            \"beforeexpand\",\n\n            /**\n             * @event beforecollapse\n             * Fires before this panel is collapsed. Return false to prevent the collapse.\n             * @param {Ext.panel.Panel} p The Panel being collapsed.\n             * @param {String} direction . The direction of the collapse. One of\n             *\n             *   - Ext.Component.DIRECTION_TOP\n             *   - Ext.Component.DIRECTION_RIGHT\n             *   - Ext.Component.DIRECTION_BOTTOM\n             *   - Ext.Component.DIRECTION_LEFT\n             *\n             * @param {Boolean} animate True if the collapse is animated, else false.\n             */\n            \"beforecollapse\",\n\n            /**\n             * @event expand\n             * Fires after this Panel has expanded.\n             * @param {Ext.panel.Panel} p The Panel that has been expanded.\n             */\n            \"expand\",\n\n            /**\n             * @event collapse\n             * Fires after this Panel hass collapsed.\n             * @param {Ext.panel.Panel} p The Panel that has been collapsed.\n             */\n            \"collapse\",\n\n            /**\n             * @event titlechange\n             * Fires after the Panel title has been set or changed.\n             * @param {Ext.panel.Panel} p the Panel which has been resized.\n             * @param {String} newTitle The new title.\n             * @param {String} oldTitle The previous panel title.\n             */\n            'titlechange',\n\n            /**\n             * @event iconchange\n             * Fires after the Panel icon has been set or changed.\n             * @param {Ext.panel.Panel} p The Panel which has the icon changed.\n             * @param {String} newIcon The path to the new icon image.\n             * @param {String} oldIcon The path to the previous panel icon image.\n             */\n            'iconchange',\n            \n            /**\n             * @event iconclschange\n             * Fires after the Panel iconCls has been set or changed.\n             * @param {Ext.panel.Panel} p The Panel which has the iconCls changed.\n             * @param {String} newIconCls The new iconCls.\n             * @param {String} oldIconCls The previous panel iconCls.\n             */\n            'iconclschange'\n        );\n\n        if (me.collapsible) {\n        // Save state on these two events.\n            this.addStateEvents(['expand', 'collapse']);\n        }\n        if (me.unstyled) {\n            me.setUI('plain');\n        }\n\n        if (me.frame) {\n            me.setUI(me.ui + '-framed');\n        }\n\n        // Backwards compatibility\n        me.bridgeToolbars();\n\n        me.callParent();\n        me.collapseDirection = me.collapseDirection || me.headerPosition || Ext.Component.DIRECTION_TOP;\n\n        // Used to track hidden content elements during collapsed state\n        me.hiddenOnCollapse = new Ext.dom.CompositeElement();\n\n    },\n\n    beforeDestroy: function() {\n        var me = this;\n        Ext.destroy(\n            me.placeholder,\n            me.ghostPanel,\n            me.dd\n        );\n        me.callParent();\n    },\n\n    initAria: function() {\n        this.callParent();\n        this.initHeaderAria();\n    },\n\n    getFocusEl: function() {\n        return  this.el;\n    },\n\n    initHeaderAria: function() {\n        var me = this,\n            el = me.el,\n            header = me.header;\n        if (el && header) {\n            el.dom.setAttribute('aria-labelledby', header.titleCmp.id);\n        }\n    },\n\n    /**\n     * Gets the {@link Ext.panel.Header Header} for this panel.\n     */\n    getHeader: function() {\n        return this.header;\n    },\n\n    /**\n     * Set a title for the panel's header. See {@link Ext.panel.Header#title}.\n     * @param {String} newTitle\n     */\n    setTitle: function(newTitle) {\n        var me = this,\n            oldTitle = me.title,\n            header = me.header,\n            reExpander = me.reExpander,\n            placeholder = me.placeholder;\n\n        me.title = newTitle;\n\n        if (header) {\n            if (header.isHeader) {\n                header.setTitle(newTitle);\n            } else {\n                header.title = newTitle;\n            }\n        } else {\n            me.updateHeader();\n        }\n\n        if (reExpander) {\n            reExpander.setTitle(newTitle);\n        }\n\n        if (placeholder && placeholder.setTitle) {\n            placeholder.setTitle(newTitle);\n        }\n\n        me.fireEvent('titlechange', me, newTitle, oldTitle);\n    },\n\n    /**\n     * Set the iconCls for the panel's header. See {@link Ext.panel.Header#iconCls}. It will fire the\n     * {@link #iconclschange} event after completion.\n     * @param {String} newIconCls The new CSS class name\n     */\n    setIconCls: function(newIconCls) {\n        var me = this,\n            oldIconCls = me.iconCls,\n            header = me.header,\n            placeholder = me.placeholder;\n\n        me.iconCls = newIconCls;\n\n        if (header) {\n            if (header.isHeader) {\n                header.setIconCls(newIconCls);\n            } else {\n                header.iconCls = newIconCls;\n            }\n        } else {\n            me.updateHeader();\n        }\n\n        if (placeholder && placeholder.setIconCls) {\n            placeholder.setIconCls(newIconCls);\n        }\n\n        me.fireEvent('iconclschange', me, newIconCls, oldIconCls);\n    },\n    \n    /**\n     * Set the icon for the panel's header. See {@link Ext.panel.Header#icon}. It will fire the\n     * {@link #iconchange} event after completion.\n     * @param {String} newIcon The new icon path\n     */\n    setIcon: function(newIcon) {\n        var me = this,\n            oldIcon = me.icon,\n            header = me.header,\n            placeholder = me.placeholder;\n\n        me.icon = newIcon;\n\n        if (header) {\n            if (header.isHeader) {\n                header.setIcon(newIcon);\n            } else {\n                header.icon = newIcon;\n            }\n        } else {\n            me.updateHeader();\n        }\n\n        if (placeholder && placeholder.setIcon) {\n            placeholder.setIcon(newIcon);\n        }\n\n        me.fireEvent('iconchange', me, newIcon, oldIcon);\n    },\n\n    bridgeToolbars: function() {\n        var me = this,\n            docked = [],\n            fbar,\n            fbarDefaults,\n            minButtonWidth = me.minButtonWidth;\n\n        function initToolbar (toolbar, pos, useButtonAlign) {\n            if (Ext.isArray(toolbar)) {\n                toolbar = {\n                    xtype: 'toolbar',\n                    items: toolbar\n                };\n            }\n            else if (!toolbar.xtype) {\n                toolbar.xtype = 'toolbar';\n            }\n            toolbar.dock = pos;\n            if (pos == 'left' || pos == 'right') {\n                toolbar.vertical = true;\n            }\n\n            // Legacy support for buttonAlign (only used by buttons/fbar)\n            if (useButtonAlign) {\n                toolbar.layout = Ext.applyIf(toolbar.layout || {}, {\n                    // default to 'end' (right-aligned) if me.buttonAlign is undefined or invalid\n                    pack: { left:'start', center:'center' }[me.buttonAlign] || 'end'\n                });\n            }\n            return toolbar;\n        }\n\n        // Short-hand toolbars (tbar, bbar and fbar plus new lbar and rbar):\n\n        /**\n         * @cfg {String} buttonAlign\n         * The alignment of any buttons added to this panel. Valid values are 'right', 'left' and 'center' (defaults to\n         * 'right' for buttons/fbar, 'left' for other toolbar types).\n         *\n         * **NOTE:** The prefered way to specify toolbars is to use the dockedItems config. Instead of buttonAlign you\n         * would add the layout: { pack: 'start' | 'center' | 'end' } option to the dockedItem config.\n         */\n\n        /**\n         * @cfg {Object/Object[]} tbar\n         * Convenience config. Short for 'Top Bar'.\n         *\n         *     tbar: [\n         *       { xtype: 'button', text: 'Button 1' }\n         *     ]\n         *\n         * is equivalent to\n         *\n         *     dockedItems: [{\n         *         xtype: 'toolbar',\n         *         dock: 'top',\n         *         items: [\n         *             { xtype: 'button', text: 'Button 1' }\n         *         ]\n         *     }]\n         */\n        if (me.tbar) {\n            docked.push(initToolbar(me.tbar, 'top'));\n            me.tbar = null;\n        }\n\n        /**\n         * @cfg {Object/Object[]} bbar\n         * Convenience config. Short for 'Bottom Bar'.\n         *\n         *     bbar: [\n         *       { xtype: 'button', text: 'Button 1' }\n         *     ]\n         *\n         * is equivalent to\n         *\n         *     dockedItems: [{\n         *         xtype: 'toolbar',\n         *         dock: 'bottom',\n         *         items: [\n         *             { xtype: 'button', text: 'Button 1' }\n         *         ]\n         *     }]\n         */\n        if (me.bbar) {\n            docked.push(initToolbar(me.bbar, 'bottom'));\n            me.bbar = null;\n        }\n\n        /**\n         * @cfg {Object/Object[]} buttons\n         * Convenience config used for adding buttons docked to the bottom of the panel. This is a\n         * synonym for the {@link #fbar} config.\n         *\n         *     buttons: [\n         *       { text: 'Button 1' }\n         *     ]\n         *\n         * is equivalent to\n         *\n         *     dockedItems: [{\n         *         xtype: 'toolbar',\n         *         dock: 'bottom',\n         *         ui: 'footer',\n         *         defaults: {minWidth: {@link #minButtonWidth}},\n         *         items: [\n         *             { xtype: 'component', flex: 1 },\n         *             { xtype: 'button', text: 'Button 1' }\n         *         ]\n         *     }]\n         *\n         * The {@link #minButtonWidth} is used as the default {@link Ext.button.Button#minWidth minWidth} for\n         * each of the buttons in the buttons toolbar.\n         */\n        if (me.buttons) {\n            me.fbar = me.buttons;\n            me.buttons = null;\n        }\n\n        /**\n         * @cfg {Object/Object[]} fbar\n         * Convenience config used for adding items to the bottom of the panel. Short for Footer Bar.\n         *\n         *     fbar: [\n         *       { type: 'button', text: 'Button 1' }\n         *     ]\n         *\n         * is equivalent to\n         *\n         *     dockedItems: [{\n         *         xtype: 'toolbar',\n         *         dock: 'bottom',\n         *         ui: 'footer',\n         *         defaults: {minWidth: {@link #minButtonWidth}},\n         *         items: [\n         *             { xtype: 'component', flex: 1 },\n         *             { xtype: 'button', text: 'Button 1' }\n         *         ]\n         *     }]\n         *\n         * The {@link #minButtonWidth} is used as the default {@link Ext.button.Button#minWidth minWidth} for\n         * each of the buttons in the fbar.\n         */\n        if (me.fbar) {\n            fbar = initToolbar(me.fbar, 'bottom', true); // only we useButtonAlign\n            fbar.ui = 'footer';\n\n            // Apply the minButtonWidth config to buttons in the toolbar\n            if (minButtonWidth) {\n                fbarDefaults = fbar.defaults;\n                fbar.defaults = function(config) {\n                    var defaults = fbarDefaults || {};\n                    if ((!config.xtype || config.xtype === 'button' || (config.isComponent && config.isXType('button'))) &&\n                            !('minWidth' in defaults)) {\n                        defaults = Ext.apply({minWidth: minButtonWidth}, defaults);\n                    }\n                    return defaults;\n                };\n            }\n\n            docked.push(fbar);\n            me.fbar = null;\n        }\n\n        /**\n         * @cfg {Object/Object[]} lbar\n         * Convenience config. Short for 'Left Bar' (left-docked, vertical toolbar).\n         *\n         *     lbar: [\n         *       { xtype: 'button', text: 'Button 1' }\n         *     ]\n         *\n         * is equivalent to\n         *\n         *     dockedItems: [{\n         *         xtype: 'toolbar',\n         *         dock: 'left',\n         *         items: [\n         *             { xtype: 'button', text: 'Button 1' }\n         *         ]\n         *     }]\n         */\n        if (me.lbar) {\n            docked.push(initToolbar(me.lbar, 'left'));\n            me.lbar = null;\n        }\n\n        /**\n         * @cfg {Object/Object[]} rbar\n         * Convenience config. Short for 'Right Bar' (right-docked, vertical toolbar).\n         *\n         *     rbar: [\n         *       { xtype: 'button', text: 'Button 1' }\n         *     ]\n         *\n         * is equivalent to\n         *\n         *     dockedItems: [{\n         *         xtype: 'toolbar',\n         *         dock: 'right',\n         *         items: [\n         *             { xtype: 'button', text: 'Button 1' }\n         *         ]\n         *     }]\n         */\n        if (me.rbar) {\n            docked.push(initToolbar(me.rbar, 'right'));\n            me.rbar = null;\n        }\n\n        if (me.dockedItems) {\n            if (!Ext.isArray(me.dockedItems)) {\n                me.dockedItems = [me.dockedItems];\n            }\n            me.dockedItems = me.dockedItems.concat(docked);\n        } else {\n            me.dockedItems = docked;\n        }\n    },\n\n    isPlaceHolderCollapse: function(){\n        return this.collapseMode == 'placeholder';\n    },\n\n    onBoxReady: function(){\n        this.callParent();\n        if (this.collapsed) {\n            this.setHiddenDocked();\n        }    \n    },\n\n    beforeRender: function() {\n        var me = this,\n            wasCollapsed;\n\n        me.callParent();\n\n        // Add class-specific header tools.\n        // Panel adds collapsible and closable.\n        me.initTools();\n\n        // Dock the header/title unless we are configured specifically not to create a header\n        if (!(me.preventHeader || (me.header === false))) {\n            me.updateHeader();\n        }\n\n        // If we are rendering collapsed, we still need to save and modify various configs\n        if (me.collapsed) {\n            if (me.isPlaceHolderCollapse()) {\n                me.hidden = true;\n\n                // This will insert the placeholder Component into the ownerCt's child collection\n                // Its getRenderTree call which is calling this will then iterate again and\n                // recreate the child items array to include the new Component.\n                me.placeholderCollapse();\n                wasCollapsed = me.collapsed;\n\n                // Temporarily clear the flag so that the header is rendered with a collapse tool in it.\n                // Placeholder collapse panels never really collapse, they just hide. The tool is always\n                // a collapse tool.\n                me.collapsed = false;\n            } else {\n                me.beginCollapse();\n                me.addClsWithUI(me.collapsedCls);\n            }\n        }\n\n        // Restore the flag if we are being rendered initially placeholder collapsed.\n        if (wasCollapsed) {\n            me.collapsed = wasCollapsed;\n        }\n    },\n\n    /**\n     * @private\n     * Tools are a Panel-specific capabilty.\n     * Panel uses initTools. Subclasses may contribute tools by implementing addTools.\n     */\n    initTools: function() {\n        var me = this;\n\n        me.tools = me.tools ? Ext.Array.clone(me.tools) : [];\n\n        // Add a collapse tool unless configured to not show a collapse tool\n        // or to not even show a header.\n        if (me.collapsible && !(me.hideCollapseTool || me.header === false || me.preventHeader)) {\n            me.collapseDirection = me.collapseDirection || me.headerPosition || 'top';\n            me.collapseTool = me.expandTool = Ext.widget({\n                xtype: 'tool',\n                type: (me.collapsed && !me.isPlaceHolderCollapse()) ? ('expand-' + me.getOppositeDirection(me.collapseDirection)) : ('collapse-' + me.collapseDirection),\n                handler: me.toggleCollapse,\n                scope: me\n            });\n\n            // Prepend collapse tool is configured to do so.\n            if (me.collapseFirst) {\n                me.tools.unshift(me.collapseTool);\n            }\n        }\n\n        // Add subclass-specific tools.\n        me.addTools();\n\n        // Make Panel closable.\n        if (me.closable) {\n            me.addClsWithUI('closable');\n            me.addTool({\n                type: 'close',\n                handler: Ext.Function.bind(me.close, me, [])\n            });\n        }\n\n        // Append collapse tool if needed.\n        if (me.collapseTool && !me.collapseFirst) {\n            me.addTool(me.collapseTool);\n        }\n    },\n\n    /**\n     * @private\n     * @template\n     * Template method to be implemented in subclasses to add their tools after the collapsible tool.\n     */\n    addTools: Ext.emptyFn,\n\n    /**\n     * Closes the Panel. By default, this method, removes it from the DOM, {@link Ext.Component#method-destroy destroy}s the\n     * Panel object and all its descendant Components. The {@link #beforeclose beforeclose} event is fired before the\n     * close happens and will cancel the close action if it returns false.\n     *\n     * **Note:** This method is also affected by the {@link #closeAction} setting. For more explicit control use\n     * {@link #method-destroy} and {@link #method-hide} methods.\n     */\n    close: function() {\n        if (this.fireEvent('beforeclose', this) !== false) {\n            this.doClose();\n        }\n    },\n\n    // private\n    doClose: function() {\n        this.fireEvent('close', this);\n        this[this.closeAction]();\n    },\n\n    /**\n     * Create, hide, or show the header component as appropriate based on the current config.\n     * @private\n     * @param {Boolean} force True to force the header to be created\n     */\n    updateHeader: function(force) {\n        var me = this,\n            header = me.header,\n            title = me.title,\n            tools = me.tools,\n            icon = me.icon || me.iconCls,\n            vertical = me.headerPosition == 'left' || me.headerPosition == 'right';\n\n        if ((header !== false) && (force || (title || icon) || (tools && tools.length) || (me.collapsible && !me.titleCollapse))) {\n            if (header && header.isHeader) {\n                header.show();\n            } else {\n                // Apply the header property to the header config\n                header = me.header = Ext.widget(Ext.apply({\n                    xtype       : 'header',\n                    title       : title,\n                    titleAlign  : me.titleAlign,\n                    orientation : vertical ? 'vertical' : 'horizontal',\n                    dock        : me.headerPosition || 'top',\n                    textCls     : me.headerTextCls,\n                    iconCls     : me.iconCls,\n                    icon        : me.icon,\n                    baseCls     : me.baseCls + '-header',\n                    tools       : tools,\n                    ui          : me.ui,\n                    id          : me.id + '_header',\n                    indicateDrag: me.draggable,\n                    frame       : (me.frame || me.alwaysFramed) && me.frameHeader,\n                    ignoreParentFrame : me.frame || me.overlapHeader,\n                    ignoreBorderManagement: me.frame || me.ignoreHeaderBorderManagement,\n                    listeners   : me.collapsible && me.titleCollapse ? {\n                        click: me.toggleCollapse,\n                        scope: me\n                    } : null\n                }, me.header));\n                me.addDocked(header, 0);\n\n                // Reference the Header's tool array.\n                // Header injects named references.\n                me.tools = header.tools;\n            }\n            me.initHeaderAria();\n        } else if (header) {\n            header.hide();\n        }\n    },\n\n    // inherit docs\n    setUI: function(ui) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        if (me.header && me.header.rendered) {\n            me.header.setUI(ui);\n        }\n    },\n\n    // private\n    getContentTarget: function() {\n        return this.body;\n    },\n\n    getTargetEl: function() {\n        var me = this;\n        return me.body || me.protoBody || me.frameBody || me.el;\n    },\n\n    // the overrides below allow for collapsed regions inside the border layout to be hidden\n\n    // inherit docs\n    isVisible: function(deep){\n        var me = this;\n        if (me.collapsed && me.placeholder) {\n            return me.placeholder.isVisible(deep);\n        }\n        return me.callParent(arguments);\n    },\n\n    // inherit docs\n    onHide: function(){\n        var me = this;\n        if (me.collapsed && me.placeholder) {\n            me.placeholder.hide();\n        } else {\n            me.callParent(arguments);\n        }\n    },\n\n    // inherit docs\n    onShow: function(){\n        var me = this;\n        if (me.collapsed && me.placeholder) {\n            // force hidden back to true, since this gets set by the layout\n            me.hidden = true;\n            me.placeholder.show();\n        } else {\n            me.callParent(arguments);\n        }\n    },\n\n    onRemoved: function(destroying) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        // If we are removed but not being destroyed, ensure our placeholder is also removed but not destroyed\n        // If we are being destroyed, our destroy processing will destroy the placeholder.\n        if (me.placeholder && !destroying) {\n            me.ownerCt.remove(me.placeholder, false);\n        }\n    },\n\n    addTool: function(tools) {\n        tools = [].concat(tools);\n\n        var me     = this,\n            header = me.header,\n            t,\n            tLen   = tools.length,\n            tool;\n\n        for (t = 0; t < tLen; t++) {\n            tool = tools[t];\n\n            me.tools.push(tool);\n\n            if (header && header.isHeader) {\n                header.addTool(tool);\n            }\n        }\n\n        me.updateHeader();\n    },\n\n    getOppositeDirection: function(d) {\n        var c = Ext.Component;\n        switch (d) {\n            case c.DIRECTION_TOP:\n                return c.DIRECTION_BOTTOM;\n            case c.DIRECTION_RIGHT:\n                return c.DIRECTION_LEFT;\n            case c.DIRECTION_BOTTOM:\n                return c.DIRECTION_TOP;\n            case c.DIRECTION_LEFT:\n                return c.DIRECTION_RIGHT;\n        }\n    },\n\n    getWidthAuthority: function() {\n        if (this.collapsed && this.collapsedHorizontal()) {\n            return 1; // the panel determine's its own width\n        }\n\n        return this.callParent();\n    },\n\n    getHeightAuthority: function() {\n        if (this.collapsed && this.collapsedVertical()) {\n            return 1; // the panel determine's its own height\n        }\n\n        return this.callParent();\n    },\n\n    collapsedHorizontal: function () {\n        var dir = this.getCollapsed();\n        return dir == 'left' || dir == 'right';\n    },\n\n    collapsedVertical: function () {\n        var dir = this.getCollapsed();\n        return dir == 'top' || dir == 'bottom';\n    },\n    \n    restoreDimension: function(){\n        var dir = this.collapseDirection;\n        // If we're collapsing top/bottom, we want to restore the height\n        // If we're collapsing left/right, we want to restore the width\n        return (dir === 'top' || dir === 'bottom') ? 'height' : 'width';    \n    },\n\n    /**\n     * Returns the current collapsed state of the panel.\n     * @return {Boolean/String} False when not collapsed, otherwise the value of {@link #collapseDirection}.\n     */\n    getCollapsed: function() {\n        var me = this;\n        // The collapsed flag, when the Panel is collapsed acts as the direction in which the collapse took\n        // place. It can still be tested as truthy/falsy if only a truth value is required.\n        if (me.collapsed === true) {\n            return me.collapseDirection;\n        }\n        return me.collapsed;\n    },\n\n    getState: function() {\n        var me = this,\n            state = me.callParent(),\n            memento;\n\n        state = me.addPropertyToState(state, 'collapsed');\n\n        // If a collapse has taken place, use remembered values as the dimensions.\n        if (me.collapsed) {\n            memento = me.collapseMemento;\n            memento = memento && memento.data;\n\n            if (me.collapsedVertical()) {\n                if (state) {\n                    delete state.height;\n                }\n                if (memento) {\n                    state = me.addPropertyToState(state, 'height', memento.height);\n                }\n            } else {\n                if (state) {\n                    delete state.width;\n                }\n                if (memento) {\n                    state = me.addPropertyToState(state, 'width', memento.width);\n                }\n            }\n        }\n\n        return state;\n    },\n\n    findReExpander: function (direction) {\n        var me = this,\n            c = Ext.Component,\n            dockedItems = me.dockedItems.items,\n            dockedItemCount = dockedItems.length,\n            comp, i;\n            \n        // never use the header if we're in collapseMode mini\n        if (me.collapseMode == 'mini') {\n            return;\n        }\n\n        switch (direction) {\n            case c.DIRECTION_TOP:\n            case c.DIRECTION_BOTTOM:\n\n                // Attempt to find a reExpander Component (docked in a horizontal orientation)\n                // Also, collect all other docked items which we must hide after collapse. \n                for (i = 0; i < dockedItemCount; i++) {\n                    comp = dockedItems[i];\n                    if (!comp.hidden) {\n                        if (comp.isHeader && (!comp.dock || comp.dock == 'top' || comp.dock == 'bottom')) {\n                            return comp;\n                        }\n                    }\n                }\n                break;\n\n            case c.DIRECTION_LEFT:\n            case c.DIRECTION_RIGHT:\n\n                // Attempt to find a reExpander Component (docked in a vecrtical orientation)\n                // Also, collect all other docked items which we must hide after collapse. \n                for (i = 0; i < dockedItemCount; i++) {\n                    comp = dockedItems[i];\n                    if (!comp.hidden) {\n                        if (comp.isHeader && (comp.dock == 'left' || comp.dock == 'right')) {\n                            return comp;\n                        }\n                    }\n                }\n                break;\n\n            default:\n                throw('Panel#findReExpander must be passed a valid collapseDirection');\n        }\n    },\n\n    getReExpander: function (direction) {\n        var me = this,\n            collapseDir = direction || me.collapseDirection,\n            reExpander = me.reExpander || me.findReExpander(collapseDir);\n\n        me.expandDirection = me.getOppositeDirection(collapseDir);\n\n        if (!reExpander) {\n        // We did not find a Header of the required orientation: create one.\n            me.reExpander = reExpander = me.createReExpander(collapseDir, {\n                dock: collapseDir,\n                cls: Ext.baseCSSPrefix + 'docked ' + me.baseCls + '-' + me.ui + '-collapsed',\n                ownerCt: me,\n                ownerLayout: me.componentLayout\n            });\n\n            me.dockedItems.insert(0, reExpander);\n        }\n        return reExpander;\n    },\n\n    createReExpander: function(direction, defaults) {\n        var me = this,\n            isLeft = direction == 'left',\n            isRight = direction == 'right',\n            isVertical = isLeft || isRight,\n            toolAtTop,\n            result = Ext.apply({\n                hideMode: 'offsets',\n                title: me.title,\n                orientation: isVertical ? 'vertical' : 'horizontal',\n                textCls: me.headerTextCls,\n                icon: me.icon,\n                iconCls: me.iconCls,\n                baseCls: me.baseCls + '-header',\n                ui: me.ui,\n                frame: me.frame && me.frameHeader,\n                ignoreParentFrame: me.frame || me.overlapHeader,\n                indicateDrag: me.draggable\n            }, defaults);\n            \n            // If we're in mini mode, set the placeholder size to only 1px since\n            // we don't need it to show up.\n            if (me.collapseMode == 'mini') {\n                if (isVertical) {\n                    result.width = 1;\n                } else {\n                    result.height = 1;\n                }\n            }\n\n        // Create the re expand tool\n        // For UI consistency reasons, collapse:left reExpanders, and region: 'west' placeHolders\n        // have the re expand tool at the *top* with a bit of space.\n        if (!me.hideCollapseTool) {\n            toolAtTop = isLeft || (isRight && me.isPlaceHolderCollapse());\n            result[toolAtTop ? 'items' : 'tools'] = [{\n                xtype: 'tool',\n                type: 'expand-' + me.getOppositeDirection(direction),\n                uiCls: ['top'],\n                handler: me.toggleCollapse,\n                scope: me\n            }];\n        }\n        result = new Ext.panel.Header(result);\n        result.addClsWithUI(me.getHeaderCollapsedClasses(result));\n        return result;\n    },\n\n    // private\n    // Create the class array to add to the Header when collpsed.\n    getHeaderCollapsedClasses: function(header) {\n        var me = this,\n            collapsedCls = me.collapsedCls,\n            collapsedClasses;\n\n        collapsedClasses = [ collapsedCls, collapsedCls + '-' + header.dock];\n        if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {\n            collapsedClasses.push(collapsedCls + '-border-' + header.dock);\n        }\n        return collapsedClasses;\n    },\n\n    /**\n     * @private\n     * Called before the change from default, configured state into the collapsed state.\n     * This method may be called at render time to enable rendering in an initially collapsed state,\n     * or at runtime when an existing, fully layed out Panel may be collapsed.\n     * It basically saves configs which need to be clobbered for the duration of the collapsed state.\n     */\n    beginCollapse: function() {\n        var me = this,\n            lastBox = me.lastBox,\n            rendered = me.rendered,\n            collapseMemento = me.collapseMemento || (me.collapseMemento = new Ext.util.Memento(me)),\n            sizeModel = me.getSizeModel(),\n            reExpander;\n\n        // When we collapse a panel, the panel is in control of one dimension (depending on\n        // collapse direction) and sets that on the component. We must restore the user's\n        // original value (including non-existance) when we expand. Using this technique, we\n        // mimic setCalculatedSize for the dimension we do not control and setSize for the\n        // one we do (only while collapsed).\n        // Additionally, the panel may have a shrink wrapped width and/or height. For shrinkWrapped\n        // panels this can be problematic, since a collapsed, shrink-wrapped panel has no way \n        // of determining its width (or height if the collapse direction is horizontal). It is\n        // therefore necessary to capture both the width and height regardless of collapse direction.\n        // This allows us to set a configured width or height on the panel when it is collapsed,\n        // and it will be restored to an unconfigured-width shrinkWrapped state on expand.\n        collapseMemento.capture(['height', 'minHeight', 'width', 'minWidth']);\n        if (lastBox) {\n            collapseMemento.capture(me.restoreDimension(), lastBox, 'last.');\n        }\n        // If the panel has a shrinkWrapped height/width and is already rendered, configure its width/height as its calculated width/height,\n        // so that the collapsed header will have the same width or height as the panel did before it was collapsed.\n        // If the shrinkWrapped panel has not yet been rendered, as will be the case when a panel is initially configured with\n        // collapsed:true, we attempt to use the configured width/height, and fall back to minWidth or minHeight if\n        // width/height has not been configured, and fall back to a value of 100 if a minWidth/minHeight has not been configured.\n        if (me.collapsedVertical()) {\n            if (sizeModel.width.shrinkWrap) {\n                me.width = rendered ? me.getWidth() : me.width || me.minWidth || 100;\n            }\n            delete me.height;\n            me.minHeight = 0;\n        } else if (me.collapsedHorizontal()) {\n            if (sizeModel.height.shrinkWrap) {\n                me.height = rendered ? me.getHeight() : me.height || me.minHeight || 100;\n            }\n            delete me.width;\n            me.minWidth = 0;\n        }\n\n        if (me.ownerCt) {\n            me.ownerCt.getLayout().beginCollapse(me);\n        }\n\n        // Get a reExpander header. This will return the Panel Header if the Header is in the correct orientation\n        // If we are using the Header as the reExpander, change its UI to collapsed state\n        if (!me.isPlaceHolderCollapse()) {\n            if (me.header === (reExpander = me.getReExpander())) {\n                me.header.addClsWithUI(me.getHeaderCollapsedClasses(me.header));\n\n                // Ensure that the reExpander has the correct framing applied.\n                if (me.header.rendered) {\n                    me.header.updateFrame();\n                }\n            }\n            // We're going to use a temporary reExpander: show it.\n            else {\n                if (reExpander.el) {\n                    reExpander.el.show();\n                    reExpander.hidden = false;\n                }\n            }\n        }\n        if (me.resizer) {\n            me.resizer.disable();\n        }\n    },\n\n    beginExpand: function() {\n        var me = this,\n            lastBox = me.lastBox,\n            collapseMemento = me.collapseMemento,\n            restoreDimension = this.restoreDimension(),\n            reExpander;\n\n        collapseMemento.restore(['minHeight', 'minWidth', restoreDimension]);\n        if (lastBox) {\n            collapseMemento.restore(restoreDimension, true, lastBox, 'last.');\n        }\n\n        if (me.ownerCt) {\n            me.ownerCt.getLayout().beginExpand(me);\n        }\n\n        if (!me.isPlaceHolderCollapse()) {\n            // If we have been using our Header as the reExpander then restore the Header to expanded UI\n            if (me.header === (reExpander = me.getReExpander())) {\n                me.header.removeClsWithUI(me.getHeaderCollapsedClasses(me.header));\n\n                // Ensure that the reExpander has the correct framing applied.\n                if (me.header.rendered) {\n                    me.header.updateFrame();\n                }\n            }\n            // We've been using a temporary reExpander: hide it.\n            else {\n                reExpander.hidden = true;\n                reExpander.el.hide();\n            }\n        }\n        if (me.resizer) {\n            me.resizer.enable();\n        }\n    },\n\n    /**\n     * Collapses the panel body so that the body becomes hidden. Docked Components parallel to the border towards which\n     * the collapse takes place will remain visible. Fires the {@link #beforecollapse} event which will cancel the\n     * collapse action if it returns false.\n     *\n     * @param {String} [direction] The direction to collapse towards. Must be one of\n     *\n     *   - Ext.Component.DIRECTION_TOP\n     *   - Ext.Component.DIRECTION_RIGHT\n     *   - Ext.Component.DIRECTION_BOTTOM\n     *   - Ext.Component.DIRECTION_LEFT\n     *\n     * Defaults to {@link #collapseDirection}.\n     *\n     * @param {Boolean} [animate] True to animate the transition, else false (defaults to the value of the\n     * {@link #animCollapse} panel config)\n     * @return {Ext.panel.Panel} this\n     */\n    collapse: function(direction, animate) {\n        var me = this,\n            collapseDir = direction || me.collapseDirection,\n            ownerCt = me.ownerCt;\n\n        if (me.isCollapsingOrExpanding) {\n            return me;\n        }\n\n        if (arguments.length < 2) {\n            animate = me.animCollapse;\n        }\n\n        if (me.collapsed || me.fireEvent('beforecollapse', me, direction, animate) === false) {\n            return me;\n        }\n\n        if (ownerCt && me.isPlaceHolderCollapse()) {\n            return me.placeholderCollapse(direction, animate);\n        }\n\n        me.collapsed = collapseDir;\n        me.beginCollapse();\n\n        me.fireHierarchyEvent('collapse');\n\n        return me.doCollapseExpand(1, animate);\n    },\n\n    doCollapseExpand: function (flags, animate) {\n        var me = this,\n            originalAnimCollapse = me.animCollapse,\n            ownerLayout = me.ownerLayout;\n\n        // we need to temporarily set animCollapse to the animate value here because ContextItem\n        // uses the animCollapse property to determine if the collapse/expand should be animated\n        me.animCollapse = animate;\n\n        // Flag used by the layouy ContextItem to impose an animation policy based upon the\n        // collapse direction and the animCollapse setting.\n        me.isCollapsingOrExpanding = flags;\n\n        if (ownerLayout && !animate) {\n            ownerLayout.onContentChange(me);\n        } else {\n            me.updateLayout({ isRoot: true });\n        }\n\n        // set animCollapse back to its original value\n        me.animCollapse = originalAnimCollapse;\n\n        return me;\n    },\n\n    /**\n     * Invoked after the Panel is Collapsed.\n     *\n     * @param {Boolean} animated\n     *\n     * @template\n     * @protected\n     */\n    afterCollapse: function(animated) {\n        var me = this,\n            ownerLayout = me.ownerLayout;\n\n        me.isCollapsingOrExpanding = 0;\n        if (me.collapseTool) {\n            me.collapseTool.setType('expand-' + me.getOppositeDirection(me.collapseDirection));\n        }\n\n        if (ownerLayout && animated) {\n            ownerLayout.onContentChange(me);\n        }\n\n        me.setHiddenDocked();\n        me.fireEvent('collapse', me);\n    },\n    \n    setHiddenDocked: function(){\n        // Hide Panel content except reExpander using visibility to prevent focusing of contained elements.\n        // Track what we hide to re-show on expand\n        var me = this,\n            toHide = me.hiddenOnCollapse,\n            reExpander = me.getReExpander(),\n            items = me.getDockedItems(),\n            len = items.length,\n            i = 0,\n            item;\n            \n        toHide.add(me.body);\n        for (; i < len; i++) {\n            item = items[i];\n            if (item && item !== reExpander && item.el) {\n                toHide.add(item.el);\n            }\n        }\n        toHide.setStyle('visibility', 'hidden');\n    },\n    \n    restoreHiddenDocked: function(){\n        var toShow = this.hiddenOnCollapse;\n        // Re-show Panel content which was hidden after collapse.\n        toShow.setStyle('visibility', '');\n        toShow.clear();\n    },\n\n    getPlaceholder: function(direction) {\n        var me = this,\n            collapseDir = direction || me.collapseDirection,\n            listeners = null,\n            placeholder = me.placeholder;\n\n        if (!placeholder) {\n            if (me.floatable || (me.collapsible && me.titleCollapse)) {\n                listeners = {\n                    click: {\n                        fn: me.floatable ? me.floatCollapsedPanel : me.toggleCollapse,\n                        element: 'el',\n                        scope: me\n                    }\n                };\n            }\n\n            me.placeholder = placeholder = Ext.widget(me.createReExpander(collapseDir, {\n                id: me.id + '-placeholder',\n                listeners: listeners\n            }));\n        }\n\n        // User created placeholder was passed in\n        if (!placeholder.placeholderFor) {\n            // Handle the case of a placeholder config\n            if (!placeholder.isComponent) {\n                me.placeholder = placeholder = me.lookupComponent(placeholder);\n            }\n            Ext.applyIf(placeholder, {\n                margins: me.margins,\n                placeholderFor: me\n            });\n\n            placeholder.addCls([Ext.baseCSSPrefix + 'region-collapsed-placeholder', Ext.baseCSSPrefix + 'region-collapsed-' + collapseDir + '-placeholder', me.collapsedCls]);\n        }\n\n        return placeholder;\n    },\n\n    placeholderCollapse: function(direction, animate) {\n        var me = this,\n            ownerCt = me.ownerCt,\n            collapseDir = direction || me.collapseDirection,\n            floatCls = Ext.baseCSSPrefix + 'border-region-slide-in',\n            placeholder = me.getPlaceholder(direction);\n\n        me.isCollapsingOrExpanding = 1;\n\n        // Upcoming layout run will ignore this Component\n        me.hidden = true;\n        me.collapsed = collapseDir;\n\n        if (placeholder.rendered) {\n            // We may have been added to another Container from that in which we rendered the placeholder\n            if (placeholder.el.dom.parentNode !== me.el.dom.parentNode) {\n                me.el.dom.parentNode.insertBefore(placeholder.el.dom, me.el.dom);\n            }\n\n            placeholder.hidden = false;\n            placeholder.el.show();\n            ownerCt.updateLayout();\n        } else {\n            ownerCt.insert(ownerCt.items.indexOf(me), placeholder);\n        }\n\n        if (me.rendered) {\n            // We MUST NOT hide using display because that resets all scroll information.\n            me.el.setVisibilityMode(me.placeholderCollapseHideMode);\n            if (animate) {\n                me.el.addCls(floatCls);\n                placeholder.el.hide();\n\n                me.el.slideOut(collapseDir.substr(0, 1), {\n                    preserveScroll: true,\n                    duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration),\n                    listeners: {\n                        afteranimate: function() {\n                            me.el.removeCls(floatCls);\n                            /* We need to show the element so that slideIn will work correctly. However, if we leave it\n                               visible then it can be seen before the animation starts, causing a flicker. The solution,\n                               borrowed from date picker, is to hide it using display none. The slideIn effect includes\n                               a call to fixDisplay() that will undo the display none at the appropriate time.\n                             */\n                            placeholder.el.show().setStyle('display', 'none').slideIn(collapseDir.substr(0, 1), {\n                                easing: 'linear',\n                                duration: 100,\n                                listeners: {\n                                    afteranimate: function() {\n                                        placeholder.focus();\n                                        me.isCollapsingOrExpanding = 0;\n                                        me.fireEvent('collapse', me);\n                                    }\n                                }\n                            });\n                        }\n                    }\n                });\n            } else {\n                me.el.hide();\n                me.isCollapsingOrExpanding = 0;\n                me.fireEvent('collapse', me);\n            }\n        } else {\n            me.isCollapsingOrExpanding = 0;\n            me.fireEvent('collapse', me);\n        }\n\n        return me;\n    },\n\n    floatCollapsedPanel: function() {\n        var me = this,\n            placeholder = me.placeholder,\n            pb = placeholder.getBox(true),\n            myBox,\n            floatCls = Ext.baseCSSPrefix + 'border-region-slide-in',\n            collapsed = me.collapsed,\n            layoutOwner = me.ownerCt || me,\n            slideDirection;\n\n        // Already floated\n        if (me.el.hasCls(floatCls)) {\n            me.slideOutFloatedPanel();\n            return;\n        }\n\n        if (me.isSliding) {\n            return;\n        }\n        me.isSliding = true;\n\n        // Function to be called when the mouse leaves the floated Panel\n        // Slide out when the mouse leaves the region bounded by the slid Component and its placeholder.\n        function onMouseLeaveFloated(e) {\n            if (!me.isDestroyed) {\n                var slideRegion = me.el.getRegion().union(placeholder.el.getRegion()).adjust(1, -1, -1, 1);\n\n                // If mouse is not within slide Region, slide it out\n                if (!slideRegion.contains(e.getPoint())) {\n                    me.slideOutFloatedPanel();\n                }\n            }\n        }\n\n        // Lay out in fully expanded mode to ensure we are at the correct size, and collect our expanded box\n        me.placeholder.el.hide();\n        me.placeholder.hidden = true;\n        me.el.show();\n        me.hidden = false;\n        me.collapsed = false;\n        layoutOwner.updateLayout();\n        myBox = me.getBox(true);\n\n        // Then go back immediately to collapsed state from which to initiate the float into view.\n        me.placeholder.el.show();\n        me.placeholder.hidden = false;\n        me.el.hide();\n        me.hidden = true;\n        me.collapsed = collapsed;\n        layoutOwner.updateLayout();\n\n        // Monitor for mouseouting of the placeholder. Hide it if they exit for half a second or more\n        me.placeholderMouseMon = placeholder.el.monitorMouseLeave(500, onMouseLeaveFloated);\n        me.panelMouseMon       = me.el.monitorMouseLeave(500, onMouseLeaveFloated);\n        me.el.addCls(floatCls);\n\n        // Hide collapse tool in header if there is one (we might be headerless)\n        if (me.collapseTool) {\n            me.collapseTool.el.hide();\n        }\n\n        switch (me.collapsed) {\n            case 'top':\n                me.el.setLeftTop(pb.x, pb.y + pb.height - 1);\n                slideDirection = 't';\n                break;\n            case 'right':\n                me.el.setLeftTop(pb.x - myBox.width + 1, pb.y);\n                slideDirection = 'r';\n                break;\n            case 'bottom':\n                me.el.setLeftTop(pb.x, pb.y - myBox.height + 1);\n                slideDirection = 'b';\n                break;\n            case 'left':\n                me.el.setLeftTop(pb.x + pb.width - 1, pb.y);\n                slideDirection = 'l';\n                break;\n        }\n\n        // Remember how we are really collapsed so we can restore it, but also so we can\n        // become a layoutRoot while we are floated:\n        me.floatedFromCollapse = me.collapsed;\n        me.collapsed = me.hidden = false;\n\n        me.el.slideIn(slideDirection, {\n            preserveScroll: true,\n            listeners: {\n                afteranimate: function() {\n                    me.isSliding = false;\n                }\n            }\n        });\n    },\n\n    isLayoutRoot: function() {\n        if (this.floatedFromCollapse) {\n            return true;\n        }\n        return this.callParent();\n    },\n\n    slideOutFloatedPanel: function() {\n        var me = this,\n            compEl = this.el,\n            collapseDirection;\n\n        if (me.isSliding) {\n            return;\n        }\n\n        me.isSliding = true;\n\n        me.slideOutFloatedPanelBegin();\n\n        if (typeof me.collapsed == 'string') {\n            collapseDirection = me.collapsed.charAt(0);\n        }\n\n        compEl.slideOut(collapseDirection, {\n            preserveScroll: true,\n            listeners: {\n                afteranimate: function() {\n                    me.slideOutFloatedPanelEnd();\n                    // this would be in slideOutFloatedPanelEnd except that the only other\n                    // caller removes this cls later\n                    me.el.removeCls(Ext.baseCSSPrefix + 'border-region-slide-in');\n                    me.isSliding = false;\n                }\n            }\n        });\n    },\n\n    /**\n     * This method begins the slide out of the floated panel.\n     * @private\n     */\n    slideOutFloatedPanelBegin: function() {\n        var me = this,\n            compEl = this.el;\n\n        me.collapsed = me.floatedFromCollapse;\n        me.hidden = true;\n        me.floatedFromCollapse = null;\n\n        // Remove mouse leave monitors\n        compEl.un(me.panelMouseMon);\n        me.placeholder.el.un(me.placeholderMouseMon);\n    },\n\n    /**\n     * This method cleans up after the slide out of the floated panel.\n     * @private\n     */\n    slideOutFloatedPanelEnd: function() {\n        if (this.collapseTool) {\n            this.collapseTool.el.show();\n        }\n    },\n\n    /**\n     * Expands the panel body so that it becomes visible.  Fires the {@link #beforeexpand} event which will\n     * cancel the expand action if it returns false.\n     * @param {Boolean} [animate] True to animate the transition, else false (defaults to the value of the\n     * {@link #animCollapse} panel config)\n     * @return {Ext.panel.Panel} this\n     */\n    expand: function(animate) {\n        var me = this;\n\n        if (me.isCollapsingOrExpanding) {\n            return me;\n        }\n\n        if (!arguments.length) {\n            animate = me.animCollapse;\n        }\n\n        if (!me.collapsed && !me.floatedFromCollapse) {\n            return me;\n        }\n\n        if (me.fireEvent('beforeexpand', me, animate) === false) {\n            return me;\n        }\n\n        if (me.isPlaceHolderCollapse()) {\n            return me.placeholderExpand(animate);\n        }\n\n        me.restoreHiddenDocked();\n        me.beginExpand();\n        me.collapsed = false;\n\n        me.fireHierarchyEvent('expand');\n\n        return me.doCollapseExpand(2, animate);\n    },\n\n    placeholderExpand: function(animate) {\n        var me = this,\n            collapseDir = me.collapsed,\n            floatCls = Ext.baseCSSPrefix + 'border-region-slide-in',\n            finalPos,\n            floatedPos,\n            slideInDirection;\n\n        if (me.floatedFromCollapse) {\n            floatedPos = me.getPosition(true);\n            // these are the same cleanups performed by the normal slideOut mechanism:\n            me.slideOutFloatedPanelBegin();\n            me.slideOutFloatedPanelEnd();\n        }\n\n        me.isCollapsingOrExpanding = 2;\n\n        // Expand me and hide the placeholder\n        me.placeholder.hidden = true;\n        me.placeholder.el.hide();\n        me.collapsed = false;\n        me.show();\n\n        if (animate) {\n            // Floated, move it back to the floated pos, and thence into the correct place\n            if (floatedPos) {\n                finalPos = me.el.getXY();\n                me.el.setLeftTop(floatedPos[0], floatedPos[1]);\n                me.el.moveTo(finalPos[0], finalPos[1], {\n                    duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration),\n                    listeners: {\n                        afteranimate: function() {\n                            me.el.removeCls(floatCls);\n                            me.isCollapsingOrExpanding = 0;\n                            me.fireEvent('expand', me);\n                        }\n                    }\n                });\n            }\n            // Not floated, slide it in to the correct place\n            else {\n                me.hidden = true;\n                me.el.addCls(floatCls);\n                me.el.hide();\n                me.collapsed = collapseDir;\n                me.placeholder.show();\n                slideInDirection = collapseDir.substr(0, 1);\n\n                // Slide this Component's el back into place, after which we lay out AGAIN\n                me.hidden = false;\n                me.el.slideIn(slideInDirection, {\n                    preserveScroll: true,\n                    duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration),\n                    listeners: {\n                        afteranimate: function() {\n                            me.collapsed = false;\n\n                            // the ordering of these two lines appears to be important in\n                            // IE9.  There is an odd expand issue in IE 9 in the border layout\n                            // example that causes the index1 child of the south dock region\n                            // to get 'hidden' after a collapse / expand cycle.  See\n                            // EXTJSIV-5318 for details\n                            me.el.removeCls(floatCls);\n                            me.placeholder.hide();\n\n                            me.isCollapsingOrExpanding = 0;\n                            me.fireEvent('expand', me);\n                        }\n                    }\n                });\n            }\n\n        } else {\n            me.isCollapsingOrExpanding = 0;\n            me.fireEvent('expand', me);\n        }\n\n        return me;\n    },\n\n    /**\n     * Invoked after the Panel is Expanded.\n     *\n     * @param {Boolean} animated\n     *\n     * @template\n     * @protected\n     */\n    afterExpand: function(animated) {\n        var me = this,\n            ownerLayout = me.ownerLayout;\n\n        me.isCollapsingOrExpanding = 0;\n        if (me.collapseTool) {\n            me.collapseTool.setType('collapse-' + me.collapseDirection);\n        }\n\n        if (ownerLayout && animated) {\n            ownerLayout.onContentChange(me);\n        }\n\n        me.fireEvent('expand', me);\n    },\n    \n    // inherit docs\n    setBorder: function(border, targetEl) {\n        if (targetEl) {\n            // skip out here, the panel will set the border on the body/header during rendering\n            return;\n        }\n        \n        var me = this,\n            header = me.header;\n            \n        if (!border) {\n            border = 0;\n        } else {\n            border = Ext.Element.unitizeBox((border === true) ? 1 : border);\n        }\n        \n        if (header) {\n            if (header.isHeader) {\n                header.setBorder(border);\n            } else {\n                header.border = border;\n            }\n        }\n        \n        if (me.rendered && me.bodyBorder !== false) {\n            me.body.setStyle('border-width', border);\n        }\n        me.updateLayout();\n        \n        me.border = border;\n    },\n\n    /**\n     * Shortcut for performing an {@link #method-expand} or {@link #method-collapse} based on the current state of the panel.\n     * @return {Ext.panel.Panel} this\n     */\n    toggleCollapse: function() {\n        return (this.collapsed || this.floatedFromCollapse) ? this.expand() : this.collapse();\n    },\n\n    // private\n    getKeyMap : function() {\n        return this.keyMap || (this.keyMap = new Ext.util.KeyMap(Ext.apply({\n            target: this.el\n        }, this.keys)));\n    },\n\n    // private\n    initDraggable : function(){\n        /**\n         * @property {Ext.dd.DragSource} dd\n         * If this Panel is configured {@link #cfg-draggable}, this property will contain an instance of {@link\n         * Ext.dd.DragSource} which handles dragging the Panel.\n         *\n         * The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource} in order to\n         * supply behaviour for each stage of the drag/drop process. See {@link #cfg-draggable}.\n         */\n        this.dd = new Ext.panel.DD(this, Ext.isBoolean(this.draggable) ? null : this.draggable);\n    },\n\n    // private - helper function for ghost\n    ghostTools : function() {\n        var tools = [],\n            header = this.header,\n            headerTools = header ? header.query('tool[hidden=false]') : [],\n            t, tLen, tool;\n\n        if (headerTools.length) {\n            t = 0;\n            tLen = headerTools.length;\n\n            for (; t < tLen; t++) {\n                tool = headerTools[t];\n\n                // Some tools can be full components, and copying them into the ghost\n                // actually removes them from the owning panel. You could also potentially\n                // end up with duplicate DOM ids as well. To avoid any issues we just make\n                // a simple bare-minimum clone of each tool for ghosting purposes.\n                tools.push({\n                    type: tool.type\n                });\n            }\n        } else {\n            tools = [{\n                type: 'placeholder'\n            }];\n        }\n        return tools;\n    },\n\n    // private - used for dragging\n    ghost: function(cls) {\n        var me = this,\n            ghostPanel = me.ghostPanel,\n            box = me.getBox(),\n            header;\n\n        if (!ghostPanel) {\n            ghostPanel = new Ext.panel.Panel({\n                renderTo: document.body,\n                floating: {\n                    shadow: false\n                },\n                frame: me.frame && !me.alwaysFramed,\n                alwaysFramed: me.alwaysFramed,\n                overlapHeader: me.overlapHeader,\n                headerPosition: me.headerPosition,\n                baseCls: me.baseCls,\n                cls: me.baseCls + '-ghost ' + (cls ||'')\n            });\n            me.ghostPanel = ghostPanel;\n        } else {\n            ghostPanel.el.show();\n        }\n        ghostPanel.floatParent = me.floatParent;\n        if (me.floating) {\n            ghostPanel.setZIndex(Ext.Number.from(me.el.getStyle('zIndex'), 0));\n        } else {\n            ghostPanel.toFront();\n        }\n        if (!(me.preventHeader || (me.header === false))) {\n            header = ghostPanel.header;\n            // restore options\n            if (header) {\n                header.suspendLayouts();\n                Ext.Array.forEach(header.query('tool'), header.remove, header);\n                header.resumeLayouts();\n            }\n            ghostPanel.addTool(me.ghostTools());\n            ghostPanel.setTitle(me.title);\n            ghostPanel.setIconCls(me.iconCls);\n        }\n\n        ghostPanel.setPagePosition(box.x, box.y);\n        ghostPanel.setSize(box.width, box.height);\n        me.el.hide();\n        return ghostPanel;\n    },\n\n    // private\n    unghost: function(show, matchPosition) {\n        var me = this;\n        if (!me.ghostPanel) {\n            return;\n        }\n        if (show !== false) {\n            // Show el first, so that position adjustment in setPagePosition\n            // will work when relative positioned elements have their XY read.\n            me.el.show();\n            if (matchPosition !== false) {\n                me.setPagePosition(me.ghostPanel.el.getXY());\n                if (me.hideMode == 'offsets') {\n                    // clear the hidden style because we just repositioned\n                    delete me.el.hideModeStyles;\n                }\n            }\n            Ext.defer(me.focus, 10, me);\n        }\n        me.ghostPanel.el.hide();\n    },\n\n    beginDrag: function() {\n        if (this.floatingDescendants) {\n            this.floatingDescendants.hide();\n        }\n    },\n\n    endDrag: function() {\n        if (this.floatingDescendants) {\n            this.floatingDescendants.show();\n        }\n    },\n\n    initResizable: function(resizable) {\n        if (this.collapsed) {\n            resizable.disabled = true;\n        }\n        this.callParent([resizable]);\n    }\n}, function() {\n    this.prototype.animCollapse = Ext.enableFx;\n});\n\n/**\n * This is the base class for {@link Ext.tip.QuickTip} and {@link Ext.tip.ToolTip} that provides the basic layout and\n * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned\n * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.\n * @xtype tip\n */\nExt.define('Ext.tip.Tip', {\n    extend: 'Ext.panel.Panel',\n\n    alternateClassName: 'Ext.Tip',\n\n    /**\n     * @cfg {Boolean} [closable=false]\n     * True to render a close tool button into the tooltip header.\n     */\n    /**\n     * @cfg {Number} width\n     * Width in pixels of the tip.  Width will be ignored if it\n     * exceeds the bounds of {@link #minWidth} or {@link #maxWidth}.  The maximum\n     * supported value is 500.\n     * \n     * Defaults to auto.\n     */\n    /**\n     * @cfg {Number} minWidth\n     * The minimum width of the tip in pixels.\n     */\n    minWidth : 40,\n    /**\n     * @cfg {Number} maxWidth\n     * The maximum width of the tip in pixels.  The maximum supported value is 500.\n     */\n    maxWidth : 300,\n    /**\n     * @cfg {Boolean/String} shadow\n     * True or \"sides\" for the default effect, \"frame\" for 4-way shadow, and \"drop\"\n     * for bottom-right shadow.\n     */\n    shadow : \"sides\",\n\n    /**\n     * @cfg {String} defaultAlign\n     * **Experimental**. The default {@link Ext.Element#alignTo} anchor position value\n     * for this tip relative to its element of origin.\n     */\n    defaultAlign : \"tl-bl?\",\n    /**\n     * @cfg {Boolean} constrainPosition\n     * If true, then the tooltip will be automatically constrained to stay within\n     * the browser viewport.\n     */\n    constrainPosition : true,\n\n    // private panel overrides\n    autoRender: true,\n    hidden: true,\n    baseCls: Ext.baseCSSPrefix + 'tip',\n    floating: {\n        shadow: true,\n        shim: true,\n        constrain: true\n    },\n    focusOnToFront: false,\n\n    /**\n     * @cfg {String} closeAction\n     * The action to take when the close header tool is clicked:\n     *\n     * - **{@link #method-destroy}** : {@link #method-remove remove} the window from the DOM and\n     *   {@link Ext.Component#method-destroy destroy} it and all descendant Components. The\n     *   window will **not** be available to be redisplayed via the {@link #method-show} method.\n     *\n     * - **{@link #method-hide}** : **Default.** {@link #method-hide} the window by setting visibility\n     *   to hidden and applying negative offsets. The window will be available to be\n     *   redisplayed via the {@link #method-show} method.\n     *\n     * **Note:** This behavior has changed! setting *does* affect the {@link #method-close} method\n     * which will invoke the approriate closeAction.\n     */\n    closeAction: 'hide',\n\n    ariaRole: 'tooltip',\n\n    // Flag to Renderable to always look up the framing styles for this Component\n    alwaysFramed: true,\n\n    frameHeader: false,\n\n    initComponent: function() {\n        var me = this;\n\n        me.floating = Ext.apply({}, {shadow: me.shadow}, me.self.prototype.floating);\n        me.callParent(arguments);\n\n        // Or in the deprecated config. Floating.doConstrain only constrains if the constrain property is truthy.\n        me.constrain = me.constrain || me.constrainPosition;\n    },\n\n    /**\n     * Shows this tip at the specified XY position.  Example usage:\n     *\n     *     // Show the tip at x:50 and y:100\n     *     tip.showAt([50,100]);\n     *\n     * @param {Number[]} xy An array containing the x and y coordinates\n     */\n    showAt : function(xy){\n        var me = this;\n        this.callParent(arguments);\n        // Show may have been vetoed.\n        if (me.isVisible()) {\n            me.setPagePosition(xy[0], xy[1]);\n            if (me.constrainPosition || me.constrain) {\n                me.doConstrain();\n            }\n            me.toFront(true);\n        }\n    },\n\n    /**\n     * **Experimental**. Shows this tip at a position relative to another element using\n     * a standard {@link Ext.Element#alignTo} anchor position value.  Example usage:\n     *\n     *    // Show the tip at the default position ('tl-br?')\n     *    tip.showBy('my-el');\n     *\n     *    // Show the tip's top-left corner anchored to the element's top-right corner\n     *    tip.showBy('my-el', 'tl-tr');\n     *\n     * @param {String/HTMLElement/Ext.Element} el An HTMLElement, Ext.Element or string\n     * id of the target element to align to.\n     *\n     * @param {String} [position] A valid {@link Ext.Element#alignTo} anchor position.\n     * \n     * Defaults to 'tl-br?' or {@link #defaultAlign} if specified.\n     */\n    showBy : function(el, pos) {\n        this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));\n    },\n\n    /**\n     * @private\n     * Set Tip draggable using base Component's draggability\n     */\n    initDraggable : function(){\n        var me = this;\n        me.draggable = {\n            el: me.getDragEl(),\n            delegate: me.header.el,\n            constrain: me,\n            constrainTo: me.el.getScopeParent()\n        };\n        // Important: Bypass Panel's initDraggable. Call direct to Component's implementation.\n        Ext.Component.prototype.initDraggable.call(me);\n    },\n\n    // Tip does not ghost. Drag is \"live\"\n    ghost: undefined,\n    unghost: undefined\n});\n\n/**\n * ToolTip is a {@link Ext.tip.Tip} implementation that handles the common case of displaying a\n * tooltip when hovering over a certain element or elements on the page. It allows fine-grained\n * control over the tooltip's alignment relative to the target element or mouse, and the timing\n * of when it is automatically shown and hidden.\n *\n * This implementation does **not** have a built-in method of automatically populating the tooltip's\n * text based on the target element; you must either configure a fixed {@link #html} value for each\n * ToolTip instance, or implement custom logic (e.g. in a {@link #beforeshow} event listener) to\n * generate the appropriate tooltip content on the fly. See {@link Ext.tip.QuickTip} for a more\n * convenient way of automatically populating and configuring a tooltip based on specific DOM\n * attributes of each target element.\n *\n * # Basic Example\n *\n *     var tip = Ext.create('Ext.tip.ToolTip', {\n *         target: 'clearButton',\n *         html: 'Press this button to clear the form'\n *     });\n *\n * {@img Ext.tip.ToolTip/Ext.tip.ToolTip1.png Basic Ext.tip.ToolTip}\n *\n * # Delegation\n *\n * In addition to attaching a ToolTip to a single element, you can also use delegation to attach\n * one ToolTip to many elements under a common parent. This is more efficient than creating many\n * ToolTip instances. To do this, point the {@link #target} config to a common ancestor of all the\n * elements, and then set the {@link #delegate} config to a CSS selector that will select all the\n * appropriate sub-elements.\n *\n * When using delegation, it is likely that you will want to programmatically change the content\n * of the ToolTip based on each delegate element; you can do this by implementing a custom\n * listener for the {@link #beforeshow} event. Example:\n *\n *     var store = Ext.create('Ext.data.ArrayStore', {\n *         fields: ['company', 'price', 'change'],\n *         data: [\n *             ['3m Co',                               71.72, 0.02],\n *             ['Alcoa Inc',                           29.01, 0.42],\n *             ['Altria Group Inc',                    83.81, 0.28],\n *             ['American Express Company',            52.55, 0.01],\n *             ['American International Group, Inc.',  64.13, 0.31],\n *             ['AT&T Inc.',                           31.61, -0.48]\n *         ]\n *     });\n *\n *     var grid = Ext.create('Ext.grid.Panel', {\n *         title: 'Array Grid',\n *         store: store,\n *         columns: [\n *             {text: 'Company', flex: 1, dataIndex: 'company'},\n *             {text: 'Price', width: 75, dataIndex: 'price'},\n *             {text: 'Change', width: 75, dataIndex: 'change'}\n *         ],\n *         height: 200,\n *         width: 400,\n *         renderTo: Ext.getBody()\n *     });\n *\n *     grid.getView().on('render', function(view) {\n *         view.tip = Ext.create('Ext.tip.ToolTip', {\n *             // The overall target element.\n *             target: view.el,\n *             // Each grid row causes its own separate show and hide.\n *             delegate: view.itemSelector,\n *             // Moving within the row should not hide the tip.\n *             trackMouse: true,\n *             // Render immediately so that tip.body can be referenced prior to the first show.\n *             renderTo: Ext.getBody(),\n *             listeners: {\n *                 // Change content dynamically depending on which element triggered the show.\n *                 beforeshow: function updateTipBody(tip) {\n *                     tip.update('Over company \"' + view.getRecord(tip.triggerElement).get('company') + '\"');\n *                 }\n *             }\n *         });\n *     });\n *\n * {@img Ext.tip.ToolTip/Ext.tip.ToolTip2.png Ext.tip.ToolTip with delegation}\n *\n * # Alignment\n *\n * The following configuration properties allow control over how the ToolTip is aligned relative to\n * the target element and/or mouse pointer:\n *\n * - {@link #anchor}\n * - {@link #anchorToTarget}\n * - {@link #anchorOffset}\n * - {@link #trackMouse}\n * - {@link #mouseOffset}\n *\n * # Showing/Hiding\n *\n * The following configuration properties allow control over how and when the ToolTip is automatically\n * shown and hidden:\n *\n * - {@link #autoHide}\n * - {@link #showDelay}\n * - {@link #hideDelay}\n * - {@link #dismissDelay}\n *\n * @docauthor Jason Johnston <jason@sencha.com>\n */\nExt.define('Ext.tip.ToolTip', {\n    extend: 'Ext.tip.Tip',\n    alias: 'widget.tooltip',\n    alternateClassName: 'Ext.ToolTip',\n    /**\n     * @property {HTMLElement} triggerElement\n     * When a ToolTip is configured with the `{@link #delegate}`\n     * option to cause selected child elements of the `{@link #target}`\n     * Element to each trigger a separate show event, this property is set to\n     * the DOM element which triggered the show.\n     */\n    /**\n     * @cfg {HTMLElement/Ext.Element/String} target\n     * The target element or string id to monitor for mouseover events to trigger\n     * showing this ToolTip.\n     */\n    /**\n     * @cfg {Boolean} [autoHide=true]\n     * True to automatically hide the tooltip after the\n     * mouse exits the target element or after the `{@link #dismissDelay}`\n     * has expired if set.  If `{@link #closable} = true`\n     * a close tool button will be rendered into the tooltip header.\n     */\n    autoHide: true,\n    \n    /**\n     * @cfg {Number} showDelay\n     * Delay in milliseconds before the tooltip displays after the mouse enters the target element.\n     */\n    showDelay: 500,\n    /**\n     * @cfg {Number} hideDelay\n     * Delay in milliseconds after the mouse exits the target element but before the tooltip actually hides.\n     * Set to 0 for the tooltip to hide immediately.\n     */\n    hideDelay: 200,\n    /**\n     * @cfg {Number} dismissDelay\n     * Delay in milliseconds before the tooltip automatically hides. To disable automatic hiding, set\n     * dismissDelay = 0.\n     */\n    dismissDelay: 5000,\n    /**\n     * @cfg {Number[]} [mouseOffset=[15,18]]\n     * An XY offset from the mouse position where the tooltip should be shown.\n     */\n    /**\n     * @cfg {Boolean} trackMouse\n     * True to have the tooltip follow the mouse as it moves over the target element.\n     */\n    trackMouse: false,\n    /**\n     * @cfg {String} anchor\n     * If specified, indicates that the tip should be anchored to a\n     * particular side of the target element or mouse pointer (\"top\", \"right\", \"bottom\",\n     * or \"left\"), with an arrow pointing back at the target or mouse pointer. If\n     * {@link #constrainPosition} is enabled, this will be used as a preferred value\n     * only and may be flipped as needed.\n     */\n    /**\n     * @cfg {Boolean} anchorToTarget\n     * True to anchor the tooltip to the target element, false to anchor it relative to the mouse coordinates.\n     * When `anchorToTarget` is true, use `{@link #defaultAlign}` to control tooltip alignment to the\n     * target element.  When `anchorToTarget` is false, use `{@link #anchor}` instead to control alignment.\n     */\n    anchorToTarget: true,\n    /**\n     * @cfg {Number} anchorOffset\n     * A numeric pixel value used to offset the default position of the anchor arrow.  When the anchor\n     * position is on the top or bottom of the tooltip, `anchorOffset` will be used as a horizontal offset.\n     * Likewise, when the anchor position is on the left or right side, `anchorOffset` will be used as\n     * a vertical offset.\n     */\n    anchorOffset: 0,\n    /**\n     * @cfg {String} delegate\n     *\n     * A {@link Ext.DomQuery DomQuery} selector which allows selection of individual elements within the\n     * `{@link #target}` element to trigger showing and hiding the ToolTip as the mouse moves within the\n     * target.\n     *\n     * When specified, the child element of the target which caused a show event is placed into the\n     * `{@link #triggerElement}` property before the ToolTip is shown.\n     *\n     * This may be useful when a Component has regular, repeating elements in it, each of which need a\n     * ToolTip which contains information specific to that element.\n     *\n     * See the delegate example in class documentation of {@link Ext.tip.ToolTip}.\n     */\n\n    // private\n    targetCounter: 0,\n    quickShowInterval: 250,\n\n    // private\n    initComponent: function() {\n        var me = this;\n        me.callParent(arguments);\n        me.lastActive = new Date();\n        me.setTarget(me.target);\n        me.origAnchor = me.anchor;\n    },\n\n    // private\n    onRender: function(ct, position) {\n        var me = this;\n        me.callParent(arguments);\n        me.anchorCls = Ext.baseCSSPrefix + 'tip-anchor-' + me.getAnchorPosition();\n        me.anchorEl = me.el.createChild({\n            cls: Ext.baseCSSPrefix + 'tip-anchor ' + me.anchorCls\n        });\n    },\n\n    /**\n     * Binds this ToolTip to the specified element. The tooltip will be displayed when the mouse moves over the element.\n     * @param {String/HTMLElement/Ext.Element} t The Element, HtmlElement, or ID of an element to bind to\n     */\n    setTarget: function(target) {\n        var me = this,\n            t = Ext.get(target),\n            tg;\n\n        if (me.target) {\n            tg = Ext.get(me.target);\n            me.mun(tg, 'mouseover', me.onTargetOver, me);\n            me.mun(tg, 'mouseout', me.onTargetOut, me);\n            me.mun(tg, 'mousemove', me.onMouseMove, me);\n        }\n\n        me.target = t;\n        if (t) {\n\n            me.mon(t, {\n                // TODO - investigate why IE6/7 seem to fire recursive resize in e.getXY\n                // breaking QuickTip#onTargetOver (EXTJSIV-1608)\n                freezeEvent: true,\n\n                mouseover: me.onTargetOver,\n                mouseout: me.onTargetOut,\n                mousemove: me.onMouseMove,\n                scope: me\n            });\n        }\n        if (me.anchor) {\n            me.anchorTarget = me.target;\n        }\n    },\n\n    // private\n    onMouseMove: function(e) {\n        var me = this,\n            t = me.delegate ? e.getTarget(me.delegate) : me.triggerElement = true,\n            xy;\n        if (t) {\n            me.targetXY = e.getXY();\n            if (t === me.triggerElement) {\n                if (!me.hidden && me.trackMouse) {\n                    xy = me.getTargetXY();\n                    if (me.constrainPosition) {\n                        xy = me.el.adjustForConstraints(xy, me.el.getScopeParent());\n                    }\n                    me.setPagePosition(xy);\n                }\n            } else {\n                me.hide();\n                me.lastActive = new Date(0);\n                me.onTargetOver(e);\n            }\n        } else if ((!me.closable && me.isVisible()) && me.autoHide !== false) {\n            me.hide();\n        }\n    },\n\n    // private\n    getTargetXY: function() {\n        var me = this,\n            mouseOffset,\n            offsets, xy, dw, dh, de, bd, scrollX, scrollY, axy, sz, constrainPosition;\n        if (me.delegate) {\n            me.anchorTarget = me.triggerElement;\n        }\n        if (me.anchor) {\n            me.targetCounter++;\n            offsets = me.getOffsets();\n            xy = (me.anchorToTarget && !me.trackMouse) ? me.el.getAlignToXY(me.anchorTarget, me.getAnchorAlign()) : me.targetXY;\n            dw = Ext.Element.getViewWidth() - 5;\n            dh = Ext.Element.getViewHeight() - 5;\n            de = document.documentElement;\n            bd = document.body;\n            scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5;\n            scrollY = (de.scrollTop || bd.scrollTop || 0) + 5;\n            axy = [xy[0] + offsets[0], xy[1] + offsets[1]];\n            sz = me.getSize();\n            constrainPosition = me.constrainPosition;\n\n            me.anchorEl.removeCls(me.anchorCls);\n\n            if (me.targetCounter < 2 && constrainPosition) {\n                if (axy[0] < scrollX) {\n                    if (me.anchorToTarget) {\n                        me.defaultAlign = 'l-r';\n                        if (me.mouseOffset) {\n                            me.mouseOffset[0] *= -1;\n                        }\n                    }\n                    me.anchor = 'left';\n                    return me.getTargetXY();\n                }\n                if (axy[0] + sz.width > dw) {\n                    if (me.anchorToTarget) {\n                        me.defaultAlign = 'r-l';\n                        if (me.mouseOffset) {\n                            me.mouseOffset[0] *= -1;\n                        }\n                    }\n                    me.anchor = 'right';\n                    return me.getTargetXY();\n                }\n                if (axy[1] < scrollY) {\n                    if (me.anchorToTarget) {\n                        me.defaultAlign = 't-b';\n                        if (me.mouseOffset) {\n                            me.mouseOffset[1] *= -1;\n                        }\n                    }\n                    me.anchor = 'top';\n                    return me.getTargetXY();\n                }\n                if (axy[1] + sz.height > dh) {\n                    if (me.anchorToTarget) {\n                        me.defaultAlign = 'b-t';\n                        if (me.mouseOffset) {\n                            me.mouseOffset[1] *= -1;\n                        }\n                    }\n                    me.anchor = 'bottom';\n                    return me.getTargetXY();\n                }\n            }\n\n            me.anchorCls = Ext.baseCSSPrefix + 'tip-anchor-' + me.getAnchorPosition();\n            me.anchorEl.addCls(me.anchorCls);\n            me.targetCounter = 0;\n            return axy;\n        } else {\n            mouseOffset = me.getMouseOffset();\n            return (me.targetXY) ? [me.targetXY[0] + mouseOffset[0], me.targetXY[1] + mouseOffset[1]] : mouseOffset;\n        }\n    },\n\n    getMouseOffset: function() {\n        var me = this,\n        offset = me.anchor ? [0, 0] : [15, 18];\n        if (me.mouseOffset) {\n            offset[0] += me.mouseOffset[0];\n            offset[1] += me.mouseOffset[1];\n        }\n        return offset;\n    },\n\n    // private\n    getAnchorPosition: function() {\n        var me = this,\n            m;\n        if (me.anchor) {\n            me.tipAnchor = me.anchor.charAt(0);\n        } else {\n            m = me.defaultAlign.match(/^([a-z]+)-([a-z]+)(\\?)?$/);\n            if (!m) {\n                Ext.Error.raise('The AnchorTip.defaultAlign value \"' + me.defaultAlign + '\" is invalid.');\n            }\n            me.tipAnchor = m[1].charAt(0);\n        }\n\n        switch (me.tipAnchor) {\n        case 't':\n            return 'top';\n        case 'b':\n            return 'bottom';\n        case 'r':\n            return 'right';\n        }\n        return 'left';\n    },\n\n    // private\n    getAnchorAlign: function() {\n        switch (this.anchor) {\n        case 'top':\n            return 'tl-bl';\n        case 'left':\n            return 'tl-tr';\n        case 'right':\n            return 'tr-tl';\n        default:\n            return 'bl-tl';\n        }\n    },\n\n    // private\n    getOffsets: function() {\n        var me = this,\n            mouseOffset,\n            offsets,\n            ap = me.getAnchorPosition().charAt(0);\n        if (me.anchorToTarget && !me.trackMouse) {\n            switch (ap) {\n            case 't':\n                offsets = [0, 9];\n                break;\n            case 'b':\n                offsets = [0, -13];\n                break;\n            case 'r':\n                offsets = [ - 13, 0];\n                break;\n            default:\n                offsets = [9, 0];\n                break;\n            }\n        } else {\n            switch (ap) {\n            case 't':\n                offsets = [ - 15 - me.anchorOffset, 30];\n                break;\n            case 'b':\n                offsets = [ - 19 - me.anchorOffset, -13 - me.el.dom.offsetHeight];\n                break;\n            case 'r':\n                offsets = [ - 15 - me.el.dom.offsetWidth, -13 - me.anchorOffset];\n                break;\n            default:\n                offsets = [25, -13 - me.anchorOffset];\n                break;\n            }\n        }\n        mouseOffset = me.getMouseOffset();\n        offsets[0] += mouseOffset[0];\n        offsets[1] += mouseOffset[1];\n\n        return offsets;\n    },\n\n    // private\n    onTargetOver: function(e) {\n        var me = this,\n            t;\n\n        if (me.disabled || e.within(me.target.dom, true)) {\n            return;\n        }\n        t = e.getTarget(me.delegate);\n        if (t) {\n            me.triggerElement = t;\n            me.clearTimer('hide');\n            me.targetXY = e.getXY();\n            me.delayShow();\n        }\n    },\n\n    // private\n    delayShow: function() {\n        var me = this;\n        if (me.hidden && !me.showTimer) {\n            if (Ext.Date.getElapsed(me.lastActive) < me.quickShowInterval) {\n                me.show();\n            } else {\n                me.showTimer = Ext.defer(me.show, me.showDelay, me);\n            }\n        }\n        else if (!me.hidden && me.autoHide !== false) {\n            me.show();\n        }\n    },\n    \n    onShowVeto: function(){\n        this.callParent();\n        this.clearTimer('show');\n    },\n\n    // private\n    onTargetOut: function(e) {\n        var me = this;\n\n        // If disabled, moving within the current target, ignore the mouseout\n        // EventObject.within is the only correct way to determine this.\n        if (me.disabled || e.within(me.target.dom, true)) {\n            return;\n        }\n        me.clearTimer('show');\n        if (me.autoHide !== false) {\n            me.delayHide();\n        }\n    },\n\n    // private\n    delayHide: function() {\n        var me = this;\n        if (!me.hidden && !me.hideTimer) {\n            me.hideTimer = Ext.defer(me.hide, me.hideDelay, me);\n        }\n    },\n\n    /**\n     * Hides this tooltip if visible.\n     */\n    hide: function() {\n        var me = this;\n        me.clearTimer('dismiss');\n        me.lastActive = new Date();\n        if (me.anchorEl) {\n            me.anchorEl.hide();\n        }\n        me.callParent(arguments);\n        delete me.triggerElement;\n    },\n\n    /**\n     * Shows this tooltip at the current event target XY position.\n     */\n    show: function() {\n        var me = this;\n\n        // Show this Component first, so that sizing can be calculated\n        // pre-show it off screen so that the el will have dimensions\n        this.callParent();\n        if (this.hidden === false) {\n            me.setPagePosition(-10000, -10000);\n\n            if (me.anchor) {\n                me.anchor = me.origAnchor;\n            }\n            \n            if (!me.calledFromShowAt) {\n                me.showAt(me.getTargetXY());\n            }\n\n            if (me.anchor) {\n                me.syncAnchor();\n                me.anchorEl.show();\n            } else {\n                me.anchorEl.hide();\n            }\n        }\n    },\n\n    // inherit docs\n    showAt: function(xy) {\n        var me = this;\n        me.lastActive = new Date();\n        me.clearTimers();\n        me.calledFromShowAt = true;\n\n        // Only call if this is hidden. May have been called from show above.\n        if (!me.isVisible()) {\n            this.callParent(arguments);\n        }\n\n        // Show may have been vetoed.\n        if (me.isVisible()) {\n            me.setPagePosition(xy[0], xy[1]);\n            if (me.constrainPosition || me.constrain) {\n                me.doConstrain();\n            }\n            me.toFront(true);\n            me.el.sync(true);\n            if (me.dismissDelay && me.autoHide !== false) {\n                me.dismissTimer = Ext.defer(me.hide, me.dismissDelay, me);\n            }\n            if (me.anchor) {\n                me.syncAnchor();\n                if (!me.anchorEl.isVisible()) {\n                    me.anchorEl.show();\n                }\n            } else {\n                me.anchorEl.hide();\n            }\n        }\n        delete me.calledFromShowAt;\n    },\n\n    // private\n    syncAnchor: function() {\n        var me = this,\n            anchorPos,\n            targetPos,\n            offset;\n        switch (me.tipAnchor.charAt(0)) {\n        case 't':\n            anchorPos = 'b';\n            targetPos = 'tl';\n            offset = [20 + me.anchorOffset, 1];\n            break;\n        case 'r':\n            anchorPos = 'l';\n            targetPos = 'tr';\n            offset = [ - 1, 12 + me.anchorOffset];\n            break;\n        case 'b':\n            anchorPos = 't';\n            targetPos = 'bl';\n            offset = [20 + me.anchorOffset, -1];\n            break;\n        default:\n            anchorPos = 'r';\n            targetPos = 'tl';\n            offset = [1, 12 + me.anchorOffset];\n            break;\n        }\n        me.anchorEl.alignTo(me.el, anchorPos + '-' + targetPos, offset);\n        me.anchorEl.setStyle('z-index', parseInt(me.el.getZIndex(), 10) || 0 + 1).setVisibilityMode(Ext.Element.DISPLAY);\n    },\n\n    // private\n    setPagePosition: function(x, y) {\n        var me = this;\n        me.callParent(arguments);\n        if (me.anchor) {\n            me.syncAnchor();\n        }\n    },\n\n    // private\n    clearTimer: function(name) {\n        name = name + 'Timer';\n        clearTimeout(this[name]);\n        delete this[name];\n    },\n\n    // private\n    clearTimers: function() {\n        var me = this;\n        me.clearTimer('show');\n        me.clearTimer('dismiss');\n        me.clearTimer('hide');\n    },\n\n    // private\n    onShow: function() {\n        var me = this;\n        me.callParent();\n        me.mon(Ext.getDoc(), 'mousedown', me.onDocMouseDown, me);\n    },\n\n    // private\n    onHide: function() {\n        var me = this;\n        me.callParent();\n        me.mun(Ext.getDoc(), 'mousedown', me.onDocMouseDown, me);\n    },\n\n    // private\n    onDocMouseDown: function(e) {\n        var me = this;\n        if (!me.closable && !e.within(me.el.dom)) {\n            me.disable();\n            Ext.defer(me.doEnable, 100, me);\n        }\n    },\n\n    // private\n    doEnable: function() {\n        if (!this.isDestroyed) {\n            this.enable();\n        }\n    },\n\n    // private\n    onDisable: function() {\n        this.callParent();\n        this.clearTimers();\n        this.hide();\n    },\n\n    beforeDestroy: function() {\n        var me = this;\n        me.clearTimers();\n        Ext.destroy(me.anchorEl);\n        delete me.anchorEl;\n        delete me.target;\n        delete me.anchorTarget;\n        delete me.triggerElement;\n        me.callParent();\n    },\n\n    // private\n    onDestroy: function() {\n        Ext.getDoc().un('mousedown', this.onDocMouseDown, this);\n        this.callParent();\n    }\n});\n\n/**\n * A specialized tooltip class for tooltips that can be specified in markup and automatically managed\n * by the global {@link Ext.tip.QuickTipManager} instance.  See the QuickTipManager documentation for\n * additional usage details and examples.\n */\nExt.define('Ext.tip.QuickTip', {\n    extend: 'Ext.tip.ToolTip',\n    alias: 'widget.quicktip',\n    alternateClassName: 'Ext.QuickTip',\n\n    /**\n     * @cfg {String/HTMLElement/Ext.Element} target\n     * The target HTMLElement, Ext.Element or id to associate with this Quicktip.\n     * \n     * Defaults to the document.\n     */\n\n    /**\n     * @cfg {Boolean} interceptTitles\n     * True to automatically use the element's DOM title value if available.\n     */\n    interceptTitles : false,\n\n    // Force creation of header Component\n    title: '&#160;',\n\n    // private\n    tagConfig : {\n        namespace : \"data-\",\n        attribute : \"qtip\",\n        width : \"qwidth\",\n        target : \"target\",\n        title : \"qtitle\",\n        hide : \"hide\",\n        cls : \"qclass\",\n        align : \"qalign\",\n        anchor : \"anchor\"\n    },\n\n    // private\n    initComponent : function(){\n        var me = this;\n\n        me.target = me.target || Ext.getDoc();\n        me.targets = me.targets || {};\n        me.callParent();\n    },\n\n    /**\n     * Configures a new quick tip instance and assigns it to a target element.\n     *\n     * For example usage, see the {@link Ext.tip.QuickTipManager} class header.\n     *\n     * @param {Object} config The config object with the following properties:\n     * @param config.autoHide\n     * @param config.cls\n     * @param config.dismissDelay overrides the singleton value\n     * @param config.target required\n     * @param config.text required\n     * @param config.title\n     * @param config.width\n     */\n    register : function(config){\n        var configs = Ext.isArray(config) ? config : arguments,\n            i = 0,\n            len = configs.length,\n            target, j, targetLen;\n\n        for (; i < len; i++) {\n            config = configs[i];\n            target = config.target;\n            if (target) {\n                if (Ext.isArray(target)) {\n                    for (j = 0, targetLen = target.length; j < targetLen; j++) {\n                        this.targets[Ext.id(target[j])] = config;\n                    }\n                } else{\n                    this.targets[Ext.id(target)] = config;\n                }\n            }\n        }\n    },\n\n    /**\n     * Removes this quick tip from its element and destroys it.\n     * @param {String/HTMLElement/Ext.Element} el The element from which the quick tip\n     * is to be removed or ID of the element.\n     */\n    unregister : function(el){\n        delete this.targets[Ext.id(el)];\n    },\n\n    /**\n     * Hides a visible tip or cancels an impending show for a particular element.\n     * @param {String/HTMLElement/Ext.Element} el The element that is the target of\n     * the tip or ID of the element.\n     */\n    cancelShow: function(el){\n        var me = this,\n            activeTarget = me.activeTarget;\n\n        el = Ext.get(el).dom;\n        if (me.isVisible()) {\n            if (activeTarget && activeTarget.el == el) {\n                me.hide();\n            }\n        } else if (activeTarget && activeTarget.el == el) {\n            me.clearTimer('show');\n        }\n    },\n\n    /**\n     * @private\n     * Reads the tip text from the closest node to the event target which contains the\n     * attribute we are configured to look for. Returns an object containing the text\n     * from the attribute, and the target element from which the text was read.\n     */\n    getTipCfg: function(e) {\n        var t = e.getTarget(),\n            titleText = t.title,\n            cfg;\n\n        if (this.interceptTitles && titleText && Ext.isString(titleText)) {\n            t.qtip = titleText;\n            t.removeAttribute(\"title\");\n            e.preventDefault();\n            return {\n                text: titleText\n            };\n        }\n        else {\n            cfg = this.tagConfig;\n            t = e.getTarget('[' + cfg.namespace + cfg.attribute + ']');\n            if (t) {\n                return {\n                    target: t,\n                    text: t.getAttribute(cfg.namespace + cfg.attribute)\n                };\n            }\n        }\n    },\n\n    // private\n    onTargetOver : function(e){\n        var me = this,\n            target = e.getTarget(me.delegate),\n            hasShowDelay,\n            delay,\n            elTarget,\n            cfg,\n            ns,\n            tipConfig,\n            autoHide,\n            targets, targetEl, value, key;\n\n        if (me.disabled) {\n            return;\n        }\n\n        // TODO - this causes \"e\" to be recycled in IE6/7 (EXTJSIV-1608) so ToolTip#setTarget\n        // was changed to include freezeEvent. The issue seems to be a nested 'resize' event\n        // that smashed Ext.EventObject.\n        me.targetXY = e.getXY();\n\n        // If the over target was filtered out by the delegate selector, or is not an HTMLElement, or is the <html> or the <body>, then return\n        if(!target || target.nodeType !== 1 || target == document.documentElement || target == document.body){\n            return;\n        }\n\n        if (me.activeTarget && ((target == me.activeTarget.el) || Ext.fly(me.activeTarget.el).contains(target))) {\n            me.clearTimer('hide');\n            me.show();\n            return;\n        }\n\n        if (target) {\n            targets = me.targets;\n\n            for (key in targets) {\n                if (targets.hasOwnProperty(key)) {\n                    value = targets[key];\n\n                    targetEl = Ext.fly(value.target);\n                    if (targetEl && (targetEl.dom === target || targetEl.contains(target))) {\n                        elTarget = targetEl.dom;\n                        break;\n                    }\n                }\n            }\n\n            if (elTarget) {\n                me.activeTarget = me.targets[elTarget.id];\n                me.activeTarget.el = target;\n                me.anchor = me.activeTarget.anchor;\n                if (me.anchor) {\n                    me.anchorTarget = target;\n                }\n                hasShowDelay = Ext.isDefined(me.activeTarget.showDelay);\n                if (hasShowDelay) {\n                    delay = me.showDelay;\n                    me.showDelay = me.activeTarget.showDelay;\n                }\n                me.delayShow();\n                if (hasShowDelay) {\n                    me.showDelay = delay;\n                }\n                return;\n            }\n        }\n\n        // Should be a fly.\n        elTarget = Ext.fly(target, '_quicktip-target');\n        cfg = me.tagConfig;\n        ns = cfg.namespace;\n        tipConfig = me.getTipCfg(e);\n\n        if (tipConfig) {\n\n            // getTipCfg may look up the parentNode axis for a tip text attribute and will return the new target node.\n            // Change our target element to match that from which the tip text attribute was read.\n            if (tipConfig.target) {\n                target = tipConfig.target;\n                elTarget = Ext.fly(target, '_quicktip-target');\n            }\n            autoHide = elTarget.getAttribute(ns + cfg.hide);\n\n            me.activeTarget = {\n                el: target,\n                text: tipConfig.text,\n                width: +elTarget.getAttribute(ns + cfg.width) || null,\n                autoHide: autoHide != \"user\" && autoHide !== 'false',\n                title: elTarget.getAttribute(ns + cfg.title),\n                cls: elTarget.getAttribute(ns + cfg.cls),\n                align: elTarget.getAttribute(ns + cfg.align)\n\n            };\n            me.anchor = elTarget.getAttribute(ns + cfg.anchor);\n            if (me.anchor) {\n                me.anchorTarget = target;\n            }\n            hasShowDelay = Ext.isDefined(me.activeTarget.showDelay);\n            if (hasShowDelay) {\n                delay = me.showDelay;\n                me.showDelay = me.activeTarget.showDelay;\n            }\n            me.delayShow();\n            if (hasShowDelay) {\n                me.showDelay = delay;\n            }\n        }\n    },\n\n    // private\n    onTargetOut : function(e){\n        var me = this,\n            active = me.activeTarget,\n            hasHideDelay,\n            delay;\n\n        // If moving within the current target, and it does not have a new tip, ignore the mouseout\n        // EventObject.within is the only correct way to determine this.\n        if (active && e.within(me.activeTarget.el) && !me.getTipCfg(e)) {\n            return;\n        }\n\n        me.clearTimer('show');\n        delete me.activeTarget;\n        if (me.autoHide !== false) {\n            hasHideDelay = active && Ext.isDefined(active.hideDelay);\n            if (hasHideDelay) {\n                delay = me.hideDelay;\n                me.hideDelay = active.hideDelay;\n            }\n            me.delayHide();\n            if (hasHideDelay) {\n                me.hideDelay = delay;\n            }\n        }\n    },\n\n    // inherit docs\n    showAt : function(xy){\n        var me = this,\n            target = me.activeTarget,\n            cls;\n\n        if (target) {\n            if (!me.rendered) {\n                me.render(Ext.getBody());\n                me.activeTarget = target;\n            }\n            me.suspendLayouts();\n            if (target.title) {\n                me.setTitle(target.title);\n                me.header.show();\n            } else {\n                me.header.hide();\n            }\n            me.update(target.text);\n            me.autoHide = target.autoHide;\n            me.dismissDelay = target.dismissDelay || me.dismissDelay;\n            if (target.mouseOffset) {\n                xy[0] += target.mouseOffset[0];\n                xy[1] += target.mouseOffset[1];\n            }\n\n            cls = me.lastCls;\n            if (cls) {\n                me.removeCls(cls);\n                delete me.lastCls;\n            }\n\n            cls = target.cls;\n            if (cls) {\n                me.addCls(cls);\n                me.lastCls = cls;\n            }\n\n            me.setWidth(target.width);\n\n            if (me.anchor) {\n                me.constrainPosition = false;\n            } else if (target.align) { // TODO: this doesn't seem to work consistently\n                xy = me.el.getAlignToXY(target.el, target.align);\n                me.constrainPosition = false;\n            }else{\n                me.constrainPosition = true;\n            }\n            me.resumeLayouts(true);\n        }\n        me.callParent([xy]);\n    },\n\n    // inherit docs\n    hide: function(){\n        delete this.activeTarget;\n        this.callParent();\n    }\n});\n\n/**\n * Provides attractive and customizable tooltips for any element. The QuickTips\n * singleton is used to configure and manage tooltips globally for multiple elements\n * in a generic manner.  To create individual tooltips with maximum customizability,\n * you should consider either {@link Ext.tip.Tip} or {@link Ext.tip.ToolTip}.\n *\n * Quicktips can be configured via tag attributes directly in markup, or by\n * registering quick tips programmatically via the {@link #register} method.\n *\n * The singleton's instance of {@link Ext.tip.QuickTip} is available via\n * {@link #getQuickTip}, and supports all the methods, and all the all the\n * configuration properties of Ext.tip.QuickTip. These settings will apply to all\n * tooltips shown by the singleton.\n *\n * Below is the summary of the configuration properties which can be used.\n * For detailed descriptions see the config options for the\n * {@link Ext.tip.QuickTip QuickTip} class\n *\n * ## QuickTips singleton configs (all are optional)\n *\n *  - `dismissDelay`\n *  - `hideDelay`\n *  - `maxWidth`\n *  - `minWidth`\n *  - `showDelay`\n *  - `trackMouse`\n *\n * ## Target element configs (optional unless otherwise noted)\n *\n *  - `autoHide`\n *  - `cls`\n *  - `dismissDelay` (overrides singleton value)\n *  - `target` (required)\n *  - `text` (required)\n *  - `title`\n *  - `width`\n *\n * Here is an example showing how some of these config options could be used:\n *\n *     @example\n *     // Init the singleton.  Any tag-based quick tips will start working.\n *     Ext.tip.QuickTipManager.init();\n *\n *     // Apply a set of config properties to the singleton\n *     Ext.apply(Ext.tip.QuickTipManager.getQuickTip(), {\n *         maxWidth: 200,\n *         minWidth: 100,\n *         showDelay: 50      // Show 50ms after entering target\n *     });\n *\n *     // Create a small panel to add a quick tip to\n *     Ext.create('Ext.container.Container', {\n *         id: 'quickTipContainer',\n *         width: 200,\n *         height: 150,\n *         style: {\n *             backgroundColor:'#000000'\n *         },\n *         renderTo: Ext.getBody()\n *     });\n *\n *\n *     // Manually register a quick tip for a specific element\n *     Ext.tip.QuickTipManager.register({\n *         target: 'quickTipContainer',\n *         title: 'My Tooltip',\n *         text: 'This tooltip was added in code',\n *         width: 100,\n *         dismissDelay: 10000 // Hide after 10 seconds hover\n *     });\n *\n * To register a quick tip in markup, you simply add one or more of the valid QuickTip\n * attributes prefixed with the **data-** namespace.  The HTML element itself is\n * automatically set as the quick tip target. Here is the summary of supported attributes\n * (optional unless otherwise noted):\n *\n *  - `hide`: Specifying \"user\" is equivalent to setting autoHide = false.\n *     Any other value will be the same as autoHide = true.\n *  - `qclass`: A CSS class to be applied to the quick tip\n *     (equivalent to the 'cls' target element config).\n *  - `qtip (required)`: The quick tip text (equivalent to the 'text' target element config).\n *  - `qtitle`: The quick tip title (equivalent to the 'title' target element config).\n *  - `qwidth`: The quick tip width (equivalent to the 'width' target element config).\n *\n * Here is an example of configuring an HTML element to display a tooltip from markup:\n *\n *     // Add a quick tip to an HTML button\n *     <input type=\"button\" value=\"OK\" data-qtitle=\"OK Button\" data-qwidth=\"100\"\n *          data-qtip=\"This is a quick tip from markup!\"></input>\n *\n * @singleton\n */\nExt.define('Ext.tip.QuickTipManager', (function() {\n    var tip,\n        disabled = false;\n\n    return {\n        requires: ['Ext.tip.QuickTip'],\n        singleton: true,\n        alternateClassName: 'Ext.QuickTips',\n\n        /**\n         * Initializes the global QuickTips instance and prepare any quick tips.\n         * @param {Boolean} [autoRender=true] True to render the QuickTips container\n         * immediately to preload images.\n         * @param {Object} [config] config object for the created QuickTip. By\n         * default, the {@link Ext.tip.QuickTip QuickTip} class is instantiated, but this can\n         * be changed by supplying an xtype property or a className property in this object.\n         * All other properties on this object are configuration for the created component.\n         */\n        init : function (autoRender, config) {\n            if (!tip) {\n                if (!Ext.isReady) {\n                    Ext.onReady(function(){\n                        Ext.tip.QuickTipManager.init(autoRender, config);\n                    });\n                    return;\n                }\n\n                var tipConfig = Ext.apply({ disabled: disabled, id: 'ext-quicktips-tip' }, config),\n                    className = tipConfig.className,\n                    xtype = tipConfig.xtype;\n\n                if (className) {\n                    delete tipConfig.className;\n                } else if (xtype) {\n                    className = 'widget.' + xtype;\n                    delete tipConfig.xtype;\n                }\n\n                if (autoRender !== false) {\n                    tipConfig.renderTo = document.body;\n\n                    if (tipConfig.renderTo.tagName.toUpperCase() != 'BODY') { // e.g., == 'FRAMESET'\n                        Ext.Error.raise({\n                            sourceClass: 'Ext.tip.QuickTipManager',\n                            sourceMethod: 'init',\n                            msg: 'Cannot init QuickTipManager: no document body'\n                        });\n                    }\n                }\n\n                tip = Ext.create(className || 'Ext.tip.QuickTip', tipConfig);\n            }\n        },\n\n        /**\n         * Destroys the QuickTips instance.\n         */\n        destroy: function() {\n            if (tip) {\n                var undef;\n                tip.destroy();\n                tip = undef;\n            }\n        },\n\n        // Protected method called by the dd classes\n        ddDisable : function(){\n            // don't disable it if we don't need to\n            if(tip && !disabled){\n                tip.disable();\n            }\n        },\n\n        // Protected method called by the dd classes\n        ddEnable : function(){\n            // only enable it if it hasn't been disabled\n            if(tip && !disabled){\n                tip.enable();\n            }\n        },\n\n        /**\n         * Enables quick tips globally.\n         */\n        enable : function(){\n            if(tip){\n                tip.enable();\n            }\n            disabled = false;\n        },\n\n        /**\n         * Disables quick tips globally.\n         */\n        disable : function(){\n            if(tip){\n                tip.disable();\n            }\n            disabled = true;\n        },\n\n        /**\n         * Returns true if quick tips are enabled, else false.\n         * @return {Boolean}\n         */\n        isEnabled : function(){\n            return tip !== undefined && !tip.disabled;\n        },\n\n        /**\n         * Gets the single {@link Ext.tip.QuickTip QuickTip} instance used to show tips\n         * from all registered elements.\n         * @return {Ext.tip.QuickTip}\n         */\n        getQuickTip : function(){\n            return tip;\n        },\n\n        /**\n         * Configures a new quick tip instance and assigns it to a target element.  See\n         * {@link Ext.tip.QuickTip#register} for details.\n         * @param {Object} config The config object\n         */\n        register : function(){\n            tip.register.apply(tip, arguments);\n        },\n\n        /**\n         * Removes any registered quick tip from the target element and destroys it.\n         * @param {String/HTMLElement/Ext.Element} el The element from which the quick tip\n         * is to be removed or ID of the element.\n         */\n        unregister : function(){\n            tip.unregister.apply(tip, arguments);\n        },\n\n        /**\n         * Alias of {@link #register}.\n         * @inheritdoc Ext.tip.QuickTipManager#register\n         */\n        tips : function(){\n            tip.register.apply(tip, arguments);\n        }\n    };\n}()));\n\n/**\n * @class Ext.app.EventBus\n * @private\n */\nExt.define('Ext.app.EventBus', {\n    requires: [\n        'Ext.util.Event',\n        'Ext.Component'\n    ],\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    constructor: function() {\n        this.mixins.observable.constructor.call(this);\n\n        this.bus = {};\n\n        var me = this;\n        Ext.override(Ext.Component, {\n            fireEvent: function(ev) {\n                if (Ext.util.Observable.prototype.fireEvent.apply(this, arguments) !== false) {\n                    return me.dispatch.call(me, ev, this, arguments);\n                }\n                return false;\n            }\n        });\n    },\n\n    dispatch: function(ev, target, args) {\n        var bus = this.bus,\n            selectors = bus[ev],\n            selector, controllers, id, events, event, i, ln;\n\n        if (selectors) {\n            // Loop over all the selectors that are bound to this event\n            for (selector in selectors) {\n                // Check if the target matches the selector\n                if (selectors.hasOwnProperty(selector) && target.is(selector)) {\n                    // Loop over all the controllers that are bound to this selector\n                    controllers = selectors[selector];\n                    for (id in controllers) {\n                        if (controllers.hasOwnProperty(id)) {\n                            // Loop over all the events that are bound to this selector on this controller\n                            events = controllers[id];\n                            for (i = 0, ln = events.length; i < ln; i++) {\n                                event = events[i];\n                                // Fire the event!\n                                if (event.fire.apply(event, Array.prototype.slice.call(args, 1)) === false) {\n                                    return false;\n                                }\n                            }\n                        }\n                    }\n                }\n            }\n        }\n        return true;\n    },\n\n    control: function(selectors, listeners, controller) {\n        var bus = this.bus,\n            hasListeners, tree, list,\n            selector, options, listener, scope, event, listenerList, ev;\n\n        if (Ext.isString(selectors)) {\n            selector = selectors;\n            selectors = {};\n            selectors[selector] = listeners;\n            this.control(selectors, null, controller);\n            return;\n        }\n\n        hasListeners = Ext.util.Observable.HasListeners.prototype;\n        for (selector in selectors) {\n            if (selectors.hasOwnProperty(selector)) {\n                listenerList = selectors[selector] || {};\n\n                for (ev in listenerList) {\n                    if (listenerList.hasOwnProperty(ev)) {\n                        options  = {};\n                        listener = listenerList[ev];\n                        scope    = controller;\n                        event    = new Ext.util.Event(controller, ev);\n\n                        // Normalize the listener\n                        if (Ext.isObject(listener)) {\n                            options  = listener;\n                            listener = options.fn;\n                            scope    = options.scope || controller;\n\n                            delete options.fn;\n                            delete options.scope;\n                        }\n\n                        event.addListener(listener, scope, options);\n\n                        hasListeners[ev] = 1;\n\n                        // Create the bus tree if it is not there yet\n                        tree = bus[ev] || (bus[ev] = {});\n                        tree = tree[selector] || (tree[selector] = {});\n                        list = tree[controller.id] || (tree[controller.id] = []);\n\n                        // Push our listener in our bus\n                        list.push(event);\n                    }\n                } //end inner loop\n            }\n        } //end outer loop\n    }\n});\n\n/**\n * Represents an Ext JS 4 application, which is typically a single page app using a {@link Ext.container.Viewport Viewport}.\n * A typical Ext.app.Application might look like this:\n *\n *     Ext.application({\n *         name: 'MyApp',\n *         launch: function() {\n *             Ext.create('Ext.container.Viewport', {\n *                 items: {\n *                     html: 'My App'\n *                 }\n *             });\n *         }\n *     });\n *\n * This does several things. First it creates a global variable called 'MyApp' - all of your Application's classes (such\n * as its Models, Views and Controllers) will reside under this single namespace, which drastically lowers the chances\n * of colliding global variables.\n *\n * When the page is ready and all of your JavaScript has loaded, your Application's {@link #launch} function is called,\n * at which time you can run the code that starts your app. Usually this consists of creating a Viewport, as we do in\n * the example above.\n *\n * # Telling Application about the rest of the app\n *\n * Because an Ext.app.Application represents an entire app, we should tell it about the other parts of the app - namely\n * the Models, Views and Controllers that are bundled with the application. Let's say we have a blog management app; we\n * might have Models and Controllers for Posts and Comments, and Views for listing, adding and editing Posts and Comments.\n * Here's how we'd tell our Application about all these things:\n *\n *     Ext.application({\n *         name: 'Blog',\n *         models: ['Post', 'Comment'],\n *         controllers: ['Posts', 'Comments'],\n *\n *         launch: function() {\n *             ...\n *         }\n *     });\n *\n * Note that we didn't actually list the Views directly in the Application itself. This is because Views are managed by\n * Controllers, so it makes sense to keep those dependencies there. The Application will load each of the specified\n * Controllers using the pathing conventions laid out in the [application architecture guide][mvc] - in this case\n * expecting the controllers to reside in app/controller/Posts.js and app/controller/Comments.js. In turn, each\n * Controller simply needs to list the Views it uses and they will be automatically loaded. Here's how our Posts\n * controller like be defined:\n *\n *     Ext.define('MyApp.controller.Posts', {\n *         extend: 'Ext.app.Controller',\n *         views: ['posts.List', 'posts.Edit'],\n *\n *         //the rest of the Controller here\n *     });\n *\n * Because we told our Application about our Models and Controllers, and our Controllers about their Views, Ext JS will\n * automatically load all of our app files for us. This means we don't have to manually add script tags into our html\n * files whenever we add a new class, but more importantly it enables us to create a minimized build of our entire\n * application using the Ext JS 4 SDK Tools.\n *\n * For more information about writing Ext JS 4 applications, please see the [application architecture guide][mvc].\n *\n * [mvc]: #/guide/application_architecture\n *\n * @docauthor Ed Spencer\n */\nExt.define('Ext.app.Application', {\n    extend: 'Ext.app.Controller',\n\n    requires: [\n        'Ext.ModelManager',\n        'Ext.data.Model',\n        'Ext.data.StoreManager',\n        'Ext.tip.QuickTipManager',\n        'Ext.ComponentManager',\n        'Ext.app.EventBus'\n    ],\n\n    /**\n     * @cfg {String} name\n     * The name of your application. This will also be the namespace for your views, controllers\n     * models and stores. Don't use spaces or special characters in the name.\n     */\n\n    /**\n     * @cfg {String[]} controllers\n     * Names of controllers that the app uses.\n     */\n\n    /**\n     * @cfg {Object} scope\n     * The scope to execute the {@link #launch} function in. Defaults to the Application instance.\n     */\n    scope: undefined,\n\n    /**\n     * @cfg {Boolean} enableQuickTips\n     * True to automatically set up Ext.tip.QuickTip support.\n     */\n    enableQuickTips: true,\n\n    /**\n     * @cfg {String} appFolder\n     * The path to the directory which contains all application's classes.\n     * This path will be registered via {@link Ext.Loader#setPath} for the namespace specified\n     * in the {@link #name name} config.\n     */\n    appFolder: 'app',\n\n    /**\n     * @cfg {Boolean} autoCreateViewport\n     * True to automatically load and instantiate AppName.view.Viewport before firing the launch function.\n     */\n    autoCreateViewport: false,\n    \n    /**\n     * @cfg {Object} paths\n     * Additional load paths to add to Ext.Loader.\n     * See {@link Ext.Loader#paths} config for more details.\n     */\n    \n    /**\n     * Creates new Application.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        config = config || {};\n        Ext.apply(this, config);\n\n        var me = this,\n            requires = config.requires || [],\n            controllers, ln, i, controller,\n            paths, path, ns;\n\n        Ext.Loader.setPath(me.name, me.appFolder);\n\n        if (me.paths) {\n            paths = me.paths;\n\n            for (ns in paths) {\n                if (paths.hasOwnProperty(ns)) {\n                    path = paths[ns];\n\n                    Ext.Loader.setPath(ns, path);\n                }\n            }\n        }\n\n        me.callParent(arguments);\n\n        me.eventbus = new Ext.app.EventBus;\n\n        controllers = Ext.Array.from(me.controllers);\n        ln = controllers && controllers.length;\n\n        me.controllers = new Ext.util.MixedCollection();\n\n        if (me.autoCreateViewport) {\n            requires.push(me.getModuleClassName('Viewport', 'view'));\n        }\n\n        for (i = 0; i < ln; i++) {\n            requires.push(me.getModuleClassName(controllers[i], 'controller'));\n        }\n\n        Ext.require(requires);\n\n        Ext.onReady(function() {\n            me.init(me);\n            for (i = 0; i < ln; i++) {\n                controller = me.getController(controllers[i]);\n                controller.init(me);\n            }\n\n            me.onBeforeLaunch.call(me);\n        }, me);\n    },\n\n    control: function(selectors, listeners, controller) {\n        this.eventbus.control(selectors, listeners, controller);\n    },\n\n    /**\n     * @method\n     * @template\n     * Called automatically when the page has completely loaded. This is an empty function that should be\n     * overridden by each application that needs to take action on page load.\n     * @param {String} profile The detected application profile\n     * @return {Boolean} By default, the Application will dispatch to the configured startup controller and\n     * action immediately after running the launch function. Return false to prevent this behavior.\n     */\n    launch: Ext.emptyFn,\n\n    /**\n     * @private\n     */\n    onBeforeLaunch: function() {\n        var me = this,\n            controllers, c, cLen, controller;\n\n        if (me.enableQuickTips) {\n            Ext.tip.QuickTipManager.init();\n        }\n\n        if (me.autoCreateViewport) {\n            me.getView('Viewport').create();\n        }\n\n        me.launch.call(this.scope || this);\n        me.launched = true;\n        me.fireEvent('launch', this);\n\n        controllers = me.controllers.items;\n        cLen        = controllers.length;\n\n        for (c = 0; c < cLen; c++) {\n            controller = controllers[c];\n            controller.onLaunch(this);\n        }\n    },\n\n    getModuleClassName: function(name, module) {\n        // Deciding if a class name must be qualified:\n        // 1 - if the name doesn't contains at least one dot, we must definitely qualify it\n        // 2 - the name may be a qualified name of a known class, but:\n        // 2.1 - in runtime, the loader may not know the class - specially in production - so we must check the class manager\n        // 2.2 - in build time, the class manager may not know the class, but the loader does, so we check the second one\n        //       (the loader check assures it's really a class, and not a namespace, so we can have 'Books.controller.Books',\n        //       and request for a controller called Books will not be underqualified)\n        if (name.indexOf('.') !== -1 && (Ext.ClassManager.isCreated(name) || Ext.Loader.isAClassNameWithAKnownPrefix(name))) {\n            return name;\n        } else {\n            return this.name + '.' + module + '.' + name;\n        }\n    },\n\n    getController: function(name) {\n        var controller = this.controllers.get(name);\n\n        if (!controller) {\n            controller = Ext.create(this.getModuleClassName(name, 'controller'), {\n                application: this,\n                id: name\n            });\n\n            this.controllers.add(controller);\n        }\n\n        return controller;\n    },\n\n    getStore: function(name) {\n        var store = Ext.StoreManager.get(name);\n\n        if (!store) {\n            store = Ext.create(this.getModuleClassName(name, 'store'), {\n                storeId: name\n            });\n        }\n\n        return store;\n    },\n\n    getModel: function(model) {\n        model = this.getModuleClassName(model, 'model');\n\n        return Ext.ModelManager.getModel(model);\n    },\n\n    getView: function(view) {\n        view = this.getModuleClassName(view, 'view');\n\n        return Ext.ClassManager.get(view);\n    }\n});\n\n/**\n * A split button that provides a built-in dropdown arrow that can fire an event separately from the default click event\n * of the button. Typically this would be used to display a dropdown menu that provides additional options to the\n * primary button action, but any custom handler can provide the arrowclick implementation.  Example usage:\n *\n *     @example\n *     // display a dropdown menu:\n *     Ext.create('Ext.button.Split', {\n *         renderTo: Ext.getBody(),\n *         text: 'Options',\n *         // handle a click on the button itself\n *         handler: function() {\n *             alert(\"The button was clicked\");\n *         },\n *         menu: new Ext.menu.Menu({\n *             items: [\n *                 // these will render as dropdown menu items when the arrow is clicked:\n *                 {text: 'Item 1', handler: function(){ alert(\"Item 1 clicked\"); }},\n *                 {text: 'Item 2', handler: function(){ alert(\"Item 2 clicked\"); }}\n *             ]\n *         })\n *     });\n *\n * Instead of showing a menu, you can provide any type of custom functionality you want when the dropdown\n * arrow is clicked:\n *\n *     Ext.create('Ext.button.Split', {\n *         renderTo: 'button-ct',\n *         text: 'Options',\n *         handler: optionsHandler,\n *         arrowHandler: myCustomHandler\n *     });\n *\n */\nExt.define('Ext.button.Split', {\n\n    /* Begin Definitions */\n    alias: 'widget.splitbutton',\n\n    extend: 'Ext.button.Button',\n    alternateClassName: 'Ext.SplitButton',\n    /* End Definitions */\n    \n    /**\n     * @cfg {Function} arrowHandler\n     * A function called when the arrow button is clicked (can be used instead of click event)\n     * @cfg {Ext.button.Split} arrowHandler.this\n     * @cfg {Event} arrowHandler.e The click event\n     */\n    /**\n     * @cfg {String} arrowTooltip\n     * The title attribute of the arrow\n     */\n\n    // private\n    arrowCls      : 'split',\n    split         : true,\n\n    // private\n    initComponent : function(){\n        this.callParent();\n        /**\n         * @event arrowclick\n         * Fires when this button's arrow is clicked.\n         * @param {Ext.button.Split} this\n         * @param {Event} e The click event\n         */\n        this.addEvents(\"arrowclick\");\n    },\n\n    /**\n     * Sets this button's arrow click handler.\n     * @param {Function} handler The function to call when the arrow is clicked\n     * @param {Object} scope (optional) Scope for the function passed above\n     */\n    setArrowHandler : function(handler, scope){\n        this.arrowHandler = handler;\n        this.scope = scope;\n    },\n\n    // private\n    onClick : function(e, t) {\n        var me = this;\n        \n        e.preventDefault();\n        if (!me.disabled) {\n            if (me.overMenuTrigger) {\n                me.maybeShowMenu();\n                me.fireEvent(\"arrowclick\", me, e);\n                if (me.arrowHandler) {\n                    me.arrowHandler.call(me.scope || me, me, e);\n                }\n            } else {\n                me.doToggle();\n                me.fireHandler(e);\n            }\n        }\n    }\n});\n\n/**\n * A specialized SplitButton that contains a menu of {@link Ext.menu.CheckItem} elements. The button automatically\n * cycles through each menu item on click, raising the button's {@link #change} event (or calling the button's\n * {@link #changeHandler} function, if supplied) for the active menu item. Clicking on the arrow section of the\n * button displays the dropdown menu just like a normal SplitButton.  Example usage:\n *\n *     @example\n *     Ext.create('Ext.button.Cycle', {\n *         showText: true,\n *         prependText: 'View as ',\n *         renderTo: Ext.getBody(),\n *         menu: {\n *             id: 'view-type-menu',\n *             items: [{\n *                 text: 'text only',\n *                 iconCls: 'view-text',\n *                 checked: true\n *             },{\n *                 text: 'HTML',\n *                 iconCls: 'view-html'\n *             }]\n *         },\n *         changeHandler: function(cycleBtn, activeItem) {\n *             Ext.Msg.alert('Change View', activeItem.text);\n *         }\n *     });\n */\nExt.define('Ext.button.Cycle', {\n\n    /* Begin Definitions */\n\n    alias: 'widget.cycle',\n\n    extend: 'Ext.button.Split',\n    alternateClassName: 'Ext.CycleButton',\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Object[]} items\n     * An array of {@link Ext.menu.CheckItem} **config** objects to be used when creating the button's menu items (e.g.,\n     * `{text:'Foo', iconCls:'foo-icon'}`)\n     * \n     * @deprecated 4.0 Use the {@link #cfg-menu} config instead. All menu items will be created as\n     * {@link Ext.menu.CheckItem CheckItems}.\n     */\n    /**\n     * @cfg {Boolean} [showText=false]\n     * True to display the active item's text as the button text. The Button will show its\n     * configured {@link #text} if this config is omitted.\n     */\n    /**\n     * @cfg {String} [prependText='']\n     * A static string to prepend before the active item's text when displayed as the button's text (only applies when\n     * showText = true).\n     */\n    /**\n     * @cfg {Function} changeHandler\n     * A callback function that will be invoked each time the active menu item in the button's menu has changed. If this\n     * callback is not supplied, the SplitButton will instead fire the {@link #change} event on active item change. The\n     * changeHandler function will be called with the following argument list: (SplitButton this, Ext.menu.CheckItem\n     * item)\n     */\n    /**\n     * @cfg {String} forceIcon\n     * A css class which sets an image to be used as the static icon for this button. This icon will always be displayed\n     * regardless of which item is selected in the dropdown list. This overrides the default behavior of changing the\n     * button's icon to match the selected item's icon on change.\n     */\n    /**\n     * @property {Ext.menu.Menu} menu\n     * The {@link Ext.menu.Menu Menu} object used to display the {@link Ext.menu.CheckItem CheckItems} representing the\n     * available choices.\n     */\n\n    // private\n    getButtonText: function(item) {\n        var me = this,\n            text = '';\n\n        if (item && me.showText === true) {\n            if (me.prependText) {\n                text += me.prependText;\n            }\n            text += item.text;\n            return text;\n        }\n        return me.text;\n    },\n\n    /**\n     * Sets the button's active menu item.\n     * @param {Ext.menu.CheckItem} item The item to activate\n     * @param {Boolean} [suppressEvent=false] True to prevent the button's change event from firing.\n     */\n    setActiveItem: function(item, suppressEvent) {\n        var me = this;\n\n        if (!Ext.isObject(item)) {\n            item = me.menu.getComponent(item);\n        }\n        if (item) {\n            if (!me.rendered) {\n                me.text = me.getButtonText(item);\n                me.iconCls = item.iconCls;\n            } else {\n                me.setText(me.getButtonText(item));\n                me.setIconCls(item.iconCls);\n            }\n            me.activeItem = item;\n            if (!item.checked) {\n                item.setChecked(true, false);\n            }\n            if (me.forceIcon) {\n                me.setIconCls(me.forceIcon);\n            }\n            if (!suppressEvent) {\n                me.fireEvent('change', me, item);\n            }\n        }\n    },\n\n    /**\n     * Gets the currently active menu item.\n     * @return {Ext.menu.CheckItem} The active item\n     */\n    getActiveItem: function() {\n        return this.activeItem;\n    },\n\n    // private\n    initComponent: function() {\n        var me      = this,\n            checked = 0,\n            items,\n            i, iLen, item;\n\n        me.addEvents(\n            /**\n             * @event change\n             * Fires after the button's active menu item has changed. Note that if a {@link #changeHandler} function is\n             * set on this CycleButton, it will be called instead on active item change and this change event will not\n             * be fired.\n             * @param {Ext.button.Cycle} this\n             * @param {Ext.menu.CheckItem} item The menu item that was selected\n             */\n            \"change\"\n        );\n\n        if (me.changeHandler) {\n            me.on('change', me.changeHandler, me.scope || me);\n            delete me.changeHandler;\n        }\n\n        // Allow them to specify a menu config which is a standard Button config.\n        // Remove direct use of \"items\" in 5.0.\n        items = (me.menu.items || []).concat(me.items || []);\n        me.menu = Ext.applyIf({\n            cls: Ext.baseCSSPrefix + 'cycle-menu',\n            items: []\n        }, me.menu);\n\n        iLen = items.length;\n\n        // Convert all items to CheckItems\n        for (i = 0; i < iLen; i++) {\n            item = items[i];\n\n            item = Ext.applyIf({\n                group        : me.id,\n                itemIndex    : i,\n                checkHandler : me.checkHandler,\n                scope        : me,\n                checked      : item.checked || false\n            }, item);\n\n            me.menu.items.push(item);\n\n            if (item.checked) {\n                checked = i;\n            }\n        }\n\n        me.itemCount = me.menu.items.length;\n        me.callParent(arguments);\n        me.on('click', me.toggleSelected, me);\n        me.setActiveItem(checked, me);\n\n        // If configured with a fixed width, the cycling will center a different child item's text each click. Prevent this.\n        if (me.width && me.showText) {\n            me.addCls(Ext.baseCSSPrefix + 'cycle-fixed-width');\n        }\n    },\n\n    // private\n    checkHandler: function(item, pressed) {\n        if (pressed) {\n            this.setActiveItem(item);\n        }\n    },\n\n    /**\n     * This is normally called internally on button click, but can be called externally to advance the button's active\n     * item programmatically to the next one in the menu. If the current item is the last one in the menu the active\n     * item will be set to the first item in the menu.\n     */\n    toggleSelected: function() {\n        var me = this,\n            m = me.menu,\n            checkItem;\n\n        checkItem = me.activeItem.next(':not([disabled])') || m.items.getAt(0);\n        checkItem.setChecked(true);\n    }\n});\n\n/**\n * @class Ext.chart.Callout\n * A mixin providing callout functionality for Ext.chart.series.Series.\n */\nExt.define('Ext.chart.Callout', {\n\n    /* Begin Definitions */\n\n    /* End Definitions */\n\n    constructor: function(config) {\n        if (config.callouts) {\n            config.callouts.styles = Ext.applyIf(config.callouts.styles || {}, {\n                color: \"#000\",\n                font: \"11px Helvetica, sans-serif\"\n            });\n            this.callouts = Ext.apply(this.callouts || {}, config.callouts);\n            this.calloutsArray = [];\n        }\n    },\n\n    renderCallouts: function() {\n        if (!this.callouts) {\n            return;\n        }\n\n        var me = this,\n            items = me.items,\n            animate = me.chart.animate,\n            config = me.callouts,\n            styles = config.styles,\n            group = me.calloutsArray,\n            store = me.chart.store,\n            len = store.getCount(),\n            ratio = items.length / len,\n            previouslyPlacedCallouts = [],\n            i,\n            count,\n            j,\n            p,\n            item,\n            label,\n            storeItem,\n            display;\n            \n        for (i = 0, count = 0; i < len; i++) {\n            for (j = 0; j < ratio; j++) {\n                item = items[count];\n                label = group[count];\n                storeItem = store.getAt(i);\n                \n                display = config.filter(storeItem);\n                \n                if (!display && !label) {\n                    count++;\n                    continue;               \n                }\n                \n                if (!label) {\n                    group[count] = label = me.onCreateCallout(storeItem, item, i, display, j, count);\n                }\n                for (p in label) {\n                    if (label[p] && label[p].setAttributes) {\n                        label[p].setAttributes(styles, true);\n                    }\n                }\n                if (!display) {\n                    for (p in label) {\n                        if (label[p]) {\n                            if (label[p].setAttributes) {\n                                label[p].setAttributes({\n                                    hidden: true\n                                }, true);\n                            } else if(label[p].setVisible) {\n                                label[p].setVisible(false);\n                            }\n                        }\n                    }\n                }\n                config.renderer(label, storeItem);\n                me.onPlaceCallout(label, storeItem, item, i, display, animate,\n                                  j, count, previouslyPlacedCallouts);\n                previouslyPlacedCallouts.push(label);\n                count++;\n            }\n        }\n        this.hideCallouts(count);\n    },\n\n    onCreateCallout: function(storeItem, item, i, display) {\n        var me = this,\n            group = me.calloutsGroup,\n            config = me.callouts,\n            styles = config.styles,\n            width = styles.width,\n            height = styles.height,\n            chart = me.chart,\n            surface = chart.surface,\n            calloutObj = {\n                //label: false,\n                //box: false,\n                lines: false\n            };\n\n        calloutObj.lines = surface.add(Ext.apply({},\n        {\n            type: 'path',\n            path: 'M0,0',\n            stroke: me.getLegendColor() || '#555'\n        },\n        styles));\n\n        if (config.items) {\n            calloutObj.panel = new Ext.Panel({\n                style: \"position: absolute;\",    \n                width: width,\n                height: height,\n                items: config.items,\n                renderTo: chart.el\n            });\n        }\n\n        return calloutObj;\n    },\n\n    hideCallouts: function(index) {\n        var calloutsArray = this.calloutsArray,\n            len = calloutsArray.length,\n            co,\n            p;\n        while (len-->index) {\n            co = calloutsArray[len];\n            for (p in co) {\n                if (co[p]) {\n                    co[p].hide(true);\n                }\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.layout.component.Draw\n * @private\n *\n */\n\nExt.define('Ext.layout.component.Draw', {\n\n    /* Begin Definitions */\n\n    alias: 'layout.draw',\n\n    extend: 'Ext.layout.component.Auto',\n\n    /* End Definitions */\n\n    type: 'draw',\n    \n    measureContentWidth : function (ownerContext) {\n        var target = ownerContext.target,\n            paddingInfo = ownerContext.getPaddingInfo(),\n            bbox = this.getBBox(ownerContext);\n            \n        if (!target.viewBox) {\n            if (target.autoSize) {\n                return bbox.width + paddingInfo.width;\n            } else {\n                return bbox.x + bbox.width + paddingInfo.width;\n            }\n        } else {\n            if (ownerContext.heightModel.shrinkWrap) {\n                return paddingInfo.width;\n            } else {\n                return bbox.width / bbox.height * (ownerContext.getProp('contentHeight') - paddingInfo.height) + paddingInfo.width;\n            }\n        }\n    },\n    \n    measureContentHeight : function (ownerContext) {\n        var target = ownerContext.target,\n            paddingInfo = ownerContext.getPaddingInfo(),\n            bbox = this.getBBox(ownerContext);\n            \n        if (!ownerContext.target.viewBox) {\n            if (target.autoSize) {\n                return bbox.height + paddingInfo.height;\n            } else {\n                return bbox.y + bbox.height + paddingInfo.height;\n            }\n        } else {\n            if (ownerContext.widthModel.shrinkWrap) {\n                return paddingInfo.height;\n            } else {\n                return bbox.height / bbox.width * (ownerContext.getProp('contentWidth') - paddingInfo.width) + paddingInfo.height;\n            }\n        }\n    },\n    \n    getBBox: function(ownerContext) {\n        var bbox = ownerContext.surfaceBBox;\n        if (!bbox) {\n            bbox = ownerContext.target.surface.items.getBBox();\n            // If the surface is empty, we'll get these values, normalize them\n            if (bbox.width === -Infinity && bbox.height === -Infinity) {\n                bbox.width = bbox.height = bbox.x = bbox.y = 0;\n            }\n            ownerContext.surfaceBBox = bbox;\n        }\n        return bbox;\n    },\n\n    publishInnerWidth: function (ownerContext, width) {\n        ownerContext.setContentWidth(width - ownerContext.getFrameInfo().width, true);\n    },\n    \n    publishInnerHeight: function (ownerContext, height) {\n        ownerContext.setContentHeight(height - ownerContext.getFrameInfo().height, true);\n    },\n    \n    finishedLayout: function (ownerContext) {\n        // TODO: Is there a better way doing this?\n        var props = ownerContext.props,\n            paddingInfo = ownerContext.getPaddingInfo();\n\n        // We don't want the cost of getProps, so we just use the props data... this is ok\n        // because all the props have been calculated by this time\n        this.owner.setSurfaceSize(props.contentWidth - paddingInfo.width, props.contentHeight - paddingInfo.height);\n        \n        // calls afterComponentLayout, so we want the surface to be sized before that:\n        this.callParent(arguments);\n    }\n});\n\n/**\n * A composite Sprite handles a group of sprites with common methods to a sprite\n * such as `hide`, `show`, `setAttributes`. These methods are applied to the set of sprites\n * added to the group.\n *\n * CompositeSprite extends {@link Ext.util.MixedCollection} so you can use the same methods\n * in `MixedCollection` to iterate through sprites, add and remove elements, etc.\n *\n * In order to create a CompositeSprite, one has to provide a handle to the surface where it is\n * rendered:\n *\n *     var group = Ext.create('Ext.draw.CompositeSprite', {\n *         surface: drawComponent.surface\n *     });\n *                  \n * Then just by using `MixedCollection` methods it's possible to add {@link Ext.draw.Sprite}s:\n *  \n *     group.add(sprite1);\n *     group.add(sprite2);\n *     group.add(sprite3);\n *                  \n * And then apply common Sprite methods to them:\n *  \n *     group.setAttributes({\n *         fill: '#f00'\n *     }, true);\n */\nExt.define('Ext.draw.CompositeSprite', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.util.MixedCollection',\n    mixins: {\n        animate: 'Ext.util.Animate'\n    },\n    autoDestroy: false,\n    \n    /* End Definitions */\n    isCompositeSprite: true,\n    constructor: function(config) {\n        var me = this;\n        \n        config = config || {};\n        Ext.apply(me, config);\n\n        me.addEvents(\n            /**\n             * @event\n             * @inheritdoc Ext.draw.Sprite#mousedown\n             */\n            'mousedown',\n            /**\n             * @event\n             * @inheritdoc Ext.draw.Sprite#mouseup\n             */\n            'mouseup',\n            /**\n             * @event\n             * @inheritdoc Ext.draw.Sprite#mouseover\n             */\n            'mouseover',\n            /**\n             * @event\n             * @inheritdoc Ext.draw.Sprite#mouseout\n             */\n            'mouseout',\n            /**\n             * @event\n             * @inheritdoc Ext.draw.Sprite#click\n             */\n            'click'\n        );\n        me.id = Ext.id(null, 'ext-sprite-group-');\n        me.callParent();\n    },\n\n    // @private\n    onClick: function(e) {\n        this.fireEvent('click', e);\n    },\n\n    // @private\n    onMouseUp: function(e) {\n        this.fireEvent('mouseup', e);\n    },\n\n    // @private\n    onMouseDown: function(e) {\n        this.fireEvent('mousedown', e);\n    },\n\n    // @private\n    onMouseOver: function(e) {\n        this.fireEvent('mouseover', e);\n    },\n\n    // @private\n    onMouseOut: function(e) {\n        this.fireEvent('mouseout', e);\n    },\n\n    attachEvents: function(o) {\n        var me = this;\n        \n        o.on({\n            scope: me,\n            mousedown: me.onMouseDown,\n            mouseup: me.onMouseUp,\n            mouseover: me.onMouseOver,\n            mouseout: me.onMouseOut,\n            click: me.onClick\n        });\n    },\n\n    // Inherit docs from MixedCollection\n    add: function(key, o) {\n        var result = this.callParent(arguments);\n        this.attachEvents(result);\n        return result;\n    },\n\n    insert: function(index, key, o) {\n        return this.callParent(arguments);\n    },\n\n    // Inherit docs from MixedCollection\n    remove: function(o) {\n        var me = this;\n        \n        o.un({\n            scope: me,\n            mousedown: me.onMouseDown,\n            mouseup: me.onMouseUp,\n            mouseover: me.onMouseOver,\n            mouseout: me.onMouseOut,\n            click: me.onClick\n        });\n        return me.callParent(arguments);\n    },\n    \n    /**\n     * Returns the group bounding box.\n     * Behaves like {@link Ext.draw.Sprite#getBBox} method.\n     * @return {Object} an object with x, y, width, and height properties.\n     */\n    getBBox: function() {\n        var i = 0,\n            sprite,\n            bb,\n            items = this.items,\n            len = this.length,\n            infinity = Infinity,\n            minX = infinity,\n            maxHeight = -infinity,\n            minY = infinity,\n            maxWidth = -infinity,\n            maxWidthBBox, maxHeightBBox;\n        \n        for (; i < len; i++) {\n            sprite = items[i];\n            if (sprite.el && ! sprite.bboxExcluded) {\n                bb = sprite.getBBox();\n                minX = Math.min(minX, bb.x);\n                minY = Math.min(minY, bb.y);\n                maxHeight = Math.max(maxHeight, bb.height + bb.y);\n                maxWidth = Math.max(maxWidth, bb.width + bb.x);\n            }\n        }\n        \n        return {\n            x: minX,\n            y: minY,\n            height: maxHeight - minY,\n            width: maxWidth - minX\n        };\n    },\n\n    /**\n     * Iterates through all sprites calling `setAttributes` on each one. For more information {@link Ext.draw.Sprite}\n     * provides a description of the attributes that can be set with this method.\n     * @param {Object} attrs Attributes to be changed on the sprite.\n     * @param {Boolean} redraw Flag to immediately draw the change.\n     * @return {Ext.draw.CompositeSprite} this\n     */\n    setAttributes: function(attrs, redraw) {\n        var i = 0,\n            items = this.items,\n            len = this.length;\n            \n        for (; i < len; i++) {\n            items[i].setAttributes(attrs, redraw);\n        }\n        return this;\n    },\n\n    /**\n     * Hides all sprites. If `true` is passed then a redraw will be forced for each sprite.\n     * @param {Boolean} redraw Flag to immediately draw the change.\n     * @return {Ext.draw.CompositeSprite} this\n     */\n    hide: function(redraw) {\n        var i = 0,\n            items = this.items,\n            len = this.length;\n            \n        for (; i < len; i++) {\n            items[i].hide(redraw);\n        }\n        return this;\n    },\n\n    /**\n     * Shows all sprites. If `true` is passed then a redraw will be forced for each sprite.\n     * @param {Boolean} redraw Flag to immediately draw the change.\n     * @return {Ext.draw.CompositeSprite} this\n     */\n    show: function(redraw) {\n        var i = 0,\n            items = this.items,\n            len = this.length;\n            \n        for (; i < len; i++) {\n            items[i].show(redraw);\n        }\n        return this;\n    },\n\n    /**\n     * Force redraw of all sprites.\n     */\n    redraw: function() {\n        var me = this,\n            i = 0,\n            items = me.items,\n            surface = me.getSurface(),\n            len = me.length;\n        \n        if (surface) {\n            for (; i < len; i++) {\n                surface.renderItem(items[i]);\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Sets style for all sprites.\n     * @param {String} style CSS Style definition.\n     */\n    setStyle: function(obj) {\n        var i = 0,\n            items = this.items,\n            len = this.length,\n            item, el;\n            \n        for (; i < len; i++) {\n            item = items[i];\n            el = item.el;\n            if (el) {\n                el.setStyle(obj);\n            }\n        }\n    },\n\n    /**\n     * Adds class to all sprites.\n     * @param {String} cls CSS class name\n     */\n    addCls: function(obj) {\n        var i = 0,\n            items = this.items,\n            surface = this.getSurface(),\n            len = this.length;\n        \n        if (surface) {\n            for (; i < len; i++) {\n                surface.addCls(items[i], obj);\n            }\n        }\n    },\n\n    /**\n     * Removes class from all sprites.\n     * @param {String} cls CSS class name\n     */\n    removeCls: function(obj) {\n        var i = 0,\n            items = this.items,\n            surface = this.getSurface(),\n            len = this.length;\n        \n        if (surface) {\n            for (; i < len; i++) {\n                surface.removeCls(items[i], obj);\n            }\n        }\n    },\n    \n    /**\n     * Grab the surface from the items\n     * @private\n     * @return {Ext.draw.Surface} The surface, null if not found\n     */\n    getSurface: function(){\n        var first = this.first();\n        if (first) {\n            return first.surface;\n        }\n        return null;\n    },\n    \n    /**\n     * Destroys this CompositeSprite.\n     */\n    destroy: function(){\n        var me = this,\n            surface = me.getSurface(),\n            destroySprites = me.autoDestroy,\n            item;\n            \n        if (surface) {\n            while (me.getCount() > 0) {\n                item = me.first();\n                me.remove(item);\n                surface.remove(item, destroySprites);\n            }\n        }\n        me.clearListeners();\n    }\n});\n\n/**\n * A Surface is an interface to render methods inside {@link Ext.draw.Component}.\n *\n * Most of the Surface methods are abstract and they have a concrete implementation\n * in {@link Ext.draw.engine.Vml VML} or {@link Ext.draw.engine.Svg SVG} engines.\n *\n * A Surface contains methods to render {@link Ext.draw.Sprite sprites}, get bounding\n * boxes of sprites, add sprites to the canvas, initialize other graphic components, etc.\n *\n * ## Adding sprites to surface\n *\n * One of the most used methods for this class is the {@link #add} method, to add Sprites to\n * the surface. For example:\n *\n *     drawComponent.surface.add({\n *         type: 'circle',\n *         fill: '#ffc',\n *         radius: 100,\n *         x: 100,\n *         y: 100\n *     });\n *\n * The configuration object passed in the `add` method is the same as described in the\n * {@link Ext.draw.Sprite} class documentation.\n *\n * Sprites can also be added to surface by setting their surface config at creation time:\n *\n *     var sprite = Ext.create('Ext.draw.Sprite', {\n *         type: 'circle',\n *         fill: '#ff0',\n *         surface: drawComponent.surface,\n *         radius: 5\n *     });\n *\n * In order to properly apply properties and render the sprite we have to\n * `show` the sprite setting the option `redraw` to `true`:\n *\n *     sprite.show(true);\n *\n */\nExt.define('Ext.draw.Surface', {\n\n    /* Begin Definitions */\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    requires: ['Ext.draw.CompositeSprite'],\n    uses: ['Ext.draw.engine.Svg', 'Ext.draw.engine.Vml', 'Ext.draw.engine.SvgExporter', 'Ext.draw.engine.ImageExporter'],\n\n    separatorRe: /[, ]+/,\n\n    statics: {\n        /**\n         * Creates and returns a new concrete Surface instance appropriate for the current environment.\n         * @param {Object} config Initial configuration for the Surface instance\n         * @param {String[]} enginePriority (Optional) order of implementations to use; the first one that is\n         * available in the current environment will be used. Defaults to `['Svg', 'Vml']`.\n         * @return {Object} The created Surface or false.\n         * @static\n         */\n        create: function(config, enginePriority) {\n            enginePriority = enginePriority || ['Svg', 'Vml'];\n\n            var i = 0,\n                len = enginePriority.length,\n                surfaceClass;\n\n            for (; i < len; i++) {\n                if (Ext.supports[enginePriority[i]] !== false) {\n                    return Ext.create('Ext.draw.engine.' + enginePriority[i], config);\n                }\n            }\n            return false;\n        },\n        \n        /**\n         * Exports a {@link Ext.draw.Surface surface} in a different format.\n         * The surface may be exported to an SVG string, using the\n         * {@link Ext.draw.engine.SvgExporter}. It may also be exported\n         * as an image using the {@link Ext.draw.engine.ImageExporter ImageExporter}.\n         * Note that this requires sending data to a remote server to process\n         * the SVG into an image, see the {@link Ext.draw.engine.ImageExporter} for\n         * more details.\n         * @param {Ext.draw.Surface} surface The surface to export.\n         * @param {Object} [config] The configuration to be passed to the exporter.\n         * See the export method for the appropriate exporter for the relevant\n         * configuration options\n         * @return {Object} See the return types for the appropriate exporter\n         * @static\n         */\n        save: function(surface, config) {\n            config = config || {};\n            var exportTypes = {\n                    'image/png': 'Image',\n                    'image/jpeg': 'Image',\n                    'image/svg+xml': 'Svg'\n                },\n                prefix = exportTypes[config.type] || 'Svg',\n                exporter = Ext.draw.engine[prefix + 'Exporter'];           \n\n            return exporter.generate(surface, config);\n            \n        }\n    },\n\n    /* End Definitions */\n\n    // @private\n    availableAttrs: {\n        blur: 0,\n        \"clip-rect\": \"0 0 1e9 1e9\",\n        cursor: \"default\",\n        cx: 0,\n        cy: 0,\n        'dominant-baseline': 'auto',\n        fill: \"none\",\n        \"fill-opacity\": 1,\n        font: '10px \"Arial\"',\n        \"font-family\": '\"Arial\"',\n        \"font-size\": \"10\",\n        \"font-style\": \"normal\",\n        \"font-weight\": 400,\n        gradient: \"\",\n        height: 0,\n        hidden: false,\n        href: \"http://sencha.com/\",\n        opacity: 1,\n        path: \"M0,0\",\n        radius: 0,\n        rx: 0,\n        ry: 0,\n        scale: \"1 1\",\n        src: \"\",\n        stroke: \"none\",\n        \"stroke-dasharray\": \"\",\n        \"stroke-linecap\": \"butt\",\n        \"stroke-linejoin\": \"butt\",\n        \"stroke-miterlimit\": 0,\n        \"stroke-opacity\": 1,\n        \"stroke-width\": 1,\n        target: \"_blank\",\n        text: \"\",\n        \"text-anchor\": \"middle\",\n        title: \"Ext Draw\",\n        width: 0,\n        x: 0,\n        y: 0,\n        zIndex: 0\n    },\n\n    /**\n     * @cfg {Number} height\n     * The height of this component in pixels (defaults to auto).\n     */\n    /**\n     * @cfg {Number} width\n     * The width of this component in pixels (defaults to auto).\n     */\n\n    container: undefined,\n    height: 352,\n    width: 512,\n    x: 0,\n    y: 0,\n\n    /**\n     * @cfg {Ext.draw.Sprite[]} items\n     * Array of sprites or sprite config objects to add initially to the surface.\n     */\n\n    /**\n     * @private Flag indicating that the surface implementation requires sprites to be maintained\n     * in order of their zIndex. Impls that don't require this can set it to false.\n     */\n    orderSpritesByZIndex: true,\n\n\n    /**\n     * Creates new Surface.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        var me = this;\n        config = config || {};\n        Ext.apply(me, config);\n\n        me.domRef = Ext.getDoc().dom;\n\n        me.customAttributes = {};\n\n        me.addEvents(\n            /**\n             * @event\n             * Fires when a mousedown is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'mousedown',\n            /**\n             * @event\n             * Fires when a mouseup is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'mouseup',\n            /**\n             * @event\n             * Fires when a mouseover is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'mouseover',\n            /**\n             * @event\n             * Fires when a mouseout is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'mouseout',\n            /**\n             * @event\n             * Fires when a mousemove is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'mousemove',\n            /**\n             * @event\n             * Fires when a mouseenter is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'mouseenter',\n            /**\n             * @event\n             * Fires when a mouseleave is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'mouseleave',\n            /**\n             * @event\n             * Fires when a click is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'click',\n            /**\n             * @event\n             * Fires when a dblclick is detected within the surface.\n             * @param {Ext.EventObject} e An object encapsulating the DOM event.\n             */\n            'dblclick'\n        );\n\n        me.mixins.observable.constructor.call(me);\n\n        me.getId();\n        me.initGradients();\n        me.initItems();\n        if (me.renderTo) {\n            me.render(me.renderTo);\n            delete me.renderTo;\n        }\n        me.initBackground(config.background);\n    },\n\n    // @private called to initialize components in the surface\n    // this is dependent on the underlying implementation.\n    initSurface: Ext.emptyFn,\n\n    // @private called to setup the surface to render an item\n    //this is dependent on the underlying implementation.\n    renderItem: Ext.emptyFn,\n\n    // @private\n    renderItems: Ext.emptyFn,\n\n    // @private\n    setViewBox: function (x, y, width, height) {\n        if (isFinite(x) && isFinite(y) && isFinite(width) && isFinite(height)) {\n            this.viewBox = {x: x, y: y, width: width, height: height};\n            this.applyViewBox();\n        }\n    },\n\n    /**\n     * Adds one or more CSS classes to the element. Duplicate classes are automatically filtered out.\n     *\n     * For example:\n     *\n     *     drawComponent.surface.addCls(sprite, 'x-visible');\n     *\n     * @param {Object} sprite The sprite to add the class to.\n     * @param {String/String[]} className The CSS class to add, or an array of classes\n     * @method\n     */\n    addCls: Ext.emptyFn,\n\n    /**\n     * Removes one or more CSS classes from the element.\n     *\n     * For example:\n     *\n     *     drawComponent.surface.removeCls(sprite, 'x-visible');\n     *\n     * @param {Object} sprite The sprite to remove the class from.\n     * @param {String/String[]} className The CSS class to remove, or an array of classes\n     * @method\n     */\n    removeCls: Ext.emptyFn,\n\n    /**\n     * Sets CSS style attributes to an element.\n     *\n     * For example:\n     *\n     *     drawComponent.surface.setStyle(sprite, {\n     *         'cursor': 'pointer'\n     *     });\n     *\n     * @param {Object} sprite The sprite to add, or an array of classes to\n     * @param {Object} styles An Object with CSS styles.\n     * @method\n     */\n    setStyle: Ext.emptyFn,\n\n    // @private\n    initGradients: function() {\n        if (this.hasOwnProperty('gradients')) {\n            var gradients = this.gradients,\n                gLen      = gradients.length,\n                fn        = this.addGradient,\n                g;\n\n            if (gradients) {\n                for (g = 0; g < gLen; g++) {\n                    if (fn.call(this, gradients[g], g, gLen) === false) {\n                        break;\n                    }\n                }\n            }\n        }\n    },\n\n    // @private\n    initItems: function() {\n        var items = this.items;\n        this.items = new Ext.draw.CompositeSprite();\n        this.items.autoDestroy = true;\n        this.groups = new Ext.draw.CompositeSprite();\n        if (items) {\n            this.add(items);\n        }\n    },\n\n    // @private\n    initBackground: function(config) {\n        var me = this,\n            width = me.width,\n            height = me.height,\n            gradientId, gradient, backgroundSprite;\n        if (Ext.isString(config)) {\n            config = {\n                fill : config\n            };\n        }\n        if (config) {\n            if (config.gradient) {\n                gradient = config.gradient;\n                gradientId = gradient.id;\n                me.addGradient(gradient);\n                me.background = me.add({\n                    type: 'rect',\n                    x: 0,\n                    y: 0,\n                    width: width,\n                    height: height,\n                    fill: 'url(#' + gradientId + ')',\n                    zIndex: -1\n                });\n            } else if (config.fill) {\n                me.background = me.add({\n                    type: 'rect',\n                    x: 0,\n                    y: 0,\n                    width: width,\n                    height: height,\n                    fill: config.fill,\n                    zIndex: -1\n                });\n            } else if (config.image) {\n                me.background = me.add({\n                    type: 'image',\n                    x: 0,\n                    y: 0,\n                    width: width,\n                    height: height,\n                    src: config.image,\n                    zIndex: -1\n                });\n            }\n            // prevent me.background to jeopardize me.items.getBBox\n            me.background.bboxExcluded = true;\n        }\n    },\n\n    /**\n     * Sets the size of the surface. Accomodates the background (if any) to fit the new size too.\n     *\n     * For example:\n     *\n     *     drawComponent.surface.setSize(500, 500);\n     *\n     * This method is generally called when also setting the size of the draw Component.\n     *\n     * @param {Number} w The new width of the canvas.\n     * @param {Number} h The new height of the canvas.\n     */\n    setSize: function(w, h) {\n        this.applyViewBox();\n    },\n\n    // @private\n    scrubAttrs: function(sprite) {\n        var i,\n            attrs = {},\n            exclude = {},\n            sattr = sprite.attr;\n        for (i in sattr) {\n            // Narrow down attributes to the main set\n            if (this.translateAttrs.hasOwnProperty(i)) {\n                // Translated attr\n                attrs[this.translateAttrs[i]] = sattr[i];\n                exclude[this.translateAttrs[i]] = true;\n            }\n            else if (this.availableAttrs.hasOwnProperty(i) && !exclude[i]) {\n                // Passtrhough attr\n                attrs[i] = sattr[i];\n            }\n        }\n        return attrs;\n    },\n\n    // @private\n    onClick: function(e) {\n        this.processEvent('click', e);\n    },\n    \n    // @private\n    onDblClick: function(e) {\n        this.processEvent('dblclick', e);\n    },\n\n    // @private\n    onMouseUp: function(e) {\n        this.processEvent('mouseup', e);\n    },\n\n    // @private\n    onMouseDown: function(e) {\n        this.processEvent('mousedown', e);\n    },\n\n    // @private\n    onMouseOver: function(e) {\n        this.processEvent('mouseover', e);\n    },\n\n    // @private\n    onMouseOut: function(e) {\n        this.processEvent('mouseout', e);\n    },\n\n    // @private\n    onMouseMove: function(e) {\n        this.fireEvent('mousemove', e);\n    },\n\n    // @private\n    onMouseEnter: Ext.emptyFn,\n\n    // @private\n    onMouseLeave: Ext.emptyFn,\n\n    /**\n     * Adds a gradient definition to the Surface. Note that in some surface engines, adding\n     * a gradient via this method will not take effect if the surface has already been rendered.\n     * Therefore, it is preferred to pass the gradients as an item to the surface config, rather\n     * than calling this method, especially if the surface is rendered immediately (e.g. due to\n     * 'renderTo' in its config). For more information on how to create gradients in the Chart\n     * configuration object please refer to {@link Ext.chart.Chart}.\n     *\n     * The gradient object to be passed into this method is composed by:\n     *\n     * - **id** - string - The unique name of the gradient.\n     * - **angle** - number, optional - The angle of the gradient in degrees.\n     * - **stops** - object - An object with numbers as keys (from 0 to 100) and style objects as values.\n     *\n     * For example:\n     *\n     *    drawComponent.surface.addGradient({\n     *        id: 'gradientId',\n     *        angle: 45,\n     *        stops: {\n     *            0: {\n     *                color: '#555'\n     *            },\n     *            100: {\n     *                color: '#ddd'\n     *            }\n     *        }\n     *    });\n     *\n     * @param {Object} gradient A gradient config.\n     * @method\n     */\n    addGradient: Ext.emptyFn,\n\n    /**\n     * Adds a Sprite to the surface. See {@link Ext.draw.Sprite} for the configuration object to be\n     * passed into this method.\n     *\n     * For example:\n     *\n     *     drawComponent.surface.add({\n     *         type: 'circle',\n     *         fill: '#ffc',\n     *         radius: 100,\n     *         x: 100,\n     *         y: 100\n     *     });\n     *\n     * @param {Ext.draw.Sprite[]/Ext.draw.Sprite...} args One or more Sprite objects or configs.\n     * @return {Ext.draw.Sprite[]/Ext.draw.Sprite} The sprites added.\n     */\n    add: function() {\n        var args = Array.prototype.slice.call(arguments),\n            sprite,\n            index,\n            hasMultipleArgs = args.length > 1,\n            items,\n            results,\n            i,\n            ln,\n            item;\n            \n        if (hasMultipleArgs || Ext.isArray(args[0])) {\n            items = hasMultipleArgs ? args : args[0];\n            results = [];\n\n            for (i = 0, ln = items.length; i < ln; i++) {\n                item = items[i];\n                item = this.add(item);\n                results.push(item);\n            }\n\n            return results;\n        }\n        sprite = this.prepareItems(args[0], true)[0];\n        this.insertByZIndex(sprite);\n        this.onAdd(sprite);\n        return sprite;\n    },\n\n    /**\n     * @private\n     * Inserts a given sprite into the correct position in the items collection, according to\n     * its zIndex. It will be inserted at the end of an existing series of sprites with the same or\n     * lower zIndex. By ensuring sprites are always ordered, this allows surface subclasses to render\n     * the sprites in the correct order for proper z-index stacking.\n     * @param {Ext.draw.Sprite} sprite\n     * @return {Number} the sprite's new index in the list\n     */\n    insertByZIndex: function(sprite) {\n        var me = this,\n            sprites = me.items.items,\n            len = sprites.length,\n            ceil = Math.ceil,\n            zIndex = sprite.attr.zIndex,\n            idx = len,\n            high = idx - 1,\n            low = 0,\n            otherZIndex;\n\n        if (me.orderSpritesByZIndex && len && zIndex < sprites[high].attr.zIndex) {\n            // Find the target index via a binary search for speed\n            while (low <= high) {\n                idx = ceil((low + high) / 2);\n                otherZIndex = sprites[idx].attr.zIndex;\n                if (otherZIndex > zIndex) {\n                    high = idx - 1;\n                }\n                else if (otherZIndex < zIndex) {\n                    low = idx + 1;\n                }\n                else {\n                    break;\n                }\n            }\n            // Step forward to the end of a sequence of the same or lower z-index\n            while (idx < len && sprites[idx].attr.zIndex <= zIndex) {\n                idx++;\n            }\n        }\n\n        me.items.insert(idx, sprite);\n        return idx;\n    },\n\n    onAdd: function(sprite) {\n        var group = sprite.group,\n            draggable = sprite.draggable,\n            groups, ln, i;\n        if (group) {\n            groups = [].concat(group);\n            ln = groups.length;\n            for (i = 0; i < ln; i++) {\n                group = groups[i];\n                this.getGroup(group).add(sprite);\n            }\n            delete sprite.group;\n        }\n        if (draggable) {\n            sprite.initDraggable();\n        }\n    },\n\n    /**\n     * Removes a given sprite from the surface, optionally destroying the sprite in the process.\n     * You can also call the sprite own `remove` method.\n     *\n     * For example:\n     *\n     *     drawComponent.surface.remove(sprite);\n     *     //or...\n     *     sprite.remove();\n     *\n     * @param {Ext.draw.Sprite} sprite\n     * @param {Boolean} destroySprite\n     */\n    remove: function(sprite, destroySprite) {\n        if (sprite) {\n            this.items.remove(sprite);\n\n            var groups = [].concat(this.groups.items),\n                gLen   = groups.length,\n                g;\n\n            for (g = 0; g < gLen; g++) {\n                groups[g].remove(sprite);\n            }\n\n            sprite.onRemove();\n            if (destroySprite === true) {\n                sprite.destroy();\n            }\n        }\n    },\n\n    /**\n     * Removes all sprites from the surface, optionally destroying the sprites in the process.\n     *\n     * For example:\n     *\n     *     drawComponent.surface.removeAll();\n     *\n     * @param {Boolean} destroySprites Whether to destroy all sprites when removing them.\n     */\n    removeAll: function(destroySprites) {\n        var items = this.items.items,\n            ln = items.length,\n            i;\n        for (i = ln - 1; i > -1; i--) {\n            this.remove(items[i], destroySprites);\n        }\n    },\n\n    onRemove: Ext.emptyFn,\n\n    onDestroy: Ext.emptyFn,\n\n    /**\n     * @private Using the current viewBox property and the surface's width and height, calculate the\n     * appropriate viewBoxShift that will be applied as a persistent transform to all sprites.\n     */\n    applyViewBox: function() {\n        var me = this,\n            viewBox = me.viewBox,\n            width = me.width || 1, // Avoid problems in division\n            height = me.height || 1,\n            viewBoxX, viewBoxY, viewBoxWidth, viewBoxHeight,\n            relativeHeight, relativeWidth, size;\n\n        if (viewBox && (width || height)) {\n            viewBoxX = viewBox.x;\n            viewBoxY = viewBox.y;\n            viewBoxWidth = viewBox.width;\n            viewBoxHeight = viewBox.height;\n            relativeHeight = height / viewBoxHeight;\n            relativeWidth = width / viewBoxWidth;\n            size = Math.min(relativeWidth, relativeHeight);\n\n            if (viewBoxWidth * size < width) {\n                viewBoxX -= (width - viewBoxWidth * size) / 2 / size;\n            }\n            if (viewBoxHeight * size < height) {\n                viewBoxY -= (height - viewBoxHeight * size) / 2 / size;\n            }\n\n            me.viewBoxShift = {\n                dx: -viewBoxX,\n                dy: -viewBoxY,\n                scale: size\n            };\n            \n            if (me.background) {\n                me.background.setAttributes(Ext.apply({}, {\n                    x: viewBoxX,\n                    y: viewBoxY,\n                    width: width / size,\n                    height: height / size\n                }, { hidden: false }), true);\n            }\n        } else {\n            if (me.background && width && height) {\n                me.background.setAttributes(Ext.apply({x: 0, y: 0, width: width, height: height}, { hidden: false }), true);\n            }\n        }\n    },\n\n\n    getBBox: function (sprite, isWithoutTransform) {\n        var realPath = this[\"getPath\" + sprite.type](sprite);\n        if (isWithoutTransform) {\n            sprite.bbox.plain = sprite.bbox.plain || Ext.draw.Draw.pathDimensions(realPath);\n            return sprite.bbox.plain;\n        }\n        if (sprite.dirtyTransform) {\n            this.applyTransformations(sprite, true);\n        }\n        sprite.bbox.transform = sprite.bbox.transform || Ext.draw.Draw.pathDimensions(Ext.draw.Draw.mapPath(realPath, sprite.matrix));\n        return sprite.bbox.transform;\n    },\n    \n    transformToViewBox: function (x, y) {\n        if (this.viewBoxShift) {\n            var me = this, shift = me.viewBoxShift;\n            return [x / shift.scale - shift.dx, y / shift.scale - shift.dy];\n        } else {\n            return [x, y];\n        }\n    },\n\n    // @private\n    applyTransformations: function(sprite, onlyMatrix) {\n        if (sprite.type == 'text') {\n            // TODO: getTextBBox function always take matrix into account no matter whether `isWithoutTransform` is true. Fix that.\n            sprite.bbox.transform = 0;\n            this.transform(sprite, false);\n        }\n\n\n        sprite.dirtyTransform = false;\n        \n        var me = this,\n            attr = sprite.attr;\n\n        if (attr.translation.x != null || attr.translation.y != null) {\n            me.translate(sprite);\n        }\n        if (attr.scaling.x != null || attr.scaling.y != null) {\n            me.scale(sprite);\n        }\n        if (attr.rotation.degrees != null) {\n            me.rotate(sprite);\n        }\n        \n        sprite.bbox.transform = 0;\n        this.transform(sprite, onlyMatrix);\n        sprite.transformations = [];\n    },\n\n    // @private\n    rotate: function (sprite) {\n        var bbox,\n            deg = sprite.attr.rotation.degrees,\n            centerX = sprite.attr.rotation.x,\n            centerY = sprite.attr.rotation.y;\n        if (!Ext.isNumber(centerX) || !Ext.isNumber(centerY)) {\n            bbox = this.getBBox(sprite, true);\n            centerX = !Ext.isNumber(centerX) ? bbox.x + bbox.width / 2 : centerX;\n            centerY = !Ext.isNumber(centerY) ? bbox.y + bbox.height / 2 : centerY;\n        }\n        sprite.transformations.push({\n            type: \"rotate\",\n            degrees: deg,\n            x: centerX,\n            y: centerY\n        });\n    },\n\n    // @private\n    translate: function(sprite) {\n        var x = sprite.attr.translation.x || 0,\n            y = sprite.attr.translation.y || 0;\n        sprite.transformations.push({\n            type: \"translate\",\n            x: x,\n            y: y\n        });\n    },\n\n    // @private\n    scale: function(sprite) {\n        var bbox,\n            x = sprite.attr.scaling.x || 1,\n            y = sprite.attr.scaling.y || 1,\n            centerX = sprite.attr.scaling.centerX,\n            centerY = sprite.attr.scaling.centerY;\n\n        if (!Ext.isNumber(centerX) || !Ext.isNumber(centerY)) {\n            bbox = this.getBBox(sprite, true);\n            centerX = !Ext.isNumber(centerX) ? bbox.x + bbox.width / 2 : centerX;\n            centerY = !Ext.isNumber(centerY) ? bbox.y + bbox.height / 2 : centerY;\n        }\n        sprite.transformations.push({\n            type: \"scale\",\n            x: x,\n            y: y,\n            centerX: centerX,\n            centerY: centerY\n        });\n    },\n\n    // @private\n    rectPath: function (x, y, w, h, r) {\n        if (r) {\n            return [[\"M\", x + r, y], [\"l\", w - r * 2, 0], [\"a\", r, r, 0, 0, 1, r, r], [\"l\", 0, h - r * 2], [\"a\", r, r, 0, 0, 1, -r, r], [\"l\", r * 2 - w, 0], [\"a\", r, r, 0, 0, 1, -r, -r], [\"l\", 0, r * 2 - h], [\"a\", r, r, 0, 0, 1, r, -r], [\"z\"]];\n        }\n        return [[\"M\", x, y], [\"l\", w, 0], [\"l\", 0, h], [\"l\", -w, 0], [\"z\"]];\n    },\n\n    // @private\n    ellipsePath: function (x, y, rx, ry) {\n        if (ry == null) {\n            ry = rx;\n        }\n        return [[\"M\", x, y], [\"m\", 0, -ry], [\"a\", rx, ry, 0, 1, 1, 0, 2 * ry], [\"a\", rx, ry, 0, 1, 1, 0, -2 * ry], [\"z\"]];\n    },\n\n    // @private\n    getPathpath: function (el) {\n        return el.attr.path;\n    },\n\n    // @private\n    getPathcircle: function (el) {\n        var a = el.attr;\n        return this.ellipsePath(a.x, a.y, a.radius, a.radius);\n    },\n\n    // @private\n    getPathellipse: function (el) {\n        var a = el.attr;\n        return this.ellipsePath(a.x, a.y,\n                                a.radiusX || (a.width / 2) || 0,\n                                a.radiusY || (a.height / 2) || 0);\n    },\n\n    // @private\n    getPathrect: function (el) {\n        var a = el.attr;\n        return this.rectPath(a.x || 0, a.y || 0, a.width || 0, a.height || 0, a.r || 0);\n    },\n\n    // @private\n    getPathimage: function (el) {\n        var a = el.attr;\n        return this.rectPath(a.x || 0, a.y || 0, a.width, a.height);\n    },\n\n    // @private\n    getPathtext: function (el) {\n        var bbox = this.getBBoxText(el);\n        return this.rectPath(bbox.x, bbox.y, bbox.width, bbox.height);\n    },\n\n    createGroup: function(id) {\n        var group = this.groups.get(id);\n        if (!group) {\n            group = new Ext.draw.CompositeSprite({\n                surface: this\n            });\n            group.id = id || Ext.id(null, 'ext-surface-group-');\n            this.groups.add(group);\n        }\n        return group;\n    },\n\n    /**\n     * Returns a new group or an existent group associated with the current surface.\n     * The group returned is a {@link Ext.draw.CompositeSprite} group.\n     *\n     * For example:\n     *\n     *     var spriteGroup = drawComponent.surface.getGroup('someGroupId');\n     *\n     * @param {String} id The unique identifier of the group.\n     * @return {Object} The {@link Ext.draw.CompositeSprite}.\n     */\n    getGroup: function(id) {\n        var group;\n        if (typeof id == \"string\") {\n            group = this.groups.get(id);\n            if (!group) {\n                group = this.createGroup(id);\n            }\n        } else {\n            group = id;\n        }\n        return group;\n    },\n\n    // @private\n    prepareItems: function(items, applyDefaults) {\n        items = [].concat(items);\n        // Make sure defaults are applied and item is initialized\n        var item, i, ln;\n        for (i = 0, ln = items.length; i < ln; i++) {\n            item = items[i];\n            if (!(item instanceof Ext.draw.Sprite)) {\n                // Temporary, just take in configs...\n                item.surface = this;\n                items[i] = this.createItem(item);\n            } else {\n                item.surface = this;\n            }\n        }\n        return items;\n    },\n\n    /**\n     * Changes the text in the sprite element. The sprite must be a `text` sprite.\n     * This method can also be called from {@link Ext.draw.Sprite}.\n     *\n     * For example:\n     *\n     *     var spriteGroup = drawComponent.surface.setText(sprite, 'my new text');\n     *\n     * @param {Object} sprite The Sprite to change the text.\n     * @param {String} text The new text to be set.\n     * @method\n     */\n    setText: Ext.emptyFn,\n\n    // @private Creates an item and appends it to the surface. Called\n    // as an internal method when calling `add`.\n    createItem: Ext.emptyFn,\n\n    /**\n     * Retrieves the id of this component.\n     * Will autogenerate an id if one has not already been set.\n     */\n    getId: function() {\n        return this.id || (this.id = Ext.id(null, 'ext-surface-'));\n    },\n\n    /**\n     * Destroys the surface. This is done by removing all components from it and\n     * also removing its reference to a DOM element.\n     *\n     * For example:\n     *\n     *      drawComponent.surface.destroy();\n     */\n    destroy: function() {\n        var me = this;\n        delete me.domRef;\n        if (me.background) {\n            me.background.destroy();\n        }\n        me.removeAll(true);\n        Ext.destroy(me.groups.items);\n    }\n});\n\n/**\n * The Draw Component is a surface in which sprites can be rendered. The Draw Component\n * manages and holds an {@link Ext.draw.Surface} instance where\n * {@link Ext.draw.Sprite Sprites} can be appended.\n *\n * One way to create a draw component is:\n *\n *     @example\n *     var drawComponent = Ext.create('Ext.draw.Component', {\n *         viewBox: false,\n *         items: [{\n *             type: 'circle',\n *             fill: '#79BB3F',\n *             radius: 100,\n *             x: 100,\n *             y: 100\n *         }]\n *     });\n *\n *     Ext.create('Ext.Window', {\n *         width: 215,\n *         height: 235,\n *         layout: 'fit',\n *         items: [drawComponent]\n *     }).show();\n *\n * In this case we created a draw component and added a {@link Ext.draw.Sprite sprite} to it.\n * The {@link Ext.draw.Sprite#type type} of the sprite is `circle` so if you run this code you'll see a yellow-ish\n * circle in a Window. When setting `viewBox` to `false` we are responsible for setting the object's position and\n * dimensions accordingly.\n *\n * You can also add sprites by using the surface's add method:\n *\n *     drawComponent.surface.add({\n *         type: 'circle',\n *         fill: '#79BB3F',\n *         radius: 100,\n *         x: 100,\n *         y: 100\n *     });\n *\n * ## Larger example\n *\n *     @example\n *     var drawComponent = Ext.create('Ext.draw.Component', {\n *         width: 800,\n *         height: 600,\n *         renderTo: document.body\n *     }), surface = drawComponent.surface;\n *\n *     surface.add([{\n *         type: 'circle',\n *         radius: 10,\n *         fill: '#f00',\n *         x: 10,\n *         y: 10,\n *         group: 'circles'\n *     }, {\n *         type: 'circle',\n *         radius: 10,\n *         fill: '#0f0',\n *         x: 50,\n *         y: 50,\n *         group: 'circles'\n *     }, {\n *         type: 'circle',\n *         radius: 10,\n *         fill: '#00f',\n *         x: 100,\n *         y: 100,\n *         group: 'circles'\n *     }, {\n *         type: 'rect',\n *         width: 20,\n *         height: 20,\n *         fill: '#f00',\n *         x: 10,\n *         y: 10,\n *         group: 'rectangles'\n *     }, {\n *         type: 'rect',\n *         width: 20,\n *         height: 20,\n *         fill: '#0f0',\n *         x: 50,\n *         y: 50,\n *         group: 'rectangles'\n *     }, {\n *         type: 'rect',\n *         width: 20,\n *         height: 20,\n *         fill: '#00f',\n *         x: 100,\n *         y: 100,\n *         group: 'rectangles'\n *     }]);\n *\n *     // Get references to my groups\n *     circles = surface.getGroup('circles');\n *     rectangles = surface.getGroup('rectangles');\n *\n *     // Animate the circles down\n *     circles.animate({\n *         duration: 1000,\n *         to: {\n *             translate: {\n *                 y: 200\n *             }\n *         }\n *     });\n *\n *     // Animate the rectangles across\n *     rectangles.animate({\n *         duration: 1000,\n *         to: {\n *             translate: {\n *                 x: 200\n *             }\n *         }\n *     });\n *\n * For more information on Sprites, the core elements added to a draw component's surface,\n * refer to the {@link Ext.draw.Sprite} documentation.\n */\nExt.define('Ext.draw.Component', {\n\n    /* Begin Definitions */\n\n    alias: 'widget.draw',\n\n    extend: 'Ext.Component',\n\n    requires: [\n        'Ext.draw.Surface',\n        'Ext.layout.component.Draw'\n    ],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String[]} enginePriority\n     * Defines the priority order for which Surface implementation to use. The first\n     * one supported by the current environment will be used.\n     */\n    enginePriority: ['Svg', 'Vml'],\n\n    baseCls: Ext.baseCSSPrefix + 'surface',\n\n    componentLayout: 'draw',\n\n    /**\n     * @cfg {Boolean} viewBox\n     * Turn on view box support which will scale and position items in the draw component to fit to the component while\n     * maintaining aspect ratio. Note that this scaling can override other sizing settings on your items.\n     */\n    viewBox: true,\n\n    shrinkWrap: 3,\n    \n    /**\n     * @cfg {Boolean} autoSize\n     * Turn on autoSize support which will set the bounding div's size to the natural size of the contents.\n     */\n    autoSize: false,\n\n    /**\n     * @cfg {Object[]} gradients (optional) Define a set of gradients that can be used as `fill` property in sprites.\n     * The gradients array is an array of objects with the following properties:\n     *\n     *  - `id` - string - The unique name of the gradient.\n     *  - `angle` - number, optional - The angle of the gradient in degrees.\n     *  - `stops` - object - An object with numbers as keys (from 0 to 100) and style objects as values\n     *\n     * ## Example\n     *\n     *     gradients: [{\n     *         id: 'gradientId',\n     *         angle: 45,\n     *         stops: {\n     *             0: {\n     *                 color: '#555'\n     *             },\n     *             100: {\n     *                 color: '#ddd'\n     *             }\n     *         }\n     *     }, {\n     *         id: 'gradientId2',\n     *         angle: 0,\n     *         stops: {\n     *             0: {\n     *                 color: '#590'\n     *             },\n     *             20: {\n     *                 color: '#599'\n     *             },\n     *             100: {\n     *                 color: '#ddd'\n     *             }\n     *         }\n     *     }]\n     *\n     * Then the sprites can use `gradientId` and `gradientId2` by setting the fill attributes to those ids, for example:\n     *\n     *     sprite.setAttributes({\n     *         fill: 'url(#gradientId)'\n     *     }, true);\n     */\n\n    /**\n     * @cfg {Ext.draw.Sprite[]} items\n     * Array of sprites or sprite config objects to add initially to the surface.\n     */\n\n    /**\n     * @property {Ext.draw.Surface} surface\n     * The Surface instance managed by this component.\n     */\n\n    initComponent: function() {\n        this.callParent(arguments);\n\n        this.addEvents(\n            /**\n             * @event\n             * Event forwarded from {@link Ext.draw.Surface surface}.\n             * @inheritdoc Ext.draw.Surface#mousedown\n             */\n            'mousedown',\n            /**\n             * @event\n             * Event forwarded from {@link Ext.draw.Surface surface}.\n             * @inheritdoc Ext.draw.Surface#mouseup\n             */\n            'mouseup',\n            /**\n             * @event\n             * Event forwarded from {@link Ext.draw.Surface surface}.\n             * @inheritdoc Ext.draw.Surface#mousemove\n             */\n            'mousemove',\n            /**\n             * @event\n             * Event forwarded from {@link Ext.draw.Surface surface}.\n             * @inheritdoc Ext.draw.Surface#mouseenter\n             */\n            'mouseenter',\n            /**\n             * @event\n             * Event forwarded from {@link Ext.draw.Surface surface}.\n             * @inheritdoc Ext.draw.Surface#mouseleave\n             */\n            'mouseleave',\n            /**\n             * @event\n             * Event forwarded from {@link Ext.draw.Surface surface}.\n             * @inheritdoc Ext.draw.Surface#click\n             */\n            'click',\n            /**\n             * @event\n             * Event forwarded from {@link Ext.draw.Surface surface}.\n             * @inheritdoc Ext.draw.Surface#dblclick\n             */\n            'dblclick'\n        );\n    },\n\n    /**\n     * @private\n     *\n     * Create the Surface on initial render\n     */\n    onRender: function() {\n        var me = this,\n            viewBox = me.viewBox,\n            autoSize = me.autoSize,\n            bbox, items, width, height, x, y;\n        me.callParent(arguments);\n\n        if (me.createSurface() !== false) {\n            items = me.surface.items;\n\n            if (viewBox || autoSize) {\n                bbox = items.getBBox();\n                width = bbox.width;\n                height = bbox.height;\n                x = bbox.x;\n                y = bbox.y;\n                if (me.viewBox) {\n                    me.surface.setViewBox(x, y, width, height);\n                } else {\n                    me.autoSizeSurface();\n                }\n            }\n        }\n    },\n\n    // @private\n    autoSizeSurface: function() {\n        var bbox = this.surface.items.getBBox();\n        this.setSurfaceSize(bbox.width, bbox.height);\n    },\n\n    setSurfaceSize: function (width, height) {\n        this.surface.setSize(width, height);\n        if (this.autoSize) {\n            var bbox = this.surface.items.getBBox();\n            this.surface.setViewBox(bbox.x, bbox.y - (+Ext.isOpera), width, height);\n        }\n    },\n    \n    /**\n     * Create the Surface instance. Resolves the correct Surface implementation to\n     * instantiate based on the 'enginePriority' config. Once the Surface instance is\n     * created you can use the handle to that instance to add sprites. For example:\n     *\n     *     drawComponent.surface.add(sprite);\n     *\n     * @private\n     */\n    createSurface: function() {\n        var me = this,\n            cfg = Ext.applyIf({\n                renderTo: me.el,\n                height: me.height,\n                width: me.width,\n                items: me.items\n            }, me.initialConfig), surface;\n\n        // ensure we remove any listeners to prevent duplicate events since we refire them below\n        delete cfg.listeners;\n        surface = Ext.draw.Surface.create(cfg);\n        if (!surface) {\n            // In case we cannot create a surface, return false so we can stop\n            return false;\n        }\n        me.surface = surface;\n\n\n        function refire(eventName) {\n            return function(e) {\n                me.fireEvent(eventName, e);\n            };\n        }\n\n        surface.on({\n            scope: me,\n            mouseup: refire('mouseup'),\n            mousedown: refire('mousedown'),\n            mousemove: refire('mousemove'),\n            mouseenter: refire('mouseenter'),\n            mouseleave: refire('mouseleave'),\n            click: refire('click'),\n            dblclick: refire('dblclick')\n        });\n    },\n\n\n    /**\n     * @private\n     *\n     * Clean up the Surface instance on component destruction\n     */\n    onDestroy: function() {\n        Ext.destroy(this.surface);\n        this.callParent(arguments);\n    }\n\n});\n\n/**\n * @private\n */\nExt.define('Ext.chart.Shape', {\n\n    /* Begin Definitions */\n\n    singleton: true,\n\n    /* End Definitions */\n\n    circle: function (surface, opts) {\n        return surface.add(Ext.apply({\n            type: 'circle',\n            x: opts.x,\n            y: opts.y,\n            stroke: null,\n            radius: opts.radius\n        }, opts));\n    },\n    line: function (surface, opts) {\n        return surface.add(Ext.apply({\n            type: 'rect',\n            x: opts.x - opts.radius,\n            y: opts.y - opts.radius,\n            height: 2 * opts.radius,\n            width: 2 * opts.radius / 5\n        }, opts));\n    },\n    square: function (surface, opts) {\n        return surface.add(Ext.applyIf({\n            type: 'rect',\n            x: opts.x - opts.radius,\n            y: opts.y - opts.radius,\n            height: 2 * opts.radius,\n            width: 2 * opts.radius,\n            radius: null\n        }, opts));\n    },\n    triangle: function (surface, opts) {\n        opts.radius *= 1.75;\n        return surface.add(Ext.apply({\n            type: 'path',\n            stroke: null,\n            path: \"M\".concat(opts.x, \",\", opts.y, \"m0-\", opts.radius * 0.58, \"l\", opts.radius * 0.5, \",\", opts.radius * 0.87, \"-\", opts.radius, \",0z\")\n        }, opts));\n    },\n    diamond: function (surface, opts) {\n        var r = opts.radius;\n        r *= 1.5;\n        return surface.add(Ext.apply({\n            type: 'path',\n            stroke: null,\n            path: [\"M\", opts.x, opts.y - r, \"l\", r, r, -r, r, -r, -r, r, -r, \"z\"]\n        }, opts));\n    },\n    cross: function (surface, opts) {\n        var r = opts.radius;\n        r = r / 1.7;\n        return surface.add(Ext.apply({\n            type: 'path',\n            stroke: null,\n            path: \"M\".concat(opts.x - r, \",\", opts.y, \"l\", [-r, -r, r, -r, r, r, r, -r, r, r, -r, r, r, r, -r, r, -r, -r, -r, r, -r, -r, \"z\"])\n        }, opts));\n    },\n    plus: function (surface, opts) {\n        var r = opts.radius / 1.3;\n        return surface.add(Ext.apply({\n            type: 'path',\n            stroke: null,\n            path: \"M\".concat(opts.x - r / 2, \",\", opts.y - r / 2, \"l\", [0, -r, r, 0, 0, r, r, 0, 0, r, -r, 0, 0, r, -r, 0, 0, -r, -r, 0, 0, -r, \"z\"])\n        }, opts));\n    },\n    arrow: function (surface, opts) {\n        var r = opts.radius;\n        return surface.add(Ext.apply({\n            type: 'path',\n            path: \"M\".concat(opts.x - r * 0.7, \",\", opts.y - r * 0.4, \"l\", [r * 0.6, 0, 0, -r * 0.4, r, r * 0.8, -r, r * 0.8, 0, -r * 0.4, -r * 0.6, 0], \"z\")\n        }, opts));\n    },\n    drop: function (surface, x, y, text, size, angle) {\n        size = size || 30;\n        angle = angle || 0;\n        surface.add({\n            type: 'path',\n            path: ['M', x, y, 'l', size, 0, 'A', size * 0.4, size * 0.4, 0, 1, 0, x + size * 0.7, y - size * 0.7, 'z'],\n            fill: '#000',\n            stroke: 'none',\n            rotate: {\n                degrees: 22.5 - angle,\n                x: x,\n                y: y\n            }\n        });\n        angle = (angle + 90) * Math.PI / 180;\n        surface.add({\n            type: 'text',\n            x: x + size * Math.sin(angle) - 10, // Shift here, Not sure why.\n            y: y + size * Math.cos(angle) + 5,\n            text:  text,\n            'font-size': size * 12 / 40,\n            stroke: 'none',\n            fill: '#fff'\n        });\n    }\n});\n\n/**\n * @class Ext.chart.LegendItem\n * A single item of a legend (marker plus label)\n */\nExt.define('Ext.chart.LegendItem', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.draw.CompositeSprite',\n\n    requires: ['Ext.chart.Shape'],\n\n    /* End Definitions */\n\n    // Position of the item, relative to the upper-left corner of the legend box\n    x: 0,\n    y: 0,\n    zIndex: 500,\n\n    // checks to make sure that a unit size follows the bold keyword in the font style value\n    boldRe: /bold\\s\\d{1,}.*/i,\n\n    constructor: function(config) {\n        this.callParent(arguments);\n        this.createLegend(config);\n    },\n\n    /**\n     * Creates all the individual sprites for this legend item\n     */\n    createLegend: function(config) {\n        var me = this,\n            index = config.yFieldIndex,\n            series = me.series,\n            seriesType = series.type,\n            idx = me.yFieldIndex,\n            legend = me.legend,\n            surface = me.surface,\n            refX = legend.x + me.x,\n            refY = legend.y + me.y,\n            bbox, z = me.zIndex,\n            markerConfig, label, mask,\n            radius, toggle = false,\n            seriesStyle = Ext.apply(series.seriesStyle, series.style);\n\n        function getSeriesProp(name) {\n            var val = series[name];\n            return (Ext.isArray(val) ? val[idx] : val);\n        }\n        \n        label = me.add('label', surface.add({\n            type: 'text',\n            x: 20,\n            y: 0,\n            zIndex: (z || 0) + 2,\n            fill: legend.labelColor,\n            font: legend.labelFont,\n            text: getSeriesProp('title') || getSeriesProp('yField'),\n            style: {\n                'cursor': 'pointer'\n            }\n        }));\n\n        // Line series - display as short line with optional marker in the middle\n        if (seriesType === 'line' || seriesType === 'scatter') {\n            if(seriesType === 'line') {\n                me.add('line', surface.add({\n                    type: 'path',\n                    path: 'M0.5,0.5L16.5,0.5',\n                    zIndex: (z || 0) + 2,\n                    \"stroke-width\": series.lineWidth,\n                    \"stroke-linejoin\": \"round\",\n                    \"stroke-dasharray\": series.dash,\n                    stroke: seriesStyle.stroke || series.getLegendColor(index) || '#000',\n                    style: {\n                        cursor: 'pointer'\n                    }\n                }));\n            }\n            if (series.showMarkers || seriesType === 'scatter') {\n                markerConfig = Ext.apply(series.markerStyle, series.markerConfig || {}, {\n                    fill: series.getLegendColor(index)\n                });\n                me.add('marker', Ext.chart.Shape[markerConfig.type](surface, {\n                    fill: markerConfig.fill,\n                    x: 8.5,\n                    y: 0.5,\n                    zIndex: (z || 0) + 2,\n                    radius: markerConfig.radius || markerConfig.size,\n                    style: {\n                        cursor: 'pointer'\n                    }\n                }));\n            }\n        }\n        // All other series types - display as filled box\n        else {\n            me.add('box', surface.add({\n                type: 'rect',\n                zIndex: (z || 0) + 2,\n                x: 0,\n                y: 0,\n                width: 12,\n                height: 12,\n                fill: series.getLegendColor(index),\n                style: {\n                    cursor: 'pointer'\n                }\n            }));\n        }\n        \n        me.setAttributes({\n            hidden: false\n        }, true);\n        \n        bbox = me.getBBox();\n        \n        mask = me.add('mask', surface.add({\n            type: 'rect',\n            x: bbox.x,\n            y: bbox.y,\n            width: bbox.width || 20,\n            height: bbox.height || 20,\n            zIndex: (z || 0) + 1,\n            fill: me.legend.boxFill,\n            style: {\n                'cursor': 'pointer'\n            }\n        }));\n\n        //add toggle listener\n        me.on('mouseover', function() {\n            label.setStyle({\n                'font-weight': 'bold'\n            });\n            mask.setStyle({\n                'cursor': 'pointer'\n            });\n            series._index = index;\n            series.highlightItem();\n        }, me);\n\n        me.on('mouseout', function() {\n            label.setStyle({\n                'font-weight': legend.labelFont && me.boldRe.test(legend.labelFont) ? 'bold' : 'normal'\n            });\n            series._index = index;\n            series.unHighlightItem();\n        }, me);\n        \n        if (!series.visibleInLegend(index)) {\n            toggle = true;\n            label.setAttributes({\n               opacity: 0.5\n            }, true);\n        }\n\n        me.on('mousedown', function() {\n            if (!toggle) {\n                series.hideAll(index);\n                label.setAttributes({\n                    opacity: 0.5\n                }, true);\n            } else {\n                series.showAll(index);\n                label.setAttributes({\n                    opacity: 1\n                }, true);\n            }\n            toggle = !toggle;\n            me.legend.chart.redraw();\n        }, me);\n        me.updatePosition({x:0, y:0}); //Relative to 0,0 at first so that the bbox is calculated correctly\n    },\n\n    /**\n     * Update the positions of all this item's sprites to match the root position\n     * of the legend box.\n     * @param {Object} relativeTo (optional) If specified, this object's 'x' and 'y' values will be used\n     *                 as the reference point for the relative positioning. Defaults to the Legend.\n     */\n    updatePosition: function(relativeTo) {\n        var me = this,\n            items = me.items,\n            ln = items.length,\n            i = 0,\n            item;\n        if (!relativeTo) {\n            relativeTo = me.legend;\n        }\n        for (; i < ln; i++) {\n            item = items[i];\n            switch (item.type) {\n                case 'text':\n                    item.setAttributes({\n                        x: 20 + relativeTo.x + me.x,\n                        y: relativeTo.y + me.y\n                    }, true);\n                    break;\n                case 'rect':\n                    item.setAttributes({\n                        translate: {\n                            x: relativeTo.x + me.x,\n                            y: relativeTo.y + me.y - 6\n                        }\n                    }, true);\n                    break;\n                default:\n                    item.setAttributes({\n                        translate: {\n                            x: relativeTo.x + me.x,\n                            y: relativeTo.y + me.y\n                        }\n                    }, true);\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.chart.Legend\n *\n * Defines a legend for a chart's series.\n * The 'chart' member must be set prior to rendering.\n * The legend class displays a list of legend items each of them related with a\n * series being rendered. In order to render the legend item of the proper series\n * the series configuration object must have `showInLegend` set to true.\n *\n * The legend configuration object accepts a `position` as parameter.\n * The `position` parameter can be `left`, `right`\n * `top` or `bottom`. For example:\n *\n *     legend: {\n *         position: 'right'\n *     },\n *\n * ## Example\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],\n *         data: [\n *             { 'name': 'metric one',   'data1': 10, 'data2': 12, 'data3': 14, 'data4': 8,  'data5': 13 },\n *             { 'name': 'metric two',   'data1': 7,  'data2': 8,  'data3': 16, 'data4': 10, 'data5': 3  },\n *             { 'name': 'metric three', 'data1': 5,  'data2': 2,  'data3': 14, 'data4': 12, 'data5': 7  },\n *             { 'name': 'metric four',  'data1': 2,  'data2': 14, 'data3': 6,  'data4': 1,  'data5': 23 },\n *             { 'name': 'metric five',  'data1': 27, 'data2': 38, 'data3': 36, 'data4': 13, 'data5': 33 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         animate: true,\n *         store: store,\n *         shadow: true,\n *         theme: 'Category1',\n *         legend: {\n *             position: 'top'\n *         },\n *         axes: [\n *             {\n *                 type: 'Numeric',\n *                 grid: true,\n *                 position: 'left',\n *                 fields: ['data1', 'data2', 'data3', 'data4', 'data5'],\n *                 title: 'Sample Values',\n *                 grid: {\n *                     odd: {\n *                         opacity: 1,\n *                         fill: '#ddd',\n *                         stroke: '#bbb',\n *                         'stroke-width': 1\n *                     }\n *                 },\n *                 minimum: 0,\n *                 adjustMinimumByMajorUnit: 0\n *             },\n *             {\n *                 type: 'Category',\n *                 position: 'bottom',\n *                 fields: ['name'],\n *                 title: 'Sample Metrics',\n *                 grid: true,\n *                 label: {\n *                     rotate: {\n *                         degrees: 315\n *                     }\n *                 }\n *             }\n *         ],\n *         series: [{\n *             type: 'area',\n *             highlight: false,\n *             axis: 'left',\n *             xField: 'name',\n *             yField: ['data1', 'data2', 'data3', 'data4', 'data5'],\n *             style: {\n *                 opacity: 0.93\n *             }\n *         }]\n *     });\n */\nExt.define('Ext.chart.Legend', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.chart.LegendItem'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Boolean} visible\n     * Whether or not the legend should be displayed.\n     */\n    visible: true,\n    \n    /**\n     * @cfg {Boolean} update\n     * If set to true the legend will be refreshed when the chart is.\n     * This is useful to update the legend items if series are\n     * added/removed/updated from the chart. Default is true.\n     */\n    update: true,\n\n    /**\n     * @cfg {String} position\n     * The position of the legend in relation to the chart. One of: \"top\",\n     * \"bottom\", \"left\", \"right\", or \"float\". If set to \"float\", then the legend\n     * box will be positioned at the point denoted by the x and y parameters.\n     */\n    position: 'bottom',\n\n    /**\n     * @cfg {Number} x\n     * X-position of the legend box. Used directly if position is set to \"float\", otherwise\n     * it will be calculated dynamically.\n     */\n    x: 0,\n\n    /**\n     * @cfg {Number} y\n     * Y-position of the legend box. Used directly if position is set to \"float\", otherwise\n     * it will be calculated dynamically.\n     */\n    y: 0,\n\n    /**\n     * @cfg {String} labelColor\n     * Color to be used for the legend labels, eg '#000'\n     */\n    labelColor: '#000',\n\n    /**\n     * @cfg {String} labelFont\n     * Font to be used for the legend labels, eg '12px Helvetica'\n     */\n    labelFont: '12px Helvetica, sans-serif',\n\n    /**\n     * @cfg {String} boxStroke\n     * Style of the stroke for the legend box\n     */\n    boxStroke: '#000',\n\n    /**\n     * @cfg {String} boxStrokeWidth\n     * Width of the stroke for the legend box\n     */\n    boxStrokeWidth: 1,\n\n    /**\n     * @cfg {String} boxFill\n     * Fill style for the legend box\n     */\n    boxFill: '#FFF',\n\n    /**\n     * @cfg {Number} itemSpacing\n     * Amount of space between legend items\n     */\n    itemSpacing: 10,\n\n    /**\n     * @cfg {Number} padding\n     * Amount of padding between the legend box's border and its items\n     */\n    padding: 5,\n\n    // @private\n    width: 0,\n    // @private\n    height: 0,\n\n    /**\n     * @cfg {Number} boxZIndex\n     * Sets the z-index for the legend. Defaults to 100.\n     */\n    boxZIndex: 100,\n\n    /**\n     * Creates new Legend.\n     * @param {Object} config  (optional) Config object.\n     */\n    constructor: function(config) {\n        var me = this;\n        if (config) {\n            Ext.apply(me, config);\n        }\n        me.items = [];\n        /**\n         * Whether the legend box is oriented vertically, i.e. if it is on the left or right side or floating.\n         * @type {Boolean}\n         */\n        me.isVertical = (\"left|right|float\".indexOf(me.position) !== -1);\n\n        // cache these here since they may get modified later on\n        me.origX = me.x;\n        me.origY = me.y;\n    },\n\n    /**\n     * @private Create all the sprites for the legend\n     */\n    create: function() {\n        var me = this,\n            seriesItems = me.chart.series.items,\n            i, ln, series;\n\n        me.createBox();\n        \n        if (me.rebuild !== false) {\n            me.createItems();\n        }\n        \n        if (!me.created && me.isDisplayed()) {\n            me.created = true;\n\n            // Listen for changes to series titles to trigger regeneration of the legend\n            for (i = 0, ln = seriesItems.length; i < ln; i++) {\n                series = seriesItems[i];\n                series.on('titlechange', function() {\n                    me.create();\n                    me.updatePosition();\n                });\n            }\n        }\n    },\n\n    /**\n     * @private Determine whether the legend should be displayed. Looks at the legend's 'visible' config,\n     * and also the 'showInLegend' config for each of the series.\n     */\n    isDisplayed: function() {\n        return this.visible && this.chart.series.findIndex('showInLegend', true) !== -1;\n    },\n\n    /**\n     * @private Create the series markers and labels\n     */\n    createItems: function() {\n        var me = this,\n            chart = me.chart,\n            seriesItems = chart.series.items,\n            ln, series,\n            surface = chart.surface,\n            items = me.items,\n            padding = me.padding,\n            itemSpacing = me.itemSpacing,\n            spacingOffset = 2,\n            maxWidth = 0,\n            maxHeight = 0,\n            totalWidth = 0,\n            totalHeight = 0,\n            vertical = me.isVertical,\n            math = Math,\n            mfloor = math.floor,\n            mmax = math.max,\n            index = 0,\n            i = 0,\n            len = items ? items.length : 0,\n            x, y, spacing, item, bbox, height, width,\n            fields, field, nFields, j;\n\n        //remove all legend items\n        if (len) {\n            for (; i < len; i++) {\n                items[i].destroy();\n            }\n        }\n        //empty array\n        items.length = [];\n        // Create all the item labels, collecting their dimensions and positioning each one\n        // properly in relation to the previous item\n        for (i = 0, ln = seriesItems.length; i < ln; i++) {\n            series = seriesItems[i];\n            if (series.showInLegend) {\n                fields = [].concat(series.yField);\n                for (j = 0, nFields = fields.length; j < nFields; j++) {\n                    field = fields[j];\n                    item = new Ext.chart.LegendItem({\n                        legend: this,\n                        series: series,\n                        surface: chart.surface,\n                        yFieldIndex: j\n                    });\n                    bbox = item.getBBox();\n\n                    //always measure from x=0, since not all markers go all the way to the left\n                    width = bbox.width;\n                    height = bbox.height;\n\n                    if (i + j === 0) {\n                        spacing = vertical ? padding + height / 2 : padding;\n                    }\n                    else {\n                        spacing = itemSpacing / (vertical ? 2 : 1);\n                    }\n                    // Set the item's position relative to the legend box\n                    item.x = mfloor(vertical ? padding : totalWidth + spacing);\n                    item.y = mfloor(vertical ? totalHeight + spacing : padding + height / 2);\n\n                    // Collect cumulative dimensions\n                    totalWidth += width + spacing;\n                    totalHeight += height + spacing;\n                    maxWidth = mmax(maxWidth, width);\n                    maxHeight = mmax(maxHeight, height);\n\n                    items.push(item);\n                }\n            }\n        }\n\n        // Store the collected dimensions for later\n        me.width = mfloor((vertical ? maxWidth : totalWidth) + padding * 2);\n        if (vertical && items.length === 1) {\n            spacingOffset = 1;\n        }\n        me.height = mfloor((vertical ? totalHeight - spacingOffset * spacing : maxHeight) + (padding * 2));\n        me.itemHeight = maxHeight;\n    },\n\n    /**\n     * @private Get the bounds for the legend's outer box\n     */\n    getBBox: function() {\n        var me = this;\n        return {\n            x: Math.round(me.x) - me.boxStrokeWidth / 2,\n            y: Math.round(me.y) - me.boxStrokeWidth / 2,\n            width: me.width,\n            height: me.height\n        };\n    },\n\n    /**\n     * @private Create the box around the legend items\n     */\n    createBox: function() {\n        var me = this,\n            box, bbox;\n\n        if (me.boxSprite) {\n            me.boxSprite.destroy();\n        }\n\n        bbox = me.getBBox();\n        //if some of the dimensions are NaN this means that we\n        //cannot set a specific width/height for the legend\n        //container. One possibility for this is that there are\n        //actually no items to show in the legend, and the legend\n        //should be hidden.\n        if (isNaN(bbox.width) || isNaN(bbox.height)) {\n            me.boxSprite = false;\n            return;\n        }\n        \n        box = me.boxSprite = me.chart.surface.add(Ext.apply({\n            type: 'rect',\n            stroke: me.boxStroke,\n            \"stroke-width\": me.boxStrokeWidth,\n            fill: me.boxFill,\n            zIndex: me.boxZIndex\n        }, bbox));\n\n        box.redraw();\n    },\n\n    /**\n     * @private Update the position of all the legend's sprites to match its current x/y values\n     */\n    updatePosition: function() {\n        var me = this,\n            items = me.items,\n            i, ln,\n            x, y,\n            legendWidth = me.width || 0,\n            legendHeight = me.height || 0,\n            padding = me.padding,\n            chart = me.chart,\n            chartBBox = chart.chartBBox,\n            insets = chart.insetPadding,\n            chartWidth = chartBBox.width - (insets * 2),\n            chartHeight = chartBBox.height - (insets * 2),\n            chartX = chartBBox.x + insets,\n            chartY = chartBBox.y + insets,\n            surface = chart.surface,\n            mfloor = Math.floor,\n            bbox;\n\n        if (me.isDisplayed()) {\n            // Find the position based on the dimensions\n            switch(me.position) {\n                case \"left\":\n                    x = insets;\n                    y = mfloor(chartY + chartHeight / 2 - legendHeight / 2);\n                    break;\n                case \"right\":\n                    x = mfloor(surface.width - legendWidth) - insets;\n                    y = mfloor(chartY + chartHeight / 2 - legendHeight / 2);\n                    break;\n                case \"top\":\n                    x = mfloor(chartX + chartWidth / 2 - legendWidth / 2);\n                    y = insets;\n                    break;\n                case \"bottom\":\n                    x = mfloor(chartX + chartWidth / 2 - legendWidth / 2);\n                    y = mfloor(surface.height - legendHeight) - insets;\n                    break;\n                default:\n                    x = mfloor(me.origX) + insets;\n                    y = mfloor(me.origY) + insets;\n            }\n            me.x = x;\n            me.y = y;\n\n            // Update the position of each item\n            for (i = 0, ln = items.length; i < ln; i++) {\n                items[i].updatePosition();\n            }\n\n            bbox = me.getBBox();\n\n            //if some of the dimensions are NaN this means that we\n            //cannot set a specific width/height for the legend\n            //container. One possibility for this is that there are\n            //actually no items to show in the legend, and the legend\n            //should be hidden.\n            if (isNaN(bbox.width) || isNaN(bbox.height)) {\n                if (me.boxSprite) {\n                    me.boxSprite.hide(true);\n                }\n            } else {\n                if (!me.boxSprite) {\n                    me.createBox();\n                }\n                // Update the position of the outer box\n                me.boxSprite.setAttributes(bbox, true);\n                me.boxSprite.show(true);\n            }\n        }\n    },\n    \n    /** toggle\n     * @param {Boolean} Whether to show or hide the legend.\n     *\n     */\n    toggle: function(show) {\n      var me = this,\n          i = 0,\n          items = me.items,\n          len = items.length;\n\n      if (me.boxSprite) {\n          if (show) {\n              me.boxSprite.show(true);\n          } else {\n              me.boxSprite.hide(true);\n          }\n      }\n\n      for (; i < len; ++i) {\n          if (show) {\n            items[i].show(true);\n          } else {\n              items[i].hide(true);\n          }\n      }\n\n      me.visible = show;\n    }\n});\n\n/**\n * @class Ext.chart.theme.Theme\n * \n * Provides chart theming.\n * \n * Used as mixins by Ext.chart.Chart.\n */\nExt.define('Ext.chart.theme.Theme', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.draw.Color'],\n\n    /* End Definitions */\n\n    theme: 'Base',\n    themeAttrs: false,\n    \n    initTheme: function(theme) {\n        var me = this,\n            themes = Ext.chart.theme,\n            key, gradients;\n        if (theme) {\n            theme = theme.split(':');\n            for (key in themes) {\n                if (key == theme[0]) {\n                    gradients = theme[1] == 'gradients';\n                    me.themeAttrs = new themes[key]({\n                        useGradients: gradients\n                    });\n                    if (gradients) {\n                        me.gradients = me.themeAttrs.gradients;\n                    }\n                    if (me.themeAttrs.background) {\n                        me.background = me.themeAttrs.background;\n                    }\n                    return;\n                }\n            }\n            Ext.Error.raise('No theme found named \"' + theme + '\"');\n        }\n    }\n}, \n// This callback is executed right after when the class is created. This scope refers to the newly created class itself\nfunction() {\n   /* Theme constructor: takes either a complex object with styles like:\n  \n   {\n        axis: {\n            fill: '#000',\n            'stroke-width': 1\n        },\n        axisLabelTop: {\n            fill: '#000',\n            font: '11px Arial'\n        },\n        axisLabelLeft: {\n            fill: '#000',\n            font: '11px Arial'\n        },\n        axisLabelRight: {\n            fill: '#000',\n            font: '11px Arial'\n        },\n        axisLabelBottom: {\n            fill: '#000',\n            font: '11px Arial'\n        },\n        axisTitleTop: {\n            fill: '#000',\n            font: '11px Arial'\n        },\n        axisTitleLeft: {\n            fill: '#000',\n            font: '11px Arial'\n        },\n        axisTitleRight: {\n            fill: '#000',\n            font: '11px Arial'\n        },\n        axisTitleBottom: {\n            fill: '#000',\n            font: '11px Arial'\n        },\n        series: {\n            'stroke-width': 1\n        },\n        seriesLabel: {\n            font: '12px Arial',\n            fill: '#333'\n        },\n        marker: {\n            stroke: '#555',\n            fill: '#000',\n            radius: 3,\n            size: 3\n        },\n        seriesThemes: [{\n            fill: '#C6DBEF'\n        }, {\n            fill: '#9ECAE1'\n        }, {\n            fill: '#6BAED6'\n        }, {\n            fill: '#4292C6'\n        }, {\n            fill: '#2171B5'\n        }, {\n            fill: '#084594'\n        }],\n        markerThemes: [{\n            fill: '#084594',\n            type: 'circle' \n        }, {\n            fill: '#2171B5',\n            type: 'cross'\n        }, {\n            fill: '#4292C6',\n            type: 'plus'\n        }]\n    }\n  \n  ...or also takes just an array of colors and creates the complex object:\n  \n  {\n      colors: ['#aaa', '#bcd', '#eee']\n  }\n  \n  ...or takes just a base color and makes a theme from it\n  \n  {\n      baseColor: '#bce'\n  }\n  \n  To create a new theme you may add it to the Themes object:\n  \n  Ext.chart.theme.MyNewTheme = Ext.extend(Object, {\n      constructor: function(config) {\n          Ext.chart.theme.call(this, config, {\n              baseColor: '#mybasecolor'\n          });\n      }\n  });\n  \n  //Proposal:\n  Ext.chart.theme.MyNewTheme = Ext.chart.createTheme('#basecolor');\n  \n  ...and then to use it provide the name of the theme (as a lower case string) in the chart config.\n  \n  {\n      theme: 'mynewtheme'\n  }\n */\n\n(function() {\n    Ext.chart.theme = function(config, base) {\n        config = config || {};\n        var i = 0, d = +new Date(), l, colors, color,\n            seriesThemes, markerThemes,\n            seriesTheme, markerTheme, \n            key, gradients = [],\n            midColor, midL;\n        \n        if (config.baseColor) {\n            midColor = Ext.draw.Color.fromString(config.baseColor);\n            midL = midColor.getHSL()[2];\n            if (midL < 0.15) {\n                midColor = midColor.getLighter(0.3);\n            } else if (midL < 0.3) {\n                midColor = midColor.getLighter(0.15);\n            } else if (midL > 0.85) {\n                midColor = midColor.getDarker(0.3);\n            } else if (midL > 0.7) {\n                midColor = midColor.getDarker(0.15);\n            }\n            config.colors = [ midColor.getDarker(0.3).toString(),\n                              midColor.getDarker(0.15).toString(),\n                              midColor.toString(),\n                              midColor.getLighter(0.15).toString(),\n                              midColor.getLighter(0.3).toString()];\n\n            delete config.baseColor;\n        }\n        if (config.colors) {\n            colors = config.colors.slice();\n            markerThemes = base.markerThemes;\n            seriesThemes = base.seriesThemes;\n            l = colors.length;\n            base.colors = colors;\n            for (; i < l; i++) {\n                color = colors[i];\n                markerTheme = markerThemes[i] || {};\n                seriesTheme = seriesThemes[i] || {};\n                markerTheme.fill = seriesTheme.fill = markerTheme.stroke = seriesTheme.stroke = color;\n                markerThemes[i] = markerTheme;\n                seriesThemes[i] = seriesTheme;\n            }\n            base.markerThemes = markerThemes.slice(0, l);\n            base.seriesThemes = seriesThemes.slice(0, l);\n        //the user is configuring something in particular (either markers, series or pie slices)\n        }\n        for (key in base) {\n            if (key in config) {\n                if (Ext.isObject(config[key]) && Ext.isObject(base[key])) {\n                    Ext.apply(base[key], config[key]);\n                } else {\n                    base[key] = config[key];\n                }\n            }\n        }\n        if (config.useGradients) {\n            colors = base.colors || (function () {\n                var ans = [];\n                for (i = 0, seriesThemes = base.seriesThemes, l = seriesThemes.length; i < l; i++) {\n                    ans.push(seriesThemes[i].fill || seriesThemes[i].stroke);\n                }\n                return ans;\n            }());\n            for (i = 0, l = colors.length; i < l; i++) {\n                midColor = Ext.draw.Color.fromString(colors[i]);\n                if (midColor) {\n                    color = midColor.getDarker(0.1).toString();\n                    midColor = midColor.toString();\n                    key = 'theme-' + midColor.substr(1) + '-' + color.substr(1) + '-' + d;\n                    gradients.push({\n                        id: key,\n                        angle: 45,\n                        stops: {\n                            0: {\n                                color: midColor.toString()\n                            },\n                            100: {\n                                color: color.toString()\n                            }\n                        }\n                    });\n                    colors[i] = 'url(#' + key + ')'; \n                }\n            }\n            base.gradients = gradients;\n            base.colors = colors;\n        }\n        /*\n        base.axis = Ext.apply(base.axis || {}, config.axis || {});\n        base.axisLabel = Ext.apply(base.axisLabel || {}, config.axisLabel || {});\n        base.axisTitle = Ext.apply(base.axisTitle || {}, config.axisTitle || {});\n        */\n        Ext.apply(this, base);\n    };\n}());\n});\n\n/**\n * Provides default colors for non-specified things. Should be sub-classed when creating new themes.\n * @private\n */\nExt.define('Ext.chart.theme.Base', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.chart.theme.Theme'],\n\n    /* End Definitions */\n\n    constructor: function(config) {\n        Ext.chart.theme.call(this, config, {\n            background: false,\n            axis: {\n                stroke: '#444',\n                'stroke-width': 1\n            },\n            axisLabelTop: {\n                fill: '#444',\n                font: '12px Arial, Helvetica, sans-serif',\n                spacing: 2,\n                padding: 5,\n                renderer: function(v) { return v; }\n            },\n            axisLabelRight: {\n                fill: '#444',\n                font: '12px Arial, Helvetica, sans-serif',\n                spacing: 2,\n                padding: 5,\n                renderer: function(v) { return v; }\n            },\n            axisLabelBottom: {\n                fill: '#444',\n                font: '12px Arial, Helvetica, sans-serif',\n                spacing: 2,\n                padding: 5,\n                renderer: function(v) { return v; }\n            },\n            axisLabelLeft: {\n                fill: '#444',\n                font: '12px Arial, Helvetica, sans-serif',\n                spacing: 2,\n                padding: 5,\n                renderer: function(v) { return v; }\n            },\n            axisTitleTop: {\n                font: 'bold 18px Arial',\n                fill: '#444'\n            },\n            axisTitleRight: {\n                font: 'bold 18px Arial',\n                fill: '#444',\n                rotate: {\n                    x:0, y:0,\n                    degrees: 270\n                }\n            },\n            axisTitleBottom: {\n                font: 'bold 18px Arial',\n                fill: '#444'\n            },\n            axisTitleLeft: {\n                font: 'bold 18px Arial',\n                fill: '#444',\n                rotate: {\n                    x:0, y:0,\n                    degrees: 270\n                }\n            },\n            series: {\n                'stroke-width': 0\n            },\n            seriesLabel: {\n                font: '12px Arial',\n                fill: '#333'\n            },\n            marker: {\n                stroke: '#555',\n                radius: 3,\n                size: 3\n            },\n            colors: [ \"#94ae0a\", \"#115fa6\",\"#a61120\", \"#ff8809\", \"#ffd13e\", \"#a61187\", \"#24ad9a\", \"#7c7474\", \"#a66111\"],\n            seriesThemes: [{\n                fill: \"#115fa6\"\n            }, {\n                fill: \"#94ae0a\"\n            }, {\n                fill: \"#a61120\"\n            }, {\n                fill: \"#ff8809\"\n            }, {\n                fill: \"#ffd13e\"\n            }, {\n                fill: \"#a61187\"\n            }, {\n                fill: \"#24ad9a\"\n            }, {\n                fill: \"#7c7474\"\n            }, {\n                fill: \"#115fa6\"\n            }, {\n                fill: \"#94ae0a\"\n            }, {\n                fill: \"#a61120\"\n            }, {\n                fill: \"#ff8809\"\n            }, {\n                fill: \"#ffd13e\"\n            }, {\n                fill: \"#a61187\"\n            }, {\n                fill: \"#24ad9a\"\n            }, {\n                fill: \"#7c7474\"\n            }, {\n                fill: \"#a66111\"\n            }],\n            markerThemes: [{\n                fill: \"#115fa6\",\n                type: 'circle' \n            }, {\n                fill: \"#94ae0a\",\n                type: 'cross'\n            }, {\n                fill: \"#115fa6\",\n                type: 'plus' \n            }, {\n                fill: \"#94ae0a\",\n                type: 'circle'\n            }, {\n                fill: \"#a61120\",\n                type: 'cross'\n            }]\n        });\n    }\n}, function() {\n    var palette = ['#b1da5a', '#4ce0e7', '#e84b67', '#da5abd', '#4d7fe6', '#fec935'],\n        names = ['Green', 'Sky', 'Red', 'Purple', 'Blue', 'Yellow'],\n        i = 0, j = 0, l = palette.length, themes = Ext.chart.theme,\n        categories = [['#f0a50a', '#c20024', '#2044ba', '#810065', '#7eae29'],\n                      ['#6d9824', '#87146e', '#2a9196', '#d39006', '#1e40ac'],\n                      ['#fbbc29', '#ce2e4e', '#7e0062', '#158b90', '#57880e'],\n                      ['#ef5773', '#fcbd2a', '#4f770d', '#1d3eaa', '#9b001f'],\n                      ['#7eae29', '#fdbe2a', '#910019', '#27b4bc', '#d74dbc'],\n                      ['#44dce1', '#0b2592', '#996e05', '#7fb325', '#b821a1']],\n        cats = categories.length;\n    \n    //Create themes from base colors\n    for (; i < l; i++) {\n        themes[names[i]] = (function(color) {\n            return Ext.extend(themes.Base, {\n                constructor: function(config) {\n                    themes.Base.prototype.constructor.call(this, Ext.apply({\n                        baseColor: color\n                    }, config));\n                }\n            });\n        }(palette[i]));\n    }\n    \n    //Create theme from color array\n    for (i = 0; i < cats; i++) {\n        themes['Category' + (i + 1)] = (function(category) {\n            return Ext.extend(themes.Base, {\n                constructor: function(config) {\n                    themes.Base.prototype.constructor.call(this, Ext.apply({\n                        colors: category\n                    }, config));\n                }\n            });\n        }(categories[i]));\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.chart.MaskLayer', {\n    extend: 'Ext.Component',\n    \n    constructor: function(config) {\n        config = Ext.apply(config || {}, {\n            style: 'position:absolute;background-color:#888;cursor:move;opacity:0.6;border:1px solid #222;'\n        });\n        this.callParent([config]);    \n    },\n    \n    initComponent: function() {\n        var me = this;\n        me.callParent(arguments);\n        me.addEvents(\n            'mousedown',\n            'mouseup',\n            'mousemove',\n            'mouseenter',\n            'mouseleave'\n        );\n    },\n\n    initDraggable: function() {\n        this.callParent(arguments);\n        this.dd.onStart = function (e) {\n            var me = this,\n                comp = me.comp;\n    \n            // Cache the start [X, Y] array\n            this.startPosition = comp.getPosition(true);\n    \n            // If client Component has a ghost method to show a lightweight version of itself\n            // then use that as a drag proxy unless configured to liveDrag.\n            if (comp.ghost && !comp.liveDrag) {\n                 me.proxy = comp.ghost();\n                 me.dragTarget = me.proxy.header.el;\n            }\n    \n            // Set the constrainTo Region before we start dragging.\n            if (me.constrain || me.constrainDelegate) {\n                me.constrainTo = me.calculateConstrainRegion();\n            }\n        };\n    }\n});\n\n/**\n * Defines a mask for a chart's series.\n * The 'chart' member must be set prior to rendering.\n *\n * A Mask can be used to select a certain region in a chart.\n * When enabled, the `select` event will be triggered when a\n * region is selected by the mask, allowing the user to perform\n * other tasks like zooming on that region, etc.\n *\n * In order to use the mask one has to set the Chart `mask` option to\n * `true`, `vertical` or `horizontal`. Then a possible configuration for the\n * listener could be:\n *\n *     items: {\n *         xtype: 'chart',\n *         animate: true,\n *         store: store1,\n *         mask: 'horizontal',\n *         listeners: {\n *             select: {\n *                 fn: function(me, selection) {\n *                     me.setZoom(selection);\n *                     me.mask.hide();\n *                 }\n *             }\n *         }\n *     }\n *\n * In this example we zoom the chart to that particular region. You can also get\n * a handle to a mask instance from the chart object. The `chart.mask` element is a\n * `Ext.Panel`.\n * \n */\nExt.define('Ext.chart.Mask', {\n    requires: [\n        'Ext.chart.MaskLayer'\n    ],\n    \n    /**\n     * @cfg {Boolean/String} mask\n     * Enables selecting a region on chart. True to enable any selection,\n     * 'horizontal' or 'vertical' to restrict the selection to X or Y axis.\n     *\n     * The mask in itself will do nothing but fire 'select' event.\n     * See {@link Ext.chart.Mask} for example.\n     */\n\n    /**\n     * Creates new Mask.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        var me = this,\n            resizeHandler;\n\n        me.addEvents('select');\n\n        if (config) {\n            Ext.apply(me, config);\n        }\n        if (me.enableMask) {\n            me.on('afterrender', function() {\n                //create a mask layer component\n                var comp = new Ext.chart.MaskLayer({\n                    renderTo: me.el,\n                    hidden: true\n                });\n                comp.el.on({\n                    'mousemove': function(e) {\n                        me.onMouseMove(e);\n                    },\n                    'mouseup': function(e) {\n                        me.resized(e);\n                    }\n                });\n                //create a resize handler for the component\n                resizeHandler = new Ext.resizer.Resizer({\n                    el: comp.el,\n                    handles: 'all',\n                    pinned: true\n                });\n                resizeHandler.on({\n                    'resize': function(e) {\n                        me.resized(e);    \n                    }    \n                });\n                comp.initDraggable();\n                me.maskType = me.mask;\n                me.mask = comp;\n                me.maskSprite = me.surface.add({\n                    type: 'path',\n                    path: ['M', 0, 0],\n                    zIndex: 1001,\n                    opacity: 0.7,\n                    hidden: true,\n                    stroke: '#444'\n                });\n            }, me, { single: true });\n        }\n    },\n    \n    resized: function(e) {\n        var me = this,\n            bbox = me.bbox || me.chartBBox,\n            x = bbox.x,\n            y = bbox.y,\n            width = bbox.width,\n            height = bbox.height,\n            box = me.mask.getBox(true),\n            max = Math.max,\n            min = Math.min,\n            staticX = box.x - x,\n            staticY = box.y - y;\n        \n        staticX = max(staticX, x);\n        staticY = max(staticY, y);\n        staticX = min(staticX, width);\n        staticY = min(staticY, height);\n        box.x = staticX;\n        box.y = staticY;\n        me.fireEvent('select', me, box);\n    },\n\n    onMouseUp: function(e) {\n        var me = this,\n            bbox = me.bbox || me.chartBBox,\n            sel = me.maskSelection;\n        me.maskMouseDown = false;\n        me.mouseDown = false;\n        if (me.mouseMoved) {\n            me.onMouseMove(e);\n            me.mouseMoved = false;\n            me.fireEvent('select', me, {\n                x: sel.x - bbox.x,\n                y: sel.y - bbox.y,\n                width: sel.width,\n                height: sel.height\n            });\n        }\n    },\n\n    onMouseDown: function(e) {\n        var me = this;\n        me.mouseDown = true;\n        me.mouseMoved = false;\n        me.maskMouseDown = {\n            x: e.getPageX() - me.el.getX(),\n            y: e.getPageY() - me.el.getY()\n        };\n    },\n\n    onMouseMove: function(e) {\n        var me = this,\n            mask = me.maskType,\n            bbox = me.bbox || me.chartBBox,\n            x = bbox.x,\n            y = bbox.y,\n            math = Math,\n            floor = math.floor,\n            abs = math.abs,\n            min = math.min,\n            max = math.max,\n            height = floor(y + bbox.height),\n            width = floor(x + bbox.width),\n            posX = e.getPageX(),\n            posY = e.getPageY(),\n            staticX = posX - me.el.getX(),\n            staticY = posY - me.el.getY(),\n            maskMouseDown = me.maskMouseDown,\n            path;\n        \n        me.mouseMoved = me.mouseDown;\n        staticX = max(staticX, x);\n        staticY = max(staticY, y);\n        staticX = min(staticX, width);\n        staticY = min(staticY, height);\n        if (maskMouseDown && me.mouseDown) {\n            if (mask == 'horizontal') {\n                staticY = y;\n                maskMouseDown.y = height;\n                posY = me.el.getY() + bbox.height + me.insetPadding;\n            }\n            else if (mask == 'vertical') {\n                staticX = x;\n                maskMouseDown.x = width;\n            }\n            width = maskMouseDown.x - staticX;\n            height = maskMouseDown.y - staticY;\n            path = ['M', staticX, staticY, 'l', width, 0, 0, height, -width, 0, 'z'];\n            me.maskSelection = {\n                x: width > 0 ? staticX : staticX + width,\n                y: height > 0 ? staticY : staticY + height,\n                width: abs(width),\n                height: abs(height)\n            };\n            me.mask.updateBox(me.maskSelection);\n            me.mask.show();\n            me.maskSprite.setAttributes({\n                hidden: true    \n            }, true);\n        }\n        else {\n            if (mask == 'horizontal') {\n                path = ['M', staticX, y, 'L', staticX, height];\n            }\n            else if (mask == 'vertical') {\n                path = ['M', x, staticY, 'L', width, staticY];\n            }\n            else {\n                path = ['M', staticX, y, 'L', staticX, height, 'M', x, staticY, 'L', width, staticY];\n            }\n            me.maskSprite.setAttributes({\n                path: path,\n                fill: me.maskMouseDown ? me.maskSprite.stroke : false,\n                'stroke-width': mask === true ? 1 : 3,\n                hidden: false\n            }, true);\n        }\n    },\n\n    onMouseLeave: function(e) {\n        var me = this;\n        me.mouseMoved = false;\n        me.mouseDown = false;\n        me.maskMouseDown = false;\n        me.mask.hide();\n        me.maskSprite.hide(true);\n    }\n});\n    \n\n/**\n * @class Ext.chart.Navigation\n *\n * Handles panning and zooming capabilities.\n *\n * Used as mixin by Ext.chart.Chart.\n */\nExt.define('Ext.chart.Navigation', {\n\n    constructor: function() {\n        this.originalStore = this.store;\n    },\n\n    /**\n     * Zooms the chart to the specified selection range.\n     * Can be used with a selection mask. For example:\n     *\n     *     items: {\n     *         xtype: 'chart',\n     *         animate: true,\n     *         store: store1,\n     *         mask: 'horizontal',\n     *         listeners: {\n     *             select: {\n     *                 fn: function(me, selection) {\n     *                     me.setZoom(selection);\n     *                     me.mask.hide();\n     *                 }\n     *             }\n     *         }\n     *     }\n     */\n    setZoom: function(zoomConfig) {\n        var me = this,\n            axes = me.axes,\n            axesItems = axes.items,\n            i, ln, axis,\n            bbox = me.chartBBox,\n            xScale = 1 / bbox.width,\n            yScale = 1 / bbox.height,\n            zoomer = {\n                x : zoomConfig.x * xScale,\n                y : zoomConfig.y * yScale,\n                width : zoomConfig.width * xScale,\n                height : zoomConfig.height * yScale\n            },\n            ends, from, to;\n        for (i = 0, ln = axesItems.length; i < ln; i++) {\n            axis = axesItems[i];\n            ends = axis.calcEnds();\n            if (axis.position == 'bottom' || axis.position == 'top') {\n                from = (ends.to - ends.from) * zoomer.x + ends.from;\n                to = (ends.to - ends.from) * zoomer.width + from;\n                axis.minimum = from;\n                axis.maximum = to;\n            } else {\n                to = (ends.to - ends.from) * (1 - zoomer.y) + ends.from;\n                from = to - (ends.to - ends.from) * zoomer.height;\n                axis.minimum = from;\n                axis.maximum = to;\n            }\n        }\n        me.redraw(false);\n    },\n\n    /**\n     * Restores the zoom to the original value. This can be used to reset\n     * the previous zoom state set by `setZoom`. For example:\n     *\n     *     myChart.restoreZoom();\n     */\n    restoreZoom: function() {\n        if (this.originalStore) {\n            this.store = this.substore = this.originalStore;\n            this.redraw(true);\n        }\n    }\n\n});\n\n/**\n * Charts provide a flexible way to achieve a wide range of data visualization capablitities.\n * Each Chart gets its data directly from a {@link Ext.data.Store Store}, and automatically\n * updates its display whenever data in the Store changes. In addition, the look and feel\n * of a Chart can be customized using {@link Ext.chart.theme.Theme Theme}s.\n * \n * ## Creating a Simple Chart\n * \n * Every Chart has three key parts - a {@link Ext.data.Store Store} that contains the data,\n * an array of {@link Ext.chart.axis.Axis Axes} which define the boundaries of the Chart,\n * and one or more {@link Ext.chart.series.Series Series} to handle the visual rendering of the data points.\n * \n * ### 1. Creating a Store\n * \n * The first step is to create a {@link Ext.data.Model Model} that represents the type of\n * data that will be displayed in the Chart. For example the data for a chart that displays\n * a weather forecast could be represented as a series of \"WeatherPoint\" data points with\n * two fields - \"temperature\", and \"date\":\n * \n *     Ext.define('WeatherPoint', {\n *         extend: 'Ext.data.Model',\n *         fields: ['temperature', 'date']\n *     });\n * \n * Next a {@link Ext.data.Store Store} must be created.  The store contains a collection of \"WeatherPoint\" Model instances.\n * The data could be loaded dynamically, but for sake of ease this example uses inline data:\n * \n *     var store = Ext.create('Ext.data.Store', {\n *         model: 'WeatherPoint',\n *         data: [\n *             { temperature: 58, date: new Date(2011, 1, 1, 8) },\n *             { temperature: 63, date: new Date(2011, 1, 1, 9) },\n *             { temperature: 73, date: new Date(2011, 1, 1, 10) },\n *             { temperature: 78, date: new Date(2011, 1, 1, 11) },\n *             { temperature: 81, date: new Date(2011, 1, 1, 12) }\n *         ]\n *     });\n *    \n * For additional information on Models and Stores please refer to the [Data Guide](#/guide/data).\n * \n * ### 2. Creating the Chart object\n * \n * Now that a Store has been created it can be used in a Chart:\n * \n *     Ext.create('Ext.chart.Chart', {\n *        renderTo: Ext.getBody(),\n *        width: 400,\n *        height: 300,\n *        store: store\n *     });\n *    \n * That's all it takes to create a Chart instance that is backed by a Store.\n * However, if the above code is run in a browser, a blank screen will be displayed.\n * This is because the two pieces that are responsible for the visual display,\n * the Chart's {@link #cfg-axes axes} and {@link #cfg-series series}, have not yet been defined.\n * \n * ### 3. Configuring the Axes\n * \n * {@link Ext.chart.axis.Axis Axes} are the lines that define the boundaries of the data points that a Chart can display.\n * This example uses one of the most common Axes configurations - a horizontal \"x\" axis, and a vertical \"y\" axis:\n * \n *     Ext.create('Ext.chart.Chart', {\n *         ...\n *         axes: [\n *             {\n *                 title: 'Temperature',\n *                 type: 'Numeric',\n *                 position: 'left',\n *                 fields: ['temperature'],\n *                 minimum: 0,\n *                 maximum: 100\n *             },\n *             {\n *                 title: 'Time',\n *                 type: 'Time',\n *                 position: 'bottom',\n *                 fields: ['date'],\n *                 dateFormat: 'ga'\n *             }\n *         ]\n *     });\n *    \n * The \"Temperature\" axis is a vertical {@link Ext.chart.axis.Numeric Numeric Axis} and is positioned on the left edge of the Chart.\n * It represents the bounds of the data contained in the \"WeatherPoint\" Model's \"temperature\" field that was\n * defined above. The minimum value for this axis is \"0\", and the maximum is \"100\".\n * \n * The horizontal axis is a {@link Ext.chart.axis.Time Time Axis} and is positioned on the bottom edge of the Chart.\n * It represents the bounds of the data contained in the \"WeatherPoint\" Model's \"date\" field.\n * The {@link Ext.chart.axis.Time#cfg-dateFormat dateFormat}\n * configuration tells the Time Axis how to format it's labels.\n * \n * Here's what the Chart looks like now that it has its Axes configured:\n * \n * {@img Ext.chart.Chart/Ext.chart.Chart1.png Chart Axes}\n * \n * ### 4. Configuring the Series\n * \n * The final step in creating a simple Chart is to configure one or more {@link Ext.chart.series.Series Series}.\n * Series are responsible for the visual representation of the data points contained in the Store.\n * This example only has one Series:\n * \n *     Ext.create('Ext.chart.Chart', {\n *         ...\n *         axes: [\n *             ...\n *         ],\n *         series: [\n *             {\n *                 type: 'line',\n *                 xField: 'date',\n *                 yField: 'temperature'\n *             }\n *         ]\n *     });\n *     \n * This Series is a {@link Ext.chart.series.Line Line Series}, and it uses the \"date\" and \"temperature\" fields\n * from the \"WeatherPoint\" Models in the Store to plot its data points:\n * \n * {@img Ext.chart.Chart/Ext.chart.Chart2.png Line Series}\n * \n * See the [Line Charts Example](#!/example/charts/Charts.html) for a live demo.\n * \n * ## Themes\n * \n * The color scheme for a Chart can be easily changed using the {@link #cfg-theme theme} configuration option:\n * \n *     Ext.create('Ext.chart.Chart', {\n *         ...\n *         theme: 'Green',\n *         ...\n *     });\n * \n * {@img Ext.chart.Chart/Ext.chart.Chart3.png Green Theme}\n * \n * For more information on Charts please refer to the [Drawing and Charting Guide](#/guide/drawing_and_charting).\n * \n */\nExt.define('Ext.chart.Chart', {\n\n    /* Begin Definitions */\n\n    alias: 'widget.chart',\n\n    extend: 'Ext.draw.Component',\n    \n    mixins: {\n        themeManager: 'Ext.chart.theme.Theme',\n        mask: 'Ext.chart.Mask',\n        navigation: 'Ext.chart.Navigation',\n        bindable: 'Ext.util.Bindable',\n        observable: 'Ext.util.Observable'\n    },\n\n    uses: [\n        'Ext.chart.series.Series'\n    ],\n    \n    requires: [\n        'Ext.util.MixedCollection',\n        'Ext.data.StoreManager',\n        'Ext.chart.Legend',\n        'Ext.chart.theme.Base',\n        'Ext.chart.theme.Theme',\n        'Ext.util.DelayedTask'\n    ],\n\n    /* End Definitions */\n\n    // @private\n    viewBox: false,\n\n    /**\n     * @cfg {String} theme\n     * The name of the theme to be used. A theme defines the colors and other visual displays of tick marks\n     * on axis, text, title text, line colors, marker colors and styles, etc. Possible theme values are 'Base', 'Green',\n     * 'Sky', 'Red', 'Purple', 'Blue', 'Yellow' and also six category themes 'Category1' to 'Category6'. Default value\n     * is 'Base'.\n     */\n\n    /**\n     * @cfg {Boolean/Object} animate\n     * True for the default animation (easing: 'ease' and duration: 500) or a standard animation config\n     * object to be used for default chart animations. Defaults to false.\n     */\n    animate: false,\n\n    /**\n     * @cfg {Boolean/Object} legend\n     * True for the default legend display or a legend config object. Defaults to false.\n     */\n    legend: false,\n\n    /**\n     * @cfg {Number} insetPadding\n     * The amount of inset padding in pixels for the chart. Defaults to 10.\n     */\n    insetPadding: 10,\n\n    /**\n     * @cfg {String[]} enginePriority\n     * Defines the priority order for which Surface implementation to use. The first one supported by the current\n     * environment will be used. Defaults to `['Svg', 'Vml']`.\n     */\n    enginePriority: ['Svg', 'Vml'],\n\n    /**\n     * @cfg {Object/Boolean} background\n     * The chart background. This can be a gradient object, image, or color. Defaults to false for no\n     * background. For example, if `background` were to be a color we could set the object as\n     *\n     *     background: {\n     *         //color string\n     *         fill: '#ccc'\n     *     }\n     *\n     * You can specify an image by using:\n     *\n     *     background: {\n     *         image: 'http://path.to.image/'\n     *     }\n     *\n     * Also you can specify a gradient by using the gradient object syntax:\n     *\n     *     background: {\n     *         gradient: {\n     *             id: 'gradientId',\n     *             angle: 45,\n     *             stops: {\n     *                 0: {\n     *                     color: '#555'\n     *                 }\n     *                 100: {\n     *                     color: '#ddd'\n     *                 }\n     *             }\n     *         }\n     *     }\n     */\n    background: false,\n\n    /**\n     * @cfg {Object[]} gradients\n     * Define a set of gradients that can be used as `fill` property in sprites. The gradients array is an\n     * array of objects with the following properties:\n     *\n     * - **id** - string - The unique name of the gradient.\n     * - **angle** - number, optional - The angle of the gradient in degrees.\n     * - **stops** - object - An object with numbers as keys (from 0 to 100) and style objects as values\n     *\n     * For example:\n     *\n     *     gradients: [{\n     *         id: 'gradientId',\n     *         angle: 45,\n     *         stops: {\n     *             0: {\n     *                 color: '#555'\n     *             },\n     *             100: {\n     *                 color: '#ddd'\n     *             }\n     *         }\n     *     }, {\n     *         id: 'gradientId2',\n     *         angle: 0,\n     *         stops: {\n     *             0: {\n     *                 color: '#590'\n     *             },\n     *             20: {\n     *                 color: '#599'\n     *             },\n     *             100: {\n     *                 color: '#ddd'\n     *             }\n     *         }\n     *     }]\n     *\n     * Then the sprites can use `gradientId` and `gradientId2` by setting the fill attributes to those ids, for example:\n     *\n     *     sprite.setAttributes({\n     *         fill: 'url(#gradientId)'\n     *     }, true);\n     */\n\n    /**\n     * @cfg {Ext.data.Store} store\n     * The store that supplies data to this chart.\n     */\n\n    /**\n     * @cfg {Ext.chart.series.Series[]} series\n     * Array of {@link Ext.chart.series.Series Series} instances or config objects.  For example:\n     * \n     *     series: [{\n     *         type: 'column',\n     *         axis: 'left',\n     *         listeners: {\n     *             'afterrender': function() {\n     *                 console('afterrender');\n     *             }\n     *         },\n     *         xField: 'category',\n     *         yField: 'data1'\n     *     }]\n     */\n\n    /**\n     * @cfg {Ext.chart.axis.Axis[]} axes\n     * Array of {@link Ext.chart.axis.Axis Axis} instances or config objects.  For example:\n     * \n     *     axes: [{\n     *         type: 'Numeric',\n     *         position: 'left',\n     *         fields: ['data1'],\n     *         title: 'Number of Hits',\n     *         minimum: 0,\n     *         //one minor tick between two major ticks\n     *         minorTickSteps: 1\n     *     }, {\n     *         type: 'Category',\n     *         position: 'bottom',\n     *         fields: ['name'],\n     *         title: 'Month of the Year'\n     *     }]\n     */\n\n    constructor: function(config) {\n        var me = this,\n            defaultAnim;\n\n        config = Ext.apply({}, config);\n        me.initTheme(config.theme || me.theme);\n        if (me.gradients) {\n            Ext.apply(config, { gradients: me.gradients });\n        }\n        if (me.background) {\n            Ext.apply(config, { background: me.background });\n        }\n        if (config.animate) {\n            defaultAnim = {\n                easing: 'ease',\n                duration: 500\n            };\n            if (Ext.isObject(config.animate)) {\n                config.animate = Ext.applyIf(config.animate, defaultAnim);\n            }\n            else {\n                config.animate = defaultAnim;\n            }\n        }\n\n        me.mixins.observable.constructor.call(me, config);\n        if (config.enableMask) {\n            me.mixins.mask.constructor.call(me);\n        }\n        me.mixins.navigation.constructor.call(me);\n        me.callParent([config]);\n    },\n    \n    getChartStore: function(){\n        return this.substore || this.store;\n    },\n\n    initComponent: function() {\n        var me = this,\n            axes,\n            series;\n        me.callParent();\n        me.addEvents(\n            'itemmousedown',\n            'itemmouseup',\n            'itemmouseover',\n            'itemmouseout',\n            'itemclick',\n            'itemdblclick',\n            'itemdragstart',\n            'itemdrag',\n            'itemdragend',\n            /**\n             * @event beforerefresh\n             * Fires before a refresh to the chart data is called. If the beforerefresh handler returns false the\n             * {@link #event-refresh} action will be cancelled.\n             * @param {Ext.chart.Chart} this\n             */\n            'beforerefresh',\n            /**\n             * @event refresh\n             * Fires after the chart data has been refreshed.\n             * @param {Ext.chart.Chart} this\n             */\n            'refresh'\n        );\n        Ext.applyIf(me, {\n            zoom: {\n                width: 1,\n                height: 1,\n                x: 0,\n                y: 0\n            }\n        });\n        me.maxGutter = [0, 0];\n        me.store = Ext.data.StoreManager.lookup(me.store);\n        axes = me.axes;\n        me.axes = new Ext.util.MixedCollection(false, function(a) { return a.position; });\n        if (axes) {\n            me.axes.addAll(axes);\n        }\n        series = me.series;\n        me.series = new Ext.util.MixedCollection(false, function(a) { return a.seriesId || (a.seriesId = Ext.id(null, 'ext-chart-series-')); });\n        if (series) {\n            me.series.addAll(series);\n        }\n        if (me.legend !== false) {\n            me.legend = new Ext.chart.Legend(Ext.applyIf({chart:me}, me.legend));\n        }\n\n        me.on({\n            mousemove: me.onMouseMove,\n            mouseleave: me.onMouseLeave,\n            mousedown: me.onMouseDown,\n            mouseup: me.onMouseUp,\n            click: me.onClick,\n            dblclick: me.onDblClick,\n            scope: me\n        });\n    },\n\n    // @private overrides the component method to set the correct dimensions to the chart.\n    afterComponentLayout: function(width, height) {\n        var me = this;\n        if (Ext.isNumber(width) && Ext.isNumber(height)) {\n            if (width !== me.curWidth || height !== me.curHeight) {\n                me.curWidth = width;\n                me.curHeight = height;\n                me.redraw(true);\n            } else if (me.needsRedraw) {\n                delete me.needsRedraw;\n                me.redraw();\n            }\n        }\n        this.callParent(arguments);\n    },\n\n    /**\n     * Redraws the chart. If animations are set this will animate the chart too. \n     * @param {Boolean} resize (optional) flag which changes the default origin points of the chart for animations.\n     */\n    redraw: function(resize) {\n        var me = this,\n            seriesItems = me.series.items,\n            seriesLen = seriesItems.length,\n            axesItems = me.axes.items,\n            axesLen = axesItems.length,\n            i,\n            chartBBox = me.chartBBox = {\n                x: 0,\n                y: 0,\n                height: me.curHeight,\n                width: me.curWidth\n            },\n            legend = me.legend;\n        me.surface.setSize(chartBBox.width, chartBBox.height);\n        // Instantiate Series and Axes\n        for (i = 0; i < seriesLen; i++) {\n            me.initializeSeries(seriesItems[i],i);\n        }\n        for (i = 0; i < axesLen; i++) {\n            me.initializeAxis(axesItems[i]);\n        }\n        //process all views (aggregated data etc) on stores\n        //before rendering.\n        for (i = 0; i < axesLen; i++) {\n            axesItems[i].processView();\n        }\n        for (i = 0; i < axesLen; i++) {\n            axesItems[i].drawAxis(true);\n        }\n\n        // Create legend if not already created\n        if (legend !== false && legend.visible) {\n            if (legend.update || !legend.created) {\n              legend.create();\n            }\n        }\n\n        // Place axes properly, including influence from each other\n        me.alignAxes();\n\n        // Reposition legend based on new axis alignment\n        if (legend !== false && legend.visible) {\n            legend.updatePosition();\n        }\n\n        // Find the max gutter\n        me.getMaxGutter();\n\n        // Draw axes and series\n        me.resizing = !!resize;\n\n        for (i = 0; i < axesLen; i++) {\n            axesItems[i].drawAxis();\n        }\n        for (i = 0; i < seriesLen; i++) {\n            me.drawCharts(seriesItems[i]);\n        }\n        me.resizing = false;\n    },\n\n    // @private set the store after rendering the chart.\n    afterRender: function() {\n        var ref,\n            me = this;\n        this.callParent();\n\n        if (me.categoryNames) {\n            me.setCategoryNames(me.categoryNames);\n        }\n\n        if (me.tipRenderer) {\n            ref = me.getFunctionRef(me.tipRenderer);\n            me.setTipRenderer(ref.fn, ref.scope);\n        }\n        me.bindStore(me.store, true);\n        me.refresh();\n\n        if (me.surface.engine === 'Vml') {\n            me.on('added', me.onAddedVml, me);\n            me.mon(Ext.container.Container.hierarchyEventSource, 'added', me.onContainerAddedVml, me);\n        }\n    },\n\n    // When using a vml surface we need to redraw when this chart or one of its ancestors\n    // is moved to a new container after render, because moving the vml chart causes the\n    // vml elements to go haywire, some displaing incorrectly or not displaying at all.\n    // This appears to be caused by the component being moved to the detached body element\n    // before being added to the new container.\n    onAddedVml: function() {\n        this.needsRedraw = true; // redraw after component layout\n    },\n\n    onContainerAddedVml: function(container) {\n        if (this.isDescendantOf(container)) {\n            this.needsRedraw = true; // redraw after component layout\n        }\n    },\n\n    // @private get x and y position of the mouse cursor.\n    getEventXY: function(e) {\n        var me = this,\n            box = this.surface.getRegion(),\n            pageXY = e.getXY(),\n            x = pageXY[0] - box.left,\n            y = pageXY[1] - box.top;\n        return [x, y];\n    },\n    \n    onClick: function(e) {\n        this.handleClick('itemclick', e);\n    },\n    \n    onDblClick: function(e) {\n        this.handleClick('itemdblclick', e);\n    },\n\n    // @private wrap the mouse down position to delegate the event to the series.\n    handleClick: function(name, e) {\n        var me = this,\n            position = me.getEventXY(e),\n            seriesItems = me.series.items,\n            i, ln, series,\n            item;\n\n        // Ask each series if it has an item corresponding to (not necessarily exactly\n        // on top of) the current mouse coords. Fire itemclick event.\n        for (i = 0, ln = seriesItems.length; i < ln; i++) {\n            series = seriesItems[i];\n            if (Ext.draw.Draw.withinBox(position[0], position[1], series.bbox)) {\n                if (series.getItemForPoint) {\n                    item = series.getItemForPoint(position[0], position[1]);\n                    if (item) {\n                        series.fireEvent(name, item);\n                    }\n                }\n            }\n        }\n    },\n\n    // @private wrap the mouse down position to delegate the event to the series.\n    onMouseDown: function(e) {\n        var me = this,\n            position = me.getEventXY(e),\n            seriesItems = me.series.items,\n            i, ln, series,\n            item;\n\n        if (me.enableMask) {\n            me.mixins.mask.onMouseDown.call(me, e);\n        }\n        // Ask each series if it has an item corresponding to (not necessarily exactly\n        // on top of) the current mouse coords. Fire itemmousedown event.\n        for (i = 0, ln = seriesItems.length; i < ln; i++) {\n            series = seriesItems[i];\n            if (Ext.draw.Draw.withinBox(position[0], position[1], series.bbox)) {\n                if (series.getItemForPoint) {\n                    item = series.getItemForPoint(position[0], position[1]);\n                    if (item) {\n                        series.fireEvent('itemmousedown', item);\n                    }\n                }\n            }\n        }\n    },\n\n    // @private wrap the mouse up event to delegate it to the series.\n    onMouseUp: function(e) {\n        var me = this,\n            position = me.getEventXY(e),\n            seriesItems = me.series.items,\n            i, ln, series,\n            item;\n\n        if (me.enableMask) {\n            me.mixins.mask.onMouseUp.call(me, e);\n        }\n        // Ask each series if it has an item corresponding to (not necessarily exactly\n        // on top of) the current mouse coords. Fire itemmouseup event.\n        for (i = 0, ln = seriesItems.length; i < ln; i++) {\n            series = seriesItems[i];\n            if (Ext.draw.Draw.withinBox(position[0], position[1], series.bbox)) {\n                if (series.getItemForPoint) {\n                    item = series.getItemForPoint(position[0], position[1]);\n                    if (item) {\n                        series.fireEvent('itemmouseup', item);\n                    }\n                }\n            }\n        }\n    },\n\n    // @private wrap the mouse move event so it can be delegated to the series.\n    onMouseMove: function(e) {\n        var me = this,\n            position = me.getEventXY(e),\n            seriesItems = me.series.items,\n            i, ln, series,\n            item, last, storeItem, storeField;\n\n        \n        if (me.enableMask) {\n            me.mixins.mask.onMouseMove.call(me, e);\n        }\n        // Ask each series if it has an item corresponding to (not necessarily exactly\n        // on top of) the current mouse coords. Fire itemmouseover/out events.\n        for (i = 0, ln = seriesItems.length; i < ln; i++) {\n            series = seriesItems[i];\n            if (Ext.draw.Draw.withinBox(position[0], position[1], series.bbox)) {\n                if (series.getItemForPoint) {\n                    item = series.getItemForPoint(position[0], position[1]);\n                    last = series._lastItemForPoint;\n                    storeItem = series._lastStoreItem;\n                    storeField = series._lastStoreField;\n\n\n                    if (item !== last || item && (item.storeItem != storeItem || item.storeField != storeField)) {\n                        if (last) {\n                            series.fireEvent('itemmouseout', last);\n                            delete series._lastItemForPoint;\n                            delete series._lastStoreField;\n                            delete series._lastStoreItem;\n                        }\n                        if (item) {\n                            series.fireEvent('itemmouseover', item);\n                            series._lastItemForPoint = item;\n                            series._lastStoreItem = item.storeItem;\n                            series._lastStoreField = item.storeField;\n                        }\n                    }\n                }\n            } else {\n                last = series._lastItemForPoint;\n                if (last) {\n                    series.fireEvent('itemmouseout', last);\n                    delete series._lastItemForPoint;\n                    delete series._lastStoreField;\n                    delete series._lastStoreItem;\n                }\n            }\n        }\n    },\n\n    // @private handle mouse leave event.\n    onMouseLeave: function(e) {\n        var me = this,\n            seriesItems = me.series.items,\n            i, ln, series;\n\n        if (me.enableMask) {\n            me.mixins.mask.onMouseLeave.call(me, e);\n        }\n        for (i = 0, ln = seriesItems.length; i < ln; i++) {\n            series = seriesItems[i];\n            delete series._lastItemForPoint;\n        }\n    },\n\n    // @private buffered refresh for when we update the store\n    delayRefresh: function() {\n        var me = this;\n        if (!me.refreshTask) {\n            me.refreshTask = new Ext.util.DelayedTask(me.refresh, me);\n        }\n        me.refreshTask.delay(me.refreshBuffer);\n    },\n\n    // @private\n    refresh: function() {\n        var me = this;\n            \n        if (me.rendered && me.curWidth !== undefined && me.curHeight !== undefined) {\n            if (!me.isVisible(true) && !me.refreshPending) {\n                me.setShowListeners('mon');\n                me.refreshPending = true;\n                return;\n            }\n            if (me.fireEvent('beforerefresh', me) !== false) {\n                me.redraw();\n                me.fireEvent('refresh', me);\n            }\n        }\n    },\n    \n    onShow: function(){\n        var me = this;\n        me.callParent(arguments);\n        if (me.refreshPending) {\n            me.delayRefresh();\n            me.setShowListeners('mun');\n        }\n        delete me.refreshPending;\n    },\n    \n    setShowListeners: function(method){\n        var me = this;\n        me[method](Ext.container.Container.hierarchyEventSource, {\n            scope: me,\n            single: true,\n            show: me.forceRefresh,\n            expand: me.forceRefresh\n        });\n    },\n    \n    forceRefresh: function(container) {\n        var me = this;\n        if (me.isDescendantOf(container) && me.refreshPending) {\n            // Add unbind here, because either expand/show could be fired,\n            // so be sure to unbind the listener that didn't\n            me.setShowListeners('mun');\n            me.delayRefresh();\n        }    \n        delete me.refreshPending;\n    },\n\n    bindStore: function(store, initial) {\n        var me = this;\n        me.mixins.bindable.bindStore.apply(me, arguments);\n        if (me.store && !initial) {\n            me.refresh();\n        }\n    },\n    \n    getStoreListeners: function() {\n        var refresh = this.refresh,\n            delayRefresh = this.delayRefresh;\n            \n        return {\n            refresh: refresh,\n            add: delayRefresh,\n            remove: delayRefresh,\n            update: delayRefresh,\n            clear: refresh\n        };\n    },\n\n    // @private Create Axis\n    initializeAxis: function(axis) {\n        var me = this,\n            chartBBox = me.chartBBox,\n            w = chartBBox.width,\n            h = chartBBox.height,\n            x = chartBBox.x,\n            y = chartBBox.y,\n            themeAttrs = me.themeAttrs,\n            config = {\n                chart: me\n            };\n        if (themeAttrs) {\n            config.axisStyle = Ext.apply({}, themeAttrs.axis);\n            config.axisLabelLeftStyle = Ext.apply({}, themeAttrs.axisLabelLeft);\n            config.axisLabelRightStyle = Ext.apply({}, themeAttrs.axisLabelRight);\n            config.axisLabelTopStyle = Ext.apply({}, themeAttrs.axisLabelTop);\n            config.axisLabelBottomStyle = Ext.apply({}, themeAttrs.axisLabelBottom);\n            config.axisTitleLeftStyle = Ext.apply({}, themeAttrs.axisTitleLeft);\n            config.axisTitleRightStyle = Ext.apply({}, themeAttrs.axisTitleRight);\n            config.axisTitleTopStyle = Ext.apply({}, themeAttrs.axisTitleTop);\n            config.axisTitleBottomStyle = Ext.apply({}, themeAttrs.axisTitleBottom);\n        }\n        switch (axis.position) {\n            case 'top':\n                Ext.apply(config, {\n                    length: w,\n                    width: h,\n                    x: x,\n                    y: y\n                });\n            break;\n            case 'bottom':\n                Ext.apply(config, {\n                    length: w,\n                    width: h,\n                    x: x,\n                    y: h\n                });\n            break;\n            case 'left':\n                Ext.apply(config, {\n                    length: h,\n                    width: w,\n                    x: x,\n                    y: h\n                });\n            break;\n            case 'right':\n                Ext.apply(config, {\n                    length: h,\n                    width: w,\n                    x: w,\n                    y: h\n                });\n            break;\n        }\n        if (!axis.chart) {\n            Ext.apply(config, axis);\n            axis = me.axes.replace(Ext.createByAlias('axis.' + axis.type.toLowerCase(), config));\n        }\n        else {\n            Ext.apply(axis, config);\n        }\n    },\n\n\n    /**\n     * @private Adjust the dimensions and positions of each axis and the chart body area after accounting\n     * for the space taken up on each side by the axes and legend.\n     */\n    alignAxes: function() {\n        var me = this,\n            axes = me.axes,\n            axesItems = axes.items,\n            axis,\n            legend = me.legend,\n            edges = ['top', 'right', 'bottom', 'left'],\n            edge,\n            i, ln,\n            chartBBox,\n            insetPadding = me.insetPadding,\n            insets = {\n                top: insetPadding,\n                right: insetPadding,\n                bottom: insetPadding,\n                left: insetPadding\n            },\n            isVertical, bbox, pos;\n\n        function getAxis(edge) {\n            var i = axes.findIndex('position', edge);\n            return (i < 0) ? null : axes.getAt(i);\n        }\n\n        // Find the space needed by axes and legend as a positive inset from each edge\n        for (i = 0, ln = edges.length; i < ln; i++) {\n            edge = edges[i];\n            isVertical = (edge === 'left' || edge === 'right');\n            axis = getAxis(edge);\n\n            // Add legend size if it's on this edge\n            if (legend !== false) {\n                if (legend.position === edge) {\n                    bbox = legend.getBBox();\n                    insets[edge] += (isVertical ? bbox.width : bbox.height) + insets[edge];\n                }\n            }\n\n            // Add axis size if there's one on this edge only if it has been\n            //drawn before.\n            if (axis && axis.bbox) {\n                bbox = axis.bbox;\n                insets[edge] += (isVertical ? bbox.width : bbox.height);\n            }\n        }\n        // Build the chart bbox based on the collected inset values\n        chartBBox = {\n            x: insets.left,\n            y: insets.top,\n            width: me.curWidth - insets.left - insets.right,\n            height: me.curHeight - insets.top - insets.bottom\n        };\n        me.chartBBox = chartBBox;\n\n        // Go back through each axis and set its length and position based on the\n        // corresponding edge of the chartBBox\n        for (i = 0, ln = axesItems.length; i < ln; i++) {\n            axis = axesItems[i];\n            pos = axis.position;\n            isVertical = (pos === 'left' || pos === 'right');\n\n            axis.x = (pos === 'right' ? chartBBox.x + chartBBox.width : chartBBox.x);\n            axis.y = (pos === 'top' ? chartBBox.y : chartBBox.y + chartBBox.height);\n            axis.width = (isVertical ? chartBBox.width : chartBBox.height);\n            axis.length = (isVertical ? chartBBox.height : chartBBox.width);\n        }\n    },\n\n    // @private initialize the series.\n    initializeSeries: function(series, idx) {\n        var me = this,\n            themeAttrs = me.themeAttrs,\n            seriesObj, markerObj, seriesThemes, st,\n            markerThemes, colorArrayStyle = [],\n            i = 0, l,\n            config = {\n                chart: me,\n                seriesId: series.seriesId\n            };\n        if (themeAttrs) {\n            seriesThemes = themeAttrs.seriesThemes;\n            markerThemes = themeAttrs.markerThemes;\n            seriesObj = Ext.apply({}, themeAttrs.series);\n            markerObj = Ext.apply({}, themeAttrs.marker);\n            config.seriesStyle = Ext.apply(seriesObj, seriesThemes[idx % seriesThemes.length]);\n            config.seriesLabelStyle = Ext.apply({}, themeAttrs.seriesLabel);\n            config.markerStyle = Ext.apply(markerObj, markerThemes[idx % markerThemes.length]);\n            if (themeAttrs.colors) {\n                config.colorArrayStyle = themeAttrs.colors;\n            } else {\n                colorArrayStyle = [];\n                for (l = seriesThemes.length; i < l; i++) {\n                    st = seriesThemes[i];\n                    if (st.fill || st.stroke) {\n                        colorArrayStyle.push(st.fill || st.stroke);\n                    }\n                }\n                if (colorArrayStyle.length) {\n                    config.colorArrayStyle = colorArrayStyle;\n                }\n            }\n            config.seriesIdx = idx;\n        }\n        if (series instanceof Ext.chart.series.Series) {\n            Ext.apply(series, config);\n        } else {\n            Ext.applyIf(config, series);\n            series = me.series.replace(Ext.createByAlias('series.' + series.type.toLowerCase(), config));\n        }\n        if (series.initialize) {\n            series.initialize();\n        }\n    },\n\n    // @private\n    getMaxGutter: function() {\n        var me = this,\n            seriesItems = me.series.items,\n            i, ln, series,\n            maxGutter = [0, 0],\n            gutter;\n        for (i = 0, ln = seriesItems.length; i < ln; i++) {\n            series = seriesItems[i];\n            gutter = series.getGutters && series.getGutters() || [0, 0];\n            maxGutter[0] = Math.max(maxGutter[0], gutter[0]);\n            maxGutter[1] = Math.max(maxGutter[1], gutter[1]);\n        }\n        me.maxGutter = maxGutter;\n    },\n\n    // @private draw axis.\n    drawAxis: function(axis) {\n        axis.drawAxis();\n    },\n\n    // @private draw series.\n    drawCharts: function(series) {\n        series.triggerafterrender = false;\n        series.drawSeries();\n        if (!this.animate) {\n            series.fireEvent('afterrender');\n        }\n    },\n    /**\n     * Saves the chart by either triggering a download or returning a string containing the chart data\n     * as SVG.  The action depends on the export type specified in the passed configuration. The chart\n     * will be exported using either the {@link Ext.draw.engine.SvgExporter} or the {@link Ext.draw.engine.ImageExporter}\n     * classes.\n     *\n     * Possible export types:\n     *\n     * - 'image/png'\n     * - 'image/jpeg',\n     * - 'image/svg+xml'\n     *\n     * If 'image/svg+xml' is specified, the SvgExporter will be used. \n     * If 'image/png' or 'image/jpeg' are specified, the ImageExporter will be used. This exporter\n     * must post the SVG data to a remote server to have the data processed, see the {@link Ext.draw.engine.ImageExporter}\n     * for more details.\n     *\n     * Example usage:\n     *\n     *     chart.save({\n     *          type: 'image/png'\n     *     });\n     *\n     * @param {Object} [config] The configuration to be passed to the exporter.\n     * See the export method for the appropriate exporter for the relevant\n     * configuration options\n     * @return {Object} See the return types for the appropriate exporter\n     */\n    save: function(config){\n        return Ext.draw.Surface.save(this.surface, config);\n    },\n    // @private remove gently.\n    destroy: function() {\n        Ext.destroy(this.surface);\n        this.bindStore(null);\n        this.callParent(arguments);\n    }\n});\n\n/**\n * @class Ext.chart.Highlight\n * A mixin providing highlight functionality for Ext.chart.series.Series.\n */\nExt.define('Ext.chart.Highlight', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.fx.Anim'],\n\n    /* End Definitions */\n\n    /**\n     * Highlight the given series item.\n     * @param {Boolean/Object} Default's false. Can also be an object width style properties (i.e fill, stroke, radius) \n     * or just use default styles per series by setting highlight = true.\n     */\n    highlight: false,\n\n    highlightCfg : {\n        fill: '#fdd',\n        \"stroke-width\": 5,\n        stroke: '#f55'\n    },\n\n    constructor: function(config) {\n        if (config.highlight) {\n            if (config.highlight !== true) { //is an object\n                this.highlightCfg = Ext.merge(this.highlightCfg, config.highlight);\n            }\n        }\n    },\n\n    /**\n     * Highlight the given series item.\n     * @param {Object} item Info about the item; same format as returned by #getItemForPoint.\n     */\n    highlightItem: function(item) {\n        if (!item) {\n            return;\n        }\n        \n        var me = this,\n            sprite = item.sprite,\n            opts = Ext.merge({}, me.highlightCfg, me.highlight),\n            surface = me.chart.surface,\n            animate = me.chart.animate,\n            p, from, to, pi;\n\n        if (!me.highlight || !sprite || sprite._highlighted) {\n            return;\n        }\n        if (sprite._anim) {\n            sprite._anim.paused = true;\n        }\n        sprite._highlighted = true;\n        if (!sprite._defaults) {\n            sprite._defaults = Ext.apply({}, sprite.attr);\n            from = {};\n            to = {};\n            for (p in opts) {\n                if (! (p in sprite._defaults)) {\n                    sprite._defaults[p] = surface.availableAttrs[p];\n                }\n                from[p] = sprite._defaults[p];\n                to[p] = opts[p];\n                if (Ext.isObject(opts[p])) {\n                    from[p] = {};\n                    to[p] = {};\n                    Ext.apply(sprite._defaults[p], sprite.attr[p]);\n                    Ext.apply(from[p], sprite._defaults[p]);\n                    for (pi in sprite._defaults[p]) {\n                        if (! (pi in opts[p])) {\n                            to[p][pi] = from[p][pi];\n                        } else {\n                            to[p][pi] = opts[p][pi];\n                        }\n                    }\n                    for (pi in opts[p]) {\n                        if (! (pi in to[p])) {\n                            to[p][pi] = opts[p][pi];\n                        }\n                    }\n                }\n            }\n            sprite._from = from;\n            sprite._to = to;\n            sprite._endStyle = to;\n        }\n        if (animate) {\n            sprite._anim = new Ext.fx.Anim({\n                target: sprite,\n                from: sprite._from,\n                to: sprite._to,\n                duration: 150\n            });\n        } else {\n            sprite.setAttributes(sprite._to, true);\n        }\n    },\n\n    /**\n     * Un-highlight any existing highlights\n     */\n    unHighlightItem: function() {\n        if (!this.highlight || !this.items) {\n            return;\n        }\n\n        var me = this,\n            items = me.items,\n            len = items.length,\n            opts = Ext.merge({}, me.highlightCfg, me.highlight),\n            animate = me.chart.animate,\n            i = 0,\n            obj, p, sprite;\n        for (; i < len; i++) {\n            if (!items[i]) {\n                continue;\n            }\n            sprite = items[i].sprite;\n            if (sprite && sprite._highlighted) {\n                if (sprite._anim) {\n                    sprite._anim.paused = true;\n                }\n                obj = {};\n                for (p in opts) {\n                    if (Ext.isObject(sprite._defaults[p])) {\n                        obj[p] = {};\n                        Ext.apply(obj[p], sprite._defaults[p]);\n                    }\n                    else {\n                        obj[p] = sprite._defaults[p];\n                    }\n                }\n                if (animate) {\n                    //sprite._to = obj;\n                    sprite._endStyle = obj;\n                    sprite._anim = new Ext.fx.Anim({\n                        target: sprite,\n                        to: obj,\n                        duration: 150\n                    });\n                }\n                else {\n                    sprite.setAttributes(obj, true);\n                }\n                delete sprite._highlighted;\n                //delete sprite._defaults;\n            }\n        }\n    },\n\n    cleanHighlights: function() {\n        if (!this.highlight) {\n            return;\n        }\n\n        var group = this.group,\n            markerGroup = this.markerGroup,\n            i = 0,\n            l;\n        for (l = group.getCount(); i < l; i++) {\n            delete group.getAt(i)._defaults;\n        }\n        if (markerGroup) {\n            for (l = markerGroup.getCount(); i < l; i++) {\n                delete markerGroup.getAt(i)._defaults;\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.chart.Label\n *\n * Labels is a mixin to the Series class. Labels methods are implemented\n * in each of the Series (Pie, Bar, etc) for label creation and placement.\n *\n * The methods implemented by the Series are:\n *\n * - **`onCreateLabel(storeItem, item, i, display)`** Called each time a new label is created.\n *   The arguments of the method are:\n *   - *`storeItem`* The element of the store that is related to the label sprite.\n *   - *`item`* The item related to the label sprite. An item is an object containing the position of the shape\n *     used to describe the visualization and also pointing to the actual shape (circle, rectangle, path, etc).\n *   - *`i`* The index of the element created (i.e the first created label, second created label, etc)\n *   - *`display`* The display type. May be <b>false</b> if the label is hidden\n *\n *  - **`onPlaceLabel(label, storeItem, item, i, display, animate)`** Called for updating the position of the label.\n *    The arguments of the method are:\n *    - *`label`* The sprite label.</li>\n *    - *`storeItem`* The element of the store that is related to the label sprite</li>\n *    - *`item`* The item related to the label sprite. An item is an object containing the position of the shape\n *      used to describe the visualization and also pointing to the actual shape (circle, rectangle, path, etc).\n *    - *`i`* The index of the element to be updated (i.e. whether it is the first, second, third from the labelGroup)\n *    - *`display`* The display type. May be <b>false</b> if the label is hidden.\n *    - *`animate`* A boolean value to set or unset animations for the labels.\n */\nExt.define('Ext.chart.Label', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.draw.Color'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Object} label\n     * Object with the following properties:\n     *\n     * - **display** : String\n     *\n     *   Specifies the presence and position of labels for each pie slice. Either \"rotate\", \"middle\", \"insideStart\",\n     *   \"insideEnd\", \"outside\", \"over\", \"under\", or \"none\" to prevent label rendering.\n     *   Default value: 'none'.\n     *\n     * - **color** : String\n     *\n     *   The color of the label text.\n     *   Default value: '#000' (black).\n     *\n     * - **contrast** : Boolean\n     *\n     *   True to render the label in contrasting color with the backround.\n     *   Default value: false.\n     *\n     * - **field** : String\n     *\n     *   The name of the field to be displayed in the label.\n     *   Default value: 'name'.\n     *\n     * - **minMargin** : Number\n     *\n     *   Specifies the minimum distance from a label to the origin of the visualization.\n     *   This parameter is useful when using PieSeries width variable pie slice lengths.\n     *   Default value: 50.\n     *\n     * - **font** : String\n     *\n     *   The font used for the labels.\n     *   Default value: \"11px Helvetica, sans-serif\".\n     *\n     * - **orientation** : String\n     *\n     *   Either \"horizontal\" or \"vertical\".\n     *   Dafault value: \"horizontal\".\n     *\n     * - **renderer** : Function\n     *\n     *   Optional function for formatting the label into a displayable value.\n     *   Default value: function(v) { return v; }\n     */\n\n    // @private a regex to parse url type colors.\n    colorStringRe: /url\\s*\\(\\s*#([^\\/)]+)\\s*\\)/,\n\n    // @private the mixin constructor. Used internally by Series.\n    constructor: function(config) {\n        var me = this;\n        me.label = Ext.applyIf(me.label || {},\n        {\n            display: \"none\",\n            color: \"#000\",\n            field: \"name\",\n            minMargin: 50,\n            font: \"11px Helvetica, sans-serif\",\n            orientation: \"horizontal\",\n            renderer: function(v) {\n                return v;\n            }\n        });\n\n        if (me.label.display !== 'none') {\n            me.labelsGroup = me.chart.surface.getGroup(me.seriesId + '-labels');\n        }\n    },\n\n    // @private a method to render all labels in the labelGroup\n    renderLabels: function() {\n        var me = this,\n            chart = me.chart,\n            gradients = chart.gradients,\n            items = me.items,\n            animate = chart.animate,\n            config = me.label,\n            display = config.display,\n            color = config.color,\n            field = [].concat(config.field),\n            group = me.labelsGroup,\n            groupLength = (group || 0) && group.length,\n            store = me.chart.getChartStore(),\n            len = store.getCount(),\n            itemLength = (items || 0) && items.length,\n            ratio = itemLength / len,\n            gradientsCount = (gradients || 0) && gradients.length,\n            Color = Ext.draw.Color,\n            hides = [],\n            gradient, i, count, groupIndex, index, j, k, colorStopTotal, colorStopIndex, colorStop, item, label,\n            storeItem, sprite, spriteColor, spriteBrightness, labelColor, colorString;\n\n        if (display == 'none') {\n            return;\n        }\n        // no items displayed, hide all labels\n        if(itemLength == 0){\n            while(groupLength--) {\n                hides.push(groupLength);\n            }\n        } else {\n            for (i = 0, count = 0, groupIndex = 0; i < len; i++) {\n                index = 0;\n                for (j = 0; j < ratio; j++) {\n                    item = items[count];\n                    label = group.getAt(groupIndex);\n                    storeItem = store.getAt(i);\n                    //check the excludes\n                    while(this.__excludes && this.__excludes[index]) {\n                        index++;\n                    }\n\n                    if (!item && label) {\n                        label.hide(true);\n                        groupIndex++;\n                    }\n\n                    if (item && field[j]) {\n                        if (!label) {\n                            label = me.onCreateLabel(storeItem, item, i, display, j, index);\n                        }\n                        me.onPlaceLabel(label, storeItem, item, i, display, animate, j, index);\n                        groupIndex++;\n\n                        //set contrast\n                        if (config.contrast && item.sprite) {\n                            sprite = item.sprite;\n                            //set the color string to the color to be set.\n                            if (sprite._endStyle) {\n                                colorString = sprite._endStyle.fill;\n                            }\n                            else if (sprite._to) {\n                                colorString = sprite._to.fill;\n                            }\n                            else {\n                                colorString = sprite.attr.fill;\n                            }\n                            colorString = colorString || sprite.attr.fill;\n\n                            spriteColor = Color.fromString(colorString);\n                            //color wasn't parsed property maybe because it's a gradient id\n                            if (colorString && !spriteColor) {\n                                colorString = colorString.match(me.colorStringRe)[1];\n                                for (k = 0; k < gradientsCount; k++) {\n                                    gradient = gradients[k];\n                                    if (gradient.id == colorString) {\n                                        //avg color stops\n                                        colorStop = 0; colorStopTotal = 0;\n                                        for (colorStopIndex in gradient.stops) {\n                                            colorStop++;\n                                            colorStopTotal += Color.fromString(gradient.stops[colorStopIndex].color).getGrayscale();\n                                        }\n                                        spriteBrightness = (colorStopTotal / colorStop) / 255;\n                                        break;\n                                    }\n                                }\n                            }\n                            else {\n                                spriteBrightness = spriteColor.getGrayscale() / 255;\n                            }\n                            if (label.isOutside) {\n                                spriteBrightness = 1;\n                            }\n                            labelColor = Color.fromString(label.attr.color || label.attr.fill).getHSL();\n                            labelColor[2] = spriteBrightness > 0.5 ? 0.2 : 0.8;\n                            label.setAttributes({\n                                fill: String(Color.fromHSL.apply({}, labelColor))\n                            }, true);\n                        }\n\n                    }\n                    count++;\n                    index++;\n                }\n            }\n            groupLength = group.length;\n        \n            while(groupLength > groupIndex){\n                hides.push(groupIndex);\n                groupIndex++;\n           }\n        }\n        me.hideLabels(hides);\n    },\n\n    hideLabels: function(hides){\n        var labelsGroup = this.labelsGroup,\n            hlen = !!hides && hides.length;\n\n        if (!labelsGroup) {\n            return;\n        }\n\n        if (hlen === false) {\n            hlen = labelsGroup.getCount();\n            while (hlen--) {\n              labelsGroup.getAt(hlen).hide(true);\n            }\n        } else {\n            while(hlen--) {\n                labelsGroup.getAt(hides[hlen]).hide(true);\n            }\n        }\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.chart.TipSurface', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.draw.Component',\n\n    /* End Definitions */\n\n    spriteArray: false,\n    renderFirst: true,\n\n    constructor: function(config) {\n        this.callParent([config]);\n        if (config.sprites) {\n            this.spriteArray = [].concat(config.sprites);\n            delete config.sprites;\n        }\n    },\n\n    onRender: function() {\n        var me = this,\n            i = 0,\n            l = 0,\n            sp,\n            sprites;\n            this.callParent(arguments);\n        sprites = me.spriteArray;\n        if (me.renderFirst && sprites) {\n            me.renderFirst = false;\n            for (l = sprites.length; i < l; i++) {\n                sp = me.surface.add(sprites[i]);\n                sp.setAttributes({\n                    hidden: false\n                },\n                true);\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.chart.Tip\n * Provides tips for Ext.chart.series.Series.\n */\nExt.define('Ext.chart.Tip', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.tip.ToolTip', 'Ext.chart.TipSurface'],\n\n    /* End Definitions */\n\n    constructor: function(config) {\n        var me = this,\n            surface,\n            sprites,\n            tipSurface;\n        if (config.tips) {\n            me.tipTimeout = null;\n            me.tipConfig = Ext.apply({}, config.tips, {\n                renderer: Ext.emptyFn,\n                constrainPosition: true,\n                autoHide: true\n            });\n            me.tooltip = new Ext.tip.ToolTip(me.tipConfig);\n            me.chart.surface.on('mousemove', me.tooltip.onMouseMove, me.tooltip);\n            me.chart.surface.on('mouseleave', function() {\n                me.hideTip();\n            });\n            if (me.tipConfig.surface) {\n                //initialize a surface\n                surface = me.tipConfig.surface;\n                sprites = surface.sprites;\n                tipSurface = new Ext.chart.TipSurface({\n                    id: 'tipSurfaceComponent',\n                    sprites: sprites\n                });\n                if (surface.width && surface.height) {\n                    tipSurface.setSize(surface.width, surface.height);\n                }\n                me.tooltip.add(tipSurface);\n                me.spriteTip = tipSurface;\n            }\n        }\n    },\n\n    showTip: function(item) {\n        var me = this,\n            tooltip,\n            spriteTip,\n            tipConfig,\n            trackMouse,\n            sprite,\n            surface,\n            surfaceExt,\n            pos,\n            x,\n            y;\n        if (!me.tooltip) {\n            return;\n        }\n        clearTimeout(me.tipTimeout);\n        tooltip = me.tooltip;\n        spriteTip = me.spriteTip;\n        tipConfig = me.tipConfig;\n        trackMouse = tooltip.trackMouse;\n        if (!trackMouse) {\n            tooltip.trackMouse = true;\n            sprite = item.sprite;\n            surface = sprite.surface;\n            surfaceExt = Ext.get(surface.getId());\n            if (surfaceExt) {\n                pos = surfaceExt.getXY();\n                x = pos[0] + (sprite.attr.x || 0) + (sprite.attr.translation && sprite.attr.translation.x || 0);\n                y = pos[1] + (sprite.attr.y || 0) + (sprite.attr.translation && sprite.attr.translation.y || 0);\n                tooltip.targetXY = [x, y];\n            }\n        }\n        if (spriteTip) {\n            tipConfig.renderer.call(tooltip, item.storeItem, item, spriteTip.surface);\n        } else {\n            tipConfig.renderer.call(tooltip, item.storeItem, item);\n        }\n        tooltip.show();\n        tooltip.trackMouse = trackMouse;\n    },\n\n    hideTip: function(item) {\n        var tooltip = this.tooltip;\n        if (!tooltip) {\n            return;\n        }\n        clearTimeout(this.tipTimeout);\n        this.tipTimeout = setTimeout(function() {\n            tooltip.hide();\n        }, 0);\n    }\n});\n\n/**\n * @class Ext.chart.axis.Abstract\n * Base class for all axis classes.\n * @private\n */\nExt.define('Ext.chart.axis.Abstract', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.chart.Chart'],\n\n    /* End Definitions */\n    \n    /**\n     * @cfg {Ext.chart.Label} label\n     * The config for chart label.\n     */\n\n    /**\n     * @cfg {String[]} fields\n     * The fields of model to bind to this axis.\n     * \n     * For example if you have a data set of lap times per car, each having the fields:\n     * `'carName'`, `'avgSpeed'`, `'maxSpeed'`. Then you might want to show the data on chart\n     * with `['carName']` on Name axis and `['avgSpeed', 'maxSpeed']` on Speed axis.\n     */\n\n    /**\n     * Creates new Axis.\n     * @param {Object} config (optional) Config options.\n     */\n    constructor: function(config) {\n        config = config || {};\n\n        var me = this,\n            pos = config.position || 'left';\n\n        pos = pos.charAt(0).toUpperCase() + pos.substring(1);\n        //axisLabel(Top|Bottom|Right|Left)Style\n        config.label = Ext.apply(config['axisLabel' + pos + 'Style'] || {}, config.label || {});\n        config.axisTitleStyle = Ext.apply(config['axisTitle' + pos + 'Style'] || {}, config.labelTitle || {});\n        Ext.apply(me, config);\n        me.fields = Ext.Array.from(me.fields);\n        this.callParent();\n        me.labels = [];\n        me.getId();\n        me.labelGroup = me.chart.surface.getGroup(me.axisId + \"-labels\");\n    },\n\n    alignment: null,\n    grid: false,\n    steps: 10,\n    x: 0,\n    y: 0,\n    minValue: 0,\n    maxValue: 0,\n\n    getId: function() {\n        return this.axisId || (this.axisId = Ext.id(null, 'ext-axis-'));\n    },\n\n    /*\n      Called to process a view i.e to make aggregation and filtering over\n      a store creating a substore to be used to render the axis. Since many axes\n      may do different things on the data and we want the final result of all these\n      operations to be rendered we need to call processView on all axes before drawing\n      them.\n    */\n    processView: Ext.emptyFn,\n\n    drawAxis: Ext.emptyFn,\n    addDisplayAndLabels: Ext.emptyFn\n});\n\n/**\n * @class Ext.chart.axis.Axis\n *\n * Defines axis for charts. The axis position, type, style can be configured.\n * The axes are defined in an axes array of configuration objects where the type,\n * field, grid and other configuration options can be set. To know more about how\n * to create a Chart please check the Chart class documentation. Here's an example for the axes part:\n * An example of axis for a series (in this case for an area chart that has multiple layers of yFields) could be:\n *\n *     axes: [{\n *         type: 'Numeric',\n *         position: 'left',\n *         fields: ['data1', 'data2', 'data3'],\n *         title: 'Number of Hits',\n *         grid: {\n *             odd: {\n *                 opacity: 1,\n *                 fill: '#ddd',\n *                 stroke: '#bbb',\n *                 'stroke-width': 1\n *             }\n *         },\n *         minimum: 0\n *     }, {\n *         type: 'Category',\n *         position: 'bottom',\n *         fields: ['name'],\n *         title: 'Month of the Year',\n *         grid: true,\n *         label: {\n *             rotate: {\n *                 degrees: 315\n *             }\n *         }\n *     }]\n *\n * In this case we use a `Numeric` axis for displaying the values of the Area series and a `Category` axis for displaying the names of\n * the store elements. The numeric axis is placed on the left of the screen, while the category axis is placed at the bottom of the chart.\n * Both the category and numeric axes have `grid` set, which means that horizontal and vertical lines will cover the chart background. In the\n * category axis the labels will be rotated so they can fit the space better.\n */\nExt.define('Ext.chart.axis.Axis', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.axis.Abstract',\n\n    alternateClassName: 'Ext.chart.Axis',\n\n    requires: ['Ext.draw.Draw'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Boolean/Object} grid\n     * The grid configuration enables you to set a background grid for an axis.\n     * If set to *true* on a vertical axis, vertical lines will be drawn.\n     * If set to *true* on a horizontal axis, horizontal lines will be drawn.\n     * If both are set, a proper grid with horizontal and vertical lines will be drawn.\n     *\n     * You can set specific options for the grid configuration for odd and/or even lines/rows.\n     * Since the rows being drawn are rectangle sprites, you can set to an odd or even property\n     * all styles that apply to {@link Ext.draw.Sprite}. For more information on all the style\n     * properties you can set please take a look at {@link Ext.draw.Sprite}. Some useful style properties are `opacity`, `fill`, `stroke`, `stroke-width`, etc.\n     *\n     * The possible values for a grid option are then *true*, *false*, or an object with `{ odd, even }` properties\n     * where each property contains a sprite style descriptor object that is defined in {@link Ext.draw.Sprite}.\n     *\n     * For example:\n     *\n     *     axes: [{\n     *         type: 'Numeric',\n     *         position: 'left',\n     *         fields: ['data1', 'data2', 'data3'],\n     *         title: 'Number of Hits',\n     *         grid: {\n     *             odd: {\n     *                 opacity: 1,\n     *                 fill: '#ddd',\n     *                 stroke: '#bbb',\n     *                 'stroke-width': 1\n     *             }\n     *         }\n     *     }, {\n     *         type: 'Category',\n     *         position: 'bottom',\n     *         fields: ['name'],\n     *         title: 'Month of the Year',\n     *         grid: true\n     *     }]\n     *\n     */\n\n    /**\n     * @cfg {Number} majorTickSteps\n     * If `minimum` and `maximum` are specified it forces the number of major ticks to the specified value.\n     * If a number of major ticks is forced, it wont search for pretty numbers at the ticks.\n     */\n\n    /**\n     * @cfg {Number} minorTickSteps\n     * The number of small ticks between two major ticks. Default is zero.\n     */\n\n    /**\n     * @cfg {String} title\n     * The title for the Axis\n     */\n\n    // @private force min/max values from store\n    forceMinMax: false,\n\n    /**\n     * @cfg {Number} dashSize\n     * The size of the dash marker. Default's 3.\n     */\n    dashSize: 3,\n\n    /**\n     * @cfg {String} position\n     * Where to set the axis. Available options are `left`, `bottom`, `right`, `top`. Default's `bottom`.\n     */\n    position: 'bottom',\n\n    // @private\n    skipFirst: false,\n\n    /**\n     * @cfg {Number} length\n     * Offset axis position. Default's 0.\n     */\n    length: 0,\n\n    /**\n     * @cfg {Number} width\n     * Offset axis width. Default's 0.\n     */\n    width: 0,\n\n    /**\n     * @cfg {Boolean} adjustEnd\n     * Whether to adjust the label at the end of the axis.\n     */\n    adjustEnd: true,\n\n    majorTickSteps: false,\n\n    // @private\n    applyData: Ext.emptyFn,\n\n    getRange: function () {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            data = store.data.items,\n            series = chart.series.items,\n            position = me.position,\n            boundedAxes,\n            seriesClasses = Ext.chart.series,\n            aggregations = [],\n            min = Infinity, max = -Infinity,\n            vertical = me.position === 'left' || me.position === 'right',\n            i, ln, ln2, j, k, dataLength = data.length, aggregates,\n            countedFields = {},\n            allFields = {},\n            excludable = true,\n            fields, fieldMap, record, field, value;\n\n        fields = me.fields;\n        for (j = 0, ln = fields.length; j < ln; j++) {\n            allFields[fields[j]] = true;\n        }\n\n        for (i = 0, ln = series.length; i < ln; i++) {\n            if (series[i].seriesIsHidden) {\n                continue;\n            }\n            if (!series[i].getAxesForXAndYFields) {\n                continue;\n            }\n\n            boundedAxes = series[i].getAxesForXAndYFields();\n            if (boundedAxes.xAxis && boundedAxes.xAxis !== position && boundedAxes.yAxis && boundedAxes.yAxis !== position) {\n                // If the series explicitly exclude current Axis, then exit.\n                continue;\n            }\n\n            if (seriesClasses.Bar && series[i] instanceof seriesClasses.Bar && !series[i].column) {\n                // If this is a horizontal bar series, then flip xField and yField.\n                fields = vertical ? Ext.Array.from(series[i].xField) : Ext.Array.from(series[i].yField);\n            } else {\n                fields = vertical ? Ext.Array.from(series[i].yField) : Ext.Array.from(series[i].xField);\n            }\n\n            if (me.fields.length) {\n                for (j = 0, ln2 = fields.length; j < ln2; j++) {\n                    if (allFields[fields[j]]) {\n                        break;\n                    }\n                }\n                if (j == ln2) {\n                    // Not matching fields, skipping this series.\n                    continue;\n                }\n            }\n\n            if (aggregates = series[i].stacked) {\n                // If this is a bar/column series, then it will be aggregated if it is of the same direction of the axis.\n                if (seriesClasses.Bar && series[i] instanceof seriesClasses.Bar) {\n                    if (series[i].column != vertical) {\n                        aggregates = false;\n                        excludable = false;\n                    }\n                }\n                // Otherwise it is stacked vertically\n                else if (!vertical) {\n                    aggregates = false;\n                    excludable = false;\n                }\n            }\n\n\n            if (aggregates) {\n                fieldMap = {};\n                for (j = 0; j < fields.length; j++) {\n                    if (excludable && series[i].__excludes && series[i].__excludes[j]) {\n                        continue;\n                    }\n                    if (!allFields[fields[j]]) {\n                        Ext.Logger.warn('Field `' + fields[j] + '` is not included in the ' + position + ' axis config.');\n                    }\n                    allFields[fields[j]] = fieldMap[fields[j]] = true;\n                }\n                aggregations.push({\n                    fields: fieldMap,\n                    value: 0\n                });\n            } else {\n\n                if (!fields || fields.length == 0) {\n                    fields = me.fields;\n                }\n                for (j = 0; j < fields.length; j++) {\n                    if (excludable && series[i].__excludes && series[i].__excludes[j]) {\n                        continue;\n                    }\n                    allFields[fields[j]] = countedFields[fields[j]] = true;\n                }\n            }\n        }\n\n        for (i = 0; i < dataLength; i++) {\n            record = data[i];\n            for (k = 0; k < aggregations.length; k++) {\n                aggregations[k].value = 0;\n            }\n            for (field in allFields) {\n                value = record.get(field);\n                if (isNaN(value)) {\n                    continue;\n                }\n                if (value === undefined) {\n                    value = 0;\n                }\n                if (countedFields[field]) {\n                    if (min > value) {\n                        min = value;\n                    }\n                    if (max < value) {\n                        max = value;\n                    }\n                }\n                for (k = 0; k < aggregations.length; k++) {\n                    if (aggregations[k].fields[field]) {\n                        aggregations[k].value += value;\n                        // If any aggregation is actually hit, then the min value should be at most 0.\n                        if (min > 0) {\n                            min = 0;\n                        }\n                        if (max < aggregations[k].value) {\n                            max = aggregations[k].value;\n                        }\n                    }\n                }\n            }\n        }\n\n        if (!isFinite(max)) {\n            max = me.prevMax || 0;\n        }\n        if (!isFinite(min)) {\n            min = me.prevMin || 0;\n        }\n\n        //normalize min max for snapEnds.\n        if (min != max && (max != Math.floor(max))) {\n            max = Math.floor(max) + 1;\n        }\n\n        if (!isNaN(me.minimum)) {\n            min = me.minimum;\n        }\n\n        if (!isNaN(me.maximum)) {\n            max = me.maximum;\n        }\n\n        if (min >= max) {\n            // snapEnds will return NaN if max >= min;\n            max = min + 1;\n        }\n\n        return {min: min, max: max};\n    },\n\n    // @private creates a structure with start, end and step points.\n    calcEnds: function () {\n        var me = this,\n            range = me.getRange(),\n            min = range.min,\n            max = range.max,\n            steps, prettyNumbers, out, changedRange;\n\n        steps = (Ext.isNumber(me.majorTickSteps) ? me.majorTickSteps + 1 : me.steps);\n        prettyNumbers = !(Ext.isNumber(me.maximum) && Ext.isNumber(me.minimum) && Ext.isNumber(me.majorTickSteps) && me.majorTickSteps > 0);\n\n        out = Ext.draw.Draw.snapEnds(min, max, steps, prettyNumbers);\n\n        if (Ext.isNumber(me.maximum)) {\n            out.to = me.maximum;\n            changedRange = true;\n        }\n        if (Ext.isNumber(me.minimum)) {\n            out.from = me.minimum;\n            changedRange = true;\n        }\n        if (me.adjustMaximumByMajorUnit) {\n            out.to = Math.ceil(out.to / out.step) * out.step;\n            changedRange = true;\n        }\n        if (me.adjustMinimumByMajorUnit) {\n            out.from = Math.floor(out.from / out.step) * out.step;\n            changedRange = true;\n        }\n\n        if (changedRange) {\n            out.steps = Math.ceil((out.to - out.from) / out.step);            \n        }\n\n        me.prevMin = (min == max ? 0 : min);\n        me.prevMax = max;\n        return out;\n    },\n\n    /**\n     * Renders the axis into the screen and updates its position.\n     */\n    drawAxis: function (init) {\n        var me = this,\n            i, \n            x = me.x,\n            y = me.y,\n            gutterX = me.chart.maxGutter[0],\n            gutterY = me.chart.maxGutter[1],\n            dashSize = me.dashSize,\n            subDashesX = me.minorTickSteps || 0,\n            subDashesY = me.minorTickSteps || 0,\n            length = me.length,\n            position = me.position,\n            inflections = [],\n            calcLabels = false,\n            stepCalcs = me.applyData(),\n            step = stepCalcs.step,\n            steps = stepCalcs.steps,\n            from = stepCalcs.from,\n            to = stepCalcs.to,\n            trueLength,\n            currentX,\n            currentY,\n            path,\n            dashesX,\n            dashesY,\n            delta;\n\n        //If no steps are specified\n        //then don't draw the axis. This generally happens\n        //when an empty store.\n        if (me.hidden || isNaN(step) || (from > to)) {\n            return;\n        }\n\n        me.from = stepCalcs.from;\n        me.to = stepCalcs.to;\n\n        if (position == 'left' || position == 'right') {\n            currentX = Math.floor(x) + 0.5;\n            path = [\"M\", currentX, y, \"l\", 0, -length];\n            trueLength = length - (gutterY * 2);\n        }\n        else {\n            currentY = Math.floor(y) + 0.5;\n            path = [\"M\", x, currentY, \"l\", length, 0];\n            trueLength = length - (gutterX * 2);\n        }\n\n        // Supports the case that we have only 1 record.\n        delta = steps && trueLength / steps;\n        dashesX = Math.max(subDashesX + 1, 0);\n        dashesY = Math.max(subDashesY + 1, 0);\n        if (me.type == 'Numeric' || me.type == 'Time') {\n            calcLabels = true;\n            me.labels = [stepCalcs.from];\n        }\n\n        if (position == 'right' || position == 'left') {\n            currentY = y - gutterY;\n            currentX = x - ((position == 'left') * dashSize * 2);\n            while (currentY >= y - gutterY - trueLength) {\n                path.push(\"M\", currentX, Math.floor(currentY) + 0.5, \"l\", dashSize * 2 + 1, 0);\n                if (currentY != y - gutterY) {\n                    for (i = 1; i < dashesY; i++) {\n                        path.push(\"M\", currentX + dashSize, Math.floor(currentY + delta * i / dashesY) + 0.5, \"l\", dashSize + 1, 0);\n                    }\n                }\n                inflections.push([ Math.floor(x), Math.floor(currentY) ]);\n                currentY -= delta;\n\n                if (calcLabels) {\n                    me.labels.push(me.labels[me.labels.length - 1] + step);\n                }\n\n                if (delta === 0) {\n                    break;\n                }\n            }\n            if (Math.round(currentY + delta - (y - gutterY - trueLength))) {\n                path.push(\"M\", currentX, Math.floor(y - length + gutterY) + 0.5, \"l\", dashSize * 2 + 1, 0);\n                for (i = 1; i < dashesY; i++) {\n                    path.push(\"M\", currentX + dashSize, Math.floor(y - length + gutterY + delta * i / dashesY) + 0.5, \"l\", dashSize + 1, 0);\n                }\n                inflections.push([ Math.floor(x), Math.floor(currentY) ]);\n                if (calcLabels) {\n                    me.labels.push(me.labels[me.labels.length - 1] + step);\n                }\n            }\n        } else {\n            currentX = x + gutterX;\n            currentY = y - ((position == 'top') * dashSize * 2);\n            while (currentX <= x + gutterX + trueLength) {\n                path.push(\"M\", Math.floor(currentX) + 0.5, currentY, \"l\", 0, dashSize * 2 + 1);\n                if (currentX != x + gutterX) {\n                    for (i = 1; i < dashesX; i++) {\n                        path.push(\"M\", Math.floor(currentX - delta * i / dashesX) + 0.5, currentY, \"l\", 0, dashSize + 1);\n                    }\n                }\n                inflections.push([ Math.floor(currentX), Math.floor(y) ]);\n                currentX += delta;\n                if (calcLabels) {\n                    me.labels.push(me.labels[me.labels.length - 1] + step);\n                }\n                if (delta === 0) {\n                    break;\n                }\n            }\n            if (Math.round(currentX - delta - (x + gutterX + trueLength))) {\n                path.push(\"M\", Math.floor(x + length - gutterX) + 0.5, currentY, \"l\", 0, dashSize * 2 + 1);\n                for (i = 1; i < dashesX; i++) {\n                    path.push(\"M\", Math.floor(x + length - gutterX - delta * i / dashesX) + 0.5, currentY, \"l\", 0, dashSize + 1);\n                }\n                inflections.push([ Math.floor(currentX), Math.floor(y) ]);\n                if (calcLabels) {\n                    me.labels.push(me.labels[me.labels.length - 1] + step);\n                }\n            }\n        }\n\n        // the label on index \"inflections.length-1\" is the last label that gets rendered\n        if (calcLabels) {\n            me.labels[inflections.length - 1] = +(me.labels[inflections.length - 1]).toFixed(10);\n        }\n\n        if (!me.axis) {\n            me.axis = me.chart.surface.add(Ext.apply({\n                type: 'path',\n                path: path\n            }, me.axisStyle));\n        }\n        me.axis.setAttributes({\n            path: path\n        }, true);\n        me.inflections = inflections;\n        if (!init && me.grid) {\n            me.drawGrid();\n        }\n        me.axisBBox = me.axis.getBBox();\n        me.drawLabel();\n    },\n\n    /**\n     * Renders an horizontal and/or vertical grid into the Surface.\n     */\n    drawGrid: function () {\n        var me = this,\n            surface = me.chart.surface,\n            grid = me.grid,\n            odd = grid.odd,\n            even = grid.even,\n            inflections = me.inflections,\n            ln = inflections.length - ((odd || even) ? 0 : 1),\n            position = me.position,\n            gutter = me.chart.maxGutter,\n            width = me.width - 2,\n            point, prevPoint,\n            i = 1,\n            path = [], styles, lineWidth, dlineWidth,\n            oddPath = [], evenPath = [];\n\n        if ((gutter[1] !== 0 && (position == 'left' || position == 'right')) ||\n            (gutter[0] !== 0 && (position == 'top' || position == 'bottom'))) {\n            i = 0;\n            ln++;\n        }\n        for (; i < ln; i++) {\n            point = inflections[i];\n            prevPoint = inflections[i - 1];\n            if (odd || even) {\n                path = (i % 2) ? oddPath : evenPath;\n                styles = ((i % 2) ? odd : even) || {};\n                lineWidth = (styles.lineWidth || styles['stroke-width'] || 0) / 2;\n                dlineWidth = 2 * lineWidth;\n                if (position == 'left') {\n                    path.push(\"M\", prevPoint[0] + 1 + lineWidth, prevPoint[1] + 0.5 - lineWidth,\n                        \"L\", prevPoint[0] + 1 + width - lineWidth, prevPoint[1] + 0.5 - lineWidth,\n                        \"L\", point[0] + 1 + width - lineWidth, point[1] + 0.5 + lineWidth,\n                        \"L\", point[0] + 1 + lineWidth, point[1] + 0.5 + lineWidth, \"Z\");\n                }\n                else if (position == 'right') {\n                    path.push(\"M\", prevPoint[0] - lineWidth, prevPoint[1] + 0.5 - lineWidth,\n                        \"L\", prevPoint[0] - width + lineWidth, prevPoint[1] + 0.5 - lineWidth,\n                        \"L\", point[0] - width + lineWidth, point[1] + 0.5 + lineWidth,\n                        \"L\", point[0] - lineWidth, point[1] + 0.5 + lineWidth, \"Z\");\n                }\n                else if (position == 'top') {\n                    path.push(\"M\", prevPoint[0] + 0.5 + lineWidth, prevPoint[1] + 1 + lineWidth,\n                        \"L\", prevPoint[0] + 0.5 + lineWidth, prevPoint[1] + 1 + width - lineWidth,\n                        \"L\", point[0] + 0.5 - lineWidth, point[1] + 1 + width - lineWidth,\n                        \"L\", point[0] + 0.5 - lineWidth, point[1] + 1 + lineWidth, \"Z\");\n                }\n                else {\n                    path.push(\"M\", prevPoint[0] + 0.5 + lineWidth, prevPoint[1] - lineWidth,\n                        \"L\", prevPoint[0] + 0.5 + lineWidth, prevPoint[1] - width + lineWidth,\n                        \"L\", point[0] + 0.5 - lineWidth, point[1] - width + lineWidth,\n                        \"L\", point[0] + 0.5 - lineWidth, point[1] - lineWidth, \"Z\");\n                }\n            } else {\n                if (position == 'left') {\n                    path = path.concat([\"M\", point[0] + 0.5, point[1] + 0.5, \"l\", width, 0]);\n                }\n                else if (position == 'right') {\n                    path = path.concat([\"M\", point[0] - 0.5, point[1] + 0.5, \"l\", -width, 0]);\n                }\n                else if (position == 'top') {\n                    path = path.concat([\"M\", point[0] + 0.5, point[1] + 0.5, \"l\", 0, width]);\n                }\n                else {\n                    path = path.concat([\"M\", point[0] + 0.5, point[1] - 0.5, \"l\", 0, -width]);\n                }\n            }\n        }\n        if (odd || even) {\n            if (oddPath.length) {\n                if (!me.gridOdd && oddPath.length) {\n                    me.gridOdd = surface.add({\n                        type: 'path',\n                        path: oddPath\n                    });\n                }\n                me.gridOdd.setAttributes(Ext.apply({\n                    path: oddPath,\n                    hidden: false\n                }, odd || {}), true);\n            }\n            if (evenPath.length) {\n                if (!me.gridEven) {\n                    me.gridEven = surface.add({\n                        type: 'path',\n                        path: evenPath\n                    });\n                }\n                me.gridEven.setAttributes(Ext.apply({\n                    path: evenPath,\n                    hidden: false\n                }, even || {}), true);\n            }\n        }\n        else {\n            if (path.length) {\n                if (!me.gridLines) {\n                    me.gridLines = me.chart.surface.add({\n                        type: 'path',\n                        path: path,\n                        \"stroke-width\": me.lineWidth || 1,\n                        stroke: me.gridColor || '#ccc'\n                    });\n                }\n                me.gridLines.setAttributes({\n                    hidden: false,\n                    path: path\n                }, true);\n            }\n            else if (me.gridLines) {\n                me.gridLines.hide(true);\n            }\n        }\n    },\n\n    // @private\n    getOrCreateLabel: function (i, text) {\n        var me = this,\n            labelGroup = me.labelGroup,\n            textLabel = labelGroup.getAt(i),\n            surface = me.chart.surface;\n        if (textLabel) {\n            if (text != textLabel.attr.text) {\n                textLabel.setAttributes(Ext.apply({\n                    text: text\n                }, me.label), true);\n                textLabel._bbox = textLabel.getBBox();\n            }\n        }\n        else {\n            textLabel = surface.add(Ext.apply({\n                group: labelGroup,\n                type: 'text',\n                x: 0,\n                y: 0,\n                text: text\n            }, me.label));\n            surface.renderItem(textLabel);\n            textLabel._bbox = textLabel.getBBox();\n        }\n        //get untransformed bounding box\n        if (me.label.rotation) {\n            textLabel.setAttributes({\n                rotation: {\n                    degrees: 0\n                }\n            }, true);\n            textLabel._ubbox = textLabel.getBBox();\n            textLabel.setAttributes(me.label, true);\n        } else {\n            textLabel._ubbox = textLabel._bbox;\n        }\n        return textLabel;\n    },\n\n    rect2pointArray: function (sprite) {\n        var surface = this.chart.surface,\n            rect = surface.getBBox(sprite, true),\n            p1 = [rect.x, rect.y],\n            p1p = p1.slice(),\n            p2 = [rect.x + rect.width, rect.y],\n            p2p = p2.slice(),\n            p3 = [rect.x + rect.width, rect.y + rect.height],\n            p3p = p3.slice(),\n            p4 = [rect.x, rect.y + rect.height],\n            p4p = p4.slice(),\n            matrix = sprite.matrix;\n        //transform the points\n        p1[0] = matrix.x.apply(matrix, p1p);\n        p1[1] = matrix.y.apply(matrix, p1p);\n\n        p2[0] = matrix.x.apply(matrix, p2p);\n        p2[1] = matrix.y.apply(matrix, p2p);\n\n        p3[0] = matrix.x.apply(matrix, p3p);\n        p3[1] = matrix.y.apply(matrix, p3p);\n\n        p4[0] = matrix.x.apply(matrix, p4p);\n        p4[1] = matrix.y.apply(matrix, p4p);\n        return [p1, p2, p3, p4];\n    },\n\n    intersect: function (l1, l2) {\n        var r1 = this.rect2pointArray(l1),\n            r2 = this.rect2pointArray(l2);\n        return !!Ext.draw.Draw.intersect(r1, r2).length;\n    },\n\n    drawHorizontalLabels: function () {\n        var me = this,\n            labelConf = me.label,\n            floor = Math.floor,\n            max = Math.max,\n            axes = me.chart.axes,\n            insetPadding = me.chart.insetPadding,\n            position = me.position,\n            inflections = me.inflections,\n            ln = inflections.length,\n            labels = me.labels,\n            maxHeight = 0,\n            ratio,\n            bbox, point, prevLabel, prevLabelId,\n            adjustEnd = me.adjustEnd,\n            hasLeft = axes.findIndex('position', 'left') != -1,\n            hasRight = axes.findIndex('position', 'right') != -1,\n            textLabel, text,\n            last, x, y, i, firstLabel;\n\n        last = ln - 1;\n        //get a reference to the first text label dimensions\n        point = inflections[0];\n        firstLabel = me.getOrCreateLabel(0, me.label.renderer(labels[0]));\n        ratio = Math.floor(Math.abs(Math.sin(labelConf.rotate && (labelConf.rotate.degrees * Math.PI / 180) || 0)));\n\n        for (i = 0; i < ln; i++) {\n            point = inflections[i];\n            text = me.label.renderer(labels[i]);\n            textLabel = me.getOrCreateLabel(i, text);\n            bbox = textLabel._bbox;\n            maxHeight = max(maxHeight, bbox.height + me.dashSize + me.label.padding);\n            x = floor(point[0] - (ratio ? bbox.height : bbox.width) / 2);\n            if (adjustEnd && me.chart.maxGutter[0] == 0) {\n                if (i == 0 && !hasLeft) {\n                    x = point[0];\n                }\n                else if (i == last && !hasRight) {\n                    x = Math.min(x, point[0] - bbox.width + insetPadding);\n                }\n            }\n            if (position == 'top') {\n                y = point[1] - (me.dashSize * 2) - me.label.padding - (bbox.height / 2);\n            }\n            else {\n                y = point[1] + (me.dashSize * 2) + me.label.padding + (bbox.height / 2);\n            }\n\n            textLabel.setAttributes({\n                hidden: false,\n                x: x,\n                y: y\n            }, true);\n\n            // Skip label if there isn't available minimum space\n            if (i != 0 && (me.intersect(textLabel, prevLabel)\n                || me.intersect(textLabel, firstLabel))) {\n                if (i === last && prevLabelId !== 0) {\n                    prevLabel.hide(true);\n                } else {\n                    textLabel.hide(true);\n                    continue;\n                }\n            }\n\n            prevLabel = textLabel;\n            prevLabelId = i;\n        }\n\n        return maxHeight;\n    },\n\n    drawVerticalLabels: function () {\n        var me = this,\n            inflections = me.inflections,\n            position = me.position,\n            ln = inflections.length,\n            chart = me.chart,\n            insetPadding = chart.insetPadding,\n            labels = me.labels,\n            maxWidth = 0,\n            max = Math.max,\n            floor = Math.floor,\n            ceil = Math.ceil,\n            axes = me.chart.axes,\n            gutterY = me.chart.maxGutter[1],\n            bbox, point, prevLabel, prevLabelId,\n            hasTop = axes.findIndex('position', 'top') != -1,\n            hasBottom = axes.findIndex('position', 'bottom') != -1,\n            adjustEnd = me.adjustEnd,\n            textLabel, text,\n            last = ln - 1, x, y, i;\n\n        for (i = 0; i < ln; i++) {\n            point = inflections[i];\n            text = me.label.renderer(labels[i]);\n            textLabel = me.getOrCreateLabel(i, text);\n            bbox = textLabel._bbox;\n\n            maxWidth = max(maxWidth, bbox.width + me.dashSize + me.label.padding);\n            y = point[1];\n            if (adjustEnd && gutterY < bbox.height / 2) {\n                if (i == last && !hasTop) {\n                    y = Math.max(y, me.y - me.length + ceil(bbox.height / 2) - insetPadding);\n                }\n                else if (i == 0 && !hasBottom) {\n                    y = me.y + gutterY - floor(bbox.height / 2);\n                }\n            }\n            if (position == 'left') {\n                x = point[0] - bbox.width - me.dashSize - me.label.padding - 2;\n            }\n            else {\n                x = point[0] + me.dashSize + me.label.padding + 2;\n            }\n            textLabel.setAttributes(Ext.apply({\n                hidden: false,\n                x: x,\n                y: y\n            }, me.label), true);\n            // Skip label if there isn't available minimum space\n            if (i != 0 && me.intersect(textLabel, prevLabel)) {\n                if (i === last && prevLabelId !== 0) {\n                    prevLabel.hide(true);\n                } else {\n                    textLabel.hide(true);\n                    continue;\n                }\n            }\n            prevLabel = textLabel;\n            prevLabelId = i;\n        }\n\n        return maxWidth;\n    },\n\n    /**\n     * Renders the labels in the axes.\n     */\n    drawLabel: function () {\n        var me = this,\n            position = me.position,\n            labelGroup = me.labelGroup,\n            inflections = me.inflections,\n            maxWidth = 0,\n            maxHeight = 0,\n            ln, i;\n\n        if (position == 'left' || position == 'right') {\n            maxWidth = me.drawVerticalLabels();\n        } else {\n            maxHeight = me.drawHorizontalLabels();\n        }\n\n        // Hide unused bars\n        ln = labelGroup.getCount();\n        i = inflections.length;\n        for (; i < ln; i++) {\n            labelGroup.getAt(i).hide(true);\n        }\n\n        me.bbox = {};\n        Ext.apply(me.bbox, me.axisBBox);\n        me.bbox.height = maxHeight;\n        me.bbox.width = maxWidth;\n        if (Ext.isString(me.title)) {\n            me.drawTitle(maxWidth, maxHeight);\n        }\n    },\n\n    /**\n     * Updates the {@link #title} of this axis.\n     * @param {String} title\n     */\n    setTitle: function (title) {\n        this.title = title;\n        this.drawLabel();\n    },\n\n    // @private draws the title for the axis.\n    drawTitle: function (maxWidth, maxHeight) {\n        var me = this,\n            position = me.position,\n            surface = me.chart.surface,\n            displaySprite = me.displaySprite,\n            title = me.title,\n            rotate = (position == 'left' || position == 'right'),\n            x = me.x,\n            y = me.y,\n            base, bbox, pad;\n\n        if (displaySprite) {\n            displaySprite.setAttributes({text: title}, true);\n        } else {\n            base = {\n                type: 'text',\n                x: 0,\n                y: 0,\n                text: title\n            };\n            displaySprite = me.displaySprite = surface.add(Ext.apply(base, me.axisTitleStyle, me.labelTitle));\n            surface.renderItem(displaySprite);\n        }\n        bbox = displaySprite.getBBox();\n        pad = me.dashSize + me.label.padding;\n\n        if (rotate) {\n            y -= ((me.length / 2) - (bbox.height / 2));\n            if (position == 'left') {\n                x -= (maxWidth + pad + (bbox.width / 2));\n            }\n            else {\n                x += (maxWidth + pad + bbox.width - (bbox.width / 2));\n            }\n            me.bbox.width += bbox.width + 10;\n        }\n        else {\n            x += (me.length / 2) - (bbox.width * 0.5);\n            if (position == 'top') {\n                y -= (maxHeight + pad + (bbox.height * 0.3));\n            }\n            else {\n                y += (maxHeight + pad + (bbox.height * 0.8));\n            }\n            me.bbox.height += bbox.height + 10;\n        }\n        displaySprite.setAttributes({\n            translate: {\n                x: x,\n                y: y\n            }\n        }, true);\n    }\n});\n\n/**\n * @class Ext.chart.axis.Category\n *\n * A type of axis that displays items in categories. This axis is generally used to\n * display categorical information like names of items, month names, quarters, etc.\n * but no quantitative values. For that other type of information `Number`\n * axis are more suitable.\n *\n * As with other axis you can set the position of the axis and its title. For example:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],\n *         data: [\n *             {'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8, 'data5':13},\n *             {'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10, 'data5':3},\n *             {'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12, 'data5':7},\n *             {'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1, 'data5':23},\n *             {'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33}\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         store: store,\n *         axes: [{\n *             type: 'Numeric',\n *             position: 'left',\n *             fields: ['data1', 'data2', 'data3', 'data4', 'data5'],\n *             title: 'Sample Values',\n *             grid: {\n *                 odd: {\n *                     opacity: 1,\n *                     fill: '#ddd',\n *                     stroke: '#bbb',\n *                     'stroke-width': 1\n *                 }\n *             },\n *             minimum: 0,\n *             adjustMinimumByMajorUnit: 0\n *         }, {\n *             type: 'Category',\n *             position: 'bottom',\n *             fields: ['name'],\n *             title: 'Sample Metrics',\n *             grid: true,\n *             label: {\n *                 rotate: {\n *                     degrees: 315\n *                 }\n *             }\n *         }],\n *         series: [{\n *             type: 'area',\n *             highlight: false,\n *             axis: 'left',\n *             xField: 'name',\n *             yField: ['data1', 'data2', 'data3', 'data4', 'data5'],\n *             style: {\n *                 opacity: 0.93\n *             }\n *         }]\n *     });\n *\n * In this example with set the category axis to the bottom of the surface, bound the axis to\n * the `name` property and set as title _Month of the Year_.\n */\nExt.define('Ext.chart.axis.Category', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.axis.Axis',\n\n    alternateClassName: 'Ext.chart.CategoryAxis',\n\n    alias: 'axis.category',\n\n    /* End Definitions */\n\n    /**\n     * A list of category names to display along this axis.\n     * @property {String} categoryNames\n     */\n    categoryNames: null,\n\n    /**\n     * Indicates whether or not to calculate the number of categories (ticks and\n     * labels) when there is not enough room to display all labels on the axis.\n     * If set to true, the axis will determine the number of categories to plot.\n     * If not, all categories will be plotted.\n     *\n     * @property calculateCategoryCount\n     * @type Boolean\n     */\n    calculateCategoryCount: false,\n\n    // @private creates an array of labels to be used when rendering.\n    setLabels: function() {\n        var store = this.chart.getChartStore(),\n            data = store.data.items,\n            d, dLen, record,\n            fields = this.fields,\n            ln = fields.length,\n            i;\n\n        this.labels = [];\n        for (d = 0, dLen = data.length; d < dLen; d++) {\n            record = data[d];\n            for (i = 0; i < ln; i++) {\n                this.labels.push(record.get(fields[i]));\n            }\n        }\n    },\n\n    // @private calculates labels positions and marker positions for rendering.\n    applyData: function() {\n        this.callParent();\n        this.setLabels();\n        var count = this.chart.getChartStore().getCount();\n        return {\n            from: 0,\n            to: count - 1,\n            power: 1,\n            step: 1,\n            steps: count - 1\n        };\n    }\n});\n\n/**\n * @class Ext.chart.axis.Gauge\n *\n * Gauge Axis is the axis to be used with a Gauge series. The Gauge axis\n * displays numeric data from an interval defined by the `minimum`, `maximum` and\n * `step` configuration properties. The placement of the numeric data can be changed\n * by altering the `margin` option that is set to `10` by default.\n *\n * A possible configuration for this axis would look like:\n *\n *     axes: [{\n *         type: 'gauge',\n *         position: 'gauge',\n *         minimum: 0,\n *         maximum: 100,\n *         steps: 10,\n *         margin: 7\n *     }],\n */\nExt.define('Ext.chart.axis.Gauge', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.axis.Abstract',\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Number} minimum (required)\n     * The minimum value of the interval to be displayed in the axis.\n     */\n\n    /**\n     * @cfg {Number} maximum (required)\n     * The maximum value of the interval to be displayed in the axis.\n     */\n\n    /**\n     * @cfg {Number} steps (required)\n     * The number of steps and tick marks to add to the interval.\n     */\n\n    /**\n     * @cfg {Number} [margin=10]\n     * The offset positioning of the tick marks and labels in pixels.\n     */\n\n    /**\n     * @cfg {String} title\n     * The title for the Axis.\n     */\n\n    position: 'gauge',\n\n    alias: 'axis.gauge',\n\n    drawAxis: function(init) {\n        var chart = this.chart,\n            surface = chart.surface,\n            bbox = chart.chartBBox,\n            centerX = bbox.x + (bbox.width / 2),\n            centerY = bbox.y + bbox.height,\n            margin = this.margin || 10,\n            rho = Math.min(bbox.width, 2 * bbox.height) /2 + margin,\n            sprites = [], sprite,\n            steps = this.steps,\n            i, pi = Math.PI,\n            cos = Math.cos,\n            sin = Math.sin;\n\n        if (this.sprites && !chart.resizing) {\n            this.drawLabel();\n            return;\n        }\n\n        if (this.margin >= 0) {\n            if (!this.sprites) {\n                //draw circles\n                for (i = 0; i <= steps; i++) {\n                    sprite = surface.add({\n                        type: 'path',\n                        path: ['M', centerX + (rho - margin) * cos(i / steps * pi - pi),\n                                    centerY + (rho - margin) * sin(i / steps * pi - pi),\n                                    'L', centerX + rho * cos(i / steps * pi - pi),\n                                    centerY + rho * sin(i / steps * pi - pi), 'Z'],\n                        stroke: '#ccc'\n                    });\n                    sprite.setAttributes({\n                        hidden: false\n                    }, true);\n                    sprites.push(sprite);\n                }\n            } else {\n                sprites = this.sprites;\n                //draw circles\n                for (i = 0; i <= steps; i++) {\n                    sprites[i].setAttributes({\n                        path: ['M', centerX + (rho - margin) * cos(i / steps * pi - pi),\n                                    centerY + (rho - margin) * sin(i / steps * pi - pi),\n                               'L', centerX + rho * cos(i / steps * pi - pi),\n                                    centerY + rho * sin(i / steps * pi - pi), 'Z'],\n                        stroke: '#ccc'\n                    }, true);\n                }\n            }\n        }\n        this.sprites = sprites;\n        this.drawLabel();\n        if (this.title) {\n            this.drawTitle();\n        }\n    },\n\n    drawTitle: function() {\n        var me = this,\n            chart = me.chart,\n            surface = chart.surface,\n            bbox = chart.chartBBox,\n            labelSprite = me.titleSprite,\n            labelBBox;\n\n        if (!labelSprite) {\n            me.titleSprite = labelSprite = surface.add({\n                type: 'text',\n                zIndex: 2\n            });\n        }\n        labelSprite.setAttributes(Ext.apply({\n            text: me.title\n        }, me.label || {}), true);\n        labelBBox = labelSprite.getBBox();\n        labelSprite.setAttributes({\n            x: bbox.x + (bbox.width / 2) - (labelBBox.width / 2),\n            y: bbox.y + bbox.height - (labelBBox.height / 2) - 4\n        }, true);\n    },\n\n    /**\n     * Updates the {@link #title} of this axis.\n     * @param {String} title\n     */\n    setTitle: function(title) {\n        this.title = title;\n        this.drawTitle();\n    },\n\n    drawLabel: function() {\n        var chart = this.chart,\n            surface = chart.surface,\n            bbox = chart.chartBBox,\n            centerX = bbox.x + (bbox.width / 2),\n            centerY = bbox.y + bbox.height,\n            margin = this.margin || 10,\n            rho = Math.min(bbox.width, 2 * bbox.height) /2 + 2 * margin,\n            round = Math.round,\n            labelArray = [], label,\n            maxValue = this.maximum || 0,\n            minValue = this.minimum || 0,\n            steps = this.steps, i = 0,\n            adjY,\n            pi = Math.PI,\n            cos = Math.cos,\n            sin = Math.sin,\n            labelConf = this.label,\n            renderer = labelConf.renderer || function(v) { return v; };\n\n        if (!this.labelArray) {\n            //draw scale\n            for (i = 0; i <= steps; i++) {\n                // TODO Adjust for height of text / 2 instead\n                adjY = (i === 0 || i === steps) ? 7 : 0;\n                label = surface.add({\n                    type: 'text',\n                    text: renderer(round(minValue + i / steps * (maxValue - minValue))),\n                    x: centerX + rho * cos(i / steps * pi - pi),\n                    y: centerY + rho * sin(i / steps * pi - pi) - adjY,\n                    'text-anchor': 'middle',\n                    'stroke-width': 0.2,\n                    zIndex: 10,\n                    stroke: '#333'\n                });\n                label.setAttributes({\n                    hidden: false\n                }, true);\n                labelArray.push(label);\n            }\n        }\n        else {\n            labelArray = this.labelArray;\n            //draw values\n            for (i = 0; i <= steps; i++) {\n                // TODO Adjust for height of text / 2 instead\n                adjY = (i === 0 || i === steps) ? 7 : 0;\n                labelArray[i].setAttributes({\n                    text: renderer(round(minValue + i / steps * (maxValue - minValue))),\n                    x: centerX + rho * cos(i / steps * pi - pi),\n                    y: centerY + rho * sin(i / steps * pi - pi) - adjY\n                }, true);\n            }\n        }\n        this.labelArray = labelArray;\n    }\n});\n\n/**\n * @class Ext.chart.axis.Numeric\n *\n * An axis to handle numeric values. This axis is used for quantitative data as\n * opposed to the category axis. You can set mininum and maximum values to the\n * axis so that the values are bound to that. If no values are set, then the\n * scale will auto-adjust to the values.\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *          fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],\n *          data: [\n *              {'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8, 'data5':13},\n *              {'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10, 'data5':3},\n *              {'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12, 'data5':7},\n *              {'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1, 'data5':23},\n *              {'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33}\n *          ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         store: store,\n *         axes: [{\n *             type: 'Numeric',\n *             grid: true,\n *             position: 'left',\n *             fields: ['data1', 'data2', 'data3', 'data4', 'data5'],\n *             title: 'Sample Values',\n *             grid: {\n *                 odd: {\n *                     opacity: 1,\n *                     fill: '#ddd',\n *                     stroke: '#bbb',\n *                     'stroke-width': 1\n *                 }\n *             },\n *             minimum: 0,\n *             adjustMinimumByMajorUnit: 0\n *         }, {\n *             type: 'Category',\n *             position: 'bottom',\n *             fields: ['name'],\n *             title: 'Sample Metrics',\n *             grid: true,\n *             label: {\n *                 rotate: {\n *                     degrees: 315\n *                 }\n *             }\n *         }],\n *         series: [{\n *             type: 'area',\n *             highlight: false,\n *             axis: 'left',\n *             xField: 'name',\n *             yField: ['data1', 'data2', 'data3', 'data4', 'data5'],\n *             style: {\n *                 opacity: 0.93\n *             }\n *         }]\n *     });\n *\n * In this example we create an axis of Numeric type. We set a minimum value so that\n * even if all series have values greater than zero, the grid starts at zero. We bind\n * the axis onto the left part of the surface by setting `position` to `left`.\n * We bind three different store fields to this axis by setting `fields` to an array.\n * We set the title of the axis to _Number of Hits_ by using the `title` property.\n * We use a `grid` configuration to set odd background rows to a certain style and even rows\n * to be transparent/ignored.\n */\nExt.define('Ext.chart.axis.Numeric', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.axis.Axis',\n\n    alternateClassName: 'Ext.chart.NumericAxis',\n\n    /* End Definitions */\n\n    type: 'numeric',\n\n    alias: 'axis.numeric',\n\n    uses: ['Ext.data.Store'],\n\n    constructor: function(config) {\n        var me = this,\n            hasLabel = !!(config.label && config.label.renderer),\n            label;\n\n        me.callParent([config]);\n        label = me.label;\n\n        if (config.constrain == null) {\n            me.constrain = (config.minimum != null && config.maximum != null);\n        }\n\n        if (!hasLabel) {\n            label.renderer = function(v) {\n                return me.roundToDecimal(v, me.decimals);\n            };\n        }\n    },\n\n    roundToDecimal: function(v, dec) {\n        var val = Math.pow(10, dec || 0);\n        return Math.round(v * val) / val;\n    },\n\n    /**\n     * The minimum value drawn by the axis. If not set explicitly, the axis\n     * minimum will be calculated automatically.\n     *\n     * @property {Number} minimum\n     */\n    minimum: NaN,\n\n    /**\n     * The maximum value drawn by the axis. If not set explicitly, the axis\n     * maximum will be calculated automatically.\n     *\n     * @property {Number} maximum\n     */\n    maximum: NaN,\n\n    /**\n     * @cfg {Boolean} constrain\n     * If true, the values of the chart will be rendered only if they belong between minimum and maximum\n     * If false, all values of the chart will be rendered, regardless of whether they belong between minimum and maximum or not\n     * Default's true if maximum and minimum is specified.\n     */\n    constrain: true,\n\n    /**\n     * The number of decimals to round the value to.\n     *\n     * @property {Number} decimals\n     */\n    decimals: 2,\n\n    /**\n     * The scaling algorithm to use on this axis. May be \"linear\" or\n     * \"logarithmic\".  Currently only linear scale is implemented.\n     *\n     * @property {String} scale\n     * @private\n     */\n    scale: \"linear\",\n\n    // @private constrains to datapoints between minimum and maximum only\n    doConstrain: function() {\n        var me = this,\n            store = me.chart.store,\n            items = store.data.items,\n            d, dLen, record,\n            series = me.chart.series.items,\n            fields = me.fields,\n            ln = fields.length,\n            range = me.calcEnds(),\n            min = range.from, max = range.to, i, l,\n            useAcum = false,\n            value, data = [],\n            addRecord;\n\n        for (i = 0, l = series.length; i < l; i++) {\n            if (series[i].type === 'bar' && series[i].stacked) {\n                // Do not constrain stacked bar chart.\n                return;\n            }\n        }\n\n        for (d = 0, dLen = items.length; d < dLen; d++) {\n            addRecord = true;\n            record = items[d];\n            for (i = 0; i < ln; i++) {\n                value = record.get(fields[i]);\n                if (+value < +min) {\n                    addRecord = false;\n                    break;\n                }\n                if (+value > +max) {\n                    addRecord = false;\n                    break;\n                }\n            }\n            if (addRecord) {\n                data.push(record);\n            }\n        }\n        me.chart.substore = Ext.create('Ext.data.Store', { model: store.model });\n        me.chart.substore.loadData(data); // data records must be loaded (not passed as config above because it's not json)\n    },\n    /**\n     * Indicates the position of the axis relative to the chart\n     *\n     * @property {String} position\n     */\n    position: 'left',\n\n    /**\n     * Indicates whether to extend maximum beyond data's maximum to the nearest\n     * majorUnit.\n     *\n     * @property {Boolean} adjustMaximumByMajorUnit\n     */\n    adjustMaximumByMajorUnit: false,\n\n    /**\n     * Indicates whether to extend the minimum beyond data's minimum to the\n     * nearest majorUnit.\n     *\n     * @property {Boolean} adjustMinimumByMajorUnit\n     */\n    adjustMinimumByMajorUnit: false,\n\n    // applying constraint\n    processView: function() {\n        var me = this,\n            constrain = me.constrain;\n        if (constrain) {\n            me.doConstrain();\n        }\n    },\n\n    // @private apply data.\n    applyData: function() {\n        this.callParent();\n        return this.calcEnds();\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.chart.axis.Radial', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.axis.Abstract',\n\n    /* End Definitions */\n\n    position: 'radial',\n\n    alias: 'axis.radial',\n\n    drawAxis: function(init) {\n        var chart = this.chart,\n            surface = chart.surface,\n            bbox = chart.chartBBox,\n            store = chart.store,\n            l = store.getCount(),\n            centerX = bbox.x + (bbox.width / 2),\n            centerY = bbox.y + (bbox.height / 2),\n            rho = Math.min(bbox.width, bbox.height) /2,\n            sprites = [], sprite,\n            steps = this.steps,\n            i, j, pi2 = Math.PI * 2,\n            cos = Math.cos, sin = Math.sin;\n\n        if (this.sprites && !chart.resizing) {\n            this.drawLabel();\n            return;\n        }\n\n        if (!this.sprites) {\n            //draw circles\n            for (i = 1; i <= steps; i++) {\n                sprite = surface.add({\n                    type: 'circle',\n                    x: centerX,\n                    y: centerY,\n                    radius: Math.max(rho * i / steps, 0),\n                    stroke: '#ccc'\n                });\n                sprite.setAttributes({\n                    hidden: false\n                }, true);\n                sprites.push(sprite);\n            }\n            //draw lines\n            for (i = 0; i < l; i++) {\n                sprite = surface.add({\n                    type: 'path',\n                    path: ['M', centerX, centerY, 'L', centerX + rho * cos(i / l * pi2), centerY + rho * sin(i / l * pi2), 'Z'],\n                    stroke: '#ccc'\n                });\n                sprite.setAttributes({\n                    hidden: false\n                }, true);\n                sprites.push(sprite);\n            }\n        } else {\n            sprites = this.sprites;\n            //draw circles\n            for (i = 0; i < steps; i++) {\n                sprites[i].setAttributes({\n                    x: centerX,\n                    y: centerY,\n                    radius: Math.max(rho * (i + 1) / steps, 0),\n                    stroke: '#ccc'\n                }, true);\n            }\n            //draw lines\n            for (j = 0; j < l; j++) {\n                sprites[i + j].setAttributes({\n                    path: ['M', centerX, centerY, 'L', centerX + rho * cos(j / l * pi2), centerY + rho * sin(j / l * pi2), 'Z'],\n                    stroke: '#ccc'\n                }, true);\n            }\n        }\n        this.sprites = sprites;\n\n        this.drawLabel();\n    },\n\n    drawLabel: function() {\n        var chart = this.chart,\n            seriesItems = chart.series.items,\n            series,\n            surface = chart.surface,\n            bbox = chart.chartBBox,\n            store = chart.store,\n            data = store.data.items,\n            ln, record,\n            centerX = bbox.x + (bbox.width / 2),\n            centerY = bbox.y + (bbox.height / 2),\n            rho = Math.min(bbox.width, bbox.height) /2,\n            max = Math.max, round = Math.round,\n            labelArray = [], label,\n            fields = [], nfields,\n            categories = [], xField,\n            aggregate = !this.maximum,\n            maxValue = this.maximum || 0,\n            steps = this.steps, i = 0, j, dx, dy,\n            pi2 = Math.PI * 2,\n            cos = Math.cos, sin = Math.sin,\n            display = this.label.display,\n            draw = display !== 'none',\n            margin = 10;\n\n        if (!draw) {\n            return;\n        }\n\n        //get all rendered fields\n        for (i = 0, ln = seriesItems.length; i < ln; i++) {\n            series = seriesItems[i];\n            fields.push(series.yField);\n            xField = series.xField;\n        }\n        \n        //get maxValue to interpolate\n        for (j = 0, ln = data.length; j < ln; j++) {\n            record = data[j];\n            if (aggregate) {\n                for (i = 0, nfields = fields.length; i < nfields; i++) {\n                    maxValue = max(+record.get(fields[i]), maxValue);\n                }\n            }\n            categories.push(record.get(xField));\n        }\n        if (!this.labelArray) {\n            if (display != 'categories') {\n                //draw scale\n                for (i = 1; i <= steps; i++) {\n                    label = surface.add({\n                        type: 'text',\n                        text: round(i / steps * maxValue),\n                        x: centerX,\n                        y: centerY - rho * i / steps,\n                        'text-anchor': 'middle',\n                        'stroke-width': 0.1,\n                        stroke: '#333'\n                    });\n                    label.setAttributes({\n                        hidden: false\n                    }, true);\n                    labelArray.push(label);\n                }\n            }\n            if (display != 'scale') {\n                //draw text\n                for (j = 0, steps = categories.length; j < steps; j++) {\n                    dx = cos(j / steps * pi2) * (rho + margin);\n                    dy = sin(j / steps * pi2) * (rho + margin);\n                    label = surface.add({\n                        type: 'text',\n                        text: categories[j],\n                        x: centerX + dx,\n                        y: centerY + dy,\n                        'text-anchor': dx * dx <= 0.001? 'middle' : (dx < 0? 'end' : 'start')\n                    });\n                    label.setAttributes({\n                        hidden: false\n                    }, true);\n                    labelArray.push(label);\n                }\n            }\n        }\n        else {\n            labelArray = this.labelArray;\n            if (display != 'categories') {\n                //draw values\n                for (i = 0; i < steps; i++) {\n                    labelArray[i].setAttributes({\n                        text: round((i + 1) / steps * maxValue),\n                        x: centerX,\n                        y: centerY - rho * (i + 1) / steps,\n                        'text-anchor': 'middle',\n                        'stroke-width': 0.1,\n                        stroke: '#333'\n                    }, true);\n                }\n            }\n            if (display != 'scale') {\n                //draw text\n                for (j = 0, steps = categories.length; j < steps; j++) {\n                    dx = cos(j / steps * pi2) * (rho + margin);\n                    dy = sin(j / steps * pi2) * (rho + margin);\n                    if (labelArray[i + j]) {\n                        labelArray[i + j].setAttributes({\n                            type: 'text',\n                            text: categories[j],\n                            x: centerX + dx,\n                            y: centerY + dy,\n                            'text-anchor': dx * dx <= 0.001? 'middle' : (dx < 0? 'end' : 'start')\n                        }, true);\n                    }\n                }\n            }\n        }\n        this.labelArray = labelArray;\n    }\n});\n\n/**\n * A type of axis whose units are measured in time values. Use this axis\n * for listing dates that you will want to group or dynamically change.\n * If you just want to display dates as categories then use the\n * Category class for axis instead.\n *\n * For example:\n *\n *     axes: [{\n *         type: 'Time',\n *         position: 'bottom',\n *         fields: 'date',\n *         title: 'Day',\n *         dateFormat: 'M d',\n *\n *         constrain: true,\n *         fromDate: new Date('1/1/11'),\n *         toDate: new Date('1/7/11')\n *     }]\n *\n * In this example we're creating a time axis that has as title *Day*.\n * The field the axis is bound to is `date`.\n * The date format to use to display the text for the axis labels is `M d`\n * which is a three letter month abbreviation followed by the day number.\n * The time axis will show values for dates between `fromDate` and `toDate`.\n * Since `constrain` is set to true all other values for other dates not between\n * the fromDate and toDate will not be displayed.\n *\n */\nExt.define('Ext.chart.axis.Time', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.axis.Numeric',\n\n    alternateClassName: 'Ext.chart.TimeAxis',\n\n    alias: 'axis.time',\n\n    uses: ['Ext.data.Store'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String/Boolean} dateFormat\n     * Indicates the format the date will be rendered on.\n     * For example: 'M d' will render the dates as 'Jan 30', etc.\n     * For a list of possible format strings see {@link Ext.Date Date}\n     */\n    dateFormat: false,\n\n    /**\n     * @cfg {Date} fromDate The starting date for the time axis.\n     */\n    fromDate: false,\n\n    /**\n     * @cfg {Date} toDate The ending date for the time axis.\n     */\n    toDate: false,\n\n    /**\n     * @cfg {Array/Boolean} step\n     * An array with two components: The first is the unit of the step (day, month, year, etc). The second one is the number of units for the step (1, 2, etc.).\n     *\n     * Defaults to: [Ext.Date.DAY, 1].\n     */\n    step: [Ext.Date.DAY, 1],\n\n    /**\n     * @cfg {Boolean} constrain\n     * If true, the values of the chart will be rendered only if they belong between the fromDate and toDate.\n     * If false, the time axis will adapt to the new values by adding/removing steps.\n     */\n    constrain: false,\n\n    constructor: function (config) {\n        var me = this, label, f, df;\n        me.callParent([config]);\n        label = me.label || {};\n        df = this.dateFormat;\n        if (df) {\n            if (label.renderer) {\n                f = label.renderer;\n                label.renderer = function(v) {\n                    v = f(v);\n                    return Ext.Date.format(new Date(f(v)), df);\n                };\n            } else {\n                label.renderer = function(v) {\n                    return Ext.Date.format(new Date(v >> 0), df);\n                };\n            }\n        }\n    },\n\n    // Before rendering, set current default step count to be number of records.\n    processView: function () {\n        var me = this;\n        if (me.fromDate) {\n            me.minimum = +me.fromDate;\n        }\n        if (me.toDate) {\n            me.maximum = +me.toDate;\n        }\n        if(me.constrain){\n            me.doConstrain();\n        }\n     },\n\n    // @private modifies the store and creates the labels for the axes.\n    calcEnds: function() {\n        var me = this, range, step = me.step;\n        if (step) {\n            range = me.getRange();\n            range = Ext.draw.Draw.snapEndsByDateAndStep(new Date(range.min), new Date(range.max), Ext.isNumber(step) ? [Date.MILLI, step]: step);\n            if (me.minimum) {\n                range.from = me.minimum;\n            }\n            if (me.maximum) {\n                range.to = me.maximum;\n            }\n            range.step = (range.to - range.from) / range.steps;\n            return range;\n        } else {\n            return me.callParent(arguments);\n        }\n    }\n });\n\n\n/**\n * @class Ext.chart.series.Series\n *\n * Series is the abstract class containing the common logic to all chart series. Series includes\n * methods from Labels, Highlights, Tips and Callouts mixins. This class implements the logic of handling\n * mouse events, animating, hiding, showing all elements and returning the color of the series to be used as a legend item.\n *\n * ## Listeners\n *\n * The series class supports listeners via the Observable syntax. Some of these listeners are:\n *\n *  - `itemmouseup` When the user interacts with a marker.\n *  - `itemmousedown` When the user interacts with a marker.\n *  - `itemmousemove` When the user iteracts with a marker.\n *  - `afterrender` Will be triggered when the animation ends or when the series has been rendered completely.\n *\n * For example:\n *\n *     series: [{\n *             type: 'column',\n *             axis: 'left',\n *             listeners: {\n *                     'afterrender': function() {\n *                             console('afterrender');\n *                     }\n *             },\n *             xField: 'category',\n *             yField: 'data1'\n *     }]\n */\nExt.define('Ext.chart.series.Series', {\n\n    /* Begin Definitions */\n\n    mixins: {\n        observable: 'Ext.util.Observable',\n        labels: 'Ext.chart.Label',\n        highlights: 'Ext.chart.Highlight',\n        tips: 'Ext.chart.Tip',\n        callouts: 'Ext.chart.Callout'\n    },\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Boolean/Object} highlight\n     * If set to `true` it will highlight the markers or the series when hovering\n     * with the mouse. This parameter can also be an object with the same style\n     * properties you would apply to a {@link Ext.draw.Sprite} to apply custom\n     * styles to markers and series.\n     */\n\n    /**\n     * @cfg {Object} tips\n     * Add tooltips to the visualization's markers. The options for the tips are the\n     * same configuration used with {@link Ext.tip.ToolTip}. For example:\n     *\n     *     tips: {\n     *       trackMouse: true,\n     *       width: 140,\n     *       height: 28,\n     *       renderer: function(storeItem, item) {\n     *         this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data1') + ' views');\n     *       }\n     *     },\n     */\n\n    /**\n     * @cfg {String} type\n     * The type of series. Set in subclasses.\n     */\n    type: null,\n\n    /**\n     * @cfg {String} title\n     * The human-readable name of the series.\n     */\n    title: null,\n\n    /**\n     * @cfg {Boolean} showInLegend\n     * Whether to show this series in the legend.\n     */\n    showInLegend: true,\n\n    /**\n     * @cfg {Function} renderer\n     * A function that can be overridden to set custom styling properties to each rendered element.\n     * Passes in (sprite, record, attributes, index, store) to the function.\n     */\n    renderer: function(sprite, record, attributes, index, store) {\n        return attributes;\n    },\n\n    /**\n     * @cfg {Array} shadowAttributes\n     * An array with shadow attributes\n     */\n    shadowAttributes: null,\n\n    // @private animating flag\n    animating: false,\n\n    /**\n     * @cfg {Object} listeners\n     * An (optional) object with event callbacks. All event callbacks get the target *item* as first parameter. The callback functions are:\n     *\n     *  - itemmouseover\n     *  - itemmouseout\n     *  - itemmousedown\n     *  - itemmouseup\n     */\n\n    constructor: function(config) {\n        var me = this;\n        if (config) {\n            Ext.apply(me, config);\n        }\n\n        me.shadowGroups = [];\n\n        me.mixins.labels.constructor.call(me, config);\n        me.mixins.highlights.constructor.call(me, config);\n        me.mixins.tips.constructor.call(me, config);\n        me.mixins.callouts.constructor.call(me, config);\n\n        me.addEvents({\n            scope: me,\n            itemmouseover: true,\n            itemmouseout: true,\n            itemmousedown: true,\n            itemmouseup: true,\n            mouseleave: true,\n            afterdraw: true,\n\n            /**\n             * @event titlechange\n             * Fires when the series title is changed via {@link #setTitle}.\n             * @param {String} title The new title value\n             * @param {Number} index The index in the collection of titles\n             */\n            titlechange: true\n        });\n\n        me.mixins.observable.constructor.call(me, config);\n\n        me.on({\n            scope: me,\n            itemmouseover: me.onItemMouseOver,\n            itemmouseout: me.onItemMouseOut,\n            mouseleave: me.onMouseLeave\n        });\n        \n        if (me.style) {\n            Ext.apply(me.seriesStyle, me.style);\n        }\n    },\n    \n    /**\n     * Iterate over each of the records for this series. The default implementation simply iterates\n     * through the entire data store, but individual series implementations can override this to\n     * provide custom handling, e.g. adding/removing records.\n     * @param {Function} fn The function to execute for each record.\n     * @param {Object} scope Scope for the fn.\n     */\n    eachRecord: function(fn, scope) {\n        var chart = this.chart;\n        (chart.substore || chart.store).each(fn, scope);\n    },\n\n    /**\n     * Return the number of records being displayed in this series. Defaults to the number of\n     * records in the store; individual series implementations can override to provide custom handling.\n     */\n    getRecordCount: function() {\n        var chart = this.chart,\n            store = chart.substore || chart.store;\n        return store ? store.getCount() : 0;\n    },\n\n    /**\n     * Determines whether the series item at the given index has been excluded, i.e. toggled off in the legend.\n     * @param index\n     */\n    isExcluded: function(index) {\n        var excludes = this.__excludes;\n        return !!(excludes && excludes[index]);\n    },\n\n    // @private set the bbox and clipBox for the series\n    setBBox: function(noGutter) {\n        var me = this,\n            chart = me.chart,\n            chartBBox = chart.chartBBox,\n            gutterX = noGutter ? 0 : chart.maxGutter[0],\n            gutterY = noGutter ? 0 : chart.maxGutter[1],\n            clipBox, bbox;\n\n        clipBox = {\n            x: chartBBox.x,\n            y: chartBBox.y,\n            width: chartBBox.width,\n            height: chartBBox.height\n        };\n        me.clipBox = clipBox;\n\n        bbox = {\n            x: (clipBox.x + gutterX) - (chart.zoom.x * chart.zoom.width),\n            y: (clipBox.y + gutterY) - (chart.zoom.y * chart.zoom.height),\n            width: (clipBox.width - (gutterX * 2)) * chart.zoom.width,\n            height: (clipBox.height - (gutterY * 2)) * chart.zoom.height\n        };\n        me.bbox = bbox;\n    },\n\n    // @private set the animation for the sprite\n    onAnimate: function(sprite, attr) {\n        var me = this;\n        sprite.stopAnimation();\n        if (me.animating) {\n            return sprite.animate(Ext.applyIf(attr, me.chart.animate));\n        } else {\n            me.animating = true;\n            return sprite.animate(Ext.apply(Ext.applyIf(attr, me.chart.animate), {\n                listeners: {\n                    'afteranimate': function() {\n                        me.animating = false;\n                        me.fireEvent('afterrender');\n                    }\n                }\n            }));\n        }\n    },\n\n    // @private return the gutter.\n    getGutters: function() {\n        return [0, 0];\n    },\n\n    // @private wrapper for the itemmouseover event.\n    onItemMouseOver: function(item) {\n        var me = this;\n        if (item.series === me) {\n            if (me.highlight) {\n                me.highlightItem(item);\n            }\n            if (me.tooltip) {\n                me.showTip(item);\n            }\n        }\n    },\n\n    // @private wrapper for the itemmouseout event.\n    onItemMouseOut: function(item) {\n        var me = this;\n        if (item.series === me) {\n            me.unHighlightItem();\n            if (me.tooltip) {\n                me.hideTip(item);\n            }\n        }\n    },\n\n    // @private wrapper for the mouseleave event.\n    onMouseLeave: function() {\n        var me = this;\n        me.unHighlightItem();\n        if (me.tooltip) {\n            me.hideTip();\n        }\n    },\n\n    /**\n     * For a given x/y point relative to the Surface, find a corresponding item from this\n     * series, if any.\n     * @param {Number} x\n     * @param {Number} y\n     * @return {Object} An object describing the item, or null if there is no matching item.\n     * The exact contents of this object will vary by series type, but should always contain the following:\n     * @return {Ext.chart.series.Series} return.series the Series object to which the item belongs\n     * @return {Object} return.value the value(s) of the item's data point\n     * @return {Array} return.point the x/y coordinates relative to the chart box of a single point\n     * for this data item, which can be used as e.g. a tooltip anchor point.\n     * @return {Ext.draw.Sprite} return.sprite the item's rendering Sprite.\n     */\n    getItemForPoint: function(x, y) {\n        //if there are no items to query just return null.\n        if (!this.items || !this.items.length || this.seriesIsHidden) {\n            return null;\n        }\n        var me = this,\n            items = me.items,\n            bbox = me.bbox,\n            item, i, ln;\n        // Check bounds\n        if (!Ext.draw.Draw.withinBox(x, y, bbox)) {\n            return null;\n        }\n        for (i = 0, ln = items.length; i < ln; i++) {\n            if (items[i] && this.isItemInPoint(x, y, items[i], i)) {\n                return items[i];\n            }\n        }\n\n        return null;\n    },\n\n    isItemInPoint: function(x, y, item, i) {\n        return false;\n    },\n\n    /**\n     * Hides all the elements in the series.\n     */\n    hideAll: function() {\n        var me = this,\n            items = me.items,\n            item, len, i, j, l, sprite, shadows;\n\n        me.seriesIsHidden = true;\n        me._prevShowMarkers = me.showMarkers;\n\n        me.showMarkers = false;\n        //hide all labels\n        me.hideLabels(0);\n        //hide all sprites\n        for (i = 0, len = items.length; i < len; i++) {\n            item = items[i];\n            sprite = item.sprite;\n            if (sprite) {\n                sprite.setAttributes({\n                    hidden: true\n                }, true);\n            }\n\n            if (sprite && sprite.shadows) {\n                shadows = sprite.shadows;\n                for (j = 0, l = shadows.length; j < l; ++j) {\n                    shadows[j].setAttributes({\n                        hidden: true\n                    }, true);\n                }\n            }\n        }\n    },\n\n    /**\n     * Shows all the elements in the series.\n     */\n    showAll: function() {\n        var me = this,\n            prevAnimate = me.chart.animate;\n        me.chart.animate = false;\n        me.seriesIsHidden = false;\n        me.showMarkers = me._prevShowMarkers;\n        me.drawSeries();\n        me.chart.animate = prevAnimate;\n    },\n    \n    hide: function() {\n        if (this.items) {\n            var me = this,\n                items = me.items,\n                i, j, lsh, ln, shadows;\n            \n            if (items && items.length) {\n                for (i = 0, ln = items.length; i < ln; ++i) {\n                    if (items[i].sprite) {\n                        items[i].sprite.hide(true);\n\n                        shadows = items[i].shadows || items[i].sprite.shadows;\n                        if (shadows) {\n                            for (j = 0, lsh = shadows.length; j < lsh; ++j) {\n                                shadows[j].hide(true);\n                            }\n                        }\n                    }\n                }\n                me.hideLabels();\n            }\n        }\n    },\n\n    /**\n     * Returns a string with the color to be used for the series legend item.\n     */\n    getLegendColor: function(index) {\n        var me = this, fill, stroke;\n        if (me.seriesStyle) {\n            fill = me.seriesStyle.fill;\n            stroke = me.seriesStyle.stroke;\n            if (fill && fill != 'none') {\n                return fill;\n            }\n            if(stroke){\n                return stroke;\n            }\n        }\n        return (me.colorArrayStyle)?me.colorArrayStyle[me.seriesIdx % me.colorArrayStyle.length]:'#000';\n    },\n\n    /**\n     * Checks whether the data field should be visible in the legend\n     * @private\n     * @param {Number} index The index of the current item\n     */\n    visibleInLegend: function(index){\n        var excludes = this.__excludes;\n        if (excludes) {\n            return !excludes[index];\n        }\n        return !this.seriesIsHidden;\n    },\n\n    /**\n     * Changes the value of the {@link #title} for the series.\n     * Arguments can take two forms:\n     * <ul>\n     * <li>A single String value: this will be used as the new single title for the series (applies\n     * to series with only one yField)</li>\n     * <li>A numeric index and a String value: this will set the title for a single indexed yField.</li>\n     * </ul>\n     * @param {Number} index\n     * @param {String} title\n     */\n    setTitle: function(index, title) {\n        var me = this,\n            oldTitle = me.title;\n\n        if (Ext.isString(index)) {\n            title = index;\n            index = 0;\n        }\n\n        if (Ext.isArray(oldTitle)) {\n            oldTitle[index] = title;\n        } else {\n            me.title = title;\n        }\n\n        me.fireEvent('titlechange', title, index);\n    }\n});\n\n/**\n * @class Ext.chart.series.Cartesian\n *\n * Common base class for series implementations which plot values using x/y coordinates.\n */\nExt.define('Ext.chart.series.Cartesian', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.series.Series',\n\n    alternateClassName: ['Ext.chart.CartesianSeries', 'Ext.chart.CartesianChart'],\n\n    /* End Definitions */\n\n    /**\n     * The field used to access the x axis value from the items from the data\n     * source.\n     *\n     * @cfg xField\n     * @type String\n     */\n    xField: null,\n\n    /**\n     * The field used to access the y-axis value from the items from the data\n     * source.\n     *\n     * @cfg yField\n     * @type String\n     */\n    yField: null,\n\n    /**\n     * @cfg {String/String[]} axis\n     * The position of the axis to bind the values to. Possible values are 'left', 'bottom', 'top' and 'right'.\n     * You must explicitly set this value to bind the values of the line series to the ones in the axis, otherwise a\n     * relative scale will be used. For example, if you're using a Scatter or Line series and you'd like to have the\n     * values in the chart relative to the bottom and left axes then `axis` should be `['left', 'bottom']`.\n     */\n    axis: 'left',\n\n    getLegendLabels: function() {\n        var me = this,\n            labels = [],\n            fields, i, ln,\n            combinations = me.combinations,\n            title,\n            combo, label0, label1;\n\n        fields = [].concat(me.yField);\n        for (i = 0, ln = fields.length; i < ln; i++) {\n            title = me.title;\n            // Use the 'title' config if present, otherwise use the raw yField name\n            labels.push((Ext.isArray(title) ? title[i] : title) || fields[i]);\n        }\n\n        // Handle yFields combined via legend drag-drop\n        // TODO need to check to see if this is supported in extjs 4 branch\n        if (combinations) {\n            combinations = Ext.Array.from(combinations);\n            for (i = 0, ln = combinations.length; i < ln; i++) {\n                combo = combinations[i];\n                label0 = labels[combo[0]];\n                label1 = labels[combo[1]];\n                labels[combo[1]] = label0 + ' & ' + label1;\n                labels.splice(combo[0], 1);\n            }\n        }\n\n        return labels;\n    },\n\n    /**\n     * @protected Iterates over a given record's values for each of this series's yFields,\n     * executing a given function for each value. Any yFields that have been combined\n     * via legend drag-drop will be treated as a single value.\n     * @param {Ext.data.Model} record\n     * @param {Function} fn\n     * @param {Object} scope\n     */\n    eachYValue: function(record, fn, scope) {\n        var me = this,\n            yValueAccessors = me.getYValueAccessors(),\n            i, ln, accessor;\n        \n        for (i = 0, ln = yValueAccessors.length; i < ln; i++) {\n            accessor = yValueAccessors[i];\n            fn.call(scope, accessor(record), i);\n        }\n    },\n\n    /**\n     * @protected Returns the number of yField values, taking into account fields combined\n     * via legend drag-drop.\n     * @return {Number}\n     */\n    getYValueCount: function() {\n        return this.getYValueAccessors().length;\n    },\n\n    combine: function(index1, index2) {\n        var me = this,\n            accessors = me.getYValueAccessors(),\n            accessor1 = accessors[index1],\n            accessor2 = accessors[index2];\n\n        // Combine the yValue accessors for the two indexes into a single accessor that returns their sum\n        accessors[index2] = function(record) {\n            return accessor1(record) + accessor2(record);\n        };\n        accessors.splice(index1, 1);\n\n        me.callParent([index1, index2]);\n    },\n\n    clearCombinations: function() {\n        // Clear combined accessors, they'll get regenerated on next call to getYValueAccessors\n        delete this.yValueAccessors;\n        this.callParent();\n    },\n\n    /**\n     * @protected Returns an array of functions, each of which returns the value of the yField\n     * corresponding to function's index in the array, for a given record (each function takes the\n     * record as its only argument.) If yFields have been combined by the user via legend drag-drop,\n     * this list of accessors will be kept in sync with those combinations.\n     * @return {Array} array of accessor functions\n     */\n    getYValueAccessors: function() {\n        var me = this,\n            accessors = me.yValueAccessors,\n            yFields, yField, i, ln;\n        if (!accessors) {\n            accessors = me.yValueAccessors = [];\n            yFields = [].concat(me.yField);\n            \n            for (i = 0, ln = yFields.length; i < ln; i++) {\n                yField = yFields[i];\n                accessors.push(function(record) {\n                    return record.get(yField);\n                });\n            }\n        }\n        return accessors;\n    },\n\n    /**\n     * Calculate the min and max values for this series's xField.\n     * @return {Array} [min, max]\n     */\n    getMinMaxXValues: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            data = store.data.items,\n            i, ln, record,\n            min, max,\n            xField = me.xField,\n            xValue;\n\n        if (me.getRecordCount() > 0) {\n            min = Infinity;\n            max = -min;\n                \n            for (i = 0, ln = data.length; i < ln; i++) {\n                record = data[i];\n                xValue = record.get(xField);\n                if (xValue > max) {\n                    max = xValue;\n                }\n                if (xValue < min) {\n                    min = xValue;\n                }\n            }\n        } else {\n            min = max = 0;\n        }\n        return [min, max];\n    },\n\n    /**\n     * Calculate the min and max values for this series's yField(s). Takes into account yField\n     * combinations, exclusions, and stacking.\n     * @return {Array} [min, max]\n     */\n    getMinMaxYValues: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            data = store.data.items,\n            i, ln, record,\n            stacked = me.stacked,\n            min, max,\n            positiveTotal, negativeTotal;\n\n        function eachYValueStacked(yValue, i) {\n            if (!me.isExcluded(i)) {\n                if (yValue < 0) {\n                    negativeTotal += yValue;\n                } else {\n                    positiveTotal += yValue;\n                }\n            }\n        }\n\n        function eachYValue(yValue, i) {\n            if (!me.isExcluded(i)) {\n                if (yValue > max) {\n                    max = yValue;\n                }\n                if (yValue < min) {\n                    min = yValue;\n                }\n            }\n        }\n\n        if (me.getRecordCount() > 0) {\n            min = Infinity;\n            max = -min;\n            \n            for (i = 0, ln = data.length; i < ln; i++) {\n                record = data[i];\n                if (stacked) {\n                    positiveTotal = 0;\n                    negativeTotal = 0;\n                    me.eachYValue(record, eachYValueStacked);\n                    if (positiveTotal > max) {\n                        max = positiveTotal;\n                    }\n                    if (negativeTotal < min) {\n                        min = negativeTotal;\n                    }\n                } else {\n                    me.eachYValue(record, eachYValue);\n                }\n            }\n        } else {\n            min = max = 0;\n        }\n        return [min, max];\n    },\n\n    getAxesForXAndYFields: function() {\n        var me = this,\n            axes = me.chart.axes,\n            axis = [].concat(me.axis),\n            yFields = {}, yFieldList = [].concat(me.yField),\n            xFields = {}, xFieldList = [].concat(me.xField),\n            fields, xAxis, yAxis, i, ln, flipXY;\n\n        \n        flipXY = me.type === 'bar' && me.column === false;\n        if(flipXY) {\n            fields = yFieldList;\n            yFieldList = xFieldList;\n            xFieldList = fields;\n        }\n        if (Ext.Array.indexOf(axis, 'top') > -1) {\n            xAxis = 'top';\n        } else if (Ext.Array.indexOf(axis, 'bottom') > -1) {\n            xAxis = 'bottom';\n        } else {\n            if (axes.get('top') && axes.get('bottom')) {\n                for (i = 0, ln = xFieldList.length; i < ln; i++) {\n                    xFields[xFieldList[i]] = true;\n                }\n                fields = [].concat(axes.get('bottom').fields);\n                for (i = 0, ln = fields.length; i < ln; i++) {\n                    if (xFields[fields[i]]) {\n                        xAxis = 'bottom';\n                        break\n                    }\n                }\n                fields = [].concat(axes.get('top').fields);\n                for (i = 0, ln = fields.length; i < ln; i++) {\n                    if (xFields[fields[i]]) {\n                        xAxis = 'top';\n                        break\n                    }\n                }\n            } else if (axes.get('top')) {\n                xAxis = 'top';\n            } else if (axes.get('bottom')) {\n                xAxis = 'bottom';\n            }\n        }\n        if (Ext.Array.indexOf(axis, 'left') > -1) {\n            yAxis = 'left';\n        } else if (Ext.Array.indexOf(axis, 'right') > -1) {\n            yAxis = 'right';\n        } else {\n            if (axes.get('left') && axes.get('right')) {\n                for (i = 0, ln = yFieldList.length; i < ln; i++) {\n                    yFields[yFieldList[i]] = true;\n                }\n                fields = [].concat(axes.get('right').fields);\n                for (i = 0, ln = fields.length; i < ln; i++) {\n                    if (yFields[fields[i]]) {\n\n                        break\n                    }\n                }\n                fields = [].concat(axes.get('left').fields);\n                for (i = 0, ln = fields.length; i < ln; i++) {\n                    if (yFields[fields[i]]) {\n                        yAxis = 'left';\n                        break\n                    }\n                }\n            } else if (axes.get('left')) {\n                yAxis = 'left';\n            } else if (axes.get('right')) {\n                yAxis = 'right';\n            }\n        }\n\n        return flipXY ? {\n            xAxis: yAxis,\n            yAxis: xAxis\n        }: {\n            xAxis: xAxis,\n            yAxis: yAxis\n        };\n    }\n\n\n});\n\n/**\n * @class Ext.chart.series.Area\n * @extends Ext.chart.series.Cartesian\n *\n * Creates a Stacked Area Chart. The stacked area chart is useful when displaying multiple aggregated layers of information.\n * As with all other series, the Area Series must be appended in the *series* Chart array configuration. See the Chart\n * documentation for more information. A typical configuration object for the area series could be:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],\n *         data: [\n *             { 'name': 'metric one',   'data1':10, 'data2':12, 'data3':14, 'data4':8,  'data5':13 },\n *             { 'name': 'metric two',   'data1':7,  'data2':8,  'data3':16, 'data4':10, 'data5':3  },\n *             { 'name': 'metric three', 'data1':5,  'data2':2,  'data3':14, 'data4':12, 'data5':7  },\n *             { 'name': 'metric four',  'data1':2,  'data2':14, 'data3':6,  'data4':1,  'data5':23 },\n *             { 'name': 'metric five',  'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         store: store,\n *         axes: [\n *             {\n *                 type: 'Numeric',\n *                 grid: true,\n *                 position: 'left',\n *                 fields: ['data1', 'data2', 'data3', 'data4', 'data5'],\n *                 title: 'Sample Values',\n *                 grid: {\n *                     odd: {\n *                         opacity: 1,\n *                         fill: '#ddd',\n *                         stroke: '#bbb',\n *                         'stroke-width': 1\n *                     }\n *                 },\n *                 minimum: 0,\n *                 adjustMinimumByMajorUnit: 0\n *             },\n *             {\n *                 type: 'Category',\n *                 position: 'bottom',\n *                 fields: ['name'],\n *                 title: 'Sample Metrics',\n *                 grid: true,\n *                 label: {\n *                     rotate: {\n *                         degrees: 315\n *                     }\n *                 }\n *             }\n *         ],\n *         series: [{\n *             type: 'area',\n *             highlight: false,\n *             axis: 'left',\n *             xField: 'name',\n *             yField: ['data1', 'data2', 'data3', 'data4', 'data5'],\n *             style: {\n *                 opacity: 0.93\n *             }\n *         }]\n *     });\n *\n * In this configuration we set `area` as the type for the series, set highlighting options to true for highlighting elements on hover,\n * take the left axis to measure the data in the area series, set as xField (x values) the name field of each element in the store,\n * and as yFields (aggregated layers) seven data fields from the same store. Then we override some theming styles by adding some opacity\n * to the style object.\n *\n * @xtype area\n */\nExt.define('Ext.chart.series.Area', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.series.Cartesian',\n\n    alias: 'series.area',\n\n    requires: ['Ext.chart.axis.Axis', 'Ext.draw.Color', 'Ext.fx.Anim'],\n\n    /* End Definitions */\n\n    type: 'area',\n\n    // @private Area charts are alyways stacked\n    stacked: true,\n\n    /**\n     * @cfg {Object} style\n     * Append styling properties to this object for it to override theme properties.\n     */\n    style: {},\n\n    constructor: function(config) {\n        this.callParent(arguments);\n        var me = this,\n            surface = me.chart.surface,\n            i, l;\n        config.highlightCfg = Ext.Object.merge({}, {\n            lineWidth: 3,\n            stroke: '#55c',\n            opacity: 0.8,\n            color: '#f00'\n        }, config.highlightCfg);\n\n        Ext.apply(me, config, {\n            __excludes: []\n        });\n        if (me.highlight) {\n            me.highlightSprite = surface.add({\n                type: 'path',\n                path: ['M', 0, 0],\n                zIndex: 1000,\n                opacity: 0.3,\n                lineWidth: 5,\n                hidden: true,\n                stroke: '#444'\n            });\n        }\n        me.group = surface.getGroup(me.seriesId);\n    },\n\n    // @private Shrinks dataSets down to a smaller size\n    shrink: function(xValues, yValues, size) {\n        var len = xValues.length,\n            ratio = Math.floor(len / size),\n            i, j,\n            xSum = 0,\n            yCompLen = this.areas.length,\n            ySum = [],\n            xRes = [],\n            yRes = [];\n        //initialize array\n        for (j = 0; j < yCompLen; ++j) {\n            ySum[j] = 0;\n        }\n        for (i = 0; i < len; ++i) {\n            xSum += +xValues[i];\n            for (j = 0; j < yCompLen; ++j) {\n                ySum[j] += +yValues[i][j];\n            }\n            if (i % ratio == 0) {\n                //push averages\n                xRes.push(xSum/ratio);\n                for (j = 0; j < yCompLen; ++j) {\n                    ySum[j] /= ratio;\n                }\n                yRes.push(ySum);\n                //reset sum accumulators\n                xSum = 0;\n                for (j = 0, ySum = []; j < yCompLen; ++j) {\n                    ySum[j] = 0;\n                }\n            }\n        }\n        return {\n            x: xRes,\n            y: yRes\n        };\n    },\n\n    // @private Get chart and data boundaries\n    getBounds: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            data = store.data.items,\n            i, l, record,\n            areas = [].concat(me.yField),\n            areasLen = areas.length,\n            xValues = [],\n            yValues = [],\n            infinity = Infinity,\n            minX = infinity,\n            minY = infinity,\n            maxX = -infinity,\n            maxY = -infinity,\n            math = Math,\n            mmin = math.min,\n            mmax = math.max,\n            boundAxis = me.getAxesForXAndYFields(),\n            boundXAxis = boundAxis.xAxis,\n            boundYAxis = boundAxis.yAxis,\n            ends, allowDate,\n            bbox, xScale, yScale, xValue, yValue, areaIndex, acumY, ln, sumValues, clipBox, areaElem, axis, out;\n\n        me.setBBox();\n        bbox = me.bbox;\n\n        if (axis = chart.axes.get(boundXAxis)) {\n            if (axis.type === 'Time') {\n                allowDate = true;\n            }\n            ends = axis.applyData();\n            minX = ends.from;\n            maxX = ends.to;\n        }\n\n        if (axis = chart.axes.get(boundYAxis)) {\n            ends = axis.applyData();\n            minY = ends.from;\n            maxY = ends.to;\n        }\n\n        // If a field was specified without a corresponding axis, create one to get bounds\n        if (me.xField && !Ext.isNumber(minX)) {\n            axis = me.getMinMaxXValues();\n            allowDate = true;\n            minX = axis[0];\n            maxX = axis[1];\n        }\n\n        if (me.yField && !Ext.isNumber(minY)) {\n            axis = me.getMinMaxYValues();\n            minY = axis[0];\n            maxY = axis[1];\n        }\n\n        if (!Ext.isNumber(minY)) {\n            minY = 0;\n        }\n        if (!Ext.isNumber(maxY)) {\n            maxY = 0;\n        }\n\n        for (i = 0, l = data.length; i < l; i++) {\n            record = data[i];\n            xValue = record.get(me.xField);\n            yValue = [];\n            if (typeof xValue != 'number') {\n                if (allowDate) {\n                    xValue = +xValue;\n                } else {\n                    xValue = i;\n                }\n            }\n            xValues.push(xValue);\n            acumY = 0;\n            for (areaIndex = 0; areaIndex < areasLen; areaIndex++) {\n                // Excluded series\n                if (me.__excludes[areaIndex]) {\n                    continue;\n                }\n                areaElem = record.get(areas[areaIndex]);\n                if (typeof areaElem == 'number') {\n                    yValue.push(areaElem);\n                }\n            }\n            yValues.push(yValue);\n        }\n\n        xScale = bbox.width / ((maxX - minX) || 1);\n        yScale = bbox.height / ((maxY - minY) || 1);\n\n        ln = xValues.length;\n        if ((ln > bbox.width) && me.areas) {\n            sumValues = me.shrink(xValues, yValues, bbox.width);\n            xValues = sumValues.x;\n            yValues = sumValues.y;\n        }\n\n        return {\n            bbox: bbox,\n            minX: minX,\n            minY: minY,\n            xValues: xValues,\n            yValues: yValues,\n            xScale: xScale,\n            yScale: yScale,\n            areasLen: areasLen\n        };\n    },\n\n    // @private Build an array of paths for the chart\n    getPaths: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            first = true,\n            bounds = me.getBounds(),\n            bbox = bounds.bbox,\n            items = me.items = [],\n            componentPaths = [],\n            componentPath,\n            count = 0,\n            paths = [],\n            i, ln, x, y, xValue, yValue, acumY, areaIndex, prevAreaIndex, areaElem, path;\n\n        ln = bounds.xValues.length;\n        // Start the path\n        for (i = 0; i < ln; i++) {\n            xValue = bounds.xValues[i];\n            yValue = bounds.yValues[i];\n            x = bbox.x + (xValue - bounds.minX) * bounds.xScale;\n            acumY = 0;\n            count = 0;\n            for (areaIndex = 0; areaIndex < bounds.areasLen; areaIndex++) {\n                // Excluded series\n                if (me.__excludes[areaIndex]) {\n                    continue;\n                }\n                if (!componentPaths[areaIndex]) {\n                    componentPaths[areaIndex] = [];\n                }\n                areaElem = yValue[count];\n                acumY += areaElem;\n                y = bbox.y + bbox.height - (acumY - bounds.minY) * bounds.yScale;\n                if (!paths[areaIndex]) {\n                    paths[areaIndex] = ['M', x, y];\n                    componentPaths[areaIndex].push(['L', x, y]);\n                } else {\n                    paths[areaIndex].push('L', x, y);\n                    componentPaths[areaIndex].push(['L', x, y]);\n                }\n                if (!items[areaIndex]) {\n                    items[areaIndex] = {\n                        pointsUp: [],\n                        pointsDown: [],\n                        series: me\n                    };\n                }\n                items[areaIndex].pointsUp.push([x, y]);\n                count++;\n            }\n        }\n\n        // Close the paths\n        for (areaIndex = 0; areaIndex < bounds.areasLen; areaIndex++) {\n            // Excluded series\n            if (me.__excludes[areaIndex]) {\n                continue;\n            }\n            path = paths[areaIndex];\n            // Close bottom path to the axis\n            if (areaIndex == 0 || first) {\n                first = false;\n                path.push('L', x, bbox.y + bbox.height,\n                          'L', bbox.x, bbox.y + bbox.height,\n                          'Z');\n            }\n            // Close other paths to the one before them\n            else {\n                componentPath = componentPaths[prevAreaIndex];\n                componentPath.reverse();\n                path.push('L', x, componentPath[0][2]);\n                for (i = 0; i < ln; i++) {\n                    path.push(componentPath[i][0],\n                              componentPath[i][1],\n                              componentPath[i][2]);\n                    items[areaIndex].pointsDown[ln -i -1] = [componentPath[i][1], componentPath[i][2]];\n                }\n                path.push('L', bbox.x, path[2], 'Z');\n            }\n            prevAreaIndex = areaIndex;\n        }\n        return {\n            paths: paths,\n            areasLen: bounds.areasLen\n        };\n    },\n\n    /**\n     * Draws the series for the current chart.\n     */\n    drawSeries: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            surface = chart.surface,\n            animate = chart.animate,\n            group = me.group,\n            endLineStyle = Ext.apply(me.seriesStyle, me.style),\n            colorArrayStyle = me.colorArrayStyle,\n            colorArrayLength = colorArrayStyle && colorArrayStyle.length || 0,\n            areaIndex, areaElem, paths, path, rendererAttributes;\n        \n        me.unHighlightItem();\n        me.cleanHighlights();\n\n        if (!store || !store.getCount() || me.seriesIsHidden) {\n            me.hide();\n            me.items = [];\n            return;\n        }\n\n        paths = me.getPaths();\n\n        if (!me.areas) {\n            me.areas = [];\n        }\n\n        for (areaIndex = 0; areaIndex < paths.areasLen; areaIndex++) {\n            // Excluded series\n            if (me.__excludes[areaIndex]) {\n                continue;\n            }\n            if (!me.areas[areaIndex]) {\n                me.items[areaIndex].sprite = me.areas[areaIndex] = surface.add(Ext.apply({}, {\n                    type: 'path',\n                    group: group,\n                    // 'clip-rect': me.clipBox,\n                    path: paths.paths[areaIndex],\n                    stroke: endLineStyle.stroke || colorArrayStyle[areaIndex % colorArrayLength],\n                    fill: colorArrayStyle[areaIndex % colorArrayLength]\n                }, endLineStyle || {}));\n            }\n            areaElem = me.areas[areaIndex];\n            path = paths.paths[areaIndex];\n            if (animate) {\n                //Add renderer to line. There is not a unique record associated with this.\n                rendererAttributes = me.renderer(areaElem, false, {\n                    path: path,\n                    // 'clip-rect': me.clipBox,\n                    fill: colorArrayStyle[areaIndex % colorArrayLength],\n                    stroke: endLineStyle.stroke || colorArrayStyle[areaIndex % colorArrayLength]\n                }, areaIndex, store);\n                //fill should not be used here but when drawing the special fill path object\n                me.animation = me.onAnimate(areaElem, {\n                    to: rendererAttributes\n                });\n            } else {\n                rendererAttributes = me.renderer(areaElem, false, {\n                    path: path,\n                    // 'clip-rect': me.clipBox,\n                    hidden: false,\n                    fill: colorArrayStyle[areaIndex % colorArrayLength],\n                    stroke: endLineStyle.stroke || colorArrayStyle[areaIndex % colorArrayLength]\n                }, areaIndex, store);\n                me.areas[areaIndex].setAttributes(rendererAttributes, true);\n            }\n        }\n        me.renderLabels();\n        me.renderCallouts();\n    },\n\n    // @private\n    onAnimate: function(sprite, attr) {\n        sprite.show();\n        return this.callParent(arguments);\n    },\n\n    // @private\n    onCreateLabel: function(storeItem, item, i, display) {\n        var me = this,\n            group = me.labelsGroup,\n            config = me.label,\n            bbox = me.bbox,\n            endLabelStyle = Ext.apply(config, me.seriesLabelStyle);\n\n        return me.chart.surface.add(Ext.apply({\n            'type': 'text',\n            'text-anchor': 'middle',\n            'group': group,\n            'x': item.point[0],\n            'y': bbox.y + bbox.height / 2\n        }, endLabelStyle || {}));\n    },\n\n    // @private\n    onPlaceLabel: function(label, storeItem, item, i, display, animate, index) {\n        var me = this,\n            chart = me.chart,\n            resizing = chart.resizing,\n            config = me.label,\n            format = config.renderer,\n            field = config.field,\n            bbox = me.bbox,\n            x = item.point[0],\n            y = item.point[1],\n            bb, width, height;\n\n        label.setAttributes({\n            text: format(storeItem.get(field[index])),\n            hidden: true\n        }, true);\n\n        bb = label.getBBox();\n        width = bb.width / 2;\n        height = bb.height / 2;\n\n        x = x - width < bbox.x? bbox.x + width : x;\n        x = (x + width > bbox.x + bbox.width) ? (x - (x + width - bbox.x - bbox.width)) : x;\n        y = y - height < bbox.y? bbox.y + height : y;\n        y = (y + height > bbox.y + bbox.height) ? (y - (y + height - bbox.y - bbox.height)) : y;\n\n        if (me.chart.animate && !me.chart.resizing) {\n            label.show(true);\n            me.onAnimate(label, {\n                to: {\n                    x: x,\n                    y: y\n                }\n            });\n        } else {\n            label.setAttributes({\n                x: x,\n                y: y\n            }, true);\n            if (resizing) {\n                me.animation.on('afteranimate', function() {\n                    label.show(true);\n                });\n            } else {\n                label.show(true);\n            }\n        }\n    },\n\n    // @private\n    onPlaceCallout : function(callout, storeItem, item, i, display, animate, index) {\n        var me = this,\n            chart = me.chart,\n            surface = chart.surface,\n            resizing = chart.resizing,\n            config = me.callouts,\n            items = me.items,\n            prev = (i == 0) ? false : items[i -1].point,\n            next = (i == items.length -1) ? false : items[i +1].point,\n            cur = item.point,\n            dir, norm, normal, a, aprev, anext,\n            bbox = callout.label.getBBox(),\n            offsetFromViz = 30,\n            offsetToSide = 10,\n            offsetBox = 3,\n            boxx, boxy, boxw, boxh,\n            p, clipRect = me.clipRect,\n            x, y;\n\n        //get the right two points\n        if (!prev) {\n            prev = cur;\n        }\n        if (!next) {\n            next = cur;\n        }\n        a = (next[1] - prev[1]) / (next[0] - prev[0]);\n        aprev = (cur[1] - prev[1]) / (cur[0] - prev[0]);\n        anext = (next[1] - cur[1]) / (next[0] - cur[0]);\n\n        norm = Math.sqrt(1 + a * a);\n        dir = [1 / norm, a / norm];\n        normal = [-dir[1], dir[0]];\n\n        //keep the label always on the outer part of the \"elbow\"\n        if (aprev > 0 && anext < 0 && normal[1] < 0 || aprev < 0 && anext > 0 && normal[1] > 0) {\n            normal[0] *= -1;\n            normal[1] *= -1;\n        } else if (Math.abs(aprev) < Math.abs(anext) && normal[0] < 0 || Math.abs(aprev) > Math.abs(anext) && normal[0] > 0) {\n            normal[0] *= -1;\n            normal[1] *= -1;\n        }\n\n        //position\n        x = cur[0] + normal[0] * offsetFromViz;\n        y = cur[1] + normal[1] * offsetFromViz;\n\n        //box position and dimensions\n        boxx = x + (normal[0] > 0? 0 : -(bbox.width + 2 * offsetBox));\n        boxy = y - bbox.height /2 - offsetBox;\n        boxw = bbox.width + 2 * offsetBox;\n        boxh = bbox.height + 2 * offsetBox;\n\n        //now check if we're out of bounds and invert the normal vector correspondingly\n        //this may add new overlaps between labels (but labels won't be out of bounds).\n        if (boxx < clipRect[0] || (boxx + boxw) > (clipRect[0] + clipRect[2])) {\n            normal[0] *= -1;\n        }\n        if (boxy < clipRect[1] || (boxy + boxh) > (clipRect[1] + clipRect[3])) {\n            normal[1] *= -1;\n        }\n\n        //update positions\n        x = cur[0] + normal[0] * offsetFromViz;\n        y = cur[1] + normal[1] * offsetFromViz;\n\n        //update box position and dimensions\n        boxx = x + (normal[0] > 0? 0 : -(bbox.width + 2 * offsetBox));\n        boxy = y - bbox.height /2 - offsetBox;\n        boxw = bbox.width + 2 * offsetBox;\n        boxh = bbox.height + 2 * offsetBox;\n\n        //set the line from the middle of the pie to the box.\n        callout.lines.setAttributes({\n            path: [\"M\", cur[0], cur[1], \"L\", x, y, \"Z\"]\n        }, true);\n        //set box position\n        callout.box.setAttributes({\n            x: boxx,\n            y: boxy,\n            width: boxw,\n            height: boxh\n        }, true);\n        //set text position\n        callout.label.setAttributes({\n            x: x + (normal[0] > 0? offsetBox : -(bbox.width + offsetBox)),\n            y: y\n        }, true);\n        for (p in callout) {\n            callout[p].show(true);\n        }\n    },\n\n    isItemInPoint: function(x, y, item, i) {\n        var me = this,\n            pointsUp = item.pointsUp,\n            pointsDown = item.pointsDown,\n            abs = Math.abs,\n            distChanged = false,\n            last = false,\n            dist = Infinity, p, pln, point;\n\n        for (p = 0, pln = pointsUp.length; p < pln; p++) {\n            point = [pointsUp[p][0], pointsUp[p][1]];\n            \n            distChanged = false;\n            last = p == pln -1;\n\n            if (dist > abs(x - point[0])) {\n                dist = abs(x - point[0]);\n                distChanged = true;\n                if (last) {\n                    ++p;\n                }\n            }\n            \n            if (!distChanged || (distChanged && last)) {\n                point = pointsUp[p -1];\n                if (y >= point[1] && (!pointsDown.length || y <= (pointsDown[p -1][1]))) {\n                    item.storeIndex = p -1;\n                    item.storeField = me.yField[i];\n                    item.storeItem = me.chart.store.getAt(p -1);\n                    item._points = pointsDown.length? [point, pointsDown[p -1]] : [point];\n                    return true;\n                } else {\n                    break;\n                }\n            }\n        }\n        return false;\n    },\n\n    /**\n     * Highlight this entire series.\n     * @param {Object} item Info about the item; same format as returned by #getItemForPoint.\n     */\n    highlightSeries: function() {\n        var area, to, fillColor;\n        if (this._index !== undefined) {\n            area = this.areas[this._index];\n            if (area.__highlightAnim) {\n                area.__highlightAnim.paused = true;\n            }\n            area.__highlighted = true;\n            area.__prevOpacity = area.__prevOpacity || area.attr.opacity || 1;\n            area.__prevFill = area.__prevFill || area.attr.fill;\n            area.__prevLineWidth = area.__prevLineWidth || area.attr.lineWidth;\n            fillColor = Ext.draw.Color.fromString(area.__prevFill);\n            to = {\n                lineWidth: (area.__prevLineWidth || 0) + 2\n            };\n            if (fillColor) {\n                to.fill = fillColor.getLighter(0.2).toString();\n            }\n            else {\n                to.opacity = Math.max(area.__prevOpacity - 0.3, 0);\n            }\n            if (this.chart.animate) {\n                area.__highlightAnim = new Ext.fx.Anim(Ext.apply({\n                    target: area,\n                    to: to\n                }, this.chart.animate));\n            }\n            else {\n                area.setAttributes(to, true);\n            }\n        }\n    },\n\n    /**\n     * UnHighlight this entire series.\n     * @param {Object} item Info about the item; same format as returned by #getItemForPoint.\n     */\n    unHighlightSeries: function() {\n        var area;\n        if (this._index !== undefined) {\n            area = this.areas[this._index];\n            if (area.__highlightAnim) {\n                area.__highlightAnim.paused = true;\n            }\n            if (area.__highlighted) {\n                area.__highlighted = false;\n                area.__highlightAnim = new Ext.fx.Anim({\n                    target: area,\n                    to: {\n                        fill: area.__prevFill,\n                        opacity: area.__prevOpacity,\n                        lineWidth: area.__prevLineWidth\n                    }\n                });\n            }\n        }\n    },\n\n    /**\n     * Highlight the specified item. If no item is provided the whole series will be highlighted.\n     * @param item {Object} Info about the item; same format as returned by #getItemForPoint\n     */\n    highlightItem: function(item) {\n        var me = this,\n            points, path;\n        if (!item) {\n            this.highlightSeries();\n            return;\n        }\n        points = item._points;\n        path = points.length == 2? ['M', points[0][0], points[0][1], 'L', points[1][0], points[1][1]]\n                : ['M', points[0][0], points[0][1], 'L', points[0][0], me.bbox.y + me.bbox.height];\n        me.highlightSprite.setAttributes({\n            path: path,\n            hidden: false\n        }, true);\n    },\n\n    /**\n     * Un-highlights the specified item. If no item is provided it will un-highlight the entire series.\n     * @param {Object} item Info about the item; same format as returned by #getItemForPoint\n     */\n    unHighlightItem: function(item) {\n        if (!item) {\n            this.unHighlightSeries();\n        }\n\n        if (this.highlightSprite) {\n            this.highlightSprite.hide(true);\n        }\n    },\n\n    // @private\n    hideAll: function(index) {\n        var me = this;\n        index = (isNaN(me._index) ? index : me._index) || 0;\n        me.__excludes[index] = true;\n        me.areas[index].hide(true);\n        me.redraw();\n    },\n\n    // @private\n    showAll: function(index) {\n        var me = this;\n        index = (isNaN(me._index) ? index : me._index) || 0;\n        me.__excludes[index] = false;\n        me.areas[index].show(true);\n        me.redraw();\n    },\n\n    redraw: function() {\n        //store previous configuration for the legend\n        //and set it to false so we don't\n        //re-build label elements if not necessary.\n        var me = this,\n            prevLegendConfig;\n        prevLegendConfig = me.chart.legend.rebuild;\n        me.chart.legend.rebuild = false;\n        me.chart.redraw();\n        me.chart.legend.rebuild = prevLegendConfig;\n    },\n    \n    hide: function() {\n        if (this.areas) {\n            var me = this,\n                areas = me.areas,\n                i, j, l, ln, shadows;\n            \n            if (areas && areas.length) {\n                for (i = 0, ln = areas.length; i < ln; ++i) {\n                    if (areas[i]) {\n                        areas[i].hide(true);\n                    }\n                }\n                me.hideLabels();\n            }\n        }\n    },\n\n    /**\n     * Returns the color of the series (to be displayed as color for the series legend item).\n     * @param {Object} item Info about the item; same format as returned by #getItemForPoint\n     */\n    getLegendColor: function(index) {\n        var me = this;\n        return me.colorArrayStyle[index % me.colorArrayStyle.length];\n    }\n});\n\n/**\n * Creates a Bar Chart. A Bar Chart is a useful visualization technique to display quantitative information for\n * different categories that can show some progression (or regression) in the dataset. As with all other series, the Bar\n * Series must be appended in the *series* Chart array configuration. See the Chart documentation for more information.\n * A typical configuration object for the bar series could be:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data'],\n *         data: [\n *             { 'name': 'metric one',   'data':10 },\n *             { 'name': 'metric two',   'data': 7 },\n *             { 'name': 'metric three', 'data': 5 },\n *             { 'name': 'metric four',  'data': 2 },\n *             { 'name': 'metric five',  'data':27 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         animate: true,\n *         store: store,\n *         axes: [{\n *             type: 'Numeric',\n *             position: 'bottom',\n *             fields: ['data'],\n *             label: {\n *                 renderer: Ext.util.Format.numberRenderer('0,0')\n *             },\n *             title: 'Sample Values',\n *             grid: true,\n *             minimum: 0\n *         }, {\n *             type: 'Category',\n *             position: 'left',\n *             fields: ['name'],\n *             title: 'Sample Metrics'\n *         }],\n *         series: [{\n *             type: 'bar',\n *             axis: 'bottom',\n *             highlight: true,\n *             tips: {\n *               trackMouse: true,\n *               width: 140,\n *               height: 28,\n *               renderer: function(storeItem, item) {\n *                 this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data') + ' views');\n *               }\n *             },\n *             label: {\n *               display: 'insideEnd',\n *                 field: 'data',\n *                 renderer: Ext.util.Format.numberRenderer('0'),\n *                 orientation: 'horizontal',\n *                 color: '#333',\n *                 'text-anchor': 'middle'\n *             },\n *             xField: 'name',\n *             yField: 'data'\n *         }]\n *     });\n *\n * In this configuration we set `bar` as the series type, bind the values of the bar to the bottom axis and set the\n * xField or category field to the `name` parameter of the store. We also set `highlight` to true which enables smooth\n * animations when bars are hovered. We also set some configuration for the bar labels to be displayed inside the bar,\n * to display the information found in the `data1` property of each element store, to render a formated text with the\n * `Ext.util.Format` we pass in, to have an `horizontal` orientation (as opposed to a vertical one) and we also set\n * other styles like `color`, `text-anchor`, etc.\n */\nExt.define('Ext.chart.series.Bar', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.series.Cartesian',\n\n    alternateClassName: ['Ext.chart.BarSeries', 'Ext.chart.BarChart', 'Ext.chart.StackedBarChart'],\n\n    requires: ['Ext.chart.axis.Axis', 'Ext.fx.Anim'],\n\n    /* End Definitions */\n\n    type: 'bar',\n\n    alias: 'series.bar',\n    /**\n     * @cfg {Boolean} column Whether to set the visualization as column chart or horizontal bar chart.\n     */\n    column: false,\n\n    /**\n     * @cfg style Style properties that will override the theming series styles.\n     */\n    style: {},\n\n    /**\n     * @cfg {Number} gutter The gutter space between single bars, as a percentage of the bar width\n     */\n    gutter: 38.2,\n\n    /**\n     * @cfg {Number} groupGutter The gutter space between groups of bars, as a percentage of the bar width\n     */\n    groupGutter: 38.2,\n\n    /**\n     * @cfg {Number} xPadding Padding between the left/right axes and the bars\n     */\n    xPadding: 0,\n\n    /**\n     * @cfg {Number} yPadding Padding between the top/bottom axes and the bars\n     */\n    yPadding: 10,\n\n    constructor: function(config) {\n        this.callParent(arguments);\n        var me = this,\n            surface = me.chart.surface,\n            shadow = me.chart.shadow,\n            i, l;\n        config.highlightCfg = Ext.Object.merge({\n            lineWidth: 3,\n            stroke: '#55c',\n            opacity: 0.8,\n            color: '#f00'\n        }, config.highlightCfg);\n        Ext.apply(me, config, {\n            shadowAttributes: [{\n                \"stroke-width\": 6,\n                \"stroke-opacity\": 0.05,\n                stroke: 'rgb(200, 200, 200)',\n                translate: {\n                    x: 1.2,\n                    y: 1.2\n                }\n            }, {\n                \"stroke-width\": 4,\n                \"stroke-opacity\": 0.1,\n                stroke: 'rgb(150, 150, 150)',\n                translate: {\n                    x: 0.9,\n                    y: 0.9\n                }\n            }, {\n                \"stroke-width\": 2,\n                \"stroke-opacity\": 0.15,\n                stroke: 'rgb(100, 100, 100)',\n                translate: {\n                    x: 0.6,\n                    y: 0.6\n                }\n            }]\n        });\n\n        me.group = surface.getGroup(me.seriesId + '-bars');\n        if (shadow) {\n            for (i = 0, l = me.shadowAttributes.length; i < l; i++) {\n                me.shadowGroups.push(surface.getGroup(me.seriesId + '-shadows' + i));\n            }\n        }\n    },\n\n    // @private sets the bar girth.\n    getBarGirth: function() {\n        var me = this,\n            store = me.chart.getChartStore(),\n            column = me.column,\n            ln = store.getCount(),\n            gutter = me.gutter / 100;\n\n        return (me.chart.chartBBox[column ? 'width' : 'height'] - me[column ? 'xPadding' : 'yPadding'] * 2) / (ln * (gutter + 1) - gutter);\n    },\n\n    // @private returns the gutters.\n    getGutters: function() {\n        var me = this,\n            column = me.column,\n            gutter = Math.ceil(me[column ? 'xPadding' : 'yPadding'] + me.getBarGirth() / 2);\n        return me.column ? [gutter, 0] : [0, gutter];\n    },\n\n    // @private Get chart and data boundaries\n    getBounds: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            data = store.data.items,\n            i, ln, record,\n            bars = [].concat(me.yField),\n            barsLen = bars.length,\n            groupBarsLen = barsLen,\n            groupGutter = me.groupGutter / 100,\n            column = me.column,\n            xPadding = me.xPadding,\n            yPadding = me.yPadding,\n            stacked = me.stacked,\n            barWidth = me.getBarGirth(),\n            barWidthProperty = column ? 'width' : 'height',\n            math = Math,\n            mmin = math.min,\n            mmax = math.max,\n            mabs = math.abs,\n            boundAxes = me.getAxesForXAndYFields(),\n            boundYAxis = boundAxes.yAxis,\n            ends, shrunkBarWidth, groupBarWidth, bbox, minY, maxY, axis, out,\n            scale, zero, total, rec, j, plus, minus;\n\n        me.setBBox(true);\n        bbox = me.bbox;\n\n        //Skip excluded series\n        if (me.__excludes) {\n            for (j = 0, total = me.__excludes.length; j < total; j++) {\n                if (me.__excludes[j]) {\n                    groupBarsLen--;\n                }\n            }\n        }\n        axis = chart.axes.get(boundYAxis);\n        if (axis) {\n            ends = axis.applyData();\n            minY = ends.from;\n            maxY = ends.to;\n        }\n\n        if (me.yField && !Ext.isNumber(minY)) {\n            out = me.getMinMaxYValues();\n            minY = out[0];\n            maxY = out[1];\n        }\n\n        if (!Ext.isNumber(minY)) {\n            minY = 0;\n        }\n        if (!Ext.isNumber(maxY)) {\n            maxY = 0;\n        }\n        scale = (column ? bbox.height - yPadding * 2 : bbox.width - xPadding * 2) / (maxY - minY);\n        shrunkBarWidth = barWidth;\n        groupBarWidth = (barWidth / ((stacked ? 1 : groupBarsLen) * (groupGutter + 1) - groupGutter));\n        \n        if (barWidthProperty in me.style) {\n            groupBarWidth = mmin(groupBarWidth, me.style[barWidthProperty]);\n            shrunkBarWidth = groupBarWidth * ((stacked ? 1 : groupBarsLen) * (groupGutter + 1) - groupGutter);\n        }\n        zero = (column) ? bbox.y + bbox.height - yPadding : bbox.x + xPadding;\n\n        if (stacked) {\n            total = [[], []];\n            for (i = 0, ln = data.length; i < ln; i++) {\n                record = data[i];\n                total[0][i] = total[0][i] || 0;\n                total[1][i] = total[1][i] || 0;\n                for (j = 0; j < barsLen; j++) {\n                    if (me.__excludes && me.__excludes[j]) {\n                        continue;\n                    }\n                    rec = record.get(bars[j]);\n                    total[+(rec > 0)][i] += mabs(rec);\n                }\n            }\n            total[+(maxY > 0)].push(mabs(maxY));\n            total[+(minY > 0)].push(mabs(minY));\n            minus = mmax.apply(math, total[0]);\n            plus = mmax.apply(math, total[1]);\n            scale = (column ? bbox.height - yPadding * 2 : bbox.width - xPadding * 2) / (plus + minus);\n            zero = zero + minus * scale * (column ? -1 : 1);\n        }\n        else if (minY / maxY < 0) {\n            zero = zero - minY * scale * (column ? -1 : 1);\n        }\n        return {\n            bars: bars,\n            bbox: bbox,\n            shrunkBarWidth: shrunkBarWidth,\n            barsLen: barsLen,\n            groupBarsLen: groupBarsLen,\n            barWidth: barWidth,\n            groupBarWidth: groupBarWidth,\n            scale: scale,\n            zero: zero,\n            xPadding: xPadding,\n            yPadding: yPadding,\n            signed: minY / maxY < 0,\n            minY: minY,\n            maxY: maxY\n        };\n    },\n\n    // @private Build an array of paths for the chart\n    getPaths: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            data = store.data.items,\n            i, total, record,\n            bounds = me.bounds = me.getBounds(),\n            items = me.items = [],\n            yFields = me.yField,\n            gutter = me.gutter / 100,\n            groupGutter = me.groupGutter / 100,\n            animate = chart.animate,\n            column = me.column,\n            group = me.group,\n            enableShadows = chart.shadow,\n            shadowGroups = me.shadowGroups,\n            shadowAttributes = me.shadowAttributes,\n            shadowGroupsLn = shadowGroups.length,\n            bbox = bounds.bbox,\n            barWidth = bounds.barWidth,\n            shrunkBarWidth = bounds.shrunkBarWidth,\n            xPadding = me.xPadding,\n            yPadding = me.yPadding,\n            stacked = me.stacked,\n            barsLen = bounds.barsLen,\n            colors = me.colorArrayStyle,\n            colorLength = colors && colors.length || 0,\n            math = Math,\n            mmax = math.max,\n            mmin = math.min,\n            mabs = math.abs,\n            j, yValue, height, totalDim, totalNegDim, bottom, top, hasShadow, barAttr, attrs, counter,\n            shadowIndex, shadow, sprite, offset, floorY;\n\n        for (i = 0, total = data.length; i < total; i++) {\n            record = data[i];\n            bottom = bounds.zero;\n            top = bounds.zero;\n            totalDim = 0;\n            totalNegDim = 0;\n            hasShadow = false;\n            for (j = 0, counter = 0; j < barsLen; j++) {\n                // Excluded series\n                if (me.__excludes && me.__excludes[j]) {\n                    continue;\n                }\n                yValue = record.get(bounds.bars[j]);\n                height = Math.round((yValue - mmax(bounds.minY, 0)) * bounds.scale);\n                barAttr = {\n                    fill: colors[(barsLen > 1 ? j : 0) % colorLength]\n                };\n                if (column) {\n                    Ext.apply(barAttr, {\n                        height: height,\n                        width: mmax(bounds.groupBarWidth, 0),\n                        x: (bbox.x + xPadding + (barWidth - shrunkBarWidth) * 0.5 + i * barWidth * (1 + gutter) + counter * bounds.groupBarWidth * (1 + groupGutter) * !stacked),\n                        y: bottom - height\n                    });\n                }\n                else {\n                    // draw in reverse order\n                    offset = (total - 1) - i;\n                    Ext.apply(barAttr, {\n                        height: mmax(bounds.groupBarWidth, 0),\n                        width: height + (bottom == bounds.zero),\n                        x: bottom + (bottom != bounds.zero),\n                        y: (bbox.y + yPadding + (barWidth - shrunkBarWidth) * 0.5 + offset * barWidth * (1 + gutter) + counter * bounds.groupBarWidth * (1 + groupGutter) * !stacked + 1)\n                    });\n                }\n                if (height < 0) {\n                    if (column) {\n                        barAttr.y = top;\n                        barAttr.height = mabs(height);\n                    } else {\n                        barAttr.x = top + height;\n                        barAttr.width = mabs(height);\n                    }\n                }\n                if (stacked) {\n                    if (height < 0) {\n                        top += height * (column ? -1 : 1);\n                    } else {\n                        bottom += height * (column ? -1 : 1);\n                    }\n                    totalDim += mabs(height);\n                    if (height < 0) {\n                        totalNegDim += mabs(height);\n                    }\n                }\n                barAttr.x = Math.floor(barAttr.x) + 1;\n                floorY = Math.floor(barAttr.y);\n                if (!Ext.isIE9 && barAttr.y > floorY) {\n                    floorY--;\n                }\n                barAttr.y = floorY;\n                barAttr.width = Math.floor(barAttr.width);\n                barAttr.height = Math.floor(barAttr.height);\n                items.push({\n                    series: me,\n                    yField: yFields[j],\n                    storeItem: record,\n                    value: [record.get(me.xField), yValue],\n                    attr: barAttr,\n                    point: column ? [barAttr.x + barAttr.width / 2, yValue >= 0 ? barAttr.y : barAttr.y + barAttr.height] :\n                                    [yValue >= 0 ? barAttr.x + barAttr.width : barAttr.x, barAttr.y + barAttr.height / 2]\n                });\n                // When resizing, reset before animating\n                if (animate && chart.resizing) {\n                    attrs = column ? {\n                        x: barAttr.x,\n                        y: bounds.zero,\n                        width: barAttr.width,\n                        height: 0\n                    } : {\n                        x: bounds.zero,\n                        y: barAttr.y,\n                        width: 0,\n                        height: barAttr.height\n                    };\n                    if (enableShadows && (stacked && !hasShadow || !stacked)) {\n                        hasShadow = true;\n                        //update shadows\n                        for (shadowIndex = 0; shadowIndex < shadowGroupsLn; shadowIndex++) {\n                            shadow = shadowGroups[shadowIndex].getAt(stacked ? i : (i * barsLen + j));\n                            if (shadow) {\n                                shadow.setAttributes(attrs, true);\n                            }\n                        }\n                    }\n                    //update sprite position and width/height\n                    sprite = group.getAt(i * barsLen + j);\n                    if (sprite) {\n                        sprite.setAttributes(attrs, true);\n                    }\n                }\n                counter++;\n            }\n            if (stacked && items.length) {\n                items[i * counter].totalDim = totalDim;\n                items[i * counter].totalNegDim = totalNegDim;\n            }\n        }\n        if (stacked && counter == 0) {\n            // Remove ghost shadow ref: EXTJSIV-5982\n            for (i = 0, total = data.length; i < total; i++) {\n                for (shadowIndex = 0; shadowIndex < shadowGroupsLn; shadowIndex++) {\n                    shadow = shadowGroups[shadowIndex].getAt(i);\n                    if (shadow) {\n                        shadow.hide(true);\n                    }\n                }\n            }\n        }\n    },\n\n    // @private render/setAttributes on the shadows\n    renderShadows: function(i, barAttr, baseAttrs, bounds) {\n        var me = this,\n            chart = me.chart,\n            surface = chart.surface,\n            animate = chart.animate,\n            stacked = me.stacked,\n            shadowGroups = me.shadowGroups,\n            shadowAttributes = me.shadowAttributes,\n            shadowGroupsLn = shadowGroups.length,\n            store = chart.getChartStore(),\n            column = me.column,\n            items = me.items,\n            shadows = [],\n            zero = bounds.zero,\n            shadowIndex, shadowBarAttr, shadow, totalDim, totalNegDim, j, rendererAttributes;\n\n        if ((stacked && (i % bounds.groupBarsLen === 0)) || !stacked) {\n            j = i / bounds.groupBarsLen;\n            //create shadows\n            for (shadowIndex = 0; shadowIndex < shadowGroupsLn; shadowIndex++) {\n                shadowBarAttr = Ext.apply({}, shadowAttributes[shadowIndex]);\n                shadow = shadowGroups[shadowIndex].getAt(stacked ? j : i);\n                Ext.copyTo(shadowBarAttr, barAttr, 'x,y,width,height');\n                if (!shadow) {\n                    shadow = surface.add(Ext.apply({\n                        type: 'rect',\n                        group: shadowGroups[shadowIndex]\n                    }, Ext.apply({}, baseAttrs, shadowBarAttr)));\n                }\n                if (stacked) {\n                    totalDim = items[i].totalDim;\n                    totalNegDim = items[i].totalNegDim;\n                    if (column) {\n                        shadowBarAttr.y = zero + totalNegDim - totalDim - 1;\n                        shadowBarAttr.height = totalDim;\n                    }\n                    else {\n                        shadowBarAttr.x = zero - totalNegDim;\n                        shadowBarAttr.width = totalDim;\n                    }\n                }\n                \n                rendererAttributes = me.renderer(shadow, store.getAt(j), shadowBarAttr, i, store);\n                rendererAttributes.hidden = !!barAttr.hidden;\n                if (animate) {\n                    me.onAnimate(shadow, { to: rendererAttributes });\n                }\n                else {\n                    shadow.setAttributes(rendererAttributes, true);\n                }\n                shadows.push(shadow);\n            }\n        }\n        return shadows;\n    },\n\n    /**\n     * Draws the series for the current chart.\n     */\n    drawSeries: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            surface = chart.surface,\n            animate = chart.animate,\n            stacked = me.stacked,\n            column = me.column,\n            enableShadows = chart.shadow,\n            shadowGroups = me.shadowGroups,\n            shadowGroupsLn = shadowGroups.length,\n            group = me.group,\n            seriesStyle = me.seriesStyle,\n            items, ln, i, j, baseAttrs, sprite, rendererAttributes, shadowIndex, shadowGroup,\n            bounds, endSeriesStyle, barAttr, attrs, anim;\n\n        if (!store || !store.getCount() || me.seriesIsHidden) {\n            me.hide();\n            me.items = [];\n            return;\n        }\n\n        //fill colors are taken from the colors array.\n        endSeriesStyle = Ext.apply({}, this.style, seriesStyle);\n        delete endSeriesStyle.fill;\n        delete endSeriesStyle.x;\n        delete endSeriesStyle.y;\n        delete endSeriesStyle.width;\n        delete endSeriesStyle.height;\n        \n        me.unHighlightItem();\n        me.cleanHighlights();\n        \n        me.getPaths();\n        bounds = me.bounds;\n        items = me.items;\n\n        baseAttrs = column ? {\n            y: bounds.zero,\n            height: 0\n        } : {\n            x: bounds.zero,\n            width: 0\n        };\n        ln = items.length;\n        // Create new or reuse sprites and animate/display\n        for (i = 0; i < ln; i++) {\n            sprite = group.getAt(i);\n            barAttr = items[i].attr;\n\n            if (enableShadows) {\n                items[i].shadows = me.renderShadows(i, barAttr, baseAttrs, bounds);\n            }\n\n            // Create a new sprite if needed (no height)\n            if (!sprite) {\n                attrs = Ext.apply({}, baseAttrs, barAttr);\n                attrs = Ext.apply(attrs, endSeriesStyle || {});\n                sprite = surface.add(Ext.apply({}, {\n                    type: 'rect',\n                    group: group\n                }, attrs));\n            }\n            if (animate) {\n                rendererAttributes = me.renderer(sprite, store.getAt(i), barAttr, i, store);\n                sprite._to = rendererAttributes;\n                anim = me.onAnimate(sprite, { to: Ext.apply(rendererAttributes, endSeriesStyle) });\n                if (enableShadows && stacked && (i % bounds.barsLen === 0)) {\n                    j = i / bounds.barsLen;\n                    for (shadowIndex = 0; shadowIndex < shadowGroupsLn; shadowIndex++) {\n                        anim.on('afteranimate', function() {\n                            this.show(true);\n                        }, shadowGroups[shadowIndex].getAt(j));\n                    }\n                }\n            }\n            else {\n                rendererAttributes = me.renderer(sprite, store.getAt(i), Ext.apply(barAttr, { hidden: false }), i, store);\n                sprite.setAttributes(Ext.apply(rendererAttributes, endSeriesStyle), true);\n            }\n            items[i].sprite = sprite;\n        }\n\n        // Hide unused sprites\n        ln = group.getCount();\n        for (j = i; j < ln; j++) {\n            group.getAt(j).hide(true);\n        }\n        \n        if (me.stacked) {\n            // If stacked, we have only store.getCount() shadows.\n            i = store.getCount();    \n        }\n        \n        // Hide unused shadows\n        if (enableShadows) {\n            for (shadowIndex = 0; shadowIndex < shadowGroupsLn; shadowIndex++) {\n                shadowGroup = shadowGroups[shadowIndex];\n                ln = shadowGroup.getCount();\n                for (j = i; j < ln; j++) {\n                    shadowGroup.getAt(j).hide(true);\n                }\n            }\n        }\n        me.renderLabels();\n    },\n\n    // @private handled when creating a label.\n    onCreateLabel: function(storeItem, item, i, display) {\n        var me = this,\n            surface = me.chart.surface,\n            group = me.labelsGroup,\n            config = me.label,\n            endLabelStyle = Ext.apply({}, config, me.seriesLabelStyle || {}),\n            sprite;\n        return surface.add(Ext.apply({\n            type: 'text',\n            group: group\n        }, endLabelStyle || {}));\n    },\n\n    // @private callback used when placing a label.\n    onPlaceLabel: function(label, storeItem, item, i, display, animate, j, index) {\n        // Determine the label's final position. Starts with the configured preferred value but\n        // may get flipped from inside to outside or vice-versa depending on space.\n        var me = this,\n            opt = me.bounds,\n            groupBarWidth = opt.groupBarWidth,\n            column = me.column,\n            chart = me.chart,\n            chartBBox = chart.chartBBox,\n            resizing = chart.resizing,\n            xValue = item.value[0],\n            yValue = item.value[1],\n            attr = item.attr,\n            config = me.label,\n            rotate = config.orientation == 'vertical',\n            field = [].concat(config.field),\n            format = config.renderer,\n            text = format(storeItem.get(field[index])),\n            size = me.getLabelSize(text),\n            width = size.width,\n            height = size.height,\n            zero = opt.zero,\n            outside = 'outside',\n            insideStart = 'insideStart',\n            insideEnd = 'insideEnd',\n            offsetX = 10,\n            offsetY = 6,\n            signed = opt.signed,\n            x, y, finalAttr;\n\n        label.setAttributes({\n            text: text\n        });\n\n        label.isOutside = false;\n        if (column) {\n            if (display == outside) {\n                if (height + offsetY + attr.height > (yValue >= 0 ? zero - chartBBox.y : chartBBox.y + chartBBox.height - zero)) {\n                    display = insideEnd;\n                }\n            } else {\n                if (height + offsetY > attr.height) {\n                    display = outside;\n                    label.isOutside = true;\n                }\n            }\n            x = attr.x + groupBarWidth / 2;\n            y = display == insideStart ?\n                    (zero + ((height / 2 + 3) * (yValue >= 0 ? -1 : 1))) :\n                    (yValue >= 0 ? (attr.y + ((height / 2 + 3) * (display == outside ? -1 : 1))) :\n                                   (attr.y + attr.height + ((height / 2 + 3) * (display === outside ? 1 : -1))));\n        }\n        else {\n            if (display == outside) {\n                if (width + offsetX + attr.width > (yValue >= 0 ? chartBBox.x + chartBBox.width - zero : zero - chartBBox.x)) {\n                    display = insideEnd;\n                }\n            }\n            else {\n                if (width + offsetX > attr.width) {\n                    display = outside;\n                    label.isOutside = true;\n                }\n            }\n            x = display == insideStart ?\n                (zero + ((width / 2 + 5) * (yValue >= 0 ? 1 : -1))) :\n                (yValue >= 0 ? (attr.x + attr.width + ((width / 2 + 5) * (display === outside ? 1 : -1))) :\n                (attr.x + ((width / 2 + 5) * (display === outside ? -1 : 1))));\n            y = attr.y + groupBarWidth / 2;\n        }\n        //set position\n        finalAttr = {\n            x: x,\n            y: y\n        };\n        //rotate\n        if (rotate) {\n            finalAttr.rotate = {\n                x: x,\n                y: y,\n                degrees: 270\n            };\n        }\n        //check for resizing\n        if (animate && resizing) {\n            if (column) {\n                x = attr.x + attr.width / 2;\n                y = zero;\n            } else {\n                x = zero;\n                y = attr.y + attr.height / 2;\n            }\n            label.setAttributes({\n                x: x,\n                y: y\n            }, true);\n            if (rotate) {\n                label.setAttributes({\n                    rotate: {\n                        x: x,\n                        y: y,\n                        degrees: 270\n                    }\n                }, true);\n            }\n        }\n        //handle animation\n        if (animate) {\n            me.onAnimate(label, { to: finalAttr });\n        }\n        else {\n            label.setAttributes(Ext.apply(finalAttr, {\n                hidden: false\n            }), true);\n        }\n    },\n\n    /* @private\n     * Gets the dimensions of a given bar label. Uses a single hidden sprite to avoid\n     * changing visible sprites.\n     * @param value\n     */\n    getLabelSize: function(value) {\n        var tester = this.testerLabel,\n            config = this.label,\n            endLabelStyle = Ext.apply({}, config, this.seriesLabelStyle || {}),\n            rotated = config.orientation === 'vertical',\n            bbox, w, h,\n            undef;\n        if (!tester) {\n            tester = this.testerLabel = this.chart.surface.add(Ext.apply({\n                type: 'text',\n                opacity: 0\n            }, endLabelStyle));\n        }\n        tester.setAttributes({\n            text: value\n        }, true);\n\n        // Flip the width/height if rotated, as getBBox returns the pre-rotated dimensions\n        bbox = tester.getBBox();\n        w = bbox.width;\n        h = bbox.height;\n        return {\n            width: rotated ? h : w,\n            height: rotated ? w : h\n        };\n    },\n\n    // @private used to animate label, markers and other sprites.\n    onAnimate: function(sprite, attr) {\n        sprite.show();\n        return this.callParent(arguments);\n    },\n\n    isItemInPoint: function(x, y, item) {\n        var bbox = item.sprite.getBBox();\n        return bbox.x <= x && bbox.y <= y\n            && (bbox.x + bbox.width) >= x\n            && (bbox.y + bbox.height) >= y;\n    },\n\n    // @private hide all markers\n    hideAll: function(index) {\n        var axes      = this.chart.axes,\n            axesItems = axes.items,\n            ln        = axesItems.length,\n            i         = 0;\n\n        index = (isNaN(this._index) ? index : this._index) || 0;\n\n        if (!this.__excludes) {\n            this.__excludes = [];\n        }\n\n        this.__excludes[index] = true;\n        this.drawSeries();\n\n        for (i; i < ln; i++) {\n            axesItems[i].drawAxis();\n        }    \n    },\n\n    // @private show all markers\n    showAll: function(index) {\n        var axes = this.chart.axes,\n            axesItems = axes.items,\n            ln        = axesItems.length,\n            i         = 0;\n\n        index = (isNaN(this._index) ? index : this._index) || 0;\n\n        if (!this.__excludes) {\n            this.__excludes = [];\n        }\n\n        this.__excludes[index] = false;\n        this.drawSeries();\n\n        for (i; i < ln; i++) {\n            axesItems[i].drawAxis();\n        }    \n    },\n\n    /**\n     * Returns a string with the color to be used for the series legend item.\n     * @param index\n     */\n    getLegendColor: function(index) {\n        var me = this,\n            colorLength = me.colorArrayStyle.length;\n\n        if (me.style && me.style.fill) {\n            return me.style.fill;\n        } else {\n            return me.colorArrayStyle[index % colorLength];\n        }\n    },\n\n    highlightItem: function(item) {\n        this.callParent(arguments);\n        this.renderLabels();\n    },\n\n    unHighlightItem: function() {\n        this.callParent(arguments);\n        this.renderLabels();\n    },\n\n    cleanHighlights: function() {\n        this.callParent(arguments);\n        this.renderLabels();\n    }\n});\n\n/**\n * @class Ext.chart.series.Column\n *\n * Creates a Column Chart. Much of the methods are inherited from Bar. A Column Chart is a useful\n * visualization technique to display quantitative information for different categories that can\n * show some progression (or regression) in the data set. As with all other series, the Column Series\n * must be appended in the *series* Chart array configuration. See the Chart documentation for more\n * information. A typical configuration object for the column series could be:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data'],\n *         data: [\n *             { 'name': 'metric one',   'data':10 },\n *             { 'name': 'metric two',   'data': 7 },\n *             { 'name': 'metric three', 'data': 5 },\n *             { 'name': 'metric four',  'data': 2 },\n *             { 'name': 'metric five',  'data':27 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         animate: true,\n *         store: store,\n *         axes: [\n *             {\n *                 type: 'Numeric',\n *                 position: 'left',\n *                 fields: ['data'],\n *                 label: {\n *                     renderer: Ext.util.Format.numberRenderer('0,0')\n *                 },\n *                 title: 'Sample Values',\n *                 grid: true,\n *                 minimum: 0\n *             },\n *             {\n *                 type: 'Category',\n *                 position: 'bottom',\n *                 fields: ['name'],\n *                 title: 'Sample Metrics'\n *             }\n *         ],\n *         series: [\n *             {\n *                 type: 'column',\n *                 axis: 'left',\n *                 highlight: true,\n *                 tips: {\n *                   trackMouse: true,\n *                   width: 140,\n *                   height: 28,\n *                   renderer: function(storeItem, item) {\n *                     this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data') + ' $');\n *                   }\n *                 },\n *                 label: {\n *                   display: 'insideEnd',\n *                   'text-anchor': 'middle',\n *                     field: 'data',\n *                     renderer: Ext.util.Format.numberRenderer('0'),\n *                     orientation: 'vertical',\n *                     color: '#333'\n *                 },\n *                 xField: 'name',\n *                 yField: 'data'\n *             }\n *         ]\n *     });\n *\n * In this configuration we set `column` as the series type, bind the values of the bars to the bottom axis,\n * set `highlight` to true so that bars are smoothly highlighted when hovered and bind the `xField` or category\n * field to the data store `name` property and the `yField` as the data1 property of a store element.\n */\nExt.define('Ext.chart.series.Column', {\n\n    /* Begin Definitions */\n\n    alternateClassName: ['Ext.chart.ColumnSeries', 'Ext.chart.ColumnChart', 'Ext.chart.StackedColumnChart'],\n\n    extend: 'Ext.chart.series.Bar',\n\n    /* End Definitions */\n\n    type: 'column',\n    alias: 'series.column',\n\n    column: true,\n\n    /**\n     * @cfg {Number} xPadding\n     * Padding between the left/right axes and the bars\n     */\n    xPadding: 10,\n\n    /**\n     * @cfg {Number} yPadding\n     * Padding between the top/bottom axes and the bars\n     */\n    yPadding: 0\n});\n\n/**\n * @class Ext.chart.series.Gauge\n * \n * Creates a Gauge Chart. Gauge Charts are used to show progress in a certain variable. There are two ways of using the Gauge chart.\n * One is setting a store element into the Gauge and selecting the field to be used from that store. Another one is instantiating the\n * visualization and using the `setValue` method to adjust the value you want.\n *\n * An example of Gauge visualization:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['data'],\n *         data: [\n *             { 'value':80 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         store: store,\n *         width: 400,\n *         height: 250,\n *         animate: true,\n *         insetPadding: 30,\n *         axes: [{\n *             type: 'gauge',\n *             position: 'gauge',\n *             minimum: 0,\n *             maximum: 100,\n *             steps: 10,\n *             margin: 10\n *         }],\n *         series: [{\n *             type: 'gauge',\n *             field: 'value',\n *             donut: 30,\n *             colorSet: ['#F49D10', '#ddd']\n *         }]\n *     });\n *\n *     Ext.widget(\"button\", {\n *         renderTo: Ext.getBody(),\n *         text: \"Refresh\",\n *         handler: function() {\n *             store.getAt(0).set('value', Math.round(Math.random()*100));\n *         }\n *     });\n * \n * In this example we create a special Gauge axis to be used with the gauge visualization (describing half-circle markers), and also we're\n * setting a maximum, minimum and steps configuration options into the axis. The Gauge series configuration contains the store field to be bound to\n * the visual display and the color set to be used with the visualization.\n * \n * @xtype gauge\n */\nExt.define('Ext.chart.series.Gauge', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.series.Series',\n\n    /* End Definitions */\n\n    type: \"gauge\",\n    alias: 'series.gauge',\n\n    rad: Math.PI / 180,\n\n    /**\n     * @cfg {Number} highlightDuration\n     * The duration for the pie slice highlight effect.\n     */\n    highlightDuration: 150,\n\n    /**\n     * @cfg {String} angleField (required)\n     * The store record field name to be used for the pie angles.\n     * The values bound to this field name must be positive real numbers.\n     */\n    angleField: false,\n\n    /**\n     * @cfg {Boolean} needle\n     * Use the Gauge Series as an area series or add a needle to it. Default's false.\n     */\n    needle: false,\n    \n    /**\n     * @cfg {Boolean/Number} donut\n     * Use the entire disk or just a fraction of it for the gauge. Default's false.\n     */\n    donut: false,\n\n    /**\n     * @cfg {Boolean} showInLegend\n     * Whether to add the pie chart elements as legend items. Default's false.\n     */\n    showInLegend: false,\n\n    /**\n     * @cfg {Object} style\n     * An object containing styles for overriding series styles from Theming.\n     */\n    style: {},\n    \n    constructor: function(config) {\n        this.callParent(arguments);\n        var me = this,\n            chart = me.chart,\n            surface = chart.surface,\n            store = chart.store,\n            shadow = chart.shadow, i, l, cfg;\n        Ext.apply(me, config, {\n            shadowAttributes: [{\n                \"stroke-width\": 6,\n                \"stroke-opacity\": 1,\n                stroke: 'rgb(200, 200, 200)',\n                translate: {\n                    x: 1.2,\n                    y: 2\n                }\n            },\n            {\n                \"stroke-width\": 4,\n                \"stroke-opacity\": 1,\n                stroke: 'rgb(150, 150, 150)',\n                translate: {\n                    x: 0.9,\n                    y: 1.5\n                }\n            },\n            {\n                \"stroke-width\": 2,\n                \"stroke-opacity\": 1,\n                stroke: 'rgb(100, 100, 100)',\n                translate: {\n                    x: 0.6,\n                    y: 1\n                }\n            }]\n        });\n        me.group = surface.getGroup(me.seriesId);\n        if (shadow) {\n            for (i = 0, l = me.shadowAttributes.length; i < l; i++) {\n                me.shadowGroups.push(surface.getGroup(me.seriesId + '-shadows' + i));\n            }\n        }\n        surface.customAttributes.segment = function(opt) {\n            return me.getSegment(opt);\n        };\n    },\n    \n    // @private updates some onbefore render parameters.\n    initialize: function() {\n        var me = this,\n            store = me.chart.getChartStore(),\n            data = store.data.items,\n            i, ln, rec;\n        //Add yFields to be used in Legend.js\n        me.yField = [];\n        if (me.label.field) {\n            for (i = 0, ln = data.length; i < ln; i++) {\n                rec = data[i];\n                me.yField.push(rec.get(me.label.field));\n            }\n        }\n    },\n\n    // @private returns an object with properties for a Slice\n    getSegment: function(opt) {\n        var me = this,\n            rad = me.rad,\n            cos = Math.cos,\n            sin = Math.sin,\n            abs = Math.abs,\n            x = me.centerX,\n            y = me.centerY,\n            x1 = 0, x2 = 0, x3 = 0, x4 = 0,\n            y1 = 0, y2 = 0, y3 = 0, y4 = 0,\n            delta = 1e-2,\n            r = opt.endRho - opt.startRho,\n            startAngle = opt.startAngle,\n            endAngle = opt.endAngle,\n            midAngle = (startAngle + endAngle) / 2 * rad,\n            margin = opt.margin || 0,\n            flag = abs(endAngle - startAngle) > 180,\n            a1 = Math.min(startAngle, endAngle) * rad,\n            a2 = Math.max(startAngle, endAngle) * rad,\n            singleSlice = false;\n\n        x += margin * cos(midAngle);\n        y += margin * sin(midAngle);\n\n        x1 = x + opt.startRho * cos(a1);\n        y1 = y + opt.startRho * sin(a1);\n\n        x2 = x + opt.endRho * cos(a1);\n        y2 = y + opt.endRho * sin(a1);\n\n        x3 = x + opt.startRho * cos(a2);\n        y3 = y + opt.startRho * sin(a2);\n\n        x4 = x + opt.endRho * cos(a2);\n        y4 = y + opt.endRho * sin(a2);\n\n        if (abs(x1 - x3) <= delta && abs(y1 - y3) <= delta) {\n            singleSlice = true;\n        }\n        //Solves mysterious clipping bug with IE\n        if (singleSlice) {\n            return {\n                path: [\n                [\"M\", x1, y1],\n                [\"L\", x2, y2],\n                [\"A\", opt.endRho, opt.endRho, 0, +flag, 1, x4, y4],\n                [\"Z\"]]\n            };\n        } else {\n            return {\n                path: [\n                [\"M\", x1, y1],\n                [\"L\", x2, y2],\n                [\"A\", opt.endRho, opt.endRho, 0, +flag, 1, x4, y4],\n                [\"L\", x3, y3],\n                [\"A\", opt.startRho, opt.startRho, 0, +flag, 0, x1, y1],\n                [\"Z\"]]\n            };\n        }\n    },\n\n    // @private utility function to calculate the middle point of a pie slice.\n    calcMiddle: function(item) {\n        var me = this,\n            rad = me.rad,\n            slice = item.slice,\n            x = me.centerX,\n            y = me.centerY,\n            startAngle = slice.startAngle,\n            endAngle = slice.endAngle,\n            radius = Math.max(('rho' in slice) ? slice.rho: me.radius, me.label.minMargin),\n            donut = +me.donut,\n            a1 = Math.min(startAngle, endAngle) * rad,\n            a2 = Math.max(startAngle, endAngle) * rad,\n            midAngle = -(a1 + (a2 - a1) / 2),\n            xm = x + (item.endRho + item.startRho) / 2 * Math.cos(midAngle),\n            ym = y - (item.endRho + item.startRho) / 2 * Math.sin(midAngle);\n\n        item.middle = {\n            x: xm,\n            y: ym\n        };\n    },\n\n    /**\n     * Draws the series for the current chart.\n     */\n    drawSeries: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            group = me.group,\n            animate = me.chart.animate,\n            axis = me.chart.axes.get(0),\n            minimum = axis && axis.minimum || me.minimum || 0,\n            maximum = axis && axis.maximum || me.maximum || 0,\n            field = me.angleField || me.field || me.xField,\n            surface = chart.surface,\n            chartBBox = chart.chartBBox,\n            rad = me.rad,\n            donut = +me.donut,\n            values = {},\n            items = [],\n            seriesStyle = me.seriesStyle,\n            seriesLabelStyle = me.seriesLabelStyle,\n            colorArrayStyle = me.colorArrayStyle,\n            colorArrayLength = colorArrayStyle && colorArrayStyle.length || 0,\n            gutterX = chart.maxGutter[0],\n            gutterY = chart.maxGutter[1],\n            cos = Math.cos,\n            sin = Math.sin,\n            rendererAttributes, centerX, centerY, slice, slices, sprite, value,\n            item, ln, record, i, j, startAngle, endAngle, middleAngle, sliceLength, path,\n            p, spriteOptions, bbox, splitAngle, sliceA, sliceB;\n        \n        Ext.apply(seriesStyle, me.style || {});\n\n        me.setBBox();\n        bbox = me.bbox;\n\n        //override theme colors\n        if (me.colorSet) {\n            colorArrayStyle = me.colorSet;\n            colorArrayLength = colorArrayStyle.length;\n        }\n        \n        //if not store or store is empty then there's nothing to draw\n        if (!store || !store.getCount() || me.seriesIsHidden) {\n            me.hide();\n            me.items = [];\n            return;\n        }\n        \n        centerX = me.centerX = chartBBox.x + (chartBBox.width / 2);\n        centerY = me.centerY = chartBBox.y + chartBBox.height;\n        me.radius = Math.min(centerX - chartBBox.x, centerY - chartBBox.y);\n        me.slices = slices = [];\n        me.items = items = [];\n        \n        if (!me.value) {\n            record = store.getAt(0);\n            me.value = record.get(field);\n        }\n        \n        value = me.value;\n        if (me.needle) {\n            sliceA = {\n                series: me,\n                value: value,\n                startAngle: -180,\n                endAngle: 0,\n                rho: me.radius\n            };\n            splitAngle = -180 * (1 - (value - minimum) / (maximum - minimum));\n            slices.push(sliceA);\n        } else {\n            splitAngle = -180 * (1 - (value - minimum) / (maximum - minimum));\n            sliceA = {\n                series: me,\n                value: value,\n                startAngle: -180,\n                endAngle: splitAngle,\n                rho: me.radius\n            };\n            sliceB = {\n                series: me,\n                value: me.maximum - value,\n                startAngle: splitAngle,\n                endAngle: 0,\n                rho: me.radius\n            };\n            slices.push(sliceA, sliceB);\n        }\n        \n        //do pie slices after.\n        for (i = 0, ln = slices.length; i < ln; i++) {\n            slice = slices[i];\n            sprite = group.getAt(i);\n            //set pie slice properties\n            rendererAttributes = Ext.apply({\n                segment: {\n                    startAngle: slice.startAngle,\n                    endAngle: slice.endAngle,\n                    margin: 0,\n                    rho: slice.rho,\n                    startRho: slice.rho * +donut / 100,\n                    endRho: slice.rho\n                } \n            }, Ext.apply(seriesStyle, colorArrayStyle && { fill: colorArrayStyle[i % colorArrayLength] } || {}));\n\n            item = Ext.apply({},\n            rendererAttributes.segment, {\n                slice: slice,\n                series: me,\n                storeItem: record,\n                index: i\n            });\n            items[i] = item;\n            // Create a new sprite if needed (no height)\n            if (!sprite) {\n                spriteOptions = Ext.apply({\n                    type: \"path\",\n                    group: group\n                }, Ext.apply(seriesStyle, colorArrayStyle && { fill: colorArrayStyle[i % colorArrayLength] } || {}));\n                sprite = surface.add(Ext.apply(spriteOptions, rendererAttributes));\n            }\n            slice.sprite = slice.sprite || [];\n            item.sprite = sprite;\n            slice.sprite.push(sprite);\n            if (animate) {\n                rendererAttributes = me.renderer(sprite, record, rendererAttributes, i, store);\n                sprite._to = rendererAttributes;\n                me.onAnimate(sprite, {\n                    to: rendererAttributes\n                });\n            } else {\n                rendererAttributes = me.renderer(sprite, record, Ext.apply(rendererAttributes, {\n                    hidden: false\n                }), i, store);\n                sprite.setAttributes(rendererAttributes, true);\n            }\n        }\n        \n        if (me.needle) {\n            splitAngle = splitAngle * Math.PI / 180;\n            \n            if (!me.needleSprite) {\n                me.needleSprite = me.chart.surface.add({\n                    type: 'path',\n                    path: ['M', centerX + (me.radius * +donut / 100) * cos(splitAngle),\n                                centerY + -Math.abs((me.radius * +donut / 100) * sin(splitAngle)),\n                           'L', centerX + me.radius * cos(splitAngle),\n                                centerY + -Math.abs(me.radius * sin(splitAngle))],\n                    'stroke-width': 4,\n                    'stroke': '#222'\n                });\n            } else {\n                if (animate) {\n                    me.onAnimate(me.needleSprite, {\n                        to: {\n                        path: ['M', centerX + (me.radius * +donut / 100) * cos(splitAngle),\n                                    centerY + -Math.abs((me.radius * +donut / 100) * sin(splitAngle)),\n                               'L', centerX + me.radius * cos(splitAngle),\n                                    centerY + -Math.abs(me.radius * sin(splitAngle))]\n                        }\n                    });\n                } else {\n                    me.needleSprite.setAttributes({\n                        type: 'path',\n                        path: ['M', centerX + (me.radius * +donut / 100) * cos(splitAngle),\n                                    centerY + -Math.abs((me.radius * +donut / 100) * sin(splitAngle)),\n                               'L', centerX + me.radius * cos(splitAngle),\n                                    centerY + -Math.abs(me.radius * sin(splitAngle))]\n                    });\n                }\n            }\n            me.needleSprite.setAttributes({\n                hidden: false    \n            }, true);\n        }\n        \n        delete me.value;\n    },\n    \n    /**\n     * Sets the Gauge chart to the current specified value.\n    */\n    setValue: function (value) {\n        this.value = value;\n        this.drawSeries();\n    },\n\n    // @private callback for when creating a label sprite.\n    onCreateLabel: function(storeItem, item, i, display) {},\n\n    // @private callback for when placing a label sprite.\n    onPlaceLabel: function(label, storeItem, item, i, display, animate, index) {},\n\n    // @private callback for when placing a callout.\n    onPlaceCallout: function() {},\n\n    // @private handles sprite animation for the series.\n    onAnimate: function(sprite, attr) {\n        sprite.show();\n        return this.callParent(arguments);\n    },\n\n    isItemInPoint: function(x, y, item, i) {\n        var me = this,\n            cx = me.centerX,\n            cy = me.centerY,\n            abs = Math.abs,\n            dx = abs(x - cx),\n            dy = abs(y - cy),\n            startAngle = item.startAngle,\n            endAngle = item.endAngle,\n            rho = Math.sqrt(dx * dx + dy * dy),\n            angle = Math.atan2(y - cy, x - cx) / me.rad;\n\n        //Only trigger events for the filled portion of the Gauge.\n        return (i === 0) && (angle >= startAngle && angle < endAngle && \n                             rho >= item.startRho && rho <= item.endRho);\n    },\n    \n    // @private shows all elements in the series.\n    showAll: function() {\n        if (!isNaN(this._index)) {\n            this.__excludes[this._index] = false;\n            this.drawSeries();\n        }\n    },\n    \n    /**\n     * Returns the color of the series (to be displayed as color for the series legend item).\n     * @param item {Object} Info about the item; same format as returned by #getItemForPoint\n     */\n    getLegendColor: function(index) {\n        var me = this;\n        return me.colorArrayStyle[index % me.colorArrayStyle.length];\n    }\n});\n\n\n/**\n * @class Ext.chart.series.Line\n * @extends Ext.chart.series.Cartesian\n *\n * Creates a Line Chart. A Line Chart is a useful visualization technique to display quantitative information for different\n * categories or other real values (as opposed to the bar chart), that can show some progression (or regression) in the dataset.\n * As with all other series, the Line Series must be appended in the *series* Chart array configuration. See the Chart\n * documentation for more information. A typical configuration object for the line series could be:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],\n *         data: [\n *             { 'name': 'metric one',   'data1': 10, 'data2': 12, 'data3': 14, 'data4': 8,  'data5': 13 },\n *             { 'name': 'metric two',   'data1': 7,  'data2': 8,  'data3': 16, 'data4': 10, 'data5': 3  },\n *             { 'name': 'metric three', 'data1': 5,  'data2': 2,  'data3': 14, 'data4': 12, 'data5': 7  },\n *             { 'name': 'metric four',  'data1': 2,  'data2': 14, 'data3': 6,  'data4': 1,  'data5': 23 },\n *             { 'name': 'metric five',  'data1': 4,  'data2': 4,  'data3': 36, 'data4': 13, 'data5': 33 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         animate: true,\n *         store: store,\n *         axes: [\n *             {\n *                 type: 'Numeric',\n *                 position: 'left',\n *                 fields: ['data1', 'data2'],\n *                 label: {\n *                     renderer: Ext.util.Format.numberRenderer('0,0')\n *                 },\n *                 title: 'Sample Values',\n *                 grid: true,\n *                 minimum: 0\n *             },\n *             {\n *                 type: 'Category',\n *                 position: 'bottom',\n *                 fields: ['name'],\n *                 title: 'Sample Metrics'\n *             }\n *         ],\n *         series: [\n *             {\n *                 type: 'line',\n *                 highlight: {\n *                     size: 7,\n *                     radius: 7\n *                 },\n *                 axis: 'left',\n *                 xField: 'name',\n *                 yField: 'data1',\n *                 markerConfig: {\n *                     type: 'cross',\n *                     size: 4,\n *                     radius: 4,\n *                     'stroke-width': 0\n *                 }\n *             },\n *             {\n *                 type: 'line',\n *                 highlight: {\n *                     size: 7,\n *                     radius: 7\n *                 },\n *                 axis: 'left',\n *                 fill: true,\n *                 xField: 'name',\n *                 yField: 'data2',\n *                 markerConfig: {\n *                     type: 'circle',\n *                     size: 4,\n *                     radius: 4,\n *                     'stroke-width': 0\n *                 }\n *             }\n *         ]\n *     });\n *\n * In this configuration we're adding two series (or lines), one bound to the `data1`\n * property of the store and the other to `data3`. The type for both configurations is\n * `line`. The `xField` for both series is the same, the name propert of the store.\n * Both line series share the same axis, the left axis. You can set particular marker\n * configuration by adding properties onto the markerConfig object. Both series have\n * an object as highlight so that markers animate smoothly to the properties in highlight\n * when hovered. The second series has `fill=true` which means that the line will also\n * have an area below it of the same color.\n *\n * **Note:** In the series definition remember to explicitly set the axis to bind the\n * values of the line series to. This can be done by using the `axis` configuration property.\n */\nExt.define('Ext.chart.series.Line', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.series.Cartesian',\n\n    alternateClassName: ['Ext.chart.LineSeries', 'Ext.chart.LineChart'],\n\n    requires: ['Ext.chart.axis.Axis', 'Ext.chart.Shape', 'Ext.draw.Draw', 'Ext.fx.Anim'],\n\n    /* End Definitions */\n\n    type: 'line',\n\n    alias: 'series.line',\n\n    /**\n     * @cfg {String} axis\n     * The position of the axis to bind the values to. Possible values are 'left', 'bottom', 'top' and 'right'.\n     * You must explicitly set this value to bind the values of the line series to the ones in the axis, otherwise a\n     * relative scale will be used.\n     */\n\n    /**\n     * @cfg {Number} selectionTolerance\n     * The offset distance from the cursor position to the line series to trigger events (then used for highlighting series, etc).\n     */\n    selectionTolerance: 20,\n\n    /**\n     * @cfg {Boolean} showMarkers\n     * Whether markers should be displayed at the data points along the line. If true,\n     * then the {@link #markerConfig} config item will determine the markers' styling.\n     */\n    showMarkers: true,\n\n    /**\n     * @cfg {Object} markerConfig\n     * The display style for the markers. Only used if {@link #showMarkers} is true.\n     * The markerConfig is a configuration object containing the same set of properties defined in\n     * the Sprite class. For example, if we were to set red circles as markers to the line series we could\n     * pass the object:\n     *\n     <pre><code>\n        markerConfig: {\n            type: 'circle',\n            radius: 4,\n            'fill': '#f00'\n        }\n     </code></pre>\n\n     */\n    markerConfig: {},\n\n    /**\n     * @cfg {Object} style\n     * An object containing style properties for the visualization lines and fill.\n     * These styles will override the theme styles.  The following are valid style properties:\n     *\n     * - `stroke` - an rgb or hex color string for the background color of the line\n     * - `stroke-width` - the width of the stroke (integer)\n     * - `fill` - the background fill color string (hex or rgb), only works if {@link #fill} is `true`\n     * - `opacity` - the opacity of the line and the fill color (decimal)\n     *\n     * Example usage:\n     *\n     *     style: {\n     *         stroke: '#00ff00',\n     *         'stroke-width': 10,\n     *         fill: '#80A080',\n     *         opacity: 0.2\n     *     }\n     */\n    style: {},\n\n    /**\n     * @cfg {Boolean/Number} smooth\n     * If set to `true` or a non-zero number, the line will be smoothed/rounded around its points; otherwise\n     * straight line segments will be drawn.\n     *\n     * A numeric value is interpreted as a divisor of the horizontal distance between consecutive points in\n     * the line; larger numbers result in sharper curves while smaller numbers result in smoother curves.\n     *\n     * If set to `true` then a default numeric value of 3 will be used. Defaults to `false`.\n     */\n    smooth: false,\n\n    /**\n     * @private Default numeric smoothing value to be used when {@link #smooth} = true.\n     */\n    defaultSmoothness: 3,\n\n    /**\n     * @cfg {Boolean} fill\n     * If true, the area below the line will be filled in using the {@link #style eefill} and\n     * {@link #style opacity} config properties. Defaults to false.\n     */\n    fill: false,\n\n    constructor: function(config) {\n        this.callParent(arguments);\n        var me = this,\n            surface = me.chart.surface,\n            shadow = me.chart.shadow,\n            i, l;\n        config.highlightCfg = Ext.Object.merge({ 'stroke-width': 3 }, config.highlightCfg);\n        Ext.apply(me, config, {\n            shadowAttributes: [{\n                \"stroke-width\": 6,\n                \"stroke-opacity\": 0.05,\n                stroke: 'rgb(0, 0, 0)',\n                translate: {\n                    x: 1,\n                    y: 1\n                }\n            }, {\n                \"stroke-width\": 4,\n                \"stroke-opacity\": 0.1,\n                stroke: 'rgb(0, 0, 0)',\n                translate: {\n                    x: 1,\n                    y: 1\n                }\n            }, {\n                \"stroke-width\": 2,\n                \"stroke-opacity\": 0.15,\n                stroke: 'rgb(0, 0, 0)',\n                translate: {\n                    x: 1,\n                    y: 1\n                }\n            }]\n        });\n        me.group = surface.getGroup(me.seriesId);\n        if (me.showMarkers) {\n            me.markerGroup = surface.getGroup(me.seriesId + '-markers');\n        }\n        if (shadow) {\n            for (i = 0, l = me.shadowAttributes.length; i < l; i++) {\n                me.shadowGroups.push(surface.getGroup(me.seriesId + '-shadows' + i));\n            }\n        }\n    },\n\n    // @private makes an average of points when there are more data points than pixels to be rendered.\n    shrink: function(xValues, yValues, size) {\n        // Start at the 2nd point...\n        var len = xValues.length,\n            ratio = Math.floor(len / size),\n            i = 1,\n            xSum = 0,\n            ySum = 0,\n            xRes = [+xValues[0]],\n            yRes = [+yValues[0]];\n\n        for (; i < len; ++i) {\n            xSum += +xValues[i] || 0;\n            ySum += +yValues[i] || 0;\n            if (i % ratio == 0) {\n                xRes.push(xSum/ratio);\n                yRes.push(ySum/ratio);\n                xSum = 0;\n                ySum = 0;\n            }\n        }\n        return {\n            x: xRes,\n            y: yRes\n        };\n    },\n\n    /**\n     * Draws the series for the current chart.\n     */\n    drawSeries: function() {\n        var me = this,\n            chart = me.chart,\n            chartAxes = chart.axes,\n            store = chart.getChartStore(),\n            data = store.data.items,\n            record,\n            storeCount = store.getCount(),\n            surface = me.chart.surface,\n            bbox = {},\n            group = me.group,\n            showMarkers = me.showMarkers,\n            markerGroup = me.markerGroup,\n            enableShadows = chart.shadow,\n            shadowGroups = me.shadowGroups,\n            shadowAttributes = me.shadowAttributes,\n            smooth = me.smooth,\n            lnsh = shadowGroups.length,\n            dummyPath = [\"M\"],\n            path = [\"M\"],\n            renderPath = [\"M\"],\n            smoothPath = [\"M\"],\n            markerIndex = chart.markerIndex,\n            axes = [].concat(me.axis),\n            shadowBarAttr,\n            xValues = [],\n            xValueMap = {},\n            yValues = [],\n            yValueMap = {},\n            onbreak = false,\n            storeIndices = [],\n            markerStyle = me.markerStyle,\n            seriesStyle = me.seriesStyle,\n            colorArrayStyle = me.colorArrayStyle,\n            colorArrayLength = colorArrayStyle && colorArrayStyle.length || 0,\n            isNumber = Ext.isNumber,\n            seriesIdx = me.seriesIdx, \n            boundAxes = me.getAxesForXAndYFields(),\n            boundXAxis = boundAxes.xAxis,\n            boundYAxis = boundAxes.yAxis,\n            shadows, shadow, shindex, fromPath, fill, fillPath, rendererAttributes,\n            x, y, prevX, prevY, firstX, firstY, markerCount, i, j, ln, axis, ends, marker, markerAux, item, xValue,\n            yValue, coords, xScale, yScale, minX, maxX, minY, maxY, line, animation, endMarkerStyle,\n            endLineStyle, type, count, opacity, lineOpacity, fillOpacity, fillDefaultValue;\n\n        if (me.fireEvent('beforedraw', me) === false) {\n            return;\n        }\n\n        //if store is empty or the series is excluded in the legend then there's nothing to draw.\n        if (!storeCount || me.seriesIsHidden) {\n            me.hide();\n            me.items = [];\n            if (me.line) {\n                me.line.hide(true);\n                if (me.line.shadows) {\n                    shadows = me.line.shadows;\n                    for (j = 0, lnsh = shadows.length; j < lnsh; j++) {\n                        shadow = shadows[j];\n                        shadow.hide(true);\n                    }\n                }\n                if (me.fillPath) {\n                    me.fillPath.hide(true);\n                }\n            }\n            me.line = null;\n            me.fillPath = null;\n            return;\n        }\n\n        //prepare style objects for line and markers\n        endMarkerStyle = Ext.apply(markerStyle || {}, me.markerConfig, {\n            fill: me.seriesStyle.fill || colorArrayStyle[seriesIdx % colorArrayStyle.length]\n        });\n        type = endMarkerStyle.type;\n        delete endMarkerStyle.type;\n        endLineStyle = seriesStyle;\n        //if no stroke with is specified force it to 0.5 because this is\n        //about making *lines*\n        if (!endLineStyle['stroke-width']) {\n            endLineStyle['stroke-width'] = 0.5;\n        }\n        \n        //set opacity values\n        opacity = 'opacity' in endLineStyle ? endLineStyle.opacity : 1;\n        fillDefaultValue = 'opacity' in endLineStyle ? endLineStyle.opacity : 0.3;\n        lineOpacity = 'lineOpacity' in endLineStyle ? endLineStyle.lineOpacity : opacity;\n        fillOpacity = 'fillOpacity' in endLineStyle ? endLineStyle.fillOpacity : fillDefaultValue;\n\n        //If we're using a time axis and we need to translate the points,\n        //then reuse the first markers as the last markers.\n        if (markerIndex && markerGroup && markerGroup.getCount()) {\n            for (i = 0; i < markerIndex; i++) {\n                marker = markerGroup.getAt(i);\n                markerGroup.remove(marker);\n                markerGroup.add(marker);\n                markerAux = markerGroup.getAt(markerGroup.getCount() - 2);\n                marker.setAttributes({\n                    x: 0,\n                    y: 0,\n                    translate: {\n                        x: markerAux.attr.translation.x,\n                        y: markerAux.attr.translation.y\n                    }\n                }, true);\n            }\n        }\n\n        me.unHighlightItem();\n        me.cleanHighlights();\n\n        me.setBBox();\n        bbox = me.bbox;\n        me.clipRect = [bbox.x, bbox.y, bbox.width, bbox.height];\n\n        if (axis = chartAxes.get(boundXAxis)) {\n            ends = axis.applyData();\n            minX = ends.from;\n            maxX = ends.to;\n        }\n\n        if (axis = chartAxes.get(boundYAxis)) {\n            ends = axis.applyData();\n            minY = ends.from;\n            maxY = ends.to;\n        }\n\n        // If a field was specified without a corresponding axis, create one to get bounds\n        if (me.xField && !Ext.isNumber(minX)) {\n            axis = me.getMinMaxXValues();\n            minX = axis[0];\n            maxX = axis[1];\n        }\n\n        if (me.yField && !Ext.isNumber(minY)) {\n            axis = me.getMinMaxYValues();\n            minY = axis[0];\n            maxY = axis[1];\n        }\n        \n        if (isNaN(minX)) {\n            minX = 0;\n            xScale = bbox.width / ((storeCount - 1) || 1);\n        }\n        else {\n            xScale = bbox.width / ((maxX - minX) || (storeCount -1) || 1);\n        }\n\n        if (isNaN(minY)) {\n            minY = 0;\n            yScale = bbox.height / ((storeCount - 1) || 1);\n        }\n        else {\n            yScale = bbox.height / ((maxY - minY) || (storeCount - 1) || 1);\n        }\n        // Extract all x and y values from the store\n        for (i = 0, ln = data.length; i < ln; i++) {\n            record = data[i];\n            xValue = record.get(me.xField);\n\n            // Ensure a value\n            if (typeof xValue == 'string' || typeof xValue == 'object' && !Ext.isDate(xValue)\n                //set as uniform distribution if the axis is a category axis.\n                || boundXAxis && chartAxes.get(boundXAxis) && chartAxes.get(boundXAxis).type == 'Category') {\n                    if (xValue in xValueMap) {\n                        xValue = xValueMap[xValue];\n                    } else {\n                        xValue = xValueMap[xValue] = i;\n                    }\n            }\n\n            // Filter out values that don't fit within the pan/zoom buffer area\n            yValue = record.get(me.yField);\n            //skip undefined values\n            if (typeof yValue == 'undefined' || (typeof yValue == 'string' && !yValue)) {\n                if (Ext.isDefined(Ext.global.console)) {\n                    Ext.global.console.warn(\"[Ext.chart.series.Line]  Skipping a store element with an undefined value at \", record, xValue, yValue);\n                }\n                continue;\n            }\n            // Ensure a value\n            if (typeof yValue == 'string' || typeof yValue == 'object' && !Ext.isDate(yValue)\n                //set as uniform distribution if the axis is a category axis.\n                || boundYAxis && chartAxes.get(boundYAxis) && chartAxes.get(boundYAxis).type == 'Category') {\n                yValue = i;\n            }\n            storeIndices.push(i);\n            xValues.push(xValue);\n            yValues.push(yValue);\n        }\n\n        ln = xValues.length;\n        if (ln > bbox.width) {\n            coords = me.shrink(xValues, yValues, bbox.width);\n            xValues = coords.x;\n            yValues = coords.y;\n        }\n\n        me.items = [];\n\n        count = 0;\n        ln = xValues.length;\n        for (i = 0; i < ln; i++) {\n            xValue = xValues[i];\n            yValue = yValues[i];\n            if (yValue === false) {\n                if (path.length == 1) {\n                    path = [];\n                }\n                onbreak = true;\n                me.items.push(false);\n                continue;\n            } else {\n                x = (bbox.x + (xValue - minX) * xScale).toFixed(2);\n                y = ((bbox.y + bbox.height) - (yValue - minY) * yScale).toFixed(2);\n                if (onbreak) {\n                    onbreak = false;\n                    path.push('M');\n                }\n                path = path.concat([x, y]);\n            }\n            if ((typeof firstY == 'undefined') && (typeof y != 'undefined')) {\n                firstY = y;\n                firstX = x;\n            }\n            // If this is the first line, create a dummypath to animate in from.\n            if (!me.line || chart.resizing) {\n                dummyPath = dummyPath.concat([x, bbox.y + bbox.height / 2]);\n            }\n\n            // When resizing, reset before animating\n            if (chart.animate && chart.resizing && me.line) {\n                me.line.setAttributes({\n                    path: dummyPath,\n                    opacity: lineOpacity\n                }, true);\n                if (me.fillPath) {\n                    me.fillPath.setAttributes({\n                        path: dummyPath,\n                        opacity: fillOpacity\n                    }, true);\n                }\n                if (me.line.shadows) {\n                    shadows = me.line.shadows;\n                    for (j = 0, lnsh = shadows.length; j < lnsh; j++) {\n                        shadow = shadows[j];\n                        shadow.setAttributes({\n                            path: dummyPath\n                        }, true);\n                    }\n                }\n            }\n            if (showMarkers) {\n                marker = markerGroup.getAt(count++);\n                if (!marker) {\n                    marker = Ext.chart.Shape[type](surface, Ext.apply({\n                        group: [group, markerGroup],\n                        x: 0, y: 0,\n                        translate: {\n                            x: +(prevX || x),\n                            y: prevY || (bbox.y + bbox.height / 2)\n                        },\n                        value: '\"' + xValue + ', ' + yValue + '\"',\n                        zIndex: 4000\n                    }, endMarkerStyle));\n                    marker._to = {\n                        translate: {\n                            x: +x,\n                            y: +y\n                        }\n                    };\n                } else {\n                    marker.setAttributes({\n                        value: '\"' + xValue + ', ' + yValue + '\"',\n                        x: 0, y: 0,\n                        hidden: false\n                    }, true);\n                    marker._to = {\n                        translate: {\n                            x: +x, \n                            y: +y\n                        }\n                    };\n                }\n            }\n            me.items.push({\n                series: me,\n                value: [xValue, yValue],\n                point: [x, y],\n                sprite: marker,\n                storeItem: store.getAt(storeIndices[i])\n            });\n            prevX = x;\n            prevY = y;\n        }\n\n        if (path.length <= 1) {\n            //nothing to be rendered\n            return;\n        }\n\n        if (me.smooth) {\n            smoothPath = Ext.draw.Draw.smooth(path, isNumber(smooth) ? smooth : me.defaultSmoothness);\n        }\n\n        renderPath = smooth ? smoothPath : path;\n\n        //Correct path if we're animating timeAxis intervals\n        if (chart.markerIndex && me.previousPath) {\n            fromPath = me.previousPath;\n            if (!smooth) {\n                Ext.Array.erase(fromPath, 1, 2);\n            }\n        } else {\n            fromPath = path;\n        }\n\n        // Only create a line if one doesn't exist.\n        if (!me.line) {\n            me.line = surface.add(Ext.apply({\n                type: 'path',\n                group: group,\n                path: dummyPath,\n                stroke: endLineStyle.stroke || endLineStyle.fill\n            }, endLineStyle || {}));\n\n            //set configuration opacity\n            me.line.setAttributes({\n                opacity: lineOpacity\n            }, true);\n\n            if (enableShadows) {\n                me.line.setAttributes(Ext.apply({}, me.shadowOptions), true);\n            }\n\n            //unset fill here (there's always a default fill withing the themes).\n            me.line.setAttributes({\n                fill: 'none',\n                zIndex: 3000\n            });\n            if (!endLineStyle.stroke && colorArrayLength) {\n                me.line.setAttributes({\n                    stroke: colorArrayStyle[seriesIdx % colorArrayLength]\n                }, true);\n            }\n            if (enableShadows) {\n                //create shadows\n                shadows = me.line.shadows = [];\n                for (shindex = 0; shindex < lnsh; shindex++) {\n                    shadowBarAttr = shadowAttributes[shindex];\n                    shadowBarAttr = Ext.apply({}, shadowBarAttr, { path: dummyPath });\n                    shadow = surface.add(Ext.apply({}, {\n                        type: 'path',\n                        group: shadowGroups[shindex]\n                    }, shadowBarAttr));\n                    shadows.push(shadow);\n                }\n            }\n        }\n        if (me.fill) {\n            fillPath = renderPath.concat([\n                [\"L\", x, bbox.y + bbox.height],\n                [\"L\", firstX, bbox.y + bbox.height],\n                [\"L\", firstX, firstY]\n            ]);\n            if (!me.fillPath) {\n                me.fillPath = surface.add({\n                    group: group,\n                    type: 'path',\n                    fill: endLineStyle.fill || colorArrayStyle[seriesIdx % colorArrayLength],\n                    path: dummyPath\n                });\n            }\n        }\n        markerCount = showMarkers && markerGroup.getCount();\n        if (chart.animate) {\n            fill = me.fill;\n            line = me.line;\n            //Add renderer to line. There is not unique record associated with this.\n            rendererAttributes = me.renderer(line, false, { path: renderPath }, i, store);\n            Ext.apply(rendererAttributes, endLineStyle || {}, {\n                stroke: endLineStyle.stroke || endLineStyle.fill\n            });\n            //fill should not be used here but when drawing the special fill path object\n            delete rendererAttributes.fill;\n            line.show(true);\n            if (chart.markerIndex && me.previousPath) {\n                me.animation = animation = me.onAnimate(line, {\n                    to: rendererAttributes,\n                    from: {\n                        path: fromPath\n                    }\n                });\n            } else {\n                me.animation = animation = me.onAnimate(line, {\n                    to: rendererAttributes\n                });\n            }\n            //animate shadows\n            if (enableShadows) {\n                shadows = line.shadows;\n                for(j = 0; j < lnsh; j++) {\n                    shadows[j].show(true);\n                    if (chart.markerIndex && me.previousPath) {\n                        me.onAnimate(shadows[j], {\n                            to: { path: renderPath },\n                            from: { path: fromPath }\n                        });\n                    } else {\n                        me.onAnimate(shadows[j], {\n                            to: { path: renderPath }\n                        });\n                    }\n                }\n            }\n            //animate fill path\n            if (fill) {\n                me.fillPath.show(true);\n                me.onAnimate(me.fillPath, {\n                    to: Ext.apply({}, {\n                        path: fillPath,\n                        fill: endLineStyle.fill || colorArrayStyle[seriesIdx % colorArrayLength],\n                        'stroke-width': 0,\n                        opacity: fillOpacity\n                    }, endLineStyle || {})\n                });\n            }\n            //animate markers\n            if (showMarkers) {\n                count = 0;\n                for(i = 0; i < ln; i++) {\n                    if (me.items[i]) {\n                        item = markerGroup.getAt(count++);\n                        if (item) {\n                            rendererAttributes = me.renderer(item, store.getAt(i), item._to, i, store);\n                            me.onAnimate(item, {\n                                to: Ext.apply(rendererAttributes, endMarkerStyle || {})\n                            });\n                            item.show(true);\n                        }\n                    }\n                }\n                for(; count < markerCount; count++) {\n                    item = markerGroup.getAt(count);\n                    item.hide(true);\n                }\n//                for(i = 0; i < (chart.markerIndex || 0)-1; i++) {\n//                    item = markerGroup.getAt(i);\n//                    item.hide(true);\n//                }\n            }\n        } else {\n            rendererAttributes = me.renderer(me.line, false, { path: renderPath, hidden: false }, i, store);\n            Ext.apply(rendererAttributes, endLineStyle || {}, {\n                stroke: endLineStyle.stroke || endLineStyle.fill\n            });\n            //fill should not be used here but when drawing the special fill path object\n            delete rendererAttributes.fill;\n            me.line.setAttributes(rendererAttributes, true);\n            me.line.setAttributes({\n                opacity: lineOpacity\n            }, true);\n            //set path for shadows\n            if (enableShadows) {\n                shadows = me.line.shadows;\n                for(j = 0; j < lnsh; j++) {\n                    shadows[j].setAttributes({\n                        path: renderPath,\n                        hidden: false\n                    }, true);\n                }\n            }\n            if (me.fill) {\n                me.fillPath.setAttributes({\n                    path: fillPath,\n                    hidden: false,\n                    opacity: fillOpacity\n                }, true);\n            }\n            if (showMarkers) {\n                count = 0;\n                for(i = 0; i < ln; i++) {\n                    if (me.items[i]) {\n                        item = markerGroup.getAt(count++);\n                        if (item) {\n                            rendererAttributes = me.renderer(item, store.getAt(i), item._to, i, store);\n                            item.setAttributes(Ext.apply(endMarkerStyle || {}, rendererAttributes || {}), true);\n                            if (!item.attr.hidden) {\n                                item.show(true);\n                            }\n                        }\n                    }\n                }\n                for(; count < markerCount; count++) {\n                    item = markerGroup.getAt(count);\n                    item.hide(true);\n                }\n            }\n        }\n\n        if (chart.markerIndex) {\n            if (me.smooth) {\n                Ext.Array.erase(path, 1, 2);\n            } else {\n                Ext.Array.splice(path, 1, 0, path[1], path[2]);\n            }\n            me.previousPath = path;\n        }\n        me.renderLabels();\n        me.renderCallouts();\n\n        me.fireEvent('draw', me);\n    },\n\n    // @private called when a label is to be created.\n    onCreateLabel: function(storeItem, item, i, display) {\n        var me = this,\n            group = me.labelsGroup,\n            config = me.label,\n            bbox = me.bbox,\n            endLabelStyle = Ext.apply(config, me.seriesLabelStyle);\n\n        return me.chart.surface.add(Ext.apply({\n            'type': 'text',\n            'text-anchor': 'middle',\n            'group': group,\n            'x': item.point[0],\n            'y': bbox.y + bbox.height / 2\n        }, endLabelStyle || {}));\n    },\n\n    // @private called when a label is to be created.\n    onPlaceLabel: function(label, storeItem, item, i, display, animate) {\n        var me = this,\n            chart = me.chart,\n            resizing = chart.resizing,\n            config = me.label,\n            format = config.renderer,\n            field = config.field,\n            bbox = me.bbox,\n            x = item.point[0],\n            y = item.point[1],\n            radius = item.sprite.attr.radius,\n            bb, width, height;\n\n        label.setAttributes({\n            text: format(storeItem.get(field)),\n            hidden: true\n        }, true);\n\n        if (display == 'rotate') {\n            label.setAttributes({\n                'text-anchor': 'start',\n                'rotation': {\n                    x: x,\n                    y: y,\n                    degrees: -45\n                }\n            }, true);\n            //correct label position to fit into the box\n            bb = label.getBBox();\n            width = bb.width;\n            height = bb.height;\n            x = x < bbox.x? bbox.x : x;\n            x = (x + width > bbox.x + bbox.width)? (x - (x + width - bbox.x - bbox.width)) : x;\n            y = (y - height < bbox.y)? bbox.y + height : y;\n\n        } else if (display == 'under' || display == 'over') {\n            //TODO(nicolas): find out why width/height values in circle bounding boxes are undefined.\n            bb = item.sprite.getBBox();\n            bb.width = bb.width || (radius * 2);\n            bb.height = bb.height || (radius * 2);\n            y = y + (display == 'over'? -bb.height : bb.height);\n            //correct label position to fit into the box\n            bb = label.getBBox();\n            width = bb.width/2;\n            height = bb.height/2;\n            x = x - width < bbox.x? bbox.x + width : x;\n            x = (x + width > bbox.x + bbox.width) ? (x - (x + width - bbox.x - bbox.width)) : x;\n            y = y - height < bbox.y? bbox.y + height : y;\n            y = (y + height > bbox.y + bbox.height) ? (y - (y + height - bbox.y - bbox.height)) : y;\n        }\n\n        if (me.chart.animate && !me.chart.resizing) {\n            label.show(true);\n            me.onAnimate(label, {\n                to: {\n                    x: x,\n                    y: y\n                }\n            });\n        } else {\n            label.setAttributes({\n                x: x,\n                y: y\n            }, true);\n            if (resizing && me.animation) {\n                me.animation.on('afteranimate', function() {\n                    label.show(true);\n                });\n            } else {\n                label.show(true);\n            }\n        }\n    },\n\n    // @private Overriding highlights.js highlightItem method.\n    highlightItem: function() {\n        var me = this;\n        me.callParent(arguments);\n        if (me.line && !me.highlighted) {\n            if (!('__strokeWidth' in me.line)) {\n                me.line.__strokeWidth = parseFloat(me.line.attr['stroke-width']) || 0;\n            }\n            if (me.line.__anim) {\n                me.line.__anim.paused = true;\n            }\n            me.line.__anim = Ext.create('Ext.fx.Anim', {\n                target: me.line,\n                to: {\n                    'stroke-width': me.line.__strokeWidth + 3\n                }\n            });\n            me.highlighted = true;\n        }\n    },\n\n    // @private Overriding highlights.js unHighlightItem method.\n    unHighlightItem: function() {\n        var me = this;\n        me.callParent(arguments);\n        if (me.line && me.highlighted) {\n            me.line.__anim = Ext.create('Ext.fx.Anim', {\n                target: me.line,\n                to: {\n                    'stroke-width': me.line.__strokeWidth\n                }\n            });\n            me.highlighted = false;\n        }\n    },\n\n    // @private called when a callout needs to be placed.\n    onPlaceCallout : function(callout, storeItem, item, i, display, animate, index) {\n        if (!display) {\n            return;\n        }\n\n        var me = this,\n            chart = me.chart,\n            surface = chart.surface,\n            resizing = chart.resizing,\n            config = me.callouts,\n            items = me.items,\n            prev = i == 0? false : items[i -1].point,\n            next = (i == items.length -1)? false : items[i +1].point,\n            cur = [+item.point[0], +item.point[1]],\n            dir, norm, normal, a, aprev, anext,\n            offsetFromViz = config.offsetFromViz || 30,\n            offsetToSide = config.offsetToSide || 10,\n            offsetBox = config.offsetBox || 3,\n            boxx, boxy, boxw, boxh,\n            p, clipRect = me.clipRect,\n            bbox = {\n                width: config.styles.width || 10,\n                height: config.styles.height || 10\n            },\n            x, y;\n\n        //get the right two points\n        if (!prev) {\n            prev = cur;\n        }\n        if (!next) {\n            next = cur;\n        }\n        a = (next[1] - prev[1]) / (next[0] - prev[0]);\n        aprev = (cur[1] - prev[1]) / (cur[0] - prev[0]);\n        anext = (next[1] - cur[1]) / (next[0] - cur[0]);\n\n        norm = Math.sqrt(1 + a * a);\n        dir = [1 / norm, a / norm];\n        normal = [-dir[1], dir[0]];\n\n        //keep the label always on the outer part of the \"elbow\"\n        if (aprev > 0 && anext < 0 && normal[1] < 0\n            || aprev < 0 && anext > 0 && normal[1] > 0) {\n            normal[0] *= -1;\n            normal[1] *= -1;\n        } else if (Math.abs(aprev) < Math.abs(anext) && normal[0] < 0\n                   || Math.abs(aprev) > Math.abs(anext) && normal[0] > 0) {\n            normal[0] *= -1;\n            normal[1] *= -1;\n        }\n        //position\n        x = cur[0] + normal[0] * offsetFromViz;\n        y = cur[1] + normal[1] * offsetFromViz;\n\n        //box position and dimensions\n        boxx = x + (normal[0] > 0? 0 : -(bbox.width + 2 * offsetBox));\n        boxy = y - bbox.height /2 - offsetBox;\n        boxw = bbox.width + 2 * offsetBox;\n        boxh = bbox.height + 2 * offsetBox;\n\n        //now check if we're out of bounds and invert the normal vector correspondingly\n        //this may add new overlaps between labels (but labels won't be out of bounds).\n        if (boxx < clipRect[0] || (boxx + boxw) > (clipRect[0] + clipRect[2])) {\n            normal[0] *= -1;\n        }\n        if (boxy < clipRect[1] || (boxy + boxh) > (clipRect[1] + clipRect[3])) {\n            normal[1] *= -1;\n        }\n\n        //update positions\n        x = cur[0] + normal[0] * offsetFromViz;\n        y = cur[1] + normal[1] * offsetFromViz;\n\n        //update box position and dimensions\n        boxx = x + (normal[0] > 0? 0 : -(bbox.width + 2 * offsetBox));\n        boxy = y - bbox.height /2 - offsetBox;\n        boxw = bbox.width + 2 * offsetBox;\n        boxh = bbox.height + 2 * offsetBox;\n\n        if (chart.animate) {\n            //set the line from the middle of the pie to the box.\n            me.onAnimate(callout.lines, {\n                to: {\n                    path: [\"M\", cur[0], cur[1], \"L\", x, y, \"Z\"]\n                }\n            });\n            //set component position\n            if (callout.panel) {\n                callout.panel.setPosition(boxx, boxy, true);\n            }\n        }\n        else {\n            //set the line from the middle of the pie to the box.\n            callout.lines.setAttributes({\n                path: [\"M\", cur[0], cur[1], \"L\", x, y, \"Z\"]\n            }, true);\n            //set component position\n            if (callout.panel) {\n                callout.panel.setPosition(boxx, boxy);\n            }\n        }\n        for (p in callout) {\n            callout[p].show(true);\n        }\n    },\n\n    isItemInPoint: function(x, y, item, i) {\n        var me = this,\n            items = me.items,\n            tolerance = me.selectionTolerance,\n            result = null,\n            prevItem,\n            nextItem,\n            prevPoint,\n            nextPoint,\n            ln,\n            x1,\n            y1,\n            x2,\n            y2,\n            xIntersect,\n            yIntersect,\n            dist1, dist2, dist, midx, midy,\n            sqrt = Math.sqrt, abs = Math.abs;\n\n        nextItem = items[i];\n        prevItem = i && items[i - 1];\n\n        if (i >= ln) {\n            prevItem = items[ln - 1];\n        }\n        prevPoint = prevItem && prevItem.point;\n        nextPoint = nextItem && nextItem.point;\n        x1 = prevItem ? prevPoint[0] : nextPoint[0] - tolerance;\n        y1 = prevItem ? prevPoint[1] : nextPoint[1];\n        x2 = nextItem ? nextPoint[0] : prevPoint[0] + tolerance;\n        y2 = nextItem ? nextPoint[1] : prevPoint[1];\n        dist1 = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));\n        dist2 = sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));\n        dist = Math.min(dist1, dist2);\n\n        if (dist <= tolerance) {\n            return dist == dist1? prevItem : nextItem;\n        }\n        return false;\n    },\n\n    // @private toggle visibility of all series elements (markers, sprites).\n    toggleAll: function(show) {\n        var me = this,\n            i, ln, shadow, shadows;\n        if (!show) {\n            Ext.chart.series.Cartesian.prototype.hideAll.call(me);\n        }\n        else {\n            Ext.chart.series.Cartesian.prototype.showAll.call(me);\n        }\n        if (me.line) {\n            me.line.setAttributes({\n                hidden: !show\n            }, true);\n            //hide shadows too\n            if (me.line.shadows) {\n                for (i = 0, shadows = me.line.shadows, ln = shadows.length; i < ln; i++) {\n                    shadow = shadows[i];\n                    shadow.setAttributes({\n                        hidden: !show\n                    }, true);\n                }\n            }\n        }\n        if (me.fillPath) {\n            me.fillPath.setAttributes({\n                hidden: !show\n            }, true);\n        }\n    },\n\n    // @private hide all series elements (markers, sprites).\n    hideAll: function() {\n        this.toggleAll(false);\n    },\n\n    // @private hide all series elements (markers, sprites).\n    showAll: function() {\n        this.toggleAll(true);\n    }\n});\n\n/**\n * @class Ext.chart.series.Pie\n *\n * Creates a Pie Chart. A Pie Chart is a useful visualization technique to display quantitative information for different\n * categories that also have a meaning as a whole.\n * As with all other series, the Pie Series must be appended in the *series* Chart array configuration. See the Chart\n * documentation for more information. A typical configuration object for the pie series could be:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data'],\n *         data: [\n *             { 'name': 'metric one',   'data': 10 },\n *             { 'name': 'metric two',   'data':  7 },\n *             { 'name': 'metric three', 'data':  5 },\n *             { 'name': 'metric four',  'data':  2 },\n *             { 'name': 'metric five',  'data': 27 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 350,\n *         animate: true,\n *         store: store,\n *         theme: 'Base:gradients',\n *         series: [{\n *             type: 'pie',\n *             angleField: 'data',\n *             showInLegend: true,\n *             tips: {\n *                 trackMouse: true,\n *                 width: 140,\n *                 height: 28,\n *                 renderer: function(storeItem, item) {\n *                     // calculate and display percentage on hover\n *                     var total = 0;\n *                     store.each(function(rec) {\n *                         total += rec.get('data');\n *                     });\n *                     this.setTitle(storeItem.get('name') + ': ' + Math.round(storeItem.get('data') / total * 100) + '%');\n *                 }\n *             },\n *             highlight: {\n *                 segment: {\n *                     margin: 20\n *                 }\n *             },\n *             label: {\n *                 field: 'name',\n *                 display: 'rotate',\n *                 contrast: true,\n *                 font: '18px Arial'\n *             }\n *         }]\n *     });\n *\n * In this configuration we set `pie` as the type for the series, set an object with specific style properties for highlighting options\n * (triggered when hovering elements). We also set true to `showInLegend` so all the pie slices can be represented by a legend item.\n *\n * We set `data` as the value of the field to determine the angle span for each pie slice. We also set a label configuration object\n * where we set the field name of the store field to be renderer as text for the label. The labels will also be displayed rotated.\n *\n * We set `contrast` to `true` to flip the color of the label if it is to similar to the background color. Finally, we set the font family\n * and size through the `font` parameter.\n *\n * @xtype pie\n */\nExt.define('Ext.chart.series.Pie', {\n\n    /* Begin Definitions */\n\n    alternateClassName: ['Ext.chart.PieSeries', 'Ext.chart.PieChart'],\n\n    extend: 'Ext.chart.series.Series',\n\n    /* End Definitions */\n\n    type: \"pie\",\n\n    alias: 'series.pie',\n\n    accuracy: 100000,\n\n    rad: Math.PI * 2 / 100000,\n\n    /**\n     * @cfg {Number} highlightDuration\n     * The duration for the pie slice highlight effect.\n     */\n    highlightDuration: 150,\n\n    /**\n     * @cfg {String} angleField (required)\n     * The store record field name to be used for the pie angles.\n     * The values bound to this field name must be positive real numbers.\n     */\n    angleField: false,\n\n    /**\n     * @cfg {String} field\n     * Alias for {@link #angleField}.\n     */\n\n    /**\n     * @cfg {String} xField\n     * Alias for {@link #angleField}.\n     */\n\n    /**\n     * @cfg {String} lengthField\n     * The store record field name to be used for the pie slice lengths.\n     * The values bound to this field name must be positive real numbers.\n     */\n    lengthField: false,\n\n    /**\n     * @cfg {Boolean/Number} donut\n     * Whether to set the pie chart as donut chart.\n     * Default's false. Can be set to a particular percentage to set the radius\n     * of the donut chart.\n     */\n    donut: false,\n\n    /**\n     * @cfg {Boolean} showInLegend\n     * Whether to add the pie chart elements as legend items. Default's false.\n     */\n    showInLegend: false,\n\n    /**\n     * @cfg {Array} colorSet\n     * An array of color values which will be used, in order, as the pie slice fill colors.\n     */\n\n    /**\n     * @cfg {Object} style\n     * An object containing styles for overriding series styles from Theming.\n     */\n    style: {},\n\n    constructor: function(config) {\n        this.callParent(arguments);\n        var me = this,\n            chart = me.chart,\n            surface = chart.surface,\n            store = chart.store,\n            shadow = chart.shadow, i, l, cfg;\n        config.highlightCfg = Ext.merge({\n            segment: {\n                margin: 20\n            }\n        }, config.highlightCfg);\n        Ext.apply(me, config, {\n            shadowAttributes: [{\n                \"stroke-width\": 6,\n                \"stroke-opacity\": 1,\n                stroke: 'rgb(200, 200, 200)',\n                translate: {\n                    x: 1.2,\n                    y: 2\n                }\n            },\n            {\n                \"stroke-width\": 4,\n                \"stroke-opacity\": 1,\n                stroke: 'rgb(150, 150, 150)',\n                translate: {\n                    x: 0.9,\n                    y: 1.5\n                }\n            },\n            {\n                \"stroke-width\": 2,\n                \"stroke-opacity\": 1,\n                stroke: 'rgb(100, 100, 100)',\n                translate: {\n                    x: 0.6,\n                    y: 1\n                }\n            }]\n        });\n        me.group = surface.getGroup(me.seriesId);\n        if (shadow) {\n            for (i = 0, l = me.shadowAttributes.length; i < l; i++) {\n                me.shadowGroups.push(surface.getGroup(me.seriesId + '-shadows' + i));\n            }\n        }\n        surface.customAttributes.segment = function(opt) {\n            //Browsers will complain if we create a path\n            //element that has no path commands. So ensure a dummy \n            //path command for an empty path.\n            var ans = me.getSegment(opt);\n            if (!ans.path || ans.path.length === 0) {\n                ans.path = ['M', 0, 0];\n            }\n            return ans;\n        };\n        me.__excludes = me.__excludes || [];\n    },\n\n    // @private updates some onbefore render parameters.\n    initialize: function() {\n        var me = this,\n            store = me.chart.getChartStore(),\n            data = store.data.items,\n            i, ln, rec;\n        //Add yFields to be used in Legend.js\n        me.yField = [];\n        if (me.label.field) {\n            for (i = 0, ln = data.length; i < ln; i++) {\n                rec = data[i];\n                me.yField.push(rec.get(me.label.field));\n            }\n        }\n    },\n\n    // @private returns an object with properties for a PieSlice.\n    getSegment: function(opt) {\n        var me = this,\n            rad = me.rad,\n            cos = Math.cos,\n            sin = Math.sin,\n            x = me.centerX,\n            y = me.centerY,\n            x1 = 0, x2 = 0, x3 = 0, x4 = 0,\n            y1 = 0, y2 = 0, y3 = 0, y4 = 0,\n            x5 = 0, y5 = 0, x6 = 0, y6 = 0,\n            delta = 1e-2,\n            startAngle = opt.startAngle,\n            endAngle = opt.endAngle,\n            midAngle = (startAngle + endAngle) / 2 * rad,\n            margin = opt.margin || 0,\n            a1 = Math.min(startAngle, endAngle) * rad,\n            a2 = Math.max(startAngle, endAngle) * rad,\n            c1 = cos(a1), s1 = sin(a1),\n            c2 = cos(a2), s2 = sin(a2),\n            cm = cos(midAngle), sm = sin(midAngle),\n            flag = 0, hsqr2 = 0.7071067811865476; // sqrt(0.5)\n\n        if (a2 - a1 < delta) {\n            return {path: \"\"};\n        }\n\n        if (margin !== 0) {\n            x += margin * cm;\n            y += margin * sm;\n        }\n\n        x2 = x + opt.endRho * c1;\n        y2 = y + opt.endRho * s1;\n\n        x4 = x + opt.endRho * c2;\n        y4 = y + opt.endRho * s2;\n\n        x6 = x + opt.endRho * cm;\n        y6 = y + opt.endRho * sm;\n\n        if (opt.startRho !== 0) {\n            x1 = x + opt.startRho * c1;\n            y1 = y + opt.startRho * s1;\n    \n            x3 = x + opt.startRho * c2;\n            y3 = y + opt.startRho * s2;\n    \n            x5 = x + opt.startRho * cm;\n            y5 = y + opt.startRho * sm;\n\n            return {\n                path: [\n                    [\"M\", x2, y2],\n                    [\"A\", opt.endRho, opt.endRho, 0, 0, 1, x6, y6], [\"L\", x6, y6],\n                    [\"A\", opt.endRho, opt.endRho, 0, flag, 1, x4, y4], [\"L\", x4, y4],\n                    [\"L\", x3, y3],\n                    [\"A\", opt.startRho, opt.startRho, 0, flag, 0, x5, y5], [\"L\", x5, y5],\n                    [\"A\", opt.startRho, opt.startRho, 0, 0, 0, x1, y1], [\"L\", x1, y1],\n                    [\"Z\"]\n                ]\n            };\n        } else {\n            return {\n                path: [\n                    [\"M\", x, y],\n                    [\"L\", x2, y2],\n                    [\"A\", opt.endRho, opt.endRho, 0, 0, 1, x6, y6], [\"L\", x6, y6],\n                    [\"A\", opt.endRho, opt.endRho, 0, flag, 1, x4, y4], [\"L\", x4, y4],\n                    [\"L\", x, y],\n                    [\"Z\"]\n                ]\n            };\n        }\n    },\n\n    // @private utility function to calculate the middle point of a pie slice.\n    calcMiddle: function(item) {\n        var me = this,\n            rad = me.rad,\n            slice = item.slice,\n            x = me.centerX,\n            y = me.centerY,\n            startAngle = slice.startAngle,\n            endAngle = slice.endAngle,\n            donut = +me.donut,\n            midAngle = -(startAngle + endAngle) * rad / 2,\n            r = (item.endRho + item.startRho) / 2,\n            xm = x + r * Math.cos(midAngle),\n            ym = y - r * Math.sin(midAngle);\n\n        item.middle = {\n            x: xm,\n            y: ym\n        };\n    },\n\n    /**\n     * Draws the series for the current chart.\n     */\n    drawSeries: function() {\n        var me = this,\n            store = me.chart.getChartStore(),\n            data = store.data.items,\n            record,\n            group = me.group,\n            animate = me.chart.animate,\n            field = me.angleField || me.field || me.xField,\n            lenField = [].concat(me.lengthField),\n            totalLenField = 0,\n            chart = me.chart,\n            surface = chart.surface,\n            chartBBox = chart.chartBBox,\n            enableShadows = chart.shadow,\n            shadowGroups = me.shadowGroups,\n            shadowAttributes = me.shadowAttributes,\n            lnsh = shadowGroups.length,\n            layers = lenField.length,\n            rhoAcum = 0,\n            donut = +me.donut,\n            layerTotals = [],\n            items = [],\n            totalField = 0,\n            maxLenField = 0,\n            angle = 0,\n            seriesStyle = me.seriesStyle,\n            colorArrayStyle = me.colorArrayStyle,\n            colorArrayLength = colorArrayStyle && colorArrayStyle.length || 0,\n            rendererAttributes,\n            shadowAttr,\n            shadows,\n            shadow,\n            shindex,\n            centerX,\n            centerY,\n            deltaRho,\n            first = 0,\n            slice,\n            slices,\n            sprite,\n            value,\n            item,\n            lenValue,\n            ln,\n            i,\n            j,\n            endAngle,\n            path,\n            p,\n            spriteOptions, bbox;\n\n        Ext.apply(seriesStyle, me.style || {});\n\n        me.setBBox();\n        bbox = me.bbox;\n\n        //override theme colors\n        if (me.colorSet) {\n            colorArrayStyle = me.colorSet;\n            colorArrayLength = colorArrayStyle.length;\n        }\n\n        //if not store or store is empty then there's nothing to draw\n        if (!store || !store.getCount() || me.seriesIsHidden) {\n            me.hide();\n            me.items = [];\n            return;\n        }\n\n        me.unHighlightItem();\n        me.cleanHighlights();\n\n        centerX = me.centerX = chartBBox.x + (chartBBox.width / 2);\n        centerY = me.centerY = chartBBox.y + (chartBBox.height / 2);\n        me.radius = Math.min(centerX - chartBBox.x, centerY - chartBBox.y);\n        me.slices = slices = [];\n        me.items = items = [];\n\n        for (i = 0, ln = data.length; i < ln; i++) {\n            record = data[i];\n            if (this.__excludes && this.__excludes[i]) {\n                //hidden series\n                continue;\n            }\n            totalField += +record.get(field);\n            if (lenField[0]) {\n                for (j = 0, totalLenField = 0; j < layers; j++) {\n                    totalLenField += +record.get(lenField[j]);\n                }\n                layerTotals[i] = totalLenField;\n                maxLenField = Math.max(maxLenField, totalLenField);\n            }\n        }\n\n        totalField = totalField || 1;\n        for (i = 0, ln = data.length; i < ln; i++) {\n            record = data[i];\n            if (this.__excludes && this.__excludes[i]) {\n                value = 0;\n            } else {\n                value = record.get(field);\n                if (first == 0) {\n                    first = 1;\n                }\n            }\n\n            // First slice\n            if (first == 1) {\n                first = 2;\n                me.firstAngle = angle = me.accuracy * value / totalField / 2;\n                for (j = 0; j < i; j++) {\n                    slices[j].startAngle = slices[j].endAngle = me.firstAngle;\n                }\n            }\n\n            endAngle = angle - me.accuracy * value / totalField;\n            slice = {\n                series: me,\n                value: value,\n                startAngle: angle,\n                endAngle: endAngle,\n                storeItem: record\n            };\n            if (lenField[0]) {\n                lenValue = +layerTotals[i];\n                //removing the floor will break Opera 11.6*\n                slice.rho = Math.floor(me.radius / maxLenField * lenValue);\n            } else {\n                slice.rho = me.radius;\n            }\n            slices[i] = slice;\n            // Do not remove this closure for the sake of https://sencha.jira.com/browse/EXTJSIV-5836\n            (function () {\n                angle = endAngle;\n            })();\n        }\n\n        //do all shadows first.\n        if (enableShadows) {\n            for (i = 0, ln = slices.length; i < ln; i++) {\n                slice = slices[i];\n                slice.shadowAttrs = [];\n                for (j = 0, rhoAcum = 0, shadows = []; j < layers; j++) {\n                    sprite = group.getAt(i * layers + j);\n                    deltaRho = lenField[j] ? store.getAt(i).get(lenField[j]) / layerTotals[i] * slice.rho: slice.rho;\n                    //set pie slice properties\n                    rendererAttributes = {\n                        segment: {\n                            startAngle: slice.startAngle,\n                            endAngle: slice.endAngle,\n                            margin: 0,\n                            rho: slice.rho,\n                            startRho: rhoAcum + (deltaRho * donut / 100),\n                            endRho: rhoAcum + deltaRho\n                        },\n                        hidden: !slice.value && (slice.startAngle % me.accuracy) == (slice.endAngle % me.accuracy)\n                    };\n                    //create shadows\n                    for (shindex = 0, shadows = []; shindex < lnsh; shindex++) {\n                        shadowAttr = shadowAttributes[shindex];\n                        shadow = shadowGroups[shindex].getAt(i);\n                        if (!shadow) {\n                            shadow = chart.surface.add(Ext.apply({}, {\n                                type: 'path',\n                                group: shadowGroups[shindex],\n                                strokeLinejoin: \"round\"\n                            }, rendererAttributes, shadowAttr));\n                        }\n                        shadowAttr = me.renderer(shadow, store.getAt(i), Ext.apply({}, rendererAttributes, shadowAttr), i, store);\n                        if (animate) {\n                            me.onAnimate(shadow, {\n                                to: shadowAttr\n                            });\n                        } else {\n                            shadow.setAttributes(shadowAttr, true);\n                        }\n                        shadows.push(shadow);\n                    }\n                    slice.shadowAttrs[j] = shadows;\n                }\n            }\n        }\n        //do pie slices after.\n        for (i = 0, ln = slices.length; i < ln; i++) {\n            slice = slices[i];\n            for (j = 0, rhoAcum = 0; j < layers; j++) {\n                sprite = group.getAt(i * layers + j);\n                deltaRho = lenField[j] ? store.getAt(i).get(lenField[j]) / layerTotals[i] * slice.rho: slice.rho;\n                //set pie slice properties\n                rendererAttributes = Ext.apply({\n                    segment: {\n                        startAngle: slice.startAngle,\n                        endAngle: slice.endAngle,\n                        margin: 0,\n                        rho: slice.rho,\n                        startRho: rhoAcum + (deltaRho * donut / 100),\n                        endRho: rhoAcum + deltaRho\n                    },\n                    hidden: (!slice.value && (slice.startAngle % me.accuracy) == (slice.endAngle % me.accuracy))\n                }, Ext.apply(seriesStyle, colorArrayStyle && { fill: colorArrayStyle[(layers > 1? j : i) % colorArrayLength] } || {}));\n                item = Ext.apply({},\n                rendererAttributes.segment, {\n                    slice: slice,\n                    series: me,\n                    storeItem: slice.storeItem,\n                    index: i\n                });\n                me.calcMiddle(item);\n                if (enableShadows) {\n                    item.shadows = slice.shadowAttrs[j];\n                }\n                items[i] = item;\n                // Create a new sprite if needed (no height)\n                if (!sprite) {\n                    spriteOptions = Ext.apply({\n                        type: \"path\",\n                        group: group,\n                        middle: item.middle\n                    }, Ext.apply(seriesStyle, colorArrayStyle && { fill: colorArrayStyle[(layers > 1? j : i) % colorArrayLength] } || {}));\n                    sprite = surface.add(Ext.apply(spriteOptions, rendererAttributes));\n                }\n                slice.sprite = slice.sprite || [];\n                item.sprite = sprite;\n                slice.sprite.push(sprite);\n                slice.point = [item.middle.x, item.middle.y];\n                if (animate) {\n                    rendererAttributes = me.renderer(sprite, store.getAt(i), rendererAttributes, i, store);\n                    sprite._to = rendererAttributes;\n                    sprite._animating = true;\n                    me.onAnimate(sprite, {\n                        to: rendererAttributes,\n                        listeners: {\n                            afteranimate: {\n                                fn: function() {\n                                    this._animating = false;\n                                },\n                                scope: sprite\n                            }\n                        }\n                    });\n                } else {\n                    rendererAttributes = me.renderer(sprite, store.getAt(i), Ext.apply(rendererAttributes, {\n                        hidden: false\n                    }), i, store);\n                    sprite.setAttributes(rendererAttributes, true);\n                }\n                rhoAcum += deltaRho;\n            }\n        }\n\n        // Hide unused bars\n        ln = group.getCount();\n        for (i = 0; i < ln; i++) {\n            if (!slices[(i / layers) >> 0] && group.getAt(i)) {\n                group.getAt(i).hide(true);\n            }\n        }\n        if (enableShadows) {\n            lnsh = shadowGroups.length;\n            for (shindex = 0; shindex < ln; shindex++) {\n                if (!slices[(shindex / layers) >> 0]) {\n                    for (j = 0; j < lnsh; j++) {\n                        if (shadowGroups[j].getAt(shindex)) {\n                            shadowGroups[j].getAt(shindex).hide(true);\n                        }\n                    }\n                }\n            }\n        }\n        me.renderLabels();\n        me.renderCallouts();\n    },\n\n    // @private callback for when creating a label sprite.\n    onCreateLabel: function(storeItem, item, i, display) {\n        var me = this,\n            group = me.labelsGroup,\n            config = me.label,\n            centerX = me.centerX,\n            centerY = me.centerY,\n            middle = item.middle,\n            endLabelStyle = Ext.apply(me.seriesLabelStyle || {}, config || {});\n\n        return me.chart.surface.add(Ext.apply({\n            'type': 'text',\n            'text-anchor': 'middle',\n            'group': group,\n            'x': middle.x,\n            'y': middle.y\n        }, endLabelStyle));\n    },\n\n    // @private callback for when placing a label sprite.\n    onPlaceLabel: function(label, storeItem, item, i, display, animate, index) {\n        var me = this,\n            chart = me.chart,\n            resizing = chart.resizing,\n            config = me.label,\n            format = config.renderer,\n            field = [].concat(config.field),\n            centerX = me.centerX,\n            centerY = me.centerY,\n            middle = item.middle,\n            opt = {\n                x: middle.x,\n                y: middle.y\n            },\n            x = middle.x - centerX,\n            y = middle.y - centerY,\n            from = {},\n            rho = 1,\n            theta = Math.atan2(y, x || 1),\n            dg = theta * 180 / Math.PI,\n            prevDg;\n\n        opt.hidden = false;\n\n        if (this.__excludes && this.__excludes[i]) {\n            opt.hidden = true;\n        }\n\n        function fixAngle(a) {\n            if (a < 0) {\n                a += 360;\n            }\n            return a % 360;\n        }\n\n        label.setAttributes({\n            text: format(storeItem.get(field[index]))\n        }, true);\n\n        switch (display) {\n        case 'outside':\n            rho = Math.sqrt(x * x + y * y) * 2;\n            //update positions\n            opt.x = rho * Math.cos(theta) + centerX;\n            opt.y = rho * Math.sin(theta) + centerY;\n            break;\n\n        case 'rotate':\n            dg = fixAngle(dg);\n            dg = (dg > 90 && dg < 270) ? dg + 180: dg;\n\n            prevDg = label.attr.rotation.degrees;\n            if (prevDg != null && Math.abs(prevDg - dg) > 180 * 0.5) {\n                if (dg > prevDg) {\n                    dg -= 360;\n                } else {\n                    dg += 360;\n                }\n                dg = dg % 360;\n            } else {\n                dg = fixAngle(dg);\n            }\n            //update rotation angle\n            opt.rotate = {\n                degrees: dg,\n                x: opt.x,\n                y: opt.y\n            };\n            break;\n\n        default:\n            break;\n        }\n        //ensure the object has zero translation\n        opt.translate = {\n            x: 0, y: 0\n        };\n        if (animate && !resizing && (display != 'rotate' || prevDg != null)) {\n            me.onAnimate(label, {\n                to: opt\n            });\n        } else {\n            label.setAttributes(opt, true);\n        }\n        label._from = from;\n    },\n\n    // @private callback for when placing a callout sprite.\n    onPlaceCallout: function(callout, storeItem, item, i, display, animate, index) {\n        var me = this,\n            chart = me.chart,\n            centerX = me.centerX,\n            centerY = me.centerY,\n            middle = item.middle,\n            opt = {\n                x: middle.x,\n                y: middle.y\n            },\n            x = middle.x - centerX,\n            y = middle.y - centerY,\n            rho = 1,\n            rhoCenter,\n            theta = Math.atan2(y, x || 1),\n            bbox = callout.label.getBBox(),\n            offsetFromViz = 20,\n            offsetToSide = 10,\n            offsetBox = 10,\n            p;\n\n        //should be able to config this.\n        rho = item.endRho + offsetFromViz;\n        rhoCenter = (item.endRho + item.startRho) / 2 + (item.endRho - item.startRho) / 3;\n        //update positions\n        opt.x = rho * Math.cos(theta) + centerX;\n        opt.y = rho * Math.sin(theta) + centerY;\n\n        x = rhoCenter * Math.cos(theta);\n        y = rhoCenter * Math.sin(theta);\n\n        if (chart.animate) {\n            //set the line from the middle of the pie to the box.\n            me.onAnimate(callout.lines, {\n                to: {\n                    path: [\"M\", x + centerX, y + centerY, \"L\", opt.x, opt.y, \"Z\", \"M\", opt.x, opt.y, \"l\", x > 0 ? offsetToSide: -offsetToSide, 0, \"z\"]\n                }\n            });\n            //set box position\n            me.onAnimate(callout.box, {\n                to: {\n                    x: opt.x + (x > 0 ? offsetToSide: -(offsetToSide + bbox.width + 2 * offsetBox)),\n                    y: opt.y + (y > 0 ? ( - bbox.height - offsetBox / 2) : ( - bbox.height - offsetBox / 2)),\n                    width: bbox.width + 2 * offsetBox,\n                    height: bbox.height + 2 * offsetBox\n                }\n            });\n            //set text position\n            me.onAnimate(callout.label, {\n                to: {\n                    x: opt.x + (x > 0 ? (offsetToSide + offsetBox) : -(offsetToSide + bbox.width + offsetBox)),\n                    y: opt.y + (y > 0 ? -bbox.height / 4: -bbox.height / 4)\n                }\n            });\n        } else {\n            //set the line from the middle of the pie to the box.\n            callout.lines.setAttributes({\n                path: [\"M\", x + centerX, y + centerY, \"L\", opt.x, opt.y, \"Z\", \"M\", opt.x, opt.y, \"l\", x > 0 ? offsetToSide: -offsetToSide, 0, \"z\"]\n            },\n            true);\n            //set box position\n            callout.box.setAttributes({\n                x: opt.x + (x > 0 ? offsetToSide: -(offsetToSide + bbox.width + 2 * offsetBox)),\n                y: opt.y + (y > 0 ? ( - bbox.height - offsetBox / 2) : ( - bbox.height - offsetBox / 2)),\n                width: bbox.width + 2 * offsetBox,\n                height: bbox.height + 2 * offsetBox\n            },\n            true);\n            //set text position\n            callout.label.setAttributes({\n                x: opt.x + (x > 0 ? (offsetToSide + offsetBox) : -(offsetToSide + bbox.width + offsetBox)),\n                y: opt.y + (y > 0 ? -bbox.height / 4: -bbox.height / 4)\n            },\n            true);\n        }\n        for (p in callout) {\n            callout[p].show(true);\n        }\n    },\n\n    // @private handles sprite animation for the series.\n    onAnimate: function(sprite, attr) {\n        sprite.show();\n        return this.callParent(arguments);\n    },\n\n    isItemInPoint: function(x, y, item, i) {\n        var me = this,\n            cx = me.centerX,\n            cy = me.centerY,\n            abs = Math.abs,\n            dx = abs(x - cx),\n            dy = abs(y - cy),\n            startAngle = item.startAngle,\n            endAngle = item.endAngle,\n            rho = Math.sqrt(dx * dx + dy * dy),\n            angle = Math.atan2(y - cy, x - cx) / me.rad;\n\n        // normalize to the same range of angles created by drawSeries\n        if (angle > me.firstAngle) {\n            angle -= me.accuracy;\n        }\n        return (angle <= startAngle && angle > endAngle\n                && rho >= item.startRho && rho <= item.endRho);\n    },\n\n    // @private hides all elements in the series.\n    hideAll: function(index) {\n        var i, l, shadow, shadows, sh, lsh, sprite;\n        index = (isNaN(this._index) ? index : this._index) || 0;\n        this.__excludes = this.__excludes || [];\n        this.__excludes[index] = true;\n        sprite = this.slices[index].sprite;\n        for (sh = 0, lsh = sprite.length; sh < lsh; sh++) {\n            sprite[sh].setAttributes({\n                hidden: true\n            }, true);\n        }\n        if (this.slices[index].shadowAttrs) {\n            for (i = 0, shadows = this.slices[index].shadowAttrs, l = shadows.length; i < l; i++) {\n                shadow = shadows[i];\n                for (sh = 0, lsh = shadow.length; sh < lsh; sh++) {\n                    shadow[sh].setAttributes({\n                        hidden: true\n                    }, true);\n                }\n            }\n        }\n        this.drawSeries();\n    },\n\n    // @private shows all elements in the series.\n    showAll: function(index) {\n        index = (isNaN(this._index) ? index : this._index) || 0;\n        this.__excludes[index] = false;\n        this.drawSeries();\n    },\n\n    /**\n     * Highlight the specified item. If no item is provided the whole series will be highlighted.\n     * @param item {Object} Info about the item; same format as returned by #getItemForPoint\n     */\n    highlightItem: function(item) {\n        var me = this,\n            rad = me.rad,\n            highlightSegment,\n            animate,\n            attrs,\n            i,\n            shadows,\n            shadow,\n            ln,\n            to,\n            itemHighlightSegment,\n            prop,\n            group,\n            display,\n            label,\n            middle,\n            r,\n            x,\n            y;\n        item = item || this.items[this._index];\n\n        //TODO(nico): sometimes in IE itemmouseover is triggered\n        //twice without triggering itemmouseout in between. This\n        //fixes the highlighting bug. Eventually, events should be\n        //changed to trigger one itemmouseout between two itemmouseovers.\n        this.unHighlightItem();\n\n        if (!item || me.animating || (item.sprite && item.sprite._animating)) {\n            return;\n        }\n        me.callParent([item]);\n        if (!me.highlight) {\n            return;\n        }\n        if ('segment' in me.highlightCfg) {\n            highlightSegment = me.highlightCfg.segment;\n            animate = me.chart.animate;\n            //animate labels\n            if (me.labelsGroup) {\n                group = me.labelsGroup;\n                display = me.label.display;\n                label = group.getAt(item.index);\n                middle = (item.startAngle + item.endAngle) / 2 * rad;\n                r = highlightSegment.margin || 0;\n                x = r * Math.cos(middle);\n                y = r * Math.sin(middle);\n\n                //TODO(nico): rounding to 1e-10\n                //gives the right translation. Translation\n                //was buggy for very small numbers. In this\n                //case we're not looking to translate to very small\n                //numbers but not to translate at all.\n                if (Math.abs(x) < 1e-10) {\n                    x = 0;\n                }\n                if (Math.abs(y) < 1e-10) {\n                    y = 0;\n                }\n\n                if (animate) {\n                    label.stopAnimation();\n                    label.animate({\n                        to: {\n                            translate: {\n                                x: x,\n                                y: y\n                            }\n                        },\n                        duration: me.highlightDuration\n                    });\n                }\n                else {\n                    label.setAttributes({\n                        translate: {\n                            x: x,\n                            y: y\n                        }\n                    }, true);\n                }\n            }\n            //animate shadows\n            if (me.chart.shadow && item.shadows) {\n                i = 0;\n                shadows = item.shadows;\n                ln = shadows.length;\n                for (; i < ln; i++) {\n                    shadow = shadows[i];\n                    to = {};\n                    itemHighlightSegment = item.sprite._from.segment;\n                    for (prop in itemHighlightSegment) {\n                        if (! (prop in highlightSegment)) {\n                            to[prop] = itemHighlightSegment[prop];\n                        }\n                    }\n                    attrs = {\n                        segment: Ext.applyIf(to, me.highlightCfg.segment)\n                    };\n                    if (animate) {\n                        shadow.stopAnimation();\n                        shadow.animate({\n                            to: attrs,\n                            duration: me.highlightDuration\n                        });\n                    }\n                    else {\n                        shadow.setAttributes(attrs, true);\n                    }\n                }\n            }\n        }\n    },\n\n    /**\n     * Un-highlights the specified item. If no item is provided it will un-highlight the entire series.\n     * @param item {Object} Info about the item; same format as returned by #getItemForPoint\n     */\n    unHighlightItem: function() {\n        var me = this,\n            items,\n            animate,\n            shadowsEnabled,\n            group,\n            len,\n            i,\n            j,\n            display,\n            shadowLen,\n            p,\n            to,\n            ihs,\n            hs,\n            sprite,\n            shadows,\n            shadow,\n            item,\n            label,\n            attrs;\n        if (!me.highlight) {\n            return;\n        }\n\n        if (('segment' in me.highlightCfg) && me.items) {\n            items = me.items;\n            animate = me.chart.animate;\n            shadowsEnabled = !!me.chart.shadow;\n            group = me.labelsGroup;\n            len = items.length;\n            i = 0;\n            j = 0;\n            display = me.label.display;\n\n            for (; i < len; i++) {\n                item = items[i];\n                if (!item) {\n                    continue;\n                }\n                sprite = item.sprite;\n                if (sprite && sprite._highlighted) {\n                    //animate labels\n                    if (group) {\n                        label = group.getAt(item.index);\n                        attrs = Ext.apply({\n                            translate: {\n                                x: 0,\n                                y: 0\n                            }\n                        },\n                        display == 'rotate' ? {\n                            rotate: {\n                                x: label.attr.x,\n                                y: label.attr.y,\n                                degrees: label.attr.rotation.degrees\n                            }\n                        }: {});\n                        if (animate) {\n                            label.stopAnimation();\n                            label.animate({\n                                to: attrs,\n                                duration: me.highlightDuration\n                            });\n                        }\n                        else {\n                            label.setAttributes(attrs, true);\n                        }\n                    }\n                    if (shadowsEnabled) {\n                        shadows = item.shadows;\n                        shadowLen = shadows.length;\n                        for (; j < shadowLen; j++) {\n                            to = {};\n                            ihs = item.sprite._to.segment;\n                            hs = item.sprite._from.segment;\n                            Ext.apply(to, hs);\n                            for (p in ihs) {\n                                if (! (p in hs)) {\n                                    to[p] = ihs[p];\n                                }\n                            }\n                            shadow = shadows[j];\n                            if (animate) {\n                                shadow.stopAnimation();\n                                shadow.animate({\n                                    to: {\n                                        segment: to\n                                    },\n                                    duration: me.highlightDuration\n                                });\n                            }\n                            else {\n                                shadow.setAttributes({ segment: to }, true);\n                            }\n                        }\n                    }\n                }\n            }\n        }\n        me.callParent(arguments);\n    },\n\n    /**\n     * Returns the color of the series (to be displayed as color for the series legend item).\n     * @param item {Object} Info about the item; same format as returned by #getItemForPoint\n     */\n    getLegendColor: function(index) {\n        var me = this;\n        return (me.colorSet && me.colorSet[index % me.colorSet.length]) || me.colorArrayStyle[index % me.colorArrayStyle.length];\n    }\n});\n\n\n/**\n * @class Ext.chart.series.Radar\n *\n * Creates a Radar Chart. A Radar Chart is a useful visualization technique for comparing different quantitative values for\n * a constrained number of categories.\n *\n * As with all other series, the Radar series must be appended in the *series* Chart array configuration. See the Chart\n * documentation for more information. A typical configuration object for the radar series could be:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data1', 'data2', 'data3'],\n *         data: [\n *             { 'name': 'metric one',   'data1': 14, 'data2': 12, 'data3': 13 },\n *             { 'name': 'metric two',   'data1': 16, 'data2':  8, 'data3':  3 },\n *             { 'name': 'metric three', 'data1': 14, 'data2':  2, 'data3':  7 },\n *             { 'name': 'metric four',  'data1':  6, 'data2': 14, 'data3': 23 },\n *             { 'name': 'metric five',  'data1': 36, 'data2': 38, 'data3': 33 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         animate: true,\n *         theme:'Category2',\n *         store: store,\n *         axes: [{\n *             type: 'Radial',\n *             position: 'radial',\n *             label: {\n *                 display: true\n *             }\n *         }],\n *         series: [{\n *             type: 'radar',\n *             xField: 'name',\n *             yField: 'data1',\n *             showInLegend: true,\n *             showMarkers: true,\n *             markerConfig: {\n *                 radius: 5,\n *                 size: 5\n *             },\n *             style: {\n *                 'stroke-width': 2,\n *                 fill: 'none'\n *             }\n *         },{\n *             type: 'radar',\n *             xField: 'name',\n *             yField: 'data2',\n *             showMarkers: true,\n *             showInLegend: true,\n *             markerConfig: {\n *                 radius: 5,\n *                 size: 5\n *             },\n *             style: {\n *                 'stroke-width': 2,\n *                 fill: 'none'\n *             }\n *         },{\n *             type: 'radar',\n *             xField: 'name',\n *             yField: 'data3',\n *             showMarkers: true,\n *             showInLegend: true,\n *             markerConfig: {\n *                 radius: 5,\n *                 size: 5\n *             },\n *             style: {\n *                 'stroke-width': 2,\n *                 fill: 'none'\n *             }\n *         }]\n *     });\n *\n * In this configuration we add three series to the chart. Each of these series is bound to the same\n * categories field, `name` but bound to different properties for each category, `data1`, `data2` and\n * `data3` respectively. All series display markers by having `showMarkers` enabled. The configuration\n * for the markers of each series can be set by adding properties onto the markerConfig object.\n * Finally we override some theme styling properties by adding properties to the `style` object.\n *\n * @xtype radar\n */\nExt.define('Ext.chart.series.Radar', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.series.Series',\n\n    requires: ['Ext.chart.Shape', 'Ext.fx.Anim'],\n\n    /* End Definitions */\n\n    type: \"radar\",\n    alias: 'series.radar',\n\n\n    rad: Math.PI / 180,\n\n    showInLegend: false,\n\n    /**\n     * @cfg {Object} style\n     * An object containing styles for overriding series styles from Theming.\n     */\n    style: {},\n\n    constructor: function(config) {\n        this.callParent(arguments);\n        var me = this,\n            surface = me.chart.surface, i, l;\n        me.group = surface.getGroup(me.seriesId);\n        if (me.showMarkers) {\n            me.markerGroup = surface.getGroup(me.seriesId + '-markers');\n        }\n    },\n\n    /**\n     * Draws the series for the current chart.\n     */\n    drawSeries: function() {\n        var me = this,\n            store = me.chart.getChartStore(),\n            data = store.data.items,\n            d, record,\n            group = me.group,\n            sprite,\n            chart = me.chart,\n            seriesItems = chart.series.items,\n            s, sLen, series,\n            animate = chart.animate,\n            field = me.field || me.yField,\n            surface = chart.surface,\n            chartBBox = chart.chartBBox,\n            seriesIdx = me.seriesIdx,\n            colorArrayStyle = me.colorArrayStyle,\n            centerX, centerY,\n            items,\n            radius,\n            maxValue = 0,\n            fields = [],\n            max = Math.max,\n            cos = Math.cos,\n            sin = Math.sin,\n            pi2 = Math.PI * 2,\n            l = store.getCount(),\n            startPath, path, x, y, rho,\n            i, nfields,\n            seriesStyle = me.seriesStyle,\n            seriesLabelStyle = me.seriesLabelStyle,\n            first = chart.resizing || !me.radar,\n            axis = chart.axes && chart.axes.get(0),\n            aggregate = !(axis && axis.maximum);\n\n        me.setBBox();\n        \n        maxValue = aggregate? 0 : (axis.maximum || 0);\n        \n        Ext.apply(seriesStyle, me.style || {});\n\n        //if the store is empty then there's nothing to draw\n        if (!store || !store.getCount() || me.seriesIsHidden) {\n            me.hide();\n            me.items = [];\n            if (me.radar) {\n                me.radar.hide(true);\n            }\n            me.radar = null;\n            return;\n        }\n        \n        if(!seriesStyle['stroke']){\n            seriesStyle['stroke'] = colorArrayStyle[seriesIdx % colorArrayStyle.length];\n        }\n\n        me.unHighlightItem();\n        me.cleanHighlights();\n\n        centerX = me.centerX = chartBBox.x + (chartBBox.width / 2);\n        centerY = me.centerY = chartBBox.y + (chartBBox.height / 2);\n        me.radius = radius = Math.min(chartBBox.width, chartBBox.height) /2;\n        me.items = items = [];\n\n        if (aggregate) {\n            //get all renderer fields\n            for (s = 0, sLen = seriesItems.length; s < sLen; s++) {\n                series = seriesItems[s];\n                fields.push(series.yField);\n            }\n            //get maxValue to interpolate\n            for (d = 0; d < l; d++) {\n                record = data[d];\n                for (i = 0, nfields = fields.length; i < nfields; i++) {\n                    maxValue = max(+record.get(fields[i]), maxValue);\n                }\n            }\n        }\n        //ensure non-zero value.\n        maxValue = maxValue || 1;\n        //create path and items\n        startPath = []; path = [];\n        for (i = 0; i < l; i++) {\n            record = data[i];\n            rho = radius * record.get(field) / maxValue;\n            x = rho * cos(i / l * pi2);\n            y = rho * sin(i / l * pi2);\n            if (i == 0) {\n                path.push('M', x + centerX, y + centerY);\n                startPath.push('M', 0.01 * x + centerX, 0.01 * y + centerY);\n            } else {\n                path.push('L', x + centerX, y + centerY);\n                startPath.push('L', 0.01 * x + centerX, 0.01 * y + centerY);\n            }\n            items.push({\n                sprite: false, //TODO(nico): add markers\n                point: [centerX + x, centerY + y],\n                storeItem: record,\n                series: me\n            });\n        }\n        path.push('Z');\n        //create path sprite\n        if (!me.radar) {\n            me.radar = surface.add(Ext.apply({\n                type: 'path',\n                group: group,\n                path: startPath\n            }, seriesStyle || {}));\n        }\n        //reset on resizing\n        if (chart.resizing) {\n            me.radar.setAttributes({\n                path: startPath\n            }, true);\n        }\n        //render/animate\n        if (chart.animate) {\n            me.onAnimate(me.radar, {\n                to: Ext.apply({\n                    path: path\n                }, seriesStyle || {})\n            });\n        } else {\n            me.radar.setAttributes(Ext.apply({\n                path: path\n            }, seriesStyle || {}), true);\n        }\n        //render markers, labels and callouts\n        if (me.showMarkers) {\n            me.drawMarkers();\n        }\n        me.renderLabels();\n        me.renderCallouts();\n    },\n\n    // @private draws the markers for the lines (if any).\n    drawMarkers: function() {\n        var me = this,\n            chart = me.chart,\n            surface = chart.surface,\n            markerStyle = Ext.apply({}, me.markerStyle || {}),\n            endMarkerStyle = Ext.apply(markerStyle, me.markerConfig, {\n                fill: me.colorArrayStyle[me.seriesIdx % me.colorArrayStyle.length]\n            }),\n            items = me.items,\n            type = endMarkerStyle.type,\n            markerGroup = me.markerGroup,\n            centerX = me.centerX,\n            centerY = me.centerY,\n            item, i, l, marker;\n        delete endMarkerStyle.type;\n\n        for (i = 0, l = items.length; i < l; i++) {\n            item = items[i];\n            marker = markerGroup.getAt(i);\n            if (!marker) {\n                marker = Ext.chart.Shape[type](surface, Ext.apply({\n                    group: markerGroup,\n                    x: 0,\n                    y: 0,\n                    translate: {\n                        x: centerX,\n                        y: centerY\n                    }\n                }, endMarkerStyle));\n            }\n            else {\n                marker.show();\n            }\n            item.sprite = marker;\n            if (chart.resizing) {\n                marker.setAttributes({\n                    x: 0,\n                    y: 0,\n                    translate: {\n                        x: centerX,\n                        y: centerY\n                    }\n                }, true);\n            }\n            marker._to = {\n                translate: {\n                    x: item.point[0],\n                    y: item.point[1]\n                }\n            };\n            //render/animate\n            if (chart.animate) {\n                me.onAnimate(marker, {\n                    to: marker._to\n                });\n            }\n            else {\n                marker.setAttributes(Ext.apply(marker._to, endMarkerStyle || {}), true);\n            }\n        }\n    },\n\n    isItemInPoint: function(x, y, item) {\n        var point,\n            tolerance = 10,\n            abs = Math.abs;\n        point = item.point;\n        return (abs(point[0] - x) <= tolerance &&\n                abs(point[1] - y) <= tolerance);\n    },\n\n    // @private callback for when creating a label sprite.\n    onCreateLabel: function(storeItem, item, i, display) {\n        var me = this,\n            group = me.labelsGroup,\n            config = me.label,\n            centerX = me.centerX,\n            centerY = me.centerY,\n            point = item.point,\n            endLabelStyle = Ext.apply(me.seriesLabelStyle || {}, config);\n\n        return me.chart.surface.add(Ext.apply({\n            'type': 'text',\n            'text-anchor': 'middle',\n            'group': group,\n            'x': centerX,\n            'y': centerY\n        }, config || {}));\n    },\n\n    // @private callback for when placing a label sprite.\n    onPlaceLabel: function(label, storeItem, item, i, display, animate) {\n        var me = this,\n            chart = me.chart,\n            resizing = chart.resizing,\n            config = me.label,\n            format = config.renderer,\n            field = config.field,\n            centerX = me.centerX,\n            centerY = me.centerY,\n            opt = {\n                x: item.point[0],\n                y: item.point[1]\n            },\n            x = opt.x - centerX,\n            y = opt.y - centerY;\n\n        label.setAttributes({\n            text: format(storeItem.get(field)),\n            hidden: true\n        },\n        true);\n\n        if (resizing) {\n            label.setAttributes({\n                x: centerX,\n                y: centerY\n            }, true);\n        }\n\n        if (animate) {\n            label.show(true);\n            me.onAnimate(label, {\n                to: opt\n            });\n        } else {\n            label.setAttributes(opt, true);\n            label.show(true);\n        }\n    },\n\n    // @private for toggling (show/hide) series.\n    toggleAll: function(show) {\n        var me = this,\n            i, ln, shadow, shadows;\n        if (!show) {\n            Ext.chart.series.Radar.superclass.hideAll.call(me);\n        }\n        else {\n            Ext.chart.series.Radar.superclass.showAll.call(me);\n        }\n        if (me.radar) {\n            me.radar.setAttributes({\n                hidden: !show\n            }, true);\n            //hide shadows too\n            if (me.radar.shadows) {\n                for (i = 0, shadows = me.radar.shadows, ln = shadows.length; i < ln; i++) {\n                    shadow = shadows[i];\n                    shadow.setAttributes({\n                        hidden: !show\n                    }, true);\n                }\n            }\n        }\n    },\n\n    // @private hide all elements in the series.\n    hideAll: function() {\n        this.toggleAll(false);\n        this.hideMarkers(0);\n    },\n\n    // @private show all elements in the series.\n    showAll: function() {\n        this.toggleAll(true);\n    },\n\n    // @private hide all markers that belong to `markerGroup`\n    hideMarkers: function(index) {\n        var me = this,\n            count = me.markerGroup && me.markerGroup.getCount() || 0,\n            i = index || 0;\n        for (; i < count; i++) {\n            me.markerGroup.getAt(i).hide(true);\n        }\n    }\n});\n\n\n/**\n * @class Ext.chart.series.Scatter\n * @extends Ext.chart.series.Cartesian\n *\n * Creates a Scatter Chart. The scatter plot is useful when trying to display more than two variables in the same visualization.\n * These variables can be mapped into x, y coordinates and also to an element's radius/size, color, etc.\n * As with all other series, the Scatter Series must be appended in the *series* Chart array configuration. See the Chart\n * documentation for more information on creating charts. A typical configuration object for the scatter could be:\n *\n *     @example\n *     var store = Ext.create('Ext.data.JsonStore', {\n *         fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],\n *         data: [\n *             { 'name': 'metric one',   'data1': 10, 'data2': 12, 'data3': 14, 'data4': 8,  'data5': 13 },\n *             { 'name': 'metric two',   'data1': 7,  'data2': 8,  'data3': 16, 'data4': 10, 'data5': 3  },\n *             { 'name': 'metric three', 'data1': 5,  'data2': 2,  'data3': 14, 'data4': 12, 'data5': 7  },\n *             { 'name': 'metric four',  'data1': 2,  'data2': 14, 'data3': 6,  'data4': 1,  'data5': 23 },\n *             { 'name': 'metric five',  'data1': 27, 'data2': 38, 'data3': 36, 'data4': 13, 'data5': 33 }\n *         ]\n *     });\n *\n *     Ext.create('Ext.chart.Chart', {\n *         renderTo: Ext.getBody(),\n *         width: 500,\n *         height: 300,\n *         animate: true,\n *         theme:'Category2',\n *         store: store,\n *         axes: [{\n *             type: 'Numeric',\n *             position: 'left',\n *             fields: ['data2', 'data3'],\n *             title: 'Sample Values',\n *             grid: true,\n *             minimum: 0\n *         }, {\n *             type: 'Category',\n *             position: 'bottom',\n *             fields: ['name'],\n *             title: 'Sample Metrics'\n *         }],\n *         series: [{\n *             type: 'scatter',\n *             markerConfig: {\n *                 radius: 5,\n *                 size: 5\n *             },\n *             axis: 'left',\n *             xField: 'name',\n *             yField: 'data2'\n *         }, {\n *             type: 'scatter',\n *             markerConfig: {\n *                 radius: 5,\n *                 size: 5\n *             },\n *             axis: 'left',\n *             xField: 'name',\n *             yField: 'data3'\n *         }]\n *     });\n *\n * In this configuration we add three different categories of scatter series. Each of them is bound to a different field of the same data store,\n * `data1`, `data2` and `data3` respectively. All x-fields for the series must be the same field, in this case `name`.\n * Each scatter series has a different styling configuration for markers, specified by the `markerConfig` object. Finally we set the left axis as\n * axis to show the current values of the elements.\n *\n * @xtype scatter\n */\nExt.define('Ext.chart.series.Scatter', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.chart.series.Cartesian',\n\n    requires: ['Ext.chart.axis.Axis', 'Ext.chart.Shape', 'Ext.fx.Anim'],\n\n    /* End Definitions */\n\n    type: 'scatter',\n    alias: 'series.scatter',\n\n    /**\n     * @cfg {Object} markerConfig\n     * The display style for the scatter series markers.\n     */\n\n    /**\n     * @cfg {Object} style\n     * Append styling properties to this object for it to override theme properties.\n     */\n    \n    /**\n     * @cfg {String/Array} axis\n     * The position of the axis to bind the values to. Possible values are 'left', 'bottom', 'top' and 'right'.\n     * You must explicitly set this value to bind the values of the line series to the ones in the axis, otherwise a\n     * relative scale will be used. If multiple axes are being used, they should both be specified in in the configuration.\n     */\n\n    constructor: function(config) {\n        this.callParent(arguments);\n        var me = this,\n            shadow = me.chart.shadow,\n            surface = me.chart.surface, i, l;\n        Ext.apply(me, config, {\n            style: {},\n            markerConfig: {},\n            shadowAttributes: [{\n                \"stroke-width\": 6,\n                \"stroke-opacity\": 0.05,\n                stroke: 'rgb(0, 0, 0)'\n            }, {\n                \"stroke-width\": 4,\n                \"stroke-opacity\": 0.1,\n                stroke: 'rgb(0, 0, 0)'\n            }, {\n                \"stroke-width\": 2,\n                \"stroke-opacity\": 0.15,\n                stroke: 'rgb(0, 0, 0)'\n            }]\n        });\n        me.group = surface.getGroup(me.seriesId);\n        if (shadow) {\n            for (i = 0, l = me.shadowAttributes.length; i < l; i++) {\n                me.shadowGroups.push(surface.getGroup(me.seriesId + '-shadows' + i));\n            }\n        }\n    },\n\n    // @private Get chart and data boundaries\n    getBounds: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            chartAxes = chart.axes,\n            boundAxes = me.getAxesForXAndYFields(),\n            boundXAxis = boundAxes.xAxis,\n            boundYAxis = boundAxes.yAxis,\n            bbox, xScale, yScale, ln, minX, minY, maxX, maxY, i, axis, ends;\n\n        me.setBBox();\n        bbox = me.bbox;\n\n        if (axis = chartAxes.get(boundXAxis)) {\n            ends = axis.applyData();\n            minX = ends.from;\n            maxX = ends.to;\n        }\n\n        if (axis = chartAxes.get(boundYAxis)) {\n            ends = axis.applyData();\n            minY = ends.from;\n            maxY = ends.to;\n        }\n\n        // If a field was specified without a corresponding axis, create one to get bounds\n        if (me.xField && !Ext.isNumber(minX)) {\n            axis = me.getMinMaxXValues();\n            minX = axis[0];\n            maxX = axis[1];\n        }\n\n        if (me.yField && !Ext.isNumber(minY)) {\n            axis = me.getMinMaxYValues();\n            minY = axis[0];\n            maxY = axis[1];\n        }\n\n        if (isNaN(minX)) {\n            minX = 0;\n            maxX = store.getCount() - 1;\n            xScale = bbox.width / (store.getCount() - 1);\n        }\n        else {\n            xScale = bbox.width / (maxX - minX);\n        }\n\n        if (isNaN(minY)) {\n            minY = 0;\n            maxY = store.getCount() - 1;\n            yScale = bbox.height / (store.getCount() - 1);\n        }\n        else {\n            yScale = bbox.height / (maxY - minY);\n        }\n\n        return {\n            bbox: bbox,\n            minX: minX,\n            minY: minY,\n            xScale: xScale,\n            yScale: yScale\n        };\n    },\n\n    // @private Build an array of paths for the chart\n    getPaths: function() {\n        var me = this,\n            chart = me.chart,\n            enableShadows = chart.shadow,\n            store = chart.getChartStore(),\n            data = store.data.items,\n            i, ln, record,\n            group = me.group,\n            bounds = me.bounds = me.getBounds(),\n            bbox = me.bbox,\n            xScale = bounds.xScale,\n            yScale = bounds.yScale,\n            minX = bounds.minX,\n            minY = bounds.minY,\n            boxX = bbox.x,\n            boxY = bbox.y,\n            boxHeight = bbox.height,\n            items = me.items = [],\n            attrs = [],\n            x, y, xValue, yValue, sprite;\n\n        for (i = 0, ln = data.length; i < ln; i++) {\n            record = data[i];\n            xValue = record.get(me.xField);\n            yValue = record.get(me.yField);\n            //skip undefined or null values\n            if (typeof yValue == 'undefined' || (typeof yValue == 'string' && !yValue)\n                || xValue == null || yValue == null) {\n                if (Ext.isDefined(Ext.global.console)) {\n                    Ext.global.console.warn(\"[Ext.chart.series.Scatter]  Skipping a store element with a value which is either undefined or null  at \", record, xValue, yValue);\n                }\n                continue;\n            }\n            // Ensure a value\n            if (typeof xValue == 'string' || typeof xValue == 'object' && !Ext.isDate(xValue)) {\n                xValue = i;\n            }\n            if (typeof yValue == 'string' || typeof yValue == 'object' && !Ext.isDate(yValue)) {\n                yValue = i;\n            }\n            x = boxX + (xValue - minX) * xScale;\n            y = boxY + boxHeight - (yValue - minY) * yScale;\n            attrs.push({\n                x: x,\n                y: y\n            });\n\n            me.items.push({\n                series: me,\n                value: [xValue, yValue],\n                point: [x, y],\n                storeItem: record\n            });\n\n            // When resizing, reset before animating\n            if (chart.animate && chart.resizing) {\n                sprite = group.getAt(i);\n                if (sprite) {\n                    me.resetPoint(sprite);\n                    if (enableShadows) {\n                        me.resetShadow(sprite);\n                    }\n                }\n            }\n        }\n        return attrs;\n    },\n\n    // @private translate point to the center\n    resetPoint: function(sprite) {\n        var bbox = this.bbox;\n        sprite.setAttributes({\n            translate: {\n                x: (bbox.x + bbox.width) / 2,\n                y: (bbox.y + bbox.height) / 2\n            }\n        }, true);\n    },\n\n    // @private translate shadows of a sprite to the center\n    resetShadow: function(sprite) {\n        var me = this,\n            shadows = sprite.shadows,\n            shadowAttributes = me.shadowAttributes,\n            ln = me.shadowGroups.length,\n            bbox = me.bbox,\n            i, attr;\n        for (i = 0; i < ln; i++) {\n            attr = Ext.apply({}, shadowAttributes[i]);\n            // TODO: fix this with setAttributes\n            if (attr.translate) {\n                attr.translate.x += (bbox.x + bbox.width) / 2;\n                attr.translate.y += (bbox.y + bbox.height) / 2;\n            }\n            else {\n                attr.translate = {\n                    x: (bbox.x + bbox.width) / 2,\n                    y: (bbox.y + bbox.height) / 2\n                };\n            }\n            shadows[i].setAttributes(attr, true);\n        }\n    },\n\n    // @private create a new point\n    createPoint: function(attr, type) {\n        var me = this,\n            chart = me.chart,\n            group = me.group,\n            bbox = me.bbox;\n\n        return Ext.chart.Shape[type](chart.surface, Ext.apply({}, {\n            x: 0,\n            y: 0,\n            group: group,\n            translate: {\n                x: (bbox.x + bbox.width) / 2,\n                y: (bbox.y + bbox.height) / 2\n            }\n        }, attr));\n    },\n\n    // @private create a new set of shadows for a sprite\n    createShadow: function(sprite, endMarkerStyle, type) {\n        var me = this,\n            chart = me.chart,\n            shadowGroups = me.shadowGroups,\n            shadowAttributes = me.shadowAttributes,\n            lnsh = shadowGroups.length,\n            bbox = me.bbox,\n            i, shadow, shadows, attr;\n\n        sprite.shadows = shadows = [];\n\n        for (i = 0; i < lnsh; i++) {\n            attr = Ext.apply({}, shadowAttributes[i]);\n            if (attr.translate) {\n                attr.translate.x += (bbox.x + bbox.width) / 2;\n                attr.translate.y += (bbox.y + bbox.height) / 2;\n            }\n            else {\n                Ext.apply(attr, {\n                    translate: {\n                        x: (bbox.x + bbox.width) / 2,\n                        y: (bbox.y + bbox.height) / 2\n                    }\n                });\n            }\n            Ext.apply(attr, endMarkerStyle);\n            shadow = Ext.chart.Shape[type](chart.surface, Ext.apply({}, {\n                x: 0,\n                y: 0,\n                group: shadowGroups[i]\n            }, attr));\n            shadows.push(shadow);\n        }\n    },\n\n    /**\n     * Draws the series for the current chart.\n     */\n    drawSeries: function() {\n        var me = this,\n            chart = me.chart,\n            store = chart.getChartStore(),\n            group = me.group,\n            enableShadows = chart.shadow,\n            shadowGroups = me.shadowGroups,\n            shadowAttributes = me.shadowAttributes,\n            lnsh = shadowGroups.length,\n            sprite, attrs, attr, ln, i, endMarkerStyle, shindex, type, shadows,\n            rendererAttributes, shadowAttribute;\n\n        endMarkerStyle = Ext.apply(me.markerStyle, me.markerConfig);\n        type = endMarkerStyle.type;\n        delete endMarkerStyle.type;\n\n        //if the store is empty then there's nothing to be rendered\n        if (!store || !store.getCount()) {\n            me.hide();\n            me.items = [];\n            return;\n        }\n\n\n        me.unHighlightItem();\n        me.cleanHighlights();\n\n        attrs = me.getPaths();\n        ln = attrs.length;\n        for (i = 0; i < ln; i++) {\n            attr = attrs[i];\n            sprite = group.getAt(i);\n            Ext.apply(attr, endMarkerStyle);\n\n            // Create a new sprite if needed (no height)\n            if (!sprite) {\n                sprite = me.createPoint(attr, type);\n                if (enableShadows) {\n                    me.createShadow(sprite, endMarkerStyle, type);\n                }\n            }\n\n            shadows = sprite.shadows;\n            if (chart.animate) {\n                rendererAttributes = me.renderer(sprite, store.getAt(i), { translate: attr }, i, store);\n                sprite._to = rendererAttributes;\n                me.onAnimate(sprite, {\n                    to: rendererAttributes\n                });\n                //animate shadows\n                for (shindex = 0; shindex < lnsh; shindex++) {\n                    shadowAttribute = Ext.apply({}, shadowAttributes[shindex]);\n                    rendererAttributes = me.renderer(shadows[shindex], store.getAt(i), Ext.apply({}, { \n                        hidden: false,\n                        translate: {\n                            x: attr.x + (shadowAttribute.translate? shadowAttribute.translate.x : 0),\n                            y: attr.y + (shadowAttribute.translate? shadowAttribute.translate.y : 0)\n                        }\n                    }, shadowAttribute), i, store);\n                    me.onAnimate(shadows[shindex], { to: rendererAttributes });\n                }\n            }\n            else {\n                rendererAttributes = me.renderer(sprite, store.getAt(i), { translate: attr }, i, store);\n                sprite._to = rendererAttributes;\n                sprite.setAttributes(rendererAttributes, true);\n                //animate shadows\n                for (shindex = 0; shindex < lnsh; shindex++) {\n                    shadowAttribute = Ext.apply({}, shadowAttributes[shindex]);\n                    rendererAttributes = me.renderer(shadows[shindex], store.getAt(i), Ext.apply({}, { \n                        hidden: false,\n                        translate: {\n                            x: attr.x + (shadowAttribute.translate? shadowAttribute.translate.x : 0),\n                            y: attr.y + (shadowAttribute.translate? shadowAttribute.translate.y : 0)\n                        } \n                    }, shadowAttribute), i, store);\n                    shadows[shindex].setAttributes(rendererAttributes, true);\n                }\n            }\n            me.items[i].sprite = sprite;\n        }\n\n        // Hide unused sprites\n        ln = group.getCount();\n        for (i = attrs.length; i < ln; i++) {\n            group.getAt(i).hide(true);\n        }\n        me.renderLabels();\n        me.renderCallouts();\n    },\n\n    // @private callback for when creating a label sprite.\n    onCreateLabel: function(storeItem, item, i, display) {\n        var me = this,\n            group = me.labelsGroup,\n            config = me.label,\n            endLabelStyle = Ext.apply({}, config, me.seriesLabelStyle),\n            bbox = me.bbox;\n\n        return me.chart.surface.add(Ext.apply({\n            type: 'text',\n            group: group,\n            x: item.point[0],\n            y: bbox.y + bbox.height / 2\n        }, endLabelStyle));\n    },\n\n    // @private callback for when placing a label sprite.\n    onPlaceLabel: function(label, storeItem, item, i, display, animate) {\n        var me = this,\n            chart = me.chart,\n            resizing = chart.resizing,\n            config = me.label,\n            format = config.renderer,\n            field = config.field,\n            bbox = me.bbox,\n            x = item.point[0],\n            y = item.point[1],\n            radius = item.sprite.attr.radius,\n            bb, width, height, anim;\n\n        label.setAttributes({\n            text: format(storeItem.get(field)),\n            hidden: true\n        }, true);\n\n        if (display == 'rotate') {\n            label.setAttributes({\n                'text-anchor': 'start',\n                'rotation': {\n                    x: x,\n                    y: y,\n                    degrees: -45\n                }\n            }, true);\n            //correct label position to fit into the box\n            bb = label.getBBox();\n            width = bb.width;\n            height = bb.height;\n            x = x < bbox.x? bbox.x : x;\n            x = (x + width > bbox.x + bbox.width)? (x - (x + width - bbox.x - bbox.width)) : x;\n            y = (y - height < bbox.y)? bbox.y + height : y;\n\n        } else if (display == 'under' || display == 'over') {\n            //TODO(nicolas): find out why width/height values in circle bounding boxes are undefined.\n            bb = item.sprite.getBBox();\n            bb.width = bb.width || (radius * 2);\n            bb.height = bb.height || (radius * 2);\n            y = y + (display == 'over'? -bb.height : bb.height);\n            //correct label position to fit into the box\n            bb = label.getBBox();\n            width = bb.width/2;\n            height = bb.height/2;\n            x = x - width < bbox.x ? bbox.x + width : x;\n            x = (x + width > bbox.x + bbox.width) ? (x - (x + width - bbox.x - bbox.width)) : x;\n            y = y - height < bbox.y? bbox.y + height : y;\n            y = (y + height > bbox.y + bbox.height) ? (y - (y + height - bbox.y - bbox.height)) : y;\n        }\n\n        if (!chart.animate) {\n            label.setAttributes({\n                x: x,\n                y: y\n            }, true);\n            label.show(true);\n        }\n        else {\n            if (resizing) {\n                anim = item.sprite.getActiveAnimation();\n                if (anim) {\n                    anim.on('afteranimate', function() {\n                        label.setAttributes({\n                            x: x,\n                            y: y\n                        }, true);\n                        label.show(true);\n                    });\n                }\n                else {\n                    label.show(true);\n                }\n            }\n            else {\n                me.onAnimate(label, {\n                    to: {\n                        x: x,\n                        y: y\n                    }\n                });\n            }\n        }\n    },\n\n    // @private callback for when placing a callout sprite.\n    onPlaceCallout: function(callout, storeItem, item, i, display, animate, index) {\n        var me = this,\n            chart = me.chart,\n            surface = chart.surface,\n            resizing = chart.resizing,\n            config = me.callouts,\n            items = me.items,\n            cur = item.point,\n            normal,\n            bbox = callout.label.getBBox(),\n            offsetFromViz = 30,\n            offsetToSide = 10,\n            offsetBox = 3,\n            boxx, boxy, boxw, boxh,\n            p, clipRect = me.bbox,\n            x, y;\n\n        //position\n        normal = [Math.cos(Math.PI /4), -Math.sin(Math.PI /4)];\n        x = cur[0] + normal[0] * offsetFromViz;\n        y = cur[1] + normal[1] * offsetFromViz;\n\n        //box position and dimensions\n        boxx = x + (normal[0] > 0? 0 : -(bbox.width + 2 * offsetBox));\n        boxy = y - bbox.height /2 - offsetBox;\n        boxw = bbox.width + 2 * offsetBox;\n        boxh = bbox.height + 2 * offsetBox;\n\n        //now check if we're out of bounds and invert the normal vector correspondingly\n        //this may add new overlaps between labels (but labels won't be out of bounds).\n        if (boxx < clipRect[0] || (boxx + boxw) > (clipRect[0] + clipRect[2])) {\n            normal[0] *= -1;\n        }\n        if (boxy < clipRect[1] || (boxy + boxh) > (clipRect[1] + clipRect[3])) {\n            normal[1] *= -1;\n        }\n\n        //update positions\n        x = cur[0] + normal[0] * offsetFromViz;\n        y = cur[1] + normal[1] * offsetFromViz;\n\n        //update box position and dimensions\n        boxx = x + (normal[0] > 0? 0 : -(bbox.width + 2 * offsetBox));\n        boxy = y - bbox.height /2 - offsetBox;\n        boxw = bbox.width + 2 * offsetBox;\n        boxh = bbox.height + 2 * offsetBox;\n\n        if (chart.animate) {\n            //set the line from the middle of the pie to the box.\n            me.onAnimate(callout.lines, {\n                to: {\n                    path: [\"M\", cur[0], cur[1], \"L\", x, y, \"Z\"]\n                }\n            }, true);\n            //set box position\n            me.onAnimate(callout.box, {\n                to: {\n                    x: boxx,\n                    y: boxy,\n                    width: boxw,\n                    height: boxh\n                }\n            }, true);\n            //set text position\n            me.onAnimate(callout.label, {\n                to: {\n                    x: x + (normal[0] > 0? offsetBox : -(bbox.width + offsetBox)),\n                    y: y\n                }\n            }, true);\n        } else {\n            //set the line from the middle of the pie to the box.\n            callout.lines.setAttributes({\n                path: [\"M\", cur[0], cur[1], \"L\", x, y, \"Z\"]\n            }, true);\n            //set box position\n            callout.box.setAttributes({\n                x: boxx,\n                y: boxy,\n                width: boxw,\n                height: boxh\n            }, true);\n            //set text position\n            callout.label.setAttributes({\n                x: x + (normal[0] > 0? offsetBox : -(bbox.width + offsetBox)),\n                y: y\n            }, true);\n        }\n        for (p in callout) {\n            callout[p].show(true);\n        }\n    },\n\n    // @private handles sprite animation for the series.\n    onAnimate: function(sprite, attr) {\n        sprite.show();\n        return this.callParent(arguments);\n    },\n\n    isItemInPoint: function(x, y, item) {\n        var point,\n            tolerance = 10,\n            abs = Math.abs;\n\n        function dist(point) {\n            var dx = abs(point[0] - x),\n                dy = abs(point[1] - y);\n            return Math.sqrt(dx * dx + dy * dy);\n        }\n        point = item.point;\n        return (point[0] - tolerance <= x && point[0] + tolerance >= x &&\n            point[1] - tolerance <= y && point[1] + tolerance >= y);\n    }\n});\n\n\n/**\n * This layout allows you to easily render content into an HTML table. The total number of columns can be specified, and\n * rowspan and colspan can be used to create complex layouts within the table. This class is intended to be extended or\n * created via the `layout: {type: 'table'}` {@link Ext.container.Container#layout} config, and should generally not\n * need to be created directly via the new keyword.\n *\n * Note that when creating a layout via config, the layout-specific config properties must be passed in via the {@link\n * Ext.container.Container#layout} object which will then be applied internally to the layout. In the case of\n * TableLayout, the only valid layout config properties are {@link #columns} and {@link #tableAttrs}. However, the items\n * added to a TableLayout can supply the following table-specific config properties:\n *\n *   - **rowspan** Applied to the table cell containing the item.\n *   - **colspan** Applied to the table cell containing the item.\n *   - **cellId** An id applied to the table cell containing the item.\n *   - **cellCls** A CSS class name added to the table cell containing the item.\n *\n * The basic concept of building up a TableLayout is conceptually very similar to building up a standard HTML table. You\n * simply add each panel (or \"cell\") that you want to include along with any span attributes specified as the special\n * config properties of rowspan and colspan which work exactly like their HTML counterparts. Rather than explicitly\n * creating and nesting rows and columns as you would in HTML, you simply specify the total column count in the\n * layout config and start adding panels in their natural order from left to right, top to bottom. The layout will\n * automatically figure out, based on the column count, rowspans and colspans, how to position each panel within the\n * table. Just like with HTML tables, your rowspans and colspans must add up correctly in your overall layout or you'll\n * end up with missing and/or extra cells! Example usage:\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Table Layout',\n *         width: 300,\n *         height: 150,\n *         layout: {\n *             type: 'table',\n *             // The total column count must be specified here\n *             columns: 3\n *         },\n *         defaults: {\n *             // applied to each contained panel\n *             bodyStyle: 'padding:20px'\n *         },\n *         items: [{\n *             html: 'Cell A content',\n *             rowspan: 2\n *         },{\n *             html: 'Cell B content',\n *             colspan: 2\n *         },{\n *             html: 'Cell C content',\n *             cellCls: 'highlight'\n *         },{\n *             html: 'Cell D content'\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.layout.container.Table', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.table'],\n    extend: 'Ext.layout.container.Container',\n    alternateClassName: 'Ext.layout.TableLayout',\n\n    /* End Definitions */\n\n    /**\n     * @cfg {Number} columns\n     * The total number of columns to create in the table for this layout. If not specified, all Components added to\n     * this layout will be rendered into a single row using one column per Component.\n     */\n\n    // private\n    monitorResize:false,\n\n    type: 'table',\n\n    clearEl: true, // Base class will not create it if already truthy. Not needed in tables.\n\n    targetCls: Ext.baseCSSPrefix + 'table-layout-ct',\n    tableCls: Ext.baseCSSPrefix + 'table-layout',\n    cellCls: Ext.baseCSSPrefix + 'table-layout-cell',\n\n    /**\n     * @cfg {Object} tableAttrs\n     * An object containing properties which are added to the {@link Ext.DomHelper DomHelper} specification used to\n     * create the layout's `<table>` element. Example:\n     *\n     *     {\n     *         xtype: 'panel',\n     *         layout: {\n     *             type: 'table',\n     *             columns: 3,\n     *             tableAttrs: {\n     *                 style: {\n     *                     width: '100%'\n     *                 }\n     *             }\n     *         }\n     *     }\n     */\n    tableAttrs: null,\n\n    /**\n     * @cfg {Object} trAttrs\n     * An object containing properties which are added to the {@link Ext.DomHelper DomHelper} specification used to\n     * create the layout's `<tr>` elements.\n     */\n\n    /**\n     * @cfg {Object} tdAttrs\n     * An object containing properties which are added to the {@link Ext.DomHelper DomHelper} specification used to\n     * create the layout's `<td>` elements.\n     */\n\n    itemSizePolicy: {\n        setsWidth: 0,\n        setsHeight: 0\n    },\n\n    getItemSizePolicy: function (item) {\n        return this.itemSizePolicy;\n    },\n\n    getLayoutItems: function() {\n        var me = this,\n            result = [],\n            items = me.callParent(),\n            item,\n            len = items.length, i;\n\n        for (i = 0; i < len; i++) {\n            item = items[i];\n            if (!item.hidden) {\n                result.push(item);\n            }\n        }\n        return result;\n    },\n\n    /**\n     * @private\n     * Iterates over all passed items, ensuring they are rendered in a cell in the proper\n     * location in the table structure.\n     */\n    renderChildren: function() {\n        var me = this,\n            items = me.getLayoutItems(),\n            tbody = me.owner.getTargetEl().child('table', true).tBodies[0],\n            rows = tbody.rows,\n            i = 0,\n            len = items.length,\n            cells, curCell, rowIdx, cellIdx, item, trEl, tdEl, itemCt;\n\n        // Calculate the correct cell structure for the current items\n        cells = me.calculateCells(items);\n\n        // Loop over each cell and compare to the current cells in the table, inserting/\n        // removing/moving cells as needed, and making sure each item is rendered into\n        // the correct cell.\n        for (; i < len; i++) {\n            curCell = cells[i];\n            rowIdx = curCell.rowIdx;\n            cellIdx = curCell.cellIdx;\n            item = items[i];\n\n            // If no row present, create and insert one\n            trEl = rows[rowIdx];\n            if (!trEl) {\n                trEl = tbody.insertRow(rowIdx);\n                if (me.trAttrs) {\n                    trEl.set(me.trAttrs);\n                }\n            }\n\n            // If no cell present, create and insert one\n            itemCt = tdEl = Ext.get(trEl.cells[cellIdx] || trEl.insertCell(cellIdx));\n            if (me.needsDivWrap()) { //create wrapper div if needed - see docs below\n                itemCt = tdEl.first() || tdEl.createChild({tag: 'div'});\n                itemCt.setWidth(null);\n            }\n\n            // Render or move the component into the cell\n            if (!item.rendered) {\n                me.renderItem(item, itemCt, 0);\n            }\n            else if (!me.isValidParent(item, itemCt, rowIdx, cellIdx, tbody)) {\n                me.moveItem(item, itemCt, 0);\n            }\n\n            // Set the cell properties\n            if (me.tdAttrs) {\n                tdEl.set(me.tdAttrs);\n            }\n            if (item.tdAttrs) {\n                tdEl.set(item.tdAttrs);\n            }\n            tdEl.set({\n                colSpan: item.colspan || 1,\n                rowSpan: item.rowspan || 1,\n                id: item.cellId || '',\n                cls: me.cellCls + ' ' + (item.cellCls || '')\n            });\n\n            // If at the end of a row, remove any extra cells\n            if (!cells[i + 1] || cells[i + 1].rowIdx !== rowIdx) {\n                cellIdx++;\n                while (trEl.cells[cellIdx]) {\n                    trEl.deleteCell(cellIdx);\n                }\n            }\n        }\n\n        // Delete any extra rows\n        rowIdx++;\n        while (tbody.rows[rowIdx]) {\n            tbody.deleteRow(rowIdx);\n        }\n    },\n\n    calculate: function (ownerContext) {\n        if (!ownerContext.hasDomProp('containerChildrenDone')) {\n            this.done = false;\n        } else {\n            var targetContext = ownerContext.targetContext,\n                widthShrinkWrap = ownerContext.widthModel.shrinkWrap,\n                heightShrinkWrap = ownerContext.heightModel.shrinkWrap,\n                shrinkWrap = heightShrinkWrap || widthShrinkWrap,\n                table = shrinkWrap && targetContext.el.child('table', true),\n                targetPadding = shrinkWrap && targetContext.getPaddingInfo();\n\n            if (widthShrinkWrap) {\n                ownerContext.setContentWidth(table.offsetWidth + targetPadding.width, true);\n            }\n\n            if (heightShrinkWrap) {\n                ownerContext.setContentHeight(table.offsetHeight + targetPadding.height, true);\n            }\n        }\n    },\n\n    finalizeLayout: function() {\n        if (this.needsDivWrap()) {\n            // set wrapper div width to match layed out item - see docs below\n            var items = this.getLayoutItems(),\n                i,\n                iLen  = items.length,\n                item;\n\n            for (i = 0; i < iLen; i++) {\n                item = items[i];\n\n                Ext.fly(item.el.dom.parentNode).setWidth(item.getWidth());\n            }\n        }\n        if (Ext.isIE6 || (Ext.isIEQuirks)) {\n            // Fixes an issue where the table won't paint\n            this.owner.getTargetEl().child('table').repaint();\n        }\n    },\n\n    /**\n     * @private\n     * Determine the row and cell indexes for each component, taking into consideration\n     * the number of columns and each item's configured colspan/rowspan values.\n     * @param {Array} items The layout components\n     * @return {Object[]} List of row and cell indexes for each of the components\n     */\n    calculateCells: function(items) {\n        var cells = [],\n            rowIdx = 0,\n            colIdx = 0,\n            cellIdx = 0,\n            totalCols = this.columns || Infinity,\n            rowspans = [], //rolling list of active rowspans for each column\n            i = 0, j,\n            len = items.length,\n            item;\n\n        for (; i < len; i++) {\n            item = items[i];\n\n            // Find the first available row/col slot not taken up by a spanning cell\n            while (colIdx >= totalCols || rowspans[colIdx] > 0) {\n                if (colIdx >= totalCols) {\n                    // move down to next row\n                    colIdx = 0;\n                    cellIdx = 0;\n                    rowIdx++;\n\n                    // decrement all rowspans\n                    for (j = 0; j < totalCols; j++) {\n                        if (rowspans[j] > 0) {\n                            rowspans[j]--;\n                        }\n                    }\n                } else {\n                    colIdx++;\n                }\n            }\n\n            // Add the cell info to the list\n            cells.push({\n                rowIdx: rowIdx,\n                cellIdx: cellIdx\n            });\n\n            // Increment\n            for (j = item.colspan || 1; j; --j) {\n                rowspans[colIdx] = item.rowspan || 1;\n                ++colIdx;\n            }\n            ++cellIdx;\n        }\n\n        return cells;\n    },\n\n    getRenderTree: function() {\n        var me = this,\n            items = me.getLayoutItems(),\n            cells,\n            rows = [],\n            result = Ext.apply({\n                tag: 'table',\n                role: 'presentation',\n                cls: me.tableCls,\n                cellspacing: 0,\n                cn: {\n                    tag: 'tbody',\n                    cn: rows\n                }\n            }, me.tableAttrs),\n            tdAttrs = me.tdAttrs,\n            needsDivWrap = me.needsDivWrap(),\n            i, len = items.length, item, curCell, tr, rowIdx, cellIdx, cell;\n\n        // Calculate the correct cell structure for the current items\n        cells = me.calculateCells(items);\n\n        for (i = 0; i < len; i++) {\n            item = items[i];\n            \n            curCell = cells[i];\n            rowIdx = curCell.rowIdx;\n            cellIdx = curCell.cellIdx;\n\n            // If no row present, create and insert one\n            tr = rows[rowIdx];\n            if (!tr) {\n                tr = rows[rowIdx] = {\n                    tag: 'tr',\n                    cn: []\n                };\n                if (me.trAttrs) {\n                    Ext.apply(tr, me.trAttrs);\n                }\n            }\n\n            // If no cell present, create and insert one\n            cell = tr.cn[cellIdx] = {\n                tag: 'td'\n            };\n            if (tdAttrs) {\n                Ext.apply(cell, tdAttrs);\n            }\n            Ext.apply(cell, {\n                colSpan: item.colspan || 1,\n                rowSpan: item.rowspan || 1,\n                id: item.cellId || '',\n                cls: me.cellCls + ' ' + (item.cellCls || '')\n            });\n\n            if (needsDivWrap) { //create wrapper div if needed - see docs below\n                cell = cell.cn = {\n                    tag: 'div'\n                };\n            }\n\n            me.configureItem(item);\n            // The DomHelper config of the item is the cell's sole child\n            cell.cn = item.getRenderTree();\n        }\n        return result;\n    },\n\n    isValidParent: function(item, target, rowIdx, cellIdx) {\n        var tbody,\n            correctCell,\n            table;\n\n        // If we were called with the 3 arg signature just check that the parent table of the item is within the render target\n        if (arguments.length === 3) {\n            table = item.el.up('table');\n            return table && table.dom.parentNode === target.dom;\n        }\n        tbody = this.owner.getTargetEl().child('table', true).tBodies[0];\n        correctCell = tbody.rows[rowIdx].cells[cellIdx];\n        return item.el.dom.parentNode === correctCell;\n    },\n\n    /**\n     * @private\n     * Opera 10.5 has a bug where if a table cell's child has box-sizing:border-box and padding, it\n     * will include that padding in the size of the cell, making it always larger than the\n     * shrink-wrapped size of its contents. To get around this we have to wrap the contents in a div\n     * and then set that div's width to match the item rendered within it afterLayout. This method\n     * determines whether we need the wrapper div; it currently does a straight UA sniff as this bug\n     * seems isolated to just Opera 10.5, but feature detection could be added here if needed.\n     */\n    needsDivWrap: function() {\n        return Ext.isOpera10_5;\n    }\n});\n\n/**\n * Provides a container for arranging a group of related Buttons in a tabular manner.\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Panel with ButtonGroup',\n *         width: 300,\n *         height:200,\n *         renderTo: document.body,\n *         bodyPadding: 10,\n *         html: 'HTML Panel Content',\n *         tbar: [{\n *             xtype: 'buttongroup',\n *             columns: 3,\n *             title: 'Clipboard',\n *             items: [{\n *                 text: 'Paste',\n *                 scale: 'large',\n *                 rowspan: 3,\n *                 iconCls: 'add',\n *                 iconAlign: 'top',\n *                 cls: 'btn-as-arrow'\n *             },{\n *                 xtype:'splitbutton',\n *                 text: 'Menu Button',\n *                 scale: 'large',\n *                 rowspan: 3,\n *                 iconCls: 'add',\n *                 iconAlign: 'top',\n *                 arrowAlign:'bottom',\n *                 menu: [{ text: 'Menu Item 1' }]\n *             },{\n *                 xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]\n *             },{\n *                 text: 'Copy', iconCls: 'add16'\n *             },{\n *                 text: 'Format', iconCls: 'add16'\n *             }]\n *         }]\n *     });\n *\n */\nExt.define('Ext.container.ButtonGroup', {\n    extend: 'Ext.panel.Panel',\n    alias: 'widget.buttongroup',\n    alternateClassName: 'Ext.ButtonGroup',\n\n    requires: ['Ext.layout.container.Table'],\n\n    /**\n     * @cfg {Number} columns\n     * The `columns` configuration property passed to the {@link #layout configured layout manager}.\n     * See {@link Ext.layout.container.Table#columns}.\n     */\n\n    /**\n     * @cfg {String} baseCls\n     * @inheritdoc\n     */\n    baseCls: Ext.baseCSSPrefix + 'btn-group',\n\n    /**\n     * @cfg {Object} layout\n     * @inheritdoc\n     */\n    layout: {\n        type: 'table'\n    },\n\n    defaultType: 'button',\n\n    /**\n     * @cfg {Boolean} frame\n     * @inheritdoc\n     */\n    frame: true,\n\n    frameHeader: false,\n\n    titleAlign: 'center',\n\n    initComponent : function() {\n        // Copy the component's columns config to the layout if specified\n        var me = this,\n            cols = me.columns;\n\n        me.noTitleCls = me.baseCls + '-notitle';\n        if (cols) {\n            me.layout = Ext.apply({}, {columns: cols}, me.layout);\n        }\n\n        if (!me.title) {\n            me.addCls(me.noTitleCls);\n        }\n        me.callParent(arguments);\n    },\n\n    // private\n    onBeforeAdd: function(component) {\n        if (component.isButton) {\n            component.ui = component.ui + '-toolbar';\n        }\n        this.callParent(arguments);\n    },\n\n    //private\n    applyDefaults: function(c) {\n        if (!Ext.isString(c)) {\n            c = this.callParent(arguments);\n        }\n        return c;\n    }\n\n    /**\n     * @cfg {Array} tools\n     * @private\n     */\n    /**\n     * @cfg {Boolean} collapsible\n     * @private\n     */\n    /**\n     * @cfg {Boolean} collapseMode\n     * @private\n     */\n    /**\n     * @cfg {Boolean} animCollapse\n     * @private\n     */\n    /**\n     * @cfg {Boolean} closable\n     * @private\n     */\n});\n\n/**\n * A specialized container representing the viewable application area (the browser viewport).\n *\n * The Viewport renders itself to the document body, and automatically sizes itself to the size of\n * the browser viewport and manages window resizing. There may only be one Viewport created\n * in a page.\n *\n * Like any {@link Ext.container.Container Container}, a Viewport will only perform sizing and positioning\n * on its child Components if you configure it with a {@link #layout}.\n *\n * A Common layout used with Viewports is {@link Ext.layout.container.Border border layout}, but if the\n * required layout is simpler, a different layout should be chosen.\n *\n * For example, to simply make a single child item occupy all available space, use\n * {@link Ext.layout.container.Fit fit layout}.\n *\n * To display one \"active\" item at full size from a choice of several child items, use\n * {@link Ext.layout.container.Card card layout}.\n *\n * Inner layouts are available because all {@link Ext.panel.Panel Panel}s\n * added to the Viewport, either through its {@link #cfg-items}, or the {@link #method-add}\n * method of any of its child Panels may themselves have a layout.\n *\n * The Viewport does not provide scrolling, so child Panels within the Viewport should provide\n * for scrolling if needed using the {@link #autoScroll} config.\n *\n * An example showing a classic application border layout:\n *\n *     @example\n *     Ext.create('Ext.container.Viewport', {\n *         layout: 'border',\n *         items: [{\n *             region: 'north',\n *             html: '<h1 class=\"x-panel-header\">Page Title</h1>',\n *             border: false,\n *             margins: '0 0 5 0'\n *         }, {\n *             region: 'west',\n *             collapsible: true,\n *             title: 'Navigation',\n *             width: 150\n *             // could use a TreePanel or AccordionLayout for navigational items\n *         }, {\n *             region: 'south',\n *             title: 'South Panel',\n *             collapsible: true,\n *             html: 'Information goes here',\n *             split: true,\n *             height: 100,\n *             minHeight: 100\n *         }, {\n *             region: 'east',\n *             title: 'East Panel',\n *             collapsible: true,\n *             split: true,\n *             width: 150\n *         }, {\n *             region: 'center',\n *             xtype: 'tabpanel', // TabPanel itself has no title\n *             activeTab: 0,      // First tab active by default\n *             items: {\n *                 title: 'Default Tab',\n *                 html: 'The first tab\\'s content. Others may be added dynamically'\n *             }\n *         }]\n *     });\n */\nExt.define('Ext.container.Viewport', {\n    extend: 'Ext.container.Container',\n    alias: 'widget.viewport',\n    requires: ['Ext.EventManager'],\n    alternateClassName: 'Ext.Viewport',\n\n    // Privatize config options which, if used, would interfere with the\n    // correct operation of the Viewport as the sole manager of the\n    // layout of the document body.\n\n    /**\n     * @cfg {String/HTMLElement/Ext.Element} applyTo\n     * @private\n     */\n\n    /**\n     * @cfg {Boolean} allowDomMove\n     * @private\n     */\n\n    /**\n     * @cfg {String/HTMLElement/Ext.Element} renderTo\n     * Always renders to document body.\n     * @private\n     */\n\n    /**\n     * @cfg {Number} height\n     * Sets itself to viewport width.\n     * @private\n     */\n\n    /**\n     * @cfg {Number} width\n     * Sets itself to viewport height.\n     * @private\n     */\n\n    /**\n     * @property {Boolean} isViewport\n     * `true` in this class to identify an object as an instantiated Viewport, or subclass thereof.\n     */\n    isViewport: true,\n\n    ariaRole: 'application',\n    \n    preserveElOnDestroy: true,\n\n    initComponent : function() {\n        var me = this,\n            html = document.body.parentNode,\n            el;\n\n        // Get the DOM disruption over with beforfe the Viewport renders and begins a layout\n        Ext.getScrollbarSize();\n        \n        // Clear any dimensions, we will size later on\n        me.width = me.height = undefined;\n\n        me.callParent(arguments);\n        Ext.fly(html).addCls(Ext.baseCSSPrefix + 'viewport');\n        if (me.autoScroll) {\n            delete me.autoScroll;\n            Ext.fly(html).setStyle('overflow', 'auto');\n        }\n        me.el = el = Ext.getBody();\n        el.setHeight = Ext.emptyFn;\n        el.setWidth = Ext.emptyFn;\n        el.setSize = Ext.emptyFn;\n        el.dom.scroll = 'no';\n        me.allowDomMove = false;\n        me.renderTo = me.el;\n    },\n    \n    onRender: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        // Important to start life as the proper size (to avoid extra layouts)\n        // But after render so that the size is not stamped into the body\n        me.width = Ext.Element.getViewportWidth();\n        me.height = Ext.Element.getViewportHeight();\n    },\n\n    afterFirstLayout: function() {\n        var me = this;\n\n        me.callParent(arguments);\n        setTimeout(function() {\n            Ext.EventManager.onWindowResize(me.fireResize, me);\n        }, 1);\n    },\n\n    fireResize : function(width, height){\n        // In IE we can get resize events that have our current size, so we ignore them\n        // to avoid the useless layout...\n        if (width != this.width || height != this.height) {\n            this.setSize(width, height);\n        }\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * Proxies are used by {@link Ext.data.Store Stores} to handle the loading and saving of {@link Ext.data.Model Model}\n * data. Usually developers will not need to create or interact with proxies directly.\n *\n * # Types of Proxy\n *\n * There are two main types of Proxy - {@link Ext.data.proxy.Client Client} and {@link Ext.data.proxy.Server Server}.\n * The Client proxies save their data locally and include the following subclasses:\n *\n * - {@link Ext.data.proxy.LocalStorage LocalStorageProxy} - saves its data to localStorage if the browser supports it\n * - {@link Ext.data.proxy.SessionStorage SessionStorageProxy} - saves its data to sessionStorage if the browsers supports it\n * - {@link Ext.data.proxy.Memory MemoryProxy} - holds data in memory only, any data is lost when the page is refreshed\n *\n * The Server proxies save their data by sending requests to some remote server. These proxies include:\n *\n * - {@link Ext.data.proxy.Ajax Ajax} - sends requests to a server on the same domain\n * - {@link Ext.data.proxy.JsonP JsonP} - uses JSON-P to send requests to a server on a different domain\n * - {@link Ext.data.proxy.Rest Rest} - uses RESTful HTTP methods (GET/PUT/POST/DELETE) to communicate with server\n * - {@link Ext.data.proxy.Direct Direct} - uses {@link Ext.direct.Manager} to send requests\n *\n * Proxies operate on the principle that all operations performed are either Create, Read, Update or Delete. These four\n * operations are mapped to the methods {@link #create}, {@link #read}, {@link #update} and {@link #destroy}\n * respectively. Each Proxy subclass implements these functions.\n *\n * The CRUD methods each expect an {@link Ext.data.Operation Operation} object as the sole argument. The Operation\n * encapsulates information about the action the Store wishes to perform, the {@link Ext.data.Model model} instances\n * that are to be modified, etc. See the {@link Ext.data.Operation Operation} documentation for more details. Each CRUD\n * method also accepts a callback function to be called asynchronously on completion.\n *\n * Proxies also support batching of Operations via a {@link Ext.data.Batch batch} object, invoked by the {@link #batch}\n * method.\n */\nExt.define('Ext.data.proxy.Proxy', {\n    alias: 'proxy.proxy',\n    alternateClassName: ['Ext.data.DataProxy', 'Ext.data.Proxy'],\n\n    uses: [\n        'Ext.data.Batch',\n        'Ext.data.Operation',\n        'Ext.data.Model'\n    ],\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @cfg {String} batchOrder\n     * Comma-separated ordering 'create', 'update' and 'destroy' actions when batching. Override this to set a different\n     * order for the batched CRUD actions to be executed in. Defaults to 'create,update,destroy'.\n     */\n    batchOrder: 'create,update,destroy',\n\n    /**\n     * @cfg {Boolean} batchActions\n     * True to batch actions of a particular type when synchronizing the store. Defaults to true.\n     */\n    batchActions: true,\n\n    /**\n     * @cfg {String} defaultReaderType\n     * The default registered reader type. Defaults to 'json'.\n     * @private\n     */\n    defaultReaderType: 'json',\n\n    /**\n     * @cfg {String} defaultWriterType\n     * The default registered writer type. Defaults to 'json'.\n     * @private\n     */\n    defaultWriterType: 'json',\n\n    /**\n     * @cfg {String/Ext.data.Model} model\n     * The name of the Model to tie to this Proxy. Can be either the string name of the Model, or a reference to the\n     * Model constructor. Required.\n     */\n\n    /**\n     * @cfg {Object/String/Ext.data.reader.Reader} reader\n     * The Ext.data.reader.Reader to use to decode the server's response or data read from client. This can either be a\n     * Reader instance, a config object or just a valid Reader type name (e.g. 'json', 'xml').\n     */\n\n    /**\n     * @cfg {Object/String/Ext.data.writer.Writer} writer\n     * The Ext.data.writer.Writer to use to encode any request sent to the server or saved to client. This can either be\n     * a Writer instance, a config object or just a valid Writer type name (e.g. 'json', 'xml').\n     */\n\n    /**\n     * @property {Boolean} isProxy\n     * `true` in this class to identify an object as an instantiated Proxy, or subclass thereof.\n     */\n    isProxy: true,\n\n    /**\n     * Creates the Proxy\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        config = config || {};\n\n        if (config.model === undefined) {\n            delete config.model;\n        }\n\n        this.mixins.observable.constructor.call(this, config);\n\n        if (this.model !== undefined && !(this.model instanceof Ext.data.Model)) {\n            this.setModel(this.model);\n        }\n\n        /**\n         * @event metachange\n         * Fires when this proxy's reader provides new metadata. Metadata usually consists\n         * of new field definitions, but can include any configuration data required by an\n         * application, and can be processed as needed in the event handler.\n         * This event is currently only fired for JsonReaders. Note that this event is also\n         * propagated by {@link Ext.data.Store}, which is typically where it would be handled.\n         * @param {Ext.data.proxy.Proxy} this\n         * @param {Object} meta The JSON metadata\n         */\n    },\n\n    /**\n     * Sets the model associated with this proxy. This will only usually be called by a Store\n     *\n     * @param {String/Ext.data.Model} model The new model. Can be either the model name string,\n     * or a reference to the model's constructor\n     * @param {Boolean} setOnStore Sets the new model on the associated Store, if one is present\n     */\n    setModel: function(model, setOnStore) {\n        this.model = Ext.ModelManager.getModel(model);\n\n        var reader = this.reader,\n            writer = this.writer;\n\n        this.setReader(reader);\n        this.setWriter(writer);\n\n        if (setOnStore && this.store) {\n            this.store.setModel(this.model);\n        }\n    },\n\n    /**\n     * Returns the model attached to this Proxy\n     * @return {Ext.data.Model} The model\n     */\n    getModel: function() {\n        return this.model;\n    },\n\n    /**\n     * Sets the Proxy's Reader by string, config object or Reader instance\n     *\n     * @param {String/Object/Ext.data.reader.Reader} reader The new Reader, which can be either a type string,\n     * a configuration object or an Ext.data.reader.Reader instance\n     * @return {Ext.data.reader.Reader} The attached Reader object\n     */\n    setReader: function(reader) {\n        var me = this,\n            needsCopy = true;\n\n        if (reader === undefined || typeof reader == 'string') {\n            reader = {\n                type: reader\n            };\n            needsCopy = false;\n        }\n\n        if (reader.isReader) {\n            reader.setModel(me.model);\n        } else {\n            if (needsCopy) {\n                reader = Ext.apply({}, reader);\n            }\n            Ext.applyIf(reader, {\n                proxy: me,\n                model: me.model,\n                type : me.defaultReaderType\n            });\n\n            reader = Ext.createByAlias('reader.' + reader.type, reader);\n        }\n\n        if (reader.onMetaChange) {\n            reader.onMetaChange = Ext.Function.createSequence(reader.onMetaChange, this.onMetaChange, this);\n        }\n\n        me.reader = reader;\n        return me.reader;\n    },\n\n    /**\n     * Returns the reader currently attached to this proxy instance\n     * @return {Ext.data.reader.Reader} The Reader instance\n     */\n    getReader: function() {\n        return this.reader;\n    },\n\n    /**\n     * @private\n     * Called each time the reader's onMetaChange is called so that the proxy can fire the metachange event\n     */\n    onMetaChange: function(meta) {\n        this.fireEvent('metachange', this, meta);\n    },\n\n    /**\n     * Sets the Proxy's Writer by string, config object or Writer instance\n     *\n     * @param {String/Object/Ext.data.writer.Writer} writer The new Writer, which can be either a type string,\n     * a configuration object or an Ext.data.writer.Writer instance\n     * @return {Ext.data.writer.Writer} The attached Writer object\n     */\n    setWriter: function(writer) {\n        var me = this,\n            needsCopy = true;\n            \n        if (writer === undefined || typeof writer == 'string') {\n            writer = {\n                type: writer\n            };\n            needsCopy = false;\n        }\n\n        if (!writer.isWriter) {\n            if (needsCopy) {\n                writer = Ext.apply({}, writer);\n            }\n            Ext.applyIf(writer, {\n                model: me.model,\n                type : me.defaultWriterType\n            });\n\n            writer = Ext.createByAlias('writer.' + writer.type, writer);\n        }\n\n        me.writer = writer;\n\n        return me.writer;\n    },\n\n    /**\n     * Returns the writer currently attached to this proxy instance\n     * @return {Ext.data.writer.Writer} The Writer instance\n     */\n    getWriter: function() {\n        return this.writer;\n    },\n\n    /**\n     * Performs the given create operation.\n     * @param {Ext.data.Operation} operation The Operation to perform\n     * @param {Function} callback Callback function to be called when the Operation has completed (whether\n     * successful or not)\n     * @param {Object} scope Scope to execute the callback function in\n     * @method\n     */\n    create: Ext.emptyFn,\n\n    /**\n     * Performs the given read operation.\n     * @param {Ext.data.Operation} operation The Operation to perform\n     * @param {Function} callback Callback function to be called when the Operation has completed (whether\n     * successful or not)\n     * @param {Object} scope Scope to execute the callback function in\n     * @method\n     */\n    read: Ext.emptyFn,\n\n    /**\n     * Performs the given update operation.\n     * @param {Ext.data.Operation} operation The Operation to perform\n     * @param {Function} callback Callback function to be called when the Operation has completed (whether\n     * successful or not)\n     * @param {Object} scope Scope to execute the callback function in\n     * @method\n     */\n    update: Ext.emptyFn,\n\n    /**\n     * Performs the given destroy operation.\n     * @param {Ext.data.Operation} operation The Operation to perform\n     * @param {Function} callback Callback function to be called when the Operation has completed (whether\n     * successful or not)\n     * @param {Object} scope Scope to execute the callback function in\n     * @method\n     */\n    destroy: Ext.emptyFn,\n\n    /**\n     * Performs a batch of {@link Ext.data.Operation Operations}, in the order specified by {@link #batchOrder}. Used\n     * internally by {@link Ext.data.Store}'s {@link Ext.data.Store#sync sync} method. Example usage:\n     *\n     *     myProxy.batch({\n     *         create : [myModel1, myModel2],\n     *         update : [myModel3],\n     *         destroy: [myModel4, myModel5]\n     *     });\n     *\n     * Where the myModel* above are {@link Ext.data.Model Model} instances - in this case 1 and 2 are new instances and\n     * have not been saved before, 3 has been saved previously but needs to be updated, and 4 and 5 have already been\n     * saved but should now be destroyed.\n     * \n     * Note that the previous version of this method took 2 arguments (operations and listeners). While this is still\n     * supported for now, the current signature is now a single `options` argument that can contain both operations and\n     * listeners, in addition to other options. The multi-argument signature will likely be deprecated in a future release.\n     *\n     * @param {Object} options Object containing one or more properties supported by the batch method:\n     * \n     * @param {Object} options.operations Object containing the Model instances to act upon, keyed by action name\n     * \n     * @param {Object} [options.listeners] Event listeners object passed straight through to the Batch -\n     * see {@link Ext.data.Batch} for details\n     * \n     * @param {Ext.data.Batch/Object} [options.batch] A {@link Ext.data.Batch} object (or batch config to apply \n     * to the created batch). If unspecified a default batch will be auto-created.\n     * \n     * @param {Function} [options.callback] The function to be called upon completion of processing the batch.\n     * The callback is called regardless of success or failure and is passed the following parameters:\n     * @param {Ext.data.Batch} options.callback.batch The {@link Ext.data.Batch batch} that was processed,\n     * containing all operations in their current state after processing\n     * @param {Object} options.callback.options The options argument that was originally passed into batch\n     * \n     * @param {Function} [options.success] The function to be called upon successful completion of the batch. The \n     * success function is called only if no exceptions were reported in any operations. If one or more exceptions\n     * occurred then the `failure` function will be called instead. The success function is called \n     * with the following parameters:\n     * @param {Ext.data.Batch} options.success.batch The {@link Ext.data.Batch batch} that was processed,\n     * containing all operations in their current state after processing\n     * @param {Object} options.success.options The options argument that was originally passed into batch\n     * \n     * @param {Function} [options.failure] The function to be called upon unsuccessful completion of the batch. The \n     * failure function is called when one or more operations returns an exception during processing (even if some\n     * operations were also successful). In this case you can check the batch's {@link Ext.data.Batch#exceptions\n     * exceptions} array to see exactly which operations had exceptions. The failure function is called with the \n     * following parameters:\n     * @param {Ext.data.Batch} options.failure.batch The {@link Ext.data.Batch batch} that was processed,\n     * containing all operations in their current state after processing\n     * @param {Object} options.failure.options The options argument that was originally passed into batch\n     * \n     * @param {Object} [options.scope] The scope in which to execute any callbacks (i.e. the `this` object inside\n     * the callback, success and/or failure functions). Defaults to the proxy.\n     *\n     * @return {Ext.data.Batch} The newly created Batch\n     */\n    batch: function(options, /* deprecated */listeners) {\n        var me = this,\n            useBatch = me.batchActions,\n            batch,\n            records,\n            actions, aLen, action, a, r, rLen, record;\n\n        if (options.operations === undefined) {\n            // the old-style (operations, listeners) signature was called\n            // so convert to the single options argument syntax\n            options = {\n                operations: options,\n                listeners: listeners\n            };\n        }\n\n        if (options.batch) {\n            if (Ext.isDefined(options.batch.runOperation)) {\n                batch = Ext.applyIf(options.batch, {\n                    proxy: me,\n                    listeners: {}\n                });\n            }\n        } else {\n            options.batch = {\n                proxy: me,\n                listeners: options.listeners || {}\n            };\n        }\n\n        if (!batch) {\n            batch = new Ext.data.Batch(options.batch);\n        }\n\n        batch.on('complete', Ext.bind(me.onBatchComplete, me, [options], 0));\n\n        actions = me.batchOrder.split(',');\n        aLen    = actions.length;\n\n        for (a = 0; a < aLen; a++) {\n            action  = actions[a];\n            records = options.operations[action];\n\n            if (records) {\n                if (useBatch) {\n                    batch.add(new Ext.data.Operation({\n                        action  : action,\n                        records : records\n                    }));\n                } else {\n                    rLen = records.length;\n\n                    for (r = 0; r < rLen; r++) {\n                        record = records[r];\n\n                        batch.add(new Ext.data.Operation({\n                            action  : action,\n                            records : [record]\n                        }));\n                    }\n                }\n            }\n        }\n\n        batch.start();\n        return batch;\n    },\n\n    /**\n     * @private\n     * The internal callback that the proxy uses to call any specified user callbacks after completion of a batch\n     */\n    onBatchComplete: function(batchOptions, batch) {\n        var scope = batchOptions.scope || this;\n\n        if (batch.hasException) {\n            if (Ext.isFunction(batchOptions.failure)) {\n                Ext.callback(batchOptions.failure, scope, [batch, batchOptions]);\n            }\n        } else if (Ext.isFunction(batchOptions.success)) {\n            Ext.callback(batchOptions.success, scope, [batch, batchOptions]);\n        }\n\n        if (Ext.isFunction(batchOptions.callback)) {\n            Ext.callback(batchOptions.callback, scope, [batch, batchOptions]);\n        }\n    }\n}, function() {\n    //backwards compatibility\n    Ext.data.DataProxy = this;\n});\n\n/**\n * @author Ed Spencer\n *\n * AbstractStore is a superclass of {@link Ext.data.Store} and {@link Ext.data.TreeStore}. It's never used directly,\n * but offers a set of methods used by both of those subclasses.\n *\n * We've left it here in the docs for reference purposes, but unless you need to make a whole new type of Store, what\n * you're probably looking for is {@link Ext.data.Store}. If you're still interested, here's a brief description of what\n * AbstractStore is and is not.\n *\n * AbstractStore provides the basic configuration for anything that can be considered a Store. It expects to be\n * given a {@link Ext.data.Model Model} that represents the type of data in the Store. It also expects to be given a\n * {@link Ext.data.proxy.Proxy Proxy} that handles the loading of data into the Store.\n *\n * AbstractStore provides a few helpful methods such as {@link #method-load} and {@link #sync}, which load and save data\n * respectively, passing the requests through the configured {@link #proxy}. Both built-in Store subclasses add extra\n * behavior to each of these functions. Note also that each AbstractStore subclass has its own way of storing data -\n * in {@link Ext.data.Store} the data is saved as a flat {@link Ext.util.MixedCollection MixedCollection}, whereas in\n * {@link Ext.data.TreeStore TreeStore} we use a {@link Ext.data.Tree} to maintain the data's hierarchy.\n *\n * The store provides filtering and sorting support. This sorting/filtering can happen on the client side\n * or can be completed on the server. This is controlled by the {@link Ext.data.Store#remoteSort remoteSort} and\n * {@link Ext.data.Store#remoteFilter remoteFilter} config options. For more information see the {@link #sort} and\n * {@link Ext.data.Store#filter filter} methods.\n */\nExt.define('Ext.data.AbstractStore', {\n\trequires: [\n        'Ext.util.MixedCollection',\n        'Ext.data.proxy.Proxy',\n        'Ext.data.Operation',\n        'Ext.util.Filter'\n    ],\n\n    mixins: {\n        observable: 'Ext.util.Observable',\n        sortable: 'Ext.util.Sortable'\n    },\n\n    statics: {\n        /**\n         * Creates a store from config object.\n         * \n         * @param {Object/Ext.data.AbstractStore} store A config for\n         * the store to be created.  It may contain a `type` field\n         * which defines the particular type of store to create.\n         * \n         * Alteratively passing an actual store to this method will\n         * just return it, no changes made.\n         * \n         * @return {Ext.data.AbstractStore} The created store.\n         * @static\n         */\n        create: function(store) {\n            if (!store.isStore) {\n                if (!store.type) {\n                    store.type = 'store';\n                }\n                store = Ext.createByAlias('store.' + store.type, store);\n            }\n            return store;\n        }\n    },\n\n    /**\n     * @cfg {Boolean} remoteSort\n     * True to defer any sorting operation to the server. If false, sorting is done locally on the client.\n     */\n    remoteSort  : false,\n\n    /**\n     * @cfg {Boolean} remoteFilter\n     * True to defer any filtering operation to the server. If false, filtering is done locally on the client.\n     */\n    remoteFilter: false,\n\n    /**\n     * @cfg {String/Ext.data.proxy.Proxy/Object} proxy\n     * The Proxy to use for this Store. This can be either a string, a config object or a Proxy instance -\n     * see {@link #setProxy} for details.\n     */\n\n    /**\n     * @cfg {Boolean/Object} autoLoad\n     * If data is not specified, and if autoLoad is true or an Object, this store's load method is automatically called\n     * after creation. If the value of autoLoad is an Object, this Object will be passed to the store's load method.\n     * Defaults to false.\n     */\n    autoLoad: undefined,\n\n    /**\n     * @cfg {Boolean} autoSync\n     * True to automatically sync the Store with its Proxy after every edit to one of its Records. Defaults to false.\n     */\n    autoSync: false,\n\n    /**\n     * @cfg {String} batchUpdateMode\n     * Sets the updating behavior based on batch synchronization. 'operation' (the default) will update the Store's\n     * internal representation of the data after each operation of the batch has completed, 'complete' will wait until\n     * the entire batch has been completed before updating the Store's data. 'complete' is a good choice for local\n     * storage proxies, 'operation' is better for remote proxies, where there is a comparatively high latency.\n     */\n    batchUpdateMode: 'operation',\n\n    /**\n     * @cfg {Boolean} filterOnLoad\n     * If true, any filters attached to this Store will be run after loading data, before the datachanged event is fired.\n     * Defaults to true, ignored if {@link Ext.data.Store#remoteFilter remoteFilter} is true\n     */\n    filterOnLoad: true,\n\n    /**\n     * @cfg {Boolean} sortOnLoad\n     * If true, any sorters attached to this Store will be run after loading data, before the datachanged event is fired.\n     * Defaults to true, igored if {@link Ext.data.Store#remoteSort remoteSort} is true\n     */\n    sortOnLoad: true,\n\n    /**\n     * @property {Boolean} implicitModel\n     * True if a model was created implicitly for this Store. This happens if a fields array is passed to the Store's\n     * constructor instead of a model constructor or name.\n     * @private\n     */\n    implicitModel: false,\n\n    /**\n     * @property {String} defaultProxyType\n     * The string type of the Proxy to create if none is specified. This defaults to creating a\n     * {@link Ext.data.proxy.Memory memory proxy}.\n     */\n    defaultProxyType: 'memory',\n\n    /**\n     * @property {Boolean} isDestroyed\n     * True if the Store has already been destroyed. If this is true, the reference to Store should be deleted\n     * as it will not function correctly any more.\n     */\n    isDestroyed: false,\n\n    /**\n     * @property {Boolean} isStore\n     * `true` in this class to identify an object as an instantiated Store, or subclass thereof.\n     */\n    isStore: true,\n\n    /**\n     * @cfg {String} storeId\n     * Unique identifier for this store. If present, this Store will be registered with the {@link Ext.data.StoreManager},\n     * making it easy to reuse elsewhere.\n     *\n     * Note that when store is instatiated by Controller, the storeId will be overridden by the name of the store.\n     */\n\n    /**\n     * @cfg {Object[]} fields\n     * This may be used in place of specifying a {@link #model} configuration. The fields should be a\n     * set of {@link Ext.data.Field} configuration objects. The store will automatically create a {@link Ext.data.Model}\n     * with these fields. In general this configuration option should only be used for simple stores like\n     * a two-field store of ComboBox. For anything more complicated, such as specifying a particular id property or\n     * associations, a {@link Ext.data.Model} should be defined and specified for the {@link #model}\n     * config.\n     */\n\n    /**\n     * @cfg {String} model\n     * Name of the {@link Ext.data.Model Model} associated with this store.\n     * The string is used as an argument for {@link Ext.ModelManager#getModel}.\n     */\n\n    /**\n     * @cfg {Object[]/Function[]} filters\n     * Array of {@link Ext.util.Filter Filters} for this store. Can also be passed array of\n     * functions which will be used as the {@link Ext.util.Filter#filterFn filterFn} config\n     * for filters:\n     * \n     *     filters: [\n     *         function(item) {\n     *             return item.internalId > 0;\n     *         }\n     *     ]\n     *\n     * To filter after the grid is loaded use the {@link Ext.data.Store#filterBy filterBy} function.\n     */\n\n    sortRoot: 'data',\n\n    //documented above\n    constructor: function(config) {\n        var me = this,\n            filters;\n\n        /**\n         * @event add\n         * Fired when a Model instance has been added to this Store\n         * @param {Ext.data.Store} store The store\n         * @param {Ext.data.Model[]} records The Model instances that were added\n         * @param {Number} index The index at which the instances were inserted\n         */\n\n        /**\n         * @event remove\n         * Fired when a Model instance has been removed from this Store\n         * @param {Ext.data.Store} store The Store object\n         * @param {Ext.data.Model} record The record that was removed\n         * @param {Number} index The index of the record that was removed\n         */\n\n        /**\n         * @event update\n         * Fires when a Model instance has been updated\n         * @param {Ext.data.Store} this\n         * @param {Ext.data.Model} record The Model instance that was updated\n         * @param {String} operation The update operation being performed. Value may be one of:\n         *\n         *     Ext.data.Model.EDIT\n         *     Ext.data.Model.REJECT\n         *     Ext.data.Model.COMMIT\n         * @param {String[]} modifiedFieldNames Array of field names changed during edit.\n         */\n\n        /**\n         * @event datachanged\n         * Fires whenever the records in the Store have changed in some way - this could include adding or removing\n         * records, or updating the data in existing records\n         * @param {Ext.data.Store} this The data store\n         */\n        \n        /**\n         * @event refresh\n         * Fires when the data cache has changed in a bulk manner (e.g., it has been sorted, filtered, etc.) and a\n         * widget that is using this Store as a Record cache should refresh its view.\n         * @param {Ext.data.Store} this The data store\n         */\n\n        /**\n         * @event beforeload\n         * Fires before a request is made for a new data object. If the beforeload handler returns false the load\n         * action will be canceled.\n         * @param {Ext.data.Store} store This Store\n         * @param {Ext.data.Operation} operation The Ext.data.Operation object that will be passed to the Proxy to\n         * load the Store\n         */\n\n        /**\n         * @event load\n         * Fires whenever the store reads data from a remote data source.\n         * @param {Ext.data.Store} this\n         * @param {Ext.data.Model[]} records An array of records\n         * @param {Boolean} successful True if the operation was successful.\n         */\n\n        /**\n         * @event write\n         * Fires whenever a successful write has been made via the configured {@link #proxy Proxy}\n         * @param {Ext.data.Store} store This Store\n         * @param {Ext.data.Operation} operation The {@link Ext.data.Operation Operation} object that was used in\n         * the write\n         */\n\n        /**\n         * @event beforesync\n         * Fired before a call to {@link #sync} is executed. Return false from any listener to cancel the sync\n         * @param {Object} options Hash of all records to be synchronized, broken down into create, update and destroy\n         */\n        /**\n         * @event clear\n         * Fired after the {@link #removeAll} method is called.\n         * @param {Ext.data.Store} this\n         */\n        /**\n         * @event metachange\n         * Fires when this store's underlying reader (available via the proxy) provides new metadata.\n         * Metadata usually consists of new field definitions, but can include any configuration data\n         * required by an application, and can be processed as needed in the event handler.\n         * This event is currently only fired for JsonReaders.\n         * @param {Ext.data.Store} this\n         * @param {Object} meta The JSON metadata\n         */\n\n        Ext.apply(me, config);\n        // don't use *config* anymore from here on... use *me* instead...\n\n        /**\n         * Temporary cache in which removed model instances are kept until successfully synchronised with a Proxy,\n         * at which point this is cleared.\n         * @protected\n         * @property {Ext.data.Model[]} removed\n         */\n        me.removed = [];\n\n        me.mixins.observable.constructor.apply(me, arguments);\n\n        var configModel = me.model;\n\n        me.model = Ext.ModelManager.getModel(me.model);\n\n        /**\n         * @property {Object} modelDefaults\n         * @private\n         * A set of default values to be applied to every model instance added via {@link Ext.data.Store#insert insert} or created\n         * via {@link Ext.data.Store#createModel createModel}. This is used internally by associations to set foreign keys and\n         * other fields. See the Association classes source code for examples. This should not need to be used by application developers.\n         */\n        Ext.applyIf(me, {\n            modelDefaults: {}\n        });\n\n        //Supports the 3.x style of simply passing an array of fields to the store, implicitly creating a model\n        if (!me.model && me.fields) {\n            me.model = Ext.define('Ext.data.Store.ImplicitModel-' + (me.storeId || Ext.id()), {\n                extend: 'Ext.data.Model',\n                fields: me.fields,\n                proxy: me.proxy || me.defaultProxyType\n            });\n\n            delete me.fields;\n\n            me.implicitModel = true;\n        }\n\n        if (!me.model && me.useModelWarning !== false) {\n            // There are a number of ways things could have gone wrong, try to give as much information as possible\n            var logMsg = [\n                Ext.getClassName(me) || 'Store',\n                ' created with no model.'\n            ];\n\n            if (typeof configModel === 'string') {\n                logMsg.push(\" The name '\", configModel, \"'\", ' does not correspond to a valid model.');\n            }\n\n            Ext.log.warn(logMsg.join(''));\n        }\n\n        //ensures that the Proxy is instantiated correctly\n        me.setProxy(me.proxy || me.model.getProxy());\n\n        me.proxy.on('metachange', me.onMetaChange, me);\n\n        if (me.id && !me.storeId) {\n            me.storeId = me.id;\n            delete me.id;\n        }\n\n        if (me.storeId) {\n            Ext.data.StoreManager.register(me);\n        }\n\n        me.mixins.sortable.initSortable.call(me);\n\n        /**\n         * @property {Ext.util.MixedCollection} filters\n         * The collection of {@link Ext.util.Filter Filters} currently applied to this Store\n         */\n        filters = me.decodeFilters(me.filters);\n        me.filters = new Ext.util.MixedCollection();\n        me.filters.addAll(filters);\n    },\n\n    /**\n     * Sets the Store's Proxy by string, config object or Proxy instance\n     * @param {String/Object/Ext.data.proxy.Proxy} proxy The new Proxy, which can be either a type string, a configuration object\n     * or an Ext.data.proxy.Proxy instance\n     * @return {Ext.data.proxy.Proxy} The attached Proxy object\n     */\n    setProxy: function(proxy) {\n        var me = this;\n\n        if (proxy instanceof Ext.data.proxy.Proxy) {\n            proxy.setModel(me.model);\n        } else {\n            if (Ext.isString(proxy)) {\n                proxy = {\n                    type: proxy\n                };\n            }\n            Ext.applyIf(proxy, {\n                model: me.model\n            });\n\n            proxy = Ext.createByAlias('proxy.' + proxy.type, proxy);\n        }\n\n        me.proxy = proxy;\n\n        return me.proxy;\n    },\n\n    /**\n     * Returns the proxy currently attached to this proxy instance\n     * @return {Ext.data.proxy.Proxy} The Proxy instance\n     */\n    getProxy: function() {\n        return this.proxy;\n    },\n\n    // private\n    onMetaChange: function(proxy, meta) {\n        this.fireEvent('metachange', this, meta);\n    },\n\n    //saves any phantom records\n    create: function(data, options) {\n        var me = this,\n            instance = Ext.ModelManager.create(Ext.applyIf(data, me.modelDefaults), me.model.modelName),\n            operation;\n\n        options = options || {};\n\n        Ext.applyIf(options, {\n            action : 'create',\n            records: [instance]\n        });\n\n        operation = new Ext.data.Operation(options);\n\n        me.proxy.create(operation, me.onProxyWrite, me);\n\n        return instance;\n    },\n\n    read: function() {\n        return this.load.apply(this, arguments);\n    },\n\n    update: function(options) {\n        var me = this,\n            operation;\n        options = options || {};\n\n        Ext.applyIf(options, {\n            action : 'update',\n            records: me.getUpdatedRecords()\n        });\n\n        operation = new Ext.data.Operation(options);\n\n        return me.proxy.update(operation, me.onProxyWrite, me);\n    },\n\n    /**\n     * @private\n     * Callback for any write Operation over the Proxy. Updates the Store's MixedCollection to reflect\n     * the updates provided by the Proxy\n     */\n    onProxyWrite: function(operation) {\n        var me = this,\n            success = operation.wasSuccessful(),\n            records = operation.getRecords();\n\n        switch (operation.action) {\n            case 'create':\n                me.onCreateRecords(records, operation, success);\n                break;\n            case 'update':\n                me.onUpdateRecords(records, operation, success);\n                break;\n            case 'destroy':\n                me.onDestroyRecords(records, operation, success);\n                break;\n        }\n\n        if (success) {\n            me.fireEvent('write', me, operation);\n            me.fireEvent('datachanged', me);\n            me.fireEvent('refresh', me);\n        }\n        //this is a callback that would have been passed to the 'create', 'update' or 'destroy' function and is optional\n        Ext.callback(operation.callback, operation.scope || me, [records, operation, success]);\n    },\n    \n    // may be implemented by store subclasses\n    onCreateRecords: Ext.emptyFn,\n    \n    // may be implemented by store subclasses\n    onUpdateRecords: Ext.emptyFn,\n    \n    /**\n     * Removes any records when a write is returned from the server.\n     * @private\n     * @param {Ext.data.Model[]} records The array of removed records\n     * @param {Ext.data.Operation} operation The operation that just completed\n     * @param {Boolean} success True if the operation was successful\n     */\n    onDestroyRecords: function(records, operation, success) {\n        if (success) {\n            this.removed = [];\n        }\n    },\n\n    //tells the attached proxy to destroy the given records\n    destroy: function(options) {\n        var me = this,\n            operation;\n\n        options = options || {};\n\n        Ext.applyIf(options, {\n            action : 'destroy',\n            records: me.getRemovedRecords()\n        });\n\n        operation = new Ext.data.Operation(options);\n\n        return me.proxy.destroy(operation, me.onProxyWrite, me);\n    },\n\n    /**\n     * @private\n     * Attached as the 'operationcomplete' event listener to a proxy's Batch object. By default just calls through\n     * to onProxyWrite.\n     */\n    onBatchOperationComplete: function(batch, operation) {\n        return this.onProxyWrite(operation);\n    },\n\n    /**\n     * @private\n     * Attached as the 'complete' event listener to a proxy's Batch object. Iterates over the batch operations\n     * and updates the Store's internal data MixedCollection.\n     */\n    onBatchComplete: function(batch, operation) {\n        var me = this,\n            operations = batch.operations,\n            length = operations.length,\n            i;\n\n        me.suspendEvents();\n\n        for (i = 0; i < length; i++) {\n            me.onProxyWrite(operations[i]);\n        }\n\n        me.resumeEvents();\n\n        me.fireEvent('datachanged', me);\n        me.fireEvent('refresh', me);\n    },\n\n    /**\n     * @private\n     */\n    onBatchException: function(batch, operation) {\n        // //decide what to do... could continue with the next operation\n        // batch.start();\n        //\n        // //or retry the last operation\n        // batch.retry();\n    },\n\n    /**\n     * @private\n     * Filter function for new records.\n     */\n    filterNew: function(item) {\n        // only want phantom records that are valid\n        return item.phantom === true && item.isValid();\n    },\n\n    /**\n     * Returns all Model instances that are either currently a phantom (e.g. have no id), or have an ID but have not\n     * yet been saved on this Store (this happens when adding a non-phantom record from another Store into this one)\n     * @return {Ext.data.Model[]} The Model instances\n     */\n    getNewRecords: function() {\n        return [];\n    },\n\n    /**\n     * Returns all Model instances that have been updated in the Store but not yet synchronized with the Proxy\n     * @return {Ext.data.Model[]} The updated Model instances\n     */\n    getUpdatedRecords: function() {\n        return [];\n    },\n\n    /**\n     * Gets all {@link Ext.data.Model records} added or updated since the last commit. Note that the order of records\n     * returned is not deterministic and does not indicate the order in which records were modified. Note also that\n     * removed records are not included (use {@link #getRemovedRecords} for that).\n     * @return {Ext.data.Model[]} The added and updated Model instances\n     */\n    getModifiedRecords : function(){\n        return [].concat(this.getNewRecords(), this.getUpdatedRecords());\n    },\n    \n    /**\n     * @private\n     * Filter function for updated records.\n     */\n    filterUpdated: function(item) {\n        // only want dirty records, not phantoms that are valid\n        return item.dirty === true && item.phantom !== true && item.isValid();\n    },\n\n    /**\n     * Returns any records that have been removed from the store but not yet destroyed on the proxy.\n     * @return {Ext.data.Model[]} The removed Model instances\n     */\n    getRemovedRecords: function() {\n        return this.removed;\n    },\n\n    filter: function(filters, value) {\n\n    },\n\n    /**\n     * @private\n     * Normalizes an array of filter objects, ensuring that they are all Ext.util.Filter instances\n     * @param {Object[]} filters The filters array\n     * @return {Ext.util.Filter[]} Array of Ext.util.Filter objects\n     */\n    decodeFilters: function(filters) {\n        if (!Ext.isArray(filters)) {\n            if (filters === undefined) {\n                filters = [];\n            } else {\n                filters = [filters];\n            }\n        }\n\n        var length = filters.length,\n            Filter = Ext.util.Filter,\n            config, i;\n\n        for (i = 0; i < length; i++) {\n            config = filters[i];\n\n            if (!(config instanceof Filter)) {\n                Ext.apply(config, {\n                    root: 'data'\n                });\n\n                //support for 3.x style filters where a function can be defined as 'fn'\n                if (config.fn) {\n                    config.filterFn = config.fn;\n                }\n\n                //support a function to be passed as a filter definition\n                if (typeof config == 'function') {\n                    config = {\n                        filterFn: config\n                    };\n                }\n\n                filters[i] = new Filter(config);\n            }\n        }\n\n        return filters;\n    },\n\n    clearFilter: function(supressEvent) {\n\n    },\n\n    isFiltered: function() {\n\n    },\n\n    filterBy: function(fn, scope) {\n\n    },\n\n    /**\n     * Synchronizes the store with its {@link #proxy}. This asks the proxy to batch together any new, updated\n     * and deleted records in the store, updating the store's internal representation of the records\n     * as each operation completes.\n     * \n     * @param {Object} [options] Object containing one or more properties supported by the sync method (these get \n     * passed along to the underlying proxy's {@link Ext.data.Proxy#batch batch} method):\n     * \n     * @param {Ext.data.Batch/Object} [options.batch] A {@link Ext.data.Batch} object (or batch config to apply \n     * to the created batch). If unspecified a default batch will be auto-created as needed.\n     * \n     * @param {Function} [options.callback] The function to be called upon completion of the sync.\n     * The callback is called regardless of success or failure and is passed the following parameters:\n     * @param {Ext.data.Batch} options.callback.batch The {@link Ext.data.Batch batch} that was processed,\n     * containing all operations in their current state after processing\n     * @param {Object} options.callback.options The options argument that was originally passed into sync\n     * \n     * @param {Function} [options.success] The function to be called upon successful completion of the sync. The \n     * success function is called only if no exceptions were reported in any operations. If one or more exceptions\n     * occurred then the failure function will be called instead. The success function is called \n     * with the following parameters:\n     * @param {Ext.data.Batch} options.success.batch The {@link Ext.data.Batch batch} that was processed,\n     * containing all operations in their current state after processing\n     * @param {Object} options.success.options The options argument that was originally passed into sync\n     * \n     * @param {Function} [options.failure] The function to be called upon unsuccessful completion of the sync. The \n     * failure function is called when one or more operations returns an exception during processing (even if some\n     * operations were also successful). In this case you can check the batch's {@link Ext.data.Batch#exceptions \n     * exceptions} array to see exactly which operations had exceptions. The failure function is called with the \n     * following parameters:\n     * @param {Ext.data.Batch} options.failure.batch The {@link Ext.data.Batch} that was processed, containing all\n     * operations in their current state after processing\n     * @param {Object} options.failure.options The options argument that was originally passed into sync\n     * \n     * @param {Object} [options.scope] The scope in which to execute any callbacks (i.e. the `this` object inside\n     * the callback, success and/or failure functions). Defaults to the store's proxy.\n     * \n     * @return {Ext.data.Store} this\n     */\n    sync: function(options) {\n        var me = this,\n            operations = {},\n            toCreate = me.getNewRecords(),\n            toUpdate = me.getUpdatedRecords(),\n            toDestroy = me.getRemovedRecords(),\n            needsSync = false;\n\n        if (toCreate.length > 0) {\n            operations.create = toCreate;\n            needsSync = true;\n        }\n\n        if (toUpdate.length > 0) {\n            operations.update = toUpdate;\n            needsSync = true;\n        }\n\n        if (toDestroy.length > 0) {\n            operations.destroy = toDestroy;\n            needsSync = true;\n        }\n\n        if (needsSync && me.fireEvent('beforesync', operations) !== false) {\n            options = options || {};\n\n            me.proxy.batch(Ext.apply(options, {\n                operations: operations,\n                listeners: me.getBatchListeners()\n            }));\n        }\n        \n        return me;\n    },\n    \n    /**\n     * @private\n     * Returns an object which is passed in as the listeners argument to proxy.batch inside this.sync.\n     * This is broken out into a separate function to allow for customisation of the listeners\n     * @return {Object} The listeners object\n     */\n    getBatchListeners: function() {\n        var me = this,\n            listeners = {\n                scope: me,\n                exception: me.onBatchException\n            };\n\n        if (me.batchUpdateMode == 'operation') {\n            listeners.operationcomplete = me.onBatchOperationComplete;\n        } else {\n            listeners.complete = me.onBatchComplete;\n        }\n\n        return listeners;\n    },\n\n    /**\n     * Saves all pending changes via the configured {@link #proxy}. Use {@link #sync} instead.\n     * @deprecated 4.0.0 Will be removed in the next major version\n     */\n    save: function() {\n        return this.sync.apply(this, arguments);\n    },\n\n    /**\n     * Loads the Store using its configured {@link #proxy}.\n     * @param {Object} options (optional) config object. This is passed into the {@link Ext.data.Operation Operation}\n     * object that is created and then sent to the proxy's {@link Ext.data.proxy.Proxy#read} function\n     * \n     * @return {Ext.data.Store} this\n     */\n    load: function(options) {\n        var me = this,\n            operation;\n\n        options = Ext.apply({\n            action: 'read',\n            filters: me.filters.items,\n            sorters: me.getSorters()\n        }, options);\n        me.lastOptions = options;\n\n        operation = new Ext.data.Operation(options);\n\n        if (me.fireEvent('beforeload', me, operation) !== false) {\n            me.loading = true;\n            me.proxy.read(operation, me.onProxyLoad, me);\n        }\n\n        return me;\n    },\n\n    /**\n     * Reloads the store using the last options passed to the {@link #method-load} method.\n     * @param {Object} options A config object which contains options which may override the options passed to the previous load call.\n     */\n    reload: function(options) {\n        return this.load(Ext.apply(this.lastOptions, options));\n    },\n\n    /**\n     * @private\n     * A model instance should call this method on the Store it has been {@link Ext.data.Model#join joined} to.\n     * @param {Ext.data.Model} record The model instance that was edited\n     * @param {String[]} modifiedFieldNames Array of field names changed during edit.\n     */\n    afterEdit : function(record, modifiedFieldNames) {\n        var me = this,\n            i, shouldSync;\n\n        if (me.autoSync && !me.autoSyncSuspended) {\n            for (i = modifiedFieldNames.length; i--;) {\n                // only sync if persistent fields were modified\n                if (record.fields.get(modifiedFieldNames[i]).persist) {\n                    shouldSync = true;\n                    break;\n                }\n            }\n            if (shouldSync) {\n                me.sync();\n            }\n        }\n\n        me.fireEvent('update', me, record, Ext.data.Model.EDIT, modifiedFieldNames);\n    },\n\n    /**\n     * @private\n     * A model instance should call this method on the Store it has been {@link Ext.data.Model#join joined} to..\n     * @param {Ext.data.Model} record The model instance that was edited\n     */\n    afterReject : function(record) {\n        // Must pass the 5th param (modifiedFieldNames) as null, otherwise the\n        // event firing machinery appends the listeners \"options\" object to the arg list\n        // which may get used as the modified fields array by a handler.\n        // This array is used for selective grid cell updating by Grid View.\n        // Null will be treated as though all cells need updating.\n        this.fireEvent('update', this, record, Ext.data.Model.REJECT, null);\n    },\n\n    /**\n     * @private\n     * A model instance should call this method on the Store it has been {@link Ext.data.Model#join joined} to.\n     * @param {Ext.data.Model} record The model instance that was edited\n     */\n    afterCommit : function(record) {\n        // Must pass the 5th param (modifiedFieldNames) as null, otherwise the\n        // event firing machinery appends the listeners \"options\" object to the arg list\n        // which may get used as the modified fields array by a handler.\n        // This array is used for selective grid cell updating by Grid View.\n        // Null will be treated as though all cells need updating.\n        this.fireEvent('update', this, record, Ext.data.Model.COMMIT, null);\n    },\n\n    // private\n    destroyStore: function() {\n        var me = this;\n\n        if (!me.isDestroyed) {\n            if (me.storeId) {\n                Ext.data.StoreManager.unregister(me);\n            }\n            me.clearData();\n            me.data = me.tree = me.sorters = me.filters = me.groupers = null;\n            if (me.reader) {\n                me.reader.destroyReader();\n            }\n            me.proxy = me.reader = me.writer = null;\n            me.clearListeners();\n            me.isDestroyed = true;\n\n            if (me.implicitModel) {\n                Ext.destroy(me.model);\n            } else {\n                me.model = null;\n            }\n        }\n    },\n\n    // private\n    doSort: function(sorterFn) {\n        var me = this;\n        if (me.remoteSort) {\n            //the load function will pick up the new sorters and request the sorted data from the proxy\n            me.load();\n        } else {\n            me.data.sortBy(sorterFn);\n            me.fireEvent('datachanged', me);\n            me.fireEvent('refresh', me);\n        }\n    },\n\n    // to be implemented by subclasses\n    clearData: Ext.emptyFn,\n    \n    // to be implemented by subclasses\n    getCount: Ext.emptyFn,\n\n    // to be implemented by subclasses\n    getById: Ext.emptyFn,\n\n    /**\n     * Removes all records from the store. This method does a \"fast remove\",\n     * individual remove events are not called. The {@link #clear} event is\n     * fired upon completion.\n     * @method\n     */\n    removeAll: Ext.emptyFn,\n    // individual store subclasses should implement a \"fast\" remove\n    // and fire a clear event afterwards\n\n    /**\n     * Returns true if the Store is currently performing a load operation\n     * @return {Boolean} True if the Store is currently loading\n     */\n    isLoading: function() {\n        return !!this.loading;\n    },\n\n    /**\n     * Suspends automatically syncing the Store with its Proxy.  Only applicable if {@link #autoSync} is `true`\n     */\n    suspendAutoSync: function() {\n        this.autoSyncSuspended = true;\n    },\n\n    /**\n     * Resumes automatically syncing the Store with its Proxy.  Only applicable if {@link #autoSync} is `true`\n     */\n    resumeAutoSync: function() {\n        this.autoSyncSuspended = false;\n    }\n\n});\n\n/**\n * @author Ed Spencer\n *\n * Simple wrapper class that represents a set of records returned by a Proxy.\n */\nExt.define('Ext.data.ResultSet', {\n    /**\n     * @cfg {Boolean} loaded\n     * True if the records have already been loaded. This is only meaningful when dealing with\n     * SQL-backed proxies.\n     */\n    loaded: true,\n\n    /**\n     * @cfg {Number} count\n     * The number of records in this ResultSet. Note that total may differ from this number.\n     */\n    count: 0,\n\n    /**\n     * @cfg {Number} total\n     * The total number of records reported by the data source. This ResultSet may form a subset of\n     * those records (see {@link #count}).\n     */\n    total: 0,\n\n    /**\n     * @cfg {Boolean} success\n     * True if the ResultSet loaded successfully, false if any errors were encountered.\n     */\n    success: false,\n\n    /**\n     * @cfg {Ext.data.Model[]} records (required)\n     * The array of record instances.\n     */\n\n    /**\n     * Creates the resultSet\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        Ext.apply(this, config);\n\n        /**\n         * @property {Number} totalRecords\n         * Copy of this.total.\n         * @deprecated Will be removed in Ext JS 5.0. Use {@link #total} instead.\n         */\n        this.totalRecords = this.total;\n\n        if (config.count === undefined) {\n            this.count = this.records.length;\n        }\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * Readers are used to interpret data to be loaded into a {@link Ext.data.Model Model} instance or a {@link\n * Ext.data.Store Store} - often in response to an AJAX request. In general there is usually no need to create\n * a Reader instance directly, since a Reader is almost always used together with a {@link Ext.data.proxy.Proxy Proxy},\n * and is configured using the Proxy's {@link Ext.data.proxy.Proxy#cfg-reader reader} configuration property:\n * \n *     Ext.create('Ext.data.Store', {\n *         model: 'User',\n *         proxy: {\n *             type: 'ajax',\n *             url : 'users.json',\n *             reader: {\n *                 type: 'json',\n *                 root: 'users'\n *             }\n *         },\n *     });\n *     \n * The above reader is configured to consume a JSON string that looks something like this:\n *  \n *     {\n *         \"success\": true,\n *         \"users\": [\n *             { \"name\": \"User 1\" },\n *             { \"name\": \"User 2\" }\n *         ]\n *     }\n * \n *\n * # Loading Nested Data\n *\n * Readers have the ability to automatically load deeply-nested data objects based on the {@link Ext.data.association.Association\n * associations} configured on each Model. Below is an example demonstrating the flexibility of these associations in a\n * fictional CRM system which manages a User, their Orders, OrderItems and Products. First we'll define the models:\n *\n *     Ext.define(\"User\", {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             'id', 'name'\n *         ],\n *\n *         hasMany: {model: 'Order', name: 'orders'},\n *\n *         proxy: {\n *             type: 'rest',\n *             url : 'users.json',\n *             reader: {\n *                 type: 'json',\n *                 root: 'users'\n *             }\n *         }\n *     });\n *\n *     Ext.define(\"Order\", {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             'id', 'total'\n *         ],\n *\n *         hasMany  : {model: 'OrderItem', name: 'orderItems', associationKey: 'order_items'},\n *         belongsTo: 'User'\n *     });\n *\n *     Ext.define(\"OrderItem\", {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             'id', 'price', 'quantity', 'order_id', 'product_id'\n *         ],\n *\n *         belongsTo: ['Order', {model: 'Product', associationKey: 'product'}]\n *     });\n *\n *     Ext.define(\"Product\", {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             'id', 'name'\n *         ],\n *\n *         hasMany: 'OrderItem'\n *     });\n *\n * This may be a lot to take in - basically a User has many Orders, each of which is composed of several OrderItems.\n * Finally, each OrderItem has a single Product. This allows us to consume data like this:\n *\n *     {\n *         \"users\": [\n *             {\n *                 \"id\": 123,\n *                 \"name\": \"Ed\",\n *                 \"orders\": [\n *                     {\n *                         \"id\": 50,\n *                         \"total\": 100,\n *                         \"order_items\": [\n *                             {\n *                                 \"id\"      : 20,\n *                                 \"price\"   : 40,\n *                                 \"quantity\": 2,\n *                                 \"product\" : {\n *                                     \"id\": 1000,\n *                                     \"name\": \"MacBook Pro\"\n *                                 }\n *                             },\n *                             {\n *                                 \"id\"      : 21,\n *                                 \"price\"   : 20,\n *                                 \"quantity\": 3,\n *                                 \"product\" : {\n *                                     \"id\": 1001,\n *                                     \"name\": \"iPhone\"\n *                                 }\n *                             }\n *                         ]\n *                     }\n *                 ]\n *             }\n *         ]\n *     }\n *\n * The JSON response is deeply nested - it returns all Users (in this case just 1 for simplicity's sake), all of the\n * Orders for each User (again just 1 in this case), all of the OrderItems for each Order (2 order items in this case),\n * and finally the Product associated with each OrderItem. Now we can read the data and use it as follows:\n *\n *     var store = Ext.create('Ext.data.Store', {\n *         model: \"User\"\n *     });\n *\n *     store.load({\n *         callback: function() {\n *             //the user that was loaded\n *             var user = store.first();\n *\n *             console.log(\"Orders for \" + user.get('name') + \":\")\n *\n *             //iterate over the Orders for each User\n *             user.orders().each(function(order) {\n *                 console.log(\"Order ID: \" + order.getId() + \", which contains items:\");\n *\n *                 //iterate over the OrderItems for each Order\n *                 order.orderItems().each(function(orderItem) {\n *                     //we know that the Product data is already loaded, so we can use the synchronous getProduct\n *                     //usually, we would use the asynchronous version (see {@link Ext.data.association.BelongsTo})\n *                     var product = orderItem.getProduct();\n *\n *                     console.log(orderItem.get('quantity') + ' orders of ' + product.get('name'));\n *                 });\n *             });\n *         }\n *     });\n *\n * Running the code above results in the following:\n *\n *     Orders for Ed:\n *     Order ID: 50, which contains items:\n *     2 orders of MacBook Pro\n *     3 orders of iPhone\n */\nExt.define('Ext.data.reader.Reader', {\n    requires: ['Ext.data.ResultSet', 'Ext.XTemplate'],\n    alternateClassName: ['Ext.data.Reader', 'Ext.data.DataReader'],\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @cfg {String} idProperty\n     * Name of the property within a row object that contains a record identifier value. Defaults to the id of the\n     * model. If an idProperty is explicitly specified it will override the idProperty defined on the model.\n     */\n\n    /**\n     * @cfg {String} [totalProperty=\"total\"]\n     * Name of the property from which to retrieve the total number of records in the dataset. This is only needed if\n     * the whole dataset is not passed in one go, but is being paged from the remote server.\n     */\n    totalProperty: 'total',\n\n    /**\n     * @cfg {String} [successProperty=\"success\"]\n     * Name of the property from which to retrieve the `success` attribute, the value of which indicates\n     * whether a given request succeeded or failed (typically a boolean or 'true'|'false'). See\n     * {@link Ext.data.proxy.Server}.{@link Ext.data.proxy.Server#exception exception} for additional information.\n     */\n    successProperty: 'success',\n\n    /**\n     * @cfg {String} root\n     * The name of the property which contains the data items corresponding to the Model(s) for which this\n     * Reader is configured.  For JSON reader it's a property name (or a dot-separated list of property names\n     * if the root is nested).  For XML reader it's a CSS selector.  For Array reader the root is not applicable\n     * since the data is assumed to be a single-level array of arrays.\n     * \n     * By default the natural root of the data will be used: the root JSON array, the root XML element, or the array.\n     *\n     * The data packet value for this property should be an empty array to clear the data or show no data.\n     */\n    root: '',\n    \n    /**\n     * @cfg {String} messageProperty\n     * The name of the property which contains a response message. This property is optional.\n     */\n    \n    /**\n     * @cfg {Boolean} [implicitIncludes=true]\n     * True to automatically parse models nested within other models in a response object. See the\n     * Ext.data.reader.Reader intro docs for full explanation.\n     */\n    implicitIncludes: true,\n    \n    /**\n     * @cfg {Boolean} [readRecordsOnFailure=true]\n     * True to extract the records from a data packet even if the {@link #successProperty} returns false.\n     */\n    readRecordsOnFailure: true,\n    \n    /**\n     * @property {Object} metaData\n     * The raw meta data that was most recently read, if any. Meta data can include existing\n     * Reader config options like {@link #idProperty}, {@link #totalProperty}, etc. that get\n     * automatically applied to the Reader, and those can still be accessed directly from the Reader\n     * if needed. However, meta data is also often used to pass other custom data to be processed\n     * by application code. For example, it is common when reconfiguring the data model of a grid to\n     * also pass a corresponding column model config to be applied to the grid. Any such data will\n     * not get applied to the Reader directly (it just gets passed through and is ignored by Ext).\n     * This metaData property gives you access to all meta data that was passed, including any such\n     * custom data ignored by the reader.\n     * \n     * This is a read-only property, and it will get replaced each time a new meta data object is\n     * passed to the reader. Note that typically you would handle proxy's\n     * {@link Ext.data.proxy.Proxy#metachange metachange} event which passes this exact same meta\n     * object to listeners. However this property is available if it's more convenient to access it\n     * via the reader directly in certain cases.\n     * @readonly\n     */\n    \n    /*\n     * @property {Boolean} isReader\n     * `true` in this class to identify an object as an instantiated Reader, or subclass thereof.\n     */\n    isReader: true,\n\n    // Private flag to the generated convertRecordData function to indicate whether to apply Field default\n    // values to fields for which no value is present in the raw data.\n    // This is set to false by a Server Proxy which is reading the response from a \"create\" or \"update\" operation.\n    applyDefaults: true,\n\n    lastFieldGeneration: null,\n    \n    /**\n     * Creates new Reader.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        var me = this;\n        \n        me.mixins.observable.constructor.call(me, config);\n        me.fieldCount = 0;\n        me.model = Ext.ModelManager.getModel(me.model);\n        me.accessExpressionFn = Ext.Function.bind(me.createFieldAccessExpression, me);\n\n        // Extractors can only be calculated if the fields MixedCollection has been set.\n        // A Model may only complete its setup (set the prototype properties) after asynchronous loading\n        // which would mean that there may be no \"fields\"\n        // If this happens, the load callback will call proxy.setModel which calls reader.setModel which\n        // triggers buildExtractors.\n        if (me.model && me.model.prototype.fields) {\n            me.buildExtractors();\n        }\n\n        this.addEvents(\n            /**\n             * @event\n             * Fires when the reader receives improperly encoded data from the server\n             * @param {Ext.data.reader.Reader} reader A reference to this reader\n             * @param {XMLHttpRequest} response The XMLHttpRequest response object\n             * @param {Ext.data.ResultSet} error The error object\n             */\n            'exception'\n        );\n    },\n\n    /**\n     * Sets a new model for the reader.\n     * @private\n     * @param {Object} model The model to set.\n     * @param {Boolean} setOnProxy True to also set on the Proxy, if one is configured\n     */\n    setModel: function(model, setOnProxy) {\n        var me = this;\n        \n        me.model = Ext.ModelManager.getModel(model);\n        me.buildExtractors(true);\n        \n        if (setOnProxy && me.proxy) {\n            me.proxy.setModel(me.model, true);\n        }\n    },\n\n    /**\n     * Reads the given response object. This method normalizes the different types of response object that may be passed to it.\n     * If it's an XMLHttpRequest object, hand off to the subclass' {@link #getResponseData} method.\n     * Else, hand off the reading of records to the {@link #readRecords} method.\n     * @param {Object} response The response object. This may be either an XMLHttpRequest object or a plain JS object\n     * @return {Ext.data.ResultSet} The parsed or default ResultSet object\n     */\n    read: function(response) {\n        var data;\n\n        if (response) {\n            data = response.responseText ? this.getResponseData(response) : this.readRecords(response);\n        }\n\n        return data || this.nullResultSet;\n    },\n\n    /**\n     * Abstracts common functionality used by all Reader subclasses. Each subclass is expected to call this function\n     * before running its own logic and returning the Ext.data.ResultSet instance. For most Readers additional\n     * processing should not be needed.\n     * @param {Object} data The raw data object\n     * @return {Ext.data.ResultSet} A ResultSet object\n     */\n    readRecords: function(data) {\n        var me = this,\n            success,\n            recordCount,\n            records,\n            root,\n            total,\n            value,\n            message;\n        \n        /*\n         * We check here whether fields collection has changed since the last read.\n         * This works around an issue when a Model is used for both a Tree and another\n         * source, because the tree decorates the model with extra fields and it causes\n         * issues because the readers aren't notified.\n         */\n        if (me.lastFieldGeneration !== me.model.prototype.fields.generation) {\n            me.buildExtractors(true);\n        }\n        \n        /**\n         * @property {Object} rawData\n         * The raw data object that was last passed to {@link #readRecords}. Stored for further processing if needed.\n         */\n        me.rawData = data;\n\n        data = me.getData(data);\n        \n        success = true;\n        recordCount = 0;\n        records = [];\n            \n        if (me.successProperty) {\n            value = me.getSuccess(data);\n            if (value === false || value === 'false') {\n                success = false;\n            }\n        }\n        \n        if (me.messageProperty) {\n            message = me.getMessage(data);\n        }\n\n        \n        // Only try and extract other data if call was successful\n        if (me.readRecordsOnFailure || success) {\n            // If we pass an array as the data, we dont use getRoot on the data.\n            // Instead the root equals to the data.\n            root = Ext.isArray(data) ? data : me.getRoot(data);\n            \n            if (root) {\n                total = root.length;\n            }\n\n          if (me.totalProperty) {\n                value = parseInt(me.getTotal(data), 10);\n                if (!isNaN(value)) {\n                    total = value;\n                }\n            }\n\n           if (root) {\n                records = me.extractData(root);\n                recordCount = records.length;\n            }\n        }\n\n        return new Ext.data.ResultSet({\n            total  : total || recordCount,\n            count  : recordCount,\n            records: records,\n            success: success,\n            message: message\n        });\n    },\n\n    /**\n     * Returns extracted, type-cast rows of data.\n     * @param {Object[]/Object} root from server response\n     * @return {Array} An array of records containing the extracted data\n     * @private\n     */\n    extractData : function(root) {\n        var me = this,\n            records = [],\n            Model   = me.model,\n            length  = root.length,\n            convertedValues, node, record, i;\n            \n        if (!root.length && Ext.isObject(root)) {\n            root = [root];\n            length = 1;\n        }\n\n        for (i = 0; i < length; i++) {\n            node = root[i];\n            if (!node.isModel) { \n                // Create a record with an empty data object.\n                // Populate that data object by extracting and converting field values from raw data\n                record = new Model(undefined, me.getId(node), node, convertedValues = {});\n\n                // If the server did not include an id in the response data, the Model constructor will mark the record as phantom.\n                // We  need to set phantom to false here because records created from a server response using a reader by definition are not phantom records.\n                record.phantom = false;\n\n                // Use generated function to extract all fields at once\n                me.convertRecordData(convertedValues, node, record);\n\n                records.push(record);\n                \n                if (me.implicitIncludes) {\n                    me.readAssociated(record, node);\n                }\n            } else {\n                // If we're given a model instance in the data, just push it on\n                // without doing any conversion\n                records.push(node);\n            }\n        }\n\n        return records;\n    },\n    \n    /**\n     * @private\n     * Loads a record's associations from the data object. This prepopulates hasMany and belongsTo associations\n     * on the record provided.\n     * @param {Ext.data.Model} record The record to load associations for\n     * @param {Object} data The data object\n     * @return {String} Return value description\n     */\n    readAssociated: function(record, data) {\n        var associations = record.associations.items,\n            i            = 0,\n            length       = associations.length,\n            association, associationData, proxy, reader;\n        \n        for (; i < length; i++) {\n            association     = associations[i];\n            associationData = this.getAssociatedDataRoot(data, association.associationKey || association.name);\n            \n            if (associationData) {\n                reader = association.getReader();\n                if (!reader) {\n                    proxy = association.associatedModel.proxy;\n                    // if the associated model has a Reader already, use that, otherwise attempt to create a sensible one\n                    if (proxy) {\n                        reader = proxy.getReader();\n                    } else {\n                        reader = new this.constructor({\n                            model: association.associatedName\n                        });\n                    }\n                }\n                association.read(record, reader, associationData);\n            }  \n        }\n    },\n    \n    /**\n     * @private\n     * Used internally by {@link #readAssociated}. Given a data object (which could be json, xml etc) for a specific\n     * record, this should return the relevant part of that data for the given association name. This is only really\n     * needed to support the XML Reader, which has to do a query to get the associated data object\n     * @param {Object} data The raw data object\n     * @param {String} associationName The name of the association to get data for (uses associationKey if present)\n     * @return {Object} The root\n     */\n    getAssociatedDataRoot: function(data, associationName) {\n        return data[associationName];\n    },\n    \n    getFields: function() {\n        return this.model.prototype.fields.items;\n    },\n\n    /**\n     * @private\n     * By default this function just returns what is passed to it. It can be overridden in a subclass\n     * to return something else. See XmlReader for an example.\n     * @param {Object} data The data object\n     * @return {Object} The normalized data object\n     */\n    getData: function(data) {\n        return data;\n    },\n\n    /**\n     * @private\n     * This will usually need to be implemented in a subclass. Given a generic data object (the type depends on the type\n     * of data we are reading), this function should return the object as configured by the Reader's 'root' meta data config.\n     * See XmlReader's getRoot implementation for an example. By default the same data object will simply be returned.\n     * @param {Object} data The data object\n     * @return {Object} The same data object\n     */\n    getRoot: function(data) {\n        return data;\n    },\n\n    /**\n     * Takes a raw response object (as passed to the {@link #read} method) and returns the useful data\n     * segment from it. This must be implemented by each subclass.\n     * @param {Object} response The response object\n     * @return {Ext.data.ResultSet} A ResultSet object\n     */\n    getResponseData: function(response) {\n        Ext.Error.raise(\"getResponseData must be implemented in the Ext.data.reader.Reader subclass\");\n    },\n\n    /**\n     * @private\n     * Reconfigures the meta data tied to this Reader\n     */\n    onMetaChange : function(meta) {\n        var me = this,\n            fields = meta.fields || me.getFields(),\n            newModel,\n            clientIdProperty;\n        \n        // save off the raw meta data\n        me.metaData = meta;\n        \n        // set any reader-specific configs from meta if available\n        me.root = meta.root || me.root;\n        me.idProperty = meta.idProperty || me.idProperty;\n        me.totalProperty = meta.totalProperty || me.totalProperty;\n        me.successProperty = meta.successProperty || me.successProperty;\n        me.messageProperty = meta.messageProperty || me.messageProperty;\n        clientIdProperty = meta.clientIdProperty;\n\n        if (me.model) {\n            me.model.setFields(fields, me.idProperty, clientIdProperty);\n            me.setModel(me.model, true);\n        }\n        else {\n            newModel = Ext.define(\"Ext.data.reader.Json-Model\" + Ext.id(), {\n                extend: 'Ext.data.Model',\n                fields: fields,\n                clientIdProperty: clientIdProperty\n            });\n            if (me.idProperty) {\n                // We only do this if the reader actually has a custom idProperty set,\n                // otherwise let the model use its own default value. It is valid for\n                // the reader idProperty to be undefined, in which case it will use the\n                // model's idProperty (in getIdProperty()).\n                newModel.idProperty = me.idProperty;\n            }\n            me.setModel(newModel, true);\n        }\n    },\n    \n    /**\n     * Get the idProperty to use for extracting data\n     * @private\n     * @return {String} The id property\n     */\n    getIdProperty: function(){\n        return this.idProperty || this.model.prototype.idProperty;\n    },\n\n    /**\n     * @private\n     * This builds optimized functions for retrieving record data and meta data from an object.\n     * Subclasses may need to implement their own getRoot function.\n     * @param {Boolean} [force=false] True to automatically remove existing extractor functions first\n     */\n    buildExtractors: function(force) {\n        var me          = this,\n            idProp      = me.getIdProperty(),\n            totalProp   = me.totalProperty,\n            successProp = me.successProperty,\n            messageProp = me.messageProperty,\n            accessor,\n            idField,\n            map;\n            \n        if (force === true) {\n            delete me.convertRecordData;\n        }\n        \n        if (me.convertRecordData) {\n            return;\n        }   \n\n        //build the extractors for all the meta data\n        if (totalProp) {\n            me.getTotal = me.createAccessor(totalProp);\n        }\n\n        if (successProp) {\n            me.getSuccess = me.createAccessor(successProp);\n        }\n\n        if (messageProp) {\n            me.getMessage = me.createAccessor(messageProp);\n        }\n\n        if (idProp) {\n            idField = me.model.prototype.fields.get(idProp);\n            if (idField) {\n                map = idField.mapping;\n                idProp = (map !== undefined && map !== null) ? map : idProp;\n            }\n            accessor = me.createAccessor(idProp);\n\n            me.getId = function(record) {\n                var id = accessor.call(me, record);\n                return (id === undefined || id === '') ? null : id;\n            };\n        } else {\n            me.getId = function() {\n                return null;\n            };\n        }\n        me.convertRecordData = me.buildRecordDataExtractor();\n        me.lastFieldGeneration = me.model.prototype.fields.generation;\n    },\n\n    recordDataExtractorTemplate : [\n        'var me = this\\n',\n        '    ,fields = me.model.prototype.fields\\n',\n        '    ,value\\n',\n        '    ,internalId\\n',\n        '<tpl for=\"fields\">',\n        '    ,__field{#} = fields.get(\"{name}\")\\n',\n        '</tpl>', ';\\n',\n\n        'return function(dest, source, record) {\\n',\n        '<tpl for=\"fields\">',\n        // createFieldAccessExpression must be implemented in subclasses to extract data from the source object in the correct way\n        '    value = {[ this.createFieldAccessExpression(values, \"__field\" + xindex, \"source\") ]};\\n',\n\n        // Code for processing a source property when a custom convert is defined\n            '<tpl if=\"hasCustomConvert\">',\n        '    dest[\"{name}\"] = value === undefined ? __field{#}.convert(__field{#}.defaultValue, record) : __field{#}.convert(value, record);\\n',\n\n        // Code for processing a source property when there is a default value\n            '<tpl elseif=\"defaultValue !== undefined\">',\n        '    if (value === undefined) {\\n',\n        '        if (me.applyDefaults) {\\n',\n                '<tpl if=\"convert\">',\n        '            dest[\"{name}\"] = __field{#}.convert(__field{#}.defaultValue, record);\\n',\n                '<tpl else>',\n        '            dest[\"{name}\"] = __field{#}.defaultValue\\n',\n                '</tpl>',\n        '        };\\n',\n        '    } else {\\n',\n                '<tpl if=\"convert\">',\n        '        dest[\"{name}\"] = __field{#}.convert(value, record);\\n',\n                '<tpl else>',\n        '        dest[\"{name}\"] = value;\\n',\n                '</tpl>',\n        '    };',\n\n        // Code for processing a source property value when there is no default value\n            '<tpl else>',\n        '    if (value !== undefined) {\\n',\n                '<tpl if=\"convert\">',\n        '        dest[\"{name}\"] = __field{#}.convert(value, record);\\n',\n                '<tpl else>',\n        '        dest[\"{name}\"] = value;\\n',\n                '</tpl>',\n        '    }\\n',\n            '</tpl>',\n\n        '</tpl>',\n\n        // set the client id as the internalId of the record.\n        // clientId handles the case where a client side record did not previously exist on the server,\n        // so the server is passing back a client id that can be used to pair the server side record up with the client record\n        '<tpl if=\"clientIdProp\">',\n        '    if (record && (internalId = {[ this.createFieldAccessExpression(\\{mapping: values.clientIdProp\\}, null, \"source\") ]})) {\\n',\n        '        record.{[\"internalId\"]} = internalId;\\n',\n        '    }\\n',\n        '</tpl>',\n\n        '};'\n    ],\n\n    /**\n     * @private\n     * Return a function which will read a raw row object in the format this Reader accepts, and populates\n     * a record's data object with converted data values.\n     *\n     * The returned function must be passed the following parameters:\n     *\n     * - dest A record's empty data object into which the new field value properties are injected.\n     * - source A raw row data object of whatever type this Reader consumes\n     * - record The record which is being populated.\n     *\n     */\n    buildRecordDataExtractor: function() {\n        var me = this,\n            modelProto = me.model.prototype,\n            templateData = {\n                clientIdProp: modelProto.clientIdProperty,\n                fields: modelProto.fields.items\n            };\n\n        me.recordDataExtractorTemplate.createFieldAccessExpression = me.accessExpressionFn;\n        // Here we are creating a new Function and invoking it immediately in the scope of this Reader\n        // It declares several vars capturing the configured context of this Reader, and returns a function\n        // which, when passed a record data object, a raw data row in the format this Reader is configured to read,\n        // and the record which is being created, will populate the record's data object from the raw row data.\n        return Ext.functionFactory(me.recordDataExtractorTemplate.apply(templateData)).call(me);\n    },\n\n    destroyReader: function() {\n        var me = this;\n        delete me.proxy;\n        delete me.model;\n        delete me.convertRecordData;\n        delete me.getId;\n        delete me.getTotal;\n        delete me.getSuccess;\n        delete me.getMessage;\n    }\n}, function() {\n    var proto = this.prototype;\n    Ext.apply(proto, {\n        // Private. Empty ResultSet to return when response is falsy (null|undefined|empty string)\n        nullResultSet: new Ext.data.ResultSet({\n            total  : 0,\n            count  : 0,\n            records: [],\n            success: true\n        }),\n        recordDataExtractorTemplate: new Ext.XTemplate(proto.recordDataExtractorTemplate)\n    });\n});\n\n/**\n * @author Ed Spencer\n *\n * The JSON Reader is used by a Proxy to read a server response that is sent back in JSON format. This usually\n * happens as a result of loading a Store - for example we might create something like this:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'name', 'email']\n *     });\n *\n *     var store = Ext.create('Ext.data.Store', {\n *         model: 'User',\n *         proxy: {\n *             type: 'ajax',\n *             url : 'users.json',\n *             reader: {\n *                 type: 'json'\n *             }\n *         }\n *     });\n *\n * The example above creates a 'User' model. Models are explained in the {@link Ext.data.Model Model} docs if you're\n * not already familiar with them.\n *\n * We created the simplest type of JSON Reader possible by simply telling our {@link Ext.data.Store Store}'s\n * {@link Ext.data.proxy.Proxy Proxy} that we want a JSON Reader. The Store automatically passes the configured model to the\n * Store, so it is as if we passed this instead:\n *\n *     reader: {\n *         type : 'json',\n *         model: 'User'\n *     }\n *\n * The reader we set up is ready to read data from our server - at the moment it will accept a response like this:\n *\n *     [\n *         {\n *             \"id\": 1,\n *             \"name\": \"Ed Spencer\",\n *             \"email\": \"ed@sencha.com\"\n *         },\n *         {\n *             \"id\": 2,\n *             \"name\": \"Abe Elias\",\n *             \"email\": \"abe@sencha.com\"\n *         }\n *     ]\n *\n * ## Reading other JSON formats\n *\n * If you already have your JSON format defined and it doesn't look quite like what we have above, you can usually\n * pass JsonReader a couple of configuration options to make it parse your format. For example, we can use the\n * {@link #cfg-root} configuration to parse data that comes back like this:\n *\n *     {\n *         \"users\": [\n *            {\n *                \"id\": 1,\n *                \"name\": \"Ed Spencer\",\n *                \"email\": \"ed@sencha.com\"\n *            },\n *            {\n *                \"id\": 2,\n *                \"name\": \"Abe Elias\",\n *                \"email\": \"abe@sencha.com\"\n *            }\n *         ]\n *     }\n *\n * To parse this we just pass in a {@link #root} configuration that matches the 'users' above:\n *\n *     reader: {\n *         type: 'json',\n *         root: 'users'\n *     }\n *\n * Sometimes the JSON structure is even more complicated. Document databases like CouchDB often provide metadata\n * around each record inside a nested structure like this:\n *\n *     {\n *         \"total\": 122,\n *         \"offset\": 0,\n *         \"users\": [\n *             {\n *                 \"id\": \"ed-spencer-1\",\n *                 \"value\": 1,\n *                 \"user\": {\n *                     \"id\": 1,\n *                     \"name\": \"Ed Spencer\",\n *                     \"email\": \"ed@sencha.com\"\n *                 }\n *             }\n *         ]\n *     }\n *\n * In the case above the record data is nested an additional level inside the \"users\" array as each \"user\" item has\n * additional metadata surrounding it ('id' and 'value' in this case). To parse data out of each \"user\" item in the\n * JSON above we need to specify the {@link #record} configuration like this:\n *\n *     reader: {\n *         type  : 'json',\n *         root  : 'users',\n *         record: 'user'\n *     }\n *\n * ## Response MetaData\n *\n * The server can return metadata in its response, in addition to the record data, that describe attributes\n * of the data set itself or are used to reconfigure the Reader. To pass metadata in the response you simply\n * add a `metaData` attribute to the root of the response data. The metaData attribute can contain anything,\n * but supports a specific set of properties that are handled by the Reader if they are present:\n * \n * - {@link #root}: the property name of the root response node containing the record data\n * - {@link #idProperty}: property name for the primary key field of the data\n * - {@link #totalProperty}: property name for the total number of records in the data\n * - {@link #successProperty}: property name for the success status of the response\n * - {@link #messageProperty}: property name for an optional response message\n * - {@link Ext.data.Model#cfg-fields fields}: Config used to reconfigure the Model's fields before converting the\n * response data into records\n * \n * An initial Reader configuration containing all of these properties might look like this (\"fields\" would be\n * included in the Model definition, not shown):\n *\n *     reader: {\n *         type : 'json',\n *         root : 'root',\n *         idProperty     : 'id',\n *         totalProperty  : 'total',\n *         successProperty: 'success',\n *         messageProperty: 'message'\n *     }\n *\n * If you were to pass a response object containing attributes different from those initially defined above, you could\n * use the `metaData` attribute to reconifgure the Reader on the fly. For example:\n *\n *     {\n *         \"count\": 1,\n *         \"ok\": true,\n *         \"msg\": \"Users found\",\n *         \"users\": [{\n *             \"userId\": 123,\n *             \"name\": \"Ed Spencer\",\n *             \"email\": \"ed@sencha.com\"\n *         }],\n *         \"metaData\": {\n *             \"root\": \"users\",\n *             \"idProperty\": 'userId',\n *             \"totalProperty\": 'count',\n *             \"successProperty\": 'ok',\n *             \"messageProperty\": 'msg'\n *         }\n *     }\n *\n * You can also place any other arbitrary data you need into the `metaData` attribute which will be ignored by the Reader,\n * but will be accessible via the Reader's {@link #metaData} property (which is also passed to listeners via the Proxy's\n * {@link Ext.data.proxy.Proxy#metachange metachange} event (also relayed by the {@link Ext.data.AbstractStore#metachange\n * store}). Application code can then process the passed metadata in any way it chooses.\n * \n * A simple example for how this can be used would be customizing the fields for a Model that is bound to a grid. By passing\n * the `fields` property the Model will be automatically updated by the Reader internally, but that change will not be\n * reflected automatically in the grid unless you also update the column configuration. You could do this manually, or you\n * could simply pass a standard grid {@link Ext.panel.Table#columns column} config object as part of the `metaData` attribute\n * and then pass that along to the grid. Here's a very simple example for how that could be accomplished:\n *\n *     // response format:\n *     {\n *         ...\n *         \"metaData\": {\n *             \"fields\": [\n *                 { \"name\": \"userId\", \"type\": \"int\" },\n *                 { \"name\": \"name\", \"type\": \"string\" },\n *                 { \"name\": \"birthday\", \"type\": \"date\", \"dateFormat\": \"Y-j-m\" },\n *             ],\n *             \"columns\": [\n *                 { \"text\": \"User ID\", \"dataIndex\": \"userId\", \"width\": 40 },\n *                 { \"text\": \"User Name\", \"dataIndex\": \"name\", \"flex\": 1 },\n *                 { \"text\": \"Birthday\", \"dataIndex\": \"birthday\", \"flex\": 1, \"format\": 'Y-j-m', \"xtype\": \"datecolumn\" }\n *             ]\n *         }\n *     }\n *\n * The Reader will automatically read the meta fields config and rebuild the Model based on the new fields, but to handle\n * the new column configuration you would need to handle the metadata within the application code. This is done simply enough\n * by handling the metachange event on either the store or the proxy, e.g.:\n *\n *     var store = Ext.create('Ext.data.Store', {\n *         ...\n *         listeners: {\n *             'metachange': function(store, meta) {\n *                 myGrid.reconfigure(store, meta.columns);\n *             }\n *         }\n *     });\n *\n */\nExt.define('Ext.data.reader.Json', {\n    extend: 'Ext.data.reader.Reader',\n    alternateClassName: 'Ext.data.JsonReader',\n    alias : 'reader.json',\n\n    root: '',\n\n    /**\n     * @cfg {String} record The optional location within the JSON response that the record data itself can be found at.\n     * See the JsonReader intro docs for more details. This is not often needed.\n     */\n\n    /**\n     * @cfg {Boolean} useSimpleAccessors True to ensure that field names/mappings are treated as literals when\n     * reading values.\n     *\n     * For example, by default, using the mapping \"foo.bar.baz\" will try and read a property foo from the root, then a property bar\n     * from foo, then a property baz from bar. Setting the simple accessors to true will read the property with the name\n     * \"foo.bar.baz\" direct from the root object.\n     */\n    useSimpleAccessors: false,\n\n    /**\n     * Reads a JSON object and returns a ResultSet. Uses the internal getTotal and getSuccess extractors to\n     * retrieve meta data from the response, and extractData to turn the JSON data into model instances.\n     * @param {Object} data The raw JSON data\n     * @return {Ext.data.ResultSet} A ResultSet containing model instances and meta data about the results\n     */\n    readRecords: function(data) {\n        //this has to be before the call to super because we use the meta data in the superclass readRecords\n        if (data.metaData) {\n            this.onMetaChange(data.metaData);\n        }\n\n        /**\n         * @property {Object} jsonData\n         * A copy of this.rawData.\n         * @deprecated Will be removed in Ext JS 5.0. This is just a copy of this.rawData - use that instead.\n         */\n        this.jsonData = data;\n        return this.callParent([data]);\n    },\n\n    //inherit docs\n    getResponseData: function(response) {\n        var data, error;\n \n        try {\n            data = Ext.decode(response.responseText);\n            return this.readRecords(data);\n        } catch (ex) {\n            error = new Ext.data.ResultSet({\n                total  : 0,\n                count  : 0,\n                records: [],\n                success: false,\n                message: ex.message\n            });\n\n            this.fireEvent('exception', this, response, error);\n\n            Ext.Logger.warn('Unable to parse the JSON returned by the server');\n\n            return error;\n        }\n    },\n\n    //inherit docs\n    buildExtractors : function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        if (me.root) {\n            me.getRoot = me.createAccessor(me.root);\n        } else {\n            me.getRoot = function(root) {\n                return root;\n            };\n        }\n    },\n\n    /**\n     * @private\n     * We're just preparing the data for the superclass by pulling out the record objects we want. If a {@link #record}\n     * was specified we have to pull those out of the larger JSON object, which is most of what this function is doing\n     * @param {Object} root The JSON root node\n     * @return {Ext.data.Model[]} The records\n     */\n    extractData: function(root) {\n        var recordName = this.record,\n            data = [],\n            length, i;\n\n        if (recordName) {\n            length = root.length;\n            \n            if (!length && Ext.isObject(root)) {\n                length = 1;\n                root = [root];\n            }\n\n            for (i = 0; i < length; i++) {\n                data[i] = root[i][recordName];\n            }\n        } else {\n            data = root;\n        }\n        return this.callParent([data]);\n    },\n\n    /**\n     * @private\n     * @method\n     * Returns an accessor function for the given property string. Gives support for properties such as the following:\n     *\n     * - 'someProperty'\n     * - 'some.property'\n     * - 'some[\"property\"]'\n     * \n     * This is used by buildExtractors to create optimized extractor functions when casting raw data into model instances.\n     */\n    createAccessor: (function() {\n        var re = /[\\[\\.]/;\n\n        return function(expr) {\n            if (Ext.isEmpty(expr)) {\n                return Ext.emptyFn;\n            }\n            if (Ext.isFunction(expr)) {\n                return expr;\n            }\n            if (this.useSimpleAccessors !== true) {\n                var i = String(expr).search(re);\n                if (i >= 0) {\n                    return Ext.functionFactory('obj', 'return obj' + (i > 0 ? '.' : '') + expr);\n                }\n            }\n            return function(obj) {\n                return obj[expr];\n            };\n        };\n    }()),\n\n    /**\n     * @private\n     * @method\n     * Returns an accessor expression for the passed Field. Gives support for properties such as the following:\n     * \n     * - 'someProperty'\n     * - 'some.property'\n     * - 'some[\"property\"]'\n     * \n     * This is used by buildExtractors to create optimized on extractor function which converts raw data into model instances.\n     */\n    createFieldAccessExpression: (function() {\n        var re = /[\\[\\.]/;\n\n        return function(field, fieldVarName, dataName) {\n            var me     = this,\n                hasMap = (field.mapping !== null),\n                map    = hasMap ? field.mapping : field.name,\n                result,\n                operatorSearch;\n\n            if (typeof map === 'function') {\n                result = fieldVarName + '.mapping(' + dataName + ', this)';\n            } else if (this.useSimpleAccessors === true || ((operatorSearch = String(map).search(re)) < 0)) {\n                if (!hasMap || isNaN(map)) {\n                    // If we don't provide a mapping, we may have a field name that is numeric\n                    map = '\"' + map + '\"';\n                }\n                result = dataName + \"[\" + map + \"]\";\n            } else {\n                result = dataName + (operatorSearch > 0 ? '.' : '') + map;\n            }\n            return result;\n        };\n    }())\n});\n\n/**\n * @author Ed Spencer\n *\n * Base Writer class used by most subclasses of {@link Ext.data.proxy.Server}. This class is responsible for taking a\n * set of {@link Ext.data.Operation} objects and a {@link Ext.data.Request} object and modifying that request based on\n * the Operations.\n *\n * For example a Ext.data.writer.Json would format the Operations and their {@link Ext.data.Model} instances based on\n * the config options passed to the JsonWriter's constructor.\n *\n * Writers are not needed for any kind of local storage - whether via a {@link Ext.data.proxy.WebStorage Web Storage\n * proxy} (see {@link Ext.data.proxy.LocalStorage localStorage} and {@link Ext.data.proxy.SessionStorage\n * sessionStorage}) or just in memory via a {@link Ext.data.proxy.Memory MemoryProxy}.\n */\nExt.define('Ext.data.writer.Writer', {\n    alias: 'writer.base',\n    alternateClassName: ['Ext.data.DataWriter', 'Ext.data.Writer'],\n    \n    /**\n     * @cfg {Boolean} writeAllFields\n     * True to write all fields from the record to the server. If set to false it will only send the fields that were\n     * modified. Note that any fields that have {@link Ext.data.Field#persist} set to false will still be ignored.\n     */\n    writeAllFields: true,\n    \n    /**\n     * @cfg {String} nameProperty\n     * This property is used to read the key for each value that will be sent to the server. For example:\n     *\n     *     Ext.define('Person', {\n     *         extend: 'Ext.data.Model',\n     *         fields: [{\n     *             name: 'first',\n     *             mapping: 'firstName'\n     *         }, {\n     *             name: 'last',\n     *             mapping: 'lastName'\n     *         }, {\n     *             name: 'age'\n     *         }]\n     *     });\n     *     new Ext.data.writer.Writer({\n     *         writeAllFields: true,\n     *         nameProperty: 'mapping'\n     *     });\n     *\n     *     // This will be sent to the server\n     *     {\n     *         firstName: 'first name value',\n     *         lastName: 'last name value',\n     *         age: 1\n     *     }\n     *\n     * If the value is not present, the field name will always be used.\n     */\n    nameProperty: 'name',\n\n    /*\n     * @property {Boolean} isWriter\n     * `true` in this class to identify an object as an instantiated Writer, or subclass thereof.\n     */\n    isWriter: true,\n\n    /**\n     * Creates new Writer.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        Ext.apply(this, config);\n    },\n\n    /**\n     * Prepares a Proxy's Ext.data.Request object\n     * @param {Ext.data.Request} request The request object\n     * @return {Ext.data.Request} The modified request object\n     */\n    write: function(request) {\n        var operation = request.operation,\n            records   = operation.records || [],\n            len       = records.length,\n            i         = 0,\n            data      = [];\n\n        for (; i < len; i++) {\n            data.push(this.getRecordData(records[i], operation));\n        }\n        return this.writeRecords(request, data);\n    },\n\n    /**\n     * Formats the data for each record before sending it to the server. This\n     * method should be overridden to format the data in a way that differs from the default.\n     * @param {Ext.data.Model} record The record that we are writing to the server.\n     * @param {Ext.data.Operation} [operation] An operation object.\n     * @return {Object} An object literal of name/value keys to be written to the server.\n     * By default this method returns the data property on the record.\n     */\n    getRecordData: function(record, operation) {\n        var isPhantom = record.phantom === true,\n            writeAll = this.writeAllFields || isPhantom,\n            nameProperty = this.nameProperty,\n            fields = record.fields,\n            fieldItems = fields.items,\n            data = {},\n            clientIdProperty = record.clientIdProperty,\n            changes,\n            name,\n            field,\n            key,\n            value,\n            f, fLen;\n\n        if (writeAll) {\n            fLen = fieldItems.length;\n\n            for (f = 0; f < fLen; f++) {\n                field = fieldItems[f];\n                if (field.persist) {\n                    name = field[nameProperty] || field.name;\n                    value = record.get(field.name);\n                    if (field.serialize) {\n                        data[name] = field.serialize(value, record);\n                    } else if (field.type === Ext.data.Types.DATE && field.dateFormat) {\n                        data[name] = Ext.Date.format(value, field.dateFormat);\n                    } else {\n                        data[name] = value;\n                    }\n                }\n            }\n        } else {\n            // Only write the changes\n            changes = record.getChanges();\n            for (key in changes) {\n                if (changes.hasOwnProperty(key)) {\n                    field = fields.get(key);\n                    if (field.persist) {\n                        name = field[nameProperty] || field.name;\n                        value = record.get(field.name);\n                        if (field.serialize) {\n                            data[name] = field.serialize(value, record);\n                        } else if (field.type === Ext.data.Types.DATE && field.dateFormat) {\n                            data[name] = Ext.Date.format(value, field.dateFormat);\n                        } else {\n                            data[name] = value;\n                        }\n                    }\n                }\n            }\n        }\n        if (isPhantom) {\n            if (clientIdProperty && operation && operation.records.length > 1) {\n                // include clientId for phantom records, if multiple records are being written to the server in one operation.\n                // The server can then return the clientId with each record so the operation can match the server records with the client records\n                data[clientIdProperty] = record.internalId;\n            }\n        } else {\n            // always include the id for non phantoms\n            data[record.idProperty] = record.getId();\n        }\n\n        return data;\n    }\n});\n\n/**\n * @class Ext.data.writer.Json\n\nThis class is used to write {@link Ext.data.Model} data to the server in a JSON format.\nThe {@link #allowSingle} configuration can be set to false to force the records to always be\nencoded in an array, even if there is only a single record being sent.\n\n * @markdown\n */\nExt.define('Ext.data.writer.Json', {\n    extend: 'Ext.data.writer.Writer',\n    alternateClassName: 'Ext.data.JsonWriter',\n    alias: 'writer.json',\n    \n    /**\n     * @cfg {String} root The key under which the records in this Writer will be placed. Defaults to <tt>undefined</tt>.\n     * Example generated request, using root: 'records':\n<pre><code>\n{'records': [{name: 'my record'}, {name: 'another record'}]}\n</code></pre>\n     */\n    root: undefined,\n    \n    /**\n     * @cfg {Boolean} encode True to use Ext.encode() on the data before sending. Defaults to <tt>false</tt>.\n     * The encode option should only be set to true when a {@link #root} is defined, because the values will be\n     * sent as part of the request parameters as opposed to a raw post. The root will be the name of the parameter\n     * sent to the server.\n     */\n    encode: false,\n    \n    /**\n     * @cfg {Boolean} allowSingle False to ensure that records are always wrapped in an array, even if there is only\n     * one record being sent. When there is more than one record, they will always be encoded into an array.\n     * Defaults to <tt>true</tt>. Example:\n     * <pre><code>\n// with allowSingle: true\n\"root\": {\n    \"first\": \"Mark\",\n    \"last\": \"Corrigan\"\n}\n\n// with allowSingle: false\n\"root\": [{\n    \"first\": \"Mark\",\n    \"last\": \"Corrigan\"\n}]\n     * </code></pre>\n     */\n    allowSingle: true,\n    \n    //inherit docs\n    writeRecords: function(request, data) {\n        var root = this.root;\n        \n        if (this.allowSingle && data.length == 1) {\n            // convert to single object format\n            data = data[0];\n        }\n        \n        if (this.encode) {\n            if (root) {\n                // sending as a param, need to encode\n                request.params[root] = Ext.encode(data);\n            } else {\n                Ext.Error.raise('Must specify a root when using encode');\n            }\n        } else {\n            // send as jsonData\n            request.jsonData = request.jsonData || {};\n            if (root) {\n                request.jsonData[root] = data;\n            } else {\n                request.jsonData = data;\n            }\n        }\n        return request;\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * ServerProxy is a superclass of {@link Ext.data.proxy.JsonP JsonPProxy} and {@link Ext.data.proxy.Ajax AjaxProxy}, and\n * would not usually be used directly.\n *\n * ServerProxy should ideally be named HttpProxy as it is a superclass for all HTTP proxies - for Ext JS 4.x it has been\n * called ServerProxy to enable any 3.x applications that reference the HttpProxy to continue to work (HttpProxy is now\n * an alias of AjaxProxy).\n * @private\n */\nExt.define('Ext.data.proxy.Server', {\n    extend: 'Ext.data.proxy.Proxy',\n    alias : 'proxy.server',\n    alternateClassName: 'Ext.data.ServerProxy',\n    uses  : ['Ext.data.Request'],\n\n    /**\n     * @cfg {String} url\n     * The URL from which to request the data object.\n     */\n\n    /**\n     * @cfg {String} pageParam\n     * The name of the 'page' parameter to send in a request. Defaults to 'page'. Set this to undefined if you don't\n     * want to send a page parameter.\n     */\n    pageParam: 'page',\n\n    /**\n     * @cfg {String} startParam\n     * The name of the 'start' parameter to send in a request. Defaults to 'start'. Set this to undefined if you don't\n     * want to send a start parameter.\n     */\n    startParam: 'start',\n\n    /**\n     * @cfg {String} limitParam\n     * The name of the 'limit' parameter to send in a request. Defaults to 'limit'. Set this to undefined if you don't\n     * want to send a limit parameter.\n     */\n    limitParam: 'limit',\n\n    /**\n     * @cfg {String} groupParam\n     * The name of the 'group' parameter to send in a request. Defaults to 'group'. Set this to undefined if you don't\n     * want to send a group parameter.\n     */\n    groupParam: 'group',\n\n    /**\n     * @cfg {String} groupDirectionParam\n     * The name of the direction parameter to send in a request. **This is only used when simpleGroupMode is set to\n     * true.** Defaults to 'groupDir'.\n     */\n    groupDirectionParam: 'groupDir',\n\n    /**\n     * @cfg {String} sortParam\n     * The name of the 'sort' parameter to send in a request. Defaults to 'sort'. Set this to undefined if you don't\n     * want to send a sort parameter.\n     */\n    sortParam: 'sort',\n\n    /**\n     * @cfg {String} filterParam\n     * The name of the 'filter' parameter to send in a request. Defaults to 'filter'. Set this to undefined if you don't\n     * want to send a filter parameter.\n     */\n    filterParam: 'filter',\n\n    /**\n     * @cfg {String} directionParam\n     * The name of the direction parameter to send in a request. **This is only used when simpleSortMode is set to\n     * true.** Defaults to 'dir'.\n     */\n    directionParam: 'dir',\n\n    /**\n     * @cfg {Boolean} simpleSortMode\n     * Enabling simpleSortMode in conjunction with remoteSort will only send one sort property and a direction when a\n     * remote sort is requested. The {@link #directionParam} and {@link #sortParam} will be sent with the property name\n     * and either 'ASC' or 'DESC'.\n     */\n    simpleSortMode: false,\n\n    /**\n     * @cfg {Boolean} simpleGroupMode\n     * Enabling simpleGroupMode in conjunction with remoteGroup will only send one group property and a direction when a\n     * remote group is requested. The {@link #groupDirectionParam} and {@link #groupParam} will be sent with the property name and either 'ASC'\n     * or 'DESC'.\n     */\n    simpleGroupMode: false,\n\n    /**\n     * @cfg {Boolean} noCache\n     * Disable caching by adding a unique parameter name to the request. Set to false to allow caching. Defaults to true.\n     */\n    noCache : true,\n\n    /**\n     * @cfg {String} cacheString\n     * The name of the cache param added to the url when using noCache. Defaults to \"_dc\".\n     */\n    cacheString: \"_dc\",\n\n    /**\n     * @cfg {Number} timeout\n     * The number of milliseconds to wait for a response. Defaults to 30000 milliseconds (30 seconds).\n     */\n    timeout : 30000,\n\n    /**\n     * @cfg {Object} api\n     * Specific urls to call on CRUD action methods \"create\", \"read\", \"update\" and \"destroy\". Defaults to:\n     *\n     *     api: {\n     *         create  : undefined,\n     *         read    : undefined,\n     *         update  : undefined,\n     *         destroy : undefined\n     *     }\n     *\n     * The url is built based upon the action being executed [create|read|update|destroy] using the commensurate\n     * {@link #api} property, or if undefined default to the configured\n     * {@link Ext.data.Store}.{@link Ext.data.proxy.Server#url url}.\n     *\n     * For example:\n     *\n     *     api: {\n     *         create  : '/controller/new',\n     *         read    : '/controller/load',\n     *         update  : '/controller/update',\n     *         destroy : '/controller/destroy_action'\n     *     }\n     *\n     * If the specific URL for a given CRUD action is undefined, the CRUD action request will be directed to the\n     * configured {@link Ext.data.proxy.Server#url url}.\n     */\n\n    constructor: function(config) {\n        var me = this;\n\n        config = config || {};\n        /**\n         * @event exception\n         * Fires when the server returns an exception\n         * @param {Ext.data.proxy.Proxy} this\n         * @param {Object} response The response from the AJAX request\n         * @param {Ext.data.Operation} operation The operation that triggered request\n         */\n        me.callParent([config]);\n\n        /**\n         * @cfg {Object} extraParams\n         * Extra parameters that will be included on every request. Individual requests with params of the same name\n         * will override these params when they are in conflict.\n         */\n        me.extraParams = config.extraParams || {};\n\n        me.api = Ext.apply({}, config.api || me.api);\n        \n\n        //backwards compatibility, will be deprecated in 5.0\n        me.nocache = me.noCache;\n    },\n\n    //in a ServerProxy all four CRUD operations are executed in the same manner, so we delegate to doRequest in each case\n    create: function() {\n        return this.doRequest.apply(this, arguments);\n    },\n\n    read: function() {\n        return this.doRequest.apply(this, arguments);\n    },\n\n    update: function() {\n        return this.doRequest.apply(this, arguments);\n    },\n\n    destroy: function() {\n        return this.doRequest.apply(this, arguments);\n    },\n\n    /**\n     * Sets a value in the underlying {@link #extraParams}.\n     * @param {String} name The key for the new value\n     * @param {Object} value The value\n     */\n    setExtraParam: function(name, value) {\n        this.extraParams[name] = value;\n    },\n\n    /**\n     * Creates an {@link Ext.data.Request Request} object from {@link Ext.data.Operation Operation}.\n     *\n     * This gets called from doRequest methods in subclasses of Server proxy.\n     * \n     * @param {Ext.data.Operation} operation The operation to execute\n     * @return {Ext.data.Request} The request object\n     */\n    buildRequest: function(operation) {\n        var me = this,\n            params = Ext.applyIf(operation.params || {}, me.extraParams || {}),\n            request;\n\n        //copy any sorters, filters etc into the params so they can be sent over the wire\n        params = Ext.applyIf(params, me.getParams(operation));\n\n        if (operation.id !== undefined && params.id === undefined) {\n            params.id = operation.id;\n        }\n\n        request = new Ext.data.Request({\n            params   : params,\n            action   : operation.action,\n            records  : operation.records,\n            operation: operation,\n            url      : operation.url,\n\n            // this is needed by JsonSimlet in order to properly construct responses for\n            // requests from this proxy\n            proxy: me\n        });\n\n        request.url = me.buildUrl(request);\n\n        /*\n         * Save the request on the Operation. Operations don't usually care about Request and Response data, but in the\n         * ServerProxy and any of its subclasses we add both request and response as they may be useful for further processing\n         */\n        operation.request = request;\n\n        return request;\n    },\n\n    // Should this be documented as protected method?\n    processResponse: function(success, operation, request, response, callback, scope) {\n        var me = this,\n            reader,\n            result;\n\n        if (success === true) {\n            reader = me.getReader();\n\n            // Apply defaults to incoming data only for read operations.\n            // For create and update, there will already be a client-side record\n            // to match with which will contain any defaulted in values.\n            reader.applyDefaults = operation.action === 'read';\n\n            result = reader.read(me.extractResponseData(response));\n\n            if (result.success !== false) {\n                //see comment in buildRequest for why we include the response object here\n                Ext.apply(operation, {\n                    response: response,\n                    resultSet: result\n                });\n\n                operation.commitRecords(result.records);\n                operation.setCompleted();\n                operation.setSuccessful();\n            } else {\n                operation.setException(result.message);\n                me.fireEvent('exception', this, response, operation);\n            }\n        } else {\n            me.setException(operation, response);\n            me.fireEvent('exception', this, response, operation);\n        }\n\n        //this callback is the one that was passed to the 'read' or 'write' function above\n        if (typeof callback == 'function') {\n            callback.call(scope || me, operation);\n        }\n\n        me.afterRequest(request, success);\n    },\n\n    /**\n     * Sets up an exception on the operation\n     * @private\n     * @param {Ext.data.Operation} operation The operation\n     * @param {Object} response The response\n     */\n    setException: function(operation, response) {\n        operation.setException({\n            status: response.status,\n            statusText: response.statusText\n        });\n    },\n\n    /**\n     * Template method to allow subclasses to specify how to get the response for the reader.\n     * @template\n     * @private\n     * @param {Object} response The server response\n     * @return {Object} The response data to be used by the reader\n     */\n    extractResponseData: function(response) {\n        return response;\n    },\n\n    /**\n     * Encode any values being sent to the server. Can be overridden in subclasses.\n     * @private\n     * @param {Array} An array of sorters/filters.\n     * @return {Object} The encoded value\n     */\n    applyEncoding: function(value) {\n        return Ext.encode(value);\n    },\n\n    /**\n     * Encodes the array of {@link Ext.util.Sorter} objects into a string to be sent in the request url. By default,\n     * this simply JSON-encodes the sorter data\n     * @param {Ext.util.Sorter[]} sorters The array of {@link Ext.util.Sorter Sorter} objects\n     * @return {String} The encoded sorters\n     */\n    encodeSorters: function(sorters) {\n        var min = [],\n            length = sorters.length,\n            i = 0;\n\n        for (; i < length; i++) {\n            min[i] = {\n                property : sorters[i].property,\n                direction: sorters[i].direction\n            };\n        }\n        return this.applyEncoding(min);\n\n    },\n\n    /**\n     * Encodes the array of {@link Ext.util.Filter} objects into a string to be sent in the request url. By default,\n     * this simply JSON-encodes the filter data\n     * @param {Ext.util.Filter[]} filters The array of {@link Ext.util.Filter Filter} objects\n     * @return {String} The encoded filters\n     */\n    encodeFilters: function(filters) {\n        var min = [],\n            length = filters.length,\n            i = 0;\n\n        for (; i < length; i++) {\n            min[i] = {\n                property: filters[i].property,\n                value   : filters[i].value\n            };\n        }\n        return this.applyEncoding(min);\n    },\n\n    /**\n     * @private\n     * Copy any sorters, filters etc into the params so they can be sent over the wire\n     */\n    getParams: function(operation) {\n        var me = this,\n            params = {},\n            isDef = Ext.isDefined,\n            groupers = operation.groupers,\n            sorters = operation.sorters,\n            filters = operation.filters,\n            page = operation.page,\n            start = operation.start,\n            limit = operation.limit,\n            simpleSortMode = me.simpleSortMode,\n            simpleGroupMode = me.simpleGroupMode,\n            pageParam = me.pageParam,\n            startParam = me.startParam,\n            limitParam = me.limitParam,\n            groupParam = me.groupParam,\n            groupDirectionParam = me.groupDirectionParam,\n            sortParam = me.sortParam,\n            filterParam = me.filterParam,\n            directionParam = me.directionParam;\n\n        if (pageParam && isDef(page)) {\n            params[pageParam] = page;\n        }\n\n        if (startParam && isDef(start)) {\n            params[startParam] = start;\n        }\n\n        if (limitParam && isDef(limit)) {\n            params[limitParam] = limit;\n        }\n\n        if (groupParam && groupers && groupers.length > 0) {\n            // Grouper is a subclass of sorter, so we can just use the sorter method\n            if (simpleGroupMode) {\n                params[groupParam] = groupers[0].property;\n                params[groupDirectionParam] = groupers[0].direction || 'ASC';\n            } else {\n                params[groupParam] = me.encodeSorters(groupers);\n            }\n        }\n\n        if (sortParam && sorters && sorters.length > 0) {\n            if (simpleSortMode) {\n                params[sortParam] = sorters[0].property;\n                params[directionParam] = sorters[0].direction;\n            } else {\n                params[sortParam] = me.encodeSorters(sorters);\n            }\n\n        }\n\n        if (filterParam && filters && filters.length > 0) {\n            params[filterParam] = me.encodeFilters(filters);\n        }\n\n        return params;\n    },\n\n    /**\n     * Generates a url based on a given Ext.data.Request object. By default, ServerProxy's buildUrl will add the\n     * cache-buster param to the end of the url. Subclasses may need to perform additional modifications to the url.\n     * @param {Ext.data.Request} request The request object\n     * @return {String} The url\n     */\n    buildUrl: function(request) {\n        var me = this,\n            url = me.getUrl(request);\n\n        if (!url) {\n            Ext.Error.raise(\"You are using a ServerProxy but have not supplied it with a url.\");\n        }\n\n        if (me.noCache) {\n            url = Ext.urlAppend(url, Ext.String.format(\"{0}={1}\", me.cacheString, Ext.Date.now()));\n        }\n\n        return url;\n    },\n\n    /**\n     * Get the url for the request taking into account the order of priority,\n     * - The request\n     * - The api\n     * - The url\n     * @private\n     * @param {Ext.data.Request} request The request\n     * @return {String} The url\n     */\n    getUrl: function(request) {\n        return request.url || this.api[request.action] || this.url;\n    },\n\n    /**\n     * In ServerProxy subclasses, the {@link #create}, {@link #read}, {@link #update} and {@link #destroy} methods all\n     * pass through to doRequest. Each ServerProxy subclass must implement the doRequest method - see {@link\n     * Ext.data.proxy.JsonP} and {@link Ext.data.proxy.Ajax} for examples. This method carries the same signature as\n     * each of the methods that delegate to it.\n     *\n     * @param {Ext.data.Operation} operation The Ext.data.Operation object\n     * @param {Function} callback The callback function to call when the Operation has completed\n     * @param {Object} scope The scope in which to execute the callback\n     */\n    doRequest: function(operation, callback, scope) {\n        Ext.Error.raise(\"The doRequest function has not been implemented on your Ext.data.proxy.Server subclass. See src/data/ServerProxy.js for details\");\n    },\n\n    /**\n     * Optional callback function which can be used to clean up after a request has been completed.\n     * @param {Ext.data.Request} request The Request object\n     * @param {Boolean} success True if the request was successful\n     * @protected\n     * @template\n     * @method\n     */\n    afterRequest: Ext.emptyFn,\n\n    onDestroy: function() {\n        Ext.destroy(this.reader, this.writer);\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * AjaxProxy is one of the most widely-used ways of getting data into your application. It uses AJAX requests to load\n * data from the server, usually to be placed into a {@link Ext.data.Store Store}. Let's take a look at a typical setup.\n * Here we're going to set up a Store that has an AjaxProxy. To prepare, we'll also set up a {@link Ext.data.Model\n * Model}:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'name', 'email']\n *     });\n *\n *     //The Store contains the AjaxProxy as an inline configuration\n *     var store = Ext.create('Ext.data.Store', {\n *         model: 'User',\n *         proxy: {\n *             type: 'ajax',\n *             url : 'users.json'\n *         }\n *     });\n *\n *     store.load();\n *\n * Our example is going to load user data into a Store, so we start off by defining a {@link Ext.data.Model Model} with\n * the fields that we expect the server to return. Next we set up the Store itself, along with a\n * {@link Ext.data.Store#proxy proxy} configuration. This configuration was automatically turned into an\n * Ext.data.proxy.Ajax instance, with the url we specified being passed into AjaxProxy's constructor.\n * It's as if we'd done this:\n *\n *     new Ext.data.proxy.Ajax({\n *         url: 'users.json',\n *         model: 'User',\n *         reader: 'json'\n *     });\n *\n * A couple of extra configurations appeared here - {@link #model} and {@link #reader}. These are set by default when we\n * create the proxy via the Store - the Store already knows about the Model, and Proxy's default {@link\n * Ext.data.reader.Reader Reader} is {@link Ext.data.reader.Json JsonReader}.\n *\n * Now when we call store.load(), the AjaxProxy springs into action, making a request to the url we configured\n * ('users.json' in this case). As we're performing a read, it sends a GET request to that url (see\n * {@link #actionMethods} to customize this - by default any kind of read will be sent as a GET request and any kind of write\n * will be sent as a POST request).\n *\n * # Limitations\n *\n * AjaxProxy cannot be used to retrieve data from other domains. If your application is running on http://domainA.com it\n * cannot load data from http://domainB.com because browsers have a built-in security policy that prohibits domains\n * talking to each other via AJAX.\n *\n * If you need to read data from another domain and can't set up a proxy server (some software that runs on your own\n * domain's web server and transparently forwards requests to http://domainB.com, making it look like they actually came\n * from http://domainA.com), you can use {@link Ext.data.proxy.JsonP} and a technique known as JSON-P (JSON with\n * Padding), which can help you get around the problem so long as the server on http://domainB.com is set up to support\n * JSON-P responses. See {@link Ext.data.proxy.JsonP JsonPProxy}'s introduction docs for more details.\n *\n * # Readers and Writers\n *\n * AjaxProxy can be configured to use any type of {@link Ext.data.reader.Reader Reader} to decode the server's response.\n * If no Reader is supplied, AjaxProxy will default to using a {@link Ext.data.reader.Json JsonReader}. Reader\n * configuration can be passed in as a simple object, which the Proxy automatically turns into a {@link\n * Ext.data.reader.Reader Reader} instance:\n *\n *     var proxy = new Ext.data.proxy.Ajax({\n *         model: 'User',\n *         reader: {\n *             type: 'xml',\n *             root: 'users'\n *         }\n *     });\n *\n *     proxy.getReader(); //returns an {@link Ext.data.reader.Xml XmlReader} instance based on the config we supplied\n *\n * # Url generation\n *\n * AjaxProxy automatically inserts any sorting, filtering, paging and grouping options into the url it generates for\n * each request. These are controlled with the following configuration options:\n *\n * - {@link #pageParam} - controls how the page number is sent to the server (see also {@link #startParam} and {@link #limitParam})\n * - {@link #sortParam} - controls how sort information is sent to the server\n * - {@link #groupParam} - controls how grouping information is sent to the server\n * - {@link #filterParam} - controls how filter information is sent to the server\n *\n * Each request sent by AjaxProxy is described by an {@link Ext.data.Operation Operation}. To see how we can customize\n * the generated urls, let's say we're loading the Proxy with the following Operation:\n *\n *     var operation = new Ext.data.Operation({\n *         action: 'read',\n *         page  : 2\n *     });\n *\n * Now we'll issue the request for this Operation by calling {@link #read}:\n *\n *     var proxy = new Ext.data.proxy.Ajax({\n *         url: '/users'\n *     });\n *\n *     proxy.read(operation); //GET /users?page=2\n *\n * Easy enough - the Proxy just copied the page property from the Operation. We can customize how this page data is sent\n * to the server:\n *\n *     var proxy = new Ext.data.proxy.Ajax({\n *         url: '/users',\n *         pageParam: 'pageNumber'\n *     });\n *\n *     proxy.read(operation); //GET /users?pageNumber=2\n *\n * Alternatively, our Operation could have been configured to send start and limit parameters instead of page:\n *\n *     var operation = new Ext.data.Operation({\n *         action: 'read',\n *         start : 50,\n *         limit : 25\n *     });\n *\n *     var proxy = new Ext.data.proxy.Ajax({\n *         url: '/users'\n *     });\n *\n *     proxy.read(operation); //GET /users?start=50&limit;=25\n *\n * Again we can customize this url:\n *\n *     var proxy = new Ext.data.proxy.Ajax({\n *         url: '/users',\n *         startParam: 'startIndex',\n *         limitParam: 'limitIndex'\n *     });\n *\n *     proxy.read(operation); //GET /users?startIndex=50&limitIndex;=25\n *\n * AjaxProxy will also send sort and filter information to the server. Let's take a look at how this looks with a more\n * expressive Operation object:\n *\n *     var operation = new Ext.data.Operation({\n *         action: 'read',\n *         sorters: [\n *             new Ext.util.Sorter({\n *                 property : 'name',\n *                 direction: 'ASC'\n *             }),\n *             new Ext.util.Sorter({\n *                 property : 'age',\n *                 direction: 'DESC'\n *             })\n *         ],\n *         filters: [\n *             new Ext.util.Filter({\n *                 property: 'eyeColor',\n *                 value   : 'brown'\n *             })\n *         ]\n *     });\n *\n * This is the type of object that is generated internally when loading a {@link Ext.data.Store Store} with sorters and\n * filters defined. By default the AjaxProxy will JSON encode the sorters and filters, resulting in something like this\n * (note that the url is escaped before sending the request, but is left unescaped here for clarity):\n *\n *     var proxy = new Ext.data.proxy.Ajax({\n *         url: '/users'\n *     });\n *\n *     proxy.read(operation); //GET /users?sort=[{\"property\":\"name\",\"direction\":\"ASC\"},{\"property\":\"age\",\"direction\":\"DESC\"}]&filter;=[{\"property\":\"eyeColor\",\"value\":\"brown\"}]\n *\n * We can again customize how this is created by supplying a few configuration options. Let's say our server is set up\n * to receive sorting information is a format like \"sortBy=name#ASC,age#DESC\". We can configure AjaxProxy to provide\n * that format like this:\n *\n *      var proxy = new Ext.data.proxy.Ajax({\n *          url: '/users',\n *          sortParam: 'sortBy',\n *          filterParam: 'filterBy',\n *\n *          //our custom implementation of sorter encoding - turns our sorters into \"name#ASC,age#DESC\"\n *          encodeSorters: function(sorters) {\n *              var length   = sorters.length,\n *                  sortStrs = [],\n *                  sorter, i;\n *\n *              for (i = 0; i < length; i++) {\n *                  sorter = sorters[i];\n *\n *                  sortStrs[i] = sorter.property + '#' + sorter.direction\n *              }\n *\n *              return sortStrs.join(\",\");\n *          }\n *      });\n *\n *      proxy.read(operation); //GET /users?sortBy=name#ASC,age#DESC&filterBy;=[{\"property\":\"eyeColor\",\"value\":\"brown\"}]\n *\n * We can also provide a custom {@link #encodeFilters} function to encode our filters.\n *\n * @constructor\n * Note that if this HttpProxy is being used by a {@link Ext.data.Store Store}, then the Store's call to\n * {@link Ext.data.Store#method-load load} will override any specified callback and params options. In this case, use the\n * {@link Ext.data.Store Store}'s events to modify parameters, or react to loading events.\n *\n * @param {Object} config (optional) Config object.\n * If an options parameter is passed, the singleton {@link Ext.Ajax} object will be used to make the request.\n */\nExt.define('Ext.data.proxy.Ajax', {\n    requires: ['Ext.util.MixedCollection', 'Ext.Ajax'],\n    extend: 'Ext.data.proxy.Server',\n    alias: 'proxy.ajax',\n    alternateClassName: ['Ext.data.HttpProxy', 'Ext.data.AjaxProxy'],\n    \n    /**\n     * @property {Object} actionMethods\n     * Mapping of action name to HTTP request method. In the basic AjaxProxy these are set to 'GET' for 'read' actions\n     * and 'POST' for 'create', 'update' and 'destroy' actions. The {@link Ext.data.proxy.Rest} maps these to the\n     * correct RESTful methods.\n     */\n    actionMethods: {\n        create : 'POST',\n        read   : 'GET',\n        update : 'POST',\n        destroy: 'POST'\n    },\n    \n    /**\n     * @cfg {Object} headers\n     * Any headers to add to the Ajax request. Defaults to undefined.\n     */\n    \n    doRequest: function(operation, callback, scope) {\n        var writer  = this.getWriter(),\n            request = this.buildRequest(operation, callback, scope);\n            \n        if (operation.allowWrite()) {\n            request = writer.write(request);\n        }\n        \n        Ext.apply(request, {\n            headers       : this.headers,\n            timeout       : this.timeout,\n            scope         : this,\n            callback      : this.createRequestCallback(request, operation, callback, scope),\n            method        : this.getMethod(request),\n            disableCaching: false // explicitly set it to false, ServerProxy handles caching\n        });\n        \n        Ext.Ajax.request(request);\n        \n        return request;\n    },\n    \n    /**\n     * Returns the HTTP method name for a given request. By default this returns based on a lookup on\n     * {@link #actionMethods}.\n     * @param {Ext.data.Request} request The request object\n     * @return {String} The HTTP method to use (should be one of 'GET', 'POST', 'PUT' or 'DELETE')\n     */\n    getMethod: function(request) {\n        return this.actionMethods[request.action];\n    },\n    \n    /**\n     * @private\n     * TODO: This is currently identical to the JsonPProxy version except for the return function's signature. There is a lot\n     * of code duplication inside the returned function so we need to find a way to DRY this up.\n     * @param {Ext.data.Request} request The Request object\n     * @param {Ext.data.Operation} operation The Operation being executed\n     * @param {Function} callback The callback function to be called when the request completes. This is usually the callback\n     * passed to doRequest\n     * @param {Object} scope The scope in which to execute the callback function\n     * @return {Function} The callback function\n     */\n    createRequestCallback: function(request, operation, callback, scope) {\n        var me = this;\n        \n        return function(options, success, response) {\n            me.processResponse(success, operation, request, response, callback, scope);\n        };\n    }\n}, function() {\n    //backwards compatibility, remove in Ext JS 5.0\n    Ext.data.HttpProxy = this;\n});\n\n/**\n * @author Ed Spencer\n *\n * Base class for any client-side storage. Used as a superclass for {@link Ext.data.proxy.Memory Memory} and\n * {@link Ext.data.proxy.WebStorage Web Storage} proxies. Do not use directly, use one of the subclasses instead.\n * @private\n */\nExt.define('Ext.data.proxy.Client', {\n    extend: 'Ext.data.proxy.Proxy',\n    alternateClassName: 'Ext.data.ClientProxy',\n    \n    /**\n     * @property {Boolean} isSynchronous\n     * `true` in this class to identify that requests made on this proxy are\n     * performed synchronously\n     */\n    isSynchronous: true,\n\n    /**\n     * Abstract function that must be implemented by each ClientProxy subclass. This should purge all record data\n     * from the client side storage, as well as removing any supporting data (such as lists of record IDs)\n     */\n    clear: function() {\n        Ext.Error.raise(\"The Ext.data.proxy.Client subclass that you are using has not defined a 'clear' function. See src/data/ClientProxy.js for details.\");\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * In-memory proxy. This proxy simply uses a local variable for data storage/retrieval, so its contents are lost on\n * every page refresh.\n *\n * Usually this Proxy isn't used directly, serving instead as a helper to a {@link Ext.data.Store Store} where a reader\n * is required to load data. For example, say we have a Store for a User model and have some inline data we want to\n * load, but this data isn't in quite the right format: we can use a MemoryProxy with a JsonReader to read it into our\n * Store:\n *\n *     //this is the model we will be using in the store\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             {name: 'id',    type: 'int'},\n *             {name: 'name',  type: 'string'},\n *             {name: 'phone', type: 'string', mapping: 'phoneNumber'}\n *         ]\n *     });\n *\n *     //this data does not line up to our model fields - the phone field is called phoneNumber\n *     var data = {\n *         users: [\n *             {\n *                 id: 1,\n *                 name: 'Ed Spencer',\n *                 phoneNumber: '555 1234'\n *             },\n *             {\n *                 id: 2,\n *                 name: 'Abe Elias',\n *                 phoneNumber: '666 1234'\n *             }\n *         ]\n *     };\n *\n *     //note how we set the 'root' in the reader to match the data structure above\n *     var store = Ext.create('Ext.data.Store', {\n *         autoLoad: true,\n *         model: 'User',\n *         data : data,\n *         proxy: {\n *             type: 'memory',\n *             reader: {\n *                 type: 'json',\n *                 root: 'users'\n *             }\n *         }\n *     });\n */\nExt.define('Ext.data.proxy.Memory', {\n    extend: 'Ext.data.proxy.Client',\n    alias: 'proxy.memory',\n    alternateClassName: 'Ext.data.MemoryProxy',\n\n    /**\n     * @cfg {Object} data\n     * Optional data to pass to configured Reader.\n     */\n\n    constructor: function(config) {\n        this.callParent([config]);\n\n        //ensures that the reader has been instantiated properly\n        this.setReader(this.reader);\n    },\n    \n    /**\n     * @private\n     * Fake processing function to commit the records, set the current operation\n     * to successful and call the callback if provided. This function is shared\n     * by the create, update and destroy methods to perform the bare minimum\n     * processing required for the proxy to register a result from the action.\n     */\n    updateOperation: function(operation, callback, scope) {\n        var i = 0,\n            recs = operation.getRecords(),\n            len = recs.length;\n            \n        for (i; i < len; i++) {\n            recs[i].commit();\n        }\n        operation.setCompleted();\n        operation.setSuccessful();\n        \n        Ext.callback(callback, scope || this, [operation]);\n    },\n    \n    /**\n     * Currently this is a hard-coded method that simply commits any records and sets the operation to successful,\n     * then calls the callback function, if provided. It is essentially mocking a server call in memory, but since\n     * there is no real back end in this case there's not much else to do. This method can be easily overridden to \n     * implement more complex logic if needed.\n     * @param {Ext.data.Operation} operation The Operation to perform\n     * @param {Function} callback Callback function to be called when the Operation has completed (whether\n     * successful or not)\n     * @param {Object} scope Scope to execute the callback function in\n     * @method\n     */\n    create: function() {\n        this.updateOperation.apply(this, arguments);\n    },\n    \n    /**\n     * Currently this is a hard-coded method that simply commits any records and sets the operation to successful,\n     * then calls the callback function, if provided. It is essentially mocking a server call in memory, but since\n     * there is no real back end in this case there's not much else to do. This method can be easily overridden to \n     * implement more complex logic if needed.\n     * @param {Ext.data.Operation} operation The Operation to perform\n     * @param {Function} callback Callback function to be called when the Operation has completed (whether\n     * successful or not)\n     * @param {Object} scope Scope to execute the callback function in\n     * @method\n     */\n    update: function() {\n        this.updateOperation.apply(this, arguments);\n    },\n    \n    /**\n     * Currently this is a hard-coded method that simply commits any records and sets the operation to successful,\n     * then calls the callback function, if provided. It is essentially mocking a server call in memory, but since\n     * there is no real back end in this case there's not much else to do. This method can be easily overridden to \n     * implement more complex logic if needed.\n     * @param {Ext.data.Operation} operation The Operation to perform\n     * @param {Function} callback Callback function to be called when the Operation has completed (whether\n     * successful or not)\n     * @param {Object} scope Scope to execute the callback function in\n     * @method\n     */\n    destroy: function() {\n        this.updateOperation.apply(this, arguments);\n    },\n\n    /**\n     * Reads data from the configured {@link #data} object. Uses the Proxy's {@link #reader}, if present.\n     * @param {Ext.data.Operation} operation The read Operation\n     * @param {Function} callback The callback to call when reading has completed\n     * @param {Object} scope The scope to call the callback function in\n     */\n    read: function(operation, callback, scope) {\n        var me = this;\n\n        operation.resultSet = me.getReader().read(me.data);\n\n        operation.setCompleted();\n        operation.setSuccessful();\n        Ext.callback(callback, scope || me, [operation]);\n    },\n\n    clear: Ext.emptyFn\n});\n\n/**\n * @private\n * @class Ext.util.LruCache\n * @extend Ext.util.HashMap\n * A linked {@link Ext.util.HashMap HashMap} implementation which maintains most recently accessed\n * items at the end of the list, and purges the cache down to the most recently accessed {@link #maxSize} items\n * upon add.\n */\nExt.define('Ext.util.LruCache', {\n    extend: 'Ext.util.HashMap',\n\n    /**\n     * @cfg {Number} maxSize The maximum size the cache is allowed to grow to before further additions cause\n     * removal of the least recently used entry.\n     */\n\n    constructor: function(config) {\n        Ext.apply(this, config);\n        this.callParent([config]);\n    },\n\n    /*\n     * @inheritdoc\n     */\n    add: function(key, newValue) {\n        var me = this,\n            existingKey = me.findKey(newValue),\n            entry;\n\n        // \"new\" value is in the list.\n        if (existingKey) {\n            me.unlinkEntry(entry = me.map[existingKey]);\n            entry.prev = me.last;\n            entry.next = null;\n        }\n        // Genuinely new: create an entry for it.\n        else {\n            entry = {\n                prev: me.last,\n                next: null,\n                key: key,\n                value: newValue\n            };\n        }\n\n        // If the list is not empty, update the last entry\n        if (me.last) {\n            me.last.next = entry;\n        }\n        // List is empty\n        else {\n            me.first = entry;\n        }\n        me.last = entry;\n        me.callParent([key, entry]);\n        me.prune();\n        return newValue;\n    },\n\n    // @private\n    insertBefore: function(key, newValue, sibling) {\n        var me = this,\n            existingKey,\n            entry;\n\n        // NOT an assignment.\n        // If there is a following sibling\n        if (sibling = this.map[this.findKey(sibling)]) {\n            existingKey = me.findKey(newValue);\n\n            // \"new\" value is in the list.\n            if (existingKey) {\n                me.unlinkEntry(entry = me.map[existingKey]);\n            }\n            // Genuinely new: create an entry for it.\n            else {\n                entry = {\n                    prev: sibling.prev,\n                    next: sibling,\n                    key: key,\n                    value: newValue\n                };\n            }\n\n            if (sibling.prev) {\n                entry.prev.next = entry;\n            } else {\n                me.first = entry;\n            }\n            entry.next = sibling;\n            sibling.prev = entry;\n            me.prune();\n            return newValue;\n        }\n        // No following sibling, it's just an add.\n        else {\n            return me.add(key, newValue);\n        }\n    },\n\n    /*\n     * @inheritdoc\n     */\n    get: function(key) {\n        var entry = this.map[key];\n        if (entry) {\n\n            // If it's not the end, move to end of list on get\n            if (entry.next) {\n                this.moveToEnd(entry);\n            }\n            return entry.value;\n        }\n    },\n\n    /*\n     * @private\n     */\n    removeAtKey: function(key) {\n        this.unlinkEntry(this.map[key]);\n        return this.callParent(arguments);\n    },\n\n    /*\n     * @inheritdoc\n     */\n    clear: function(/* private */ initial) {\n        this.first = this.last = null;\n        return this.callParent(arguments);\n    },\n\n    // private. Only used by internal methods.\n    unlinkEntry: function(entry) {\n        // Stitch the list back up.\n        if (entry) {\n            if (entry.next) {\n                entry.next.prev = entry.prev;\n            } else {\n                this.last = entry.prev;\n            }\n            if (entry.prev) {\n                entry.prev.next = entry.next;\n            } else {\n                this.first = entry.next;\n            }\n            entry.prev = entry.next = null;\n        }\n    },\n\n    // private. Only used by internal methods.\n    moveToEnd: function(entry) {\n        this.unlinkEntry(entry);\n\n        // NOT an assignment.\n        // If the list is not empty, update the last entry\n        if (entry.prev = this.last) {\n            this.last.next = entry;\n        }\n        // List is empty\n        else {\n            this.first = entry;\n        }\n        this.last = entry;\n    },\n\n    /*\n     * @private\n     */\n    getArray: function(isKey) {\n        var arr = [],\n            entry = this.first;\n\n        while (entry) {\n            arr.push(isKey ? entry.key: entry.value);\n            entry = entry.next;\n        }\n        return arr;\n    },\n\n    /**\n     * Executes the specified function once for each item in the cache.\n     * Returning false from the function will cease iteration.\n     *\n     * By default, iteration is from least recently used to most recent.\n     *\n     * The paramaters passed to the function are:\n     * <div class=\"mdetail-params\"><ul>\n     * <li><b>key</b> : String<p class=\"sub-desc\">The key of the item</p></li>\n     * <li><b>value</b> : Number<p class=\"sub-desc\">The value of the item</p></li>\n     * <li><b>length</b> : Number<p class=\"sub-desc\">The total number of items in the hash</p></li>\n     * </ul></div>\n     * @param {Function} fn The function to execute.\n     * @param {Object} scope The scope (<code>this</code> reference) to execute in. Defaults to this LruCache.\n     * @param {Boolean} [reverse=false] Pass <code>true</code> to iterate the list in reverse (most recent first) order.\n     * @return {Ext.util.LruCache} this\n     */\n    each: function(fn, scope, reverse) {\n        var me = this,\n            entry = reverse ? me.last : me.first,\n            length = me.length;\n\n        scope = scope || me;\n        while (entry) {\n            if (fn.call(scope, entry.key, entry.value, length) === false) {\n                break;\n            }\n            entry = reverse ? entry.prev : entry.next;\n        }\n        return me;\n    },\n\n    /**\n     * @private\n     */\n    findKey: function(value) {\n        var key,\n            map = this.map;\n\n        for (key in map) {\n            if (map.hasOwnProperty(key) && map[key].value === value) {\n                return key;\n            }\n        }\n        return undefined;\n    },\n\n    /**\n     * Purge the least recently used entries if the maxSize has been exceeded.\n     */\n    prune: function() {\n        var me = this,\n            purgeCount = me.maxSize ? (me.length - me.maxSize) : 0;\n\n        if (purgeCount > 0) {\n            for (; me.first && purgeCount; purgeCount--) {\n                me.removeAtKey(me.first.key);\n            }\n        }\n    }\n\n  /**\n   * @method containsKey\n   * @private\n   */\n  /**\n   * @method contains\n   * @private\n   */\n  /**\n   * @method getKeys\n   * @private\n   */\n  /**\n   * @method getValues\n   * @private\n   */\n});\n\n/**\n * The Store class encapsulates a client side cache of {@link Ext.data.Model Model} objects. Stores load data via a\n * {@link Ext.data.proxy.Proxy Proxy}, and also provide functions for {@link #sort sorting}, {@link #filter filtering}\n * and querying the {@link Ext.data.Model model} instances contained within it.\n *\n * Creating a Store is easy - we just tell it the Model and the Proxy to use to load and save its data:\n *\n *      // Set up a {@link Ext.data.Model model} to use in our Store\n *      Ext.define('User', {\n *          extend: 'Ext.data.Model',\n *          fields: [\n *              {name: 'firstName', type: 'string'},\n *              {name: 'lastName',  type: 'string'},\n *              {name: 'age',       type: 'int'},\n *              {name: 'eyeColor',  type: 'string'}\n *          ]\n *      });\n *\n *      var myStore = Ext.create('Ext.data.Store', {\n *          model: 'User',\n *          proxy: {\n *              type: 'ajax',\n *              url: '/users.json',\n *              reader: {\n *                  type: 'json',\n *                  root: 'users'\n *              }\n *          },\n *          autoLoad: true\n *      });\n *\n * In the example above we configured an AJAX proxy to load data from the url '/users.json'. We told our Proxy to use a\n * {@link Ext.data.reader.Json JsonReader} to parse the response from the server into Model object - {@link\n * Ext.data.reader.Json see the docs on JsonReader} for details.\n *\n * ## Inline data\n *\n * Stores can also load data inline. Internally, Store converts each of the objects we pass in as {@link #cfg-data} into\n * Model instances:\n *\n *      Ext.create('Ext.data.Store', {\n *          model: 'User',\n *          data : [\n *              {firstName: 'Ed',    lastName: 'Spencer'},\n *              {firstName: 'Tommy', lastName: 'Maintz'},\n *              {firstName: 'Aaron', lastName: 'Conran'},\n *              {firstName: 'Jamie', lastName: 'Avins'}\n *          ]\n *      });\n *\n * Loading inline data using the method above is great if the data is in the correct format already (e.g. it doesn't\n * need to be processed by a {@link Ext.data.reader.Reader reader}). If your inline data requires processing to decode\n * the data structure, use a {@link Ext.data.proxy.Memory MemoryProxy} instead (see the {@link Ext.data.proxy.Memory\n * MemoryProxy} docs for an example).\n *\n * Additional data can also be loaded locally using {@link #method-add}.\n * \n * ## Dynamic Loading\n *\n * Stores can be dynamically updated by calling the {@link #method-load} method:\n *\n *     store.load({\n *         params: {\n *             group: 3,\n *             type: 'user'\n *         },\n *         callback: function(records, operation, success) {\n *             // do something after the load finishes\n *         },\n *         scope: this\n *     });\n *\n * Here a bunch of arbitrary parameters is passed along with the load request and a callback function is set\n * up to do something after the loading is over.\n *\n * ## Loading Nested Data\n *\n * Applications often need to load sets of associated data - for example a CRM system might load a User and her Orders.\n * Instead of issuing an AJAX request for the User and a series of additional AJAX requests for each Order, we can load\n * a nested dataset and allow the Reader to automatically populate the associated models. Below is a brief example, see\n * the {@link Ext.data.reader.Reader} intro docs for a full explanation:\n *\n *      var store = Ext.create('Ext.data.Store', {\n *          autoLoad: true,\n *          model: \"User\",\n *          proxy: {\n *              type: 'ajax',\n *              url: 'users.json',\n *              reader: {\n *                  type: 'json',\n *                  root: 'users'\n *              }\n *          }\n *      });\n *\n * Which would consume a response like this:\n *\n *      {\n *          \"users\": [{\n *              \"id\": 1,\n *              \"name\": \"Ed\",\n *              \"orders\": [{\n *                  \"id\": 10,\n *                  \"total\": 10.76,\n *                  \"status\": \"invoiced\"\n *             },{\n *                  \"id\": 11,\n *                  \"total\": 13.45,\n *                  \"status\": \"shipped\"\n *             }]\n *          }]\n *      }\n *\n * See the {@link Ext.data.reader.Reader} intro docs for a full explanation.\n *\n * ## Filtering and Sorting\n *\n * Stores can be sorted and filtered - in both cases either remotely or locally. The {@link #sorters} and\n * {@link #cfg-filters} are held inside {@link Ext.util.MixedCollection MixedCollection} instances to make them easy to manage.\n * Usually it is sufficient to either just specify sorters and filters in the Store configuration or call {@link #sort}\n * or {@link #filter}:\n *\n *      var store = Ext.create('Ext.data.Store', {\n *          model: 'User',\n *          sorters: [{\n *              property: 'age',\n *              direction: 'DESC'\n *          }, {\n *              property: 'firstName',\n *              direction: 'ASC'\n *          }],\n *\n *          filters: [{\n *              property: 'firstName',\n *              value: /Ed/\n *          }]\n *      });\n *\n * The new Store will keep the configured sorters and filters in the MixedCollection instances mentioned above. By\n * default, sorting and filtering are both performed locally by the Store - see {@link #remoteSort} and\n * {@link #remoteFilter} to allow the server to perform these operations instead.\n *\n * Filtering and sorting after the Store has been instantiated is also easy. Calling {@link #filter} adds another filter\n * to the Store and automatically filters the dataset (calling {@link #filter} with no arguments simply re-applies all\n * existing filters). Note that by default {@link #sortOnFilter} is set to true, which means that your sorters are\n * automatically reapplied if using local sorting.\n *\n *      store.filter('eyeColor', 'Brown');\n *\n * Change the sorting at any time by calling {@link #sort}:\n *\n *      store.sort('height', 'ASC');\n *\n * Note that all existing sorters will be removed in favor of the new sorter data (if {@link #sort} is called with no\n * arguments, the existing sorters are just reapplied instead of being removed). To keep existing sorters and add new\n * ones, just add them to the MixedCollection:\n *\n *      store.sorters.add(new Ext.util.Sorter({\n *          property : 'shoeSize',\n *          direction: 'ASC'\n *      }));\n *\n *      store.sort();\n *\n * ## Registering with StoreManager\n *\n * Any Store that is instantiated with a {@link #storeId} will automatically be registed with the {@link\n * Ext.data.StoreManager StoreManager}. This makes it easy to reuse the same store in multiple views:\n *\n *      //this store can be used several times\n *      Ext.create('Ext.data.Store', {\n *          model: 'User',\n *          storeId: 'usersStore'\n *      });\n *\n *      new Ext.List({\n *          store: 'usersStore',\n *          //other config goes here\n *      });\n *\n *      new Ext.view.View({\n *          store: 'usersStore',\n *          //other config goes here\n *      });\n *\n * ## Further Reading\n *\n * Stores are backed up by an ecosystem of classes that enables their operation. To gain a full understanding of these\n * pieces and how they fit together, see:\n *\n *   - {@link Ext.data.proxy.Proxy Proxy} - overview of what Proxies are and how they are used\n *   - {@link Ext.data.Model Model} - the core class in the data package\n *   - {@link Ext.data.reader.Reader Reader} - used by any subclass of {@link Ext.data.proxy.Server ServerProxy} to read a response\n *\n * @author Ed Spencer\n */\nExt.define('Ext.data.Store', {\n    extend: 'Ext.data.AbstractStore',\n\n    alias: 'store.store',\n\n    // Required classes must be loaded before the definition callback runs\n    // The class definition callback creates a dummy Store which requires that\n    // all the classes below have been loaded.\n    requires: [\n        'Ext.data.StoreManager',\n        'Ext.data.Model',\n        'Ext.data.proxy.Ajax',\n        'Ext.data.proxy.Memory',\n        'Ext.data.reader.Json',\n        'Ext.data.writer.Json',\n        'Ext.util.LruCache'\n    ],\n\n    uses: [\n        'Ext.ModelManager',\n        'Ext.util.Grouper'\n    ],\n\n    remoteSort: false,\n    remoteFilter: false,\n\n    /**\n     * @cfg {Boolean} remoteGroup\n     * True if the grouping should apply on the server side, false if it is local only.  If the\n     * grouping is local, it can be applied immediately to the data.  If it is remote, then it will simply act as a\n     * helper, automatically sending the grouping information to the server.\n     */\n    remoteGroup : false,\n\n    /**\n     * @cfg {String/Ext.data.proxy.Proxy/Object} proxy\n     * The Proxy to use for this Store. This can be either a string, a config object or a Proxy instance -\n     * see {@link #setProxy} for details.\n     */\n\n    /**\n     * @cfg {Object[]/Ext.data.Model[]} data\n     * Array of Model instances or data objects to load locally. See \"Inline data\" above for details.\n     */\n\n    /**\n     * @cfg {String} groupField\n     * The field by which to group data in the store. Internally, grouping is very similar to sorting - the\n     * groupField and {@link #groupDir} are injected as the first sorter (see {@link #sort}). Stores support a single\n     * level of grouping, and groups can be fetched via the {@link #getGroups} method.\n     */\n    groupField: undefined,\n\n    /**\n     * @cfg {String} groupDir\n     * The direction in which sorting should be applied when grouping. Supported values are \"ASC\" and \"DESC\".\n     */\n    groupDir: \"ASC\",\n\n    /**\n     * @cfg {Number} trailingBufferZone\n     * When {@link #buffered}, the number of extra records to keep cached on the trailing side of scrolling buffer\n     * as scrolling proceeds. A larger number means fewer replenishments from the server.\n     */\n    trailingBufferZone: 25,\n\n    /**\n     * @cfg {Number} leadingBufferZone\n     * When {@link #buffered}, the number of extra rows to keep cached on the leading side of scrolling buffer\n     * as scrolling proceeds. A larger number means fewer replenishments from the server.\n     */\n    leadingBufferZone: 200,\n\n    /**\n     * @cfg {Number} pageSize\n     * The number of records considered to form a 'page'. This is used to power the built-in\n     * paging using the nextPage and previousPage functions when the grid is paged using a\n     * {@link Ext.toolbar.Paging PagingScroller} Defaults to 25.\n     *\n     * If this Store is {@link #buffered}, pages are loaded into a page cache before the Store's\n     * data is updated from the cache. The pageSize is the number of rows loaded into the cache in one request.\n     * This will not affect the rendering of a buffered grid, but a larger page size will mean fewer loads.\n     *\n     * In a buffered grid, scrolling is monitored, and the page cache is kept primed with data ahead of the\n     * direction of scroll to provide rapid access to data when scrolling causes it to be required. Several pages\n     * in advance may be requested depending on various parameters.\n     *\n     * It is recommended to tune the {@link #pageSize}, {@link #trailingBufferZone} and\n     * {@link #leadingBufferZone} configurations based upon the conditions pertaining in your deployed application.\n     *\n     * The provided SDK example `examples/grid/infinite-scroll-grid-tuner.html` can be used to experiment with\n     * different settings including simulating Ajax latency.\n     */\n    pageSize: undefined,\n\n    /**\n     * @property {Number} currentPage\n     * The page that the Store has most recently loaded (see {@link #loadPage})\n     */\n    currentPage: 1,\n\n    /**\n     * @cfg {Boolean} clearOnPageLoad\n     * True to empty the store when loading another page via {@link #loadPage},\n     * {@link #nextPage} or {@link #previousPage}. Setting to false keeps existing records, allowing\n     * large data sets to be loaded one page at a time but rendered all together.\n     */\n    clearOnPageLoad: true,\n\n    /**\n     * @property {Boolean} loading\n     * True if the Store is currently loading via its Proxy\n     * @private\n     */\n    loading: false,\n\n    /**\n     * @cfg {Boolean} sortOnFilter\n     * For local filtering only, causes {@link #sort} to be called whenever {@link #filter} is called,\n     * causing the sorters to be reapplied after filtering. Defaults to true\n     */\n    sortOnFilter: true,\n\n    /**\n     * @cfg {Boolean} buffered\n     * Allows the Store to prefetch and cache in a **page cache**, pages of Records, and to then satisfy\n     * loading requirements from this page cache.\n     *\n     * To use buffered Stores, initiate the process by loading the first page. The number of rows rendered are\n     * determined automatically, and the range of pages needed to keep the cache primed for scrolling is\n     * requested and cached.\n     * Example:\n     *\n     *    // Load page 1\n     *    myStore.loadPage(1);\n     *\n     * A {@link Ext.grid.PagingScroller PagingScroller} is instantiated which will monitor the scrolling in the grid, and\n     * refresh the view's rows from the page cache as needed. It will also pull new data into the page\n     * cache when scrolling of the view draws upon data near either end of the prefetched data.\n     *\n     * The margins which trigger view refreshing from the prefetched data are {@link Ext.grid.PagingScroller#numFromEdge},\n     * {@link Ext.grid.PagingScroller#leadingBufferZone} and {@link Ext.grid.PagingScroller#trailingBufferZone}.\n     *\n     * The margins which trigger loading more data into the page cache are, {@link #leadingBufferZone} and\n     * {@link #trailingBufferZone}.\n     *\n     * By defult, only 5 pages of data are cached in the page cache, with pages \"scrolling\" out of the buffer\n     * as the view moves down through the dataset.\n     * Setting this value to zero means that no pages are *ever* scrolled out of the page cache, and\n     * that eventually the whole dataset may become present in the page cache. This is sometimes desirable\n     * as long as datasets do not reach astronomical proportions.\n     *\n     * Selection state may be maintained across page boundaries by configuring the SelectionModel not to discard\n     * records from its collection when those Records cycle out of the Store's primary collection. This is done\n     * by configuring the SelectionModel like this:\n     *\n     *    selModel: {\n     *        pruneRemoved: false\n     *    }\n     *\n     */\n    buffered: false,\n\n    /**\n     * @cfg {Number} purgePageCount\n     * *Valid only when used with a {@link Ext.data.Store#buffered buffered} Store.*\n     *\n     * The number of pages *additional to the required buffered range* to keep in the prefetch cache before purging least recently used records.\n     *\n     * For example, if the height of the view area and the configured {@link #trailingBufferZone} and {@link #leadingBufferZone} require that there\n     * are three pages in the cache, then a `purgePageCount` of 5 ensures that up to 8 pages can be in the page cache any any one time.\n     *\n     * A value of 0 indicates to never purge the prefetched data.\n     */\n    purgePageCount: 5,\n\n    /**\n     * @cfg {Boolean} [clearRemovedOnLoad=true]\n     * True to clear anything in the {@link #removed} record collection when the store loads.\n     */\n    clearRemovedOnLoad: true,\n\n    defaultPageSize: 25,\n\n    // Private. Used as parameter to loadRecords\n    addRecordsOptions: {\n        addRecords: true\n    },\n\n    statics: {\n        recordIdFn: function(record) {\n            return record.internalId;\n        },\n        recordIndexFn: function(record) {\n            return record.index;\n        }\n    },\n\n    onClassExtended: function(cls, data, hooks) {\n        var model = data.model,\n            onBeforeClassCreated;\n\n        if (typeof model == 'string') {\n            onBeforeClassCreated = hooks.onBeforeCreated;\n\n            hooks.onBeforeCreated = function() {\n                var me = this,\n                    args = arguments;\n\n                Ext.require(model, function() {\n                    onBeforeClassCreated.apply(me, args);\n                });\n            };\n        }\n    },\n\n    /**\n     * Creates the store.\n     * @param {Object} [config] Config object\n     */\n    constructor: function(config) {\n        // Clone the config so we don't modify the original config object\n        config = Ext.Object.merge({}, config);\n\n        var me = this,\n            groupers = config.groupers || me.groupers,\n            groupField = config.groupField || me.groupField,\n            proxy,\n            data;\n\n        /**\n         * @event beforeprefetch\n         * Fires before a prefetch occurs. Return false to cancel.\n         * @param {Ext.data.Store} this\n         * @param {Ext.data.Operation} operation The associated operation\n         */\n        /**\n         * @event groupchange\n         * Fired whenever the grouping in the grid changes\n         * @param {Ext.data.Store} store The store\n         * @param {Ext.util.Grouper[]} groupers The array of grouper objects\n         */\n        /**\n         * @event prefetch\n         * Fires whenever records have been prefetched\n         * @param {Ext.data.Store} this\n         * @param {Ext.data.Model[]} records An array of records.\n         * @param {Boolean} successful True if the operation was successful.\n         * @param {Ext.data.Operation} operation The associated operation\n         */\n        data = config.data || me.data;\n\n        /**\n         * @property {Ext.util.MixedCollection} data\n         * The MixedCollection that holds this store's local cache of records.\n         */\n        me.data = new Ext.util.MixedCollection(false, Ext.data.Store.recordIdFn);\n\n        if (data) {\n            me.inlineData = data;\n            delete config.data;\n        }\n\n        if (!groupers && groupField) {\n            groupers = [{\n                property : groupField,\n                direction: config.groupDir || me.groupDir\n            }];\n        }\n        delete config.groupers;\n\n        /**\n         * @property {Ext.util.MixedCollection} groupers\n         * The collection of {@link Ext.util.Grouper Groupers} currently applied to this Store.\n         */\n        me.groupers = new Ext.util.MixedCollection();\n        me.groupers.addAll(me.decodeGroupers(groupers));\n\n        this.callParent([config]);\n        // don't use *config* anymore from here on... use *me* instead...\n\n        if (me.buffered) {\n\n            /**\n             * @property {Ext.data.Store.PageMap} pageMap\n             * Internal PageMap instance.\n             * @private\n             */\n            me.pageMap = new me.PageMap({\n                pageSize: me.pageSize,\n                maxSize: me.purgePageCount,\n                listeners: {\n                    // Whenever PageMap gets cleared, it means we re no longer interested in \n                    // any outstanding page prefetches, so cancel tham all\n                    clear: me.cancelAllPrefetches,\n                    scope: me\n                }\n            });\n            me.pageRequests = {};\n\n            me.sortOnLoad = false;\n            me.filterOnLoad = false;\n        }\n\n        // Only sort by group fields if we are doing local grouping\n        if (me.remoteGroup) {\n            me.remoteSort = true;\n        }\n        if (me.groupers.items.length && !me.remoteGroup) {\n            me.sort(me.groupers.items, 'prepend', false);\n        }\n\n        proxy = me.proxy;\n        data = me.inlineData;\n\n        // Page size for non-buffered Store defaults to 25\n        // For a buffered Store, the default page size is taken from the initial call to prefetch.\n        if (!me.buffered && !me.pageSize) {\n            me.pageSize = me.defaultPageSize;\n        }\n\n        if (data) {\n            if (proxy instanceof Ext.data.proxy.Memory) {\n                proxy.data = data;\n                me.read();\n            } else {\n                me.add.apply(me, [data]);\n            }\n\n            me.sort();\n            delete me.inlineData;\n        } else if (me.autoLoad) {\n            Ext.defer(me.load, 10, me, [ typeof me.autoLoad === 'object' ? me.autoLoad : undefined ]);\n            // Remove the defer call, we may need reinstate this at some point, but currently it's not obvious why it's here.\n            // this.load(typeof this.autoLoad == 'object' ? this.autoLoad : undefined);\n        }\n    },\n\n     // private override\n     // After destroying the Store, clear the page prefetch cache\n    destroyStore: function() {\n        this.callParent(arguments);\n\n        // Release cached pages.\n        // Will also cancel outstanding prefetch requests, and cause a generation change\n        // so that incoming prefetch data will be ignored.\n        if (this.pageMap) {\n            this.pageMap.clear();\n        }\n    },\n\n    onBeforeSort: function() {\n        var groupers = this.groupers;\n        if (groupers.getCount() > 0) {\n            this.sort(groupers.items, 'prepend', false);\n        }\n    },\n\n    /**\n     * @private\n     * Normalizes an array of grouper objects, ensuring that they are all Ext.util.Grouper instances\n     * @param {Object[]} groupers The groupers array\n     * @return {Ext.util.Grouper[]} Array of Ext.util.Grouper objects\n     */\n    decodeGroupers: function(groupers) {\n        if (!Ext.isArray(groupers)) {\n            if (groupers === undefined) {\n                groupers = [];\n            } else {\n                groupers = [groupers];\n            }\n        }\n\n        var length = groupers.length,\n            Grouper = Ext.util.Grouper,\n            config, i, result = [];\n\n        for (i = 0; i < length; i++) {\n            config = groupers[i];\n\n            if (!(config instanceof Grouper)) {\n                if (Ext.isString(config)) {\n                    config = {\n                        property: config\n                    };\n                }\n\n                config = Ext.apply({\n                    root     : 'data',\n                    direction: \"ASC\"\n                }, config);\n\n                //support for 3.x style sorters where a function can be defined as 'fn'\n                if (config.fn) {\n                    config.sorterFn = config.fn;\n                }\n\n                //support a function to be passed as a sorter definition\n                if (typeof config == 'function') {\n                    config = {\n                        sorterFn: config\n                    };\n                }\n\n                // return resulting Groupers in a separate array so as not to mutate passed in data objects.\n                result.push(new Grouper(config));\n            } else {\n                result.push(config);\n            }\n        }\n        return result;\n    },\n\n    /**\n     * Groups data inside the store.\n     * @param {String/Object[]} groupers Either a string name of one of the fields in this Store's\n     * configured {@link Ext.data.Model Model}, or an Array of grouper configurations.\n     * @param {String} [direction=\"ASC\"] The overall direction to group the data by.\n     */\n    group: function(groupers, direction) {\n        var me = this,\n            hasNew = false,\n            grouper,\n            newGroupers;\n\n        if (Ext.isArray(groupers)) {\n            newGroupers = groupers;\n        } else if (Ext.isObject(groupers)) {\n            newGroupers = [groupers];\n        } else if (Ext.isString(groupers)) {\n            grouper = me.groupers.get(groupers);\n\n            if (!grouper) {\n                grouper = {\n                    property : groupers,\n                    direction: direction\n                };\n                newGroupers = [grouper];\n            } else if (direction === undefined) {\n                grouper.toggle();\n            } else {\n                grouper.setDirection(direction);\n            }\n        }\n\n        if (newGroupers && newGroupers.length) {\n            hasNew = true;\n            newGroupers = me.decodeGroupers(newGroupers);\n            me.groupers.clear();\n            me.groupers.addAll(newGroupers);\n        }\n\n        if (me.remoteGroup) {\n            if (me.buffered) {\n                me.pageMap.clear();\n                me.loadPage(1, { groupChange: true });\n            } else {\n                me.load({\n                    scope: me,\n                    callback: me.fireGroupChange\n                });\n            }\n        } else {\n            // need to explicitly force a sort if we have groupers\n            me.sort(null, null, null, hasNew);\n            me.fireGroupChange();\n        }\n    },\n\n    /**\n     * Clear any groupers in the store\n     */\n    clearGrouping: function() {\n        var me       = this,\n            groupers = me.groupers.items,\n            gLen     = groupers.length,\n            grouper, g;\n\n        for (g = 0; g < gLen; g++) {\n            grouper = groupers[g];\n\n            me.sorters.remove(grouper);\n        }\n        me.groupers.clear();\n        if (me.remoteGroup) {\n            if (me.buffered) {\n                me.pageMap.clear();\n                me.loadPage(1, { groupChange: true });\n            } else {\n                me.load({\n                    scope: me,\n                    callback: me.fireGroupChange\n                });\n            }\n        } else {\n            me.sort();\n            me.fireGroupChange();\n        }\n    },\n\n    /**\n     * Checks if the store is currently grouped\n     * @return {Boolean} True if the store is grouped.\n     */\n    isGrouped: function() {\n        return this.groupers.getCount() > 0;\n    },\n\n    /**\n     * Fires the groupchange event. Abstracted out so we can use it\n     * as a callback\n     * @private\n     */\n    fireGroupChange: function() {\n        this.fireEvent('groupchange', this, this.groupers);\n    },\n\n    /**\n     * Returns an array containing the result of applying grouping to the records in this store.\n     * See {@link #groupField}, {@link #groupDir} and {@link #getGroupString}. Example for a store\n     * containing records with a color field:\n     *\n     *     var myStore = Ext.create('Ext.data.Store', {\n     *         groupField: 'color',\n     *         groupDir  : 'DESC'\n     *     });\n     *\n     *     myStore.getGroups(); // returns:\n     *     [\n     *         {\n     *             name: 'yellow',\n     *             children: [\n     *                 // all records where the color field is 'yellow'\n     *             ]\n     *         },\n     *         {\n     *             name: 'red',\n     *             children: [\n     *                 // all records where the color field is 'red'\n     *             ]\n     *         }\n     *     ]\n     *\n     * Group contents are effected by filtering.\n     *\n     * @param {String} [groupName] Pass in an optional groupName argument to access a specific\n     * group as defined by {@link #getGroupString}.\n     * @return {Object/Object[]} The grouped data\n     */\n    getGroups: function(requestGroupString) {\n        var records = this.data.items,\n            length = records.length,\n            groups = [],\n            pointers = {},\n            record,\n            groupStr,\n            group,\n            i;\n\n        for (i = 0; i < length; i++) {\n            record = records[i];\n            groupStr = this.getGroupString(record);\n            group = pointers[groupStr];\n\n            if (group === undefined) {\n                group = {\n                    name: groupStr,\n                    children: []\n                };\n\n                groups.push(group);\n                pointers[groupStr] = group;\n            }\n\n            group.children.push(record);\n        }\n\n        return requestGroupString ? pointers[requestGroupString] : groups;\n    },\n\n    /**\n     * @private\n     * For a given set of records and a Grouper, returns an array of arrays - each of which is the set of records\n     * matching a certain group.\n     */\n    getGroupsForGrouper: function(records, grouper) {\n        var length = records.length,\n            groups = [],\n            oldValue,\n            newValue,\n            record,\n            group,\n            i;\n\n        for (i = 0; i < length; i++) {\n            record = records[i];\n            newValue = grouper.getGroupString(record);\n\n            if (newValue !== oldValue) {\n                group = {\n                    name: newValue,\n                    grouper: grouper,\n                    records: []\n                };\n                groups.push(group);\n            }\n\n            group.records.push(record);\n\n            oldValue = newValue;\n        }\n\n        return groups;\n    },\n\n    /**\n     * @private\n     * This is used recursively to gather the records into the configured Groupers. The data MUST have been sorted for\n     * this to work properly (see {@link #getGroupData} and {@link #getGroupsForGrouper}) Most of the work is done by\n     * {@link #getGroupsForGrouper} - this function largely just handles the recursion.\n     *\n     * @param {Ext.data.Model[]} records The set or subset of records to group\n     * @param {Number} grouperIndex The grouper index to retrieve\n     * @return {Object[]} The grouped records\n     */\n    getGroupsForGrouperIndex: function(records, grouperIndex) {\n        var me = this,\n            groupers = me.groupers,\n            grouper = groupers.getAt(grouperIndex),\n            groups = me.getGroupsForGrouper(records, grouper),\n            length = groups.length,\n            i;\n\n        if (grouperIndex + 1 < groupers.length) {\n            for (i = 0; i < length; i++) {\n                groups[i].children = me.getGroupsForGrouperIndex(groups[i].records, grouperIndex + 1);\n            }\n        }\n\n        for (i = 0; i < length; i++) {\n            groups[i].depth = grouperIndex;\n        }\n\n        return groups;\n    },\n\n    /**\n     * @private\n     * Returns records grouped by the configured {@link #groupers grouper} configuration. Sample return value (in\n     * this case grouping by genre and then author in a fictional books dataset):\n     *\n     *     [\n     *         {\n     *             name: 'Fantasy',\n     *             depth: 0,\n     *             records: [\n     *                 //book1, book2, book3, book4\n     *             ],\n     *             children: [\n     *                 {\n     *                     name: 'Rowling',\n     *                     depth: 1,\n     *                     records: [\n     *                         //book1, book2\n     *                     ]\n     *                 },\n     *                 {\n     *                     name: 'Tolkein',\n     *                     depth: 1,\n     *                     records: [\n     *                         //book3, book4\n     *                     ]\n     *                 }\n     *             ]\n     *         }\n     *     ]\n     *\n     * @param {Boolean} [sort=true] True to call {@link #sort} before finding groups. Sorting is required to make grouping\n     * function correctly so this should only be set to false if the Store is known to already be sorted correctly.\n     * @return {Object[]} The group data\n     */\n    getGroupData: function(sort) {\n        var me = this;\n        if (sort !== false) {\n            me.sort();\n        }\n\n        return me.getGroupsForGrouperIndex(me.data.items, 0);\n    },\n\n    /**\n     * Returns the string to group on for a given model instance. The default implementation of this method returns\n     * the model's {@link #groupField}, but this can be overridden to group by an arbitrary string. For example, to\n     * group by the first letter of a model's 'name' field, use the following code:\n     *\n     *     Ext.create('Ext.data.Store', {\n     *         groupDir: 'ASC',\n     *         getGroupString: function(instance) {\n     *             return instance.get('name')[0];\n     *         }\n     *     });\n     *\n     * @param {Ext.data.Model} instance The model instance\n     * @return {String} The string to compare when forming groups\n     */\n    getGroupString: function(instance) {\n        var group = this.groupers.first();\n        if (group) {\n            return instance.get(group.property);\n        }\n        return '';\n    },\n\n    /**\n     * Inserts Model instances into the Store at the given index and fires the {@link #event-add} event.\n     * See also {@link #method-add}.\n     *\n     * @param {Number} index The start index at which to insert the passed Records.\n     * @param {Ext.data.Model[]} records An Array of Ext.data.Model objects to add to the store.\n     */\n    insert: function(index, records) {\n        var me = this,\n            sync = false,\n            i,\n            record,\n            len;\n\n        records = [].concat(records);\n        for (i = 0,len = records.length; i < len; i++) {\n            record = me.createModel(records[i]);\n            record.set(me.modelDefaults);\n            // reassign the model in the array in case it wasn't created yet\n            records[i] = record;\n\n            me.data.insert(index + i, record);\n            record.join(me);\n\n            sync = sync || record.phantom === true;\n        }\n\n        if (me.snapshot) {\n            me.snapshot.addAll(records);\n        }\n\n        if (me.requireSort) {\n            // suspend events so the usual data changed events don't get fired.\n            me.suspendEvents();\n            me.sort();\n            me.resumeEvents();\n        }\n\n        me.fireEvent('add', me, records, index);\n        me.fireEvent('datachanged', me);\n        if (me.autoSync && sync && !me.autoSyncSuspended) {\n            me.sync();\n        }\n    },\n\n    /**\n     * Adds Model instance to the Store. This method accepts either:\n     *\n     * - An array of Model instances or Model configuration objects.\n     * - Any number of Model instance or Model configuration object arguments.\n     *\n     * The new Model instances will be added at the end of the existing collection.\n     *\n     * Sample usage:\n     *\n     *     myStore.add({some: 'data'}, {some: 'other data'});\n     *\n     * Note that if this Store is sorted, the new Model instances will be inserted\n     * at the correct point in the Store to maintain the sort order.\n     *\n     * @param {Ext.data.Model[]/Ext.data.Model...} model An array of Model instances\n     * or Model configuration objects, or variable number of Model instance or config arguments.\n     * @return {Ext.data.Model[]} The model instances that were added\n     */\n    add: function(records) {\n        //accept both a single-argument array of records, or any number of record arguments\n        if (!Ext.isArray(records)) {\n            records = Array.prototype.slice.apply(arguments);\n        } else {\n            // Create an array copy\n            records = records.slice(0);\n        }\n\n        var me = this,\n            i = 0,\n            length = records.length,\n            record,\n            isSorted = !me.remoteSort && me.sorters && me.sorters.items.length;\n\n        // If this Store is sorted, and they only passed one Record (99% or use cases)\n        // then it's much more efficient to add it sorted than to append and then sort.\n        if (isSorted && length === 1) {\n            return [ me.addSorted(me.createModel(records[0])) ];\n        }\n\n        for (; i < length; i++) {\n            record = me.createModel(records[i]);\n            // reassign the model in the array in case it wasn't created yet\n            records[i] = record;\n        }\n\n        // If this sort is sorted, set the flag used by the insert method to sort\n        // before firing events.\n        if (isSorted) {\n            me.requireSort = true;\n        }\n\n        me.insert(me.data.length, records);\n        delete me.requireSort;\n\n        return records;\n    },\n\n    /**\n     * (Local sort only) Inserts the passed Record into the Store at the index where it\n     * should go based on the current sort information.\n     *\n     * @param {Ext.data.Record} record\n     */\n    addSorted: function(record) {\n        var me = this,\n            index = me.data.findInsertionIndex(record, me.generateComparator());\n\n        me.insert(index, record);\n        return record;\n    },\n\n    /**\n     * Converts a literal to a model, if it's not a model already\n     * @private\n     * @param {Ext.data.Model/Object} record The record to create\n     * @return {Ext.data.Model}\n     */\n    createModel: function(record) {\n        if (!record.isModel) {\n            record = Ext.ModelManager.create(record, this.model);\n        }\n\n        return record;\n    },\n\n    /**\n     * Calls the specified function for each {@link Ext.data.Model record} in the store.\n     *\n     * When store is filtered, only loops over the filtered records.\n     *\n     * @param {Function} fn The function to call. The {@link Ext.data.Model Record} is passed as the first parameter.\n     * Returning `false` aborts and exits the iteration.\n     * @param {Object} [scope] The scope (this reference) in which the function is executed.\n     * Defaults to the current {@link Ext.data.Model record} in the iteration.\n     */\n    each: function(fn, scope) {\n        var data = this.data.items,\n            dLen = data.length,\n            record, d;\n\n        for (d = 0; d < dLen; d++) {\n            record = data[d];\n            if (fn.call(scope || record, record, d, dLen) === false) {\n                break;\n            }\n        }\n    },\n\n    /**\n     * Removes the given record from the Store, firing the 'remove' event for each instance that is removed,\n     * plus a single 'datachanged' event after removal.\n     *\n     * @param {Ext.data.Model/Ext.data.Model[]} records Model instance or array of instances to remove.\n     */\n    remove: function(records, /* private */ isMove) {\n        if (!Ext.isArray(records)) {\n            records = [records];\n        }\n\n        /*\n         * Pass the isMove parameter if we know we're going to be re-inserting this record\n         */\n        isMove = isMove === true;\n        var me = this,\n            sync = false,\n            i = 0,\n            length = records.length,\n            isNotPhantom,\n            index,\n            record;\n\n        for (; i < length; i++) {\n            record = records[i];\n            index = me.data.indexOf(record);\n\n            if (me.snapshot) {\n                me.snapshot.remove(record);\n            }\n\n            if (index > -1) {\n                isNotPhantom = record.phantom !== true;\n\n                // don't push phantom records onto removed\n                if (!isMove && isNotPhantom) {\n\n                    // Store the index the record was removed from so that rejectChanges can re-insert at the correct place.\n                    // The record's index property won't do, as that is the index in the overall dataset when Store is buffered.\n                    record.removedFrom = index;\n                    me.removed.push(record);\n                }\n\n                record.unjoin(me);\n                me.data.remove(record);\n                sync = sync || isNotPhantom;\n\n                me.fireEvent('remove', me, record, index);\n            }\n        }\n\n        me.fireEvent('datachanged', me);\n        if (!isMove && me.autoSync && sync && !me.autoSyncSuspended) {\n            me.sync();\n        }\n    },\n\n    /**\n     * Removes the model instance at the given index\n     * @param {Number} index The record index\n     */\n    removeAt: function(index) {\n        var record = this.getAt(index);\n\n        if (record) {\n            this.remove(record);\n        }\n    },\n\n    /**\n     * Loads data into the Store via the configured {@link #proxy}. This uses the Proxy to make an\n     * asynchronous call to whatever storage backend the Proxy uses, automatically adding the retrieved\n     * instances into the Store and calling an optional callback if required. Example usage:\n     *\n     *     store.load({\n     *         scope: this,\n     *         callback: function(records, operation, success) {\n     *             // the {@link Ext.data.Operation operation} object\n     *             // contains all of the details of the load operation\n     *             console.log(records);\n     *         }\n     *     });\n     *\n     * If the callback scope does not need to be set, a function can simply be passed:\n     *\n     *     store.load(function(records, operation, success) {\n     *         console.log('loaded records');\n     *     });\n     *\n     * @param {Object/Function} [options] config object, passed into the Ext.data.Operation object before loading.\n     * Additionally `addRecords: true` can be specified to add these records to the existing records, default is\n     * to remove the Store's existing records first.\n     */\n    load: function(options) {\n        var me = this;\n\n        options = options || {};\n\n        if (typeof options == 'function') {\n            options = {\n                callback: options\n            };\n        }\n\n        options.groupers = options.groupers ||  me.groupers.items;\n        options.page = options.page || me.currentPage;\n        options.start = (options.start !== undefined) ? options.start : (options.page - 1) * me.pageSize;\n        options.limit = options.limit || me.pageSize;\n        options.addRecords = options.addRecords || false;\n\n        if (me.buffered) {\n            return me.loadToPrefetch(options);\n        }\n        return me.callParent([options]);\n    },\n\n    reload: function(options) {\n        var me = this,\n            startIdx,\n            endIdx,\n            startPage,\n            endPage,\n            i,\n            waitForReload,\n            bufferZone,\n            records;\n\n        if (!options) {\n            options = {};\n        }\n\n        // If buffered, we have to clear the page cache and then\n        // cache the page range surrounding store's loaded range.\n        if (me.buffered) {\n\n            // So that prefetchPage does not consider the store to be fully loaded if the local count is equal to the total count\n            delete me.totalCount;\n\n            waitForReload = function() {\n                if (me.rangeCached(startIdx, endIdx)) {\n                    me.loading = false;\n                    me.pageMap.un('pageAdded', waitForReload);\n                    records = me.pageMap.getRange(startIdx, endIdx);\n                    me.loadRecords(records, {\n                        start: startIdx\n                    });\n                    me.fireEvent('load', me, records, true);\n                }\n            };\n            bufferZone = Math.ceil((me.leadingBufferZone + me.trailingBufferZone) / 2);\n\n            // Get our record index range in the dataset\n            startIdx = options.start || me.getAt(0).index;\n            endIdx = startIdx + (options.count || me.getCount()) - 1;\n\n            // Calculate a page range which encompasses the Store's loaded range plus both buffer zones\n            startPage = me.getPageFromRecordIndex(Math.max(startIdx - bufferZone, 0));\n            endPage = me.getPageFromRecordIndex(endIdx + bufferZone);\n\n            // Clear cache (with initial flag so that any listening PagingScroller does not reset to page 1).\n            me.pageMap.clear(true);\n\n            if (me.fireEvent('beforeload', me, options) !== false) {\n                me.loading = true;\n\n                // Recache the page range which encapsulates our visible records\n                for (i = startPage; i <= endPage; i++) {\n                    me.prefetchPage(i, options);\n                }\n\n                // Wait for the requested range to become available in the page map\n                // Load the range as soon as the whole range is available\n                me.pageMap.on('pageAdded', waitForReload);\n            }\n        } else {\n            return me.callParent(arguments);\n        }\n    },\n\n    /**\n     * @private\n     * Called internally when a Proxy has completed a load request\n     */\n    onProxyLoad: function(operation) {\n        var me = this,\n            resultSet = operation.getResultSet(),\n            records = operation.getRecords(),\n            successful = operation.wasSuccessful();\n\n        if (resultSet) {\n            me.totalCount = resultSet.total;\n        }\n\n        if (successful) {\n            me.loadRecords(records, operation);\n        }\n\n        me.loading = false;\n        if (me.hasListeners.load) {\n            me.fireEvent('load', me, records, successful);\n        }\n\n        //TODO: deprecate this event, it should always have been 'load' instead. 'load' is now documented, 'read' is not.\n        //People are definitely using this so can't deprecate safely until 2.x\n        if (me.hasListeners.read) {\n            me.fireEvent('read', me, records, successful);\n        }\n\n        //this is a callback that would have been passed to the 'read' function and is optional\n        Ext.callback(operation.callback, operation.scope || me, [records, operation, successful]);\n    },\n\n    //inherit docs\n    getNewRecords: function() {\n        return this.data.filterBy(this.filterNew).items;\n    },\n\n    //inherit docs\n    getUpdatedRecords: function() {\n        return this.data.filterBy(this.filterUpdated).items;\n    },\n\n    /**\n     * Filters the loaded set of records by a given set of filters.\n     *\n     * By default, the passed filter(s) are *added* to the collection of filters being used to filter this Store.\n     *\n     * To remove existing filters before applying a new set of filters use\n     *\n     *     // Clear the filter collection without updating the UI\n     *     store.clearFilter(true);\n     *\n     * see {@link #clearFilter}.\n     *\n     * Alternatively, if filters are configured with an `id`, then existing filters store may be *replaced* by new\n     * filters having the same `id`.\n     *\n     * Filtering by single field:\n     *\n     *     store.filter(\"email\", /\\.com$/);\n     *\n     * Using multiple filters:\n     *\n     *     store.filter([\n     *         {property: \"email\", value: /\\.com$/},\n     *         {filterFn: function(item) { return item.get(\"age\") > 10; }}\n     *     ]);\n     *\n     * Using Ext.util.Filter instances instead of config objects\n     * (note that we need to specify the {@link Ext.util.Filter#root root} config option in this case):\n     *\n     *     store.filter([\n     *         Ext.create('Ext.util.Filter', {property: \"email\", value: /\\.com$/, root: 'data'}),\n     *         Ext.create('Ext.util.Filter', {filterFn: function(item) { return item.get(\"age\") > 10; }, root: 'data'})\n     *     ]);\n     *\n     * When store is filtered, most of the methods for accessing store data will be working only\n     * within the set of filtered records. Two notable exceptions are {@link #queryBy} and\n     * {@link #getById}.\n     *\n     * @param {Object[]/Ext.util.Filter[]/String} filters The set of filters to apply to the data.\n     * These are stored internally on the store, but the filtering itself is done on the Store's\n     * {@link Ext.util.MixedCollection MixedCollection}. See MixedCollection's\n     * {@link Ext.util.MixedCollection#filter filter} method for filter syntax.\n     * Alternatively, pass in a property string\n     * @param {String} [value] value to filter by (only if using a property string as the first argument)\n     */\n    filter: function(filters, value) {\n        if (Ext.isString(filters)) {\n            filters = {\n                property: filters,\n                value: value\n            };\n        }\n\n        var me = this,\n            decoded = me.decodeFilters(filters),\n            i = 0,\n            doLocalSort = me.sorters.length && me.sortOnFilter && !me.remoteSort,\n            length = decoded.length;\n\n        for (; i < length; i++) {\n            me.filters.replace(decoded[i]);\n        }\n\n        if (me.remoteFilter) {\n            // So that prefetchPage does not consider the store to be fully loaded if the local count is equal to the total count\n            delete me.totalCount;\n            \n            // For a buffered Store, we have to clear the prefetch cache because the dataset will change upon filtering.\n            // Then we must prefetch the new page 1, and when that arrives, reload the visible part of the Store\n            // via the guaranteedrange event\n            if (me.buffered) {\n                me.pageMap.clear();\n                me.loadPage(1);\n            } else {\n                // Reset to the first page, the filter is likely to produce a smaller data set\n                me.currentPage = 1;\n                //the load function will pick up the new filters and request the filtered data from the proxy\n                me.load();\n            }\n        } else {\n            /**\n             * @property {Ext.util.MixedCollection} snapshot\n             * A pristine (unfiltered) collection of the records in this store. This is used to reinstate\n             * records when a filter is removed or changed\n             */\n            if (me.filters.getCount()) {\n                me.snapshot = me.snapshot || me.data.clone();\n                me.data = me.data.filter(me.filters.items);\n\n                if (doLocalSort) {\n                    me.sort();\n                } else {\n                    // fire datachanged event if it hasn't already been fired by doSort\n                    me.fireEvent('datachanged', me);\n                    me.fireEvent('refresh', me);\n                }\n            }\n        }\n    },\n\n    /**\n     * Reverts to a view of the Record cache with no filtering applied.\n     * @param {Boolean} suppressEvent If `true` the filter is cleared silently.\n     *\n     * For a locally filtered Store, this means that the filter collection is cleared without firing the\n     * {@link #datachanged} event.\n     *\n     * For a remotely filtered Store, this means that the filter collection is cleared, but the store\n     * is not reloaded from the server.\n     */\n    clearFilter: function(suppressEvent) {\n        var me = this;\n\n        me.filters.clear();\n\n        if (me.remoteFilter) {\n\n            // In a buffered Store, the meaing of suppressEvent is to simply clear the filters collection\n            if (suppressEvent) {\n                return;\n            }\n\n            // So that prefetchPage does not consider the store to be fully loaded if the local count is equal to the total count\n            delete me.totalCount;\n\n            // For a buffered Store, we have to clear the prefetch cache because the dataset will change upon filtering.\n            // Then we must prefetch the new page 1, and when that arrives, reload the visible part of the Store\n            // via the guaranteedrange event\n            if (me.buffered) {\n                me.pageMap.clear();\n                me.loadPage(1);\n            } else {\n                // Reset to the first page, clearing a filter will destroy the context of the current dataset\n                me.currentPage = 1;\n                me.load();\n            }\n        } else if (me.isFiltered()) {\n            me.data = me.snapshot.clone();\n            delete me.snapshot;\n\n            if (suppressEvent !== true) {\n                me.fireEvent('datachanged', me);\n                me.fireEvent('refresh', me);\n            }\n        }\n    },\n\n    /**\n     * Returns true if this store is currently filtered\n     * @return {Boolean}\n     */\n    isFiltered: function() {\n        var snapshot = this.snapshot;\n        return !! snapshot && snapshot !== this.data;\n    },\n\n    /**\n     * Filters by a function. The specified function will be called for each\n     * Record in this Store. If the function returns `true` the Record is included,\n     * otherwise it is filtered out.\n     *\n     * When store is filtered, most of the methods for accessing store data will be working only\n     * within the set of filtered records. Two notable exceptions are {@link #queryBy} and\n     * {@link #getById}.\n     *\n     * @param {Function} fn The function to be called. It will be passed the following parameters:\n     *  @param {Ext.data.Model} fn.record The record to test for filtering. Access field values\n     *  using {@link Ext.data.Model#get}.\n     *  @param {Object} fn.id The ID of the Record passed.\n     * @param {Object} [scope] The scope (this reference) in which the function is executed.\n     * Defaults to this Store.\n     */\n    filterBy: function(fn, scope) {\n        var me = this;\n\n        me.snapshot = me.snapshot || me.data.clone();\n        me.data = me.queryBy(fn, scope || me);\n        me.fireEvent('datachanged', me);\n        me.fireEvent('refresh', me);\n    },\n\n    /**\n     * Query all the cached records in this Store using a filtering function. The specified function\n     * will be called with each record in this Store. If the function returns `true` the record is\n     * included in the results.\n     *\n     * This method is not effected by filtering, it will always look from all records inside the store\n     * no matter if filter is applied or not.\n     *\n     * @param {Function} fn The function to be called. It will be passed the following parameters:\n     *  @param {Ext.data.Model} fn.record The record to test for filtering. Access field values\n     *  using {@link Ext.data.Model#get}.\n     *  @param {Object} fn.id The ID of the Record passed.\n     * @param {Object} [scope] The scope (this reference) in which the function is executed\n     * Defaults to this Store.\n     * @return {Ext.util.MixedCollection} Returns an Ext.util.MixedCollection of the matched records\n     */\n    queryBy: function(fn, scope) {\n        var me = this,\n            data = me.snapshot || me.data;\n        return data.filterBy(fn, scope || me);\n    },\n\n    /**\n     * Query all the cached records in this Store by name/value pair.\n     * The parameters will be used to generated a filter function that is given\n     * to the queryBy method.\n     *\n     * This method compliments queryBy by generating the query function automatically.\n     *\n     * @param {String} property The property to create the filter function for\n     * @param {String/RegExp} value The string/regex to compare the property value to\n     * @param {Boolean} [anyMatch=false] True if we don't care if the filter value is not the full value.\n     * @param {Boolean} [caseSensitive=false] True to create a case-sensitive regex.\n     * @param {Boolean} [exactMatch=false] True to force exact match (^ and $ characters added to the regex).\n     * Ignored if anyMatch is true.\n     * @return {Ext.util.MixedCollection} Returns an Ext.util.MixedCollection of the matched records\n     */\n    query: function(property, value, anyMatch, caseSensitive, exactMatch) {\n        var me = this,\n            queryFn = me.createFilterFn(property, value, anyMatch, caseSensitive, exactMatch),\n            results = me.queryBy(queryFn);\n\n        //create an empty mixed collection for use if queryBy returns null\n        if(!results) {\n            results = new Ext.util.MixedCollection();\n        }\n\n        return results;\n    },\n\n    /**\n     * Loads an array of data straight into the Store.\n     *\n     * Using this method is great if the data is in the correct format already (e.g. it doesn't need to be\n     * processed by a reader). If your data requires processing to decode the data structure, use a\n     * {@link Ext.data.proxy.Memory MemoryProxy} instead.\n     *\n     * @param {Ext.data.Model[]/Object[]} data Array of data to load. Any non-model instances will be cast\n     * into model instances first.\n     * @param {Boolean} [append=false] True to add the records to the existing records in the store, false\n     * to remove the old ones first.\n     */\n    loadData: function(data, append) {\n        var me = this,\n            model = me.model,\n            length = data.length,\n            newData = [],\n            i,\n            record;\n\n        //make sure each data element is an Ext.data.Model instance\n        for (i = 0; i < length; i++) {\n            record = data[i];\n\n            if (!(record.isModel)) {\n                record = Ext.ModelManager.create(record, model);\n            }\n            newData.push(record);\n        }\n\n        me.loadRecords(newData, append ? me.addRecordsOptions : undefined);\n    },\n\n    /**\n     * Loads data via the bound Proxy's reader\n     *\n     * Use this method if you are attempting to load data and want to utilize the configured data reader.\n     *\n     * @param {Object[]} data The full JSON object you'd like to load into the Data store.\n     * @param {Boolean} [append=false] True to add the records to the existing records in the store, false\n     * to remove the old ones first.\n     */\n    loadRawData : function(data, append) {\n         var me      = this,\n             result  = me.proxy.reader.read(data),\n             records = result.records;\n\n         if (result.success) {\n             me.totalCount = result.total;\n             me.loadRecords(records, append ? me.addRecordsOptions : undefined);\n             me.fireEvent('load', me, records, true);\n         }\n     },\n\n    /**\n     * Loads an array of {@link Ext.data.Model model} instances into the store, fires the datachanged event. This should only usually\n     * be called internally when loading from the {@link Ext.data.proxy.Proxy Proxy}, when adding records manually use {@link #method-add} instead\n     * @param {Ext.data.Model[]} records The array of records to load\n     * @param {Object} options\n     * @param {Boolean} [options.addRecords=false] Pass `true` to add these records to the existing records, `false` to remove the Store's existing records first.\n     * @param {Number}  [options.start] Only used by buffered Stores. The index *within the overall dataset* of the first record in the array.\n     */\n    loadRecords: function(records, options) {\n        var me     = this,\n            i      = 0,\n            length = records.length,\n            start,\n            addRecords,\n            snapshot = me.snapshot;\n\n        if (options) {\n            start = options.start;\n            addRecords = options.addRecords;\n        }\n\n        if (!addRecords) {\n            delete me.snapshot;\n            me.clearData(true);\n        } else if (snapshot) {\n            snapshot.addAll(records);\n        }\n\n        me.data.addAll(records);\n\n        if (start !== undefined) {\n            for (; i < length; i++) {\n                records[i].index = start + i;\n                records[i].join(me);\n            }\n        } else {\n            for (; i < length; i++) {\n                records[i].join(me);\n            }\n        }\n\n        /*\n         * this rather inelegant suspension and resumption of events is required because both the filter and sort functions\n         * fire an additional datachanged event, which is not wanted. Ideally we would do this a different way. The first\n         * datachanged event is fired by the call to this.add, above.\n         */\n        me.suspendEvents();\n\n        if (me.filterOnLoad && !me.remoteFilter) {\n            me.filter();\n        }\n\n        if (me.sortOnLoad && !me.remoteSort) {\n            me.sort(undefined, undefined, undefined, true);\n        }\n\n        me.resumeEvents();\n        me.fireEvent('datachanged', me);\n        me.fireEvent('refresh', me);\n    },\n\n    // PAGING METHODS\n    /**\n     * Loads a given 'page' of data by setting the start and limit values appropriately. Internally this just causes a normal\n     * load operation, passing in calculated 'start' and 'limit' params\n     * @param {Number} page The number of the page to load\n     * @param {Object} options See options for {@link #method-load}\n     */\n    loadPage: function(page, options) {\n        var me = this;\n\n        me.currentPage = page;\n\n        // Copy options into a new object so as not to mutate passed in objects\n        options = Ext.apply({\n            page: page,\n            start: (page - 1) * me.pageSize,\n            limit: me.pageSize,\n            addRecords: !me.clearOnPageLoad\n        }, options);\n\n        if (me.buffered) {\n            return me.loadToPrefetch(options);\n        }\n        me.read(options);\n    },\n\n    /**\n     * Loads the next 'page' in the current data set\n     * @param {Object} options See options for {@link #method-load}\n     */\n    nextPage: function(options) {\n        this.loadPage(this.currentPage + 1, options);\n    },\n\n    /**\n     * Loads the previous 'page' in the current data set\n     * @param {Object} options See options for {@link #method-load}\n     */\n    previousPage: function(options) {\n        this.loadPage(this.currentPage - 1, options);\n    },\n\n    // private\n    clearData: function(isLoad) {\n        var me = this,\n            records = me.data.items,\n            i = records.length;\n\n        while (i--) {\n            records[i].unjoin(me);\n        }\n        me.data.clear();\n        if (isLoad !== true || me.clearRemovedOnLoad) {\n            me.removed.length = 0;\n        }\n    },\n\n    loadToPrefetch: function(options) {\n        var me = this,\n            i,\n            records,\n\n            // Get the requested record index range in the dataset\n            startIdx = options.start,\n            endIdx = options.start + options.limit - 1,\n\n            // The end index to load into the store's live record collection\n            loadEndIdx = options.start + (me.viewSize || options.limit) - 1,\n\n            // Calculate a page range which encompasses the requested range plus both buffer zones\n            startPage = me.getPageFromRecordIndex(Math.max(startIdx - me.trailingBufferZone, 0)),\n            endPage = me.getPageFromRecordIndex(endIdx + me.leadingBufferZone),\n\n            // Wait for the viewable range to be available\n            waitForRequestedRange = function() {\n                if (me.rangeCached(startIdx, loadEndIdx)) {\n                    me.loading = false;\n                    records = me.pageMap.getRange(startIdx, loadEndIdx);\n                    me.pageMap.un('pageAdded', waitForRequestedRange);\n\n                    // If there is a listener for guranteedrange (PagingScroller uses this), then go through that event\n                    if (me.hasListeners.guaranteedrange) {\n                        me.guaranteeRange(startIdx, loadEndIdx, options.callback, options.scope);\n                    }\n                    // Otherwise load the records directly\n                    else {\n                        me.loadRecords(records, {\n                            start: startIdx\n                        });\n                    }\n                    me.fireEvent('load', me, records, true);\n                    if (options.groupChange) {\n                        me.fireGroupChange();\n                    }\n                }\n            };\n\n        if (me.fireEvent('beforeload', me, options) !== false) {\n\n            // So that prefetchPage does not consider the store to be fully loaded if the local count is equal to the total count\n            delete me.totalCount;\n\n            me.loading = true;\n\n            // Wait for the requested range to become available in the page map\n            me.pageMap.on('pageAdded', waitForRequestedRange);\n            \n            // Load the first page in the range, which will give us the initial total count.\n            // Once it is loaded, go ahead and prefetch any subsequent pages, if necessary.\n            // The prefetchPage has a check to prevent us loading more than the totalCount,\n            // so we don't want to blindly load up <n> pages where it isn't required. \n            me.on('prefetch', function(){\n                for (i = startPage + 1; i <= endPage; ++i) {\n                    me.prefetchPage(i, options);\n                }\n            }, null, {single: true});\n            \n            me.prefetchPage(startPage, options);\n        }\n    },\n\n    // Buffering\n    /**\n     * Prefetches data into the store using its configured {@link #proxy}.\n     * @param {Object} options (Optional) config object, passed into the Ext.data.Operation object before loading.\n     * See {@link #method-load}\n     */\n    prefetch: function(options) {\n        var me = this,\n            pageSize = me.pageSize,\n            proxy,\n            operation;\n\n        // Check pageSize has not been tampered with. That would break page caching\n        if (pageSize) {\n            if (me.lastPageSize && pageSize != me.lastPageSize) {\n                Ext.error.raise(\"pageSize cannot be dynamically altered\");\n            }\n            if (!me.pageMap.pageSize) {\n                me.pageMap.pageSize = pageSize;\n            }\n        }\n\n        // Allow first prefetch call to imply the required page size.\n        else {\n            me.pageSize = me.pageMap.pageSize = pageSize = options.limit;\n        }\n\n        // So that we can check for tampering next time through\n        me.lastPageSize = pageSize;\n\n        // Always get whole pages.\n        if (!options.page) {\n            options.page = me.getPageFromRecordIndex(options.start);\n            options.start = (options.page - 1) * pageSize;\n            options.limit = Math.ceil(options.limit / pageSize) * pageSize;\n        }\n\n        // Currently not requesting this page, then request it...\n        if (!me.pageRequests[options.page]) {\n\n            // Copy options into a new object so as not to mutate passed in objects\n            options = Ext.apply({\n                action : 'read',\n                filters: me.filters.items,\n                sorters: me.sorters.items,\n                groupers: me.groupers.items,\n\n                // Generation # of the page map to which the requested records belong.\n                // If page map is cleared while this request is in flight, the generation will increment and the payload will be rejected\n                generation: me.pageMap.generation\n            }, options);\n\n            operation = new Ext.data.Operation(options);\n\n            if (me.fireEvent('beforeprefetch', me, operation) !== false) {\n                me.loading = true;\n                proxy = me.proxy;\n                me.pageRequests[options.page] = proxy.read(operation, me.onProxyPrefetch, me);\n                if (proxy.isSynchronous) {\n                    delete me.pageRequests[options.page];\n                }\n            }\n        }\n\n        return me;\n    },\n\n    /**\n     * @private\n     * Cancels all pending prefetch requests.\n     *\n     * This is called when the page map is cleared.\n     *\n     * Any requests which still make it through will be for the previous page map generation\n     * (generation is incremented upon clear), and so will be rejected upon arrival.\n     */\n    cancelAllPrefetches: function() {\n        var me = this,\n            reqs = me.pageRequests,\n            req,\n            page;\n\n        // If any requests return, we no longer respond to them.\n        if (me.pageMap.events.pageadded) {\n            me.pageMap.events.pageadded.clearListeners();\n        }\n\n        // Cancel all outstanding requests\n        for (page in reqs) {\n            if (reqs.hasOwnProperty(page)) {\n                req = reqs[page];\n                delete reqs[page];\n                delete req.callback;\n            }\n        }\n    },\n\n    /**\n     * Prefetches a page of data.\n     * @param {Number} page The page to prefetch\n     * @param {Object} options (Optional) config object, passed into the Ext.data.Operation object before loading.\n     * See {@link #method-load}\n     */\n    prefetchPage: function(page, options) {\n        var me = this,\n            pageSize = me.pageSize || me.defaultPageSize,\n            start = (page - 1) * me.pageSize,\n            total = me.totalCount;\n\n        // No more data to prefetch.\n        if (total !== undefined && me.getCount() === total) {\n            return;\n        }\n\n        // Copy options into a new object so as not to mutate passed in objects\n        me.prefetch(Ext.applyIf({\n            page     : page,\n            start    : start,\n            limit    : pageSize\n        }, options));\n    },\n\n    /**\n     * Called after the configured proxy completes a prefetch operation.\n     * @private\n     * @param {Ext.data.Operation} operation The operation that completed\n     */\n    onProxyPrefetch: function(operation) {\n        var me = this,\n            resultSet = operation.getResultSet(),\n            records = operation.getRecords(),\n            successful = operation.wasSuccessful(),\n            page = operation.page;\n\n        // Only cache the data if the operation was invoked for the current generation of the page map.\n        // If the generation has changed since the request was fired off, it will have been cancelled.\n        if (operation.generation === me.pageMap.generation) {\n\n            if (resultSet) {\n                me.totalCount = resultSet.total;\n                me.fireEvent('totalcountchange', me.totalCount);\n            }\n\n            // Remove the loaded page from the outstanding pages hash\n            if (page !== undefined) {\n                delete me.pageRequests[page];\n            }\n\n            // Add the page into the page map.\n            // pageAdded event may trigger the onGuaranteedRange\n            if (successful) {\n                me.cachePage(records, operation.page);\n            }\n\n            me.loading = false;\n            me.fireEvent('prefetch', me, records, successful, operation);\n\n            //this is a callback that would have been passed to the 'read' function and is optional\n            Ext.callback(operation.callback, operation.scope || me, [records, operation, successful]);\n        }\n    },\n\n    /**\n     * Caches the records in the prefetch and stripes them with their server-side\n     * index.\n     * @private\n     * @param {Ext.data.Model[]} records The records to cache\n     * @param {Ext.data.Operation} The associated operation\n     */\n    cachePage: function(records, page) {\n        var me = this;\n\n        if (!Ext.isDefined(me.totalCount)) {\n            me.totalCount = records.length;\n            me.fireEvent('totalcountchange', me.totalCount);\n        }\n\n        // Add the fetched page into the pageCache\n        me.pageMap.addPage(page, records);\n    },\n\n    /**\n     * Determines if the passed range is available in the page cache.\n     * @private\n     * @param {Number} start The start index\n     * @param {Number} end The end index in the range\n     */\n    rangeCached: function(start, end) {\n        return this.pageMap && this.pageMap.hasRange(start, end);\n    },\n\n    /**\n     * Determines if the passed page is available in the page cache.\n     * @private\n     * @param {Number} page The page to find in the page cache.\n     */\n    pageCached: function(page) {\n        return this.pageMap && this.pageMap.hasPage(page);\n    },\n\n    /**\n     * Determines if the passed range is available in the page cache.\n     * @private\n     * @deprecated 4.1.0 use {@link #rangeCached} instead\n     * @param {Number} start The start index\n     * @param {Number} end The end index in the range\n     */\n    rangeSatisfied: function(start, end) {\n        return this.rangeCached(start, end);\n    },\n\n    /**\n     * Determines the page from a record index\n     * @param {Number} index The record index\n     * @return {Number} The page the record belongs to\n     */\n    getPageFromRecordIndex: function(index) {\n        return Math.floor(index / this.pageSize) + 1;\n    },\n\n    /**\n     * Handles a guaranteed range being loaded\n     * @private\n     */\n    onGuaranteedRange: function(options) {\n        var me = this,\n            totalCount = me.getTotalCount(),\n            start = options.prefetchStart,\n            end = ((totalCount - 1) < options.prefetchEnd) ? totalCount - 1 : options.prefetchEnd,\n            range;\n\n        end = Math.max(0, end);\n\n        if (start > end) {\n            Ext.log({\n                level: 'warn',\n                msg: 'Start (' + start + ') was greater than end (' + end +\n                    ') for the range of records requested (' + start + '-' +\n                    options.prefetchEnd + ')' + (this.storeId ? ' from store \"' + this.storeId + '\"' : '')\n            });\n        }\n\n        range = me.pageMap.getRange(start, end);\n        me.fireEvent('guaranteedrange', range, start, end);\n        if (options.cb) {\n            options.cb.call(options.scope || me, range, start, end);\n        }\n    },\n\n    /**\n     * Ensures that the specified range of rows is present in the cache.\n     *\n     * Converts the row range to a page range and then only load pages which are not already\n     * present in the page cache.\n     */\n    prefetchRange: function(start, end) {\n        var me = this,\n            startPage, endPage, page;\n        if (!me.rangeCached(start, end)) {\n            startPage = me.getPageFromRecordIndex(start);\n            endPage = me.getPageFromRecordIndex(end);\n\n            // Ensure that the page cache's max size is correct.\n            // Our purgePageCount is the number of additional pages *outside of the required range* which\n            // may be kept in the cache. A purgePageCount of zero means unlimited.\n            me.pageMap.maxSize = me.purgePageCount ? (endPage - startPage + 1) + me.purgePageCount : 0;\n\n            // We have the range, but ensure that we have a \"buffer\" of pages around it.\n            for (page = startPage; page <= endPage; page++) {\n                if (!me.pageCached(page)) {\n                    me.prefetchPage(page);\n                }\n            }\n        }\n    },\n\n    /**\n     * Guarantee a specific range, this will load the store with a range (that\n     * must be the pageSize or smaller) and take care of any loading that may\n     * be necessary.\n     */\n    guaranteeRange: function(start, end, cb, scope) {\n        // Sanity check end point to be within dataset range\n        end = (end > this.totalCount) ? this.totalCount - 1 : end;\n\n        var me = this,\n            lastRequestStart = me.lastRequestStart,\n            options = {\n                prefetchStart: start,\n                prefetchEnd: end,\n                cb: cb,\n                scope: scope\n            },\n            pageAddHandler;\n\n        me.lastRequestStart = start;\n\n        // If data request can be satisfied from the page cache\n        if (me.rangeCached(start, end)) {\n\n            // Attempt to keep the page cache primed with pages which encompass the live data range\n            if (start < lastRequestStart) {\n                start = Math.max(start - me.leadingBufferZone, 0);\n                end   = Math.min(end   + me.trailingBufferZone, me.totalCount - 1);\n            } else {\n                start = Math.max(Math.min(start - me.trailingBufferZone, me.totalCount - me.pageSize), 0);\n                end   = Math.min(end + me.leadingBufferZone, me.totalCount - 1);\n            }\n\n            // If the prefetch window calculated round the requested range is not already satisfied in the page cache,\n            // then arrange to prefetch it.\n            if (!me.rangeCached(start, end)) {\n                // We have the range, but ensure that we have a \"buffer\" of pages around it.\n                me.prefetchRange(start, end);\n            }\n            me.onGuaranteedRange(options);\n        }\n        // At least some of the requested range needs loading from server\n        else {\n            // Private event used by the LoadMask class to perform masking when the range required for rendering is not found in the cache\n            me.fireEvent('cachemiss', me, start, end);\n\n            // Calculate a prefetch range which is centered on the requested data\n            start = Math.min(Math.max(Math.floor(start - ((me.leadingBufferZone + me.trailingBufferZone) / 2)), 0), me.totalCount - me.pageSize);\n            end =   Math.min(Math.max(Math.ceil (end   + ((me.leadingBufferZone + me.trailingBufferZone) / 2)), 0), me.totalCount - 1);\n\n            // Add a pageAdded listener, and as soon as the requested range is loaded, fire the guaranteedrange event\n            pageAddHandler = function(page, records) {\n                if (me.rangeCached(options.prefetchStart, options.prefetchEnd)) {\n                    // Private event used by the LoadMask class to unmask when the range required for rendering has been loaded into the cache\n                    me.fireEvent('cachefilled', me, start, end);\n                    me.pageMap.un('pageAdded', pageAddHandler);\n                    me.onGuaranteedRange(options);\n                }\n            };\n            me.pageMap.on('pageAdded', pageAddHandler);\n\n            // Prioritize the request for the *exact range that the UI is asking for*.\n            // When a page request is in flight, it will not be requested again by checking the me.pageRequests hash,\n            // so the request after this will only request the *remaining* unrequested pages .\n            me.prefetchRange(options.prefetchStart, options.prefetchEnd);\n\n            // Load the pages that need loading.\n            me.prefetchRange(start, end);\n        }\n    },\n\n    // because prefetchData is stored by index\n    // this invalidates all of the prefetchedData\n    sort: function() {\n        var me = this,\n            prefetchData = me.pageMap;\n\n        if (me.buffered) {\n            if (me.remoteSort) {\n                prefetchData.clear();\n                me.callParent(arguments);\n            } else {\n                me.callParent(arguments);\n            }\n        } else {\n            me.callParent(arguments);\n        }\n    },\n\n    // overriden to provide striping of the indexes as sorting occurs.\n    // this cannot be done inside of sort because datachanged has already\n    // fired and will trigger a repaint of the bound view.\n    doSort: function(sorterFn) {\n        var me = this,\n            range,\n            ln,\n            i;\n        if (me.remoteSort) {\n\n            // For a buffered Store, we have to clear the prefetch cache since it is keyed by the index within the dataset.\n            // Then we must prefetch the new page 1, and when that arrives, reload the visible part of the Store\n            // via the guaranteedrange event\n            if (me.buffered) {\n                me.pageMap.clear();\n                me.loadPage(1);\n            } else {\n                //the load function will pick up the new sorters and request the sorted data from the proxy\n                me.load();\n            }\n        } else {\n            me.data.sortBy(sorterFn);\n            if (!me.buffered) {\n                range = me.getRange();\n                ln = range.length;\n                for (i = 0; i < ln; i++) {\n                    range[i].index = i;\n                }\n            }\n            me.fireEvent('datachanged', me);\n            me.fireEvent('refresh', me);\n        }\n    },\n\n    /**\n     * Finds the index of the first matching Record in this store by a specific field value.\n     *\n     * When store is filtered, finds records only within filter.\n     *\n     * @param {String} fieldName The name of the Record field to test.\n     * @param {String/RegExp} value Either a string that the field value\n     * should begin with, or a RegExp to test against the field.\n     * @param {Number} [startIndex=0] The index to start searching at\n     * @param {Boolean} [anyMatch=false] True to match any part of the string, not just the beginning\n     * @param {Boolean} [caseSensitive=false] True for case sensitive comparison\n     * @param {Boolean} [exactMatch=false] True to force exact match (^ and $ characters added to the regex).\n     * @return {Number} The matched index or -1\n     */\n    find: function(property, value, start, anyMatch, caseSensitive, exactMatch) {\n        var fn = this.createFilterFn(property, value, anyMatch, caseSensitive, exactMatch);\n        return fn ? this.data.findIndexBy(fn, null, start) : -1;\n    },\n\n    /**\n     * Finds the first matching Record in this store by a specific field value.\n     *\n     * When store is filtered, finds records only within filter.\n     *\n     * @param {String} fieldName The name of the Record field to test.\n     * @param {String/RegExp} value Either a string that the field value\n     * should begin with, or a RegExp to test against the field.\n     * @param {Number} [startIndex=0] The index to start searching at\n     * @param {Boolean} [anyMatch=false] True to match any part of the string, not just the beginning\n     * @param {Boolean} [caseSensitive=false] True for case sensitive comparison\n     * @param {Boolean} [exactMatch=false] True to force exact match (^ and $ characters added to the regex).\n     * @return {Ext.data.Model} The matched record or null\n     */\n    findRecord: function() {\n        var me = this,\n            index = me.find.apply(me, arguments);\n        return index !== -1 ? me.getAt(index) : null;\n    },\n\n    /**\n     * @private\n     * Returns a filter function used to test a the given property's value. Defers most of the work to\n     * Ext.util.MixedCollection's createValueMatcher function.\n     *\n     * @param {String} property The property to create the filter function for\n     * @param {String/RegExp} value The string/regex to compare the property value to\n     * @param {Boolean} [anyMatch=false] True if we don't care if the filter value is not the full value.\n     * @param {Boolean} [caseSensitive=false] True to create a case-sensitive regex.\n     * @param {Boolean} [exactMatch=false] True to force exact match (^ and $ characters added to the regex).\n     * Ignored if anyMatch is true.\n     */\n    createFilterFn: function(property, value, anyMatch, caseSensitive, exactMatch) {\n        if (Ext.isEmpty(value)) {\n            return false;\n        }\n        value = this.data.createValueMatcher(value, anyMatch, caseSensitive, exactMatch);\n        return function(r) {\n            return value.test(r.data[property]);\n        };\n    },\n\n    /**\n     * Finds the index of the first matching Record in this store by a specific field value.\n     *\n     * When store is filtered, finds records only within filter.\n     *\n     * @param {String} fieldName The name of the Record field to test.\n     * @param {Object} value The value to match the field against.\n     * @param {Number} [startIndex=0] The index to start searching at\n     * @return {Number} The matched index or -1\n     */\n    findExact: function(property, value, start) {\n        return this.data.findIndexBy(function(rec) {\n            return rec.isEqual(rec.get(property), value);\n        },\n        this, start);\n    },\n\n    /**\n     * Find the index of the first matching Record in this Store by a function.\n     * If the function returns `true` it is considered a match.\n     *\n     * When store is filtered, finds records only within filter.\n     *\n     * @param {Function} fn The function to be called. It will be passed the following parameters:\n     *  @param {Ext.data.Model} fn.record The record to test for filtering. Access field values\n     *  using {@link Ext.data.Model#get}.\n     *  @param {Object} fn.id The ID of the Record passed.\n     * @param {Object} [scope] The scope (this reference) in which the function is executed.\n     * Defaults to this Store.\n     * @param {Number} [startIndex=0] The index to start searching at\n     * @return {Number} The matched index or -1\n     */\n    findBy: function(fn, scope, start) {\n        return this.data.findIndexBy(fn, scope, start);\n    },\n\n    /**\n     * Collects unique values for a particular dataIndex from this store.\n     *\n     * @param {String} dataIndex The property to collect\n     * @param {Boolean} [allowNull] Pass true to allow null, undefined or empty string values\n     * @param {Boolean} [bypassFilter] Pass true to collect from all records, even ones which are filtered.\n     * @return {Object[]} An array of the unique values\n     */\n    collect: function(dataIndex, allowNull, bypassFilter) {\n        var me = this,\n            data = (bypassFilter === true && me.snapshot) ? me.snapshot : me.data;\n\n        return data.collect(dataIndex, 'data', allowNull);\n    },\n\n    /**\n     * Gets the number of records in store.\n     *\n     * If using paging, this may not be the total size of the dataset. If the data object\n     * used by the Reader contains the dataset size, then the {@link #getTotalCount} function returns\n     * the dataset size.  **Note**: see the Important note in {@link #method-load}.\n     *\n     * When store is filtered, it's the number of records matching the filter.\n     *\n     * @return {Number} The number of Records in the Store.\n     */\n    getCount: function() {\n        return this.data.length || 0;\n    },\n\n    /**\n     * Returns the total number of {@link Ext.data.Model Model} instances that the {@link Ext.data.proxy.Proxy Proxy}\n     * indicates exist. This will usually differ from {@link #getCount} when using paging - getCount returns the\n     * number of records loaded into the Store at the moment, getTotalCount returns the number of records that\n     * could be loaded into the Store if the Store contained all data\n     * @return {Number} The total number of Model instances available via the Proxy. 0 returned if\n     * no value has been set via the reader.\n     */\n    getTotalCount: function() {\n        return this.totalCount || 0;\n    },\n\n    /**\n     * Get the Record at the specified index.\n     *\n     * The index is effected by filtering.\n     *\n     * @param {Number} index The index of the Record to find.\n     * @return {Ext.data.Model} The Record at the passed index. Returns undefined if not found.\n     */\n    getAt: function(index) {\n        return this.data.getAt(index);\n    },\n\n    /**\n     * Returns a range of Records between specified indices.\n     *\n     * This method is effected by filtering.\n     *\n     * @param {Number} [startIndex=0] The starting index\n     * @param {Number} [endIndex] The ending index. Defaults to the last Record in the Store.\n     * @return {Ext.data.Model[]} An array of Records\n     */\n    getRange: function(start, end) {\n        return this.data.getRange(start, end);\n    },\n\n    /**\n     * Get the Record with the specified id.\n     *\n     * This method is not effected by filtering, lookup will be performed from all records\n     * inside the store, filtered or not.\n     *\n     * @param {Mixed} id The id of the Record to find.\n     * @return {Ext.data.Model} The Record with the passed id. Returns null if not found.\n     */\n    getById: function(id) {\n        return (this.snapshot || this.data).findBy(function(record) {\n            return record.getId() === id;\n        });\n    },\n\n    /**\n     * Get the index of the record within the store.\n     *\n     * When store is filtered, records outside of filter will not be found.\n     *\n     * @param {Ext.data.Model} record The Ext.data.Model object to find.\n     * @return {Number} The index of the passed Record. Returns -1 if not found.\n     */\n    indexOf: function(record) {\n        return this.data.indexOf(record);\n    },\n\n\n    /**\n     * Get the index within the entire dataset. From 0 to the totalCount.\n     *\n     * Like #indexOf, this method is effected by filtering.\n     *\n     * @param {Ext.data.Model} record The Ext.data.Model object to find.\n     * @return {Number} The index of the passed Record. Returns -1 if not found.\n     */\n    indexOfTotal: function(record) {\n        var index = record.index;\n        if (index || index === 0) {\n            return index;\n        }\n        return this.indexOf(record);\n    },\n\n    /**\n     * Get the index within the store of the Record with the passed id.\n     *\n     * Like #indexOf, this method is effected by filtering.\n     *\n     * @param {String} id The id of the Record to find.\n     * @return {Number} The index of the Record. Returns -1 if not found.\n     */\n    indexOfId: function(id) {\n        return this.indexOf(this.getById(id));\n    },\n\n    /**\n     * Removes all items from the store.\n     * @param {Boolean} silent Prevent the `clear` event from being fired.\n     */\n    removeAll: function(silent) {\n        var me = this;\n\n        me.clearData();\n        if (me.snapshot) {\n            me.snapshot.clear();\n        }\n\n        // Special handling to synch the PageMap only for removeAll\n        // TODO: handle other store/data modifications WRT buffered Stores.\n        if (me.pageMap) {\n            me.pageMap.clear();\n        }\n        if (silent !== true) {\n            me.fireEvent('clear', me);\n        }\n    },\n\n    /*\n     * Aggregation methods\n     */\n\n    /**\n     * Convenience function for getting the first model instance in the store.\n     *\n     * When store is filtered, will return first item within the filter.\n     *\n     * @param {Boolean} [grouped] True to perform the operation for each group\n     * in the store. The value returned will be an object literal with the key being the group\n     * name and the first record being the value. The grouped parameter is only honored if\n     * the store has a groupField.\n     * @return {Ext.data.Model/undefined} The first model instance in the store, or undefined\n     */\n    first: function(grouped) {\n        var me = this;\n\n        if (grouped && me.isGrouped()) {\n            return me.aggregate(function(records) {\n                return records.length ? records[0] : undefined;\n            }, me, true);\n        } else {\n            return me.data.first();\n        }\n    },\n\n    /**\n     * Convenience function for getting the last model instance in the store.\n     *\n     * When store is filtered, will return last item within the filter.\n     *\n     * @param {Boolean} [grouped] True to perform the operation for each group\n     * in the store. The value returned will be an object literal with the key being the group\n     * name and the last record being the value. The grouped parameter is only honored if\n     * the store has a groupField.\n     * @return {Ext.data.Model/undefined} The last model instance in the store, or undefined\n     */\n    last: function(grouped) {\n        var me = this;\n\n        if (grouped && me.isGrouped()) {\n            return me.aggregate(function(records) {\n                var len = records.length;\n                return len ? records[len - 1] : undefined;\n            }, me, true);\n        } else {\n            return me.data.last();\n        }\n    },\n\n    /**\n     * Sums the value of `property` for each {@link Ext.data.Model record} between `start`\n     * and `end` and returns the result.\n     *\n     * When store is filtered, only sums items within the filter.\n     *\n     * @param {String} field A field in each record\n     * @param {Boolean} [grouped] True to perform the operation for each group\n     * in the store. The value returned will be an object literal with the key being the group\n     * name and the sum for that group being the value. The grouped parameter is only honored if\n     * the store has a groupField.\n     * @return {Number} The sum\n     */\n    sum: function(field, grouped) {\n        var me = this;\n\n        if (grouped && me.isGrouped()) {\n            return me.aggregate(me.getSum, me, true, [field]);\n        } else {\n            return me.getSum(me.data.items, field);\n        }\n    },\n\n    // @private, see sum\n    getSum: function(records, field) {\n        var total = 0,\n            i = 0,\n            len = records.length;\n\n        for (; i < len; ++i) {\n            total += records[i].get(field);\n        }\n\n        return total;\n    },\n\n    /**\n     * Gets the count of items in the store.\n     *\n     * When store is filtered, only items within the filter are counted.\n     *\n     * @param {Boolean} [grouped] True to perform the operation for each group\n     * in the store. The value returned will be an object literal with the key being the group\n     * name and the count for each group being the value. The grouped parameter is only honored if\n     * the store has a groupField.\n     * @return {Number} the count\n     */\n    count: function(grouped) {\n        var me = this;\n\n        if (grouped && me.isGrouped()) {\n            return me.aggregate(function(records) {\n                return records.length;\n            }, me, true);\n        } else {\n            return me.getCount();\n        }\n    },\n\n    /**\n     * Gets the minimum value in the store.\n     *\n     * When store is filtered, only items within the filter are aggregated.\n     *\n     * @param {String} field The field in each record\n     * @param {Boolean} [grouped] True to perform the operation for each group\n     * in the store. The value returned will be an object literal with the key being the group\n     * name and the minimum in the group being the value. The grouped parameter is only honored if\n     * the store has a groupField.\n     * @return {Object} The minimum value, if no items exist, undefined.\n     */\n    min: function(field, grouped) {\n        var me = this;\n\n        if (grouped && me.isGrouped()) {\n            return me.aggregate(me.getMin, me, true, [field]);\n        } else {\n            return me.getMin(me.data.items, field);\n        }\n    },\n\n    // @private, see min\n    getMin: function(records, field) {\n        var i = 1,\n            len = records.length,\n            value, min;\n\n        if (len > 0) {\n            min = records[0].get(field);\n        }\n\n        for (; i < len; ++i) {\n            value = records[i].get(field);\n            if (value < min) {\n                min = value;\n            }\n        }\n        return min;\n    },\n\n    /**\n     * Gets the maximum value in the store.\n     *\n     * When store is filtered, only items within the filter are aggregated.\n     *\n     * @param {String} field The field in each record\n     * @param {Boolean} [grouped] True to perform the operation for each group\n     * in the store. The value returned will be an object literal with the key being the group\n     * name and the maximum in the group being the value. The grouped parameter is only honored if\n     * the store has a groupField.\n     * @return {Object} The maximum value, if no items exist, undefined.\n     */\n    max: function(field, grouped) {\n        var me = this;\n\n        if (grouped && me.isGrouped()) {\n            return me.aggregate(me.getMax, me, true, [field]);\n        } else {\n            return me.getMax(me.data.items, field);\n        }\n    },\n\n    // @private, see max\n    getMax: function(records, field) {\n        var i = 1,\n            len = records.length,\n            value,\n            max;\n\n        if (len > 0) {\n            max = records[0].get(field);\n        }\n\n        for (; i < len; ++i) {\n            value = records[i].get(field);\n            if (value > max) {\n                max = value;\n            }\n        }\n        return max;\n    },\n\n    /**\n     * Gets the average value in the store.\n     *\n     * When store is filtered, only items within the filter are aggregated.\n     *\n     * @param {String} field The field in each record\n     * @param {Boolean} [grouped] True to perform the operation for each group\n     * in the store. The value returned will be an object literal with the key being the group\n     * name and the group average being the value. The grouped parameter is only honored if\n     * the store has a groupField.\n     * @return {Object} The average value, if no items exist, 0.\n     */\n    average: function(field, grouped) {\n        var me = this;\n        if (grouped && me.isGrouped()) {\n            return me.aggregate(me.getAverage, me, true, [field]);\n        } else {\n            return me.getAverage(me.data.items, field);\n        }\n    },\n\n    // @private, see average\n    getAverage: function(records, field) {\n        var i = 0,\n            len = records.length,\n            sum = 0;\n\n        if (records.length > 0) {\n            for (; i < len; ++i) {\n                sum += records[i].get(field);\n            }\n            return sum / len;\n        }\n        return 0;\n    },\n\n    /**\n     * Runs the aggregate function for all the records in the store.\n     *\n     * When store is filtered, only items within the filter are aggregated.\n     *\n     * @param {Function} fn The function to execute. The function is called with a single parameter,\n     * an array of records for that group.\n     * @param {Object} [scope] The scope to execute the function in. Defaults to the store.\n     * @param {Boolean} [grouped] True to perform the operation for each group\n     * in the store. The value returned will be an object literal with the key being the group\n     * name and the group average being the value. The grouped parameter is only honored if\n     * the store has a groupField.\n     * @param {Array} [args] Any arguments to append to the function call\n     * @return {Object} An object literal with the group names and their appropriate values.\n     */\n    aggregate: function(fn, scope, grouped, args) {\n        args = args || [];\n        if (grouped && this.isGrouped()) {\n            var groups = this.getGroups(),\n                i = 0,\n                len = groups.length,\n                out = {},\n                group;\n\n            for (; i < len; ++i) {\n                group = groups[i];\n                out[group.name] = fn.apply(scope || this, [group.children].concat(args));\n            }\n            return out;\n        } else {\n            return fn.apply(scope || this, [this.data.items].concat(args));\n        }\n    },\n\n    /**\n     * Commits all Records with {@link #getModifiedRecords outstanding changes}. To handle updates for changes,\n     * subscribe to the Store's {@link #event-update update event}, and perform updating when the third parameter is\n     * Ext.data.Record.COMMIT.\n     */\n    commitChanges : function(){\n        var me = this,\n            recs = me.getModifiedRecords(),\n            len = recs.length,\n            i = 0;\n\n        for (; i < len; i++){\n            recs[i].commit();\n        }\n\n        // Since removals are cached in a simple array we can simply reset it here.\n        // Adds and updates are managed in the data MixedCollection and should already be current.\n        me.removed.length = 0;\n    },\n\n    filterNewOnly: function(item){\n        return item.phantom === true;\n    },\n\n    // Ideally in the future this will use getModifiedRecords, where there will be a param\n    // to getNewRecords & getUpdatedRecords to indicate whether to get only the valid\n    // records or grab all of them\n    getRejectRecords: function() {\n        // Return phantom records + updated records\n        return Ext.Array.push(this.data.filterBy(this.filterNewOnly).items, this.getUpdatedRecords());\n    },\n\n    /**\n     * {@link Ext.data.Model#reject Rejects} outstanding changes on all {@link #getModifiedRecords modified records}\n     * and re-insert any records that were removed locally. Any phantom records will be removed.\n     */\n    rejectChanges : function() {\n        var me = this,\n            recs = me.getRejectRecords(),\n            len = recs.length,\n            i = 0,\n            rec;\n\n        for (; i < len; i++) {\n            rec = recs[i];\n            rec.reject();\n            if (rec.phantom) {\n                me.remove(rec);\n            }\n        }\n\n        // Restore removed records back to their original positions\n        recs = me.removed;\n        len = recs.length;\n        for (i = 0; i < len; i++) {\n            rec = recs[i];\n            me.insert(rec.removedFrom || 0, rec);\n            rec.reject();\n        }\n\n        // Since removals are cached in a simple array we can simply reset it here.\n        // Adds and updates are managed in the data MixedCollection and should already be current.\n        me.removed.length = 0;\n    }\n}, function() {\n    // A dummy empty store with a fieldless Model defined in it.\n    // Just for binding to Views which are instantiated with no Store defined.\n    // They will be able to run and render fine, and be bound to a generated Store later.\n    Ext.regStore('ext-empty-store', {fields: [], proxy: 'memory'});\n\n    /**\n     * @class Ext.data.Store.PageMap\n     * @extends Ext.util.LruCache\n     * Private class for use by only Store when configured `buffered: true`.\n     * @private\n     */\n    this.prototype.PageMap = new Ext.Class({\n        extend: 'Ext.util.LruCache',\n\n        // Maintain a generation counter, so that the Store can reject incoming pages destined for the previous generation\n        clear: function(initial) {\n            this.generation = (this.generation ||0) + 1;\n            this.callParent(arguments);\n        },\n\n        getPageFromRecordIndex: this.prototype.getPageFromRecordIndex,\n\n        addPage: function(page, records) {\n            this.add(page, records);\n            this.fireEvent('pageAdded', page, records);\n        },\n\n        getPage: function(page) {\n            return this.get(page);\n        },\n\n        hasRange: function(start, end) {\n            var page = this.getPageFromRecordIndex(start),\n                endPage = this.getPageFromRecordIndex(end);\n\n            for (; page <= endPage; page++) {\n                if (!this.hasPage(page)) {\n                    return false;\n                }\n            }\n            return true;\n        },\n\n        hasPage: function(page) {\n            // We must use this.get to trigger an access so that the page which is checked for presence is not eligible for pruning\n            return !!this.get(page);\n        },\n\n        getRange: function(start, end) {\n            if (!this.hasRange(start, end)) {\n                Ext.Error.raise('PageMap asked for range which it does not have');\n            }\n            var me = this,\n                startPage = me.getPageFromRecordIndex(start),\n                endPage = me.getPageFromRecordIndex(end),\n                dataStart = (startPage - 1) * me.pageSize,\n                dataEnd = (endPage * me.pageSize) - 1,\n                page = startPage,\n                result = [],\n                sliceBegin, sliceEnd, doSlice,\n                i = 0, len;\n\n            for (; page <= endPage; page++) {\n\n                // First and last pages will need slicing to cut into the actual wanted records\n                if (page == startPage) {\n                    sliceBegin = start - dataStart;\n                    doSlice = true;\n                } else {\n                    sliceBegin = 0;\n                    doSlice = false;\n                }\n                if (page == endPage) {\n                    sliceEnd = me.pageSize - (dataEnd - end);\n                    doSlice = true;\n                }\n\n                // First and last pages will need slicing\n                if (doSlice) {\n                    Ext.Array.push(result, Ext.Array.slice(me.getPage(page), sliceBegin, sliceEnd));\n                } else {\n                    Ext.Array.push(result, me.getPage(page));\n                }\n            }\n\n            // Inject the dataset ordinal position into the record as the index\n            for (len = result.length; i < len; i++) {\n                result[i].index = start++;\n            }\n            return result;\n        }\n    });\n});\n\n/**\n * @author Ed Spencer\n * @class Ext.data.reader.Array\n * \n * <p>Data reader class to create an Array of {@link Ext.data.Model} objects from an Array.\n * Each element of that Array represents a row of data fields. The\n * fields are pulled into a Record object using as a subscript, the <code>mapping</code> property\n * of the field definition if it exists, or the field's ordinal position in the definition.</p>\n * \n * <p><u>Example code:</u></p>\n * \n<pre><code>\nEmployee = Ext.define('Employee', {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id',\n        {name: 'name', mapping: 1},         // \"mapping\" only needed if an \"id\" field is present which\n        {name: 'occupation', mapping: 2}    // precludes using the ordinal position as the index.        \n    ]\n});\n\nvar myReader = new Ext.data.reader.Array({\n    model: 'Employee'\n}, Employee);\n</code></pre>\n * \n * <p>This would consume an Array like this:</p>\n * \n<pre><code>\n[ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]\n</code></pre>\n * \n * @constructor\n * Create a new ArrayReader\n * @param {Object} meta Metadata configuration options.\n */\nExt.define('Ext.data.reader.Array', {\n    extend: 'Ext.data.reader.Json',\n    alternateClassName: 'Ext.data.ArrayReader',\n    alias : 'reader.array',\n\n    // For Array Reader, methods in the base which use these properties must not see the defaults\n    totalProperty: undefined,\n    successProperty: undefined,\n\n    /**\n     * @private\n     * Returns an accessor expression for the passed Field from an Array using either the Field's mapping, or\n     * its ordinal position in the fields collsction as the index.\n     * This is used by buildExtractors to create optimized on extractor function which converts raw data into model instances.\n     */\n    createFieldAccessExpression: function(field, fieldVarName, dataName) {\n            // In the absence of a mapping property, use the original ordinal position\n            // at which the Model inserted the field into its collection.\n        var index  = (field.mapping == null) ? field.originalIndex : field.mapping,\n            result;\n\n        if (typeof index === 'function') {\n            result = fieldVarName + '.mapping(' + dataName + ', this)';\n        } else {\n            if (isNaN(index)) {\n                index = '\"' + index + '\"';\n            }\n            result = dataName + \"[\" + index + \"]\";\n        }\n        return result;\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * Small helper class to make creating {@link Ext.data.Store}s from Array data easier. An ArrayStore will be\n * automatically configured with a {@link Ext.data.reader.Array}.\n *\n * A store configuration would be something like:\n *\n *     var store = Ext.create('Ext.data.ArrayStore', {\n *         // store configs\n *         storeId: 'myStore',\n *         // reader configs\n *         fields: [\n *            'company',\n *            {name: 'price', type: 'float'},\n *            {name: 'change', type: 'float'},\n *            {name: 'pctChange', type: 'float'},\n *            {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}\n *         ]\n *     });\n *\n * This store is configured to consume a returned object of the form:\n *\n *     var myData = [\n *         ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],\n *         ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],\n *         ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],\n *         ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],\n *         ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']\n *     ];\n *\n * An object literal of this form could also be used as the {@link #cfg-data} config option.\n *\n */\nExt.define('Ext.data.ArrayStore', {\n    extend: 'Ext.data.Store',\n    alias: 'store.array',\n    requires: [\n        'Ext.data.proxy.Memory',\n        'Ext.data.reader.Array'\n    ],\n\n    constructor: function(config) {\n        config = Ext.apply({\n            proxy: {\n                type: 'memory',\n                reader: 'array'\n            }\n        }, config);\n        this.callParent([config]);\n    },\n\n    loadData: function(data, append) {\n        if (this.expandData === true) {\n            var r = [],\n                i = 0,\n                ln = data.length;\n\n            for (; i < ln; i++) {\n                r[r.length] = [data[i]];\n            }\n\n            data = r;\n        }\n\n        this.callParent([data, append]);\n    }\n}, function() {\n    // backwards compat\n    Ext.data.SimpleStore = Ext.data.ArrayStore;\n    // Ext.reg('simplestore', Ext.data.SimpleStore);\n});\n\n/**\n * @author Ed Spencer\n * @class Ext.data.Batch\n *\n * <p>Provides a mechanism to run one or more {@link Ext.data.Operation operations} in a given order. Fires the 'operationcomplete' event\n * after the completion of each Operation, and the 'complete' event when all Operations have been successfully executed. Fires an 'exception'\n * event if any of the Operations encounter an exception.</p>\n *\n * <p>Usually these are only used internally by {@link Ext.data.proxy.Proxy} classes</p>\n *\n */\nExt.define('Ext.data.Batch', {\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @cfg {Boolean} autoStart\n     * True to immediately start processing the batch as soon as it is constructed (defaults to false)\n     */\n    autoStart: false,\n    \n    /**\n     * @cfg {Boolean} pauseOnException\n     * True to pause the execution of the batch if any operation encounters an exception\n     * (defaults to false). If you set this to true you are responsible for implementing the appropriate\n     * handling logic and restarting or discarding the batch as needed. There are different ways you could \n     * do this, e.g. by handling the batch's {@link #exception} event directly, or perhaps by overriding\n     * {@link Ext.data.AbstractStore#onBatchException onBatchException} at the store level. If you do pause\n     * and attempt to handle the exception you can call {@link #retry} to process the same operation again. \n     * \n     * Note that {@link Ext.data.Operation operations} are atomic, so any operations that may have succeeded\n     * prior to an exception (and up until pausing the batch) will be finalized at the server level and will\n     * not be automatically reversible. Any transactional / rollback behavior that might be desired would have\n     * to be implemented at the application level. Pausing on exception will likely be most beneficial when\n     * used in coordination with such a scheme, where an exception might actually affect subsequent operations\n     * in the same batch and so should be handled before continuing with the next operation.\n     * \n     * If you have not implemented transactional operation handling then this option should typically be left \n     * to the default of false (e.g. process as many operations as possible, and handle any exceptions \n     * asynchronously without holding up the rest of the batch).\n     */\n    pauseOnException: false,\n\n    /**\n     * @property {Number} current\n     * The index of the current operation being executed. Read only\n     */\n    current: -1,\n\n    /**\n     * @property {Number} total\n     * The total number of operations in this batch. Read only\n     */\n    total: 0,\n\n    /**\n     * @property {Boolean} isRunning\n     * True if the batch is currently running. Read only\n     */\n    isRunning: false,\n\n    /**\n     * @property {Boolean} isComplete\n     * True if this batch has been executed completely. Read only\n     */\n    isComplete: false,\n\n    /**\n     * @property {Boolean} hasException\n     * True if this batch has encountered an exception. This is cleared at the start of each operation. Read only\n     */\n    hasException: false,\n\n    /**\n     * Creates new Batch object.\n     * @param {Object} [config] Config object\n     */\n    constructor: function(config) {\n        var me = this;\n\n        /**\n         * @event complete\n         * Fired when all operations of this batch have been completed\n         * @param {Ext.data.Batch} batch The batch object\n         * @param {Object} operation The last operation that was executed\n         */\n\n        /**\n         * @event exception\n         * Fired when a operation encountered an exception\n         * @param {Ext.data.Batch} batch The batch object\n         * @param {Object} operation The operation that encountered the exception\n         */\n\n        /**\n         * @event operationcomplete\n         * Fired when each operation of the batch completes\n         * @param {Ext.data.Batch} batch The batch object\n         * @param {Object} operation The operation that just completed\n         */\n\n        me.mixins.observable.constructor.call(me, config);\n\n        /**\n         * Ordered array of operations that will be executed by this batch\n         * @property {Ext.data.Operation[]} operations\n         */\n        me.operations = [];\n        \n        /**\n         * Ordered array of operations that raised an exception during the most recent\n         * batch execution and did not successfully complete\n         * @property {Ext.data.Operation[]} exceptions\n         */\n        me.exceptions = [];\n    },\n\n    /**\n     * Adds a new operation to this batch at the end of the {@link #operations} array\n     * @param {Object} operation The {@link Ext.data.Operation Operation} object\n     * @return {Ext.data.Batch} this\n     */\n    add: function(operation) {\n        this.total++;\n\n        operation.setBatch(this);\n\n        this.operations.push(operation);\n        \n        return this;\n    },\n\n    /**\n     * Kicks off execution of the batch, continuing from the next operation if the previous\n     * operation encountered an exception, or if execution was paused. Use this method to start\n     * the batch for the first time or to restart a paused batch by skipping the current\n     * unsuccessful operation.\n     * \n     * To retry processing the current operation before continuing to the rest of the batch (e.g.\n     * because you explicitly handled the operation's exception), call {@link #retry} instead.\n     * \n     * Note that if the batch is already running any call to start will be ignored.\n     * \n     * @return {Ext.data.Batch} this\n     */\n    start: function(/* private */ index) {\n        var me = this;\n        \n        if (me.isRunning) {\n            return me;\n        }\n        \n        me.exceptions.length = 0;\n        me.hasException = false;\n        me.isRunning = true;\n\n        return me.runOperation(Ext.isDefined(index) ? index : me.current + 1);\n    },\n    \n    /**\n     * Kicks off execution of the batch, continuing from the current operation. This is intended\n     * for restarting a {@link #pause paused} batch after an exception, and the operation that raised\n     * the exception will now be retried. The batch will then continue with its normal processing until\n     * all operations are complete or another exception is encountered.\n     * \n     * Note that if the batch is already running any call to retry will be ignored.\n     * \n     * @return {Ext.data.Batch} this\n     */\n    retry: function() {\n        return this.start(this.current);\n    },\n\n    /**\n     * @private\n     * Runs the next operation, relative to this.current.\n     * @return {Ext.data.Batch} this\n     */\n    runNextOperation: function() {\n        return this.runOperation(this.current + 1);\n    },\n\n    /**\n     * Pauses execution of the batch, but does not cancel the current operation\n     * @return {Ext.data.Batch} this\n     */\n    pause: function() {\n        this.isRunning = false;\n        return this;\n    },\n\n    /**\n     * Executes an operation by its numeric index in the {@link #operations} array\n     * @param {Number} index The operation index to run\n     * @return {Ext.data.Batch} this\n     */\n    runOperation: function(index) {\n        var me = this,\n            operations = me.operations,\n            operation = operations[index],\n            onProxyReturn;\n\n        if (operation === undefined) {\n            me.isRunning = false;\n            me.isComplete = true;\n            me.fireEvent('complete', me, operations[operations.length - 1]);\n        } else {\n            me.current = index;\n\n            onProxyReturn = function(operation) {\n                var hasException = operation.hasException();\n\n                if (hasException) {\n                    me.hasException = true;\n                    me.exceptions.push(operation);\n                    me.fireEvent('exception', me, operation);\n                }\n\n                if (hasException && me.pauseOnException) {\n                    me.pause();\n                } else {\n                    operation.setCompleted();\n                    me.fireEvent('operationcomplete', me, operation);\n                    me.runNextOperation();\n                }\n            };\n\n            operation.setStarted();\n\n            me.proxy[operation.action](operation, onProxyReturn, me);\n        }\n        \n        return me;\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.data.BufferStore', {\n    extend: 'Ext.data.Store',\n    alias: 'store.buffer',\n    sortOnLoad: false,\n    filterOnLoad: false,\n    \n    constructor: function() {\n        Ext.Error.raise('The BufferStore class has been deprecated. Instead, specify the buffered config option on Ext.data.Store');\n    }\n});\n\n/**\n * Ext.Direct aims to streamline communication between the client and server by providing a single interface that\n * reduces the amount of common code typically required to validate data and handle returned data packets (reading data,\n * error conditions, etc).\n *\n * The Ext.direct namespace includes several classes for a closer integration with the server-side. The Ext.data\n * namespace also includes classes for working with Ext.data.Stores which are backed by data from an Ext.Direct method.\n *\n * # Specification\n *\n * For additional information consult the [Ext.Direct Specification][1].\n *\n * # Providers\n *\n * Ext.Direct uses a provider architecture, where one or more providers are used to transport data to and from the\n * server. There are several providers that exist in the core at the moment:\n *\n * - {@link Ext.direct.JsonProvider JsonProvider} for simple JSON operations\n * - {@link Ext.direct.PollingProvider PollingProvider} for repeated requests\n * - {@link Ext.direct.RemotingProvider RemotingProvider} exposes server side on the client.\n *\n * A provider does not need to be invoked directly, providers are added via {@link Ext.direct.Manager}.{@link #addProvider}.\n *\n * # Router\n *\n * Ext.Direct utilizes a \"router\" on the server to direct requests from the client to the appropriate server-side\n * method. Because the Ext.Direct API is completely platform-agnostic, you could completely swap out a Java based server\n * solution and replace it with one that uses C# without changing the client side JavaScript at all.\n *\n * # Server side events\n *\n * Custom events from the server may be handled by the client by adding listeners, for example:\n *\n *     {\"type\":\"event\",\"name\":\"message\",\"data\":\"Successfully polled at: 11:19:30 am\"}\n *\n *     // add a handler for a 'message' event sent by the server\n *     Ext.direct.Manager.on('message', function(e){\n *         out.append(String.format('<p><i>{0}</i></p>', e.data));\n *         out.el.scrollTo('t', 100000, true);\n *     });\n *\n *    [1]: http://sencha.com/products/extjs/extdirect\n *\n * @singleton\n * @alternateClassName Ext.Direct\n */\nExt.define('Ext.direct.Manager', {\n\n    /* Begin Definitions */\n    singleton: true,\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    requires: ['Ext.util.MixedCollection'],\n\n    /**\n     * Exception types.\n     */\n    exceptions: {\n        TRANSPORT: 'xhr',\n        PARSE: 'parse',\n        LOGIN: 'login',\n        SERVER: 'exception'\n    },\n\n    /* End Definitions */\n\n    constructor: function(){\n        var me = this;\n\n        me.addEvents(\n            /**\n             * @event event\n             * Fires after an event.\n             * @param {Ext.direct.Event} e The Ext.direct.Event type that occurred.\n             * @param {Ext.direct.Provider} provider The {@link Ext.direct.Provider Provider}.\n             */\n            'event',\n            /**\n             * @event exception\n             * Fires after an event exception.\n             * @param {Ext.direct.Event} e The event type that occurred.\n             */\n            'exception'\n        );\n        me.transactions = new Ext.util.MixedCollection();\n        me.providers = new Ext.util.MixedCollection();\n\n        me.mixins.observable.constructor.call(me);\n    },\n\n    /**\n     * Adds an Ext.Direct Provider and creates the proxy or stub methods to execute server-side methods. If the provider\n     * is not already connected, it will auto-connect.\n     *\n     *     var pollProv = new Ext.direct.PollingProvider({\n     *         url: 'php/poll2.php'\n     *     });\n     *\n     *     Ext.direct.Manager.addProvider({\n     *         \"type\":\"remoting\",       // create a {@link Ext.direct.RemotingProvider}\n     *         \"url\":\"php\\/router.php\", // url to connect to the Ext.Direct server-side router.\n     *         \"actions\":{              // each property within the actions object represents a Class\n     *             \"TestAction\":[       // array of methods within each server side Class\n     *             {\n     *                 \"name\":\"doEcho\", // name of method\n     *                 \"len\":1\n     *             },{\n     *                 \"name\":\"multiply\",\n     *                 \"len\":1\n     *             },{\n     *                 \"name\":\"doForm\",\n     *                 \"formHandler\":true, // handle form on server with Ext.Direct.Transaction\n     *                 \"len\":1\n     *             }]\n     *         },\n     *         \"namespace\":\"myApplication\",// namespace to create the Remoting Provider in\n     *     },{\n     *         type: 'polling', // create a {@link Ext.direct.PollingProvider}\n     *         url:  'php/poll.php'\n     *     }, pollProv); // reference to previously created instance\n     *\n     * @param {Ext.direct.Provider/Object...} provider\n     * Accepts any number of Provider descriptions (an instance or config object for\n     * a Provider). Each Provider description instructs Ext.Directhow to create\n     * client-side stub methods.\n     */\n    addProvider : function(provider){\n        var me = this,\n            args = arguments,\n            i = 0,\n            len;\n\n        if (args.length > 1) {\n            for (len = args.length; i < len; ++i) {\n                me.addProvider(args[i]);\n            }\n            return;\n        }\n\n        // if provider has not already been instantiated\n        if (!provider.isProvider) {\n            provider = Ext.create('direct.' + provider.type + 'provider', provider);\n        }\n        me.providers.add(provider);\n        provider.on('data', me.onProviderData, me);\n\n\n        if (!provider.isConnected()) {\n            provider.connect();\n        }\n\n        return provider;\n    },\n\n    /**\n     * Retrieves a {@link Ext.direct.Provider provider} by the **{@link Ext.direct.Provider#id id}** specified when the\n     * provider is {@link #addProvider added}.\n     * @param {String/Ext.direct.Provider} id The id of the provider, or the provider instance.\n     */\n    getProvider : function(id){\n        return id.isProvider ? id : this.providers.get(id);\n    },\n\n    /**\n     * Removes the provider.\n     * @param {String/Ext.direct.Provider} provider The provider instance or the id of the provider.\n     * @return {Ext.direct.Provider} The provider, null if not found.\n     */\n    removeProvider : function(provider){\n        var me = this,\n            providers = me.providers;\n\n        provider = provider.isProvider ? provider : providers.get(provider);\n\n        if (provider) {\n            provider.un('data', me.onProviderData, me);\n            providers.remove(provider);\n            return provider;\n        }\n        return null;\n    },\n\n    /**\n     * Adds a transaction to the manager.\n     * @private\n     * @param {Ext.direct.Transaction} transaction The transaction to add\n     * @return {Ext.direct.Transaction} transaction\n     */\n    addTransaction: function(transaction){\n        this.transactions.add(transaction);\n        return transaction;\n    },\n\n    /**\n     * Removes a transaction from the manager.\n     * @private\n     * @param {String/Ext.direct.Transaction} transaction The transaction/id of transaction to remove\n     * @return {Ext.direct.Transaction} transaction\n     */\n    removeTransaction: function(transaction){\n        transaction = this.getTransaction(transaction);\n        this.transactions.remove(transaction);\n        return transaction;\n    },\n\n    /**\n     * Gets a transaction\n     * @private\n     * @param {String/Ext.direct.Transaction} transaction The transaction/id of transaction to get\n     * @return {Ext.direct.Transaction}\n     */\n    getTransaction: function(transaction){\n        return Ext.isObject(transaction) ? transaction : this.transactions.get(transaction);\n    },\n\n    onProviderData : function(provider, event){\n        var me = this,\n            i = 0,\n            len;\n\n        if (Ext.isArray(event)) {\n            for (len = event.length; i < len; ++i) {\n                me.onProviderData(provider, event[i]);\n            }\n            return;\n        }\n        if (event.name && event.name != 'event' && event.name != 'exception') {\n            me.fireEvent(event.name, event);\n        } else if (event.status === false) {\n            me.fireEvent('exception', event);\n        }\n        me.fireEvent('event', event, provider);\n    },\n    \n    /**\n     * Parses a direct function. It may be passed in a string format, for example:\n     * \"MyApp.Person.read\".\n     * @protected\n     * @param {String/Function} fn The direct function\n     * @return {Function} The function to use in the direct call. Null if not found\n     */\n    parseMethod: function(fn){\n        if (Ext.isString(fn)) {\n            var parts = fn.split('.'),\n                i = 0,\n                len = parts.length,\n                current = window;\n                \n            while (current && i < len) {\n                current = current[parts[i]];\n                ++i;\n            }\n            fn = Ext.isFunction(current) ? current : null;\n        }\n        return fn || null;\n    }\n    \n}, function(){\n    // Backwards compatibility\n    Ext.Direct = Ext.direct.Manager;\n});\n\n/**\n * This class is used to send requests to the server using {@link Ext.direct.Manager Ext.Direct}. When a\n * request is made, the transport mechanism is handed off to the appropriate\n * {@link Ext.direct.RemotingProvider Provider} to complete the call.\n *\n * # Specifying the function\n *\n * This proxy expects a Direct remoting method to be passed in order to be able to complete requests.\n * This can be done by specifying the {@link #directFn} configuration. This will use the same direct\n * method for all requests. Alternatively, you can provide an {@link #api} configuration. This\n * allows you to specify a different remoting method for each CRUD action.\n *\n * # Parameters\n *\n * This proxy provides options to help configure which parameters will be sent to the server.\n * By specifying the {@link #paramsAsHash} option, it will send an object literal containing each\n * of the passed parameters. The {@link #paramOrder} option can be used to specify the order in which\n * the remoting method parameters are passed.\n *\n * # Example Usage\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['firstName', 'lastName'],\n *         proxy: {\n *             type: 'direct',\n *             directFn: MyApp.getUsers,\n *             paramOrder: 'id' // Tells the proxy to pass the id as the first parameter to the remoting method.\n *         }\n *     });\n *     User.load(1);\n */\nExt.define('Ext.data.proxy.Direct', {\n    /* Begin Definitions */\n\n    extend: 'Ext.data.proxy.Server',\n    alternateClassName: 'Ext.data.DirectProxy',\n\n    alias: 'proxy.direct',\n\n    requires: ['Ext.direct.Manager'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String/String[]} paramOrder\n     * Defaults to undefined. A list of params to be executed server side.  Specify the params in the order in\n     * which they must be executed on the server-side as either (1) an Array of String values, or (2) a String\n     * of params delimited by either whitespace, comma, or pipe. For example, any of the following would be\n     * acceptable:\n     *\n     *     paramOrder: ['param1','param2','param3']\n     *     paramOrder: 'param1 param2 param3'\n     *     paramOrder: 'param1,param2,param3'\n     *     paramOrder: 'param1|param2|param'\n     */\n    paramOrder: undefined,\n\n    /**\n     * @cfg {Boolean} paramsAsHash\n     * Send parameters as a collection of named arguments.\n     * Providing a {@link #paramOrder} nullifies this configuration.\n     */\n    paramsAsHash: true,\n\n    /**\n     * @cfg {Function/String} directFn\n     * Function to call when executing a request. directFn is a simple alternative to defining the api configuration-parameter\n     * for Store's which will not implement a full CRUD api. The directFn may also be a string reference to the fully qualified\n     * name of the function, for example: 'MyApp.company.GetProfile'. This can be useful when using dynamic loading. The string \n     * will be looked up when the proxy is created.\n     */\n    directFn : undefined,\n\n    /**\n     * @cfg {Object} api\n     * The same as {@link Ext.data.proxy.Server#api}, however instead of providing urls, you should provide a direct\n     * function call. See {@link #directFn}.\n     */\n\n    /**\n     * @cfg {Object} extraParams\n     * Extra parameters that will be included on every read request. Individual requests with params\n     * of the same name will override these params when they are in conflict.\n     */\n\n    // private\n    paramOrderRe: /[\\s,|]/,\n\n    constructor: function(config){\n        var me = this,\n            paramOrder,\n            fn,\n            api;\n            \n        me.callParent(arguments);\n        \n        paramOrder = me.paramOrder;\n        if (Ext.isString(paramOrder)) {\n            me.paramOrder = paramOrder.split(me.paramOrderRe);\n        }\n        \n        fn = me.directFn;\n        if (fn) {\n            me.directFn = Ext.direct.Manager.parseMethod(fn);\n        }\n        \n        api = me.api;\n        for (fn in api) {\n            if (api.hasOwnProperty(fn)) {\n                api[fn] = Ext.direct.Manager.parseMethod(api[fn]);\n            }\n        }\n    },\n\n    doRequest: function(operation, callback, scope) {\n        var me = this,\n            writer = me.getWriter(),\n            request = me.buildRequest(operation, callback, scope),\n            fn = me.api[request.action]  || me.directFn,\n            params = request.params,\n            args = [],\n            method;\n\n        if (!fn) {\n            Ext.Error.raise('No direct function specified for this proxy');\n        }\n\n        if (operation.allowWrite()) {\n            request = writer.write(request);\n        }\n\n        if (operation.action == 'read') {\n            // We need to pass params\n            method = fn.directCfg.method;\n            args = method.getArgs(params, me.paramOrder, me.paramsAsHash);\n        } else {\n            args.push(request.jsonData);\n        }\n\n        Ext.apply(request, {\n            args: args,\n            directFn: fn\n        });\n        args.push(me.createRequestCallback(request, operation, callback, scope), me);\n        fn.apply(window, args);\n    },\n\n    /*\n     * Inherit docs. We don't apply any encoding here because\n     * all of the direct requests go out as jsonData\n     */\n    applyEncoding: function(value){\n        return value;\n    },\n\n    createRequestCallback: function(request, operation, callback, scope){\n        var me = this;\n\n        return function(data, event){\n            me.processResponse(event.status, operation, request, event, callback, scope);\n        };\n    },\n\n    // inherit docs\n    extractResponseData: function(response){\n        return Ext.isDefined(response.result) ? response.result : response.data;\n    },\n\n    // inherit docs\n    setException: function(operation, response) {\n        operation.setException(response.message);\n    },\n\n    // inherit docs\n    buildUrl: function(){\n        return '';\n    }\n});\n\n/**\n * Small helper class to create an {@link Ext.data.Store} configured with an {@link Ext.data.proxy.Direct}\n * and {@link Ext.data.reader.Json} to make interacting with an {@link Ext.direct.Manager} server-side\n * {@link Ext.direct.Provider Provider} easier. To create a different proxy/reader combination create a basic\n * {@link Ext.data.Store} configured as needed.\n *\n * **Note:** Although they are not listed, this class inherits all of the config options of:\n *\n * - **{@link Ext.data.Store Store}**\n *\n * - **{@link Ext.data.reader.Json JsonReader}**\n *\n *   - **{@link Ext.data.reader.Json#cfg-root root}**\n *   - **{@link Ext.data.reader.Json#idProperty idProperty}**\n *   - **{@link Ext.data.reader.Json#totalProperty totalProperty}**\n *\n * - **{@link Ext.data.proxy.Direct DirectProxy}**\n *\n *   - **{@link Ext.data.proxy.Direct#directFn directFn}**\n *   - **{@link Ext.data.proxy.Direct#paramOrder paramOrder}**\n *   - **{@link Ext.data.proxy.Direct#paramsAsHash paramsAsHash}**\n *\n */\nExt.define('Ext.data.DirectStore', {\n    /* Begin Definitions */\n    \n    extend: 'Ext.data.Store',\n    \n    alias: 'store.direct',\n    \n    requires: ['Ext.data.proxy.Direct'],\n   \n    /* End Definitions */\n\n    constructor : function(config){\n        config = Ext.apply({}, config);\n        if (!config.proxy) {\n            var proxy = {\n                type: 'direct',\n                reader: {\n                    type: 'json'\n                }\n            };\n            Ext.copyTo(proxy, config, 'paramOrder,paramsAsHash,directFn,api,simpleSortMode');\n            Ext.copyTo(proxy.reader, config, 'totalProperty,root,idProperty');\n            config.proxy = proxy;\n        }\n        this.callParent([config]);\n    }    \n});\n\n/**\n * @class Ext.data.JsonP\n * @singleton\n * This class is used to create JSONP requests. JSONP is a mechanism that allows for making\n * requests for data cross domain. More information is available <a href=\"http://en.wikipedia.org/wiki/JSONP\">here</a>.\n */\nExt.define('Ext.data.JsonP', {\n\n    /* Begin Definitions */\n\n    singleton: true,\n\n    /* End Definitions */\n\n    /**\n     * Number of requests done so far.\n     * @private\n     */\n    requestCount: 0,\n\n    /**\n     * Hash of pending requests.\n     * @private\n     */\n    requests: {},\n\n    /**\n     * @property timeout\n     * @type Number\n     * A default timeout for any JsonP requests. If the request has not completed in this time the\n     * failure callback will be fired. The timeout is in ms. Defaults to <tt>30000</tt>.\n     */\n    timeout: 30000,\n\n    /**\n     * @property disableCaching\n     * @type Boolean\n     * True to add a unique cache-buster param to requests. Defaults to <tt>true</tt>.\n     */\n    disableCaching: true,\n\n    /**\n     * @property disableCachingParam\n     * @type String\n     * Change the parameter which is sent went disabling caching through a cache buster. Defaults to <tt>'_dc'</tt>.\n     */\n    disableCachingParam: '_dc',\n\n    /**\n     * @property callbackKey\n     * @type String\n     * Specifies the GET parameter that will be sent to the server containing the function name to be executed when\n     * the request completes. Defaults to <tt>callback</tt>. Thus, a common request will be in the form of\n     * url?callback=Ext.data.JsonP.callback1\n     */\n    callbackKey: 'callback',\n\n    /**\n     * Makes a JSONP request.\n     * @param {Object} options An object which may contain the following properties. Note that options will\n     * take priority over any defaults that are specified in the class.\n     * <ul>\n     * <li><b>url</b> : String <div class=\"sub-desc\">The URL to request.</div></li>\n     * <li><b>params</b> : Object (Optional)<div class=\"sub-desc\">An object containing a series of\n     * key value pairs that will be sent along with the request.</div></li>\n     * <li><b>timeout</b> : Number (Optional) <div class=\"sub-desc\">See {@link #timeout}</div></li>\n     * <li><b>callbackKey</b> : String (Optional) <div class=\"sub-desc\">See {@link #callbackKey}</div></li>\n     * <li><b>callbackName</b> : String (Optional) <div class=\"sub-desc\">The function name to use for this request.\n     * By default this name will be auto-generated: Ext.data.JsonP.callback1, Ext.data.JsonP.callback2, etc.\n     * Setting this option to \"my_name\" will force the function name to be Ext.data.JsonP.my_name.\n     * Use this if you want deterministic behavior, but be careful - the callbackName should be different\n     * in each JsonP request that you make.</div></li>\n     * <li><b>disableCaching</b> : Boolean (Optional) <div class=\"sub-desc\">See {@link #disableCaching}</div></li>\n     * <li><b>disableCachingParam</b> : String (Optional) <div class=\"sub-desc\">See {@link #disableCachingParam}</div></li>\n     * <li><b>success</b> : Function (Optional) <div class=\"sub-desc\">A function to execute if the request succeeds.</div></li>\n     * <li><b>failure</b> : Function (Optional) <div class=\"sub-desc\">A function to execute if the request fails.</div></li>\n     * <li><b>callback</b> : Function (Optional) <div class=\"sub-desc\">A function to execute when the request\n     * completes, whether it is a success or failure.</div></li>\n     * <li><b>scope</b> : Object (Optional)<div class=\"sub-desc\">The scope in\n     * which to execute the callbacks: The \"this\" object for the callback function. Defaults to the browser window.</div></li>\n     * </ul>\n     * @return {Object} request An object containing the request details.\n     */\n    request: function(options){\n        options = Ext.apply({}, options);\n\n        if (!options.url) {\n            Ext.Error.raise('A url must be specified for a JSONP request.');\n        }\n\n        var me = this,\n            disableCaching = Ext.isDefined(options.disableCaching) ? options.disableCaching : me.disableCaching,\n            cacheParam = options.disableCachingParam || me.disableCachingParam,\n            id = ++me.requestCount,\n            callbackName = options.callbackName || 'callback' + id,\n            callbackKey = options.callbackKey || me.callbackKey,\n            timeout = Ext.isDefined(options.timeout) ? options.timeout : me.timeout,\n            params = Ext.apply({}, options.params),\n            url = options.url,\n            name = Ext.name,\n            request,\n            script;\n\n        params[callbackKey] = name + '.data.JsonP.' + callbackName;\n        if (disableCaching) {\n            params[cacheParam] = new Date().getTime();\n        }\n\n        script = me.createScript(url, params, options);\n\n        me.requests[id] = request = {\n            url: url,\n            params: params,\n            script: script,\n            id: id,\n            scope: options.scope,\n            success: options.success,\n            failure: options.failure,\n            callback: options.callback,\n            callbackKey: callbackKey,\n            callbackName: callbackName\n        };\n\n        if (timeout > 0) {\n            request.timeout = setTimeout(Ext.bind(me.handleTimeout, me, [request]), timeout);\n        }\n\n        me.setupErrorHandling(request);\n        me[callbackName] = Ext.bind(me.handleResponse, me, [request], true);\n        me.loadScript(request);\n        return request;\n    },\n\n    /**\n     * Abort a request. If the request parameter is not specified all open requests will\n     * be aborted.\n     * @param {Object/String} request (Optional) The request to abort\n     */\n    abort: function(request){\n        var me = this,\n            requests = me.requests,\n            key;\n\n        if (request) {\n            if (!request.id) {\n                request = requests[request];\n            }\n            me.handleAbort(request);\n        } else {\n            for (key in requests) {\n                if (requests.hasOwnProperty(key)) {\n                    me.abort(requests[key]);\n                }\n            }\n        }\n    },\n\n    /**\n     * Sets up error handling for the script\n     * @private\n     * @param {Object} request The request\n     */\n    setupErrorHandling: function(request){\n        request.script.onerror = Ext.bind(this.handleError, this, [request]);\n    },\n\n    /**\n     * Handles any aborts when loading the script\n     * @private\n     * @param {Object} request The request\n     */\n    handleAbort: function(request){\n        request.errorType = 'abort';\n        this.handleResponse(null, request);\n    },\n\n    /**\n     * Handles any script errors when loading the script\n     * @private\n     * @param {Object} request The request\n     */\n    handleError: function(request){\n        request.errorType = 'error';\n        this.handleResponse(null, request);\n    },\n\n    /**\n     * Cleans up anu script handling errors\n     * @private\n     * @param {Object} request The request\n     */\n    cleanupErrorHandling: function(request){\n        request.script.onerror = null;\n    },\n\n    /**\n     * Handle any script timeouts\n     * @private\n     * @param {Object} request The request\n     */\n    handleTimeout: function(request){\n        request.errorType = 'timeout';\n        this.handleResponse(null, request);\n    },\n\n    /**\n     * Handle a successful response\n     * @private\n     * @param {Object} result The result from the request\n     * @param {Object} request The request\n     */\n    handleResponse: function(result, request){\n\n        var success = true;\n\n        if (request.timeout) {\n            clearTimeout(request.timeout);\n        }\n        delete this[request.callbackName];\n        delete this.requests[request.id];\n        this.cleanupErrorHandling(request);\n        Ext.fly(request.script).remove();\n\n        if (request.errorType) {\n            success = false;\n            Ext.callback(request.failure, request.scope, [request.errorType]);\n        } else {\n            Ext.callback(request.success, request.scope, [result]);\n        }\n        Ext.callback(request.callback, request.scope, [success, result, request.errorType]);\n    },\n\n    /**\n     * Create the script tag given the specified url, params and options. The options\n     * parameter is passed to allow an override to access it.\n     * @private\n     * @param {String} url The url of the request\n     * @param {Object} params Any extra params to be sent\n     * @param {Object} options The object passed to {@link #request}.\n     */\n    createScript: function(url, params, options) {\n        var script = document.createElement('script');\n        script.setAttribute(\"src\", Ext.urlAppend(url, Ext.Object.toQueryString(params)));\n        script.setAttribute(\"async\", true);\n        script.setAttribute(\"type\", \"text/javascript\");\n        return script;\n    },\n\n    /**\n     * Loads the script for the given request by appending it to the HEAD element. This is\n     * its own method so that users can override it (as well as {@link #createScript}).\n     * @private\n     * @param request The request object.\n     */\n    loadScript: function (request) {\n        Ext.getHead().appendChild(request.script);\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * The JsonP proxy is useful when you need to load data from a domain other than the one your application is running on. If\n * your application is running on http://domainA.com it cannot use {@link Ext.data.proxy.Ajax Ajax} to load its data\n * from http://domainB.com because cross-domain ajax requests are prohibited by the browser.\n *\n * We can get around this using a JsonP proxy. JsonP proxy injects a `<script>` tag into the DOM whenever an AJAX request\n * would usually be made. Let's say we want to load data from http://domainB.com/users - the script tag that would be\n * injected might look like this:\n *\n *     <script src=\"http://domainB.com/users?callback=someCallback\"></script>\n *\n * When we inject the tag above, the browser makes a request to that url and includes the response as if it was any\n * other type of JavaScript include. By passing a callback in the url above, we're telling domainB's server that we want\n * to be notified when the result comes in and that it should call our callback function with the data it sends back. So\n * long as the server formats the response to look like this, everything will work:\n *\n *     someCallback({\n *         users: [\n *             {\n *                 id: 1,\n *                 name: \"Ed Spencer\",\n *                 email: \"ed@sencha.com\"\n *             }\n *         ]\n *     });\n *\n * As soon as the script finishes loading, the 'someCallback' function that we passed in the url is called with the JSON\n * object that the server returned.\n *\n * JsonP proxy takes care of all of this automatically. It formats the url you pass, adding the callback parameter\n * automatically. It even creates a temporary callback function, waits for it to be called and then puts the data into\n * the Proxy making it look just like you loaded it through a normal {@link Ext.data.proxy.Ajax AjaxProxy}. Here's how\n * we might set that up:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'name', 'email']\n *     });\n *\n *     var store = Ext.create('Ext.data.Store', {\n *         model: 'User',\n *         proxy: {\n *             type: 'jsonp',\n *             url : 'http://domainB.com/users'\n *         }\n *     });\n *\n *     store.load();\n *\n * That's all we need to do - JsonP proxy takes care of the rest. In this case the Proxy will have injected a script tag\n * like this:\n *\n *     <script src=\"http://domainB.com/users?callback=callback1\"></script>\n *\n * # Customization\n *\n * This script tag can be customized using the {@link #callbackKey} configuration. For example:\n *\n *     var store = Ext.create('Ext.data.Store', {\n *         model: 'User',\n *         proxy: {\n *             type: 'jsonp',\n *             url : 'http://domainB.com/users',\n *             callbackKey: 'theCallbackFunction'\n *         }\n *     });\n *\n *     store.load();\n *\n * Would inject a script tag like this:\n *\n *     <script src=\"http://domainB.com/users?theCallbackFunction=callback1\"></script>\n *\n * # Implementing on the server side\n *\n * The remote server side needs to be configured to return data in this format. Here are suggestions for how you might\n * achieve this using Java, PHP and ASP.net:\n *\n * Java:\n *\n *     boolean jsonP = false;\n *     String cb = request.getParameter(\"callback\");\n *     if (cb != null) {\n *         jsonP = true;\n *         response.setContentType(\"text/javascript\");\n *     } else {\n *         response.setContentType(\"application/x-json\");\n *     }\n *     Writer out = response.getWriter();\n *     if (jsonP) {\n *         out.write(cb + \"(\");\n *     }\n *     out.print(dataBlock.toJsonString());\n *     if (jsonP) {\n *         out.write(\");\");\n *     }\n *\n * PHP:\n *\n *     $callback = $_REQUEST['callback'];\n *\n *     // Create the output object.\n *     $output = array('a' => 'Apple', 'b' => 'Banana');\n *\n *     //start output\n *     if ($callback) {\n *         header('Content-Type: text/javascript');\n *         echo $callback . '(' . json_encode($output) . ');';\n *     } else {\n *         header('Content-Type: application/x-json');\n *         echo json_encode($output);\n *     }\n *\n * ASP.net:\n *\n *     String jsonString = \"{success: true}\";\n *     String cb = Request.Params.Get(\"callback\");\n *     String responseString = \"\";\n *     if (!String.IsNullOrEmpty(cb)) {\n *         responseString = cb + \"(\" + jsonString + \")\";\n *     } else {\n *         responseString = jsonString;\n *     }\n *     Response.Write(responseString);\n */\nExt.define('Ext.data.proxy.JsonP', {\n    extend: 'Ext.data.proxy.Server',\n    alternateClassName: 'Ext.data.ScriptTagProxy',\n    alias: ['proxy.jsonp', 'proxy.scripttag'],\n    requires: ['Ext.data.JsonP'],\n\n    defaultWriterType: 'base',\n\n    /**\n     * @cfg {String} callbackKey\n     * See {@link Ext.data.JsonP#callbackKey}.\n     */\n    callbackKey : 'callback',\n\n    /**\n     * @cfg {String} recordParam\n     * The param name to use when passing records to the server (e.g. 'records=someEncodedRecordString'). Defaults to\n     * 'records'\n     */\n    recordParam: 'records',\n\n    /**\n     * @cfg {Boolean} autoAppendParams\n     * True to automatically append the request's params to the generated url. Defaults to true\n     */\n    autoAppendParams: true,\n\n    constructor: function(){\n        this.addEvents(\n            /**\n             * @event\n             * Fires when the server returns an exception\n             * @param {Ext.data.proxy.Proxy} this\n             * @param {Ext.data.Request} request The request that was sent\n             * @param {Ext.data.Operation} operation The operation that triggered the request\n             */\n            'exception'\n        );\n        this.callParent(arguments);\n    },\n\n    /**\n     * @private\n     * Performs the read request to the remote domain. JsonP proxy does not actually create an Ajax request,\n     * instead we write out a `<script>` tag based on the configuration of the internal Ext.data.Request object\n     * @param {Ext.data.Operation} operation The {@link Ext.data.Operation Operation} object to execute\n     * @param {Function} callback A callback function to execute when the Operation has been completed\n     * @param {Object} scope The scope to execute the callback in\n     */\n    doRequest: function(operation, callback, scope) {\n        //generate the unique IDs for this request\n        var me      = this,\n            writer  = me.getWriter(),\n            request = me.buildRequest(operation),\n            params = request.params;\n\n        if (operation.allowWrite()) {\n            request = writer.write(request);\n        }\n\n        // apply JsonP proxy-specific attributes to the Request\n        Ext.apply(request, {\n            callbackKey: me.callbackKey,\n            timeout: me.timeout,\n            scope: me,\n            disableCaching: false, // handled by the proxy\n            callback: me.createRequestCallback(request, operation, callback, scope)\n        });\n\n        // prevent doubling up\n        if (me.autoAppendParams) {\n            request.params = {};\n        }\n\n        request.jsonp = Ext.data.JsonP.request(request);\n        // restore on the request\n        request.params = params;\n        operation.setStarted();\n        me.lastRequest = request;\n\n        return request;\n    },\n\n    /**\n     * @private\n     * Creates and returns the function that is called when the request has completed. The returned function\n     * should accept a Response object, which contains the response to be read by the configured Reader.\n     * The third argument is the callback that should be called after the request has been completed and the Reader has decoded\n     * the response. This callback will typically be the callback passed by a store, e.g. in proxy.read(operation, theCallback, scope)\n     * theCallback refers to the callback argument received by this function.\n     * See {@link #doRequest} for details.\n     * @param {Ext.data.Request} request The Request object\n     * @param {Ext.data.Operation} operation The Operation being executed\n     * @param {Function} callback The callback function to be called when the request completes. This is usually the callback\n     * passed to doRequest\n     * @param {Object} scope The scope in which to execute the callback function\n     * @return {Function} The callback function\n     */\n    createRequestCallback: function(request, operation, callback, scope) {\n        var me = this;\n\n        return function(success, response, errorType) {\n            delete me.lastRequest;\n            me.processResponse(success, operation, request, response, callback, scope);\n        };\n    },\n\n    // inherit docs\n    setException: function(operation, response) {\n        operation.setException(operation.request.jsonp.errorType);\n    },\n\n\n    /**\n     * Generates a url based on a given Ext.data.Request object. Adds the params and callback function name to the url\n     * @param {Ext.data.Request} request The request object\n     * @return {String} The url\n     */\n    buildUrl: function(request) {\n        var me      = this,\n            url     = me.callParent(arguments),\n            params  = Ext.apply({}, request.params),\n            filters = params.filters,\n            records,\n            filter, i;\n\n        delete params.filters;\n\n        if (me.autoAppendParams) {\n            url = Ext.urlAppend(url, Ext.Object.toQueryString(params));\n        }\n\n        if (filters && filters.length) {\n            for (i = 0; i < filters.length; i++) {\n                filter = filters[i];\n\n                if (filter.value) {\n                    url = Ext.urlAppend(url, filter.property + \"=\" + filter.value);\n                }\n            }\n        }\n\n        //if there are any records present, append them to the url also\n        records = request.records;\n\n        if (Ext.isArray(records) && records.length > 0) {\n            url = Ext.urlAppend(url, Ext.String.format(\"{0}={1}\", me.recordParam, me.encodeRecords(records)));\n        }\n\n        return url;\n    },\n\n    //inherit docs\n    destroy: function() {\n        this.abort();\n        this.callParent(arguments);\n    },\n\n    /**\n     * Aborts the current server request if one is currently running\n     */\n    abort: function() {\n        var lastRequest = this.lastRequest;\n        if (lastRequest) {\n            Ext.data.JsonP.abort(lastRequest.jsonp);\n        }\n    },\n\n    /**\n     * Encodes an array of records into a string suitable to be appended to the script src url. This is broken out into\n     * its own function so that it can be easily overridden.\n     * @param {Ext.data.Model[]} records The records array\n     * @return {String} The encoded records string\n     */\n    encodeRecords: function(records) {\n        var encoded = \"\",\n            i = 0,\n            len = records.length;\n\n        for (; i < len; i++) {\n            encoded += Ext.Object.toQueryString(records[i].getData());\n        }\n\n        return encoded;\n    }\n});\n\n/**\n * @class Ext.data.JsonPStore\n * @extends Ext.data.Store\n * <p>Small helper class to make creating {@link Ext.data.Store}s from different domain JSON data easier.\n * A JsonPStore will be automatically configured with a {@link Ext.data.reader.Json} and a {@link Ext.data.proxy.JsonP JsonPProxy}.</p>\n * <p>A store configuration would be something like:<pre><code>\nvar store = new Ext.data.JsonPStore({\n    // store configs\n    storeId: 'myStore',\n\n    // proxy configs\n    url: 'get-images.php',\n\n    // reader configs\n    root: 'images',\n    idProperty: 'name',\n    fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]\n});\n * </code></pre></p>\n * <p>This store is configured to consume a returned object of the form:<pre><code>\nstcCallback({\n    images: [\n        {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},\n        {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}\n    ]\n})\n * </code></pre>\n * <p>Where stcCallback is the callback name passed in the request to the remote domain. See {@link Ext.data.proxy.JsonP JsonPProxy}\n * for details of how this works.</p>\n * An object literal of this form could also be used as the {@link #cfg-data} config option.</p>\n * @xtype jsonpstore\n */\nExt.define('Ext.data.JsonPStore', {\n    extend: 'Ext.data.Store',\n    alias : 'store.jsonp',\n    requires: [\n        'Ext.data.proxy.JsonP',\n        'Ext.data.reader.Json'\n    ],\n\n    constructor: function(config) {\n        config = Ext.apply({\n            proxy: {\n                type: 'jsonp',\n                reader: 'json'\n            }\n        }, config);\n        this.callParent([config]);\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * <p>Small helper class to make creating {@link Ext.data.Store}s from JSON data easier.\n * A JsonStore will be automatically configured with a {@link Ext.data.reader.Json}.</p>\n *\n * <p>A store configuration would be something like:</p>\n *\n<pre><code>\nvar store = new Ext.data.JsonStore({\n    // store configs\n    storeId: 'myStore',\n\n    proxy: {\n        type: 'ajax',\n        url: 'get-images.php',\n        reader: {\n            type: 'json',\n            root: 'images',\n            idProperty: 'name'\n        }\n    },\n\n    //alternatively, a {@link Ext.data.Model} name can be given (see {@link Ext.data.Store} for an example)\n    fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]\n});\n</code></pre>\n *\n * <p>This store is configured to consume a returned object of the form:<pre><code>\n{\n    images: [\n        {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},\n        {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}\n    ]\n}\n</code></pre>\n *\n * <p>An object literal of this form could also be used as the {@link #cfg-data} config option.</p>\n */\nExt.define('Ext.data.JsonStore',  {\n    extend: 'Ext.data.Store',\n    alias: 'store.json',\n    requires: [\n        'Ext.data.proxy.Ajax',\n        'Ext.data.reader.Json',\n        'Ext.data.writer.Json'\n    ],\n\n    constructor: function(config) {\n        config = Ext.apply({\n            proxy: {\n                type  : 'ajax',\n                reader: 'json',\n                writer: 'json'\n            }\n        }, config);\n        this.callParent([config]);\n    }\n});\n\n/**\n * This class is used as a set of methods that are applied to the prototype of a\n * Model to decorate it with a Node API. This means that models used in conjunction with a tree\n * will have all of the tree related methods available on the model. In general this class will\n * not be used directly by the developer. This class also creates extra fields on the model if\n * they do not exist, to help maintain the tree state and UI. These fields are documented as\n * config options.\n */\nExt.define('Ext.data.NodeInterface', {\n    requires: ['Ext.data.Field'],\n\n    /**\n     * @cfg {String} parentId\n     * ID of parent node.\n     */\n\n    /**\n     * @cfg {Number} index\n     * The position of the node inside its parent. When parent has 4 children and the node is third amongst them,\n     * index will be 2.\n     */\n\n    /**\n     * @cfg {Number} depth\n     * The number of parents this node has. A root node has depth 0, a child of it depth 1, and so on...\n     */\n\n    /**\n     * @cfg {Boolean} [expanded=false]\n     * True if the node is expanded.\n     */\n\n    /**\n     * @cfg {Boolean} [expandable=false]\n     * Set to true to allow for expanding/collapsing of this node.\n     */\n\n    /**\n     * @cfg {Boolean} [checked=null]\n     * Set to true or false to show a checkbox alongside this node.\n     */\n\n    /**\n     * @cfg {Boolean} [leaf=false]\n     * Set to true to indicate that this child can have no children. The expand icon/arrow will then not be\n     * rendered for this node.\n     */\n\n    /**\n     * @cfg {String} cls\n     * CSS class to apply for this node.\n     */\n\n    /**\n     * @cfg {String} iconCls\n     * CSS class to apply for this node's icon.\n     */\n\n    /**\n     * @cfg {String} icon\n     * URL for this node's icon.\n     */\n\n    /**\n     * @cfg {Boolean} root\n     * True if this is the root node.\n     */\n\n    /**\n     * @cfg {Boolean} isLast\n     * True if this is the last node.\n     */\n\n    /**\n     * @cfg {Boolean} isFirst\n     * True if this is the first node.\n     */\n\n    /**\n     * @cfg {Boolean} [allowDrop=true]\n     * Set to false to deny dropping on this node.\n     */\n\n    /**\n     * @cfg {Boolean} [allowDrag=true]\n     * Set to false to deny dragging of this node.\n     */\n\n    /**\n     * @cfg {Boolean} [loaded=false]\n     * True if the node has finished loading.\n     */\n\n    /**\n     * @cfg {Boolean} [loading=false]\n     * True if the node is currently loading.\n     */\n\n    /**\n     * @cfg {String} href\n     * An URL for a link that's created when this config is specified.\n     */\n\n    /**\n     * @cfg {String} hrefTarget\n     * Target for link. Only applicable when {@link #href} also specified.\n     */\n\n    /**\n     * @cfg {String} qtip\n     * Tooltip text to show on this node.\n     */\n\n    /**\n     * @cfg {String} qtitle\n     * Tooltip title.\n     */\n\n    /**\n     * @cfg {String} text\n     * The text for to show on node label.\n     */\n\n    /**\n     * @cfg {Ext.data.NodeInterface[]} children\n     * Array of child nodes.\n     */\n\n\n    /**\n     * @property nextSibling\n     * A reference to this node's next sibling node. `null` if this node does not have a next sibling.\n     */\n\n    /**\n     * @property previousSibling\n     * A reference to this node's previous sibling node. `null` if this node does not have a previous sibling.\n     */\n\n    /**\n     * @property parentNode\n     * A reference to this node's parent node. `null` if this node is the root node.\n     */\n\n    /**\n     * @property lastChild\n     * A reference to this node's last child node. `null` if this node has no children.\n     */\n\n    /**\n     * @property firstChild\n     * A reference to this node's first child node. `null` if this node has no children.\n     */\n\n    /**\n     * @property childNodes\n     * An array of this nodes children.  Array will be empty if this node has no chidren.\n     */\n\n    statics: {\n        /**\n         * This method allows you to decorate a Model's class to implement the NodeInterface.\n         * This adds a set of methods, new events, new properties and new fields on every Record.\n         * @param {Ext.Class/Ext.data.Model} modelClass The Model class or an instance of the Model class you want to\n         * decorate the prototype of.\n         * @static\n         */\n        decorate: function(modelClass) {\n            var idName, idType;\n            \n            // get the reference to the model class, in case the argument was a string or a record\n            if (typeof modelClass == 'string') {\n                modelClass = Ext.ModelManager.getModel(modelClass);\n            } else if (modelClass.isModel) {\n                modelClass = Ext.ModelManager.getModel(modelClass.modelName);\n            }\n            \n            // avoid unnecessary work in case the model was already decorated\n            if (modelClass.prototype.isNode) {\n                return;\n            }\n\n            idName = modelClass.prototype.idProperty;\n            idField = modelClass.prototype.fields.get(idName);\n            idType = modelClass.prototype.fields.get(idName).type.type;\n            modelClass.override(this.getPrototypeBody());\n            this.applyFields(modelClass, [\n                {name: 'parentId',   type: idType,    defaultValue: null, useNull: idField.useNull},\n                {name: 'index',      type: 'int',     defaultValue: null, persist: false},\n                {name: 'depth',      type: 'int',     defaultValue: 0, persist: false},\n                {name: 'expanded',   type: 'bool',    defaultValue: false, persist: false},\n                {name: 'expandable', type: 'bool',    defaultValue: true, persist: false},\n                {name: 'checked',    type: 'auto',    defaultValue: null, persist: false},\n                {name: 'leaf',       type: 'bool',    defaultValue: false},\n                {name: 'cls',        type: 'string',  defaultValue: null, persist: false},\n                {name: 'iconCls',    type: 'string',  defaultValue: null, persist: false},\n                {name: 'icon',       type: 'string',  defaultValue: null, persist: false},\n                {name: 'root',       type: 'boolean', defaultValue: false, persist: false},\n                {name: 'isLast',     type: 'boolean', defaultValue: false, persist: false},\n                {name: 'isFirst',    type: 'boolean', defaultValue: false, persist: false},\n                {name: 'allowDrop',  type: 'boolean', defaultValue: true, persist: false},\n                {name: 'allowDrag',  type: 'boolean', defaultValue: true, persist: false},\n                {name: 'loaded',     type: 'boolean', defaultValue: false, persist: false},\n                {name: 'loading',    type: 'boolean', defaultValue: false, persist: false},\n                {name: 'href',       type: 'string',  defaultValue: null, persist: false},\n                {name: 'hrefTarget', type: 'string',  defaultValue: null, persist: false},\n                {name: 'qtip',       type: 'string',  defaultValue: null, persist: false},\n                {name: 'qtitle',     type: 'string',  defaultValue: null, persist: false},\n                {name: 'children',   type: 'auto',   defaultValue: null, persist: false}\n            ]);\n        },\n        \n        applyFields: function(modelClass, addFields) {\n            var modelPrototype = modelClass.prototype,\n                fields = modelPrototype.fields,\n                keys = fields.keys,\n                ln = addFields.length,\n                addField, i;\n\n            for (i = 0; i < ln; i++) {\n                addField = addFields[i];\n                if (!Ext.Array.contains(keys, addField.name)) {\n                    fields.add(new Ext.data.Field(addField));\n                }\n            }\n\n        },\n\n        getPrototypeBody: function() {\n            return {\n                /**\n                 * @property {Boolean} isNode\n                 * `true` in this class to identify an object as an instantiated Node, or subclass thereof.\n                 */\n                isNode: true,\n                \n                constructor: function() {\n                    var me = this;\n                    this.callParent(arguments);\n                    Ext.applyIf(me, {\n                        firstChild: null,\n                        lastChild: null,\n                        parentNode: null,\n                        previousSibling: null,\n                        nextSibling: null,\n                        childNodes: []\n                    });\n                    me.enableBubble([\n                        /**\n                         * @event append\n                         * Fires when a new child node is appended\n                         * @param {Ext.data.NodeInterface} this This node\n                         * @param {Ext.data.NodeInterface} node The newly appended node\n                         * @param {Number} index The index of the newly appended node\n                         */\n                        \"append\",\n\n                        /**\n                         * @event remove\n                         * Fires when a child node is removed\n                         * @param {Ext.data.NodeInterface} this This node\n                         * @param {Ext.data.NodeInterface} node The removed node\n                         * @param {Boolean} isMove `true` if the child node is being removed so it can be moved to another position in the tree.\n                         * (a side effect of calling {@link Ext.data.NodeInterface#appendChild appendChild} or\n                         * {@link Ext.data.NodeInterface#insertBefore insertBefore} with a node that already has a parentNode)\n                         */\n                        \"remove\",\n\n                        /**\n                         * @event move\n                         * Fires when this node is moved to a new location in the tree\n                         * @param {Ext.data.NodeInterface} this This node\n                         * @param {Ext.data.NodeInterface} oldParent The old parent of this node\n                         * @param {Ext.data.NodeInterface} newParent The new parent of this node\n                         * @param {Number} index The index it was moved to\n                         */\n                        \"move\",\n\n                        /**\n                         * @event insert\n                         * Fires when a new child node is inserted.\n                         * @param {Ext.data.NodeInterface} this This node\n                         * @param {Ext.data.NodeInterface} node The child node inserted\n                         * @param {Ext.data.NodeInterface} refNode The child node the node was inserted before\n                         */\n                        \"insert\",\n\n                        /**\n                         * @event beforeappend\n                         * Fires before a new child is appended, return false to cancel the append.\n                         * @param {Ext.data.NodeInterface} this This node\n                         * @param {Ext.data.NodeInterface} node The child node to be appended\n                         */\n                        \"beforeappend\",\n\n                        /**\n                         * @event beforeremove\n                         * Fires before a child is removed, return false to cancel the remove.\n                         * @param {Ext.data.NodeInterface} this This node\n                         * @param {Ext.data.NodeInterface} node The child node to be removed\n                         * @param {Boolean} isMove `true` if the child node is being removed so it can be moved to another position in the tree.\n                         * (a side effect of calling {@link Ext.data.NodeInterface#appendChild appendChild} or\n                         * {@link Ext.data.NodeInterface#insertBefore insertBefore} with a node that already has a parentNode)\n                         */\n                        \"beforeremove\",\n\n                        /**\n                         * @event beforemove\n                         * Fires before this node is moved to a new location in the tree. Return false to cancel the move.\n                         * @param {Ext.data.NodeInterface} this This node\n                         * @param {Ext.data.NodeInterface} oldParent The parent of this node\n                         * @param {Ext.data.NodeInterface} newParent The new parent this node is moving to\n                         * @param {Number} index The index it is being moved to\n                         */\n                        \"beforemove\",\n\n                         /**\n                          * @event beforeinsert\n                          * Fires before a new child is inserted, return false to cancel the insert.\n                          * @param {Ext.data.NodeInterface} this This node\n                          * @param {Ext.data.NodeInterface} node The child node to be inserted\n                          * @param {Ext.data.NodeInterface} refNode The child node the node is being inserted before\n                          */\n                        \"beforeinsert\",\n\n                        /**\n                         * @event expand\n                         * Fires when this node is expanded.\n                         * @param {Ext.data.NodeInterface} this The expanding node\n                         */\n                        \"expand\",\n\n                        /**\n                         * @event collapse\n                         * Fires when this node is collapsed.\n                         * @param {Ext.data.NodeInterface} this The collapsing node\n                         */\n                        \"collapse\",\n\n                        /**\n                         * @event beforeexpand\n                         * Fires before this node is expanded.\n                         * @param {Ext.data.NodeInterface} this The expanding node\n                         */\n                        \"beforeexpand\",\n\n                        /**\n                         * @event beforecollapse\n                         * Fires before this node is collapsed.\n                         * @param {Ext.data.NodeInterface} this The collapsing node\n                         */\n                        \"beforecollapse\",\n\n                        /**\n                         * @event sort\n                         * Fires when this node's childNodes are sorted.\n                         * @param {Ext.data.NodeInterface} this This node.\n                         * @param {Ext.data.NodeInterface[]} childNodes The childNodes of this node.\n                         */\n                        \"sort\"\n                    ]);\n                    return me;\n                },\n                /**\n                 * Ensures that the passed object is an instance of a Record with the NodeInterface applied\n                 * @return {Ext.data.NodeInterface}\n                 */\n                createNode: function(node) {\n                    if (Ext.isObject(node) && !node.isModel) {\n                        node = Ext.ModelManager.create(node, this.modelName);\n                    }\n                    // The node may already decorated, but may not have been\n                    // so when the model constructor was called. If not,\n                    // setup defaults here\n                    if (!node.childNodes) {\n                        Ext.applyIf(node, {\n                            firstChild: null,\n                            lastChild: null,\n                            parentNode: null,\n                            previousSibling: null,\n                            nextSibling: null,\n                            childNodes: []\n                        });\n                    }\n                    return node;\n                },\n\n                /**\n                 * Returns true if this node is a leaf\n                 * @return {Boolean}\n                 */\n                isLeaf : function() {\n                    return this.get('leaf') === true;\n                },\n\n                /**\n                 * Sets the first child of this node\n                 * @private\n                 * @param {Ext.data.NodeInterface} node\n                 */\n                setFirstChild : function(node) {\n                    this.firstChild = node;\n                },\n\n                /**\n                 * Sets the last child of this node\n                 * @private\n                 * @param {Ext.data.NodeInterface} node\n                 */\n                setLastChild : function(node) {\n                    this.lastChild = node;\n                },\n\n                /**\n                 * Updates general data of this node like isFirst, isLast, depth. This\n                 * method is internally called after a node is moved. This shouldn't\n                 * have to be called by the developer unless they are creating custom\n                 * Tree plugins.\n                 * @return {Boolean}\n                 */\n                updateInfo: function(commit) {\n                    var me = this,\n                        isRoot = me.isRoot(),\n                        parentNode = me.parentNode,\n                        isFirst = (!parentNode || isRoot ? true : parentNode.firstChild === me),\n                        isLast = (!parentNode || isRoot ? true : parentNode.lastChild === me),\n                        depth = 0,\n                        parent = me,\n                        children = me.childNodes,\n                        len = children.length,\n                        i = 0,\n                        phantom = me.phantom;\n\n                    while (parent.parentNode) {\n                        ++depth;\n                        parent = parent.parentNode;\n                    }\n\n                    me.beginEdit();\n                    me.set({\n                        isFirst: isFirst,\n                        isLast: isLast,\n                        depth: depth,\n                        index: parentNode ? parentNode.indexOf(me) : 0,\n                        parentId: parentNode ? parentNode.getId() : null\n                    });\n                    me.endEdit(true);\n                    if (commit) {\n                        me.commit();\n                        me.phantom = phantom;\n                    }\n\n                    for (i = 0; i < len; i++) {\n                        children[i].updateInfo(commit);\n                    }\n                },\n\n                /**\n                 * Returns true if this node is the last child of its parent\n                 * @return {Boolean}\n                 */\n                isLast : function() {\n                   return this.get('isLast');\n                },\n\n                /**\n                 * Returns true if this node is the first child of its parent\n                 * @return {Boolean}\n                 */\n                isFirst : function() {\n                   return this.get('isFirst');\n                },\n\n                /**\n                 * Returns true if this node has one or more child nodes, else false.\n                 * @return {Boolean}\n                 */\n                hasChildNodes : function() {\n                    return !this.isLeaf() && this.childNodes.length > 0;\n                },\n\n                /**\n                 * Returns true if this node has one or more child nodes, or if the <tt>expandable</tt>\n                 * node attribute is explicitly specified as true, otherwise returns false.\n                 * @return {Boolean}\n                 */\n                isExpandable : function() {\n                    var me = this;\n\n                    if (me.get('expandable')) {\n                        return !(me.isLeaf() || (me.isLoaded() && !me.hasChildNodes()));\n                    }\n                    return false;\n                },\n                \n                triggerUIUpdate: function(){\n                    // This isn't ideal, however none of the underlying fields have changed\n                    // but we still need to update the UI\n                    this.afterEdit([]);    \n                },\n\n                /**\n                 * Inserts node(s) as the last child node of this node.\n                 *\n                 * If the node was previously a child node of another parent node, it will be removed from that node first.\n                 *\n                 * @param {Ext.data.NodeInterface/Ext.data.NodeInterface[]} node The node or Array of nodes to append\n                 * @return {Ext.data.NodeInterface} The appended node if single append, or null if an array was passed\n                 */\n                appendChild : function(node, suppressEvents, commit) {\n                    var me = this,\n                        i, ln,\n                        index,\n                        oldParent,\n                        ps;\n\n                    // if passed an array do them one by one\n                    if (Ext.isArray(node)) {\n                        // suspend auto syncing while we append all the nodes\n                        me.callStore('suspendAutoSync');\n                        for (i = 0, ln = node.length - 1; i < ln; i++) {\n                            me.appendChild(node[i]);\n                        }\n                        // resume auto syncing before we append the last node\n                        me.callStore('resumeAutoSync');\n                        me.appendChild(node[ln]);\n                    } else {\n                        // Make sure it is a record\n                        node = me.createNode(node);\n\n                        if (suppressEvents !== true && (!me.hasListeners.beforeappend || me.fireEvent(\"beforeappend\", me, node) === false)) {\n                            return false;\n                        }\n\n                        index = me.childNodes.length;\n                        oldParent = node.parentNode;\n\n                        // it's a move, make sure we move it cleanly\n                        if (oldParent) {\n                            if (suppressEvents !== true && (!me.hasListeners.beforeremove || node.fireEvent(\"beforemove\", node, oldParent, me, index) === false)) {\n                                return false;\n                            }\n                            oldParent.removeChild(node, false, false, true);\n                        }\n\n                        index = me.childNodes.length;\n                        if (index === 0) {\n                            me.setFirstChild(node);\n                        }\n\n                        me.childNodes.push(node);\n                        node.parentNode = me;\n                        node.nextSibling = null;\n\n                        me.setLastChild(node);\n\n                        ps = me.childNodes[index - 1];\n                        if (ps) {\n                            node.previousSibling = ps;\n                            ps.nextSibling = node;\n                            ps.updateInfo(commit);\n                        } else {\n                            node.previousSibling = null;\n                        }\n\n                        node.updateInfo(commit);\n\n                        // As soon as we append a child to this node, we are loaded\n                        if (!me.isLoaded()) {\n                            me.set('loaded', true);\n                        } else if (me.childNodes.length === 1) {\n                            me.triggerUIUpdate();\n                        }\n\n                        if(!node.isLeaf() && node.phantom) {\n                            node.set('loaded', true);\n                        }\n\n                        if (suppressEvents !== true) {\n                            me.fireEvent(\"append\", me, node, index);\n\n                            if (oldParent) {\n                                node.fireEvent(\"move\", node, oldParent, me, index);\n                            }\n                        }\n\n                        return node;\n                    }\n                },\n\n                /**\n                 * Returns the bubble target for this node\n                 * @private\n                 * @return {Object} The bubble target\n                 */\n                getBubbleTarget: function() {\n                    return this.parentNode;\n                },\n\n                /**\n                 * Removes a child node from this node.\n                 * @param {Ext.data.NodeInterface} node The node to remove\n                 * @param {Boolean} [destroy=false] True to destroy the node upon removal.\n                 * @return {Ext.data.NodeInterface} The removed node\n                 */\n                removeChild : function(node, destroy, suppressEvents, isMove) {\n                    var me = this,\n                        index = me.indexOf(node),\n                        i, childCount;\n\n                    if (index == -1 || (suppressEvents !== true && (!me.hasListeners.beforeremove || me.fireEvent(\"beforeremove\", me, node, !!isMove) === false))) {\n                        return false;\n                    }\n\n                    // remove it from childNodes collection\n                    Ext.Array.erase(me.childNodes, index, 1);\n\n                    // update child refs\n                    if (me.firstChild == node) {\n                        me.setFirstChild(node.nextSibling);\n                    }\n                    if (me.lastChild == node) {\n                        me.setLastChild(node.previousSibling);\n                    }\n\n                    // update siblings\n                    if (node.previousSibling) {\n                        node.previousSibling.nextSibling = node.nextSibling;\n                    }\n                    if (node.nextSibling) {\n                        node.nextSibling.previousSibling = node.previousSibling;\n                    }\n\n                    // update the info for all siblings starting at the index before the node's old index (or 0 if the removed node was the firstChild)\n                    for(i = index > 0 ? index - 1 : 0, childCount = me.childNodes.length; i < childCount; i++) {\n                        me.childNodes[i].updateInfo();\n                    }\n\n                    // If this node suddenly doesnt have childnodes anymore, update myself\n                    if (!me.childNodes.length) {\n                        me.triggerUIUpdate();\n                    }\n\n                    if (suppressEvents !== true) {\n                        if (me.hasListeners.remove) {\n                            me.fireEvent(\"remove\", me, node, !!isMove);\n                        }\n                    }\n\n                    if (destroy) {\n                        node.destroy(true);\n                    } else {\n                        node.clear();\n                    }\n\n                    return node;\n                },\n\n                /**\n                 * Creates a copy (clone) of this Node.\n                 * @param {String} [id] A new id, defaults to this Node's id.\n                 * @param {Boolean} [deep=false] True to recursively copy all child Nodes into the new Node.\n                 * False to copy without child Nodes.\n                 * @return {Ext.data.NodeInterface} A copy of this Node.\n                 */\n                copy: function(newId, deep) {\n                    var me = this,\n                        result = me.callOverridden(arguments),\n                        len = me.childNodes ? me.childNodes.length : 0,\n                        i;\n\n                    // Move child nodes across to the copy if required\n                    if (deep) {\n                        for (i = 0; i < len; i++) {\n                            result.appendChild(me.childNodes[i].copy(true));\n                        }\n                    }\n                    return result;\n                },\n\n                /**\n                 * Clears the node.\n                 * @private\n                 * @param {Boolean} [destroy=false] True to destroy the node.\n                 */\n                clear : function(destroy) {\n                    var me = this;\n\n                    // clear any references from the node\n                    me.parentNode = me.previousSibling = me.nextSibling = null;\n                    if (destroy) {\n                        me.firstChild = me.lastChild = null;\n                    }\n                },\n\n                /**\n                 * Destroys the node.\n                 */\n                destroy : function(silent) {\n                    /*\n                     * Silent is to be used in a number of cases\n                     * 1) When setRoot is called.\n                     * 2) When destroy on the tree is called\n                     * 3) For destroying child nodes on a node\n                     */\n                    var me      = this,\n                        options = me.destroyOptions,\n                        nodes   = me.childNodes,\n                        nLen    = nodes.length,\n                        n;\n\n                    if (silent === true) {\n                        me.clear(true);\n\n                        for (n = 0; n < nLen; n++) {\n                            nodes[n].destroy(true);\n                        }\n\n                        me.childNodes = null;\n                        delete me.destroyOptions;\n                        me.callOverridden([options]);\n                    } else {\n                        me.destroyOptions = silent;\n                        // overridden method will be called, since remove will end up calling destroy(true);\n                        me.remove(true);\n                    }\n                },\n\n                /**\n                 * Inserts the first node before the second node in this nodes childNodes collection.\n                 * @param {Ext.data.NodeInterface} node The node to insert\n                 * @param {Ext.data.NodeInterface} refNode The node to insert before (if null the node is appended)\n                 * @return {Ext.data.NodeInterface} The inserted node\n                 */\n                insertBefore : function(node, refNode, suppressEvents) {\n                    var me = this,\n                        index     = me.indexOf(refNode),\n                        oldParent = node.parentNode,\n                        refIndex  = index,\n                        childCount, ps, i;\n\n                    if (!refNode) { // like standard Dom, refNode can be null for append\n                        return me.appendChild(node);\n                    }\n\n                    // nothing to do\n                    if (node == refNode) {\n                        return false;\n                    }\n\n                    // Make sure it is a record with the NodeInterface\n                    node = me.createNode(node);\n\n                    if (suppressEvents !== true && (!me.hasListeners.beforeinsert || me.fireEvent(\"beforeinsert\", me, node, refNode) === false)) {\n                        return false;\n                    }\n\n                    // when moving internally, indexes will change after remove\n                    if (oldParent == me && me.indexOf(node) < index) {\n                        refIndex--;\n                    }\n\n                    // it's a move, make sure we move it cleanly\n                    if (oldParent) {\n                        if (suppressEvents !== true && (!me.hasListeners.beforeremove || node.fireEvent(\"beforemove\", node, oldParent, me, index, refNode) === false)) {\n                            return false;\n                        }\n                        oldParent.removeChild(node, false, false, true);\n                    }\n\n                    if (refIndex === 0) {\n                        me.setFirstChild(node);\n                    }\n\n                    Ext.Array.splice(me.childNodes, refIndex, 0, node);\n                    node.parentNode = me;\n\n                    node.nextSibling = refNode;\n                    refNode.previousSibling = node;\n\n                    ps = me.childNodes[refIndex - 1];\n                    if (ps) {\n                        node.previousSibling = ps;\n                        ps.nextSibling = node;\n                    } else {\n                        node.previousSibling = null;\n                    }\n\n                    // update the info for all siblings starting at the index before the node's insertion point (or 0 if the inserted node is the firstChild)\n                    for(i = refIndex > 0 ? refIndex - 1 : 0, childCount = me.childNodes.length; i < childCount; i++) {\n                        me.childNodes[i].updateInfo();\n                    }\n\n                    if (!me.isLoaded()) {\n                        me.set('loaded', true);\n                    }\n                    // If this node didnt have any childnodes before, update myself\n                    else if (me.childNodes.length === 1) {\n                        me.triggerUIUpdate();\n                    }\n\n                    if(!node.isLeaf() && node.phantom) {\n                        node.set('loaded', true);\n                    }\n\n                    if (suppressEvents !== true) {\n                        if (me.hasListeners.insert) {\n                            me.fireEvent(\"insert\", me, node, refNode);\n                        }\n\n                        if (oldParent && me.hasListeners.move) {\n                            node.fireEvent(\"move\", node, oldParent, me, refIndex, refNode);\n                        }\n                    }\n\n                    return node;\n                },\n\n                /**\n                 * Inserts a node into this node.\n                 * @param {Number} index The zero-based index to insert the node at\n                 * @param {Ext.data.NodeInterface} node The node to insert\n                 * @return {Ext.data.NodeInterface} The node you just inserted\n                 */\n                insertChild: function(index, node) {\n                    var sibling = this.childNodes[index];\n                    if (sibling) {\n                        return this.insertBefore(node, sibling);\n                    }\n                    else {\n                        return this.appendChild(node);\n                    }\n                },\n\n                /**\n                 * Removes this node from its parent\n                 * @param {Boolean} [destroy=false] True to destroy the node upon removal.\n                 * @return {Ext.data.NodeInterface} this\n                 */\n                remove : function(destroy, suppressEvents) {\n                    var parentNode = this.parentNode;\n\n                    if (parentNode) {\n                        parentNode.removeChild(this, destroy, suppressEvents);\n                    }\n                    return this;\n                },\n\n                /**\n                 * Removes all child nodes from this node.\n                 * @param {Boolean} [destroy=false] <True to destroy the node upon removal.\n                 * @return {Ext.data.NodeInterface} this\n                 */\n                removeAll : function(destroy, suppressEvents) {\n                    var cn = this.childNodes,\n                        n;\n\n                    while ((n = cn[0])) {\n                        this.removeChild(n, destroy, suppressEvents);\n                    }\n                    return this;\n                },\n\n                /**\n                 * Returns the child node at the specified index.\n                 * @param {Number} index\n                 * @return {Ext.data.NodeInterface}\n                 */\n                getChildAt : function(index) {\n                    return this.childNodes[index];\n                },\n\n                /**\n                 * Replaces one child node in this node with another.\n                 * @param {Ext.data.NodeInterface} newChild The replacement node\n                 * @param {Ext.data.NodeInterface} oldChild The node to replace\n                 * @return {Ext.data.NodeInterface} The replaced node\n                 */\n                replaceChild : function(newChild, oldChild, suppressEvents) {\n                    var s = oldChild ? oldChild.nextSibling : null;\n\n                    this.removeChild(oldChild, false, suppressEvents);\n                    this.insertBefore(newChild, s, suppressEvents);\n                    return oldChild;\n                },\n\n                /**\n                 * Returns the index of a child node\n                 * @param {Ext.data.NodeInterface} node\n                 * @return {Number} The index of the node or -1 if it was not found\n                 */\n                indexOf : function(child) {\n                    return Ext.Array.indexOf(this.childNodes, child);\n                },\n                \n                /**\n                 * Returns the index of a child node that matches the id\n                 * @param {String} id The id of the node to find\n                 * @return {Number} The index of the node or -1 if it was not found\n                 */\n                indexOfId: function(id) {\n                    var childNodes = this.childNodes,\n                        len = childNodes.length,\n                        i = 0;\n                        \n                    for (; i < len; ++i) {\n                        if (childNodes[i].getId() === id) {\n                            return i;\n                        }    \n                    }\n                    return -1;\n                },\n\n                /**\n                 * Gets the hierarchical path from the root of the current node.\n                 * @param {String} [field] The field to construct the path from. Defaults to the model idProperty.\n                 * @param {String} [separator=\"/\"] A separator to use.\n                 * @return {String} The node path\n                 */\n                getPath: function(field, separator) {\n                    field = field || this.idProperty;\n                    separator = separator || '/';\n\n                    var path = [this.get(field)],\n                        parent = this.parentNode;\n\n                    while (parent) {\n                        path.unshift(parent.get(field));\n                        parent = parent.parentNode;\n                    }\n                    return separator + path.join(separator);\n                },\n\n                /**\n                 * Returns depth of this node (the root node has a depth of 0)\n                 * @return {Number}\n                 */\n                getDepth : function() {\n                    return this.get('depth');\n                },\n\n                /**\n                 * Bubbles up the tree from this node, calling the specified function with each node. The arguments to the function\n                 * will be the args provided or the current node. If the function returns false at any point,\n                 * the bubble is stopped.\n                 * @param {Function} fn The function to call\n                 * @param {Object} [scope] The scope (this reference) in which the function is executed. Defaults to the current Node.\n                 * @param {Array} [args] The args to call the function with. Defaults to passing the current Node.\n                 */\n                bubble : function(fn, scope, args) {\n                    var p = this;\n                    while (p) {\n                        if (fn.apply(scope || p, args || [p]) === false) {\n                            break;\n                        }\n                        p = p.parentNode;\n                    }\n                },\n\n                cascade: function() {\n                    if (Ext.isDefined(Ext.global.console)) {\n                        Ext.global.console.warn('Ext.data.Node: cascade has been deprecated. Please use cascadeBy instead.');\n                    }\n                    return this.cascadeBy.apply(this, arguments);\n                },\n\n                /**\n                 * Cascades down the tree from this node, calling the specified function with each node. The arguments to the function\n                 * will be the args provided or the current node. If the function returns false at any point,\n                 * the cascade is stopped on that branch.\n                 * @param {Function} fn The function to call\n                 * @param {Object} [scope] The scope (this reference) in which the function is executed. Defaults to the current Node.\n                 * @param {Array} [args] The args to call the function with. Defaults to passing the current Node.\n                 */\n                cascadeBy : function(fn, scope, args) {\n                    if (fn.apply(scope || this, args || [this]) !== false) {\n                        var childNodes = this.childNodes,\n                            length     = childNodes.length,\n                            i;\n\n                        for (i = 0; i < length; i++) {\n                            childNodes[i].cascadeBy(fn, scope, args);\n                        }\n                    }\n                },\n\n                /**\n                 * Interates the child nodes of this node, calling the specified function with each node. The arguments to the function\n                 * will be the args provided or the current node. If the function returns false at any point,\n                 * the iteration stops.\n                 * @param {Function} fn The function to call\n                 * @param {Object} [scope] The scope (this reference) in which the function is executed. Defaults to the current Node in iteration.\n                 * @param {Array} [args] The args to call the function with. Defaults to passing the current Node.\n                 */\n                eachChild : function(fn, scope, args) {\n                    var childNodes = this.childNodes,\n                        length     = childNodes.length,\n                        i;\n\n                    for (i = 0; i < length; i++) {\n                        if (fn.apply(scope || this, args || [childNodes[i]]) === false) {\n                            break;\n                        }\n                    }\n                },\n\n                /**\n                 * Finds the first child that has the attribute with the specified value.\n                 * @param {String} attribute The attribute name\n                 * @param {Object} value The value to search for\n                 * @param {Boolean} [deep=false] True to search through nodes deeper than the immediate children\n                 * @return {Ext.data.NodeInterface} The found child or null if none was found\n                 */\n                findChild : function(attribute, value, deep) {\n                    return this.findChildBy(function() {\n                        return this.get(attribute) == value;\n                    }, null, deep);\n                },\n\n                /**\n                 * Finds the first child by a custom function. The child matches if the function passed returns true.\n                 * @param {Function} fn A function which must return true if the passed Node is the required Node.\n                 * @param {Object} [scope] The scope (this reference) in which the function is executed. Defaults to the Node being tested.\n                 * @param {Boolean} [deep=false] True to search through nodes deeper than the immediate children\n                 * @return {Ext.data.NodeInterface} The found child or null if none was found\n                 */\n                findChildBy : function(fn, scope, deep) {\n                    var cs = this.childNodes,\n                        len = cs.length,\n                        i = 0, n, res;\n\n                    for (; i < len; i++) {\n                        n = cs[i];\n                        if (fn.call(scope || n, n) === true) {\n                            return n;\n                        }\n                        else if (deep) {\n                            res = n.findChildBy(fn, scope, deep);\n                            if (res !== null) {\n                                return res;\n                            }\n                        }\n                    }\n\n                    return null;\n                },\n\n                /**\n                 * Returns true if this node is an ancestor (at any point) of the passed node.\n                 * @param {Ext.data.NodeInterface} node\n                 * @return {Boolean}\n                 */\n                contains : function(node) {\n                    return node.isAncestor(this);\n                },\n\n                /**\n                 * Returns true if the passed node is an ancestor (at any point) of this node.\n                 * @param {Ext.data.NodeInterface} node\n                 * @return {Boolean}\n                 */\n                isAncestor : function(node) {\n                    var p = this.parentNode;\n                    while (p) {\n                        if (p == node) {\n                            return true;\n                        }\n                        p = p.parentNode;\n                    }\n                    return false;\n                },\n\n                /**\n                 * Sorts this nodes children using the supplied sort function.\n                 * @param {Function} fn A function which, when passed two Nodes, returns -1, 0 or 1 depending upon required sort order.\n                 * @param {Boolean} [recursive=false] True to apply this sort recursively\n                 * @param {Boolean} [suppressEvent=false] True to not fire a sort event.\n                 */\n                sort : function(sortFn, recursive, suppressEvent) {\n                    var cs  = this.childNodes,\n                        ln = cs.length,\n                        i, n;\n\n                    if (ln > 0) {\n                        Ext.Array.sort(cs, sortFn);\n                        for (i = 0; i < ln; i++) {\n                            n = cs[i];\n                            n.previousSibling = cs[i-1];\n                            n.nextSibling = cs[i+1];\n\n                            if (i === 0) {\n                                this.setFirstChild(n);\n                            }\n                            if (i == ln - 1) {\n                                this.setLastChild(n);\n                            }\n                            n.updateInfo();\n                            if (recursive && !n.isLeaf()) {\n                                n.sort(sortFn, true, true);\n                            }\n                        }\n\n                        if (suppressEvent !== true) {\n                            this.fireEvent('sort', this, cs);\n                        }\n                    }\n                },\n\n                /**\n                 * Returns true if this node is expaned\n                 * @return {Boolean}\n                 */\n                isExpanded: function() {\n                    return this.get('expanded');\n                },\n\n                /**\n                 * Returns true if this node is loaded\n                 * @return {Boolean}\n                 */\n                isLoaded: function() {\n                    return this.get('loaded');\n                },\n\n                /**\n                 * Returns true if this node is loading\n                 * @return {Boolean}\n                 */\n                isLoading: function() {\n                    return this.get('loading');\n                },\n\n                /**\n                 * Returns true if this node is the root node\n                 * @return {Boolean}\n                 */\n                isRoot: function() {\n                    return !this.parentNode;\n                },\n\n                /**\n                 * Returns true if this node is visible\n                 * @return {Boolean}\n                 */\n                isVisible: function() {\n                    var parent = this.parentNode;\n                    while (parent) {\n                        if (!parent.isExpanded()) {\n                            return false;\n                        }\n                        parent = parent.parentNode;\n                    }\n                    return true;\n                },\n\n                /**\n                 * Expand this node.\n                 * @param {Boolean} [recursive=false] True to recursively expand all the children\n                 * @param {Function} [callback] The function to execute once the expand completes\n                 * @param {Object} [scope] The scope to run the callback in\n                 */\n                expand: function(recursive, callback, scope) {\n                    var me = this;\n\n                    // all paths must call the callback (eventually) or things like\n                    // selectPath fail\n\n                    // First we start by checking if this node is a parent\n                    if (!me.isLeaf()) {\n                        // If it's loaded, wait until it loads before proceeding\n                        if (me.isLoading()) {\n                            me.on('expand', function(){\n                                me.expand(recursive, callback, scope);\n                            }, me, {single: true});\n                        } else {\n                            // Now we check if this record is already expanding or expanded\n                            if (!me.isExpanded()) {\n                                // The TreeStore actually listens for the beforeexpand method and checks\n                                // whether we have to asynchronously load the children from the server\n                                // first. Thats why we pass a callback function to the event that the\n                                // store can call once it has loaded and parsed all the children.\n                                me.fireEvent('beforeexpand', me, function() {\n                                    me.set('expanded', true);\n                                    if (me.hasListeners.expand) {\n                                        me.fireEvent('expand', me, me.childNodes, false);\n                                    }\n\n                                    // Call the expandChildren method if recursive was set to true\n                                    if (recursive) {\n                                        me.expandChildren(true, callback, scope);\n                                    } else {\n                                        Ext.callback(callback, scope || me, [me.childNodes]);\n                                    }\n                                }, me);\n                            } else if (recursive) {\n                                // If it is is already expanded but we want to recursively expand then call expandChildren\n                                me.expandChildren(true, callback, scope);\n                            } else {\n                                Ext.callback(callback, scope || me, [me.childNodes]);\n                            }\n                        }\n                    } else {\n                        // If it's not then we fire the callback right away\n                        Ext.callback(callback, scope || me); // leaf = no childNodes\n                    }\n                },\n\n                /**\n                 * Expand all the children of this node.\n                 * @param {Boolean} [recursive=false] True to recursively expand all the children\n                 * @param {Function} [callback] The function to execute once all the children are expanded\n                 * @param {Object} [scope] The scope to run the callback in\n                 */\n                expandChildren: function(recursive, callback, scope) {\n                    var me = this,\n                        i = 0,\n                        nodes = me.childNodes,\n                        ln = nodes.length,\n                        node,\n                        expanding = 0;\n\n                    for (; i < ln; ++i) {\n                        node = nodes[i];\n                        if (!node.isLeaf()) {\n                            expanding++;\n                            nodes[i].expand(recursive, function () {\n                                expanding--;\n                                if (callback && !expanding) {\n                                    Ext.callback(callback, scope || me, [me.childNodes]);\n                                }\n                            });\n                        }\n                    }\n\n                    if (!expanding && callback) {\n                        Ext.callback(callback, scope || me, [me.childNodes]);                    }\n                },\n\n                /**\n                 * Collapse this node.\n                 * @param {Boolean} [recursive=false] True to recursively collapse all the children\n                 * @param {Function} [callback] The function to execute once the collapse completes\n                 * @param {Object} [scope] The scope to run the callback in\n                 */\n                collapse: function(recursive, callback, scope) {\n                    var me = this;\n\n                    // First we start by checking if this node is a parent\n                    if (!me.isLeaf()) {\n                        // Now we check if this record is already collapsing or collapsed\n                        if (!me.collapsing && me.isExpanded()) {\n                            me.fireEvent('beforecollapse', me, function() {\n                                me.set('expanded', false);\n                                if (me.hasListeners.collapse) {\n                                    me.fireEvent('collapse', me, me.childNodes, false);\n                                }\n\n                                // Call the collapseChildren method if recursive was set to true\n                                if (recursive) {\n                                    me.collapseChildren(true, callback, scope);\n                                }\n                                else {\n                                    Ext.callback(callback, scope || me, [me.childNodes]);\n                                }\n                            }, me);\n                        }\n                        // If it is is already collapsed but we want to recursively collapse then call collapseChildren\n                        else if (recursive) {\n                            me.collapseChildren(true, callback, scope);\n                        } else {\n                            Ext.callback(callback, scope || me, [me.childNodes]);\n                        }\n                    }\n                    // If it's not then we fire the callback right away\n                    else {\n                        Ext.callback(callback, scope || me, [me.childNodes]);\n                    }\n                },\n\n                /**\n                 * Collapse all the children of this node.\n                 * @param {Function} [recursive=false] True to recursively collapse all the children\n                 * @param {Function} [callback] The function to execute once all the children are collapsed\n                 * @param {Object} [scope] The scope to run the callback in\n                 */\n                collapseChildren: function(recursive, callback, scope) {\n                    var me = this,\n                        i = 0,\n                        nodes = me.childNodes,\n                        ln = nodes.length,\n                        node,\n                        collapsing = 0;\n\n                    for (; i < ln; ++i) {\n                        node = nodes[i];\n                        if (!node.isLeaf()) {\n                            collapsing++;\n                            nodes[i].collapse(recursive, function () {\n                                collapsing--;\n                                if (callback && !collapsing) {\n                                    Ext.callback(callback, scope || me, [me.childNodes]);\n                                }\n                            });\n                        }\n                    }\n\n                    if (!collapsing && callback) {\n                        Ext.callback(callback, scope || me, [me.childNodes]);\n                    }\n                }\n            };\n        }\n    }\n});\n\n/**\n * Node Store\n * @private\n */\nExt.define('Ext.data.NodeStore', {\n    extend: 'Ext.data.Store',\n    alias: 'store.node',\n    requires: ['Ext.data.NodeInterface'],\n\n    /**\n     * @cfg {Ext.data.Model} node\n     * The Record you want to bind this Store to. Note that\n     * this record will be decorated with the Ext.data.NodeInterface if this is not the\n     * case yet.\n     */\n    node: null,\n\n    /**\n     * @cfg {Boolean} recursive\n     * Set this to true if you want this NodeStore to represent\n     * all the descendents of the node in its flat data collection. This is useful for\n     * rendering a tree structure to a DataView and is being used internally by\n     * the TreeView. Any records that are moved, removed, inserted or appended to the\n     * node at any depth below the node this store is bound to will be automatically\n     * updated in this Store's internal flat data structure.\n     */\n    recursive: false,\n    \n    /** \n     * @cfg {Boolean} rootVisible\n     * False to not include the root node in this Stores collection.\n     */    \n    rootVisible: false,\n\n    /**\n     * @cfg {Ext.data.TreeStore} treeStore\n     * The TreeStore that is used by this NodeStore's Ext.tree.View.\n     */\n\n    constructor: function(config) {\n        var me = this,\n            node;\n\n        config = config || {};\n        Ext.apply(me, config);\n\n        if (Ext.isDefined(me.proxy)) {\n            Ext.Error.raise(\"A NodeStore cannot be bound to a proxy. Instead bind it to a record \" +\n                            \"decorated with the NodeInterface by setting the node config.\");\n        }\n        me.useModelWarning = false;\n\n        config.proxy = {type: 'proxy'};\n        me.callParent([config]);\n\n        node = me.node;\n        if (node) {\n            me.node = null;\n            me.setNode(node);\n        }\n    },\n\n    setNode: function(node) {\n        var me = this;\n        if (me.node && me.node != node) {\n            // We want to unbind our listeners on the old node\n            me.mun(me.node, {\n                expand: me.onNodeExpand,\n                collapse: me.onNodeCollapse,\n                append: me.onNodeAppend,\n                insert: me.onNodeInsert,\n                remove: me.onNodeRemove,\n                sort: me.onNodeSort,\n                scope: me\n            });\n            me.node = null;\n        }\n\n        if (node) {\n            Ext.data.NodeInterface.decorate(node.self);\n            me.removeAll();\n            if (me.rootVisible) {\n                me.add(node);\n            } else if (!node.isExpanded() && me.treeStore.autoLoad !== false) {\n                node.expand();\n            }\n\n            me.mon(node, {\n                expand: me.onNodeExpand,\n                collapse: me.onNodeCollapse,\n                append: me.onNodeAppend,\n                insert: me.onNodeInsert,\n                remove: me.onNodeRemove,\n                sort: me.onNodeSort,\n                scope: me\n            });\n            me.node = node;\n            if (node.isExpanded() && node.isLoaded()) {\n                me.onNodeExpand(node, node.childNodes, true);\n            }\n        }\n    },\n\n    onNodeSort: function(node, childNodes) {\n        var me = this;\n\n        if ((me.indexOf(node) !== -1 || (node === me.node && !me.rootVisible) && node.isExpanded())) {\n            me.onNodeCollapse(node, childNodes, true);\n            me.onNodeExpand(node, childNodes, true);\n        }\n    },\n\n    onNodeExpand: function(parent, records, suppressEvent) {\n        var me = this,\n            insertIndex = me.indexOf(parent) + 1,\n            ln = records ? records.length : 0,\n            i, record;\n\n        if (!me.recursive && parent !== me.node) {\n            return;\n        }\n\n        if (parent !== this.node && !me.isVisible(parent)) {\n            return;\n        }\n\n        if (!suppressEvent && me.fireEvent('beforeexpand', parent, records, insertIndex) === false) {\n            return;\n        }\n\n        if (ln) {\n            me.insert(insertIndex, records);\n            for (i = 0; i < ln; i++) {\n                record = records[i];\n                if (record.isExpanded()) {\n                    if (record.isLoaded()) {\n                        // Take a shortcut\n                        me.onNodeExpand(record, record.childNodes, true);\n                    }\n                    else {\n                        record.set('expanded', false);\n                        record.expand();\n                    }\n                }\n            }\n        }\n\n        if (!suppressEvent) {\n            me.fireEvent('expand', parent, records);\n        }\n    },\n\n    onNodeCollapse: function(parent, records, suppressEvent) {\n        var me = this,\n            ln = records.length,\n            collapseIndex = me.indexOf(parent) + 1,\n            i, record;\n\n        if (!me.recursive && parent !== me.node) {\n            return;\n        }\n\n        if (!suppressEvent && me.fireEvent('beforecollapse', parent, records, collapseIndex) === false) {\n            return;\n        }\n\n        for (i = 0; i < ln; i++) {\n            record = records[i];\n            me.remove(record);\n            if (record.isExpanded()) {\n                me.onNodeCollapse(record, record.childNodes, true);\n            }\n        }\n\n        if (!suppressEvent) {\n            me.fireEvent('collapse', parent, records, collapseIndex);\n        }\n    },\n\n    onNodeAppend: function(parent, node, index) {\n        var me = this,\n            refNode, sibling;\n\n        if (me.isVisible(node)) {\n            if (index === 0) {\n                refNode = parent;\n            } else {\n                sibling = node.previousSibling;\n                while (sibling.isExpanded() && sibling.lastChild) {\n                    sibling = sibling.lastChild;\n                }\n                refNode = sibling;\n            }\n            me.insert(me.indexOf(refNode) + 1, node);\n            if (!node.isLeaf() && node.isExpanded()) {\n                if (node.isLoaded()) {\n                    // Take a shortcut\n                    me.onNodeExpand(node, node.childNodes, true);\n                }\n                else {\n                    node.set('expanded', false);\n                    node.expand();\n                }\n            }\n        }\n    },\n\n    onNodeInsert: function(parent, node, refNode) {\n        var me = this,\n            index = this.indexOf(refNode);\n\n        if (index != -1 && me.isVisible(node)) {\n            me.insert(index, node);\n            if (!node.isLeaf() && node.isExpanded()) {\n                if (node.isLoaded()) {\n                    // Take a shortcut\n                    me.onNodeExpand(node, node.childNodes, true);\n                }\n                else {\n                    node.set('expanded', false);\n                    node.expand();\n                }\n            }\n        }\n    },\n\n    onNodeRemove: function(parent, node, index) {\n        var me = this;\n        if (me.indexOf(node) != -1) {\n            if (!node.isLeaf() && node.isExpanded()) {\n                me.onNodeCollapse(node, node.childNodes, true);\n            }\n            me.remove(node);\n        }\n    },\n\n    isVisible: function(node) {\n        var parent = node.parentNode;\n        while (parent) {\n            if (parent === this.node && !this.rootVisible && parent.isExpanded()) {\n                return true;\n            }\n\n            if (this.indexOf(parent) === -1 || !parent.isExpanded()) {\n                return false;\n            }\n\n            parent = parent.parentNode;\n        }\n        return true;\n    }\n});\n\n/**\n * @author Ed Spencer\n * \n * Simple class that represents a Request that will be made by any {@link Ext.data.proxy.Server} subclass.\n * All this class does is standardize the representation of a Request as used by any ServerProxy subclass,\n * it does not contain any actual logic or perform the request itself.\n */\nExt.define('Ext.data.Request', {\n    /**\n     * @cfg {String} action\n     * The name of the action this Request represents. Usually one of 'create', 'read', 'update' or 'destroy'.\n     */\n    action: undefined,\n    \n    /**\n     * @cfg {Object} params\n     * HTTP request params. The Proxy and its Writer have access to and can modify this object.\n     */\n    params: undefined,\n    \n    /**\n     * @cfg {String} method\n     * The HTTP method to use on this Request. Should be one of 'GET', 'POST', 'PUT' or 'DELETE'.\n     */\n    method: 'GET',\n    \n    /**\n     * @cfg {String} url\n     * The url to access on this Request\n     */\n    url: undefined,\n\n    /**\n     * Creates the Request object.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        Ext.apply(this, config);\n    }\n});\n\n/**\n * @author Don Griffin\n *\n * This class is a sequential id generator. A simple use of this class would be like so:\n *\n *     Ext.define('MyApp.data.MyModel', {\n *         extend: 'Ext.data.Model',\n *         idgen: 'sequential'\n *     });\n *     // assign id's of 1, 2, 3, etc.\n *\n * An example of a configured generator would be:\n *\n *     Ext.define('MyApp.data.MyModel', {\n *         extend: 'Ext.data.Model',\n *         idgen: {\n *             type: 'sequential',\n *             prefix: 'ID_',\n *             seed: 1000\n *         }\n *     });\n *     // assign id's of ID_1000, ID_1001, ID_1002, etc.\n *\n */\nExt.define('Ext.data.SequentialIdGenerator', {\n    extend: 'Ext.data.IdGenerator',\n    alias: 'idgen.sequential',\n\n    constructor: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        me.parts = [ me.prefix, ''];\n    },\n\n    /**\n     * @cfg {String} prefix\n     * The string to place in front of the sequential number for each generated id. The\n     * default is blank.\n     */\n    prefix: '',\n\n    /**\n     * @cfg {Number} seed\n     * The number at which to start generating sequential id's. The default is 1.\n     */\n    seed: 1,\n\n    /**\n     * Generates and returns the next id.\n     * @return {String} The next id.\n     */\n    generate: function () {\n        var me = this,\n            parts = me.parts;\n\n        parts[1] = me.seed++;\n        return parts.join('');\n    }\n});\n\n/**\n * @class Ext.data.Tree\n *\n * This class is used as a container for a series of nodes. The nodes themselves maintain\n * the relationship between parent/child. The tree itself acts as a manager. It gives functionality\n * to retrieve a node by its identifier: {@link #getNodeById}.\n *\n * The tree also relays events from any of it's child nodes, allowing them to be handled in a\n * centralized fashion. In general this class is not used directly, rather used internally\n * by other parts of the framework.\n *\n */\nExt.define('Ext.data.Tree', {\n    alias: 'data.tree',\n\n    mixins: {\n        observable: \"Ext.util.Observable\"\n    },\n\n    /**\n     * @property {Ext.data.NodeInterface}\n     * The root node for this tree\n     */\n    root: null,\n\n    /**\n     * Creates new Tree object.\n     * @param {Ext.data.NodeInterface} root (optional) The root node\n     */\n    constructor: function(root) {\n        var me = this;\n\n        me.mixins.observable.constructor.call(me);\n\n        if (root) {\n            me.setRootNode(root);\n        }\n    },\n\n    /**\n     * Returns the root node for this tree.\n     * @return {Ext.data.NodeInterface}\n     */\n    getRootNode : function() {\n        return this.root;\n    },\n\n    /**\n     * Sets the root node for this tree.\n     * @param {Ext.data.NodeInterface} node\n     * @return {Ext.data.NodeInterface} The root node\n     */\n    setRootNode : function(node) {\n        var me = this;\n\n        me.root = node;\n\n        if (me.fireEvent('beforeappend', null, node) !== false) {\n            node.set('root', true);\n            node.updateInfo();\n            // root node should never be phantom or dirty, so commit it\n            node.commit();\n\n            node.on({\n                scope: me,\n                insert: me.onNodeInsert,\n                append: me.onNodeAppend,\n                remove: me.onNodeRemove\n            });\n\n            me.relayEvents(node, [\n                /**\n                 * @event append\n                 * @inheritdoc Ext.data.NodeInterface#append\n                 */\n                \"append\",\n\n                /**\n                 * @event remove\n                 * @inheritdoc Ext.data.NodeInterface#remove\n                 */\n                \"remove\",\n\n                /**\n                 * @event move\n                 * @inheritdoc Ext.data.NodeInterface#move\n                 */\n                \"move\",\n\n                /**\n                 * @event insert\n                 * @inheritdoc Ext.data.NodeInterface#insert\n                 */\n                \"insert\",\n\n                /**\n                 * @event beforeappend\n                 * @inheritdoc Ext.data.NodeInterface#beforeappend\n                 */\n                \"beforeappend\",\n\n                /**\n                 * @event beforeremove\n                 * @inheritdoc Ext.data.NodeInterface#beforeremove\n                 */\n                \"beforeremove\",\n\n                /**\n                 * @event beforemove\n                 * @inheritdoc Ext.data.NodeInterface#beforemove\n                 */\n                \"beforemove\",\n\n                /**\n                 * @event beforeinsert\n                 * @inheritdoc Ext.data.NodeInterface#beforeinsert\n                 */\n                \"beforeinsert\",\n\n                /**\n                 * @event expand\n                 * @inheritdoc Ext.data.NodeInterface#expand\n                 */\n                \"expand\",\n\n                /**\n                 * @event collapse\n                 * @inheritdoc Ext.data.NodeInterface#collapse\n                 */\n                \"collapse\",\n\n                /**\n                 * @event beforeexpand\n                 * @inheritdoc Ext.data.NodeInterface#beforeexpand\n                 */\n                \"beforeexpand\",\n\n                /**\n                 * @event beforecollapse\n                 * @inheritdoc Ext.data.NodeInterface#beforecollapse\n                 */\n                \"beforecollapse\" ,\n\n                /**\n                 * @event sort\n                 * @inheritdoc Ext.data.NodeInterface#event-sort\n                 */\n                \"sort\",\n\n                /**\n                 * @event rootchange\n                 * Fires whenever the root node is changed in the tree.\n                 * @param {Ext.data.Model} root The new root\n                 */\n                \"rootchange\"\n            ]);\n\n            me.nodeHash = {};\n            me.registerNode(node);\n            me.fireEvent('append', null, node);\n            me.fireEvent('rootchange', node);\n        }\n\n        return node;\n    },\n\n    /**\n     * Flattens all the nodes in the tree into an array.\n     * @private\n     * @return {Ext.data.NodeInterface[]} The flattened nodes.\n     */\n    flatten: function(){\n        return Ext.Object.getValues(this.nodeHash);\n    },\n\n    /**\n     * Fired when a node is inserted into the root or one of it's children\n     * @private\n     * @param {Ext.data.NodeInterface} parent The parent node\n     * @param {Ext.data.NodeInterface} node The inserted node\n     */\n    onNodeInsert: function(parent, node) {\n        this.registerNode(node, true);\n    },\n\n    /**\n     * Fired when a node is appended into the root or one of it's children\n     * @private\n     * @param {Ext.data.NodeInterface} parent The parent node\n     * @param {Ext.data.NodeInterface} node The appended node\n     */\n    onNodeAppend: function(parent, node) {\n        this.registerNode(node, true);\n    },\n\n    /**\n     * Fired when a node is removed from the root or one of it's children\n     * @private\n     * @param {Ext.data.NodeInterface} parent The parent node\n     * @param {Ext.data.NodeInterface} node The removed node\n     */\n    onNodeRemove: function(parent, node) {\n        this.unregisterNode(node, true);\n    },\n\n    /**\n     * Fired when a node's id changes.  Updates the node's id in the node hash.\n     * @private\n     * @param {Ext.data.NodeInterface} node \n     * @param {Number} oldId The old id\n     * @param {Number} newId The new id\n     */\n    onNodeIdChanged: function(node, oldId, newId) {\n        var nodeHash = this.nodeHash;\n    \n        nodeHash[newId] = node;\n        delete nodeHash[oldId || node.internalId];\n    },\n\n    /**\n     * Gets a node in this tree by its id.\n     * @param {String} id\n     * @return {Ext.data.NodeInterface} The match node.\n     */\n    getNodeById : function(id) {\n        return this.nodeHash[id];\n    },\n\n    /**\n     * Registers a node with the tree\n     * @private\n     * @param {Ext.data.NodeInterface} The node to register\n     * @param {Boolean} [includeChildren] True to unregister any child nodes\n     */\n    registerNode : function(node, includeChildren) {\n        var me = this;\n\n        me.nodeHash[node.getId() || node.internalId] = node;\n        node.on('idchanged', me.onNodeIdChanged, me);\n        if (includeChildren === true) {\n            node.eachChild(function(child){\n                me.registerNode(child, true);\n            });\n        }\n    },\n\n    /**\n     * Unregisters a node with the tree\n     * @private\n     * @param {Ext.data.NodeInterface} The node to unregister\n     * @param {Boolean} [includeChildren] True to unregister any child nodes\n     */\n    unregisterNode : function(node, includeChildren) {\n        delete this.nodeHash[node.getId() || node.internalId];\n        if (includeChildren === true) {\n            node.eachChild(function(child){\n                this.unregisterNode(child, true);\n            }, this);\n        }\n    },\n\n    /**\n     * Sorts this tree\n     * @private\n     * @param {Function} sorterFn The function to use for sorting\n     * @param {Boolean} recursive True to perform recursive sorting\n     */\n    sort: function(sorterFn, recursive) {\n        this.getRootNode().sort(sorterFn, recursive);\n    },\n\n     /**\n     * Filters this tree\n     * @private\n     * @param {Function} sorterFn The function to use for filtering\n     * @param {Boolean} recursive True to perform recursive filtering\n     */\n    filter: function(filters, recursive) {\n        this.getRootNode().filter(filters, recursive);\n    }\n});\n\n/**\n * The TreeStore is a store implementation that is backed by by an {@link Ext.data.Tree}.\n * It provides convenience methods for loading nodes, as well as the ability to use\n * the hierarchical tree structure combined with a store. This class is generally used\n * in conjunction with {@link Ext.tree.Panel}. This class also relays many events from\n * the Tree for convenience.\n *\n * # Using Models\n *\n * If no Model is specified, an implicit model will be created that implements {@link Ext.data.NodeInterface}.\n * The standard Tree fields will also be copied onto the Model for maintaining their state. These fields are listed\n * in the {@link Ext.data.NodeInterface} documentation.\n *\n * # Reading Nested Data\n *\n * For the tree to read nested data, the {@link Ext.data.reader.Reader} must be configured with a root property,\n * so the reader can find nested data for each node (if a root is not specified, it will default to\n * 'children'). This will tell the tree to look for any nested tree nodes by the same keyword, i.e., 'children'.\n * If a root is specified in the config make sure that any nested nodes with children have the same name.\n * Note that setting {@link #defaultRootProperty} accomplishes the same thing.\n */\nExt.define('Ext.data.TreeStore', {\n    extend: 'Ext.data.AbstractStore',\n    alias: 'store.tree',\n    requires: [\n        'Ext.util.Sorter',\n        'Ext.data.Tree',\n        'Ext.data.NodeInterface'\n    ],\n\n    /**\n     * @cfg {Ext.data.Model/Ext.data.NodeInterface/Object} root\n     * The root node for this store. For example:\n     *\n     *     root: {\n     *         expanded: true,\n     *         text: \"My Root\",\n     *         children: [\n     *             { text: \"Child 1\", leaf: true },\n     *             { text: \"Child 2\", expanded: true, children: [\n     *                 { text: \"GrandChild\", leaf: true }\n     *             ] }\n     *         ]\n     *     }\n     *\n     * Setting the `root` config option is the same as calling {@link #setRootNode}.\n     */\n\n    /**\n     * @cfg {Boolean} [clearOnLoad=true]\n     * Remove previously existing child nodes before loading. \n     */\n    clearOnLoad : true,\n\n    /**\n     * @cfg {Boolean} [clearRemovedOnLoad=true]\n     * If `true`, when a node is reloaded, any records in the {@link #removed} record collection that were previously descendants of the node being reloaded will be cleared from the {@link #removed} collection.\n     * Only applicable if {@link #clearOnLoad} is `true`.\n     */\n    clearRemovedOnLoad: true,\n\n    /**\n     * @cfg {String} [nodeParam=\"node\"]\n     * The name of the parameter sent to the server which contains the identifier of the node.\n     */\n    nodeParam: 'node',\n\n    /**\n     * @cfg {String} [defaultRootId=\"root\"]\n     * The default root id.\n     */\n    defaultRootId: 'root',\n\n    /**\n     * @cfg {String} [defaultRootProperty=\"children\"]\n     * The root property to specify on the reader if one is not explicitly defined.\n     */\n    defaultRootProperty: 'children',\n    \n    // Keep a copy of the default so we know if it's been changed in a subclass/config\n    rootProperty: 'children',\n\n    /**\n     * @cfg {Boolean} [folderSort=false]\n     * Set to true to automatically prepend a leaf sorter.\n     */\n    folderSort: false,\n\n    constructor: function(config) {\n        var me = this,\n            root,\n            fields,\n            defaultRoot;\n\n        config = Ext.apply({}, config);\n\n        /**\n         * If we have no fields declare for the store, add some defaults.\n         * These will be ignored if a model is explicitly specified.\n         */\n        fields = config.fields || me.fields;\n        if (!fields) {\n            config.fields = [\n                {name: 'text', type: 'string'}\n            ];\n            defaultRoot = config.defaultRootProperty || me.defaultRootProperty;\n            if (defaultRoot !== me.defaultRootProperty) {\n                config.fields.push({\n                    name: defaultRoot,   \n                    type: 'auto',   \n                    defaultValue: null, \n                    persist: false\n                });\n            }\n        }\n\n        me.callParent([config]);\n\n        // We create our data tree.\n        me.tree = new Ext.data.Tree();\n\n        me.relayEvents(me.tree, [\n            /**\n             * @event append\n             * @inheritdoc Ext.data.Tree#append\n             */\n            \"append\",\n\n            /**\n             * @event remove\n             * @inheritdoc Ext.data.Tree#remove\n             */\n            \"remove\",\n\n            /**\n             * @event move\n             * @inheritdoc Ext.data.Tree#move\n             */\n            \"move\",\n\n            /**\n             * @event insert\n             * @inheritdoc Ext.data.Tree#insert\n             */\n            \"insert\",\n\n            /**\n             * @event beforeappend\n             * @inheritdoc Ext.data.Tree#beforeappend\n             */\n            \"beforeappend\",\n\n            /**\n             * @event beforeremove\n             * @inheritdoc Ext.data.Tree#beforeremove\n             */\n            \"beforeremove\",\n\n            /**\n             * @event beforemove\n             * @inheritdoc Ext.data.Tree#beforemove\n             */\n            \"beforemove\",\n\n            /**\n             * @event beforeinsert\n             * @inheritdoc Ext.data.Tree#beforeinsert\n             */\n            \"beforeinsert\",\n\n            /**\n             * @event expand\n             * @inheritdoc Ext.data.Tree#expand\n             */\n            \"expand\",\n\n            /**\n             * @event collapse\n             * @inheritdoc Ext.data.Tree#collapse\n             */\n            \"collapse\",\n\n            /**\n             * @event beforeexpand\n             * @inheritdoc Ext.data.Tree#beforeexpand\n             */\n            \"beforeexpand\",\n\n            /**\n             * @event beforecollapse\n             * @inheritdoc Ext.data.Tree#beforecollapse\n             */\n            \"beforecollapse\",\n\n            /**\n             * @event sort\n             * @inheritdoc Ext.data.Tree#sort\n             */\n            \"sort\",\n\n            /**\n             * @event rootchange\n             * @inheritdoc Ext.data.Tree#rootchange\n             */\n            \"rootchange\"\n        ]);\n\n        me.tree.on({\n            scope: me,\n            remove: me.onNodeRemove,\n            // this event must follow the relay to beforeitemexpand to allow users to\n            // cancel the expand:\n            beforeexpand: me.onBeforeNodeExpand,\n            beforecollapse: me.onBeforeNodeCollapse,\n            append: me.onNodeAdded,\n            insert: me.onNodeAdded,\n            sort: me.onNodeSort\n        });\n\n        me.onBeforeSort();\n\n        root = me.root;\n        if (root) {\n            delete me.root;\n            me.setRootNode(root);\n        }\n\n        if (Ext.isDefined(me.nodeParameter)) {\n            if (Ext.isDefined(Ext.global.console)) {\n                Ext.global.console.warn('Ext.data.TreeStore: nodeParameter has been deprecated. Please use nodeParam instead.');\n            }\n            me.nodeParam = me.nodeParameter;\n            delete me.nodeParameter;\n        }\n    },\n\n    // inherit docs\n    setProxy: function(proxy) {\n        var reader,\n            needsRoot;\n\n        if (proxy instanceof Ext.data.proxy.Proxy) {\n            // proxy instance, check if a root was set\n            needsRoot = Ext.isEmpty(proxy.getReader().root);\n        } else if (Ext.isString(proxy)) {\n            // string type, means a reader can't be set\n            needsRoot = true;\n        } else {\n            // object, check if a reader and a root were specified.\n            reader = proxy.reader;\n            needsRoot = !(reader && !Ext.isEmpty(reader.root));\n        }\n        proxy = this.callParent(arguments);\n        if (needsRoot) {\n            reader = proxy.getReader();\n            reader.root = this.defaultRootProperty;\n            // force rebuild\n            reader.buildExtractors(true);\n        }\n    },\n\n    // inherit docs\n    onBeforeSort: function() {\n        if (this.folderSort) {\n            this.sort({\n                property: 'leaf',\n                direction: 'ASC'\n            }, 'prepend', false);\n        }\n    },\n\n    /**\n     * Called before a node is expanded.\n     * @private\n     * @param {Ext.data.NodeInterface} node The node being expanded.\n     * @param {Function} callback The function to run after the expand finishes\n     * @param {Object} scope The scope in which to run the callback function\n     */\n    onBeforeNodeExpand: function(node, callback, scope) {\n        if (node.isLoaded()) {\n            Ext.callback(callback, scope || node, [node.childNodes]);\n        }\n        else if (node.isLoading()) {\n            this.on('load', function() {\n                Ext.callback(callback, scope || node, [node.childNodes]);\n            }, this, {single: true});\n        }\n        else {\n            this.read({\n                node: node,\n                callback: function() {\n                    Ext.callback(callback, scope || node, [node.childNodes]);\n                }\n            });\n        }\n    },\n\n    //inherit docs\n    getNewRecords: function() {\n        return Ext.Array.filter(this.tree.flatten(), this.filterNew);\n    },\n\n    //inherit docs\n    getUpdatedRecords: function() {\n        return Ext.Array.filter(this.tree.flatten(), this.filterUpdated);\n    },\n\n    /**\n     * Called before a node is collapsed.\n     * @private\n     * @param {Ext.data.NodeInterface} node The node being collapsed.\n     * @param {Function} callback The function to run after the collapse finishes\n     * @param {Object} scope The scope in which to run the callback function\n     */\n    onBeforeNodeCollapse: function(node, callback, scope) {\n        callback.call(scope || node, node.childNodes);\n    },\n\n    onNodeRemove: function(parent, node, isMove) {\n        var me = this,\n            removed = me.removed;\n\n        if (!node.isReplace && Ext.Array.indexOf(removed, node) == -1) {\n            removed.push(node);\n        }\n\n        if (me.autoSync && !me.autoSyncSuspended && !isMove) {\n            me.sync();\n        }\n    },\n\n    onNodeAdded: function(parent, node) {\n        var me = this,\n            proxy = me.getProxy(),\n            reader = proxy.getReader(),\n            data = node.raw || node[node.persistenceProperty],\n            dataRoot;\n\n        Ext.Array.remove(me.removed, node);\n\n        if (!node.isLeaf()) {\n            dataRoot = reader.getRoot(data);\n            if (dataRoot) {\n                me.fillNode(node, reader.extractData(dataRoot));\n                delete data[reader.root];\n            }\n        }\n\n        if (me.autoSync && !me.autoSyncSuspended && (node.phantom || node.dirty)) {\n            me.sync();\n        }\n    },\n\n    onNodeSort: function() {\n        if(this.autoSync && !this.autoSyncSuspended) {\n            this.sync();\n        }\n    },\n\n    /**\n     * Sets the root node for this store.  See also the {@link #root} config option.\n     * @param {Ext.data.Model/Ext.data.NodeInterface/Object} root\n     * @return {Ext.data.NodeInterface} The new root\n     */\n    setRootNode: function(root, /* private */ preventLoad) {\n        var me = this,\n            model = me.model,\n            idProperty = model.prototype.idProperty\n\n        root = root || {};\n        if (!root.isModel) {\n            // create a default rootNode and create internal data struct.\n            Ext.applyIf(root, {\n                id: me.defaultRootId,\n                text: 'Root',\n                allowDrag: false\n            });\n            if (root[idProperty] === undefined) {\n                root[idProperty] = me.defaultRootId;\n            }\n            Ext.data.NodeInterface.decorate(model);\n            root = Ext.ModelManager.create(root, model);\n        } else if (root.isModel && !root.isNode) {\n            Ext.data.NodeInterface.decorate(model);\n        }\n\n\n        // Because we have decorated the model with new fields,\n        // we need to build new extactor functions on the reader.\n        me.getProxy().getReader().buildExtractors(true);\n\n        // When we add the root to the tree, it will automaticaly get the NodeInterface\n        me.tree.setRootNode(root);\n\n        // If the user has set expanded: true on the root, we want to call the expand function\n        if (preventLoad !== true && !root.isLoaded() && (me.autoLoad === true || root.isExpanded())) {\n            me.load({\n                node: root\n            });\n        }\n\n        return root;\n    },\n\n    /**\n     * Returns the root node for this tree.\n     * @return {Ext.data.NodeInterface}\n     */\n    getRootNode: function() {\n        return this.tree.getRootNode();\n    },\n\n    /**\n     * Returns the record node by id\n     * @return {Ext.data.NodeInterface}\n     */\n    getNodeById: function(id) {\n        return this.tree.getNodeById(id);\n    },\n    \n    // inherit docs\n    getById: function(id) {\n        return this.getNodeById(id);    \n    },\n\n    /**\n     * Loads the Store using its configured {@link #proxy}.\n     * @param {Object} options (Optional) config object. This is passed into the {@link Ext.data.Operation Operation}\n     * object that is created and then sent to the proxy's {@link Ext.data.proxy.Proxy#read} function.\n     * The options can also contain a node, which indicates which node is to be loaded. If not specified, it will\n     * default to the root node.\n     */\n    load: function(options) {\n        options = options || {};\n        options.params = options.params || {};\n\n        var me = this,\n            node = options.node || me.tree.getRootNode();\n\n        // If there is not a node it means the user hasnt defined a rootnode yet. In this case lets just\n        // create one for them.\n        if (!node) {\n            node = me.setRootNode({\n                expanded: true\n            }, true);\n        }\n\n        // Assign the ID of the Operation so that a REST proxy can create the correct URL\n        options.id = node.getId();\n\n        if (me.clearOnLoad) {\n            if(me.clearRemovedOnLoad) {\n                // clear from the removed array any nodes that were descendants of the node being reloaded so that they do not get saved on next sync.\n                me.clearRemoved(node);\n            }\n            // temporarily remove the onNodeRemove event listener so that when removeAll is called, the removed nodes do not get added to the removed array\n            me.tree.un('remove', me.onNodeRemove, me);\n            // remove all the nodes\n            node.removeAll(false);\n            // reattach the onNodeRemove listener\n            me.tree.on('remove', me.onNodeRemove, me);\n        }\n\n        Ext.applyIf(options, {\n            node: node\n        });\n        options.params[me.nodeParam] = node ? node.getId() : 'root';\n\n        if (node) {\n            node.set('loading', true);\n        }\n\n        return me.callParent([options]);\n    },\n\n    /**\n     * Removes all records that used to be descendants of the passed node from the removed array\n     * @private\n     * @param {Ext.data.NodeInterface} node\n     */\n    clearRemoved: function(node) {\n        var me = this,\n            removed = me.removed,\n            id = node.getId(),\n            removedLength = removed.length,\n            i = removedLength,\n            recordsToClear = {},\n            newRemoved = [],\n            removedHash = {},\n            removedNode,\n            targetNode,\n            targetId;\n\n        if(node === me.getRootNode()) {\n            // if the passed node is the root node, just reset the removed array\n            me.removed = [];\n            return;\n        }\n\n        // add removed records to a hash so they can be easily retrieved by id later\n        for(; i--;) {\n            removedNode = removed[i];\n            removedHash[removedNode.getId()] = removedNode;\n        }\n\n        for(i = removedLength; i--;) {\n            removedNode = removed[i];\n            targetNode = removedNode;\n            while(targetNode && targetNode.getId() !== id) {\n                // walk up the parent hierarchy until we find the passed node or until we get to the root node\n                targetId = targetNode.get('parentId');\n                targetNode = targetNode.parentNode || me.getNodeById(targetId) || removedHash[targetId];\n            }\n            if(targetNode) {\n                // removed node was previously a descendant of the passed node - add it to the records to clear from \"removed\" later\n                recordsToClear[removedNode.getId()] = removedNode;\n            }\n        }\n\n        // create a new removed array containing only the records that are not in recordsToClear\n        for(i = 0; i < removedLength; i++) {\n            removedNode = removed[i];\n            if(!recordsToClear[removedNode.getId()]) {\n                newRemoved.push(removedNode);\n            }\n        }\n\n        me.removed = newRemoved;\n    },\n\n    /**\n     * Fills a node with a series of child records.\n     * @private\n     * @param {Ext.data.NodeInterface} node The node to fill\n     * @param {Ext.data.Model[]} newNodes The records to add\n     */\n    fillNode: function(node, newNodes) {\n        var me = this,\n            ln = newNodes ? newNodes.length : 0,\n            sorters = me.sorters,\n            i, sortCollection,\n            needsIndexSort = false,\n            performLocalSort = ln && me.sortOnLoad && !me.remoteSort && sorters && sorters.items && sorters.items.length,\n            node1, node2;\n\n        // See if there are any differing index values in the new nodes. If not, then we do not have to sortByIndex\n        for (i = 1; i < ln; i++) {\n            node1 = newNodes[i];\n            node2 = newNodes[i - 1];\n            needsIndexSort = node1[node1.persistenceProperty].index != node2[node2.persistenceProperty].index;\n            if (needsIndexSort) {\n                break;\n            }\n        }\n\n        // If there is a set of local sorters defined.\n        if (performLocalSort) {\n            // If sorting by index is needed, sort by index first\n            if (needsIndexSort) {\n                me.sorters.insert(0, me.indexSorter);\n            }\n            sortCollection = new Ext.util.MixedCollection();\n            sortCollection.addAll(newNodes);\n            sortCollection.sort(me.sorters.items);\n            newNodes = sortCollection.items;\n\n            // Remove the index sorter\n            me.sorters.remove(me.indexSorter);\n        } else if (needsIndexSort) {\n            Ext.Array.sort(newNodes, me.sortByIndex);\n        }\n\n        node.set('loaded', true);\n        for (i = 0; i < ln; i++) {\n            node.appendChild(newNodes[i], undefined, true);\n        }\n\n        return newNodes;\n    },\n\n    /**\n     * Sorter function for sorting records in index order\n     * @private\n     * @param {Ext.data.NodeInterface} node1\n     * @param {Ext.data.NodeInterface} node2\n     * @return {Number}\n     */\n    sortByIndex: function(node1, node2) {\n        return node1[node1.persistenceProperty].index - node2[node2.persistenceProperty].index;\n    },\n\n    // inherit docs\n    onProxyLoad: function(operation) {\n        var me = this,\n            successful = operation.wasSuccessful(),\n            records = operation.getRecords(),\n            node = operation.node;\n\n        me.loading = false;\n        node.set('loading', false);\n        if (successful) {\n            if (!me.clearOnLoad) {\n                records = me.cleanRecords(node, records);\n            }\n            records = me.fillNode(node, records);\n        }\n        // The load event has an extra node parameter\n        // (differing from the load event described in AbstractStore)\n        /**\n         * @event load\n         * Fires whenever the store reads data from a remote data source.\n         * @param {Ext.data.TreeStore} this\n         * @param {Ext.data.NodeInterface} node The node that was loaded.\n         * @param {Ext.data.Model[]} records An array of records.\n         * @param {Boolean} successful True if the operation was successful.\n         */\n        // deprecate read?\n        me.fireEvent('read', me, operation.node, records, successful);\n        me.fireEvent('load', me, operation.node, records, successful);\n        //this is a callback that would have been passed to the 'read' function and is optional\n        Ext.callback(operation.callback, operation.scope || me, [records, operation, successful]);\n    },\n    \n    onCreateRecords: function(records) {\n        this.callParent(arguments);\n        \n        var i = 0,\n            len = records.length,\n            tree = this.tree,\n            node;\n\n        for (; i < len; ++i) {\n            node = records[i];\n            tree.onNodeIdChanged(node, null, node.getId());\n        }\n        \n    },\n    \n    cleanRecords: function(node, records){\n        var nodeHash = {},\n            childNodes = node.childNodes,\n            i = 0,\n            len  = childNodes.length,\n            out = [],\n            rec;\n            \n        // build a hash of all the childNodes under the current node for performance\n        for (; i < len; ++i) {\n            nodeHash[childNodes[i].getId()] = true;\n        }\n        \n        for (i = 0, len = records.length; i < len; ++i) {\n            rec = records[i];\n            if (!nodeHash[rec.getId()]) {\n                out.push(rec);    \n            }\n        }\n        \n        return out;\n    },\n\n    // inherit docs\n    removeAll: function() {\n        var root = this.getRootNode();\n        if (root) {\n            root.destroy(true);\n        }\n        this.fireEvent('clear', this);\n    },\n\n    // inherit docs\n    doSort: function(sorterFn) {\n        var me = this;\n        if (me.remoteSort) {\n            //the load function will pick up the new sorters and request the sorted data from the proxy\n            me.load();\n        } else {\n            me.tree.sort(sorterFn, true);\n            me.fireEvent('datachanged', me);\n            me.fireEvent('refresh', me);\n        }\n        me.fireEvent('sort', me);\n    }\n}, function() {\n    var proto = this.prototype;\n    proto.indexSorter = new Ext.util.Sorter({\n        sorterFn: proto.sortByIndex\n    });\n});\n\n/**\n * @extend Ext.data.IdGenerator\n * @author Don Griffin\n *\n * This class generates UUID's according to RFC 4122. This class has a default id property.\n * This means that a single instance is shared unless the id property is overridden. Thus,\n * two {@link Ext.data.Model} instances configured like the following share one generator:\n *\n *     Ext.define('MyApp.data.MyModelX', {\n *         extend: 'Ext.data.Model',\n *         idgen: 'uuid'\n *     });\n *\n *     Ext.define('MyApp.data.MyModelY', {\n *         extend: 'Ext.data.Model',\n *         idgen: 'uuid'\n *     });\n *\n * This allows all models using this class to share a commonly configured instance.\n *\n * # Using Version 1 (\"Sequential\") UUID's\n *\n * If a server can provide a proper timestamp and a \"cryptographic quality random number\"\n * (as described in RFC 4122), the shared instance can be configured as follows:\n *\n *     Ext.data.IdGenerator.get('uuid').reconfigure({\n *         version: 1,\n *         clockSeq: clock, // 14 random bits\n *         salt: salt,      // 48 secure random bits (the Node field)\n *         timestamp: ts    // timestamp per Section 4.1.4\n *     });\n *\n *     // or these values can be split into 32-bit chunks:\n *\n *     Ext.data.IdGenerator.get('uuid').reconfigure({\n *         version: 1,\n *         clockSeq: clock,\n *         salt: { lo: saltLow32, hi: saltHigh32 },\n *         timestamp: { lo: timestampLow32, hi: timestamptHigh32 }\n *     });\n *\n * This approach improves the generator's uniqueness by providing a valid timestamp and\n * higher quality random data. Version 1 UUID's should not be used unless this information\n * can be provided by a server and care should be taken to avoid caching of this data.\n *\n * See http://www.ietf.org/rfc/rfc4122.txt for details.\n */\nExt.define('Ext.data.UuidGenerator', (function () {\n    var twoPow14 = Math.pow(2, 14),\n        twoPow16 = Math.pow(2, 16),\n        twoPow28 = Math.pow(2, 28),\n        twoPow32 = Math.pow(2, 32);\n\n    function toHex (value, length) {\n        var ret = value.toString(16);\n        if (ret.length > length) {\n            ret = ret.substring(ret.length - length); // right-most digits\n        } else if (ret.length < length) {\n            ret = Ext.String.leftPad(ret, length, '0');\n        }\n        return ret;\n    }\n\n    function rand (lo, hi) {\n        var v = Math.random() * (hi - lo + 1);\n        return Math.floor(v) + lo;\n    }\n\n    function split (bignum) {\n        if (typeof(bignum) == 'number') {\n            var hi = Math.floor(bignum / twoPow32);\n            return {\n                lo: Math.floor(bignum - hi * twoPow32),\n                hi: hi\n            };\n        }\n        return bignum;\n    }\n\n    return {\n        extend: 'Ext.data.IdGenerator',\n\n        alias: 'idgen.uuid',\n\n        id: 'uuid', // shared by default\n\n        /**\n         * @property {Number/Object} salt\n         * When created, this value is a 48-bit number. For computation, this value is split\n         * into 32-bit parts and stored in an object with `hi` and `lo` properties.\n         */\n\n        /**\n         * @property {Number/Object} timestamp\n         * When created, this value is a 60-bit number. For computation, this value is split\n         * into 32-bit parts and stored in an object with `hi` and `lo` properties.\n         */\n\n        /**\n         * @cfg {Number} version\n         * The Version of UUID. Supported values are:\n         *\n         *  * 1 : Time-based, \"sequential\" UUID.\n         *  * 4 : Pseudo-random UUID.\n         *\n         * The default is 4.\n         */\n        version: 4,\n\n        constructor: function() {\n            var me = this;\n\n            me.callParent(arguments);\n\n            me.parts = [];\n            me.init();\n        },\n\n        generate: function () {\n            var me = this,\n                parts = me.parts,\n                ts = me.timestamp;\n\n            /*\n               The magic decoder ring (derived from RFC 4122 Section 4.2.2):\n\n               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n               |                          time_low                             |\n               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n               |           time_mid            |  ver  |        time_hi        |\n               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n               |res|  clock_hi |   clock_low   |    salt 0   |M|     salt 1    |\n               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n               |                         salt (2-5)                            |\n               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\n                         time_mid      clock_hi (low 6 bits)\n                time_low     | time_hi |clock_lo\n                    |        |     |   || salt[0]\n                    |        |     |   ||   | salt[1..5]\n                    v        v     v   vv   v v\n                    0badf00d-aced-1def-b123-dfad0badbeef\n                                  ^    ^     ^\n                            version    |     multicast (low bit)\n                                       |\n                                    reserved (upper 2 bits)\n            */\n            parts[0] = toHex(ts.lo, 8);\n            parts[1] = toHex(ts.hi & 0xFFFF, 4);\n            parts[2] = toHex(((ts.hi >>> 16) & 0xFFF) | (me.version << 12), 4);\n            parts[3] = toHex(0x80 | ((me.clockSeq >>> 8) & 0x3F), 2) +\n                       toHex(me.clockSeq & 0xFF, 2);\n            parts[4] = toHex(me.salt.hi, 4) + toHex(me.salt.lo, 8);\n\n            if (me.version == 4) {\n                me.init(); // just regenerate all the random values...\n            } else {\n                // sequentially increment the timestamp...\n                ++ts.lo;\n                if (ts.lo >= twoPow32) { // if (overflow)\n                    ts.lo = 0;\n                    ++ts.hi;\n                }\n            }\n\n            return parts.join('-').toLowerCase();\n        },\n\n        getRecId: function (rec) {\n            return rec.getId();\n        },\n\n        /**\n         * @private\n         */\n        init: function () {\n            var me = this,\n                salt, time;\n\n            if (me.version == 4) {\n                // See RFC 4122 (Secion 4.4)\n                //   o  If the state was unavailable (e.g., non-existent or corrupted),\n                //      or the saved node ID is different than the current node ID,\n                //      generate a random clock sequence value.\n                me.clockSeq = rand(0, twoPow14-1);\n\n                // we run this on every id generation...\n                salt = me.salt || (me.salt = {});\n                time = me.timestamp || (me.timestamp = {});\n\n                // See RFC 4122 (Secion 4.4)\n                salt.lo = rand(0, twoPow32-1);\n                salt.hi = rand(0, twoPow16-1);\n                time.lo = rand(0, twoPow32-1);\n                time.hi = rand(0, twoPow28-1);\n            } else {\n                // this is run only once per-instance\n                me.salt = split(me.salt);\n                me.timestamp = split(me.timestamp);\n\n                // Set multicast bit: \"the least significant bit of the first octet of the\n                // node ID\" (nodeId = salt for this implementation):\n                me.salt.hi |= 0x100;\n            }\n        },\n\n        /**\n         * Reconfigures this generator given new config properties.\n         */\n        reconfigure: function (config) {\n            Ext.apply(this, config);\n            this.init();\n        }\n    };\n}()));\n\n/**\n * @author Ed Spencer\n *\n * The XML Reader is used by a Proxy to read a server response that is sent back in XML format. This usually happens as\n * a result of loading a Store - for example we might create something like this:\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'name', 'email']\n *     });\n *\n *     var store = Ext.create('Ext.data.Store', {\n *         model: 'User',\n *         proxy: {\n *             type: 'ajax',\n *             url : 'users.xml',\n *             reader: {\n *                 type: 'xml',\n *                 record: 'user',\n *                 root: 'users'\n *             }\n *         }\n *     });\n *\n * The example above creates a 'User' model. Models are explained in the {@link Ext.data.Model Model} docs if you're not\n * already familiar with them.\n *\n * We created the simplest type of XML Reader possible by simply telling our {@link Ext.data.Store Store}'s {@link\n * Ext.data.proxy.Proxy Proxy} that we want a XML Reader. The Store automatically passes the configured model to the\n * Store, so it is as if we passed this instead:\n *\n *     reader: {\n *         type : 'xml',\n *         model: 'User',\n *         record: 'user',\n *         root: 'users'\n *     }\n *\n * The reader we set up is ready to read data from our server - at the moment it will accept a response like this:\n *\n *     <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n *     <users>\n *         <user>\n *             <id>1</id>\n *             <name>Ed Spencer</name>\n *             <email>ed@sencha.com</email>\n *         </user>\n *         <user>\n *             <id>2</id>\n *             <name>Abe Elias</name>\n *             <email>abe@sencha.com</email>\n *         </user>\n *     </users>\n *\n * First off there's {@link #root} option to define the root node `<users>` (there should be only one in a well-formed\n * XML document). Then the XML Reader uses the configured {@link #record} option to pull out the data for each record -\n * in this case we set record to 'user', so each `<user>` above will be converted into a User model.\n *\n * Note that XmlReader doesn't care whether your {@link #root} and {@link #record} elements are nested deep inside a\n * larger structure, so a response like this will still work:\n *\n *     <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n *     <deeply>\n *         <nested>\n *             <xml>\n *                 <users>\n *                     <user>\n *                         <id>1</id>\n *                         <name>Ed Spencer</name>\n *                         <email>ed@sencha.com</email>\n *                     </user>\n *                     <user>\n *                         <id>2</id>\n *                         <name>Abe Elias</name>\n *                         <email>abe@sencha.com</email>\n *                     </user>\n *                 </users>\n *             </xml>\n *         </nested>\n *     </deeply>\n *\n * # Response metadata\n *\n * The server can return additional data in its response, such as the {@link #totalProperty total number of records} and\n * the {@link #successProperty success status of the response}. These are typically included in the XML response like\n * this:\n *\n *     <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n *     <users>\n *         <total>100</total>\n *         <success>true</success>\n *         <user>\n *             <id>1</id>\n *             <name>Ed Spencer</name>\n *             <email>ed@sencha.com</email>\n *         </user>\n *         <user>\n *             <id>2</id>\n *             <name>Abe Elias</name>\n *             <email>abe@sencha.com</email>\n *         </user>\n *     </users>\n *\n * If these properties are present in the XML response they can be parsed out by the XmlReader and used by the Store\n * that loaded it. We can set up the names of these properties by specifying a final pair of configuration options:\n *\n *     reader: {\n *         type: 'xml',\n *         root: 'users',\n *         totalProperty  : 'total',\n *         successProperty: 'success'\n *     }\n *\n * These final options are not necessary to make the Reader work, but can be useful when the server needs to report an\n * error or if it needs to indicate that there is a lot of data available of which only a subset is currently being\n * returned.\n *\n * # Response format\n *\n * **Note:** in order for the browser to parse a returned XML document, the Content-Type header in the HTTP response\n * must be set to \"text/xml\" or \"application/xml\". This is very important - the XmlReader will not work correctly\n * otherwise.\n */\nExt.define('Ext.data.reader.Xml', {\n    extend: 'Ext.data.reader.Reader',\n    alternateClassName: 'Ext.data.XmlReader',\n    alias : 'reader.xml',\n\n    /**\n     * @cfg {String} record (required)\n     * The DomQuery path to the repeated element which contains record information.\n     */\n\n    /**\n     * @private\n     * Creates a function to return some particular key of data from a response. The totalProperty and\n     * successProperty are treated as special cases for type casting, everything else is just a simple selector.\n     * @param {String} key\n     * @return {Function}\n     */\n    createAccessor: function(expr) {\n        var me = this;\n\n        if (Ext.isEmpty(expr)) {\n            return Ext.emptyFn;\n        }\n\n        if (Ext.isFunction(expr)) {\n            return expr;\n        }\n\n        return function(root) {\n            return me.getNodeValue(Ext.DomQuery.selectNode(expr, root));\n        };\n    },\n\n    getNodeValue: function(node) {\n        if (node && node.firstChild) {\n            return node.firstChild.nodeValue;\n        }\n        return undefined;\n    },\n\n    //inherit docs\n    getResponseData: function(response) {\n        var xml = response.responseXML,\n            error,\n            msg;\n\n        if (!xml) {\n            msg = 'XML data not found in the response';               \n\n            error = new Ext.data.ResultSet({\n                total  : 0,\n                count  : 0,\n                records: [],\n                success: false,\n                message: msg\n            });\n\n            this.fireEvent('exception', this, response, error);\n\n            Ext.Logger.warn(msg);\n\n            return error;\n        }\n\n        return this.readRecords(xml);\n    },\n\n    /**\n     * Normalizes the data object.\n     * @param {Object} data The raw data object\n     * @return {Object} The documentElement property of the data object if present, or the same object if not.\n     */\n    getData: function(data) {\n        return data.documentElement || data;\n    },\n\n    /**\n     * @private\n     * Given an XML object, returns the Element that represents the root as configured by the Reader's meta data.\n     * @param {Object} data The XML data object\n     * @return {XMLElement} The root node element\n     */\n    getRoot: function(data) {\n        var nodeName = data.nodeName,\n            root     = this.root;\n\n        if (!root || (nodeName && nodeName == root)) {\n            return data;\n        } else if (Ext.DomQuery.isXml(data)) {\n            // This fix ensures we have XML data\n            // Related to TreeStore calling getRoot with the root node, which isn't XML\n            // Probably should be resolved in TreeStore at some point\n            return Ext.DomQuery.selectNode(root, data);\n        }\n    },\n\n    /**\n     * @private\n     * We're just preparing the data for the superclass by pulling out the record nodes we want.\n     * @param {XMLElement} root The XML root node\n     * @return {Ext.data.Model[]} The records\n     */\n    extractData: function(root) {\n        var recordName = this.record;\n\n        if (!recordName) {\n            Ext.Error.raise('Record is a required parameter');\n        }\n\n        if (recordName != root.nodeName) {\n            root = Ext.DomQuery.select(recordName, root);\n        } else {\n            root = [root];\n        }\n        return this.callParent([root]);\n    },\n\n    /**\n     * @private\n     * See Ext.data.reader.Reader's getAssociatedDataRoot docs.\n     * @param {Object} data The raw data object\n     * @param {String} associationName The name of the association to get data for (uses associationKey if present)\n     * @return {XMLElement} The root\n     */\n    getAssociatedDataRoot: function(data, associationName) {\n        return Ext.DomQuery.select(associationName, data)[0];\n    },\n\n    /**\n     * Parses an XML document and returns a ResultSet containing the model instances.\n     * @param {Object} doc Parsed XML document\n     * @return {Ext.data.ResultSet} The parsed result set\n     */\n    readRecords: function(doc) {\n        // it's possible that we get passed an array here by associations.\n        // Make sure we strip that out (see Ext.data.reader.Reader#readAssociated)\n        if (Ext.isArray(doc)) {\n            doc = doc[0];\n        }\n\n        /**\n         * @property {Object} xmlData\n         * Copy of {@link #rawData}.\n         * @deprecated Will be removed in Ext JS 5.0. Use {@link #rawData} instead.\n         */\n        this.xmlData = doc;\n        return this.callParent([doc]);\n    },\n\n    /**\n     * @private\n     * Returns an accessor expression for the passed Field from an XML element using either the Field's mapping, or\n     * its ordinal position in the fields collsction as the index.\n     * This is used by buildExtractors to create optimized on extractor function which converts raw data into model instances.\n     */\n    createFieldAccessExpression: function(field, fieldVarName, dataName) {\n        var selector = field.mapping || field.name,\n            result;\n\n        if (typeof selector === 'function') {\n            result = fieldVarName + '.mapping(' + dataName + ', this)';\n        } else {\n            result = 'me.getNodeValue(Ext.DomQuery.selectNode(\"' + selector + '\", ' + dataName + '))';\n        }\n        return result;\n    }\n});\n\n/**\n * @author Ed Spencer\n * @class Ext.data.writer.Xml\n\nThis class is used to write {@link Ext.data.Model} data to the server in an XML format.\nThe {@link #documentRoot} property is used to specify the root element in the XML document.\nThe {@link #record} option is used to specify the element name for each record that will make\nup the XML document.\n\n * @markdown\n */\nExt.define('Ext.data.writer.Xml', {\n    \n    /* Begin Definitions */\n    \n    extend: 'Ext.data.writer.Writer',\n    alternateClassName: 'Ext.data.XmlWriter',\n    \n    alias: 'writer.xml',\n    \n    /* End Definitions */\n    \n    /**\n     * @cfg {String} documentRoot The name of the root element of the document. Defaults to <tt>'xmlData'</tt>.\n     * If there is more than 1 record and the root is not specified, the default document root will still be used\n     * to ensure a valid XML document is created.\n     */\n    documentRoot: 'xmlData',\n    \n    /**\n     * @cfg {String} defaultDocumentRoot The root to be used if {@link #documentRoot} is empty and a root is required\n     * to form a valid XML document.\n     */\n    defaultDocumentRoot: 'xmlData',\n\n    /**\n     * @cfg {String} header A header to use in the XML document (such as setting the encoding or version).\n     * Defaults to <tt>''</tt>.\n     */\n    header: '',\n\n    /**\n     * @cfg {String} record The name of the node to use for each record. Defaults to <tt>'record'</tt>.\n     */\n    record: 'record',\n\n    //inherit docs\n    writeRecords: function(request, data) {\n        var me = this,\n            xml = [],\n            i = 0,\n            len = data.length,\n            root = me.documentRoot,\n            record = me.record,\n            needsRoot = data.length !== 1,\n            item,\n            key;\n            \n        // may not exist\n        xml.push(me.header || '');\n        \n        if (!root && needsRoot) {\n            root = me.defaultDocumentRoot;\n        }\n        \n        if (root) {\n            xml.push('<', root, '>');\n        }\n            \n        for (; i < len; ++i) {\n            item = data[i];\n            xml.push('<', record, '>');\n            for (key in item) {\n                if (item.hasOwnProperty(key)) {\n                    xml.push('<', key, '>', item[key], '</', key, '>');\n                }\n            }\n            xml.push('</', record, '>');\n        }\n        \n        if (root) {\n            xml.push('</', root, '>');\n        }\n            \n        request.xmlData = xml.join('');\n        return request;\n    }\n});\n\n/**\n * @author Ed Spencer\n * <p>Small helper class to make creating {@link Ext.data.Store}s from XML data easier.\n * A XmlStore will be automatically configured with a {@link Ext.data.reader.Xml}.</p>\n * <p>A store configuration would be something like:<pre><code>\nvar store = new Ext.data.XmlStore({\n    // store configs\n    storeId: 'myStore',\n    url: 'sheldon.xml', // automatically configures a HttpProxy\n    // reader configs\n    record: 'Item', // records will have an \"Item\" tag\n    idPath: 'ASIN',\n    totalRecords: '@TotalResults'\n    fields: [\n        // set up the fields mapping into the xml doc\n        // The first needs mapping, the others are very basic\n        {name: 'Author', mapping: 'ItemAttributes > Author'},\n        'Title', 'Manufacturer', 'ProductGroup'\n    ]\n});\n * </code></pre></p>\n * <p>This store is configured to consume a returned object of the form:<pre><code>\n&#60?xml version=\"1.0\" encoding=\"UTF-8\"?>\n&#60ItemSearchResponse xmlns=\"http://webservices.amazon.com/AWSECommerceService/2009-05-15\">\n    &#60Items>\n        &#60Request>\n            &#60IsValid>True&#60/IsValid>\n            &#60ItemSearchRequest>\n                &#60Author>Sidney Sheldon&#60/Author>\n                &#60SearchIndex>Books&#60/SearchIndex>\n            &#60/ItemSearchRequest>\n        &#60/Request>\n        &#60TotalResults>203&#60/TotalResults>\n        &#60TotalPages>21&#60/TotalPages>\n        &#60Item>\n            &#60ASIN>0446355453&#60/ASIN>\n            &#60DetailPageURL>\n                http://www.amazon.com/\n            &#60/DetailPageURL>\n            &#60ItemAttributes>\n                &#60Author>Sidney Sheldon&#60/Author>\n                &#60Manufacturer>Warner Books&#60/Manufacturer>\n                &#60ProductGroup>Book&#60/ProductGroup>\n                &#60Title>Master of the Game&#60/Title>\n            &#60/ItemAttributes>\n        &#60/Item>\n    &#60/Items>\n&#60/ItemSearchResponse>\n * </code></pre>\n * An object literal of this form could also be used as the {@link #cfg-data} config option.</p>\n * <p><b>Note:</b> This class accepts all of the configuration options of\n * <b>{@link Ext.data.reader.Xml XmlReader}</b>.</p>\n */\nExt.define('Ext.data.XmlStore', {\n    extend: 'Ext.data.Store',\n    alias: 'store.xml',\n\n    requires: [\n        'Ext.data.proxy.Ajax',\n        'Ext.data.reader.Xml',\n        'Ext.data.writer.Xml'\n    ],\n    \n    constructor: function(config){\n        config = Ext.apply({\n            proxy: {\n                type: 'ajax',\n                reader: 'xml',\n                writer: 'xml'\n            }\n        }, config);\n\n        this.callParent([config]);\n    }\n});\n\n/**\n * @author Ed Spencer\n * @class Ext.data.association.BelongsTo\n *\n * Represents a many to one association with another model. The owner model is expected to have\n * a foreign key which references the primary key of the associated model:\n *\n *     Ext.define('Category', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             { name: 'id',   type: 'int' },\n *             { name: 'name', type: 'string' }\n *         ]\n *     });\n *\n *     Ext.define('Product', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             { name: 'id',          type: 'int' },\n *             { name: 'category_id', type: 'int' },\n *             { name: 'name',        type: 'string' }\n *         ],\n *         // we can use the belongsTo shortcut on the model to create a belongsTo association\n *         associations: [\n *             { type: 'belongsTo', model: 'Category' }\n *         ]\n *     });\n *\n * In the example above we have created models for Products and Categories, and linked them together\n * by saying that each Product belongs to a Category. This automatically links each Product to a Category\n * based on the Product's category_id, and provides new functions on the Product model:\n *\n * ## Generated getter function\n *\n * The first function that is added to the owner model is a getter function:\n *\n *     var product = new Product({\n *         id: 100,\n *         category_id: 20,\n *         name: 'Sneakers'\n *     });\n *\n *     product.getCategory(function(category, operation) {\n *         // do something with the category object\n *         alert(category.get('id')); // alerts 20\n *     }, this);\n *\n * The getCategory function was created on the Product model when we defined the association. This uses the\n * Category's configured {@link Ext.data.proxy.Proxy proxy} to load the Category asynchronously, calling the provided\n * callback when it has loaded.\n *\n * The new getCategory function will also accept an object containing success, failure and callback properties\n * - callback will always be called, success will only be called if the associated model was loaded successfully\n * and failure will only be called if the associatied model could not be loaded:\n *\n *     product.getCategory({\n *         reload: true, // force a reload if the owner model is already cached\n *         callback: function(category, operation) {}, // a function that will always be called\n *         success : function(category, operation) {}, // a function that will only be called if the load succeeded\n *         failure : function(category, operation) {}, // a function that will only be called if the load did not succeed\n *         scope   : this // optionally pass in a scope object to execute the callbacks in\n *     });\n *\n * In each case above the callbacks are called with two arguments - the associated model instance and the\n * {@link Ext.data.Operation operation} object that was executed to load that instance. The Operation object is\n * useful when the instance could not be loaded.\n * \n * Once the getter has been called on the model, it will be cached if the getter is called a second time. To\n * force the model to reload, specify reload: true in the options object.\n *\n * ## Generated setter function\n *\n * The second generated function sets the associated model instance - if only a single argument is passed to\n * the setter then the following two calls are identical:\n *\n *     // this call...\n *     product.setCategory(10);\n *\n *     // is equivalent to this call:\n *     product.set('category_id', 10);\n *     \n * An instance of the owner model can also be passed as a parameter.\n *\n * If we pass in a second argument, the model will be automatically saved and the second argument passed to\n * the owner model's {@link Ext.data.Model#save save} method:\n *\n *     product.setCategory(10, function(product, operation) {\n *         // the product has been saved\n *         alert(product.get('category_id')); //now alerts 10\n *     });\n *\n *     //alternative syntax:\n *     product.setCategory(10, {\n *         callback: function(product, operation), // a function that will always be called\n *         success : function(product, operation), // a function that will only be called if the load succeeded\n *         failure : function(product, operation), // a function that will only be called if the load did not succeed\n *         scope   : this //optionally pass in a scope object to execute the callbacks in\n *     })\n *\n * ## Customisation\n *\n * Associations reflect on the models they are linking to automatically set up properties such as the\n * {@link #primaryKey} and {@link #foreignKey}. These can alternatively be specified:\n *\n *     Ext.define('Product', {\n *         fields: [...],\n *\n *         associations: [\n *             { type: 'belongsTo', model: 'Category', primaryKey: 'unique_id', foreignKey: 'cat_id' }\n *         ]\n *     });\n *\n * Here we replaced the default primary key (defaults to 'id') and foreign key (calculated as 'category_id')\n * with our own settings. Usually this will not be needed.\n */\nExt.define('Ext.data.association.BelongsTo', {\n    extend: 'Ext.data.association.Association',\n    alternateClassName: 'Ext.data.BelongsToAssociation',\n    alias: 'association.belongsto',\n\n    /**\n     * @cfg {String} foreignKey The name of the foreign key on the owner model that links it to the associated\n     * model. Defaults to the lowercased name of the associated model plus \"_id\", e.g. an association with a\n     * model called Product would set up a product_id foreign key.\n     *\n     *     Ext.define('Order', {\n     *         extend: 'Ext.data.Model',\n     *         fields: ['id', 'date'],\n     *         hasMany: 'Product'\n     *     });\n     *\n     *     Ext.define('Product', {\n     *         extend: 'Ext.data.Model',\n     *         fields: ['id', 'name', 'order_id'], // refers to the id of the order that this product belongs to\n     *         belongsTo: 'Order'\n     *     });\n     *     var product = new Product({\n     *         id: 1,\n     *         name: 'Product 1',\n     *         order_id: 22\n     *     }, 1);\n     *     product.getOrder(); // Will make a call to the server asking for order_id 22\n     *\n     */\n\n    /**\n     * @cfg {String} getterName The name of the getter function that will be added to the local model's prototype.\n     * Defaults to 'get' + the name of the foreign model, e.g. getCategory\n     */\n\n    /**\n     * @cfg {String} setterName The name of the setter function that will be added to the local model's prototype.\n     * Defaults to 'set' + the name of the foreign model, e.g. setCategory\n     */\n\n    /**\n     * @cfg {String} type The type configuration can be used when creating associations using a configuration object.\n     * Use 'belongsTo' to create a BelongsTo association.\n     *\n     *     associations: [{\n     *         type: 'belongsTo',\n     *         model: 'User'\n     *     }]\n     */\n    constructor: function(config) {\n        this.callParent(arguments);\n\n        var me             = this,\n            ownerProto     = me.ownerModel.prototype,\n            associatedName = me.associatedName,\n            getterName     = me.getterName || 'get' + associatedName,\n            setterName     = me.setterName || 'set' + associatedName;\n\n        Ext.applyIf(me, {\n            name        : associatedName,\n            foreignKey  : associatedName.toLowerCase() + \"_id\",\n            instanceName: associatedName + 'BelongsToInstance',\n            associationKey: associatedName.toLowerCase()\n        });\n\n        ownerProto[getterName] = me.createGetter();\n        ownerProto[setterName] = me.createSetter();\n    },\n\n    /**\n     * @private\n     * Returns a setter function to be placed on the owner model's prototype\n     * @return {Function} The setter function\n     */\n    createSetter: function() {\n        var me = this,\n            foreignKey = me.foreignKey;\n\n        //'this' refers to the Model instance inside this function\n        return function(value, options, scope) {\n            // If we pass in an instance, pull the id out\n            if (value && value.isModel) {\n                value = value.getId();\n            }\n            this.set(foreignKey, value);\n\n            if (Ext.isFunction(options)) {\n                options = {\n                    callback: options,\n                    scope: scope || this\n                };\n            }\n\n            if (Ext.isObject(options)) {\n                return this.save(options);\n            }\n        };\n    },\n\n    /**\n     * @private\n     * Returns a getter function to be placed on the owner model's prototype. We cache the loaded instance\n     * the first time it is loaded so that subsequent calls to the getter always receive the same reference.\n     * @return {Function} The getter function\n     */\n    createGetter: function() {\n        var me              = this,\n            associatedName  = me.associatedName,\n            associatedModel = me.associatedModel,\n            foreignKey      = me.foreignKey,\n            primaryKey      = me.primaryKey,\n            instanceName    = me.instanceName;\n\n        //'this' refers to the Model instance inside this function\n        return function(options, scope) {\n            options = options || {};\n\n            var model = this,\n                foreignKeyId = model.get(foreignKey),\n                success,\n                instance,\n                args;\n\n            if (options.reload === true || model[instanceName] === undefined) {\n                instance = Ext.ModelManager.create({}, associatedName);\n                instance.set(primaryKey, foreignKeyId);\n\n                if (typeof options == 'function') {\n                    options = {\n                        callback: options,\n                        scope: scope || model\n                    };\n                }\n                \n                // Overwrite the success handler so we can assign the current instance\n                success = options.success;\n                options.success = function(rec){\n                    model[instanceName] = rec;\n                    if (success) {\n                        success.apply(this, arguments);\n                    }\n                };\n\n                associatedModel.load(foreignKeyId, options);\n                // assign temporarily while we wait for data to return\n                model[instanceName] = instance;\n                return instance;\n            } else {\n                instance = model[instanceName];\n                args = [instance];\n                scope = scope || options.scope || model;\n\n                //TODO: We're duplicating the callback invokation code that the instance.load() call above\n                //makes here - ought to be able to normalize this - perhaps by caching at the Model.load layer\n                //instead of the association layer.\n                Ext.callback(options, scope, args);\n                Ext.callback(options.success, scope, args);\n                Ext.callback(options.failure, scope, args);\n                Ext.callback(options.callback, scope, args);\n\n                return instance;\n            }\n        };\n    },\n\n    /**\n     * Read associated data\n     * @private\n     * @param {Ext.data.Model} record The record we're writing to\n     * @param {Ext.data.reader.Reader} reader The reader for the associated model\n     * @param {Object} associationData The raw associated data\n     */\n    read: function(record, reader, associationData){\n        record[this.instanceName] = reader.read([associationData]).records[0];\n    }\n});\n\n/**\n * General purpose inflector class that {@link #pluralize pluralizes}, {@link #singularize singularizes} and\n * {@link #ordinalize ordinalizes} words. Sample usage:\n *\n *     //turning singular words into plurals\n *     Ext.util.Inflector.pluralize('word'); //'words'\n *     Ext.util.Inflector.pluralize('person'); //'people'\n *     Ext.util.Inflector.pluralize('sheep'); //'sheep'\n *\n *     //turning plurals into singulars\n *     Ext.util.Inflector.singularize('words'); //'word'\n *     Ext.util.Inflector.singularize('people'); //'person'\n *     Ext.util.Inflector.singularize('sheep'); //'sheep'\n *\n *     //ordinalizing numbers\n *     Ext.util.Inflector.ordinalize(11); //\"11th\"\n *     Ext.util.Inflector.ordinalize(21); //\"21st\"\n *     Ext.util.Inflector.ordinalize(1043); //\"1043rd\"\n *\n * # Customization\n *\n * The Inflector comes with a default set of US English pluralization rules. These can be augmented with additional\n * rules if the default rules do not meet your application's requirements, or swapped out entirely for other languages.\n * Here is how we might add a rule that pluralizes \"ox\" to \"oxen\":\n *\n *     Ext.util.Inflector.plural(/^(ox)$/i, \"$1en\");\n *\n * Each rule consists of two items - a regular expression that matches one or more rules, and a replacement string. In\n * this case, the regular expression will only match the string \"ox\", and will replace that match with \"oxen\". Here's\n * how we could add the inverse rule:\n *\n *     Ext.util.Inflector.singular(/^(ox)en$/i, \"$1\");\n *\n * Note that the ox/oxen rules are present by default.\n */\nExt.define('Ext.util.Inflector', {\n\n    /* Begin Definitions */\n\n    singleton: true,\n\n    /* End Definitions */\n\n    /**\n     * @private\n     * The registered plural tuples. Each item in the array should contain two items - the first must be a regular\n     * expression that matchers the singular form of a word, the second must be a String that replaces the matched\n     * part of the regular expression. This is managed by the {@link #plural} method.\n     * @property {Array} plurals\n     */\n    plurals: [\n        [(/(quiz)$/i),                \"$1zes\"  ],\n        [(/^(ox)$/i),                 \"$1en\"   ],\n        [(/([m|l])ouse$/i),           \"$1ice\"  ],\n        [(/(matr|vert|ind)ix|ex$/i),  \"$1ices\" ],\n        [(/(x|ch|ss|sh)$/i),          \"$1es\"   ],\n        [(/([^aeiouy]|qu)y$/i),       \"$1ies\"  ],\n        [(/(hive)$/i),                \"$1s\"    ],\n        [(/(?:([^f])fe|([lr])f)$/i),  \"$1$2ves\"],\n        [(/sis$/i),                   \"ses\"    ],\n        [(/([ti])um$/i),              \"$1a\"    ],\n        [(/(buffal|tomat|potat)o$/i), \"$1oes\"  ],\n        [(/(bu)s$/i),                 \"$1ses\"  ],\n        [(/(alias|status|sex)$/i),    \"$1es\"   ],\n        [(/(octop|vir)us$/i),         \"$1i\"    ],\n        [(/(ax|test)is$/i),           \"$1es\"   ],\n        [(/^person$/),                \"people\" ],\n        [(/^man$/),                   \"men\"    ],\n        [(/^(child)$/),               \"$1ren\"  ],\n        [(/s$/i),                     \"s\"      ],\n        [(/$/),                       \"s\"      ]\n    ],\n\n    /**\n     * @private\n     * The set of registered singular matchers. Each item in the array should contain two items - the first must be a\n     * regular expression that matches the plural form of a word, the second must be a String that replaces the\n     * matched part of the regular expression. This is managed by the {@link #singular} method.\n     * @property {Array} singulars\n     */\n    singulars: [\n      [(/(quiz)zes$/i),                                                    \"$1\"     ],\n      [(/(matr)ices$/i),                                                   \"$1ix\"   ],\n      [(/(vert|ind)ices$/i),                                               \"$1ex\"   ],\n      [(/^(ox)en/i),                                                       \"$1\"     ],\n      [(/(alias|status)es$/i),                                             \"$1\"     ],\n      [(/(octop|vir)i$/i),                                                 \"$1us\"   ],\n      [(/(cris|ax|test)es$/i),                                             \"$1is\"   ],\n      [(/(shoe)s$/i),                                                      \"$1\"     ],\n      [(/(o)es$/i),                                                        \"$1\"     ],\n      [(/(bus)es$/i),                                                      \"$1\"     ],\n      [(/([m|l])ice$/i),                                                   \"$1ouse\" ],\n      [(/(x|ch|ss|sh)es$/i),                                               \"$1\"     ],\n      [(/(m)ovies$/i),                                                     \"$1ovie\" ],\n      [(/(s)eries$/i),                                                     \"$1eries\"],\n      [(/([^aeiouy]|qu)ies$/i),                                            \"$1y\"    ],\n      [(/([lr])ves$/i),                                                    \"$1f\"    ],\n      [(/(tive)s$/i),                                                      \"$1\"     ],\n      [(/(hive)s$/i),                                                      \"$1\"     ],\n      [(/([^f])ves$/i),                                                    \"$1fe\"   ],\n      [(/(^analy)ses$/i),                                                  \"$1sis\"  ],\n      [(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i), \"$1$2sis\"],\n      [(/([ti])a$/i),                                                      \"$1um\"   ],\n      [(/(n)ews$/i),                                                       \"$1ews\"  ],\n      [(/people$/i),                                                       \"person\" ],\n      [(/s$/i),                                                            \"\"       ]\n    ],\n\n    /**\n     * @private\n     * The registered uncountable words\n     * @property {String[]} uncountable\n     */\n     uncountable: [\n        \"sheep\",\n        \"fish\",\n        \"series\",\n        \"species\",\n        \"money\",\n        \"rice\",\n        \"information\",\n        \"equipment\",\n        \"grass\",\n        \"mud\",\n        \"offspring\",\n        \"deer\",\n        \"means\"\n    ],\n\n    /**\n     * Adds a new singularization rule to the Inflector. See the intro docs for more information\n     * @param {RegExp} matcher The matcher regex\n     * @param {String} replacer The replacement string, which can reference matches from the matcher argument\n     */\n    singular: function(matcher, replacer) {\n        this.singulars.unshift([matcher, replacer]);\n    },\n\n    /**\n     * Adds a new pluralization rule to the Inflector. See the intro docs for more information\n     * @param {RegExp} matcher The matcher regex\n     * @param {String} replacer The replacement string, which can reference matches from the matcher argument\n     */\n    plural: function(matcher, replacer) {\n        this.plurals.unshift([matcher, replacer]);\n    },\n\n    /**\n     * Removes all registered singularization rules\n     */\n    clearSingulars: function() {\n        this.singulars = [];\n    },\n\n    /**\n     * Removes all registered pluralization rules\n     */\n    clearPlurals: function() {\n        this.plurals = [];\n    },\n\n    /**\n     * Returns true if the given word is transnumeral (the word is its own singular and plural form - e.g. sheep, fish)\n     * @param {String} word The word to test\n     * @return {Boolean} True if the word is transnumeral\n     */\n    isTransnumeral: function(word) {\n        return Ext.Array.indexOf(this.uncountable, word) != -1;\n    },\n\n    /**\n     * Returns the pluralized form of a word (e.g. Ext.util.Inflector.pluralize('word') returns 'words')\n     * @param {String} word The word to pluralize\n     * @return {String} The pluralized form of the word\n     */\n    pluralize: function(word) {\n        if (this.isTransnumeral(word)) {\n            return word;\n        }\n\n        var plurals = this.plurals,\n            length  = plurals.length,\n            tuple, regex, i;\n\n        for (i = 0; i < length; i++) {\n            tuple = plurals[i];\n            regex = tuple[0];\n\n            if (regex == word || (regex.test && regex.test(word))) {\n                return word.replace(regex, tuple[1]);\n            }\n        }\n\n        return word;\n    },\n\n    /**\n     * Returns the singularized form of a word (e.g. Ext.util.Inflector.singularize('words') returns 'word')\n     * @param {String} word The word to singularize\n     * @return {String} The singularized form of the word\n     */\n    singularize: function(word) {\n        if (this.isTransnumeral(word)) {\n            return word;\n        }\n\n        var singulars = this.singulars,\n            length    = singulars.length,\n            tuple, regex, i;\n\n        for (i = 0; i < length; i++) {\n            tuple = singulars[i];\n            regex = tuple[0];\n\n            if (regex == word || (regex.test && regex.test(word))) {\n                return word.replace(regex, tuple[1]);\n            }\n        }\n\n        return word;\n    },\n\n    /**\n     * Returns the correct {@link Ext.data.Model Model} name for a given string. Mostly used internally by the data\n     * package\n     * @param {String} word The word to classify\n     * @return {String} The classified version of the word\n     */\n    classify: function(word) {\n        return Ext.String.capitalize(this.singularize(word));\n    },\n\n    /**\n     * Ordinalizes a given number by adding a prefix such as 'st', 'nd', 'rd' or 'th' based on the last digit of the\n     * number. 21 -> 21st, 22 -> 22nd, 23 -> 23rd, 24 -> 24th etc\n     * @param {Number} number The number to ordinalize\n     * @return {String} The ordinalized number\n     */\n    ordinalize: function(number) {\n        var parsed = parseInt(number, 10),\n            mod10  = parsed % 10,\n            mod100 = parsed % 100;\n\n        //11 through 13 are a special case\n        if (11 <= mod100 && mod100 <= 13) {\n            return number + \"th\";\n        } else {\n            switch(mod10) {\n                case 1 : return number + \"st\";\n                case 2 : return number + \"nd\";\n                case 3 : return number + \"rd\";\n                default: return number + \"th\";\n            }\n        }\n    }\n}, function() {\n    //aside from the rules above, there are a number of words that have irregular pluralization so we add them here\n    var irregulars = {\n            alumnus: 'alumni',\n            cactus : 'cacti',\n            focus  : 'foci',\n            nucleus: 'nuclei',\n            radius: 'radii',\n            stimulus: 'stimuli',\n            ellipsis: 'ellipses',\n            paralysis: 'paralyses',\n            oasis: 'oases',\n            appendix: 'appendices',\n            index: 'indexes',\n            beau: 'beaux',\n            bureau: 'bureaux',\n            tableau: 'tableaux',\n            woman: 'women',\n            child: 'children',\n            man: 'men',\n            corpus:\t'corpora',\n            criterion: 'criteria',\n            curriculum:\t'curricula',\n            genus: 'genera',\n            memorandum:\t'memoranda',\n            phenomenon:\t'phenomena',\n            foot: 'feet',\n            goose: 'geese',\n            tooth: 'teeth',\n            antenna: 'antennae',\n            formula: 'formulae',\n            nebula: 'nebulae',\n            vertebra: 'vertebrae',\n            vita: 'vitae'\n        },\n        singular;\n\n    for (singular in irregulars) {\n        this.plural(singular, irregulars[singular]);\n        this.singular(irregulars[singular], singular);\n    }\n});\n\n/**\n * @author Ed Spencer\n * @class Ext.data.association.HasMany\n * \n * <p>Represents a one-to-many relationship between two models. Usually created indirectly via a model definition:</p>\n * \n<pre><code>\nExt.define('Product', {\n    extend: 'Ext.data.Model',\n    fields: [\n        {name: 'id',      type: 'int'},\n        {name: 'user_id', type: 'int'},\n        {name: 'name',    type: 'string'}\n    ]\n});\n\nExt.define('User', {\n    extend: 'Ext.data.Model',\n    fields: [\n        {name: 'id',   type: 'int'},\n        {name: 'name', type: 'string'}\n    ],\n    // we can use the hasMany shortcut on the model to create a hasMany association\n    hasMany: {model: 'Product', name: 'products'}\n});\n</pre></code>\n* \n * <p>Above we created Product and User models, and linked them by saying that a User hasMany Products. This gives\n * us a new function on every User instance, in this case the function is called 'products' because that is the name\n * we specified in the association configuration above.</p>\n * \n * <p>This new function returns a specialized {@link Ext.data.Store Store} which is automatically filtered to load\n * only Products for the given model instance:</p>\n * \n<pre><code>\n//first, we load up a User with id of 1\nvar user = Ext.create('User', {id: 1, name: 'Ed'});\n\n//the user.products function was created automatically by the association and returns a {@link Ext.data.Store Store}\n//the created store is automatically scoped to the set of Products for the User with id of 1\nvar products = user.products();\n\n//we still have all of the usual Store functions, for example it's easy to add a Product for this User\nproducts.add({\n    name: 'Another Product'\n});\n\n//saves the changes to the store - this automatically sets the new Product's user_id to 1 before saving\nproducts.sync();\n</code></pre>\n * \n * <p>The new Store is only instantiated the first time you call products() to conserve memory and processing time,\n * though calling products() a second time returns the same store instance.</p>\n * \n * <p><u>Custom filtering</u></p>\n * \n * <p>The Store is automatically furnished with a filter - by default this filter tells the store to only return\n * records where the associated model's foreign key matches the owner model's primary key. For example, if a User\n * with ID = 100 hasMany Products, the filter loads only Products with user_id == 100.</p>\n * \n * <p>Sometimes we want to filter by another field - for example in the case of a Twitter search application we may\n * have models for Search and Tweet:</p>\n * \n<pre><code>\nExt.define('Search', {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id', 'query'\n    ],\n\n    hasMany: {\n        model: 'Tweet',\n        name : 'tweets',\n        filterProperty: 'query'\n    }\n});\n\nExt.define('Tweet', {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id', 'text', 'from_user'\n    ]\n});\n\n//returns a Store filtered by the filterProperty\nvar store = new Search({query: 'Sencha Touch'}).tweets();\n</code></pre>\n * \n * <p>The tweets association above is filtered by the query property by setting the {@link #filterProperty}, and is\n * equivalent to this:</p>\n * \n<pre><code>\nvar store = Ext.create('Ext.data.Store', {\n    model: 'Tweet',\n    filters: [\n        {\n            property: 'query',\n            value   : 'Sencha Touch'\n        }\n    ]\n});\n</code></pre>\n */\nExt.define('Ext.data.association.HasMany', {\n    extend: 'Ext.data.association.Association',\n    alternateClassName: 'Ext.data.HasManyAssociation',\n    requires: ['Ext.util.Inflector'],\n\n    alias: 'association.hasmany',\n\n    /**\n     * @cfg {String} foreignKey The name of the foreign key on the associated model that links it to the owner\n     * model. Defaults to the lowercased name of the owner model plus \"_id\", e.g. an association with a where a\n     * model called Group hasMany Users would create 'group_id' as the foreign key. When the remote store is loaded,\n     * the store is automatically filtered so that only records with a matching foreign key are included in the \n     * resulting child store. This can be overridden by specifying the {@link #filterProperty}.\n     * <pre><code>\nExt.define('Group', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name'],\n    hasMany: 'User'\n});\n\nExt.define('User', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name', 'group_id'], // refers to the id of the group that this user belongs to\n    belongsTo: 'Group'\n});\n     * </code></pre>\n     */\n    \n    /**\n     * @cfg {String} name The name of the function to create on the owner model to retrieve the child store.\n     * If not specified, the pluralized name of the child model is used.\n     * <pre><code>\n// This will create a users() method on any Group model instance\nExt.define('Group', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name'],\n    hasMany: 'User'\n});\nvar group = new Group();\nconsole.log(group.users());\n\n// The method to retrieve the users will now be getUserList\nExt.define('Group', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name'],\n    hasMany: {model: 'User', name: 'getUserList'}\n});\nvar group = new Group();\nconsole.log(group.getUserList());\n     * </code></pre>\n     */\n    \n    /**\n     * @cfg {Object} storeConfig Optional configuration object that will be passed to the generated Store. Defaults to \n     * undefined.\n     */\n    \n    /**\n     * @cfg {String} filterProperty Optionally overrides the default filter that is set up on the associated Store. If\n     * this is not set, a filter is automatically created which filters the association based on the configured \n     * {@link #foreignKey}. See intro docs for more details. Defaults to undefined\n     */\n    \n    /**\n     * @cfg {Boolean} autoLoad True to automatically load the related store from a remote source when instantiated.\n     * Defaults to <tt>false</tt>.\n     */\n    \n    /**\n     * @cfg {String} type The type configuration can be used when creating associations using a configuration object.\n     * Use 'hasMany' to create a HasMany association\n     * <pre><code>\nassociations: [{\n    type: 'hasMany',\n    model: 'User'\n}]\n     * </code></pre>\n     */\n    \n    constructor: function(config) {\n        var me = this,\n            ownerProto,\n            name;\n            \n        me.callParent(arguments);\n        \n        me.name = me.name || Ext.util.Inflector.pluralize(me.associatedName.toLowerCase());\n        \n        ownerProto = me.ownerModel.prototype;\n        name = me.name;\n        \n        Ext.applyIf(me, {\n            storeName : name + \"Store\",\n            foreignKey: me.ownerName.toLowerCase() + \"_id\"\n        });\n        \n        ownerProto[name] = me.createStore();\n    },\n    \n    /**\n     * @private\n     * Creates a function that returns an Ext.data.Store which is configured to load a set of data filtered\n     * by the owner model's primary key - e.g. in a hasMany association where Group hasMany Users, this function\n     * returns a Store configured to return the filtered set of a single Group's Users.\n     * @return {Function} The store-generating function\n     */\n    createStore: function() {\n        var that            = this,\n            associatedModel = that.associatedModel,\n            storeName       = that.storeName,\n            foreignKey      = that.foreignKey,\n            primaryKey      = that.primaryKey,\n            filterProperty  = that.filterProperty,\n            autoLoad        = that.autoLoad,\n            storeConfig     = that.storeConfig || {};\n        \n        return function() {\n            var me = this,\n                config, filter,\n                modelDefaults = {};\n                \n            if (me[storeName] === undefined) {\n                if (filterProperty) {\n                    filter = {\n                        property  : filterProperty,\n                        value     : me.get(filterProperty),\n                        exactMatch: true\n                    };\n                } else {\n                    filter = {\n                        property  : foreignKey,\n                        value     : me.get(primaryKey),\n                        exactMatch: true\n                    };\n                }\n                \n                modelDefaults[foreignKey] = me.get(primaryKey);\n                \n                config = Ext.apply({}, storeConfig, {\n                    model        : associatedModel,\n                    filters      : [filter],\n                    remoteFilter : false,\n                    modelDefaults: modelDefaults\n                });\n                \n                me[storeName] = Ext.data.AbstractStore.create(config);\n                if (autoLoad) {\n                    me[storeName].load();\n                }\n            }\n            \n            return me[storeName];\n        };\n    },\n    \n    /**\n     * Read associated data\n     * @private\n     * @param {Ext.data.Model} record The record we're writing to\n     * @param {Ext.data.reader.Reader} reader The reader for the associated model\n     * @param {Object} associationData The raw associated data\n     */\n    read: function(record, reader, associationData){\n        var store = record[this.name](),\n            inverse,\n            items, iLen, i;\n    \n        store.add(reader.read(associationData).records);\n    \n        //now that we've added the related records to the hasMany association, set the inverse belongsTo\n        //association on each of them if it exists\n        inverse = this.associatedModel.prototype.associations.findBy(function(assoc){\n            return assoc.type === 'belongsTo' && assoc.associatedName === record.$className;\n        });\n    \n        //if the inverse association was found, set it now on each record we've just created\n        if (inverse) {\n            items = store.data.items;\n            iLen  = items.length;\n\n            for (i = 0; i < iLen; i++) {\n                items[i][inverse.instanceName] = record;\n            }\n        }\n    }\n});\n\n/**\n * @class Ext.data.association.HasOne\n * \n * Represents a one to one association with another model. The owner model is expected to have\n * a foreign key which references the primary key of the associated model:\n *\n *     Ext.define('Address', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             { name: 'id',          type: 'int' },\n *             { name: 'number', type: 'string' },\n *             { name: 'street', type: 'string' },\n *             { name: 'city', type: 'string' },\n *             { name: 'zip', type: 'string' },\n *         ]\n *     });\n *\n *     Ext.define('Person', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             { name: 'id',   type: 'int' },\n *             { name: 'name', type: 'string' },\n *             { name: 'address_id', type: 'int'}\n *         ],\n *         // we can use the hasOne shortcut on the model to create a hasOne association\n *         associations: [{ type: 'hasOne', model: 'Address' }]\n *     });\n *\n * In the example above we have created models for People and Addresses, and linked them together\n * by saying that each Person has a single Address. This automatically links each Person to an Address\n * based on the Persons address_id, and provides new functions on the Person model:\n *\n * ## Generated getter function\n *\n * The first function that is added to the owner model is a getter function:\n *\n *     var person = new Person({\n *         id: 100,\n *         address_id: 20,\n *         name: 'John Smith'\n *     });\n *\n *     person.getAddress(function(address, operation) {\n *         // do something with the address object\n *         alert(address.get('id')); // alerts 20\n *     }, this);\n *\n * The getAddress function was created on the Person model when we defined the association. This uses the\n * Persons configured {@link Ext.data.proxy.Proxy proxy} to load the Address asynchronously, calling the provided\n * callback when it has loaded.\n *\n * The new getAddress function will also accept an object containing success, failure and callback properties\n * - callback will always be called, success will only be called if the associated model was loaded successfully\n * and failure will only be called if the associatied model could not be loaded:\n *\n *     person.getAddress({\n *         reload: true, // force a reload if the owner model is already cached\n *         callback: function(address, operation) {}, // a function that will always be called\n *         success : function(address, operation) {}, // a function that will only be called if the load succeeded\n *         failure : function(address, operation) {}, // a function that will only be called if the load did not succeed\n *         scope   : this // optionally pass in a scope object to execute the callbacks in\n *     });\n *\n * In each case above the callbacks are called with two arguments - the associated model instance and the\n * {@link Ext.data.Operation operation} object that was executed to load that instance. The Operation object is\n * useful when the instance could not be loaded.\n * \n * Once the getter has been called on the model, it will be cached if the getter is called a second time. To\n * force the model to reload, specify reload: true in the options object.\n *\n * ## Generated setter function\n *\n * The second generated function sets the associated model instance - if only a single argument is passed to\n * the setter then the following two calls are identical:\n *\n *     // this call...\n *     person.setAddress(10);\n *\n *     // is equivalent to this call:\n *     person.set('address_id', 10);\n *     \n * An instance of the owner model can also be passed as a parameter.\n *\n * If we pass in a second argument, the model will be automatically saved and the second argument passed to\n * the owner model's {@link Ext.data.Model#save save} method:\n *\n *     person.setAddress(10, function(address, operation) {\n *         // the address has been saved\n *         alert(address.get('address_id')); //now alerts 10\n *     });\n *\n *     //alternative syntax:\n *     person.setAddress(10, {\n *         callback: function(address, operation), // a function that will always be called\n *         success : function(address, operation), // a function that will only be called if the load succeeded\n *         failure : function(address, operation), // a function that will only be called if the load did not succeed\n *         scope   : this //optionally pass in a scope object to execute the callbacks in\n *     })\n *\n * ## Customisation\n *\n * Associations reflect on the models they are linking to automatically set up properties such as the\n * {@link #primaryKey} and {@link #foreignKey}. These can alternatively be specified:\n *\n *     Ext.define('Person', {\n *         fields: [...],\n *\n *         associations: [\n *             { type: 'hasOne', model: 'Address', primaryKey: 'unique_id', foreignKey: 'addr_id' }\n *         ]\n *     });\n *\n * Here we replaced the default primary key (defaults to 'id') and foreign key (calculated as 'address_id')\n * with our own settings. Usually this will not be needed.\n */\nExt.define('Ext.data.association.HasOne', {\n    extend: 'Ext.data.association.Association',\n    alternateClassName: 'Ext.data.HasOneAssociation',\n\n    alias: 'association.hasone',\n    \n    /**\n     * @cfg {String} foreignKey The name of the foreign key on the owner model that links it to the associated\n     * model. Defaults to the lowercased name of the associated model plus \"_id\", e.g. an association with a\n     * model called Person would set up a address_id foreign key.\n     *\n     *     Ext.define('Person', {\n     *         extend: 'Ext.data.Model',\n     *         fields: ['id', 'name', 'address_id'], // refers to the id of the address object\n     *         hasOne: 'Address'\n     *     });\n     *\n     *     Ext.define('Address', {\n     *         extend: 'Ext.data.Model',\n     *         fields: ['id', 'number', 'street', 'city', 'zip'], \n     *         belongsTo: 'Person'\n     *     });\n     *     var Person = new Person({\n     *         id: 1,\n     *         name: 'John Smith',\n     *         address_id: 13\n     *     }, 1);\n     *     person.getAddress(); // Will make a call to the server asking for address_id 13\n     *\n     */\n\n    /**\n     * @cfg {String} getterName The name of the getter function that will be added to the local model's prototype.\n     * Defaults to 'get' + the name of the foreign model, e.g. getAddress\n     */\n\n    /**\n     * @cfg {String} setterName The name of the setter function that will be added to the local model's prototype.\n     * Defaults to 'set' + the name of the foreign model, e.g. setAddress\n     */\n\n    /**\n     * @cfg {String} type The type configuration can be used when creating associations using a configuration object.\n     * Use 'hasOne' to create a HasOne association.\n     *\n     *     associations: [{\n     *         type: 'hasOne',\n     *         model: 'Address'\n     *     }]\n     */\n    \n    constructor: function(config) {\n        this.callParent(arguments);\n\n        var me             = this,\n            ownerProto     = me.ownerModel.prototype,\n            associatedName = me.associatedName,\n            getterName     = me.getterName || 'get' + associatedName,\n            setterName     = me.setterName || 'set' + associatedName;\n\n        Ext.applyIf(me, {\n            name        : associatedName,\n            foreignKey  : associatedName.toLowerCase() + \"_id\",\n            instanceName: associatedName + 'HasOneInstance',\n            associationKey: associatedName.toLowerCase()\n        });\n\n        ownerProto[getterName] = me.createGetter();\n        ownerProto[setterName] = me.createSetter();\n    },\n    \n    /**\n     * @private\n     * Returns a setter function to be placed on the owner model's prototype\n     * @return {Function} The setter function\n     */\n    createSetter: function() {\n        var me              = this,\n            ownerModel      = me.ownerModel,\n            foreignKey      = me.foreignKey;\n\n        //'this' refers to the Model instance inside this function\n        return function(value, options, scope) {\n            if (value && value.isModel) {\n                value = value.getId();\n            }\n            \n            this.set(foreignKey, value);\n\n            if (Ext.isFunction(options)) {\n                options = {\n                    callback: options,\n                    scope: scope || this\n                };\n            }\n\n            if (Ext.isObject(options)) {\n                return this.save(options);\n            }\n        };\n    },\n\n    /**\n     * @private\n     * Returns a getter function to be placed on the owner model's prototype. We cache the loaded instance\n     * the first time it is loaded so that subsequent calls to the getter always receive the same reference.\n     * @return {Function} The getter function\n     */\n    createGetter: function() {\n        var me              = this,\n            ownerModel      = me.ownerModel,\n            associatedName  = me.associatedName,\n            associatedModel = me.associatedModel,\n            foreignKey      = me.foreignKey,\n            primaryKey      = me.primaryKey,\n            instanceName    = me.instanceName;\n\n        //'this' refers to the Model instance inside this function\n        return function(options, scope) {\n            options = options || {};\n\n            var model = this,\n                foreignKeyId = model.get(foreignKey),\n                success,\n                instance,\n                args;\n\n            if (options.reload === true || model[instanceName] === undefined) {\n                instance = Ext.ModelManager.create({}, associatedName);\n                instance.set(primaryKey, foreignKeyId);\n\n                if (typeof options == 'function') {\n                    options = {\n                        callback: options,\n                        scope: scope || model\n                    };\n                }\n                \n                // Overwrite the success handler so we can assign the current instance\n                success = options.success;\n                options.success = function(rec){\n                    model[instanceName] = rec;\n                    if (success) {\n                        success.apply(this, arguments);\n                    }\n                };\n\n                associatedModel.load(foreignKeyId, options);\n                // assign temporarily while we wait for data to return\n                model[instanceName] = instance;\n                return instance;\n            } else {\n                instance = model[instanceName];\n                args = [instance];\n                scope = scope || options.scope || model;\n\n                //TODO: We're duplicating the callback invokation code that the instance.load() call above\n                //makes here - ought to be able to normalize this - perhaps by caching at the Model.load layer\n                //instead of the association layer.\n                Ext.callback(options, scope, args);\n                Ext.callback(options.success, scope, args);\n                Ext.callback(options.failure, scope, args);\n                Ext.callback(options.callback, scope, args);\n\n                return instance;\n            }\n        };\n    },\n    \n    /**\n     * Read associated data\n     * @private\n     * @param {Ext.data.Model} record The record we're writing to\n     * @param {Ext.data.reader.Reader} reader The reader for the associated model\n     * @param {Object} associationData The raw associated data\n     */\n    read: function(record, reader, associationData){\n        var inverse = this.associatedModel.prototype.associations.findBy(function(assoc){\n            return assoc.type === 'belongsTo' && assoc.associatedName === record.$className;\n        }), newRecord = reader.read([associationData]).records[0];\n        \n        record[this.instanceName] = newRecord;\n    \n        //if the inverse association was found, set it now on each record we've just created\n        if (inverse) {\n            newRecord[inverse.instanceName] = record;\n        }\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * WebStorageProxy is simply a superclass for the {@link Ext.data.proxy.LocalStorage LocalStorage} and {@link\n * Ext.data.proxy.SessionStorage SessionStorage} proxies. It uses the new HTML5 key/value client-side storage objects to\n * save {@link Ext.data.Model model instances} for offline use.\n * @private\n */\nExt.define('Ext.data.proxy.WebStorage', {\n    extend: 'Ext.data.proxy.Client',\n    alternateClassName: 'Ext.data.WebStorageProxy',\n    requires: [\n        'Ext.data.SequentialIdGenerator'\n    ],\n\n    /**\n     * @cfg {String} id\n     * The unique ID used as the key in which all record data are stored in the local storage object.\n     */\n    id: undefined,\n\n    /**\n     * Creates the proxy, throws an error if local storage is not supported in the current browser.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        this.callParent(arguments);\n\n        /**\n         * @property {Object} cache\n         * Cached map of records already retrieved by this Proxy. Ensures that the same instance is always retrieved.\n         */\n        this.cache = {};\n\n        if (this.getStorageObject() === undefined) {\n            Ext.Error.raise(\"Local Storage is not supported in this browser, please use another type of data proxy\");\n        }\n\n        //if an id is not given, try to use the store's id instead\n        this.id = this.id || (this.store ? this.store.storeId : undefined);\n\n        if (this.id === undefined) {\n            Ext.Error.raise(\"No unique id was provided to the local storage proxy. See Ext.data.proxy.LocalStorage documentation for details\");\n        }\n\n        this.initialize();\n    },\n\n    //inherit docs\n    create: function(operation, callback, scope) {\n        var me = this,\n            records = operation.records,\n            length = records.length,\n            ids = me.getIds(),\n            id, record, i;\n\n        operation.setStarted();\n\n        if(me.isHierarchical === undefined) {\n            // if the storage object does not yet contain any data, this is the first point at which we can determine whether or not this proxy deals with hierarchical data.\n            // it cannot be determined during initialization because the Model is not decorated with NodeInterface until it is used in a TreeStore\n            me.isHierarchical = !!records[0].isNode;\n            if(me.isHierarchical) {\n                me.getStorageObject().setItem(me.getTreeKey(), true);\n            }\n        }\n\n        for (i = 0; i < length; i++) {\n            record = records[i];\n\n            if (record.phantom) {\n                record.phantom = false;\n                id = me.getNextId();\n            } else {\n                id = record.getId();\n            }\n\n            me.setRecord(record, id);\n            record.commit();\n            ids.push(id);\n        }\n\n        me.setIds(ids);\n\n        operation.setCompleted();\n        operation.setSuccessful();\n\n        if (typeof callback == 'function') {\n            callback.call(scope || me, operation);\n        }\n    },\n\n    //inherit docs\n    read: function(operation, callback, scope) {\n        //TODO: respect sorters, filters, start and limit options on the Operation\n\n        var me = this,\n            records = [],\n            i = 0,\n            success = true,\n            Model = me.model,\n            ids, length, record, data, id;\n\n        operation.setStarted();\n\n        if(me.isHierarchical) {\n            records = me.getTreeData();\n        } else {\n            ids = me.getIds();\n            length = ids.length;\n            id = operation.id;\n            //read a single record\n            if (id) {\n                data = me.getRecord(id);\n                if (data !== null) {\n                    record = new Model(data, id, data);\n                }\n\n                if (record) {\n                    records.push(record);\n                } else {\n                    success = false;\n                }\n            } else {\n                for (; i < length; i++) {\n                    id = ids[i];\n                    data = me.getRecord(id);\n                    records.push(new Model(data, id, data));\n                }\n            }\n\n        }\n\n        if(success) {\n            operation.setSuccessful();\n        }\n        operation.setCompleted();\n\n        operation.resultSet = Ext.create('Ext.data.ResultSet', {\n            records: records,\n            total  : records.length,\n            loaded : true\n        });\n\n        if (typeof callback == 'function') {\n            callback.call(scope || me, operation);\n        }\n    },\n\n    //inherit docs\n    update: function(operation, callback, scope) {\n        var records = operation.records,\n            length  = records.length,\n            ids     = this.getIds(),\n            record, id, i;\n\n        operation.setStarted();\n\n        for (i = 0; i < length; i++) {\n            record = records[i];\n            this.setRecord(record);\n            record.commit();\n\n            //we need to update the set of ids here because it's possible that a non-phantom record was added\n            //to this proxy - in which case the record's id would never have been added via the normal 'create' call\n            id = record.getId();\n            if (id !== undefined && Ext.Array.indexOf(ids, id) == -1) {\n                ids.push(id);\n            }\n        }\n        this.setIds(ids);\n\n        operation.setCompleted();\n        operation.setSuccessful();\n\n        if (typeof callback == 'function') {\n            callback.call(scope || this, operation);\n        }\n    },\n\n    //inherit\n    destroy: function(operation, callback, scope) {\n        var me = this,\n            records = operation.records,\n            ids = me.getIds(),\n            idLength = ids.length,\n            newIds = [],\n            removedHash = {},\n            i = records.length,\n            id;\n\n        operation.setStarted();\n\n        for (; i--;) {\n            Ext.apply(removedHash, me.removeRecord(records[i]));\n        }\n\n        for(i = 0; i < idLength; i++) {\n            id = ids[i];\n            if(!removedHash[id]) {\n                newIds.push(id);\n            }\n        }\n\n        me.setIds(newIds);\n\n        operation.setCompleted();\n        operation.setSuccessful();\n\n        if (typeof callback == 'function') {\n            callback.call(scope || me, operation);\n        }\n    },\n\n    /**\n     * @private\n     * Fetches record data from the Proxy by ID.\n     * @param {String} id The record's unique ID\n     * @return {Object} The record data\n     */\n    getRecord: function(id) {\n        var me = this,\n            cache = me.cache,\n            data = !cache[id] ? Ext.decode(me.getStorageObject().getItem(me.getRecordKey(id))) : cache[id];\n\n        if(!data) {\n            return null;\n        }\n\n        cache[id] = data;\n        data[me.model.prototype.idProperty] = id;\n\n        return data;\n    },\n\n    /**\n     * Saves the given record in the Proxy.\n     * @param {Ext.data.Model} record The model instance\n     * @param {String} [id] The id to save the record under (defaults to the value of the record's getId() function)\n     */\n    setRecord: function(record, id) {\n        if (id) {\n            record.setId(id);\n        } else {\n            id = record.getId();\n        }\n\n        var me = this,\n            rawData = record.data,\n            data    = {},\n            model   = me.model,\n            fields  = model.prototype.fields.items,\n            length  = fields.length,\n            i = 0,\n            field, name, obj, key;\n\n        for (; i < length; i++) {\n            field = fields[i];\n            name  = field.name;\n\n            if(field.persist) {\n                data[name] = rawData[name];\n            }\n        }\n\n        // no need to store the id in the data, since it is already stored in the record key\n        delete data[me.model.prototype.idProperty];\n\n        // if the record is a tree node and it's a direct child of the root node, do not store the parentId\n        if(record.isNode && record.get('depth') === 1) {\n            delete data.parentId;\n        }\n\n        obj = me.getStorageObject();\n        key = me.getRecordKey(id);\n\n        //keep the cache up to date\n        me.cache[id] = data;\n\n        //iPad bug requires that we remove the item before setting it\n        obj.removeItem(key);\n        obj.setItem(key, Ext.encode(data));\n    },\n\n    /**\n     * @private\n     * Physically removes a given record from the local storage and recursively removes children if the record is a tree node. Used internally by {@link #destroy}.\n     * @param {Ext.data.Model} record The record to remove\n     * @return {Object} a hash with the ids of the records that were removed as keys and the records that were removed as values\n     */\n    removeRecord: function(record) {\n        var me = this,\n            id = record.getId(),\n            records = {},\n            i, childNodes;\n\n        records[id] = record;\n        me.getStorageObject().removeItem(me.getRecordKey(id));\n        delete me.cache[id];\n\n        if(record.childNodes) {\n            childNodes = record.childNodes;\n            for(i = childNodes.length; i--;) {\n                Ext.apply(records, me.removeRecord(childNodes[i]));\n            }\n        }\n\n        return records;\n    },\n\n    /**\n     * @private\n     * Given the id of a record, returns a unique string based on that id and the id of this proxy. This is used when\n     * storing data in the local storage object and should prevent naming collisions.\n     * @param {String/Number/Ext.data.Model} id The record id, or a Model instance\n     * @return {String} The unique key for this record\n     */\n    getRecordKey: function(id) {\n        if (id.isModel) {\n            id = id.getId();\n        }\n\n        return Ext.String.format(\"{0}-{1}\", this.id, id);\n    },\n\n    /**\n     * @private\n     * Returns the unique key used to store the current record counter for this proxy. This is used internally when\n     * realizing models (creating them when they used to be phantoms), in order to give each model instance a unique id.\n     * @return {String} The counter key\n     */\n    getRecordCounterKey: function() {\n        return Ext.String.format(\"{0}-counter\", this.id);\n    },\n\n    /**\n     * @private\n     * Returns the unique key used to store the tree indicator. This is used internally to determine if the stored data is hierarchical\n     * @return {String} The counter key\n     */\n    getTreeKey: function() {\n        return Ext.String.format(\"{0}-tree\", this.id);\n    },\n\n    /**\n     * @private\n     * Returns the array of record IDs stored in this Proxy\n     * @return {Number[]} The record IDs. Each is cast as a Number\n     */\n    getIds: function() {\n        var me = this,\n            ids = (me.getStorageObject().getItem(me.id) || \"\").split(\",\"),\n            model = me.model,\n            length = ids.length,\n            isString = model.prototype.fields.get(model.prototype.idProperty).type.type === 'string',\n            i;\n\n        if (length == 1 && ids[0] === \"\") {\n            ids = [];\n        } else {\n            for (i = 0; i < length; i++) {\n                ids[i] = isString ? ids[i] : +ids[i];\n            }\n        }\n\n        return ids;\n    },\n\n    /**\n     * @private\n     * Saves the array of ids representing the set of all records in the Proxy\n     * @param {Number[]} ids The ids to set\n     */\n    setIds: function(ids) {\n        var obj = this.getStorageObject(),\n            str = ids.join(\",\");\n\n        obj.removeItem(this.id);\n\n        if (!Ext.isEmpty(str)) {\n            obj.setItem(this.id, str);\n        }\n    },\n\n    /**\n     * @private\n     * Returns the next numerical ID that can be used when realizing a model instance (see getRecordCounterKey).\n     * Increments the counter.\n     * @return {Number} The id\n     */\n    getNextId: function() {\n        var me = this,\n            obj = me.getStorageObject(),\n            key = me.getRecordCounterKey(),\n            model = me.model,\n            isString = model.prototype.fields.get(model.prototype.idProperty).type.type === 'string',\n            id;\n\n        id = me.idGenerator.generate();\n\n        obj.setItem(key, id);\n\n        if(!isString) {\n            id = +id;\n        }\n\n        return id;\n    },\n\n    /**\n     * Gets tree data and transforms it from key value pairs into a hierarchical structure.\n     * @private\n     * @return {Ext.data.NodeInterface[]}\n     */\n    getTreeData: function() {\n        var me = this,\n            ids = me.getIds(),\n            length = ids.length,\n            records = [],\n            recordHash = {},\n            root = [],\n            i = 0,\n            Model = me.model,\n            idProperty = Model.prototype.idProperty,\n            rootLength, record, parent, parentId, children, id;\n\n        for(; i < length; i++) {\n            id = ids[i];\n            // get the record for each id\n            record = me.getRecord(id);\n            // push the record into the records array\n            records.push(record);\n            // add the record to the record hash so it can be easily retrieved by id later\n            recordHash[id] = record;\n            if(!record.parentId) {\n                // push records that are at the root level (those with no parent id) into the \"root\" array\n                root.push(record);\n            }\n        }\n\n        rootLength = root.length;\n\n        // sort the records by parent id for greater efficiency, so that each parent record only has to be found once for all of its children\n        Ext.Array.sort(records, me.sortByParentId);\n\n        // append each record to its parent, starting after the root node(s), since root nodes do not need to be attached to a parent\n        for(i = rootLength; i < length; i++) {\n            record = records[i];\n            parentId = record.parentId;\n            if(!parent || parent[idProperty] !== parentId) {\n                // if this record has a different parent id from the previous record, we need to look up the parent by id.\n                parent = recordHash[parentId];\n                parent.children = children = [];\n            }\n\n            // push the record onto its parent's children array\n            children.push(record);\n        }\n\n        for(i = length; i--;) {\n            record = records[i];\n            if(!record.children && !record.leaf) {\n                // set non-leaf nodes with no children to loaded so the proxy won't try to dynamically load their contents when they are expanded\n                record.loaded = true;\n            }\n        }\n\n        // Create model instances out of all the \"root-level\" nodes.\n        for(i = rootLength; i--;) {\n            record = root[i];\n            root[i] = new Model(record, record[idProperty], record);\n        }\n\n        return root;\n    },\n\n    /**\n     * Sorter function for sorting records by parentId\n     * @private\n     * @param {Object} node1\n     * @param {Object} node2\n     * @return {Number}\n     */\n    sortByParentId: function(node1, node2) {\n        return (node1.parentId || 0) - (node2.parentId || 0);\n    },\n\n    /**\n     * @private\n     * Sets up the Proxy by claiming the key in the storage object that corresponds to the unique id of this Proxy. Called\n     * automatically by the constructor, this should not need to be called again unless {@link #clear} has been called.\n     */\n    initialize: function() {\n        var me = this,\n            storageObject = me.getStorageObject(),\n            lastId = +storageObject.getItem(me.getRecordCounterKey());\n\n        storageObject.setItem(me.id, storageObject.getItem(me.id) || \"\");\n        if(storageObject.getItem(me.getTreeKey())) {\n            me.isHierarchical = true;\n        }\n\n        me.idGenerator = new Ext.data.SequentialIdGenerator({\n            seed: lastId ? lastId + 1 : 1\n        });\n    },\n\n    /**\n     * Destroys all records stored in the proxy and removes all keys and values used to support the proxy from the\n     * storage object.\n     */\n    clear: function() {\n        var me = this,\n            obj = me.getStorageObject(),\n            ids = me.getIds(),\n            len = ids.length,\n            i;\n\n        //remove all the records\n        for (i = 0; i < len; i++) {\n            obj.removeItem(me.getRecordKey(ids[i]));\n        }\n\n        //remove the supporting objects\n        obj.removeItem(me.getRecordCounterKey());\n        obj.removeItem(me.getTreeKey());\n        obj.removeItem(me.id);\n\n        // clear the cache\n        me.cache = {};\n    },\n\n    /**\n     * @private\n     * Abstract function which should return the storage object that data will be saved to. This must be implemented\n     * in each subclass.\n     * @return {Object} The storage object\n     */\n    getStorageObject: function() {\n        Ext.Error.raise(\"The getStorageObject function has not been defined in your Ext.data.proxy.WebStorage subclass\");\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * The LocalStorageProxy uses the new HTML5 localStorage API to save {@link Ext.data.Model Model} data locally on the\n * client browser. HTML5 localStorage is a key-value store (e.g. cannot save complex objects like JSON), so\n * LocalStorageProxy automatically serializes and deserializes data when saving and retrieving it.\n *\n * localStorage is extremely useful for saving user-specific information without needing to build server-side\n * infrastructure to support it. Let's imagine we're writing a Twitter search application and want to save the user's\n * searches locally so they can easily perform a saved search again later. We'd start by creating a Search model:\n *\n *     Ext.define('Search', {\n *         fields: ['id', 'query'],\n *         extend: 'Ext.data.Model',\n *         proxy: {\n *             type: 'localstorage',\n *             id  : 'twitter-Searches'\n *         }\n *     });\n *\n * Our Search model contains just two fields - id and query - plus a Proxy definition. The only configuration we need to\n * pass to the LocalStorage proxy is an {@link #id}. This is important as it separates the Model data in this Proxy from\n * all others. The localStorage API puts all data into a single shared namespace, so by setting an id we enable\n * LocalStorageProxy to manage the saved Search data.\n *\n * Saving our data into localStorage is easy and would usually be done with a {@link Ext.data.Store Store}:\n *\n *     //our Store automatically picks up the LocalStorageProxy defined on the Search model\n *     var store = Ext.create('Ext.data.Store', {\n *         model: \"Search\"\n *     });\n *\n *     //loads any existing Search data from localStorage\n *     store.load();\n *\n *     //now add some Searches\n *     store.add({query: 'Sencha Touch'});\n *     store.add({query: 'Ext JS'});\n *\n *     //finally, save our Search data to localStorage\n *     store.sync();\n *\n * The LocalStorageProxy automatically gives our new Searches an id when we call store.sync(). It encodes the Model data\n * and places it into localStorage. We can also save directly to localStorage, bypassing the Store altogether:\n *\n *     var search = Ext.create('Search', {query: 'Sencha Animator'});\n *\n *     //uses the configured LocalStorageProxy to save the new Search to localStorage\n *     search.save();\n *\n * # Limitations\n *\n * If this proxy is used in a browser where local storage is not supported, the constructor will throw an error. A local\n * storage proxy requires a unique ID which is used as a key in which all record data are stored in the local storage\n * object.\n *\n * It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided but the\n * attached store has a storeId, the storeId will be used. If neither option is presented the proxy will throw an error.\n */\nExt.define('Ext.data.proxy.LocalStorage', {\n    extend: 'Ext.data.proxy.WebStorage',\n    alias: 'proxy.localstorage',\n    alternateClassName: 'Ext.data.LocalStorageProxy',\n    \n    //inherit docs\n    getStorageObject: function() {\n        return window.localStorage;\n    }\n});\n\n/**\n * @author Ed Spencer\n *\n * The Rest proxy is a specialization of the {@link Ext.data.proxy.Ajax AjaxProxy} which simply maps the four actions\n * (create, read, update and destroy) to RESTful HTTP verbs. For example, let's set up a {@link Ext.data.Model Model}\n * with an inline Rest proxy\n *\n *     Ext.define('User', {\n *         extend: 'Ext.data.Model',\n *         fields: ['id', 'name', 'email'],\n *\n *         proxy: {\n *             type: 'rest',\n *             url : '/users'\n *         }\n *     });\n *\n * Now we can create a new User instance and save it via the Rest proxy. Doing this will cause the Proxy to send a POST\n * request to '/users':\n *\n *     var user = Ext.create('User', {name: 'Ed Spencer', email: 'ed@sencha.com'});\n *\n *     user.save(); //POST /users\n *\n * Let's expand this a little and provide a callback for the {@link Ext.data.Model#save} call to update the Model once\n * it has been created. We'll assume the creation went successfully and that the server gave this user an ID of 123:\n *\n *     user.save({\n *         success: function(user) {\n *             user.set('name', 'Khan Noonien Singh');\n *\n *             user.save(); //PUT /users/123\n *         }\n *     });\n *\n * Now that we're no longer creating a new Model instance, the request method is changed to an HTTP PUT, targeting the\n * relevant url for that user. Now let's delete this user, which will use the DELETE method:\n *\n *         user.destroy(); //DELETE /users/123\n *\n * Finally, when we perform a load of a Model or Store, Rest proxy will use the GET method:\n *\n *     //1. Load via Store\n *\n *     //the Store automatically picks up the Proxy from the User model\n *     var store = Ext.create('Ext.data.Store', {\n *         model: 'User'\n *     });\n *\n *     store.load(); //GET /users\n *\n *     //2. Load directly from the Model\n *\n *     //GET /users/123\n *     Ext.ModelManager.getModel('User').load(123, {\n *         success: function(user) {\n *             console.log(user.getId()); //outputs 123\n *         }\n *     });\n *\n * # Url generation\n *\n * The Rest proxy is able to automatically generate the urls above based on two configuration options - {@link #appendId} and\n * {@link #format}. If appendId is true (it is by default) then Rest proxy will automatically append the ID of the Model\n * instance in question to the configured url, resulting in the '/users/123' that we saw above.\n *\n * If the request is not for a specific Model instance (e.g. loading a Store), the url is not appended with an id.\n * The Rest proxy will automatically insert a '/' before the ID if one is not already present.\n *\n *     new Ext.data.proxy.Rest({\n *         url: '/users',\n *         appendId: true //default\n *     });\n *\n *     // Collection url: /users\n *     // Instance url  : /users/123\n *\n * The Rest proxy can also optionally append a format string to the end of any generated url:\n *\n *     new Ext.data.proxy.Rest({\n *         url: '/users',\n *         format: 'json'\n *     });\n *\n *     // Collection url: /users.json\n *     // Instance url  : /users/123.json\n *\n * If further customization is needed, simply implement the {@link #buildUrl} method and add your custom generated url\n * onto the {@link Ext.data.Request Request} object that is passed to buildUrl. See [Rest proxy's implementation][1] for\n * an example of how to achieve this.\n *\n * Note that Rest proxy inherits from {@link Ext.data.proxy.Ajax AjaxProxy}, which already injects all of the sorter,\n * filter, group and paging options into the generated url. See the {@link Ext.data.proxy.Ajax AjaxProxy docs} for more\n * details.\n *\n * [1]: source/Rest.html#Ext-data-proxy-Rest-method-buildUrl\n */\nExt.define('Ext.data.proxy.Rest', {\n    extend: 'Ext.data.proxy.Ajax',\n    alternateClassName: 'Ext.data.RestProxy',\n    alias : 'proxy.rest',\n    \n    /**\n     * @cfg {Boolean} appendId\n     * True to automatically append the ID of a Model instance when performing a request based on that single instance.\n     * See Rest proxy intro docs for more details. Defaults to true.\n     */\n    appendId: true,\n    \n    /**\n     * @cfg {String} format\n     * Optional data format to send to the server when making any request (e.g. 'json'). See the Rest proxy intro docs\n     * for full details. Defaults to undefined.\n     */\n    \n    /**\n     * @cfg {Boolean} batchActions\n     * True to batch actions of a particular type when synchronizing the store. Defaults to false.\n     */\n    batchActions: false,\n    \n    /**\n     * Specialized version of buildUrl that incorporates the {@link #appendId} and {@link #format} options into the\n     * generated url. Override this to provide further customizations, but remember to call the superclass buildUrl so\n     * that additional parameters like the cache buster string are appended.\n     * @param {Object} request\n     */\n    buildUrl: function(request) {\n        var me        = this,\n            operation = request.operation,\n            records   = operation.records || [],\n            record    = records[0],\n            format    = me.format,\n            url       = me.getUrl(request),\n            id        = record ? record.getId() : operation.id;\n        \n        if (me.appendId && id) {\n            if (!url.match(/\\/$/)) {\n                url += '/';\n            }\n            \n            url += id;\n        }\n        \n        if (format) {\n            if (!url.match(/\\.$/)) {\n                url += '.';\n            }\n            \n            url += format;\n        }\n        \n        request.url = url;\n        \n        return me.callParent(arguments);\n    }\n}, function() {\n    Ext.apply(this.prototype, {\n        /**\n         * @property {Object} actionMethods\n         * Mapping of action name to HTTP request method. These default to RESTful conventions for the 'create', 'read',\n         * 'update' and 'destroy' actions (which map to 'POST', 'GET', 'PUT' and 'DELETE' respectively). This object\n         * should not be changed except globally via {@link Ext#override Ext.override} - the {@link #getMethod} function\n         * can be overridden instead.\n         */\n        actionMethods: {\n            create : 'POST',\n            read   : 'GET',\n            update : 'PUT',\n            destroy: 'DELETE'\n        }\n    });\n});\n\n/**\n * @author Ed Spencer\n *\n * Proxy which uses HTML5 session storage as its data storage/retrieval mechanism. If this proxy is used in a browser\n * where session storage is not supported, the constructor will throw an error. A session storage proxy requires a\n * unique ID which is used as a key in which all record data are stored in the session storage object.\n *\n * It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided but the\n * attached store has a storeId, the storeId will be used. If neither option is presented the proxy will throw an error.\n *\n * Proxies are almost always used with a {@link Ext.data.Store store}:\n *\n *     new Ext.data.Store({\n *         proxy: {\n *             type: 'sessionstorage',\n *             id  : 'myProxyKey'\n *         }\n *     });\n *\n * Alternatively you can instantiate the Proxy directly:\n *\n *     new Ext.data.proxy.SessionStorage({\n *         id  : 'myOtherProxyKey'\n *     });\n *\n * Note that session storage is different to local storage (see {@link Ext.data.proxy.LocalStorage}) - if a browser\n * session is ended (e.g. by closing the browser) then all data in a SessionStorageProxy are lost. Browser restarts\n * don't affect the {@link Ext.data.proxy.LocalStorage} - the data are preserved.\n */\nExt.define('Ext.data.proxy.SessionStorage', {\n    extend: 'Ext.data.proxy.WebStorage',\n    alias: 'proxy.sessionstorage',\n    alternateClassName: 'Ext.data.SessionStorageProxy',\n    \n    //inherit docs\n    getStorageObject: function() {\n        return window.sessionStorage;\n    }\n});\n\n/*\n * This is a derivative of the similarly named class in the YUI Library.\n * The original license:\n * Copyright (c) 2006, Yahoo! Inc. All rights reserved.\n * Code licensed under the BSD License:\n * http://developer.yahoo.net/yui/license.txt\n */\n\n\n/**\n * A DragDrop implementation that does not move, but can be a drop\n * target.  You would get the same result by simply omitting implementation\n * for the event callbacks, but this way we reduce the processing cost of the\n * event listener and the callbacks.\n */\nExt.define('Ext.dd.DDTarget', {\n    extend: 'Ext.dd.DragDrop',\n\n    /**\n     * Creates new DDTarget.\n     * @param {String} id the id of the element that is a drop target\n     * @param {String} sGroup the group of related DragDrop objects\n     * @param {Object} config an object containing configurable attributes.\n     * Valid properties for DDTarget in addition to those in DragDrop: none.\n     */\n    constructor: function(id, sGroup, config) {\n        if (id) {\n            this.initTarget(id, sGroup, config);\n        }\n    },\n\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    getDragEl: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    isValidHandleChild: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    startDrag: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    endDrag: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    onDrag: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    onDragDrop: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    onDragEnter: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    onDragOut: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    onDragOver: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    onInvalidDrop: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    onMouseDown: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    onMouseUp: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    setXConstraint: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    setYConstraint: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    resetConstraints: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    clearConstraints: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    clearTicks: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    setInitPosition: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    setDragElId: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    setHandleElId: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    setOuterHandleElId: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    addInvalidHandleClass: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    addInvalidHandleId: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    addInvalidHandleType: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    removeInvalidHandleClass: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    removeInvalidHandleId: Ext.emptyFn,\n    /**\n     * Overridden and disabled. A DDTarget does not support being dragged.\n     * @method\n     */\n    removeInvalidHandleType: Ext.emptyFn,\n\n    toString: function() {\n        return (\"DDTarget \" + this.id);\n    }\n});\n\n/**\n * A DragTracker listens for drag events on an Element and fires events at the start and end of the drag,\n * as well as during the drag. This is useful for components such as {@link Ext.slider.Multi}, where there is\n * an element that can be dragged around to change the Slider's value.\n *\n * DragTracker provides a series of template methods that should be overridden to provide functionality\n * in response to detected drag operations. These are onBeforeStart, onStart, onDrag and onEnd.\n * See {@link Ext.slider.Multi}'s initEvents function for an example implementation.\n */\nExt.define('Ext.dd.DragTracker', {\n\n    uses: ['Ext.util.Region'],\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @property {Boolean} active\n     * Indicates whether the user is currently dragging this tracker.\n     * @readonly\n     */\n    active: false,\n\n    /**\n     * @property {HTMLElement} dragTarget\n     * The element being dragged.\n     *\n     * Only valid during drag operations.\n     *\n     * If the {@link #delegate} option is used, this will be the delegate element which was mousedowned.\n     * @readonly\n     */\n\n    /**\n     * @cfg {Boolean} trackOver\n     * Set to true to fire mouseover and mouseout events when the mouse enters or leaves the target element.\n     *\n     * This is implicitly set when an {@link #overCls} is specified.\n     *\n     * If the {@link #delegate} option is used, these events fire only when a delegate element is entered of left.\n     */\n    trackOver: false,\n\n    /**\n     * @cfg {String} overCls\n     * A CSS class to add to the DragTracker's target element when the element (or, if the {@link #delegate}\n     * option is used, when a delegate element) is mouseovered.\n     *\n     * If the {@link #delegate} option is used, these events fire only when a delegate element is entered of left.\n     */\n\n    /**\n     * @cfg {Ext.util.Region/Ext.Element} constrainTo\n     * A {@link Ext.util.Region Region} (Or an element from which a Region measurement will be read)\n     * which is used to constrain the result of the {@link #getOffset} call.\n     *\n     * This may be set any time during the DragTracker's lifecycle to set a dynamic constraining region.\n     */\n\n    /**\n     * @cfg {Number} tolerance\n     * Number of pixels the drag target must be moved before dragging is\n     * considered to have started.\n     */\n    tolerance: 5,\n\n    /**\n     * @cfg {Boolean/Number} autoStart\n     * Specify `true` to defer trigger start by 1000 ms.\n     * Specify a Number for the number of milliseconds to defer trigger start.\n     */\n    autoStart: false,\n\n    /**\n     * @cfg {String} delegate\n     * A {@link Ext.DomQuery DomQuery} selector which identifies child elements within the DragTracker's encapsulating\n     * Element which are the tracked elements. This limits tracking to only begin when the matching elements are mousedowned.\n     *\n     * This may also be a specific child element within the DragTracker's encapsulating element to use as the tracked element.\n     */\n\n    /**\n     * @cfg {Boolean} [preventDefault=true]\n     * Specify `false` to enable default actions on onMouseDown events.\n     */\n\n    /**\n     * @cfg {Boolean} [stopEvent=false]\n     * Specify `true` to stop the `mousedown` event from bubbling to outer listeners from the target element (or its delegates).\n     */\n\n    constructor : function(config){\n        var me = this;\n        Ext.apply(me, config);\n        me.addEvents(\n            /**\n             * @event mouseover\n             * Fires when the mouse enters the DragTracker's target element (or if {@link #delegate} is\n             * used, when the mouse enters a delegate element).\n             *\n             * **Only available when {@link #trackOver} is `true`**\n             *\n             * @param {Object} this\n             * @param {Object} e event object\n             * @param {HTMLElement} target The element mouseovered.\n             */\n            'mouseover',\n\n            /**\n             * @event mouseout\n             * Fires when the mouse exits the DragTracker's target element (or if {@link #delegate} is\n             * used, when the mouse exits a delegate element).\n             * \n             * **Only available when {@link #trackOver} is `true`**\n             *\n             * @param {Object} this\n             * @param {Object} e event object\n             */\n            'mouseout',\n\n            /**\n             * @event mousedown\n             * Fires when the mouse button is pressed down, but before a drag operation begins. The\n             * drag operation begins after either the mouse has been moved by {@link #tolerance} pixels,\n             * or after the {@link #autoStart} timer fires.\n             *\n             * Return false to veto the drag operation.\n             *\n             * @param {Object} this\n             * @param {Object} e event object\n             */\n            'mousedown',\n\n            /**\n             * @event mouseup\n             * @param {Object} this\n             * @param {Object} e event object\n             */\n            'mouseup',\n\n            /**\n             * @event mousemove\n             * Fired when the mouse is moved. Returning false cancels the drag operation.\n             * @param {Object} this\n             * @param {Object} e event object\n             */\n            'mousemove',\n\n            /**\n             * @event beforestart\n             * @param {Object} this\n             * @param {Object} e event object\n             */\n            'beforedragstart',\n\n            /**\n             * @event dragstart\n             * @param {Object} this\n             * @param {Object} e event object\n             */\n            'dragstart',\n\n            /**\n             * @event dragend\n             * @param {Object} this\n             * @param {Object} e event object\n             */\n            'dragend',\n\n            /**\n             * @event drag\n             * @param {Object} this\n             * @param {Object} e event object\n             */\n            'drag'\n        );\n\n        me.dragRegion = new Ext.util.Region(0,0,0,0);\n\n        if (me.el) {\n            me.initEl(me.el);\n        }\n\n        // Dont pass the config so that it is not applied to 'this' again\n        me.mixins.observable.constructor.call(me);\n        if (me.disabled) {\n            me.disable();\n        }\n\n    },\n\n    /**\n     * Initializes the DragTracker on a given element.\n     * @param {Ext.Element/HTMLElement} el The element\n     */\n    initEl: function(el) {\n        var me = this;\n        \n        me.el = Ext.get(el);\n\n        // The delegate option may also be an element on which to listen\n        me.handle = Ext.get(me.delegate);\n\n        // If delegate specified an actual element to listen on, we do not use the delegate listener option\n        me.delegate = me.handle ? undefined : me.delegate;\n\n        if (!me.handle) {\n            me.handle = me.el;\n        }\n\n        // Add a mousedown listener which reacts only on the elements targeted by the delegate config.\n        // We process mousedown to begin tracking.\n        me.mon(me.handle, {\n            mousedown: me.onMouseDown,\n            delegate: me.delegate,\n            scope: me\n        });\n\n        // If configured to do so, track mouse entry and exit into the target (or delegate).\n        // The mouseover and mouseout CANNOT be replaced with mouseenter and mouseleave\n        // because delegate cannot work with those pseudoevents. Entry/exit checking is done in the handler.\n        if (me.trackOver || me.overCls) {\n            me.mon(me.handle, {\n                mouseover: me.onMouseOver,\n                mouseout: me.onMouseOut,\n                delegate: me.delegate,\n                scope: me\n            });\n        }\n    },\n\n    disable: function() {\n        this.disabled = true;\n    },\n\n    enable: function() {\n        this.disabled = false;\n    },\n\n    destroy : function() {\n        this.clearListeners();\n        delete this.el;\n    },\n\n    // When the pointer enters a tracking element, fire a mouseover if the mouse entered from outside.\n    // This is mouseenter functionality, but we cannot use mouseenter because we are using \"delegate\" to filter mouse targets\n    onMouseOver: function(e, target) {\n        var me = this;\n        if (!me.disabled) {\n            if (Ext.EventManager.contains(e) || me.delegate) {\n                me.mouseIsOut = false;\n                if (me.overCls) {\n                    me.el.addCls(me.overCls);\n                }\n                me.fireEvent('mouseover', me, e, me.delegate ? e.getTarget(me.delegate, target) : me.handle);\n            }\n        }\n    },\n\n    // When the pointer exits a tracking element, fire a mouseout.\n    // This is mouseleave functionality, but we cannot use mouseleave because we are using \"delegate\" to filter mouse targets\n    onMouseOut: function(e) {\n        var me = this;\n        \n        if (me.mouseIsDown) {\n            me.mouseIsOut = true;\n        } else {\n            if (me.overCls) {\n                me.el.removeCls(me.overCls);\n            }\n            me.fireEvent('mouseout', me, e);\n        }\n    },\n\n    onMouseDown: function(e, target){\n        var me = this,\n            el;\n        \n        // If this is disabled, or the mousedown has been processed by an upstream DragTracker, return\n        if (me.disabled ||e.dragTracked) {\n            return;\n        }\n\n        // This information should be available in mousedown listener and onBeforeStart implementations\n        me.dragTarget = me.delegate ? target : me.handle.dom;\n        me.startXY = me.lastXY = e.getXY();\n        me.startRegion = Ext.fly(me.dragTarget).getRegion();\n\n        if (me.fireEvent('mousedown', me, e) === false ||\n            me.fireEvent('beforedragstart', me, e) === false ||\n            me.onBeforeStart(e) === false) {\n            return;\n        }\n\n        // Track when the mouse is down so that mouseouts while the mouse is down are not processed.\n        // The onMouseOut method will only ever be called after mouseup.\n        me.mouseIsDown = true;\n\n        // Flag for downstream DragTracker instances that the mouse is being tracked.\n        e.dragTracked = true;\n        \n        // See Ext.dd.DragDropManager::handleMouseDown\n        el = me.el.dom;\n        if (Ext.isIE && el.setCapture) {\n            el.setCapture();\n        }\n\n        if (me.preventDefault !== false) {\n            e.preventDefault();\n        }\n        Ext.getDoc().on({\n            scope: me,\n            mouseup: me.onMouseUp,\n            mousemove: me.onMouseMove,\n            selectstart: me.stopSelect\n        });\n        if (me.autoStart) {\n            me.timer =  Ext.defer(me.triggerStart, me.autoStart === true ? 1000 : me.autoStart, me, [e]);\n        }\n    },\n\n    onMouseMove: function(e, target){\n        var me = this,\n            xy = e.getXY(),\n            s = me.startXY;\n\n        e.preventDefault();\n\n        me.lastXY = xy;\n        if (!me.active) {\n            if (Math.max(Math.abs(s[0]-xy[0]), Math.abs(s[1]-xy[1])) > me.tolerance) {\n                me.triggerStart(e);\n            } else {\n                return;\n            }\n        }\n\n        // Returning false from a mousemove listener deactivates\n        if (me.fireEvent('mousemove', me, e) === false) {\n            me.onMouseUp(e);\n        } else {\n            me.onDrag(e);\n            me.fireEvent('drag', me, e);\n        }\n    },\n\n    onMouseUp: function(e) {\n        var me = this;\n        // Clear the flag which ensures onMouseOut fires only after the mouse button\n        // is lifted if the mouseout happens *during* a drag.\n        me.mouseIsDown = false;\n\n        // If we mouseouted the el *during* the drag, the onMouseOut method will not have fired. Ensure that it gets processed.\n        if (me.mouseIsOut) {\n            me.mouseIsOut = false;\n            me.onMouseOut(e);\n        }\n        e.preventDefault();\n        \n        // See Ext.dd.DragDropManager::handleMouseDown\n        if (Ext.isIE && document.releaseCapture) {\n            document.releaseCapture();\n        }\n        \n        me.fireEvent('mouseup', me, e);\n        me.endDrag(e);\n    },\n\n    /**\n     * @private\n     * Stop the drag operation, and remove active mouse listeners.\n     */\n    endDrag: function(e) {\n        var me = this,\n            doc = Ext.getDoc(),\n            wasActive = me.active;\n\n        doc.un('mousemove', me.onMouseMove, me);\n        doc.un('mouseup', me.onMouseUp, me);\n        doc.un('selectstart', me.stopSelect, me);\n        me.clearStart();\n        me.active = false;\n        if (wasActive) {\n            me.onEnd(e);\n            me.fireEvent('dragend', me, e);\n        }\n        // Private property calculated when first required and only cached during a drag\n        delete me._constrainRegion;\n\n        // Remove flag from event singleton.  Using \"Ext.EventObject\" here since \"endDrag\" is called directly in some cases without an \"e\" param\n        delete Ext.EventObject.dragTracked;\n    },\n\n    triggerStart: function(e) {\n        var me = this;\n        me.clearStart();\n        me.active = true;\n        me.onStart(e);\n        me.fireEvent('dragstart', me, e);\n    },\n\n    clearStart : function() {\n        var timer = this.timer;\n        if (timer) {\n            clearTimeout(timer);\n            delete this.timer;\n        }\n    },\n\n    stopSelect : function(e) {\n        e.stopEvent();\n        return false;\n    },\n\n    /**\n     * Template method which should be overridden by each DragTracker instance. Called when the user first clicks and\n     * holds the mouse button down. Return false to disallow the drag\n     * @param {Ext.EventObject} e The event object\n     * @template\n     */\n    onBeforeStart : function(e) {\n\n    },\n\n    /**\n     * Template method which should be overridden by each DragTracker instance. Called when a drag operation starts\n     * (e.g. the user has moved the tracked element beyond the specified tolerance)\n     * @param {Ext.EventObject} e The event object\n     * @template\n     */\n    onStart : function(xy) {\n\n    },\n\n    /**\n     * Template method which should be overridden by each DragTracker instance. Called whenever a drag has been detected.\n     * @param {Ext.EventObject} e The event object\n     * @template\n     */\n    onDrag : function(e) {\n\n    },\n\n    /**\n     * Template method which should be overridden by each DragTracker instance. Called when a drag operation has been completed\n     * (e.g. the user clicked and held the mouse down, dragged the element and then released the mouse button)\n     * @param {Ext.EventObject} e The event object\n     * @template\n     */\n    onEnd : function(e) {\n\n    },\n\n    /**\n     * Returns the drag target. This is usually the DragTracker's encapsulating element.\n     *\n     * If the {@link #delegate} option is being used, this may be a child element which matches the\n     * {@link #delegate} selector.\n     *\n     * @return {Ext.Element} The element currently being tracked.\n     */\n    getDragTarget : function(){\n        return this.dragTarget;\n    },\n\n    /**\n     * @private\n     * @returns {Ext.Element} The DragTracker's encapsulating element.\n     */\n    getDragCt : function(){\n        return this.el;\n    },\n\n    /**\n     * @private\n     * Return the Region into which the drag operation is constrained.\n     * Either the XY pointer itself can be constrained, or the dragTarget element\n     * The private property _constrainRegion is cached until onMouseUp\n     */\n    getConstrainRegion: function() {\n        var me = this;\n        \n        if (me.constrainTo) {\n            if (me.constrainTo instanceof Ext.util.Region) {\n                return me.constrainTo;\n            }\n            if (!me._constrainRegion) {\n                me._constrainRegion = Ext.fly(me.constrainTo).getViewRegion();\n            }\n        } else {\n            if (!me._constrainRegion) {\n                me._constrainRegion = me.getDragCt().getViewRegion();\n            }\n        }\n        return me._constrainRegion;\n    },\n\n    getXY : function(constrain){\n        return constrain ? this.constrainModes[constrain](this, this.lastXY) : this.lastXY;\n    },\n\n    /**\n     * Returns the X, Y offset of the current mouse position from the mousedown point.\n     *\n     * This method may optionally constrain the real offset values, and returns a point coerced in one\n     * of two modes:\n     *\n     *  - `point`\n     *    The current mouse position is coerced into the constrainRegion and the resulting position is returned.\n     *  - `dragTarget`\n     *    The new {@link Ext.util.Region Region} of the {@link #getDragTarget dragTarget} is calculated\n     *    based upon the current mouse position, and then coerced into the constrainRegion. The returned\n     *    mouse position is then adjusted by the same delta as was used to coerce the region.\\\n     *\n     * @param constrainMode {String} (Optional) If omitted the true mouse position is returned. May be passed\n     * as `point` or `dragTarget`. See above.\n     * @returns {Number[]} The `X, Y` offset from the mousedown point, optionally constrained.\n     */\n    getOffset : function(constrain){\n        var xy = this.getXY(constrain),\n            s = this.startXY;\n\n        return [xy[0]-s[0], xy[1]-s[1]];\n    },\n\n    constrainModes: {\n        // Constrain the passed point to within the constrain region\n        point: function(me, xy) {\n            var dr = me.dragRegion,\n                constrainTo = me.getConstrainRegion();\n\n            // No constraint\n            if (!constrainTo) {\n                return xy;\n            }\n\n            dr.x = dr.left = dr[0] = dr.right = xy[0];\n            dr.y = dr.top = dr[1] = dr.bottom = xy[1];\n            dr.constrainTo(constrainTo);\n\n            return [dr.left, dr.top];\n        },\n\n        // Constrain the dragTarget to within the constrain region. Return the passed xy adjusted by the same delta.\n        dragTarget: function(me, xy) {\n            var s = me.startXY,\n                dr = me.startRegion.copy(),\n                constrainTo = me.getConstrainRegion(),\n                adjust;\n\n            // No constraint\n            if (!constrainTo) {\n                return xy;\n            }\n\n            // See where the passed XY would put the dragTarget if translated by the unconstrained offset.\n            // If it overflows, we constrain the passed XY to bring the potential\n            // region back within the boundary.\n            dr.translateBy(xy[0]-s[0], xy[1]-s[1]);\n\n            // Constrain the X coordinate by however much the dragTarget overflows\n            if (dr.right > constrainTo.right) {\n                xy[0] += adjust = (constrainTo.right - dr.right);    // overflowed the right\n                dr.left += adjust;\n            }\n            if (dr.left < constrainTo.left) {\n                xy[0] += (constrainTo.left - dr.left);      // overflowed the left\n            }\n\n            // Constrain the Y coordinate by however much the dragTarget overflows\n            if (dr.bottom > constrainTo.bottom) {\n                xy[1] += adjust = (constrainTo.bottom - dr.bottom);  // overflowed the bottom\n                dr.top += adjust;\n            }\n            if (dr.top < constrainTo.top) {\n                xy[1] += (constrainTo.top - dr.top);        // overflowed the top\n            }\n            return xy;\n        }\n    }\n});\n\n/**\n * This class provides a container DD instance that allows dragging of multiple child source nodes.\n *\n * This class does not move the drag target nodes, but a proxy element which may contain any DOM structure you wish. The\n * DOM element to show in the proxy is provided by either a provided implementation of {@link #getDragData}, or by\n * registered draggables registered with {@link Ext.dd.Registry}\n *\n * If you wish to provide draggability for an arbitrary number of DOM nodes, each of which represent some application\n * object (For example nodes in a {@link Ext.view.View DataView}) then use of this class is the most efficient way to\n * \"activate\" those nodes.\n *\n * By default, this class requires that draggable child nodes are registered with {@link Ext.dd.Registry}. However a\n * simpler way to allow a DragZone to manage any number of draggable elements is to configure the DragZone with an\n * implementation of the {@link #getDragData} method which interrogates the passed mouse event to see if it has taken\n * place within an element, or class of elements. This is easily done by using the event's {@link\n * Ext.EventObject#getTarget getTarget} method to identify a node based on a {@link Ext.DomQuery} selector. For example,\n * to make the nodes of a DataView draggable, use the following technique. Knowledge of the use of the DataView is\n * required:\n *\n *     myDataView.on('render', function(v) {\n *         myDataView.dragZone = new Ext.dd.DragZone(v.getEl(), {\n *\n *     //      On receipt of a mousedown event, see if it is within a DataView node.\n *     //      Return a drag data object if so.\n *             getDragData: function(e) {\n *\n *     //          Use the DataView's own itemSelector (a mandatory property) to\n *     //          test if the mousedown is within one of the DataView's nodes.\n *                 var sourceEl = e.getTarget(v.itemSelector, 10);\n *\n *     //          If the mousedown is within a DataView node, clone the node to produce\n *     //          a ddel element for use by the drag proxy. Also add application data\n *     //          to the returned data object.\n *                 if (sourceEl) {\n *                     d = sourceEl.cloneNode(true);\n *                     d.id = Ext.id();\n *                     return {\n *                         ddel: d,\n *                         sourceEl: sourceEl,\n *                         repairXY: Ext.fly(sourceEl).getXY(),\n *                         sourceStore: v.store,\n *                         draggedRecord: v.{@link Ext.view.View#getRecord getRecord}(sourceEl)\n *                     }\n *                 }\n *             },\n *\n *     //      Provide coordinates for the proxy to slide back to on failed drag.\n *     //      This is the original XY coordinates of the draggable element captured\n *     //      in the getDragData method.\n *             getRepairXY: function() {\n *                 return this.dragData.repairXY;\n *             }\n *         });\n *     });\n *\n * See the {@link Ext.dd.DropZone DropZone} documentation for details about building a DropZone which cooperates with\n * this DragZone.\n */\nExt.define('Ext.dd.DragZone', {\n    extend: 'Ext.dd.DragSource',\n\n    /**\n     * Creates new DragZone.\n     * @param {String/HTMLElement/Ext.Element} el The container element or ID of it.\n     * @param {Object} config\n     */\n    constructor : function(el, config){\n        this.callParent([el, config]);\n        if (this.containerScroll) {\n            Ext.dd.ScrollManager.register(this.el);\n        }\n    },\n\n    /**\n     * @property {Object} dragData\n     * This property contains the data representing the dragged object. This data is set up by the implementation of the\n     * {@link #getDragData} method. It must contain a ddel property, but can contain any other data according to the\n     * application's needs.\n     */\n\n    /**\n     * @cfg {Boolean} containerScroll\n     * True to register this container with the Scrollmanager for auto scrolling during drag operations.\n     */\n\n    /**\n     * Called when a mousedown occurs in this container. Looks in {@link Ext.dd.Registry} for a valid target to drag\n     * based on the mouse down. Override this method to provide your own lookup logic (e.g. finding a child by class\n     * name). Make sure your returned object has a \"ddel\" attribute (with an HTML Element) for other functions to work.\n     * @param {Event} e The mouse down event\n     * @return {Object} The dragData\n     */\n    getDragData : function(e){\n        return Ext.dd.Registry.getHandleFromEvent(e);\n    },\n\n    /**\n     * Called once drag threshold has been reached to initialize the proxy element. By default, it clones the\n     * this.dragData.ddel\n     * @param {Number} x The x position of the click on the dragged object\n     * @param {Number} y The y position of the click on the dragged object\n     * @return {Boolean} true to continue the drag, false to cancel\n     * @template\n     */\n    onInitDrag : function(x, y){\n        this.proxy.update(this.dragData.ddel.cloneNode(true));\n        this.onStartDrag(x, y);\n        return true;\n    },\n\n    /**\n     * Called after a repair of an invalid drop. By default, highlights this.dragData.ddel\n     * @template\n     */\n    afterRepair : function(){\n        var me = this;\n        if (Ext.enableFx) {\n            Ext.fly(me.dragData.ddel).highlight(me.repairHighlightColor);\n        }\n        me.dragging = false;\n    },\n\n    /**\n     * Called before a repair of an invalid drop to get the XY to animate to. By default returns the XY of\n     * this.dragData.ddel\n     * @param {Event} e The mouse up event\n     * @return {Number[]} The xy location (e.g. `[100, 200]`)\n     * @template\n     */\n    getRepairXY : function(e){\n        return Ext.fly(this.dragData.ddel).getXY();\n    },\n\n    destroy : function(){\n        this.callParent();\n        if (this.containerScroll) {\n            Ext.dd.ScrollManager.unregister(this.el);\n        }\n    }\n});\n\n/**\n * Provides automatic scrolling of overflow regions in the page during drag operations.\n *\n * The ScrollManager configs will be used as the defaults for any scroll container registered with it, but you can also\n * override most of the configs per scroll container by adding a ddScrollConfig object to the target element that\n * contains these properties: {@link #hthresh}, {@link #vthresh}, {@link #increment} and {@link #frequency}. Example\n * usage:\n *\n *     var el = Ext.get('scroll-ct');\n *     el.ddScrollConfig = {\n *         vthresh: 50,\n *         hthresh: -1,\n *         frequency: 100,\n *         increment: 200\n *     };\n *     Ext.dd.ScrollManager.register(el);\n *\n * Note: This class is designed to be used in \"Point Mode\n */\nExt.define('Ext.dd.ScrollManager', {\n    singleton: true,\n    requires: [\n        'Ext.dd.DragDropManager'\n    ],\n\n    constructor: function() {\n        var ddm = Ext.dd.DragDropManager;\n        ddm.fireEvents = Ext.Function.createSequence(ddm.fireEvents, this.onFire, this);\n        ddm.stopDrag = Ext.Function.createSequence(ddm.stopDrag, this.onStop, this);\n        this.doScroll = Ext.Function.bind(this.doScroll, this);\n        this.ddmInstance = ddm;\n        this.els = {};\n        this.dragEl = null;\n        this.proc = {};\n    },\n\n    onStop: function(e){\n        var sm = Ext.dd.ScrollManager;\n        sm.dragEl = null;\n        sm.clearProc();\n    },\n\n    triggerRefresh: function() {\n        if (this.ddmInstance.dragCurrent) {\n            this.ddmInstance.refreshCache(this.ddmInstance.dragCurrent.groups);\n        }\n    },\n\n    doScroll: function() {\n        if (this.ddmInstance.dragCurrent) {\n            var proc   = this.proc,\n                procEl = proc.el,\n                ddScrollConfig = proc.el.ddScrollConfig,\n                inc = ddScrollConfig ? ddScrollConfig.increment : this.increment;\n\n            if (!this.animate) {\n                if (procEl.scroll(proc.dir, inc)) {\n                    this.triggerRefresh();\n                }\n            } else {\n                procEl.scroll(proc.dir, inc, true, this.animDuration, this.triggerRefresh);\n            }\n        }\n    },\n\n    clearProc: function() {\n        var proc = this.proc;\n        if (proc.id) {\n            clearInterval(proc.id);\n        }\n        proc.id = 0;\n        proc.el = null;\n        proc.dir = \"\";\n    },\n\n    startProc: function(el, dir) {\n        this.clearProc();\n        this.proc.el = el;\n        this.proc.dir = dir;\n        var group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup : undefined,\n            freq  = (el.ddScrollConfig && el.ddScrollConfig.frequency)\n                  ? el.ddScrollConfig.frequency\n                  : this.frequency;\n\n        if (group === undefined || this.ddmInstance.dragCurrent.ddGroup == group) {\n            this.proc.id = setInterval(this.doScroll, freq);\n        }\n    },\n\n    onFire: function(e, isDrop) {\n        if (isDrop || !this.ddmInstance.dragCurrent) {\n            return;\n        }\n        if (!this.dragEl || this.dragEl != this.ddmInstance.dragCurrent) {\n            this.dragEl = this.ddmInstance.dragCurrent;\n            // refresh regions on drag start\n            this.refreshCache();\n        }\n\n        var xy = e.getXY(),\n            pt = e.getPoint(),\n            proc = this.proc,\n            els = this.els,\n            id, el, r, c;\n\n        for (id in els) {\n            el = els[id];\n            r = el._region;\n            c = el.ddScrollConfig ? el.ddScrollConfig : this;\n            if (r && r.contains(pt) && el.isScrollable()) {\n                if (r.bottom - pt.y <= c.vthresh) {\n                    if(proc.el != el){\n                        this.startProc(el, \"down\");\n                    }\n                    return;\n                }else if (r.right - pt.x <= c.hthresh) {\n                    if (proc.el != el) {\n                        this.startProc(el, \"left\");\n                    }\n                    return;\n                } else if(pt.y - r.top <= c.vthresh) {\n                    if (proc.el != el) {\n                        this.startProc(el, \"up\");\n                    }\n                    return;\n                } else if(pt.x - r.left <= c.hthresh) {\n                    if (proc.el != el) {\n                        this.startProc(el, \"right\");\n                    }\n                    return;\n                }\n            }\n        }\n        this.clearProc();\n    },\n\n    /**\n     * Registers new overflow element(s) to auto scroll\n     * @param {String/HTMLElement/Ext.Element/String[]/HTMLElement[]/Ext.Element[]} el\n     * The id of or the element to be scrolled or an array of either\n     */\n    register : function(el){\n        if (Ext.isArray(el)) {\n            for(var i = 0, len = el.length; i < len; i++) {\n                    this.register(el[i]);\n            }\n        } else {\n            el = Ext.get(el);\n            this.els[el.id] = el;\n        }\n    },\n\n    /**\n     * Unregisters overflow element(s) so they are no longer scrolled\n     * @param {String/HTMLElement/Ext.Element/String[]/HTMLElement[]/Ext.Element[]} el\n     * The id of or the element to be removed or an array of either\n     */\n    unregister : function(el){\n        if(Ext.isArray(el)){\n            for (var i = 0, len = el.length; i < len; i++) {\n                this.unregister(el[i]);\n            }\n        }else{\n            el = Ext.get(el);\n            delete this.els[el.id];\n        }\n    },\n\n    /**\n     * The number of pixels from the top or bottom edge of a container the pointer needs to be to trigger scrolling\n     */\n    vthresh : 25,\n\n    /**\n     * The number of pixels from the right or left edge of a container the pointer needs to be to trigger scrolling\n     */\n    hthresh : 25,\n\n    /**\n     * The number of pixels to scroll in each scroll increment\n     */\n    increment : 100,\n\n    /**\n     * The frequency of scrolls in milliseconds\n     */\n    frequency : 500,\n\n    /**\n     * True to animate the scroll\n     */\n    animate: true,\n\n    /**\n     * The animation duration in seconds - MUST BE less than Ext.dd.ScrollManager.frequency!\n     */\n    animDuration: 0.4,\n\n    /**\n     * @property {String} ddGroup\n     * The named drag drop {@link Ext.dd.DragSource#ddGroup group} to which this container belongs. If a ddGroup is\n     * specified, then container scrolling will only occur when a dragged object is in the same ddGroup.\n     */\n    ddGroup: undefined,\n\n    /**\n     * Manually trigger a cache refresh.\n     */\n    refreshCache : function(){\n        var els = this.els,\n            id;\n        for (id in els) {\n            if(typeof els[id] == 'object'){ // for people extending the object prototype\n                els[id]._region = els[id].getRegion();\n            }\n        }\n    }\n});\n\n/**\n * A simple class that provides the basic implementation needed to make any element a drop target that can have\n * draggable items dropped onto it.  The drop has no effect until an implementation of notifyDrop is provided.\n */\nExt.define('Ext.dd.DropTarget', {\n    extend: 'Ext.dd.DDTarget',\n    requires: ['Ext.dd.ScrollManager'],\n\n    /**\n     * Creates new DropTarget.\n     * @param {String/HTMLElement/Ext.Element} el The container element or ID of it.\n     * @param {Object} config\n     */\n    constructor : function(el, config){\n        this.el = Ext.get(el);\n\n        Ext.apply(this, config);\n\n        if(this.containerScroll){\n            Ext.dd.ScrollManager.register(this.el);\n        }\n\n        this.callParent([this.el.dom, this.ddGroup || this.group,\n              {isTarget: true}]);\n    },\n\n    /**\n     * @cfg {String} ddGroup\n     * A named drag drop group to which this object belongs.  If a group is specified, then this object will only\n     * interact with other drag drop objects in the same group.\n     */\n    /**\n     * @cfg {String} [overClass=\"\"]\n     * The CSS class applied to the drop target element while the drag source is over it.\n     */\n    /**\n     * @cfg {String} dropAllowed\n     * The CSS class returned to the drag source when drop is allowed.\n     */\n    dropAllowed : Ext.baseCSSPrefix + 'dd-drop-ok',\n    /**\n     * @cfg {String} dropNotAllowed\n     * The CSS class returned to the drag source when drop is not allowed.\n     */\n    dropNotAllowed : Ext.baseCSSPrefix + 'dd-drop-nodrop',\n\n    // private\n    isTarget : true,\n\n    // private\n    isNotifyTarget : true,\n\n    /**\n     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source is now over the\n     * target.  This default implementation adds the CSS class specified by overClass (if any) to the drop element\n     * and returns the dropAllowed config value.  This method should be overridden if drop validation is required.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {String} status The CSS class that communicates the drop status back to the source so that the\n     * underlying {@link Ext.dd.StatusProxy} can be updated\n     * @template\n     */\n    notifyEnter : function(dd, e, data){\n        if(this.overClass){\n            this.el.addCls(this.overClass);\n        }\n        return this.dropAllowed;\n    },\n\n    /**\n     * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the target.\n     * This method will be called on every mouse movement while the drag source is over the drop target.\n     * This default implementation simply returns the dropAllowed config value.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {String} status The CSS class that communicates the drop status back to the source so that the\n     * underlying {@link Ext.dd.StatusProxy} can be updated\n     * @template\n     */\n    notifyOver : function(dd, e, data){\n        return this.dropAllowed;\n    },\n\n    /**\n     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source has been dragged\n     * out of the target without dropping.  This default implementation simply removes the CSS class specified by\n     * overClass (if any) from the drop element.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @template\n     */\n    notifyOut : function(dd, e, data){\n        if(this.overClass){\n            this.el.removeCls(this.overClass);\n        }\n    },\n\n    /**\n     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the dragged item has\n     * been dropped on it.  This method has no default implementation and returns false, so you must provide an\n     * implementation that does something to process the drop event and returns true so that the drag source's\n     * repair action does not run.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {Boolean} False if the drop was invalid.\n     * @template\n     */\n    notifyDrop : function(dd, e, data){\n        return false;\n    },\n\n    destroy : function(){\n        this.callParent();\n        if(this.containerScroll){\n            Ext.dd.ScrollManager.unregister(this.el);\n        }\n    }\n});\n\n/**\n * Provides easy access to all drag drop components that are registered on a page. Items can be retrieved either\n * directly by DOM node id, or by passing in the drag drop event that occurred and looking up the event target.\n */\nExt.define('Ext.dd.Registry', {\n    singleton: true,\n    constructor: function() {\n        this.elements = {}; \n        this.handles = {}; \n        this.autoIdSeed = 0;\n    },\n    \n    getId: function(el, autogen){\n        if(typeof el == \"string\"){\n            return el;\n        }\n        var id = el.id;\n        if(!id && autogen !== false){\n            id = \"extdd-\" + (++this.autoIdSeed);\n            el.id = id;\n        }\n        return id;\n    },\n    \n    /**\n     * Registers a drag drop element.\n     *\n     * @param {String/HTMLElement} element The id or DOM node to register\n     * @param {Object} data An custom data object that will be passed between the elements that are involved in drag\n     * drop operations. You can populate this object with any arbitrary properties that your own code knows how to\n     * interpret, plus there are some specific properties known to the Registry that should be populated in the data\n     * object (if applicable):\n     * @param {HTMLElement[]} data.handles Array of DOM nodes that trigger dragging for the element being registered.\n     * @param {Boolean} data.isHandle True if the element passed in triggers dragging itself, else false.\n     */\n    register : function(el, data){\n        data = data || {};\n        if (typeof el == \"string\") {\n            el = document.getElementById(el);\n        }\n        data.ddel = el;\n        this.elements[this.getId(el)] = data;\n        if (data.isHandle !== false) {\n            this.handles[data.ddel.id] = data;\n        }\n        if (data.handles) {\n            var hs = data.handles,\n                i, len;\n            for (i = 0, len = hs.length; i < len; i++) {\n                this.handles[this.getId(hs[i])] = data;\n            }\n        }\n    },\n\n    /**\n     * Unregister a drag drop element\n     * @param {String/HTMLElement} element The id or DOM node to unregister\n     */\n    unregister : function(el){\n        var id = this.getId(el, false),\n            data = this.elements[id],\n            hs, i, len;\n        if(data){\n            delete this.elements[id];\n            if(data.handles){\n                hs = data.handles;\n                for (i = 0, len = hs.length; i < len; i++) {\n                    delete this.handles[this.getId(hs[i], false)];\n                }\n            }\n        }\n    },\n\n    /**\n     * Returns the handle registered for a DOM Node by id\n     * @param {String/HTMLElement} id The DOM node or id to look up\n     * @return {Object} handle The custom handle data\n     */\n    getHandle : function(id){\n        if(typeof id != \"string\"){ // must be element?\n            id = id.id;\n        }\n        return this.handles[id];\n    },\n\n    /**\n     * Returns the handle that is registered for the DOM node that is the target of the event\n     * @param {Event} e The event\n     * @return {Object} handle The custom handle data\n     */\n    getHandleFromEvent : function(e){\n        var t = e.getTarget();\n        return t ? this.handles[t.id] : null;\n    },\n\n    /**\n     * Returns a custom data object that is registered for a DOM node by id\n     * @param {String/HTMLElement} id The DOM node or id to look up\n     * @return {Object} data The custom data\n     */\n    getTarget : function(id){\n        if(typeof id != \"string\"){ // must be element?\n            id = id.id;\n        }\n        return this.elements[id];\n    },\n\n    /**\n     * Returns a custom data object that is registered for the DOM node that is the target of the event\n     * @param {Event} e The event\n     * @return {Object} data The custom data\n     */\n    getTargetFromEvent : function(e){\n        var t = e.getTarget();\n        return t ? this.elements[t.id] || this.handles[t.id] : null;\n    }\n});\n\n/**\n * This class provides a container DD instance that allows dropping on multiple child target nodes.\n *\n * By default, this class requires that child nodes accepting drop are registered with {@link Ext.dd.Registry}.\n * However a simpler way to allow a DropZone to manage any number of target elements is to configure the\n * DropZone with an implementation of {@link #getTargetFromEvent} which interrogates the passed\n * mouse event to see if it has taken place within an element, or class of elements. This is easily done\n * by using the event's {@link Ext.EventObject#getTarget getTarget} method to identify a node based on a\n * {@link Ext.DomQuery} selector.\n *\n * Once the DropZone has detected through calling getTargetFromEvent, that the mouse is over\n * a drop target, that target is passed as the first parameter to {@link #onNodeEnter}, {@link #onNodeOver},\n * {@link #onNodeOut}, {@link #onNodeDrop}. You may configure the instance of DropZone with implementations\n * of these methods to provide application-specific behaviour for these events to update both\n * application state, and UI state.\n *\n * For example to make a GridPanel a cooperating target with the example illustrated in\n * {@link Ext.dd.DragZone DragZone}, the following technique might be used:\n *\n *     myGridPanel.on('render', function() {\n *         myGridPanel.dropZone = new Ext.dd.DropZone(myGridPanel.getView().scroller, {\n *\n *             // If the mouse is over a grid row, return that node. This is\n *             // provided as the \"target\" parameter in all \"onNodeXXXX\" node event handling functions\n *             getTargetFromEvent: function(e) {\n *                 return e.getTarget(myGridPanel.getView().rowSelector);\n *             },\n *\n *             // On entry into a target node, highlight that node.\n *             onNodeEnter : function(target, dd, e, data){\n *                 Ext.fly(target).addCls('my-row-highlight-class');\n *             },\n *\n *             // On exit from a target node, unhighlight that node.\n *             onNodeOut : function(target, dd, e, data){\n *                 Ext.fly(target).removeCls('my-row-highlight-class');\n *             },\n *\n *             // While over a target node, return the default drop allowed class which\n *             // places a \"tick\" icon into the drag proxy.\n *             onNodeOver : function(target, dd, e, data){\n *                 return Ext.dd.DropZone.prototype.dropAllowed;\n *             },\n *\n *             // On node drop we can interrogate the target to find the underlying\n *             // application object that is the real target of the dragged data.\n *             // In this case, it is a Record in the GridPanel's Store.\n *             // We can use the data set up by the DragZone's getDragData method to read\n *             // any data we decided to attach in the DragZone's getDragData method.\n *             onNodeDrop : function(target, dd, e, data){\n *                 var rowIndex = myGridPanel.getView().findRowIndex(target);\n *                 var r = myGridPanel.getStore().getAt(rowIndex);\n *                 Ext.Msg.alert('Drop gesture', 'Dropped Record id ' + data.draggedRecord.id +\n *                     ' on Record id ' + r.id);\n *                 return true;\n *             }\n *         });\n *     }\n *\n * See the {@link Ext.dd.DragZone DragZone} documentation for details about building a DragZone which\n * cooperates with this DropZone.\n */\nExt.define('Ext.dd.DropZone', {\n    extend: 'Ext.dd.DropTarget',\n    requires: ['Ext.dd.Registry'],\n\n    /**\n     * Returns a custom data object associated with the DOM node that is the target of the event.  By default\n     * this looks up the event target in the {@link Ext.dd.Registry}, although you can override this method to\n     * provide your own custom lookup.\n     * @param {Event} e The event\n     * @return {Object} data The custom data\n     */\n    getTargetFromEvent : function(e){\n        return Ext.dd.Registry.getTargetFromEvent(e);\n    },\n\n    /**\n     * Called when the DropZone determines that a {@link Ext.dd.DragSource} has entered a drop node\n     * that has either been registered or detected by a configured implementation of {@link #getTargetFromEvent}.\n     * This method has no default implementation and should be overridden to provide\n     * node-specific processing if necessary.\n     * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from \n     * {@link #getTargetFromEvent} for this node)\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     */\n    onNodeEnter : function(n, dd, e, data){\n        \n    },\n\n    /**\n     * Called while the DropZone determines that a {@link Ext.dd.DragSource} is over a drop node\n     * that has either been registered or detected by a configured implementation of {@link #getTargetFromEvent}.\n     * The default implementation returns this.dropAllowed, so it should be\n     * overridden to provide the proper feedback.\n     * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from\n     * {@link #getTargetFromEvent} for this node)\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {String} status The CSS class that communicates the drop status back to the source so that the\n     * underlying {@link Ext.dd.StatusProxy} can be updated\n     * @template\n     */\n    onNodeOver : function(n, dd, e, data){\n        return this.dropAllowed;\n    },\n\n    /**\n     * Called when the DropZone determines that a {@link Ext.dd.DragSource} has been dragged out of\n     * the drop node without dropping.  This method has no default implementation and should be overridden to provide\n     * node-specific processing if necessary.\n     * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from\n     * {@link #getTargetFromEvent} for this node)\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @template\n     */\n    onNodeOut : function(n, dd, e, data){\n        \n    },\n\n    /**\n     * Called when the DropZone determines that a {@link Ext.dd.DragSource} has been dropped onto\n     * the drop node.  The default implementation returns false, so it should be overridden to provide the\n     * appropriate processing of the drop event and return true so that the drag source's repair action does not run.\n     * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from\n     * {@link #getTargetFromEvent} for this node)\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {Boolean} True if the drop was valid, else false\n     * @template\n     */\n    onNodeDrop : function(n, dd, e, data){\n        return false;\n    },\n\n    /**\n     * Called while the DropZone determines that a {@link Ext.dd.DragSource} is being dragged over it,\n     * but not over any of its registered drop nodes.  The default implementation returns this.dropNotAllowed, so\n     * it should be overridden to provide the proper feedback if necessary.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {String} status The CSS class that communicates the drop status back to the source so that the\n     * underlying {@link Ext.dd.StatusProxy} can be updated\n     * @template\n     */\n    onContainerOver : function(dd, e, data){\n        return this.dropNotAllowed;\n    },\n\n    /**\n     * Called when the DropZone determines that a {@link Ext.dd.DragSource} has been dropped on it,\n     * but not on any of its registered drop nodes.  The default implementation returns false, so it should be\n     * overridden to provide the appropriate processing of the drop event if you need the drop zone itself to\n     * be able to accept drops.  It should return true when valid so that the drag source's repair action does not run.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {Boolean} True if the drop was valid, else false\n     * @template\n     */\n    onContainerDrop : function(dd, e, data){\n        return false;\n    },\n\n    /**\n     * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the source is now over\n     * the zone.  The default implementation returns this.dropNotAllowed and expects that only registered drop\n     * nodes can process drag drop operations, so if you need the drop zone itself to be able to process drops\n     * you should override this method and provide a custom implementation.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {String} status The CSS class that communicates the drop status back to the source so that the\n     * underlying {@link Ext.dd.StatusProxy} can be updated\n     * @template\n     */\n    notifyEnter : function(dd, e, data){\n        return this.dropNotAllowed;\n    },\n\n    /**\n     * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the drop zone.\n     * This method will be called on every mouse movement while the drag source is over the drop zone.\n     * It will call {@link #onNodeOver} while the drag source is over a registered node, and will also automatically\n     * delegate to the appropriate node-specific methods as necessary when the drag source enters and exits\n     * registered nodes ({@link #onNodeEnter}, {@link #onNodeOut}). If the drag source is not currently over a\n     * registered node, it will call {@link #onContainerOver}.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {String} status The CSS class that communicates the drop status back to the source so that the\n     * underlying {@link Ext.dd.StatusProxy} can be updated\n     * @template\n     */\n    notifyOver : function(dd, e, data){\n        var n = this.getTargetFromEvent(e);\n        if(!n) { // not over valid drop target\n            if(this.lastOverNode){\n                this.onNodeOut(this.lastOverNode, dd, e, data);\n                this.lastOverNode = null;\n            }\n            return this.onContainerOver(dd, e, data);\n        }\n        if(this.lastOverNode != n){\n            if(this.lastOverNode){\n                this.onNodeOut(this.lastOverNode, dd, e, data);\n            }\n            this.onNodeEnter(n, dd, e, data);\n            this.lastOverNode = n;\n        }\n        return this.onNodeOver(n, dd, e, data);\n    },\n\n    /**\n     * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the source has been dragged\n     * out of the zone without dropping.  If the drag source is currently over a registered node, the notification\n     * will be delegated to {@link #onNodeOut} for node-specific handling, otherwise it will be ignored.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag zone\n     * @template\n     */\n    notifyOut : function(dd, e, data){\n        if(this.lastOverNode){\n            this.onNodeOut(this.lastOverNode, dd, e, data);\n            this.lastOverNode = null;\n        }\n    },\n\n    /**\n     * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the dragged item has\n     * been dropped on it.  The drag zone will look up the target node based on the event passed in, and if there\n     * is a node registered for that event, it will delegate to {@link #onNodeDrop} for node-specific handling,\n     * otherwise it will call {@link #onContainerDrop}.\n     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone\n     * @param {Event} e The event\n     * @param {Object} data An object containing arbitrary data supplied by the drag source\n     * @return {Boolean} False if the drop was invalid.\n     * @template\n     */\n    notifyDrop : function(dd, e, data){\n        if(this.lastOverNode){\n            this.onNodeOut(this.lastOverNode, dd, e, data);\n            this.lastOverNode = null;\n        }\n        var n = this.getTargetFromEvent(e);\n        return n ?\n            this.onNodeDrop(n, dd, e, data) :\n            this.onContainerDrop(dd, e, data);\n    },\n\n    // private\n    triggerCacheRefresh : function() {\n        Ext.dd.DDM.refreshCache(this.groups);\n    }\n});\n\n/**\n * @class Ext.direct.Event\n * A base class for all Ext.direct events. An event is\n * created after some kind of interaction with the server.\n * The event class is essentially just a data structure\n * to hold a Direct response.\n */\nExt.define('Ext.direct.Event', {\n\n    /* Begin Definitions */\n\n    alias: 'direct.event',\n\n    requires: ['Ext.direct.Manager'],\n\n    /* End Definitions */\n\n    status: true,\n\n    /**\n     * Creates new Event.\n     * @param {Object} config (optional) Config object.\n     */\n    constructor: function(config) {\n        Ext.apply(this, config);\n    },\n\n    /**\n     * Return the raw data for this event.\n     * @return {Object} The data from the event\n     */\n    getData: function(){\n        return this.data;\n    }\n});\n\n/**\n * @class Ext.direct.RemotingEvent\n * An event that is fired when data is received from a \n * {@link Ext.direct.RemotingProvider}. Contains a method to the\n * related transaction for the direct request, see {@link #getTransaction}\n */\nExt.define('Ext.direct.RemotingEvent', {\n    \n    /* Begin Definitions */\n   \n    extend: 'Ext.direct.Event',\n    \n    alias: 'direct.rpc',\n    \n    /* End Definitions */\n    \n    /**\n     * Get the transaction associated with this event.\n     * @return {Ext.direct.Transaction} The transaction\n     */\n    getTransaction: function(){\n        return this.transaction || Ext.direct.Manager.getTransaction(this.tid);\n    }\n});\n\n/**\n * @class Ext.direct.ExceptionEvent\n * An event that is fired when an exception is received from a {@link Ext.direct.RemotingProvider}\n */\nExt.define('Ext.direct.ExceptionEvent', {\n    \n    /* Begin Definitions */\n   \n    extend: 'Ext.direct.RemotingEvent',\n    \n    alias: 'direct.exception',\n    \n    /* End Definitions */\n   \n   status: false\n});\n\n/**\n * Ext.direct.Provider is an abstract class meant to be extended.\n *\n * For example Ext JS implements the following subclasses:\n *\n *     Provider\n *     |\n *     +---{@link Ext.direct.JsonProvider JsonProvider}\n *         |\n *         +---{@link Ext.direct.PollingProvider PollingProvider}\n *         |\n *         +---{@link Ext.direct.RemotingProvider RemotingProvider}\n *\n * @abstract\n */\nExt.define('Ext.direct.Provider', {\n\n    /* Begin Definitions */\n\n   alias: 'direct.provider',\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /* End Definitions */\n\n   /**\n     * @cfg {String} id\n     * The unique id of the provider (defaults to an {@link Ext#id auto-assigned id}).\n     * You should assign an id if you need to be able to access the provider later and you do\n     * not have an object reference available, for example:\n     *\n     *     Ext.direct.Manager.addProvider({\n     *         type: 'polling',\n     *         url:  'php/poll.php',\n     *         id:   'poll-provider'\n     *     });\n     *     var p = {@link Ext.direct.Manager}.{@link Ext.direct.Manager#getProvider getProvider}('poll-provider');\n     *     p.disconnect();\n     *\n     */\n\n    constructor : function(config){\n        var me = this;\n\n        Ext.apply(me, config);\n        me.addEvents(\n            /**\n             * @event connect\n             * Fires when the Provider connects to the server-side\n             * @param {Ext.direct.Provider} provider The {@link Ext.direct.Provider Provider}.\n             */\n            'connect',\n            /**\n             * @event disconnect\n             * Fires when the Provider disconnects from the server-side\n             * @param {Ext.direct.Provider} provider The {@link Ext.direct.Provider Provider}.\n             */\n            'disconnect',\n            /**\n             * @event data\n             * Fires when the Provider receives data from the server-side\n             * @param {Ext.direct.Provider} provider The {@link Ext.direct.Provider Provider}.\n             * @param {Ext.direct.Event} e The Ext.direct.Event type that occurred.\n             */\n            'data',\n            /**\n             * @event exception\n             * Fires when the Provider receives an exception from the server-side\n             */\n            'exception'\n        );\n        me.mixins.observable.constructor.call(me, config);\n    },\n\n    /**\n     * Returns whether or not the server-side is currently connected.\n     * Abstract method for subclasses to implement.\n     */\n    isConnected: function(){\n        return false;\n    },\n\n    /**\n     * Abstract methods for subclasses to implement.\n     * @method\n     */\n    connect: Ext.emptyFn,\n\n    /**\n     * Abstract methods for subclasses to implement.\n     * @method\n     */\n    disconnect: Ext.emptyFn\n});\n\n/**\n * @class Ext.direct.JsonProvider\n\nA base provider for communicating using JSON. This is an abstract class\nand should not be instanced directly.\n\n * @markdown\n * @abstract\n */\n\nExt.define('Ext.direct.JsonProvider', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.direct.Provider',\n\n    alias: 'direct.jsonprovider',\n\n    uses: ['Ext.direct.ExceptionEvent'],\n\n    /* End Definitions */\n\n   /**\n    * Parse the JSON response\n    * @private\n    * @param {Object} response The XHR response object\n    * @return {Object} The data in the response.\n    */\n   parseResponse: function(response){\n        if (!Ext.isEmpty(response.responseText)) {\n            if (Ext.isObject(response.responseText)) {\n                return response.responseText;\n            }\n            return Ext.decode(response.responseText);\n        }\n        return null;\n    },\n\n    /**\n     * Creates a set of events based on the XHR response\n     * @private\n     * @param {Object} response The XHR response\n     * @return {Ext.direct.Event[]} An array of Ext.direct.Event\n     */\n    createEvents: function(response){\n        var data = null,\n            events = [],\n            event,\n            i = 0,\n            len;\n\n        try{\n            data = this.parseResponse(response);\n        } catch(e) {\n            event = new Ext.direct.ExceptionEvent({\n                data: e,\n                xhr: response,\n                code: Ext.direct.Manager.exceptions.PARSE,\n                message: 'Error parsing json response: \\n\\n ' + data\n            });\n            return [event];\n        }\n\n        if (Ext.isArray(data)) {\n            for (len = data.length; i < len; ++i) {\n                events.push(this.createEvent(data[i]));\n            }\n        } else {\n            events.push(this.createEvent(data));\n        }\n        return events;\n    },\n\n    /**\n     * Create an event from a response object\n     * @param {Object} response The XHR response object\n     * @return {Ext.direct.Event} The event\n     */\n    createEvent: function(response){\n        return Ext.create('direct.' + response.type, response);\n    }\n});\n\n/**\n * @class Ext.direct.PollingProvider\n *\n * <p>Provides for repetitive polling of the server at distinct {@link #interval intervals}.\n * The initial request for data originates from the client, and then is responded to by the\n * server.</p>\n * \n * <p>All configurations for the PollingProvider should be generated by the server-side\n * API portion of the Ext.Direct stack.</p>\n *\n * <p>An instance of PollingProvider may be created directly via the new keyword or by simply\n * specifying <tt>type = 'polling'</tt>.  For example:</p>\n * <pre><code>\nvar pollA = new Ext.direct.PollingProvider({\n    type:'polling',\n    url: 'php/pollA.php',\n});\nExt.direct.Manager.addProvider(pollA);\npollA.disconnect();\n\nExt.direct.Manager.addProvider(\n    {\n        type:'polling',\n        url: 'php/pollB.php',\n        id: 'pollB-provider'\n    }\n);\nvar pollB = Ext.direct.Manager.getProvider('pollB-provider');\n * </code></pre>\n */\nExt.define('Ext.direct.PollingProvider', {\n    \n    /* Begin Definitions */\n    \n    extend: 'Ext.direct.JsonProvider',\n    \n    alias: 'direct.pollingprovider',\n    \n    uses: ['Ext.direct.ExceptionEvent'],\n    \n    requires: ['Ext.Ajax', 'Ext.util.DelayedTask'],\n    \n    /* End Definitions */\n    \n    /**\n     * @cfg {Number} interval\n     * How often to poll the server-side in milliseconds. Defaults to every 3 seconds.\n     */\n    interval: 3000,\n\n    /**\n     * @cfg {Object} baseParams\n     * An object containing properties which are to be sent as parameters on every polling request\n     */\n    \n    /**\n     * @cfg {String/Function} url\n     * The url which the PollingProvider should contact with each request. This can also be\n     * an imported Ext.Direct method which will accept the baseParams as its only argument.\n     */\n\n    // private\n    constructor : function(config){\n        this.callParent(arguments);\n        this.addEvents(\n            /**\n             * @event beforepoll\n             * Fired immediately before a poll takes place, an event handler can return false\n             * in order to cancel the poll.\n             * @param {Ext.direct.PollingProvider} this\n             */\n            'beforepoll',            \n            /**\n             * @event poll\n             * This event has not yet been implemented.\n             * @param {Ext.direct.PollingProvider} this\n             */\n            'poll'\n        );\n    },\n\n    // inherited\n    isConnected: function(){\n        return !!this.pollTask;\n    },\n\n    /**\n     * Connect to the server-side and begin the polling process. To handle each\n     * response subscribe to the data event.\n     */\n    connect: function(){\n        var me = this, url = me.url;\n        \n        if (url && !me.pollTask) {\n            me.pollTask = Ext.TaskManager.start({\n                run: function(){\n                    if (me.fireEvent('beforepoll', me) !== false) {\n                        if (Ext.isFunction(url)) {\n                            url(me.baseParams);\n                        } else {\n                            Ext.Ajax.request({\n                                url: url,\n                                callback: me.onData,\n                                scope: me,\n                                params: me.baseParams\n                            });\n                        }\n                    }\n                },\n                interval: me.interval,\n                scope: me\n            });\n            me.fireEvent('connect', me);\n        } else if (!url) {\n            Ext.Error.raise('Error initializing PollingProvider, no url configured.');\n        }\n    },\n\n    /**\n     * Disconnect from the server-side and stop the polling process. The disconnect\n     * event will be fired on a successful disconnect.\n     */\n    disconnect: function(){\n        var me = this;\n        \n        if (me.pollTask) {\n            Ext.TaskManager.stop(me.pollTask);\n            delete me.pollTask;\n            me.fireEvent('disconnect', me);\n        }\n    },\n\n    // private\n    onData: function(opt, success, response){\n        var me = this, \n            i = 0, \n            len,\n            events;\n        \n        if (success) {\n            events = me.createEvents(response);\n            for (len = events.length; i < len; ++i) {\n                me.fireEvent('data', me, events[i]);\n            }\n        } else {\n            me.fireEvent('data', me, new Ext.direct.ExceptionEvent({\n                data: null,\n                code: Ext.direct.Manager.exceptions.TRANSPORT,\n                message: 'Unable to connect to the server.',\n                xhr: response\n            }));\n        }\n    }\n});\n\n/**\n * Small utility class used internally to represent a Direct method.\n * @private\n */\nExt.define('Ext.direct.RemotingMethod', {\n\n    constructor: function(config){\n        var me = this,\n            params = Ext.isDefined(config.params) ? config.params : config.len,\n            name, pLen, p, param;\n\n        me.name = config.name;\n        me.formHandler = config.formHandler;\n        if (Ext.isNumber(params)) {\n            // given only the number of parameters\n            me.len = params;\n            me.ordered = true;\n        } else {\n            /*\n             * Given an array of either\n             * a) String\n             * b) Objects with a name property. We may want to encode extra info in here later\n             */\n            me.params = [];\n\t\t\tpLen = params.length;\n            for (p = 0; p < pLen; p++) {\n                param = params[p];\n                name  = Ext.isObject(param) ? param.name : param;\n                me.params.push(name);\n            }\n        }\n    },\n    \n    getArgs: function(params, paramOrder, paramsAsHash){\n        var args = [],\n            i,\n            len;\n        \n        if (this.ordered) {\n            if (this.len > 0) {\n                // If a paramOrder was specified, add the params into the argument list in that order.\n                if (paramOrder) {\n                    for (i = 0, len = paramOrder.length; i < len; i++) {\n                        args.push(params[paramOrder[i]]);\n                    }\n                } else if (paramsAsHash) {\n                    // If paramsAsHash was specified, add all the params as a single object argument.\n                    args.push(params);\n                }\n            }\n        } else {\n            args.push(params);\n        } \n        \n        return args;\n    },\n\n    /**\n     * Takes the arguments for the Direct function and splits the arguments\n     * from the scope and the callback.\n     * @param {Array} args The arguments passed to the direct call\n     * @return {Object} An object with 3 properties, args, callback & scope.\n     */\n    getCallData: function(args){\n        var me = this,\n            data = null,\n            len  = me.len,\n            params = me.params,\n            callback,\n            scope,\n            name;\n\n        if (me.ordered) {\n            callback = args[len];\n            scope = args[len + 1];\n            if (len !== 0) {\n                data = args.slice(0, len);\n            }\n        } else {\n            data = Ext.apply({}, args[0]);\n            callback = args[1];\n            scope = args[2];\n\n            // filter out any non-existent properties\n            for (name in data) {\n                if (data.hasOwnProperty(name)) {\n                    if (!Ext.Array.contains(params, name)) {\n                        delete data[name];\n                    }\n                }\n            }\n        }\n\n        return {\n            data: data,\n            callback: callback,\n            scope: scope\n        };\n    }\n});\n\n/**\n * Supporting Class for Ext.Direct (not intended to be used directly).\n */\nExt.define('Ext.direct.Transaction', {\n    \n    /* Begin Definitions */\n   \n    alias: 'direct.transaction',\n    alternateClassName: 'Ext.Direct.Transaction',\n   \n    statics: {\n        TRANSACTION_ID: 0\n    },\n   \n    /* End Definitions */\n\n    /**\n     * Creates new Transaction.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config){\n        var me = this;\n        \n        Ext.apply(me, config);\n        me.id = me.tid = ++me.self.TRANSACTION_ID;\n        me.retryCount = 0;\n    },\n   \n    send: function(){\n         this.provider.queueTransaction(this);\n    },\n\n    retry: function(){\n        this.retryCount++;\n        this.send();\n    },\n\n    getProvider: function(){\n        return this.provider;\n    }\n});\n\n/**\n * @class Ext.direct.RemotingProvider\n * \n * <p>The {@link Ext.direct.RemotingProvider RemotingProvider} exposes access to\n * server side methods on the client (a remote procedure call (RPC) type of\n * connection where the client can initiate a procedure on the server).</p>\n * \n * <p>This allows for code to be organized in a fashion that is maintainable,\n * while providing a clear path between client and server, something that is\n * not always apparent when using URLs.</p>\n * \n * <p>To accomplish this the server-side needs to describe what classes and methods\n * are available on the client-side. This configuration will typically be\n * outputted by the server-side Ext.Direct stack when the API description is built.</p>\n */\nExt.define('Ext.direct.RemotingProvider', {\n    \n    /* Begin Definitions */\n   \n    alias: 'direct.remotingprovider',\n    \n    extend: 'Ext.direct.JsonProvider', \n    \n    requires: [\n        'Ext.util.MixedCollection', \n        'Ext.util.DelayedTask', \n        'Ext.direct.Transaction',\n        'Ext.direct.RemotingMethod'\n    ],\n   \n    /* End Definitions */\n   \n   /**\n     * @cfg {Object} actions\n     * Object literal defining the server side actions and methods. For example, if\n     * the Provider is configured with:\n     * <pre><code>\n\"actions\":{ // each property within the 'actions' object represents a server side Class \n    \"TestAction\":[ // array of methods within each server side Class to be   \n    {              // stubbed out on client\n        \"name\":\"doEcho\", \n        \"len\":1            \n    },{\n        \"name\":\"multiply\",// name of method\n        \"len\":2           // The number of parameters that will be used to create an\n                          // array of data to send to the server side function.\n                          // Ensure the server sends back a Number, not a String. \n    },{\n        \"name\":\"doForm\",\n        \"formHandler\":true, // direct the client to use specialized form handling method \n        \"len\":1\n    }]\n}\n     * </code></pre>\n     * <p>Note that a Store is not required, a server method can be called at any time.\n     * In the following example a <b>client side</b> handler is used to call the\n     * server side method \"multiply\" in the server-side \"TestAction\" Class:</p>\n     * <pre><code>\nTestAction.multiply(\n    2, 4, // pass two arguments to server, so specify len=2\n    // callback function after the server is called\n    // result: the result returned by the server\n    //      e: Ext.direct.RemotingEvent object\n    function(result, e){\n        var t = e.getTransaction();\n        var action = t.action; // server side Class called\n        var method = t.method; // server side method called\n        if(e.status){\n            var answer = Ext.encode(result); // 8\n    \n        }else{\n            var msg = e.message; // failure message\n        }\n    }\n);\n     * </code></pre>\n     * In the example above, the server side \"multiply\" function will be passed two\n     * arguments (2 and 4).  The \"multiply\" method should return the value 8 which will be\n     * available as the <tt>result</tt> in the example above. \n     */\n    \n    /**\n     * @cfg {String/Object} namespace\n     * Namespace for the Remoting Provider (defaults to the browser global scope of <i>window</i>).\n     * Explicitly specify the namespace Object, or specify a String to have a\n     * {@link Ext#namespace namespace created} implicitly.\n     */\n    \n    /**\n     * @cfg {String} url\n     * <b>Required</b>. The url to connect to the {@link Ext.direct.Manager} server-side router. \n     */\n    \n    /**\n     * @cfg {String} enableUrlEncode\n     * Specify which param will hold the arguments for the method.\n     * Defaults to <tt>'data'</tt>.\n     */\n    \n    /**\n     * @cfg {Number/Boolean} enableBuffer\n     * <p><tt>true</tt> or <tt>false</tt> to enable or disable combining of method\n     * calls. If a number is specified this is the amount of time in milliseconds\n     * to wait before sending a batched request.</p>\n     * <br><p>Calls which are received within the specified timeframe will be\n     * concatenated together and sent in a single request, optimizing the\n     * application by reducing the amount of round trips that have to be made\n     * to the server.</p>\n     */\n    enableBuffer: 10,\n    \n    /**\n     * @cfg {Number} maxRetries\n     * Number of times to re-attempt delivery on failure of a call.\n     */\n    maxRetries: 1,\n    \n    /**\n     * @cfg {Number} timeout\n     * The timeout to use for each request.\n     */\n    timeout: undefined,\n    \n    constructor : function(config){\n        var me = this;\n        me.callParent(arguments);\n        me.addEvents(\n            /**\n             * @event beforecall\n             * Fires immediately before the client-side sends off the RPC call.\n             * By returning false from an event handler you can prevent the call from\n             * executing.\n             * @param {Ext.direct.RemotingProvider} provider\n             * @param {Ext.direct.Transaction} transaction\n             * @param {Object} meta The meta data\n             */            \n            'beforecall',            \n            /**\n             * @event call\n             * Fires immediately after the request to the server-side is sent. This does\n             * NOT fire after the response has come back from the call.\n             * @param {Ext.direct.RemotingProvider} provider\n             * @param {Ext.direct.Transaction} transaction\n             * @param {Object} meta The meta data\n             */            \n            'call'\n        );\n        me.namespace = (Ext.isString(me.namespace)) ? Ext.ns(me.namespace) : me.namespace || window;\n        me.transactions = new Ext.util.MixedCollection();\n        me.callBuffer = [];\n    },\n    \n    /**\n     * Initialize the API\n     * @private\n     */\n    initAPI : function(){\n        var actions = this.actions,\n            namespace = this.namespace,\n            action,\n            cls,\n            methods,\n            i,\n            len,\n            method;\n            \n        for (action in actions) {\n            if (actions.hasOwnProperty(action)) {\n                cls = namespace[action];\n                if (!cls) {\n                    cls = namespace[action] = {};\n                }\n                methods = actions[action];\n                \n                for (i = 0, len = methods.length; i < len; ++i) {\n                    method = new Ext.direct.RemotingMethod(methods[i]);\n                    cls[method.name] = this.createHandler(action, method);\n                }\n            }\n        }\n    },\n    \n    /**\n     * Create a handler function for a direct call.\n     * @private\n     * @param {String} action The action the call is for\n     * @param {Object} method The details of the method\n     * @return {Function} A JS function that will kick off the call\n     */\n    createHandler : function(action, method){\n        var me = this,\n            handler;\n        \n        if (!method.formHandler) {\n            handler = function(){\n                me.configureRequest(action, method, Array.prototype.slice.call(arguments, 0));\n            };\n        } else {\n            handler = function(form, callback, scope){\n                me.configureFormRequest(action, method, form, callback, scope);\n            };\n        }\n        handler.directCfg = {\n            action: action,\n            method: method\n        };\n        return handler;\n    },\n    \n    // inherit docs\n    isConnected: function(){\n        return !!this.connected;\n    },\n\n    // inherit docs\n    connect: function(){\n        var me = this;\n        \n        if (me.url) {\n            me.initAPI();\n            me.connected = true;\n            me.fireEvent('connect', me);\n        } else if(!me.url) {\n            Ext.Error.raise('Error initializing RemotingProvider, no url configured.');\n        }\n    },\n\n    // inherit docs\n    disconnect: function(){\n        var me = this;\n        \n        if (me.connected) {\n            me.connected = false;\n            me.fireEvent('disconnect', me);\n        }\n    },\n    \n    /**\n     * Run any callbacks related to the transaction.\n     * @private\n     * @param {Ext.direct.Transaction} transaction The transaction\n     * @param {Ext.direct.Event} event The event\n     */\n    runCallback: function(transaction, event){\n        var success = !!event.status,\n            funcName = success ? 'success' : 'failure',\n            callback,\n            result;\n        \n        if (transaction && transaction.callback) {\n            callback = transaction.callback;\n            result = Ext.isDefined(event.result) ? event.result : event.data;\n        \n            if (Ext.isFunction(callback)) {\n                callback(result, event, success);\n            } else {\n                Ext.callback(callback[funcName], callback.scope, [result, event, success]);\n                Ext.callback(callback.callback, callback.scope, [result, event, success]);\n            }\n        }\n    },\n    \n    /**\n     * React to the ajax request being completed\n     * @private\n     */\n    onData: function(options, success, response){\n        var me = this,\n            i = 0,\n            len,\n            events,\n            event,\n            transaction,\n            transactions;\n            \n        if (success) {\n            events = me.createEvents(response);\n            for (len = events.length; i < len; ++i) {\n                event = events[i];\n                transaction = me.getTransaction(event);\n                me.fireEvent('data', me, event);\n                if (transaction) {\n                    me.runCallback(transaction, event, true);\n                    Ext.direct.Manager.removeTransaction(transaction);\n                }\n            }\n        } else {\n            transactions = [].concat(options.transaction);\n            for (len = transactions.length; i < len; ++i) {\n                transaction = me.getTransaction(transactions[i]);\n                if (transaction && transaction.retryCount < me.maxRetries) {\n                    transaction.retry();\n                } else {\n                    event = new Ext.direct.ExceptionEvent({\n                        data: null,\n                        transaction: transaction,\n                        code: Ext.direct.Manager.exceptions.TRANSPORT,\n                        message: 'Unable to connect to the server.',\n                        xhr: response\n                    });\n                    me.fireEvent('data', me, event);\n                    if (transaction) {\n                        me.runCallback(transaction, event, false);\n                        Ext.direct.Manager.removeTransaction(transaction);\n                    }\n                }\n            }\n        }\n    },\n    \n    /**\n     * Get transaction from XHR options\n     * @private\n     * @param {Object} options The options sent to the Ajax request\n     * @return {Ext.direct.Transaction} The transaction, null if not found\n     */\n    getTransaction: function(options){\n        return options && options.tid ? Ext.direct.Manager.getTransaction(options.tid) : null;\n    },\n    \n    /**\n     * Configure a direct request\n     * @private\n     * @param {String} action The action being executed\n     * @param {Object} method The being executed\n     */\n    configureRequest: function(action, method, args){\n        var me = this,\n            callData = method.getCallData(args),\n            data = callData.data, \n            callback = callData.callback, \n            scope = callData.scope,\n            transaction;\n\n        transaction = new Ext.direct.Transaction({\n            provider: me,\n            args: args,\n            action: action,\n            method: method.name,\n            data: data,\n            callback: scope && Ext.isFunction(callback) ? Ext.Function.bind(callback, scope) : callback\n        });\n\n        if (me.fireEvent('beforecall', me, transaction, method) !== false) {\n            Ext.direct.Manager.addTransaction(transaction);\n            me.queueTransaction(transaction);\n            me.fireEvent('call', me, transaction, method);\n        }\n    },\n    \n    /**\n     * Gets the Ajax call info for a transaction\n     * @private\n     * @param {Ext.direct.Transaction} transaction The transaction\n     * @return {Object} The call params\n     */\n    getCallData: function(transaction){\n        return {\n            action: transaction.action,\n            method: transaction.method,\n            data: transaction.data,\n            type: 'rpc',\n            tid: transaction.id\n        };\n    },\n    \n    /**\n     * Sends a request to the server\n     * @private\n     * @param {Object/Array} data The data to send\n     */\n    sendRequest : function(data){\n        var me = this,\n            request = {\n                url: me.url,\n                callback: me.onData,\n                scope: me,\n                transaction: data,\n                timeout: me.timeout\n            }, callData,\n            enableUrlEncode = me.enableUrlEncode,\n            i = 0,\n            len,\n            params;\n            \n\n        if (Ext.isArray(data)) {\n            callData = [];\n            for (len = data.length; i < len; ++i) {\n                callData.push(me.getCallData(data[i]));\n            }\n        } else {\n            callData = me.getCallData(data);\n        }\n\n        if (enableUrlEncode) {\n            params = {};\n            params[Ext.isString(enableUrlEncode) ? enableUrlEncode : 'data'] = Ext.encode(callData);\n            request.params = params;\n        } else {\n            request.jsonData = callData;\n        }\n        Ext.Ajax.request(request);\n    },\n    \n    /**\n     * Add a new transaction to the queue\n     * @private\n     * @param {Ext.direct.Transaction} transaction The transaction\n     */\n    queueTransaction: function(transaction){\n        var me = this,\n            enableBuffer = me.enableBuffer;\n        \n        if (transaction.form) {\n            me.sendFormRequest(transaction);\n            return;\n        }\n        \n        me.callBuffer.push(transaction);\n        if (enableBuffer) {\n            if (!me.callTask) {\n                me.callTask = new Ext.util.DelayedTask(me.combineAndSend, me);\n            }\n            me.callTask.delay(Ext.isNumber(enableBuffer) ? enableBuffer : 10);\n        } else {\n            me.combineAndSend();\n        }\n    },\n    \n    /**\n     * Combine any buffered requests and send them off\n     * @private\n     */\n    combineAndSend : function(){\n        var buffer = this.callBuffer,\n            len = buffer.length;\n            \n        if (len > 0) {\n            this.sendRequest(len == 1 ? buffer[0] : buffer);\n            this.callBuffer = [];\n        }\n    },\n    \n    /**\n     * Configure a form submission request\n     * @private\n     * @param {String} action The action being executed\n     * @param {Object} method The method being executed\n     * @param {HTMLElement} form The form being submitted\n     * @param {Function} callback (optional) A callback to run after the form submits\n     * @param {Object} scope (optional) A scope to execute the callback in\n     */\n    configureFormRequest : function(action, method, form, callback, scope){\n        var me = this,\n            transaction = new Ext.direct.Transaction({\n                provider: me,\n                action: action,\n                method: method.name,\n                args: [form, callback, scope],\n                callback: scope && Ext.isFunction(callback) ? Ext.Function.bind(callback, scope) : callback,\n                isForm: true\n            }),\n            isUpload,\n            params;\n\n        if (me.fireEvent('beforecall', me, transaction, method) !== false) {\n            Ext.direct.Manager.addTransaction(transaction);\n            isUpload = String(form.getAttribute(\"enctype\")).toLowerCase() == 'multipart/form-data';\n            \n            params = {\n                extTID: transaction.id,\n                extAction: action,\n                extMethod: method.name,\n                extType: 'rpc',\n                extUpload: String(isUpload)\n            };\n            \n            // change made from typeof callback check to callback.params\n            // to support addl param passing in DirectSubmit EAC 6/2\n            Ext.apply(transaction, {\n                form: Ext.getDom(form),\n                isUpload: isUpload,\n                params: callback && Ext.isObject(callback.params) ? Ext.apply(params, callback.params) : params\n            });\n            me.fireEvent('call', me, transaction, method);\n            me.sendFormRequest(transaction);\n        }\n    },\n    \n    /**\n     * Sends a form request\n     * @private\n     * @param {Ext.direct.Transaction} transaction The transaction to send\n     */\n    sendFormRequest: function(transaction){\n        Ext.Ajax.request({\n            url: this.url,\n            params: transaction.params,\n            callback: this.onData,\n            scope: this,\n            form: transaction.form,\n            isUpload: transaction.isUpload,\n            transaction: transaction\n        });\n    }\n    \n});\n\n/**\n * @private\n */\nExt.define('Ext.draw.Matrix', {\n\n    /* Begin Definitions */\n\n    requires: ['Ext.draw.Draw'],\n\n    /* End Definitions */\n\n    constructor: function(a, b, c, d, e, f) {\n        if (a != null) {\n            this.matrix = [[a, c, e], [b, d, f], [0, 0, 1]];\n        }\n        else {\n            this.matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];\n        }\n    },\n\n    add: function(a, b, c, d, e, f) {\n        var me = this,\n            out = [[], [], []],\n            matrix = [[a, c, e], [b, d, f], [0, 0, 1]],\n            x,\n            y,\n            z,\n            res;\n\n        for (x = 0; x < 3; x++) {\n            for (y = 0; y < 3; y++) {\n                res = 0;\n                for (z = 0; z < 3; z++) {\n                    res += me.matrix[x][z] * matrix[z][y];\n                }\n                out[x][y] = res;\n            }\n        }\n        me.matrix = out;\n    },\n\n    prepend: function(a, b, c, d, e, f) {\n        var me = this,\n            out = [[], [], []],\n            matrix = [[a, c, e], [b, d, f], [0, 0, 1]],\n            x,\n            y,\n            z,\n            res;\n\n        for (x = 0; x < 3; x++) {\n            for (y = 0; y < 3; y++) {\n                res = 0;\n                for (z = 0; z < 3; z++) {\n                    res += matrix[x][z] * me.matrix[z][y];\n                }\n                out[x][y] = res;\n            }\n        }\n        me.matrix = out;\n    },\n\n    invert: function() {\n        var matrix = this.matrix,\n            a = matrix[0][0],\n            b = matrix[1][0],\n            c = matrix[0][1],\n            d = matrix[1][1],\n            e = matrix[0][2],\n            f = matrix[1][2],\n            x = a * d - b * c;\n        return new Ext.draw.Matrix(d / x, -b / x, -c / x, a / x, (c * f - d * e) / x, (b * e - a * f) / x);\n    },\n\n    clone: function() {\n        var matrix = this.matrix,\n            a = matrix[0][0],\n            b = matrix[1][0],\n            c = matrix[0][1],\n            d = matrix[1][1],\n            e = matrix[0][2],\n            f = matrix[1][2];\n        return new Ext.draw.Matrix(a, b, c, d, e, f);\n    },\n\n    translate: function(x, y) {\n        this.prepend(1, 0, 0, 1, x, y);\n    },\n\n    scale: function(x, y, cx, cy) {\n        var me = this;\n        if (y == null) {\n            y = x;\n        }\n        me.add(x, 0, 0, y, cx * (1 - x), cy * (1 - y));\n    },\n\n    rotate: function(a, x, y) {\n        a = Ext.draw.Draw.rad(a);\n        var me = this,\n            cos = +Math.cos(a).toFixed(9),\n            sin = +Math.sin(a).toFixed(9);\n        me.add(cos, sin, -sin, cos, x - cos * x + sin * y, -(sin * x) + y - cos * y);\n    },\n\n    x: function(x, y) {\n        var matrix = this.matrix;\n        return x * matrix[0][0] + y * matrix[0][1] + matrix[0][2];\n    },\n\n    y: function(x, y) {\n        var matrix = this.matrix;\n        return x * matrix[1][0] + y * matrix[1][1] + matrix[1][2];\n    },\n\n    get: function(i, j) {\n        return + this.matrix[i][j].toFixed(4);\n    },\n\n    toString: function() {\n        var me = this;\n        return [me.get(0, 0), me.get(0, 1), me.get(1, 0), me.get(1, 1), 0, 0].join();\n    },\n\n    toSvg: function() {\n        var me = this;\n        return \"matrix(\" + [me.get(0, 0), me.get(1, 0), me.get(0, 1), me.get(1, 1), me.get(0, 2), me.get(1, 2)].join() + \")\";\n    },\n\n    toFilter: function(dx, dy) {\n        var me = this;\n        dx = dx || 0;\n        dy = dy || 0;\n        return \"progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', filterType='bilinear', M11=\" + me.get(0, 0) +\n            \", M12=\" + me.get(0, 1) + \", M21=\" + me.get(1, 0) + \", M22=\" + me.get(1, 1) +\n            \", Dx=\" + (me.get(0, 2) + dx) + \", Dy=\" + (me.get(1, 2) + dy) + \")\";\n    },\n\n    offset: function() {\n        var matrix = this.matrix;\n        return [(matrix[0][2] || 0).toFixed(4), (matrix[1][2] || 0).toFixed(4)];\n    },\n\n    // Split matrix into Translate Scale, Shear, and Rotate\n    split: function () {\n        function norm(a) {\n            return a[0] * a[0] + a[1] * a[1];\n        }\n        function normalize(a) {\n            var mag = Math.sqrt(norm(a));\n            a[0] /= mag;\n            a[1] /= mag;\n        }\n        var matrix = this.matrix,\n            out = {\n                translateX: matrix[0][2],\n                translateY: matrix[1][2]\n            },\n            row;\n\n        // scale and shear\n        row = [[matrix[0][0], matrix[0][1]], [matrix[1][1], matrix[1][1]]];\n        out.scaleX = Math.sqrt(norm(row[0]));\n        normalize(row[0]);\n\n        out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1];\n        row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear];\n\n        out.scaleY = Math.sqrt(norm(row[1]));\n        normalize(row[1]);\n        out.shear /= out.scaleY;\n\n        // rotation\n        out.rotate = Math.asin(-row[0][1]);\n\n        out.isSimple = !+out.shear.toFixed(9) && (out.scaleX.toFixed(9) == out.scaleY.toFixed(9) || !out.rotate);\n\n        return out;\n    }\n});\n\n/**\n * DD implementation for Panels.\n * @private\n */\nExt.define('Ext.draw.SpriteDD', {\n    extend: 'Ext.dd.DragSource',\n\n    constructor : function(sprite, cfg){\n        var me = this,\n            el = sprite.el;\n        me.sprite = sprite;\n        me.el = el;\n        me.dragData = {el: el, sprite: sprite};\n        me.callParent([el, cfg]);\n        me.sprite.setStyle('cursor', 'move');\n    },\n\n    showFrame: Ext.emptyFn,\n    createFrame : Ext.emptyFn,\n\n    getDragEl : function(e){\n        return this.el;\n    },\n    \n    getRegion: function() {\n        var me = this,\n            el = me.el,\n            pos, x1, x2, y1, y2, t, r, b, l, bbox, sprite;\n        \n        sprite = me.sprite;\n        bbox = sprite.getBBox();\n        \n        try {\n            pos = Ext.Element.getXY(el);\n        } catch (e) { }\n\n        if (!pos) {\n            return null;\n        }\n\n        x1 = pos[0];\n        x2 = x1 + bbox.width;\n        y1 = pos[1];\n        y2 = y1 + bbox.height;\n        \n        return new Ext.util.Region(y1, x2, y2, x1);\n    },\n\n    /*\n      TODO(nico): Cumulative translations in VML are handled\n      differently than in SVG. While in SVG we specify the translation\n      relative to the original x, y position attributes, in VML the translation\n      is a delta between the last position of the object (modified by the last\n      translation) and the new one.\n      \n      In VML the translation alters the position\n      of the object, we should change that or alter the SVG impl.\n    */\n     \n    startDrag: function(x, y) {\n        var me = this,\n            attr = me.sprite.attr;\n        me.prev = me.sprite.surface.transformToViewBox(x, y);\n    },\n\n    onDrag: function(e) {\n        var xy = e.getXY(),\n            me = this,\n            sprite = me.sprite,\n            attr = sprite.attr, dx, dy;\n        xy = me.sprite.surface.transformToViewBox(xy[0], xy[1]);\n        dx = xy[0] - me.prev[0];\n        dy = xy[1] - me.prev[1];\n        sprite.setAttributes({\n            translate: {\n                x: attr.translation.x + dx,\n                y: attr.translation.y + dy\n            }\n        }, true);\n        me.prev = xy;\n    },\n\n    setDragElPos: function () {\n        // Disable automatic DOM move in DD that spoils layout of VML engine.\n        return false;\n    }\n});\n\n/**\n * A Sprite is an object rendered in a Drawing surface.\n *\n * ## Types\n *\n * The following sprite types are supported:\n *\n * ### Rect\n *\n * Rectangle requires `width` and `height` attributes:\n *\n *     @example\n *     Ext.create('Ext.draw.Component', {\n *         renderTo: Ext.getBody(),\n *         width: 200,\n *         height: 200,\n *         items: [{\n *             type: 'rect',\n *             width: 100,\n *             height: 50,\n *             radius: 10,\n *             fill: 'green',\n *             opacity: 0.5,\n *             stroke: 'red',\n *             'stroke-width': 2\n *         }]\n *     });\n *\n * ### Circle\n *\n * Circle requires `x`, `y` and `radius` attributes:\n *\n *     @example\n *     Ext.create('Ext.draw.Component', {\n *         renderTo: Ext.getBody(),\n *         width: 200,\n *         height: 200,\n *         items: [{\n *             type: 'circle',\n *             radius: 90,\n *             x: 100,\n *             y: 100,\n *             fill: 'blue',\n *         }]\n *     });\n *\n * ### Ellipse\n *\n * Ellipse requires `x`, `y`, `radiusX` and `radiusY` attributes:\n *\n *     @example\n *     Ext.create('Ext.draw.Component', {\n *         renderTo: Ext.getBody(),\n *         width: 200,\n *         height: 200,\n *         items: [{\n *             type: \"ellipse\",\n *             radiusX: 100,\n *             radiusY: 50,\n *             x: 100,\n *             y: 100,\n *             fill: 'red'\n *         }]\n *     });\n *\n * ### Path\n *\n * Path requires the `path` attribute:\n *\n *     @example\n *     Ext.create('Ext.draw.Component', {\n *         renderTo: Ext.getBody(),\n *         width: 200,\n *         height: 200,\n *         items: [{\n *             type: \"path\",\n *             path: \"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 \" +\n *                   \"-85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 \" +\n *                   \"10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 \" +\n *                   \"24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 \" +\n *                   \"33.6L-66.6 26z\",\n *             fill: \"purple\"\n *         }]\n *     });\n *\n * ### Text\n *\n * Text requires the `text` attribute:\n *\n *     @example\n *     Ext.create('Ext.draw.Component', {\n *         renderTo: Ext.getBody(),\n *         width: 200,\n *         height: 200,\n *         items: [{\n *             type: \"text\",\n *             text: \"Hello, Sprite!\",\n *             fill: \"green\",\n *             font: \"18px monospace\"\n *         }]\n *     });\n *\n * ### Image\n *\n * Image requires `width`, `height` and `src` attributes:\n *\n *     @example\n *     Ext.create('Ext.draw.Component', {\n *         renderTo: Ext.getBody(),\n *         width: 200,\n *         height: 200,\n *         items: [{\n *             type: \"image\",\n *             src: \"http://www.sencha.com/img/apple-touch-icon.png\",\n *             width: 200,\n *             height: 200\n *         }]\n *     });\n *\n * ## Creating and adding a Sprite to a Surface\n *\n * See {@link Ext.draw.Surface} documentation.\n *\n * ## Transforming sprites\n *\n * See {@link #setAttributes} method documentation for examples on how to translate, scale and rotate the sprites.\n *\n */\nExt.define('Ext.draw.Sprite', {\n\n    /* Begin Definitions */\n\n    mixins: {\n        observable: 'Ext.util.Observable',\n        animate: 'Ext.util.Animate'\n    },\n\n    requires: ['Ext.draw.SpriteDD'],\n\n    /* End Definitions */\n\n    /**\n     * @cfg {String} type The type of the sprite.\n     * Possible options are 'circle', 'ellipse', 'path', 'rect', 'text', 'image'.\n     *\n     * See {@link Ext.draw.Sprite} class documentation for examples of all types.\n     */\n\n    /**\n     * @cfg {Number} width The width of the rect or image sprite.\n     */\n\n    /**\n     * @cfg {Number} height The height of the rect or image sprite.\n     */\n\n    /**\n     * @cfg {Number} radius The radius of the circle sprite. Or in case of rect sprite, the border radius.\n     */\n\n    /**\n     * @cfg {Number} radiusX The radius of the ellipse sprite along x-axis.\n     */\n\n    /**\n     * @cfg {Number} radiusY The radius of the ellipse sprite along y-axis.\n     */\n\n    /**\n     * @cfg {Number} x Sprite position along the x-axis.\n     */\n\n    /**\n     * @cfg {Number} y Sprite position along the y-axis.\n     */\n\n    /**\n     * @cfg {String} path The path of the path sprite written in SVG-like path syntax.\n     */\n\n    /**\n     * @cfg {Number} opacity The opacity of the sprite. A number between 0 and 1.\n     */\n\n    /**\n     * @cfg {String} fill The fill color.\n     */\n\n    /**\n     * @cfg {String} stroke The stroke color.\n     */\n\n    /**\n     * @cfg {Number} stroke-width The width of the stroke.\n     *\n     * Note that this attribute needs to be quoted when used.  Like so:\n     *\n     *     \"stroke-width\": 12,\n     */\n\n    /**\n     * @cfg {String} font Used with text type sprites. The full font description.\n     * Uses the same syntax as the CSS font parameter\n     */\n\n    /**\n     * @cfg {String} text The actual text to render in text sprites.\n     */\n\n    /**\n     * @cfg {String} src Path to the image to show in image sprites.\n     */\n\n    /**\n     * @cfg {String/String[]} group The group that this sprite belongs to, or an array of groups.\n     * Only relevant when added to a {@link Ext.draw.Surface Surface}.\n     */\n\n    /**\n     * @cfg {Boolean} draggable True to make the sprite draggable.\n     */\n\n    dirty: false,\n    dirtyHidden: false,\n    dirtyTransform: false,\n    dirtyPath: true,\n    dirtyFont: true,\n    zIndexDirty: true,\n\n    /**\n     * @property {Boolean} isSprite\n     * `true` in this class to identify an object as an instantiated Sprite, or subclass thereof.\n     */\n    isSprite: true,\n    zIndex: 0,\n    fontProperties: [\n        'font',\n        'font-size',\n        'font-weight',\n        'font-style',\n        'font-family',\n        'text-anchor',\n        'text'\n    ],\n    pathProperties: [\n        'x',\n        'y',\n        'd',\n        'path',\n        'height',\n        'width',\n        'radius',\n        'r',\n        'rx',\n        'ry',\n        'cx',\n        'cy'\n    ],\n    constructor: function(config) {\n        var me = this;\n        config = Ext.merge({}, config || {});\n        me.id = Ext.id(null, 'ext-sprite-');\n        me.transformations = [];\n        Ext.copyTo(this, config, 'surface,group,type,draggable');\n        //attribute bucket\n        me.bbox = {};\n        me.attr = {\n            zIndex: 0,\n            translation: {\n                x: null,\n                y: null\n            },\n            rotation: {\n                degrees: null,\n                x: null,\n                y: null\n            },\n            scaling: {\n                x: null,\n                y: null,\n                cx: null,\n                cy: null\n            }\n        };\n        //delete not bucket attributes\n        delete config.surface;\n        delete config.group;\n        delete config.type;\n        delete config.draggable;\n        me.setAttributes(config);\n        me.addEvents(\n            /**\n             * @event\n             * Fires before the sprite is destroyed. Return false from an event handler to stop the destroy.\n             * @param {Ext.draw.Sprite} this\n             */\n            'beforedestroy',\n            /**\n             * @event\n             * Fires after the sprite is destroyed.\n             * @param {Ext.draw.Sprite} this\n             */\n            'destroy',\n            /**\n             * @event\n             * Fires after the sprite markup is rendered.\n             * @param {Ext.draw.Sprite} this\n             */\n            'render',\n            /**\n             * @event\n             * @inheritdoc Ext.dom.Element#mousedown\n             */\n            'mousedown',\n            /**\n             * @event\n             * @inheritdoc Ext.dom.Element#mouseup\n             */\n            'mouseup',\n            /**\n             * @event\n             * @inheritdoc Ext.dom.Element#mouseover\n             */\n            'mouseover',\n            /**\n             * @event\n             * @inheritdoc Ext.dom.Element#mouseout\n             */\n            'mouseout',\n            /**\n             * @event\n             * @inheritdoc Ext.dom.Element#mousemove\n             */\n            'mousemove',\n            /**\n             * @event\n             * @inheritdoc Ext.dom.Element#click\n             */\n            'click'\n        );\n        me.mixins.observable.constructor.apply(this, arguments);\n    },\n\n    /**\n     * @property {Ext.dd.DragSource} dd\n     * If this Sprite is configured {@link #draggable}, this property will contain\n     * an instance of {@link Ext.dd.DragSource} which handles dragging the Sprite.\n     *\n     * The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource}\n     * in order to supply behaviour for each stage of the drag/drop process. See {@link #draggable}.\n     */\n\n    initDraggable: function() {\n        var me = this;\n        me.draggable = true;\n        //create element if it doesn't exist.\n        if (!me.el) {\n            me.surface.createSpriteElement(me);\n        }\n        me.dd = new Ext.draw.SpriteDD(me, Ext.isBoolean(me.draggable) ? null : me.draggable);\n        me.on('beforedestroy', me.dd.destroy, me.dd);\n    },\n\n    /**\n     * Change the attributes of the sprite.\n     *\n     * ## Translation\n     *\n     * For translate, the configuration object contains x and y attributes that indicate where to\n     * translate the object. For example:\n     *\n     *     sprite.setAttributes({\n     *       translate: {\n     *        x: 10,\n     *        y: 10\n     *       }\n     *     }, true);\n     *\n     *\n     * ## Rotation\n     *\n     * For rotation, the configuration object contains x and y attributes for the center of the rotation (which are optional),\n     * and a `degrees` attribute that specifies the rotation in degrees. For example:\n     *\n     *     sprite.setAttributes({\n     *       rotate: {\n     *        degrees: 90\n     *       }\n     *     }, true);\n     *\n     * That example will create a 90 degrees rotation using the centroid of the Sprite as center of rotation, whereas:\n     *\n     *     sprite.setAttributes({\n     *       rotate: {\n     *        x: 0,\n     *        y: 0,\n     *        degrees: 90\n     *       }\n     *     }, true);\n     *\n     * will create a rotation around the `(0, 0)` axis.\n     *\n     *\n     * ## Scaling\n     *\n     * For scaling, the configuration object contains x and y attributes for the x-axis and y-axis scaling. For example:\n     *\n     *     sprite.setAttributes({\n     *       scale: {\n     *        x: 10,\n     *        y: 3\n     *       }\n     *     }, true);\n     *\n     * You can also specify the center of scaling by adding `cx` and `cy` as properties:\n     *\n     *     sprite.setAttributes({\n     *       scale: {\n     *        cx: 0,\n     *        cy: 0,\n     *        x: 10,\n     *        y: 3\n     *       }\n     *     }, true);\n     *\n     * That last example will scale a sprite taking as centers of scaling the `(0, 0)` coordinate.\n     *\n     * @param {Object} attrs attributes to be changed on the sprite.\n     * @param {Boolean} redraw Flag to immediately draw the change.\n     * @return {Ext.draw.Sprite} this\n     */\n    setAttributes: function(attrs, redraw) {\n        var me = this,\n            fontProps = me.fontProperties,\n            fontPropsLength = fontProps.length,\n            pathProps = me.pathProperties,\n            pathPropsLength = pathProps.length,\n            hasSurface = !!me.surface,\n            custom = hasSurface && me.surface.customAttributes || {},\n            spriteAttrs = me.attr,\n            dirtyBBox = false,\n            attr, i, newTranslation, translation, newRotate, rotation, newScaling, scaling;\n\n        attrs = Ext.apply({}, attrs);\n        for (attr in custom) {\n            if (attrs.hasOwnProperty(attr) && typeof custom[attr] == \"function\") {\n                Ext.apply(attrs, custom[attr].apply(me, [].concat(attrs[attr])));\n            }\n        }\n\n        // Flag a change in hidden\n        if (!!attrs.hidden !== !!spriteAttrs.hidden) {\n            me.dirtyHidden = true;\n        }\n\n        // Flag path change\n        for (i = 0; i < pathPropsLength; i++) {\n            attr = pathProps[i];\n            if (attr in attrs && attrs[attr] !== spriteAttrs[attr]) {\n                me.dirtyPath = true;\n                dirtyBBox = true;\n                break;\n            }\n        }\n\n        // Flag zIndex change\n        if ('zIndex' in attrs) {\n            me.zIndexDirty = true;\n        }\n\n        // Flag font/text change\n        if ('text' in attrs) {\n            me.dirtyFont = true;\n            dirtyBBox = true;\n        }\n\n        for (i = 0; i < fontPropsLength; i++) {\n            attr = fontProps[i];\n            if (attr in attrs && attrs[attr] !== spriteAttrs[attr]) {\n                me.dirtyFont = true;\n                dirtyBBox = true;\n                break;\n            }\n        }\n\n        newTranslation = attrs.translation || attrs.translate;\n        delete attrs.translate;\n        delete attrs.translation;\n        translation = spriteAttrs.translation;\n        if (newTranslation) {\n            if (('x' in newTranslation && newTranslation.x !== translation.x) ||\n                ('y' in newTranslation && newTranslation.y !== translation.y)) {\n                me.dirtyTransform = true;\n                translation.x = newTranslation.x;\n                translation.y = newTranslation.y;\n            }\n        }\n\n        newRotate = attrs.rotation || attrs.rotate;\n        rotation = spriteAttrs.rotation;\n        delete attrs.rotate;\n        delete attrs.rotation;\n        if (newRotate) {\n            if (('x' in newRotate && newRotate.x !== rotation.x) ||\n                ('y' in newRotate && newRotate.y !== rotation.y) ||\n                ('degrees' in newRotate && newRotate.degrees !== rotation.degrees)) {\n                me.dirtyTransform = true;\n                rotation.x = newRotate.x;\n                rotation.y = newRotate.y;\n                rotation.degrees = newRotate.degrees;\n            }\n        }\n\n        newScaling = attrs.scaling || attrs.scale;\n        scaling = spriteAttrs.scaling;\n        delete attrs.scale;\n        delete attrs.scaling;\n        if (newScaling) {\n            if (('x' in newScaling && newScaling.x !== scaling.x) ||\n                ('y' in newScaling && newScaling.y !== scaling.y) ||\n                ('cx' in newScaling && newScaling.cx !== scaling.cx) ||\n                ('cy' in newScaling && newScaling.cy !== scaling.cy)) {\n                me.dirtyTransform = true;\n                scaling.x = newScaling.x;\n                scaling.y = newScaling.y;\n                scaling.cx = newScaling.cx;\n                scaling.cy = newScaling.cy;\n            }\n        }\n\n        // If the bbox is changed, then the bbox based transforms should be invalidated.\n        if (!me.dirtyTransform && dirtyBBox) {\n            if (spriteAttrs.scaling.x === null ||\n                spriteAttrs.scaling.y === null ||\n                spriteAttrs.rotation.y === null ||\n                spriteAttrs.rotation.y === null) {\n                me.dirtyTransform = true;\n            }\n        }\n\n        Ext.apply(spriteAttrs, attrs);\n        me.dirty = true;\n\n        if (redraw === true && hasSurface) {\n            me.redraw();\n        }\n        return this;\n    },\n\n    /**\n     * Retrieves the bounding box of the sprite.\n     * This will be returned as an object with x, y, width, and height properties.\n     * @return {Object} bbox\n     */\n    getBBox: function() {\n        return this.surface.getBBox(this);\n    },\n\n    setText: function(text) {\n        return this.surface.setText(this, text);\n    },\n\n    /**\n     * Hides the sprite.\n     * @param {Boolean} redraw Flag to immediately draw the change.\n     * @return {Ext.draw.Sprite} this\n     */\n    hide: function(redraw) {\n        this.setAttributes({\n            hidden: true\n        }, redraw);\n        return this;\n    },\n\n    /**\n     * Shows the sprite.\n     * @param {Boolean} redraw Flag to immediately draw the change.\n     * @return {Ext.draw.Sprite} this\n     */\n    show: function(redraw) {\n        this.setAttributes({\n            hidden: false\n        }, redraw);\n        return this;\n    },\n\n    /**\n     * Removes the sprite.\n     * @return {Boolean} True if sprite was successfully removed.\n     * False when there was no surface to remove it from.\n     */\n    remove: function() {\n        if (this.surface) {\n            this.surface.remove(this);\n            return true;\n        }\n        return false;\n    },\n\n    onRemove: function() {\n        this.surface.onRemove(this);\n    },\n\n    /**\n     * Removes the sprite and clears all listeners.\n     */\n    destroy: function() {\n        var me = this;\n        if (me.fireEvent('beforedestroy', me) !== false) {\n            me.remove();\n            me.surface.onDestroy(me);\n            me.clearListeners();\n            me.fireEvent('destroy');\n        }\n    },\n\n    /**\n     * Redraws the sprite.\n     * @return {Ext.draw.Sprite} this\n     */\n    redraw: function() {\n        this.surface.renderItem(this);\n        return this;\n    },\n\n    /**\n     * Wrapper for setting style properties, also takes single object parameter of multiple styles.\n     * @param {String/Object} property The style property to be set, or an object of multiple styles.\n     * @param {String} value (optional) The value to apply to the given property, or null if an object was passed.\n     * @return {Ext.draw.Sprite} this\n     */\n    setStyle: function() {\n        this.el.setStyle.apply(this.el, arguments);\n        return this;\n    },\n\n    /**\n     * Adds one or more CSS classes to the element. Duplicate classes are automatically filtered out.  Note this method\n     * is severly limited in VML.\n     * @param {String/String[]} className The CSS class to add, or an array of classes\n     * @return {Ext.draw.Sprite} this\n     */\n    addCls: function(obj) {\n        this.surface.addCls(this, obj);\n        return this;\n    },\n\n    /**\n     * Removes one or more CSS classes from the element.\n     * @param {String/String[]} className The CSS class to remove, or an array of classes.  Note this method\n     * is severly limited in VML.\n     * @return {Ext.draw.Sprite} this\n     */\n    removeCls: function(obj) {\n        this.surface.removeCls(this, obj);\n        return this;\n    }\n});\n\n/**\n * This class encapsulates a drawn text item as rendered by the Ext.draw package within a Component which can be\n * then used anywhere in an ExtJS application just like any other Component.\n *\n * ## Example usage\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Panel with VerticalTextItem',\n *         width: 300,\n *         height: 200,\n *         lbar: {\n *             layout: {\n *                 align: 'center'\n *             },\n *             items: [{\n *                 xtype: 'text',\n *                 text: 'Sample VerticalTextItem',\n *                 degrees: 90\n *             }]\n *         },\n *         renderTo: Ext.getBody()\n *     });\n *\n * @constructor\n * Creates a new Text Component\n * @param {Object} text A config object containing a `text` property, a `degrees` property,\n * and, optionally, a `styleSelector` property which specifies a selector which provides CSS rules to\n * give font family, size and color to the drawn text.\n */\nExt.define('Ext.draw.Text', {\n    extend: 'Ext.draw.Component',\n    uses: ['Ext.util.CSS'],\n    alias: 'widget.text',\n\n    /**\n     * @cfg {String} text\n     * The text to display (html tags are <b>not</b> accepted)\n     */\n    text: '',\n\n    /**\n     * @cfg {String} styleSelector\n     * A CSS selector string which matches a style rule in the document stylesheet from which\n     * the text's font properties are read.\n     *\n     * **Drawn** text is not styled by CSS, but by properties set during its construction, so these styles\n     * must be programatically read from a stylesheet rule found via a selector at construction time.\n     */\n\n    /**\n     * @cfg {Number} degrees\n     * The angle by which to initially rotate the text clockwise. Defaults to zero.\n     */\n\n    focusable: false,\n    viewBox: false,\n    autoSize: true,\n    baseCls: Ext.baseCSSPrefix + 'surface ' + Ext.baseCSSPrefix + 'draw-text',\n\n    initComponent: function() {\n        var me = this;\n\n        me.textConfig = Ext.apply({\n            type: 'text',\n            text: me.text,\n            rotate: {\n                degrees: me.degrees || 0\n            }\n        }, me.textStyle);\n        Ext.apply(me.textConfig, me.getStyles(me.styleSelectors || me.styleSelector));\n\n        // Surface is created from the *initialConfig*, not the current object state,\n        // So the generated items must go into the initialConfig\n        me.initialConfig.items = [me.textConfig];\n        me.callParent(arguments);\n    },\n\n    /**\n     * @private\n     * Accumulates a style object based upon the styles specified in document stylesheets\n     * by an array of CSS selectors\n     */\n    getStyles: function(selectors) {\n        selectors = Ext.Array.from(selectors);\n        var i = 0,\n            len = selectors.length,\n            rule,\n            style,\n            prop,\n            result = {};\n\n        for (; i < len; i++) {\n            // Get the style rule which exactly matches the selector.\n            rule = Ext.util.CSS.getRule(selectors[i]);\n            if (rule) {\n                style = rule.style;\n                if (style) {\n                    Ext.apply(result, {\n                        'font-family': style.fontFamily,\n                        'font-weight': style.fontWeight,\n                        'line-height': style.lineHeight,\n                        'font-size': style.fontSize,\n                        fill: style.color\n                    });\n                }\n            }\n        }\n        return result;\n    },\n\n    /**\n     * Sets the clockwise rotation angle relative to the horizontal axis.\n     * @param {Number} degrees The clockwise angle (in degrees) from the horizontal axis\n     * by which the text should be rotated.\n     */\n    setAngle: function(degrees) {\n        var me = this,\n            surface,\n            sprite;\n            \n        if (me.rendered) {\n            surface = me.surface;\n            sprite = surface.items.items[0];\n\n            me.degrees = degrees;\n            sprite.setAttributes({\n                rotate: {\n                    degrees: degrees\n                }\n            }, true);\n            if (me.autoSize || me.viewBox) {\n                me.updateLayout();\n            }\n        } else {\n            me.degrees = degrees;\n        }\n    },\n\n    /**\n     * Updates this item's text.\n     * @param {String} t The text to display (html **not** accepted).\n     */\n    setText: function(text) {\n        var me = this,\n            surface,\n            sprite;\n            \n        if (me.rendered) {\n            surface = me.surface;\n            sprite = surface.items.items[0];\n\n            me.text = text || '';\n            surface.remove(sprite);\n            me.textConfig.type = 'text';\n            me.textConfig.text = me.text;\n            sprite = surface.add(me.textConfig);\n            sprite.setAttributes({\n                rotate: {\n                    degrees: me.degrees\n                }\n            }, true);\n            if (me.autoSize || me.viewBox) {\n                me.updateLayout();\n            }\n        } else {\n            me.on({\n                render: function() {\n                    me.setText(text);\n                },\n                single: true\n            });\n        }\n    }\n});\n\n/**\n * Exports a {@link Ext.draw.Surface Surface} to an image. To do this,\n * the svg string must be sent to a remote server and processed.\n *\n * # Sending the data\n *\n * A post request is made to the URL. The following fields are sent:\n *\n * + width: The width of the image\n * + height: The height of the image\n * + type: The image type to save as, see {@link #supportedTypes}\n * + svg: The svg string for the surface\n *\n * # The response\n *\n * It is expected that the user will be prompted with an image download.\n * As such, the following options should be set on the server:\n *\n * + Content-Disposition: 'attachment, filename=\"chart.png\"'\n * + Content-Type: 'image/png'\n *\n * **Important**: By default, chart data is sent to a server operated\n * by Sencha to do data processing. You may change this default by\n * setting the {@link #defaultUrl} of this class.\n */\nExt.define('Ext.draw.engine.ImageExporter', {\n    singleton: true,\n\n    /**\n     * @property {String} [defaultUrl=\"http://svg.sencha.io\"]\n     * The default URL to submit the form request.\n     */\n    defaultUrl: 'http://svg.sencha.io',\n\n    /**\n     * @property {Array} [supportedTypes=[\"image/png\", \"image/jpeg\"]]\n     * A list of export types supported by the server\n     */\n    supportedTypes: ['image/png', 'image/jpeg'],\n\n    /**\n     * @property {String} [widthParam=\"width\"]\n     * The name of the width parameter to be sent to the server.\n     * The Sencha IO server expects it to be the default value.\n     */\n    widthParam: 'width',\n\n    /**\n     * @property {String} [heightParam=\"height\"]\n     * The name of the height parameter to be sent to the server.\n     * The Sencha IO server expects it to be the default value.\n     */\n    heightParam: 'height',\n\n    /**\n     * @property {String} [typeParam=\"type\"]\n     * The name of the type parameter to be sent to the server.\n     * The Sencha IO server expects it to be the default value.\n     */\n    typeParam: 'type',\n\n    /**\n     * @property {String} [svgParam=\"svg\"]\n     * The name of the svg parameter to be sent to the server.\n     * The Sencha IO server expects it to be the default value.\n     */\n    svgParam: 'svg',\n\n    formCls: Ext.baseCSSPrefix + 'hide-display',\n\n    /**\n     * Exports the surface to an image\n     * @param {Ext.draw.Surface} surface The surface to export\n     * @param {Object} [config] The following config options are supported:\n     *\n     * @param {Number} config.width A width to send to the server to for\n     * configuring the image height\n     *\n     * @param {Number} config.height A height to send to the server for\n     * configuring the image height\n     *\n     * @param {String} config.url The url to post the data to. Defaults to\n     * the {@link #defaultUrl} configuration on the class.\n     *\n     * @param {String} config.type The type of image to export. See the\n     * {@link #supportedTypes}\n     *\n     * @param {String} config.widthParam The name of the width parameter to send\n     * to the server. Defaults to {@link #widthParam}\n     *\n     * @param {String} config.heightParam The name of the height parameter to send\n     * to the server. Defaults to {@link #heightParam}\n     *\n     * @param {String} config.typeParam The name of the type parameter to send\n     * to the server. Defaults to {@link #typeParam}\n     *\n     * @param {String} config.svgParam The name of the svg parameter to send\n     * to the server. Defaults to {@link #svgParam}\n     *\n     * @return {Boolean} True if the surface was successfully sent to the server.\n     */\n    generate: function(surface, config) {\n        config = config || {};\n        var me = this,\n            type = config.type,\n            form;\n\n        if (Ext.Array.indexOf(me.supportedTypes, type) === -1) {\n            return false;\n        }\n\n        form = Ext.getBody().createChild({\n            tag: 'form',\n            method: 'POST',\n            action: config.url || me.defaultUrl,\n            cls: me.formCls,\n            children: [{\n                tag: 'input',\n                type: 'hidden',\n                name: config.widthParam || me.widthParam,\n                value: config.width || surface.width\n            }, {\n                tag: 'input',\n                type: 'hidden',\n                name: config.heightParam || me.heightParam,\n                value: config.height || surface.height\n            }, {\n                tag: 'input',\n                type: 'hidden',\n                name: config.typeParam || me.typeParam,\n                value: type\n            }, {\n                tag: 'input',\n                type: 'hidden',\n                name: config.svgParam || me.svgParam\n            }]\n        });\n\n        // Assign the data on the value so it doesn't get messed up in the html insertion\n        form.last(null, true).value = Ext.draw.engine.SvgExporter.generate(surface);\n\n        form.dom.submit();\n        form.remove();\n        return true;\n    }\n\n});\n\n/**\n * Provides specific methods to draw with SVG.\n */\nExt.define('Ext.draw.engine.Svg', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.draw.Surface',\n\n    requires: ['Ext.draw.Draw', 'Ext.draw.Sprite', 'Ext.draw.Matrix', 'Ext.Element'],\n\n    /* End Definitions */\n\n    engine: 'Svg',\n\n    trimRe: /^\\s+|\\s+$/g,\n    spacesRe: /\\s+/,\n    xlink: \"http:/\" + \"/www.w3.org/1999/xlink\",\n\n    translateAttrs: {\n        radius: \"r\",\n        radiusX: \"rx\",\n        radiusY: \"ry\",\n        path: \"d\",\n        lineWidth: \"stroke-width\",\n        fillOpacity: \"fill-opacity\",\n        strokeOpacity: \"stroke-opacity\",\n        strokeLinejoin: \"stroke-linejoin\"\n    },\n\n    parsers: {},\n\n    minDefaults: {\n        circle: {\n            cx: 0,\n            cy: 0,\n            r: 0,\n            fill: \"none\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        ellipse: {\n            cx: 0,\n            cy: 0,\n            rx: 0,\n            ry: 0,\n            fill: \"none\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        rect: {\n            x: 0,\n            y: 0,\n            width: 0,\n            height: 0,\n            rx: 0,\n            ry: 0,\n            fill: \"none\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        text: {\n            x: 0,\n            y: 0,\n            \"text-anchor\": \"start\",\n            \"font-family\": null,\n            \"font-size\": null,\n            \"font-weight\": null,\n            \"font-style\": null,\n            fill: \"#000\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        path: {\n            d: \"M0,0\",\n            fill: \"none\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        image: {\n            x: 0,\n            y: 0,\n            width: 0,\n            height: 0,\n            preserveAspectRatio: \"none\",\n            opacity: null\n        }\n    },\n\n    createSvgElement: function(type, attrs) {\n        var el = this.domRef.createElementNS(\"http:/\" + \"/www.w3.org/2000/svg\", type),\n            key;\n        if (attrs) {\n            for (key in attrs) {\n                el.setAttribute(key, String(attrs[key]));\n            }\n        }\n        return el;\n    },\n\n    createSpriteElement: function(sprite) {\n        // Create svg element and append to the DOM.\n        var el = this.createSvgElement(sprite.type);\n        el.id = sprite.id;\n        if (el.style) {\n            el.style.webkitTapHighlightColor = \"rgba(0,0,0,0)\";\n        }\n        sprite.el = Ext.get(el);\n        this.applyZIndex(sprite); //performs the insertion\n        sprite.matrix = new Ext.draw.Matrix();\n        sprite.bbox = {\n            plain: 0,\n            transform: 0\n        };\n        this.applyAttrs(sprite);\n        this.applyTransformations(sprite);\n        sprite.fireEvent(\"render\", sprite);\n        return el;\n    },\n    \n    getBBoxText: function (sprite) {\n        var bbox = {},\n            bb, height, width, i, ln, el;\n\n        if (sprite && sprite.el) {\n            el = sprite.el.dom;\n            try {\n                bbox = el.getBBox();\n                return bbox;\n            } catch(e) {\n                // Firefox 3.0.x plays badly here\n            }\n            bbox = {x: bbox.x, y: Infinity, width: 0, height: 0};\n            ln = el.getNumberOfChars();\n            for (i = 0; i < ln; i++) {\n                bb = el.getExtentOfChar(i);\n                bbox.y = Math.min(bb.y, bbox.y);\n                height = bb.y + bb.height - bbox.y;\n                bbox.height = Math.max(bbox.height, height);\n                width = bb.x + bb.width - bbox.x;\n                bbox.width = Math.max(bbox.width, width);\n            }\n            return bbox;\n        }\n    },\n\n    hide: function() {\n        Ext.get(this.el).hide();\n    },\n\n    show: function() {\n        Ext.get(this.el).show();\n    },\n\n    hidePrim: function(sprite) {\n        this.addCls(sprite, Ext.baseCSSPrefix + 'hide-visibility');\n    },\n\n    showPrim: function(sprite) {\n        this.removeCls(sprite, Ext.baseCSSPrefix + 'hide-visibility');\n    },\n\n    getDefs: function() {\n        return this._defs || (this._defs = this.createSvgElement(\"defs\"));\n    },\n\n    transform: function(sprite, matrixOnly) {\n        var me = this,\n            matrix = new Ext.draw.Matrix(),\n            transforms = sprite.transformations,\n            transformsLength = transforms.length,\n            i = 0,\n            transform, type;\n            \n        for (; i < transformsLength; i++) {\n            transform = transforms[i];\n            type = transform.type;\n            if (type == \"translate\") {\n                matrix.translate(transform.x, transform.y);\n            }\n            else if (type == \"rotate\") {\n                matrix.rotate(transform.degrees, transform.x, transform.y);\n            }\n            else if (type == \"scale\") {\n                matrix.scale(transform.x, transform.y, transform.centerX, transform.centerY);\n            }\n        }\n        sprite.matrix = matrix;\n        if (!matrixOnly) {\n            sprite.el.set({transform: matrix.toSvg()});\n        }\n    },\n\n    setSize: function(width, height) {\n        var me = this,\n            el = me.el;\n        \n        width = +width || me.width;\n        height = +height || me.height;\n        me.width = width;\n        me.height = height;\n\n        el.setSize(width, height);\n        el.set({\n            width: width,\n            height: height\n        });\n        me.callParent([width, height]);\n    },\n\n    /**\n     * Get the region for the surface's canvas area\n     * @returns {Ext.util.Region}\n     */\n    getRegion: function() {\n        // Mozilla requires using the background rect because the svg element returns an\n        // incorrect region. Webkit gives no region for the rect and must use the svg element.\n        var svgXY = this.el.getXY(),\n            rectXY = this.bgRect.getXY(),\n            max = Math.max,\n            x = max(svgXY[0], rectXY[0]),\n            y = max(svgXY[1], rectXY[1]);\n        return {\n            left: x,\n            top: y,\n            right: x + this.width,\n            bottom: y + this.height\n        };\n    },\n\n    onRemove: function(sprite) {\n        if (sprite.el) {\n            sprite.el.destroy();\n            delete sprite.el;\n        }\n        this.callParent(arguments);\n    },\n    \n    setViewBox: function(x, y, width, height) {\n        if (isFinite(x) && isFinite(y) && isFinite(width) && isFinite(height)) {\n            this.callParent(arguments);\n            this.el.dom.setAttribute(\"viewBox\", [x, y, width, height].join(\" \"));\n        }\n    },\n\n    render: function (container) {\n        var me = this,\n            width,\n            height,\n            el,\n            defs,\n            bgRect,\n            webkitRect;\n        if (!me.el) {\n            width = me.width || 0;\n            height = me.height || 0;\n            el = me.createSvgElement('svg', {\n                xmlns: \"http:/\" + \"/www.w3.org/2000/svg\",\n                version: 1.1,\n                width: width,\n                height: height\n            });\n            defs = me.getDefs();\n\n            // Create a rect that is always the same size as the svg root; this serves 2 purposes:\n            // (1) It allows mouse events to be fired over empty areas in Webkit, and (2) we can\n            // use it rather than the svg element for retrieving the correct client rect of the\n            // surface in Mozilla (see https://bugzilla.mozilla.org/show_bug.cgi?id=530985)\n            bgRect = me.createSvgElement(\"rect\", {\n                width: \"100%\",\n                height: \"100%\",\n                fill: \"#000\",\n                stroke: \"none\",\n                opacity: 0\n            });\n            \n            if (Ext.isSafari3) {\n                // Rect that we will show/hide to fix old WebKit bug with rendering issues.\n                webkitRect = me.createSvgElement(\"rect\", {\n                    x: -10,\n                    y: -10,\n                    width: \"110%\",\n                    height: \"110%\",\n                    fill: \"none\",\n                    stroke: \"#000\"\n                });\n            }\n            el.appendChild(defs);\n            if (Ext.isSafari3) {\n                el.appendChild(webkitRect);\n            }\n            el.appendChild(bgRect);\n            container.appendChild(el);\n            me.el = Ext.get(el);\n            me.bgRect = Ext.get(bgRect);\n            if (Ext.isSafari3) {\n                me.webkitRect = Ext.get(webkitRect);\n                me.webkitRect.hide();\n            }\n            me.el.on({\n                scope: me,\n                mouseup: me.onMouseUp,\n                mousedown: me.onMouseDown,\n                mouseover: me.onMouseOver,\n                mouseout: me.onMouseOut,\n                mousemove: me.onMouseMove,\n                mouseenter: me.onMouseEnter,\n                mouseleave: me.onMouseLeave,\n                click: me.onClick,\n                dblclick: me.onDblClick\n            });\n        }\n        me.renderAll();\n    },\n\n    // private\n    onMouseEnter: function(e) {\n        if (this.el.parent().getRegion().contains(e.getPoint())) {\n            this.fireEvent('mouseenter', e);\n        }\n    },\n\n    // private\n    onMouseLeave: function(e) {\n        if (!this.el.parent().getRegion().contains(e.getPoint())) {\n            this.fireEvent('mouseleave', e);\n        }\n    },\n    // @private - Normalize a delegated single event from the main container to each sprite and sprite group\n    processEvent: function(name, e) {\n        var target = e.getTarget(),\n            surface = this.surface,\n            sprite;\n\n        this.fireEvent(name, e);\n        // We wrap text types in a tspan, sprite is the parent.\n        if (target.nodeName == \"tspan\" && target.parentNode) {\n            target = target.parentNode;\n        }\n        sprite = this.items.get(target.id);\n        if (sprite) {\n            sprite.fireEvent(name, sprite, e);\n        }\n    },\n\n    /* @private - Wrap SVG text inside a tspan to allow for line wrapping.  In addition this normallizes\n     * the baseline for text the vertical middle of the text to be the same as VML.\n     */\n    tuneText: function (sprite, attrs) {\n        var el = sprite.el.dom,\n            tspans = [],\n            height, tspan, text, i, ln, texts, factor, x;\n\n        if (attrs.hasOwnProperty(\"text\")) {\n            //only create new tspans for text lines if the text has been \n            //updated or if it's the first time we're setting the text\n            //into the sprite.\n\n            //get the actual rendered text.\n            text = sprite.tspans && Ext.Array.map(sprite.tspans, function(t) { return t.textContent; }).join('');\n\n            if (!sprite.tspans || attrs.text != text) {\n                tspans = this.setText(sprite, attrs.text);\n                sprite.tspans = tspans;\n            //for all other cases reuse the tspans previously created.\n            } else {\n                tspans = sprite.tspans || [];\n            }\n        }\n        // Normalize baseline via a DY shift of first tspan. Shift other rows by height * line height (1.2)\n        if (tspans.length) {\n            height = this.getBBoxText(sprite).height;\n            x = sprite.el.dom.getAttribute(\"x\");\n            for (i = 0, ln = tspans.length; i < ln; i++) {\n                // The text baseline for FireFox 3.0 and 3.5 is different than other SVG implementations\n                // so we are going to normalize that here\n                factor = (Ext.isFF3_0 || Ext.isFF3_5) ? 2 : 4;\n                tspans[i].setAttribute(\"x\", x);\n                tspans[i].setAttribute(\"dy\", i ? height * 1.2 : height / factor);\n            }\n            sprite.dirty = true;\n        }\n    },\n\n    setText: function(sprite, textString) {\n         var me = this,\n             el = sprite.el.dom,\n             tspans = [],\n             height, tspan, text, i, ln, texts;\n        \n        while (el.firstChild) {\n            el.removeChild(el.firstChild);\n        }\n        // Wrap each row into tspan to emulate rows\n        texts = String(textString).split(\"\\n\");\n        for (i = 0, ln = texts.length; i < ln; i++) {\n            text = texts[i];\n            if (text) {\n                tspan = me.createSvgElement(\"tspan\");\n                tspan.appendChild(document.createTextNode(Ext.htmlDecode(text)));\n                el.appendChild(tspan);\n                tspans[i] = tspan;\n            }\n        }\n        return tspans;\n    },\n\n    renderAll: function() {\n        this.items.each(this.renderItem, this);\n    },\n\n    renderItem: function (sprite) {\n        if (!this.el) {\n            return;\n        }\n        if (!sprite.el) {\n            this.createSpriteElement(sprite);\n        }\n        if (sprite.zIndexDirty) {\n            this.applyZIndex(sprite);\n        }\n        if (sprite.dirty) {\n            this.applyAttrs(sprite);\n            if (sprite.dirtyTransform) {\n                this.applyTransformations(sprite);\n            }\n        }\n    },\n\n    redraw: function(sprite) {\n        sprite.dirty = sprite.zIndexDirty = true;\n        this.renderItem(sprite);\n    },\n\n    applyAttrs: function (sprite) {\n        var me = this,\n            el = sprite.el,\n            group = sprite.group,\n            sattr = sprite.attr,\n            parsers = me.parsers,\n            //Safari does not handle linear gradients correctly in quirksmode\n            //ref: https://bugs.webkit.org/show_bug.cgi?id=41952\n            //ref: EXTJSIV-1472\n            gradientsMap = me.gradientsMap || {},\n            safariFix = Ext.isSafari && !Ext.isStrict,\n            groups, i, ln, attrs, font, key, style, name, rect;\n\n        if (group) {\n            groups = [].concat(group);\n            ln = groups.length;\n            for (i = 0; i < ln; i++) {\n                group = groups[i];\n                me.getGroup(group).add(sprite);\n            }\n            delete sprite.group;\n        }\n        attrs = me.scrubAttrs(sprite) || {};\n\n        // if (sprite.dirtyPath) {\n            sprite.bbox.plain = 0;\n            sprite.bbox.transform = 0;\n            if (sprite.type == \"circle\" || sprite.type == \"ellipse\") {\n                attrs.cx = attrs.cx || attrs.x;\n                attrs.cy = attrs.cy || attrs.y;\n            }\n            else if (sprite.type == \"rect\") {\n                attrs.rx = attrs.ry = attrs.r;\n            }\n            else if (sprite.type == \"path\" && attrs.d) {\n                attrs.d = Ext.draw.Draw.pathToString(Ext.draw.Draw.pathToAbsolute(attrs.d));\n            }\n            sprite.dirtyPath = false;\n        // }\n        // else {\n        //     delete attrs.d;\n        // }\n\n        if (attrs['clip-rect']) {\n            me.setClip(sprite, attrs);\n            delete attrs['clip-rect'];\n        }\n        if (sprite.type == 'text' && attrs.font && sprite.dirtyFont) {\n            el.set({ style: \"font: \" + attrs.font});\n        }\n        if (sprite.type == \"image\") {\n            el.dom.setAttributeNS(me.xlink, \"href\", attrs.src);\n        }\n        Ext.applyIf(attrs, me.minDefaults[sprite.type]);\n\n        if (sprite.dirtyHidden) {\n            (sattr.hidden) ? me.hidePrim(sprite) : me.showPrim(sprite);\n            sprite.dirtyHidden = false;\n        }\n        for (key in attrs) {\n            if (attrs.hasOwnProperty(key) && attrs[key] != null) {\n                //Safari does not handle linear gradients correctly in quirksmode\n                //ref: https://bugs.webkit.org/show_bug.cgi?id=41952\n                //ref: EXTJSIV-1472\n                //if we're Safari in QuirksMode and we're applying some color attribute and the value of that\n                //attribute is a reference to a gradient then assign a plain color to that value instead of the gradient.\n                if (safariFix && ('color|stroke|fill'.indexOf(key) > -1) && (attrs[key] in gradientsMap)) {\n                    attrs[key] = gradientsMap[attrs[key]];\n                }\n                //hidden is not a proper SVG attribute.\n                if (key == 'hidden' && sprite.type == 'text') {\n                    continue;\n                }\n                if (key in parsers) {\n                    el.dom.setAttribute(key, parsers[key](attrs[key], sprite, me));\n                } else {\n                    el.dom.setAttribute(key, attrs[key]);\n                }\n            }\n        }\n        \n        if (sprite.type == 'text') {\n            me.tuneText(sprite, attrs);\n        }\n        sprite.dirtyFont = false;\n\n        //set styles\n        style = sattr.style;\n        if (style) {\n            el.setStyle(style);\n        }\n\n        sprite.dirty = false;\n\n        if (Ext.isSafari3) {\n            // Refreshing the view to fix bug EXTJSIV-1: rendering issue in old Safari 3\n            me.webkitRect.show();\n            setTimeout(function () {\n                me.webkitRect.hide();\n            });\n        }\n    },\n\n    setClip: function(sprite, params) {\n        var me = this,\n            rect = params[\"clip-rect\"],\n            clipEl, clipPath;\n        if (rect) {\n            if (sprite.clip) {\n                sprite.clip.parentNode.parentNode.removeChild(sprite.clip.parentNode);\n            }\n            clipEl = me.createSvgElement('clipPath');\n            clipPath = me.createSvgElement('rect');\n            clipEl.id = Ext.id(null, 'ext-clip-');\n            clipPath.setAttribute(\"x\", rect.x);\n            clipPath.setAttribute(\"y\", rect.y);\n            clipPath.setAttribute(\"width\", rect.width);\n            clipPath.setAttribute(\"height\", rect.height);\n            clipEl.appendChild(clipPath);\n            me.getDefs().appendChild(clipEl);\n            sprite.el.dom.setAttribute(\"clip-path\", \"url(#\" + clipEl.id + \")\");\n            sprite.clip = clipPath;\n        } \n        // if (!attrs[key]) {\n        //     var clip = Ext.getDoc().dom.getElementById(sprite.el.getAttribute(\"clip-path\").replace(/(^url\\(#|\\)$)/g, \"\"));\n        //     clip && clip.parentNode.removeChild(clip);\n        //     sprite.el.setAttribute(\"clip-path\", \"\");\n        //     delete attrss.clip;\n        // }\n    },\n\n    /**\n     * Insert or move a given sprite's element to the correct place in the DOM list for its zIndex\n     * @param {Ext.draw.Sprite} sprite\n     */\n    applyZIndex: function(sprite) {\n        var me = this,\n            items = me.items,\n            idx = items.indexOf(sprite),\n            el = sprite.el,\n            prevEl;\n        if (me.el.dom.childNodes[idx + 2] !== el.dom) { //shift by 2 to account for defs and bg rect\n            if (idx > 0) {\n                // Find the first previous sprite which has its DOM element created already\n                do {\n                    prevEl = items.getAt(--idx).el;\n                } while (!prevEl && idx > 0);\n            }\n            el.insertAfter(prevEl || me.bgRect);\n        }\n        sprite.zIndexDirty = false;\n    },\n\n    createItem: function (config) {\n        var sprite = new Ext.draw.Sprite(config);\n        sprite.surface = this;\n        return sprite;\n    },\n\n    addGradient: function(gradient) {\n        gradient = Ext.draw.Draw.parseGradient(gradient);\n        var me = this,\n            ln = gradient.stops.length,\n            vector = gradient.vector,\n            //Safari does not handle linear gradients correctly in quirksmode\n            //ref: https://bugs.webkit.org/show_bug.cgi?id=41952\n            //ref: EXTJSIV-1472\n            usePlain = Ext.isSafari && !Ext.isStrict,\n            gradientEl, stop, stopEl, i, gradientsMap;\n            \n        gradientsMap = me.gradientsMap || {};\n        \n        if (!usePlain) {\n            if (gradient.type == \"linear\") {\n                gradientEl = me.createSvgElement(\"linearGradient\");\n                gradientEl.setAttribute(\"x1\", vector[0]);\n                gradientEl.setAttribute(\"y1\", vector[1]);\n                gradientEl.setAttribute(\"x2\", vector[2]);\n                gradientEl.setAttribute(\"y2\", vector[3]);\n            }\n            else {\n                gradientEl = me.createSvgElement(\"radialGradient\");\n                gradientEl.setAttribute(\"cx\", gradient.centerX);\n                gradientEl.setAttribute(\"cy\", gradient.centerY);\n                gradientEl.setAttribute(\"r\", gradient.radius);\n                if (Ext.isNumber(gradient.focalX) && Ext.isNumber(gradient.focalY)) {\n                    gradientEl.setAttribute(\"fx\", gradient.focalX);\n                    gradientEl.setAttribute(\"fy\", gradient.focalY);\n                }\n            }\n            gradientEl.id = gradient.id;\n            me.getDefs().appendChild(gradientEl);\n            for (i = 0; i < ln; i++) {\n                stop = gradient.stops[i];\n                stopEl = me.createSvgElement(\"stop\");\n                stopEl.setAttribute(\"offset\", stop.offset + \"%\");\n                stopEl.setAttribute(\"stop-color\", stop.color);\n                stopEl.setAttribute(\"stop-opacity\",stop.opacity);\n                gradientEl.appendChild(stopEl);\n            }\n        } else {\n            gradientsMap['url(#' + gradient.id + ')'] = gradient.stops[0].color;\n        }\n        me.gradientsMap = gradientsMap;\n    },\n\n    /**\n     * Checks if the specified CSS class exists on this element's DOM node.\n     * @param {Ext.draw.Sprite} sprite The sprite to look into.\n     * @param {String} className The CSS class to check for\n     * @return {Boolean} True if the class exists, else false\n     */\n    hasCls: function(sprite, className) {\n        return className && (' ' + (sprite.el.dom.getAttribute('class') || '') + ' ').indexOf(' ' + className + ' ') != -1;\n    },\n\n    addCls: function(sprite, className) {\n        var el = sprite.el,\n            i,\n            len,\n            v,\n            cls = [],\n            curCls =  el.getAttribute('class') || '';\n        // Separate case is for speed\n        if (!Ext.isArray(className)) {\n            if (typeof className == 'string' && !this.hasCls(sprite, className)) {\n                el.set({ 'class': curCls + ' ' + className });\n            }\n        }\n        else {\n            for (i = 0, len = className.length; i < len; i++) {\n                v = className[i];\n                if (typeof v == 'string' && (' ' + curCls + ' ').indexOf(' ' + v + ' ') == -1) {\n                    cls.push(v);\n                }\n            }\n            if (cls.length) {\n                el.set({ 'class': ' ' + cls.join(' ') });\n            }\n        }\n    },\n\n    removeCls: function(sprite, className) {\n        var me = this,\n            el = sprite.el,\n            curCls =  el.getAttribute('class') || '',\n            i, idx, len, cls, elClasses;\n        if (!Ext.isArray(className)){\n            className = [className];\n        }\n        if (curCls) {\n            elClasses = curCls.replace(me.trimRe, ' ').split(me.spacesRe);\n            for (i = 0, len = className.length; i < len; i++) {\n                cls = className[i];\n                if (typeof cls == 'string') {\n                    cls = cls.replace(me.trimRe, '');\n                    idx = Ext.Array.indexOf(elClasses, cls);\n                    if (idx != -1) {\n                        Ext.Array.erase(elClasses, idx, 1);\n                    }\n                }\n            }\n            el.set({ 'class': elClasses.join(' ') });\n        }\n    },\n\n    destroy: function() {\n        var me = this;\n        \n        me.callParent();\n        if (me.el) {\n            me.el.remove();\n        }\n        if (me._defs) {\n            Ext.get(me._defs).destroy();\n        }\n        if (me.bgRect) {\n            Ext.get(me.bgRect).destroy();\n        }\n        if (me.webkitRect) {\n            Ext.get(me.webkitRect).destroy();\n        }\n        delete me.el;\n    }\n});\n\n/**\n * A utility class for exporting a {@link Ext.draw.Surface Surface} to a string\n * that may be saved or used for processing on the server.\n *\n * @singleton\n */\nExt.define('Ext.draw.engine.SvgExporter', function(){\n   var commaRe = /,/g,\n       fontRegex = /(-?\\d*\\.?\\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)\\s('*.*'*)/,\n       rgbColorRe = /rgb\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)/g,\n       rgbaColorRe = /rgba\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,([\\d\\.]+)\\)/g,\n       surface, len, width, height,\n\n   init = function(s){\n       surface = s;\n       len = surface.length;\n       width = surface.width;\n       height = surface.height;\n   },\n   spriteProcessor = {\n       path: function(sprite){\n\n           var attr = sprite.attr,\n               path = attr.path,\n               pathString = '',\n               props, p, pLen;\n\n           if (Ext.isArray(path[0])) {\n               pLen = path.length;\n               for (p = 0; p < pLen; p++) {\n                   pathString += path[p].join(' ');\n               }\n           } else if (Ext.isArray(path)) {\n               pathString = path.join(' ');\n           } else {\n               pathString = path.replace(commaRe,' ');\n           }\n\n           props = toPropertyString({\n               d: pathString,\n               fill: attr.fill || 'none',\n               stroke: attr.stroke,\n               'fill-opacity': attr.opacity,\n               'stroke-width': attr['stroke-width'],\n               'stroke-opacity': attr['stroke-opacity'],\n               \"z-index\": attr.zIndex,\n               transform: sprite.matrix.toSvg()\n           });\n\n           return '<path ' + props + '/>';\n       },\n       text: function(sprite){\n\n           // TODO\n           // implement multi line support (@see Svg.js tuneText)\n\n           var attr = sprite.attr,\n               match = fontRegex.exec(attr.font),\n               size = (match && match[1]) || \"12\",\n               // default font family is Arial\n               family = (match && match[3]) || 'Arial',\n               text = attr.text,\n               factor = (Ext.isFF3_0 || Ext.isFF3_5) ? 2 : 4,\n               tspanString = '',\n               props;\n\n           sprite.getBBox();\n           tspanString += '<tspan x=\"' + (attr.x || '') + '\" dy=\"';\n           tspanString += (size/factor)+'\">';\n           tspanString += Ext.htmlEncode(text) + '</tspan>';\n\n\n           props = toPropertyString({\n               x: attr.x,\n               y: attr.y,\n               'font-size': size,\n               'font-family': family,\n               'font-weight': attr['font-weight'],\n               'text-anchor': attr['text-anchor'],\n               // if no fill property is set it will be black\n               fill: attr.fill || '#000',\n               'fill-opacity': attr.opacity,\n               transform: sprite.matrix.toSvg()\n           });\n\n\n\n           return '<text '+ props + '>' +  tspanString + '</text>';\n       },\n       rect: function(sprite){\n\n           var attr = sprite.attr,\n               props =  toPropertyString({\n                   x: attr.x,\n                   y: attr.y,\n                   rx: attr.rx,\n                   ry: attr.ry,\n                   width: attr.width,\n                   height: attr.height,\n                   fill: attr.fill || 'none',\n                   'fill-opacity': attr.opacity,\n                   stroke: attr.stroke,\n                   'stroke-opacity': attr['stroke-opacity'],\n                   'stroke-width':attr['stroke-width'],\n                   transform: sprite.matrix && sprite.matrix.toSvg()\n               });\n\n           return '<rect ' + props + '/>';\n       },\n       circle: function(sprite){\n\n           var attr = sprite.attr,\n               props = toPropertyString({\n                   cx: attr.x,\n                   cy: attr.y,\n                   r: attr.radius,\n                   fill: attr.translation.fill || attr.fill || 'none',\n                   'fill-opacity': attr.opacity,\n                   stroke: attr.stroke,\n                   'stroke-opacity': attr['stroke-opacity'],\n                   'stroke-width':attr['stroke-width'],\n                   transform: sprite.matrix.toSvg()\n               });\n\n           return '<circle ' + props + ' />';\n       },\n       image: function(sprite){\n\n           var attr = sprite.attr,\n               props = toPropertyString({\n                   x: attr.x - (attr.width/2 >> 0),\n                   y: attr.y - (attr.height/2 >> 0),\n                   width: attr.width,\n                   height: attr.height,\n                   'xlink:href': attr.src,\n                   transform: sprite.matrix.toSvg()\n               });\n\n           return '<image ' + props + ' />';\n       }\n   },\n   svgHeader = function(){\n       var svg = '<?xml version=\"1.0\" standalone=\"yes\"?>';\n       svg += '<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">';\n       return svg;\n   },\n   svgContent = function(){\n       var svg = '<svg width=\"'+width+'px\" height=\"'+height+'px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\">',\n           defs = '', item, itemsLen, items, gradient,\n           getSvgString, colorstops, stop,\n           coll, keys, colls, k, kLen, key, collI, i, j, stopsLen, sortedItems, za, zb;\n\n       items = surface.items.items;\n       itemsLen = items.length;\n\n\n       getSvgString = function(node){\n\n           var childs = node.childNodes,\n               childLength = childs.length,\n               i = 0,\n               attrLength,\n               j,\n               svgString = '', child, attr, tagName, attrItem;\n\n               for(; i < childLength; i++){\n                   child = childs[i];\n                   attr = child.attributes;\n                   tagName = child.tagName;\n\n                   svgString += '<' +tagName;\n\n                   for(j = 0, attrLength = attr.length; j < attrLength; j++){\n                       attrItem = attr.item(j);\n                       svgString += ' '+attrItem.name+'=\"'+attrItem.value+'\"';\n                   }\n\n                   svgString += '>';\n\n                   if(child.childNodes.length > 0){\n                       svgString += getSvgString(child);\n                   }\n\n                   svgString += '</' + tagName + '>';\n\n               }\n           return svgString;\n       };\n\n\n       if(surface.getDefs){\n           defs = getSvgString(surface.getDefs());\n       }else{\n           // IE\n           coll = surface.gradientsColl;\n           if (coll) {\n               keys  = coll.keys;\n               colls = coll.items;\n               k     = 0;\n               kLen  = keys.length;\n           }\n\n           for (; k < kLen; k++) {\n               key   = keys[k];\n               collI = colls[k];\n\n               gradient = surface.gradientsColl.getByKey(key);\n               defs += '<linearGradient id=\"' + key + '\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\">';\n\n               var color = gradient.colors.replace(rgbColorRe, 'rgb($1|$2|$3)');\n               color = color.replace(rgbaColorRe, 'rgba($1|$2|$3|$4)')\n               colorstops = color.split(',');\n               for(i=0, stopsLen = colorstops.length; i < stopsLen; i++){\n                   stop = colorstops[i].split(' ');\n                   color = Ext.draw.Color.fromString(stop[1].replace(/\\|/g,','));\n                   defs += '<stop offset=\"'+stop[0]+'\" stop-color=\"' + color.toString() + '\" stop-opacity=\"1\"></stop>';\n               }\n               defs += '</linearGradient>';\n           }\n       }\n\n       svg += '<defs>' + defs + '</defs>';\n\n       // thats the background rectangle\n       svg += spriteProcessor.rect({\n           attr: {\n                   width: '100%',\n                   height: '100%',\n                   fill: '#fff',\n                   stroke: 'none',\n                   opacity: '0'\n           }\n       });\n\n       // Sort the items (stable sort guaranteed)\n       sortedItems = new Array(itemsLen);\n       for(i = 0; i < itemsLen; i++){\n           sortedItems[i] = i;\n       }\n       sortedItems.sort(function (a, b) {\n           za = items[a].attr.zIndex || 0;\n           zb = items[b].attr.zIndex || 0;\n           if (za == zb) {\n               return a - b;\n           }\n           return za - zb;\n       });\n\n       for(i = 0; i < itemsLen; i++){\n           item = items[sortedItems[i]];\n           if(!item.attr.hidden){\n               svg += spriteProcessor[item.type](item);\n           }\n       }\n\n       svg += '</svg>';\n\n       return svg;\n   },\n   toPropertyString = function(obj){\n       var propString = '',\n           key;\n\n       for(key in obj){\n\n           if(obj.hasOwnProperty(key) && obj[key] != null){\n               propString += key +'=\"'+ obj[key]+'\" ';\n           }\n\n       }\n\n       return propString;\n   };\n\n   return {\n       singleton: true,\n\n       /**\n        * Exports the passed surface to a SVG string representation\n        * @param {Ext.draw.Surface} surface The surface to export\n        * @param {Object} [config] Any configuration for the export. Currently this is\n        * unused but may provide more options in the future\n        * @return {String} The SVG as a string\n        */\n       generate: function(surface, config){\n           config = config || {};\n           init(surface);\n           return svgHeader() + svgContent();\n       }\n   };\n});\n\n/**\n * Provides specific methods to draw with VML.\n */\nExt.define('Ext.draw.engine.Vml', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.draw.Surface',\n\n    requires: ['Ext.draw.Draw', 'Ext.draw.Color', 'Ext.draw.Sprite', 'Ext.draw.Matrix', 'Ext.Element'],\n\n    /* End Definitions */\n\n    engine: 'Vml',\n\n    map: {M: \"m\", L: \"l\", C: \"c\", Z: \"x\", m: \"t\", l: \"r\", c: \"v\", z: \"x\"},\n    bitesRe: /([clmz]),?([^clmz]*)/gi,\n    valRe: /-?[^,\\s\\-]+/g,\n    fillUrlRe: /^url\\(\\s*['\"]?([^\\)]+?)['\"]?\\s*\\)$/i,\n    pathlike: /^(path|rect)$/,\n    NonVmlPathRe: /[ahqstv]/ig, // Non-VML Pathing ops\n    partialPathRe: /[clmz]/g,\n    fontFamilyRe: /^['\"]+|['\"]+$/g,\n    baseVmlCls: Ext.baseCSSPrefix + 'vml-base',\n    vmlGroupCls: Ext.baseCSSPrefix + 'vml-group',\n    spriteCls: Ext.baseCSSPrefix + 'vml-sprite',\n    measureSpanCls: Ext.baseCSSPrefix + 'vml-measure-span',\n    zoom: 21600,\n    coordsize: 1000,\n    coordorigin: '0 0',\n    zIndexShift: 0,\n    // VML uses CSS z-index and therefore doesn't need sprites to be kept in zIndex order\n    orderSpritesByZIndex: false,\n\n    // @private\n    // Convert an SVG standard path into a VML path\n    path2vml: function (path) {\n        var me = this,\n            nonVML = me.NonVmlPathRe,\n            map = me.map,\n            val = me.valRe,\n            zoom = me.zoom,\n            bites = me.bitesRe,\n            command = Ext.Function.bind(Ext.draw.Draw.pathToAbsolute, Ext.draw.Draw),\n            res, pa, p, r, i, ii, j, jj;\n        if (String(path).match(nonVML)) {\n            command = Ext.Function.bind(Ext.draw.Draw.path2curve, Ext.draw.Draw);\n        } else if (!String(path).match(me.partialPathRe)) {\n            res = String(path).replace(bites, function (all, command, args) {\n                var vals = [],\n                    isMove = command.toLowerCase() == \"m\",\n                    res = map[command];\n                args.replace(val, function (value) {\n                    if (isMove && vals.length === 2) {\n                        res += vals + map[command == \"m\" ? \"l\" : \"L\"];\n                        vals = [];\n                    }\n                    vals.push(Math.round(value * zoom));\n                });\n                return res + vals;\n            });\n            return res;\n        }\n        pa = command(path);\n        res = [];\n        for (i = 0, ii = pa.length; i < ii; i++) {\n            p = pa[i];\n            r = pa[i][0].toLowerCase();\n            if (r == \"z\") {\n                r = \"x\";\n            }\n            for (j = 1, jj = p.length; j < jj; j++) {\n                r += Math.round(p[j] * me.zoom) + (j != jj - 1 ? \",\" : \"\");\n            }\n            res.push(r);\n        }\n        return res.join(\" \");\n    },\n\n    // @private - set of attributes which need to be translated from the sprite API to the native browser API\n    translateAttrs: {\n        radius: \"r\",\n        radiusX: \"rx\",\n        radiusY: \"ry\",\n        lineWidth: \"stroke-width\",\n        fillOpacity: \"fill-opacity\",\n        strokeOpacity: \"stroke-opacity\",\n        strokeLinejoin: \"stroke-linejoin\"\n    },\n\n    // @private - Minimun set of defaults for different types of sprites.\n    minDefaults: {\n        circle: {\n            fill: \"none\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        ellipse: {\n            cx: 0,\n            cy: 0,\n            rx: 0,\n            ry: 0,\n            fill: \"none\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        rect: {\n            x: 0,\n            y: 0,\n            width: 0,\n            height: 0,\n            rx: 0,\n            ry: 0,\n            fill: \"none\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        text: {\n            x: 0,\n            y: 0,\n            \"text-anchor\": \"start\",\n            font: '10px \"Arial\"',\n            fill: \"#000\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        path: {\n            d: \"M0,0\",\n            fill: \"none\",\n            stroke: null,\n            \"stroke-width\": null,\n            opacity: null,\n            \"fill-opacity\": null,\n            \"stroke-opacity\": null\n        },\n        image: {\n            x: 0,\n            y: 0,\n            width: 0,\n            height: 0,\n            preserveAspectRatio: \"none\",\n            opacity: null\n        }\n    },\n\n    // private\n    onMouseEnter: function (e) {\n        this.fireEvent(\"mouseenter\", e);\n    },\n\n    // private\n    onMouseLeave: function (e) {\n        this.fireEvent(\"mouseleave\", e);\n    },\n\n    // @private - Normalize a delegated single event from the main container to each sprite and sprite group\n    processEvent: function (name, e) {\n        var target = e.getTarget(),\n            surface = this.surface,\n            sprite;\n        this.fireEvent(name, e);\n        sprite = this.items.get(target.id);\n        if (sprite) {\n            sprite.fireEvent(name, sprite, e);\n        }\n    },\n\n    // Create the VML element/elements and append them to the DOM\n    createSpriteElement: function (sprite) {\n        var me = this,\n            attr = sprite.attr,\n            type = sprite.type,\n            zoom = me.zoom,\n            vml = sprite.vml || (sprite.vml = {}),\n            round = Math.round,\n            el = (type === 'image') ? me.createNode('image') : me.createNode('shape'),\n            path, skew, textPath;\n\n        el.coordsize = zoom + ' ' + zoom;\n        el.coordorigin = attr.coordorigin || \"0 0\";\n        Ext.get(el).addCls(me.spriteCls);\n        if (type == \"text\") {\n            vml.path = path = me.createNode(\"path\");\n            path.textpathok = true;\n            vml.textpath = textPath = me.createNode(\"textpath\");\n            textPath.on = true;\n            el.appendChild(textPath);\n            el.appendChild(path);\n        }\n        el.id = sprite.id;\n        sprite.el = Ext.get(el);\n        sprite.el.setStyle('zIndex', -me.zIndexShift);\n        me.el.appendChild(el);\n        if (type !== 'image') {\n            skew = me.createNode(\"skew\");\n            skew.on = true;\n            el.appendChild(skew);\n            sprite.skew = skew;\n        }\n        sprite.matrix = new Ext.draw.Matrix();\n        sprite.bbox = {\n            plain: null,\n            transform: null\n        };\n\n        this.applyAttrs(sprite);\n        this.applyTransformations(sprite);        \n        sprite.fireEvent(\"render\", sprite);\n        return sprite.el;\n    },\n\n    getBBoxText: function (sprite) {\n        var vml = sprite.vml;\n        return {\n            x: vml.X + (vml.bbx || 0) - vml.W / 2,\n            y: vml.Y - vml.H / 2,\n            width: vml.W,\n            height: vml.H\n        };\n    },\n\n    applyAttrs: function (sprite) {\n        var me = this,\n            vml = sprite.vml,\n            group = sprite.group,\n            spriteAttr = sprite.attr,\n            el = sprite.el,\n            dom = el.dom,\n            style, name, groups, i, ln, scrubbedAttrs, font, key,\n            cx, cy, rx, ry;\n\n        if (group) {\n            groups = [].concat(group);\n            ln = groups.length;\n            for (i = 0; i < ln; i++) {\n                group = groups[i];\n                me.getGroup(group).add(sprite);\n            }\n            delete sprite.group;\n        }\n        scrubbedAttrs = me.scrubAttrs(sprite) || {};\n\n        if (sprite.zIndexDirty) {\n            me.setZIndex(sprite);\n        }\n\n        // Apply minimum default attributes\n        Ext.applyIf(scrubbedAttrs, me.minDefaults[sprite.type]);\n\n        if (sprite.type == 'image') {\n            Ext.apply(sprite.attr, {\n                x: scrubbedAttrs.x,\n                y: scrubbedAttrs.y,\n                width: scrubbedAttrs.width,\n                height: scrubbedAttrs.height\n            });\n            el.setStyle({\n                width: scrubbedAttrs.width + 'px',\n                height: scrubbedAttrs.height + 'px'\n            });\n            dom.src = scrubbedAttrs.src;\n        }\n\n        if (dom.href) {\n            dom.href = scrubbedAttrs.href;\n        }\n        if (dom.title) {\n            dom.title = scrubbedAttrs.title;\n        }\n        if (dom.target) {\n            dom.target = scrubbedAttrs.target;\n        }\n        if (dom.cursor) {\n            dom.cursor = scrubbedAttrs.cursor;\n        }\n\n        // Change visibility\n        if (sprite.dirtyHidden) {\n            (scrubbedAttrs.hidden) ? me.hidePrim(sprite) : me.showPrim(sprite);\n            sprite.dirtyHidden = false;\n        }\n\n        // Update path\n        if (sprite.dirtyPath) {\n            if (sprite.type == \"circle\" || sprite.type == \"ellipse\") {\n                cx = scrubbedAttrs.x;\n                cy = scrubbedAttrs.y;\n                rx = scrubbedAttrs.rx || scrubbedAttrs.r || 0;\n                ry = scrubbedAttrs.ry || scrubbedAttrs.r || 0;\n                dom.path = Ext.String.format(\"ar{0},{1},{2},{3},{4},{1},{4},{1}\",\n                    Math.round((cx - rx) * me.zoom),\n                    Math.round((cy - ry) * me.zoom),\n                    Math.round((cx + rx) * me.zoom),\n                    Math.round((cy + ry) * me.zoom),\n                    Math.round(cx * me.zoom));\n                sprite.dirtyPath = false;\n            }\n            else if (sprite.type !== \"text\" && sprite.type !== 'image') {\n                sprite.attr.path = scrubbedAttrs.path = me.setPaths(sprite, scrubbedAttrs) || scrubbedAttrs.path;\n                dom.path = me.path2vml(scrubbedAttrs.path);\n                sprite.dirtyPath = false;\n            }\n        }\n\n        // Apply clipping\n        if (\"clip-rect\" in scrubbedAttrs) {\n            me.setClip(sprite, scrubbedAttrs);\n        }\n\n        // Handle text (special handling required)\n        if (sprite.type == \"text\") {\n            me.setTextAttributes(sprite, scrubbedAttrs);\n        }\n\n        // Handle fill and opacity\n        if (scrubbedAttrs.opacity || scrubbedAttrs['stroke-opacity'] || scrubbedAttrs.fill) {\n            me.setFill(sprite, scrubbedAttrs);\n        }\n\n        // Handle stroke (all fills require a stroke element)\n        if (scrubbedAttrs.stroke || scrubbedAttrs['stroke-opacity'] || scrubbedAttrs.fill) {\n            me.setStroke(sprite, scrubbedAttrs);\n        }\n\n        //set styles\n        style = spriteAttr.style;\n        if (style) {\n            el.setStyle(style);\n        }\n\n        sprite.dirty = false;\n    },\n\n    setZIndex: function (sprite) {\n        var me = this,\n            zIndex = sprite.attr.zIndex,\n            shift = me.zIndexShift,\n            items, iLen, item, i;\n\n        if (zIndex < shift) {\n            // This means bad thing happened.\n            // The algorithm below will guarantee O(n) time.\n            items = me.items.items;\n            iLen = items.length;\n\n            for (i = 0; i < iLen; i++) {\n                if ((zIndex = items[i].attr.zIndex) && zIndex < shift) { // zIndex is no longer useful this case\n                    shift = zIndex;\n                }\n            }\n\n            me.zIndexShift = shift;\n            for (i = 0; i < iLen; i++) {\n                item = items[i];\n                if (item.el) {\n                    item.el.setStyle('zIndex', item.attr.zIndex - shift);\n                }\n                item.zIndexDirty = false;\n            }\n        } else if (sprite.el) {\n            sprite.el.setStyle('zIndex', zIndex - shift);\n            sprite.zIndexDirty = false;\n        }\n    },\n\n    // Normalize all virtualized types into paths.\n    setPaths: function (sprite, params) {\n        var spriteAttr = sprite.attr, thickness = sprite.attr['stroke-width'] || 1;\n        // Clear bbox cache\n        sprite.bbox.plain = null;\n        sprite.bbox.transform = null;\n        if (sprite.type == 'circle') {\n            spriteAttr.rx = spriteAttr.ry = params.r;\n            return Ext.draw.Draw.ellipsePath(sprite);\n        }\n        else if (sprite.type == 'ellipse') {\n            spriteAttr.rx = params.rx;\n            spriteAttr.ry = params.ry;\n            return Ext.draw.Draw.ellipsePath(sprite);\n        }\n        else if (sprite.type == 'rect') {\n            spriteAttr.rx = spriteAttr.ry = params.r;\n            return Ext.draw.Draw.rectPath(sprite);\n        }\n        else if (sprite.type == 'path' && spriteAttr.path) {\n            return Ext.draw.Draw.pathToAbsolute(spriteAttr.path);\n        }\n        return false;\n    },\n\n    setFill: function (sprite, params) {\n        var me = this,\n            el = sprite.el.dom,\n            fillEl = el.fill,\n            newfill = false,\n            opacity, gradient, fillUrl, rotation, angle;\n\n        if (!fillEl) {\n            // NOT an expando (but it sure looks like one)...\n            fillEl = el.fill = me.createNode(\"fill\");\n            newfill = true;\n        }\n        if (Ext.isArray(params.fill)) {\n            params.fill = params.fill[0];\n        }\n        if (params.fill == \"none\") {\n            fillEl.on = false;\n        }\n        else {\n            if (typeof params.opacity == \"number\") {\n                fillEl.opacity = params.opacity;\n            }\n            if (typeof params[\"fill-opacity\"] == \"number\") {\n                fillEl.opacity = params[\"fill-opacity\"];\n            }\n            fillEl.on = true;\n            if (typeof params.fill == \"string\") {\n                fillUrl = params.fill.match(me.fillUrlRe);\n                if (fillUrl) {\n                    fillUrl = fillUrl[1];\n                    // If the URL matches one of the registered gradients, render that gradient\n                    if (fillUrl.charAt(0) == \"#\") {\n                        gradient = me.gradientsColl.getByKey(fillUrl.substring(1));\n                    }\n                    if (gradient) {\n                        // VML angle is offset and inverted from standard, and must be adjusted to match rotation transform\n                        rotation = params.rotation;\n                        angle = -(gradient.angle + 270 + (rotation ? rotation.degrees : 0)) % 360;\n                        // IE will flip the angle at 0 degrees...\n                        if (angle === 0) {\n                            angle = 180;\n                        }\n                        fillEl.angle = angle;\n                        fillEl.type = \"gradient\";\n                        fillEl.method = \"sigma\";\n                        if (fillEl.colors) {\n                            fillEl.colors.value = gradient.colors;\n                        } else {\n                            fillEl.colors = gradient.colors;\n                        }\n                    }\n                    // Otherwise treat it as an image\n                    else {\n                        fillEl.src = fillUrl;\n                        fillEl.type = \"tile\";\n                    }\n                }\n                else {\n                    fillEl.color = Ext.draw.Color.toHex(params.fill);\n                    fillEl.src = \"\";\n                    fillEl.type = \"solid\";\n                }\n            }\n        }\n        if (newfill) {\n            el.appendChild(fillEl);\n        }\n    },\n\n    setStroke: function (sprite, params) {\n        var me = this,\n            el = sprite.el.dom,\n            strokeEl = sprite.strokeEl,\n            newStroke = false,\n            width, opacity;\n\n        if (!strokeEl) {\n            strokeEl = sprite.strokeEl = me.createNode(\"stroke\");\n            newStroke = true;\n        }\n        if (Ext.isArray(params.stroke)) {\n            params.stroke = params.stroke[0];\n        }\n        if (!params.stroke || params.stroke == \"none\" || params.stroke == 0 || params[\"stroke-width\"] == 0) {\n            strokeEl.on = false;\n        }\n        else {\n            strokeEl.on = true;\n            if (params.stroke && !params.stroke.match(me.fillUrlRe)) {\n                // VML does NOT support a gradient stroke :(\n                strokeEl.color = Ext.draw.Color.toHex(params.stroke);\n            }\n            strokeEl.dashstyle = params[\"stroke-dasharray\"] ? \"dash\" : \"solid\";\n            strokeEl.joinstyle = params[\"stroke-linejoin\"];\n            strokeEl.endcap = params[\"stroke-linecap\"] || \"round\";\n            strokeEl.miterlimit = params[\"stroke-miterlimit\"] || 8;\n            width = parseFloat(params[\"stroke-width\"] || 1) * 0.75;\n            opacity = params[\"stroke-opacity\"] || 1;\n            // VML Does not support stroke widths under 1, so we're going to fiddle with stroke-opacity instead.\n            if (Ext.isNumber(width) && width < 1) {\n                strokeEl.weight = 1;\n                strokeEl.opacity = opacity * width;\n            }\n            else {\n                strokeEl.weight = width;\n                strokeEl.opacity = opacity;\n            }\n        }\n        if (newStroke) {\n            el.appendChild(strokeEl);\n        }\n    },\n\n    setClip: function (sprite, params) {\n        var me = this,\n            el = sprite.el,\n            clipEl = sprite.clipEl,\n            rect = String(params[\"clip-rect\"]).split(me.separatorRe);\n        if (!clipEl) {\n            clipEl = sprite.clipEl = me.el.insertFirst(Ext.getDoc().dom.createElement(\"div\"));\n            clipEl.addCls(Ext.baseCSSPrefix + 'vml-sprite');\n        }\n        if (rect.length == 4) {\n            rect[2] = +rect[2] + (+rect[0]);\n            rect[3] = +rect[3] + (+rect[1]);\n            clipEl.setStyle(\"clip\", Ext.String.format(\"rect({1}px {2}px {3}px {0}px)\", rect[0], rect[1], rect[2], rect[3]));\n            clipEl.setSize(me.el.width, me.el.height);\n        }\n        else {\n            clipEl.setStyle(\"clip\", \"\");\n        }\n    },\n\n    setTextAttributes: function (sprite, params) {\n        var me = this,\n            vml = sprite.vml,\n            textStyle = vml.textpath.style,\n            spanCacheStyle = me.span.style,\n            zoom = me.zoom,\n            round = Math.round,\n            fontObj = {\n                fontSize: \"font-size\",\n                fontWeight: \"font-weight\",\n                fontStyle: \"font-style\"\n            },\n            fontProp,\n            paramProp;\n        if (sprite.dirtyFont) {\n            if (params.font) {\n                textStyle.font = spanCacheStyle.font = params.font;\n            }\n            if (params[\"font-family\"]) {\n                textStyle.fontFamily = '\"' + params[\"font-family\"].split(\",\")[0].replace(me.fontFamilyRe, \"\") + '\"';\n                spanCacheStyle.fontFamily = params[\"font-family\"];\n            }\n\n            for (fontProp in fontObj) {\n                paramProp = params[fontObj[fontProp]];\n                if (paramProp) {\n                    textStyle[fontProp] = spanCacheStyle[fontProp] = paramProp;\n                }\n            }\n\n            me.setText(sprite, params.text);\n\n            if (vml.textpath.string) {\n                me.span.innerHTML = String(vml.textpath.string).replace(/</g, \"&#60;\").replace(/&/g, \"&#38;\").replace(/\\n/g, \"<br/>\");\n            }\n            vml.W = me.span.offsetWidth;\n            vml.H = me.span.offsetHeight + 2; // TODO handle baseline differences and offset in VML Textpath\n\n            // text-anchor emulation\n            if (params[\"text-anchor\"] == \"middle\") {\n                textStyle[\"v-text-align\"] = \"center\";\n            }\n            else if (params[\"text-anchor\"] == \"end\") {\n                textStyle[\"v-text-align\"] = \"right\";\n                vml.bbx = -Math.round(vml.W / 2);\n            }\n            else {\n                textStyle[\"v-text-align\"] = \"left\";\n                vml.bbx = Math.round(vml.W / 2);\n            }\n        }\n        vml.X = params.x;\n        vml.Y = params.y;\n        vml.path.v = Ext.String.format(\"m{0},{1}l{2},{1}\", Math.round(vml.X * zoom), Math.round(vml.Y * zoom), Math.round(vml.X * zoom) + 1);\n        // Clear bbox cache\n        sprite.bbox.plain = null;\n        sprite.bbox.transform = null;\n        sprite.dirtyFont = false;\n    },\n\n    setText: function (sprite, text) {\n        sprite.vml.textpath.string = Ext.htmlDecode(text);\n    },\n\n    hide: function () {\n        this.el.hide();\n    },\n\n    show: function () {\n        this.el.show();\n    },\n\n    hidePrim: function (sprite) {\n        sprite.el.addCls(Ext.baseCSSPrefix + 'hide-visibility');\n    },\n\n    showPrim: function (sprite) {\n        sprite.el.removeCls(Ext.baseCSSPrefix + 'hide-visibility');\n    },\n\n    setSize: function (width, height) {\n        var me = this;\n        width = width || me.width;\n        height = height || me.height;\n        me.width = width;\n        me.height = height;\n\n        if (me.el) {\n            // Size outer div\n            if (width != undefined) {\n                me.el.setWidth(width);\n            }\n            if (height != undefined) {\n                me.el.setHeight(height);\n            }\n        }\n\n        me.callParent(arguments);\n    },\n\n    /**\n     * @private Using the current viewBox property and the surface's width and height, calculate the\n     * appropriate viewBoxShift that will be applied as a persistent transform to all sprites.\n     */\n    applyViewBox: function () {\n        var me = this,\n            viewBox = me.viewBox,\n            width = me.width,\n            height = me.height,\n            items,\n            iLen,\n            i;\n        \n        me.callParent();\n\n        if (viewBox && (width || height)) {\n            items = me.items.items;\n            iLen = items.length;\n\n            for (i = 0; i < iLen; i++) {\n                me.applyTransformations(items[i]);\n            }\n        }\n    },\n\n    onAdd: function (item) {\n        this.callParent(arguments);\n        if (this.el) {\n            this.renderItem(item);\n        }\n    },\n\n    onRemove: function (sprite) {\n        if (sprite.el) {\n            sprite.el.remove();\n            delete sprite.el;\n        }\n        this.callParent(arguments);\n    },\n\n    render: function (container) {\n        var me = this,\n            doc = Ext.getDoc().dom,\n            el;\n        // VML Node factory method (createNode)\n        if (!me.createNode) {\n            try {\n                if (!doc.namespaces.rvml) {\n                    doc.namespaces.add(\"rvml\", \"urn:schemas-microsoft-com:vml\");\n                }\n                me.createNode = function (tagName) {\n                    return doc.createElement(\"<rvml:\" + tagName + ' class=\"rvml\">');\n                };\n            } catch (e) {\n                me.createNode = function (tagName) {\n                    return doc.createElement(\"<\" + tagName + ' xmlns=\"urn:schemas-microsoft.com:vml\" class=\"rvml\">');\n                };\n            }\n        }\n\n        if (!me.el) {\n            el = doc.createElement(\"div\");\n            me.el = Ext.get(el);\n            me.el.addCls(me.baseVmlCls);\n\n            // Measuring span (offscrren)\n            me.span = doc.createElement(\"span\");\n            Ext.get(me.span).addCls(me.measureSpanCls);\n            el.appendChild(me.span);\n            me.el.setSize(me.width || 0, me.height || 0);\n            container.appendChild(el);\n            me.el.on({\n                scope: me,\n                mouseup: me.onMouseUp,\n                mousedown: me.onMouseDown,\n                mouseover: me.onMouseOver,\n                mouseout: me.onMouseOut,\n                mousemove: me.onMouseMove,\n                mouseenter: me.onMouseEnter,\n                mouseleave: me.onMouseLeave,\n                click: me.onClick,\n                dblclick: me.onDblClick\n            });\n        }\n        me.renderAll();\n    },\n\n    renderAll: function () {\n        this.items.each(this.renderItem, this);\n    },\n\n    redraw: function (sprite) {\n        sprite.dirty = true;\n        this.renderItem(sprite);\n    },\n\n    renderItem: function (sprite) {\n        // Does the surface element exist?\n        if (!this.el) {\n            return;\n        }\n\n        // Create sprite element if necessary\n        if (!sprite.el) {\n            this.createSpriteElement(sprite);\n        }\n\n        if (sprite.dirty) {\n            this.applyAttrs(sprite);\n            if (sprite.dirtyTransform) {\n                this.applyTransformations(sprite);\n            }\n        }\n    },\n\n    rotationCompensation: function (deg, dx, dy) {\n        var matrix = new Ext.draw.Matrix();\n        matrix.rotate(-deg, 0.5, 0.5);\n        return {\n            x: matrix.x(dx, dy),\n            y: matrix.y(dx, dy)\n        };\n    },\n\n    transform: function (sprite, matrixOnly) {\n        var me = this,\n            bbox = me.getBBox(sprite, true),\n            cx = bbox.x + bbox.width * 0.5,\n            cy = bbox.y + bbox.height * 0.5,\n            matrix = new Ext.draw.Matrix(),\n            transforms = sprite.transformations,\n            transformsLength = transforms.length,\n            i = 0,\n            deltaDegrees = 0,\n            deltaScaleX = 1,\n            deltaScaleY = 1,\n            flip = \"\",\n            el = sprite.el,\n            dom = el.dom,\n            domStyle = dom.style,\n            zoom = me.zoom,\n            skew = sprite.skew,\n            shift = me.viewBoxShift,\n            deltaX, deltaY, transform, type, compensate, y, fill, newAngle, zoomScaleX, zoomScaleY, newOrigin, offset;\n\n\n        for (; i < transformsLength; i++) {\n            transform = transforms[i];\n            type = transform.type;\n            if (type == \"translate\") {\n                matrix.translate(transform.x, transform.y);\n            }\n            else if (type == \"rotate\") {\n                matrix.rotate(transform.degrees, transform.x, transform.y);\n                deltaDegrees += transform.degrees;\n            }\n            else if (type == \"scale\") {\n                matrix.scale(transform.x, transform.y, transform.centerX, transform.centerY);\n                deltaScaleX *= transform.x;\n                deltaScaleY *= transform.y;\n            }\n        }\n\n        sprite.matrix = matrix.clone();\n\n        if (matrixOnly) {\n            return;\n        }\n\n        if (shift) {\n            matrix.prepend(shift.scale, 0, 0, shift.scale, shift.dx * shift.scale, shift.dy * shift.scale);\n        }\n\n        // Hide element while we transform\n        if (sprite.type != \"image\" && skew) {\n            skew.origin = \"0,0\";\n            // matrix transform via VML skew\n            skew.matrix = matrix.toString();\n            // skew.offset = '32767,1' OK\n            // skew.offset = '32768,1' Crash\n            // M$, R U kidding??\n            offset = matrix.offset();\n            if (offset[0] > 32767) {\n                offset[0] = 32767;\n            } else if (offset[0] < -32768) {\n                offset[0] = -32768;\n            }\n            if (offset[1] > 32767) {\n                offset[1] = 32767;\n            } else if (offset[1] < -32768) {\n                offset[1] = -32768;\n            }\n            skew.offset = offset;\n        }\n        else {\n            domStyle.filter = matrix.toFilter();\n            domStyle.left = Math.min(\n                matrix.x(bbox.x, bbox.y),\n                matrix.x(bbox.x + bbox.width, bbox.y),\n                matrix.x(bbox.x, bbox.y + bbox.height),\n                matrix.x(bbox.x + bbox.width, bbox.y + bbox.height)) + 'px';\n            domStyle.top = Math.min(\n                matrix.y(bbox.x, bbox.y),\n                matrix.y(bbox.x + bbox.width, bbox.y),\n                matrix.y(bbox.x, bbox.y + bbox.height),\n                matrix.y(bbox.x + bbox.width, bbox.y + bbox.height)) + 'px';\n        }\n    },\n\n    createItem: function (config) {\n        return Ext.create('Ext.draw.Sprite', config);\n    },\n\n    getRegion: function () {\n        return this.el.getRegion();\n    },\n\n    addCls: function (sprite, className) {\n        if (sprite && sprite.el) {\n            sprite.el.addCls(className);\n        }\n    },\n\n    removeCls: function (sprite, className) {\n        if (sprite && sprite.el) {\n            sprite.el.removeCls(className);\n        }\n    },\n\n    /**\n     * Adds a definition to this Surface for a linear gradient. We convert the gradient definition\n     * to its corresponding VML attributes and store it for later use by individual sprites.\n     * @param {Object} gradient\n     */\n    addGradient: function (gradient) {\n        var gradients = this.gradientsColl || (this.gradientsColl = Ext.create('Ext.util.MixedCollection')),\n            colors = [],\n            stops = Ext.create('Ext.util.MixedCollection'),\n            keys,\n            items,\n            iLen,\n            key,\n            item,\n            i;\n\n        // Build colors string\n        stops.addAll(gradient.stops);\n        stops.sortByKey(\"ASC\", function (a, b) {\n            a = parseInt(a, 10);\n            b = parseInt(b, 10);\n            return a > b ? 1 : (a < b ? -1 : 0);\n        });\n\n        keys = stops.keys;\n        items = stops.items;\n        iLen = keys.length;\n\n        for (i = 0; i < iLen; i++) {\n            key = keys[i];\n            item = items[i];\n            colors.push(key + '% ' + item.color);\n        }\n\n        gradients.add(gradient.id, {\n            colors: colors.join(\",\"),\n            angle: gradient.angle\n        });\n    },\n\n    destroy: function () {\n        var me = this;\n\n        me.callParent(arguments);\n        if (me.el) {\n            me.el.remove();\n        }\n        delete me.el;\n    }\n});\n\n/**\n * A simple Component for displaying an Adobe Flash SWF movie. The movie will be sized and can participate\n * in layout like any other Component.\n *\n * This component requires the third-party SWFObject library version 2.2 or above. It is not included within\n * the ExtJS distribution, so you will have to include it into your page manually in order to use this component.\n * The SWFObject library can be downloaded from the [SWFObject project page](http://code.google.com/p/swfobject)\n * and then simply import it into the head of your HTML document:\n *\n *     <script type=\"text/javascript\" src=\"path/to/local/swfobject.js\"></script>\n *\n * ## Configuration\n *\n * This component allows several options for configuring how the target Flash movie is embedded. The most\n * important is the required {@link #url} which points to the location of the Flash movie to load. Other\n * configurations include:\n *\n * - {@link #backgroundColor}\n * - {@link #wmode}\n * - {@link #flashVars}\n * - {@link #flashParams}\n * - {@link #flashAttributes}\n *\n * ## Example usage:\n *\n *     var win = Ext.widget('window', {\n *         title: \"It's a tiger!\",\n *         layout: 'fit',\n *         width: 300,\n *         height: 300,\n *         x: 20,\n *         y: 20,\n *         resizable: true,\n *         items: {\n *             xtype: 'flash',\n *             url: 'tiger.swf'\n *         }\n *     });\n *     win.show();\n *\n * ## Express Install\n *\n * Adobe provides a tool called [Express Install](http://www.adobe.com/devnet/flashplayer/articles/express_install.html)\n * that offers users an easy way to upgrade their Flash player. If you wish to make use of this, you should set\n * the static EXPRESS\\_INSTALL\\_URL property to the location of your Express Install SWF file:\n *\n *     Ext.flash.Component.EXPRESS_INSTALL_URL = 'path/to/local/expressInstall.swf';\n *\n * @docauthor Jason Johnston <jason@sencha.com>\n */\nExt.define('Ext.flash.Component', {\n    extend: 'Ext.Component',\n    alternateClassName: 'Ext.FlashComponent',\n    alias: 'widget.flash',\n\n    /**\n     * @cfg {String} [flashVersion=\"9.0.115\"]\n     * Indicates the version the flash content was published for.\n     */\n    flashVersion : '9.0.115',\n\n    /**\n     * @cfg {String} [backgroundColor=\"#ffffff\"]\n     * The background color of the SWF movie.\n     */\n    backgroundColor: '#ffffff',\n\n    /**\n     * @cfg {String} [wmode=\"opaque\"]\n     * The wmode of the flash object. This can be used to control layering.\n     * Set to 'transparent' to ignore the {@link #backgroundColor} and make the background of the Flash\n     * movie transparent.\n     */\n    wmode: 'opaque',\n\n    /**\n     * @cfg {Object} flashVars\n     * A set of key value pairs to be passed to the flash object as flash variables.\n     */\n\n    /**\n     * @cfg {Object} flashParams\n     * A set of key value pairs to be passed to the flash object as parameters. Possible parameters can be found here:\n     * http://kb2.adobe.com/cps/127/tn_12701.html\n     */\n\n    /**\n     * @cfg {Object} flashAttributes\n     * A set of key value pairs to be passed to the flash object as attributes.\n     */\n\n    /**\n     * @cfg {String} url (required)\n     * The URL of the SWF file to include.\n     */\n\n    /**\n     * @cfg {String/Number} [swfWidth=\"100%\"]\n     * The width of the embedded SWF movie inside the component.\n     *\n     * Defaults to \"100%\" so that the movie matches the width of the component.\n     */\n    swfWidth: '100%',\n\n    /**\n     * @cfg {String/Number} [swfHeight=\"100%\"]\n     * The height of the embedded SWF movie inside the component.\n     *\n     * Defaults to \"100%\" so that the movie matches the height of the component.\n     */\n    swfHeight: '100%',\n\n    /**\n     * @cfg {Boolean} [expressInstall=false]\n     * True to prompt the user to install flash if not installed. Note that this uses\n     * Ext.FlashComponent.EXPRESS_INSTALL_URL, which should be set to the local resource.\n     */\n    expressInstall: false,\n\n    /**\n     * @property {Ext.Element} swf\n     * A reference to the object or embed element into which the SWF file is loaded. Only\n     * populated after the component is rendered and the SWF has been successfully embedded.\n     */\n\n    // Have to create a placeholder div with the swfId, which SWFObject will replace with the object/embed element.\n    renderTpl: ['<div id=\"{swfId}\"></div>'],\n\n    initComponent: function() {\n        if (!('swfobject' in window)) {\n            Ext.Error.raise('The SWFObject library is not loaded. Ext.flash.Component requires SWFObject version 2.2 or later: http://code.google.com/p/swfobject/');\n        }\n        if (!this.url) {\n            Ext.Error.raise('The \"url\" config is required for Ext.flash.Component');\n        }\n\n        this.callParent();\n        this.addEvents(\n            /**\n             * @event success\n             * Fired when the Flash movie has been successfully embedded\n             * @param {Ext.flash.Component} this\n             */\n            'success',\n\n            /**\n             * @event failure\n             * Fired when the Flash movie embedding fails\n             * @param {Ext.flash.Component} this\n             */\n            'failure'\n        );\n    },\n    \n    beforeRender: function(){\n        this.callParent();\n        \n        Ext.applyIf(this.renderData, {\n            swfId: this.getSwfId()\n        });\n    },\n\n    afterRender: function() {\n        var me = this,\n            flashParams = Ext.apply({}, me.flashParams), \n            flashVars = Ext.apply({}, me.flashVars);\n\n        me.callParent();\n\n        flashParams = Ext.apply({\n            allowScriptAccess: 'always',\n            bgcolor: me.backgroundColor,\n            wmode: me.wmode\n        }, flashParams);\n\n        flashVars = Ext.apply({\n            allowedDomain: document.location.hostname\n        }, flashVars);\n\n        new swfobject.embedSWF(\n            me.url,\n            me.getSwfId(),\n            me.swfWidth,\n            me.swfHeight,\n            me.flashVersion,\n            me.expressInstall ? me.statics.EXPRESS_INSTALL_URL : undefined,\n            flashVars,\n            flashParams,\n            me.flashAttributes,\n            Ext.bind(me.swfCallback, me)\n        );\n    },\n\n    /**\n     * @private\n     * The callback method for handling an embedding success or failure by SWFObject\n     * @param {Object} e The event object passed by SWFObject - see http://code.google.com/p/swfobject/wiki/api\n     */\n    swfCallback: function(e) {\n        var me = this;\n        if (e.success) {\n            me.swf = Ext.get(e.ref);\n            me.onSuccess();\n            me.fireEvent('success', me);\n        } else {\n            me.onFailure();\n            me.fireEvent('failure', me);\n        }\n    },\n\n    /**\n     * Retrieves the id of the SWF object/embed element.\n     */\n    getSwfId: function() {\n        return this.swfId || (this.swfId = \"extswf\" + this.getAutoId());\n    },\n\n    onSuccess: function() {\n        // swfobject forces visiblity:visible on the swf element, which prevents it \n        // from getting hidden when an ancestor is given visibility:hidden.\n        this.swf.setStyle('visibility', 'inherit');\n    },\n\n    onFailure: Ext.emptyFn,\n\n    beforeDestroy: function() {\n        var me = this,\n            swf = me.swf;\n        if (swf) {\n            swfobject.removeSWF(me.getSwfId());\n            Ext.destroy(swf);\n            delete me.swf;\n        }\n        me.callParent();\n    },\n\n    statics: {\n        /**\n         * @property {String}\n         * The url for installing flash if it doesn't exist. This should be set to a local resource.\n         * See http://www.adobe.com/devnet/flashplayer/articles/express_install.html for details.\n         * @static\n         */\n        EXPRESS_INSTALL_URL: 'http:/' + '/swfobject.googlecode.com/svn/trunk/swfobject/expressInstall.swf'\n    }\n});\n\n/**\n * The subclasses of this class provide actions to perform upon {@link Ext.form.Basic Form}s.\n *\n * Instances of this class are only created by a {@link Ext.form.Basic Form} when the Form needs to perform an action\n * such as submit or load. The Configuration options listed for this class are set through the Form's action methods:\n * {@link Ext.form.Basic#submit submit}, {@link Ext.form.Basic#load load} and {@link Ext.form.Basic#doAction doAction}\n *\n * The instance of Action which performed the action is passed to the success and failure callbacks of the Form's action\n * methods ({@link Ext.form.Basic#submit submit}, {@link Ext.form.Basic#load load} and\n * {@link Ext.form.Basic#doAction doAction}), and to the {@link Ext.form.Basic#actioncomplete actioncomplete} and\n * {@link Ext.form.Basic#actionfailed actionfailed} event handlers.\n */\nExt.define('Ext.form.action.Action', {\n    alternateClassName: 'Ext.form.Action',\n\n    /**\n     * @cfg {Ext.form.Basic} form\n     * The {@link Ext.form.Basic BasicForm} instance that is invoking this Action. Required.\n     */\n\n    /**\n     * @cfg {String} url\n     * The URL that the Action is to invoke. Will default to the {@link Ext.form.Basic#url url} configured on the\n     * {@link #form}.\n     */\n\n    /**\n     * @cfg {Boolean} reset\n     * When set to **true**, causes the Form to be {@link Ext.form.Basic#reset reset} on Action success. If specified,\n     * this happens before the {@link #success} callback is called and before the Form's\n     * {@link Ext.form.Basic#actioncomplete actioncomplete} event fires.\n     */\n\n    /**\n     * @cfg {String} method\n     * The HTTP method to use to access the requested URL.\n     * Defaults to the {@link Ext.form.Basic#method BasicForm's method}, or 'POST' if not specified.\n     */\n\n    /**\n     * @cfg {Object/String} params\n     * Extra parameter values to pass. These are added to the Form's {@link Ext.form.Basic#baseParams} and passed to the\n     * specified URL along with the Form's input fields.\n     *\n     * Parameters are encoded as standard HTTP parameters using {@link Ext#urlEncode Ext.Object.toQueryString}.\n     */\n\n    /**\n     * @cfg {Object} headers\n     * Extra headers to be sent in the AJAX request for submit and load actions.\n     * See {@link Ext.data.proxy.Ajax#headers}.\n     */\n\n    /**\n     * @cfg {Number} timeout\n     * The number of seconds to wait for a server response before failing with the {@link #failureType} as\n     * {@link Ext.form.action.Action#CONNECT_FAILURE}. If not specified, defaults to the configured\n     * {@link Ext.form.Basic#timeout timeout} of the {@link #form}.\n     */\n\n    /**\n     * @cfg {Function} success\n     * The function to call when a valid success return packet is received.\n     * @cfg {Ext.form.Basic} success.form The form that requested the action\n     * @cfg {Ext.form.action.Action} success.action The Action class. The {@link #result} property of this object may\n     * be examined to perform custom postprocessing.\n     */\n\n    /**\n     * @cfg {Function} failure\n     * The function to call when a failure packet was received, or when an error ocurred in the Ajax communication.\n     * @cfg {Ext.form.Basic} failure.form The form that requested the action\n     * @cfg {Ext.form.action.Action} failure.action The Action class. If an Ajax error ocurred, the failure type will\n     * be in {@link #failureType}. The {@link #result} property of this object may be examined to perform custom\n     * postprocessing.\n     */\n\n    /**\n     * @cfg {Object} scope\n     * The scope in which to call the configured #success and #failure callback functions\n     * (the `this` reference for the callback functions).\n     */\n\n    /**\n     * @cfg {String} waitMsg\n     * The message to be displayed by a call to {@link Ext.window.MessageBox#wait} during the time the action is being\n     * processed.\n     */\n\n    /**\n     * @cfg {String} waitTitle\n     * The title to be displayed by a call to {@link Ext.window.MessageBox#wait} during the time the action is being\n     * processed.\n     */\n\n    /**\n     * @cfg {Boolean} submitEmptyText\n     * If set to true, the emptyText value will be sent with the form when it is submitted.\n     */\n    submitEmptyText : true,\n\n    /**\n     * @property {String} type\n     * The type of action this Action instance performs. Currently only \"submit\" and \"load\" are supported.\n     */\n\n    /**\n     * @property {String} failureType\n     * The type of failure detected will be one of these:\n     * {@link #CLIENT_INVALID}, {@link #SERVER_INVALID}, {@link #CONNECT_FAILURE}, or {@link #LOAD_FAILURE}.\n     *\n     * Usage:\n     *\n     *     var fp = new Ext.form.Panel({\n     *     ...\n     *     buttons: [{\n     *         text: 'Save',\n     *         formBind: true,\n     *         handler: function(){\n     *             if(fp.getForm().isValid()){\n     *                 fp.getForm().submit({\n     *                     url: 'form-submit.php',\n     *                     waitMsg: 'Submitting your data...',\n     *                     success: function(form, action){\n     *                         // server responded with success = true\n     *                         var result = action.{@link #result};\n     *                     },\n     *                     failure: function(form, action){\n     *                         if (action.{@link #failureType} === Ext.form.action.Action.CONNECT_FAILURE) {\n     *                             Ext.Msg.alert('Error',\n     *                                 'Status:'+action.{@link #response}.status+': '+\n     *                                 action.{@link #response}.statusText);\n     *                         }\n     *                         if (action.failureType === Ext.form.action.Action.SERVER_INVALID){\n     *                             // server responded with success = false\n     *                             Ext.Msg.alert('Invalid', action.{@link #result}.errormsg);\n     *                         }\n     *                     }\n     *                 });\n     *             }\n     *         }\n     *     },{\n     *         text: 'Reset',\n     *         handler: function(){\n     *             fp.getForm().reset();\n     *         }\n     *     }]\n     */\n\n    /**\n     * @property {Object} response\n     * The raw XMLHttpRequest object used to perform the action.\n     */\n\n    /**\n     * @property {Object} result\n     * The decoded response object containing a boolean `success` property and other, action-specific properties.\n     */\n\n    /**\n     * Creates new Action.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        if (config) {\n            Ext.apply(this, config);\n        }\n\n        // Normalize the params option to an Object\n        var params = config.params;\n        if (Ext.isString(params)) {\n            this.params = Ext.Object.fromQueryString(params);\n        }\n    },\n\n    /**\n     * @method\n     * Invokes this action using the current configuration.\n     */\n    run: Ext.emptyFn,\n\n    /**\n     * @private\n     * @method onSuccess\n     * Callback method that gets invoked when the action completes successfully. Must be implemented by subclasses.\n     * @param {Object} response\n     */\n\n    /**\n     * @private\n     * @method handleResponse\n     * Handles the raw response and builds a result object from it. Must be implemented by subclasses.\n     * @param {Object} response\n     */\n\n    /**\n     * @private\n     * Handles a failure response.\n     * @param {Object} response\n     */\n    onFailure : function(response){\n        this.response = response;\n        this.failureType = Ext.form.action.Action.CONNECT_FAILURE;\n        this.form.afterAction(this, false);\n    },\n\n    /**\n     * @private\n     * Validates that a response contains either responseText or responseXML and invokes\n     * {@link #handleResponse} to build the result object.\n     * @param {Object} response The raw response object.\n     * @return {Object/Boolean} The result object as built by handleResponse, or `true` if\n     * the response had empty responseText and responseXML.\n     */\n    processResponse : function(response){\n        this.response = response;\n        if (!response.responseText && !response.responseXML) {\n            return true;\n        }\n        return (this.result = this.handleResponse(response));\n    },\n\n    /**\n     * @private\n     * Build the URL for the AJAX request. Used by the standard AJAX submit and load actions.\n     * @return {String} The URL.\n     */\n    getUrl: function() {\n        return this.url || this.form.url;\n    },\n\n    /**\n     * @private\n     * Determine the HTTP method to be used for the request.\n     * @return {String} The HTTP method\n     */\n    getMethod: function() {\n        return (this.method || this.form.method || 'POST').toUpperCase();\n    },\n\n    /**\n     * @private\n     * Get the set of parameters specified in the BasicForm's baseParams and/or the params option.\n     * Items in params override items of the same name in baseParams.\n     * @return {Object} the full set of parameters\n     */\n    getParams: function() {\n        return Ext.apply({}, this.params, this.form.baseParams);\n    },\n\n    /**\n     * @private\n     * Creates a callback object.\n     */\n    createCallback: function() {\n        var me = this,\n            undef,\n            form = me.form;\n        return {\n            success: me.onSuccess,\n            failure: me.onFailure,\n            scope: me,\n            timeout: (this.timeout * 1000) || (form.timeout * 1000),\n            upload: form.fileUpload ? me.onSuccess : undef\n        };\n    },\n\n    statics: {\n        /**\n         * @property\n         * Failure type returned when client side validation of the Form fails thus aborting a submit action. Client\n         * side validation is performed unless {@link Ext.form.action.Submit#clientValidation} is explicitly set to\n         * false.\n         * @static\n         */\n        CLIENT_INVALID: 'client',\n\n        /**\n         * @property\n         * Failure type returned when server side processing fails and the {@link #result}'s `success` property is set to\n         * false.\n         *\n         * In the case of a form submission, field-specific error messages may be returned in the {@link #result}'s\n         * errors property.\n         * @static\n         */\n        SERVER_INVALID: 'server',\n\n        /**\n         * @property\n         * Failure type returned when a communication error happens when attempting to send a request to the remote\n         * server. The {@link #response} may be examined to provide further information.\n         * @static\n         */\n        CONNECT_FAILURE: 'connect',\n\n        /**\n         * @property\n         * Failure type returned when the response's `success` property is set to false, or no field values are returned\n         * in the response's data property.\n         * @static\n         */\n        LOAD_FAILURE: 'load'\n\n\n    }\n});\n\n/**\n * A class which handles loading of data from a server into the Fields of an {@link Ext.form.Basic}.\n *\n * Instances of this class are only created by a {@link Ext.form.Basic Form} when {@link Ext.form.Basic#load load}ing.\n *\n * ## Response Packet Criteria\n *\n * A response packet **must** contain:\n *\n *   - **`success`** property : Boolean\n *   - **`data`** property : Object\n *\n * The `data` property contains the values of Fields to load. The individual value object for each Field is passed to\n * the Field's {@link Ext.form.field.Field#setValue setValue} method.\n *\n * ## JSON Packets\n *\n * By default, response packets are assumed to be JSON, so for the following form load call:\n *\n *     var myFormPanel = new Ext.form.Panel({\n *         title: 'Client and routing info',\n *         renderTo: Ext.getBody(),\n *         defaults: {\n *             xtype: 'textfield'\n *         },\n *         items: [{\n *             fieldLabel: 'Client',\n *             name: 'clientName'\n *         }, {\n *             fieldLabel: 'Port of loading',\n *             name: 'portOfLoading'\n *         }, {\n *             fieldLabel: 'Port of discharge',\n *             name: 'portOfDischarge'\n *         }]\n *     });\n *     myFormPanel.{@link Ext.form.Panel#getForm getForm}().{@link Ext.form.Basic#load load}({\n *         url: '/getRoutingInfo.php',\n *         params: {\n *             consignmentRef: myConsignmentRef\n *         },\n *         failure: function(form, action) {\n *             Ext.Msg.alert(\"Load failed\", action.result.errorMessage);\n *         }\n *     });\n *\n * a **success response** packet may look like this:\n *\n *     {\n *         success: true,\n *         data: {\n *             clientName: \"Fred. Olsen Lines\",\n *             portOfLoading: \"FXT\",\n *             portOfDischarge: \"OSL\"\n *         }\n *     }\n *\n * while a **failure response** packet may look like this:\n *\n *     {\n *         success: false,\n *         errorMessage: \"Consignment reference not found\"\n *     }\n *\n * Other data may be placed into the response for processing the {@link Ext.form.Basic Form}'s callback or event handler\n * methods. The object decoded from this JSON is available in the {@link Ext.form.action.Action#result result} property.\n */\nExt.define('Ext.form.action.Load', {\n    extend:'Ext.form.action.Action',\n    requires: ['Ext.data.Connection'],\n    alternateClassName: 'Ext.form.Action.Load',\n    alias: 'formaction.load',\n\n    type: 'load',\n\n    /**\n     * @private\n     */\n    run: function() {\n        Ext.Ajax.request(Ext.apply(\n            this.createCallback(),\n            {\n                method: this.getMethod(),\n                url: this.getUrl(),\n                headers: this.headers,\n                params: this.getParams()\n            }\n        ));\n    },\n\n    /**\n     * @private\n     */\n    onSuccess: function(response){\n        var result = this.processResponse(response),\n            form = this.form;\n        if (result === true || !result.success || !result.data) {\n            this.failureType = Ext.form.action.Action.LOAD_FAILURE;\n            form.afterAction(this, false);\n            return;\n        }\n        form.clearInvalid();\n        form.setValues(result.data);\n        form.afterAction(this, true);\n    },\n\n    /**\n     * @private\n     */\n    handleResponse: function(response) {\n        var reader = this.form.reader,\n            rs, data;\n        if (reader) {\n            rs = reader.read(response);\n            data = rs.records && rs.records[0] ? rs.records[0].data : null;\n            return {\n                success : rs.success,\n                data : data\n            };\n        }\n        return Ext.decode(response.responseText);\n    }\n});\n\n\n/**\n * A class which handles submission of data from {@link Ext.form.Basic Form}s and processes the returned response.\n *\n * Instances of this class are only created by a {@link Ext.form.Basic Form} when\n * {@link Ext.form.Basic#submit submit}ting.\n *\n * # Response Packet Criteria\n *\n * A response packet may contain:\n *\n *   - **`success`** property : Boolean - required.\n *\n *   - **`errors`** property : Object - optional, contains error messages for invalid fields.\n *\n * # JSON Packets\n *\n * By default, response packets are assumed to be JSON, so a typical response packet may look like this:\n *\n *     {\n *         success: false,\n *         errors: {\n *             clientCode: \"Client not found\",\n *             portOfLoading: \"This field must not be null\"\n *         }\n *     }\n *\n * Other data may be placed into the response for processing by the {@link Ext.form.Basic}'s callback or event handler\n * methods. The object decoded from this JSON is available in the {@link Ext.form.action.Action#result result} property.\n *\n * Alternatively, if an {@link Ext.form.Basic#errorReader errorReader} is specified as an\n * {@link Ext.data.reader.Xml XmlReader}:\n *\n *     errorReader: new Ext.data.reader.Xml({\n *             record : 'field',\n *             success: '@success'\n *         }, [\n *             'id', 'msg'\n *         ]\n *     )\n *\n * then the results may be sent back in XML format:\n *\n *     <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n *     <message success=\"false\">\n *     <errors>\n *         <field>\n *             <id>clientCode</id>\n *             <msg><![CDATA[Code not found. <br /><i>This is a test validation message from the server </i>]]></msg>\n *         </field>\n *         <field>\n *             <id>portOfLoading</id>\n *             <msg><![CDATA[Port not found. <br /><i>This is a test validation message from the server </i>]]></msg>\n *         </field>\n *     </errors>\n *     </message>\n *\n * Other elements may be placed into the response XML for processing by the {@link Ext.form.Basic}'s callback or event\n * handler methods. The XML document is available in the {@link Ext.form.Basic#errorReader errorReader}'s\n * {@link Ext.data.reader.Xml#xmlData xmlData} property.\n */\nExt.define('Ext.form.action.Submit', {\n    extend:'Ext.form.action.Action',\n    alternateClassName: 'Ext.form.Action.Submit',\n    alias: 'formaction.submit',\n\n    type: 'submit',\n\n    /**\n     * @cfg {Boolean} [clientValidation=true]\n     * Determines whether a Form's fields are validated in a final call to {@link Ext.form.Basic#isValid isValid} prior\n     * to submission. Pass false in the Form's submit options to prevent this.\n     */\n\n    // inherit docs\n    run : function(){\n        var form = this.form;\n        if (this.clientValidation === false || form.isValid()) {\n            this.doSubmit();\n        } else {\n            // client validation failed\n            this.failureType = Ext.form.action.Action.CLIENT_INVALID;\n            form.afterAction(this, false);\n        }\n    },\n\n    /**\n     * @private\n     * Performs the submit of the form data.\n     */\n    doSubmit: function() {\n        var formEl,\n            ajaxOptions = Ext.apply(this.createCallback(), {\n                url: this.getUrl(),\n                method: this.getMethod(),\n                headers: this.headers\n            });\n\n        // For uploads we need to create an actual form that contains the file upload fields,\n        // and pass that to the ajax call so it can do its iframe-based submit method.\n        if (this.form.hasUpload()) {\n            formEl = ajaxOptions.form = this.buildForm();\n            ajaxOptions.isUpload = true;\n        } else {\n            ajaxOptions.params = this.getParams();\n        }\n\n        Ext.Ajax.request(ajaxOptions);\n\n        if (formEl) {\n            Ext.removeNode(formEl);\n        }\n    },\n\n    /**\n     * @private\n     * Builds the full set of parameters from the field values plus any additional configured params.\n     */\n    getParams: function() {\n        var nope = false,\n            configParams = this.callParent(),\n            fieldParams = this.form.getValues(nope, nope, this.submitEmptyText !== nope);\n        return Ext.apply({}, fieldParams, configParams);\n    },\n\n    /**\n     * @private\n     * Builds a form element containing fields corresponding to all the parameters to be\n     * submitted (everything returned by {@link #getParams}.\n     *\n     * NOTE: the form element is automatically added to the DOM, so any code that uses\n     * it must remove it from the DOM after finishing with it.\n     *\n     * @return {HTMLElement}\n     */\n    buildForm: function() {\n        var fieldsSpec = [],\n            formSpec,\n            formEl,\n            basicForm = this.form,\n            params = this.getParams(),\n            uploadFields = [],\n            fields = basicForm.getFields().items,\n            f,\n            fLen   = fields.length,\n            field, key, value, v, vLen,\n            u, uLen;\n\n        for (f = 0; f < fLen; f++) {\n            field = fields[f];\n\n            if (field.isFileUpload()) {\n                uploadFields.push(field);\n            }\n        }\n\n        function addField(name, val) {\n            fieldsSpec.push({\n                tag: 'input',\n                type: 'hidden',\n                name: name,\n                value: Ext.String.htmlEncode(val)\n            });\n        }\n\n        for (key in params) {\n            if (params.hasOwnProperty(key)) {\n                value = params[key];\n\n                if (Ext.isArray(value)) {\n                    vLen = value.length;\n                    for (v = 0; v < vLen; v++) {\n                        addField(key, value[v]);\n                    }\n                } else {\n                    addField(key, value);\n                }\n            }\n        }\n\n        formSpec = {\n            tag: 'form',\n            action: this.getUrl(),\n            method: this.getMethod(),\n            target: this.target || '_self',\n            style: 'display:none',\n            cn: fieldsSpec\n        };\n\n        // Set the proper encoding for file uploads\n        if (uploadFields.length) {\n            formSpec.encoding = formSpec.enctype = 'multipart/form-data';\n        }\n\n        // Create the form\n        formEl = Ext.DomHelper.append(Ext.getBody(), formSpec);\n\n        // Special handling for file upload fields: since browser security measures prevent setting\n        // their values programatically, and prevent carrying their selected values over when cloning,\n        // we have to move the actual field instances out of their components and into the form.\n        uLen = uploadFields.length;\n\n        for (u = 0; u < uLen; u++) {\n            field = uploadFields[u];\n            if (field.rendered) { // can only have a selected file value after being rendered\n                formEl.appendChild(field.extractFileInput());\n            }\n        }\n\n        return formEl;\n    },\n\n\n\n    /**\n     * @private\n     */\n    onSuccess: function(response) {\n        var form = this.form,\n            success = true,\n            result = this.processResponse(response);\n        if (result !== true && !result.success) {\n            if (result.errors) {\n                form.markInvalid(result.errors);\n            }\n            this.failureType = Ext.form.action.Action.SERVER_INVALID;\n            success = false;\n        }\n        form.afterAction(this, success);\n    },\n\n    /**\n     * @private\n     */\n    handleResponse: function(response) {\n        var form = this.form,\n            errorReader = form.errorReader,\n            rs, errors, i, len, records;\n        if (errorReader) {\n            rs = errorReader.read(response);\n            records = rs.records;\n            errors = [];\n            if (records) {\n                for(i = 0, len = records.length; i < len; i++) {\n                    errors[i] = records[i].data;\n                }\n            }\n            if (errors.length < 1) {\n                errors = null;\n            }\n            return {\n                success : rs.success,\n                errors : errors\n            };\n        }\n        return Ext.decode(response.responseText);\n    }\n});\n\n/**\n * A subclass of Ext.dd.DragTracker which handles dragging any Component.\n *\n * This is configured with a Component to be made draggable, and a config object for the {@link Ext.dd.DragTracker}\n * class.\n *\n * A {@link #delegate} may be provided which may be either the element to use as the mousedown target or a {@link\n * Ext.DomQuery} selector to activate multiple mousedown targets.\n *\n * When the Component begins to be dragged, its `beginDrag` method will be called if implemented.\n *\n * When the drag ends, its `endDrag` method will be called if implemented.\n */\nExt.define('Ext.util.ComponentDragger', {\n    extend: 'Ext.dd.DragTracker',\n\n    /**\n     * @cfg {Boolean} constrain\n     * Specify as `true` to constrain the Component to within the bounds of the {@link #constrainTo} region.\n     */\n\n    /**\n     * @cfg {String/Ext.Element} delegate\n     * A {@link Ext.DomQuery DomQuery} selector which identifies child elements within the Component's encapsulating\n     * Element which are the drag handles. This limits dragging to only begin when the matching elements are\n     * mousedowned.\n     *\n     * This may also be a specific child element within the Component's encapsulating element to use as the drag handle.\n     */\n\n    /**\n     * @cfg {Boolean} constrainDelegate\n     * Specify as `true` to constrain the drag handles within the {@link #constrainTo} region.\n     */\n\n    autoStart: 500,\n\n    /**\n     * Creates new ComponentDragger.\n     * @param {Object} comp The Component to provide dragging for.\n     * @param {Object} [config] Config object\n     */\n    constructor: function(comp, config) {\n        this.comp = comp;\n        this.initialConstrainTo = config.constrainTo;\n        this.callParent([ config ]);\n    },\n\n    onStart: function(e) {\n        var me = this,\n            comp = me.comp;\n\n        // Cache the start [X, Y] array\n        this.startPosition = comp.el.getXY();\n\n        // If client Component has a ghost method to show a lightweight version of itself\n        // then use that as a drag proxy unless configured to liveDrag.\n        if (comp.ghost && !comp.liveDrag) {\n             me.proxy = comp.ghost();\n             me.dragTarget = me.proxy.header.el;\n        }\n\n        // Set the constrainTo Region before we start dragging.\n        if (me.constrain || me.constrainDelegate) {\n            me.constrainTo = me.calculateConstrainRegion();\n        }\n\n        if (comp.beginDrag) {\n            comp.beginDrag();\n        }\n    },\n\n    calculateConstrainRegion: function() {\n        var me = this,\n            comp = me.comp,\n            c = me.initialConstrainTo,\n            delegateRegion,\n            elRegion,\n            dragEl = me.proxy ? me.proxy.el : comp.el,\n            shadowSize = (!me.constrainDelegate && dragEl.shadow && !dragEl.shadowDisabled) ? dragEl.shadow.getShadowSize() : 0;\n\n        // The configured constrainTo might be a Region or an element\n        if (!(c instanceof Ext.util.Region)) {\n            c =  Ext.fly(c).getViewRegion();\n        }\n\n        // Reduce the constrain region to allow for shadow\n        if (shadowSize) {\n            c.adjust(shadowSize[0], -shadowSize[1], -shadowSize[2], shadowSize[3]);\n        }\n\n        // If they only want to constrain the *delegate* to within the constrain region,\n        // adjust the region to be larger based on the insets of the delegate from the outer\n        // edges of the Component.\n        if (!me.constrainDelegate) {\n            delegateRegion = Ext.fly(me.dragTarget).getRegion();\n            elRegion = dragEl.getRegion();\n\n            c.adjust(\n                delegateRegion.top - elRegion.top,\n                delegateRegion.right - elRegion.right,\n                delegateRegion.bottom - elRegion.bottom,\n                delegateRegion.left - elRegion.left\n            );\n        }\n        return c;\n    },\n\n    // Move either the ghost Component or the target Component to its new position on drag\n    onDrag: function(e) {\n        var me = this,\n            comp = (me.proxy && !me.comp.liveDrag) ? me.proxy : me.comp,\n            offset = me.getOffset(me.constrain || me.constrainDelegate ? 'dragTarget' : null);\n\n        comp.setPagePosition(me.startPosition[0] + offset[0], me.startPosition[1] + offset[1]);\n    },\n\n    onEnd: function(e) {\n        var comp = this.comp;\n        if (this.proxy && !comp.liveDrag) {\n            comp.unghost();\n        }\n        if (comp.endDrag) {\n            comp.endDrag();\n        }\n    }\n});\n\n/**\n * A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and\n * {@link #cfg-draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport, restored to\n * their prior size, and can be {@link #method-minimize}d.\n *\n * Windows can also be linked to a {@link Ext.ZIndexManager} or managed by the {@link Ext.WindowManager} to provide\n * grouping, activation, to front, to back and other application-specific behavior.\n *\n * By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element specify\n * {@link Ext.Component#renderTo renderTo}.\n *\n * **As with all {@link Ext.container.Container Container}s, it is important to consider how you want the Window to size\n * and arrange any child Components. Choose an appropriate {@link #layout} configuration which lays out child Components\n * in the required manner.**\n *\n *     @example\n *     Ext.create('Ext.window.Window', {\n *         title: 'Hello',\n *         height: 200,\n *         width: 400,\n *         layout: 'fit',\n *         items: {  // Let's put an empty grid in just to illustrate fit layout\n *             xtype: 'grid',\n *             border: false,\n *             columns: [{header: 'World'}],                 // One header just for show. There's no data,\n *             store: Ext.create('Ext.data.ArrayStore', {}) // A dummy empty data store\n *         }\n *     }).show();\n */\nExt.define('Ext.window.Window', {\n    extend: 'Ext.panel.Panel',\n\n    alternateClassName: 'Ext.Window',\n\n    requires: ['Ext.util.ComponentDragger', 'Ext.util.Region', 'Ext.EventManager'],\n\n    alias: 'widget.window',\n\n    /**\n     * @cfg {Number} x\n     * The X position of the left edge of the window on initial showing. Defaults to centering the Window within the\n     * width of the Window's container {@link Ext.Element Element} (The Element that the Window is rendered to).\n     */\n\n    /**\n     * @cfg {Number} y\n     * The Y position of the top edge of the window on initial showing. Defaults to centering the Window within the\n     * height of the Window's container {@link Ext.Element Element} (The Element that the Window is rendered to).\n     */\n\n    /**\n     * @cfg {Boolean} [modal=false]\n     * True to make the window modal and mask everything behind it when displayed, false to display it without\n     * restricting access to other UI elements.\n     */\n\n    /**\n     * @cfg {String/Ext.Element} [animateTarget=null]\n     * Id or element from which the window should animate while opening.\n     */\n\n    /**\n     * @cfg {String/Number/Ext.Component} defaultFocus\n     * Specifies a Component to receive focus when this Window is focused.\n     *\n     * This may be one of:\n     *\n     *   - The index of a footer Button.\n     *   - The id or {@link Ext.AbstractComponent#itemId} of a descendant Component.\n     *   - A Component.\n     */\n\n    /**\n     * @cfg {Function} onEsc\n     * Allows override of the built-in processing for the escape key. Default action is to close the Window (performing\n     * whatever action is specified in {@link #closeAction}. To prevent the Window closing when the escape key is\n     * pressed, specify this as {@link Ext#emptyFn Ext.emptyFn}.\n     */\n\n    /**\n     * @cfg {Boolean} [collapsed=false]\n     * True to render the window collapsed, false to render it expanded. Note that if {@link #expandOnShow}\n     * is true (the default) it will override the `collapsed` config and the window will always be\n     * expanded when shown.\n     */\n\n    /**\n     * @cfg {Boolean} [maximized=false]\n     * True to initially display the window in a maximized state.\n     */\n\n    /**\n    * @cfg {String} [baseCls='x-window']\n    * The base CSS class to apply to this panel's element.\n    */\n    baseCls: Ext.baseCSSPrefix + 'window',\n\n    /**\n     * @cfg {Boolean/Object} resizable\n     * Specify as `true` to allow user resizing at each edge and corner of the window, false to disable resizing.\n     *\n     * This may also be specified as a config object to Ext.resizer.Resizer\n     */\n    resizable: true,\n\n    /**\n     * @cfg {Boolean} draggable\n     * True to allow the window to be dragged by the header bar, false to disable dragging. Note that\n     * by default the window will be centered in the viewport, so if dragging is disabled the window may need to be\n     * positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).\n     */\n    draggable: true,\n\n    /**\n     * @cfg {Boolean} constrain\n     * True to constrain the window within its containing element, false to allow it to fall outside of its containing\n     * element. By default the window will be rendered to document.body. To render and constrain the window within\n     * another element specify {@link #renderTo}. Optionally the header only can be constrained\n     * using {@link #constrainHeader}.\n     */\n    constrain: false,\n\n    /**\n     * @cfg {Boolean} constrainHeader\n     * True to constrain the window header within its containing element (allowing the window body to fall outside of\n     * its containing element) or false to allow the header to fall outside its containing element.\n     * Optionally the entire window can be constrained using {@link #constrain}.\n     */\n    constrainHeader: false,\n\n    /**\n     * @cfg {Ext.util.Region/Ext.Element} constrainTo\n     * A {@link Ext.util.Region Region} (or an element from which a Region measurement will be read) which is used\n     * to constrain the window.\n     */\n\n    /**\n     * @cfg {Boolean} plain\n     * True to render the window body with a transparent background so that it will blend into the framing elements,\n     * false to add a lighter background color to visually highlight the body element and separate it more distinctly\n     * from the surrounding frame.\n     */\n    plain: false,\n\n    /**\n     * @cfg {Boolean} minimizable\n     * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button\n     * and disallow minimizing the window. Note that this button provides no implementation -- the\n     * behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a custom\n     * minimize behavior implemented for this option to be useful.\n     */\n    minimizable: false,\n\n    /**\n     * @cfg {Boolean} maximizable\n     * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button\n     * and disallow maximizing the window. Note that when a window is maximized, the tool button\n     * will automatically change to a 'restore' button with the appropriate behavior already built-in that will restore\n     * the window to its previous size.\n     */\n    maximizable: false,\n\n    // inherit docs\n    minHeight: 50,\n\n    // inherit docs\n    minWidth: 50,\n\n    /**\n     * @cfg {Boolean} expandOnShow\n     * True to always expand the window when it is displayed, false to keep it in its current state (which may be\n     * {@link #collapsed}) when displayed.\n     */\n    expandOnShow: true,\n\n    // inherited docs, same default\n    collapsible: false,\n\n    /**\n     * @cfg {Boolean} closable\n     * True to display the 'close' tool button and allow the user to close the window, false to hide the button and\n     * disallow closing the window.\n     *\n     * By default, when close is requested by either clicking the close button in the header or pressing ESC when the\n     * Window has focus, the {@link #method-close} method will be called. This will _{@link Ext.Component#method-destroy destroy}_ the\n     * Window and its content meaning that it may not be reused.\n     *\n     * To make closing a Window _hide_ the Window so that it may be reused, set {@link #closeAction} to 'hide'.\n     */\n    closable: true,\n\n    /**\n     * @cfg {Boolean} hidden\n     * Render this Window hidden. If `true`, the {@link #method-hide} method will be called internally.\n     */\n    hidden: true,\n\n    /**\n     * @cfg\n     * @inheritdoc\n     * Windows render to the body on first show.\n     */\n    autoRender: true,\n\n    /**\n     * @cfg\n     * @inheritdoc\n     * Windows hide using offsets in order to preserve the scroll positions of their descendants.\n     */\n    hideMode: 'offsets',\n\n    /**\n     * @cfg\n     * @private\n     */\n    floating: true,\n\n    ariaRole: 'alertdialog',\n\n    itemCls: Ext.baseCSSPrefix + 'window-item',\n    \n    initialAlphaNum: /^[a-z0-9]/,\n\n    overlapHeader: true,\n\n    ignoreHeaderBorderManagement: true,\n\n    // Flag to Renderable to always look up the framing styles for this Component\n    alwaysFramed: true,\n\n    /**\n     * @property {Boolean} isWindow\n     * `true` in this class to identify an object as an instantiated Window, or subclass thereof.\n     */\n    isWindow: true,\n\n    // private\n    initComponent: function() {\n        var me = this;\n        // Explicitly set frame to false, since alwaysFramed is\n        // true, we only want to lookup framing in a specific instance\n        me.frame = false;\n        me.callParent();\n        me.addEvents(\n            /**\n             * @event activate\n             * Fires after the window has been visually activated via {@link #setActive}.\n             * @param {Ext.window.Window} this\n             */\n\n            /**\n             * @event deactivate\n             * Fires after the window has been visually deactivated via {@link #setActive}.\n             * @param {Ext.window.Window} this\n             */\n\n            /**\n             * @event resize\n             * Fires after the window has been resized.\n             * @param {Ext.window.Window} this\n             * @param {Number} width The window's new width\n             * @param {Number} height The window's new height\n             */\n            'resize',\n\n            /**\n             * @event maximize\n             * Fires after the window has been maximized.\n             * @param {Ext.window.Window} this\n             */\n            'maximize',\n\n            /**\n             * @event minimize\n             * Fires after the window has been minimized.\n             * @param {Ext.window.Window} this\n             */\n            'minimize',\n\n            /**\n             * @event restore\n             * Fires after the window has been restored to its original size after being maximized.\n             * @param {Ext.window.Window} this\n             */\n            'restore'\n        );\n\n        if (me.plain) {\n            me.addClsWithUI('plain');\n        }\n\n        if (me.modal) {\n            me.ariaRole = 'dialog';\n        }\n\n        // clickToRaise\n        if (me.floating) {\n            me.on({\n                element: 'el',\n                mousedown: me.onMouseDown,\n                scope: me\n            });\n        }\n\n        me.addStateEvents(['maximize', 'restore', 'resize', 'dragend']);\n    },\n\n    getElConfig: function () {\n        var me = this,\n            elConfig;\n\n        elConfig = me.callParent();\n        elConfig.tabIndex = -1;\n        return elConfig;\n    },\n\n    // State Management\n    // private\n\n    getState: function() {\n        var me = this,\n            state = me.callParent() || {},\n            maximized = !!me.maximized;\n\n        state.maximized = maximized;\n        Ext.apply(state, {\n            size: maximized ? me.restoreSize : me.getSize(),\n            pos: maximized ? me.restorePos : me.getPosition()\n        });\n        return state;\n    },\n\n    applyState: function(state){\n        var me = this;\n\n        if (state) {\n            me.maximized = state.maximized;\n            if (me.maximized) {\n                me.hasSavedRestore = true;\n                me.restoreSize = state.size;\n                me.restorePos = state.pos;\n            } else {\n                Ext.apply(me, {\n                    width: state.size.width,\n                    height: state.size.height,\n                    x: state.pos[0],\n                    y: state.pos[1]\n                });\n            }\n        }\n    },\n\n    // private\n    onMouseDown: function (e) {\n        var preventFocus;\n            \n        if (this.floating) {\n            if (Ext.fly(e.getTarget()).focusable()) {\n                preventFocus = true;\n            }\n            this.toFront(preventFocus);\n        }\n    },\n\n    // private\n    onRender: function(ct, position) {\n        var me = this;\n        me.callParent(arguments);\n        me.focusEl = me.el;\n\n        // Double clicking a header will toggleMaximize\n        if (me.maximizable) {\n            me.header.on({\n                scope: me,\n                dblclick: me.toggleMaximize\n            });\n        }\n    },\n\n    // private\n    afterRender: function() {\n        var me = this,\n            keyMap;\n\n        me.callParent();\n\n        // Initialize\n        if (me.maximized) {\n            me.maximized = false;\n            me.maximize();\n        }\n\n        if (me.closable) {\n            keyMap = me.getKeyMap();\n            keyMap.on(27, me.onEsc, me);\n        } else {\n            keyMap = me.keyMap;\n        }\n        if (keyMap && me.hidden) {\n            keyMap.disable();\n        }\n    },\n\n    /**\n     * @private\n     * Override Component.initDraggable.\n     * Window uses the header element as the delegate.\n     */\n    initDraggable: function() {\n        var me = this,\n            ddConfig;\n\n        if (!me.header) {\n            me.updateHeader(true);\n        }\n\n        /*\n         * Check the header here again. If for whatever reason it wasn't created in\n         * updateHeader (we were configured with header: false) then we'll just ignore the rest since the\n         * header acts as the drag handle.\n         */\n        if (me.header) {\n            ddConfig = Ext.applyIf({\n                el: me.el,\n                delegate: '#' + Ext.escapeId(me.header.id)\n            }, me.draggable);\n\n            // Add extra configs if Window is specified to be constrained\n            if (me.constrain || me.constrainHeader) {\n                ddConfig.constrain = me.constrain;\n                ddConfig.constrainDelegate = me.constrainHeader;\n                ddConfig.constrainTo = me.constrainTo || me.container;\n            }\n\n            /**\n             * @property {Ext.util.ComponentDragger} dd\n             * If this Window is configured {@link #cfg-draggable}, this property will contain an instance of\n             * {@link Ext.util.ComponentDragger} (A subclass of {@link Ext.dd.DragTracker DragTracker}) which handles dragging\n             * the Window's DOM Element, and constraining according to the {@link #constrain} and {@link #constrainHeader} .\n             *\n             * This has implementations of `onBeforeStart`, `onDrag` and `onEnd` which perform the dragging action. If\n             * extra logic is needed at these points, use {@link Ext.Function#createInterceptor createInterceptor} or\n             * {@link Ext.Function#createSequence createSequence} to augment the existing implementations.\n             */\n            me.dd = new Ext.util.ComponentDragger(this, ddConfig);\n            me.relayEvents(me.dd, ['dragstart', 'drag', 'dragend']);\n        }\n    },\n\n    // private\n    onEsc: function(k, e) {\n        // Only process ESC if the FocusManager is not doing it\n        if (!Ext.FocusManager || !Ext.FocusManager.enabled || Ext.FocusManager.focusedCmp === this) {\n            e.stopEvent();\n            this.close();\n        }\n    },\n\n    // private\n    beforeDestroy: function() {\n        var me = this;\n        if (me.rendered) {\n            delete this.animateTarget;\n            me.hide();\n            Ext.destroy(\n                me.keyMap\n            );\n        }\n        me.callParent();\n    },\n\n    /**\n     * @private\n     * Contribute class-specific tools to the header.\n     * Called by Panel's initTools.\n     */\n    addTools: function() {\n        var me = this;\n\n        // Call Panel's initTools\n        me.callParent();\n\n        if (me.minimizable) {\n            me.addTool({\n                type: 'minimize',\n                handler: Ext.Function.bind(me.minimize, me, [])\n            });\n        }\n        if (me.maximizable) {\n            me.addTool({\n                type: 'maximize',\n                handler: Ext.Function.bind(me.maximize, me, [])\n            });\n            me.addTool({\n                type: 'restore',\n                handler: Ext.Function.bind(me.restore, me, []),\n                hidden: true\n            });\n        }\n    },\n\n    /**\n     * @private\n     * Returns the focus holder element associated with this Window. By default, this is the Window's element.\n     * @returns {Ext.Element/Ext.Component} the focus holding element or Component.\n     */\n    getFocusEl: function() {\n        return this.getDefaultFocus();\n    },\n\n    /**\n     * Gets the configured default focus item.  If a {@link #defaultFocus} is set, it will\n     * receive focus when the Window's <code>focus</code> method is called, otherwise the\n     * Window itself will receive focus.\n     */\n    getDefaultFocus: function() {\n        var me = this,\n            result,\n            defaultComp = me.defaultButton || me.defaultFocus,\n            selector;\n\n        if (defaultComp !== undefined) {\n            // Number is index of Button\n            if (Ext.isNumber(defaultComp)) {\n                result = me.query('button')[defaultComp];\n            }\n            // String is ID or CQ selector\n            else if (Ext.isString(defaultComp)) {\n                selector = defaultComp;\n                \n                // Try id/itemId match if selector begins with alphanumeric\n                if (selector.match(me.initialAlphaNum)) {\n                    result = me.down('#' + selector);\n                }\n                // If not found, use as selector\n                if (!result) {\n                    result = me.down(selector);\n                }\n            }\n            // Otherwise, if it's got a focus method, use it\n            else if (defaultComp.focus) {\n                result = defaultComp;\n            }\n        }\n        return result || me.el;\n    },\n\n    /**\n     * @private\n     * Called when a Component's focusEl receives focus.\n     * If there is a valid default focus Component to jump to, focus that,\n     * otherwise continue as usual, focus this Component.\n     */\n    onFocus: function() {\n        var me = this,\n            focusDescendant;\n\n        // If the FocusManager is enabled, then we must noy jumpt to focus the default focus. We must focus the Window\n        if ((Ext.FocusManager && Ext.FocusManager.enabled) || ((focusDescendant = me.getDefaultFocus()) === me)) {\n            me.callParent(arguments);\n        } else {\n            focusDescendant.focus();\n        }\n    },\n\n    beforeLayout: function () {\n        var shadow = this.el.shadow;\n\n        this.callParent();\n        if (shadow) {\n            shadow.hide();\n        }\n    },\n\n    onShow: function() {\n        var me = this;\n\n        me.callParent(arguments);\n        if (me.expandOnShow) {\n            me.expand(false);\n        }\n        me.syncMonitorWindowResize();\n\n        if (me.keyMap) {\n            me.keyMap.enable();\n        }\n   },\n\n    // private\n    doClose: function() {\n        var me = this;\n\n        // Being called as callback after going through the hide call below\n        if (me.hidden) {\n            me.fireEvent('close', me);\n            if (me.closeAction == 'destroy') {\n                this.destroy();\n            }\n        } else {\n            // close after hiding\n            me.hide(me.animateTarget, me.doClose, me);\n        }\n    },\n\n    // private\n    afterHide: function() {\n        var me = this;\n\n        // No longer subscribe to resizing now that we're hidden\n        me.syncMonitorWindowResize();\n\n        // Turn off keyboard handling once window is hidden\n        if (me.keyMap) {\n            me.keyMap.disable();\n        }\n\n        // Perform superclass's afterHide tasks.\n        me.callParent(arguments);\n    },\n\n    // private\n    onWindowResize: function() {\n        var me = this,\n            sizeModel;\n\n        if (me.maximized) {\n            me.fitContainer();\n        } else {\n            sizeModel = me.getSizeModel();\n            if (sizeModel.width.natural || sizeModel.height.natural) {\n                me.updateLayout();\n            }\n        }\n\n        me.doConstrain();\n    },\n\n    /**\n     * Placeholder method for minimizing the window. By default, this method simply fires the {@link #event-minimize} event\n     * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior, either\n     * the minimize event can be handled or this method can be overridden.\n     * @return {Ext.window.Window} this\n     */\n    minimize: function() {\n        this.fireEvent('minimize', this);\n        return this;\n    },\n\n    afterCollapse: function() {\n        var me = this;\n\n        if (me.maximizable) {\n            me.tools.maximize.hide();\n            me.tools.restore.hide();\n        }\n        if (me.resizer) {\n            me.resizer.disable();\n        }\n        me.callParent(arguments);\n    },\n\n    afterExpand: function() {\n        var me = this;\n\n        if (me.maximized) {\n            me.tools.restore.show();\n        } else if (me.maximizable) {\n            me.tools.maximize.show();\n        }\n        if (me.resizer) {\n            me.resizer.enable();\n        }\n        me.callParent(arguments);\n    },\n\n    /**\n     * Fits the window within its current container and automatically replaces the {@link #maximizable 'maximize' tool\n     * button} with the 'restore' tool button. Also see {@link #toggleMaximize}.\n     * @return {Ext.window.Window} this\n     */\n    maximize: function() {\n        var me = this;\n\n        if (!me.maximized) {\n            me.expand(false);\n            if (!me.hasSavedRestore) {\n                me.restoreSize = me.getSize();\n                me.restorePos = me.getPosition(true);\n            }\n            if (me.maximizable) {\n                me.tools.maximize.hide();\n                me.tools.restore.show();\n            }\n            me.maximized = true;\n            me.el.disableShadow();\n\n            if (me.dd) {\n                me.dd.disable();\n            }\n            if (me.resizer) {\n                me.resizer.disable();\n            }\n            if (me.collapseTool) {\n                me.collapseTool.hide();\n            }\n            me.el.addCls(Ext.baseCSSPrefix + 'window-maximized');\n            me.container.addCls(Ext.baseCSSPrefix + 'window-maximized-ct');\n\n            me.syncMonitorWindowResize();\n            me.fitContainer();\n            me.fireEvent('maximize', me);\n        }\n        return me;\n    },\n\n    /**\n     * Restores a {@link #maximizable maximized} window back to its original size and position prior to being maximized\n     * and also replaces the 'restore' tool button with the 'maximize' tool button. Also see {@link #toggleMaximize}.\n     * @return {Ext.window.Window} this\n     */\n    restore: function() {\n        var me = this,\n            tools = me.tools;\n\n        if (me.maximized) {\n            delete me.hasSavedRestore;\n            me.removeCls(Ext.baseCSSPrefix + 'window-maximized');\n\n            // Toggle tool visibility\n            if (tools.restore) {\n                tools.restore.hide();\n            }\n            if (tools.maximize) {\n                tools.maximize.show();\n            }\n            if (me.collapseTool) {\n                me.collapseTool.show();\n            }\n\n            me.maximized = false;\n\n            // Restore the position/sizing\n            me.setPosition(me.restorePos);\n            me.setSize(me.restoreSize);\n\n            // Unset old position/sizing\n            delete me.restorePos;\n            delete me.restoreSize;\n\n            me.el.enableShadow(true);\n\n            // Allow users to drag and drop again\n            if (me.dd) {\n                me.dd.enable();\n            }\n            \n            if (me.resizer) {\n                me.resizer.enable();\n            }\n\n            me.container.removeCls(Ext.baseCSSPrefix + 'window-maximized-ct');\n\n            me.syncMonitorWindowResize();\n            me.doConstrain();\n            me.fireEvent('restore', me);\n        }\n        return me;\n    },\n\n    /**\n     * Synchronizes the presence of our listener for window resize events. This method\n     * should be called whenever this status might change.\n     * @private\n     */\n    syncMonitorWindowResize: function () {\n        var me = this,\n            currentlyMonitoring = me._monitoringResize,\n            // all the states where we should be listening to window resize:\n            yes = me.monitorResize || me.constrain || me.constrainHeader || me.maximized,\n            // all the states where we veto this:\n            veto = me.hidden || me.destroying || me.isDestroyed;\n\n        if (yes && !veto) {\n            // we should be listening...\n            if (!currentlyMonitoring) {\n                // but we aren't, so set it up\n                Ext.EventManager.onWindowResize(me.onWindowResize, me);\n                me._monitoringResize = true;\n            }\n        } else if (currentlyMonitoring) {\n            // we should not be listening, but we are, so tear it down\n            Ext.EventManager.removeResizeListener(me.onWindowResize, me);\n            me._monitoringResize = false;\n        }\n    },\n\n    /**\n     * A shortcut method for toggling between {@link #method-maximize} and {@link #method-restore} based on the current maximized\n     * state of the window.\n     * @return {Ext.window.Window} this\n     */\n    toggleMaximize: function() {\n        return this[this.maximized ? 'restore': 'maximize']();\n    }\n\n});\n\n/**\n * Layout class for components with {@link Ext.form.Labelable field labeling}, handling the sizing and alignment of\n * the form control, label, and error message treatment.\n * @private\n */\nExt.define('Ext.layout.component.field.Field', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.layout.component.Auto',\n\n    alias: 'layout.field',\n\n    uses: ['Ext.tip.QuickTip', 'Ext.util.TextMetrics', 'Ext.util.CSS'],\n\n    /* End Definitions */\n\n    type: 'field',\n    \n    naturalSizingProp: 'size',\n\n    beginLayout: function(ownerContext) {\n        var me = this,\n            owner = me.owner,\n            widthModel = ownerContext.widthModel,\n            ownerNaturalSize = owner[me.naturalSizingProp],\n            width;\n\n        me.callParent(arguments);\n\n        ownerContext.labelStrategy = me.getLabelStrategy();\n        ownerContext.errorStrategy = me.getErrorStrategy();\n\n        ownerContext.labelContext = ownerContext.getEl('labelEl');\n        ownerContext.bodyCellContext = ownerContext.getEl('bodyEl');\n        ownerContext.inputContext = ownerContext.getEl('inputEl');\n        ownerContext.errorContext = ownerContext.getEl('errorEl');\n\n        // width:100% on an element inside a table in IE6/7 \"strict\" sizes the content box.\n        // store the input element's border and padding info so that subclasses can take it into consideration if needed\n        if ((Ext.isIE6 || Ext.isIE7) && Ext.isStrict && ownerContext.inputContext) {\n            me.ieInputWidthAdjustment = ownerContext.inputContext.getPaddingInfo().width + ownerContext.inputContext.getBorderInfo().width;\n        }\n\n        // perform preparation on the label and error (setting css classes, qtips, etc.)\n        ownerContext.labelStrategy.prepare(ownerContext, owner);\n        ownerContext.errorStrategy.prepare(ownerContext, owner);\n\n        // Body cell must stretch to use up available width unless the field is auto width\n        if (widthModel.shrinkWrap) {\n            // When the width needs to be auto, table-layout cannot be fixed\n            me.beginLayoutShrinkWrap(ownerContext);\n        } else if (widthModel.natural) {\n\n            // When a size specified, natural becomes fixed width unless the inpiutWidth is specified - we shrinkwrap that\n            if (typeof ownerNaturalSize == 'number' && !owner.inputWidth) {\n                me.beginLayoutFixed(ownerContext, (width = ownerNaturalSize * 6.5 + 20), 'px');\n            }\n\n            // Otherwise it is the same as shrinkWrap\n            else {\n                me.beginLayoutShrinkWrap(ownerContext);\n            }\n            ownerContext.setWidth(width, false);\n        } else {\n            me.beginLayoutFixed(ownerContext, '100', '%');\n        }\n    },\n\n    beginLayoutFixed: function (ownerContext, width, suffix) {\n        var owner = ownerContext.target,\n            inputEl = owner.inputEl,\n            inputWidth = owner.inputWidth;\n\n        owner.el.setStyle('table-layout', 'fixed');\n        owner.bodyEl.setStyle('width', width + suffix);\n        if (inputEl && inputWidth) {\n            inputEl.setStyle('width', inputWidth + 'px');\n        }\n        ownerContext.isFixed = true;\n    },\n\n    beginLayoutShrinkWrap: function (ownerContext) {\n        var owner = ownerContext.target,\n            inputEl = owner.inputEl,\n            inputWidth = owner.inputWidth;\n\n        if (inputEl && inputEl.dom) {\n            inputEl.dom.removeAttribute('size');\n            if (inputWidth) {\n                inputEl.setStyle('width', inputWidth + 'px');\n            }\n        }\n        owner.el.setStyle('table-layout', 'auto');\n        owner.bodyEl.setStyle('width', '');\n    },\n\n    finishedLayout: function(ownerContext){\n        var owner = this.owner;\n\n        this.callParent(arguments);        \n        ownerContext.labelStrategy.finishedLayout(ownerContext, owner);\n        ownerContext.errorStrategy.finishedLayout(ownerContext, owner);\n    },\n\n    calculateOwnerHeightFromContentHeight: function(ownerContext, contentHeight) {\n        return contentHeight;\n    },\n\n    measureContentHeight: function (ownerContext) {\n        return ownerContext.el.getHeight();\n    },\n    \n    measureContentWidth: function (ownerContext) {\n        return ownerContext.el.getWidth();\n    },\n\n    measureLabelErrorHeight: function (ownerContext) {\n        return ownerContext.labelStrategy.getHeight(ownerContext) +\n               ownerContext.errorStrategy.getHeight(ownerContext);\n    },\n\n    onFocus: function() {\n        this.getErrorStrategy().onFocus(this.owner);    \n    },\n\n    /**\n     * Return the set of strategy functions from the {@link #labelStrategies labelStrategies collection}\n     * that is appropriate for the field's {@link Ext.form.Labelable#labelAlign labelAlign} config.\n     */\n    getLabelStrategy: function() {\n        var me = this,\n            strategies = me.labelStrategies,\n            labelAlign = me.owner.labelAlign;\n        return strategies[labelAlign] || strategies.base;\n    },\n\n    /**\n     * Return the set of strategy functions from the {@link #errorStrategies errorStrategies collection}\n     * that is appropriate for the field's {@link Ext.form.Labelable#msgTarget msgTarget} config.\n     */\n    getErrorStrategy: function() {\n        var me = this,\n            owner = me.owner,\n            strategies = me.errorStrategies,\n            msgTarget = owner.msgTarget;\n        return !owner.preventMark && Ext.isString(msgTarget) ?\n                (strategies[msgTarget] || strategies.elementId) :\n                strategies.none;\n    },\n\n    /**\n     * Collection of named strategies for laying out and adjusting labels to accommodate error messages.\n     * An appropriate one will be chosen based on the owner field's {@link Ext.form.Labelable#labelAlign} config.\n     */\n    labelStrategies: (function() {\n        var base = {\n                prepare: function(ownerContext, owner) {\n                    var cls = owner.labelCls + '-' + owner.labelAlign,\n                        labelEl = owner.labelEl;\n\n                    if (labelEl) {\n                        labelEl.addCls(cls);\n                    }\n                },\n\n                getHeight: function () {\n                    return 0;\n                },\n                \n                finishedLayout: Ext.emptyFn\n            };\n\n        return {\n            base: base,\n\n            /**\n             * Label displayed above the bodyEl\n             */\n            top: Ext.applyIf({        \n                        \n                getHeight: function (ownerContext) {\n                    var labelContext = ownerContext.labelContext,\n                        props = labelContext.props,\n                        height = props.height;\n                        \n                    if (height === undefined) {\n                        props.height = height = labelContext.el.getHeight();\n                    }\n\n                    return height;\n                }\n            }, base),\n\n            /**\n             * Label displayed to the left of the bodyEl\n             */\n            left: base,\n\n            /**\n             * Same as left, only difference is text-align in CSS\n             */\n            right: base\n        };\n    }()),\n\n    /**\n     * Collection of named strategies for laying out and adjusting insets to accommodate error messages.\n     * An appropriate one will be chosen based on the owner field's {@link Ext.form.Labelable#msgTarget} config.\n     */\n    errorStrategies: (function() {\n        function showTip(owner) {\n            var tip = Ext.layout.component.field.Field.tip,\n                target;\n                \n            if (tip && tip.isVisible()) {\n                target = tip.activeTarget;\n                if (target && target.el === owner.getActionEl().dom) {\n                    tip.toFront(true);\n                }\n            }\n        }\n\n        var applyIf = Ext.applyIf,\n            emptyFn = Ext.emptyFn,\n            iconCls = Ext.baseCSSPrefix + 'form-invalid-icon',\n            iconWidth,\n            base = {\n                prepare: function(ownerContext, owner) {\n                    var el = owner.errorEl;\n                    if (el) {\n                        el.setDisplayed(false);\n                    }\n                },\n                getHeight: function () {\n                    return 0;\n                },\n                onFocus: emptyFn,\n                finishedLayout: emptyFn\n            };\n\n        return {\n            none: base,\n\n            /**\n             * Error displayed as icon (with QuickTip on hover) to right of the bodyEl\n             */\n            side: applyIf({\n                prepare: function(ownerContext, owner) {\n                    var errorEl = owner.errorEl,\n                        sideErrorCell = owner.sideErrorCell,\n                        displayError = owner.hasActiveError(),\n                        tempEl;\n\n                    // Capture error icon width once\n                    if (!iconWidth) {\n                        iconWidth = (tempEl = Ext.getBody().createChild({style: 'position:absolute', cls: iconCls})).getWidth();\n                        tempEl.remove();\n                    }\n\n                    errorEl.addCls(iconCls);\n                    errorEl.set({'data-errorqtip': owner.getActiveError() || ''});\n                    if (owner.autoFitErrors) {\n                        errorEl.setDisplayed(displayError);\n                    }\n                    // Not autofitting, the space must still be allocated.\n                    else {\n                        errorEl.setVisible(displayError);\n                    }\n\n                    // If we are auto fitting, then hide and show the entire cell\n                    if (sideErrorCell && owner.autoFitErrors) {\n                        sideErrorCell.setDisplayed(displayError);\n                    }\n                    owner.bodyEl.dom.colSpan = owner.getBodyColspan();\n\n                    // TODO: defer the tip call until after the layout to avoid immediate DOM reads now\n                    Ext.layout.component.field.Field.initTip();\n                },\n                onFocus: showTip\n            }, base),\n\n            /**\n             * Error message displayed underneath the bodyEl\n             */\n            under: applyIf({\n                prepare: function(ownerContext, owner) {\n                    var errorEl = owner.errorEl,\n                        cls = Ext.baseCSSPrefix + 'form-invalid-under';\n\n                    errorEl.addCls(cls);\n                    errorEl.setDisplayed(owner.hasActiveError());\n                },\n                getHeight: function (ownerContext) {\n                    var height = 0,\n                        errorContext, props;\n\n                    if (ownerContext.target.hasActiveError()) {\n                        errorContext = ownerContext.errorContext;\n                        props = errorContext.props;\n                        height = props.height;\n\n                        if (height === undefined) {\n                            props.height = height = errorContext.el.getHeight();\n                        }\n                    }\n\n                    return height;\n                }\n            }, base),\n\n            /**\n             * Error displayed as QuickTip on hover of the field container\n             */\n            qtip: applyIf({\n                prepare: function(ownerContext, owner) {\n                    Ext.layout.component.field.Field.initTip();\n                    owner.getActionEl().set({'data-errorqtip': owner.getActiveError() || ''});\n                },\n                onFocus: showTip\n            }, base),\n\n            /**\n             * Error displayed as title tip on hover of the field container\n             */\n            title: applyIf({\n                prepare: function(ownerContext, owner) {\n                    owner.el.set({'title': owner.getActiveError() || ''});\n                }\n            }, base),\n\n            /**\n             * Error message displayed as content of an element with a given id elsewhere in the app\n             */\n            elementId: applyIf({\n                prepare: function(ownerContext, owner) {\n                    var targetEl = Ext.fly(owner.msgTarget);\n                    if (targetEl) {\n                        targetEl.dom.innerHTML = owner.getActiveError() || '';\n                        targetEl.setDisplayed(owner.hasActiveError());\n                    }\n                }\n            }, base)\n        };\n    }()),\n\n    statics: {\n        /**\n         * Use a custom QuickTip instance separate from the main QuickTips singleton, so that we\n         * can give it a custom frame style. Responds to errorqtip rather than the qtip property.\n         * @static\n         */\n        initTip: function() {\n            var tip = this.tip;\n            if (!tip) {\n                tip = this.tip = Ext.create('Ext.tip.QuickTip', {\n                    baseCls: Ext.baseCSSPrefix + 'form-invalid-tip'\n                });\n                tip.tagConfig = Ext.apply({}, {attribute: 'errorqtip'}, tip.tagConfig);\n            }\n        },\n\n        /**\n         * Destroy the error tip instance.\n         * @static\n         */\n        destroyTip: function() {\n            var tip = this.tip;\n            if (tip) {\n                tip.destroy();\n                delete this.tip;\n            }\n        }\n    }\n});\n\n/**\n * Layout class for {@link Ext.form.field.Text} fields. Handles sizing the input field.\n * @private\n */\nExt.define('Ext.layout.component.field.Text', {\n    extend: 'Ext.layout.component.field.Field',\n    alias: 'layout.textfield',\n    requires: ['Ext.util.TextMetrics'],\n\n    type: 'textfield',\n    \n    canGrowWidth: true,\n\n    beginLayoutCycle: function(ownerContext) {\n        var me = this;\n        \n        me.callParent(arguments);\n        \n        // Clear height, in case a previous layout cycle stretched it.\n        if (ownerContext.shrinkWrap) {\n            ownerContext.inputContext.el.setStyle('height', '');\n        }\n    },\n\n    measureContentWidth: function (ownerContext) {\n        var me = this,\n            owner = me.owner,\n            width = me.callParent(arguments),\n            inputContext = ownerContext.inputContext,\n            inputEl, value, calcWidth, max, min;\n\n        if (owner.grow && me.canGrowWidth && !ownerContext.state.growHandled) {\n            inputEl = owner.inputEl;\n\n            // Find the width that contains the whole text value\n            value = Ext.util.Format.htmlEncode(inputEl.dom.value || (owner.hasFocus ? '' : owner.emptyText) || '');\n            value += owner.growAppend;\n            calcWidth = inputEl.getTextWidth(value) + inputContext.getFrameInfo().width;\n\n            max = owner.growMax;\n            min = Math.min(max, width);\n            max = Math.max(owner.growMin, max, min);\n\n            // Constrain\n            calcWidth = Ext.Number.constrain(calcWidth, owner.growMin, max);\n            inputContext.setWidth(calcWidth);\n            ownerContext.state.growHandled = true;\n            \n            // Now that we've set the inputContext, we need to recalculate the width\n            inputContext.domBlock(me, 'width');\n            width = NaN;\n        }\n        return width;\n    },\n    \n    publishInnerHeight: function(ownerContext, height) {\n        ownerContext.inputContext.setHeight(height - this.measureLabelErrorHeight(ownerContext));\n    },\n\n    beginLayoutFixed: function(ownerContext, width, suffix) {\n        var me = this,\n            ieInputWidthAdjustment = me.ieInputWidthAdjustment;\n\n        if (ieInputWidthAdjustment) {\n            // adjust for IE 6/7 strict content-box model\n            // RTL: This might have to be padding-left unless the senses of the padding styles switch when in RTL mode.\n            me.owner.bodyEl.setStyle('padding-right', ieInputWidthAdjustment + 'px');\n            if(suffix === 'px') {\n                width -= ieInputWidthAdjustment;\n            }\n        }\n\n        me.callParent(arguments);\n    }\n});\n\n/**\n * A mixin which allows a component to be configured and decorated with a label and/or error message as is\n * common for form fields. This is used by e.g. Ext.form.field.Base and Ext.form.FieldContainer\n * to let them be managed by the Field layout.\n *\n * NOTE: This mixin is mainly for internal library use and most users should not need to use it directly. It\n * is more likely you will want to use one of the component classes that import this mixin, such as\n * Ext.form.field.Base or Ext.form.FieldContainer.\n *\n * Use of this mixin does not make a component a field in the logical sense, meaning it does not provide any\n * logic or state related to values or validation; that is handled by the related Ext.form.field.Field\n * mixin. These two mixins may be used separately (for example Ext.form.FieldContainer is Labelable but not a\n * Field), or in combination (for example Ext.form.field.Base implements both and has logic for connecting the\n * two.)\n *\n * Component classes which use this mixin should use the Field layout\n * or a derivation thereof to properly size and position the label and message according to the component config.\n * They must also call the {@link #initLabelable} method during component initialization to ensure the mixin gets\n * set up correctly.\n *\n * @docauthor Jason Johnston <jason@sencha.com>\n */\nExt.define(\"Ext.form.Labelable\", {\n    requires: ['Ext.XTemplate'],\n\n    autoEl: {\n        tag: 'table',\n        cellpadding: 0\n    },\n\n    childEls: [\n        /**\n         * @property {Ext.Element} labelCell\n         * The `<TD>` Element which contains the label Element for this component. Only available after the component has been rendered.\n         */\n        'labelCell',\n\n        /**\n         * @property {Ext.Element} labelEl\n         * The label Element for this component. Only available after the component has been rendered.\n         */\n        'labelEl',\n\n        /**\n         * @property {Ext.Element} bodyEl\n         * The div Element wrapping the component's contents. Only available after the component has been rendered.\n         */\n        'bodyEl',\n\n        // private - the TD which contains the msgTarget: 'side' error icon\n        'sideErrorCell',\n\n        /**\n         * @property {Ext.Element} errorEl\n         * The div Element that will contain the component's error message(s). Note that depending on the configured\n         * {@link #msgTarget}, this element may be hidden in favor of some other form of presentation, but will always\n         * be present in the DOM for use by assistive technologies.\n         */\n        'errorEl',\n\n        'inputRow',\n\n        'bottomPlaceHolder'\n    ],\n\n    /**\n     * @cfg {String/String[]/Ext.XTemplate} labelableRenderTpl\n     * The rendering template for the field decorations. Component classes using this mixin\n     * should include logic to use this as their {@link Ext.AbstractComponent#renderTpl renderTpl},\n     * and implement the {@link #getSubTplMarkup} method to generate the field body content.\n     *\n     * The structure of a field is a table as follows:\n     * \n     * If `labelAlign: 'left', `msgTarget: 'side'`\n     * \n     *      +----------------------+----------------------+-------------+\n     *      | Label:               | InputField           | sideErrorEl |\n     *      +----------------------+----------------------+-------------+\n     *\n     * If `labelAlign: 'left', `msgTarget: 'under'`\n     * \n     *      +----------------------+------------------------------------+\n     *      | Label:               | InputField      (colspan=2)        |\n     *      |                      | underErrorEl                       |\n     *      +----------------------+------------------------------------+\n     *\n     * If `labelAlign: 'top', `msgTarget: 'side'`\n     *\n     *      +---------------------------------------------+-------------+\n     *      | label                                       |             |\n     *      | InputField                                  | sideErrorEl |\n     *      +---------------------------------------------+-------------+\n     *\n     * If `labelAlign: 'top', `msgTarget: 'under'`\n     * \n     *      +-----------------------------------------------------------+\n     *      | label                                                     |\n     *      | InputField                      (colspan=2)               |\n     *      | underErrorEl                                              |\n     *      +-----------------------------------------------------------+\n     *\n     * The total columns always the same for fields with each setting of {@link #labelAlign} because when\n     * rendered into a {@link Ext.layout.container.Form} layout, just the `TR` of the table\n     * will be placed into the form's main `TABLE`, and the columns of all the siblings\n     * must match so that they all line up. In a {@link Ext.layout.container.Form} layout, different\n     * settings of {@link #labelAlign} are not supported because of the incompatible column structure.\n     *\n     * When the triggerCell or side error cell are hidden or shown, the input cell's colspan\n     * is recalculated to maintain the correct 3 visible column count.\n     * @private\n     */\n    labelableRenderTpl: [\n\n        // body row. If a heighted Field (eg TextArea, HtmlEditor, this must greedily consume height.\n        '<tr id=\"{id}-inputRow\" <tpl if=\"inFormLayout\">id=\"{id}\"</tpl>>',\n\n            // Label cell\n            '<tpl if=\"labelOnLeft\">',\n                '<td id=\"{id}-labelCell\" style=\"{labelCellStyle}\" {labelCellAttrs}>',\n                    '{beforeLabelTpl}',\n                    '<label id=\"{id}-labelEl\" {labelAttrTpl}<tpl if=\"inputId\"> for=\"{inputId}\"</tpl> class=\"{labelCls}\"',\n                        '<tpl if=\"labelStyle\"> style=\"{labelStyle}\"</tpl>>',\n                        '{beforeLabelTextTpl}',\n                        '<tpl if=\"fieldLabel\">{fieldLabel}{labelSeparator}</tpl>',\n                        '{afterLabelTextTpl}',\n                    '</label>',\n                    '{afterLabelTpl}',\n                '</td>',\n            '</tpl>',\n\n            // Body of the input. That will be an input element, or, from a TriggerField, a table containing an input cell and trigger cell(s)\n            '<td class=\"{baseBodyCls} {fieldBodyCls}\" id=\"{id}-bodyEl\" colspan=\"{bodyColspan}\" role=\"presentation\">',\n                '{beforeBodyEl}',\n\n                // Label just sits on top of the input field if labelAlign === 'top'\n                '<tpl if=\"labelAlign==\\'top\\'\">',\n                    '{beforeLabelTpl}',\n                    '<div id=\"{id}-labelCell\" style=\"{labelCellStyle}\">',\n                        '<label id=\"{id}-labelEl\" {labelAttrTpl}<tpl if=\"inputId\"> for=\"{inputId}\"</tpl> class=\"{labelCls}\"',\n                            '<tpl if=\"labelStyle\"> style=\"{labelStyle}\"</tpl>>',\n                            '{beforeLabelTextTpl}',\n                            '<tpl if=\"fieldLabel\">{fieldLabel}{labelSeparator}</tpl>',\n                            '{afterLabelTextTpl}',\n                        '</label>',\n                    '</div>',\n                    '{afterLabelTpl}',\n                '</tpl>',\n\n                '{beforeSubTpl}',\n                '{[values.$comp.getSubTplMarkup()]}',\n                '{afterSubTpl}',\n\n            // Final TD. It's a side error element unless there's a floating external one\n            '<tpl if=\"msgTarget===\\'side\\'\">',\n                '{afterBodyEl}',\n                '</td>',\n                '<td id=\"{id}-sideErrorCell\" vAlign=\"{[values.labelAlign===\\'top\\' && !values.hideLabel ? \\'bottom\\' : \\'middle\\']}\" style=\"{[values.autoFitErrors ? \\'display:none\\' : \\'\\']}\" width=\"{errorIconWidth}\">',\n                    '<div id=\"{id}-errorEl\" class=\"{errorMsgCls}\" style=\"display:none;width:{errorIconWidth}px\"></div>',\n                '</td>',\n            '<tpl elseif=\"msgTarget==\\'under\\'\">',\n                '<div id=\"{id}-errorEl\" class=\"{errorMsgClass}\" colspan=\"2\" style=\"display:none\"></div>',\n                '{afterBodyEl}',\n                '</td>',\n            '</tpl>',\n\n        '</tr>',\n        {\n            disableFormats: true\n        }\n    ],\n\n    /**\n     * @cfg {String/String[]/Ext.XTemplate} activeErrorsTpl\n     * The template used to format the Array of error messages passed to {@link #setActiveErrors} into a single HTML\n     * string. By default this renders each message as an item in an unordered list.\n     */\n    activeErrorsTpl: [\n        '<tpl if=\"errors && errors.length\">',\n            '<ul><tpl for=\"errors\"><li>{.}</li></tpl></ul>',\n        '</tpl>'\n    ],\n\n    /**\n     * @property {Boolean} isFieldLabelable\n     * Flag denoting that this object is labelable as a field. Always true.\n     */\n    isFieldLabelable: true,\n\n    /**\n     * @cfg {String} formItemCls\n     * A CSS class to be applied to the outermost element to denote that it is participating in the form field layout.\n     */\n    formItemCls: Ext.baseCSSPrefix + 'form-item',\n\n    /**\n     * @cfg {String} labelCls\n     * The CSS class to be applied to the label element. This (single) CSS class is used to formulate the renderSelector\n     * and drives the field layout where it is concatenated with a hyphen ('-') and {@link #labelAlign}. To add\n     * additional classes, use {@link #labelClsExtra}.\n     */\n    labelCls: Ext.baseCSSPrefix + 'form-item-label',\n\n    /**\n     * @cfg {String} labelClsExtra\n     * An optional string of one or more additional CSS classes to add to the label element. Defaults to empty.\n     */\n\n    /**\n     * @cfg {String} errorMsgCls\n     * The CSS class to be applied to the error message element.\n     */\n    errorMsgCls: Ext.baseCSSPrefix + 'form-error-msg',\n\n    /**\n     * @cfg {String} baseBodyCls\n     * The CSS class to be applied to the body content element.\n     */\n    baseBodyCls: Ext.baseCSSPrefix + 'form-item-body',\n\n    /**\n     * @cfg {String} fieldBodyCls\n     * An extra CSS class to be applied to the body content element in addition to {@link #baseBodyCls}.\n     */\n    fieldBodyCls: '',\n\n    /**\n     * @cfg {String} clearCls\n     * The CSS class to be applied to the special clearing div rendered directly after the field contents wrapper to\n     * provide field clearing.\n     */\n    clearCls: Ext.baseCSSPrefix + 'clear',\n\n    /**\n     * @cfg {String} invalidCls\n     * The CSS class to use when marking the component invalid.\n     */\n    invalidCls : Ext.baseCSSPrefix + 'form-invalid',\n\n    /**\n     * @cfg {String} fieldLabel\n     * The label for the field. It gets appended with the {@link #labelSeparator}, and its position and sizing is\n     * determined by the {@link #labelAlign}, {@link #labelWidth}, and {@link #labelPad} configs.\n     */\n    fieldLabel: undefined,\n\n    /**\n     * @cfg {String} labelAlign\n     * Controls the position and alignment of the {@link #fieldLabel}. Valid values are:\n     *\n     *   - \"left\" (the default) - The label is positioned to the left of the field, with its text aligned to the left.\n     *     Its width is determined by the {@link #labelWidth} config.\n     *   - \"top\" - The label is positioned above the field.\n     *   - \"right\" - The label is positioned to the left of the field, with its text aligned to the right.\n     *     Its width is determined by the {@link #labelWidth} config.\n     */\n    labelAlign : 'left',\n\n    /**\n     * @cfg {Number} labelWidth\n     * The width of the {@link #fieldLabel} in pixels. Only applicable if the {@link #labelAlign} is set to \"left\" or\n     * \"right\".\n     */\n    labelWidth: 100,\n\n    /**\n     * @cfg {Number} labelPad\n     * The amount of space in pixels between the {@link #fieldLabel} and the input field.\n     */\n    labelPad : 5,\n\n    //<locale>\n    /**\n     * @cfg {String} labelSeparator\n     * Character(s) to be inserted at the end of the {@link #fieldLabel label text}.\n     *\n     * Set to empty string to hide the separator completely.\n     */\n    labelSeparator : ':',\n    //</locale>\n\n    /**\n     * @cfg {String} labelStyle\n     * A CSS style specification string to apply directly to this field's label.\n     */\n\n    /**\n     * @cfg {Boolean} hideLabel\n     * Set to true to completely hide the label element ({@link #fieldLabel} and {@link #labelSeparator}). Also see\n     * {@link #hideEmptyLabel}, which controls whether space will be reserved for an empty fieldLabel.\n     */\n    hideLabel: false,\n\n    /**\n     * @cfg {Boolean} hideEmptyLabel\n     * When set to true, the label element ({@link #fieldLabel} and {@link #labelSeparator}) will be automatically\n     * hidden if the {@link #fieldLabel} is empty. Setting this to false will cause the empty label element to be\n     * rendered and space to be reserved for it; this is useful if you want a field without a label to line up with\n     * other labeled fields in the same form.\n     *\n     * If you wish to unconditionall hide the label even if a non-empty fieldLabel is configured, then set the\n     * {@link #hideLabel} config to true.\n     */\n    hideEmptyLabel: true,\n\n    /**\n     * @cfg {Boolean} preventMark\n     * true to disable displaying any {@link #setActiveError error message} set on this object.\n     */\n    preventMark: false,\n\n    /**\n     * @cfg {Boolean} autoFitErrors\n     * Whether to adjust the component's body area to make room for 'side' or 'under' {@link #msgTarget error messages}.\n     */\n    autoFitErrors: true,\n\n    /**\n     * @cfg {String} msgTarget\n     * The location where the error message text should display. Must be one of the following values:\n     *\n     *   - `qtip` Display a quick tip containing the message when the user hovers over the field.\n     *     This is the default.\n     *\n     *     **{@link Ext.tip.QuickTipManager#init} must have been called for this setting to work.**\n     *\n     *   - `title` Display the message in a default browser title attribute popup.\n     *   - `under` Add a block div beneath the field containing the error message.\n     *   - `side` Add an error icon to the right of the field, displaying the message in a popup on hover.\n     *   - `none` Don't display any error message. This might be useful if you are implementing custom error display.\n     *   - `[element id]` Add the error message directly to the innerHTML of the specified element.\n     */\n    msgTarget: 'qtip',\n\n    /**\n     * @cfg {String} activeError\n     * If specified, then the component will be displayed with this value as its active error when first rendered. Use\n     * {@link #setActiveError} or {@link #unsetActiveError} to change it after component creation.\n     */\n\n    /**\n     * @private\n     * Tells the layout system that the height can be measured immediately because the width does not need setting.\n     */\n    noWrap: true,\n\n    labelableInsertions: [\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} beforeBodyEl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * at the beginning of the input containing element. If an `XTemplate` is used, the component's {@link Ext.AbstractComponent#renderData render data}\n         * serves as the context.\n         */\n        'beforeBodyEl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} afterBodyEl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * at the end of the input containing element. If an `XTemplate` is used, the component's {@link Ext.AbstractComponent#renderData render data}\n         * serves as the context.\n         */\n        'afterBodyEl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} beforeLabelTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * before the label element. If an `XTemplate` is used, the component's {@link Ext.AbstractComponent#renderData render data}\n         * serves as the context.\n         */\n        'beforeLabelTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} afterLabelTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * after the label element. If an `XTemplate` is used, the component's {@link Ext.AbstractComponent#renderData render data}\n         * serves as the context.\n         */\n        'afterLabelTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} beforeSubTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * before the {@link #getSubTplMarkup subTpl markup}. If an `XTemplate` is used, the\n         * component's {@link Ext.AbstractComponent#renderData render data} serves as the context.\n         */\n        'beforeSubTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} afterSubTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * after the {@link #getSubTplMarkup subTpl markup}. If an `XTemplate` is used, the\n         * component's {@link Ext.AbstractComponent#renderData render data} serves as the context.\n         */\n        'afterSubTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} beforeLabelTextTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * before the label text. If an `XTemplate` is used, the component's {@link Ext.AbstractComponent#renderData render data}\n         * serves as the context.\n         */\n        'beforeLabelTextTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} afterLabelTextTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * after the label text. If an `XTemplate` is used, the component's {@link Ext.AbstractComponent#renderData render data}\n         * serves as the context.\n         */\n        'afterLabelTextTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} labelAttrTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * inside the label element (as attributes). If an `XTemplate` is used, the component's\n         * {@link Ext.AbstractComponent#renderData render data} serves as the context.\n         */\n        'labelAttrTpl'\n    ],\n\n    // This is an array to avoid a split on every call to Ext.copyTo\n    labelableRenderProps: [ 'allowBlank', 'id', 'labelAlign', 'fieldBodyCls', 'baseBodyCls',\n                            'clearCls', 'labelSeparator', 'msgTarget' ],\n\n    /**\n     * Performs initialization of this mixin. Component classes using this mixin should call this method during their\n     * own initialization.\n     */\n    initLabelable: function() {\n        var me = this,\n            padding = me.padding;\n\n        // This Component is rendered as a table. Padding doesn't work on tables\n        // Before padding can be applied to the encapsulating table element, copy the padding into\n        // an extraMargins property which is to be added to all computed margins post render :(\n        if (padding) {\n            me.padding = undefined;\n            me.extraMargins = Ext.Element.parseBox(padding);\n        }\n\n        me.addCls(me.formItemCls);\n        \n        // Prevent first render of active error, at Field render time from signalling a change from undefined to \"\n        me.lastActiveError = '';\n\n        me.addEvents(\n            /**\n             * @event errorchange\n             * Fires when the active error message is changed via {@link #setActiveError}.\n             * @param {Ext.form.Labelable} this\n             * @param {String} error The active error message\n             */\n            'errorchange'\n        );\n    },\n\n    /**\n     * Returns the trimmed label by slicing off the label separator character. Can be overridden.\n     * @return {String} The trimmed field label, or empty string if not defined\n     */\n    trimLabelSeparator: function() {\n        var me = this,\n            separator = me.labelSeparator,\n            label = me.fieldLabel || '',\n            lastChar = label.substr(label.length - 1);\n\n        // if the last char is the same as the label separator then slice it off otherwise just return label value\n        return lastChar === separator ? label.slice(0, -1) : label;\n    },\n\n    /**\n     * Returns the label for the field. Defaults to simply returning the {@link #fieldLabel} config. Can be overridden\n     * to provide a custom generated label.\n     * @template\n     * @return {String} The configured field label, or empty string if not defined\n     */\n    getFieldLabel: function() {\n        return this.trimLabelSeparator();\n    },\n    \n    /**\n     * Set the label of this field.\n     * @param {String} label The new label. The {@link #labelSeparator} will be automatically appended to the label\n     * string.\n     */\n    setFieldLabel: function(label){\n        label = label || '';\n        \n        var me = this,\n            separator = me.labelSeparator,\n            labelEl = me.labelEl;\n        \n        me.fieldLabel = label;\n        if (me.rendered) {\n            if (Ext.isEmpty(label) && me.hideEmptyLabel) {\n                labelEl.parent().setDisplayed('none');\n            } else {\n                if (separator) {\n                    label = me.trimLabelSeparator() + separator;\n                }\n                labelEl.update(label);\n                labelEl.parent().setDisplayed('');\n            }\n            me.updateLayout();\n        }\n    },\n\n    getInsertionRenderData: function (data, names) {\n        var i = names.length,\n            name, value;\n\n        while (i--) {\n            name = names[i];\n            value = this[name];\n\n            if (value) {\n                if (typeof value != 'string') {\n                    if (!value.isTemplate) {\n                        value = Ext.XTemplate.getTpl(this, name);\n                    }\n                    value = value.apply(data);\n                }\n            }\n\n            data[name] = value || '';\n        }\n\n        return data;\n    },\n\n    /**\n     * Generates the arguments for the field decorations {@link #labelableRenderTpl rendering template}.\n     * @return {Object} The template arguments\n     * @protected\n     */\n    getLabelableRenderData: function() {\n        var me = this,\n            data,\n            tempEl,\n            topLabel = me.labelAlign === 'top';\n\n        if (!Ext.form.Labelable.errorIconWidth) {\n            Ext.form.Labelable.errorIconWidth = (tempEl = Ext.resetElement.createChild({style: 'position:absolute', cls: Ext.baseCSSPrefix + 'form-invalid-icon'})).getWidth();\n            tempEl.remove();\n        }\n\n        data = Ext.copyTo({\n            inFormLayout   : me.ownerLayout && me.ownerLayout.type === 'form',\n            inputId        : me.getInputId(),\n            labelOnLeft    : !topLabel,\n            hideLabel      : !me.hasVisibleLabel(),\n            fieldLabel     : me.getFieldLabel(),\n            labelCellStyle : me.getLabelCellStyle(),\n            labelCellAttrs : me.getLabelCellAttrs(),\n            labelCls       : me.getLabelCls(),\n            labelStyle     : me.getLabelStyle(),\n            bodyColspan    : me.getBodyColspan(),\n            externalError  : !me.autoFitErrors,\n            errorMsgCls    : me.getErrorMsgCls(),\n            errorIconWidth : Ext.form.Labelable.errorIconWidth\n        },\n        me, me.labelableRenderProps, true);\n\n        me.getInsertionRenderData(data, me.labelableInsertions);\n\n        return data;\n    },\n    \n    beforeLabelableRender: function() {\n        var me = this;\n        if (me.ownerLayout) {\n            me.addCls(Ext.baseCSSPrefix + me.ownerLayout.type + '-form-item');\n        }\n    },\n\n    onLabelableRender: function() {\n        var me = this,\n            margins,\n            side,\n            style = {};\n\n        if (me.extraMargins) {\n            margins = me.el.getMargin();\n            for (side in margins) {\n                if (margins.hasOwnProperty(side)) {\n                    style['margin-' + side] = (margins[side] + me.extraMargins[side]) + 'px';\n                }\n            }\n            me.el.setStyle(style);\n        }\n    },\n    \n    /**\n     * Checks if the field has a visible label\n     * @return {Boolean} True if the field has a visible label\n     */\n    hasVisibleLabel: function(){\n        if (this.hideLabel) {\n            return false;\n        }\n        return !(this.hideEmptyLabel && !this.getFieldLabel());\n    },\n    \n    /**\n     * @private\n     * Calculates the colspan value for the body cell - the cell which contains the input field.\n     *\n     * The field table structure contains 4 columns:\n     */\n    getBodyColspan: function() {\n        var me = this,\n            result;\n\n        if (me.msgTarget === 'side' && (!me.autoFitErrors || me.hasActiveError())) {\n            result = 1;\n        } else {\n            result = 2;\n        }\n        if (me.labelAlign !== 'top' && !me.hasVisibleLabel()) {\n            result++;\n        }\n        return result;\n    },\n    \n    getLabelCls: function() {\n        var labelCls = this.labelCls,\n            labelClsExtra = this.labelClsExtra;\n\n        if (this.labelAlign === 'top') {\n            labelCls += '-top';\n        }\n        return labelClsExtra ? labelCls + ' ' + labelClsExtra : labelCls;\n    },\n\n    getLabelCellStyle: function() {\n        var me = this,\n            hideLabelCell = me.hideLabel || (!me.fieldLabel && me.hideEmptyLabel);\n\n        return hideLabelCell ? 'display:none;' : '';\n    },\n    \n    getErrorMsgCls: function() {\n        var me = this,\n            hideLabelCell = (me.hideLabel || (!me.fieldLabel && me.hideEmptyLabel));\n        \n        return me.errorMsgCls + (!hideLabelCell && me.labelAlign === 'top' ? ' ' + Ext.baseCSSPrefix + 'lbl-top-err-icon' : '');\n    },\n\n    getLabelCellAttrs: function() {\n        var me = this,\n            labelAlign = me.labelAlign,\n            result = '';\n\n        if (labelAlign !== 'top') {\n            result = 'valign=\"top\" halign=\"' + labelAlign + '\" width=\"' + (me.labelWidth + me.labelPad) + '\"';\n        }\n        return result + ' class=\"' + Ext.baseCSSPrefix + 'field-label-cell\"';\n    },\n    \n    /**\n     * Gets any label styling for the labelEl\n     * @private\n     * @return {String} The label styling\n     */\n    getLabelStyle: function(){\n        var me = this,\n            labelPad = me.labelPad,\n            labelStyle = '';\n\n        // Calculate label styles up front rather than in the Field layout for speed; this\n        // is safe because label alignment/width/pad are not expected to change.\n        if (me.labelAlign !== 'top') {\n            if (me.labelWidth) {\n                labelStyle = 'width:' + me.labelWidth + 'px;';\n            }\n            labelStyle += 'margin-right:' + labelPad + 'px;';\n        }\n        \n        return labelStyle + (me.labelStyle || '');\n    },\n\n    /**\n     * Gets the markup to be inserted into the outer template's bodyEl. Defaults to empty string, should be implemented\n     * by classes including this mixin as needed.\n     * @return {String} The markup to be inserted\n     * @protected\n     */\n    getSubTplMarkup: function() {\n        return '';\n    },\n\n    /**\n     * Get the input id, if any, for this component. This is used as the \"for\" attribute on the label element.\n     * Implementing subclasses may also use this as e.g. the id for their own input element.\n     * @return {String} The input id\n     */\n    getInputId: function() {\n        return '';\n    },\n\n    /**\n     * Gets the active error message for this component, if any. This does not trigger validation on its own, it merely\n     * returns any message that the component may already hold.\n     * @return {String} The active error message on the component; if there is no error, an empty string is returned.\n     */\n    getActiveError : function() {\n        return this.activeError || '';\n    },\n\n    /**\n     * Tells whether the field currently has an active error message. This does not trigger validation on its own, it\n     * merely looks for any message that the component may already hold.\n     * @return {Boolean}\n     */\n    hasActiveError: function() {\n        return !!this.getActiveError();\n    },\n\n    /**\n     * Sets the active error message to the given string. This replaces the entire error message contents with the given\n     * string. Also see {@link #setActiveErrors} which accepts an Array of messages and formats them according to the\n     * {@link #activeErrorsTpl}. Note that this only updates the error message element's text and attributes, you'll\n     * have to call doComponentLayout to actually update the field's layout to match. If the field extends {@link\n     * Ext.form.field.Base} you should call {@link Ext.form.field.Base#markInvalid markInvalid} instead.\n     * @param {String} msg The error message\n     */\n    setActiveError: function(msg) {\n        this.setActiveErrors(msg);\n    },\n\n    /**\n     * Gets an Array of any active error messages currently applied to the field. This does not trigger validation on\n     * its own, it merely returns any messages that the component may already hold.\n     * @return {String[]} The active error messages on the component; if there are no errors, an empty Array is\n     * returned.\n     */\n    getActiveErrors: function() {\n        return this.activeErrors || [];\n    },\n\n    /**\n     * Set the active error message to an Array of error messages. The messages are formatted into a single message\n     * string using the {@link #activeErrorsTpl}. Also see {@link #setActiveError} which allows setting the entire error\n     * contents with a single string. Note that this only updates the error message element's text and attributes,\n     * you'll have to call doComponentLayout to actually update the field's layout to match. If the field extends\n     * {@link Ext.form.field.Base} you should call {@link Ext.form.field.Base#markInvalid markInvalid} instead.\n     * @param {String[]} errors The error messages\n     */\n    setActiveErrors: function(errors) {\n        errors = Ext.Array.from(errors);\n        this.activeError = errors[0];\n        this.activeErrors = errors;\n        this.activeError = this.getTpl('activeErrorsTpl').apply({errors: errors});\n        this.renderActiveError();\n    },\n\n    /**\n     * Clears the active error message(s). Note that this only clears the error message element's text and attributes,\n     * you'll have to call doComponentLayout to actually update the field's layout to match. If the field extends {@link\n     * Ext.form.field.Base} you should call {@link Ext.form.field.Base#clearInvalid clearInvalid} instead.\n     */\n    unsetActiveError: function() {\n        delete this.activeError;\n        delete this.activeErrors;\n        this.renderActiveError();\n    },\n\n    /**\n     * @private\n     * Updates the rendered DOM to match the current activeError. This only updates the content and\n     * attributes, you'll have to call doComponentLayout to actually update the display.\n     */\n    renderActiveError: function() {\n        var me = this,\n            activeError = me.getActiveError(),\n            hasError = !!activeError;\n\n        if (activeError !== me.lastActiveError) {\n            me.fireEvent('errorchange', me, activeError);\n            me.lastActiveError = activeError;\n        }\n\n        if (me.rendered && !me.isDestroyed && !me.preventMark) {\n            // Add/remove invalid class\n            me.el[hasError ? 'addCls' : 'removeCls'](me.invalidCls);\n\n            // Update the aria-invalid attribute\n            me.getActionEl().dom.setAttribute('aria-invalid', hasError);\n\n            // Update the errorEl (There will only be one if msgTarget is 'side' or 'under') with the error message text\n            if (me.errorEl) {\n                me.errorEl.dom.innerHTML = activeError;\n            }\n        }\n    },\n\n    /**\n     * Applies a set of default configuration values to this Labelable instance. For each of the properties in the given\n     * object, check if this component hasOwnProperty that config; if not then it's inheriting a default value from its\n     * prototype and we should apply the default value.\n     * @param {Object} defaults The defaults to apply to the object.\n     */\n    setFieldDefaults: function(defaults) {\n        var me = this,\n            val, key;\n\n        for (key in defaults) {\n            if (defaults.hasOwnProperty(key)) {\n                val = defaults[key];\n\n                if (!me.hasOwnProperty(key)) {\n                    me[key] = val;\n                }\n            }\n        }\n    }\n});\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * This mixin provides a common interface for the logical behavior and state of form fields, including:\n *\n * - Getter and setter methods for field values\n * - Events and methods for tracking value and validity changes\n * - Methods for triggering validation\n *\n * **NOTE**: When implementing custom fields, it is most likely that you will want to extend the {@link Ext.form.field.Base}\n * component class rather than using this mixin directly, as BaseField contains additional logic for generating an\n * actual DOM complete with {@link Ext.form.Labelable label and error message} display and a form input field,\n * plus methods that bind the Field value getters and setters to the input field's value.\n *\n * If you do want to implement this mixin directly and don't want to extend {@link Ext.form.field.Base}, then\n * you will most likely want to override the following methods with custom implementations: {@link #getValue},\n * {@link #setValue}, and {@link #getErrors}. Other methods may be overridden as needed but their base\n * implementations should be sufficient for common cases. You will also need to make sure that {@link #initField}\n * is called during the component's initialization.\n */\nExt.define('Ext.form.field.Field', {\n    /**\n     * @property {Boolean} isFormField\n     * Flag denoting that this component is a Field. Always true.\n     */\n    isFormField : true,\n\n    /**\n     * @cfg {Object} value\n     * A value to initialize this field with.\n     */\n\n    /**\n     * @cfg {String} name\n     * The name of the field. By default this is used as the parameter name when including the\n     * {@link #getSubmitData field value} in a {@link Ext.form.Basic#submit form submit()}. To prevent the field from\n     * being included in the form submit, set {@link #submitValue} to false.\n     */\n\n    /**\n     * @cfg {Boolean} disabled\n     * True to disable the field. Disabled Fields will not be {@link Ext.form.Basic#submit submitted}.\n     */\n    disabled : false,\n\n    /**\n     * @cfg {Boolean} submitValue\n     * Setting this to false will prevent the field from being {@link Ext.form.Basic#submit submitted} even when it is\n     * not disabled.\n     */\n    submitValue: true,\n\n    /**\n     * @cfg {Boolean} validateOnChange\n     * Specifies whether this field should be validated immediately whenever a change in its value is detected.\n     * If the validation results in a change in the field's validity, a {@link #validitychange} event will be\n     * fired. This allows the field to show feedback about the validity of its contents immediately as the user is\n     * typing.\n     *\n     * When set to false, feedback will not be immediate. However the form will still be validated before submitting if\n     * the clientValidation option to {@link Ext.form.Basic#doAction} is enabled, or if the field or form are validated\n     * manually.\n     *\n     * See also {@link Ext.form.field.Base#checkChangeEvents} for controlling how changes to the field's value are\n     * detected.\n     */\n    validateOnChange: true,\n\n    /**\n     * @private\n     */\n    suspendCheckChange: 0,\n\n    /**\n     * Initializes this Field mixin on the current instance. Components using this mixin should call this method during\n     * their own initialization process.\n     */\n    initField: function() {\n        this.addEvents(\n            /**\n             * @event change\n             * Fires when the value of a field is changed via the {@link #setValue} method.\n             * @param {Ext.form.field.Field} this\n             * @param {Object} newValue The new value\n             * @param {Object} oldValue The original value\n             */\n            'change',\n            /**\n             * @event validitychange\n             * Fires when a change in the field's validity is detected.\n             * @param {Ext.form.field.Field} this\n             * @param {Boolean} isValid Whether or not the field is now valid\n             */\n            'validitychange',\n            /**\n             * @event dirtychange\n             * Fires when a change in the field's {@link #isDirty} state is detected.\n             * @param {Ext.form.field.Field} this\n             * @param {Boolean} isDirty Whether or not the field is now dirty\n             */\n            'dirtychange'\n        );\n\n        this.initValue();\n    },\n\n    /**\n     * Initializes the field's value based on the initial config.\n     */\n    initValue: function() {\n        var me = this;\n\n        me.value = me.transformOriginalValue(me.value);\n        /**\n         * @property {Object} originalValue\n         * The original value of the field as configured in the {@link #value} configuration, or as loaded by the last\n         * form load operation if the form's {@link Ext.form.Basic#trackResetOnLoad trackResetOnLoad} setting is `true`.\n         */\n        me.originalValue = me.lastValue = me.value;\n\n        // Set the initial value - prevent validation on initial set\n        me.suspendCheckChange++;\n        me.setValue(me.value);\n        me.suspendCheckChange--;\n    },\n    \n    /**\n     * Allows for any necessary modifications before the original\n     * value is set\n     * @protected\n     * @param {Object} value The initial value\n     * @return {Object} The modified initial value\n     */\n    transformOriginalValue: function(value){\n        return value;\n    },\n\n    /**\n     * Returns the {@link Ext.form.field.Field#name name} attribute of the field. This is used as the parameter name\n     * when including the field value in a {@link Ext.form.Basic#submit form submit()}.\n     * @return {String} name The field {@link Ext.form.field.Field#name name}\n     */\n    getName: function() {\n        return this.name;\n    },\n\n    /**\n     * Returns the current data value of the field. The type of value returned is particular to the type of the\n     * particular field (e.g. a Date object for {@link Ext.form.field.Date}).\n     * @return {Object} value The field value\n     */\n    getValue: function() {\n        return this.value;\n    },\n\n    /**\n     * Sets a data value into the field and runs the change detection and validation.\n     * @param {Object} value The value to set\n     * @return {Ext.form.field.Field} this\n     */\n    setValue: function(value) {\n        var me = this;\n        me.value = value;\n        me.checkChange();\n        return me;\n    },\n\n    /**\n     * Returns whether two field {@link #getValue values} are logically equal. Field implementations may override this\n     * to provide custom comparison logic appropriate for the particular field's data type.\n     * @param {Object} value1 The first value to compare\n     * @param {Object} value2 The second value to compare\n     * @return {Boolean} True if the values are equal, false if inequal.\n     */\n    isEqual: function(value1, value2) {\n        return String(value1) === String(value2);\n    },\n\n    /**\n     * Returns whether two values are logically equal.\n     * Similar to {@link #isEqual}, however null or undefined values will be treated as empty strings.\n     * @private\n     * @param {Object} value1 The first value to compare\n     * @param {Object} value2 The second value to compare\n     * @return {Boolean} True if the values are equal, false if inequal.\n     */\n    isEqualAsString: function(value1, value2){\n        return String(Ext.value(value1, '')) === String(Ext.value(value2, ''));\n    },\n\n    /**\n     * Returns the parameter(s) that would be included in a standard form submit for this field. Typically this will be\n     * an object with a single name-value pair, the name being this field's {@link #getName name} and the value being\n     * its current stringified value. More advanced field implementations may return more than one name-value pair.\n     *\n     * Note that the values returned from this method are not guaranteed to have been successfully {@link #validate\n     * validated}.\n     *\n     * @return {Object} A mapping of submit parameter names to values; each value should be a string, or an array of\n     * strings if that particular name has multiple values. It can also return null if there are no parameters to be\n     * submitted.\n     */\n    getSubmitData: function() {\n        var me = this,\n            data = null;\n        if (!me.disabled && me.submitValue && !me.isFileUpload()) {\n            data = {};\n            data[me.getName()] = '' + me.getValue();\n        }\n        return data;\n    },\n\n    /**\n     * Returns the value(s) that should be saved to the {@link Ext.data.Model} instance for this field, when {@link\n     * Ext.form.Basic#updateRecord} is called. Typically this will be an object with a single name-value pair, the name\n     * being this field's {@link #getName name} and the value being its current data value. More advanced field\n     * implementations may return more than one name-value pair. The returned values will be saved to the corresponding\n     * field names in the Model.\n     *\n     * Note that the values returned from this method are not guaranteed to have been successfully {@link #validate\n     * validated}.\n     *\n     * @return {Object} A mapping of submit parameter names to values; each value should be a string, or an array of\n     * strings if that particular name has multiple values. It can also return null if there are no parameters to be\n     * submitted.\n     */\n    getModelData: function() {\n        var me = this,\n            data = null;\n        if (!me.disabled && !me.isFileUpload()) {\n            data = {};\n            data[me.getName()] = me.getValue();\n        }\n        return data;\n    },\n\n    /**\n     * Resets the current field value to the originally loaded value and clears any validation messages. See {@link\n     * Ext.form.Basic}.{@link Ext.form.Basic#trackResetOnLoad trackResetOnLoad}\n     */\n    reset : function(){\n        var me = this;\n\n        me.beforeReset();\n        me.setValue(me.originalValue);\n        me.clearInvalid();\n        // delete here so we reset back to the original state\n        delete me.wasValid;\n    },\n    \n    /**\n     * Template method before a field is reset.\n     * @protected\n     */\n    beforeReset: Ext.emptyFn,\n\n    /**\n     * Resets the field's {@link #originalValue} property so it matches the current {@link #getValue value}. This is\n     * called by {@link Ext.form.Basic}.{@link Ext.form.Basic#setValues setValues} if the form's\n     * {@link Ext.form.Basic#trackResetOnLoad trackResetOnLoad} property is set to true.\n     */\n    resetOriginalValue: function() {\n        this.originalValue = this.getValue();\n        this.checkDirty();\n    },\n\n    /**\n     * Checks whether the value of the field has changed since the last time it was checked.\n     * If the value has changed, it:\n     *\n     * 1. Fires the {@link #change change event},\n     * 2. Performs validation if the {@link #validateOnChange} config is enabled, firing the\n     *    {@link #validitychange validitychange event} if the validity has changed, and\n     * 3. Checks the {@link #isDirty dirty state} of the field and fires the {@link #dirtychange dirtychange event}\n     *    if it has changed.\n     */\n    checkChange: function() {\n        if (!this.suspendCheckChange) {\n            var me = this,\n                newVal = me.getValue(),\n                oldVal = me.lastValue;\n            if (!me.isEqual(newVal, oldVal) && !me.isDestroyed) {\n                me.lastValue = newVal;\n                me.fireEvent('change', me, newVal, oldVal);\n                me.onChange(newVal, oldVal);\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Called when the field's value changes. Performs validation if the {@link #validateOnChange}\n     * config is enabled, and invokes the dirty check.\n     */\n    onChange: function(newVal, oldVal) {\n        if (this.validateOnChange) {\n            this.validate();\n        }\n        this.checkDirty();\n    },\n\n    /**\n     * Returns true if the value of this Field has been changed from its {@link #originalValue}.\n     * Will always return false if the field is disabled.\n     *\n     * Note that if the owning {@link Ext.form.Basic form} was configured with\n     * {@link Ext.form.Basic#trackResetOnLoad trackResetOnLoad} then the {@link #originalValue} is updated when\n     * the values are loaded by {@link Ext.form.Basic}.{@link Ext.form.Basic#setValues setValues}.\n     * @return {Boolean} True if this field has been changed from its original value (and is not disabled),\n     * false otherwise.\n     */\n    isDirty : function() {\n        var me = this;\n        return !me.disabled && !me.isEqual(me.getValue(), me.originalValue);\n    },\n\n    /**\n     * Checks the {@link #isDirty} state of the field and if it has changed since the last time it was checked,\n     * fires the {@link #dirtychange} event.\n     */\n    checkDirty: function() {\n        var me = this,\n            isDirty = me.isDirty();\n        if (isDirty !== me.wasDirty) {\n            me.fireEvent('dirtychange', me, isDirty);\n            me.onDirtyChange(isDirty);\n            me.wasDirty = isDirty;\n        }\n    },\n\n    /**\n     * @private Called when the field's dirty state changes.\n     * @param {Boolean} isDirty\n     */\n    onDirtyChange: Ext.emptyFn,\n\n    /**\n     * Runs this field's validators and returns an array of error messages for any validation failures. This is called\n     * internally during validation and would not usually need to be used manually.\n     *\n     * Each subclass should override or augment the return value to provide their own errors.\n     *\n     * @param {Object} value The value to get errors for (defaults to the current field value)\n     * @return {String[]} All error messages for this field; an empty Array if none.\n     */\n    getErrors: function(value) {\n        return [];\n    },\n\n    /**\n     * Returns whether or not the field value is currently valid by {@link #getErrors validating} the field's current\n     * value. The {@link #validitychange} event will not be fired; use {@link #validate} instead if you want the event\n     * to fire. **Note**: {@link #disabled} fields are always treated as valid.\n     *\n     * Implementations are encouraged to ensure that this method does not have side-effects such as triggering error\n     * message display.\n     *\n     * @return {Boolean} True if the value is valid, else false\n     */\n    isValid : function() {\n        var me = this;\n        return me.disabled || Ext.isEmpty(me.getErrors());\n    },\n\n    /**\n     * Returns whether or not the field value is currently valid by {@link #getErrors validating} the field's current\n     * value, and fires the {@link #validitychange} event if the field's validity has changed since the last validation.\n     * **Note**: {@link #disabled} fields are always treated as valid.\n     *\n     * Custom implementations of this method are allowed to have side-effects such as triggering error message display.\n     * To validate without side-effects, use {@link #isValid}.\n     *\n     * @return {Boolean} True if the value is valid, else false\n     */\n    validate : function() {\n        var me = this,\n            isValid = me.isValid();\n        if (isValid !== me.wasValid) {\n            me.wasValid = isValid;\n            me.fireEvent('validitychange', me, isValid);\n        }\n        return isValid;\n    },\n\n    /**\n     * A utility for grouping a set of modifications which may trigger value changes into a single transaction, to\n     * prevent excessive firing of {@link #change} events. This is useful for instance if the field has sub-fields which\n     * are being updated as a group; you don't want the container field to check its own changed state for each subfield\n     * change.\n     * @param {Object} fn A function containing the transaction code\n     */\n    batchChanges: function(fn) {\n        try {\n            this.suspendCheckChange++;\n            fn();\n        } catch(e){\n            throw e;\n        } finally {\n            this.suspendCheckChange--;\n        }\n        this.checkChange();\n    },\n\n    /**\n     * Returns whether this Field is a file upload field; if it returns true, forms will use special techniques for\n     * {@link Ext.form.Basic#submit submitting the form} via AJAX. See {@link Ext.form.Basic#hasUpload} for details. If\n     * this returns true, the {@link #extractFileInput} method must also be implemented to return the corresponding file\n     * input element.\n     * @return {Boolean}\n     */\n    isFileUpload: function() {\n        return false;\n    },\n\n    /**\n     * Only relevant if the instance's {@link #isFileUpload} method returns true. Returns a reference to the file input\n     * DOM element holding the user's selected file. The input will be appended into the submission form and will not be\n     * returned, so this method should also create a replacement.\n     * @return {HTMLElement}\n     */\n    extractFileInput: function() {\n        return null;\n    },\n\n    /**\n     * @method markInvalid\n     * Associate one or more error messages with this field. Components using this mixin should implement this method to\n     * update the component's rendering to display the messages.\n     *\n     * **Note**: this method does not cause the Field's {@link #validate} or {@link #isValid} methods to return `false`\n     * if the value does _pass_ validation. So simply marking a Field as invalid will not prevent submission of forms\n     * submitted with the {@link Ext.form.action.Submit#clientValidation} option set.\n     *\n     * @param {String/String[]} errors The error message(s) for the field.\n     */\n    markInvalid: Ext.emptyFn,\n\n    /**\n     * @method clearInvalid\n     * Clear any invalid styles/messages for this field. Components using this mixin should implement this method to\n     * update the components rendering to clear any existing messages.\n     *\n     * **Note**: this method does not cause the Field's {@link #validate} or {@link #isValid} methods to return `true`\n     * if the value does not _pass_ validation. So simply clearing a field's errors will not necessarily allow\n     * submission of forms submitted with the {@link Ext.form.action.Submit#clientValidation} option set.\n     */\n    clearInvalid: Ext.emptyFn\n\n});\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * Base class for form fields that provides default event handling, rendering, and other common functionality\n * needed by all form field types. Utilizes the {@link Ext.form.field.Field} mixin for value handling and validation,\n * and the {@link Ext.form.Labelable} mixin to provide label and error message display.\n *\n * In most cases you will want to use a subclass, such as {@link Ext.form.field.Text} or {@link Ext.form.field.Checkbox},\n * rather than creating instances of this class directly. However if you are implementing a custom form field,\n * using this as the parent class is recommended.\n *\n * # Values and Conversions\n *\n * Because Base implements the Field mixin, it has a main value that can be initialized with the\n * {@link #value} config and manipulated via the {@link #getValue} and {@link #setValue} methods. This main\n * value can be one of many data types appropriate to the current field, for instance a {@link Ext.form.field.Date Date}\n * field would use a JavaScript Date object as its value type. However, because the field is rendered as a HTML\n * input, this value data type can not always be directly used in the rendered field.\n *\n * Therefore Base introduces the concept of a \"raw value\". This is the value of the rendered HTML input field,\n * and is normally a String. The {@link #getRawValue} and {@link #setRawValue} methods can be used to directly\n * work with the raw value, though it is recommended to use getValue and setValue in most cases.\n *\n * Conversion back and forth between the main value and the raw value is handled by the {@link #valueToRaw} and\n * {@link #rawToValue} methods. If you are implementing a subclass that uses a non-String value data type, you\n * should override these methods to handle the conversion.\n *\n * # Rendering\n *\n * The content of the field body is defined by the {@link #fieldSubTpl} XTemplate, with its argument data\n * created by the {@link #getSubTplData} method. Override this template and/or method to create custom\n * field renderings.\n *\n * # Example usage:\n *\n *     @example\n *     // A simple subclass of Base that creates a HTML5 search field. Redirects to the\n *     // searchUrl when the Enter key is pressed.222\n *     Ext.define('Ext.form.SearchField', {\n *         extend: 'Ext.form.field.Base',\n *         alias: 'widget.searchfield',\n *     \n *         inputType: 'search',\n *     \n *         // Config defining the search URL\n *         searchUrl: 'http://www.google.com/search?q={0}',\n *     \n *         // Add specialkey listener\n *         initComponent: function() {\n *             this.callParent();\n *             this.on('specialkey', this.checkEnterKey, this);\n *         },\n *     \n *         // Handle enter key presses, execute the search if the field has a value\n *         checkEnterKey: function(field, e) {\n *             var value = this.getValue();\n *             if (e.getKey() === e.ENTER && !Ext.isEmpty(value)) {\n *                 location.href = Ext.String.format(this.searchUrl, value);\n *             }\n *         }\n *     });\n *     \n *     Ext.create('Ext.form.Panel', {\n *         title: 'Base Example',\n *         bodyPadding: 5,\n *         width: 250,\n *     \n *         // Fields will be arranged vertically, stretched to full width\n *         layout: 'anchor',\n *         defaults: {\n *             anchor: '100%'\n *         },\n *         items: [{\n *             xtype: 'searchfield',\n *             fieldLabel: 'Search',\n *             name: 'query'\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.form.field.Base', {\n    extend: 'Ext.Component',\n    mixins: {\n        labelable: 'Ext.form.Labelable',\n        field: 'Ext.form.field.Field'\n    },\n    alias: 'widget.field',\n    alternateClassName: ['Ext.form.Field', 'Ext.form.BaseField'],\n    requires: ['Ext.util.DelayedTask', 'Ext.XTemplate', 'Ext.layout.component.field.Field'],\n\n    /**\n     * @cfg {Ext.XTemplate} fieldSubTpl\n     * The content of the field body is defined by this config option.\n     * @private\n     */\n    fieldSubTpl: [ // note: {id} here is really {inputId}, but {cmpId} is available\n        '<input id=\"{id}\" type=\"{type}\" {inputAttrTpl}',\n            ' size=\"1\"', // allows inputs to fully respect CSS widths across all browsers\n            '<tpl if=\"name\"> name=\"{name}\"</tpl>',\n            '<tpl if=\"value\"> value=\"{[Ext.util.Format.htmlEncode(values.value)]}\"</tpl>',\n            '<tpl if=\"placeholder\"> placeholder=\"{placeholder}\"</tpl>',\n            '{%if (values.maxLength !== undefined){%} maxlength=\"{maxLength}\"{%}%}',\n            '<tpl if=\"readOnly\"> readonly=\"readonly\"</tpl>',\n            '<tpl if=\"disabled\"> disabled=\"disabled\"</tpl>',\n            '<tpl if=\"tabIdx\"> tabIndex=\"{tabIdx}\"</tpl>',\n            '<tpl if=\"fieldStyle\"> style=\"{fieldStyle}\"</tpl>',\n        ' class=\"{fieldCls} {typeCls} {editableCls}\" autocomplete=\"off\"/>',\n        {\n            disableFormats: true\n        }\n    ],\n\n    subTplInsertions: [\n        /**\n         * @cfg {String/Array/Ext.XTemplate} inputAttrTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * inside the input element (as attributes). If an `XTemplate` is used, the component's\n         * {@link #getSubTplData subTpl data} serves as the context.\n         */\n        'inputAttrTpl'\n    ],\n\n    /**\n     * @cfg {String} name\n     * The name of the field. This is used as the parameter name when including the field value\n     * in a {@link Ext.form.Basic#submit form submit()}. If no name is configured, it falls back to the {@link #inputId}.\n     * To prevent the field from being included in the form submit, set {@link #submitValue} to false.\n     */\n\n    /**\n     * @cfg {String} inputType\n     * The type attribute for input fields -- e.g. radio, text, password, file. The extended types\n     * supported by HTML5 inputs (url, email, etc.) may also be used, though using them will cause older browsers to\n     * fall back to 'text'.\n     *\n     * The type 'password' must be used to render that field type currently -- there is no separate Ext component for\n     * that. You can use {@link Ext.form.field.File} which creates a custom-rendered file upload field, but if you want\n     * a plain unstyled file input you can use a Base with inputType:'file'.\n     */\n    inputType: 'text',\n\n    /**\n     * @cfg {Number} tabIndex\n     * The tabIndex for this field. Note this only applies to fields that are rendered, not those which are built via\n     * applyTo\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} invalidText\n     * The error text to use when marking a field invalid and no message is provided\n     */\n    invalidText : 'The value in this field is invalid',\n    //</locale>\n\n    /**\n     * @cfg {String} [fieldCls='x-form-field']\n     * The default CSS class for the field input\n     */\n    fieldCls : Ext.baseCSSPrefix + 'form-field',\n\n    /**\n     * @cfg {String} fieldStyle\n     * Optional CSS style(s) to be applied to the {@link #inputEl field input element}. Should be a valid argument to\n     * {@link Ext.Element#applyStyles}. Defaults to undefined. See also the {@link #setFieldStyle} method for changing\n     * the style after initialization.\n     */\n\n    /**\n     * @cfg {String} [focusCls='x-form-focus']\n     * The CSS class to use when the field receives focus\n     */\n    focusCls : 'form-focus',\n\n    /**\n     * @cfg {String} dirtyCls\n     * The CSS class to use when the field value {@link #isDirty is dirty}.\n     */\n    dirtyCls : Ext.baseCSSPrefix + 'form-dirty',\n\n    /**\n     * @cfg {String[]} checkChangeEvents\n     * A list of event names that will be listened for on the field's {@link #inputEl input element}, which will cause\n     * the field's value to be checked for changes. If a change is detected, the {@link #change change event} will be\n     * fired, followed by validation if the {@link #validateOnChange} option is enabled.\n     *\n     * Defaults to ['change', 'propertychange'] in Internet Explorer, and ['change', 'input', 'textInput', 'keyup',\n     * 'dragdrop'] in other browsers. This catches all the ways that field values can be changed in most supported\n     * browsers; the only known exceptions at the time of writing are:\n     *\n     *   - Safari 3.2 and older: cut/paste in textareas via the context menu, and dragging text into textareas\n     *   - Opera 10 and 11: dragging text into text fields and textareas, and cut via the context menu in text fields\n     *     and textareas\n     *   - Opera 9: Same as Opera 10 and 11, plus paste from context menu in text fields and textareas\n     *\n     * If you need to guarantee on-the-fly change notifications including these edge cases, you can call the\n     * {@link #checkChange} method on a repeating interval, e.g. using {@link Ext.TaskManager}, or if the field is within\n     * a {@link Ext.form.Panel}, you can use the FormPanel's {@link Ext.form.Panel#pollForChanges} configuration to set up\n     * such a task automatically.\n     */\n    checkChangeEvents: Ext.isIE && (!document.documentMode || document.documentMode < 9) ?\n                        ['change', 'propertychange'] :\n                        ['change', 'input', 'textInput', 'keyup', 'dragdrop'],\n\n    /**\n     * @cfg {Number} checkChangeBuffer\n     * Defines a timeout in milliseconds for buffering {@link #checkChangeEvents} that fire in rapid succession.\n     * Defaults to 50 milliseconds.\n     */\n    checkChangeBuffer: 50,\n\n    componentLayout: 'field',\n\n    /**\n     * @cfg {Boolean} readOnly\n     * true to mark the field as readOnly in HTML.\n     *\n     * **Note**: this only sets the element's readOnly DOM attribute. Setting `readOnly=true`, for example, will not\n     * disable triggering a ComboBox or Date; it gives you the option of forcing the user to choose via the trigger\n     * without typing in the text box. To hide the trigger use `{@link Ext.form.field.Trigger#hideTrigger hideTrigger}`.\n     */\n    readOnly : false,\n\n    /**\n     * @cfg {String} readOnlyCls\n     * The CSS class applied to the component's main element when it is {@link #readOnly}.\n     */\n    readOnlyCls: Ext.baseCSSPrefix + 'form-readonly',\n\n    /**\n     * @cfg {String} inputId\n     * The id that will be given to the generated input DOM element. Defaults to an automatically generated id. If you\n     * configure this manually, you must make sure it is unique in the document.\n     */\n\n    /**\n     * @cfg {Boolean} validateOnBlur\n     * Whether the field should validate when it loses focus. This will cause fields to be validated\n     * as the user steps through the fields in the form regardless of whether they are making changes to those fields\n     * along the way. See also {@link #validateOnChange}.\n     */\n    validateOnBlur: true,\n\n    // private\n    hasFocus : false,\n\n    baseCls: Ext.baseCSSPrefix + 'field',\n\n    maskOnDisable: false,\n\n    // private\n    initComponent : function() {\n        var me = this;\n\n        me.callParent();\n\n        me.subTplData = me.subTplData || {};\n\n        me.addEvents(\n            /**\n             * @event specialkey\n             * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. To handle other keys\n             * see {@link Ext.util.KeyMap}. You can check {@link Ext.EventObject#getKey} to determine which key was\n             * pressed. For example:\n             *\n             *     var form = new Ext.form.Panel({\n             *         ...\n             *         items: [{\n             *                 fieldLabel: 'Field 1',\n             *                 name: 'field1',\n             *                 allowBlank: false\n             *             },{\n             *                 fieldLabel: 'Field 2',\n             *                 name: 'field2',\n             *                 listeners: {\n             *                     specialkey: function(field, e){\n             *                         // e.HOME, e.END, e.PAGE_UP, e.PAGE_DOWN,\n             *                         // e.TAB, e.ESC, arrow keys: e.LEFT, e.RIGHT, e.UP, e.DOWN\n             *                         if (e.{@link Ext.EventObject#getKey getKey()} == e.ENTER) {\n             *                             var form = field.up('form').getForm();\n             *                             form.submit();\n             *                         }\n             *                     }\n             *                 }\n             *             }\n             *         ],\n             *         ...\n             *     });\n             *\n             * @param {Ext.form.field.Base} this\n             * @param {Ext.EventObject} e The event object\n             */\n            'specialkey',\n\n            /**\n             * @event writeablechange\n             * Fires when this field changes its read-only status.\n             * @param {Ext.form.field.Base} this\n             * @param {Boolean} Read only flag\n             */\n            'writeablechange'\n        );\n\n        // Init mixins\n        me.initLabelable();\n        me.initField();\n\n        // Default name to inputId\n        if (!me.name) {\n            me.name = me.getInputId();\n        }\n    },\n    \n    beforeRender: function(){\n        var me = this;\n            \n        me.callParent(arguments);\n        me.beforeLabelableRender(arguments);\n        if (me.readOnly) {\n            me.addCls(me.readOnlyCls);\n        }\n    },\n\n    /**\n     * Returns the input id for this field. If none was specified via the {@link #inputId} config, then an id will be\n     * automatically generated.\n     */\n    getInputId: function() {\n        return this.inputId || (this.inputId = this.id + '-inputEl');\n    },\n\n    /**\n     * Creates and returns the data object to be used when rendering the {@link #fieldSubTpl}.\n     * @return {Object} The template data\n     * @template\n     */\n    getSubTplData: function() {\n        var me = this,\n            type = me.inputType,\n            inputId = me.getInputId(),\n            data;\n        \n        data = Ext.apply({\n            id         : inputId,\n            cmpId      : me.id,\n            name       : me.name || inputId,\n            disabled   : me.disabled,\n            readOnly   : me.readOnly,\n            value      : me.getRawValue(),\n            type       : type,\n            fieldCls   : me.fieldCls,\n            fieldStyle : me.getFieldStyle(),\n            tabIdx     : me.tabIndex,\n            typeCls    : Ext.baseCSSPrefix + 'form-' + (type === 'password' ? 'text' : type)\n        }, me.subTplData);\n\n        me.getInsertionRenderData(data, me.subTplInsertions);\n\n        return data;\n    },\n\n    afterFirstLayout: function() {\n        this.callParent();\n        var el = this.inputEl;\n        if (el) {\n            el.selectable();\n        }\n    },\n\n    applyRenderSelectors: function() {\n        var me = this;\n\n        me.callParent();\n\n        /**\n         * @property {Ext.Element} inputEl\n         * The input Element for this Field. Only available after the field has been rendered.\n         */\n        me.inputEl = me.el.getById(me.getInputId());\n    },\n\n    /**\n     * Gets the markup to be inserted into the outer template's bodyEl. For fields this is the actual input element.\n     */\n    getSubTplMarkup: function() {\n        return this.getTpl('fieldSubTpl').apply(this.getSubTplData());\n    },\n\n    initRenderTpl: function() {\n        var me = this;\n        if (!me.hasOwnProperty('renderTpl')) {\n            me.renderTpl = me.getTpl('labelableRenderTpl');\n        }\n        return me.callParent();\n    },\n\n    initRenderData: function() {\n        return Ext.applyIf(this.callParent(), this.getLabelableRenderData());\n    },\n\n    /**\n     * Set the {@link #fieldStyle CSS style} of the {@link #inputEl field input element}.\n     * @param {String/Object/Function} style The style(s) to apply. Should be a valid argument to {@link\n     * Ext.Element#applyStyles}.\n     */\n    setFieldStyle: function(style) {\n        var me = this,\n            inputEl = me.inputEl;\n        if (inputEl) {\n            inputEl.applyStyles(style);\n        }\n        me.fieldStyle = style;\n    },\n\n    getFieldStyle: function() {\n        return 'width:100%;' + (Ext.isObject(this.fieldStyle) ? Ext.DomHelper.generateStyles(this.fieldStyle) : this.fieldStyle ||'');\n    },\n\n    // private\n    onRender : function() {\n        var me = this;\n        me.callParent(arguments);\n        me.onLabelableRender();\n        me.renderActiveError();\n    },\n\n    getFocusEl: function() {\n        return this.inputEl;\n    },\n\n    isFileUpload: function() {\n        return this.inputType === 'file';\n    },\n\n    extractFileInput: function() {\n        var me = this,\n            fileInput = me.isFileUpload() ? me.inputEl.dom : null,\n            clone;\n        if (fileInput) {\n            clone = fileInput.cloneNode(true);\n            fileInput.parentNode.replaceChild(clone, fileInput);\n            me.inputEl = Ext.get(clone);\n        }\n        return fileInput;\n    },\n\n    // private override to use getSubmitValue() as a convenience\n    getSubmitData: function() {\n        var me = this,\n            data = null,\n            val;\n        if (!me.disabled && me.submitValue && !me.isFileUpload()) {\n            val = me.getSubmitValue();\n            if (val !== null) {\n                data = {};\n                data[me.getName()] = val;\n            }\n        }\n        return data;\n    },\n\n    /**\n     * Returns the value that would be included in a standard form submit for this field. This will be combined with the\n     * field's name to form a name=value pair in the {@link #getSubmitData submitted parameters}. If an empty string is\n     * returned then just the name= will be submitted; if null is returned then nothing will be submitted.\n     *\n     * Note that the value returned will have been {@link #processRawValue processed} but may or may not have been\n     * successfully {@link #validate validated}.\n     *\n     * @return {String} The value to be submitted, or null.\n     */\n    getSubmitValue: function() {\n        return this.processRawValue(this.getRawValue());\n    },\n\n    /**\n     * Returns the raw value of the field, without performing any normalization, conversion, or validation. To get a\n     * normalized and converted value see {@link #getValue}.\n     * @return {String} value The raw String value of the field\n     */\n    getRawValue: function() {\n        var me = this,\n            v = (me.inputEl ? me.inputEl.getValue() : Ext.value(me.rawValue, ''));\n        me.rawValue = v;\n        return v;\n    },\n\n    /**\n     * Sets the field's raw value directly, bypassing {@link #valueToRaw value conversion}, change detection, and\n     * validation. To set the value with these additional inspections see {@link #setValue}.\n     * @param {Object} value The value to set\n     * @return {Object} value The field value that is set\n     */\n    setRawValue: function(value) {\n        var me = this;\n        value = Ext.value(me.transformRawValue(value), '');\n        me.rawValue = value;\n\n        // Some Field subclasses may not render an inputEl\n        if (me.inputEl) {\n            me.inputEl.dom.value = value;\n        }\n        return value;\n    },\n    \n    /**\n     * Transform the raw value before it is set\n     * @protected\n     * @param {Object} value The value\n     * @return {Object} The value to set\n     */\n    transformRawValue: function(value) {\n        return value;\n    },\n\n    /**\n     * Converts a mixed-type value to a raw representation suitable for displaying in the field. This allows controlling\n     * how value objects passed to {@link #setValue} are shown to the user, including localization. For instance, for a\n     * {@link Ext.form.field.Date}, this would control how a Date object passed to {@link #setValue} would be converted\n     * to a String for display in the field.\n     *\n     * See {@link #rawToValue} for the opposite conversion.\n     *\n     * The base implementation simply does a standard toString conversion, and converts {@link Ext#isEmpty empty values}\n     * to an empty string.\n     *\n     * @param {Object} value The mixed-type value to convert to the raw representation.\n     * @return {Object} The converted raw value.\n     */\n    valueToRaw: function(value) {\n        return '' + Ext.value(value, '');\n    },\n\n    /**\n     * Converts a raw input field value into a mixed-type value that is suitable for this particular field type. This\n     * allows controlling the normalization and conversion of user-entered values into field-type-appropriate values,\n     * e.g. a Date object for {@link Ext.form.field.Date}, and is invoked by {@link #getValue}.\n     *\n     * It is up to individual implementations to decide how to handle raw values that cannot be successfully converted\n     * to the desired object type.\n     *\n     * See {@link #valueToRaw} for the opposite conversion.\n     *\n     * The base implementation does no conversion, returning the raw value untouched.\n     *\n     * @param {Object} rawValue\n     * @return {Object} The converted value.\n     */\n    rawToValue: function(rawValue) {\n        return rawValue;\n    },\n\n    /**\n     * Performs any necessary manipulation of a raw field value to prepare it for {@link #rawToValue conversion} and/or\n     * {@link #validate validation}, for instance stripping out ignored characters. In the base implementation it does\n     * nothing; individual subclasses may override this as needed.\n     *\n     * @param {Object} value The unprocessed string value\n     * @return {Object} The processed string value\n     */\n    processRawValue: function(value) {\n        return value;\n    },\n\n    /**\n     * Returns the current data value of the field. The type of value returned is particular to the type of the\n     * particular field (e.g. a Date object for {@link Ext.form.field.Date}), as the result of calling {@link #rawToValue} on\n     * the field's {@link #processRawValue processed} String value. To return the raw String value, see {@link #getRawValue}.\n     * @return {Object} value The field value\n     */\n    getValue: function() {\n        var me = this,\n            val = me.rawToValue(me.processRawValue(me.getRawValue()));\n        me.value = val;\n        return val;\n    },\n\n    /**\n     * Sets a data value into the field and runs the change detection and validation. To set the value directly\n     * without these inspections see {@link #setRawValue}.\n     * @param {Object} value The value to set\n     * @return {Ext.form.field.Field} this\n     */\n    setValue: function(value) {\n        var me = this;\n        me.setRawValue(me.valueToRaw(value));\n        return me.mixins.field.setValue.call(me, value);\n    },\n\n    onBoxReady: function() {\n        var me = this;\n        me.callParent();\n        \n        if (me.setReadOnlyOnBoxReady) {\n            me.setReadOnly(me.readOnly);\n        }\n            \n    },\n\n    //private\n    onDisable: function() {\n        var me = this,\n            inputEl = me.inputEl;\n            \n        me.callParent();\n        if (inputEl) {\n            inputEl.dom.disabled = true;\n            if (me.hasActiveError()) {\n                // clear invalid state since the field is now disabled\n                me.clearInvalid();\n                me.needsValidateOnEnable = true;\n            }\n        }\n    },\n\n    //private\n    onEnable: function() {\n        var me = this,\n            inputEl = me.inputEl;\n            \n        me.callParent();\n        if (inputEl) {\n            inputEl.dom.disabled = false;\n            if (me.needsValidateOnEnable) {\n                delete me.needsValidateOnEnable;\n                // will trigger errors to be shown\n                me.forceValidation = true;\n                me.isValid();\n                delete me.forceValidation;\n            }\n        }\n    },\n\n    /**\n     * Sets the read only state of this field.\n     * @param {Boolean} readOnly Whether the field should be read only.\n     */\n    setReadOnly: function(readOnly) {\n        var me = this,\n            inputEl = me.inputEl;\n        readOnly = !!readOnly;\n        me[readOnly ? 'addCls' : 'removeCls'](me.readOnlyCls);\n        me.readOnly = readOnly;\n        if (inputEl) {\n            inputEl.dom.readOnly = readOnly;\n        } else if (me.rendering) {\n            me.setReadOnlyOnBoxReady = true;\n        }\n        me.fireEvent('writeablechange', me, readOnly);\n    },\n\n    // private\n    fireKey: function(e){\n        if(e.isSpecialKey()){\n            this.fireEvent('specialkey', this, new Ext.EventObjectImpl(e));\n        }\n    },\n\n    // private\n    initEvents : function(){\n        var me = this,\n            inputEl = me.inputEl,\n            onChangeTask,\n            onChangeEvent,\n            events = me.checkChangeEvents,\n            e,\n            eLen   = events.length,\n            event;\n\n        // standardise buffer across all browsers + OS-es for consistent event order.\n        // (the 10ms buffer for Editors fixes a weird FF/Win editor issue when changing OS window focus)\n        if (me.inEditor) {\n            me.onBlur = Ext.Function.createBuffered(me.onBlur, 10);\n        }\n        if (inputEl) {\n            me.mon(inputEl, Ext.EventManager.getKeyEvent(), me.fireKey,  me);\n\n            // listen for immediate value changes\n            onChangeTask = new Ext.util.DelayedTask(me.checkChange, me);\n            me.onChangeEvent = onChangeEvent = function() {\n                onChangeTask.delay(me.checkChangeBuffer);\n            };\n\n            for (e = 0; e < eLen; e++) {\n                event = events[e];\n\n                if (event === 'propertychange') {\n                    me.usesPropertychange = true;\n                }\n\n                me.mon(inputEl, event, onChangeEvent);\n            }\n        }\n        me.callParent();\n    },\n\n    doComponentLayout: function() {\n        var me = this,\n            inputEl = me.inputEl,\n            usesPropertychange = me.usesPropertychange,\n            ename = 'propertychange',\n            onChangeEvent = me.onChangeEvent;\n\n        // In IE if propertychange is one of the checkChangeEvents, we need to remove\n        // the listener prior to layout and re-add it after, to prevent it from firing\n        // needlessly for attribute and style changes applied to the inputEl.\n        if (usesPropertychange) {\n            me.mun(inputEl, ename, onChangeEvent);\n        }\n        me.callParent(arguments);\n        if (usesPropertychange) {\n            me.mon(inputEl, ename, onChangeEvent);\n        }\n    },\n\n    /**\n     * @private Called when the field's dirty state changes. Adds/removes the {@link #dirtyCls} on the main element.\n     * @param {Boolean} isDirty\n     */\n    onDirtyChange: function(isDirty) {\n        this[isDirty ? 'addCls' : 'removeCls'](this.dirtyCls);\n    },\n\n\n    /**\n     * Returns whether or not the field value is currently valid by {@link #getErrors validating} the\n     * {@link #processRawValue processed raw value} of the field. **Note**: {@link #disabled} fields are\n     * always treated as valid.\n     *\n     * @return {Boolean} True if the value is valid, else false\n     */\n    isValid : function() {\n        var me = this,\n            disabled = me.disabled,\n            validate = me.forceValidation || !disabled;\n            \n        \n        return validate ? me.validateValue(me.processRawValue(me.getRawValue())) : disabled;\n    },\n\n\n    /**\n     * Uses {@link #getErrors} to build an array of validation errors. If any errors are found, they are passed to\n     * {@link #markInvalid} and false is returned, otherwise true is returned.\n     *\n     * Previously, subclasses were invited to provide an implementation of this to process validations - from 3.2\n     * onwards {@link #getErrors} should be overridden instead.\n     *\n     * @param {Object} value The value to validate\n     * @return {Boolean} True if all validations passed, false if one or more failed\n     */\n    validateValue: function(value) {\n        var me = this,\n            errors = me.getErrors(value),\n            isValid = Ext.isEmpty(errors);\n        if (!me.preventMark) {\n            if (isValid) {\n                me.clearInvalid();\n            } else {\n                me.markInvalid(errors);\n            }\n        }\n\n        return isValid;\n    },\n\n    /**\n     * Display one or more error messages associated with this field, using {@link #msgTarget} to determine how to\n     * display the messages and applying {@link #invalidCls} to the field's UI element.\n     *\n     * **Note**: this method does not cause the Field's {@link #validate} or {@link #isValid} methods to return `false`\n     * if the value does _pass_ validation. So simply marking a Field as invalid will not prevent submission of forms\n     * submitted with the {@link Ext.form.action.Submit#clientValidation} option set.\n     *\n     * @param {String/String[]} errors The validation message(s) to display.\n     */\n    markInvalid : function(errors) {\n        // Save the message and fire the 'invalid' event\n        var me = this,\n            oldMsg = me.getActiveError();\n        me.setActiveErrors(Ext.Array.from(errors));\n        if (oldMsg !== me.getActiveError()) {\n            me.updateLayout();\n        }\n    },\n\n    /**\n     * Clear any invalid styles/messages for this field.\n     *\n     * **Note**: this method does not cause the Field's {@link #validate} or {@link #isValid} methods to return `true`\n     * if the value does not _pass_ validation. So simply clearing a field's errors will not necessarily allow\n     * submission of forms submitted with the {@link Ext.form.action.Submit#clientValidation} option set.\n     */\n    clearInvalid : function() {\n        // Clear the message and fire the 'valid' event\n        var me = this,\n            hadError = me.hasActiveError();\n        me.unsetActiveError();\n        if (hadError) {\n            me.updateLayout();\n        }\n    },\n\n    /**\n     * @private Overrides the method from the Ext.form.Labelable mixin to also add the invalidCls to the inputEl,\n     * as that is required for proper styling in IE with nested fields (due to lack of child selector)\n     */\n    renderActiveError: function() {\n        var me = this,\n            hasError = me.hasActiveError();\n        if (me.inputEl) {\n            // Add/remove invalid class\n            me.inputEl[hasError ? 'addCls' : 'removeCls'](me.invalidCls + '-field');\n        }\n        me.mixins.labelable.renderActiveError.call(me);\n    },\n\n\n    getActionEl: function() {\n        return this.inputEl || this.el;\n    }\n\n});\n\n/**\n * @singleton\n * @alternateClassName Ext.form.VTypes\n *\n * This is a singleton object which contains a set of commonly used field validation functions\n * and provides a mechanism for creating reusable custom field validations.\n * The following field validation functions are provided out of the box:\n *\n * - {@link #alpha}\n * - {@link #alphanum}\n * - {@link #email}\n * - {@link #url}\n *\n * VTypes can be applied to a {@link Ext.form.field.Text Text Field} using the `{@link Ext.form.field.Text#vtype vtype}` configuration:\n *\n *     Ext.create('Ext.form.field.Text', {\n *         fieldLabel: 'Email Address',\n *         name: 'email',\n *         vtype: 'email' // applies email validation rules to this field\n *     });\n *\n * To create custom VTypes:\n *\n *     // custom Vtype for vtype:'time'\n *     var timeTest = /^([1-9]|1[0-9]):([0-5][0-9])(\\s[a|p]m)$/i;\n *     Ext.apply(Ext.form.field.VTypes, {\n *         //  vtype validation function\n *         time: function(val, field) {\n *             return timeTest.test(val);\n *         },\n *         // vtype Text property: The error text to display when the validation function returns false\n *         timeText: 'Not a valid time.  Must be in the format \"12:34 PM\".',\n *         // vtype Mask property: The keystroke filter mask\n *         timeMask: /[\\d\\s:amp]/i\n *     });\n *\n * In the above example the `time` function is the validator that will run when field validation occurs,\n * `timeText` is the error message, and `timeMask` limits what characters can be typed into the field.\n * Note that the `Text` and `Mask` functions must begin with the same name as the validator function.\n *\n * Using a custom validator is the same as using one of the build-in validators - just use the name of the validator function\n * as the `{@link Ext.form.field.Text#vtype vtype}` configuration on a {@link Ext.form.field.Text Text Field}:\n *\n *     Ext.create('Ext.form.field.Text', {\n *         fieldLabel: 'Departure Time',\n *         name: 'departureTime',\n *         vtype: 'time' // applies custom time validation rules to this field\n *     });\n *\n * Another example of a custom validator:\n *\n *     // custom Vtype for vtype:'IPAddress'\n *     Ext.apply(Ext.form.field.VTypes, {\n *         IPAddress:  function(v) {\n *             return /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/.test(v);\n *         },\n *         IPAddressText: 'Must be a numeric IP address',\n *         IPAddressMask: /[\\d\\.]/i\n *     });\n *\n * It's important to note that using {@link Ext#apply Ext.apply()} means that the custom validator function\n * as well as `Text` and `Mask` fields are added as properties of the `Ext.form.field.VTypes` singleton.\n */\nExt.define('Ext.form.field.VTypes', (function(){\n    // closure these in so they are only created once.\n    var alpha = /^[a-zA-Z_]+$/,\n        alphanum = /^[a-zA-Z0-9_]+$/,\n        email = /^(\\w+)([\\-+.][\\w]+)*@(\\w[\\-\\w]*\\.){1,5}([A-Za-z]){2,6}$/,\n        url = /(((^https?)|(^ftp)):\\/\\/([\\-\\w]+\\.)+\\w{2,3}(\\/[%\\-\\w]+(\\.\\w{2,})?)*(([\\w\\-\\.\\?\\\\\\/+@&#;`~=%!]*)(\\.\\w{2,})?)*\\/?)/i;\n\n    // All these messages and functions are configurable\n    return {\n        singleton: true,\n        alternateClassName: 'Ext.form.VTypes',\n\n        /**\n         * The function used to validate email addresses. Note that this is a very basic validation - complete\n         * validation per the email RFC specifications is very complex and beyond the scope of this class, although this\n         * function can be overridden if a more comprehensive validation scheme is desired. See the validation section\n         * of the [Wikipedia article on email addresses][1] for additional information. This implementation is intended\n         * to validate the following emails:\n         *\n         * - `barney@example.de`\n         * - `barney.rubble@example.com`\n         * - `barney-rubble@example.coop`\n         * - `barney+rubble@example.com`\n         *\n         * [1]: http://en.wikipedia.org/wiki/E-mail_address\n         *\n         * @param {String} value The email address\n         * @return {Boolean} true if the RegExp test passed, and false if not.\n         */\n        'email' : function(v){\n            return email.test(v);\n        },\n        //<locale>\n        /**\n         * @property {String} emailText\n         * The error text to display when the email validation function returns false.\n         * Defaults to: 'This field should be an e-mail address in the format \"user@example.com\"'\n         */\n        'emailText' : 'This field should be an e-mail address in the format \"user@example.com\"',\n        //</locale>\n        /**\n         * @property {RegExp} emailMask\n         * The keystroke filter mask to be applied on email input. See the {@link #email} method for information about\n         * more complex email validation. Defaults to: /[a-z0-9_\\.\\-@]/i\n         */\n        'emailMask' : /[a-z0-9_\\.\\-@\\+]/i,\n\n        /**\n         * The function used to validate URLs\n         * @param {String} value The URL\n         * @return {Boolean} true if the RegExp test passed, and false if not.\n         */\n        'url' : function(v){\n            return url.test(v);\n        },\n        //<locale>\n        /**\n         * @property {String} urlText\n         * The error text to display when the url validation function returns false.\n         * Defaults to: 'This field should be a URL in the format \"http:/'+'/www.example.com\"'\n         */\n        'urlText' : 'This field should be a URL in the format \"http:/'+'/www.example.com\"',\n        //</locale>\n\n        /**\n         * The function used to validate alpha values\n         * @param {String} value The value\n         * @return {Boolean} true if the RegExp test passed, and false if not.\n         */\n        'alpha' : function(v){\n            return alpha.test(v);\n        },\n        //<locale>\n        /**\n         * @property {String} alphaText\n         * The error text to display when the alpha validation function returns false.\n         * Defaults to: 'This field should only contain letters and _'\n         */\n        'alphaText' : 'This field should only contain letters and _',\n        //</locale>\n        /**\n         * @property {RegExp} alphaMask\n         * The keystroke filter mask to be applied on alpha input. Defaults to: /[a-z_]/i\n         */\n        'alphaMask' : /[a-z_]/i,\n\n        /**\n         * The function used to validate alphanumeric values\n         * @param {String} value The value\n         * @return {Boolean} true if the RegExp test passed, and false if not.\n         */\n        'alphanum' : function(v){\n            return alphanum.test(v);\n        },\n        //<locale>\n        /**\n         * @property {String} alphanumText\n         * The error text to display when the alphanumeric validation function returns false.\n         * Defaults to: 'This field should only contain letters, numbers and _'\n         */\n        'alphanumText' : 'This field should only contain letters, numbers and _',\n        //</locale>\n        /**\n         * @property {RegExp} alphanumMask\n         * The keystroke filter mask to be applied on alphanumeric input. Defaults to: /[a-z0-9_]/i\n         */\n        'alphanumMask' : /[a-z0-9_]/i\n    };\n}()));\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * A basic text field.  Can be used as a direct replacement for traditional text inputs,\n * or as the base class for more sophisticated input controls (like {@link Ext.form.field.TextArea}\n * and {@link Ext.form.field.ComboBox}). Has support for empty-field placeholder values (see {@link #emptyText}).\n *\n * # Validation\n *\n * The Text field has a useful set of validations built in:\n *\n * - {@link #allowBlank} for making the field required\n * - {@link #minLength} for requiring a minimum value length\n * - {@link #maxLength} for setting a maximum value length (with {@link #enforceMaxLength} to add it\n *   as the `maxlength` attribute on the input element)\n * - {@link #regex} to specify a custom regular expression for validation\n *\n * In addition, custom validations may be added:\n *\n * - {@link #vtype} specifies a virtual type implementation from {@link Ext.form.field.VTypes} which can contain\n *   custom validation logic\n * - {@link #validator} allows a custom arbitrary function to be called during validation\n *\n * The details around how and when each of these validation options get used are described in the\n * documentation for {@link #getErrors}.\n *\n * By default, the field value is checked for validity immediately while the user is typing in the\n * field. This can be controlled with the {@link #validateOnChange}, {@link #checkChangeEvents}, and\n * {@link #checkChangeBuffer} configurations. Also see the details on Form Validation in the\n * {@link Ext.form.Panel} class documentation.\n *\n * # Masking and Character Stripping\n *\n * Text fields can be configured with custom regular expressions to be applied to entered values before\n * validation: see {@link #maskRe} and {@link #stripCharsRe} for details.\n *\n * # Example usage\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Contact Info',\n *         width: 300,\n *         bodyPadding: 10,\n *         renderTo: Ext.getBody(),\n *         items: [{\n *             xtype: 'textfield',\n *             name: 'name',\n *             fieldLabel: 'Name',\n *             allowBlank: false  // requires a non-empty value\n *         }, {\n *             xtype: 'textfield',\n *             name: 'email',\n *             fieldLabel: 'Email Address',\n *             vtype: 'email'  // requires value to be a valid email address format\n *         }]\n *     });\n */\nExt.define('Ext.form.field.Text', {\n    extend:'Ext.form.field.Base',\n    alias: 'widget.textfield',\n    requires: ['Ext.form.field.VTypes', 'Ext.layout.component.field.Text'],\n    alternateClassName: ['Ext.form.TextField', 'Ext.form.Text'],\n\n    /**\n     * @cfg {String} vtypeText\n     * A custom error message to display in place of the default message provided for the **`{@link #vtype}`** currently\n     * set for this field. **Note**: only applies if **`{@link #vtype}`** is set, else ignored.\n     */\n\n    /**\n     * @cfg {RegExp} stripCharsRe\n     * A JavaScript RegExp object used to strip unwanted content from the value\n     * during input. If `stripCharsRe` is specified,\n     * every *character sequence* matching `stripCharsRe` will be removed.\n     */\n\n    /**\n     * @cfg {Number} size\n     * An initial value for the 'size' attribute on the text input element. This is only used if the field has no\n     * configured {@link #width} and is not given a width by its container's layout. Defaults to 20.\n     */\n    size: 20,\n\n    /**\n     * @cfg {Boolean} [grow=false]\n     * true if this field should automatically grow and shrink to its content\n     */\n\n    /**\n     * @cfg {Number} growMin\n     * The minimum width to allow when `{@link #grow} = true`\n     */\n    growMin : 30,\n\n    /**\n     * @cfg {Number} growMax\n     * The maximum width to allow when `{@link #grow} = true`\n     */\n    growMax : 800,\n\n    //<locale>\n    /**\n     * @cfg {String} growAppend\n     * A string that will be appended to the field's current value for the purposes of calculating the target field\n     * size. Only used when the {@link #grow} config is true. Defaults to a single capital \"W\" (the widest character in\n     * common fonts) to leave enough space for the next typed character and avoid the field value shifting before the\n     * width is adjusted.\n     */\n    growAppend: 'W',\n    //</locale>\n\n    /**\n     * @cfg {String} vtype\n     * A validation type name as defined in {@link Ext.form.field.VTypes}\n     */\n\n    /**\n     * @cfg {RegExp} maskRe An input mask regular expression that will be used to filter keystrokes (character being\n     * typed) that do not match.\n     * Note: It does not filter characters already in the input.\n     */\n\n    /**\n     * @cfg {Boolean} [disableKeyFilter=false]\n     * Specify true to disable input keystroke filtering\n     */\n\n    /**\n     * @cfg {Boolean} allowBlank\n     * Specify false to validate that the value's length is > 0\n     */\n    allowBlank : true,\n\n    /**\n     * @cfg {Number} minLength\n     * Minimum input field length required\n     */\n    minLength : 0,\n\n    /**\n     * @cfg {Number} maxLength\n     * Maximum input field length allowed by validation. This behavior is intended to\n     * provide instant feedback to the user by improving usability to allow pasting and editing or overtyping and back\n     * tracking. To restrict the maximum number of characters that can be entered into the field use the\n     * **{@link Ext.form.field.Text#enforceMaxLength enforceMaxLength}** option.\n     *\n     * Defaults to Number.MAX_VALUE.\n     */\n    maxLength : Number.MAX_VALUE,\n\n    /**\n     * @cfg {Boolean} enforceMaxLength\n     * True to set the maxLength property on the underlying input field. Defaults to false\n     */\n\n    /**\n     * @cfg {String} minLengthText\n     * Error text to display if the **{@link #minLength minimum length}** validation fails.\n     */\n    //<locale>\n    minLengthText : 'The minimum length for this field is {0}',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} maxLengthText\n     * Error text to display if the **{@link #maxLength maximum length}** validation fails\n     */\n    maxLengthText : 'The maximum length for this field is {0}',\n    //</locale>\n\n    /**\n     * @cfg {Boolean} [selectOnFocus=false]\n     * true to automatically select any existing field text when the field receives input focus\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} blankText\n     * The error text to display if the **{@link #allowBlank}** validation fails\n     */\n    blankText : 'This field is required',\n    //</locale>\n\n    /**\n     * @cfg {Function} validator\n     * A custom validation function to be called during field validation ({@link #getErrors}).\n     * If specified, this function will be called first, allowing the developer to override the default validation\n     * process.\n     *\n     * This function will be passed the following parameters:\n     *\n     * @cfg {Object} validator.value The current field value\n     * @cfg {Boolean/String} validator.return\n     *\n     * - True if the value is valid\n     * - An error message if the value is invalid\n     */\n\n    /**\n     * @cfg {RegExp} regex\n     * A JavaScript RegExp object to be tested against the field value during validation.\n     * If the test fails, the field will be marked invalid using\n     * either **{@link #regexText}** or **{@link #invalidText}**.\n     */\n\n    /**\n     * @cfg {String} regexText\n     * The error text to display if **{@link #regex}** is used and the test fails during validation\n     */\n    regexText : '',\n\n    /**\n     * @cfg {String} emptyText\n     * The default text to place into an empty field.\n     *\n     * Note that normally this value will be submitted to the server if this field is enabled; to prevent this you can\n     * set the {@link Ext.form.action.Action#submitEmptyText submitEmptyText} option of {@link Ext.form.Basic#submit} to\n     * false.\n     *\n     * Also note that if you use {@link #inputType inputType}:'file', {@link #emptyText} is not supported and should be\n     * avoided.\n     *\n     * Note that for browsers that support it, setting this property will use the HTML 5 placeholder attribute, and for\n     * older browsers that don't support the HTML 5 placeholder attribute the value will be placed directly into the input\n     * element itself as the raw value. This means that older browsers will obfuscate the {@link #emptyText} value for\n     * password input fields.\n     */\n\n    /**\n     * @cfg {String} [emptyCls='x-form-empty-field']\n     * The CSS class to apply to an empty field to style the **{@link #emptyText}**.\n     * This class is automatically added and removed as needed depending on the current field value.\n     */\n    emptyCls : Ext.baseCSSPrefix + 'form-empty-field',\n\n    /**\n     * @cfg {String} [requiredCls='x-form-required-field']\n     * The CSS class to apply to a required field, i.e. a field where **{@link #allowBlank}** is false.\n     */\n    requiredCls : Ext.baseCSSPrefix + 'form-required-field',\n\n    /**\n     * @cfg {Boolean} [enableKeyEvents=false]\n     * true to enable the proxying of key events for the HTML input field\n     */\n\n    componentLayout: 'textfield',\n\n    // private\n    valueContainsPlaceholder : false,\n\n\n    initComponent: function () {\n        var me = this;\n\n        me.callParent();\n\n        me.addEvents(\n            /**\n             * @event autosize\n             * Fires when the **{@link #autoSize}** function is triggered and the field is resized according to the\n             * {@link #grow}/{@link #growMin}/{@link #growMax} configs as a result. This event provides a hook for the\n             * developer to apply additional logic at runtime to resize the field if needed.\n             * @param {Ext.form.field.Text} this This text field\n             * @param {Number} width The new field width\n             */\n            'autosize',\n\n            /**\n             * @event keydown\n             * Keydown input field event. This event only fires if **{@link #enableKeyEvents}** is set to true.\n             * @param {Ext.form.field.Text} this This text field\n             * @param {Ext.EventObject} e\n             */\n            'keydown',\n            /**\n             * @event keyup\n             * Keyup input field event. This event only fires if **{@link #enableKeyEvents}** is set to true.\n             * @param {Ext.form.field.Text} this This text field\n             * @param {Ext.EventObject} e\n             */\n            'keyup',\n            /**\n             * @event keypress\n             * Keypress input field event. This event only fires if **{@link #enableKeyEvents}** is set to true.\n             * @param {Ext.form.field.Text} this This text field\n             * @param {Ext.EventObject} e\n             */\n            'keypress'\n        );\n        me.addStateEvents('change');\n        me.setGrowSizePolicy();\n    },\n\n    // private\n    setGrowSizePolicy: function(){\n        if (this.grow) {\n            this.shrinkWrap |= 1; // width must shrinkWrap\n        }    \n    },\n\n    // private\n    initEvents : function(){\n        var me = this,\n            el = me.inputEl;\n\n        me.callParent();\n        if(me.selectOnFocus || me.emptyText){\n            me.mon(el, 'mousedown', me.onMouseDown, me);\n        }\n        if(me.maskRe || (me.vtype && me.disableKeyFilter !== true && (me.maskRe = Ext.form.field.VTypes[me.vtype+'Mask']))){\n            me.mon(el, 'keypress', me.filterKeys, me);\n        }\n\n        if (me.enableKeyEvents) {\n            me.mon(el, {\n                scope: me,\n                keyup: me.onKeyUp,\n                keydown: me.onKeyDown,\n                keypress: me.onKeyPress\n            });\n        }\n    },\n\n    /**\n     * @private\n     * Override. Treat undefined and null values as equal to an empty string value.\n     */\n    isEqual: function(value1, value2) {\n        return this.isEqualAsString(value1, value2);\n    },\n\n    /**\n     * @private\n     * If grow=true, invoke the autoSize method when the field's value is changed.\n     */\n    onChange: function() {\n        this.callParent();\n        this.autoSize();\n    },\n\n    getSubTplData: function() {\n        var me = this,\n            value = me.getRawValue(),\n            isEmpty = me.emptyText && value.length < 1,\n            maxLength = me.maxLength,\n            placeholder;\n            \n        // We can't just dump the value here, since MAX_VALUE ends up\n        // being something like 1.xxxxe+300, which gets interpreted as 1\n        // in the markup\n        if (me.enforceMaxLength) {\n            if (maxLength === Number.MAX_VALUE) {\n                maxLength = undefined;\n            }\n        } else {\n            maxLength = undefined;\n        }\n\n        if (isEmpty) {\n            if (Ext.supports.Placeholder) {\n                placeholder = me.emptyText;\n            } else {\n                value = me.emptyText;\n                me.valueContainsPlaceholder = true;\n            }\n        }\n\n        return Ext.apply(me.callParent(), {\n            maxLength   : maxLength,\n            readOnly    : me.readOnly,\n            placeholder : placeholder,\n            value       : value,\n            fieldCls    : me.fieldCls + ((isEmpty && (placeholder || value)) ? ' ' + me.emptyCls : '') + (me.allowBlank ? '' :  ' ' + me.requiredCls)\n        });\n    },\n\n    afterRender: function(){\n        this.autoSize();\n        this.callParent();\n    },\n\n    onMouseDown: function(e){\n        var me = this;\n        if(!me.hasFocus){\n            me.mon(me.inputEl, 'mouseup', Ext.emptyFn, me, { single: true, preventDefault: true });\n        }\n    },\n\n    /**\n     * Performs any necessary manipulation of a raw String value to prepare it for conversion and/or\n     * {@link #validate validation}. For text fields this applies the configured {@link #stripCharsRe}\n     * to the raw value.\n     * @param {String} value The unprocessed string value\n     * @return {String} The processed string value\n     */\n    processRawValue: function(value) {\n        var me = this,\n            stripRe = me.stripCharsRe,\n            newValue;\n\n        if (stripRe) {\n            newValue = value.replace(stripRe, '');\n            if (newValue !== value) {\n                me.setRawValue(newValue);\n                value = newValue;\n            }\n        }\n        return value;\n    },\n\n    //private\n    onDisable: function(){\n        this.callParent();\n        if (Ext.isIE) {\n            this.inputEl.dom.unselectable = 'on';\n        }\n    },\n\n    //private\n    onEnable: function(){\n        this.callParent();\n        if (Ext.isIE) {\n            this.inputEl.dom.unselectable = '';\n        }\n    },\n\n    onKeyDown: function(e) {\n        this.fireEvent('keydown', this, e);\n    },\n\n    onKeyUp: function(e) {\n        this.fireEvent('keyup', this, e);\n    },\n\n    onKeyPress: function(e) {\n        this.fireEvent('keypress', this, e);\n    },\n\n    /**\n     * Resets the current field value to the originally-loaded value and clears any validation messages.\n     * Also adds **{@link #emptyText}** and **{@link #emptyCls}** if the original value was blank.\n     */\n    reset : function(){\n        this.callParent();\n        this.applyEmptyText();\n    },\n\n    applyEmptyText : function(){\n        var me = this,\n            emptyText = me.emptyText,\n            isEmpty;\n\n        if (me.rendered && emptyText) {\n            isEmpty = me.getRawValue().length < 1 && !me.hasFocus;\n\n            if (Ext.supports.Placeholder) {\n                me.inputEl.dom.placeholder = emptyText;\n            } else if (isEmpty) {\n                me.setRawValue(emptyText);\n                me.valueContainsPlaceholder = true;\n            }\n\n            //all browsers need this because of a styling issue with chrome + placeholders.\n            //the text isnt vertically aligned when empty (and using the placeholder)\n            if (isEmpty) {\n                me.inputEl.addCls(me.emptyCls);\n            }\n\n            me.autoSize();\n        }\n    },\n    \n    afterFirstLayout: function() {\n        this.callParent();\n        if (Ext.isIE && this.disabled) {\n            var el = this.inputEl;\n            if (el) {\n                el.dom.unselectable = 'on';\n            }\n        }\n    },\n    \n    // private\n    preFocus : function(){\n        var me = this,\n            inputEl = me.inputEl,\n            emptyText = me.emptyText,\n            isEmpty;\n\n        me.callParent(arguments);\n        if ((emptyText && !Ext.supports.Placeholder) && (inputEl.dom.value === me.emptyText && me.valueContainsPlaceholder)) {\n            me.setRawValue('');\n            isEmpty = true;\n            inputEl.removeCls(me.emptyCls);\n            me.valueContainsPlaceholder = false;\n        } else if (Ext.supports.Placeholder) {\n            me.inputEl.removeCls(me.emptyCls);\n        }\n        if (me.selectOnFocus || isEmpty) {\n            inputEl.dom.select();\n        }\n    },\n\n    onFocus: function() {\n        var me = this;\n        me.callParent(arguments);\n        if (me.emptyText) {\n            me.autoSize();\n        }\n    },\n\n    // private\n    postBlur : function(){\n        this.callParent(arguments);\n        this.applyEmptyText();\n    },\n\n    // private\n    filterKeys : function(e){\n        /*\n         * On European keyboards, the right alt key, Alt Gr, is used to type certain special characters.\n         * JS detects a keypress of this as ctrlKey & altKey. As such, we check that alt isn't pressed\n         * so we can still process these special characters.\n         */\n        if (e.ctrlKey && !e.altKey) {\n            return;\n        }\n        var key = e.getKey(),\n            charCode = String.fromCharCode(e.getCharCode());\n\n        if((Ext.isGecko || Ext.isOpera) && (e.isNavKeyPress() || key === e.BACKSPACE || (key === e.DELETE && e.button === -1))){\n            return;\n        }\n\n        if((!Ext.isGecko && !Ext.isOpera) && e.isSpecialKey() && !charCode){\n            return;\n        }\n        if(!this.maskRe.test(charCode)){\n            e.stopEvent();\n        }\n    },\n\n    getState: function() {\n        return this.addPropertyToState(this.callParent(), 'value');\n    },\n\n    applyState: function(state) {\n        this.callParent(arguments);\n        if(state.hasOwnProperty('value')) {\n            this.setValue(state.value);\n        }\n    },\n\n    /**\n     * Returns the raw String value of the field, without performing any normalization, conversion, or validation. Gets\n     * the current value of the input element if the field has been rendered, ignoring the value if it is the\n     * {@link #emptyText}. To get a normalized and converted value see {@link #getValue}.\n     * @return {String} The raw String value of the field\n     */\n    getRawValue: function() {\n        var me = this,\n            v = me.callParent();\n        if (v === me.emptyText && me.valueContainsPlaceholder) {\n            v = '';\n        }\n        return v;\n    },\n\n    /**\n     * Sets a data value into the field and runs the change detection and validation. Also applies any configured\n     * {@link #emptyText} for text fields. To set the value directly without these inspections see {@link #setRawValue}.\n     * @param {Object} value The value to set\n     * @return {Ext.form.field.Text} this\n     */\n    setValue: function(value) {\n        var me = this,\n            inputEl = me.inputEl;\n\n        if (inputEl && me.emptyText && !Ext.isEmpty(value)) {\n            inputEl.removeCls(me.emptyCls);\n            me.valueContainsPlaceholder = false;\n        }\n\n        me.callParent(arguments);\n\n        me.applyEmptyText();\n        return me;\n    },\n\n    /**\n     * Validates a value according to the field's validation rules and returns an array of errors\n     * for any failing validations. Validation rules are processed in the following order:\n     *\n     * 1. **Field specific validator**\n     *\n     *     A validator offers a way to customize and reuse a validation specification.\n     *     If a field is configured with a `{@link #validator}`\n     *     function, it will be passed the current field value.  The `{@link #validator}`\n     *     function is expected to return either:\n     *\n     *     - Boolean `true`  if the value is valid (validation continues).\n     *     - a String to represent the invalid message if invalid (validation halts).\n     *\n     * 2. **Basic Validation**\n     *\n     *     If the `{@link #validator}` has not halted validation,\n     *     basic validation proceeds as follows:\n     *\n     *     - `{@link #allowBlank}` : (Invalid message = `{@link #blankText}`)\n     *\n     *         Depending on the configuration of `{@link #allowBlank}`, a\n     *         blank field will cause validation to halt at this step and return\n     *         Boolean true or false accordingly.\n     *\n     *     - `{@link #minLength}` : (Invalid message = `{@link #minLengthText}`)\n     *\n     *         If the passed value does not satisfy the `{@link #minLength}`\n     *         specified, validation halts.\n     *\n     *     -  `{@link #maxLength}` : (Invalid message = `{@link #maxLengthText}`)\n     *\n     *         If the passed value does not satisfy the `{@link #maxLength}`\n     *         specified, validation halts.\n     *\n     * 3. **Preconfigured Validation Types (VTypes)**\n     *\n     *     If none of the prior validation steps halts validation, a field\n     *     configured with a `{@link #vtype}` will utilize the\n     *     corresponding {@link Ext.form.field.VTypes VTypes} validation function.\n     *     If invalid, either the field's `{@link #vtypeText}` or\n     *     the VTypes vtype Text property will be used for the invalid message.\n     *     Keystrokes on the field will be filtered according to the VTypes\n     *     vtype Mask property.\n     *\n     * 4. **Field specific regex test**\n     *\n     *     If none of the prior validation steps halts validation, a field's\n     *     configured `{@link #regex}` test will be processed.\n     *     The invalid message for this test is configured with `{@link #regexText}`\n     *\n     * @param {Object} value The value to validate. The processed raw value will be used if nothing is passed.\n     * @return {String[]} Array of any validation errors\n     */\n    getErrors: function(value) {\n        var me = this,\n            errors = me.callParent(arguments),\n            validator = me.validator,\n            emptyText = me.emptyText,\n            allowBlank = me.allowBlank,\n            vtype = me.vtype,\n            vtypes = Ext.form.field.VTypes,\n            regex = me.regex,\n            format = Ext.String.format,\n            msg;\n\n        value = value || me.processRawValue(me.getRawValue());\n\n        if (Ext.isFunction(validator)) {\n            msg = validator.call(me, value);\n            if (msg !== true) {\n                errors.push(msg);\n            }\n        }\n\n        if (value.length < 1 || (value === me.emptyText && me.valueContainsPlaceholder)) {\n            if (!allowBlank) {\n                errors.push(me.blankText);\n            }\n            //if value is blank, there cannot be any additional errors\n            return errors;\n        }\n\n        if (value.length < me.minLength) {\n            errors.push(format(me.minLengthText, me.minLength));\n        }\n\n        if (value.length > me.maxLength) {\n            errors.push(format(me.maxLengthText, me.maxLength));\n        }\n\n        if (vtype) {\n            if(!vtypes[vtype](value, me)){\n                errors.push(me.vtypeText || vtypes[vtype +'Text']);\n            }\n        }\n\n        if (regex && !regex.test(value)) {\n            errors.push(me.regexText || me.invalidText);\n        }\n\n        return errors;\n    },\n\n    /**\n     * Selects text in this field\n     * @param {Number} [start=0] The index where the selection should start\n     * @param {Number} [end] The index where the selection should end (defaults to the text length)\n     */\n    selectText : function(start, end){\n        var me = this,\n            v = me.getRawValue(),\n            doFocus = true,\n            el = me.inputEl.dom,\n            undef,\n            range;\n\n        if (v.length > 0) {\n            start = start === undef ? 0 : start;\n            end = end === undef ? v.length : end;\n            if (el.setSelectionRange) {\n                el.setSelectionRange(start, end);\n            }\n            else if(el.createTextRange) {\n                range = el.createTextRange();\n                range.moveStart('character', start);\n                range.moveEnd('character', end - v.length);\n                range.select();\n            }\n            doFocus = Ext.isGecko || Ext.isOpera;\n        }\n        if (doFocus) {\n            me.focus();\n        }\n    },\n\n    /**\n     * Automatically grows the field to accomodate the width of the text up to the maximum field width allowed. This\n     * only takes effect if {@link #grow} = true, and fires the {@link #autosize} event if the width changes.\n     */\n    autoSize: function() {\n        var me = this;\n        if (me.grow && me.rendered) {\n            me.autoSizing = true;\n            me.updateLayout();\n        }\n    },\n\n    afterComponentLayout: function() {\n        var me = this,\n            width;\n\n        me.callParent(arguments);\n        if (me.autoSizing) {\n            width = me.inputEl.getWidth();\n            if (width !== me.lastInputWidth) {\n                me.fireEvent('autosize', me, width);\n                me.lastInputWidth = width;\n                delete me.autoSizing;\n            }\n        }\n    }\n});\n\n/**\n * Layout class for {@link Ext.form.field.TextArea} fields. Handles sizing the textarea field.\n * @private\n */\nExt.define('Ext.layout.component.field.TextArea', {\n    extend: 'Ext.layout.component.field.Text',\n    alias: 'layout.textareafield',\n\n    type: 'textareafield',\n    \n    canGrowWidth: false,\n    \n    naturalSizingProp: 'cols',\n    \n    beginLayout: function(ownerContext){\n        this.callParent(arguments);\n        ownerContext.target.inputEl.setStyle('height', '');\n    },\n\n    measureContentHeight: function (ownerContext) {\n        var me = this,\n            owner = me.owner,\n            height = me.callParent(arguments),\n            inputContext, inputEl, value, max, curWidth, calcHeight;\n\n        if (owner.grow && !ownerContext.state.growHandled) {\n            inputContext = ownerContext.inputContext;\n            inputEl = owner.inputEl;\n            curWidth = inputEl.getWidth(true); //subtract border/padding to get the available width for the text\n\n            // Get and normalize the field value for measurement\n            value = Ext.util.Format.htmlEncode(inputEl.dom.value) || '&#160;';\n            value += owner.growAppend;\n            \n            // Translate newlines to <br> tags\n            value = value.replace(/\\n/g, '<br/>');\n\n            // Find the height that contains the whole text value\n            calcHeight = Ext.util.TextMetrics.measure(inputEl, value, curWidth).height +\n                         inputContext.getBorderInfo().height + inputContext.getPaddingInfo().height;\n\n            // Constrain\n            calcHeight = Ext.Number.constrain(calcHeight, owner.growMin, owner.growMax);\n            inputContext.setHeight(calcHeight);\n            ownerContext.state.growHandled = true;\n            \n            // Now that we've set the inputContext, we need to recalculate the width\n            inputContext.domBlock(me, 'height');\n            height = NaN;\n        }\n        return height;\n    }\n});\n\n/**\n * @docauthor Robert Dougan <rob@sencha.com>\n *\n * This class creates a multiline text field, which can be used as a direct replacement for traditional\n * textarea fields. In addition, it supports automatically {@link #grow growing} the height of the textarea to\n * fit its content.\n *\n * All of the configuration options from {@link Ext.form.field.Text} can be used on TextArea.\n *\n * Example usage:\n *\n *     @example\n *     Ext.create('Ext.form.FormPanel', {\n *         title      : 'Sample TextArea',\n *         width      : 400,\n *         bodyPadding: 10,\n *         renderTo   : Ext.getBody(),\n *         items: [{\n *             xtype     : 'textareafield',\n *             grow      : true,\n *             name      : 'message',\n *             fieldLabel: 'Message',\n *             anchor    : '100%'\n *         }]\n *     });\n *\n * Some other useful configuration options when using {@link #grow} are {@link #growMin} and {@link #growMax}.\n * These allow you to set the minimum and maximum grow heights for the textarea.\n * \n * **NOTE:** In some browsers, carriage returns ('\\r', not to be confused with new lines)\n * will be automatically stripped out the value is set to the textarea. Since we cannot\n * use any reasonable method to attempt to re-insert these, they will automatically be\n * stripped out to ensure the behaviour is consistent across browser.\n */\nExt.define('Ext.form.field.TextArea', {\n    extend:'Ext.form.field.Text',\n    alias: ['widget.textareafield', 'widget.textarea'],\n    alternateClassName: 'Ext.form.TextArea',\n    requires: [\n        'Ext.XTemplate', \n        'Ext.layout.component.field.TextArea',\n        'Ext.util.DelayedTask'\n    ],\n\n    // This template includes a \\n after <textarea> opening tag so that an initial value starting \n    // with \\n does not lose its first character when the markup is parsed.\n    // Both textareas below have the same value:\n    // <textarea>initial value</textarea>\n    // <textarea>\n    // initial value\n    // </textarea>\n    fieldSubTpl: [\n        '<textarea id=\"{id}\" {inputAttrTpl}',\n            '<tpl if=\"name\"> name=\"{name}\"</tpl>',\n            '<tpl if=\"rows\"> rows=\"{rows}\" </tpl>',\n            '<tpl if=\"cols\"> cols=\"{cols}\" </tpl>',\n            '<tpl if=\"placeholder\"> placeholder=\"{placeholder}\"</tpl>',\n            '<tpl if=\"size\"> size=\"{size}\"</tpl>',\n            '<tpl if=\"maxLength !== undefined\"> maxlength=\"{maxLength}\"</tpl>',\n            '<tpl if=\"readOnly\"> readonly=\"readonly\"</tpl>',\n            '<tpl if=\"disabled\"> disabled=\"disabled\"</tpl>',\n            '<tpl if=\"tabIdx\"> tabIndex=\"{tabIdx}\"</tpl>',\n            ' class=\"{fieldCls} {typeCls}\" ',\n            '<tpl if=\"fieldStyle\"> style=\"{fieldStyle}\"</tpl>',\n            ' autocomplete=\"off\">\\n',\n            '<tpl if=\"value\">{[Ext.util.Format.htmlEncode(values.value)]}</tpl>',\n        '</textarea>',\n        {\n            disableFormats: true\n        }\n    ],\n\n    /**\n     * @cfg {Number} growMin\n     * The minimum height to allow when {@link #grow}=true\n     */\n    growMin: 60,\n\n    /**\n     * @cfg {Number} growMax\n     * The maximum height to allow when {@link #grow}=true\n     */\n    growMax: 1000,\n\n    /**\n     * @cfg {String} growAppend\n     * A string that will be appended to the field's current value for the purposes of calculating the target field\n     * size. Only used when the {@link #grow} config is true. Defaults to a newline for TextArea to ensure there is\n     * always a space below the current line.\n     */\n    growAppend: '\\n-',\n\n    /**\n     * @cfg {Number} cols\n     * An initial value for the 'cols' attribute on the textarea element. This is only used if the component has no\n     * configured {@link #width} and is not given a width by its container's layout.\n     */\n    cols: 20,\n\n    /**\n     * @cfg {Number} rows\n     * An initial value for the 'rows' attribute on the textarea element. This is only used if the component has no\n     * configured {@link #height} and is not given a height by its container's layout. Defaults to 4.\n     */\n    rows: 4,\n\n    /**\n     * @cfg {Boolean} enterIsSpecial\n     * True if you want the ENTER key to be classed as a special key and the {@link #specialkey} event to be fired\n     * when ENTER is pressed.\n     */\n    enterIsSpecial: false,\n\n    /**\n     * @cfg {Boolean} preventScrollbars\n     * true to prevent scrollbars from appearing regardless of how much text is in the field. This option is only\n     * relevant when {@link #grow} is true. Equivalent to setting overflow: hidden.\n     */\n    preventScrollbars: false,\n\n    // private\n    componentLayout: 'textareafield',\n    \n    setGrowSizePolicy: Ext.emptyFn,\n    \n    returnRe: /\\r/g,\n\n    // private\n    getSubTplData: function() {\n        var me = this,\n            fieldStyle = me.getFieldStyle(),\n            ret = me.callParent();\n\n        if (me.grow) {\n            if (me.preventScrollbars) {\n                ret.fieldStyle = (fieldStyle||'') + ';overflow:hidden;height:' + me.growMin + 'px';\n            }\n        }\n\n        Ext.applyIf(ret, {\n            cols: me.cols,\n            rows: me.rows\n        });\n\n        return ret;\n    },\n\n    afterRender: function () {\n        var me = this;\n\n        me.callParent(arguments);\n\n        me.needsMaxCheck = me.enforceMaxLength && me.maxLength !== Number.MAX_VALUE && !Ext.supports.TextAreaMaxLength;\n        if (me.needsMaxCheck) {\n            me.inputEl.on('paste', me.onPaste, me);\n        }\n    },\n    \n    // The following overrides deal with an issue whereby some browsers\n    // will strip carriage returns from the textarea input, while others\n    // will not. Since there's no way to be sure where to insert returns,\n    // the best solution is to strip them out in all cases to ensure that\n    // the behaviour is consistent in a cross browser fashion. As such,\n    // we override in all cases when setting the value to control this.\n    transformRawValue: function(value){\n        return this.stripReturns(value);\n    },\n    \n    transformOriginalValue: function(value){\n        return this.stripReturns(value); \n    },\n    \n    valueToRaw: function(value){\n        value = this.stripReturns(value);\n        return this.callParent([value]);\n    },\n    \n    stripReturns: function(value){\n        if (value) {\n            value = value.replace(this.returnRe, '');\n        }\n        return value;\n    },\n\n    onPaste: function(e){\n        var me = this;\n        if (!me.pasteTask) {\n            me.pasteTask = new Ext.util.DelayedTask(me.pasteCheck, me);\n        }\n        // since we can't get the paste data, we'll give the area a chance to populate\n        me.pasteTask.delay(1);\n    },\n    \n    pasteCheck: function(){\n        var me = this,\n            value = me.getValue(),\n            max = me.maxLength;\n            \n        if (value.length > max) {\n            value = value.substr(0, max);\n            me.setValue(value);\n        }\n    },\n\n    // private\n    fireKey: function(e) {\n        var me = this,\n            key = e.getKey(),\n            value;\n            \n        if (e.isSpecialKey() && (me.enterIsSpecial || (key !== e.ENTER || e.hasModifier()))) {\n            me.fireEvent('specialkey', me, e);\n        }\n        \n        if (me.needsMaxCheck && key !== e.BACKSPACE && key !== e.DELETE && !e.isNavKeyPress() && !me.isCutCopyPasteSelectAll(e, key)) {\n            value = me.getValue();\n            if (value.length >= me.maxLength) {\n                e.stopEvent();\n            }\n        }\n    },\n    \n    isCutCopyPasteSelectAll: function(e, key) {\n        if (e.CTRL) {\n            return key === e.A || key === e.C || key === e.V || key === e.X;\n        }\n        return false;\n    },\n\n    /**\n     * Automatically grows the field to accomodate the height of the text up to the maximum field height allowed. This\n     * only takes effect if {@link #grow} = true, and fires the {@link #autosize} event if the height changes.\n     */\n    autoSize: function() {\n        var me = this,\n            height;\n\n        if (me.grow && me.rendered) {\n            me.updateLayout();\n            height = me.inputEl.getHeight();\n            if (height !== me.lastInputHeight) {\n                /**\n                 * @event autosize\n                 * Fires when the {@link #autoSize} function is triggered and the field is resized according to\n                 * the grow/growMin/growMax configs as a result. This event provides a hook for the developer\n                 * to apply additional logic at runtime to resize the field if needed.\n                 * @param {Ext.form.field.Text} this\n                 * @param {Number} height\n                 */\n                me.fireEvent('autosize', me, height);\n                me.lastInputHeight = height;\n            }\n        }\n    },\n\n    // private\n    initAria: function() {\n        this.callParent(arguments);\n        this.getActionEl().dom.setAttribute('aria-multiline', true);\n    },\n    \n    beforeDestroy: function(){\n        var task = this.pasteTask;\n        if (task) {\n            task.delay();\n        }    \n        this.callParent();\n    }\n});\n\n/**\n * A display-only text field which is not validated and not submitted. This is useful for when you want to display a\n * value from a form's {@link Ext.form.Basic#load loaded data} but do not want to allow the user to edit or submit that\n * value. The value can be optionally {@link #htmlEncode HTML encoded} if it contains HTML markup that you do not want\n * to be rendered.\n *\n * If you have more complex content, or need to include components within the displayed content, also consider using a\n * {@link Ext.form.FieldContainer} instead.\n *\n * Example:\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         renderTo: Ext.getBody(),\n *         width: 175,\n *         height: 120,\n *         bodyPadding: 10,\n *         title: 'Final Score',\n *         items: [{\n *             xtype: 'displayfield',\n *             fieldLabel: 'Home',\n *             name: 'home_score',\n *             value: '10'\n *         }, {\n *             xtype: 'displayfield',\n *             fieldLabel: 'Visitor',\n *             name: 'visitor_score',\n *             value: '11'\n *         }],\n *         buttons: [{\n *             text: 'Update'\n *         }]\n *     });\n */\nExt.define('Ext.form.field.Display', {\n    extend:'Ext.form.field.Base',\n    alias: 'widget.displayfield',\n    requires: ['Ext.util.Format', 'Ext.XTemplate'],\n    alternateClassName: ['Ext.form.DisplayField', 'Ext.form.Display'],\n    fieldSubTpl: [\n        '<div id=\"{id}\"',\n        '<tpl if=\"fieldStyle\"> style=\"{fieldStyle}\"</tpl>', \n        ' class=\"{fieldCls}\">{value}</div>',\n        {\n            compiled: true,\n            disableFormats: true\n        }\n    ],\n\n    /**\n     * @cfg {String} [fieldCls=\"x-form-display-field\"]\n     * The default CSS class for the field.\n     */\n    fieldCls: Ext.baseCSSPrefix + 'form-display-field',\n\n    /**\n     * @cfg {Boolean} htmlEncode\n     * True to escape HTML in text when rendering it.\n     */\n    htmlEncode: false,\n    \n    /**\n     * @cfg {Function} renderer\n     * A function to transform the raw value for display in the field. The function will receive 2 arguments, the raw value\n     * and the {@link Ext.form.field.Display} object.\n     */\n    \n    /**\n     * @cfg {Object} scope\n     * The scope to execute the {@link #renderer} function. Defaults to this.\n     */\n\n    validateOnChange: false,\n\n    initEvents: Ext.emptyFn,\n\n    submitValue: false,\n    \n    isDirty: function(){\n        return false;\n    },\n\n    isValid: function() {\n        return true;\n    },\n\n    validate: function() {\n        return true;\n    },\n\n    getRawValue: function() {\n        return this.rawValue;\n    },\n\n    setRawValue: function(value) {\n        var me = this,\n            display;\n            \n        value = Ext.value(value, '');\n        me.rawValue = value;\n        if (me.rendered) {\n            me.inputEl.dom.innerHTML = me.getDisplayValue();\n            me.updateLayout();\n        }\n        return value;\n    },\n\n    /**\n     * @private\n     * Format the value to display.\n     */\n    getDisplayValue: function() {\n        var me = this,\n            value = this.getRawValue(),\n            display;\n        if (me.renderer) {\n             display = me.renderer.call(me.scope || me, value, me);\n        } else {\n             display = me.htmlEncode ? Ext.util.Format.htmlEncode(value) : value;\n        }\n        return display;\n    },\n        \n    getSubTplData: function() {\n        var ret = this.callParent(arguments);\n\n        ret.value = this.getDisplayValue();\n\n        return ret;\n    }\n\n    /**\n     * @cfg {String} inputType\n     * @private\n     */\n    /**\n     * @cfg {Boolean} disabled\n     * @private\n     */\n    /**\n     * @cfg {Boolean} readOnly\n     * @private\n     */\n    /**\n     * @cfg {Boolean} validateOnChange\n     * @private\n     */\n    /**\n     * @cfg {Number} checkChangeEvents\n     * @private\n     */\n    /**\n     * @cfg {Number} checkChangeBuffer\n     * @private\n     */\n});\n\n/**\n * This is a layout that enables anchoring of contained elements relative to the container's dimensions.\n * If the container is resized, all anchored items are automatically rerendered according to their\n * `{@link #anchor}` rules.\n *\n * This class is intended to be extended or created via the {@link Ext.container.AbstractContainer#layout layout}: 'anchor' \n * config, and should generally not need to be created directly via the new keyword.\n * \n * AnchorLayout does not have any direct config options (other than inherited ones). By default,\n * AnchorLayout will calculate anchor measurements based on the size of the container itself. However, the\n * container using the AnchorLayout can supply an anchoring-specific config property of `anchorSize`.\n *\n * If anchorSize is specifed, the layout will use it as a virtual container for the purposes of calculating\n * anchor measurements based on it instead, allowing the container to be sized independently of the anchoring\n * logic if necessary.\n *\n *     @example\n *     Ext.create('Ext.Panel', {\n *         width: 500,\n *         height: 400,\n *         title: \"AnchorLayout Panel\",\n *         layout: 'anchor',\n *         renderTo: Ext.getBody(),\n *         items: [\n *             {\n *                 xtype: 'panel',\n *                 title: '75% Width and 20% Height',\n *                 anchor: '75% 20%'\n *             },\n *             {\n *                 xtype: 'panel',\n *                 title: 'Offset -300 Width & -200 Height',\n *                 anchor: '-300 -200'\t\t\n *             },\n *             {\n *                 xtype: 'panel',\n *                 title: 'Mixed Offset and Percent',\n *                 anchor: '-250 20%'\n *             }\n *         ]\n *     });\n */\nExt.define('Ext.layout.container.Anchor', {\n\n    /* Begin Definitions */\n\n    alias: 'layout.anchor',\n    extend: 'Ext.layout.container.Container',\n    alternateClassName: 'Ext.layout.AnchorLayout',\n\n    /* End Definitions */\n\n    type: 'anchor',\n\n    manageOverflow: 2,\n\n    renderTpl: [\n        '{%this.renderBody(out,values);this.renderPadder(out,values)%}'\n    ],\n\n    /**\n     * @cfg {String} anchor\n     *\n     * This configuation option is to be applied to **child `items`** of a container managed by\n     * this layout (ie. configured with `layout:'anchor'`).\n     *\n     * This value is what tells the layout how an item should be anchored to the container. `items`\n     * added to an AnchorLayout accept an anchoring-specific config property of **anchor** which is a string\n     * containing two values: the horizontal anchor value and the vertical anchor value (for example, '100% 50%').\n     * The following types of anchor values are supported:\n     *\n     * - **Percentage** : Any value between 1 and 100, expressed as a percentage.\n     *\n     *   The first anchor is the percentage width that the item should take up within the container, and the\n     *   second is the percentage height.  For example:\n     *\n     *       // two values specified\n     *       anchor: '100% 50%' // render item complete width of the container and\n     *                          // 1/2 height of the container\n     *       // one value specified\n     *       anchor: '100%'     // the width value; the height will default to auto\n     *\n     * - **Offsets** : Any positive or negative integer value.\n     *\n     *   This is a raw adjustment where the first anchor is the offset from the right edge of the container,\n     *   and the second is the offset from the bottom edge. For example:\n     *\n     *       // two values specified\n     *       anchor: '-50 -100' // render item the complete width of the container\n     *                          // minus 50 pixels and\n     *                          // the complete height minus 100 pixels.\n     *       // one value specified\n     *       anchor: '-50'      // anchor value is assumed to be the right offset value\n     *                          // bottom offset will default to 0\n     *\n     * - **Sides** : Valid values are `right` (or `r`) and `bottom` (or `b`).\n     *\n     *   Either the container must have a fixed size or an anchorSize config value defined at render time in\n     *   order for these to have any effect.\n     *   \n     * - **Mixed** :\n     *\n     *   Anchor values can also be mixed as needed.  For example, to render the width offset from the container\n     *   right edge by 50 pixels and 75% of the container's height use:\n     *   \n     *       anchor:   '-50 75%'\n     */\n\n    /**\n     * @cfg {String} defaultAnchor\n     * Default anchor for all child **container** items applied if no anchor or specific width is set on the child item.\n     */\n    defaultAnchor: '100%',\n\n    parseAnchorRE: /^(r|right|b|bottom)$/i,\n\n    beginLayout: function (ownerContext) {\n        var me = this,\n            dimensions = 0,\n            anchorSpec, childContext, childItems, i, length, target;\n\n        me.callParent(arguments);\n\n        childItems = ownerContext.childItems; // populated by callParent\n        length = childItems.length;\n\n        for (i = 0; i < length; ++i) {\n            childContext = childItems[i];\n            anchorSpec = childContext.target.anchorSpec;\n\n            if (anchorSpec) {\n                if (childContext.widthModel.calculated && anchorSpec.right) {\n                    dimensions |= 1;\n                }\n                if (childContext.heightModel.calculated && anchorSpec.bottom) {\n                    dimensions |= 2;\n                }\n\n                if (dimensions == 3) { // if (both dimensions in play)\n                    break;\n                }\n            }\n        }\n\n        ownerContext.anchorDimensions = dimensions;\n\n        // Work around WebKit RightMargin bug. We're going to inline-block all the children\n        // only ONCE and remove it when we're done\n        if (!Ext.supports.RightMargin && !me.rightMarginCleanerFn) {\n            target = ownerContext.targetContext.el; // targetContext is added by superclass\n\n            me.rightMarginCleanerFn = Ext.Element.getRightMarginFixCleaner(target);\n            target.addCls(Ext.baseCSSPrefix + 'inline-children');\n        }\n\n        me.sanityCheck(ownerContext);\n    },\n\n    calculate: function (ownerContext) {\n        var me = this,\n            containerSize = me.getContainerSize(ownerContext);\n\n        if (ownerContext.anchorDimensions !== ownerContext.state.calculatedAnchors) {\n            me.calculateAnchors(ownerContext, containerSize);\n        }\n\n        if (ownerContext.hasDomProp('containerChildrenDone')) {\n            // Once the child layouts are done we can determine the content sizes...\n\n            if (!containerSize.gotAll) {\n                me.done = false;\n            }\n\n            me.calculateContentSize(ownerContext, ownerContext.anchorDimensions);\n\n            if (me.done) {\n                me.calculateOverflow(ownerContext, containerSize, ownerContext.anchorDimensions);\n                return;\n            }\n        }\n\n        me.done = false;\n    },\n\n    calculateAnchors: function (ownerContext, containerSize) {\n        var me = this,\n            childItems = ownerContext.childItems,\n            length = childItems.length,\n            gotHeight = containerSize.gotHeight,\n            gotWidth = containerSize.gotWidth,\n            ownerHeight = containerSize.height,\n            ownerWidth = containerSize.width,\n            state = ownerContext.state,\n            calculatedAnchors = (gotWidth ? 1 : 0) | (gotHeight ? 2 : 0),\n            anchorSpec, childContext, childMargins, height, i, width;\n\n        state.calculatedAnchors = (state.calculatedAnchors || 0) | calculatedAnchors;\n\n        for (i = 0; i < length; i++) {\n            childContext = childItems[i];\n            childMargins = childContext.getMarginInfo();\n            anchorSpec = childContext.target.anchorSpec;\n\n            // Check widthModel in case \"defaults\" has applied an anchor to a component\n            // that also has width (which must win). If we did not make this check in this\n            // way, we would attempt to calculate a width where it had been configured.\n            //\n            if (gotWidth && childContext.widthModel.calculated) {\n                width = anchorSpec.right(ownerWidth) - childMargins.width;\n                width = me.adjustWidthAnchor(width, childContext);\n\n                childContext.setWidth(width);\n            }\n\n            // Repeat for height\n            if (gotHeight && childContext.heightModel.calculated) {\n                height = anchorSpec.bottom(ownerHeight) - childMargins.height;\n                height = me.adjustHeightAnchor(height, childContext);\n\n                childContext.setHeight(height);\n            }\n        }\n    },\n\n    finishedLayout: function (ownerContext) {\n        var cleanerFn = this.rightMarginCleanerFn;\n\n        if (cleanerFn) {\n            delete this.rightMarginCleanerFn;\n            ownerContext.targetContext.el.removeCls(Ext.baseCSSPrefix + 'inline-children');\n            cleanerFn();\n        }\n    },\n\n    sanityCheck: function (ownerContext) {\n        var shrinkWrapWidth = ownerContext.widthModel.shrinkWrap,\n            shrinkWrapHeight = ownerContext.heightModel.shrinkWrap,\n            children = ownerContext.childItems,\n            anchorSpec, comp, childContext,\n            i, length;\n\n        for (i = 0, length = children.length; i < length; ++i) {\n            childContext = children[i];\n            comp = childContext.target;\n            anchorSpec = comp.anchorSpec;\n\n            if (anchorSpec) {\n                if (childContext.widthModel.calculated && anchorSpec.right) {\n                    if (shrinkWrapWidth) {\n                        Ext.log({\n                            level: 'warn',\n                            msg: 'Right anchor on '+comp.id+' in shrinkWrap width container'\n                        });\n                    }\n                }\n\n                if (childContext.heightModel.calculated && anchorSpec.bottom) {\n                    if (shrinkWrapHeight) {\n                        Ext.log({\n                            level: 'warn',\n                            msg: 'Bottom anchor on '+comp.id+' in shrinkWrap height container'\n                        });\n                    }\n                }\n            }\n        }\n    },\n\n    // private\n    anchorFactory: {\n        offset: function (delta) {\n            return function(v) {\n                return v + delta;\n            };\n        },\n        ratio: function (ratio) {\n            return function(v) {\n                return Math.floor(v * ratio);\n            };\n        },\n        standard: function (diff) {\n            return function(v) {\n                return v - diff;\n            };\n        }\n    },\n\n    parseAnchor: function(a, start, cstart) {\n        if (a && a != 'none') {\n            var factory = this.anchorFactory,\n                delta;\n\n            if (this.parseAnchorRE.test(a)) {\n                return factory.standard(cstart - start);\n            }    \n            if (a.indexOf('%') != -1) {\n                return factory.ratio(parseFloat(a.replace('%', '')) * 0.01);\n            }    \n            delta = parseInt(a, 10);\n            if (!isNaN(delta)) {\n                return factory.offset(delta);\n            }\n        }\n        return null;\n    },\n\n    // private\n    adjustWidthAnchor: function(value, childContext) {\n        return value;\n    },\n\n    // private\n    adjustHeightAnchor: function(value, childContext) {\n        return value;\n    },\n\n    configureItem: function(item) {\n        var me = this,\n            owner = me.owner,\n            anchor= item.anchor,\n            anchorsArray,\n            anchorWidth,\n            anchorHeight;\n\n        me.callParent(arguments);\n\n        if (!item.anchor && item.items && !Ext.isNumber(item.width) && !(Ext.isIE6 && Ext.isStrict)) {\n            item.anchor = anchor = me.defaultAnchor;\n        }\n\n        /**\n         * @cfg {Number/Object} anchorSize\n         * Defines the anchoring size of container.\n         * Either a number to define the width of the container or an object with `width` and `height` fields.\n         * @member Ext.container.Container\n         */ \n        if (owner.anchorSize) {\n            if (typeof owner.anchorSize == 'number') {\n                anchorWidth = owner.anchorSize;\n            } else {\n                anchorWidth = owner.anchorSize.width;\n                anchorHeight = owner.anchorSize.height;\n            }\n        } else {\n            anchorWidth = owner.initialConfig.width;\n            anchorHeight = owner.initialConfig.height;\n        }\n\n        if (anchor) {\n            // cache all anchor values\n            anchorsArray = anchor.split(' ');\n            item.anchorSpec = {\n                right: me.parseAnchor(anchorsArray[0], item.initialConfig.width, anchorWidth),\n                bottom: me.parseAnchor(anchorsArray[1], item.initialConfig.height, anchorHeight)\n            };\n        }\n    },\n\n    sizePolicy: {\n        '': {\n            setsWidth: 0,\n            setsHeight: 0\n        },\n        b: {\n            setsWidth: 0,\n            setsHeight: 1\n        },\n        r: {\n            '': {\n                setsWidth: 1,\n                setsHeight: 0\n            },\n            b: {\n                setsWidth: 1,\n                setsHeight: 1\n\n            }\n        }\n    },\n\n    getItemSizePolicy: function (item) {\n        var anchorSpec = item.anchorSpec,\n            key = '',\n            policy = this.sizePolicy,\n            sizeModel;\n\n        if (anchorSpec) {\n            sizeModel = this.owner.getSizeModel();\n            if (anchorSpec.right && !sizeModel.width.shrinkWrap) {\n                policy = policy.r;\n            }\n            if (anchorSpec.bottom && !sizeModel.height.shrinkWrap) {\n                key = 'b';\n            }\n        }\n\n        return policy[key];\n    }\n});\n\n/**\n * Utility class for generating different styles of message boxes.  The singleton instance, Ext.MessageBox\n * alias `Ext.Msg` can also be used.\n *\n * Note that a MessageBox is asynchronous.  Unlike a regular JavaScript `alert` (which will halt\n * browser execution), showing a MessageBox will not cause the code to stop.  For this reason, if you have code\n * that should only run *after* some user feedback from the MessageBox, you must use a callback function\n * (see the `function` parameter for {@link #method-show} for more details).\n *\n * Basic alert\n *\n *     @example\n *     Ext.Msg.alert('Status', 'Changes saved successfully.');\n *\n * Prompt for user data and process the result using a callback\n *\n *     @example\n *     Ext.Msg.prompt('Name', 'Please enter your name:', function(btn, text){\n *         if (btn == 'ok'){\n *             // process text value and close...\n *         }\n *     });\n *\n * Show a dialog using config options\n *\n *     @example\n *     Ext.Msg.show({\n *          title:'Save Changes?',\n *          msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',\n *          buttons: Ext.Msg.YESNOCANCEL,\n *          icon: Ext.Msg.QUESTION\n *     });\n */\nExt.define('Ext.window.MessageBox', {\n    extend: 'Ext.window.Window',\n\n    requires: [\n        'Ext.toolbar.Toolbar',\n        'Ext.form.field.Text',\n        'Ext.form.field.TextArea',\n        'Ext.form.field.Display',\n        'Ext.button.Button',\n        'Ext.layout.container.Anchor',\n        'Ext.layout.container.HBox',\n        'Ext.ProgressBar'\n    ],\n\n    alias: 'widget.messagebox',\n\n    /**\n     * @property\n     * Button config that displays a single OK button\n     */\n    OK : 1,\n    /**\n     * @property\n     * Button config that displays a single Yes button\n     */\n    YES : 2,\n    /**\n     * @property\n     * Button config that displays a single No button\n     */\n    NO : 4,\n    /**\n     * @property\n     * Button config that displays a single Cancel button\n     */\n    CANCEL : 8,\n    /**\n     * @property\n     * Button config that displays OK and Cancel buttons\n     */\n    OKCANCEL : 9,\n    /**\n     * @property\n     * Button config that displays Yes and No buttons\n     */\n    YESNO : 6,\n    /**\n     * @property\n     * Button config that displays Yes, No and Cancel buttons\n     */\n    YESNOCANCEL : 14,\n    /**\n     * @property\n     * The CSS class that provides the INFO icon image\n     */\n    INFO : Ext.baseCSSPrefix + 'message-box-info',\n    /**\n     * @property\n     * The CSS class that provides the WARNING icon image\n     */\n    WARNING : Ext.baseCSSPrefix + 'message-box-warning',\n    /**\n     * @property\n     * The CSS class that provides the QUESTION icon image\n     */\n    QUESTION : Ext.baseCSSPrefix + 'message-box-question',\n    /**\n     * @property\n     * The CSS class that provides the ERROR icon image\n     */\n    ERROR : Ext.baseCSSPrefix + 'message-box-error',\n\n    // hide it by offsets. Windows are hidden on render by default.\n    hideMode: 'offsets',\n    closeAction: 'hide',\n    resizable: false,\n    title: '&#160;',\n\n    width: 600,\n    height: 500,\n    minWidth: 250,\n    maxWidth: 600,\n    minHeight: 110,\n    maxHeight: 500,\n    constrain: true,\n\n    cls: Ext.baseCSSPrefix + 'message-box',\n\n    layout: {\n        type: 'vbox',\n        align: 'stretch'\n    },\n\n    /**\n     * @property\n     * The default height in pixels of the message box's multiline textarea if displayed.\n     */\n    defaultTextHeight : 75,\n    /**\n     * @property\n     * The minimum width in pixels of the message box if it is a progress-style dialog.  This is useful\n     * for setting a different minimum width than text-only dialogs may need.\n     */\n    minProgressWidth : 250,\n    /**\n     * @property\n     * The minimum width in pixels of the message box if it is a prompt dialog.  This is useful\n     * for setting a different minimum width than text-only dialogs may need.\n     */\n    minPromptWidth: 250,\n    //<locale type=\"object\">\n    /**\n     * @property\n     * An object containing the default button text strings that can be overriden for localized language support.\n     * Supported properties are: ok, cancel, yes and no.  Generally you should include a locale-specific\n     * resource file for handling language support across the framework.\n     * Customize the default text like so:\n     *\n     *     Ext.window.MessageBox.buttonText.yes = \"oui\"; //french\n     */\n    buttonText: {\n        ok: 'OK',\n        yes: 'Yes',\n        no: 'No',\n        cancel: 'Cancel'\n    },\n    //</locale>\n\n    buttonIds: [\n        'ok', 'yes', 'no', 'cancel'\n    ],\n\n    //<locale type=\"object\">\n    titleText: {\n        confirm: 'Confirm',\n        prompt: 'Prompt',\n        wait: 'Loading...',\n        alert: 'Attention'\n    },\n    //</locale>\n\n    iconHeight: 35,\n\n    makeButton: function(btnIdx) {\n        var btnId = this.buttonIds[btnIdx];\n        return new Ext.button.Button({\n            handler: this.btnCallback,\n            itemId: btnId,\n            scope: this,\n            text: this.buttonText[btnId],\n            minWidth: 75\n        });\n    },\n\n    btnCallback: function(btn) {\n        var me = this,\n            value,\n            field;\n\n        if (me.cfg.prompt || me.cfg.multiline) {\n            if (me.cfg.multiline) {\n                field = me.textArea;\n            } else {\n                field = me.textField;\n            }\n            value = field.getValue();\n            field.reset();\n        }\n\n        // Important not to have focus remain in the hidden Window; Interferes with DnD.\n        btn.blur();\n        me.hide();\n        me.userCallback(btn.itemId, value, me.cfg);\n    },\n\n    hide: function() {\n        var me = this;\n        me.dd.endDrag();\n        me.progressBar.reset();\n        me.removeCls(me.cfg.cls);\n        me.callParent(arguments);\n    },\n\n    initComponent: function() {\n        var me = this,\n            baseId = me.id,\n            i, button,\n            tbLayout;\n\n        me.title = '&#160;';\n\n        me.topContainer = new Ext.container.Container({\n            layout: 'hbox',\n            style: {\n                padding: '10px',\n                overflow: 'hidden'\n            },\n            items: [\n                me.iconComponent = new Ext.Component({\n                    cls: me.baseCls + '-icon',\n                    width: 50,\n                    height: me.iconHeight\n                }),\n                me.promptContainer = new Ext.container.Container({\n                    flex: 1,\n                    layout: {\n                        type: 'anchor'\n                    },\n                    items: [\n                        me.msg = new Ext.form.field.Display({\n                            id: baseId + '-displayfield',\n                            cls: me.baseCls + '-text'\n                        }),\n                        me.textField = new Ext.form.field.Text({\n                            id: baseId + '-testfield',\n                            anchor: '100%',\n                            enableKeyEvents: true,\n                            listeners: {\n                                keydown: me.onPromptKey,\n                                scope: me\n                            }\n                        }),\n                        me.textArea = new Ext.form.field.TextArea({\n                            id: baseId + '-textarea',\n                            anchor: '100%',\n                            height: 75\n                        })\n                    ]\n                })\n            ]\n        });\n        me.progressBar = new Ext.ProgressBar({\n            id: baseId + '-progressbar',\n            margins: '0 10 0 10'\n        });\n\n        me.items = [me.topContainer, me.progressBar];\n\n        // Create the buttons based upon passed bitwise config\n        me.msgButtons = [];\n        for (i = 0; i < 4; i++) {\n            button = me.makeButton(i);\n            me.msgButtons[button.itemId] = button;\n            me.msgButtons.push(button);\n        }\n        me.bottomTb = new Ext.toolbar.Toolbar({\n            id: baseId + '-toolbar',\n            ui: 'footer',\n            dock: 'bottom',\n            layout: {\n                pack: 'center'\n            },\n            items: [\n                me.msgButtons[0],\n                me.msgButtons[1],\n                me.msgButtons[2],\n                me.msgButtons[3]\n            ]\n        });\n        me.dockedItems = [me.bottomTb];\n\n        // Get control at Toolbar's finishedLayout call and snag the contentWidth to contribute to our auto width calculation\n        tbLayout = me.bottomTb.getLayout();\n        tbLayout.finishedLayout = Ext.Function.createInterceptor(tbLayout.finishedLayout, function(ownerContext) {\n            me.tbWidth = ownerContext.getProp('contentWidth');\n        });\n        me.on('close', me.onClose, me);\n\n        me.callParent();\n    },\n    \n    onClose: function(){\n        var btn = this.header.child('[type=close]');\n        // Give a temporary itemId so it can act like the cancel button\n        btn.itemId = 'cancel';\n        this.btnCallback(btn);\n        delete btn.itemId;\n    },\n\n    onPromptKey: function(textField, e) {\n        var me = this,\n            blur;\n\n        if (e.keyCode === Ext.EventObject.RETURN || e.keyCode === 10) {\n            if (me.msgButtons.ok.isVisible()) {\n                blur = true;\n                me.msgButtons.ok.handler.call(me, me.msgButtons.ok);\n            } else if (me.msgButtons.yes.isVisible()) {\n                me.msgButtons.yes.handler.call(me, me.msgButtons.yes);\n                blur = true;\n            }\n\n            if (blur) {\n                me.textField.blur();\n            }\n        }\n    },\n\n    reconfigure: function(cfg) {\n        var me = this,\n            buttons = 0,\n            hideToolbar = true,\n            initialWidth = me.maxWidth,\n            oldButtonText = me.buttonText,\n            i;\n\n        // Restore default buttonText before reconfiguring.\n        me.updateButtonText();\n\n        cfg = cfg || {};\n        me.cfg = cfg;\n        if (cfg.width) {\n            initialWidth = cfg.width;\n        }\n\n        // Default to allowing the Window to take focus.\n        delete me.defaultFocus;\n\n        // clear any old animateTarget\n        me.animateTarget = cfg.animateTarget || undefined;\n\n        // Defaults to modal\n        me.modal = cfg.modal !== false;\n\n        // Show the title\n        if (cfg.title) {\n            me.setTitle(cfg.title||'&#160;');\n        }\n\n        // Extract button configs\n        if (Ext.isObject(cfg.buttons)) {\n            me.buttonText = cfg.buttons;\n            buttons = 0;\n        } else {\n            me.buttonText = cfg.buttonText || me.buttonText;\n            buttons = Ext.isNumber(cfg.buttons) ? cfg.buttons : 0;\n        }\n\n        // Apply custom-configured buttonText\n        // Infer additional buttons from the specified property names in the buttonText object\n        buttons = buttons | me.updateButtonText();\n\n        // Restore buttonText. Next run of reconfigure will restore to prototype's buttonText\n        me.buttonText = oldButtonText;\n\n        // During the on render, or size resetting layouts, and in subsequent hiding and showing, we need to\n        // suspend layouts, and flush at the end when the Window's children are at their final visibility.\n        Ext.suspendLayouts();\n        me.hidden = false;\n        if (!me.rendered) {\n            me.width = initialWidth;\n            me.render(Ext.getBody());\n        } else {\n            me.setSize(initialWidth, me.maxHeight);\n        }\n\n        // Hide or show the close tool\n        me.closable = cfg.closable && !cfg.wait;\n        me.header.child('[type=close]').setVisible(cfg.closable !== false);\n\n        // Hide or show the header\n        if (!cfg.title && !me.closable) {\n            me.header.hide();\n        } else {\n            me.header.show();\n        }\n\n        // Default to dynamic drag: drag the window, not a ghost\n        me.liveDrag = !cfg.proxyDrag;\n\n        // wrap the user callback\n        me.userCallback = Ext.Function.bind(cfg.callback ||cfg.fn || Ext.emptyFn, cfg.scope || Ext.global);\n\n        // Hide or show the icon Component\n        me.setIcon(cfg.icon);\n\n        // Hide or show the message area\n        if (cfg.msg) {\n            me.msg.setValue(cfg.msg);\n            me.msg.show();\n        } else {\n            me.msg.hide();\n        }\n\n        // flush the layout here to pick up\n        // height adjustments on the msg field\n        Ext.resumeLayouts(true);\n        Ext.suspendLayouts();\n\n        // Hide or show the input field\n        if (cfg.prompt || cfg.multiline) {\n            me.multiline = cfg.multiline;\n            if (cfg.multiline) {\n                me.textArea.setValue(cfg.value);\n                me.textArea.setHeight(cfg.defaultTextHeight || me.defaultTextHeight);\n                me.textArea.show();\n                me.textField.hide();\n                me.defaultFocus = me.textArea;\n            } else {\n                me.textField.setValue(cfg.value);\n                me.textArea.hide();\n                me.textField.show();\n                me.defaultFocus = me.textField;\n            }\n        } else {\n            me.textArea.hide();\n            me.textField.hide();\n        }\n\n        // Hide or show the progress bar\n        if (cfg.progress || cfg.wait) {\n            me.progressBar.show();\n            me.updateProgress(0, cfg.progressText);\n            if(cfg.wait === true){\n                me.progressBar.wait(cfg.waitConfig);\n            }\n        } else {\n            me.progressBar.hide();\n        }\n\n        // Hide or show buttons depending on flag value sent.\n        for (i = 0; i < 4; i++) {\n            if (buttons & Math.pow(2, i)) {\n\n                // Default to focus on the first visible button if focus not already set\n                if (!me.defaultFocus) {\n                    me.defaultFocus = me.msgButtons[i];\n                }\n                me.msgButtons[i].show();\n                hideToolbar = false;\n            } else {\n                me.msgButtons[i].hide();\n            }\n        }\n\n        // Hide toolbar if no buttons to show\n        if (hideToolbar) {\n            me.bottomTb.hide();\n        } else {\n            me.bottomTb.show();\n        }\n        Ext.resumeLayouts(true);\n    },\n\n    /**\n     * @private\n     * Set button text according to current buttonText property object\n     * @return {Number} The buttons bitwise flag based upon the button IDs specified in the buttonText property.\n     */\n    updateButtonText: function() {\n        var me = this,\n            buttonText = me.buttonText,\n            buttons = 0,\n            btnId,\n            btn;\n\n        for (btnId in buttonText) {\n            if (buttonText.hasOwnProperty(btnId)) {\n                btn = me.msgButtons[btnId];\n                if (btn) {\n                    if (me.cfg && me.cfg.buttonText) {\n                        buttons = buttons | Math.pow(2, Ext.Array.indexOf(me.buttonIds, btnId));\n                    }\n                    if (btn.text != buttonText[btnId]) {\n                        btn.setText(buttonText[btnId]);\n                    }\n                }\n            }\n        }\n        return buttons;\n    },\n\n    /**\n     * Displays a new message box, or reinitializes an existing message box, based on the config options passed in. All\n     * display functions (e.g. prompt, alert, etc.) on MessageBox call this function internally, although those calls\n     * are basic shortcuts and do not support all of the config options allowed here.\n     *\n     * Example usage:\n     *\n     *     Ext.Msg.show({\n     *         title: 'Address',\n     *         msg: 'Please enter your address:',\n     *         width: 300,\n     *         buttons: Ext.Msg.OKCANCEL,\n     *         multiline: true,\n     *         fn: saveAddress,\n     *         animateTarget: 'addAddressBtn',\n     *         icon: Ext.window.MessageBox.INFO\n     *     });\n     *\n     * @param {Object} config The following config options are supported:\n     *\n     * @param {String/Ext.dom.Element} config.animateTarget\n     * An id or Element from which the message box should animate as it opens and closes.\n     *\n     * @param {Number} [config.buttons=false]\n     * A bitwise button specifier consisting of the sum of any of the following constants:\n     *\n     *  - Ext.MessageBox.OK\n     *  - Ext.MessageBox.YES\n     *  - Ext.MessageBox.NO\n     *  - Ext.MessageBox.CANCEL\n     *\n     * Some common combinations have already been predefined:\n     *\n     *  - Ext.MessageBox.OKCANCEL\n     *  - Ext.MessageBox.YESNO\n     *  - Ext.MessageBox.YESNOCANCEL\n     *\n     * Or false to not show any buttons.\n     *\n     * This may also be specified as an object hash containing custom button text in the same format as the\n     * {@link #buttonText} config. Button IDs present as property names will be made visible.\n     *\n     * @param {Boolean} config.closable\n     * False to hide the top-right close button (defaults to true). Note that progress and wait dialogs will ignore this\n     * property and always hide the close button as they can only be closed programmatically.\n     *\n     * @param {String} config.cls\n     * A custom CSS class to apply to the message box's container element\n     *\n     * @param {Number} [config.defaultTextHeight=75]\n     * The default height in pixels of the message box's multiline textarea if displayed.\n     *\n     * @param {Function} config.fn\n     * A callback function which is called when the dialog is dismissed either by clicking on the configured buttons, or\n     * on the dialog close button, or by pressing the return button to enter input.\n     *\n     * Progress and wait dialogs will ignore this option since they do not respond to user actions and can only be\n     * closed programmatically, so any required function should be called by the same code after it closes the dialog.\n     * Parameters passed:\n     *\n     *  @param {String} config.fn.buttonId The ID of the button pressed, one of:\n     *\n     * - ok\n     * - yes\n     * - no\n     * - cancel\n     *\n     *  @param {String} config.fn.text Value of the input field if either `prompt` or `multiline` is true\n     *  @param {Object} config.fn.opt The config object passed to show.\n     *\n     * @param {Object} config.buttonText\n     * An object containing string properties which override the system-supplied button text values just for this\n     * invocation. The property names are:\n     *\n     * - ok\n     * - yes\n     * - no\n     * - cancel\n     *\n     * @param {Object} config.scope\n     * The scope (`this` reference) in which the function will be executed.\n     *\n     * @param {String} config.icon\n     * A CSS class that provides a background image to be used as the body icon for the dialog.\n     * One can use a predefined icon class:\n     *\n     *  - Ext.MessageBox.INFO\n     *  - Ext.MessageBox.WARNING\n     *  - Ext.MessageBox.QUESTION\n     *  - Ext.MessageBox.ERROR\n     *\n     * or use just any `'custom-class'`. Defaults to empty string.\n     *\n     * @param {String} config.iconCls\n     * The standard {@link Ext.window.Window#iconCls} to add an optional header icon (defaults to '')\n     *\n     * @param {Number} config.maxWidth\n     * The maximum width in pixels of the message box (defaults to 600)\n     *\n     * @param {Number} config.minWidth\n     * The minimum width in pixels of the message box (defaults to 100)\n     *\n     * @param {Boolean} config.modal\n     * False to allow user interaction with the page while the message box is displayed (defaults to true)\n     *\n     * @param {String} config.msg\n     * A string that will replace the existing message box body text (defaults to the XHTML-compliant non-breaking space\n     * character '&#160;')\n     *\n     * @param {Boolean} config.multiline\n     * True to prompt the user to enter multi-line text (defaults to false)\n     *\n     * @param {Boolean} config.progress\n     * True to display a progress bar (defaults to false)\n     *\n     * @param {String} config.progressText\n     * The text to display inside the progress bar if progress = true (defaults to '')\n     *\n     * @param {Boolean} config.prompt\n     * True to prompt the user to enter single-line text (defaults to false)\n     *\n     * @param {Boolean} config.proxyDrag\n     * True to display a lightweight proxy while dragging (defaults to false)\n     *\n     * @param {String} config.title\n     * The title text\n     *\n     * @param {String} config.value\n     * The string value to set into the active textbox element if displayed\n     *\n     * @param {Boolean} config.wait\n     * True to display a progress bar (defaults to false)\n     *\n     * @param {Object} config.waitConfig\n     * A {@link Ext.ProgressBar#wait} config object (applies only if wait = true)\n     *\n     * @param {Number} config.width\n     * The width of the dialog in pixels\n     *\n     * @return {Ext.window.MessageBox} this\n     */\n    show: function(cfg) {\n        var me = this;\n\n        me.reconfigure(cfg);\n        me.addCls(cfg.cls);\n        me.doAutoSize();\n\n        // Set the flag, so that the parent show method performs the show procedure that we need.\n        // ie: animation from animTarget, onShow processing and focusing.\n        me.hidden = true;\n        me.callParent();\n        return me;\n    },\n\n    onShow: function() {\n        this.callParent(arguments);\n        this.center();\n    },\n\n    doAutoSize: function() {\n        var me = this,\n            headerVisible = me.header.rendered && me.header.isVisible(),\n            footerVisible = me.bottomTb.rendered && me.bottomTb.isVisible(),\n            width,\n            height;\n\n        if (!Ext.isDefined(me.frameWidth)) {\n            me.frameWidth = me.el.getWidth() - me.body.getWidth();\n        }\n\n        // Allow per-invocation override of minWidth\n        me.minWidth = me.cfg.minWidth || Ext.getClass(this).prototype.minWidth;\n\n        // Width must be max of titleWidth, message+icon width, and total button width\n        width = Math.max(\n            headerVisible ? me.header.getMinWidth() : 0,                            // title width\n            me.cfg.width || me.msg.getWidth() + me.iconComponent.getWidth() + 25,   // msg + icon width + topContainer's layout padding */\n            (footerVisible ? me.tbWidth : 0)// total button width\n        );\n\n        height = (headerVisible ? me.header.getHeight() : 0) +\n            me.topContainer.getHeight() +\n            me.progressBar.getHeight() +\n            (footerVisible ? me.bottomTb.getHeight() + me.bottomTb.el.getMargin('tb') : 0);\n\n        me.setSize(width + me.frameWidth, height + me.frameWidth);\n        return me;\n    },\n\n    updateText: function(text) {\n        this.msg.setValue(text);\n        return this.doAutoSize(true);\n    },\n\n    /**\n     * Adds the specified icon to the dialog.  By default, the class 'x-messagebox-icon' is applied for default\n     * styling, and the class passed in is expected to supply the background image url. Pass in empty string ('')\n     * to clear any existing icon. This method must be called before the MessageBox is shown.\n     * The following built-in icon classes are supported, but you can also pass in a custom class name:\n     *\n     *     Ext.window.MessageBox.INFO\n     *     Ext.window.MessageBox.WARNING\n     *     Ext.window.MessageBox.QUESTION\n     *     Ext.window.MessageBox.ERROR\n     *\n     * @param {String} icon A CSS classname specifying the icon's background image url, or empty string to clear the icon\n     * @return {Ext.window.MessageBox} this\n     */\n    setIcon : function(icon) {\n        var me = this;\n        me.iconComponent.removeCls(me.messageIconCls);\n        if (icon) {\n            me.iconComponent.show();\n            me.iconComponent.addCls(Ext.baseCSSPrefix + 'dlg-icon');\n            me.iconComponent.addCls(me.messageIconCls = icon);\n        } else {\n            me.iconComponent.removeCls(Ext.baseCSSPrefix + 'dlg-icon');\n            me.iconComponent.hide();\n        }\n        return me;\n    },\n\n    /**\n     * Updates a progress-style message box's text and progress bar. Only relevant on message boxes\n     * initiated via {@link Ext.window.MessageBox#progress} or {@link Ext.window.MessageBox#wait},\n     * or by calling {@link Ext.window.MessageBox#method-show} with progress: true.\n     *\n     * @param {Number} [value=0] Any number between 0 and 1 (e.g., .5)\n     * @param {String} [progressText=''] The progress text to display inside the progress bar.\n     * @param {String} [msg] The message box's body text is replaced with the specified string (defaults to undefined\n     * so that any existing body text will not get overwritten by default unless a new value is passed in)\n     * @return {Ext.window.MessageBox} this\n     */\n    updateProgress : function(value, progressText, msg){\n        this.progressBar.updateProgress(value, progressText);\n        if (msg){\n            this.updateText(msg);\n        }\n        return this;\n    },\n\n    onEsc: function() {\n        if (this.closable !== false) {\n            this.callParent(arguments);\n        }\n    },\n\n    /**\n     * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's confirm).\n     * If a callback function is passed it will be called after the user clicks either button,\n     * and the id of the button that was clicked will be passed as the only parameter to the callback\n     * (could also be the top-right close button, which will always report as \"cancel\").\n     *\n     * @param {String} title The title bar text\n     * @param {String} msg The message box body text\n     * @param {Function} [fn] The callback function invoked after the message box is closed.\n     * See {@link #method-show} method for details.\n     * @param {Object} [scope=window] The scope (`this` reference) in which the callback is executed.\n     * @return {Ext.window.MessageBox} this\n     */\n    confirm: function(cfg, msg, fn, scope) {\n        if (Ext.isString(cfg)) {\n            cfg = {\n                title: cfg,\n                icon: this.QUESTION,\n                msg: msg,\n                buttons: this.YESNO,\n                callback: fn,\n                scope: scope\n            };\n        }\n        return this.show(cfg);\n    },\n\n    /**\n     * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's prompt).\n     * The prompt can be a single-line or multi-line textbox.  If a callback function is passed it will be called after the user\n     * clicks either button, and the id of the button that was clicked (could also be the top-right\n     * close button, which will always report as \"cancel\") and the text that was entered will be passed as the two parameters to the callback.\n     *\n     * @param {String} title The title bar text\n     * @param {String} msg The message box body text\n     * @param {Function} [fn] The callback function invoked after the message box is closed.\n     * See {@link #method-show} method for details.\n     * @param {Object} [scope=window] The scope (`this` reference) in which the callback is executed.\n     * @param {Boolean/Number} [multiline=false] True to create a multiline textbox using the defaultTextHeight\n     * property, or the height in pixels to create the textbox/\n     * @param {String} [value=''] Default value of the text input element\n     * @return {Ext.window.MessageBox} this\n     */\n    prompt : function(cfg, msg, fn, scope, multiline, value){\n        if (Ext.isString(cfg)) {\n            cfg = {\n                prompt: true,\n                title: cfg,\n                minWidth: this.minPromptWidth,\n                msg: msg,\n                buttons: this.OKCANCEL,\n                callback: fn,\n                scope: scope,\n                multiline: multiline,\n                value: value\n            };\n        }\n        return this.show(cfg);\n    },\n\n    /**\n     * Displays a message box with an infinitely auto-updating progress bar.  This can be used to block user\n     * interaction while waiting for a long-running process to complete that does not have defined intervals.\n     * You are responsible for closing the message box when the process is complete.\n     *\n     * @param {String} msg The message box body text\n     * @param {String} [title] The title bar text\n     * @param {Object} [config] A {@link Ext.ProgressBar#wait} config object\n     * @return {Ext.window.MessageBox} this\n     */\n    wait : function(cfg, title, config){\n        if (Ext.isString(cfg)) {\n            cfg = {\n                title : title,\n                msg : cfg,\n                closable: false,\n                wait: true,\n                modal: true,\n                minWidth: this.minProgressWidth,\n                waitConfig: config\n            };\n        }\n        return this.show(cfg);\n    },\n\n    /**\n     * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript alert prompt).\n     * If a callback function is passed it will be called after the user clicks the button, and the\n     * id of the button that was clicked will be passed as the only parameter to the callback\n     * (could also be the top-right close button, which will always report as \"cancel\").\n     *\n     * @param {String} title The title bar text\n     * @param {String} msg The message box body text\n     * @param {Function} [fn] The callback function invoked after the message box is closed.\n     * See {@link #method-show} method for details.\n     * @param {Object} [scope=window] The scope (<code>this</code> reference) in which the callback is executed.\n     * @return {Ext.window.MessageBox} this\n     */\n    alert: function(cfg, msg, fn, scope) {\n        if (Ext.isString(cfg)) {\n            cfg = {\n                title : cfg,\n                msg : msg,\n                buttons: this.OK,\n                fn: fn,\n                scope : scope,\n                minWidth: this.minWidth\n            };\n        }\n        return this.show(cfg);\n    },\n\n    /**\n     * Displays a message box with a progress bar.\n     *\n     * You are responsible for updating the progress bar as needed via {@link Ext.window.MessageBox#updateProgress}\n     * and closing the message box when the process is complete.\n     *\n     * @param {String} title The title bar text\n     * @param {String} msg The message box body text\n     * @param {String} [progressText=''] The text to display inside the progress bar\n     * @return {Ext.window.MessageBox} this\n     */\n    progress : function(cfg, msg, progressText){\n        if (Ext.isString(cfg)) {\n            cfg = {\n                title: cfg,\n                msg: msg,\n                progress: true,\n                progressText: progressText\n            };\n        }\n        return this.show(cfg);\n    }\n}, function() {\n    /**\n     * @class Ext.MessageBox\n     * @alternateClassName Ext.Msg\n     * @extends Ext.window.MessageBox\n     * @singleton\n     * Singleton instance of {@link Ext.window.MessageBox}.\n     */\n    Ext.MessageBox = Ext.Msg = new this();\n});\n\n/**\n * Provides input field management, validation, submission, and form loading services for the collection\n * of {@link Ext.form.field.Field Field} instances within a {@link Ext.container.Container}. It is recommended\n * that you use a {@link Ext.form.Panel} as the form container, as that has logic to automatically\n * hook up an instance of {@link Ext.form.Basic} (plus other conveniences related to field configuration.)\n *\n * ## Form Actions\n *\n * The Basic class delegates the handling of form loads and submits to instances of {@link Ext.form.action.Action}.\n * See the various Action implementations for specific details of each one's functionality, as well as the\n * documentation for {@link #doAction} which details the configuration options that can be specified in\n * each action call.\n *\n * The default submit Action is {@link Ext.form.action.Submit}, which uses an Ajax request to submit the\n * form's values to a configured URL. To enable normal browser submission of an Ext form, use the\n * {@link #standardSubmit} config option.\n *\n * ## File uploads\n *\n * File uploads are not performed using normal 'Ajax' techniques; see the description for\n * {@link #hasUpload} for details. If you're using file uploads you should read the method description.\n *\n * ## Example usage:\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Basic Form',\n *         renderTo: Ext.getBody(),\n *         bodyPadding: 5,\n *         width: 350,\n *\n *         // Any configuration items here will be automatically passed along to\n *         // the Ext.form.Basic instance when it gets created.\n *\n *         // The form will submit an AJAX request to this URL when submitted\n *         url: 'save-form.php',\n *\n *         items: [{\n *             xtype: 'textfield',\n *             fieldLabel: 'Field',\n *             name: 'theField'\n *         }],\n *\n *         buttons: [{\n *             text: 'Submit',\n *             handler: function() {\n *                 // The getForm() method returns the Ext.form.Basic instance:\n *                 var form = this.up('form').getForm();\n *                 if (form.isValid()) {\n *                     // Submit the Ajax request and handle the response\n *                     form.submit({\n *                         success: function(form, action) {\n *                            Ext.Msg.alert('Success', action.result.message);\n *                         },\n *                         failure: function(form, action) {\n *                             Ext.Msg.alert('Failed', action.result ? action.result.message : 'No response');\n *                         }\n *                     });\n *                 }\n *             }\n *         }]\n *     });\n *\n * @docauthor Jason Johnston <jason@sencha.com>\n */\nExt.define('Ext.form.Basic', {\n    extend: 'Ext.util.Observable',\n    alternateClassName: 'Ext.form.BasicForm',\n    requires: ['Ext.util.MixedCollection', 'Ext.form.action.Load', 'Ext.form.action.Submit',\n               'Ext.window.MessageBox', 'Ext.data.Errors', 'Ext.util.DelayedTask'],\n\n    /**\n     * Creates new form.\n     * @param {Ext.container.Container} owner The component that is the container for the form, usually a {@link Ext.form.Panel}\n     * @param {Object} config Configuration options. These are normally specified in the config to the\n     * {@link Ext.form.Panel} constructor, which passes them along to the BasicForm automatically.\n     */\n    constructor: function(owner, config) {\n        var me = this,\n            onItemAddOrRemove = me.onItemAddOrRemove,\n            api,\n            fn;\n\n        /**\n         * @property {Ext.container.Container} owner\n         * The container component to which this BasicForm is attached.\n         */\n        me.owner = owner;\n\n        // Listen for addition/removal of fields in the owner container\n        me.mon(owner, {\n            add: onItemAddOrRemove,\n            remove: onItemAddOrRemove,\n            scope: me\n        });\n\n        Ext.apply(me, config);\n\n        // Normalize the paramOrder to an Array\n        if (Ext.isString(me.paramOrder)) {\n            me.paramOrder = me.paramOrder.split(/[\\s,|]/);\n        }\n        \n        if (me.api) {\n            api = me.api = Ext.apply({}, me.api);\n            for (fn in api) {\n                if (api.hasOwnProperty(fn)) {\n                    api[fn] = Ext.direct.Manager.parseMethod(api[fn]);\n                }\n            }\n        }\n\n        me.checkValidityTask = new Ext.util.DelayedTask(me.checkValidity, me);\n\n        me.addEvents(\n            /**\n             * @event beforeaction\n             * Fires before any action is performed. Return false to cancel the action.\n             * @param {Ext.form.Basic} this\n             * @param {Ext.form.action.Action} action The {@link Ext.form.action.Action} to be performed\n             */\n            'beforeaction',\n            /**\n             * @event actionfailed\n             * Fires when an action fails.\n             * @param {Ext.form.Basic} this\n             * @param {Ext.form.action.Action} action The {@link Ext.form.action.Action} that failed\n             */\n            'actionfailed',\n            /**\n             * @event actioncomplete\n             * Fires when an action is completed.\n             * @param {Ext.form.Basic} this\n             * @param {Ext.form.action.Action} action The {@link Ext.form.action.Action} that completed\n             */\n            'actioncomplete',\n            /**\n             * @event validitychange\n             * Fires when the validity of the entire form changes.\n             * @param {Ext.form.Basic} this\n             * @param {Boolean} valid `true` if the form is now valid, `false` if it is now invalid.\n             */\n            'validitychange',\n            /**\n             * @event dirtychange\n             * Fires when the dirty state of the entire form changes.\n             * @param {Ext.form.Basic} this\n             * @param {Boolean} dirty `true` if the form is now dirty, `false` if it is no longer dirty.\n             */\n            'dirtychange'\n        );\n        me.callParent();\n    },\n\n    /**\n     * Do any post layout initialization\n     * @private\n     */\n    initialize : function() {\n        var me = this;\n        me.initialized = true;\n        me.onValidityChange(!me.hasInvalidField());\n    },\n\n\n    /**\n     * @cfg {String} method\n     * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.\n     */\n\n    /**\n     * @cfg {Ext.data.reader.Reader} reader\n     * An Ext.data.DataReader (e.g. {@link Ext.data.reader.Xml}) to be used to read\n     * data when executing 'load' actions. This is optional as there is built-in\n     * support for processing JSON responses.\n     */\n\n    /**\n     * @cfg {Ext.data.reader.Reader} errorReader\n     * An Ext.data.DataReader (e.g. {@link Ext.data.reader.Xml}) to be used to\n     * read field error messages returned from 'submit' actions. This is optional\n     * as there is built-in support for processing JSON responses.\n     *\n     * The Records which provide messages for the invalid Fields must use the\n     * Field name (or id) as the Record ID, and must contain a field called 'msg'\n     * which contains the error message.\n     *\n     * The errorReader does not have to be a full-blown implementation of a\n     * Reader. It simply needs to implement a `read(xhr)` function\n     * which returns an Array of Records in an object with the following\n     * structure:\n     *\n     *     {\n     *         records: recordArray\n     *     }\n     */\n\n    /**\n     * @cfg {String} url\n     * The URL to use for form actions if one isn't supplied in the\n     * {@link #doAction doAction} options.\n     */\n\n    /**\n     * @cfg {Object} baseParams\n     * Parameters to pass with all requests. e.g. baseParams: `{id: '123', foo: 'bar'}`.\n     *\n     * Parameters are encoded as standard HTTP parameters using {@link Ext.Object#toQueryString}.\n     */\n\n    /**\n     * @cfg {Number} timeout\n     * Timeout for form actions in seconds.\n     */\n    timeout: 30,\n\n    /**\n     * @cfg {Object} api\n     * If specified, load and submit actions will be handled with {@link Ext.form.action.DirectLoad DirectLoad}\n     * and {@link Ext.form.action.DirectSubmit DirectSubmit}.  Methods which have been imported by\n     * {@link Ext.direct.Manager} can be specified here to load and submit forms. API methods may also be\n     * specified as strings. See {@link Ext.data.proxy.Direct#directFn}.  Such as the following:\n     *\n     *     api: {\n     *         load: App.ss.MyProfile.load,\n     *         submit: App.ss.MyProfile.submit\n     *     }\n     *\n     * Load actions can use {@link #paramOrder} or {@link #paramsAsHash} to customize how the load method\n     * is invoked.  Submit actions will always use a standard form submit. The `formHandler` configuration\n     * (see Ext.direct.RemotingProvider#action) must be set on the associated server-side method which has\n     * been imported by {@link Ext.direct.Manager}.\n     */\n\n    /**\n     * @cfg {String/String[]} paramOrder\n     * A list of params to be executed server side. Only used for the {@link #api} `load`\n     * configuration.\n     *\n     * Specify the params in the order in which they must be executed on the\n     * server-side as either (1) an Array of String values, or (2) a String of params\n     * delimited by either whitespace, comma, or pipe. For example,\n     * any of the following would be acceptable:\n     *\n     *     paramOrder: ['param1','param2','param3']\n     *     paramOrder: 'param1 param2 param3'\n     *     paramOrder: 'param1,param2,param3'\n     *     paramOrder: 'param1|param2|param'\n     */\n\n    /**\n     * @cfg {Boolean} paramsAsHash\n     * Only used for the {@link #api} `load` configuration. If true, parameters will be sent as a\n     * single hash collection of named arguments. Providing a {@link #paramOrder} nullifies this\n     * configuration.\n     */\n    paramsAsHash: false,\n\n    //<locale>\n    /**\n     * @cfg {String} waitTitle\n     * The default title to show for the waiting message box\n     */\n    waitTitle: 'Please Wait...',\n    //</locale>\n\n    /**\n     * @cfg {Boolean} trackResetOnLoad\n     * If set to true, {@link #reset}() resets to the last loaded or {@link #setValues}() data instead of\n     * when the form was first created.\n     */\n    trackResetOnLoad: false,\n\n    /**\n     * @cfg {Boolean} standardSubmit\n     * If set to true, a standard HTML form submit is used instead of a XHR (Ajax) style form submission.\n     * All of the field values, plus any additional params configured via {@link #baseParams}\n     * and/or the `options` to {@link #submit}, will be included in the values submitted in the form.\n     */\n\n    /**\n     * @cfg {String/HTMLElement/Ext.Element} waitMsgTarget\n     * By default wait messages are displayed with Ext.MessageBox.wait. You can target a specific\n     * element by passing it or its id or mask the form itself by passing in true.\n     */\n\n\n    // Private\n    wasDirty: false,\n\n\n    /**\n     * Destroys this object.\n     */\n    destroy: function() {\n        this.clearListeners();\n        this.checkValidityTask.cancel();\n    },\n\n    /**\n     * @private\n     * Handle addition or removal of descendant items. Invalidates the cached list of fields\n     * so that {@link #getFields} will do a fresh query next time it is called. Also adds listeners\n     * for state change events on added fields, and tracks components with formBind=true.\n     */\n    onItemAddOrRemove: function(parent, child) {\n        var me = this,\n            isAdding = !!child.ownerCt,\n            isContainer = child.isContainer;\n\n        function handleField(field) {\n            // Listen for state change events on fields\n            me[isAdding ? 'mon' : 'mun'](field, {\n                validitychange: me.checkValidity,\n                dirtychange: me.checkDirty,\n                scope: me,\n                buffer: 100 //batch up sequential calls to avoid excessive full-form validation\n            });\n            // Flush the cached list of fields\n            delete me._fields;\n        }\n\n        if (child.isFormField) {\n            handleField(child);\n        } else if (isContainer) {\n            // Walk down\n            if (child.isDestroyed || child.destroying) {\n                // the container is destroyed, this means we may have child fields, so here\n                // we just invalidate all the fields to be sure.\n                delete me._fields;\n            } else {\n                Ext.Array.forEach(child.query('[isFormField]'), handleField);\n            }\n        }\n\n        // Flush the cached list of formBind components\n        delete this._boundItems;\n\n        // Check form bind, but only after initial add. Batch it to prevent excessive validation\n        // calls when many fields are being added at once.\n        if (me.initialized) {\n            me.checkValidityTask.delay(10);\n        }\n    },\n\n    /**\n     * Return all the {@link Ext.form.field.Field} components in the owner container.\n     * @return {Ext.util.MixedCollection} Collection of the Field objects\n     */\n    getFields: function() {\n        var fields = this._fields;\n        if (!fields) {\n            fields = this._fields = new Ext.util.MixedCollection();\n            fields.addAll(this.owner.query('[isFormField]'));\n        }\n        return fields;\n    },\n\n    /**\n     * @private\n     * Finds and returns the set of all items bound to fields inside this form\n     * @return {Ext.util.MixedCollection} The set of all bound form field items\n     */\n    getBoundItems: function() {\n        var boundItems = this._boundItems;\n        \n        if (!boundItems || boundItems.getCount() === 0) {\n            boundItems = this._boundItems = new Ext.util.MixedCollection();\n            boundItems.addAll(this.owner.query('[formBind]'));\n        }\n        \n        return boundItems;\n    },\n\n    /**\n     * Returns true if the form contains any invalid fields. No fields will be marked as invalid\n     * as a result of calling this; to trigger marking of fields use {@link #isValid} instead.\n     */\n    hasInvalidField: function() {\n        return !!this.getFields().findBy(function(field) {\n            var preventMark = field.preventMark,\n                isValid;\n            field.preventMark = true;\n            isValid = field.isValid();\n            field.preventMark = preventMark;\n            return !isValid;\n        });\n    },\n\n    /**\n     * Returns true if client-side validation on the form is successful. Any invalid fields will be\n     * marked as invalid. If you only want to determine overall form validity without marking anything,\n     * use {@link #hasInvalidField} instead.\n     * @return Boolean\n     */\n    isValid: function() {\n        var me = this,\n            invalid;\n        Ext.suspendLayouts();\n        invalid = me.getFields().filterBy(function(field) {\n            return !field.validate();\n        });\n        Ext.resumeLayouts(true);\n        return invalid.length < 1;\n    },\n\n    /**\n     * Check whether the validity of the entire form has changed since it was last checked, and\n     * if so fire the {@link #validitychange validitychange} event. This is automatically invoked\n     * when an individual field's validity changes.\n     */\n    checkValidity: function() {\n        var me = this,\n            valid = !me.hasInvalidField();\n        if (valid !== me.wasValid) {\n            me.onValidityChange(valid);\n            me.fireEvent('validitychange', me, valid);\n            me.wasValid = valid;\n        }\n    },\n\n    /**\n     * @private\n     * Handle changes in the form's validity. If there are any sub components with\n     * formBind=true then they are enabled/disabled based on the new validity.\n     * @param {Boolean} valid\n     */\n    onValidityChange: function(valid) {\n        var boundItems = this.getBoundItems(),\n            items, i, iLen, cmp;\n\n        if (boundItems) {\n            items = boundItems.items;\n            iLen  = items.length;\n\n            for (i = 0; i < iLen; i++) {\n                cmp = items[i];\n\n                if (cmp.disabled === valid) {\n                    cmp.setDisabled(!valid);\n                }\n            }\n        }\n    },\n\n    /**\n     * Returns true if any fields in this form have changed from their original values.\n     *\n     * Note that if this BasicForm was configured with {@link #trackResetOnLoad} then the\n     * Fields' *original values* are updated when the values are loaded by {@link #setValues}\n     * or {@link #loadRecord}.\n     *\n     * @return Boolean\n     */\n    isDirty: function() {\n        return !!this.getFields().findBy(function(f) {\n            return f.isDirty();\n        });\n    },\n\n    /**\n     * Check whether the dirty state of the entire form has changed since it was last checked, and\n     * if so fire the {@link #dirtychange dirtychange} event. This is automatically invoked\n     * when an individual field's dirty state changes.\n     */\n    checkDirty: function() {\n        var dirty = this.isDirty();\n        if (dirty !== this.wasDirty) {\n            this.fireEvent('dirtychange', this, dirty);\n            this.wasDirty = dirty;\n        }\n    },\n\n    /**\n     * Returns true if the form contains a file upload field. This is used to determine the method for submitting the\n     * form: File uploads are not performed using normal 'Ajax' techniques, that is they are **not** performed using\n     * XMLHttpRequests. Instead a hidden `<form>` element containing all the fields is created temporarily and submitted\n     * with its [target][1] set to refer to a dynamically generated, hidden `<iframe>` which is inserted into the document\n     * but removed after the return data has been gathered.\n     *\n     * The server response is parsed by the browser to create the document for the IFRAME. If the server is using JSON\n     * to send the return object, then the [Content-Type][2] header must be set to \"text/html\" in order to tell the\n     * browser to insert the text unchanged into the document body.\n     *\n     * Characters which are significant to an HTML parser must be sent as HTML entities, so encode `\"<\"` as `\"&lt;\"`,\n     * `\"&\"` as `\"&amp;\"` etc.\n     *\n     * The response text is retrieved from the document, and a fake XMLHttpRequest object is created containing a\n     * responseText property in order to conform to the requirements of event handlers and callbacks.\n     *\n     * Be aware that file upload packets are sent with the content type [multipart/form][3] and some server technologies\n     * (notably JEE) may require some custom processing in order to retrieve parameter names and parameter values from\n     * the packet content.\n     *\n     * [1]: http://www.w3.org/TR/REC-html40/present/frames.html#adef-target\n     * [2]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17\n     * [3]: http://www.faqs.org/rfcs/rfc2388.html\n     *\n     * @return Boolean\n     */\n    hasUpload: function() {\n        return !!this.getFields().findBy(function(f) {\n            return f.isFileUpload();\n        });\n    },\n\n    /**\n     * Performs a predefined action (an implementation of {@link Ext.form.action.Action}) to perform application-\n     * specific processing.\n     *\n     * @param {String/Ext.form.action.Action} action The name of the predefined action type, or instance of {@link\n     * Ext.form.action.Action} to perform.\n     *\n     * @param {Object} [options] The options to pass to the {@link Ext.form.action.Action} that will get created,\n     * if the action argument is a String.\n     *\n     * All of the config options listed below are supported by both the {@link Ext.form.action.Submit submit} and\n     * {@link Ext.form.action.Load load} actions unless otherwise noted (custom actions could also accept other\n     * config options):\n     *\n     * @param {String} options.url\n     * The url for the action (defaults to the form's {@link #url}.)\n     *\n     * @param {String} options.method\n     * The form method to use (defaults to the form's method, or POST if not defined)\n     *\n     * @param {String/Object} options.params\n     * The params to pass (defaults to the form's baseParams, or none if not defined)\n     *\n     * Parameters are encoded as standard HTTP parameters using {@link Ext#urlEncode Ext.Object.toQueryString}.\n     *\n     * @param {Object} options.headers\n     * Request headers to set for the action.\n     *\n     * @param {Function} options.success\n     * The callback that will be invoked after a successful response (see top of {@link Ext.form.action.Submit submit}\n     * and {@link Ext.form.action.Load load} for a description of what constitutes a successful response).\n     * @param {Ext.form.Basic} options.success.form The form that requested the action.\n     * @param {Ext.form.action.Action} options.success.action The Action object which performed the operation.\n     * The action object contains these properties of interest:\n     *\n     *  - {@link Ext.form.action.Action#response response}\n     *  - {@link Ext.form.action.Action#result result} - interrogate for custom postprocessing\n     *  - {@link Ext.form.action.Action#type type}\n     *\n     * @param {Function} options.failure\n     * The callback that will be invoked after a failed transaction attempt.\n     * @param {Ext.form.Basic} options.failure.form The form that requested the action.\n     * @param {Ext.form.action.Action} options.failure.action The Action object which performed the operation.\n     * The action object contains these properties of interest:\n     *\n     * - {@link Ext.form.action.Action#failureType failureType}\n     * - {@link Ext.form.action.Action#response response}\n     * - {@link Ext.form.action.Action#result result} - interrogate for custom postprocessing\n     * - {@link Ext.form.action.Action#type type}\n     *\n     * @param {Object} options.scope\n     * The scope in which to call the callback functions (The this reference for the callback functions).\n     *\n     * @param {Boolean} options.clientValidation\n     * Submit Action only. Determines whether a Form's fields are validated in a final call to {@link\n     * Ext.form.Basic#isValid isValid} prior to submission. Set to false to prevent this. If undefined, pre-submission\n     * field validation is performed.\n     *\n     * @return {Ext.form.Basic} this\n     */\n    doAction: function(action, options) {\n        if (Ext.isString(action)) {\n            action = Ext.ClassManager.instantiateByAlias('formaction.' + action, Ext.apply({}, options, {form: this}));\n        }\n        if (this.fireEvent('beforeaction', this, action) !== false) {\n            this.beforeAction(action);\n            Ext.defer(action.run, 100, action);\n        }\n        return this;\n    },\n\n    /**\n     * Shortcut to {@link #doAction do} a {@link Ext.form.action.Submit submit action}. This will use the\n     * {@link Ext.form.action.Submit AJAX submit action} by default. If the {@link #standardSubmit} config\n     * is enabled it will use a standard form element to submit, or if the {@link #api} config is present\n     * it will use the {@link Ext.form.action.DirectLoad Ext.direct.Direct submit action}.\n     *\n     * The following code:\n     *\n     *     myFormPanel.getForm().submit({\n     *         clientValidation: true,\n     *         url: 'updateConsignment.php',\n     *         params: {\n     *             newStatus: 'delivered'\n     *         },\n     *         success: function(form, action) {\n     *            Ext.Msg.alert('Success', action.result.msg);\n     *         },\n     *         failure: function(form, action) {\n     *             switch (action.failureType) {\n     *                 case Ext.form.action.Action.CLIENT_INVALID:\n     *                     Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');\n     *                     break;\n     *                 case Ext.form.action.Action.CONNECT_FAILURE:\n     *                     Ext.Msg.alert('Failure', 'Ajax communication failed');\n     *                     break;\n     *                 case Ext.form.action.Action.SERVER_INVALID:\n     *                    Ext.Msg.alert('Failure', action.result.msg);\n     *            }\n     *         }\n     *     });\n     *\n     * would process the following server response for a successful submission:\n     *\n     *     {\n     *         \"success\":true, // note this is Boolean, not string\n     *         \"msg\":\"Consignment updated\"\n     *     }\n     *\n     * and the following server response for a failed submission:\n     *\n     *     {\n     *         \"success\":false, // note this is Boolean, not string\n     *         \"msg\":\"You do not have permission to perform this operation\"\n     *     }\n     *\n     * @param {Object} options The options to pass to the action (see {@link #doAction} for details).\n     * @return {Ext.form.Basic} this\n     */\n    submit: function(options) {\n        options = options || {};\n        var me = this,\n            action;\n            \n        if (options.standardSubmit || me.standardSubmit) {\n            action = 'standardsubmit';\n        } else {\n            action = me.api ? 'directsubmit' : 'submit';\n        }\n            \n        return me.doAction(action, options);\n    },\n\n    /**\n     * Shortcut to {@link #doAction do} a {@link Ext.form.action.Load load action}.\n     * @param {Object} options The options to pass to the action (see {@link #doAction} for details)\n     * @return {Ext.form.Basic} this\n     */\n    load: function(options) {\n        return this.doAction(this.api ? 'directload' : 'load', options);\n    },\n\n    /**\n     * Persists the values in this form into the passed {@link Ext.data.Model} object in a beginEdit/endEdit block.\n     * If the record is not specified, it will attempt to update (if it exists) the record provided to loadRecord.\n     * @param {Ext.data.Model} [record] The record to edit\n     * @return {Ext.form.Basic} this\n     */\n    updateRecord: function(record) {\n        record = record || this._record;\n        if (!record) {\n            Ext.Error.raise(\"A record is required.\");\n        }\n        var fields = record.fields.items,\n            values = this.getFieldValues(),\n            obj = {},\n            i = 0,\n            len = fields.length,\n            name;\n\n        for (; i < len; ++i) {\n            name  = fields[i].name;\n\n            if (values.hasOwnProperty(name)) {\n                obj[name] = values[name];\n            }\n        }\n\n        record.beginEdit();\n        record.set(obj);\n        record.endEdit();\n\n        return this;\n    },\n\n    /**\n     * Loads an {@link Ext.data.Model} into this form by calling {@link #setValues} with the\n     * {@link Ext.data.Model#raw record data}.\n     * See also {@link #trackResetOnLoad}.\n     * @param {Ext.data.Model} record The record to load\n     * @return {Ext.form.Basic} this\n     */\n    loadRecord: function(record) {\n        this._record = record;\n        return this.setValues(record.data);\n    },\n\n    /**\n     * Returns the last Ext.data.Model instance that was loaded via {@link #loadRecord}\n     * @return {Ext.data.Model} The record\n     */\n    getRecord: function() {\n        return this._record;\n    },\n\n    /**\n     * @private\n     * Called before an action is performed via {@link #doAction}.\n     * @param {Ext.form.action.Action} action The Action instance that was invoked\n     */\n    beforeAction: function(action) {\n        var waitMsg = action.waitMsg,\n            maskCls = Ext.baseCSSPrefix + 'mask-loading',\n            fields  = this.getFields().items,\n            f,\n            fLen    = fields.length,\n            field, waitMsgTarget;\n\n        // Call HtmlEditor's syncValue before actions\n        for (f = 0; f < fLen; f++) {\n            field = fields[f];\n\n            if (field.isFormField && field.syncValue) {\n                field.syncValue();\n            }\n        }\n\n        if (waitMsg) {\n            waitMsgTarget = this.waitMsgTarget;\n            if (waitMsgTarget === true) {\n                this.owner.el.mask(waitMsg, maskCls);\n            } else if (waitMsgTarget) {\n                waitMsgTarget = this.waitMsgTarget = Ext.get(waitMsgTarget);\n                waitMsgTarget.mask(waitMsg, maskCls);\n            } else {\n                Ext.MessageBox.wait(waitMsg, action.waitTitle || this.waitTitle);\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Called after an action is performed via {@link #doAction}.\n     * @param {Ext.form.action.Action} action The Action instance that was invoked\n     * @param {Boolean} success True if the action completed successfully, false, otherwise.\n     */\n    afterAction: function(action, success) {\n        if (action.waitMsg) {\n            var messageBox = Ext.MessageBox,\n                waitMsgTarget = this.waitMsgTarget;\n            if (waitMsgTarget === true) {\n                this.owner.el.unmask();\n            } else if (waitMsgTarget) {\n                waitMsgTarget.unmask();\n            } else {\n                // Do not fire the hide event because that triggers complex processing\n                // which is not necessary just for the wait window, and which may interfere with the app.\n                messageBox.suspendEvents();\n                messageBox.hide();\n                messageBox.resumeEvents();\n            }\n        }\n        if (success) {\n            if (action.reset) {\n                this.reset();\n            }\n            Ext.callback(action.success, action.scope || action, [this, action]);\n            this.fireEvent('actioncomplete', this, action);\n        } else {\n            Ext.callback(action.failure, action.scope || action, [this, action]);\n            this.fireEvent('actionfailed', this, action);\n        }\n    },\n\n\n    /**\n     * Find a specific {@link Ext.form.field.Field} in this form by id or name.\n     * @param {String} id The value to search for (specify either a {@link Ext.Component#id id} or\n     * {@link Ext.form.field.Field#getName name or hiddenName}).\n     * @return {Ext.form.field.Field} The first matching field, or `null` if none was found.\n     */\n    findField: function(id) {\n        return this.getFields().findBy(function(f) {\n            return f.id === id || f.getName() === id;\n        });\n    },\n\n\n    /**\n     * Mark fields in this form invalid in bulk.\n     * @param {Object/Object[]/Ext.data.Errors} errors\n     * Either an array in the form `[{id:'fieldId', msg:'The message'}, ...]`,\n     * an object hash of `{id: msg, id2: msg2}`, or a {@link Ext.data.Errors} object.\n     * @return {Ext.form.Basic} this\n     */\n    markInvalid: function(errors) {\n        var me = this,\n            e, eLen, error, value,\n            key;\n\n        function mark(fieldId, msg) {\n            var field = me.findField(fieldId);\n            if (field) {\n                field.markInvalid(msg);\n            }\n        }\n\n        if (Ext.isArray(errors)) {\n            eLen = errors.length;\n\n            for (e = 0; e < eLen; e++) {\n                error = errors[e];\n                mark(error.id, error.msg);\n            }\n        } else if (errors instanceof Ext.data.Errors) {\n            eLen  = errors.items.length;\n            for (e = 0; e < eLen; e++) {\n                error = errors.items[e];\n\n                mark(error.field, error.message);\n            }\n        } else {\n            for (key in errors) {\n                if (errors.hasOwnProperty(key)) {\n                    value = errors[key];\n                    mark(key, value, errors);\n                }\n            }\n        }\n        return this;\n    },\n\n    /**\n     * Set values for fields in this form in bulk.\n     *\n     * @param {Object/Object[]} values Either an array in the form:\n     *\n     *     [{id:'clientName', value:'Fred. Olsen Lines'},\n     *      {id:'portOfLoading', value:'FXT'},\n     *      {id:'portOfDischarge', value:'OSL'} ]\n     *\n     * or an object hash of the form:\n     *\n     *     {\n     *         clientName: 'Fred. Olsen Lines',\n     *         portOfLoading: 'FXT',\n     *         portOfDischarge: 'OSL'\n     *     }\n     *\n     * @return {Ext.form.Basic} this\n     */\n    setValues: function(values) {\n        var me = this,\n            v, vLen, val, field;\n\n        function setVal(fieldId, val) {\n            var field = me.findField(fieldId);\n            if (field) {\n                field.setValue(val);\n                if (me.trackResetOnLoad) {\n                    field.resetOriginalValue();\n                }\n            }\n        }\n\n        if (Ext.isArray(values)) {\n            // array of objects\n            vLen = values.length;\n\n            for (v = 0; v < vLen; v++) {\n                val = values[v];\n\n                setVal(val.id, val.value);\n            }\n        } else {\n            // object hash\n            Ext.iterate(values, setVal);\n        }\n        return this;\n    },\n\n    /**\n     * Retrieves the fields in the form as a set of key/value pairs, using their\n     * {@link Ext.form.field.Field#getSubmitData getSubmitData()} method to collect the values.\n     * If multiple fields return values under the same name those values will be combined into an Array.\n     * This is similar to {@link Ext.form.Basic#getFieldValues getFieldValues} except that this method\n     * collects only String values for submission, while getFieldValues collects type-specific data\n     * values (e.g. Date objects for date fields.)\n     *\n     * @param {Boolean} [asString=false] If true, will return the key/value collection as a single\n     * URL-encoded param string.\n     * @param {Boolean} [dirtyOnly=false] If true, only fields that are dirty will be included in the result.\n     * @param {Boolean} [includeEmptyText=false] If true, the configured emptyText of empty fields will be used.\n     * @param {Boolean} [useDataValues=false] If true, the {@link Ext.form.field.Field#getModelData getModelData}\n     * method is used to retrieve values from fields, otherwise the {@link Ext.form.field.Field#getSubmitData getSubmitData}\n     * method is used.\n     * @return {String/Object}\n     */\n    getValues: function(asString, dirtyOnly, includeEmptyText, useDataValues) {\n        var values  = {},\n            fields  = this.getFields().items,\n            f,\n            fLen    = fields.length,\n            isArray = Ext.isArray,\n            field, data, val, bucket, name;\n\n        for (f = 0; f < fLen; f++) {\n            field = fields[f];\n\n            if (!dirtyOnly || field.isDirty()) {\n                data = field[useDataValues ? 'getModelData' : 'getSubmitData'](includeEmptyText);\n\n                if (Ext.isObject(data)) {\n                    for (name in data) {\n                        if (data.hasOwnProperty(name)) {\n                            val = data[name];\n\n                            if (includeEmptyText && val === '') {\n                                val = field.emptyText || '';\n                            }\n\n                            if (values.hasOwnProperty(name)) {\n                                bucket = values[name];\n\n                                if (!isArray(bucket)) {\n                                    bucket = values[name] = [bucket];\n                                }\n\n                                if (isArray(val)) {\n                                    values[name] = values[name] = bucket.concat(val);\n                                } else {\n                                    bucket.push(val);\n                                }\n                            } else {\n                                values[name] = val;\n                            }\n                        }\n                    }\n                }\n            }\n        }\n\n        if (asString) {\n            values = Ext.Object.toQueryString(values);\n        }\n        return values;\n    },\n\n    /**\n     * Retrieves the fields in the form as a set of key/value pairs, using their\n     * {@link Ext.form.field.Field#getModelData getModelData()} method to collect the values.\n     * If multiple fields return values under the same name those values will be combined into an Array.\n     * This is similar to {@link #getValues} except that this method collects type-specific data values\n     * (e.g. Date objects for date fields) while getValues returns only String values for submission.\n     *\n     * @param {Boolean} [dirtyOnly=false] If true, only fields that are dirty will be included in the result.\n     * @return {Object}\n     */\n    getFieldValues: function(dirtyOnly) {\n        return this.getValues(false, dirtyOnly, false, true);\n    },\n\n    /**\n     * Clears all invalid field messages in this form.\n     * @return {Ext.form.Basic} this\n     */\n    clearInvalid: function() {\n        Ext.suspendLayouts();\n\n        var me     = this,\n            fields = me.getFields().items,\n            f,\n            fLen   = fields.length;\n\n        for (f = 0; f < fLen; f++) {\n            fields[f].clearInvalid();\n        }\n\n        Ext.resumeLayouts(true);\n        return me;\n    },\n\n    /**\n     * Resets all fields in this form.\n     * @return {Ext.form.Basic} this\n     */\n    reset: function() {\n        Ext.suspendLayouts();\n\n        var me     = this,\n            fields = me.getFields().items,\n            f,\n            fLen   = fields.length;\n\n        for (f = 0; f < fLen; f++) {\n            fields[f].reset();\n        }\n\n        Ext.resumeLayouts(true);\n        return me;\n    },\n\n    /**\n     * Calls {@link Ext#apply Ext.apply} for all fields in this form with the passed object.\n     * @param {Object} obj The object to be applied\n     * @return {Ext.form.Basic} this\n     */\n    applyToFields: function(obj) {\n        var fields = this.getFields().items,\n            f,\n            fLen   = fields.length;\n\n        for (f = 0; f < fLen; f++) {\n            Ext.apply(fields[f], obj);\n        }\n\n        return this;\n    },\n\n    /**\n     * Calls {@link Ext#applyIf Ext.applyIf} for all field in this form with the passed object.\n     * @param {Object} obj The object to be applied\n     * @return {Ext.form.Basic} this\n     */\n    applyIfToFields: function(obj) {\n        var fields = this.getFields().items,\n            f,\n            fLen   = fields.length;\n\n        for (f = 0; f < fLen; f++) {\n            Ext.applyIf(fields[f], obj);\n        }\n\n        return this;\n    }\n});\n\n/**\n * This layout implements the column arrangement for {@link Ext.form.CheckboxGroup} and {@link Ext.form.RadioGroup}.\n * It groups the component's sub-items into columns based on the component's\n * {@link Ext.form.CheckboxGroup#columns columns} and {@link Ext.form.CheckboxGroup#vertical} config properties.\n */\nExt.define('Ext.layout.container.CheckboxGroup', {\n    extend: 'Ext.layout.container.Container',\n    alias: ['layout.checkboxgroup'],\n\n    /**\n     * @cfg {Boolean} [autoFlex=true]\n     * By default,  CheckboxGroup allocates all available space to the configured columns meaning that\n     * column are evenly spaced across the container.\n     *\n     * To have each column only be wide enough to fit the container Checkboxes (or Radios), set `autoFlex` to `false`\n     */\n    autoFlex: true,\n\n    type: 'checkboxgroup',\n\n    childEls: [\n        'innerCt'\n    ],\n\n    renderTpl: [\n        '<table id=\"{ownerId}-innerCt\" role=\"presentation\" style=\"{tableStyle}\"><tbody><tr>',\n            '<tpl for=\"columns\">',\n                '<td class=\"{parent.colCls}\" valign=\"top\" style=\"{style}\">',\n                    '{% this.renderColumn(out,parent,xindex-1) %}',\n                '</td>',\n            '</tpl>',\n        '</tr></tbody></table>'\n    ],\n\n    lastOwnerItemsGeneration : null,\n\n    beginLayout: function(ownerContext) {\n        var me = this,\n            columns,\n            numCols,\n            i, width, cwidth,\n            totalFlex = 0, flexedCols = 0,\n            autoFlex = me.autoFlex,\n            innerCtStyle = me.innerCt.dom.style;\n\n        me.callParent(arguments);\n\n        columns = me.columnNodes;\n        ownerContext.innerCtContext = ownerContext.getEl('innerCt', me);\n\n        // The columns config may be an array of widths. Any value < 1 is taken to be a fraction:\n        if (!ownerContext.widthModel.shrinkWrap) {\n            numCols = columns.length;\n\n            // If columns is an array of numeric widths\n            if (me.columnsArray) {\n\n                // first calculate total flex\n                for (i = 0; i < numCols; i++) {\n                    width = me.owner.columns[i];\n                    if (width < 1) {\n                        totalFlex += width;\n                        flexedCols++;\n                    }\n                }\n\n                // now apply widths\n                for (i = 0; i < numCols; i++) {\n                    width = me.owner.columns[i];\n                    if (width < 1) {\n                        cwidth = ((width / totalFlex) * 100) + '%';\n                    } else {\n                        cwidth = width + 'px';\n                    }\n                    columns[i].style.width = cwidth;\n                }\n            }\n\n            // Otherwise it's the *number* of columns, so distributed the widths evenly\n            else {\n                for (i = 0; i < numCols; i++) {\n                    // autoFlex: true will automatically calculate % widths\n                    // autoFlex: false allows the table to decide (shrinkWrap, in effect)\n                    // on a per-column basis\n                    cwidth = autoFlex\n                        ? (1 / numCols * 100) + '%'\n                        : '';\n                    columns[i].style.width = cwidth;\n                    flexedCols++;\n                }\n            }\n\n            // no flexed cols -- all widths are fixed\n            if (!flexedCols) {\n                innerCtStyle.tableLayout = 'fixed';\n                innerCtStyle.width = '';\n            // some flexed cols -- need to fix some\n            } else if (flexedCols < numCols) {\n                innerCtStyle.tableLayout = 'fixed';\n                innerCtStyle.width = '100%';\n            // let the table decide\n            } else {\n                innerCtStyle.tableLayout = 'auto';\n                // if autoFlex, fill available space, else compact down\n                if (autoFlex) {\n                    innerCtStyle.width = '100%';\n                } else {\n                    innerCtStyle.width = '';\n                }\n            }\n\n        } else {\n            innerCtStyle.tableLayout = 'auto';\n            innerCtStyle.width = '';\n        }\n    },\n\n    cacheElements: function () {\n        var me = this;\n\n        // Grab defined childEls\n        me.callParent();\n\n        me.rowEl = me.innerCt.down('tr');\n\n        // Grab columns TDs\n        me.columnNodes = me.rowEl.dom.childNodes;\n    },\n\n    /*\n     * Just wait for the child items to all lay themselves out in the width we are configured\n     * to make available to them. Then we can measure our height.\n     */\n    calculate: function(ownerContext) {\n        var me = this,\n            targetContext, widthShrinkWrap, heightShrinkWrap, shrinkWrap, table, targetPadding;\n\n        // The columnNodes are widthed using their own width attributes, we just need to wait\n        // for all children to have arranged themselves in that width, and then collect our height.\n        if (!ownerContext.getDomProp('containerChildrenDone')) {\n            me.done = false;\n        } else {\n            targetContext = ownerContext.innerCtContext;\n            widthShrinkWrap = ownerContext.widthModel.shrinkWrap;\n            heightShrinkWrap = ownerContext.heightModel.shrinkWrap;\n            shrinkWrap = heightShrinkWrap || widthShrinkWrap;\n            table = targetContext.el.dom;\n            targetPadding = shrinkWrap && targetContext.getPaddingInfo();\n\n            if (widthShrinkWrap) {\n                ownerContext.setContentWidth(table.offsetWidth + targetPadding.width, true);\n            }\n\n            if (heightShrinkWrap) {\n                ownerContext.setContentHeight(table.offsetHeight + targetPadding.height, true);\n            }\n        }\n    },\n\n    doRenderColumn: function (out, renderData, columnIndex) {\n        // Careful! This method is bolted on to the renderTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the renderTpl instance!\n\n        var me = renderData.$layout,\n            owner = me.owner,\n            columnCount = renderData.columnCount,\n            items = owner.items.items,\n            itemCount = items.length,\n            item, itemIndex, rowCount, increment, tree;\n\n        // Example:\n        //      columnCount = 3\n        //      items.length = 10\n\n        if (owner.vertical) {\n            //        0   1   2\n            //      +---+---+---+\n            //    0 | 0 | 4 | 8 |\n            //      +---+---+---+\n            //    1 | 1 | 5 | 9 |\n            //      +---+---+---+\n            //    2 | 2 | 6 |   |\n            //      +---+---+---+\n            //    3 | 3 | 7 |   |\n            //      +---+---+---+\n\n            rowCount = Math.ceil(itemCount / columnCount); // = 4\n            itemIndex = columnIndex * rowCount;\n            itemCount = Math.min(itemCount, itemIndex + rowCount);\n            increment = 1;\n        } else {\n            //        0   1   2\n            //      +---+---+---+\n            //    0 | 0 | 1 | 2 |\n            //      +---+---+---+\n            //    1 | 3 | 4 | 5 |\n            //      +---+---+---+\n            //    2 | 6 | 7 | 8 |\n            //      +---+---+---+\n            //    3 | 9 |   |   |\n            //      +---+---+---+\n\n            itemIndex = columnIndex;\n            increment = columnCount;\n        }\n\n        for ( ; itemIndex < itemCount; itemIndex += increment) {\n            item = items[itemIndex];\n            me.configureItem(item);\n            tree = item.getRenderTree();\n            Ext.DomHelper.generateMarkup(tree, out);\n        }\n    },\n\n    /**\n     * Returns the number of columns in the checkbox group.\n     * @private\n     */\n    getColumnCount: function() {\n        var me = this,\n            owner = me.owner,\n            ownerColumns = owner.columns;\n\n        // Our columns config is an array of numeric widths.\n        // Calculate our total width\n        if (me.columnsArray) {\n            return ownerColumns.length;\n        }\n\n        if (Ext.isNumber(ownerColumns)) {\n            return ownerColumns;\n        }\n        return owner.items.length;\n    },\n\n    getItemSizePolicy: function (item) {\n        return this.autoSizePolicy;\n    },\n\n    getRenderData: function () {\n        var me = this,\n            data = me.callParent(),\n            owner = me.owner,\n            i, columns = me.getColumnCount(),\n            width, column, cwidth,\n            autoFlex = me.autoFlex,\n            totalFlex = 0, flexedCols = 0;\n\n        // calculate total flex\n        if (me.columnsArray) {\n            for (i=0; i < columns; i++) {\n                width = me.owner.columns[i];\n                if (width < 1) {\n                    totalFlex += width;\n                    flexedCols++;\n                }\n            }\n        }\n\n        data.colCls = owner.groupCls;\n        data.columnCount = columns;\n\n        data.columns = [];\n        for (i = 0; i < columns; i++) {\n            column = (data.columns[i] = {});\n\n            if (me.columnsArray) {\n                width = me.owner.columns[i];\n                if (width < 1) {\n                    cwidth = ((width / totalFlex) * 100) + '%';\n                } else {\n                    cwidth = width + 'px';\n                }\n                column.style = 'width:' + cwidth;\n            } else {\n                column.style = 'width:' + (1 / columns * 100) + '%';\n                flexedCols++;\n            }\n        }\n\n        // If the columns config was an array of column widths, allow table to auto width\n        data.tableStyle =\n            !flexedCols ? 'table-layout:fixed;' :\n            (flexedCols < columns) ? 'table-layout:fixed;width:100%' :\n            (autoFlex) ? 'table-layout:auto;width:100%' : 'table-layout:auto;';\n\n        return data;\n    },\n\n    initLayout: function () {\n        var me = this,\n            owner = me.owner;\n\n        me.columnsArray = Ext.isArray(owner.columns);\n        me.autoColumns = !owner.columns || owner.columns === 'auto';\n        me.vertical = owner.vertical;\n\n        me.callParent();\n    },\n\n    // Always valid. beginLayout ensures the encapsulating elements of all children are in the correct place\n    isValidParent: function() {\n        return true;\n    },\n\n    setupRenderTpl: function (renderTpl) {\n        this.callParent(arguments);\n\n        renderTpl.renderColumn = this.doRenderColumn;\n    },\n\n    renderChildren: function () {\n        var me = this,\n            generation = me.owner.items.generation;\n\n        if (me.lastOwnerItemsGeneration !== generation) {\n            me.lastOwnerItemsGeneration = generation;\n            me.renderItems(me.getLayoutItems());\n        }\n    },\n\n    /**\n     * Iterates over all passed items, ensuring they are rendered.  If the items are already rendered,\n     * also determines if the items are in the proper place in the dom.\n     * @protected\n     */\n    renderItems : function(items) {\n        var me = this,\n            itemCount = items.length,\n            i,\n            item,\n            rowCount,\n            columnCount,\n            rowIndex,\n            columnIndex;\n\n        if (itemCount) {\n            Ext.suspendLayouts();\n\n            if (me.autoColumns) {\n                me.addMissingColumns(itemCount);\n            }\n\n            columnCount = me.columnNodes.length;\n            rowCount = Math.ceil(itemCount / columnCount);\n\n            for (i = 0; i < itemCount; i++) {\n                item = items[i];\n                rowIndex = me.getRenderRowIndex(i, rowCount, columnCount);\n                columnIndex = me.getRenderColumnIndex(i, rowCount, columnCount);\n\n                if (!item.rendered) {\n                    me.renderItem(item, rowIndex, columnIndex);\n                } else if (!me.isItemAtPosition(item, rowIndex, columnIndex)) {\n                    me.moveItem(item, rowIndex, columnIndex);\n                }\n            }\n\n            if (me.autoColumns) {\n                me.removeExceedingColumns(itemCount);\n            }\n\n            Ext.resumeLayouts(true);\n        }\n    },\n\n    isItemAtPosition : function(item, rowIndex, columnIndex) {\n        return item.el.dom === this.getNodeAt(rowIndex, columnIndex);\n    },\n\n    getRenderColumnIndex : function(itemIndex, rowCount, columnCount) {\n        if (this.vertical) {\n            return Math.floor(itemIndex / rowCount);\n        } else {\n            return itemIndex % columnCount;\n        }\n    },\n\n    getRenderRowIndex : function(itemIndex, rowCount, columnCount) {\n        var me = this;\n        if (me.vertical) {\n            return itemIndex % rowCount;\n        } else {\n            return Math.floor(itemIndex / columnCount);\n        }\n    },\n\n    getNodeAt : function(rowIndex, columnIndex) {\n        return this.columnNodes[columnIndex].childNodes[rowIndex];\n    },\n\n    addMissingColumns : function(itemsCount) {\n        var me = this,\n            existingColumnsCount = me.columnNodes.length,\n            missingColumnsCount,\n            row,\n            cls,\n            i;\n        if (existingColumnsCount < itemsCount) {\n            missingColumnsCount = itemsCount - existingColumnsCount;\n            row = me.rowEl;\n            cls = me.owner.groupCls;\n            for (i = 0; i < missingColumnsCount; i++) {\n                row.createChild({\n                    cls: cls,\n                    tag: 'td',\n                    vAlign: 'top'\n                });\n            }\n        }\n    },\n\n    removeExceedingColumns : function(itemsCount) {\n        var me = this,\n            existingColumnsCount = me.columnNodes.length,\n            exceedingColumnsCount,\n            row,\n            i;\n        if (existingColumnsCount > itemsCount) {\n            exceedingColumnsCount = existingColumnsCount - itemsCount;\n            row = me.rowEl;\n            for (i = 0; i < exceedingColumnsCount; i++) {\n                row.last().remove();\n            }\n        }\n    },\n\n    /**\n     * Renders the given Component into the specified row and column\n     * @param {Ext.Component} item The Component to render\n     * @param {number} rowIndex row index\n     * @param {number} columnIndex column index\n     * @private\n     */\n    renderItem : function(item, rowIndex, columnIndex) {\n        var me = this;\n\n        me.configureItem(item);\n        item.render(Ext.get(me.columnNodes[columnIndex]), rowIndex);\n        me.afterRenderItem(item);\n    },\n\n    /**\n     * Moves the given already rendered Component to the specified row and column\n     * @param {Ext.Component} item The Component to move\n     * @param {number} rowIndex row index\n     * @param {number} columnIndex column index\n     * @private\n     */\n    moveItem : function(item, rowIndex, columnIndex) {\n        var me = this,\n            column = me.columnNodes[columnIndex],\n            targetNode = column.childNodes[rowIndex];\n        column.insertBefore(item.el.dom, targetNode || null);\n    }\n\n});\n\n/**\n * @private\n */\nExt.define('Ext.layout.component.field.FieldContainer', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.layout.component.field.Field',\n\n    alias: 'layout.fieldcontainer',\n\n    /* End Definitions */\n\n    type: 'fieldcontainer',\n\n    waitForOuterHeightInDom: true,\n    waitForOuterWidthInDom: true,\n\n    beginLayout: function(ownerContext) {\n        this.callParent(arguments);\n\n        // Tell Component.measureAutoDimensions to measure the DOM when containerChildrenDone is true\n        ownerContext.hasRawContent = true;\n        ownerContext.target.bodyEl.setStyle('height', '');\n    },\n\n    measureContentHeight: function (ownerContext) {\n        // since we are measuring the outer el, we have to wait for whatever is in our\n        // container to be flushed to the DOM... especially for things like box layouts\n        // that size the innerCt since that is all that will contribute to our size!\n        return ownerContext.hasDomProp('containerLayoutDone') ? this.callParent(arguments) : NaN;\n    },\n\n    measureContentWidth: function (ownerContext) {\n        // see measureContentHeight\n        return ownerContext.hasDomProp('containerLayoutDone') ? this.callParent(arguments) : NaN;\n    },\n\n    publishInnerWidth: function (ownerContext, width) {\n        var bodyContext = ownerContext.bodyCellContext;\n        bodyContext.setWidth(bodyContext.el.getWidth(), false);\n    },\n    \n    publishInnerHeight: function (ownerContext, height) {\n        var bodyContext = ownerContext.bodyCellContext;\n        bodyContext.setHeight(height - this.measureLabelErrorHeight(ownerContext));\n    }\n});\n\n/**\n * A mixin for {@link Ext.container.Container} components that are likely to have form fields in their\n * items subtree. Adds the following capabilities:\n *\n * - Methods for handling the addition and removal of {@link Ext.form.Labelable} and {@link Ext.form.field.Field}\n *   instances at any depth within the container.\n * - Events ({@link #fieldvaliditychange} and {@link #fielderrorchange}) for handling changes to the state\n *   of individual fields at the container level.\n * - Automatic application of {@link #fieldDefaults} config properties to each field added within the\n *   container, to facilitate uniform configuration of all fields.\n *\n * This mixin is primarily for internal use by {@link Ext.form.Panel} and {@link Ext.form.FieldContainer},\n * and should not normally need to be used directly. @docauthor Jason Johnston <jason@sencha.com>\n */\nExt.define('Ext.form.FieldAncestor', {\n\n    /**\n     * @cfg {Object} fieldDefaults\n     * If specified, the properties in this object are used as default config values for each {@link Ext.form.Labelable}\n     * instance (e.g. {@link Ext.form.field.Base} or {@link Ext.form.FieldContainer}) that is added as a descendant of\n     * this container. Corresponding values specified in an individual field's own configuration, or from the {@link\n     * Ext.container.Container#defaults defaults config} of its parent container, will take precedence. See the\n     * documentation for {@link Ext.form.Labelable} to see what config options may be specified in the fieldDefaults.\n     *\n     * Example:\n     *\n     *     new Ext.form.Panel({\n     *         fieldDefaults: {\n     *             labelAlign: 'left',\n     *             labelWidth: 100\n     *         },\n     *         items: [{\n     *             xtype: 'fieldset',\n     *             defaults: {\n     *                 labelAlign: 'top'\n     *             },\n     *             items: [{\n     *                 name: 'field1'\n     *             }, {\n     *                 name: 'field2'\n     *             }]\n     *         }, {\n     *             xtype: 'fieldset',\n     *             items: [{\n     *                 name: 'field3',\n     *                 labelWidth: 150\n     *             }, {\n     *                 name: 'field4'\n     *             }]\n     *         }]\n     *     });\n     *\n     * In this example, field1 and field2 will get labelAlign:'top' (from the fieldset's defaults) and labelWidth:100\n     * (from fieldDefaults), field3 and field4 will both get labelAlign:'left' (from fieldDefaults and field3 will use\n     * the labelWidth:150 from its own config.\n     */\n\n\n    /**\n     * Initializes the FieldAncestor's state; this must be called from the initComponent method of any components\n     * importing this mixin.\n     * @protected\n     */\n    initFieldAncestor: function() {\n        var me = this,\n            onSubtreeChange = me.onFieldAncestorSubtreeChange;\n\n        me.addEvents(\n            /**\n             * @event fieldvaliditychange\n             * Fires when the validity state of any one of the {@link Ext.form.field.Field} instances within this\n             * container changes.\n             * @param {Ext.form.FieldAncestor} this\n             * @param {Ext.form.Labelable} The Field instance whose validity changed\n             * @param {String} isValid The field's new validity state\n             */\n            'fieldvaliditychange',\n\n            /**\n             * @event fielderrorchange\n             * Fires when the active error message is changed for any one of the {@link Ext.form.Labelable} instances\n             * within this container.\n             * @param {Ext.form.FieldAncestor} this\n             * @param {Ext.form.Labelable} The Labelable instance whose active error was changed\n             * @param {String} error The active error message\n             */\n            'fielderrorchange'\n        );\n\n        // Catch addition and removal of descendant fields\n        me.on('add', onSubtreeChange, me);\n        me.on('remove', onSubtreeChange, me);\n\n        me.initFieldDefaults();\n    },\n\n    /**\n     * @private Initialize the {@link #fieldDefaults} object\n     */\n    initFieldDefaults: function() {\n        if (!this.fieldDefaults) {\n            this.fieldDefaults = {};\n        }\n    },\n\n    /**\n     * @private\n     * Handle the addition and removal of components in the FieldAncestor component's child tree.\n     */\n    onFieldAncestorSubtreeChange: function(parent, child) {\n        var me = this,\n            isAdding = !!child.ownerCt;\n\n        function handleCmp(cmp) {\n            var isLabelable = cmp.isFieldLabelable,\n                isField = cmp.isFormField;\n            if (isLabelable || isField) {\n                if (isLabelable) {\n                    me['onLabelable' + (isAdding ? 'Added' : 'Removed')](cmp);\n                }\n                if (isField) {\n                    me['onField' + (isAdding ? 'Added' : 'Removed')](cmp);\n                }\n            }\n            else if (cmp.isContainer) {\n                Ext.Array.forEach(cmp.getRefItems(), handleCmp);\n            }\n        }\n        handleCmp(child);\n    },\n\n    /**\n     * Called when a {@link Ext.form.Labelable} instance is added to the container's subtree.\n     * @param {Ext.form.Labelable} labelable The instance that was added\n     * @protected\n     */\n    onLabelableAdded: function(labelable) {\n        var me = this;\n\n        // buffer slightly to avoid excessive firing while sub-fields are changing en masse\n        me.mon(labelable, 'errorchange', me.handleFieldErrorChange, me, {buffer: 10});\n\n        labelable.setFieldDefaults(me.fieldDefaults);\n    },\n\n    /**\n     * Called when a {@link Ext.form.field.Field} instance is added to the container's subtree.\n     * @param {Ext.form.field.Field} field The field which was added\n     * @protected\n     */\n    onFieldAdded: function(field) {\n        var me = this;\n        me.mon(field, 'validitychange', me.handleFieldValidityChange, me);\n    },\n\n    /**\n     * Called when a {@link Ext.form.Labelable} instance is removed from the container's subtree.\n     * @param {Ext.form.Labelable} labelable The instance that was removed\n     * @protected\n     */\n    onLabelableRemoved: function(labelable) {\n        var me = this;\n        me.mun(labelable, 'errorchange', me.handleFieldErrorChange, me);\n    },\n\n    /**\n     * Called when a {@link Ext.form.field.Field} instance is removed from the container's subtree.\n     * @param {Ext.form.field.Field} field The field which was removed\n     * @protected\n     */\n    onFieldRemoved: function(field) {\n        var me = this;\n        me.mun(field, 'validitychange', me.handleFieldValidityChange, me);\n    },\n\n    /**\n     * @private Handle validitychange events on sub-fields; invoke the aggregated event and method\n     */\n    handleFieldValidityChange: function(field, isValid) {\n        var me = this;\n        me.fireEvent('fieldvaliditychange', me, field, isValid);\n        me.onFieldValidityChange(field, isValid);\n    },\n\n    /**\n     * @private Handle errorchange events on sub-fields; invoke the aggregated event and method\n     */\n    handleFieldErrorChange: function(labelable, activeError) {\n        var me = this;\n        me.fireEvent('fielderrorchange', me, labelable, activeError);\n        me.onFieldErrorChange(labelable, activeError);\n    },\n\n    /**\n     * Fired when the validity of any field within the container changes.\n     * @param {Ext.form.field.Field} field The sub-field whose validity changed\n     * @param {Boolean} valid The new validity state\n     * @protected\n     */\n    onFieldValidityChange: Ext.emptyFn,\n\n    /**\n     * Fired when the error message of any field within the container changes.\n     * @param {Ext.form.Labelable} field The sub-field whose active error changed\n     * @param {String} error The new active error message\n     * @protected\n     */\n    onFieldErrorChange: Ext.emptyFn\n\n});\n\n/**\n * FieldContainer is a derivation of {@link Ext.container.Container Container} that implements the\n * {@link Ext.form.Labelable Labelable} mixin. This allows it to be configured so that it is rendered with\n * a {@link #fieldLabel field label} and optional {@link #msgTarget error message} around its sub-items.\n * This is useful for arranging a group of fields or other components within a single item in a form, so\n * that it lines up nicely with other fields. A common use is for grouping a set of related fields under\n * a single label in a form.\n * \n * The container's configured {@link #cfg-items} will be layed out within the field body area according to the\n * configured {@link #layout} type. The default layout is `'autocontainer'`.\n * \n * Like regular fields, FieldContainer can inherit its decoration configuration from the\n * {@link Ext.form.Panel#fieldDefaults fieldDefaults} of an enclosing FormPanel. In addition,\n * FieldContainer itself can pass {@link #fieldDefaults} to any {@link Ext.form.Labelable fields}\n * it may itself contain.\n * \n * If you are grouping a set of {@link Ext.form.field.Checkbox Checkbox} or {@link Ext.form.field.Radio Radio}\n * fields in a single labeled container, consider using a {@link Ext.form.CheckboxGroup}\n * or {@link Ext.form.RadioGroup} instead as they are specialized for handling those types.\n *\n * # Example\n * \n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'FieldContainer Example',\n *         width: 550,\n *         bodyPadding: 10,\n * \n *         items: [{\n *             xtype: 'fieldcontainer',\n *             fieldLabel: 'Last Three Jobs',\n *             labelWidth: 100,\n * \n *             // The body area will contain three text fields, arranged\n *             // horizontally, separated by draggable splitters.\n *             layout: 'hbox',\n *             items: [{\n *                 xtype: 'textfield',\n *                 flex: 1\n *             }, {\n *                 xtype: 'splitter'\n *             }, {\n *                 xtype: 'textfield',\n *                 flex: 1\n *             }, {\n *                 xtype: 'splitter'\n *             }, {\n *                 xtype: 'textfield',\n *                 flex: 1\n *             }]\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n * \n * # Usage of fieldDefaults\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'FieldContainer Example',\n *         width: 350,\n *         bodyPadding: 10,\n * \n *         items: [{\n *             xtype: 'fieldcontainer',\n *             fieldLabel: 'Your Name',\n *             labelWidth: 75,\n *             defaultType: 'textfield',\n * \n *             // Arrange fields vertically, stretched to full width\n *             layout: 'anchor',\n *             defaults: {\n *                 layout: '100%'\n *             },\n * \n *             // These config values will be applied to both sub-fields, except\n *             // for Last Name which will use its own msgTarget.\n *             fieldDefaults: {\n *                 msgTarget: 'under',\n *                 labelAlign: 'top'\n *             },\n * \n *             items: [{\n *                 fieldLabel: 'First Name',\n *                 name: 'firstName'\n *             }, {\n *                 fieldLabel: 'Last Name',\n *                 name: 'lastName',\n *                 msgTarget: 'under'\n *             }]\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n * \n * @docauthor Jason Johnston <jason@sencha.com>\n */\nExt.define('Ext.form.FieldContainer', {\n    extend: 'Ext.container.Container',\n    mixins: {\n        labelable: 'Ext.form.Labelable',\n        fieldAncestor: 'Ext.form.FieldAncestor'\n    },\n    requires: 'Ext.layout.component.field.FieldContainer',\n\n    alias: 'widget.fieldcontainer',\n\n    componentLayout: 'fieldcontainer',\n    \n    componentCls: Ext.baseCSSPrefix + 'form-fieldcontainer',\n\n    /**\n     * @cfg {Boolean} combineLabels\n     * If set to true, and there is no defined {@link #fieldLabel}, the field container will automatically\n     * generate its label by combining the labels of all the fields it contains. Defaults to false.\n     */\n    combineLabels: false,\n\n    //<locale>\n    /**\n     * @cfg {String} labelConnector\n     * The string to use when joining the labels of individual sub-fields, when {@link #combineLabels} is\n     * set to true. Defaults to ', '.\n     */\n    labelConnector: ', ',\n    //</locale>\n\n    /**\n     * @cfg {Boolean} combineErrors\n     * If set to true, the field container will automatically combine and display the validation errors from\n     * all the fields it contains as a single error on the container, according to the configured\n     * {@link #msgTarget}. Defaults to false.\n     */\n    combineErrors: false,\n\n    maskOnDisable: false,\n\n    fieldSubTpl: '{%this.renderContainer(out,values)%}',\n\n    initComponent: function() {\n        var me = this;\n\n        // Init mixins\n        me.initLabelable();\n        me.initFieldAncestor();\n\n        me.callParent();\n    },\n\n    beforeRender: function(){\n        this.callParent(arguments);\n        this.beforeLabelableRender(arguments);\n    },\n\n    /**\n     * @protected Called when a {@link Ext.form.Labelable} instance is added to the container's subtree.\n     * @param {Ext.form.Labelable} labelable The instance that was added\n     */\n    onLabelableAdded: function(labelable) {\n        var me = this;\n        me.mixins.fieldAncestor.onLabelableAdded.call(this, labelable);\n        me.updateLabel();\n    },\n\n    /**\n     * @protected Called when a {@link Ext.form.Labelable} instance is removed from the container's subtree.\n     * @param {Ext.form.Labelable} labelable The instance that was removed\n     */\n    onLabelableRemoved: function(labelable) {\n        var me = this;\n        me.mixins.fieldAncestor.onLabelableRemoved.call(this, labelable);\n        me.updateLabel();\n    },\n\n    initRenderTpl: function() {\n        var me = this;\n        if (!me.hasOwnProperty('renderTpl')) {\n            me.renderTpl = me.getTpl('labelableRenderTpl');\n        }\n        return me.callParent();\n    },\n\n    initRenderData: function() {\n        return Ext.applyIf(this.callParent(), this.getLabelableRenderData());\n    },\n\n    /**\n     * Returns the combined field label if {@link #combineLabels} is set to true and if there is no\n     * set {@link #fieldLabel}. Otherwise returns the fieldLabel like normal. You can also override\n     * this method to provide a custom generated label.\n     * @template\n     * @return {String} The label, or empty string if none.\n     */\n    getFieldLabel: function() {\n        var label = this.fieldLabel || '';\n        if (!label && this.combineLabels) {\n            label = Ext.Array.map(this.query('[isFieldLabelable]'), function(field) {\n                return field.getFieldLabel();\n            }).join(this.labelConnector);\n        }\n        return label;\n    },\n\n    getSubTplData: function() {\n        var ret = this.initRenderData();\n\n        Ext.apply(ret, this.subTplData);\n        return ret;\n    },\n\n    getSubTplMarkup: function() {\n        var me = this,\n            tpl = me.getTpl('fieldSubTpl'),\n            html;\n\n        if (!tpl.renderContent) {\n            me.setupRenderTpl(tpl);\n        }\n\n        html = tpl.apply(me.getSubTplData());\n        return html;\n    },\n\n    /**\n     * @private Updates the content of the labelEl if it is rendered\n     */\n    updateLabel: function() {\n        var me = this,\n            label = me.labelEl;\n        if (label) {\n            me.setFieldLabel(me.getFieldLabel());\n        }\n    },\n\n\n    /**\n     * @private Fired when the error message of any field within the container changes, and updates the\n     * combined error message to match.\n     */\n    onFieldErrorChange: function(field, activeError) {\n        if (this.combineErrors) {\n            var me = this,\n                oldError = me.getActiveError(),\n                invalidFields = Ext.Array.filter(me.query('[isFormField]'), function(field) {\n                    return field.hasActiveError();\n                }),\n                newErrors = me.getCombinedErrors(invalidFields);\n\n            if (newErrors) {\n                me.setActiveErrors(newErrors);\n            } else {\n                me.unsetActiveError();\n            }\n\n            if (oldError !== me.getActiveError()) {\n                me.doComponentLayout();\n            }\n        }\n    },\n\n    /**\n     * Takes an Array of invalid {@link Ext.form.field.Field} objects and builds a combined list of error\n     * messages from them. Defaults to prepending each message by the field name and a colon. This\n     * can be overridden to provide custom combined error message handling, for instance changing\n     * the format of each message or sorting the array (it is sorted in order of appearance by default).\n     * @param {Ext.form.field.Field[]} invalidFields An Array of the sub-fields which are currently invalid.\n     * @return {String[]} The combined list of error messages\n     */\n    getCombinedErrors: function(invalidFields) {\n        var errors = [],\n            f,\n            fLen   = invalidFields.length,\n            field,\n            activeErrors, a, aLen,\n            error, label;\n\n        for (f = 0; f < fLen; f++) {\n            field = invalidFields[f];\n            activeErrors = field.getActiveErrors();\n            aLen         = activeErrors.length;\n\n            for (a = 0; a < aLen; a++) {\n                error = activeErrors[a];\n                label = field.getFieldLabel();\n\n                errors.push((label ? label + ': ' : '') + error);\n            }\n        }\n\n        return errors;\n    },\n\n    getTargetEl: function() {\n        return this.bodyEl || this.callParent();\n    }\n});\n\n/**\n * A {@link Ext.form.FieldContainer field container} which has a specialized layout for arranging\n * {@link Ext.form.field.Checkbox} controls into columns, and provides convenience\n * {@link Ext.form.field.Field} methods for {@link #getValue getting}, {@link #setValue setting},\n * and {@link #validate validating} the group of checkboxes as a whole.\n *\n * # Validation\n *\n * Individual checkbox fields themselves have no default validation behavior, but\n * sometimes you want to require a user to select at least one of a group of checkboxes. CheckboxGroup\n * allows this by setting the config `{@link #allowBlank}:false`; when the user does not check at\n * least one of the checkboxes, the entire group will be highlighted as invalid and the\n * {@link #blankText error message} will be displayed according to the {@link #msgTarget} config.\n *\n * # Layout\n *\n * The default layout for CheckboxGroup makes it easy to arrange the checkboxes into\n * columns; see the {@link #columns} and {@link #vertical} config documentation for details. You may also\n * use a completely different layout by setting the {@link #layout} to one of the other supported layout\n * types; for instance you may wish to use a custom arrangement of hbox and vbox containers. In that case\n * the checkbox components at any depth will still be managed by the CheckboxGroup's validation.\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Checkbox Group',\n *         width: 300,\n *         height: 125,\n *         bodyPadding: 10,\n *         renderTo: Ext.getBody(),\n *         items:[{\n *             xtype: 'checkboxgroup',\n *             fieldLabel: 'Two Columns',\n *             // Arrange checkboxes into two columns, distributed vertically\n *             columns: 2,\n *             vertical: true,\n *             items: [\n *                 { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },\n *                 { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true },\n *                 { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },\n *                 { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },\n *                 { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },\n *                 { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }\n *             ]\n *         }]\n *     });\n */\nExt.define('Ext.form.CheckboxGroup', {\n    extend:'Ext.form.FieldContainer',\n    mixins: {\n        field: 'Ext.form.field.Field'\n    },\n    alias: 'widget.checkboxgroup',\n    requires: ['Ext.layout.container.CheckboxGroup', 'Ext.form.field.Base'],\n\n    /**\n     * @cfg {String} name\n     * @private\n     */\n\n    /**\n     * @cfg {Ext.form.field.Checkbox[]/Object[]} items\n     * An Array of {@link Ext.form.field.Checkbox Checkbox}es or Checkbox config objects to arrange in the group.\n     */\n\n    /**\n     * @cfg {String/Number/Number[]} columns\n     * Specifies the number of columns to use when displaying grouped checkbox/radio controls using automatic layout.\n     * This config can take several types of values:\n     *\n     * - 'auto' - The controls will be rendered one per column on one row and the width of each column will be evenly\n     *   distributed based on the width of the overall field container. This is the default.\n     * - Number - If you specific a number (e.g., 3) that number of columns will be created and the contained controls\n     *   will be automatically distributed based on the value of {@link #vertical}.\n     * - Array - You can also specify an array of column widths, mixing integer (fixed width) and float (percentage\n     *   width) values as needed (e.g., [100, .25, .75]). Any integer values will be rendered first, then any float\n     *   values will be calculated as a percentage of the remaining space. Float values do not have to add up to 1\n     *   (100%) although if you want the controls to take up the entire field container you should do so.\n     */\n    columns : 'auto',\n\n    /**\n     * @cfg {Boolean} vertical\n     * True to distribute contained controls across columns, completely filling each column top to bottom before\n     * starting on the next column. The number of controls in each column will be automatically calculated to keep\n     * columns as even as possible. The default value is false, so that controls will be added to columns one at a time,\n     * completely filling each row left to right before starting on the next row.\n     */\n    vertical : false,\n\n    /**\n     * @cfg {Boolean} allowBlank\n     * False to validate that at least one item in the group is checked. If no items are selected at\n     * validation time, {@link #blankText} will be used as the error text.\n     */\n    allowBlank : true,\n\n    //<locale>\n    /**\n     * @cfg {String} blankText\n     * Error text to display if the {@link #allowBlank} validation fails\n     */\n    blankText : \"You must select at least one item in this group\",\n    //</locale>\n\n    // private\n    defaultType : 'checkboxfield',\n\n    // private\n    groupCls : Ext.baseCSSPrefix + 'form-check-group',\n\n    /**\n     * @cfg {String} [fieldBodyCls='x-form-checkboxgroup-body']\n     * An extra CSS class to be applied to the body content element in addition to {@link #baseBodyCls}.\n     */\n    fieldBodyCls: Ext.baseCSSPrefix + 'form-checkboxgroup-body',\n\n    // private\n    layout: 'checkboxgroup',\n\n    initComponent: function() {\n        var me = this;\n        me.callParent();\n        me.initField();\n    },\n\n    /**\n     * Initializes the field's value based on the initial config. If the {@link #value} config is specified then we use\n     * that to set the value; otherwise we initialize the originalValue by querying the values of all sub-checkboxes\n     * after they have been initialized.\n     * @protected\n     */\n    initValue: function() {\n        var me = this,\n            valueCfg = me.value;\n        me.originalValue = me.lastValue = valueCfg || me.getValue();\n        if (valueCfg) {\n            me.setValue(valueCfg);\n        }\n    },\n\n    /**\n     * When a checkbox is added to the group, monitor it for changes\n     * @param {Object} field\n     * @protected\n     */\n    onFieldAdded: function(field) {\n        var me = this;\n        if (field.isCheckbox) {\n            me.mon(field, 'change', me.checkChange, me);\n        }\n        me.callParent(arguments);\n    },\n\n    onFieldRemoved: function(field) {\n        var me = this;\n        if (field.isCheckbox) {\n            me.mun(field, 'change', me.checkChange, me);\n        }\n        me.callParent(arguments);\n    },\n\n    // private override - the group value is a complex object, compare using object serialization\n    isEqual: function(value1, value2) {\n        var toQueryString = Ext.Object.toQueryString;\n        return toQueryString(value1) === toQueryString(value2);\n    },\n\n    /**\n     * Runs CheckboxGroup's validations and returns an array of any errors. The only error by default is if allowBlank\n     * is set to true and no items are checked.\n     * @return {String[]} Array of all validation errors\n     */\n    getErrors: function() {\n        var errors = [];\n        if (!this.allowBlank && Ext.isEmpty(this.getChecked())) {\n            errors.push(this.blankText);\n        }\n        return errors;\n    },\n\n    /**\n     * @private Returns all checkbox components within the container\n     * @param {String} [query] An additional query to add to the selector.\n     */\n    getBoxes: function(query) {\n        return this.query('[isCheckbox]' + (query||''));\n    },\n\n    /**\n     * @private Convenience function which calls the given function for every checkbox in the group\n     * @param {Function} fn The function to call\n     * @param {Object} [scope] scope object\n     */\n    eachBox: function(fn, scope) {\n        Ext.Array.forEach(this.getBoxes(), fn, scope || this);\n    },\n\n    /**\n     * Returns an Array of all checkboxes in the container which are currently checked\n     * @return {Ext.form.field.Checkbox[]} Array of Ext.form.field.Checkbox components\n     */\n    getChecked: function() {\n        return this.getBoxes('[checked]');\n    },\n\n    // private override\n    isDirty: function(){\n        var boxes = this.getBoxes(),\n            b ,\n            bLen  = boxes.length;\n\n        for (b = 0; b < bLen; b++) {\n            if (boxes[b].isDirty()) {\n                return true;\n            }\n        }\n    },\n\n    // private override\n    setReadOnly: function(readOnly) {\n        var boxes = this.getBoxes(),\n            b,\n            bLen  = boxes.length;\n\n        for (b = 0; b < bLen; b++) {\n            boxes[b].setReadOnly(readOnly);\n        }\n\n        this.readOnly = readOnly;\n    },\n\n    /**\n     * Resets the checked state of all {@link Ext.form.field.Checkbox checkboxes} in the group to their originally\n     * loaded values and clears any validation messages.\n     * See {@link Ext.form.Basic}.{@link Ext.form.Basic#trackResetOnLoad trackResetOnLoad}\n     */\n    reset: function() {\n        var me = this,\n            hadError = me.hasActiveError(),\n            preventMark = me.preventMark;\n        me.preventMark = true;\n        me.batchChanges(function() {\n            var boxes = me.getBoxes(),\n                b,\n                bLen  = boxes.length;\n\n            for (b = 0; b < bLen; b++) {\n                boxes[b].reset();\n            }\n        });\n        me.preventMark = preventMark;\n        me.unsetActiveError();\n        if (hadError) {\n            me.updateLayout();\n        }\n    },\n\n    resetOriginalValue: function(){\n        var me    = this,\n            boxes = me.getBoxes(),\n            b,\n            bLen  = boxes.length;\n\n        for (b = 0; b < bLen; b++) {\n            boxes[b].resetOriginalValue();\n        }\n\n        me.originalValue = me.getValue();\n        me.checkDirty();\n    },\n\n\n    /**\n     * Sets the value(s) of all checkboxes in the group. The expected format is an Object of name-value pairs\n     * corresponding to the names of the checkboxes in the group. Each pair can have either a single or multiple values:\n     *\n     *   - A single Boolean or String value will be passed to the `setValue` method of the checkbox with that name.\n     *     See the rules in {@link Ext.form.field.Checkbox#setValue} for accepted values.\n     *   - An Array of String values will be matched against the {@link Ext.form.field.Checkbox#inputValue inputValue}\n     *     of checkboxes in the group with that name; those checkboxes whose inputValue exists in the array will be\n     *     checked and others will be unchecked.\n     *\n     * If a checkbox's name is not in the mapping at all, it will be unchecked.\n     *\n     * An example:\n     *\n     *     var myCheckboxGroup = new Ext.form.CheckboxGroup({\n     *         columns: 3,\n     *         items: [{\n     *             name: 'cb1',\n     *             boxLabel: 'Single 1'\n     *         }, {\n     *             name: 'cb2',\n     *             boxLabel: 'Single 2'\n     *         }, {\n     *             name: 'cb3',\n     *             boxLabel: 'Single 3'\n     *         }, {\n     *             name: 'cbGroup',\n     *             boxLabel: 'Grouped 1'\n     *             inputValue: 'value1'\n     *         }, {\n     *             name: 'cbGroup',\n     *             boxLabel: 'Grouped 2'\n     *             inputValue: 'value2'\n     *         }, {\n     *             name: 'cbGroup',\n     *             boxLabel: 'Grouped 3'\n     *             inputValue: 'value3'\n     *         }]\n     *     });\n     *\n     *     myCheckboxGroup.setValue({\n     *         cb1: true,\n     *         cb3: false,\n     *         cbGroup: ['value1', 'value3']\n     *     });\n     *\n     * The above code will cause the checkbox named 'cb1' to be checked, as well as the first and third checkboxes named\n     * 'cbGroup'. The other three checkboxes will be unchecked.\n     *\n     * @param {Object} value The mapping of checkbox names to values.\n     * @return {Ext.form.CheckboxGroup} this\n     */\n    setValue: function(value) {\n        var me    = this,\n            boxes = me.getBoxes(),\n            b,\n            bLen  = boxes.length,\n            box, name,\n            cbValue;\n\n        me.batchChanges(function() {\n            for (b = 0; b < bLen; b++) {\n                box = boxes[b];\n                name = box.getName();\n                cbValue = false;\n\n                if (value && value.hasOwnProperty(name)) {\n                    if (Ext.isArray(value[name])) {\n                        cbValue = Ext.Array.contains(value[name], box.inputValue);\n                    } else {\n                        // single value, let the checkbox's own setValue handle conversion\n                        cbValue = value[name];\n                    }\n                }\n\n                box.setValue(cbValue);\n            }\n        });\n        return me;\n    },\n\n\n    /**\n     * Returns an object containing the values of all checked checkboxes within the group. Each key-value pair in the\n     * object corresponds to a checkbox {@link Ext.form.field.Checkbox#name name}. If there is only one checked checkbox\n     * with a particular name, the value of that pair will be the String {@link Ext.form.field.Checkbox#inputValue\n     * inputValue} of that checkbox. If there are multiple checked checkboxes with that name, the value of that pair\n     * will be an Array of the selected inputValues.\n     *\n     * The object format returned from this method can also be passed directly to the {@link #setValue} method.\n     *\n     * NOTE: In Ext 3, this method returned an array of Checkbox components; this was changed to make it more consistent\n     * with other field components and with the {@link #setValue} argument signature. If you need the old behavior in\n     * Ext 4+, use the {@link #getChecked} method instead.\n     */\n    getValue: function() {\n        var values = {},\n            boxes  = this.getBoxes(),\n            b,\n            bLen   = boxes.length,\n            box, name, inputValue, bucket;\n\n        for (b = 0; b < bLen; b++) {\n            box        = boxes[b];\n            name       = box.getName();\n            inputValue = box.inputValue;\n\n            if (box.getValue()) {\n                if (values.hasOwnProperty(name)) {\n                    bucket = values[name];\n                    if (!Ext.isArray(bucket)) {\n                        bucket = values[name] = [bucket];\n                    }\n                    bucket.push(inputValue);\n                } else {\n                    values[name] = inputValue;\n                }\n            }\n        }\n\n        return values;\n    },\n\n    /*\n     * Don't return any data for submit; the form will get the info from the individual checkboxes themselves.\n     */\n    getSubmitData: function() {\n        return null;\n    },\n\n    /*\n     * Don't return any data for the model; the form will get the info from the individual checkboxes themselves.\n     */\n    getModelData: function() {\n        return null;\n    },\n\n    validate: function() {\n        var me = this,\n            errors,\n            isValid,\n            wasValid;\n\n        if (me.disabled) {\n            isValid = true;\n        } else {\n            errors = me.getErrors();\n            isValid = Ext.isEmpty(errors);\n            wasValid = !me.hasActiveError();\n            if (isValid) {\n                me.unsetActiveError();\n            } else {\n                me.setActiveError(errors);\n            }\n        }\n        if (isValid !== wasValid) {\n            me.fireEvent('validitychange', me, isValid);\n            me.updateLayout();\n        }\n\n        return isValid;\n    }\n\n}, function() {\n\n    this.borrow(Ext.form.field.Base, ['markInvalid', 'clearInvalid']);\n\n});\n\n\n/**\n * @private\n * Private utility class for managing all {@link Ext.form.field.Checkbox} fields grouped by name.\n */\nExt.define('Ext.form.CheckboxManager', {\n    extend: 'Ext.util.MixedCollection',\n    singleton: true,\n\n    getByName: function(name) {\n        return this.filterBy(function(item) {\n            return item.name == name;\n        });\n    },\n\n    getWithValue: function(name, value) {\n        return this.filterBy(function(item) {\n            return item.name == name && item.inputValue == value;\n        });\n    },\n\n    getChecked: function(name) {\n        return this.filterBy(function(item) {\n            return item.name == name && item.checked;\n        });\n    }\n});\n\n/**\n * Component layout for Ext.form.FieldSet components\n * @private\n */\nExt.define('Ext.layout.component.FieldSet', {\n    extend: 'Ext.layout.component.Body',\n    alias: ['layout.fieldset'],\n\n    type: 'fieldset',\n\n    beforeLayoutCycle: function (ownerContext) {\n        if (ownerContext.target.collapsed) {\n            ownerContext.heightModel = this.sizeModels.shrinkWrap;\n        }\n    },\n\n    beginLayoutCycle: function (ownerContext) {\n        var target = ownerContext.target,\n            lastSize;\n\n        this.callParent(arguments);\n\n        // Each time we begin (2nd+ would be due to invalidate) we need to publish the\n        // known contentHeight if we are collapsed:\n        //\n        if (target.collapsed) {\n            ownerContext.setContentHeight(0);\n\n            // If we are also shrinkWrap width, we must provide a contentWidth (since the\n            // container layout is not going to run).\n            //\n            if (ownerContext.widthModel.shrinkWrap) {\n                lastSize = target.lastComponentSize;\n                ownerContext.setContentWidth((lastSize && lastSize.contentWidth) || 100);\n            }\n        }\n    },\n\n    calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {\n        var border = ownerContext.getBorderInfo(),\n            legend = ownerContext.target.legend;\n            \n        // Height of fieldset is content height plus top border width (which is either the legend height or top border width) plus bottom border width\n        return ownerContext.getProp('contentHeight') + ownerContext.getPaddingInfo().height + (legend ? legend.getHeight() : border.top) + border.bottom;\n    },\n\n    publishInnerHeight: function (ownerContext, height) {\n        // Subtract the legend off here and pass it up to the body\n        // We do this because we don't want to set an incorrect body height\n        // and then setting it again with the correct value\n        var legend = ownerContext.target.legend;\n        if (legend) {\n            height -= legend.getHeight();\n        }\n        this.callParent([ownerContext, height]);\n    },\n\n    getLayoutItems : function() {\n        var legend = this.owner.legend;\n        if (legend) {\n            return [legend];\n        }\n        return [];\n    }\n});\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * A container for grouping sets of fields, rendered as a HTML `fieldset` element. The {@link #title}\n * config will be rendered as the fieldset's `legend`.\n *\n * While FieldSets commonly contain simple groups of fields, they are general {@link Ext.container.Container Containers}\n * and may therefore contain any type of components in their {@link #cfg-items}, including other nested containers.\n * The default {@link #layout} for the FieldSet's items is `'anchor'`, but it can be configured to use any other\n * layout type.\n *\n * FieldSets may also be collapsed if configured to do so; this can be done in two ways:\n *\n * 1. Set the {@link #collapsible} config to true; this will result in a collapse button being rendered next to\n *    the {@link #title legend title}, or:\n * 2. Set the {@link #checkboxToggle} config to true; this is similar to using {@link #collapsible} but renders\n *    a {@link Ext.form.field.Checkbox checkbox} in place of the toggle button. The fieldset will be expanded when the\n *    checkbox is checked and collapsed when it is unchecked. The checkbox will also be included in the\n *    {@link Ext.form.Basic#submit form submit parameters} using the {@link #checkboxName} as its parameter name.\n *\n * # Example usage\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Simple Form with FieldSets',\n *         labelWidth: 75, // label settings here cascade unless overridden\n *         url: 'save-form.php',\n *         frame: true,\n *         bodyStyle: 'padding:5px 5px 0',\n *         width: 550,\n *         renderTo: Ext.getBody(),\n *         layout: 'column', // arrange fieldsets side by side\n *         defaults: {\n *             bodyPadding: 4\n *         },\n *         items: [{\n *             // Fieldset in Column 1 - collapsible via toggle button\n *             xtype:'fieldset',\n *             columnWidth: 0.5,\n *             title: 'Fieldset 1',\n *             collapsible: true,\n *             defaultType: 'textfield',\n *             defaults: {anchor: '100%'},\n *             layout: 'anchor',\n *             items :[{\n *                 fieldLabel: 'Field 1',\n *                 name: 'field1'\n *             }, {\n *                 fieldLabel: 'Field 2',\n *                 name: 'field2'\n *             }]\n *         }, {\n *             // Fieldset in Column 2 - collapsible via checkbox, collapsed by default, contains a panel\n *             xtype:'fieldset',\n *             title: 'Show Panel', // title or checkboxToggle creates fieldset header\n *             columnWidth: 0.5,\n *             checkboxToggle: true,\n *             collapsed: true, // fieldset initially collapsed\n *             layout:'anchor',\n *             items :[{\n *                 xtype: 'panel',\n *                 anchor: '100%',\n *                 title: 'Panel inside a fieldset',\n *                 frame: true,\n *                 height: 52\n *             }]\n *         }]\n *     });\n */\nExt.define('Ext.form.FieldSet', {\n    extend: 'Ext.container.Container',\n    alias: 'widget.fieldset',\n    uses: ['Ext.form.field.Checkbox', 'Ext.panel.Tool', 'Ext.layout.container.Anchor', 'Ext.layout.component.FieldSet'],\n\n    /**\n     * @cfg {String} title\n     * A title to be displayed in the fieldset's legend. May contain HTML markup.\n     */\n\n    /**\n     * @cfg {Boolean} [checkboxToggle=false]\n     * Set to true to render a checkbox into the fieldset frame just in front of the legend to expand/collapse the\n     * fieldset when the checkbox is toggled.. This checkbox will be included in form submits using\n     * the {@link #checkboxName}.\n     */\n\n    /**\n     * @cfg {String} checkboxName\n     * The name to assign to the fieldset's checkbox if {@link #checkboxToggle} = true\n     * (defaults to '[fieldset id]-checkbox').\n     */\n\n    /**\n     * @cfg {Boolean} [collapsible=false]\n     * Set to true to make the fieldset collapsible and have the expand/collapse toggle button automatically rendered\n     * into the legend element, false to keep the fieldset statically sized with no collapse button.\n     * Another option is to configure {@link #checkboxToggle}. Use the {@link #collapsed} config to collapse the\n     * fieldset by default.\n     */\n\n    /**\n     * @cfg {Boolean} collapsed\n     * Set to true to render the fieldset as collapsed by default. If {@link #checkboxToggle} is specified, the checkbox\n     * will also be unchecked by default.\n     */\n    collapsed: false,\n\n    /**\n     * @cfg {Boolean} [toggleOnTitleClick=true]\n     * Set to true will add a listener to the titleCmp property for the click event which will execute the\n     * {@link #toggle} method. This option is only used when the {@link #collapsible} property is set to true.\n     */\n    toggleOnTitleClick : true,\n\n    /**\n     * @property {Ext.Component} legend\n     * The component for the fieldset's legend. Will only be defined if the configuration requires a legend to be\n     * created, by setting the {@link #title} or {@link #checkboxToggle} options.\n     */\n\n    /**\n     * @cfg {String} [baseCls='x-fieldset']\n     * The base CSS class applied to the fieldset.\n     */\n    baseCls: Ext.baseCSSPrefix + 'fieldset',\n\n    /**\n     * @cfg {String} layout\n     * The {@link Ext.container.Container#layout} for the fieldset's immediate child items.\n     */\n    layout: 'anchor',\n\n    border: 1,\n\n    componentLayout: 'fieldset',\n\n    autoEl: 'fieldset',\n\n    childEls: [\n        'body'\n    ],\n\n    renderTpl: [\n        '{%this.renderLegend(out,values);%}',\n        '<div id=\"{id}-body\" class=\"{baseCls}-body\">',\n            '{%this.renderContainer(out,values);%}',\n        '</div>'\n    ],\n\n    stateEvents : [ 'collapse', 'expand' ],\n\n    maskOnDisable: false,\n\n    beforeDestroy: function(){\n        var me = this,\n            legend = me.legend;\n\n        if (legend) {\n            // get rid of the ownerCt since it's not a proper item\n            delete legend.ownerCt;\n            legend.destroy();\n            me.legend = null;\n        }\n        me.callParent();\n    },\n\n    initComponent: function() {\n        var me = this,\n            baseCls = me.baseCls;\n\n        me.callParent();\n\n        me.addEvents(\n\n            /**\n             * @event beforeexpand\n             * Fires before this FieldSet is expanded. Return false to prevent the expand.\n             * @param {Ext.form.FieldSet} f The FieldSet being expanded.\n             */\n            \"beforeexpand\",\n\n            /**\n             * @event beforecollapse\n             * Fires before this FieldSet is collapsed. Return false to prevent the collapse.\n             * @param {Ext.form.FieldSet} f The FieldSet being collapsed.\n             */\n            \"beforecollapse\",\n\n            /**\n             * @event expand\n             * Fires after this FieldSet has expanded.\n             * @param {Ext.form.FieldSet} f The FieldSet that has been expanded.\n             */\n            \"expand\",\n\n            /**\n             * @event collapse\n             * Fires after this FieldSet has collapsed.\n             * @param {Ext.form.FieldSet} f The FieldSet that has been collapsed.\n             */\n            \"collapse\"\n        );\n\n        if (me.collapsed) {\n            me.addCls(baseCls + '-collapsed');\n            me.collapse();\n        }\n        if (me.title) {\n            me.addCls(baseCls + '-with-title');\n        }\n        if (me.title || me.checkboxToggle || me.collapsible) {\n            me.addCls(baseCls + '-with-legend');\n            me.legend = Ext.widget(me.createLegendCt());\n        }\n    },\n\n    /**\n     * Initialized the renderData to be used when rendering the renderTpl.\n     * @return {Object} Object with keys and values that are going to be applied to the renderTpl\n     * @private\n     */\n    initRenderData: function() {\n        var data = this.callParent();\n\n        data.baseCls = this.baseCls;\n\n        return data;\n    },\n\n    getState: function () {\n        var state = this.callParent();\n\n        state = this.addPropertyToState(state, 'collapsed');\n\n        return state;\n    },\n\n    afterCollapse: Ext.emptyFn,\n    afterExpand: Ext.emptyFn,\n\n    collapsedHorizontal: function () {\n        return true;\n    },\n\n    collapsedVertical: function () {\n        return true;\n    },\n\n    createLegendCt: function () {\n        var me = this,\n            items = [],\n            legend = {\n                xtype: 'container',\n                baseCls: me.baseCls + '-header',\n                id: me.id + '-legend',\n                autoEl: 'legend',\n                items: items,\n                ownerCt: me,\n                ownerLayout: me.componentLayout\n            };\n\n        // Checkbox\n        if (me.checkboxToggle) {\n            items.push(me.createCheckboxCmp());\n        } else if (me.collapsible) {\n            // Toggle button\n            items.push(me.createToggleCmp());\n        }\n\n        // Title\n        items.push(me.createTitleCmp());\n\n        return legend;\n    },\n\n    /**\n     * Creates the legend title component. This is only called internally, but could be overridden in subclasses to\n     * customize the title component. If {@link #toggleOnTitleClick} is set to true, a listener for the click event\n     * will toggle the collapsed state of the FieldSet.\n     * @return Ext.Component\n     * @protected\n     */\n    createTitleCmp: function() {\n        var me  = this,\n            cfg = {\n                xtype : 'component',\n                html  : me.title,\n                cls   : me.baseCls + '-header-text',\n                id    : me.id + '-legendTitle'\n            };\n\n        if (me.collapsible && me.toggleOnTitleClick) {\n            cfg.listeners = {\n                el : {\n                    scope : me,\n                    click : me.toggle\n                }\n            };\n            cfg.cls += ' ' + me.baseCls + '-header-text-collapsible';\n        }\n\n        return (me.titleCmp = Ext.widget(cfg));\n    },\n\n    /**\n     * @property {Ext.form.field.Checkbox} checkboxCmp\n     * Refers to the {@link Ext.form.field.Checkbox} component that is added next to the title in the legend. Only\n     * populated if the fieldset is configured with {@link #checkboxToggle}:true.\n     */\n\n    /**\n     * Creates the checkbox component. This is only called internally, but could be overridden in subclasses to\n     * customize the checkbox's configuration or even return an entirely different component type.\n     * @return Ext.Component\n     * @protected\n     */\n    createCheckboxCmp: function() {\n        var me = this,\n            suffix = '-checkbox';\n\n        me.checkboxCmp = Ext.widget({\n            xtype: 'checkbox',\n            hideEmptyLabel: true,\n            name: me.checkboxName || me.id + suffix,\n            cls: me.baseCls + '-header' + suffix,\n            id: me.id + '-legendChk',\n            checked: !me.collapsed,\n            listeners: {\n                change: me.onCheckChange,\n                scope: me\n            }\n        });\n        return me.checkboxCmp;\n    },\n\n    /**\n     * @property {Ext.panel.Tool} toggleCmp\n     * Refers to the {@link Ext.panel.Tool} component that is added as the collapse/expand button next to the title in\n     * the legend. Only populated if the fieldset is configured with {@link #collapsible}:true.\n     */\n\n    /**\n     * Creates the toggle button component. This is only called internally, but could be overridden in subclasses to\n     * customize the toggle component.\n     * @return Ext.Component\n     * @protected\n     */\n    createToggleCmp: function() {\n        var me = this;\n        me.toggleCmp = Ext.widget({\n            xtype: 'tool',\n            type: 'toggle',\n            handler: me.toggle,\n            id: me.id + '-legendToggle',\n            scope: me\n        });\n        return me.toggleCmp;\n    },\n\n    doRenderLegend: function (out, renderData) {\n        // Careful! This method is bolted on to the renderTpl so all we get for context is\n        // the renderData! The \"this\" pointer is the renderTpl instance!\n\n        var me = renderData.$comp,\n            legend = me.legend,\n            tree;\n            \n        // Create the Legend component if needed\n        if (legend) {\n            legend.ownerLayout.configureItem(legend);\n            tree = legend.getRenderTree();\n            Ext.DomHelper.generateMarkup(tree, out);\n        }\n    },\n\n    finishRender: function () {\n        var legend = this.legend;\n\n        this.callParent();\n\n        if (legend) {\n            legend.finishRender();\n        }\n    },\n\n    getCollapsed: function () {\n        return this.collapsed ? 'top' : false;\n    },\n\n    getCollapsedDockedItems: function () {\n        var legend = this.legend;\n\n        return legend ? [ legend ] : [];\n    },\n\n    /**\n     * Sets the title of this fieldset\n     * @param {String} title The new title\n     * @return {Ext.form.FieldSet} this\n     */\n    setTitle: function(title) {\n        var me = this,\n            legend = me.legend;\n            \n        me.title = title;\n        if (me.rendered) {\n            if (!me.legend) {\n                me.legend = legend = Ext.widget(me.createLegendCt());\n                legend.ownerLayout.configureItem(legend);\n                legend.render(me.el, 0);\n            }\n            me.titleCmp.update(title);\n        }\n        return me;\n    },\n\n    getTargetEl : function() {\n        return this.body || this.frameBody || this.el;\n    },\n\n    getContentTarget: function() {\n        return this.body;\n    },\n\n    /**\n     * Expands the fieldset.\n     * @return {Ext.form.FieldSet} this\n     */\n    expand : function(){\n        return this.setExpanded(true);\n    },\n\n    /**\n     * Collapses the fieldset.\n     * @return {Ext.form.FieldSet} this\n     */\n    collapse : function() {\n        return this.setExpanded(false);\n    },\n\n    /**\n     * @private Collapse or expand the fieldset\n     */\n    setExpanded: function(expanded) {\n        var me = this,\n            checkboxCmp = me.checkboxCmp,\n            operation = expanded ? 'expand' : 'collapse';\n\n        if (!me.rendered || me.fireEvent('before' + operation, me) !== false) {\n            expanded = !!expanded;\n\n            if (checkboxCmp) {\n                checkboxCmp.setValue(expanded);\n            }\n\n            if (expanded) {\n                me.removeCls(me.baseCls + '-collapsed');\n            } else {\n                me.addCls(me.baseCls + '-collapsed');\n            }\n            me.collapsed = !expanded;\n            if (me.rendered) {\n                // say explicitly we are not root because when we have a fixed/configured height\n                // our ownerLayout would say we are root and so would not have it's height\n                // updated since it's not included in the layout cycle\n                me.updateLayout({ isRoot: false });\n                me.fireEvent(operation, me);\n            }\n        }\n        return me;\n    },\n    \n    getRefItems: function(deep) {\n        var refItems = this.callParent(arguments),\n            legend = this.legend;\n\n        // Prepend legend items to ensure correct order\n        if (legend) {\n            refItems.unshift(legend);\n            if (deep) {\n                refItems.unshift.apply(refItems, legend.getRefItems(true));\n            }\n        }\n        return refItems;\n    },\n\n    /**\n     * Toggle the fieldset's collapsed state to the opposite of what it is currently\n     */\n    toggle: function() {\n        this.setExpanded(!!this.collapsed);\n    },\n\n    /**\n     * @private\n     * Handle changes in the checkbox checked state\n     */\n    onCheckChange: function(cmp, checked) {\n        this.setExpanded(checked);\n    },\n\n    setupRenderTpl: function (renderTpl) {\n        this.callParent(arguments);\n\n        renderTpl.renderLegend = this.doRenderLegend;\n    }\n});\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * Produces a standalone `<label />` element which can be inserted into a form and be associated with a field\n * in that form using the {@link #forId} property.\n * \n * **NOTE:** in most cases it will be more appropriate to use the {@link Ext.form.Labelable#fieldLabel fieldLabel}\n * and associated config properties ({@link Ext.form.Labelable#labelAlign}, {@link Ext.form.Labelable#labelWidth},\n * etc.) in field components themselves, as that allows labels to be uniformly sized throughout the form.\n * Ext.form.Label should only be used when your layout can not be achieved with the standard\n * {@link Ext.form.Labelable field layout}.\n * \n * You will likely be associating the label with a field component that extends {@link Ext.form.field.Base}, so\n * you should make sure the {@link #forId} is set to the same value as the {@link Ext.form.field.Base#inputId inputId}\n * of that field.\n * \n * The label's text can be set using either the {@link #text} or {@link #html} configuration properties; the\n * difference between the two is that the former will automatically escape HTML characters when rendering, while\n * the latter will not.\n *\n * # Example\n * \n * This example creates a Label after its associated Text field, an arrangement that cannot currently\n * be achieved using the standard Field layout's labelAlign.\n * \n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Field with Label',\n *         width: 400,\n *         bodyPadding: 10,\n *         renderTo: Ext.getBody(),\n *         layout: {\n *             type: 'hbox',\n *             align: 'middle'\n *         },\n *         items: [{\n *             xtype: 'textfield',\n *             hideLabel: true,\n *             flex: 1\n *         }, {\n *             xtype: 'label',\n *             forId: 'myFieldId',\n *             text: 'My Awesome Field',\n *             margin: '0 0 0 10'\n *         }]\n *     });\n */\nExt.define('Ext.form.Label', {\n    extend:'Ext.Component',\n    alias: 'widget.label',\n    requires: ['Ext.util.Format'],\n\n    autoEl: 'label',\n\n    /**\n     * @cfg {String} [text='']\n     * The plain text to display within the label. If you need to include HTML\n     * tags within the label's innerHTML, use the {@link #html} config instead.\n     */\n    /**\n     * @cfg {String} forId\n     * The id of the input element to which this label will be bound via the standard HTML 'for'\n     * attribute. If not specified, the attribute will not be added to the label. In most cases you will be\n     * associating the label with a {@link Ext.form.field.Base} component, so you should make sure this matches\n     * the {@link Ext.form.field.Base#inputId inputId} of that field.\n     */\n    /**\n     * @cfg {String} [html='']\n     * An HTML fragment that will be used as the label's innerHTML.\n     * Note that if {@link #text} is specified it will take precedence and this value will be ignored.\n     */\n    \n    maskOnDisable: false,\n\n    getElConfig: function(){\n        var me = this;\n\n        me.html = me.text ? Ext.util.Format.htmlEncode(me.text) : (me.html || '');\n        return Ext.apply(me.callParent(), {\n            htmlFor: me.forId || ''\n        });\n    },\n\n    /**\n     * Updates the label's innerHTML with the specified string.\n     * @param {String} text The new label text\n     * @param {Boolean} [encode=true] False to skip HTML-encoding the text when rendering it\n     * to the label. This might be useful if you want to include tags in the label's innerHTML rather\n     * than rendering them as string literals per the default logic.\n     * @return {Ext.form.Label} this\n     */\n    setText : function(text, encode){\n        var me = this;\n        \n        encode = encode !== false;\n        if(encode) {\n            me.text = text;\n            delete me.html;\n        } else {\n            me.html = text;\n            delete me.text;\n        }\n        \n        if(me.rendered){\n            me.el.dom.innerHTML = encode !== false ? Ext.util.Format.htmlEncode(text) : text;\n            me.updateLayout();\n        }\n        return me;\n    }\n});\n\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n * \n * FormPanel provides a standard container for forms. It is essentially a standard {@link Ext.panel.Panel} which\n * automatically creates a {@link Ext.form.Basic BasicForm} for managing any {@link Ext.form.field.Field}\n * objects that are added as descendants of the panel. It also includes conveniences for configuring and\n * working with the BasicForm and the collection of Fields.\n * \n * # Layout\n * \n * By default, FormPanel is configured with `{@link Ext.layout.container.Anchor layout:'anchor'}` for\n * the layout of its immediate child items. This can be changed to any of the supported container layouts.\n * The layout of sub-containers is configured in {@link Ext.container.Container#layout the standard way}.\n * \n * # BasicForm\n * \n * Although **not listed** as configuration options of FormPanel, the FormPanel class accepts all\n * of the config options supported by the {@link Ext.form.Basic} class, and will pass them along to\n * the internal BasicForm when it is created.\n * \n * The following events fired by the BasicForm will be re-fired by the FormPanel and can therefore be\n * listened for on the FormPanel itself:\n * \n * - {@link Ext.form.Basic#beforeaction beforeaction}\n * - {@link Ext.form.Basic#actionfailed actionfailed}\n * - {@link Ext.form.Basic#actioncomplete actioncomplete}\n * - {@link Ext.form.Basic#validitychange validitychange}\n * - {@link Ext.form.Basic#dirtychange dirtychange}\n * \n * # Field Defaults\n * \n * The {@link #fieldDefaults} config option conveniently allows centralized configuration of default values\n * for all fields added as descendants of the FormPanel. Any config option recognized by implementations\n * of {@link Ext.form.Labelable} may be included in this object. See the {@link #fieldDefaults} documentation\n * for details of how the defaults are applied.\n * \n * # Form Validation\n * \n * With the default configuration, form fields are validated on-the-fly while the user edits their values.\n * This can be controlled on a per-field basis (or via the {@link #fieldDefaults} config) with the field\n * config properties {@link Ext.form.field.Field#validateOnChange} and {@link Ext.form.field.Base#checkChangeEvents},\n * and the FormPanel's config properties {@link #pollForChanges} and {@link #pollInterval}.\n * \n * Any component within the FormPanel can be configured with `formBind: true`. This will cause that\n * component to be automatically disabled when the form is invalid, and enabled when it is valid. This is most\n * commonly used for Button components to prevent submitting the form in an invalid state, but can be used on\n * any component type.\n * \n * For more information on form validation see the following:\n * \n * - {@link Ext.form.field.Field#validateOnChange}\n * - {@link #pollForChanges} and {@link #pollInterval}\n * - {@link Ext.form.field.VTypes}\n * - {@link Ext.form.Basic#doAction BasicForm.doAction clientValidation notes}\n * \n * # Form Submission\n * \n * By default, Ext Forms are submitted through Ajax, using {@link Ext.form.action.Action}. See the documentation for\n * {@link Ext.form.Basic} for details.\n *\n * # Example usage\n * \n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Simple Form',\n *         bodyPadding: 5,\n *         width: 350,\n * \n *         // The form will submit an AJAX request to this URL when submitted\n *         url: 'save-form.php',\n * \n *         // Fields will be arranged vertically, stretched to full width\n *         layout: 'anchor',\n *         defaults: {\n *             anchor: '100%'\n *         },\n * \n *         // The fields\n *         defaultType: 'textfield',\n *         items: [{\n *             fieldLabel: 'First Name',\n *             name: 'first',\n *             allowBlank: false\n *         },{\n *             fieldLabel: 'Last Name',\n *             name: 'last',\n *             allowBlank: false\n *         }],\n * \n *         // Reset and Submit buttons\n *         buttons: [{\n *             text: 'Reset',\n *             handler: function() {\n *                 this.up('form').getForm().reset();\n *             }\n *         }, {\n *             text: 'Submit',\n *             formBind: true, //only enabled once the form is valid\n *             disabled: true,\n *             handler: function() {\n *                 var form = this.up('form').getForm();\n *                 if (form.isValid()) {\n *                     form.submit({\n *                         success: function(form, action) {\n *                            Ext.Msg.alert('Success', action.result.msg);\n *                         },\n *                         failure: function(form, action) {\n *                             Ext.Msg.alert('Failed', action.result.msg);\n *                         }\n *                     });\n *                 }\n *             }\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n *\n */\nExt.define('Ext.form.Panel', {\n    extend:'Ext.panel.Panel',\n    mixins: {\n        fieldAncestor: 'Ext.form.FieldAncestor'\n    },\n    alias: 'widget.form',\n    alternateClassName: ['Ext.FormPanel', 'Ext.form.FormPanel'],\n    requires: ['Ext.form.Basic', 'Ext.util.TaskRunner'],\n\n    /**\n     * @cfg {Boolean} pollForChanges\n     * If set to `true`, sets up an interval task (using the {@link #pollInterval}) in which the\n     * panel's fields are repeatedly checked for changes in their values. This is in addition to the normal detection\n     * each field does on its own input element, and is not needed in most cases. It does, however, provide a\n     * means to absolutely guarantee detection of all changes including some edge cases in some browsers which\n     * do not fire native events. Defaults to `false`.\n     */\n\n    /**\n     * @cfg {Number} pollInterval\n     * Interval in milliseconds at which the form's fields are checked for value changes. Only used if\n     * the {@link #pollForChanges} option is set to `true`. Defaults to 500 milliseconds.\n     */\n\n    /**\n     * @cfg {String} layout\n     * The {@link Ext.container.Container#layout} for the form panel's immediate child items.\n     * Defaults to `'anchor'`.\n     */\n    layout: 'anchor',\n\n    ariaRole: 'form',\n    \n    basicFormConfigs: [\n        'api', \n        'baseParams', \n        'errorReader', \n        'method', \n        'paramOrder',\n        'paramsAsHash',\n        'reader',\n        'standardSubmit',\n        'timeout',\n        'trackResetOnLoad',\n        'url',\n        'waitMsgTarget',\n        'waitTitle'\n    ],\n\n    initComponent: function() {\n        var me = this;\n\n        if (me.frame) {\n            me.border = false;\n        }\n\n        me.initFieldAncestor();\n        me.callParent();\n\n        me.relayEvents(me.form, [\n            /**\n             * @event beforeaction\n             * @inheritdoc Ext.form.Basic#beforeaction\n             */\n            'beforeaction',\n            /**\n             * @event actionfailed\n             * @inheritdoc Ext.form.Basic#actionfailed\n             */\n            'actionfailed',\n            /**\n             * @event actioncomplete\n             * @inheritdoc Ext.form.Basic#actioncomplete\n             */\n            'actioncomplete',\n            /**\n             * @event validitychange\n             * @inheritdoc Ext.form.Basic#validitychange\n             */\n            'validitychange',\n            /**\n             * @event dirtychange\n             * @inheritdoc Ext.form.Basic#dirtychange\n             */\n            'dirtychange'\n        ]);\n\n        // Start polling if configured\n        if (me.pollForChanges) {\n            me.startPolling(me.pollInterval || 500);\n        }\n    },\n\n    initItems: function() {\n        // Create the BasicForm\n        var me = this;\n\n        me.form = me.createForm();\n        me.callParent();\n    },\n\n    // Initialize the BasicForm after all layouts have been completed.\n    afterFirstLayout: function() {\n        this.callParent();\n        this.form.initialize();\n    },\n\n    /**\n     * @private\n     */\n    createForm: function() {\n        var cfg = {},\n            props = this.basicFormConfigs,\n            len = props.length,\n            i = 0,\n            prop;\n            \n        for (; i < len; ++i) {\n            prop = props[i];\n            cfg[prop] = this[prop];\n        }\n        return new Ext.form.Basic(this, cfg);\n    },\n\n    /**\n     * Provides access to the {@link Ext.form.Basic Form} which this Panel contains.\n     * @return {Ext.form.Basic} The {@link Ext.form.Basic Form} which this Panel contains.\n     */\n    getForm: function() {\n        return this.form;\n    },\n\n    /**\n     * Loads an {@link Ext.data.Model} into this form (internally just calls {@link Ext.form.Basic#loadRecord})\n     * See also {@link Ext.form.Basic#trackResetOnLoad trackResetOnLoad}.\n     * @param {Ext.data.Model} record The record to load\n     * @return {Ext.form.Basic} The Ext.form.Basic attached to this FormPanel\n     */\n    loadRecord: function(record) {\n        return this.getForm().loadRecord(record);\n    },\n\n    /**\n     * Returns the currently loaded Ext.data.Model instance if one was loaded via {@link #loadRecord}.\n     * @return {Ext.data.Model} The loaded instance\n     */\n    getRecord: function() {\n        return this.getForm().getRecord();\n    },\n\n    /**\n     * Convenience function for fetching the current value of each field in the form. This is the same as calling\n     * {@link Ext.form.Basic#getValues this.getForm().getValues()}.\n     *\n     * @inheritdoc Ext.form.Basic#getValues\n     */\n    getValues: function(asString, dirtyOnly, includeEmptyText, useDataValues) {\n        return this.getForm().getValues(asString, dirtyOnly, includeEmptyText, useDataValues);\n    },\n\n    beforeDestroy: function() {\n        this.stopPolling();\n        this.form.destroy();\n        this.callParent();\n    },\n\n    /**\n     * This is a proxy for the underlying BasicForm's {@link Ext.form.Basic#load} call.\n     * @param {Object} options The options to pass to the action (see {@link Ext.form.Basic#load} and\n     * {@link Ext.form.Basic#doAction} for details)\n     */\n    load: function(options) {\n        this.form.load(options);\n    },\n\n    /**\n     * This is a proxy for the underlying BasicForm's {@link Ext.form.Basic#submit} call.\n     * @param {Object} options The options to pass to the action (see {@link Ext.form.Basic#submit} and\n     * {@link Ext.form.Basic#doAction} for details)\n     */\n    submit: function(options) {\n        this.form.submit(options);\n    },\n\n    /**\n     * Start an interval task to continuously poll all the fields in the form for changes in their\n     * values. This is normally started automatically by setting the {@link #pollForChanges} config.\n     * @param {Number} interval The interval in milliseconds at which the check should run.\n     */\n    startPolling: function(interval) {\n        this.stopPolling();\n        var task = new Ext.util.TaskRunner(interval);\n        task.start({\n            interval: 0,\n            run: this.checkChange,\n            scope: this\n        });\n        this.pollTask = task;\n    },\n\n    /**\n     * Stop a running interval task that was started by {@link #startPolling}.\n     */\n    stopPolling: function() {\n        var task = this.pollTask;\n        if (task) {\n            task.stopAll();\n            delete this.pollTask;\n        }\n    },\n\n    /**\n     * Forces each field within the form panel to\n     * {@link Ext.form.field.Field#checkChange check if its value has changed}.\n     */\n    checkChange: function() {\n        var fields = this.form.getFields().items,\n            f,\n            fLen   = fields.length,\n            field;\n\n        for (f = 0; f < fLen; f++) {\n            fields[f].checkChange();\n        }\n    }\n});\n\n/**\n * A {@link Ext.form.FieldContainer field container} which has a specialized layout for arranging\n * {@link Ext.form.field.Radio} controls into columns, and provides convenience {@link Ext.form.field.Field}\n * methods for {@link #getValue getting}, {@link #setValue setting}, and {@link #validate validating} the\n * group of radio buttons as a whole.\n *\n * # Validation\n *\n * Individual radio buttons themselves have no default validation behavior, but\n * sometimes you want to require a user to select one of a group of radios. RadioGroup\n * allows this by setting the config `{@link #allowBlank}:false`; when the user does not check at\n * one of the radio buttons, the entire group will be highlighted as invalid and the\n * {@link #blankText error message} will be displayed according to the {@link #msgTarget} config.\n *\n * # Layout\n *\n * The default layout for RadioGroup makes it easy to arrange the radio buttons into\n * columns; see the {@link #columns} and {@link #vertical} config documentation for details. You may also\n * use a completely different layout by setting the {@link #layout} to one of the other supported layout\n * types; for instance you may wish to use a custom arrangement of hbox and vbox containers. In that case\n * the Radio components at any depth will still be managed by the RadioGroup's validation.\n *\n * # Example usage\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'RadioGroup Example',\n *         width: 300,\n *         height: 125,\n *         bodyPadding: 10,\n *         renderTo: Ext.getBody(),\n *         items:[{\n *             xtype: 'radiogroup',\n *             fieldLabel: 'Two Columns',\n *             // Arrange radio buttons into two columns, distributed vertically\n *             columns: 2,\n *             vertical: true,\n *             items: [\n *                 { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },\n *                 { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true},\n *                 { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },\n *                 { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },\n *                 { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },\n *                 { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }\n *             ]\n *         }]\n *     });\n *\n */\nExt.define('Ext.form.RadioGroup', {\n    extend: 'Ext.form.CheckboxGroup',\n    alias: 'widget.radiogroup',\n\n    /**\n     * @cfg {Ext.form.field.Radio[]/Object[]} items\n     * An Array of {@link Ext.form.field.Radio Radio}s or Radio config objects to arrange in the group.\n     */\n    /**\n     * @cfg {Boolean} allowBlank\n     * True to allow every item in the group to be blank.\n     * If allowBlank = false and no items are selected at validation time, {@link #blankText} will\n     * be used as the error text.\n     */\n    allowBlank : true,\n    //<locale>\n    /**\n     * @cfg {String} blankText\n     * Error text to display if the {@link #allowBlank} validation fails\n     */\n    blankText : 'You must select one item in this group',\n    //</locale>\n\n    // private\n    defaultType : 'radiofield',\n\n    // private\n    groupCls : Ext.baseCSSPrefix + 'form-radio-group',\n\n    getBoxes: function(query) {\n        return this.query('[isRadio]' + (query||''));\n    },\n    \n    checkChange: function() {\n        var value = this.getValue(),\n            key = Ext.Object.getKeys(value)[0];\n            \n        // If the value is an array we skip out here because it's during a change\n        // between multiple items, so we never want to fire a change\n        if (Ext.isArray(value[key])) {\n            return;\n        }\n        this.callParent(arguments);    \n    },\n\n    /**\n     * Sets the value of the radio group. The radio with corresponding name and value will be set.\n     * This method is simpler than {@link Ext.form.CheckboxGroup#setValue} because only 1 value is allowed\n     * for each name.\n     * \n     * @param {Object} value The map from names to values to be set.\n     * @return {Ext.form.CheckboxGroup} this\n     */\n    setValue: function(value) {\n        var cbValue, first, formId, radios,\n            i, len, name;\n\n        if (Ext.isObject(value)) {\n            for (name in value) {\n                if (value.hasOwnProperty(name)) {\n                    cbValue = value[name];\n                    first = this.items.first();\n                    formId = first ? first.getFormId() : null;\n                    radios = Ext.form.RadioManager.getWithValue(name, cbValue, formId).items;\n                    len = radios.length;\n\n                    for (i = 0; i < len; ++i) {\n                        radios[i].setValue(true);\n                    }\n                }\n            }\n        }\n        return this;\n    }\n});\n\n/**\n * @private\n * Private utility class for managing all {@link Ext.form.field.Radio} fields grouped by name.\n */\nExt.define('Ext.form.RadioManager', {\n    extend: 'Ext.util.MixedCollection',\n    singleton: true,\n\n    getByName: function(name, formId) {\n        return this.filterBy(function(item) {\n            return item.name == name && item.getFormId() == formId;\n        });\n    },\n\n    getWithValue: function(name, value, formId) {\n        return this.filterBy(function(item) {\n            return item.name == name && item.inputValue == value && item.getFormId() == formId;\n        });\n    },\n\n    getChecked: function(name, formId) {\n        return this.findBy(function(item) {\n            return item.name == name && item.checked && item.getFormId() == formId;\n        });\n    }\n});\n\n/**\n * Provides {@link Ext.direct.Manager} support for loading form data.\n *\n * This example illustrates usage of Ext.direct.Direct to **load** a form through Ext.Direct.\n *\n *     var myFormPanel = new Ext.form.Panel({\n *         // configs for FormPanel\n *         title: 'Basic Information',\n *         renderTo: document.body,\n *         width: 300, height: 160,\n *         padding: 10,\n *\n *         // configs apply to child items\n *         defaults: {anchor: '100%'},\n *         defaultType: 'textfield',\n *         items: [{\n *             fieldLabel: 'Name',\n *             name: 'name'\n *         },{\n *             fieldLabel: 'Email',\n *             name: 'email'\n *         },{\n *             fieldLabel: 'Company',\n *             name: 'company'\n *         }],\n *\n *         // configs for BasicForm\n *         api: {\n *             // The server-side method to call for load() requests\n *             load: Profile.getBasicInfo,\n *             // The server-side must mark the submit handler as a 'formHandler'\n *             submit: Profile.updateBasicInfo\n *         },\n *         // specify the order for the passed params\n *         paramOrder: ['uid', 'foo']\n *     });\n *\n *     // load the form\n *     myFormPanel.getForm().load({\n *         // pass 2 arguments to server side getBasicInfo method (len=2)\n *         params: {\n *             foo: 'bar',\n *             uid: 34\n *         }\n *     });\n *\n * The data packet sent to the server will resemble something like:\n *\n *     [\n *         {\n *             \"action\":\"Profile\",\"method\":\"getBasicInfo\",\"type\":\"rpc\",\"tid\":2,\n *             \"data\":[34,\"bar\"] // note the order of the params\n *         }\n *     ]\n *\n * The form will process a data packet returned by the server that is similar to the following format:\n *\n *     [\n *         {\n *             \"action\":\"Profile\",\"method\":\"getBasicInfo\",\"type\":\"rpc\",\"tid\":2,\n *             \"result\":{\n *                 \"success\":true,\n *                 \"data\":{\n *                     \"name\":\"Fred Flintstone\",\n *                     \"company\":\"Slate Rock and Gravel\",\n *                     \"email\":\"fred.flintstone@slaterg.com\"\n *                 }\n *             }\n *         }\n *     ]\n */\nExt.define('Ext.form.action.DirectLoad', {\n    extend:'Ext.form.action.Load',\n    requires: ['Ext.direct.Manager'],\n    alternateClassName: 'Ext.form.Action.DirectLoad',\n    alias: 'formaction.directload',\n\n    type: 'directload',\n\n    run: function() {\n        var me = this,\n            form = me.form,\n            fn = form.api.load,\n            method = fn.directCfg.method,\n            args = method.getArgs(me.getParams(), form.paramOrder, form.paramsAsHash);\n            \n        args.push(me.onComplete, me);\n        fn.apply(window, args);\n    },\n\n    // Direct actions have already been processed and therefore\n    // we can directly set the result; Direct Actions do not have\n    // a this.response property.\n    processResponse: function(result) {\n        return (this.result = result);\n    },\n\n    onComplete: function(data, response) {\n        if (data) {\n            this.onSuccess(data);\n        } else {\n            this.onFailure(null);\n        }\n    }\n});\n\n\n\n/**\n * Provides Ext.direct support for submitting form data.\n *\n * This example illustrates usage of Ext.direct.Direct to **submit** a form through Ext.Direct.\n *\n *     var myFormPanel = new Ext.form.Panel({\n *         // configs for FormPanel\n *         title: 'Basic Information',\n *         renderTo: document.body,\n *         width: 300, height: 160,\n *         padding: 10,\n *         buttons:[{\n *             text: 'Submit',\n *             handler: function(){\n *                 myFormPanel.getForm().submit({\n *                     params: {\n *                         foo: 'bar',\n *                         uid: 34\n *                     }\n *                 });\n *             }\n *         }],\n *\n *         // configs apply to child items\n *         defaults: {anchor: '100%'},\n *         defaultType: 'textfield',\n *         items: [{\n *             fieldLabel: 'Name',\n *             name: 'name'\n *         },{\n *             fieldLabel: 'Email',\n *             name: 'email'\n *         },{\n *             fieldLabel: 'Company',\n *             name: 'company'\n *         }],\n *\n *         // configs for BasicForm\n *         api: {\n *             // The server-side method to call for load() requests\n *             load: Profile.getBasicInfo,\n *             // The server-side must mark the submit handler as a 'formHandler'\n *             submit: Profile.updateBasicInfo\n *         },\n *         // specify the order for the passed params\n *         paramOrder: ['uid', 'foo']\n *     });\n *\n * The data packet sent to the server will resemble something like:\n *\n *     {\n *         \"action\":\"Profile\",\"method\":\"updateBasicInfo\",\"type\":\"rpc\",\"tid\":\"6\",\n *         \"result\":{\n *             \"success\":true,\n *             \"id\":{\n *                 \"extAction\":\"Profile\",\"extMethod\":\"updateBasicInfo\",\n *                 \"extType\":\"rpc\",\"extTID\":\"6\",\"extUpload\":\"false\",\n *                 \"name\":\"Aaron Conran\",\"email\":\"aaron@sencha.com\",\"company\":\"Sencha Inc.\"\n *             }\n *         }\n *     }\n *\n * The form will process a data packet returned by the server that is similar to the following:\n *\n *     // sample success packet (batched requests)\n *     [\n *         {\n *             \"action\":\"Profile\",\"method\":\"updateBasicInfo\",\"type\":\"rpc\",\"tid\":3,\n *             \"result\":{\n *                 \"success\":true\n *             }\n *         }\n *     ]\n *\n *     // sample failure packet (one request)\n *     {\n *             \"action\":\"Profile\",\"method\":\"updateBasicInfo\",\"type\":\"rpc\",\"tid\":\"6\",\n *             \"result\":{\n *                 \"errors\":{\n *                     \"email\":\"already taken\"\n *                 },\n *                 \"success\":false,\n *                 \"foo\":\"bar\"\n *             }\n *     }\n *\n * Also see the discussion in {@link Ext.form.action.DirectLoad}.\n */\nExt.define('Ext.form.action.DirectSubmit', {\n    extend:'Ext.form.action.Submit',\n    requires: ['Ext.direct.Manager'],\n    alternateClassName: 'Ext.form.Action.DirectSubmit',\n    alias: 'formaction.directsubmit',\n\n    type: 'directsubmit',\n\n    doSubmit: function() {\n        var me = this,\n            callback = Ext.Function.bind(me.onComplete, me),\n            formEl = me.buildForm();\n        me.form.api.submit(formEl, callback, me);\n        Ext.removeNode(formEl);\n    },\n\n    // Direct actions have already been processed and therefore\n    // we can directly set the result; Direct Actions do not have\n    // a this.response property.\n    processResponse: function(result) {\n        return (this.result = result);\n    },\n    \n    onComplete: function(data, response){\n        if (data) {\n            this.onSuccess(data);\n        } else {\n            this.onFailure(null);\n        }\n    }\n});\n\n/**\n * A class which handles submission of data from {@link Ext.form.Basic Form}s using a standard `<form>` element submit.\n * It does not handle the response from the submit.\n *\n * If validation of the form fields fails, the Form's afterAction method will be called. Otherwise, afterAction will not\n * be called.\n *\n * Instances of this class are only created by a {@link Ext.form.Basic Form} when\n * {@link Ext.form.Basic#submit submit}ting, when the form's {@link Ext.form.Basic#standardSubmit} config option is true.\n */\nExt.define('Ext.form.action.StandardSubmit', {\n    extend:'Ext.form.action.Submit',\n    alias: 'formaction.standardsubmit',\n\n    /**\n     * @cfg {String} target\n     * Optional target attribute to be used for the form when submitting.\n     * \n     * Defaults to the current window/frame.\n     */\n\n    /**\n     * @private\n     * Perform the form submit. Creates and submits a temporary form element containing an input element for each\n     * field value returned by {@link Ext.form.Basic#getValues}, plus any configured {@link #params params} or\n     * {@link Ext.form.Basic#baseParams baseParams}.\n     */\n    doSubmit: function() {\n        var form = this.buildForm();\n        form.submit();\n        Ext.removeNode(form);\n    }\n\n});\n\n/**\n * @docauthor Robert Dougan <rob@sencha.com>\n *\n * Single checkbox field. Can be used as a direct replacement for traditional checkbox fields. Also serves as a\n * parent class for {@link Ext.form.field.Radio radio buttons}.\n *\n * # Labeling\n *\n * In addition to the {@link Ext.form.Labelable standard field labeling options}, checkboxes\n * may be given an optional {@link #boxLabel} which will be displayed immediately after checkbox. Also see\n * {@link Ext.form.CheckboxGroup} for a convenient method of grouping related checkboxes.\n *\n * # Values\n *\n * The main value of a checkbox is a boolean, indicating whether or not the checkbox is checked.\n * The following values will check the checkbox:\n *\n * - `true`\n * - `'true'`\n * - `'1'`\n * - `'on'`\n *\n * Any other value will uncheck the checkbox.\n *\n * In addition to the main boolean value, you may also specify a separate {@link #inputValue}. This will be\n * sent as the parameter value when the form is {@link Ext.form.Basic#submit submitted}. You will want to set\n * this value if you have multiple checkboxes with the same {@link #name}. If not specified, the value `on`\n * will be used.\n *\n * # Example usage\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         bodyPadding: 10,\n *         width: 300,\n *         title: 'Pizza Order',\n *         items: [\n *             {\n *                 xtype: 'fieldcontainer',\n *                 fieldLabel: 'Toppings',\n *                 defaultType: 'checkboxfield',\n *                 items: [\n *                     {\n *                         boxLabel  : 'Anchovies',\n *                         name      : 'topping',\n *                         inputValue: '1',\n *                         id        : 'checkbox1'\n *                     }, {\n *                         boxLabel  : 'Artichoke Hearts',\n *                         name      : 'topping',\n *                         inputValue: '2',\n *                         checked   : true,\n *                         id        : 'checkbox2'\n *                     }, {\n *                         boxLabel  : 'Bacon',\n *                         name      : 'topping',\n *                         inputValue: '3',\n *                         id        : 'checkbox3'\n *                     }\n *                 ]\n *             }\n *         ],\n *         bbar: [\n *             {\n *                 text: 'Select Bacon',\n *                 handler: function() {\n *                     Ext.getCmp('checkbox3').setValue(true);\n *                 }\n *             },\n *             '-',\n *             {\n *                 text: 'Select All',\n *                 handler: function() {\n *                     Ext.getCmp('checkbox1').setValue(true);\n *                     Ext.getCmp('checkbox2').setValue(true);\n *                     Ext.getCmp('checkbox3').setValue(true);\n *                 }\n *             },\n *             {\n *                 text: 'Deselect All',\n *                 handler: function() {\n *                     Ext.getCmp('checkbox1').setValue(false);\n *                     Ext.getCmp('checkbox2').setValue(false);\n *                     Ext.getCmp('checkbox3').setValue(false);\n *                 }\n *             }\n *         ],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.form.field.Checkbox', {\n    extend: 'Ext.form.field.Base',\n    alias: ['widget.checkboxfield', 'widget.checkbox'],\n    alternateClassName: 'Ext.form.Checkbox',\n    requires: ['Ext.XTemplate', 'Ext.form.CheckboxManager' ],\n\n    componentLayout: 'field',\n\n    childEls: [\n        /**\n         * @property {Ext.Element} boxLabelEl\n         * A reference to the label element created for the {@link #boxLabel}. Only present if the component has been\n         * rendered and has a boxLabel configured.\n         */\n        'boxLabelEl'\n    ],\n\n    // note: {id} here is really {inputId}, but {cmpId} is available\n    fieldSubTpl: [\n        '<tpl if=\"boxLabel && boxLabelAlign == \\'before\\'\">',\n            '{beforeBoxLabelTpl}',\n            '<label id=\"{cmpId}-boxLabelEl\" {boxLabelAttrTpl} class=\"{boxLabelCls} {boxLabelCls}-{boxLabelAlign}\" for=\"{id}\">',\n                '{beforeBoxLabelTextTpl}',\n                '{boxLabel}',\n                '{afterBoxLabelTextTpl}',\n            '</label>',\n            '{afterBoxLabelTpl}',\n        '</tpl>',\n        // Creates not an actual checkbox, but a button which is given aria role=\"checkbox\" (If ARIA is required) and\n        // styled with a custom checkbox image. This allows greater control and consistency in\n        // styling, and using a button allows it to gain focus and handle keyboard nav properly.\n        '<input type=\"button\" id=\"{id}\" {inputAttrTpl}',\n            '<tpl if=\"tabIdx\"> tabIndex=\"{tabIdx}\"</tpl>',\n            '<tpl if=\"disabled\"> disabled=\"disabled\"</tpl>',\n            '<tpl if=\"fieldStyle\"> style=\"{fieldStyle}\"</tpl>',\n            ' class=\"{fieldCls} {typeCls}\" autocomplete=\"off\" hidefocus=\"true\" />',\n        '<tpl if=\"boxLabel && boxLabelAlign == \\'after\\'\">',\n            '{beforeBoxLabelTpl}',\n            '<label id=\"{cmpId}-boxLabelEl\" {boxLabelAttrTpl} class=\"{boxLabelCls} {boxLabelCls}-{boxLabelAlign}\" for=\"{id}\">',\n                '{beforeBoxLabelTextTpl}',\n                '{boxLabel}',\n                '{afterBoxLabelTextTpl}',\n            '</label>',\n            '{afterBoxLabelTpl}',\n        '</tpl>',\n        {\n            disableFormats: true,\n            compiled: true\n        }\n    ],\n\n    subTplInsertions: [\n        /**\n         * @cfg {String/Array/Ext.XTemplate} beforeBoxLabelTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * before the box label element. If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'beforeBoxLabelTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} afterBoxLabelTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * after the box label element. If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'afterBoxLabelTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} beforeBoxLabelTextTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * before the box label text. If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'beforeBoxLabelTextTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} afterBoxLabelTextTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * after the box label text. If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'afterBoxLabelTextTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} boxLabelAttrTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * inside the box label element (as attributes). If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'boxLabelAttrTpl',\n\n        // inherited\n        'inputAttrTpl'\n    ],\n\n    /*\n     * @property {Boolean} isCheckbox\n     * `true` in this class to identify an object as an instantiated Checkbox, or subclass thereof.\n     */\n    isCheckbox: true,\n\n    /**\n     * @cfg {String} [focusCls='x-form-cb-focus']\n     * The CSS class to use when the checkbox receives focus\n     */\n    focusCls: 'form-cb-focus',\n\n    /**\n     * @cfg {String} [fieldCls='x-form-field']\n     * The default CSS class for the checkbox\n     */\n\n    /**\n     * @cfg {String} [fieldBodyCls='x-form-cb-wrap']\n     * An extra CSS class to be applied to the body content element in addition to {@link #fieldBodyCls}.\n     * .\n     */\n    fieldBodyCls: Ext.baseCSSPrefix + 'form-cb-wrap',\n\n    /**\n     * @cfg {Boolean} checked\n     * true if the checkbox should render initially checked\n     */\n    checked: false,\n\n    /**\n     * @cfg {String} [checkedCls='x-form-cb-checked']\n     * The CSS class added to the component's main element when it is in the checked state.\n     */\n    checkedCls: Ext.baseCSSPrefix + 'form-cb-checked',\n\n    /**\n     * @cfg {String} boxLabel\n     * An optional text label that will appear next to the checkbox. Whether it appears before or after the checkbox is\n     * determined by the {@link #boxLabelAlign} config.\n     */\n\n    /**\n     * @cfg {String} [boxLabelCls='x-form-cb-label']\n     * The CSS class to be applied to the {@link #boxLabel} element\n     */\n    boxLabelCls: Ext.baseCSSPrefix + 'form-cb-label',\n\n    /**\n     * @cfg {String} boxLabelAlign\n     * The position relative to the checkbox where the {@link #boxLabel} should appear. Recognized values are 'before'\n     * and 'after'.\n     */\n    boxLabelAlign: 'after',\n\n    /**\n     * @cfg {String} inputValue\n     * The value that should go into the generated input element's value attribute and should be used as the parameter\n     * value when submitting as part of a form.\n     */\n    inputValue: 'on',\n\n    /**\n     * @cfg {String} uncheckedValue\n     * If configured, this will be submitted as the checkbox's value during form submit if the checkbox is unchecked. By\n     * default this is undefined, which results in nothing being submitted for the checkbox field when the form is\n     * submitted (the default behavior of HTML checkboxes).\n     */\n\n    /**\n     * @cfg {Function} handler\n     * A function called when the {@link #checked} value changes (can be used instead of handling the {@link #change\n     * change event}).\n     * @cfg {Ext.form.field.Checkbox} handler.checkbox The Checkbox being toggled.\n     * @cfg {Boolean} handler.checked The new checked state of the checkbox.\n     */\n\n    /**\n     * @cfg {Object} scope\n     * An object to use as the scope ('this' reference) of the {@link #handler} function.\n     *\n     * Defaults to this Checkbox.\n     */\n\n    // private overrides\n    checkChangeEvents: [],\n    inputType: 'checkbox',\n\n    // private\n    onRe: /^on$/i,\n\n    initComponent: function() {\n        this.callParent(arguments);\n        this.getManager().add(this);\n    },\n\n    initValue: function() {\n        var me = this,\n            checked = !!me.checked;\n\n        /**\n         * @property {Object} originalValue\n         * The original value of the field as configured in the {@link #checked} configuration, or as loaded by the last\n         * form load operation if the form's {@link Ext.form.Basic#trackResetOnLoad trackResetOnLoad} setting is `true`.\n         */\n        me.originalValue = me.lastValue = checked;\n\n        // Set the initial checked state\n        me.setValue(checked);\n    },\n\n    getElConfig: function() {\n        var me = this;\n\n        // Add the checked class if this begins checked\n        if (me.isChecked(me.rawValue, me.inputValue)) {\n            me.addCls(me.checkedCls);\n        }\n        return me.callParent();\n    },\n\n    getFieldStyle: function() {\n        return Ext.isObject(this.fieldStyle) ? Ext.DomHelper.generateStyles(this.fieldStyle) : this.fieldStyle ||'';\n    },\n\n    getSubTplData: function() {\n        var me = this;\n        return Ext.apply(me.callParent(), {\n            disabled      : me.readOnly || me.disabled,\n            boxLabel      : me.boxLabel,\n            boxLabelCls   : me.boxLabelCls,\n            boxLabelAlign : me.boxLabelAlign\n        });\n    },\n\n    initEvents: function() {\n        var me = this;\n        me.callParent();\n        me.mon(me.inputEl, 'click', me.onBoxClick, me);\n    },\n\n    /**\n     * @private Handle click on the checkbox button\n     */\n    onBoxClick: function(e) {\n        var me = this;\n        if (!me.disabled && !me.readOnly) {\n            this.setValue(!this.checked);\n        }\n    },\n\n    /**\n     * Returns the checked state of the checkbox.\n     * @return {Boolean} True if checked, else false\n     */\n    getRawValue: function() {\n        return this.checked;\n    },\n\n    /**\n     * Returns the checked state of the checkbox.\n     * @return {Boolean} True if checked, else false\n     */\n    getValue: function() {\n        return this.checked;\n    },\n\n    /**\n     * Returns the submit value for the checkbox which can be used when submitting forms.\n     * @return {String} If checked the {@link #inputValue} is returned; otherwise the {@link #uncheckedValue}\n     * (or null if the latter is not configured).\n     */\n    getSubmitValue: function() {\n        var unchecked = this.uncheckedValue,\n            uncheckedVal = Ext.isDefined(unchecked) ? unchecked : null;\n        return this.checked ? this.inputValue : uncheckedVal;\n    },\n\n    isChecked: function(rawValue, inputValue) {\n        return (rawValue === true || rawValue === 'true' || rawValue === '1' || rawValue === 1 ||\n                      (((Ext.isString(rawValue) || Ext.isNumber(rawValue)) && inputValue) ? rawValue == inputValue : this.onRe.test(rawValue)));\n    },\n\n    /**\n     * Sets the checked state of the checkbox.\n     *\n     * @param {Boolean/String/Number} value The following values will check the checkbox:\n     * `true, 'true', '1', 1, or 'on'`, as well as a String that matches the {@link #inputValue}.\n     * Any other value will uncheck the checkbox.\n     * @return {Boolean} the new checked state of the checkbox\n     */\n    setRawValue: function(value) {\n        var me = this,\n            inputEl = me.inputEl,\n            checked = me.isChecked(value, me.inputValue);\n\n        if (inputEl) {\n            me[checked ? 'addCls' : 'removeCls'](me.checkedCls);\n        }\n\n        me.checked = me.rawValue = checked;\n        return checked;\n    },\n\n    /**\n     * Sets the checked state of the checkbox, and invokes change detection.\n     * @param {Boolean/String} checked The following values will check the checkbox: `true, 'true', '1', or 'on'`, as\n     * well as a String that matches the {@link #inputValue}. Any other value will uncheck the checkbox.\n     * @return {Ext.form.field.Checkbox} this\n     */\n    setValue: function(checked) {\n        var me = this,\n            boxes, i, len, box;\n\n        // If an array of strings is passed, find all checkboxes in the group with the same name as this\n        // one and check all those whose inputValue is in the array, unchecking all the others. This is to\n        // facilitate setting values from Ext.form.Basic#setValues, but is not publicly documented as we\n        // don't want users depending on this behavior.\n        if (Ext.isArray(checked)) {\n            boxes = me.getManager().getByName(me.name, me.getFormId()).items;\n            len = boxes.length;\n\n            for (i = 0; i < len; ++i) {\n                box = boxes[i];\n                box.setValue(Ext.Array.contains(checked, box.inputValue));\n            }\n        } else {\n            me.callParent(arguments);\n        }\n\n        return me;\n    },\n\n    // private\n    valueToRaw: function(value) {\n        // No extra conversion for checkboxes\n        return value;\n    },\n\n    /**\n     * @private\n     * Called when the checkbox's checked state changes. Invokes the {@link #handler} callback\n     * function if specified.\n     */\n    onChange: function(newVal, oldVal) {\n        var me = this,\n            handler = me.handler;\n        if (handler) {\n            handler.call(me.scope || me, me, newVal);\n        }\n        me.callParent(arguments);\n    },\n    \n    resetOriginalValue: function(/* private */ fromBoxInGroup){\n        var me = this,\n            boxes,\n            box,\n            len,\n            i;\n            \n        // If we're resetting the value of a field in a group, also reset the others.\n        if (!fromBoxInGroup) {\n            boxes = me.getManager().getByName(me.name, me.getFormId()).items;\n            len  = boxes.length;\n            \n            for (i = 0; i < len; ++i) {\n                box = boxes[i];\n                if (box !== me) {\n                    boxes[i].resetOriginalValue(true);\n                }\n            }\n        }\n        me.callParent();\n    },\n\n    // inherit docs\n    beforeDestroy: function(){\n        this.callParent();\n        this.getManager().removeAtKey(this.id);\n    },\n\n    // inherit docs\n    getManager: function() {\n        return Ext.form.CheckboxManager;\n    },\n\n    onEnable: function() {\n        var me = this,\n            inputEl = me.inputEl;\n        me.callParent();\n        if (inputEl) {\n            // Can still be disabled if the field is readOnly\n            inputEl.dom.disabled = me.readOnly;\n        }\n    },\n\n    setReadOnly: function(readOnly) {\n        var me = this,\n            inputEl = me.inputEl;\n        if (inputEl) {\n            // Set the button to disabled when readonly\n            inputEl.dom.disabled = !!readOnly || me.disabled;\n        }\n        me.callParent(arguments);\n    },\n\n    getFormId: function(){\n        var me = this,\n            form;\n\n        if (!me.formId) {\n            form = me.up('form');\n            if (form) {\n                me.formId = form.id;\n            }\n        }\n        return me.formId;\n    }\n});\n\n/**\n * Layout class for {@link Ext.form.field.Trigger} fields. Adjusts the input field size to accommodate\n * the trigger button(s).\n * @private\n */\nExt.define('Ext.layout.component.field.Trigger', {\n\n    /* Begin Definitions */\n\n    alias: 'layout.triggerfield',\n\n    extend: 'Ext.layout.component.field.Field',\n\n    /* End Definitions */\n\n    type: 'triggerfield',\n\n    beginLayout: function(ownerContext) {\n        var me = this,\n            owner = me.owner,\n            flags;\n\n        ownerContext.triggerWrap = ownerContext.getEl('triggerWrap');\n\n        me.callParent(arguments);\n\n        // if any of these important states have changed, sync them now:\n        flags = owner.getTriggerStateFlags();\n        if (flags != owner.lastTriggerStateFlags) {\n            owner.lastTriggerStateFlags = flags;\n            me.updateEditState();\n        }\n    },\n\n    beginLayoutFixed: function (ownerContext, width, suffix) {\n        var me = this,\n            owner = ownerContext.target,\n            ieInputWidthAdjustment = me.ieInputWidthAdjustment || 0,\n            inputWidth = '100%',\n            triggerWrap = owner.triggerWrap;\n\n        me.callParent(arguments);\n\n        owner.inputCell.setStyle('width', '100%');\n        if(ieInputWidthAdjustment) {\n            // adjust for IE 6/7 strict content-box model\n            // RTL: This might have to be padding-left unless the senses of the padding styles switch when in RTL mode.\n            owner.inputCell.setStyle('padding-right', ieInputWidthAdjustment + 'px');\n            if(suffix === 'px') {\n                if (owner.inputWidth) {\n                    inputWidth = owner.inputWidth - owner.getTriggerWidth();\n                } else {\n                    inputWidth = width - ieInputWidthAdjustment - owner.getTriggerWidth();\n                }\n                inputWidth += 'px';\n            }\n        }\n        owner.inputEl.setStyle('width', inputWidth);\n        inputWidth = owner.inputWidth;\n        if (inputWidth) {\n            triggerWrap.setStyle('width', inputWidth + (ieInputWidthAdjustment) + 'px');\n        } else {\n            triggerWrap.setStyle('width', width + suffix);\n        }\n        triggerWrap.setStyle('table-layout', 'fixed');\n    },\n\n    beginLayoutShrinkWrap: function (ownerContext) {\n        var owner = ownerContext.target,\n            emptyString = '',\n            inputWidth = owner.inputWidth,\n            triggerWrap = owner.triggerWrap,\n            ieInputWidthAdjustment = this.ieInputWidthAdjustment || 0;\n\n        this.callParent(arguments);\n\n        if (inputWidth) {\n            triggerWrap.setStyle('width', inputWidth + 'px');\n            inputWidth = (inputWidth - owner.getTriggerWidth()) + 'px';\n            owner.inputEl.setStyle('width', inputWidth);\n            owner.inputCell.setStyle('width', inputWidth);\n        } else {\n            owner.inputCell.setStyle('width', emptyString);\n            owner.inputEl.setStyle('width', emptyString);\n            triggerWrap.setStyle('width', emptyString);\n            triggerWrap.setStyle('table-layout', 'auto');\n        }\n    },\n\n    getTextWidth: function () {\n        var me = this,\n            owner = me.owner,\n            inputEl = owner.inputEl,\n            value;\n\n        // Find the width that contains the whole text value\n        value = (inputEl.dom.value || (owner.hasFocus ? '' : owner.emptyText) || '') + owner.growAppend;\n        return inputEl.getTextWidth(value);\n    },\n\n    measureContentWidth: function (ownerContext) {\n        var me = this,\n            owner = me.owner,\n            width = me.callParent(arguments),\n            inputContext = ownerContext.inputContext,\n            calcWidth, max, min;\n\n        if (owner.grow && !ownerContext.state.growHandled) {\n            calcWidth = me.getTextWidth() + ownerContext.inputContext.getFrameInfo().width;\n\n            max = owner.growMax;\n            min = Math.min(max, width);\n            max = Math.max(owner.growMin, max, min);\n\n            // Constrain\n            calcWidth = Ext.Number.constrain(calcWidth, owner.growMin, max);\n            inputContext.setWidth(calcWidth);\n            ownerContext.state.growHandled = true;\n            \n            // Now that we've set the inputContext, we need to recalculate the width\n            inputContext.domBlock(me, 'width');\n            width = NaN;\n        }\n        return width;\n    },\n\n    updateEditState: function() {\n        var me = this,\n            owner = me.owner,\n            inputEl = owner.inputEl,\n            noeditCls = Ext.baseCSSPrefix + 'trigger-noedit',\n            displayed,\n            readOnly;\n\n        if (me.owner.readOnly) {\n            inputEl.addCls(noeditCls);\n            readOnly = true;\n            displayed = false;\n        } else {\n            if (me.owner.editable) {\n                inputEl.removeCls(noeditCls);\n                readOnly = false;\n            } else {\n                inputEl.addCls(noeditCls);\n                readOnly = true;\n            }\n            displayed = !me.owner.hideTrigger;\n        }\n\n        owner.triggerCell.setDisplayed(displayed);\n        inputEl.dom.readOnly = readOnly;\n    }\n});\n\n/**\n * Layout class for {@link Ext.form.field.ComboBox} fields. Handles sizing the input field.\n * @private\n */\nExt.define('Ext.layout.component.field.ComboBox', {\n    extend: 'Ext.layout.component.field.Trigger',\n    alias: 'layout.combobox',\n    requires: ['Ext.util.TextMetrics'],\n\n    type: 'combobox',\n\n    startingWidth: null,\n\n    getTextWidth: function () {\n        var me = this,\n            owner = me.owner,\n            store = owner.store,\n            field = owner.displayField,\n            storeLn = store.data.length,\n            value = '',\n            i = 0, n = 0, ln, item, width;\n\n        for (; i < storeLn; i++) {\n            item = store.getAt(i).data[field];\n            ln = item.length;\n            // compare the current item's length with the current longest length and store the value\n            if (ln > n) {\n                n = ln;\n                value = item;\n            }\n        }\n\n        width = Math.max(me.callParent(arguments), owner.inputEl.getTextWidth(value + owner.growAppend));\n\n        // it's important to know the starting width else the inputEl could be resized smaller than the boundlist\n        // NOTE that when removing items from the store that the startingWidth needs to be recalculated\n        if (!me.startingWidth || owner.removingRecords) {\n            me.startingWidth = width;\n\n            // also, if the width is less than growMin reset the default boundlist width\n            // or it will appear wider than the component if the trigger is clicked\n            if (width < owner.growMin) {\n                owner.defaultListConfig.minWidth = owner.growMin;\n            }\n\n            owner.removingRecords = false;\n        }\n \n        // only resize if the new width is greater than the starting width\n        return (width < me.startingWidth) ? me.startingWidth : width;\n    }\n});\n\n/**\n * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).\n * The trigger has no default action, so you must assign a function to implement the trigger click handler by overriding\n * {@link #onTriggerClick}. You can create a Trigger field directly, as it renders exactly like a combobox for which you\n * can provide a custom implementation.\n *\n * For example:\n *\n *     @example\n *     Ext.define('Ext.ux.CustomTrigger', {\n *         extend: 'Ext.form.field.Trigger',\n *         alias: 'widget.customtrigger',\n *\n *         // override onTriggerClick\n *         onTriggerClick: function() {\n *             Ext.Msg.alert('Status', 'You clicked my trigger!');\n *         }\n *     });\n *\n *     Ext.create('Ext.form.FormPanel', {\n *         title: 'Form with TriggerField',\n *         bodyPadding: 5,\n *         width: 350,\n *         renderTo: Ext.getBody(),\n *         items:[{\n *             xtype: 'customtrigger',\n *             fieldLabel: 'Sample Trigger',\n *             emptyText: 'click the trigger'\n *         }]\n *     });\n *\n * However, in general you will most likely want to use Trigger as the base class for a reusable component.\n * {@link Ext.form.field.Date} and {@link Ext.form.field.ComboBox} are perfect examples of this.\n */\nExt.define('Ext.form.field.Trigger', {\n    extend:'Ext.form.field.Text',\n    alias: ['widget.triggerfield', 'widget.trigger'],\n    requires: ['Ext.DomHelper', 'Ext.util.ClickRepeater', 'Ext.layout.component.field.Trigger'],\n    alternateClassName: ['Ext.form.TriggerField', 'Ext.form.TwinTriggerField', 'Ext.form.Trigger'],\n\n    childEls: [\n        /**\n         * @property {Ext.CompositeElement} triggerEl\n         * A composite of all the trigger button elements. Only set after the field has been rendered.\n         */\n        { name: 'triggerCell', select: '.' + Ext.baseCSSPrefix + 'trigger-cell' },\n        { name: 'triggerEl', select: '.' + Ext.baseCSSPrefix + 'form-trigger' },\n\n        /**\n         * @property {Ext.Element} triggerWrap\n         * A reference to the `TABLE` element which encapsulates the input field and all trigger button(s). Only set after the field has been rendered.\n         */\n        'triggerWrap',\n\n        /**\n         * @property {Ext.Element} inputCell\n         * A reference to the `TD` element wrapping the input element. Only set after the field has been rendered.\n         */\n        'inputCell'\n    ],\n\n    /**\n     * @cfg {String} triggerCls\n     * An additional CSS class used to style the trigger button. The trigger will always get the {@link #triggerBaseCls}\n     * by default and triggerCls will be **appended** if specified.\n     */\n\n    /**\n     * @cfg\n     * The base CSS class that is always added to the trigger button. The {@link #triggerCls} will be appended in\n     * addition to this class.\n     */\n    triggerBaseCls: Ext.baseCSSPrefix + 'form-trigger',\n\n    /**\n     * @cfg\n     * The CSS class that is added to the div wrapping the trigger button(s).\n     */\n    triggerWrapCls: Ext.baseCSSPrefix + 'form-trigger-wrap',\n\n    /**\n     * @cfg\n     * The CSS class that is added to the text field when component is read-only or not editable.\n     */\n    triggerNoEditCls: Ext.baseCSSPrefix + 'trigger-noedit',\n\n    /**\n     * @cfg {Boolean} hideTrigger\n     * true to hide the trigger element and display only the base text field\n     */\n    hideTrigger: false,\n\n    /**\n     * @cfg {Boolean} editable\n     * false to prevent the user from typing text directly into the field; the field can only have its value set via an\n     * action invoked by the trigger.\n     */\n    editable: true,\n\n    /**\n     * @cfg {Boolean} readOnly\n     * true to prevent the user from changing the field, and hides the trigger. Supercedes the editable and hideTrigger\n     * options if the value is true.\n     */\n    readOnly: false,\n\n    /**\n     * @cfg {Boolean} [selectOnFocus=false]\n     * true to select any existing text in the field immediately on focus. Only applies when\n     * {@link #editable editable} = true\n     */\n\n    /**\n     * @cfg {Boolean} repeatTriggerClick\n     * true to attach a {@link Ext.util.ClickRepeater click repeater} to the trigger.\n     */\n    repeatTriggerClick: false,\n\n\n    /**\n     * @method autoSize\n     * @private\n     */\n    autoSize: Ext.emptyFn,\n    // private\n    monitorTab: true,\n    // private\n    mimicing: false,\n    // private\n    triggerIndexRe: /trigger-index-(\\d+)/,\n\n    componentLayout: 'triggerfield',\n\n    initComponent: function() {\n        this.wrapFocusCls = this.triggerWrapCls + '-focus';\n        this.callParent(arguments);\n    },\n\n    getSubTplMarkup: function() {\n        var me = this,\n            field = me.callParent(arguments);\n\n        return '<table id=\"' + me.id + '-triggerWrap\" class=\"' + Ext.baseCSSPrefix + 'form-trigger-wrap\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>' +\n            '<td id=\"' + me.id + '-inputCell\" class=\"' + Ext.baseCSSPrefix + 'form-trigger-input-cell\">' + field + '</td>' +\n            me.getTriggerMarkup() +\n            '</tr></tbody></table>';\n    },\n    \n    getSubTplData: function(){\n        var me = this,\n            data = me.callParent(),\n            readOnly = me.readOnly === true,\n            editable = me.editable !== false;\n        \n        return Ext.apply(data, {\n            editableCls: (readOnly || !editable) ? ' ' + me.triggerNoEditCls : '',\n            readOnly: !editable || readOnly\n        });  \n    },\n\n    getLabelableRenderData: function() {\n        var me = this,\n            triggerWrapCls = me.triggerWrapCls,\n            result = me.callParent(arguments);\n\n        return Ext.applyIf(result, {\n            triggerWrapCls: triggerWrapCls,\n            triggerMarkup: me.getTriggerMarkup()\n        });\n    },\n\n    getTriggerMarkup: function() {\n        var me = this,\n            i = 0,\n            hideTrigger = (me.readOnly || me.hideTrigger),\n            triggerCls,\n            triggerBaseCls = me.triggerBaseCls,\n            triggerConfigs = [];\n\n        // TODO this trigger<n>Cls API design doesn't feel clean, especially where it butts up against the\n        // single triggerCls config. Should rethink this, perhaps something more structured like a list of\n        // trigger config objects that hold cls, handler, etc.\n        // triggerCls is a synonym for trigger1Cls, so copy it.\n        if (!me.trigger1Cls) {\n            me.trigger1Cls = me.triggerCls;\n        }\n\n        // Create as many trigger elements as we have trigger<n>Cls configs, but always at least one\n        for (i = 0; (triggerCls = me['trigger' + (i + 1) + 'Cls']) || i < 1; i++) {\n            triggerConfigs.push({\n                tag: 'td',\n                valign: 'top',\n                cls: Ext.baseCSSPrefix + 'trigger-cell',\n                style: 'width:' + me.triggerWidth + (hideTrigger ? 'px;display:none' : 'px'),\n                cn: {\n                    cls: [Ext.baseCSSPrefix + 'trigger-index-' + i, triggerBaseCls, triggerCls].join(' '),\n                    role: 'button'\n                }\n            });\n        }\n        triggerConfigs[i - 1].cn.cls += ' ' + triggerBaseCls + '-last';\n\n        return Ext.DomHelper.markup(triggerConfigs);\n    },\n    \n    disableCheck: function() {\n        return !this.disabled;    \n    },\n\n    // private\n    beforeRender: function() {\n        var me = this,\n            triggerBaseCls = me.triggerBaseCls,\n            tempEl;\n            \n        /**\n         * @property {Number} triggerWidth\n         * Width of the trigger element. Unless set explicitly, it will be\n         * automatically calculated through creating a temporary element\n         * on page. (That will be done just once per app run.)\n         * @private\n         */\n        if (!me.triggerWidth) {\n            tempEl = Ext.resetElement.createChild({\n                style: 'position: absolute;', \n                cls: Ext.baseCSSPrefix + 'form-trigger'\n            });\n            Ext.form.field.Trigger.prototype.triggerWidth = tempEl.getWidth();\n            tempEl.remove();\n        }\n\n        me.callParent();\n\n        if (triggerBaseCls != Ext.baseCSSPrefix + 'form-trigger') {\n            // we may need to change the selectors by which we extract trigger elements if is triggerBaseCls isn't the value we\n            // stuck in childEls\n            me.addChildEls({ name: 'triggerEl', select: '.' + triggerBaseCls });\n        }\n\n        // these start correct in the fieldSubTpl:\n        me.lastTriggerStateFlags = me.getTriggerStateFlags();\n    },\n\n    onRender: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        me.doc = Ext.getDoc();\n        me.initTrigger();\n        me.triggerEl.unselectable();\n    },\n\n    /**\n     * Get the total width of the trigger button area.\n     * @return {Number} The total trigger width\n     */\n    getTriggerWidth: function() {\n        var me = this,\n            totalTriggerWidth = 0;\n\n        if (me.triggerWrap && !me.hideTrigger && !me.readOnly) {\n            totalTriggerWidth = me.triggerEl.getCount() * me.triggerWidth;\n        }\n        return totalTriggerWidth;\n    },\n\n    setHideTrigger: function(hideTrigger) {\n        if (hideTrigger != this.hideTrigger) {\n            this.hideTrigger = hideTrigger;\n            this.updateLayout();\n        }\n    },\n\n    /**\n     * Sets the editable state of this field. This method is the runtime equivalent of setting the 'editable' config\n     * option at config time.\n     * @param {Boolean} editable True to allow the user to directly edit the field text. If false is passed, the user\n     * will only be able to modify the field using the trigger. Will also add a click event to the text field which\n     * will call the trigger. \n     */\n    setEditable: function(editable) {\n        if (editable != this.editable) {\n            this.editable = editable;\n            this.updateLayout();\n        }\n    },\n\n    /**\n     * Sets the read-only state of this field. This method is the runtime equivalent of setting the 'readOnly' config\n     * option at config time.\n     * @param {Boolean} readOnly True to prevent the user changing the field and explicitly hide the trigger. Setting\n     * this to true will supercede settings editable and hideTrigger. Setting this to false will defer back to editable\n     * and hideTrigger.\n     */\n    setReadOnly: function(readOnly) {\n        if (readOnly != this.readOnly) {\n            this.readOnly = readOnly;\n            this.updateLayout();\n        }\n    },\n\n    // private\n    initTrigger: function() {\n        var me = this,\n            triggerWrap = me.triggerWrap,\n            triggerEl = me.triggerEl,\n            disableCheck = me.disableCheck,\n            els, eLen, el, e, idx;\n\n        if (me.repeatTriggerClick) {\n            me.triggerRepeater = new Ext.util.ClickRepeater(triggerWrap, {\n                preventDefault: true,\n                handler: me.onTriggerWrapClick,\n                listeners: {\n                    mouseup: me.onTriggerWrapMouseup,\n                    scope: me\n                },\n                scope: me\n            });\n        } else {\n            me.mon(triggerWrap, {\n                click: me.onTriggerWrapClick,\n                mouseup: me.onTriggerWrapMouseup,\n                scope: me\n            });\n        }\n\n        triggerEl.setVisibilityMode(Ext.Element.DISPLAY);\n        triggerEl.addClsOnOver(me.triggerBaseCls + '-over', disableCheck, me);\n\n        els  = triggerEl.elements;\n        eLen = els.length;\n\n        for (e = 0; e < eLen; e++) {\n            el = els[e];\n            idx = e+1;\n            el.addClsOnOver(me['trigger' + (idx) + 'Cls'] + '-over', disableCheck, me);\n            el.addClsOnClick(me['trigger' + (idx) + 'Cls'] + '-click', disableCheck, me);\n        }\n\n        triggerEl.addClsOnClick(me.triggerBaseCls + '-click', disableCheck, me);\n\n    },\n\n    // private\n    onDestroy: function() {\n        var me = this;\n        Ext.destroyMembers(me, 'triggerRepeater', 'triggerWrap', 'triggerEl');\n        delete me.doc;\n        me.callParent();\n    },\n\n    // private\n    onFocus: function() {\n        var me = this;\n        me.callParent(arguments);\n        if (!me.mimicing) {\n            me.bodyEl.addCls(me.wrapFocusCls);\n            me.mimicing = true;\n            me.mon(me.doc, 'mousedown', me.mimicBlur, me, {\n                delay: 10\n            });\n            if (me.monitorTab) {\n                me.on('specialkey', me.checkTab, me);\n            }\n        }\n    },\n\n    // private\n    checkTab: function(me, e) {\n        if (!this.ignoreMonitorTab && e.getKey() == e.TAB) {\n            this.triggerBlur();\n        }\n    },\n\n    /**\n     * Returns a set of flags that describe the trigger state. These are just used to easily\n     * determine if the DOM is out-of-sync with the component's properties.\n     * @private\n     */\n    getTriggerStateFlags: function () {\n        var me = this,\n            state = 0;\n\n        if (me.readOnly) {\n            state += 1;\n        }\n        if (me.editable) {\n            state += 2;\n        }\n        if (me.hideTrigger) {\n            state += 4;\n        }\n        return state;\n    },\n\n    /**\n     * @private\n     * The default blur handling must not occur for a TriggerField, implementing this template method as emptyFn disables that.\n     * Instead the tab key is monitored, and the superclass's onBlur is called when tab is detected\n     */\n    onBlur: Ext.emptyFn,\n\n    // private\n    mimicBlur: function(e) {\n        if (!this.isDestroyed && !this.bodyEl.contains(e.target) && this.validateBlur(e)) {\n            this.triggerBlur(e);\n        }\n    },\n\n    // private\n    triggerBlur: function(e) {\n        var me = this;\n        me.mimicing = false;\n        me.mun(me.doc, 'mousedown', me.mimicBlur, me);\n        if (me.monitorTab && me.inputEl) {\n            me.un('specialkey', me.checkTab, me);\n        }\n        Ext.form.field.Trigger.superclass.onBlur.call(me, e);\n        if (me.bodyEl) {\n            me.bodyEl.removeCls(me.wrapFocusCls);\n        }\n    },\n\n    // private\n    // This should be overridden by any subclass that needs to check whether or not the field can be blurred.\n    validateBlur: function(e) {\n        return true;\n    },\n\n    // private\n    // process clicks upon triggers.\n    // determine which trigger index, and dispatch to the appropriate click handler\n    onTriggerWrapClick: function() {\n        var me = this,\n            targetEl, match,\n            triggerClickMethod,\n            event;\n\n        event = arguments[me.triggerRepeater ? 1 : 0];\n        if (event && !me.readOnly && !me.disabled) {\n                targetEl = event.getTarget('.' + me.triggerBaseCls, null);\n                match = targetEl && targetEl.className.match(me.triggerIndexRe);\n\n            if (match) {\n                triggerClickMethod = me['onTrigger' + (parseInt(match[1], 10) + 1) + 'Click'] || me.onTriggerClick;\n                if (triggerClickMethod) {\n                    triggerClickMethod.call(me, event);\n                }\n            }\n        }\n    },\n\n    // private\n    // Handle trigger mouse up gesture. To be implemented in subclasses.\n    // Currently the Spinner subclass refocuses the input element upon end of spin.\n    onTriggerWrapMouseup: Ext.emptyFn,\n\n    /**\n     * @method onTriggerClick\n     * @protected\n     * The function that should handle the trigger's click event. This method does nothing by default until overridden\n     * by an implementing function. See Ext.form.field.ComboBox and Ext.form.field.Date for sample implementations.\n     * @param {Ext.EventObject} e\n     */\n    onTriggerClick: Ext.emptyFn\n\n    /**\n     * @cfg {Boolean} grow\n     * @private\n     */\n    /**\n     * @cfg {Number} growMin\n     * @private\n     */\n    /**\n     * @cfg {Number} growMax\n     * @private\n     */\n});\n\n/**\n * An abstract class for fields that have a single trigger which opens a \"picker\" popup below the field, e.g. a combobox\n * menu list or a date picker. It provides a base implementation for toggling the picker's visibility when the trigger\n * is clicked, as well as keyboard navigation and some basic events. Sizing and alignment of the picker can be\n * controlled via the {@link #matchFieldWidth} and {@link #pickerAlign}/{@link #pickerOffset} config properties\n * respectively.\n *\n * You would not normally use this class directly, but instead use it as the parent class for a specific picker field\n * implementation. Subclasses must implement the {@link #createPicker} method to create a picker component appropriate\n * for the field.\n */\nExt.define('Ext.form.field.Picker', {\n    extend: 'Ext.form.field.Trigger',\n    alias: 'widget.pickerfield',\n    alternateClassName: 'Ext.form.Picker',\n    requires: ['Ext.util.KeyNav'],\n\n    /**\n     * @cfg {Boolean} matchFieldWidth\n     * Whether the picker dropdown's width should be explicitly set to match the width of the field. Defaults to true.\n     */\n    matchFieldWidth: true,\n\n    /**\n     * @cfg {String} pickerAlign\n     * The {@link Ext.Element#alignTo alignment position} with which to align the picker. Defaults to \"tl-bl?\"\n     */\n    pickerAlign: 'tl-bl?',\n\n    /**\n     * @cfg {Number[]} pickerOffset\n     * An offset [x,y] to use in addition to the {@link #pickerAlign} when positioning the picker.\n     * Defaults to undefined.\n     */\n\n    /**\n     * @cfg {String} [openCls='x-pickerfield-open']\n     * A class to be added to the field's {@link #bodyEl} element when the picker is opened.\n     */\n    openCls: Ext.baseCSSPrefix + 'pickerfield-open',\n\n    /**\n     * @property {Boolean} isExpanded\n     * True if the picker is currently expanded, false if not.\n     */\n\n    /**\n     * @cfg {Boolean} editable\n     * False to prevent the user from typing text directly into the field; the field can only have its value set via\n     * selecting a value from the picker. In this state, the picker can also be opened by clicking directly on the input\n     * field itself.\n     */\n    editable: true,\n\n\n    initComponent: function() {\n        this.callParent();\n\n        // Custom events\n        this.addEvents(\n            /**\n             * @event expand\n             * Fires when the field's picker is expanded.\n             * @param {Ext.form.field.Picker} field This field instance\n             */\n            'expand',\n            /**\n             * @event collapse\n             * Fires when the field's picker is collapsed.\n             * @param {Ext.form.field.Picker} field This field instance\n             */\n            'collapse',\n            /**\n             * @event select\n             * Fires when a value is selected via the picker.\n             * @param {Ext.form.field.Picker} field This field instance\n             * @param {Object} value The value that was selected. The exact type of this value is dependent on\n             * the individual field and picker implementations.\n             */\n            'select'\n        );\n    },\n\n\n    initEvents: function() {\n        var me = this;\n        me.callParent();\n\n        // Add handlers for keys to expand/collapse the picker\n        me.keyNav = new Ext.util.KeyNav(me.inputEl, {\n            down: me.onDownArrow,\n            esc: {\n                handler: me.onEsc,\n                scope: me,\n                defaultEventAction: false\n            },\n            scope: me,\n            forceKeyDown: true\n        });\n\n        // Non-editable allows opening the picker by clicking the field\n        if (!me.editable) {\n            me.mon(me.inputEl, 'click', me.onTriggerClick, me);\n        }\n\n        // Disable native browser autocomplete\n        if (Ext.isGecko) {\n            me.inputEl.dom.setAttribute('autocomplete', 'off');\n        }\n    },\n\n    // private\n    onEsc: function(e) {\n        var me = this;\n        if (me.isExpanded) {\n            me.collapse();\n            e.stopEvent();\n        } else {\n            // If there's an ancestor Window which will see the ESC event and hide, ensure this Field blurs\n            // so that a down arrow will not pop up a disembodied dropdown list.\n            if (me.up('window')) {\n                me.blur();\n            }\n            // Otherwise, only stop the ESC key event if it's not going to bubble up to the FocusManager\n            else if ((!Ext.FocusManager || !Ext.FocusManager.enabled)) {\n                e.stopEvent();\n            }\n        }\n    },\n\n    onDownArrow: function(e) {\n        if (!this.isExpanded) {\n            // Don't call expand() directly as there may be additional processing involved before\n            // expanding, e.g. in the case of a ComboBox query.\n            this.onTriggerClick();\n        }\n    },\n\n    /**\n     * Expands this field's picker dropdown.\n     */\n    expand: function() {\n        var me = this,\n            bodyEl, picker, collapseIf;\n\n        if (me.rendered && !me.isExpanded && !me.isDestroyed) {\n            bodyEl = me.bodyEl;\n            picker = me.getPicker();\n            collapseIf = me.collapseIf;\n\n            // show the picker and set isExpanded flag\n            picker.show();\n            me.isExpanded = true;\n            me.alignPicker();\n            bodyEl.addCls(me.openCls);\n\n            // monitor clicking and mousewheel\n            me.mon(Ext.getDoc(), {\n                mousewheel: collapseIf,\n                mousedown: collapseIf,\n                scope: me\n            });\n            Ext.EventManager.onWindowResize(me.alignPicker, me);\n            me.fireEvent('expand', me);\n            me.onExpand();\n        }\n    },\n\n    onExpand: Ext.emptyFn,\n\n    /**\n     * Aligns the picker to the input element\n     * @protected\n     */\n    alignPicker: function() {\n        var me = this,\n            picker = me.getPicker();\n\n        if (me.isExpanded) {\n            if (me.matchFieldWidth) {\n                // Auto the height (it will be constrained by min and max width) unless there are no records to display.\n                picker.setWidth(me.bodyEl.getWidth());\n            }\n            if (picker.isFloating()) {\n                me.doAlign();\n            }\n        }\n    },\n\n    /**\n     * Performs the alignment on the picker using the class defaults\n     * @private\n     */\n    doAlign: function(){\n        var me = this,\n            picker = me.picker,\n            aboveSfx = '-above',\n            isAbove;\n\n        me.picker.alignTo(me.inputEl, me.pickerAlign, me.pickerOffset);\n        // add the {openCls}-above class if the picker was aligned above\n        // the field due to hitting the bottom of the viewport\n        isAbove = picker.el.getY() < me.inputEl.getY();\n        me.bodyEl[isAbove ? 'addCls' : 'removeCls'](me.openCls + aboveSfx);\n        picker[isAbove ? 'addCls' : 'removeCls'](picker.baseCls + aboveSfx);\n    },\n\n    /**\n     * Collapses this field's picker dropdown.\n     */\n    collapse: function() {\n        if (this.isExpanded && !this.isDestroyed) {\n            var me = this,\n                openCls = me.openCls,\n                picker = me.picker,\n                doc = Ext.getDoc(),\n                collapseIf = me.collapseIf,\n                aboveSfx = '-above';\n\n            // hide the picker and set isExpanded flag\n            picker.hide();\n            me.isExpanded = false;\n\n            // remove the openCls\n            me.bodyEl.removeCls([openCls, openCls + aboveSfx]);\n            picker.el.removeCls(picker.baseCls + aboveSfx);\n\n            // remove event listeners\n            doc.un('mousewheel', collapseIf, me);\n            doc.un('mousedown', collapseIf, me);\n            Ext.EventManager.removeResizeListener(me.alignPicker, me);\n            me.fireEvent('collapse', me);\n            me.onCollapse();\n        }\n    },\n\n    onCollapse: Ext.emptyFn,\n\n\n    /**\n     * @private\n     * Runs on mousewheel and mousedown of doc to check to see if we should collapse the picker\n     */\n    collapseIf: function(e) {\n        var me = this;\n\n        if (!me.isDestroyed && !e.within(me.bodyEl, false, true) && !e.within(me.picker.el, false, true) && !me.isEventWithinPickerLoadMask(e)) {\n            me.collapse();\n        }\n    },\n\n    /**\n     * Returns a reference to the picker component for this field, creating it if necessary by\n     * calling {@link #createPicker}.\n     * @return {Ext.Component} The picker component\n     */\n    getPicker: function() {\n        var me = this;\n        return me.picker || (me.picker = me.createPicker());\n    },\n\n    /**\n     * @method\n     * Creates and returns the component to be used as this field's picker. Must be implemented by subclasses of Picker.\n     * The current field should also be passed as a configuration option to the picker component as the pickerField\n     * property.\n     */\n    createPicker: Ext.emptyFn,\n\n    /**\n     * Handles the trigger click; by default toggles between expanding and collapsing the picker component.\n     * @protected\n     */\n    onTriggerClick: function() {\n        var me = this;\n        if (!me.readOnly && !me.disabled) {\n            if (me.isExpanded) {\n                me.collapse();\n            } else {\n                me.expand();\n            }\n            me.inputEl.focus();\n        }\n    },\n\n    mimicBlur: function(e) {\n        var me = this,\n            picker = me.picker;\n        // ignore mousedown events within the picker element\n        if (!picker || !e.within(picker.el, false, true) && !me.isEventWithinPickerLoadMask(e)) {\n            me.callParent(arguments);\n        }\n    },\n\n    onDestroy : function(){\n        var me = this,\n            picker = me.picker;\n\n        Ext.EventManager.removeResizeListener(me.alignPicker, me);\n        Ext.destroy(me.keyNav);\n        if (picker) {\n            delete picker.pickerField;\n            picker.destroy();\n        }\n        me.callParent();\n    },\n\n    /**\n     * returns true if the picker has a load mask and the passed event is within the load mask\n     * @private\n     * @param {Ext.EventObject} e\n     * @return {Boolean}\n     */\n    isEventWithinPickerLoadMask: function(e) {\n        var loadMask = this.picker.loadMask;\n\n        return loadMask ? e.within(loadMask.maskEl, false, true) || e.within(loadMask.el, false, true) : false;\n    }\n\n});\n\n\n/**\n * Component layout for {@link Ext.view.BoundList}.\n * @private\n */\nExt.define('Ext.layout.component.BoundList', {\n    extend: 'Ext.layout.component.Auto',\n    alias: 'layout.boundlist',\n\n    type: 'component',\n    \n    beginLayout: function(ownerContext) {\n        var me = this,\n            owner = me.owner,\n            toolbar = owner.pagingToolbar;\n\n        me.callParent(arguments);\n        \n        if (owner.floating) {\n            ownerContext.savedXY = owner.el.getXY();\n            // move way offscreen to prevent any constraining\n            owner.el.setXY([-9999, -9999]);\n        }\n        \n        if (toolbar) {\n            ownerContext.toolbarContext = ownerContext.context.getCmp(toolbar);\n        }\n        ownerContext.listContext = ownerContext.getEl('listEl');\n    },\n    \n    beginLayoutCycle: function(ownerContext){\n        var owner = this.owner;\n        \n        this.callParent(arguments);\n        if (ownerContext.heightModel.auto) {\n            // Set the el/listEl to be autoHeight since they may have been previously sized\n            // by another layout process. If the el was at maxHeight first, the listEl will\n            // always size to the maxHeight regardless of the content.\n            owner.el.setHeight('auto');\n            owner.listEl.setHeight('auto');\n        }\n    },\n\n    getLayoutItems: function() {\n        var toolbar = this.owner.pagingToolbar;\n        return toolbar ? [toolbar] : [];\n    },\n    \n    isValidParent: function() {\n        // this only ever gets called with the toolbar, since it's rendered inside we\n        // know the parent is always valid\n        return true;\n    },\n\n    finishedLayout: function(ownerContext) {\n        var xy = ownerContext.savedXY;\n        \n        this.callParent(arguments);\n        if (xy) {\n            this.owner.el.setXY(xy);\n        }\n    },\n    \n    measureContentWidth: function(ownerContext) {\n        return this.owner.listEl.getWidth();\n    },\n    \n    measureContentHeight: function(ownerContext) {\n        return this.owner.listEl.getHeight();\n    },\n    \n    publishInnerHeight: function(ownerContext, height) {\n        var toolbar = ownerContext.toolbarContext,\n            toolbarHeight = 0;\n            \n        if (toolbar) {\n            toolbarHeight = toolbar.getProp('height');\n        }\n        \n        if (toolbarHeight === undefined) {\n            this.done = false;\n        } else {\n            ownerContext.listContext.setHeight(height - ownerContext.getFrameInfo().height - toolbarHeight);\n        }\n    },\n    \n    calculateOwnerHeightFromContentHeight: function(ownerContext){\n        var height = this.callParent(arguments),\n            toolbar = ownerContext.toolbarContext;\n            \n        if (toolbar) {\n            height += toolbar.getProp('height');\n        }\n        return height;\n    }\n});\n\n/**\n * Tracks what records are currently selected in a databound component.\n *\n * This is an abstract class and is not meant to be directly used. Databound UI widgets such as\n * {@link Ext.grid.Panel Grid} and {@link Ext.tree.Panel Tree} should subclass Ext.selection.Model\n * and provide a way to binding to the component.\n *\n * The abstract methods `onSelectChange` and `onLastFocusChanged` should be implemented in these\n * subclasses to update the UI widget.\n */\nExt.define('Ext.selection.Model', {\n    extend: 'Ext.util.Observable',\n    alternateClassName: 'Ext.AbstractSelectionModel',\n    requires: ['Ext.data.StoreManager'],\n    mixins: {\n        bindable: 'Ext.util.Bindable'    \n    },\n    // lastSelected\n\n    /**\n     * @cfg {String} mode\n     * Mode of selection.  Valid values are:\n     *\n     * - **SINGLE** - Only allows selecting one item at a time.  Use {@link #allowDeselect} to allow\n     *   deselecting that item.  This is the default.\n     * - **SIMPLE** - Allows simple selection of multiple items one-by-one. Each click in grid will either\n     *   select or deselect an item.\n     * - **MULTI** - Allows complex selection of multiple items using Ctrl and Shift keys.\n     */\n\n    /**\n     * @cfg {Boolean} allowDeselect\n     * Allow users to deselect a record in a DataView, List or Grid.\n     * Only applicable when the {@link #mode} is 'SINGLE'.\n     */\n    allowDeselect: false,\n\n    /**\n     * @property {Ext.util.MixedCollection} [selected=undefined]\n     * A MixedCollection that maintains all of the currently selected records.\n     * @readonly\n     */\n    selected: null,\n\n    /**\n     * @cfg {Boolean} pruneRemoved\n     * Prune records when they are removed from the store from the selection.\n     * This is a private flag. For an example of its usage, take a look at\n     * Ext.selection.TreeModel.\n     */\n    pruneRemoved: true,\n\n    constructor: function(cfg) {\n        var me = this;\n\n        cfg = cfg || {};\n        Ext.apply(me, cfg);\n\n        me.addEvents(\n            /**\n             * @event\n             * Fired after a selection change has occurred\n             * @param {Ext.selection.Model} this\n             * @param {Ext.data.Model[]} selected The selected records\n             */\n            'selectionchange',\n            /**\n             * @event\n             * Fired when a row is focused\n             * @param {Ext.selection.Model} this\n             * @param {Ext.data.Model} oldFocused The previously focused record\n             * @param {Ext.data.Model} newFocused The newly focused record\n             */\n            'focuschange'\n        );\n\n        me.modes = {\n            SINGLE: true,\n            SIMPLE: true,\n            MULTI: true\n        };\n\n        // sets this.selectionMode\n        me.setSelectionMode(cfg.mode || me.mode);\n\n        // maintains the currently selected records.\n        me.selected = new Ext.util.MixedCollection();\n\n        me.callParent(arguments);\n    },\n\n    // binds the store to the selModel.\n    bindStore: function(store, initial){\n        var me = this;\n        me.mixins.bindable.bindStore.apply(me, arguments);\n        if(me.store && !initial) {\n            me.refresh();\n        }\n    },\n    \n    getStoreListeners: function() {\n        var me = this;\n        return {\n            add: me.onStoreAdd,\n            clear: me.onStoreClear,\n            remove: me.onStoreRemove,\n            update: me.onStoreUpdate    \n        }; \n    },\n\n    /**\n     * Selects all records in the view.\n     * @param {Boolean} suppressEvent True to suppress any select events\n     */\n    selectAll: function(suppressEvent) {\n        var me = this,\n            selections = me.store.getRange(),\n            i = 0,\n            len = selections.length,\n            start = me.getSelection().length;\n\n        me.bulkChange = true;\n        for (; i < len; i++) {\n            me.doSelect(selections[i], true, suppressEvent);\n        }\n        delete me.bulkChange;\n        // fire selection change only if the number of selections differs\n        me.maybeFireSelectionChange(me.getSelection().length !== start);\n    },\n\n    /**\n     * Deselects all records in the view.\n     * @param {Boolean} suppressEvent True to suppress any deselect events\n     */\n    deselectAll: function(suppressEvent) {\n        var me = this,\n            selections = me.getSelection(),\n            i = 0,\n            len = selections.length,\n            start = me.getSelection().length;\n\n        me.bulkChange = true;\n        for (; i < len; i++) {\n            me.doDeselect(selections[i], suppressEvent);\n        }\n        delete me.bulkChange;\n        // fire selection change only if the number of selections differs\n        me.maybeFireSelectionChange(me.getSelection().length !== start);\n    },\n\n    // Provides differentiation of logic between MULTI, SIMPLE and SINGLE\n    // selection modes. Requires that an event be passed so that we can know\n    // if user held ctrl or shift.\n    selectWithEvent: function(record, e, keepExisting) {\n        var me = this;\n\n        switch (me.selectionMode) {\n            case 'MULTI':\n                if (e.ctrlKey && me.isSelected(record)) {\n                    me.doDeselect(record, false);\n                } else if (e.shiftKey && me.lastFocused) {\n                    me.selectRange(me.lastFocused, record, e.ctrlKey);\n                } else if (e.ctrlKey) {\n                    me.doSelect(record, true, false);\n                } else if (me.isSelected(record) && !e.shiftKey && !e.ctrlKey && me.selected.getCount() > 1) {\n                    me.doSelect(record, keepExisting, false);\n                } else {\n                    me.doSelect(record, false);\n                }\n                break;\n            case 'SIMPLE':\n                if (me.isSelected(record)) {\n                    me.doDeselect(record);\n                } else {\n                    me.doSelect(record, true);\n                }\n                break;\n            case 'SINGLE':\n                // if allowDeselect is on and this record isSelected, deselect it\n                if (me.allowDeselect && me.isSelected(record)) {\n                    me.doDeselect(record);\n                // select the record and do NOT maintain existing selections\n                } else {\n                    me.doSelect(record, false);\n                }\n                break;\n        }\n    },\n\n    /**\n     * Selects a range of rows if the selection model {@link #isLocked is not locked}.\n     * All rows in between startRow and endRow are also selected.\n     * @param {Ext.data.Model/Number} startRow The record or index of the first row in the range\n     * @param {Ext.data.Model/Number} endRow The record or index of the last row in the range\n     * @param {Boolean} keepExisting (optional) True to retain existing selections\n     */\n    selectRange : function(startRow, endRow, keepExisting, dir){\n        var me = this,\n            store = me.store,\n            selectedCount = 0,\n            i,\n            tmp,\n            dontDeselect,\n            records = [];\n\n        if (me.isLocked()){\n            return;\n        }\n\n        if (!keepExisting) {\n            me.deselectAll(true);\n        }\n\n        if (!Ext.isNumber(startRow)) {\n            startRow = store.indexOf(startRow);\n        }\n        if (!Ext.isNumber(endRow)) {\n            endRow = store.indexOf(endRow);\n        }\n\n        // swap values\n        if (startRow > endRow){\n            tmp = endRow;\n            endRow = startRow;\n            startRow = tmp;\n        }\n\n        for (i = startRow; i <= endRow; i++) {\n            if (me.isSelected(store.getAt(i))) {\n                selectedCount++;\n            }\n        }\n\n        if (!dir) {\n            dontDeselect = -1;\n        } else {\n            dontDeselect = (dir == 'up') ? startRow : endRow;\n        }\n\n        for (i = startRow; i <= endRow; i++){\n            if (selectedCount == (endRow - startRow + 1)) {\n                if (i != dontDeselect) {\n                    me.doDeselect(i, true);\n                }\n            } else {\n                records.push(store.getAt(i));\n            }\n        }\n        me.doMultiSelect(records, true);\n    },\n\n    /**\n     * Selects a record instance by record instance or index.\n     * @param {Ext.data.Model[]/Number} records An array of records or an index\n     * @param {Boolean} [keepExisting=false] True to retain existing selections\n     * @param {Boolean} [suppressEvent=false] True to not fire a select event\n     */\n    select: function(records, keepExisting, suppressEvent) {\n        // Automatically selecting eg store.first() or store.last() will pass undefined, so that must just return;\n        if (Ext.isDefined(records)) {\n            this.doSelect(records, keepExisting, suppressEvent);\n        }\n    },\n\n    /**\n     * Deselects a record instance by record instance or index.\n     * @param {Ext.data.Model[]/Number} records An array of records or an index\n     * @param {Boolean} [suppressEvent=false] True to not fire a deselect event\n     */\n    deselect: function(records, suppressEvent) {\n        this.doDeselect(records, suppressEvent);\n    },\n\n    doSelect: function(records, keepExisting, suppressEvent) {\n        var me = this,\n            record;\n\n        if (me.locked || !me.store) {\n            return;\n        }\n        if (typeof records === \"number\") {\n            records = [me.store.getAt(records)];\n        }\n        if (me.selectionMode == \"SINGLE\" && records) {\n            record = records.length ? records[0] : records;\n            me.doSingleSelect(record, suppressEvent);\n        } else {\n            me.doMultiSelect(records, keepExisting, suppressEvent);\n        }\n    },\n\n    doMultiSelect: function(records, keepExisting, suppressEvent) {\n        var me = this,\n            selected = me.selected,\n            change = false,\n            i = 0,\n            len, record;\n\n        if (me.locked) {\n            return;\n        }\n\n\n        records = !Ext.isArray(records) ? [records] : records;\n        len = records.length;\n        if (!keepExisting && selected.getCount() > 0) {\n            if (me.doDeselect(me.getSelection(), suppressEvent) === false) {\n                return;\n            }\n            // TODO - coalesce the selectionchange event in deselect w/the one below...\n        }\n\n        function commit () {\n            selected.add(record);\n            change = true;\n        }\n\n        for (; i < len; i++) {\n            record = records[i];\n            if (keepExisting && me.isSelected(record)) {\n                continue;\n            }\n            me.lastSelected = record;\n\n            me.onSelectChange(record, true, suppressEvent, commit);\n        }\n        if (!me.preventFocus) {\n            me.setLastFocused(record, suppressEvent);\n        }\n        // fire selchange if there was a change and there is no suppressEvent flag\n        me.maybeFireSelectionChange(change && !suppressEvent);\n    },\n\n    // records can be an index, a record or an array of records\n    doDeselect: function(records, suppressEvent) {\n        var me = this,\n            selected = me.selected,\n            i = 0,\n            len, record,\n            attempted = 0,\n            accepted = 0;\n\n        if (me.locked || !me.store) {\n            return false;\n        }\n\n        if (typeof records === \"number\") {\n            records = [me.store.getAt(records)];\n        } else if (!Ext.isArray(records)) {\n            records = [records];\n        }\n\n        function commit () {\n            ++accepted;\n            selected.remove(record);\n        }\n\n        len = records.length;\n\n        for (; i < len; i++) {\n            record = records[i];\n            if (me.isSelected(record)) {\n                if (me.lastSelected == record) {\n                    me.lastSelected = selected.last();\n                }\n                ++attempted;\n                me.onSelectChange(record, false, suppressEvent, commit);\n            }\n        }\n\n        // fire selchange if there was a change and there is no suppressEvent flag\n        me.maybeFireSelectionChange(accepted > 0 && !suppressEvent);\n        return accepted === attempted;\n    },\n\n    doSingleSelect: function(record, suppressEvent) {\n        var me = this,\n            changed = false,\n            selected = me.selected;\n\n        if (me.locked) {\n            return;\n        }\n        // already selected.\n        // should we also check beforeselect?\n        if (me.isSelected(record)) {\n            return;\n        }\n\n        function commit () {\n            me.bulkChange = true;\n            if (selected.getCount() > 0 && me.doDeselect(me.lastSelected, suppressEvent) === false) {\n                delete me.bulkChange;\n                return false;\n            }\n            delete me.bulkChange;\n\n            selected.add(record);\n            me.lastSelected = record;\n            changed = true;\n        }\n\n        me.onSelectChange(record, true, suppressEvent, commit);\n\n        if (changed) {\n            if (!suppressEvent) {\n                me.setLastFocused(record);\n            }\n            me.maybeFireSelectionChange(!suppressEvent);\n        }\n    },\n\n    /**\n     * Sets a record as the last focused record. This does NOT mean\n     * that the record has been selected.\n     * @param {Ext.data.Model} record\n     */\n    setLastFocused: function(record, supressFocus) {\n        var me = this,\n            recordBeforeLast = me.lastFocused;\n\n        me.lastFocused = record;\n         \n        // Only call the changed method if in fact the selected record *has* changed.\n        if (record !== recordBeforeLast) {\n            me.onLastFocusChanged(recordBeforeLast, record, supressFocus);\n        }\n    },\n\n    /**\n     * Determines if this record is currently focused.\n     * @param {Ext.data.Model} record\n     */\n    isFocused: function(record) {\n        return record === this.getLastFocused();\n    },\n\n\n    // fire selection change as long as true is not passed\n    // into maybeFireSelectionChange\n    maybeFireSelectionChange: function(fireEvent) {\n        var me = this;\n        if (fireEvent && !me.bulkChange) {\n            me.fireEvent('selectionchange', me, me.getSelection());\n        }\n    },\n\n    /**\n     * Returns the last selected record.\n     */\n    getLastSelected: function() {\n        return this.lastSelected;\n    },\n\n    getLastFocused: function() {\n        return this.lastFocused;\n    },\n\n    /**\n     * Returns an array of the currently selected records.\n     * @return {Ext.data.Model[]} The selected records\n     */\n    getSelection: function() {\n        return this.selected.getRange();\n    },\n\n    /**\n     * Returns the current selectionMode.\n     * @return {String} The selectionMode: 'SINGLE', 'MULTI' or 'SIMPLE'.\n     */\n    getSelectionMode: function() {\n        return this.selectionMode;\n    },\n\n    /**\n     * Sets the current selectionMode.\n     * @param {String} selMode 'SINGLE', 'MULTI' or 'SIMPLE'.\n     */\n    setSelectionMode: function(selMode) {\n        selMode = selMode ? selMode.toUpperCase() : 'SINGLE';\n        // set to mode specified unless it doesnt exist, in that case\n        // use single.\n        this.selectionMode = this.modes[selMode] ? selMode : 'SINGLE';\n    },\n\n    /**\n     * Returns true if the selections are locked.\n     * @return {Boolean}\n     */\n    isLocked: function() {\n        return this.locked;\n    },\n\n    /**\n     * Locks the current selection and disables any changes from happening to the selection.\n     * @param {Boolean} locked  True to lock, false to unlock.\n     */\n    setLocked: function(locked) {\n        this.locked = !!locked;\n    },\n\n    /**\n     * Returns true if the specified row is selected.\n     * @param {Ext.data.Model/Number} record The record or index of the record to check\n     * @return {Boolean}\n     */\n    isSelected: function(record) {\n        record = Ext.isNumber(record) ? this.store.getAt(record) : record;\n        return this.selected.indexOf(record) !== -1;\n    },\n\n    /**\n     * Returns true if there are any a selected records.\n     * @return {Boolean}\n     */\n    hasSelection: function() {\n        return this.selected.getCount() > 0;\n    },\n\n    refresh: function() {\n        var me = this,\n            store = me.store,\n            toBeSelected = [],\n            oldSelections = me.getSelection(),\n            len = oldSelections.length,\n            selection,\n            change,\n            i = 0,\n            lastFocused = me.getLastFocused();\n\n        // Not been bound yet.\n        if (!store) {\n            return;\n        }\n\n        // check to make sure that there are no records\n        // missing after the refresh was triggered, prune\n        // them from what is to be selected if so\n        for (; i < len; i++) {\n            selection = oldSelections[i];\n            if (!me.pruneRemoved || store.indexOf(selection) !== -1) {\n                toBeSelected.push(selection);\n            }\n        }\n\n        // there was a change from the old selected and\n        // the new selection\n        if (me.selected.getCount() != toBeSelected.length) {\n            change = true;\n        }\n\n        me.clearSelections();\n\n        if (store.indexOf(lastFocused) !== -1) {\n            // restore the last focus but supress restoring focus\n            me.setLastFocused(lastFocused, true);\n        }\n\n        if (toBeSelected.length) {\n            // perform the selection again\n            me.doSelect(toBeSelected, false, true);\n        }\n\n        me.maybeFireSelectionChange(change);\n    },\n\n    /**\n     * A fast reset of the selections without firing events, updating the ui, etc.\n     * For private usage only.\n     * @private\n     */\n    clearSelections: function() {\n        // reset the entire selection to nothing\n        this.selected.clear();\n        this.lastSelected = null;\n        this.setLastFocused(null);\n    },\n\n    // when a record is added to a store\n    onStoreAdd: Ext.emptyFn,\n\n    // when a store is cleared remove all selections\n    // (if there were any)\n    onStoreClear: function() {\n        if (this.selected.getCount > 0) {\n            this.clearSelections();\n            this.maybeFireSelectionChange(true);\n        }\n    },\n\n    // prune records from the SelectionModel if\n    // they were selected at the time they were\n    // removed.\n    onStoreRemove: function(store, record, index) {\n        var me = this,\n            selected = me.selected;\n\n        if (me.locked || !me.pruneRemoved) {\n            return;\n        }\n\n        if (selected.remove(record)) {\n            if (me.lastSelected == record) {\n                me.lastSelected = null;\n            }\n            if (me.getLastFocused() == record) {\n                me.setLastFocused(null);\n            }\n            me.maybeFireSelectionChange(true);\n        }\n    },\n\n    /**\n     * Returns the count of selected records.\n     * @return {Number} The number of selected records\n     */\n    getCount: function() {\n        return this.selected.getCount();\n    },\n\n    // cleanup.\n    destroy: Ext.emptyFn,\n\n    // if records are updated\n    onStoreUpdate: Ext.emptyFn,\n\n    /**\n     * @abstract\n     * @private\n     */\n    onStoreLoad: Ext.emptyFn,\n\n    // @abstract\n    onSelectChange: Ext.emptyFn,\n\n    // @abstract\n    onLastFocusChanged: function(oldFocused, newFocused) {\n        this.fireEvent('focuschange', this, oldFocused, newFocused);\n    },\n\n    // @abstract\n    onEditorKey: Ext.emptyFn,\n\n    // @abstract\n    bindComponent: Ext.emptyFn,\n\n    // @abstract\n    beforeViewRender: Ext.emptyFn\n\n});\n\n/**\n * @private\n */\nExt.define('Ext.selection.DataViewModel', {\n    extend: 'Ext.selection.Model',\n\n    requires: ['Ext.util.KeyNav'],\n\n    deselectOnContainerClick: true,\n\n    /**\n     * @cfg {Boolean} enableKeyNav\n     *\n     * Turns on/off keyboard navigation within the DataView.\n     */\n    enableKeyNav: true,\n\n    constructor: function(cfg){\n        this.addEvents(\n            /**\n             * @event beforedeselect\n             * Fired before a record is deselected. If any listener returns false, the\n             * deselection is cancelled.\n             * @param {Ext.selection.DataViewModel} this\n             * @param {Ext.data.Model} record The deselected record\n             */\n            'beforedeselect',\n\n            /**\n             * @event beforeselect\n             * Fired before a record is selected. If any listener returns false, the\n             * selection is cancelled.\n             * @param {Ext.selection.DataViewModel} this\n             * @param {Ext.data.Model} record The selected record\n             */\n            'beforeselect',\n\n            /**\n             * @event deselect\n             * Fired after a record is deselected\n             * @param {Ext.selection.DataViewModel} this\n             * @param  {Ext.data.Model} record The deselected record\n             */\n            'deselect',\n\n            /**\n             * @event select\n             * Fired after a record is selected\n             * @param {Ext.selection.DataViewModel} this\n             * @param  {Ext.data.Model} record The selected record\n             */\n            'select'\n        );\n        this.callParent(arguments);\n    },\n\n    bindComponent: function(view) {\n        var me = this,\n            eventListeners = {\n                refresh: me.refresh,\n                scope: me\n            };\n\n        me.view = view;\n        me.bindStore(view.getStore());\n\n        eventListeners[view.triggerEvent] = me.onItemClick;\n        eventListeners[view.triggerCtEvent] = me.onContainerClick;\n\n        view.on(eventListeners);\n\n        if (me.enableKeyNav) {\n            me.initKeyNav(view);\n        }\n    },\n\n    onItemClick: function(view, record, item, index, e) {\n        this.selectWithEvent(record, e);\n    },\n\n    onContainerClick: function() {\n        if (this.deselectOnContainerClick) {\n            this.deselectAll();\n        }\n    },\n\n    initKeyNav: function(view) {\n        var me = this;\n\n        if (!view.rendered) {\n            view.on({\n                render: Ext.Function.bind(me.initKeyNav, me, [view]),\n                single: true\n            });\n            return;\n        }\n\n        view.el.set({\n            tabIndex: -1\n        });\n        me.keyNav = new Ext.util.KeyNav({\n            target: view.el,\n            ignoreInputFields: true,\n            down: Ext.pass(me.onNavKey, [1], me),\n            right: Ext.pass(me.onNavKey, [1], me),\n            left: Ext.pass(me.onNavKey, [-1], me),\n            up: Ext.pass(me.onNavKey, [-1], me),\n            scope: me\n        });\n    },\n\n    onNavKey: function(step) {\n        step = step || 1;\n        var me = this,\n            view = me.view,\n            selected = me.getSelection()[0],\n            numRecords = me.view.store.getCount(),\n            idx;\n\n        if (selected) {\n            idx = view.indexOf(view.getNode(selected)) + step;\n        } else {\n            idx = 0;\n        }\n\n        if (idx < 0) {\n            idx = numRecords - 1;\n        } else if (idx >= numRecords) {\n            idx = 0;\n        }\n\n        me.select(idx);\n    },\n\n    // Allow the DataView to update the ui\n    onSelectChange: function(record, isSelected, suppressEvent, commitFn) {\n        var me = this,\n            view = me.view,\n            eventName = isSelected ? 'select' : 'deselect';\n\n        if ((suppressEvent || me.fireEvent('before' + eventName, me, record)) !== false &&\n                commitFn() !== false) {\n\n            if (view) {\n                if (isSelected) {\n                    view.onItemSelect(record);\n                } else {\n                    view.onItemDeselect(record);\n                }\n            }\n\n            if (!suppressEvent) {\n                me.fireEvent(eventName, me, record);\n            }\n        }\n    },\n    \n    destroy: function(){\n        Ext.destroy(this.keyNav);\n        this.callParent();\n    }\n});\n\n/**\n * @class Ext.view.AbstractView\n * This is an abstract superclass and should not be used directly. Please see {@link Ext.view.View}.\n * @private\n */\nExt.define('Ext.view.AbstractView', {\n    extend: 'Ext.Component',\n    requires: [\n        'Ext.LoadMask',\n        'Ext.data.StoreManager',\n        'Ext.CompositeElementLite',\n        'Ext.DomQuery',\n        'Ext.selection.DataViewModel'\n    ],\n    mixins: {\n        bindable: 'Ext.util.Bindable'\n    },\n\n    inheritableStatics: {\n        getRecord: function(node) {\n            return this.getBoundView(node).getRecord(node);\n        },\n\n        getBoundView: function(node) {\n            return Ext.getCmp(node.boundView);\n        }\n    },\n\n    /**\n     * @cfg {String/String[]/Ext.XTemplate} tpl (required)\n     * The HTML fragment or an array of fragments that will make up the template used by this DataView.  This should\n     * be specified in the same format expected by the constructor of {@link Ext.XTemplate}.\n     */\n    /**\n     * @cfg {Ext.data.Store} store (required)\n     * The {@link Ext.data.Store} to bind this DataView to.\n     */\n\n    /**\n     * @cfg {Boolean} deferInitialRefresh\n     * <p>Defaults to <code>true</code> to defer the initial refresh of the view.</p>\n     * <p>This allows the View to execute its render and initial layout more quickly because the process will not be encumbered\n     * by the expensive update of the view structure.</p>\n     * <p><b>Important: </b>Be aware that this will mean that the View's item elements will not be available immediately upon render, so\n     * <i>selection</i> may not take place at render time. To access a View's item elements as soon as possible, use the {@link #viewready} event.\n     * Or set <code>deferInitialrefresh</code> to false, but this will be at the cost of slower rendering.</p>\n     */\n    deferInitialRefresh: true,\n\n    /**\n     * @cfg {String} itemSelector (required)\n     * <b>This is a required setting</b>. A simple CSS selector (e.g. <tt>div.some-class</tt> or\n     * <tt>span:first-child</tt>) that will be used to determine what nodes this DataView will be\n     * working with. The itemSelector is used to map DOM nodes to records. As such, there should\n     * only be one root level element that matches the selector for each record.\n     */\n\n    /**\n     * @cfg {String} itemCls\n     * Specifies the class to be assigned to each element in the view when used in conjunction with the\n     * {@link #itemTpl} configuration.\n     */\n    itemCls: Ext.baseCSSPrefix + 'dataview-item',\n\n    /**\n     * @cfg {String/String[]/Ext.XTemplate} itemTpl\n     * The inner portion of the item template to be rendered. Follows an XTemplate\n     * structure and will be placed inside of a tpl.\n     */\n\n    /**\n     * @cfg {String} overItemCls\n     * A CSS class to apply to each item in the view on mouseover.\n     * Setting this will automatically set {@link #trackOver} to `true`.\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} loadingText\n     * A string to display during data load operations.  If specified, this text will be\n     * displayed in a loading div and the view's contents will be cleared while loading, otherwise the view's\n     * contents will continue to display normally until the new data is loaded and the contents are replaced.\n     */\n    loadingText: 'Loading...',\n    //</locale>\n\n    /**\n     * @cfg {Boolean/Object} loadMask\n     * False to disable a load mask from displaying while the view is loading. This can also be a\n     * {@link Ext.LoadMask} configuration object.\n     */\n    loadMask: true,\n\n    /**\n     * @cfg {String} loadingCls\n     * The CSS class to apply to the loading message element. Defaults to Ext.LoadMask.prototype.msgCls \"x-mask-loading\".\n     */\n\n    /**\n     * @cfg {Boolean} loadingUseMsg\n     * Whether or not to use the loading message.\n     * @private\n     */\n    loadingUseMsg: true,\n\n\n    /**\n     * @cfg {Number} loadingHeight\n     * If specified, gives an explicit height for the data view when it is showing the {@link #loadingText},\n     * if that is specified. This is useful to prevent the view's height from collapsing to zero when the\n     * loading mask is applied and there are no other contents in the data view.\n     */\n\n    /**\n     * @cfg {String} selectedItemCls\n     * A CSS class to apply to each selected item in the view.\n     */\n    selectedItemCls: Ext.baseCSSPrefix + 'item-selected',\n\n    //<locale>\n    /**\n     * @cfg {String} emptyText\n     * The text to display in the view when there is no data to display.\n     * Note that when using local data the emptyText will not be displayed unless you set\n     * the {@link #deferEmptyText} option to false.\n     */\n    emptyText: \"\",\n    //</locale>\n\n    /**\n     * @cfg {Boolean} deferEmptyText\n     * True to defer emptyText being applied until the store's first load.\n     */\n    deferEmptyText: true,\n\n    /**\n     * @cfg {Boolean} trackOver\n     * When `true` the {@link #overItemCls} will be applied to rows when hovered over.\n     * This in return will also cause {@link Ext.view.View#highlightitem highlightitem} and\n     * {@link Ext.view.View#unhighlightitem unhighlightitem} events to be fired.\n     *\n     * Enabled automatically when the {@link #overItemCls} config is set.\n     */\n    trackOver: false,\n\n    /**\n     * @cfg {Boolean} blockRefresh\n     * Set this to true to ignore refresh events on the bound store. This is useful if\n     * you wish to provide custom transition animations via a plugin\n     */\n    blockRefresh: false,\n\n    /**\n     * @cfg {Boolean} disableSelection\n     * True to disable selection within the DataView. This configuration will lock the selection model\n     * that the DataView uses.\n     */\n\n    /**\n     * @cfg {Boolean} preserveScrollOnRefresh=false\n     * True to preserve scroll position across refresh operations.\n     */\n    preserveScrollOnRefresh: false,\n\n    //private\n    last: false,\n\n    triggerEvent: 'itemclick',\n    triggerCtEvent: 'containerclick',\n\n    addCmpEvents: function() {\n\n    },\n\n    // private\n    initComponent : function(){\n        var me = this,\n            isDef = Ext.isDefined,\n            itemTpl = me.itemTpl,\n            memberFn = {};\n\n        if (itemTpl) {\n            if (Ext.isArray(itemTpl)) {\n                // string array\n                itemTpl = itemTpl.join('');\n            } else if (Ext.isObject(itemTpl)) {\n                // tpl instance\n                memberFn = Ext.apply(memberFn, itemTpl.initialConfig);\n                itemTpl = itemTpl.html;\n            }\n\n            if (!me.itemSelector) {\n                me.itemSelector = '.' + me.itemCls;\n            }\n\n            itemTpl = Ext.String.format('<tpl for=\".\"><div class=\"{0}\">{1}</div></tpl>', me.itemCls, itemTpl);\n            me.tpl = new Ext.XTemplate(itemTpl, memberFn);\n        }\n\n        if (!isDef(me.tpl) || !isDef(me.itemSelector)) {\n            Ext.Error.raise({\n                sourceClass: 'Ext.view.View',\n                tpl: me.tpl,\n                itemSelector: me.itemSelector,\n                msg: \"DataView requires both tpl and itemSelector configurations to be defined.\"\n            });\n        }\n\n        me.callParent();\n        if(Ext.isString(me.tpl) || Ext.isArray(me.tpl)){\n            me.tpl = new Ext.XTemplate(me.tpl);\n        }\n\n        // backwards compat alias for overClass/selectedClass\n        // TODO: Consider support for overCls generation Ext.Component config\n        if (isDef(me.overCls) || isDef(me.overClass)) {\n            if (Ext.isDefined(Ext.global.console)) {\n                Ext.global.console.warn('Ext.view.View: Using the deprecated overCls or overClass configuration. Use overItemCls instead.');\n            }\n            me.overItemCls = me.overCls || me.overClass;\n            delete me.overCls;\n            delete me.overClass;\n        }\n\n        if (me.overItemCls) {\n            me.trackOver = true;\n        }\n\n        if (isDef(me.selectedCls) || isDef(me.selectedClass)) {\n            if (Ext.isDefined(Ext.global.console)) {\n                Ext.global.console.warn('Ext.view.View: Using the deprecated selectedCls or selectedClass configuration. Use selectedItemCls instead.');\n            }\n            me.selectedItemCls = me.selectedCls || me.selectedClass;\n            delete me.selectedCls;\n            delete me.selectedClass;\n        }\n\n        me.addEvents(\n            /**\n             * @event beforerefresh\n             * Fires before the view is refreshed\n             * @param {Ext.view.View} this The DataView object\n             */\n            'beforerefresh',\n            /**\n             * @event refresh\n             * Fires when the view is refreshed\n             * @param {Ext.view.View} this The DataView object\n             */\n            'refresh',\n            /**\n             * @event viewready\n             * Fires when the View's item elements representing Store items has been rendered. If the {@link #deferInitialRefresh} flag\n             * was set (and it is <code>true</code> by default), this will be <b>after</b> initial render, and no items will be available\n             * for selection until this event fires.\n             * @param {Ext.view.View} this\n             */\n            'viewready',\n            /**\n             * @event itemupdate\n             * Fires when the node associated with an individual record is updated\n             * @param {Ext.data.Model} record The model instance\n             * @param {Number} index The index of the record/node\n             * @param {HTMLElement} node The node that has just been updated\n             */\n            'itemupdate',\n            /**\n             * @event itemadd\n             * Fires when the nodes associated with an recordset have been added to the underlying store\n             * @param {Ext.data.Model[]} records The model instance\n             * @param {Number} index The index at which the set of record/nodes starts\n             * @param {HTMLElement[]} node The node that has just been updated\n             */\n            'itemadd',\n            /**\n             * @event itemremove\n             * Fires when the node associated with an individual record is removed\n             * @param {Ext.data.Model} record The model instance\n             * @param {Number} index The index of the record/node\n             */\n            'itemremove'\n        );\n\n        me.addCmpEvents();\n\n        // Look up the configured Store. If none configured, use the fieldless, empty Store defined in Ext.data.Store.\n        me.store = Ext.data.StoreManager.lookup(me.store || 'ext-empty-store');\n        me.bindStore(me.store, true);\n        me.all = new Ext.CompositeElementLite();\n\n        // We track the scroll position\n        me.scrollState = {\n            top: 0,\n            left: 0\n        };\n        me.on({\n            scroll: me.onViewScroll,\n            element: 'el',\n            scope: me\n        });\n    },\n\n    onRender: function() {\n        var me = this,\n            mask = me.loadMask,\n            cfg = {\n                msg: me.loadingText,\n                msgCls: me.loadingCls,\n                useMsg: me.loadingUseMsg,\n                // The store gets bound in initComponent, so while\n                // rendering let's push on the store\n                store: me.getMaskStore()\n            };\n\n        me.callParent(arguments);\n\n        if (mask) {\n            // either a config object \n            if (Ext.isObject(mask)) {\n                cfg = Ext.apply(cfg, mask);\n            }\n            // Attach the LoadMask to a *Component* so that it can be sensitive to resizing during long loads.\n            // If this DataView is floating, then mask this DataView.\n            // Otherwise, mask its owning Container (or this, if there *is* no owning Container).\n            // LoadMask captures the element upon render.\n            me.loadMask = new Ext.LoadMask(me, cfg);\n            me.loadMask.on({\n                scope: me,\n                beforeshow: me.onMaskBeforeShow,\n                hide: me.onMaskHide\n            });\n        }\n    },\n    \n    finishRender: function(){\n        var me = this;\n        me.callParent(arguments);\n        // Kick off the refresh before layouts are resumed after the render \n        // completes, but after afterrender is fired on the view\n        if (!me.up('[collapsed],[hidden]')) {\n            me.doFirstRefresh(me.store);\n        }\n    },\n\n    onBoxReady: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        // If the refresh was not kicked off on render due to a collapsed or hidden ancestor,\n        // kick it off as soon as we get layed out\n        if (!me.firstRefreshDone) {\n            me.doFirstRefresh(me.store);\n        }\n    },\n    \n    getMaskStore: function(){\n        return this.store;    \n    },\n    \n    onMaskBeforeShow: function(){\n        var me = this,\n            loadingHeight = me.loadingHeight;\n\n        me.getSelectionModel().deselectAll();\n        me.all.clear();\n        if (loadingHeight && loadingHeight > me.getHeight()) {\n            me.hasLoadingHeight = true;\n            me.oldMinHeight = me.minHeight;\n            me.minHeight = loadingHeight;\n            me.updateLayout();\n        }\n    },\n\n    onMaskHide: function(){\n        var me = this;\n\n        if (!me.destroying && me.hasLoadingHeight) {\n            me.minHeight = me.oldMinHeight;\n            me.updateLayout();\n            delete me.hasLoadingHeight;\n        }\n    },\n\n    beforeRender: function() {\n        this.callParent(arguments);\n        this.getSelectionModel().beforeViewRender(this);\n    },\n\n    afterRender: function() {\n        this.callParent(arguments);\n\n        // Init the SelectionModel after any on('render') listeners have been added.\n        // Drag plugins create a DragDrop instance in a render listener, and that needs\n        // to see an itemmousedown event first.\n        this.getSelectionModel().bindComponent(this);\n    },\n\n    /**\n     * Gets the selection model for this view.\n     * @return {Ext.selection.Model} The selection model\n     */\n    getSelectionModel: function(){\n        var me = this,\n            mode = 'SINGLE';\n\n        if (!me.selModel) {\n            me.selModel = {};\n        }\n\n        if (me.simpleSelect) {\n            mode = 'SIMPLE';\n        } else if (me.multiSelect) {\n            mode = 'MULTI';\n        }\n\n        Ext.applyIf(me.selModel, {\n            allowDeselect: me.allowDeselect,\n            mode: mode\n        });\n\n        if (!me.selModel.events) {\n            me.selModel = new Ext.selection.DataViewModel(me.selModel);\n        }\n\n        if (!me.selModel.hasRelaySetup) {\n            me.relayEvents(me.selModel, [\n                'selectionchange', 'beforeselect', 'beforedeselect', 'select', 'deselect', 'focuschange'\n            ]);\n            me.selModel.hasRelaySetup = true;\n        }\n\n        // lock the selection model if user\n        // has disabled selection\n        if (me.disableSelection) {\n            me.selModel.locked = true;\n        }\n\n        return me.selModel;\n    },\n\n    /**\n     * Refreshes the view by reloading the data from the store and re-rendering the template.\n     */\n    refresh: function() {\n        var me = this,\n            targetEl,\n            targetParent,\n            oldDisplay,\n            nextSibling,\n            dom,\n            records;\n\n        if (!me.rendered || me.isDestroyed) {\n            return;\n        }\n\n        if (!me.hasListeners.beforerefresh || me.fireEvent('beforerefresh', me) !== false) {\n            targetEl = me.getTargetEl();\n            records = me.store.getRange();\n            dom = targetEl.dom;\n\n            // Updating is much quicker if done when the targetEl is detached from the document, and not displayed.\n            // But this resets the scroll position, so when preserving scroll position, this cannot be done.\n            if (!me.preserveScrollOnRefresh) {\n                targetParent = dom.parentNode;\n                oldDisplay = dom.style.display;\n                dom.style.display = 'none';\n                nextSibling = dom.nextSibling;\n                targetParent.removeChild(dom);\n            }\n\n            if (me.refreshCounter) {\n                me.clearViewEl();\n            } else {\n                me.fixedNodes = targetEl.dom.childNodes.length;\n                me.refreshCounter = 1;\n            }\n\n            // Always attempt to create the required markup after the fixedNodes.\n            // Usually, for an empty record set, this would be blank, but when the Template\n            // Creates markup outside of the record loop, this must still be honoured even if there are no\n            // records.\n            me.tpl.append(targetEl, me.collectData(records, 0));\n\n            // The emptyText is now appended to the View's element\n            // after any fixedNodes.\n            if (records.length < 1) {\n                if (!me.deferEmptyText || me.hasSkippedEmptyText) {\n                    Ext.core.DomHelper.insertHtml('beforeEnd', targetEl.dom, me.emptyText);\n                }\n                me.all.clear();\n            } else {\n                me.all.fill(Ext.query(me.getItemSelector(), targetEl.dom));\n                me.updateIndexes(0);\n            }\n\n            me.selModel.refresh();\n            me.hasSkippedEmptyText = true;\n\n            if (!me.preserveScrollOnRefresh) {\n                targetParent.insertBefore(dom, nextSibling);\n                dom.style.display = oldDisplay;\n            }\n\n            // Ensure layout system knows about new content size\n            this.refreshSize();\n\n            me.fireEvent('refresh', me);\n\n            // Upon first refresh, fire the viewready event.\n            // Reconfiguring the grid \"renews\" this event.\n            if (!me.viewReady) {\n                // Fire an event when deferred content becomes available.\n                // This supports grid Panel's deferRowRender capability\n                me.viewReady = true;\n                me.fireEvent('viewready', me);\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Called by the framework when the view is refreshed, or when rows are added or deleted.\n     * \n     * These operations may cause the view's dimensions to change, and if the owning container\n     * is shrinkwrapping this view, then the layout must be updated to accommodate these new dimensions.\n     */\n    refreshSize: function() {\n        var sizeModel = this.getSizeModel();\n        if (sizeModel.height.shrinkWrap || sizeModel.width.shrinkWrap) {\n            this.updateLayout();\n        }\n    },\n\n    clearViewEl: function(){\n        // The purpose of this is to allow boilerplate HTML nodes to remain in place inside a View\n        // while the transient, templated data can be discarded and recreated.\n        // The first time through this code, we take a count of the number of existing child nodes.\n        // Subsequent refreshes then do not clear the entire element, but remove all nodes\n        // *after* the fixedNodes count.\n        // In particular, this is used in infinite grid scrolling: A very tall \"stretcher\" element is\n        // inserted into the View's element to create a scrollbar of the correct proportion.\n\n        var me = this,\n            el = me.getTargetEl();\n\n        if (me.fixedNodes) {\n            while (el.dom.childNodes[me.fixedNodes]) {\n                el.dom.removeChild(el.dom.childNodes[me.fixedNodes]);\n            }\n        } else {\n            el.update('');\n        }\n        me.refreshCounter++;\n    },\n\n    // Private template method to be overridden in subclasses.\n    onViewScroll: Ext.emptyFn,\n\n    /**\n     * Saves the scrollState in a private variable. Must be used in conjunction with restoreScrollState.\n     * @private\n     */\n    saveScrollState: function() {\n        if (this.rendered) {\n            var dom = this.el.dom,\n                state = this.scrollState;\n\n            state.left = dom.scrollLeft;\n            state.top = dom.scrollTop;\n        }\n    },\n\n    /**\n     * Restores the scrollState.\n     * Must be used in conjunction with saveScrollState\n     * @private\n     */\n    restoreScrollState: function() {\n        if (this.rendered) {\n            var dom = this.el.dom, \n                state = this.scrollState;\n\n            dom.scrollLeft = state.left;\n            dom.scrollTop = state.top;\n        }\n    },\n\n    /**\n     * Function which can be overridden to provide custom formatting for each Record that is used by this\n     * DataView's {@link #tpl template} to render each node.\n     * @param {Object/Object[]} data The raw data object that was used to create the Record.\n     * @param {Number} recordIndex the index number of the Record being prepared for rendering.\n     * @param {Ext.data.Model} record The Record being prepared for rendering.\n     * @return {Array/Object} The formatted data in a format expected by the internal {@link #tpl template}'s overwrite() method.\n     * (either an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'}))\n     */\n    prepareData: function(data, index, record) {\n        var associatedData, attr;\n        if (record) {\n            associatedData = record.getAssociatedData();\n            for (attr in associatedData) {\n                if (associatedData.hasOwnProperty(attr)) {\n                    data[attr] = associatedData[attr];\n                }\n            }\n        }\n        return data;\n    },\n\n    /**\n     * <p>Function which can be overridden which returns the data object passed to this\n     * DataView's {@link #tpl template} to render the whole DataView.</p>\n     * <p>This is usually an Array of data objects, each element of which is processed by an\n     * {@link Ext.XTemplate XTemplate} which uses <tt>'&lt;tpl for=\".\"&gt;'</tt> to iterate over its supplied\n     * data object as an Array. However, <i>named</i> properties may be placed into the data object to\n     * provide non-repeating data such as headings, totals etc.</p>\n     * @param {Ext.data.Model[]} records An Array of {@link Ext.data.Model}s to be rendered into the DataView.\n     * @param {Number} startIndex the index number of the Record being prepared for rendering.\n     * @return {Object[]} An Array of data objects to be processed by a repeating XTemplate. May also\n     * contain <i>named</i> properties.\n     */\n    collectData : function(records, startIndex){\n        var data = [],\n            i = 0,\n            len = records.length,\n            record;\n\n        for (; i < len; i++) {\n            record = records[i];\n            data[i] = this.prepareData(record.data, startIndex + i, record);\n        }\n        return data;\n    },\n\n    // private\n    bufferRender : function(records, index){\n        var me = this,\n            div = me.renderBuffer || (me.renderBuffer = document.createElement('div'));\n\n        me.tpl.overwrite(div, me.collectData(records, index));\n        return Ext.query(me.getItemSelector(), div);\n    },\n\n    // private\n    onUpdate : function(ds, record){\n        var me = this,\n            index,\n            node;\n\n        if (me.viewReady) {\n            index = me.store.indexOf(record);\n            if (index > -1) {\n                node = me.bufferRender([record], index)[0];\n                // ensure the node actually exists in the DOM\n                if (me.getNode(record)) {\n                    me.all.replaceElement(index, node, true);\n                    me.updateIndexes(index, index);\n                    // Maintain selection after update\n                    // TODO: Move to approriate event handler.\n                    me.selModel.refresh();\n                    if (me.hasListeners.itemupdate) {\n                        me.fireEvent('itemupdate', record, index, node);\n                    }\n                    return node;\n                }\n            }\n        }\n\n    },\n\n    // private\n    onAdd : function(ds, records, index) {\n        var me = this,\n            nodes;\n\n        if (me.rendered) {\n            // If we are adding into an empty view, we must refresh in order that the *full tpl* is applied\n            // which might create boilerplate content *around* the record nodes.\n            if (me.all.getCount() === 0) {\n                me.refresh();\n                return;\n            }\n\n            nodes = me.bufferRender(records, index);\n            me.doAdd(nodes, records, index);\n\n            me.selModel.refresh();\n            me.updateIndexes(index);\n\n            // Ensure layout system knows about new content size\n            me.refreshSize();\n\n            if (me.hasListeners.itemadd) {\n                me.fireEvent('itemadd', records, index, nodes);\n            }\n        }\n\n    },\n\n    doAdd: function(nodes, records, index) {\n        var all = this.all,\n            count = all.getCount();\n\n        if (count === 0) {\n            this.clearViewEl();\n            this.getTargetEl().appendChild(nodes);\n        } else if (index < count) {\n            if (index === 0) {\n                all.item(index).insertSibling(nodes, 'before', true);\n            } else {\n                all.item(index - 1).insertSibling(nodes, 'after', true);\n            }\n        } else {\n            all.last().insertSibling(nodes, 'after', true);\n        }\n\n        Ext.Array.insert(all.elements, index, nodes);\n    },\n\n    // private\n    onRemove : function(ds, record, index) {\n        var me = this;\n\n        if (me.all.getCount()) {\n            if (me.store.getCount() === 0) {\n                // Refresh so emptyText can be applied if necessary\n                me.refresh();\n            } else {\n                // Just remove the element which corresponds to the removed record\n                // The tpl's full HTML will still be in place.\n                me.doRemove(record, index);\n                if (me.selModel.refreshOnRemove) {\n                    me.selModel.refresh();\n                }\n                me.updateIndexes(index);\n            }\n\n            // Ensure layout system knows about new content height\n            this.refreshSize();\n\n            if (me.hasListeners.itemremove) {\n                me.fireEvent('itemremove', record, index);\n            }\n        }\n    },\n\n    doRemove: function(record, index) {\n        this.all.removeElement(index, true);\n    },\n\n    /**\n     * Refreshes an individual node's data from the store.\n     * @param {Number} index The item's data index in the store\n     */\n    refreshNode : function(index){\n        this.onUpdate(this.store, this.store.getAt(index));\n    },\n\n    // private\n    updateIndexes : function(startIndex, endIndex) {\n        var ns = this.all.elements,\n            records = this.store.getRange(),\n            i;\n\n        startIndex = startIndex || 0;\n        endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));\n        for (i = startIndex; i <= endIndex; i++) {\n            ns[i].viewIndex = i;\n            ns[i].viewRecordId = records[i].internalId;\n            if (!ns[i].boundView) {\n                ns[i].boundView = this.id;\n            }\n        }\n    },\n\n    /**\n     * Returns the store associated with this DataView.\n     * @return {Ext.data.Store} The store\n     */\n    getStore : function() {\n        return this.store;\n    },\n\n    /**\n     * Changes the data store bound to this view and refreshes it.\n     * @param {Ext.data.Store} store The store to bind to this view\n     */\n    bindStore : function(store, initial) {\n        var me = this;\n        me.mixins.bindable.bindStore.apply(me, arguments);\n\n        // Bind the store to our selection model unless it's the initial bind.\n        // Initial bind takes place afterRender\n        if (!initial) {\n            me.getSelectionModel().bindStore(me.store);\n        }\n\n        // If we have already achieved our first layout, refresh immediately.\n        // If we have bound to the Store before the first layout, then onBoxReady will\n        // call doFirstRefresh\n        if (me.componentLayoutCounter) {\n            me.doFirstRefresh(store);\n        }\n    },\n\n    /**\n     * @private\n     * Perform the first refresh of the View from a newly bound store.\n     * \n     * This is called when this View has been sized for the first time.\n     */\n    doFirstRefresh: function(store) {\n        var me = this;\n\n        // Flag to prevent a second \"first\" refresh from onBoxReady\n        me.firstRefreshDone = true;\n\n        // 4.1.0: If we have a store, and the Store is *NOT* already loading (a refresh is on the way), then\n        // on first layout, refresh regardless of record count.\n        // Template may contain boilerplate HTML outside of record iteration loop.\n        // Also, emptyText is appended by the refresh method.\n        // We call refresh on a defer if this is the initial call, and we are configured to defer the initial refresh.\n        if (store && !store.loading) {\n            if (me.deferInitialRefresh) {\n                me.applyFirstRefresh();\n            } else {\n                me.refresh();\n            }\n        }\n    },\n    \n    applyFirstRefresh: function(){\n        var me = this;\n        if (me.isDestroyed) {\n            return;\n        }\n        \n        // In the case of an animated collapse/expand, the layout will\n        // be marked as though it's complete, yet the element itself may\n        // still be animating, which means we could trigger a layout while\n        // everything is not in the correct place. As such, wait until the\n        // animation has finished before kicking off the refresh. The problem\n        // occurs because both the refresh and the animation are running on\n        // a timer which makes it impossible to control the order of when\n        // the refresh is fired.\n        if (me.up('[isCollapsingOrExpanding]')) {\n            Ext.Function.defer(me.applyFirstRefresh, 100, me);\n        } else {\n            Ext.Function.defer(function () {\n                if (!me.isDestroyed) {\n                    me.refresh();\n                }\n            }, 1);\n        }\n    },\n\n    onUnbindStore: function(store) {\n        this.setMaskBind(null);\n    },\n\n    onBindStore: function(store) {\n        this.setMaskBind(store);\n    },\n\n    setMaskBind: function(store) {\n        var mask = this.loadMask;\n        if (mask && mask.bindStore) {\n            mask.bindStore(store);\n        }\n    },\n\n    getStoreListeners: function() {\n        var me = this;\n        return {\n            refresh: me.onDataRefresh,\n            add: me.onAdd,\n            remove: me.onRemove,\n            update: me.onUpdate,\n            clear: me.refresh\n        };\n    },\n\n    /**\n     * @private\n     * Calls this.refresh if this.blockRefresh is not true\n     */\n    onDataRefresh: function() {\n        var me = this,\n            // If we have an ancestor in a non-boxready state (collapsed or in-transition, or hidden), and we are still waiting\n            // for the first refresh, then block the refresh because that first visible, expanded layout will trigger the refresh\n            blockedByAncestor = !me.firstRefreshDone && (!me.rendered || me.up('[collapsed],[isCollapsingOrExpanding],[hidden]'));\n\n        // If are blocking *an initial refresh* because of an ancestor in a non-boxready state,\n        // then cancel any defer on the initial refresh that is going to happen on boxReady - that will be a data-driven refresh, NOT\n        // a render-time, delayable refresh. This is particularly important if the boxready occurs because of the \"preflight\" layout\n        // of an animated expand. If refresh is delayed it occur during the expand animation and cause errors.\n        if (blockedByAncestor) {\n            me.deferInitialRefresh = false;\n        } else if (me.blockRefresh !== true) {\n            me.firstRefreshDone = true;\n            me.refresh.apply(me, arguments);\n        }\n\n    },\n\n    /**\n     * Returns the template node the passed child belongs to, or null if it doesn't belong to one.\n     * @param {HTMLElement} node\n     * @return {HTMLElement} The template node\n     */\n    findItemByChild: function(node){\n        return Ext.fly(node).findParent(this.getItemSelector(), this.getTargetEl());\n    },\n\n    /**\n     * Returns the template node by the Ext.EventObject or null if it is not found.\n     * @param {Ext.EventObject} e\n     */\n    findTargetByEvent: function(e) {\n        return e.getTarget(this.getItemSelector(), this.getTargetEl());\n    },\n\n\n    /**\n     * Gets the currently selected nodes.\n     * @return {HTMLElement[]} An array of HTMLElements\n     */\n    getSelectedNodes: function(){\n        var nodes   = [],\n            records = this.selModel.getSelection(),\n            ln = records.length,\n            i  = 0;\n\n        for (; i < ln; i++) {\n            nodes.push(this.getNode(records[i]));\n        }\n\n        return nodes;\n    },\n\n    /**\n     * Gets an array of the records from an array of nodes\n     * @param {HTMLElement[]} nodes The nodes to evaluate\n     * @return {Ext.data.Model[]} records The {@link Ext.data.Model} objects\n     */\n    getRecords: function(nodes) {\n        var records = [],\n            i = 0,\n            len = nodes.length,\n            data = this.store.data;\n\n        for (; i < len; i++) {\n            records[records.length] = data.getByKey(nodes[i].viewRecordId);\n        }\n\n        return records;\n    },\n\n    /**\n     * Gets a record from a node\n     * @param {Ext.Element/HTMLElement} node The node to evaluate\n     *\n     * @return {Ext.data.Model} record The {@link Ext.data.Model} object\n     */\n    getRecord: function(node){\n        return this.store.data.getByKey(Ext.getDom(node).viewRecordId);\n    },\n\n\n    /**\n     * Returns true if the passed node is selected, else false.\n     * @param {HTMLElement/Number/Ext.data.Model} node The node, node index or record to check\n     * @return {Boolean} True if selected, else false\n     */\n    isSelected : function(node) {\n        // TODO: El/Idx/Record\n        var r = this.getRecord(node);\n        return this.selModel.isSelected(r);\n    },\n\n    /**\n     * Selects a record instance by record instance or index.\n     * @param {Ext.data.Model[]/Number} records An array of records or an index\n     * @param {Boolean} keepExisting\n     * @param {Boolean} suppressEvent Set to false to not fire a select event\n     * @deprecated 4.0 Use {@link Ext.selection.Model#select} instead.\n     */\n    select: function(records, keepExisting, suppressEvent) {\n        this.selModel.select(records, keepExisting, suppressEvent);\n    },\n\n    /**\n     * Deselects a record instance by record instance or index.\n     * @param {Ext.data.Model[]/Number} records An array of records or an index\n     * @param {Boolean} suppressEvent Set to false to not fire a deselect event\n     */\n    deselect: function(records, suppressEvent) {\n        this.selModel.deselect(records, suppressEvent);\n    },\n\n    /**\n     * Gets a template node.\n     * @param {HTMLElement/String/Number/Ext.data.Model} nodeInfo An HTMLElement template node, index of a template node,\n     * the id of a template node or the record associated with the node.\n     * @return {HTMLElement} The node or null if it wasn't found\n     */\n    getNode : function(nodeInfo) {\n        if ((!nodeInfo && nodeInfo !== 0) || !this.rendered) {\n            return null;\n        }\n\n        if (Ext.isString(nodeInfo)) {\n            return document.getElementById(nodeInfo);\n        }\n        if (Ext.isNumber(nodeInfo)) {\n            return this.all.elements[nodeInfo];\n        }\n        if (nodeInfo.isModel) {\n            return this.getNodeByRecord(nodeInfo);\n        }\n        return nodeInfo; // already an HTMLElement\n    },\n\n    /**\n     * @private\n     */\n    getNodeByRecord: function(record) {\n        var ns = this.all.elements,\n            ln = ns.length,\n            i = 0;\n\n        for (; i < ln; i++) {\n            if (ns[i].viewRecordId === record.internalId) {\n                return ns[i];\n            }\n        }\n\n        return null;\n    },\n\n    /**\n     * Gets a range nodes.\n     * @param {Number} start (optional) The index of the first node in the range\n     * @param {Number} end (optional) The index of the last node in the range\n     * @return {HTMLElement[]} An array of nodes\n     */\n    getNodes: function(start, end) {\n        var ns = this.all.elements;\n\n        if (end === undefined) {\n            end = ns.length;\n        } else {\n            end++;\n        }\n        return this.all.elements.slice(start||0, end);\n    },\n\n    /**\n     * Finds the index of the passed node.\n     * @param {HTMLElement/String/Number/Ext.data.Model} nodeInfo An HTMLElement template node, index of a template node, the id of a template node\n     * or a record associated with a node.\n     * @return {Number} The index of the node or -1\n     */\n    indexOf: function(node) {\n        node = this.getNode(node);\n        if (!node && node !== 0) {\n            return -1;\n        }\n        if (Ext.isNumber(node.viewIndex)) {\n            return node.viewIndex;\n        }\n        return this.all.indexOf(node);\n    },\n\n    onDestroy : function() {\n        var me = this;\n\n        me.all.clear();\n        me.callParent();\n        me.bindStore(null);\n        me.selModel.destroy();\n    },\n\n    // invoked by the selection model to maintain visual UI cues\n    onItemSelect: function(record) {\n        var node = this.getNode(record);\n\n        if (node) {\n            Ext.fly(node).addCls(this.selectedItemCls);\n        }\n    },\n\n    // invoked by the selection model to maintain visual UI cues\n    onItemDeselect: function(record) {\n        var node = this.getNode(record);\n\n        if (node) {\n            Ext.fly(node).removeCls(this.selectedItemCls);\n        }\n    },\n\n    getItemSelector: function() {\n        return this.itemSelector;\n    }\n}, function() {\n    // all of this information is available directly\n    // from the SelectionModel itself, the only added methods\n    // to DataView regarding selection will perform some transformation/lookup\n    // between HTMLElement/Nodes to records and vice versa.\n    Ext.deprecate('extjs', '4.0', function() {\n        Ext.view.AbstractView.override({\n            /**\n             * @cfg {Boolean} [multiSelect=false]\n             * True to allow selection of more than one item at a time, false to allow selection of only a single item\n             * at a time or no selection at all, depending on the value of {@link #singleSelect}.\n             * @deprecated 4.1.1 Use {@link Ext.selection.Model#mode} 'MULTI' instead.\n             */\n            /**\n             * @cfg {Boolean} [singleSelect]\n             * Allows selection of exactly one item at a time. As this is the default selection mode anyway, this config\n             * is completely ignored.\n             * @removed 4.1.1 Use {@link Ext.selection.Model#mode} 'SINGLE' instead.\n             */\n            /**\n             * @cfg {Boolean} [simpleSelect=false]\n             * True to enable multiselection by clicking on multiple items without requiring the user to hold Shift or Ctrl,\n             * false to force the user to hold Ctrl or Shift to select more than on item.\n             * @deprecated 4.1.1 Use {@link Ext.selection.Model#mode} 'SIMPLE' instead.\n             */\n\n            /**\n             * Gets the number of selected nodes.\n             * @return {Number} The node count\n             * @deprecated 4.0 Use {@link Ext.selection.Model#getCount} instead.\n             */\n            getSelectionCount : function(){\n                if (Ext.global.console) {\n                    Ext.global.console.warn(\"DataView: getSelectionCount will be removed, please interact with the Ext.selection.DataViewModel\");\n                }\n                return this.selModel.getSelection().length;\n            },\n\n            /**\n             * Gets an array of the selected records\n             * @return {Ext.data.Model[]} An array of {@link Ext.data.Model} objects\n             * @deprecated 4.0 Use {@link Ext.selection.Model#getSelection} instead.\n             */\n            getSelectedRecords : function(){\n                if (Ext.global.console) {\n                    Ext.global.console.warn(\"DataView: getSelectedRecords will be removed, please interact with the Ext.selection.DataViewModel\");\n                }\n                return this.selModel.getSelection();\n            },\n\n            select: function(records, keepExisting, supressEvents) {\n                if (Ext.global.console) {\n                    Ext.global.console.warn(\"DataView: select will be removed, please access select through a DataView's SelectionModel, ie: view.getSelectionModel().select()\");\n                }\n                var sm = this.getSelectionModel();\n                return sm.select.apply(sm, arguments);\n            },\n\n            /**\n             * Deselects all selected records.\n             * @deprecated 4.0 Use {@link Ext.selection.Model#deselectAll} instead.\n             */\n            clearSelections: function() {\n                if (Ext.global.console) {\n                    Ext.global.console.warn(\"DataView: clearSelections will be removed, please access deselectAll through DataView's SelectionModel, ie: view.getSelectionModel().deselectAll()\");\n                }\n                var sm = this.getSelectionModel();\n                return sm.deselectAll();\n            }\n        });\n    });\n});\n\n/**\n * A mechanism for displaying data using custom layout templates and formatting.\n *\n * The View uses an {@link Ext.XTemplate} as its internal templating mechanism, and is bound to an\n * {@link Ext.data.Store} so that as the data in the store changes the view is automatically updated\n * to reflect the changes. The view also provides built-in behavior for many common events that can\n * occur for its contained items including click, doubleclick, mouseover, mouseout, etc. as well as a\n * built-in selection model. **In order to use these features, an {@link #itemSelector} config must\n * be provided for the View to determine what nodes it will be working with.**\n *\n * The example below binds a View to a {@link Ext.data.Store} and renders it into an {@link Ext.panel.Panel}.\n *\n *     @example\n *     Ext.define('Image', {\n *         extend: 'Ext.data.Model',\n *         fields: [\n *             { name:'src', type:'string' },\n *             { name:'caption', type:'string' }\n *         ]\n *     });\n *\n *     Ext.create('Ext.data.Store', {\n *         id:'imagesStore',\n *         model: 'Image',\n *         data: [\n *             { src:'http://www.sencha.com/img/20110215-feat-drawing.png', caption:'Drawing & Charts' },\n *             { src:'http://www.sencha.com/img/20110215-feat-data.png', caption:'Advanced Data' },\n *             { src:'http://www.sencha.com/img/20110215-feat-html5.png', caption:'Overhauled Theme' },\n *             { src:'http://www.sencha.com/img/20110215-feat-perf.png', caption:'Performance Tuned' }\n *         ]\n *     });\n *\n *     var imageTpl = new Ext.XTemplate(\n *         '<tpl for=\".\">',\n *             '<div style=\"margin-bottom: 10px;\" class=\"thumb-wrap\">',\n *               '<img src=\"{src}\" />',\n *               '<br/><span>{caption}</span>',\n *             '</div>',\n *         '</tpl>'\n *     );\n *\n *     Ext.create('Ext.view.View', {\n *         store: Ext.data.StoreManager.lookup('imagesStore'),\n *         tpl: imageTpl,\n *         itemSelector: 'div.thumb-wrap',\n *         emptyText: 'No images available',\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.view.View', {\n    extend: 'Ext.view.AbstractView',\n    alternateClassName: 'Ext.DataView',\n    alias: 'widget.dataview',\n\n    deferHighlight: (Ext.isIE6 || Ext.isIE7) ? 100 : 0,\n\n    inputTagRe: /^textarea$|^input$/i,\n\n    inheritableStatics: {\n        EventMap: {\n            mousedown: 'MouseDown',\n            mouseup: 'MouseUp',\n            click: 'Click',\n            dblclick: 'DblClick',\n            contextmenu: 'ContextMenu',\n            mouseover: 'MouseOver',\n            mouseout: 'MouseOut',\n            mouseenter: 'MouseEnter',\n            mouseleave: 'MouseLeave',\n            keydown: 'KeyDown',\n            focus: 'Focus'\n        }\n    },\n\n    initComponent: function() {\n        var me = this;\n        me.callParent();\n        if (me.deferHighlight){\n            me.setHighlightedItem =\n                Ext.Function.createBuffered(me.setHighlightedItem, me.deferHighlight, me);\n        }\n    },\n\n    addCmpEvents: function() {\n        this.addEvents(\n            /**\n             * @event beforeitemmousedown\n             * Fires before the mousedown event on an item is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforeitemmousedown',\n            /**\n             * @event beforeitemmouseup\n             * Fires before the mouseup event on an item is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforeitemmouseup',\n            /**\n             * @event beforeitemmouseenter\n             * Fires before the mouseenter event on an item is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforeitemmouseenter',\n            /**\n             * @event beforeitemmouseleave\n             * Fires before the mouseleave event on an item is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforeitemmouseleave',\n            /**\n             * @event beforeitemclick\n             * Fires before the click event on an item is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforeitemclick',\n            /**\n             * @event beforeitemdblclick\n             * Fires before the dblclick event on an item is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforeitemdblclick',\n            /**\n             * @event beforeitemcontextmenu\n             * Fires before the contextmenu event on an item is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforeitemcontextmenu',\n            /**\n             * @event beforeitemkeydown\n             * Fires before the keydown event on an item is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object. Use {@link Ext.EventObject#getKey getKey()} to retrieve the key that was pressed.\n             */\n            'beforeitemkeydown',\n            /**\n             * @event itemmousedown\n             * Fires when there is a mouse down on an item\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'itemmousedown',\n            /**\n             * @event itemmouseup\n             * Fires when there is a mouse up on an item\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'itemmouseup',\n            /**\n             * @event itemmouseenter\n             * Fires when the mouse enters an item.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'itemmouseenter',\n            /**\n             * @event itemmouseleave\n             * Fires when the mouse leaves an item.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'itemmouseleave',\n            /**\n             * @event itemclick\n             * Fires when an item is clicked.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'itemclick',\n            /**\n             * @event itemdblclick\n             * Fires when an item is double clicked.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'itemdblclick',\n            /**\n             * @event itemcontextmenu\n             * Fires when an item is right clicked.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'itemcontextmenu',\n            /**\n             * @event itemkeydown\n             * Fires when a key is pressed while an item is currently selected.\n             * @param {Ext.view.View} this\n             * @param {Ext.data.Model} record The record that belongs to the item\n             * @param {HTMLElement} item The item's element\n             * @param {Number} index The item's index\n             * @param {Ext.EventObject} e The raw event object. Use {@link Ext.EventObject#getKey getKey()} to retrieve the key that was pressed.\n             */\n            'itemkeydown',\n            /**\n             * @event beforecontainermousedown\n             * Fires before the mousedown event on the container is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforecontainermousedown',\n            /**\n             * @event beforecontainermouseup\n             * Fires before the mouseup event on the container is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforecontainermouseup',\n            /**\n             * @event beforecontainermouseover\n             * Fires before the mouseover event on the container is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforecontainermouseover',\n            /**\n             * @event beforecontainermouseout\n             * Fires before the mouseout event on the container is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforecontainermouseout',\n            /**\n             * @event beforecontainerclick\n             * Fires before the click event on the container is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforecontainerclick',\n            /**\n             * @event beforecontainerdblclick\n             * Fires before the dblclick event on the container is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforecontainerdblclick',\n            /**\n             * @event beforecontainercontextmenu\n             * Fires before the contextmenu event on the container is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'beforecontainercontextmenu',\n            /**\n             * @event beforecontainerkeydown\n             * Fires before the keydown event on the container is processed. Returns false to cancel the default action.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object. Use {@link Ext.EventObject#getKey getKey()} to retrieve the key that was pressed.\n             */\n            'beforecontainerkeydown',\n            /**\n             * @event containermouseup\n             * Fires when there is a mouse up on the container\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'containermouseup',\n            /**\n             * @event containermouseover\n             * Fires when you move the mouse over the container.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'containermouseover',\n            /**\n             * @event containermouseout\n             * Fires when you move the mouse out of the container.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'containermouseout',\n            /**\n             * @event containerclick\n             * Fires when the container is clicked.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'containerclick',\n            /**\n             * @event containerdblclick\n             * Fires when the container is double clicked.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'containerdblclick',\n            /**\n             * @event containercontextmenu\n             * Fires when the container is right clicked.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object\n             */\n            'containercontextmenu',\n            /**\n             * @event containerkeydown\n             * Fires when a key is pressed while the container is focused, and no item is currently selected.\n             * @param {Ext.view.View} this\n             * @param {Ext.EventObject} e The raw event object. Use {@link Ext.EventObject#getKey getKey()} to retrieve the key that was pressed.\n             */\n            'containerkeydown',\n\n            /**\n             * @event\n             * @inheritdoc Ext.selection.DataViewModel#selectionchange\n             */\n            'selectionchange',\n            /**\n             * @event\n             * @inheritdoc Ext.selection.DataViewModel#beforeselect\n             */\n            'beforeselect',\n            /**\n             * @event\n             * @inheritdoc Ext.selection.DataViewModel#beforedeselect\n             */\n            'beforedeselect',\n            /**\n             * @event\n             * @inheritdoc Ext.selection.DataViewModel#select\n             */\n            'select',\n            /**\n             * @event\n             * @inheritdoc Ext.selection.DataViewModel#deselect\n             */\n            'deselect',\n            /**\n             * @event\n             * @inheritdoc Ext.selection.DataViewModel#focuschange\n             */\n            'focuschange',\n            \n            /**\n             * @event highlightitem\n             * Fires when a node is highlighted using keyboard navigation, or mouseover.\n             * @param {Ext.view.View} view This View Component.\n             * @param {Ext.Element} node The highlighted node.\n             */\n            'highlightitem',\n            \n            /**\n             * @event unhighlightitem\n             * Fires when a node is unhighlighted using keyboard navigation, or mouseout.\n             * @param {Ext.view.View} view This View Component.\n             * @param {Ext.Element} node The previously highlighted node.\n             */\n            'unhighlightitem'\n        );\n    },\n\n    getFocusEl: function() {\n        return this.getTargetEl();\n    },\n\n    // private\n    afterRender: function(){\n        var me = this;\n        me.callParent();\n        me.mon(me.getTargetEl(), {\n            scope: me,\n            /*\n             * We need to make copies of this since some of the events fired here will end up triggering\n             * a new event to be called and the shared event object will be mutated. In future we should\n             * investigate if there are any issues with creating a new event object for each event that\n             * is fired.\n             */\n            freezeEvent: true,\n            click: me.handleEvent,\n            mousedown: me.handleEvent,\n            mouseup: me.handleEvent,\n            dblclick: me.handleEvent,\n            contextmenu: me.handleEvent,\n            mouseover: me.handleEvent,\n            mouseout: me.handleEvent,\n            keydown: me.handleEvent\n        });\n    },\n\n    handleEvent: function(e) {\n        var me = this,\n            key = e.type == 'keydown' && e.getKey();\n\n        if (me.processUIEvent(e) !== false) {\n            me.processSpecialEvent(e);\n        }\n\n        // After all listeners have processed the event, then unless the user is typing into an input field,\n        // prevent browser's default action on SPACE which is to focus the event's target element.\n        // Focusing causes the browser to attempt to scroll the element into view.\n        if (key === e.SPACE) {\n            if (!me.inputTagRe.test(e.getTarget().tagName)) {\n                e.stopEvent();\n            }\n        }\n    },\n\n    // Private template method\n    processItemEvent: Ext.emptyFn,\n    processContainerEvent: Ext.emptyFn,\n    processSpecialEvent: Ext.emptyFn,\n\n    /*\n     * Returns true if this mouseover/out event is still over the overItem.\n     */\n    stillOverItem: function (event, overItem) {\n        var nowOver;\n\n        // There is this weird bug when you hover over the border of a cell it is saying\n        // the target is the table.\n        // BrowserBug: IE6 & 7. If me.mouseOverItem has been removed and is no longer\n        // in the DOM then accessing .offsetParent will throw an \"Unspecified error.\" exception.\n        // typeof'ng and checking to make sure the offsetParent is an object will NOT throw\n        // this hard exception.\n        if (overItem && typeof(overItem.offsetParent) === \"object\") {\n            // mouseout : relatedTarget == nowOver, target == wasOver\n            // mouseover: relatedTarget == wasOver, target == nowOver\n            nowOver = (event.type == 'mouseout') ? event.getRelatedTarget() : event.getTarget();\n            return Ext.fly(overItem).contains(nowOver);\n        }\n\n        return false;\n    },\n\n    processUIEvent: function(e) {\n        var me = this,\n            item = e.getTarget(me.getItemSelector(), me.getTargetEl()),\n            map = this.statics().EventMap,\n            index, record,\n            type = e.type,\n            overItem = me.mouseOverItem,\n            newType;\n\n        if (!item) {\n            if (type == 'mouseover' && me.stillOverItem(e, overItem)) {\n                item = overItem;\n            }\n\n            // Try to get the selected item to handle the keydown event, otherwise we'll just fire a container keydown event\n            if (type == 'keydown') {\n                record = me.getSelectionModel().getLastSelected();\n                if (record) {\n                    item = me.getNode(record);\n                }\n            }\n        }\n\n        if (item) {\n            index = me.indexOf(item);\n            if (!record) {\n                record = me.getRecord(item);\n            }\n\n            // It is possible for an event to arrive for which there is no record... this\n            // can happen with dblclick where the clicks are on removal actions (think a\n            // grid w/\"delete row\" action column)\n            if (!record || me.processItemEvent(record, item, index, e) === false) {\n                return false;\n            }\n\n            newType = me.isNewItemEvent(item, e);\n            if (newType === false) {\n                return false;\n            }\n\n            if (\n                (me['onBeforeItem' + map[newType]](record, item, index, e) === false) ||\n                (me.fireEvent('beforeitem' + newType, me, record, item, index, e) === false) ||\n                (me['onItem' + map[newType]](record, item, index, e) === false)\n            ) {\n                return false;\n            }\n\n            me.fireEvent('item' + newType, me, record, item, index, e);\n        }\n        else {\n            if (\n                (me.processContainerEvent(e) === false) ||\n                (me['onBeforeContainer' + map[type]](e) === false) ||\n                (me.fireEvent('beforecontainer' + type, me, e) === false) ||\n                (me['onContainer' + map[type]](e) === false)\n            ) {\n                return false;\n            }\n\n            me.fireEvent('container' + type, me, e);\n        }\n\n        return true;\n    },\n\n    isNewItemEvent: function (item, e) {\n        var me = this,\n            overItem = me.mouseOverItem,\n            type = e.type;\n\n        switch (type) {\n            case 'mouseover':\n                if (item === overItem) {\n                    return false;\n                }\n                me.mouseOverItem = item;\n                return 'mouseenter';\n\n            case 'mouseout':\n                // If the currently mouseovered item contains the mouseover target, it's *NOT* a mouseleave\n                if (me.stillOverItem(e, overItem)) {\n                    return false;\n                }\n                me.mouseOverItem = null;\n                return 'mouseleave';\n        }\n        return type;\n    },\n\n    // private\n    onItemMouseEnter: function(record, item, index, e) {\n        if (this.trackOver) {\n            this.highlightItem(item);\n        }\n    },\n\n    // private\n    onItemMouseLeave : function(record, item, index, e) {\n        if (this.trackOver) {\n            this.clearHighlight();\n        }\n    },\n\n    // @private, template methods\n    onItemMouseDown: Ext.emptyFn,\n    onItemMouseUp: Ext.emptyFn,\n    onItemFocus: Ext.emptyFn,\n    onItemClick: Ext.emptyFn,\n    onItemDblClick: Ext.emptyFn,\n    onItemContextMenu: Ext.emptyFn,\n    onItemKeyDown: Ext.emptyFn,\n    onBeforeItemMouseDown: Ext.emptyFn,\n    onBeforeItemMouseUp: Ext.emptyFn,\n    onBeforeItemFocus: Ext.emptyFn,\n    onBeforeItemMouseEnter: Ext.emptyFn,\n    onBeforeItemMouseLeave: Ext.emptyFn,\n    onBeforeItemClick: Ext.emptyFn,\n    onBeforeItemDblClick: Ext.emptyFn,\n    onBeforeItemContextMenu: Ext.emptyFn,\n    onBeforeItemKeyDown: Ext.emptyFn,\n\n    // @private, template methods\n    onContainerMouseDown: Ext.emptyFn,\n    onContainerMouseUp: Ext.emptyFn,\n    onContainerMouseOver: Ext.emptyFn,\n    onContainerMouseOut: Ext.emptyFn,\n    onContainerClick: Ext.emptyFn,\n    onContainerDblClick: Ext.emptyFn,\n    onContainerContextMenu: Ext.emptyFn,\n    onContainerKeyDown: Ext.emptyFn,\n    onBeforeContainerMouseDown: Ext.emptyFn,\n    onBeforeContainerMouseUp: Ext.emptyFn,\n    onBeforeContainerMouseOver: Ext.emptyFn,\n    onBeforeContainerMouseOut: Ext.emptyFn,\n    onBeforeContainerClick: Ext.emptyFn,\n    onBeforeContainerDblClick: Ext.emptyFn,\n    onBeforeContainerContextMenu: Ext.emptyFn,\n    onBeforeContainerKeyDown: Ext.emptyFn,\n\n    //private\n    setHighlightedItem: function(item){\n        var me = this,\n            highlighted = me.highlightedItem;\n\n        if (highlighted != item){\n            if (highlighted) {\n                Ext.fly(highlighted).removeCls(me.overItemCls);\n                me.fireEvent('unhighlightitem', me, highlighted);\n            }\n\n            me.highlightedItem = item;\n\n            if (item) {\n                //console.log(item.viewIndex);\n                Ext.fly(item).addCls(me.overItemCls);\n                me.fireEvent('highlightitem', me, item);\n            }\n        }\n    },\n\n    /**\n     * Highlights a given item in the View. This is called by the mouseover handler if {@link #overItemCls}\n     * and {@link #trackOver} are configured, but can also be called manually by other code, for instance to\n     * handle stepping through the list via keyboard navigation.\n     * @param {HTMLElement} item The item to highlight\n     */\n    highlightItem: function(item) {\n        this.setHighlightedItem(item);\n    },\n\n    /**\n     * Un-highlights the currently highlighted item, if any.\n     */\n    clearHighlight: function() {\n        this.setHighlightedItem(undefined);\n    },\n    \n    onUpdate: function(store, record){\n        var me = this,\n            node,\n            newNode,\n            highlighted;\n        \n        if (me.viewReady) {\n            node = me.getNode(record);\n            newNode = me.callParent(arguments);\n            highlighted = me.highlightedItem;\n            \n            if (highlighted && highlighted === node) {\n                delete me.highlightedItem;\n                if (newNode) {\n                    me.highlightItem(newNode);\n                }\n            }\n        }\n    },\n\n    refresh: function() {\n        this.clearHighlight();\n        this.callParent(arguments);\n    }\n});\n\n/**\n * A simple class that renders text directly into a toolbar.\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Panel with TextItem',\n *         width: 300,\n *         height: 200,\n *         tbar: [\n *             { xtype: 'tbtext', text: 'Sample Text Item' }\n *         ],\n *         renderTo: Ext.getBody()\n *     });\n *\n * @constructor\n * Creates a new TextItem\n * @param {Object} text A text string, or a config object containing a #text property\n */\nExt.define('Ext.toolbar.TextItem', {\n    extend: 'Ext.toolbar.Item',\n    requires: ['Ext.XTemplate'],\n    alias: 'widget.tbtext',\n    alternateClassName: 'Ext.Toolbar.TextItem',\n\n    /**\n     * @cfg {String} text\n     * The text to be used as innerHTML (html tags are accepted).\n     */\n    text: '',\n\n    renderTpl: '{text}',\n    //\n    baseCls: Ext.baseCSSPrefix + 'toolbar-text',\n\n    beforeRender : function() {\n        var me = this;\n\n        me.callParent();\n\n        Ext.apply(me.renderData, {\n            text: me.text\n        });\n    },\n\n    /**\n     * Updates this item's text, setting the text to be used as innerHTML.\n     * @param {String} text The text to display (html accepted).\n     */\n    setText : function(text) {\n        var me = this;\n        if (me.rendered) {\n            me.el.update(text);\n            me.updateLayout();\n        } else {\n            this.text = text;\n        }\n    }\n});\n\n/**\n * A field with a pair of up/down spinner buttons. This class is not normally instantiated directly,\n * instead it is subclassed and the {@link #onSpinUp} and {@link #onSpinDown} methods are implemented\n * to handle when the buttons are clicked. A good example of this is the {@link Ext.form.field.Number}\n * field which uses the spinner to increment and decrement the field's value by its\n * {@link Ext.form.field.Number#step step} config value.\n *\n * For example:\n *\n *     @example\n *     Ext.define('Ext.ux.CustomSpinner', {\n *         extend: 'Ext.form.field.Spinner',\n *         alias: 'widget.customspinner',\n *\n *         // override onSpinUp (using step isn't neccessary)\n *         onSpinUp: function() {\n *             var me = this;\n *             if (!me.readOnly) {\n *                 var val = parseInt(me.getValue().split(' '), 10)||0; // gets rid of \" Pack\", defaults to zero on parse failure\n *                 me.setValue((val + me.step) + ' Pack');\n *             }\n *         },\n *\n *         // override onSpinDown\n *         onSpinDown: function() {\n *             var val, me = this;\n *             if (!me.readOnly) {\n *                var val = parseInt(me.getValue().split(' '), 10)||0; // gets rid of \" Pack\", defaults to zero on parse failure\n *                if (val <= me.step) {\n *                    me.setValue('Dry!');\n *                } else {\n *                    me.setValue((val - me.step) + ' Pack');\n *                }\n *             }\n *         }\n *     });\n *\n *     Ext.create('Ext.form.FormPanel', {\n *         title: 'Form with SpinnerField',\n *         bodyPadding: 5,\n *         width: 350,\n *         renderTo: Ext.getBody(),\n *         items:[{\n *             xtype: 'customspinner',\n *             fieldLabel: 'How Much Beer?',\n *             step: 6\n *         }]\n *     });\n *\n * By default, pressing the up and down arrow keys will also trigger the onSpinUp and onSpinDown methods;\n * to prevent this, set `{@link #keyNavEnabled} = false`.\n */\nExt.define('Ext.form.field.Spinner', {\n    extend: 'Ext.form.field.Trigger',\n    alias: 'widget.spinnerfield',\n    alternateClassName: 'Ext.form.Spinner',\n    requires: ['Ext.util.KeyNav'],\n\n    trigger1Cls: Ext.baseCSSPrefix + 'form-spinner-up',\n    trigger2Cls: Ext.baseCSSPrefix + 'form-spinner-down',\n\n    /**\n     * @cfg {Boolean} spinUpEnabled\n     * Specifies whether the up spinner button is enabled. Defaults to true. To change this after the component is\n     * created, use the {@link #setSpinUpEnabled} method.\n     */\n    spinUpEnabled: true,\n\n    /**\n     * @cfg {Boolean} spinDownEnabled\n     * Specifies whether the down spinner button is enabled. Defaults to true. To change this after the component is\n     * created, use the {@link #setSpinDownEnabled} method.\n     */\n    spinDownEnabled: true,\n\n    /**\n     * @cfg {Boolean} keyNavEnabled\n     * Specifies whether the up and down arrow keys should trigger spinning up and down. Defaults to true.\n     */\n    keyNavEnabled: true,\n\n    /**\n     * @cfg {Boolean} mouseWheelEnabled\n     * Specifies whether the mouse wheel should trigger spinning up and down while the field has focus.\n     * Defaults to true.\n     */\n    mouseWheelEnabled: true,\n\n    /**\n     * @cfg {Boolean} repeatTriggerClick\n     * Whether a {@link Ext.util.ClickRepeater click repeater} should be attached to the spinner buttons.\n     * Defaults to true.\n     */\n    repeatTriggerClick: true,\n\n    /**\n     * @method\n     * @protected\n     * This method is called when the spinner up button is clicked, or when the up arrow key is pressed if\n     * {@link #keyNavEnabled} is true. Must be implemented by subclasses.\n     */\n    onSpinUp: Ext.emptyFn,\n\n    /**\n     * @method\n     * @protected\n     * This method is called when the spinner down button is clicked, or when the down arrow key is pressed if\n     * {@link #keyNavEnabled} is true. Must be implemented by subclasses.\n     */\n    onSpinDown: Ext.emptyFn,\n\n    triggerTpl: '<td style=\"{triggerStyle}\">' +\n                    '<div class=\"' + Ext.baseCSSPrefix + 'trigger-index-0 ' + Ext.baseCSSPrefix + 'form-trigger ' + Ext.baseCSSPrefix + 'form-spinner-up\" role=\"button\"></div>' +\n                    '<div class=\"' + Ext.baseCSSPrefix + 'trigger-index-1 ' + Ext.baseCSSPrefix + 'form-trigger ' + Ext.baseCSSPrefix + 'form-spinner-down\" role=\"button\"></div>' +\n                '</td>' +\n            '</tr>',\n\n    initComponent: function() {\n        this.callParent();\n\n        this.addEvents(\n            /**\n             * @event spin\n             * Fires when the spinner is made to spin up or down.\n             * @param {Ext.form.field.Spinner} this\n             * @param {String} direction Either 'up' if spinning up, or 'down' if spinning down.\n             */\n            'spin',\n\n            /**\n             * @event spinup\n             * Fires when the spinner is made to spin up.\n             * @param {Ext.form.field.Spinner} this\n             */\n            'spinup',\n\n            /**\n             * @event spindown\n             * Fires when the spinner is made to spin down.\n             * @param {Ext.form.field.Spinner} this\n             */\n            'spindown'\n        );\n    },\n\n    /**\n     * @private\n     * Override.\n     */\n    onRender: function() {\n        var me = this,\n            triggers;\n\n        me.callParent(arguments);\n        triggers = me.triggerEl;\n        \n        /**\n         * @property {Ext.Element} spinUpEl\n         * The spinner up button element\n         */\n        me.spinUpEl = triggers.item(0);\n        /**\n         * @property {Ext.Element} spinDownEl\n         * The spinner down button element\n         */\n        me.spinDownEl = triggers.item(1);\n        \n        me.triggerCell = me.spinUpEl.parent(); \n\n        // Set initial enabled/disabled states\n        me.setSpinUpEnabled(me.spinUpEnabled);\n        me.setSpinDownEnabled(me.spinDownEnabled);\n\n        // Init up/down arrow keys\n        if (me.keyNavEnabled) {\n            me.spinnerKeyNav = new Ext.util.KeyNav(me.inputEl, {\n                scope: me,\n                up: me.spinUp,\n                down: me.spinDown\n            });\n        }\n\n        // Init mouse wheel\n        if (me.mouseWheelEnabled) {\n            me.mon(me.bodyEl, 'mousewheel', me.onMouseWheel, me);\n        }\n    },\n\n    getSubTplMarkup: function() {\n        var me = this,\n            field = Ext.form.field.Base.prototype.getSubTplMarkup.apply(me, arguments);\n\n        return '<table id=\"' + me.id + '-triggerWrap\" class=\"' + Ext.baseCSSPrefix + 'form-trigger-wrap\" cellpadding=\"0\" cellspacing=\"0\">' +\n            '<tbody>' +\n                '<tr><td id=\"' + me.id + '-inputCell\" class=\"' + Ext.baseCSSPrefix + 'form-trigger-input-cell\">' + field + '</td>' +\n                me.getTriggerMarkup() +\n            '</tbody></table>';\n    },\n\n    getTriggerMarkup: function() {\n        var me = this,\n            hideTrigger = (me.readOnly || me.hideTrigger);\n\n        return me.getTpl('triggerTpl').apply({\n            triggerStyle: 'width:' + me.triggerWidth + (hideTrigger ? 'px;display:none' : 'px')\n        });\n    },\n\n    /**\n     * Get the total width of the spinner button area.\n     * @return {Number} The total spinner button width\n     */\n    getTriggerWidth: function() {\n        var me = this,\n            totalTriggerWidth = 0;\n\n        if (me.triggerWrap && !me.hideTrigger && !me.readOnly) {\n            totalTriggerWidth = me.triggerWidth;\n        }\n        return totalTriggerWidth;\n    },\n\n    /**\n     * @private\n     * Handles the spinner up button clicks.\n     */\n    onTrigger1Click: function() {\n        this.spinUp();\n    },\n\n    /**\n     * @private\n     * Handles the spinner down button clicks.\n     */\n    onTrigger2Click: function() {\n        this.spinDown();\n    },\n\n    // private\n    // Handle trigger mouse up gesture; refocuses the input element upon end of spin.\n    onTriggerWrapMouseup: function() {\n        this.inputEl.focus();\n    },\n\n    /**\n     * Triggers the spinner to step up; fires the {@link #spin} and {@link #spinup} events and calls the\n     * {@link #onSpinUp} method. Does nothing if the field is {@link #disabled} or if {@link #spinUpEnabled}\n     * is false.\n     */\n    spinUp: function() {\n        var me = this;\n        if (me.spinUpEnabled && !me.disabled) {\n            me.fireEvent('spin', me, 'up');\n            me.fireEvent('spinup', me);\n            me.onSpinUp();\n        }\n    },\n\n    /**\n     * Triggers the spinner to step down; fires the {@link #spin} and {@link #spindown} events and calls the\n     * {@link #onSpinDown} method. Does nothing if the field is {@link #disabled} or if {@link #spinDownEnabled}\n     * is false.\n     */\n    spinDown: function() {\n        var me = this;\n        if (me.spinDownEnabled && !me.disabled) {\n            me.fireEvent('spin', me, 'down');\n            me.fireEvent('spindown', me);\n            me.onSpinDown();\n        }\n    },\n\n    /**\n     * Sets whether the spinner up button is enabled.\n     * @param {Boolean} enabled true to enable the button, false to disable it.\n     */\n    setSpinUpEnabled: function(enabled) {\n        var me = this,\n            wasEnabled = me.spinUpEnabled;\n        me.spinUpEnabled = enabled;\n        if (wasEnabled !== enabled && me.rendered) {\n            me.spinUpEl[enabled ? 'removeCls' : 'addCls'](me.trigger1Cls + '-disabled');\n        }\n    },\n\n    /**\n     * Sets whether the spinner down button is enabled.\n     * @param {Boolean} enabled true to enable the button, false to disable it.\n     */\n    setSpinDownEnabled: function(enabled) {\n        var me = this,\n            wasEnabled = me.spinDownEnabled;\n        me.spinDownEnabled = enabled;\n        if (wasEnabled !== enabled && me.rendered) {\n            me.spinDownEl[enabled ? 'removeCls' : 'addCls'](me.trigger2Cls + '-disabled');\n        }\n    },\n\n    /**\n     * @private\n     * Handles mousewheel events on the field\n     */\n    onMouseWheel: function(e) {\n        var me = this,\n            delta;\n        if (me.hasFocus) {\n            delta = e.getWheelDelta();\n            if (delta > 0) {\n                me.spinUp();\n            }\n            else if (delta < 0) {\n                me.spinDown();\n            }\n            e.stopEvent();\n        }\n    },\n\n    onDestroy: function() {\n        Ext.destroyMembers(this, 'spinnerKeyNav', 'spinUpEl', 'spinDownEl');\n        this.callParent();\n    }\n\n});\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * A numeric text field that provides automatic keystroke filtering to disallow non-numeric characters,\n * and numeric validation to limit the value to a range of valid numbers. The range of acceptable number\n * values can be controlled by setting the {@link #minValue} and {@link #maxValue} configs, and fractional\n * decimals can be disallowed by setting {@link #allowDecimals} to `false`.\n *\n * By default, the number field is also rendered with a set of up/down spinner buttons and has\n * up/down arrow key and mouse wheel event listeners attached for incrementing/decrementing the value by the\n * {@link #step} value. To hide the spinner buttons set `{@link #hideTrigger hideTrigger}:true`; to disable\n * the arrow key and mouse wheel handlers set `{@link #keyNavEnabled keyNavEnabled}:false` and\n * `{@link #mouseWheelEnabled mouseWheelEnabled}:false`. See the example below.\n *\n * # Example usage\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'On The Wall',\n *         width: 300,\n *         bodyPadding: 10,\n *         renderTo: Ext.getBody(),\n *         items: [{\n *             xtype: 'numberfield',\n *             anchor: '100%',\n *             name: 'bottles',\n *             fieldLabel: 'Bottles of Beer',\n *             value: 99,\n *             maxValue: 99,\n *             minValue: 0\n *         }],\n *         buttons: [{\n *             text: 'Take one down, pass it around',\n *             handler: function() {\n *                 this.up('form').down('[name=bottles]').spinDown();\n *             }\n *         }]\n *     });\n *\n * # Removing UI Enhancements\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Personal Info',\n *         width: 300,\n *         bodyPadding: 10,\n *         renderTo: Ext.getBody(),\n *         items: [{\n *             xtype: 'numberfield',\n *             anchor: '100%',\n *             name: 'age',\n *             fieldLabel: 'Age',\n *             minValue: 0, //prevents negative numbers\n *\n *             // Remove spinner buttons, and arrow key and mouse wheel listeners\n *             hideTrigger: true,\n *             keyNavEnabled: false,\n *             mouseWheelEnabled: false\n *         }]\n *     });\n *\n * # Using Step\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         renderTo: Ext.getBody(),\n *         title: 'Step',\n *         width: 300,\n *         bodyPadding: 10,\n *         items: [{\n *             xtype: 'numberfield',\n *             anchor: '100%',\n *             name: 'evens',\n *             fieldLabel: 'Even Numbers',\n *\n *             // Set step so it skips every other number\n *             step: 2,\n *             value: 0,\n *\n *             // Add change handler to force user-entered numbers to evens\n *             listeners: {\n *                 change: function(field, value) {\n *                     value = parseInt(value, 10);\n *                     field.setValue(value + value % 2);\n *                 }\n *             }\n *         }]\n *     });\n */\nExt.define('Ext.form.field.Number', {\n    extend:'Ext.form.field.Spinner',\n    alias: 'widget.numberfield',\n    alternateClassName: ['Ext.form.NumberField', 'Ext.form.Number'],\n\n    /**\n     * @cfg {RegExp} stripCharsRe\n     * @private\n     */\n    /**\n     * @cfg {RegExp} maskRe\n     * @private\n     */\n\n    /**\n     * @cfg {Boolean} allowDecimals\n     * False to disallow decimal values\n     */\n    allowDecimals : true,\n\n    //<locale>\n    /**\n     * @cfg {String} decimalSeparator\n     * Character(s) to allow as the decimal separator\n     */\n    decimalSeparator : '.',\n    //</locale>\n    \n    //<locale>\n    /**\n     * @cfg {Boolean} [submitLocaleSeparator=true]\n     * False to ensure that the {@link #getSubmitValue} method strips\n     * always uses `.` as the separator, regardless of the {@link #decimalSeparator}\n     * configuration.\n     */\n    submitLocaleSeparator: true,\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {Number} decimalPrecision\n     * The maximum precision to display after the decimal separator\n     */\n    decimalPrecision : 2,\n    //</locale>\n\n    /**\n     * @cfg {Number} minValue\n     * The minimum allowed value. Will be used by the field's validation logic,\n     * and for {@link Ext.form.field.Spinner#setSpinUpEnabled enabling/disabling the down spinner button}.\n     *\n     * Defaults to Number.NEGATIVE_INFINITY.\n     */\n    minValue: Number.NEGATIVE_INFINITY,\n\n    /**\n     * @cfg {Number} maxValue\n     * The maximum allowed value. Will be used by the field's validation logic, and for\n     * {@link Ext.form.field.Spinner#setSpinUpEnabled enabling/disabling the up spinner button}.\n     *\n     * Defaults to Number.MAX_VALUE.\n     */\n    maxValue: Number.MAX_VALUE,\n\n    /**\n     * @cfg {Number} step\n     * Specifies a numeric interval by which the field's value will be incremented or decremented when the user invokes\n     * the spinner.\n     */\n    step: 1,\n\n    //<locale>\n    /**\n     * @cfg {String} minText\n     * Error text to display if the minimum value validation fails.\n     */\n    minText : 'The minimum value for this field is {0}',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} maxText\n     * Error text to display if the maximum value validation fails.\n     */\n    maxText : 'The maximum value for this field is {0}',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} nanText\n     * Error text to display if the value is not a valid number. For example, this can happen if a valid character like\n     * '.' or '-' is left in the field with no number.\n     */\n    nanText : '{0} is not a valid number',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} negativeText\n     * Error text to display if the value is negative and {@link #minValue} is set to 0. This is used instead of the\n     * {@link #minText} in that circumstance only.\n     */\n    negativeText : 'The value cannot be negative',\n    //</locale>\n\n    /**\n     * @cfg {String} baseChars\n     * The base set of characters to evaluate as valid numbers.\n     */\n    baseChars : '0123456789',\n\n    /**\n     * @cfg {Boolean} autoStripChars\n     * True to automatically strip not allowed characters from the field.\n     */\n    autoStripChars: false,\n\n    initComponent: function() {\n        var me = this,\n            allowed;\n\n        me.callParent();\n\n        me.setMinValue(me.minValue);\n        me.setMaxValue(me.maxValue);\n\n        // Build regexes for masking and stripping based on the configured options\n        if (me.disableKeyFilter !== true) {\n            allowed = me.baseChars + '';\n            if (me.allowDecimals) {\n                allowed += me.decimalSeparator;\n            }\n            if (me.minValue < 0) {\n                allowed += '-';\n            }\n            allowed = Ext.String.escapeRegex(allowed);\n            me.maskRe = new RegExp('[' + allowed + ']');\n            if (me.autoStripChars) {\n                me.stripCharsRe = new RegExp('[^' + allowed + ']', 'gi');\n            }\n        }\n    },\n\n    /**\n     * Runs all of Number's validations and returns an array of any errors. Note that this first runs Text's\n     * validations, so the returned array is an amalgamation of all field errors. The additional validations run test\n     * that the value is a number, and that it is within the configured min and max values.\n     * @param {Object} [value] The value to get errors for (defaults to the current field value)\n     * @return {String[]} All validation errors for this field\n     */\n    getErrors: function(value) {\n        var me = this,\n            errors = me.callParent(arguments),\n            format = Ext.String.format,\n            num;\n\n        value = Ext.isDefined(value) ? value : this.processRawValue(this.getRawValue());\n\n        if (value.length < 1) { // if it's blank and textfield didn't flag it then it's valid\n             return errors;\n        }\n\n        value = String(value).replace(me.decimalSeparator, '.');\n\n        if(isNaN(value)){\n            errors.push(format(me.nanText, value));\n        }\n\n        num = me.parseValue(value);\n\n        if (me.minValue === 0 && num < 0) {\n            errors.push(this.negativeText);\n        }\n        else if (num < me.minValue) {\n            errors.push(format(me.minText, me.minValue));\n        }\n\n        if (num > me.maxValue) {\n            errors.push(format(me.maxText, me.maxValue));\n        }\n\n\n        return errors;\n    },\n\n    rawToValue: function(rawValue) {\n        var value = this.fixPrecision(this.parseValue(rawValue));\n        if (value === null) {\n            value = rawValue || null;\n        }\n        return  value;\n    },\n\n    valueToRaw: function(value) {\n        var me = this,\n            decimalSeparator = me.decimalSeparator;\n        value = me.parseValue(value);\n        value = me.fixPrecision(value);\n        value = Ext.isNumber(value) ? value : parseFloat(String(value).replace(decimalSeparator, '.'));\n        value = isNaN(value) ? '' : String(value).replace('.', decimalSeparator);\n        return value;\n    },\n    \n    getSubmitValue: function() {\n        var me = this,\n            value = me.callParent();\n            \n        if (!me.submitLocaleSeparator) {\n            value = value.replace(me.decimalSeparator, '.');\n        }  \n        return value;\n    },\n\n    onChange: function() {\n        this.toggleSpinners();\n        this.callParent(arguments);\n    },\n    \n    toggleSpinners: function(){\n        var me = this,\n            value = me.getValue(),\n            valueIsNull = value === null;\n            \n        me.setSpinUpEnabled(valueIsNull || value < me.maxValue);\n        me.setSpinDownEnabled(valueIsNull || value > me.minValue);\n    },\n\n    /**\n     * Replaces any existing {@link #minValue} with the new value.\n     * @param {Number} value The minimum value\n     */\n    setMinValue : function(value) {\n        this.minValue = Ext.Number.from(value, Number.NEGATIVE_INFINITY);\n        this.toggleSpinners();\n    },\n\n    /**\n     * Replaces any existing {@link #maxValue} with the new value.\n     * @param {Number} value The maximum value\n     */\n    setMaxValue: function(value) {\n        this.maxValue = Ext.Number.from(value, Number.MAX_VALUE);\n        this.toggleSpinners();\n    },\n\n    // private\n    parseValue : function(value) {\n        value = parseFloat(String(value).replace(this.decimalSeparator, '.'));\n        return isNaN(value) ? null : value;\n    },\n\n    /**\n     * @private\n     */\n    fixPrecision : function(value) {\n        var me = this,\n            nan = isNaN(value),\n            precision = me.decimalPrecision;\n\n        if (nan || !value) {\n            return nan ? '' : value;\n        } else if (!me.allowDecimals || precision <= 0) {\n            precision = 0;\n        }\n\n        return parseFloat(Ext.Number.toFixed(parseFloat(value), precision));\n    },\n\n    beforeBlur : function() {\n        var me = this,\n            v = me.parseValue(me.getRawValue());\n\n        if (!Ext.isEmpty(v)) {\n            me.setValue(v);\n        }\n    },\n\n    onSpinUp: function() {\n        var me = this;\n        if (!me.readOnly) {\n            me.setValue(Ext.Number.constrain(me.getValue() + me.step, me.minValue, me.maxValue));\n        }\n    },\n\n    onSpinDown: function() {\n        var me = this;\n        if (!me.readOnly) {\n            me.setValue(Ext.Number.constrain(me.getValue() - me.step, me.minValue, me.maxValue));\n        }\n    }\n});\n\n/**\n * As the number of records increases, the time required for the browser to render them increases. Paging is used to\n * reduce the amount of data exchanged with the client. Note: if there are more records/rows than can be viewed in the\n * available screen area, vertical scrollbars will be added.\n *\n * Paging is typically handled on the server side (see exception below). The client sends parameters to the server side,\n * which the server needs to interpret and then respond with the appropriate data.\n *\n * Ext.toolbar.Paging is a specialized toolbar that is bound to a {@link Ext.data.Store} and provides automatic\n * paging control. This Component {@link Ext.data.Store#method-load load}s blocks of data into the {@link #store} by passing\n * parameters used for paging criteria.\n *\n * {@img Ext.toolbar.Paging/Ext.toolbar.Paging.png Ext.toolbar.Paging component}\n *\n * Paging Toolbar is typically used as one of the Grid's toolbars:\n *\n *     @example\n *     var itemsPerPage = 2;   // set the number of items you want per page\n *\n *     var store = Ext.create('Ext.data.Store', {\n *         id:'simpsonsStore',\n *         autoLoad: false,\n *         fields:['name', 'email', 'phone'],\n *         pageSize: itemsPerPage, // items per page\n *         proxy: {\n *             type: 'ajax',\n *             url: 'pagingstore.js',  // url that will load data with respect to start and limit params\n *             reader: {\n *                 type: 'json',\n *                 root: 'items',\n *                 totalProperty: 'total'\n *             }\n *         }\n *     });\n *\n *     // specify segment of data you want to load using params\n *     store.load({\n *         params:{\n *             start:0,\n *             limit: itemsPerPage\n *         }\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Simpsons',\n *         store: store,\n *         columns: [\n *             { header: 'Name',  dataIndex: 'name' },\n *             { header: 'Email', dataIndex: 'email', flex: 1 },\n *             { header: 'Phone', dataIndex: 'phone' }\n *         ],\n *         width: 400,\n *         height: 125,\n *         dockedItems: [{\n *             xtype: 'pagingtoolbar',\n *             store: store,   // same store GridPanel is using\n *             dock: 'bottom',\n *             displayInfo: true\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n *\n * To use paging, you need to set a pageSize configuration on the Store, and pass the paging requirements to\n * the server when the store is first loaded.\n *\n *     store.load({\n *         params: {\n *             // specify params for the first page load if using paging\n *             start: 0,\n *             limit: myPageSize,\n *             // other params\n *             foo:   'bar'\n *         }\n *     });\n *\n * If using {@link Ext.data.Store#autoLoad store's autoLoad} configuration:\n *\n *     var myStore = Ext.create('Ext.data.Store', {\n *         {@link Ext.data.Store#autoLoad autoLoad}: {start: 0, limit: 25},\n *         ...\n *     });\n *\n * The packet sent back from the server would have this form:\n *\n *     {\n *         \"success\": true,\n *         \"results\": 2000,\n *         \"rows\": [ // ***Note:** this must be an Array\n *             { \"id\":  1, \"name\": \"Bill\", \"occupation\": \"Gardener\" },\n *             { \"id\":  2, \"name\":  \"Ben\", \"occupation\": \"Horticulturalist\" },\n *             ...\n *             { \"id\": 25, \"name\":  \"Sue\", \"occupation\": \"Botanist\" }\n *         ]\n *     }\n *\n * ## Paging with Local Data\n *\n * Paging can also be accomplished with local data using extensions:\n *\n *   - [Ext.ux.data.PagingStore][1]\n *   - Paging Memory Proxy (examples/ux/PagingMemoryProxy.js)\n *\n *    [1]: http://sencha.com/forum/showthread.php?t=71532\n */\nExt.define('Ext.toolbar.Paging', {\n    extend: 'Ext.toolbar.Toolbar',\n    alias: 'widget.pagingtoolbar',\n    alternateClassName: 'Ext.PagingToolbar',\n    requires: ['Ext.toolbar.TextItem', 'Ext.form.field.Number'],\n    mixins: {\n        bindable: 'Ext.util.Bindable'    \n    },\n    /**\n     * @cfg {Ext.data.Store} store (required)\n     * The {@link Ext.data.Store} the paging toolbar should use as its data source.\n     */\n\n    /**\n     * @cfg {Boolean} displayInfo\n     * true to display the displayMsg\n     */\n    displayInfo: false,\n\n    /**\n     * @cfg {Boolean} prependButtons\n     * true to insert any configured items _before_ the paging buttons.\n     */\n    prependButtons: false,\n\n    //<locale>\n    /**\n     * @cfg {String} displayMsg\n     * The paging status message to display. Note that this string is\n     * formatted using the braced numbers {0}-{2} as tokens that are replaced by the values for start, end and total\n     * respectively. These tokens should be preserved when overriding this string if showing those values is desired.\n     */\n    displayMsg : 'Displaying {0} - {1} of {2}',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} emptyMsg\n     * The message to display when no records are found.\n     */\n    emptyMsg : 'No data to display',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} beforePageText\n     * The text displayed before the input item.\n     */\n    beforePageText : 'Page',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} afterPageText\n     * Customizable piece of the default paging text. Note that this string is formatted using\n     * {0} as a token that is replaced by the number of total pages. This token should be preserved when overriding this\n     * string if showing the total page count is desired.\n     */\n    afterPageText : 'of {0}',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} firstText\n     * The quicktip text displayed for the first page button.\n     * **Note**: quick tips must be initialized for the quicktip to show.\n     */\n    firstText : 'First Page',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} prevText\n     * The quicktip text displayed for the previous page button.\n     * **Note**: quick tips must be initialized for the quicktip to show.\n     */\n    prevText : 'Previous Page',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} nextText\n     * The quicktip text displayed for the next page button.\n     * **Note**: quick tips must be initialized for the quicktip to show.\n     */\n    nextText : 'Next Page',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} lastText\n     * The quicktip text displayed for the last page button.\n     * **Note**: quick tips must be initialized for the quicktip to show.\n     */\n    lastText : 'Last Page',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} refreshText\n     * The quicktip text displayed for the Refresh button.\n     * **Note**: quick tips must be initialized for the quicktip to show.\n     */\n    refreshText : 'Refresh',\n    //</locale>\n\n    /**\n     * @cfg {Number} inputItemWidth\n     * The width in pixels of the input field used to display and change the current page number.\n     */\n    inputItemWidth : 30,\n\n    /**\n     * Gets the standard paging items in the toolbar\n     * @private\n     */\n    getPagingItems: function() {\n        var me = this;\n\n        return [{\n            itemId: 'first',\n            tooltip: me.firstText,\n            overflowText: me.firstText,\n            iconCls: Ext.baseCSSPrefix + 'tbar-page-first',\n            disabled: true,\n            handler: me.moveFirst,\n            scope: me\n        },{\n            itemId: 'prev',\n            tooltip: me.prevText,\n            overflowText: me.prevText,\n            iconCls: Ext.baseCSSPrefix + 'tbar-page-prev',\n            disabled: true,\n            handler: me.movePrevious,\n            scope: me\n        },\n        '-',\n        me.beforePageText,\n        {\n            xtype: 'numberfield',\n            itemId: 'inputItem',\n            name: 'inputItem',\n            cls: Ext.baseCSSPrefix + 'tbar-page-number',\n            allowDecimals: false,\n            minValue: 1,\n            hideTrigger: true,\n            enableKeyEvents: true,\n            keyNavEnabled: false,\n            selectOnFocus: true,\n            submitValue: false,\n            // mark it as not a field so the form will not catch it when getting fields\n            isFormField: false,\n            width: me.inputItemWidth,\n            margins: '-1 2 3 2',\n            listeners: {\n                scope: me,\n                keydown: me.onPagingKeyDown,\n                blur: me.onPagingBlur\n            }\n        },{\n            xtype: 'tbtext',\n            itemId: 'afterTextItem',\n            text: Ext.String.format(me.afterPageText, 1)\n        },\n        '-',\n        {\n            itemId: 'next',\n            tooltip: me.nextText,\n            overflowText: me.nextText,\n            iconCls: Ext.baseCSSPrefix + 'tbar-page-next',\n            disabled: true,\n            handler: me.moveNext,\n            scope: me\n        },{\n            itemId: 'last',\n            tooltip: me.lastText,\n            overflowText: me.lastText,\n            iconCls: Ext.baseCSSPrefix + 'tbar-page-last',\n            disabled: true,\n            handler: me.moveLast,\n            scope: me\n        },\n        '-',\n        {\n            itemId: 'refresh',\n            tooltip: me.refreshText,\n            overflowText: me.refreshText,\n            iconCls: Ext.baseCSSPrefix + 'tbar-loading',\n            handler: me.doRefresh,\n            scope: me\n        }];\n    },\n\n    initComponent : function(){\n        var me = this,\n            pagingItems = me.getPagingItems(),\n            userItems   = me.items || me.buttons || [];\n\n        if (me.prependButtons) {\n            me.items = userItems.concat(pagingItems);\n        } else {\n            me.items = pagingItems.concat(userItems);\n        }\n        delete me.buttons;\n\n        if (me.displayInfo) {\n            me.items.push('->');\n            me.items.push({xtype: 'tbtext', itemId: 'displayItem'});\n        }\n\n        me.callParent();\n\n        me.addEvents(\n            /**\n             * @event change\n             * Fires after the active page has been changed.\n             * @param {Ext.toolbar.Paging} this\n             * @param {Object} pageData An object that has these properties:\n             *\n             * - `total` : Number\n             *\n             *   The total number of records in the dataset as returned by the server\n             *\n             * - `currentPage` : Number\n             *\n             *   The current page number\n             *\n             * - `pageCount` : Number\n             *\n             *   The total number of pages (calculated from the total number of records in the dataset as returned by the\n             *   server and the current {@link Ext.data.Store#pageSize pageSize})\n             *\n             * - `toRecord` : Number\n             *\n             *   The starting record index for the current page\n             *\n             * - `fromRecord` : Number\n             *\n             *   The ending record index for the current page\n             */\n            'change',\n\n            /**\n             * @event beforechange\n             * Fires just before the active page is changed. Return false to prevent the active page from being changed.\n             * @param {Ext.toolbar.Paging} this\n             * @param {Number} page The page number that will be loaded on change\n             */\n            'beforechange'\n        );\n        me.on('beforerender', me.onLoad, me, {single: true});\n\n        me.bindStore(me.store || 'ext-empty-store', true);\n    },\n    // private\n    updateInfo : function(){\n        var me = this,\n            displayItem = me.child('#displayItem'),\n            store = me.store,\n            pageData = me.getPageData(),\n            count, msg;\n\n        if (displayItem) {\n            count = store.getCount();\n            if (count === 0) {\n                msg = me.emptyMsg;\n            } else {\n                msg = Ext.String.format(\n                    me.displayMsg,\n                    pageData.fromRecord,\n                    pageData.toRecord,\n                    pageData.total\n                );\n            }\n            displayItem.setText(msg);\n        }\n    },\n\n    // private\n    onLoad : function(){\n        var me = this,\n            pageData,\n            currPage,\n            pageCount,\n            afterText,\n            count,\n            isEmpty;\n\n        count = me.store.getCount();\n        isEmpty = count === 0;\n        if (!isEmpty) {\n            pageData = me.getPageData();\n            currPage = pageData.currentPage;\n            pageCount = pageData.pageCount;\n            afterText = Ext.String.format(me.afterPageText, isNaN(pageCount) ? 1 : pageCount);\n        } else {\n            currPage = 0;\n            pageCount = 0;\n            afterText = Ext.String.format(me.afterPageText, 0);\n        }\n\n        Ext.suspendLayouts();\n        me.child('#afterTextItem').setText(afterText);\n        me.child('#inputItem').setDisabled(isEmpty).setValue(currPage);\n        me.child('#first').setDisabled(currPage === 1 || isEmpty);\n        me.child('#prev').setDisabled(currPage === 1  || isEmpty);\n        me.child('#next').setDisabled(currPage === pageCount  || isEmpty);\n        me.child('#last').setDisabled(currPage === pageCount  || isEmpty);\n        me.child('#refresh').enable();\n        me.updateInfo();\n        Ext.resumeLayouts(true);\n\n        if (me.rendered) {\n            me.fireEvent('change', me, pageData);\n        }\n    },\n\n    // private\n    getPageData : function(){\n        var store = this.store,\n            totalCount = store.getTotalCount();\n\n        return {\n            total : totalCount,\n            currentPage : store.currentPage,\n            pageCount: Math.ceil(totalCount / store.pageSize),\n            fromRecord: ((store.currentPage - 1) * store.pageSize) + 1,\n            toRecord: Math.min(store.currentPage * store.pageSize, totalCount)\n\n        };\n    },\n\n    // private\n    onLoadError : function(){\n        if (!this.rendered) {\n            return;\n        }\n        this.child('#refresh').enable();\n    },\n\n    // private\n    readPageFromInput : function(pageData){\n        var v = this.child('#inputItem').getValue(),\n            pageNum = parseInt(v, 10);\n\n        if (!v || isNaN(pageNum)) {\n            this.child('#inputItem').setValue(pageData.currentPage);\n            return false;\n        }\n        return pageNum;\n    },\n\n    onPagingFocus : function(){\n        this.child('#inputItem').select();\n    },\n\n    //private\n    onPagingBlur : function(e){\n        var curPage = this.getPageData().currentPage;\n        this.child('#inputItem').setValue(curPage);\n    },\n\n    // private\n    onPagingKeyDown : function(field, e){\n        var me = this,\n            k = e.getKey(),\n            pageData = me.getPageData(),\n            increment = e.shiftKey ? 10 : 1,\n            pageNum;\n\n        if (k == e.RETURN) {\n            e.stopEvent();\n            pageNum = me.readPageFromInput(pageData);\n            if (pageNum !== false) {\n                pageNum = Math.min(Math.max(1, pageNum), pageData.pageCount);\n                if(me.fireEvent('beforechange', me, pageNum) !== false){\n                    me.store.loadPage(pageNum);\n                }\n            }\n        } else if (k == e.HOME || k == e.END) {\n            e.stopEvent();\n            pageNum = k == e.HOME ? 1 : pageData.pageCount;\n            field.setValue(pageNum);\n        } else if (k == e.UP || k == e.PAGE_UP || k == e.DOWN || k == e.PAGE_DOWN) {\n            e.stopEvent();\n            pageNum = me.readPageFromInput(pageData);\n            if (pageNum) {\n                if (k == e.DOWN || k == e.PAGE_DOWN) {\n                    increment *= -1;\n                }\n                pageNum += increment;\n                if (pageNum >= 1 && pageNum <= pageData.pageCount) {\n                    field.setValue(pageNum);\n                }\n            }\n        }\n    },\n\n    // private\n    beforeLoad : function(){\n        if(this.rendered && this.refresh){\n            this.refresh.disable();\n        }\n    },\n\n    /**\n     * Move to the first page, has the same effect as clicking the 'first' button.\n     */\n    moveFirst : function(){\n        if (this.fireEvent('beforechange', this, 1) !== false){\n            this.store.loadPage(1);\n        }\n    },\n\n    /**\n     * Move to the previous page, has the same effect as clicking the 'previous' button.\n     */\n    movePrevious : function(){\n        var me = this,\n            prev = me.store.currentPage - 1;\n\n        if (prev > 0) {\n            if (me.fireEvent('beforechange', me, prev) !== false) {\n                me.store.previousPage();\n            }\n        }\n    },\n\n    /**\n     * Move to the next page, has the same effect as clicking the 'next' button.\n     */\n    moveNext : function(){\n        var me = this,\n            total = me.getPageData().pageCount,\n            next = me.store.currentPage + 1;\n\n        if (next <= total) {\n            if (me.fireEvent('beforechange', me, next) !== false) {\n                me.store.nextPage();\n            }\n        }\n    },\n\n    /**\n     * Move to the last page, has the same effect as clicking the 'last' button.\n     */\n    moveLast : function(){\n        var me = this,\n            last = me.getPageData().pageCount;\n\n        if (me.fireEvent('beforechange', me, last) !== false) {\n            me.store.loadPage(last);\n        }\n    },\n\n    /**\n     * Refresh the current page, has the same effect as clicking the 'refresh' button.\n     */\n    doRefresh : function(){\n        var me = this,\n            current = me.store.currentPage;\n\n        if (me.fireEvent('beforechange', me, current) !== false) {\n            me.store.loadPage(current);\n        }\n    },\n    \n    getStoreListeners: function() {\n        return {\n            beforeload: this.beforeLoad,\n            load: this.onLoad,\n            exception: this.onLoadError\n        };\n    },\n\n    /**\n     * Unbinds the paging toolbar from the specified {@link Ext.data.Store} **(deprecated)**\n     * @param {Ext.data.Store} store The data store to unbind\n     */\n    unbind : function(store){\n        this.bindStore(null);\n    },\n\n    /**\n     * Binds the paging toolbar to the specified {@link Ext.data.Store} **(deprecated)**\n     * @param {Ext.data.Store} store The data store to bind\n     */\n    bind : function(store){\n        this.bindStore(store);\n    },\n\n    // private\n    onDestroy : function(){\n        this.unbind();\n        this.callParent();\n    }\n});\n\n/**\n * An internally used DataView for {@link Ext.form.field.ComboBox ComboBox}.\n */\nExt.define('Ext.view.BoundList', {\n    extend: 'Ext.view.View',\n    alias: 'widget.boundlist',\n    alternateClassName: 'Ext.BoundList',\n    requires: ['Ext.layout.component.BoundList', 'Ext.toolbar.Paging'],\n\n    /**\n     * @cfg {Number} [pageSize=0]\n     * If greater than `0`, a {@link Ext.toolbar.Paging} is displayed at the bottom of the list and store\n     * queries will execute with page {@link Ext.data.Operation#start start} and\n     * {@link Ext.data.Operation#limit limit} parameters.\n     */\n    pageSize: 0,\n    \n    /**\n     * @cfg {String} [displayField=\"\"]\n     * The field from the store to show in the view.\n     */\n\n    /**\n     * @property {Ext.toolbar.Paging} pagingToolbar\n     * A reference to the PagingToolbar instance in this view. Only populated if {@link #pageSize} is greater\n     * than zero and the BoundList has been rendered.\n     */\n\n    // private overrides\n    baseCls: Ext.baseCSSPrefix + 'boundlist',\n    itemCls: Ext.baseCSSPrefix + 'boundlist-item',\n    listItemCls: '',\n    shadow: false,\n    trackOver: true,\n    refreshed: 0,\n    \n    // This Component is used as a popup, not part of a complex layout. Display data immediately.\n    deferInitialRefresh: false,\n\n    componentLayout: 'boundlist',\n\n    childEls: [\n        'listEl'\n    ],\n\n    renderTpl: [\n        '<div id=\"{id}-listEl\" class=\"{baseCls}-list-ct\" style=\"overflow:auto\"></div>',\n        '{%',\n            'var me=values.$comp, pagingToolbar=me.pagingToolbar;',\n            'if (pagingToolbar) {',\n                'pagingToolbar.ownerLayout = me.componentLayout;',\n                'Ext.DomHelper.generateMarkup(pagingToolbar.getRenderTree(), out);',\n            '}',\n        '%}',\n        {\n            disableFormats: true\n        }\n    ],\n\n    /**\n     * @cfg {String/Ext.XTemplate} tpl\n     * A String or Ext.XTemplate instance to apply to inner template.\n     *\n     * {@link Ext.view.BoundList} is used for the dropdown list of {@link Ext.form.field.ComboBox}.\n     * To customize the template you can do this:\n     *\n     *     Ext.create('Ext.form.field.ComboBox', {\n     *         fieldLabel   : 'State',\n     *         queryMode    : 'local',\n     *         displayField : 'text',\n     *         valueField   : 'abbr',\n     *         store        : Ext.create('StateStore', {\n     *             fields : ['abbr', 'text'],\n     *             data   : [\n     *                 {\"abbr\":\"AL\", \"name\":\"Alabama\"},\n     *                 {\"abbr\":\"AK\", \"name\":\"Alaska\"},\n     *                 {\"abbr\":\"AZ\", \"name\":\"Arizona\"}\n     *                 //...\n     *             ]\n     *         }),\n     *         listConfig : {\n     *             tpl : '<tpl for=\".\"><div class=\"x-boundlist-item\">{abbr}</div></tpl>'\n     *         }\n     *     });\n     *\n     * Defaults to:\n     *\n     *     Ext.create('Ext.XTemplate',\n     *         '<ul><tpl for=\".\">',\n     *             '<li role=\"option\" class=\"' + itemCls + '\">' + me.getInnerTpl(me.displayField) + '</li>',\n     *         '</tpl></ul>'\n     *     );\n     *\n     */\n\n    initComponent: function() {\n        var me = this,\n            baseCls = me.baseCls,\n            itemCls = me.itemCls;\n            \n        me.selectedItemCls = baseCls + '-selected';\n        me.overItemCls = baseCls + '-item-over';\n        me.itemSelector = \".\" + itemCls;\n\n        if (me.floating) {\n            me.addCls(baseCls + '-floating');\n        }\n\n        if (!me.tpl) {\n            // should be setting aria-posinset based on entire set of data\n            // not filtered set\n            me.tpl = new Ext.XTemplate(\n                '<ul><tpl for=\".\">',\n                    '<li role=\"option\" class=\"' + itemCls + '\">' + me.getInnerTpl(me.displayField) + '</li>',\n                '</tpl></ul>'\n            );\n        } else if (Ext.isString(me.tpl)) {\n            me.tpl = new Ext.XTemplate(me.tpl);\n        }\n\n        if (me.pageSize) {\n            me.pagingToolbar = me.createPagingToolbar();\n        }\n\n        me.callParent();\n    },\n\n    beforeRender: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        // If there's a Menu among our ancestors, then add the menu class.\n        // This is so that the MenuManager does not see a mousedown in this Component as a document mousedown, outside the Menu\n        if (me.up('menu')) {\n            me.addCls(Ext.baseCSSPrefix + 'menu');\n        }\n    },\n\n    /**\n     * @private\n     * Boundlist-specific implementation of the getBubbleTarget used by {@link Ext.AbstractComponent#up} method.\n     * This links to the owning input field so that the FocusManager, when receiving notification of a hide event,\n     * can find a focusable parent.\n     */\n    getBubbleTarget: function() {\n        return this.pickerField;\n    },\n\n    getRefItems: function() {\n        return this.pagingToolbar ? [ this.pagingToolbar ] : [];\n    },\n\n    createPagingToolbar: function() {\n        return Ext.widget('pagingtoolbar', {\n            id: this.id + '-paging-toolbar',\n            pageSize: this.pageSize,\n            store: this.store,\n            border: false,\n            ownerCt: this,\n            ownerLayout: this.getComponentLayout()\n        });\n    },\n\n    // Do the job of a container layout at this point even though we are not a Container.\n    // TODO: Refactor as a Container.\n    finishRenderChildren: function () {\n        var toolbar = this.pagingToolbar;\n\n        this.callParent(arguments);\n\n        if (toolbar) {\n            toolbar.finishRender();\n        }\n    },\n    \n    refresh: function(){\n        var me = this,\n            toolbar = me.pagingToolbar;\n        \n        me.callParent();\n        // The view removes the targetEl from the DOM before updating the template\n        // Ensure the toolbar goes to the end\n        if (me.rendered && toolbar && toolbar.rendered && !me.preserveScrollOnRefresh) {\n            me.el.appendChild(toolbar.el);\n        }  \n    },\n\n    bindStore : function(store, initial) {\n        var toolbar = this.pagingToolbar;\n            \n        this.callParent(arguments);\n        if (toolbar) {\n            toolbar.bindStore(this.store, initial);\n        }\n    },\n\n    getTargetEl: function() {\n        return this.listEl || this.el;\n    },\n\n    /**\n     * A method that returns the inner template for displaying items in the list.\n     * This method is useful to override when using a more complex display value, for example\n     * inserting an icon along with the text.\n     * @param {String} displayField The {@link #displayField} for the BoundList.\n     * @return {String} The inner template\n     */\n    getInnerTpl: function(displayField) {\n        return '{' + displayField + '}';\n    },\n\n    onDestroy: function() {\n        Ext.destroyMembers(this, 'pagingToolbar', 'listEl');\n        this.callParent();\n    }\n});\n\n/**\n * A specialized {@link Ext.util.KeyNav} implementation for navigating a {@link Ext.view.BoundList} using\n * the keyboard. The up, down, pageup, pagedown, home, and end keys move the active highlight\n * through the list. The enter key invokes the selection model's select action using the highlighted item.\n */\nExt.define('Ext.view.BoundListKeyNav', {\n    extend: 'Ext.util.KeyNav',\n    requires: 'Ext.view.BoundList',\n\n    /**\n     * @cfg {Ext.view.BoundList} boundList (required)\n     * The {@link Ext.view.BoundList} instance for which key navigation will be managed.\n     */\n\n    constructor: function(el, config) {\n        var me = this;\n        me.boundList = config.boundList;\n        me.callParent([el, Ext.apply({}, config, me.defaultHandlers)]);\n    },\n\n    defaultHandlers: {\n        up: function() {\n            var me = this,\n                boundList = me.boundList,\n                allItems = boundList.all,\n                oldItem = boundList.highlightedItem,\n                oldItemIdx = oldItem ? boundList.indexOf(oldItem) : -1,\n                newItemIdx = oldItemIdx > 0 ? oldItemIdx - 1 : allItems.getCount() - 1; //wraps around\n            me.highlightAt(newItemIdx);\n        },\n\n        down: function() {\n            var me = this,\n                boundList = me.boundList,\n                allItems = boundList.all,\n                oldItem = boundList.highlightedItem,\n                oldItemIdx = oldItem ? boundList.indexOf(oldItem) : -1,\n                newItemIdx = oldItemIdx < allItems.getCount() - 1 ? oldItemIdx + 1 : 0; //wraps around\n            me.highlightAt(newItemIdx);\n        },\n\n        pageup: function() {\n            //TODO\n        },\n\n        pagedown: function() {\n            //TODO\n        },\n\n        home: function() {\n            this.highlightAt(0);\n        },\n\n        end: function() {\n            var me = this;\n            me.highlightAt(me.boundList.all.getCount() - 1);\n        },\n\n        enter: function(e) {\n            this.selectHighlighted(e);\n        }\n    },\n\n    /**\n     * Highlights the item at the given index.\n     * @param {Number} index\n     */\n    highlightAt: function(index) {\n        var boundList = this.boundList,\n            item = boundList.all.item(index);\n        if (item) {\n            item = item.dom;\n            boundList.highlightItem(item);\n            boundList.getTargetEl().scrollChildIntoView(item, false);\n        }\n    },\n\n    /**\n     * Triggers selection of the currently highlighted item according to the behavior of\n     * the configured SelectionModel.\n     */\n    selectHighlighted: function(e) {\n        var me = this,\n            boundList = me.boundList,\n            highlighted = boundList.highlightedItem,\n            selModel = boundList.getSelectionModel();\n        if (highlighted) {\n            selModel.selectWithEvent(boundList.getRecord(highlighted), e);\n        }\n    }\n\n});\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * A combobox control with support for autocomplete, remote loading, and many other features.\n *\n * A ComboBox is like a combination of a traditional HTML text `<input>` field and a `<select>`\n * field; the user is able to type freely into the field, and/or pick values from a dropdown selection\n * list. The user can input any value by default, even if it does not appear in the selection list;\n * to prevent free-form values and restrict them to items in the list, set {@link #forceSelection} to `true`.\n *\n * The selection list's options are populated from any {@link Ext.data.Store}, including remote\n * stores. The data items in the store are mapped to each option's displayed text and backing value via\n * the {@link #valueField} and {@link #displayField} configurations, respectively.\n *\n * If your store is not remote, i.e. it depends only on local data and is loaded up front, you should be\n * sure to set the {@link #queryMode} to `'local'`, as this will improve responsiveness for the user.\n *\n * # Example usage:\n *\n *     @example\n *     // The data store containing the list of states\n *     var states = Ext.create('Ext.data.Store', {\n *         fields: ['abbr', 'name'],\n *         data : [\n *             {\"abbr\":\"AL\", \"name\":\"Alabama\"},\n *             {\"abbr\":\"AK\", \"name\":\"Alaska\"},\n *             {\"abbr\":\"AZ\", \"name\":\"Arizona\"}\n *             //...\n *         ]\n *     });\n *\n *     // Create the combo box, attached to the states data store\n *     Ext.create('Ext.form.ComboBox', {\n *         fieldLabel: 'Choose State',\n *         store: states,\n *         queryMode: 'local',\n *         displayField: 'name',\n *         valueField: 'abbr',\n *         renderTo: Ext.getBody()\n *     });\n *\n * # Events\n *\n * To do something when something in ComboBox is selected, configure the select event:\n *\n *     var cb = Ext.create('Ext.form.ComboBox', {\n *         // all of your config options\n *         listeners:{\n *              scope: yourScope,\n *              'select': yourFunction\n *         }\n *     });\n *\n *     // Alternatively, you can assign events after the object is created:\n *     var cb = new Ext.form.field.ComboBox(yourOptions);\n *     cb.on('select', yourFunction, yourScope);\n *\n * # Multiple Selection\n *\n * ComboBox also allows selection of multiple items from the list; to enable multi-selection set the\n * {@link #multiSelect} config to `true`.\n * \n * # Filtered Stores\n * \n * If you have a local store that is already filtered, you can use the {@link #lastQuery} config option\n * to prevent the store from having the filter being cleared on first expand.\n *\n * ## Customized combobox\n *\n * Both the text shown in dropdown menu and text field can be easily customized:\n *\n *     @example\n *     var states = Ext.create('Ext.data.Store', {\n *         fields: ['abbr', 'name'],\n *         data : [\n *             {\"abbr\":\"AL\", \"name\":\"Alabama\"},\n *             {\"abbr\":\"AK\", \"name\":\"Alaska\"},\n *             {\"abbr\":\"AZ\", \"name\":\"Arizona\"}\n *         ]\n *     });\n *\n *     Ext.create('Ext.form.ComboBox', {\n *         fieldLabel: 'Choose State',\n *         store: states,\n *         queryMode: 'local',\n *         valueField: 'abbr',\n *         renderTo: Ext.getBody(),\n *         // Template for the dropdown menu.\n *         // Note the use of \"x-boundlist-item\" class,\n *         // this is required to make the items selectable.\n *         tpl: Ext.create('Ext.XTemplate',\n *             '<tpl for=\".\">',\n *                 '<div class=\"x-boundlist-item\">{abbr} - {name}</div>',\n *             '</tpl>'\n *         ),\n *         // template for the content inside text field\n *         displayTpl: Ext.create('Ext.XTemplate',\n *             '<tpl for=\".\">',\n *                 '{abbr} - {name}',\n *             '</tpl>'\n *         )\n *     });\n *\n * See also the {@link #listConfig} option for additional configuration of the dropdown.\n *\n */\nExt.define('Ext.form.field.ComboBox', {\n    extend:'Ext.form.field.Picker',\n    requires: ['Ext.util.DelayedTask', 'Ext.EventObject', 'Ext.view.BoundList', 'Ext.view.BoundListKeyNav', 'Ext.data.StoreManager', 'Ext.layout.component.field.ComboBox'],\n    alternateClassName: 'Ext.form.ComboBox',\n    alias: ['widget.combobox', 'widget.combo'],\n    mixins: {\n        bindable: 'Ext.util.Bindable'    \n    },\n\n    componentLayout: 'combobox',\n\n    /**\n     * @cfg {String} [triggerCls='x-form-arrow-trigger']\n     * An additional CSS class used to style the trigger button. The trigger will always get the {@link #triggerBaseCls}\n     * by default and `triggerCls` will be **appended** if specified.\n     */\n    triggerCls: Ext.baseCSSPrefix + 'form-arrow-trigger',\n    \n    /**\n     * @cfg {String} [hiddenName=\"\"]\n     * The name of an underlying hidden field which will be synchronized with the underlying value of the combo.\n     * This option is useful if the combo is part of a form element doing a regular form post. The hidden field\n     * will not be created unless a hiddenName is specified.\n     */\n    hiddenName: '',\n    \n    /**\n     * @property {Ext.Element} hiddenDataEl\n     * @private\n     */\n\n    /**\n     * @private\n     * @cfg {String}\n     * CSS class used to find the {@link #hiddenDataEl}\n     */\n    hiddenDataCls: Ext.baseCSSPrefix + 'hide-display ' + Ext.baseCSSPrefix + 'form-data-hidden',\n\n    /**\n     * @cfg\n     * @inheritdoc\n     */\n    fieldSubTpl: [\n        '<div class=\"{hiddenDataCls}\" role=\"presentation\"></div>',\n        '<input id=\"{id}\" type=\"{type}\" {inputAttrTpl} class=\"{fieldCls} {typeCls}\" autocomplete=\"off\"',\n            '<tpl if=\"value\"> value=\"{[Ext.util.Format.htmlEncode(values.value)]}\"</tpl>',\n            '<tpl if=\"name\"> name=\"{name}\"</tpl>',\n            '<tpl if=\"placeholder\"> placeholder=\"{placeholder}\"</tpl>',\n            '<tpl if=\"size\"> size=\"{size}\"</tpl>',\n            '<tpl if=\"maxLength !== undefined\"> maxlength=\"{maxLength}\"</tpl>',\n            '<tpl if=\"readOnly\"> readonly=\"readonly\"</tpl>',\n            '<tpl if=\"disabled\"> disabled=\"disabled\"</tpl>',\n            '<tpl if=\"tabIdx\"> tabIndex=\"{tabIdx}\"</tpl>',\n            '<tpl if=\"fieldStyle\"> style=\"{fieldStyle}\"</tpl>',\n            '/>',\n        {\n            compiled: true,\n            disableFormats: true\n        }\n    ],\n\n    getSubTplData: function(){\n        var me = this;\n        Ext.applyIf(me.subTplData, {\n            hiddenDataCls: me.hiddenDataCls\n        });\n        return me.callParent(arguments);\n    },\n\n    afterRender: function(){\n        var me = this;\n        me.callParent(arguments);\n        me.setHiddenValue(me.value);\n    },\n\n    /**\n     * @cfg {Ext.data.Store/Array} store\n     * The data source to which this combo is bound. Acceptable values for this property are:\n     *\n     *   - **any {@link Ext.data.Store Store} subclass**\n     *   - **an Array** : Arrays will be converted to a {@link Ext.data.Store} internally, automatically generating\n     *     {@link Ext.data.Field#name field names} to work with all data components.\n     *\n     *     - **1-dimensional array** : (e.g., `['Foo','Bar']`)\n     *\n     *       A 1-dimensional array will automatically be expanded (each array item will be used for both the combo\n     *       {@link #valueField} and {@link #displayField})\n     *\n     *     - **2-dimensional array** : (e.g., `[['f','Foo'],['b','Bar']]`)\n     *\n     *       For a multi-dimensional array, the value in index 0 of each item will be assumed to be the combo\n     *       {@link #valueField}, while the value at index 1 is assumed to be the combo {@link #displayField}.\n     *\n     * See also {@link #queryMode}.\n     */\n\n    /**\n     * @cfg {Boolean} multiSelect\n     * If set to `true`, allows the combo field to hold more than one value at a time, and allows selecting multiple\n     * items from the dropdown list. The combo's text field will show all selected values separated by the\n     * {@link #delimiter}.\n     */\n    multiSelect: false,\n\n    //<locale>\n    /**\n     * @cfg {String} delimiter\n     * The character(s) used to separate the {@link #displayField display values} of multiple selected items when\n     * `{@link #multiSelect} = true`.\n     */\n    delimiter: ', ',\n    //</locale>\n\n    /**\n     * @cfg {String} displayField\n     * The underlying {@link Ext.data.Field#name data field name} to bind to this ComboBox.\n     *\n     * See also `{@link #valueField}`.\n     */\n    displayField: 'text',\n\n    /**\n     * @cfg {String} valueField (required)\n     * The underlying {@link Ext.data.Field#name data value name} to bind to this ComboBox.\n     *\n     * **Note**: use of a `valueField` requires the user to make a selection in order for a value to be mapped. See also\n     * `{@link #displayField}`.\n     *\n     * Defaults to match the value of the {@link #displayField} config.\n     */\n\n    /**\n     * @cfg {String} triggerAction\n     * The action to execute when the trigger is clicked.\n     *\n     *   - **`'all'`** :\n     *\n     *     {@link #doQuery run the query} specified by the `{@link #allQuery}` config option\n     *\n     *   - **`'query'`** :\n     *\n     *     {@link #doQuery run the query} using the {@link Ext.form.field.Base#getRawValue raw value}.\n     *\n     * See also `{@link #queryParam}`.\n     */\n    triggerAction: 'all',\n\n    /**\n     * @cfg {String} allQuery\n     * The text query to send to the server to return all records for the list with no filtering\n     */\n    allQuery: '',\n\n    /**\n     * @cfg {String} queryParam\n     * Name of the parameter used by the Store to pass the typed string when the ComboBox is configured with\n     * `{@link #queryMode}: 'remote'`. If explicitly set to a falsy value it will not be sent.\n     */\n    queryParam: 'query',\n\n    /**\n     * @cfg {String} queryMode\n     * The mode in which the ComboBox uses the configured Store. Acceptable values are:\n     *\n     *   - **`'remote'`** :\n     *\n     *     In `queryMode: 'remote'`, the ComboBox loads its Store dynamically based upon user interaction.\n     *\n     *     This is typically used for \"autocomplete\" type inputs, and after the user finishes typing, the Store is {@link\n     *     Ext.data.Store#method-load load}ed.\n     *\n     *     A parameter containing the typed string is sent in the load request. The default parameter name for the input\n     *     string is `query`, but this can be configured using the {@link #queryParam} config.\n     *\n     *     In `queryMode: 'remote'`, the Store may be configured with `{@link Ext.data.Store#remoteFilter remoteFilter}:\n     *     true`, and further filters may be _programatically_ added to the Store which are then passed with every load\n     *     request which allows the server to further refine the returned dataset.\n     *\n     *     Typically, in an autocomplete situation, {@link #hideTrigger} is configured `true` because it has no meaning for\n     *     autocomplete.\n     *\n     *   - **`'local'`** :\n     *\n     *     ComboBox loads local data\n     *\n     *         var combo = new Ext.form.field.ComboBox({\n     *             renderTo: document.body,\n     *             queryMode: 'local',\n     *             store: new Ext.data.ArrayStore({\n     *                 id: 0,\n     *                 fields: [\n     *                     'myId',  // numeric value is the key\n     *                     'displayText'\n     *                 ],\n     *                 data: [[1, 'item1'], [2, 'item2']]  // data is local\n     *             }),\n     *             valueField: 'myId',\n     *             displayField: 'displayText',\n     *             triggerAction: 'all'\n     *         });\n     */\n    queryMode: 'remote',\n\n    /**\n     * @cfg {Boolean} [queryCaching=true]\n     * When true, this prevents the combo from re-querying (either locally or remotely) when the current query\n     * is the same as the previous query.\n     */\n    queryCaching: true,\n\n    /**\n     * @cfg {Number} pageSize\n     * If greater than `0`, a {@link Ext.toolbar.Paging} is displayed in the footer of the dropdown list and the\n     * {@link #doQuery filter queries} will execute with page start and {@link Ext.view.BoundList#pageSize limit}\n     * parameters. Only applies when `{@link #queryMode} = 'remote'`.\n     */\n    pageSize: 0,\n\n    /**\n     * @cfg {Number} queryDelay\n     * The length of time in milliseconds to delay between the start of typing and sending the query to filter the\n     * dropdown list.\n     *\n     * Defaults to `500` if `{@link #queryMode} = 'remote'` or `10` if `{@link #queryMode} = 'local'`\n     */\n\n    /**\n     * @cfg {Number} minChars\n     * The minimum number of characters the user must type before autocomplete and {@link #typeAhead} activate.\n     *\n     * Defaults to `4` if `{@link #queryMode} = 'remote'` or `0` if `{@link #queryMode} = 'local'`,\n     * does not apply if `{@link Ext.form.field.Trigger#editable editable} = false`.\n     */\n\n    /**\n     * @cfg {Boolean} autoSelect\n     * `true` to automatically highlight the first result gathered by the data store in the dropdown list when it is\n     * opened. A false value would cause nothing in the list to be highlighted automatically, so\n     * the user would have to manually highlight an item before pressing the enter or {@link #selectOnTab tab} key to\n     * select it (unless the value of ({@link #typeAhead}) were true), or use the mouse to select a value.\n     */\n    autoSelect: true,\n\n    /**\n     * @cfg {Boolean} typeAhead\n     * `true` to populate and autoselect the remainder of the text being typed after a configurable delay\n     * ({@link #typeAheadDelay}) if it matches a known value.\n     */\n    typeAhead: false,\n\n    /**\n     * @cfg {Number} typeAheadDelay\n     * The length of time in milliseconds to wait until the typeahead text is displayed if `{@link #typeAhead} = true`\n     */\n    typeAheadDelay: 250,\n\n    /**\n     * @cfg {Boolean} selectOnTab\n     * Whether the Tab key should select the currently highlighted item.\n     */\n    selectOnTab: true,\n\n    /**\n     * @cfg {Boolean} forceSelection\n     * `true` to restrict the selected value to one of the values in the list, `false` to allow the user to set\n     * arbitrary text into the field.\n     */\n    forceSelection: false,\n\n    /**\n     * @cfg {Boolean} growToLongestValue\n     * `false` to not allow the component to resize itself when its data changes\n     * (and its {@link #grow} property is `true`)\n     */\n    growToLongestValue: true,\n\n    /**\n     * @cfg {String} valueNotFoundText\n     * When using a name/value combo, if the value passed to setValue is not found in the store, valueNotFoundText will\n     * be displayed as the field text if defined. If this default text is used, it means there\n     * is no value set and no validation will occur on this field.\n     */\n\n    /**\n     * @property {String} lastQuery\n     * The value of the match string used to filter the store. Delete this property to force a requery. Example use:\n     *\n     *     var combo = new Ext.form.field.ComboBox({\n     *         ...\n     *         queryMode: 'remote',\n     *         listeners: {\n     *             // delete the previous query in the beforequery event or set\n     *             // combo.lastQuery = null (this will reload the store the next time it expands)\n     *             beforequery: function(qe){\n     *                 delete qe.combo.lastQuery;\n     *             }\n     *         }\n     *     });\n     *\n     * To make sure the filter in the store is not cleared the first time the ComboBox trigger is used configure the\n     * combo with `lastQuery=''`. Example use:\n     *\n     *     var combo = new Ext.form.field.ComboBox({\n     *         ...\n     *         queryMode: 'local',\n     *         triggerAction: 'all',\n     *         lastQuery: ''\n     *     });\n     */\n\n    /**\n     * @cfg {Object} defaultListConfig\n     * Set of options that will be used as defaults for the user-configured {@link #listConfig} object.\n     */\n    defaultListConfig: {\n        loadingHeight: 70,\n        minWidth: 70,\n        maxHeight: 300,\n        shadow: 'sides'\n    },\n\n    /**\n     * @cfg {String/HTMLElement/Ext.Element} transform\n     * The id, DOM node or {@link Ext.Element} of an existing HTML `<select>` element to convert into a ComboBox. The\n     * target select's options will be used to build the options in the ComboBox dropdown; a configured {@link #store}\n     * will take precedence over this.\n     */\n\n    /**\n     * @cfg {Object} listConfig\n     * An optional set of configuration properties that will be passed to the {@link Ext.view.BoundList}'s constructor.\n     * Any configuration that is valid for BoundList can be included. Some of the more useful ones are:\n     *\n     *   - {@link Ext.view.BoundList#cls cls} - defaults to empty\n     *   - {@link Ext.view.BoundList#emptyText emptyText} - defaults to empty string\n     *   - {@link Ext.view.BoundList#itemSelector itemSelector} - defaults to the value defined in BoundList\n     *   - {@link Ext.view.BoundList#loadingText loadingText} - defaults to `'Loading...'`\n     *   - {@link Ext.view.BoundList#minWidth minWidth} - defaults to `70`\n     *   - {@link Ext.view.BoundList#maxWidth maxWidth} - defaults to `undefined`\n     *   - {@link Ext.view.BoundList#maxHeight maxHeight} - defaults to `300`\n     *   - {@link Ext.view.BoundList#resizable resizable} - defaults to `false`\n     *   - {@link Ext.view.BoundList#shadow shadow} - defaults to `'sides'`\n     *   - {@link Ext.view.BoundList#width width} - defaults to `undefined` (automatically set to the width of the ComboBox\n     *     field if {@link #matchFieldWidth} is true)\n     */\n\n    //private\n    ignoreSelection: 0,\n\n    //private, tells the layout to recalculate its startingWidth when a record is removed from its bound store\n    removingRecords: null,\n\n    //private helper\n    resizeComboToGrow: function () {\n        var me = this;\n        return me.grow && me.growToLongestValue;\n    },\n\n    initComponent: function() {\n        var me = this,\n            isDefined = Ext.isDefined,\n            store = me.store,\n            transform = me.transform,\n            transformSelect, isLocalMode;\n\n        Ext.applyIf(me.renderSelectors, {\n            hiddenDataEl: '.' + me.hiddenDataCls.split(' ').join('.')\n        });\n        \n        if (me.typeAhead && me.multiSelect) {\n            Ext.Error.raise('typeAhead and multiSelect are mutually exclusive options -- please remove one of them.');\n        }\n        if (me.typeAhead && !me.editable) {\n            Ext.Error.raise('If typeAhead is enabled the combo must be editable: true -- please change one of those settings.');\n        }\n        if (me.selectOnFocus && !me.editable) {\n            Ext.Error.raise('If selectOnFocus is enabled the combo must be editable: true -- please change one of those settings.');\n        }\n\n        this.addEvents(\n            /**\n             * @event beforequery\n             * Fires before all queries are processed. Return false to cancel the query or set the queryEvent's cancel\n             * property to true.\n             *\n             * @param {Object} queryEvent An object that has these properties:\n             *\n             *   - `combo` : Ext.form.field.ComboBox\n             *\n             *     This combo box\n             *\n             *   - `query` : String\n             *\n             *     The query string\n             *\n             *   - `forceAll` : Boolean\n             *\n             *     True to force \"all\" query\n             *\n             *   - `cancel` : Boolean\n             *\n             *     Set to true to cancel the query\n             */\n            'beforequery',\n\n            /**\n             * @event select\n             * Fires when at least one list item is selected.\n             * @param {Ext.form.field.ComboBox} combo This combo box\n             * @param {Array} records The selected records\n             */\n            'select',\n\n            /**\n             * @event beforeselect\n             * Fires before the selected item is added to the collection\n             * @param {Ext.form.field.ComboBox} combo This combo box\n             * @param {Ext.data.Record} record The selected record\n             * @param {Number} index The index of the selected record\n             */\n            'beforeselect',\n\n            /**\n             * @event beforedeselect\n             * Fires before the deselected item is removed from the collection\n             * @param {Ext.form.field.ComboBox} combo This combo box\n             * @param {Ext.data.Record} record The deselected record\n             * @param {Number} index The index of the deselected record\n             */\n            'beforedeselect'\n        );\n\n        // Build store from 'transform' HTML select element's options\n        if (transform) {\n            transformSelect = Ext.getDom(transform);\n            if (transformSelect) {\n                if (!me.store) {\n                    store = Ext.Array.map(Ext.Array.from(transformSelect.options), function(option){\n                        return [option.value, option.text];\n                    });\n                }\n                if (!me.name) {\n                    me.name = transformSelect.name;\n                }\n                if (!('value' in me)) {\n                    me.value = transformSelect.value;\n                }\n            }\n        }\n\n        me.bindStore(store || 'ext-empty-store', true);\n        store = me.store;\n        if (store.autoCreated) {\n            me.queryMode = 'local';\n            me.valueField = me.displayField = 'field1';\n            if (!store.expanded) {\n                me.displayField = 'field2';\n            }\n        }\n\n\n        if (!isDefined(me.valueField)) {\n            me.valueField = me.displayField;\n        }\n\n        isLocalMode = me.queryMode === 'local';\n        if (!isDefined(me.queryDelay)) {\n            me.queryDelay = isLocalMode ? 10 : 500;\n        }\n        if (!isDefined(me.minChars)) {\n            me.minChars = isLocalMode ? 0 : 4;\n        }\n\n        if (!me.displayTpl) {\n            me.displayTpl = new Ext.XTemplate(\n                '<tpl for=\".\">' +\n                    '{[typeof values === \"string\" ? values : values[\"' + me.displayField + '\"]]}' +\n                    '<tpl if=\"xindex < xcount\">' + me.delimiter + '</tpl>' +\n                '</tpl>'\n            );\n        } else if (Ext.isString(me.displayTpl)) {\n            me.displayTpl = new Ext.XTemplate(me.displayTpl);\n        }\n\n        me.callParent();\n\n        me.doQueryTask = new Ext.util.DelayedTask(me.doRawQuery, me);\n\n        // store has already been loaded, setValue\n        if (me.store.getCount() > 0) {\n            me.setValue(me.value);\n        }\n\n        // render in place of 'transform' select\n        if (transformSelect) {\n            me.render(transformSelect.parentNode, transformSelect);\n            Ext.removeNode(transformSelect);\n            delete me.renderTo;\n        }\n    },\n\n    /**\n     * Returns the store associated with this ComboBox.\n     * @return {Ext.data.Store} The store\n     */\n    getStore : function(){\n        return this.store;\n    },\n\n    beforeBlur: function() {\n        this.doQueryTask.cancel();\n        this.assertValue();\n    },\n\n    // private\n    assertValue: function() {\n        var me = this,\n            value = me.getRawValue(),\n            rec;\n\n        if (me.forceSelection) {\n            if (me.multiSelect) {\n                // For multiselect, check that the current displayed value matches the current\n                // selection, if it does not then revert to the most recent selection.\n                if (value !== me.getDisplayValue()) {\n                    me.setValue(me.lastSelection);\n                }\n            } else {\n                // For single-select, match the displayed value to a record and select it,\n                // if it does not match a record then revert to the most recent selection.\n                rec = me.findRecordByDisplay(value);\n                if (rec) {\n                    me.select(rec);\n                } else {\n                    me.setValue(me.lastSelection);\n                }\n            }\n        }\n        me.collapse();\n    },\n\n    onTypeAhead: function() {\n        var me = this,\n            displayField = me.displayField,\n            record = me.store.findRecord(displayField, me.getRawValue()),\n            boundList = me.getPicker(),\n            newValue, len, selStart;\n\n        if (record) {\n            newValue = record.get(displayField);\n            len = newValue.length;\n            selStart = me.getRawValue().length;\n\n            boundList.highlightItem(boundList.getNode(record));\n\n            if (selStart !== 0 && selStart !== len) {\n                me.setRawValue(newValue);\n                me.selectText(selStart, newValue.length);\n            }\n        }\n    },\n\n    // invoked when a different store is bound to this combo\n    // than the original\n    resetToDefault: Ext.emptyFn,\n    \n    beforeReset: function() {\n        this.callParent();\n        this.clearFilter();    \n    },\n    \n    onUnbindStore: function(store) {\n        var picker = this.picker;\n        if (!store && picker) {\n            picker.bindStore(null);\n        }\n        this.clearFilter();\n    },\n    \n    onBindStore: function(store, initial) {\n        var picker = this.picker;\n        if (!initial) {\n            this.resetToDefault();\n        }\n        if (picker) {\n            picker.bindStore(store);\n        }\n    },\n    \n    getStoreListeners: function() {\n        var me = this;\n        \n        return {\n            beforeload: me.onBeforeLoad,\n            clear: me.onClear,\n            datachanged: me.onDataChanged,\n            load: me.onLoad,\n            exception: me.onException,\n            remove: me.onRemove\n        }; \n    },\n    \n    onBeforeLoad: function(){\n        // If we're remote loading, the load mask will show which will trigger a deslectAll.\n        // This selection change will trigger the collapse in onListSelectionChange. As such\n        // we'll veto it for now and restore selection listeners when we've loaded.\n        ++this.ignoreSelection;    \n    },\n    \n    onDataChanged: function() {\n        var me = this;\n\n        if (me.resizeComboToGrow()) {\n            me.updateLayout();\n        }\n    },\n\n    onClear: function() {\n        var me = this;\n\n        if (me.resizeComboToGrow()) {\n            me.removingRecords = true;\n            me.onDataChanged();\n        }\n    },\n\n    onRemove: function() {\n        var me = this;\n\n        if (me.resizeComboToGrow()) {\n            me.removingRecords = true;\n        }\n    },\n\n    onException: function(){\n        if (this.ignoreSelection > 0) {\n            --this.ignoreSelection;\n        }\n        this.collapse();    \n    },\n\n    onLoad: function() {\n        var me = this,\n            value = me.value;\n\n        if (me.ignoreSelection > 0) {\n            --me.ignoreSelection;\n        }\n        // If performing a remote query upon the raw value...\n        if (me.rawQuery) {\n            me.rawQuery = false;\n            me.syncSelection();\n            if (me.picker && !me.picker.getSelectionModel().hasSelection()) {\n                me.doAutoSelect();\n            }\n        }\n        // If store initial load or triggerAction: 'all' trigger click.\n        else {\n            // Set the value on load\n            if (me.value || me.value === 0) {\n                me.setValue(me.value);\n            } else {\n                // There's no value.\n                // Highlight the first item in the list if autoSelect: true\n                if (me.store.getCount()) {\n                    me.doAutoSelect();\n                } else {\n                    // assign whatever empty value we have to prevent change from firing\n                    me.setValue(me.value);\n                }\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Execute the query with the raw contents within the textfield.\n     */\n    doRawQuery: function() {\n        this.doQuery(this.getRawValue(), false, true);\n    },\n\n    /**\n     * Executes a query to filter the dropdown list. Fires the {@link #beforequery} event prior to performing the query\n     * allowing the query action to be canceled if needed.\n     *\n     * @param {String} queryString The SQL query to execute\n     * @param {Boolean} [forceAll=false] `true` to force the query to execute even if there are currently fewer characters in\n     * the field than the minimum specified by the `{@link #minChars}` config option. It also clears any filter\n     * previously saved in the current store.\n     * @param {Boolean} [rawQuery=false] Pass as true if the raw typed value is being used as the query string. This causes the\n     * resulting store load to leave the raw value undisturbed.\n     * @return {Boolean} true if the query was permitted to run, false if it was cancelled by a {@link #beforequery}\n     * handler.\n     */\n    doQuery: function(queryString, forceAll, rawQuery) {\n        queryString = queryString || '';\n\n        // store in object and pass by reference in 'beforequery'\n        // so that client code can modify values.\n        var me = this,\n            qe = {\n                query: queryString,\n                forceAll: forceAll,\n                combo: me,\n                cancel: false\n            },\n            store = me.store,\n            isLocalMode = me.queryMode === 'local',\n            needsRefresh;\n\n        if (me.fireEvent('beforequery', qe) === false || qe.cancel) {\n            return false;\n        }\n\n        // get back out possibly modified values\n        queryString = qe.query;\n        forceAll = qe.forceAll;\n\n        // query permitted to run\n        if (forceAll || (queryString.length >= me.minChars)) {\n            // expand before starting query so LoadMask can position itself correctly\n            me.expand();\n\n            // make sure they aren't querying the same thing\n            if (!me.queryCaching || me.lastQuery !== queryString) {\n                me.lastQuery = queryString;\n\n                if (isLocalMode) {\n                    // forceAll means no filtering - show whole dataset.\n                    store.suspendEvents();\n                    needsRefresh = me.clearFilter();\n                    if (queryString || !forceAll) {\n                        me.activeFilter = new Ext.util.Filter({\n                            root: 'data',\n                            property: me.displayField,\n                            value: queryString\n                        });\n                        store.filter(me.activeFilter);\n                        needsRefresh = true;\n                    } else {\n                        delete me.activeFilter;\n                    }\n                    store.resumeEvents();\n                    if (me.rendered && needsRefresh) {\n                        me.getPicker().refresh();\n                    }\n                } else {\n                    // Set flag for onLoad handling to know how the Store was loaded\n                    me.rawQuery = rawQuery;\n\n                    // In queryMode: 'remote', we assume Store filters are added by the developer as remote filters,\n                    // and these are automatically passed as params with every load call, so we do *not* call clearFilter.\n                    if (me.pageSize) {\n                        // if we're paging, we've changed the query so start at page 1.\n                        me.loadPage(1);\n                    } else {\n                        store.load({\n                            params: me.getParams(queryString)\n                        });\n                    }\n                }\n            }\n\n            // Clear current selection if it does not match the current value in the field\n            if (me.getRawValue() !== me.getDisplayValue()) {\n                me.ignoreSelection++;\n                me.picker.getSelectionModel().deselectAll();\n                me.ignoreSelection--;\n            }\n\n            if (isLocalMode) {\n                me.doAutoSelect();\n            }\n            if (me.typeAhead) {\n                me.doTypeAhead();\n            }\n        }\n        return true;\n    },\n    \n    /**\n     * Clears any previous filters applied by the combo to the store\n     * @private\n     * @return {Boolean} True if a filter was removed\n     */\n    clearFilter: function() {\n        var store = this.store,\n            filter = this.activeFilter,\n            filters = store.filters,\n            remaining;\n            \n        if (filter) {\n            if (filters.getCount() > 1) {\n                // More than 1 existing filter\n                filters.remove(filter);\n                remaining = filters.getRange();\n            }\n            store.clearFilter(true);\n            if (remaining) {\n                store.filter(remaining);\n            }\n        }\n        return !!filter;\n    },\n\n    loadPage: function(pageNum){\n        this.store.loadPage(pageNum, {\n            params: this.getParams(this.lastQuery)\n        });\n    },\n\n    onPageChange: function(toolbar, newPage){\n        /*\n         * Return false here so we can call load ourselves and inject the query param.\n         * We don't want to do this for every store load since the developer may load\n         * the store through some other means so we won't add the query param.\n         */\n        this.loadPage(newPage);\n        return false;\n    },\n\n    // private\n    getParams: function(queryString) {\n        var params = {},\n            param = this.queryParam;\n\n        if (param) {\n            params[param] = queryString;\n        }\n        return params;\n    },\n\n    /**\n     * @private\n     * If the autoSelect config is true, and the picker is open, highlights the first item.\n     */\n    doAutoSelect: function() {\n        var me = this,\n            picker = me.picker,\n            lastSelected, itemNode;\n        if (picker && me.autoSelect && me.store.getCount() > 0) {\n            // Highlight the last selected item and scroll it into view\n            lastSelected = picker.getSelectionModel().lastSelected;\n            itemNode = picker.getNode(lastSelected || 0);\n            if (itemNode) {\n                picker.highlightItem(itemNode);\n                picker.listEl.scrollChildIntoView(itemNode, false);\n            }\n        }\n    },\n\n    doTypeAhead: function() {\n        if (!this.typeAheadTask) {\n            this.typeAheadTask = new Ext.util.DelayedTask(this.onTypeAhead, this);\n        }\n        if (this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE) {\n            this.typeAheadTask.delay(this.typeAheadDelay);\n        }\n    },\n\n    onTriggerClick: function() {\n        var me = this;\n        if (!me.readOnly && !me.disabled) {\n            if (me.isExpanded) {\n                me.collapse();\n            } else {\n                me.onFocus({});\n                if (me.triggerAction === 'all') {\n                    me.doQuery(me.allQuery, true);\n                } else {\n                    me.doQuery(me.getRawValue(), false, true);\n                }\n            }\n            me.inputEl.focus();\n        }\n    },\n\n\n    // store the last key and doQuery if relevant\n    onKeyUp: function(e, t) {\n        var me = this,\n            key = e.getKey();\n\n        if (!me.readOnly && !me.disabled && me.editable) {\n            me.lastKey = key;\n            // we put this in a task so that we can cancel it if a user is\n            // in and out before the queryDelay elapses\n\n            // perform query w/ any normal key or backspace or delete\n            if (!e.isSpecialKey() || key == e.BACKSPACE || key == e.DELETE) {\n                me.doQueryTask.delay(me.queryDelay);\n            }\n        }\n\n        if (me.enableKeyEvents) {\n            me.callParent(arguments);\n        }\n    },\n\n    initEvents: function() {\n        var me = this;\n        me.callParent();\n\n        /*\n         * Setup keyboard handling. If enableKeyEvents is true, we already have\n         * a listener on the inputEl for keyup, so don't create a second.\n         */\n        if (!me.enableKeyEvents) {\n            me.mon(me.inputEl, 'keyup', me.onKeyUp, me);\n        }\n    },\n\n    onDestroy: function() {\n        this.bindStore(null);\n        this.callParent();\n    },\n\n    // The picker (the dropdown) must have its zIndex managed by the same ZIndexManager which is\n    // providing the zIndex of our Container.\n    onAdded: function() {\n        var me = this;\n        me.callParent(arguments);\n        if (me.picker) {\n            me.picker.ownerCt = me.up('[floating]');\n            me.picker.registerWithOwnerCt();\n        }\n    },\n\n    createPicker: function() {\n        var me = this,\n            picker,\n            pickerCfg = Ext.apply({\n                xtype: 'boundlist',\n                pickerField: me,\n                selModel: {\n                    mode: me.multiSelect ? 'SIMPLE' : 'SINGLE'\n                },\n                floating: true,\n                hidden: true,\n                store: me.store,\n                displayField: me.displayField,\n                focusOnToFront: false,\n                pageSize: me.pageSize,\n                tpl: me.tpl\n            }, me.listConfig, me.defaultListConfig);\n\n        picker = me.picker = Ext.widget(pickerCfg);\n        if (me.pageSize) {\n            picker.pagingToolbar.on('beforechange', me.onPageChange, me);\n        }\n\n        me.mon(picker, {\n            itemclick: me.onItemClick,\n            refresh: me.onListRefresh,\n            scope: me\n        });\n\n        me.mon(picker.getSelectionModel(), {\n            beforeselect: me.onBeforeSelect,\n            beforedeselect: me.onBeforeDeselect,\n            selectionchange: me.onListSelectionChange,\n            scope: me\n        });\n\n        return picker;\n    },\n\n    alignPicker: function(){\n        var me = this,\n            picker = me.getPicker(),\n            heightAbove = me.getPosition()[1] - Ext.getBody().getScroll().top,\n            heightBelow = Ext.Element.getViewHeight() - heightAbove - me.getHeight(),\n            space = Math.max(heightAbove, heightBelow);\n\n        // Allow the picker to height itself naturally.\n        if (picker.height) {\n            delete picker.height;\n            picker.updateLayout();\n        }\n        // Then ensure that vertically, the dropdown will fit into the space either above or below the inputEl.\n        if (picker.getHeight() > space - 5) {\n            picker.setHeight(space - 5); // have some leeway so we aren't flush against\n        }\n        me.callParent();\n    },\n\n    onListRefresh: function() {\n        this.alignPicker();\n        this.syncSelection();\n    },\n\n    onItemClick: function(picker, record){\n        /*\n         * If we're doing single selection, the selection change events won't fire when\n         * clicking on the selected element. Detect it here.\n         */\n        var me = this,\n            selection = me.picker.getSelectionModel().getSelection(),\n            valueField = me.valueField;\n\n        if (!me.multiSelect && selection.length) {\n            if (record.get(valueField) === selection[0].get(valueField)) {\n                // Make sure we also update the display value if it's only partial\n                me.displayTplData = [record.data];\n                me.setRawValue(me.getDisplayValue());\n                me.collapse();\n            }\n        }\n    },\n\n    onBeforeSelect: function(list, record) {\n        return this.fireEvent('beforeselect', this, record, record.index);\n    },\n\n    onBeforeDeselect: function(list, record) {\n        return this.fireEvent('beforedeselect', this, record, record.index);\n    },\n\n    onListSelectionChange: function(list, selectedRecords) {\n        var me = this,\n            isMulti = me.multiSelect,\n            hasRecords = selectedRecords.length > 0;\n        // Only react to selection if it is not called from setValue, and if our list is\n        // expanded (ignores changes to the selection model triggered elsewhere)\n        if (!me.ignoreSelection && me.isExpanded) {\n            if (!isMulti) {\n                Ext.defer(me.collapse, 1, me);\n            }\n            /*\n             * Only set the value here if we're in multi selection mode or we have\n             * a selection. Otherwise setValue will be called with an empty value\n             * which will cause the change event to fire twice.\n             */\n            if (isMulti || hasRecords) {\n                me.setValue(selectedRecords, false);\n            }\n            if (hasRecords) {\n                me.fireEvent('select', me, selectedRecords);\n            }\n            me.inputEl.focus();\n        }\n    },\n\n    /**\n     * @private\n     * Enables the key nav for the BoundList when it is expanded.\n     */\n    onExpand: function() {\n        var me = this,\n            keyNav = me.listKeyNav,\n            selectOnTab = me.selectOnTab,\n            picker = me.getPicker();\n\n        // Handle BoundList navigation from the input field. Insert a tab listener specially to enable selectOnTab.\n        if (keyNav) {\n            keyNav.enable();\n        } else {\n            keyNav = me.listKeyNav = new Ext.view.BoundListKeyNav(this.inputEl, {\n                boundList: picker,\n                forceKeyDown: true,\n                tab: function(e) {\n                    if (selectOnTab) {\n                        this.selectHighlighted(e);\n                        me.triggerBlur();\n                    }\n                    // Tab key event is allowed to propagate to field\n                    return true;\n                }\n            });\n        }\n\n        // While list is expanded, stop tab monitoring from Ext.form.field.Trigger so it doesn't short-circuit selectOnTab\n        if (selectOnTab) {\n            me.ignoreMonitorTab = true;\n        }\n\n        Ext.defer(keyNav.enable, 1, keyNav); //wait a bit so it doesn't react to the down arrow opening the picker\n        me.inputEl.focus();\n    },\n\n    /**\n     * @private\n     * Disables the key nav for the BoundList when it is collapsed.\n     */\n    onCollapse: function() {\n        var me = this,\n            keyNav = me.listKeyNav;\n        if (keyNav) {\n            keyNav.disable();\n            me.ignoreMonitorTab = false;\n        }\n    },\n\n    /**\n     * Selects an item by a {@link Ext.data.Model Model}, or by a key value.\n     * @param {Object} r\n     */\n    select: function(r) {\n        this.setValue(r, true);\n    },\n\n    /**\n     * Finds the record by searching for a specific field/value combination.\n     * @param {String} field The name of the field to test.\n     * @param {Object} value The value to match the field against.\n     * @return {Ext.data.Model} The matched record or false.\n     */\n    findRecord: function(field, value) {\n        var ds = this.store,\n            idx = ds.findExact(field, value);\n        return idx !== -1 ? ds.getAt(idx) : false;\n    },\n\n    /**\n     * Finds the record by searching values in the {@link #valueField}.\n     * @param {Object} value The value to match the field against.\n     * @return {Ext.data.Model} The matched record or false.\n     */\n    findRecordByValue: function(value) {\n        return this.findRecord(this.valueField, value);\n    },\n\n    /**\n     * Finds the record by searching values in the {@link #displayField}.\n     * @param {Object} value The value to match the field against.\n     * @return {Ext.data.Model} The matched record or false.\n     */\n    findRecordByDisplay: function(value) {\n        return this.findRecord(this.displayField, value);\n    },\n\n    /**\n     * Sets the specified value(s) into the field. For each value, if a record is found in the {@link #store} that\n     * matches based on the {@link #valueField}, then that record's {@link #displayField} will be displayed in the\n     * field. If no match is found, and the {@link #valueNotFoundText} config option is defined, then that will be\n     * displayed as the default field text. Otherwise a blank value will be shown, although the value will still be set.\n     * @param {String/String[]} value The value(s) to be set. Can be either a single String or {@link Ext.data.Model},\n     * or an Array of Strings or Models.\n     * @return {Ext.form.field.Field} this\n     */\n    setValue: function(value, doSelect) {\n        var me = this,\n            valueNotFoundText = me.valueNotFoundText,\n            inputEl = me.inputEl,\n            i, len, record,\n            dataObj,\n            matchedRecords = [],\n            displayTplData = [],\n            processedValue = [];\n\n        if (me.store.loading) {\n            // Called while the Store is loading. Ensure it is processed by the onLoad method.\n            me.value = value;\n            me.setHiddenValue(me.value);\n            return me;\n        }\n\n        // This method processes multi-values, so ensure value is an array.\n        value = Ext.Array.from(value);\n\n        // Loop through values, matching each from the Store, and collecting matched records\n        for (i = 0, len = value.length; i < len; i++) {\n            record = value[i];\n            if (!record || !record.isModel) {\n                record = me.findRecordByValue(record);\n            }\n            // record found, select it.\n            if (record) {\n                matchedRecords.push(record);\n                displayTplData.push(record.data);\n                processedValue.push(record.get(me.valueField));\n            }\n            // record was not found, this could happen because\n            // store is not loaded or they set a value not in the store\n            else {\n                // If we are allowing insertion of values not represented in the Store, then push the value and\n                // create a fake record data object to push as a display value for use by the displayTpl\n                if (!me.forceSelection) {\n                    processedValue.push(value[i]);\n                    dataObj = {};\n                    dataObj[me.displayField] = value[i];\n                    displayTplData.push(dataObj);\n                    // TODO: Add config to create new records on selection of a value that has no match in the Store\n                }\n                // Else, if valueNotFoundText is defined, display it, otherwise display nothing for this value\n                else if (Ext.isDefined(valueNotFoundText)) {\n                    displayTplData.push(valueNotFoundText);\n                }\n            }\n        }\n\n        // Set the value of this field. If we are multiselecting, then that is an array.\n        me.setHiddenValue(processedValue);\n        me.value = me.multiSelect ? processedValue : processedValue[0];\n        if (!Ext.isDefined(me.value)) {\n            me.value = null;\n        }\n        me.displayTplData = displayTplData; //store for getDisplayValue method\n        me.lastSelection = me.valueModels = matchedRecords;\n\n        if (inputEl && me.emptyText && !Ext.isEmpty(value)) {\n            inputEl.removeCls(me.emptyCls);\n        }\n\n        // Calculate raw value from the collection of Model data\n        me.setRawValue(me.getDisplayValue());\n        me.checkChange();\n\n        if (doSelect !== false) {\n            me.syncSelection();\n        }\n        me.applyEmptyText();\n\n        return me;\n    },\n\n    /**\n     * @private\n     * Set the value of {@link #hiddenDataEl}\n     * Dynamically adds and removes input[type=hidden] elements\n     */\n    setHiddenValue: function(values){\n        var me = this,\n            name = me.hiddenName, \n            i,\n            dom, childNodes, input, valueCount, childrenCount;\n            \n        if (!me.hiddenDataEl || !name) {\n            return;\n        }\n        values = Ext.Array.from(values);\n        dom = me.hiddenDataEl.dom;\n        childNodes = dom.childNodes;\n        input = childNodes[0];\n        valueCount = values.length;\n        childrenCount = childNodes.length;\n        \n        if (!input && valueCount > 0) {\n            me.hiddenDataEl.update(Ext.DomHelper.markup({\n                tag: 'input', \n                type: 'hidden', \n                name: name\n            }));\n            childrenCount = 1;\n            input = dom.firstChild;\n        }\n        while (childrenCount > valueCount) {\n            dom.removeChild(childNodes[0]);\n            -- childrenCount;\n        }\n        while (childrenCount < valueCount) {\n            dom.appendChild(input.cloneNode(true));\n            ++ childrenCount;\n        }\n        for (i = 0; i < valueCount; i++) {\n            childNodes[i].value = values[i];\n        }\n    },\n\n    /**\n     * @private Generates the string value to be displayed in the text field for the currently stored value\n     */\n    getDisplayValue: function() {\n        return this.displayTpl.apply(this.displayTplData);\n    },\n\n    getValue: function() {\n        // If the user has not changed the raw field value since a value was selected from the list,\n        // then return the structured value from the selection. If the raw field value is different\n        // than what would be displayed due to selection, return that raw value.\n        var me = this,\n            picker = me.picker,\n            rawValue = me.getRawValue(), //current value of text field\n            value = me.value; //stored value from last selection or setValue() call\n\n        if (me.getDisplayValue() !== rawValue) {\n            value = rawValue;\n            me.value = me.displayTplData = me.valueModels = null;\n            if (picker) {\n                me.ignoreSelection++;\n                picker.getSelectionModel().deselectAll();\n                me.ignoreSelection--;\n            }\n        }\n\n        return value;\n    },\n\n    getSubmitValue: function() {\n        return this.getValue();\n    },\n\n    isEqual: function(v1, v2) {\n        var fromArray = Ext.Array.from,\n            i, len;\n\n        v1 = fromArray(v1);\n        v2 = fromArray(v2);\n        len = v1.length;\n\n        if (len !== v2.length) {\n            return false;\n        }\n\n        for(i = 0; i < len; i++) {\n            if (v2[i] !== v1[i]) {\n                return false;\n            }\n        }\n\n        return true;\n    },\n\n    /**\n     * Clears any value currently set in the ComboBox.\n     */\n    clearValue: function() {\n        this.setValue([]);\n    },\n\n    /**\n     * @private Synchronizes the selection in the picker to match the current value of the combobox.\n     */\n    syncSelection: function() {\n        var me = this,\n            picker = me.picker,\n            selection, selModel,\n            values = me.valueModels || [],\n            vLen  = values.length, v, value;\n\n        if (picker) {\n            // From the value, find the Models that are in the store's current data\n            selection = [];\n            for (v = 0; v < vLen; v++) {\n                value = values[v];\n\n                if (value && value.isModel && me.store.indexOf(value) >= 0) {\n                    selection.push(value);\n                }\n            }\n\n            // Update the selection to match\n            me.ignoreSelection++;\n            selModel = picker.getSelectionModel();\n            selModel.deselectAll();\n            if (selection.length) {\n                selModel.select(selection);\n            }\n            me.ignoreSelection--;\n        }\n    },\n    \n    onEditorTab: function(e){\n        var keyNav = this.listKeyNav;\n        \n        if (this.selectOnTab && keyNav) {\n            keyNav.selectHighlighted(e);\n        }\n    }\n});\n\n/**\n * @private\n * A month picker component. This class is used by the {@link Ext.picker.Date Date picker} class\n * to allow browsing and selection of year/months combinations.\n */\nExt.define('Ext.picker.Month', {\n    extend: 'Ext.Component',\n    requires: [\n        'Ext.XTemplate', \n        'Ext.util.ClickRepeater', \n        'Ext.Date', \n        'Ext.button.Button'\n    ],\n    alias: 'widget.monthpicker',\n    alternateClassName: 'Ext.MonthPicker',\n\n    childEls: [\n        'bodyEl', 'prevEl', 'nextEl', 'buttonsEl', 'monthEl', 'yearEl'\n    ],\n\n    renderTpl: [\n        '<div id=\"{id}-bodyEl\" class=\"{baseCls}-body\">',\n          '<div id=\"{id}-monthEl\" class=\"{baseCls}-months\">',\n              '<tpl for=\"months\">',\n                  '<div class=\"{parent.baseCls}-item {parent.baseCls}-month\"><a style=\"{parent.monthStyle}\" href=\"#\" hidefocus=\"on\">{.}</a></div>',\n              '</tpl>',\n          '</div>',\n          '<div id=\"{id}-yearEl\" class=\"{baseCls}-years\">',\n              '<div class=\"{baseCls}-yearnav\">',\n                  '<button id=\"{id}-prevEl\" class=\"{baseCls}-yearnav-prev\"></button>',\n                  '<button id=\"{id}-nextEl\" class=\"{baseCls}-yearnav-next\"></button>',\n              '</div>',\n              '<tpl for=\"years\">',\n                  '<div class=\"{parent.baseCls}-item {parent.baseCls}-year\"><a href=\"#\" hidefocus=\"on\">{.}</a></div>',\n              '</tpl>',\n          '</div>',\n          '<div class=\"' + Ext.baseCSSPrefix + 'clear\"></div>',\n        '</div>',\n        '<tpl if=\"showButtons\">',\n            '<div id=\"{id}-buttonsEl\" class=\"{baseCls}-buttons\">{%',\n                'var me=values.$comp, okBtn=me.okBtn, cancelBtn=me.cancelBtn;',\n                'okBtn.ownerLayout = cancelBtn.ownerLayout = me.componentLayout;',\n                'okBtn.ownerCt = cancelBtn.ownerCt = me;',\n                'Ext.DomHelper.generateMarkup(okBtn.getRenderTree(), out);',\n                'Ext.DomHelper.generateMarkup(cancelBtn.getRenderTree(), out);',\n            '%}</div>',\n        '</tpl>'\n    ],\n\n    //<locale>\n    /**\n     * @cfg {String} okText The text to display on the ok button.\n     */\n    okText: 'OK',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} cancelText The text to display on the cancel button.\n     */\n    cancelText: 'Cancel',\n    //</locale>\n\n    /**\n     * @cfg {String} [baseCls='x-monthpicker']\n     *  The base CSS class to apply to the picker element.\n     */\n    baseCls: Ext.baseCSSPrefix + 'monthpicker',\n\n    /**\n     * @cfg {Boolean} showButtons True to show ok and cancel buttons below the picker.\n     */\n    showButtons: true,\n\n    /**\n     * @cfg {String} [selectedCls='x-monthpicker-selected'] The class to be added to selected items in the picker.\n     */\n\n    /**\n     * @cfg {Date/Number[]} value The default value to set. See {@link #setValue}\n     */\n    \n    \n    width: 178,\n    measureWidth: 35,\n    measureMaxHeight: 20,\n\n    // used when attached to date picker which isnt showing buttons\n    smallCls: Ext.baseCSSPrefix + 'monthpicker-small',\n\n    // private\n    totalYears: 10,\n    yearOffset: 5, // 10 years in total, 2 per row\n    monthOffset: 6, // 12 months, 2 per row\n\n    // private, inherit docs\n    initComponent: function(){\n        var me = this;\n\n        me.selectedCls = me.baseCls + '-selected';\n        me.addEvents(\n            /**\n             * @event cancelclick\n             * Fires when the cancel button is pressed.\n             * @param {Ext.picker.Month} this\n             */\n            'cancelclick',\n\n            /**\n             * @event monthclick\n             * Fires when a month is clicked.\n             * @param {Ext.picker.Month} this\n             * @param {Array} value The current value\n             */\n            'monthclick',\n\n            /**\n             * @event monthdblclick\n             * Fires when a month is clicked.\n             * @param {Ext.picker.Month} this\n             * @param {Array} value The current value\n             */\n            'monthdblclick',\n\n            /**\n             * @event okclick\n             * Fires when the ok button is pressed.\n             * @param {Ext.picker.Month} this\n             * @param {Array} value The current value\n             */\n            'okclick',\n\n            /**\n             * @event select\n             * Fires when a month/year is selected.\n             * @param {Ext.picker.Month} this\n             * @param {Array} value The current value\n             */\n            'select',\n\n            /**\n             * @event yearclick\n             * Fires when a year is clicked.\n             * @param {Ext.picker.Month} this\n             * @param {Array} value The current value\n             */\n            'yearclick',\n\n            /**\n             * @event yeardblclick\n             * Fires when a year is clicked.\n             * @param {Ext.picker.Month} this\n             * @param {Array} value The current value\n             */\n            'yeardblclick'\n        );\n        if (me.small) {\n            me.addCls(me.smallCls);\n        }\n        me.setValue(me.value);\n        me.activeYear = me.getYear(new Date().getFullYear() - 4, -4);\n\n        if (me.showButtons) {\n            me.okBtn = new Ext.button.Button({\n                text: me.okText,\n                handler: me.onOkClick,\n                scope: me\n            });\n            me.cancelBtn = new Ext.button.Button({\n                text: me.cancelText,\n                handler: me.onCancelClick,\n                scope: me\n            });\n        }\n\n        this.callParent();\n    },\n\n    // private, inherit docs\n    beforeRender: function(){\n        var me = this,\n            i = 0,\n            months = [],\n            shortName = Ext.Date.getShortMonthName,\n            monthLen = me.monthOffset,\n            margin = me.monthMargin,\n            style = '';\n\n        me.callParent();\n\n        for (; i < monthLen; ++i) {\n            months.push(shortName(i), shortName(i + monthLen));\n        }\n        \n        if (Ext.isDefined(margin)) {\n            style = 'margin: 0 ' + margin + 'px;';\n        }\n\n        Ext.apply(me.renderData, {\n            months: months,\n            years: me.getYears(),\n            showButtons: me.showButtons,\n            monthStyle: style\n        });\n    },\n\n    // private, inherit docs\n    afterRender: function(){\n        var me = this,\n            body = me.bodyEl,\n            buttonsEl = me.buttonsEl;\n\n        me.callParent();\n\n        me.mon(body, 'click', me.onBodyClick, me);\n        me.mon(body, 'dblclick', me.onBodyClick, me);\n\n        // keep a reference to the year/month elements since we'll be re-using them\n        me.years = body.select('.' + me.baseCls + '-year a');\n        me.months = body.select('.' + me.baseCls + '-month a');\n\n        me.backRepeater = new Ext.util.ClickRepeater(me.prevEl, {\n            handler: Ext.Function.bind(me.adjustYear, me, [-me.totalYears])\n        });\n\n        me.prevEl.addClsOnOver(me.baseCls + '-yearnav-prev-over');\n        me.nextRepeater = new Ext.util.ClickRepeater(me.nextEl, {\n            handler: Ext.Function.bind(me.adjustYear, me, [me.totalYears])\n        });\n        me.nextEl.addClsOnOver(me.baseCls + '-yearnav-next-over');\n        me.updateBody();\n        \n        if (!Ext.isDefined(me.monthMargin)) {\n            Ext.picker.Month.prototype.monthMargin = me.calculateMonthMargin();\n        }\n    },\n    \n    calculateMonthMargin: function(){\n        // We use this method for locales where the short month name\n        // may be longer than we see in English. For example in the \n        // zh_TW locale the month ends up spanning lines, so we loosen\n        // the margins to get some extra space\n        var me = this,\n            monthEl = me.monthEl,\n            months = me.months,\n            first = months.first(),\n            itemMargin = first.getMargin('l');\n            \n        while (itemMargin && me.getLargest() > me.measureMaxHeight) {\n            --itemMargin;\n            months.setStyle('margin', '0 ' + itemMargin + 'px');\n        }\n        return itemMargin;\n    },\n    \n    getLargest: function(months){\n        var largest = 0;\n        this.months.each(function(item){\n            var h = item.getHeight();\n            if (h > largest) {\n                largest = h;\n            }\n        });\n        return largest;\n        \n    },\n\n    /**\n     * Set the value for the picker.\n     * @param {Date/Number[]} value The value to set. It can be a Date object, where the month/year will be extracted, or\n     * it can be an array, with the month as the first index and the year as the second.\n     * @return {Ext.picker.Month} this\n     */\n    setValue: function(value){\n        var me = this,\n            active = me.activeYear,\n            offset = me.monthOffset,\n            year,\n            index;\n\n        if (!value) {\n            me.value = [null, null];\n        } else if (Ext.isDate(value)) {\n            me.value = [value.getMonth(), value.getFullYear()];\n        } else {\n            me.value = [value[0], value[1]];\n        }\n\n        if (me.rendered) {\n            year = me.value[1];\n            if (year !== null) {\n                if ((year < active || year > active + me.yearOffset)) {\n                    me.activeYear = year - me.yearOffset + 1;\n                }\n            }\n            me.updateBody();\n        }\n\n        return me;\n    },\n\n    /**\n     * Gets the selected value. It is returned as an array [month, year]. It may\n     * be a partial value, for example [null, 2010]. The month is returned as\n     * 0 based.\n     * @return {Number[]} The selected value\n     */\n    getValue: function(){\n        return this.value;\n    },\n\n    /**\n     * Checks whether the picker has a selection\n     * @return {Boolean} Returns true if both a month and year have been selected\n     */\n    hasSelection: function(){\n        var value = this.value;\n        return value[0] !== null && value[1] !== null;\n    },\n\n    /**\n     * Get an array of years to be pushed in the template. It is not in strict\n     * numerical order because we want to show them in columns.\n     * @private\n     * @return {Number[]} An array of years\n     */\n    getYears: function(){\n        var me = this,\n            offset = me.yearOffset,\n            start = me.activeYear, // put the \"active\" year on the left\n            end = start + offset,\n            i = start,\n            years = [];\n\n        for (; i < end; ++i) {\n            years.push(i, i + offset);\n        }\n\n        return years;\n    },\n\n    /**\n     * Update the years in the body based on any change\n     * @private\n     */\n    updateBody: function(){\n        var me = this,\n            years = me.years,\n            months = me.months,\n            yearNumbers = me.getYears(),\n            cls = me.selectedCls,\n            value = me.getYear(null),\n            month = me.value[0],\n            monthOffset = me.monthOffset,\n            year,\n            yearItems, y, yLen, el;\n\n        if (me.rendered) {\n            years.removeCls(cls);\n            months.removeCls(cls);\n\n            yearItems = years.elements;\n            yLen      = yearItems.length;\n\n            for (y = 0; y < yLen; y++) {\n                el = Ext.fly(yearItems[y]);\n\n                year = yearNumbers[y];\n                el.dom.innerHTML = year;\n                if (year == value) {\n                    el.dom.className = cls;\n                }\n            }\n            if (month !== null) {\n                if (month < monthOffset) {\n                    month = month * 2;\n                } else {\n                    month = (month - monthOffset) * 2 + 1;\n                }\n                months.item(month).addCls(cls);\n            }\n        }\n    },\n\n    /**\n     * Gets the current year value, or the default.\n     * @private\n     * @param {Number} defaultValue The default value to use if the year is not defined.\n     * @param {Number} offset A number to offset the value by\n     * @return {Number} The year value\n     */\n    getYear: function(defaultValue, offset) {\n        var year = this.value[1];\n        offset = offset || 0;\n        return year === null ? defaultValue : year + offset;\n    },\n\n    /**\n     * React to clicks on the body\n     * @private\n     */\n    onBodyClick: function(e, t) {\n        var me = this,\n            isDouble = e.type == 'dblclick';\n\n        if (e.getTarget('.' + me.baseCls + '-month')) {\n            e.stopEvent();\n            me.onMonthClick(t, isDouble);\n        } else if (e.getTarget('.' + me.baseCls + '-year')) {\n            e.stopEvent();\n            me.onYearClick(t, isDouble);\n        }\n    },\n\n    /**\n     * Modify the year display by passing an offset.\n     * @param {Number} [offset=10] The offset to move by.\n     */\n    adjustYear: function(offset){\n        if (typeof offset != 'number') {\n            offset = this.totalYears;\n        }\n        this.activeYear += offset;\n        this.updateBody();\n    },\n\n    /**\n     * React to the ok button being pressed\n     * @private\n     */\n    onOkClick: function(){\n        this.fireEvent('okclick', this, this.value);\n    },\n\n    /**\n     * React to the cancel button being pressed\n     * @private\n     */\n    onCancelClick: function(){\n        this.fireEvent('cancelclick', this);\n    },\n\n    /**\n     * React to a month being clicked\n     * @private\n     * @param {HTMLElement} target The element that was clicked\n     * @param {Boolean} isDouble True if the event was a doubleclick\n     */\n    onMonthClick: function(target, isDouble){\n        var me = this;\n        me.value[0] = me.resolveOffset(me.months.indexOf(target), me.monthOffset);\n        me.updateBody();\n        me.fireEvent('month' + (isDouble ? 'dbl' : '') + 'click', me, me.value);\n        me.fireEvent('select', me, me.value);\n    },\n\n    /**\n     * React to a year being clicked\n     * @private\n     * @param {HTMLElement} target The element that was clicked\n     * @param {Boolean} isDouble True if the event was a doubleclick\n     */\n    onYearClick: function(target, isDouble){\n        var me = this;\n        me.value[1] = me.activeYear + me.resolveOffset(me.years.indexOf(target), me.yearOffset);\n        me.updateBody();\n        me.fireEvent('year' + (isDouble ? 'dbl' : '') + 'click', me, me.value);\n        me.fireEvent('select', me, me.value);\n\n    },\n\n    /**\n     * Returns an offsetted number based on the position in the collection. Since our collections aren't\n     * numerically ordered, this function helps to normalize those differences.\n     * @private\n     * @param {Object} index\n     * @param {Object} offset\n     * @return {Number} The correctly offsetted number\n     */\n    resolveOffset: function(index, offset){\n        if (index % 2 === 0) {\n            return (index / 2);\n        } else {\n            return offset + Math.floor(index / 2);\n        }\n    },\n\n    // private, inherit docs\n    beforeDestroy: function(){\n        var me = this;\n        me.years = me.months = null;\n        Ext.destroyMembers(me, 'backRepeater', 'nextRepeater', 'okBtn', 'cancelBtn');\n        me.callParent();\n    },\n\n    // Do the job of a container layout at this point even though we are not a Container.\n    // TODO: Refactor as a Container.\n    finishRenderChildren: function () {\n        var me = this;\n\n        this.callParent(arguments);\n\n        if (this.showButtons) {\n            me.okBtn.finishRender();\n            me.cancelBtn.finishRender();\n        }\n    },\n\n    onDestroy: function() {\n        Ext.destroyMembers(this, 'okBtn', 'cancelBtn');\n        this.callParent();\n    }\n    \n});\n\n/**\n * A date picker. This class is used by the Ext.form.field.Date field to allow browsing and selection of valid\n * dates in a popup next to the field, but may also be used with other components.\n *\n * Typically you will need to implement a handler function to be notified when the user chooses a date from the picker;\n * you can register the handler using the {@link #select} event, or by implementing the {@link #handler} method.\n *\n * By default the user will be allowed to pick any date; this can be changed by using the {@link #minDate},\n * {@link #maxDate}, {@link #disabledDays}, {@link #disabledDatesRE}, and/or {@link #disabledDates} configs.\n *\n * All the string values documented below may be overridden by including an Ext locale file in your page.\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Choose a future date:',\n *         width: 200,\n *         bodyPadding: 10,\n *         renderTo: Ext.getBody(),\n *         items: [{\n *             xtype: 'datepicker',\n *             minDate: new Date(),\n *             handler: function(picker, date) {\n *                 // do something with the selected date\n *             }\n *         }]\n *     });\n */\nExt.define('Ext.picker.Date', {\n    extend: 'Ext.Component',\n    requires: [\n        'Ext.XTemplate',\n        'Ext.button.Button',\n        'Ext.button.Split',\n        'Ext.util.ClickRepeater',\n        'Ext.util.KeyNav',\n        'Ext.EventObject',\n        'Ext.fx.Manager',\n        'Ext.picker.Month'\n    ],\n    alias: 'widget.datepicker',\n    alternateClassName: 'Ext.DatePicker',\n\n    childEls: [\n        'innerEl', 'eventEl', 'prevEl', 'nextEl', 'middleBtnEl', 'footerEl'\n    ],\n    \n    border: true,\n\n    renderTpl: [\n        '<div id=\"{id}-innerEl\" role=\"grid\">',\n            '<div role=\"presentation\" class=\"{baseCls}-header\">',\n                '<div class=\"{baseCls}-prev\"><a id=\"{id}-prevEl\" href=\"#\" role=\"button\" title=\"{prevText}\"></a></div>',\n                '<div class=\"{baseCls}-month\" id=\"{id}-middleBtnEl\">{%this.renderMonthBtn(values, out)%}</div>',\n                '<div class=\"{baseCls}-next\"><a id=\"{id}-nextEl\" href=\"#\" role=\"button\" title=\"{nextText}\"></a></div>',\n            '</div>',\n            '<table id=\"{id}-eventEl\" class=\"{baseCls}-inner\" cellspacing=\"0\" role=\"presentation\">',\n                '<thead role=\"presentation\"><tr role=\"presentation\">',\n                    '<tpl for=\"dayNames\">',\n                        '<th role=\"columnheader\" title=\"{.}\"><span>{.:this.firstInitial}</span></th>',\n                    '</tpl>',\n                '</tr></thead>',\n                '<tbody role=\"presentation\"><tr role=\"presentation\">',\n                    '<tpl for=\"days\">',\n                        '{#:this.isEndOfWeek}',\n                        '<td role=\"gridcell\" id=\"{[Ext.id()]}\">',\n                            '<a role=\"presentation\" href=\"#\" hidefocus=\"on\" class=\"{parent.baseCls}-date\" tabIndex=\"1\">',\n                                '<em role=\"presentation\"><span role=\"presentation\"></span></em>',\n                            '</a>',\n                        '</td>',\n                    '</tpl>',\n                '</tr></tbody>',\n            '</table>',\n            '<tpl if=\"showToday\">',\n                '<div id=\"{id}-footerEl\" role=\"presentation\" class=\"{baseCls}-footer\">{%this.renderTodayBtn(values, out)%}</div>',\n            '</tpl>',\n        '</div>',\n        {\n            firstInitial: function(value) {\n                return Ext.picker.Date.prototype.getDayInitial(value);\n            },\n            isEndOfWeek: function(value) {\n                // convert from 1 based index to 0 based\n                // by decrementing value once.\n                value--;\n                var end = value % 7 === 0 && value !== 0;\n                return end ? '</tr><tr role=\"row\">' : '';\n            },\n            renderTodayBtn: function(values, out) {\n                Ext.DomHelper.generateMarkup(values.$comp.todayBtn.getRenderTree(), out);\n            },\n            renderMonthBtn: function(values, out) {\n                Ext.DomHelper.generateMarkup(values.$comp.monthBtn.getRenderTree(), out);\n            }\n        }\n    ],\n\n    //<locale>\n    /**\n     * @cfg {String} todayText\n     * The text to display on the button that selects the current date\n     */\n    todayText : 'Today',\n    //</locale>\n    \n    //<locale>\n    /**\n     * @cfg {String} ariaTitle\n     * The text to display for the aria title\n     */\n    ariaTitle: 'Date Picker: {0}',\n    //</locale>\n    \n    //<locale>\n    /**\n     * @cfg {String} ariaTitleDateFormat\n     * The date format to display for the current value in the {@link #ariaTitle}\n     */\n    ariaTitleDateFormat: 'F d, Y',\n    //</locale>\n\n    /**\n     * @cfg {Function} handler\n     * Optional. A function that will handle the select event of this picker. The handler is passed the following\n     * parameters:\n     *\n     *   - `picker` : Ext.picker.Date\n     *\n     * This Date picker.\n     *\n     *   - `date` : Date\n     *\n     * The selected date.\n     */\n\n    /**\n     * @cfg {Object} scope\n     * The scope (`this` reference) in which the `{@link #handler}` function will be called.\n     *\n     * Defaults to this DatePicker instance.\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} todayTip\n     * A string used to format the message for displaying in a tooltip over the button that selects the current date.\n     * The `{0}` token in string is replaced by today's date.\n     */\n    todayTip : '{0} (Spacebar)',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} minText\n     * The error text to display if the minDate validation fails.\n     */\n    minText : 'This date is before the minimum date',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} maxText\n     * The error text to display if the maxDate validation fails.\n     */\n    maxText : 'This date is after the maximum date',\n    //</locale>\n\n    /**\n     * @cfg {String} format\n     * The default date format string which can be overriden for localization support. The format must be valid\n     * according to {@link Ext.Date#parse} (defaults to {@link Ext.Date#defaultFormat}).\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} disabledDaysText\n     * The tooltip to display when the date falls on a disabled day.\n     */\n    disabledDaysText : 'Disabled',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} disabledDatesText\n     * The tooltip text to display when the date falls on a disabled date.\n     */\n    disabledDatesText : 'Disabled',\n    //</locale>\n\n    /**\n     * @cfg {String[]} monthNames\n     * An array of textual month names which can be overriden for localization support (defaults to Ext.Date.monthNames)\n     */\n\n    /**\n     * @cfg {String[]} dayNames\n     * An array of textual day names which can be overriden for localization support (defaults to Ext.Date.dayNames)\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} nextText\n     * The next month navigation button tooltip\n     */\n    nextText : 'Next Month (Control+Right)',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} prevText\n     * The previous month navigation button tooltip\n     */\n    prevText : 'Previous Month (Control+Left)',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} monthYearText\n     * The header month selector tooltip\n     */\n    monthYearText : 'Choose a month (Control+Up/Down to move years)',\n    //</locale>\n    \n    //<locale>\n    /**\n     * @cfg {String} monthYearFormat\n     * The date format for the header month\n     */\n    monthYearFormat: 'F Y',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {Number} [startDay=undefined]\n     * Day index at which the week should begin, 0-based.\n     *\n     * Defaults to `0` (Sunday).\n     */\n    startDay : 0,\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {Boolean} showToday\n     * False to hide the footer area containing the Today button and disable the keyboard handler for spacebar that\n     * selects the current date.\n     */\n    showToday : true,\n    //</locale>\n\n    /**\n     * @cfg {Date} [minDate=null]\n     * Minimum allowable date (JavaScript date object)\n     */\n\n    /**\n     * @cfg {Date} [maxDate=null]\n     * Maximum allowable date (JavaScript date object)\n     */\n\n    /**\n     * @cfg {Number[]} [disabledDays=null]\n     * An array of days to disable, 0-based. For example, [0, 6] disables Sunday and Saturday.\n     */\n\n    /**\n     * @cfg {RegExp} [disabledDatesRE=null]\n     * JavaScript regular expression used to disable a pattern of dates. The {@link #disabledDates}\n     * config will generate this regex internally, but if you specify disabledDatesRE it will take precedence over the\n     * disabledDates value.\n     */\n\n    /**\n     * @cfg {String[]} disabledDates\n     * An array of 'dates' to disable, as strings. These strings will be used to build a dynamic regular expression so\n     * they are very powerful. Some examples:\n     *\n     *   - ['03/08/2003', '09/16/2003'] would disable those exact dates\n     *   - ['03/08', '09/16'] would disable those days for every year\n     *   - ['^03/08'] would only match the beginning (useful if you are using short years)\n     *   - ['03/../2006'] would disable every day in March 2006\n     *   - ['^03'] would disable every day in every March\n     *\n     * Note that the format of the dates included in the array should exactly match the {@link #format} config. In order\n     * to support regular expressions, if you are using a date format that has '.' in it, you will have to escape the\n     * dot when restricting dates. For example: ['03\\\\.08\\\\.03'].\n     */\n\n    /**\n     * @cfg {Boolean} disableAnim\n     * True to disable animations when showing the month picker.\n     */\n    disableAnim: false,\n\n    /**\n     * @cfg {String} [baseCls='x-datepicker']\n     * The base CSS class to apply to this components element.\n     */\n    baseCls: Ext.baseCSSPrefix + 'datepicker',\n\n    /**\n     * @cfg {String} [selectedCls='x-datepicker-selected']\n     * The class to apply to the selected cell.\n     */\n\n    /**\n     * @cfg {String} [disabledCellCls='x-datepicker-disabled']\n     * The class to apply to disabled cells.\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} longDayFormat\n     * The format for displaying a date in a longer format.\n     */\n    longDayFormat: 'F d, Y',\n    //</locale>\n\n    /**\n     * @cfg {Object} keyNavConfig\n     * Specifies optional custom key event handlers for the {@link Ext.util.KeyNav} attached to this date picker. Must\n     * conform to the config format recognized by the {@link Ext.util.KeyNav} constructor. Handlers specified in this\n     * object will replace default handlers of the same name.\n     */\n\n    /**\n     * @cfg {Boolean} focusOnShow\n     * True to automatically focus the picker on show.\n     */\n    focusOnShow: false,\n\n    // private\n    // Set by other components to stop the picker focus being updated when the value changes.\n    focusOnSelect: true,\n\n    width: 178,\n\n    // default value used to initialise each date in the DatePicker\n    // (note: 12 noon was chosen because it steers well clear of all DST timezone changes)\n    initHour: 12, // 24-hour format\n\n    numDays: 42,\n\n    // private, inherit docs\n    initComponent : function() {\n        var me = this,\n            clearTime = Ext.Date.clearTime;\n\n        me.selectedCls = me.baseCls + '-selected';\n        me.disabledCellCls = me.baseCls + '-disabled';\n        me.prevCls = me.baseCls + '-prevday';\n        me.activeCls = me.baseCls + '-active';\n        me.nextCls = me.baseCls + '-prevday';\n        me.todayCls = me.baseCls + '-today';\n        me.dayNames = me.dayNames.slice(me.startDay).concat(me.dayNames.slice(0, me.startDay));\n\n        me.listeners = Ext.apply(me.listeners||{}, {\n            mousewheel: {\n                element: 'eventEl',\n                fn: me.handleMouseWheel,\n                scope: me\n            },\n            click: {\n                element: 'eventEl',\n                fn: me.handleDateClick, \n                scope: me,\n                delegate: 'a.' + me.baseCls + '-date'\n            }\n        });\n        this.callParent();\n\n        me.value = me.value ?\n                 clearTime(me.value, true) : clearTime(new Date());\n\n        me.addEvents(\n            /**\n             * @event select\n             * Fires when a date is selected\n             * @param {Ext.picker.Date} this DatePicker\n             * @param {Date} date The selected date\n             */\n            'select'\n        );\n\n        me.initDisabledDays();\n    },\n\n    beforeRender: function () {\n        /*\n         * days array for looping through 6 full weeks (6 weeks * 7 days)\n         * Note that we explicitly force the size here so the template creates\n         * all the appropriate cells.\n         */\n        var me = this,\n            days = new Array(me.numDays),\n            today = Ext.Date.format(new Date(), me.format);\n\n        // If there's a Menu among our ancestors, then add the menu class.\n        // This is so that the MenuManager does not see a mousedown in this Component as a document mousedown, outside the Menu\n        if (me.up('menu')) {\n            me.addCls(Ext.baseCSSPrefix + 'menu');\n        }\n\n        me.monthBtn = new Ext.button.Split({\n            ownerCt: me,\n            ownerLayout: me.getComponentLayout(),\n            text: '',\n            tooltip: me.monthYearText,\n            listeners: {\n                click: me.showMonthPicker,\n                arrowclick: me.showMonthPicker,\n                scope: me\n            }\n        });\n\n        if (this.showToday) {\n            me.todayBtn = new Ext.button.Button({\n                ownerCt: me,\n                ownerLayout: me.getComponentLayout(),\n                text: Ext.String.format(me.todayText, today),\n                tooltip: Ext.String.format(me.todayTip, today),\n                tooltipType: 'title',\n                handler: me.selectToday,\n                scope: me\n            });\n        }\n\n        me.callParent();\n\n        Ext.applyIf(me, {\n            renderData: {}\n        });\n\n        Ext.apply(me.renderData, {\n            dayNames: me.dayNames,\n            showToday: me.showToday,\n            prevText: me.prevText,\n            nextText: me.nextText,\n            days: days\n        });\n    },\n\n    // Do the job of a container layout at this point even though we are not a Container.\n    // TODO: Refactor as a Container.\n    finishRenderChildren: function () {\n        var me = this;\n        \n        me.callParent();\n        me.monthBtn.finishRender();\n        if (me.showToday) {\n            me.todayBtn.finishRender();\n        }\n    },\n\n    // private, inherit docs\n    onRender : function(container, position){\n        var me = this;\n\n        me.callParent(arguments);\n        me.el.unselectable();\n        me.cells = me.eventEl.select('tbody td');\n        me.textNodes = me.eventEl.query('tbody td span');\n    },\n\n    // private, inherit docs\n    initEvents: function(){\n        var me = this,\n            eDate = Ext.Date,\n            day = eDate.DAY;\n\n        me.callParent();\n\n        me.prevRepeater = new Ext.util.ClickRepeater(me.prevEl, {\n            handler: me.showPrevMonth,\n            scope: me,\n            preventDefault: true,\n            stopDefault: true\n        });\n\n        me.nextRepeater = new Ext.util.ClickRepeater(me.nextEl, {\n            handler: me.showNextMonth,\n            scope: me,\n            preventDefault:true,\n            stopDefault:true\n        });\n\n        me.keyNav = new Ext.util.KeyNav(me.eventEl, Ext.apply({\n            scope: me,\n            left : function(e){\n                if(e.ctrlKey){\n                    me.showPrevMonth();\n                }else{\n                    me.update(eDate.add(me.activeDate, day, -1));\n                }\n            },\n\n            right : function(e){\n                if(e.ctrlKey){\n                    me.showNextMonth();\n                }else{\n                    me.update(eDate.add(me.activeDate, day, 1));\n                }\n            },\n\n            up : function(e){\n                if(e.ctrlKey){\n                    me.showNextYear();\n                }else{\n                    me.update(eDate.add(me.activeDate, day, -7));\n                }\n            },\n\n            down : function(e){\n                if(e.ctrlKey){\n                    me.showPrevYear();\n                }else{\n                    me.update(eDate.add(me.activeDate, day, 7));\n                }\n            },\n            pageUp : me.showNextMonth,\n            pageDown : me.showPrevMonth,\n            enter : function(e){\n                e.stopPropagation();\n                return true;\n            }\n        }, me.keyNavConfig));\n\n        if (me.showToday) {\n            me.todayKeyListener = me.eventEl.addKeyListener(Ext.EventObject.SPACE, me.selectToday,  me);\n        }\n        me.update(me.value);\n    },\n\n    /**\n     * Setup the disabled dates regex based on config options\n     * @private\n     */\n    initDisabledDays : function(){\n        var me = this,\n            dd = me.disabledDates,\n            re = '(?:',\n            len,\n            d, dLen, dI;\n\n        if(!me.disabledDatesRE && dd){\n                len = dd.length - 1;\n\n            dLen = dd.length;\n\n            for (d = 0; d < dLen; d++) {\n                dI = dd[d];\n\n                re += Ext.isDate(dI) ? '^' + Ext.String.escapeRegex(Ext.Date.dateFormat(dI, me.format)) + '$' : dI;\n                if (d != len) {\n                    re += '|';\n                }\n            }\n\n            me.disabledDatesRE = new RegExp(re + ')');\n        }\n    },\n\n    /**\n     * Replaces any existing disabled dates with new values and refreshes the DatePicker.\n     * @param {String[]/RegExp} disabledDates An array of date strings (see the {@link #disabledDates} config for\n     * details on supported values), or a JavaScript regular expression used to disable a pattern of dates.\n     * @return {Ext.picker.Date} this\n     */\n    setDisabledDates : function(dd){\n        var me = this;\n\n        if(Ext.isArray(dd)){\n            me.disabledDates = dd;\n            me.disabledDatesRE = null;\n        }else{\n            me.disabledDatesRE = dd;\n        }\n        me.initDisabledDays();\n        me.update(me.value, true);\n        return me;\n    },\n\n    /**\n     * Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DatePicker.\n     * @param {Number[]} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config for details\n     * on supported values.\n     * @return {Ext.picker.Date} this\n     */\n    setDisabledDays : function(dd){\n        this.disabledDays = dd;\n        return this.update(this.value, true);\n    },\n\n    /**\n     * Replaces any existing {@link #minDate} with the new value and refreshes the DatePicker.\n     * @param {Date} value The minimum date that can be selected\n     * @return {Ext.picker.Date} this\n     */\n    setMinDate : function(dt){\n        this.minDate = dt;\n        return this.update(this.value, true);\n    },\n\n    /**\n     * Replaces any existing {@link #maxDate} with the new value and refreshes the DatePicker.\n     * @param {Date} value The maximum date that can be selected\n     * @return {Ext.picker.Date} this\n     */\n    setMaxDate : function(dt){\n        this.maxDate = dt;\n        return this.update(this.value, true);\n    },\n\n    /**\n     * Sets the value of the date field\n     * @param {Date} value The date to set\n     * @return {Ext.picker.Date} this\n     */\n    setValue : function(value){\n        this.value = Ext.Date.clearTime(value, true);\n        return this.update(this.value);\n    },\n\n    /**\n     * Gets the current selected value of the date field\n     * @return {Date} The selected date\n     */\n    getValue : function(){\n        return this.value;\n    },\n\n    //<locale type=\"function\">\n    /**\n     * Gets a single character to represent the day of the week\n     * @return {String} The character\n     */\n    getDayInitial: function(value){\n        return value.substr(0,1);\n    },\n    //</locale>\n\n    // private\n    focus : function(){\n        this.update(this.activeDate);\n    },\n\n    // private, inherit docs\n    onEnable: function(){\n        this.callParent();\n        this.setDisabledStatus(false);\n        this.update(this.activeDate);\n\n    },\n\n    // private, inherit docs\n    onDisable : function(){\n        this.callParent();\n        this.setDisabledStatus(true);\n    },\n\n    /**\n     * Set the disabled state of various internal components\n     * @private\n     * @param {Boolean} disabled\n     */\n    setDisabledStatus : function(disabled){\n        var me = this;\n\n        me.keyNav.setDisabled(disabled);\n        me.prevRepeater.setDisabled(disabled);\n        me.nextRepeater.setDisabled(disabled);\n        if (me.showToday) {\n            me.todayKeyListener.setDisabled(disabled);\n            me.todayBtn.setDisabled(disabled);\n        }\n    },\n\n    /**\n     * Get the current active date.\n     * @private\n     * @return {Date} The active date\n     */\n    getActive: function(){\n        return this.activeDate || this.value;\n    },\n\n    /**\n     * Run any animation required to hide/show the month picker.\n     * @private\n     * @param {Boolean} isHide True if it's a hide operation\n     */\n    runAnimation: function(isHide){\n        var picker = this.monthPicker,\n            options = {\n                duration: 200,\n                callback: function(){\n                    if (isHide) {\n                        picker.hide();\n                    } else {\n                        picker.show();\n                    }\n                }\n            };\n\n        if (isHide) {\n            picker.el.slideOut('t', options);\n        } else {\n            picker.el.slideIn('t', options);\n        }\n    },\n\n    /**\n     * Hides the month picker, if it's visible.\n     * @param {Boolean} [animate] Indicates whether to animate this action. If the animate\n     * parameter is not specified, the behavior will use {@link #disableAnim} to determine\n     * whether to animate or not.\n     * @return {Ext.picker.Date} this\n     */\n    hideMonthPicker : function(animate){\n        var me = this,\n            picker = me.monthPicker;\n\n        if (picker) {\n            if (me.shouldAnimate(animate)) {\n                me.runAnimation(true);\n            } else {\n                picker.hide();\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Show the month picker\n     * @param {Boolean} [animate] Indicates whether to animate this action. If the animate\n     * parameter is not specified, the behavior will use {@link #disableAnim} to determine\n     * whether to animate or not.\n     * @return {Ext.picker.Date} this\n     */\n    showMonthPicker : function(animate){\n        var me = this,\n            picker;\n        \n        if (me.rendered && !me.disabled) {\n            picker = me.createMonthPicker();\n            picker.setValue(me.getActive());\n            picker.setSize(me.getSize());\n            picker.setPosition(-1, -1);\n            if (me.shouldAnimate(animate)) {\n                me.runAnimation(false);\n            } else {\n                picker.show();\n            }\n        }\n        return me;\n    },\n    \n    /**\n     * Checks whether a hide/show action should animate\n     * @private\n     * @param {Boolean} [animate] A possible animation value\n     * @return {Boolean} Whether to animate the action\n     */\n    shouldAnimate: function(animate){\n        return Ext.isDefined(animate) ? animate : !this.disableAnim;\n    },\n\n    /**\n     * Create the month picker instance\n     * @private\n     * @return {Ext.picker.Month} picker\n     */\n    createMonthPicker: function(){\n        var me = this,\n            picker = me.monthPicker;\n\n        if (!picker) {\n            me.monthPicker = picker = new Ext.picker.Month({\n                renderTo: me.el,\n                floating: true,\n                shadow: false,\n                small: me.showToday === false,\n                listeners: {\n                    scope: me,\n                    cancelclick: me.onCancelClick,\n                    okclick: me.onOkClick,\n                    yeardblclick: me.onOkClick,\n                    monthdblclick: me.onOkClick\n                }\n            });\n            if (!me.disableAnim) {\n                // hide the element if we're animating to prevent an initial flicker\n                picker.el.setStyle('display', 'none');\n            }\n            me.on('beforehide', Ext.Function.bind(me.hideMonthPicker, me, [false]));\n        }\n        return picker;\n    },\n\n    /**\n     * Respond to an ok click on the month picker\n     * @private\n     */\n    onOkClick: function(picker, value){\n        var me = this,\n            month = value[0],\n            year = value[1],\n            date = new Date(year, month, me.getActive().getDate());\n\n        if (date.getMonth() !== month) {\n            // 'fix' the JS rolling date conversion if needed\n            date = Ext.Date.getLastDateOfMonth(new Date(year, month, 1));\n        }\n        me.update(date);\n        me.hideMonthPicker();\n    },\n\n    /**\n     * Respond to a cancel click on the month picker\n     * @private\n     */\n    onCancelClick: function(){\n        // update the selected value, also triggers a focus\n        this.selectedUpdate(this.activeDate);\n        this.hideMonthPicker();\n    },\n\n    /**\n     * Show the previous month.\n     * @param {Object} e\n     * @return {Ext.picker.Date} this\n     */\n    showPrevMonth : function(e){\n        return this.update(Ext.Date.add(this.activeDate, Ext.Date.MONTH, -1));\n    },\n\n    /**\n     * Show the next month.\n     * @param {Object} e\n     * @return {Ext.picker.Date} this\n     */\n    showNextMonth : function(e){\n        return this.update(Ext.Date.add(this.activeDate, Ext.Date.MONTH, 1));\n    },\n\n    /**\n     * Show the previous year.\n     * @return {Ext.picker.Date} this\n     */\n    showPrevYear : function(){\n        this.update(Ext.Date.add(this.activeDate, Ext.Date.YEAR, -1));\n    },\n\n    /**\n     * Show the next year.\n     * @return {Ext.picker.Date} this\n     */\n    showNextYear : function(){\n        this.update(Ext.Date.add(this.activeDate, Ext.Date.YEAR, 1));\n    },\n\n    /**\n     * Respond to the mouse wheel event\n     * @private\n     * @param {Ext.EventObject} e\n     */\n    handleMouseWheel : function(e){\n        e.stopEvent();\n        if(!this.disabled){\n            var delta = e.getWheelDelta();\n            if(delta > 0){\n                this.showPrevMonth();\n            } else if(delta < 0){\n                this.showNextMonth();\n            }\n        }\n    },\n\n    /**\n     * Respond to a date being clicked in the picker\n     * @private\n     * @param {Ext.EventObject} e\n     * @param {HTMLElement} t\n     */\n    handleDateClick : function(e, t){\n        var me = this,\n            handler = me.handler;\n\n        e.stopEvent();\n        if(!me.disabled && t.dateValue && !Ext.fly(t.parentNode).hasCls(me.disabledCellCls)){\n            me.doCancelFocus = me.focusOnSelect === false;\n            me.setValue(new Date(t.dateValue));\n            delete me.doCancelFocus;\n            me.fireEvent('select', me, me.value);\n            if (handler) {\n                handler.call(me.scope || me, me, me.value);\n            }\n            // event handling is turned off on hide\n            // when we are using the picker in a field\n            // therefore onSelect comes AFTER the select\n            // event.\n            me.onSelect();\n        }\n    },\n\n    /**\n     * Perform any post-select actions\n     * @private\n     */\n    onSelect: function() {\n        if (this.hideOnSelect) {\n             this.hide();\n         }\n    },\n\n    /**\n     * Sets the current value to today.\n     * @return {Ext.picker.Date} this\n     */\n    selectToday : function(){\n        var me = this,\n            btn = me.todayBtn,\n            handler = me.handler;\n\n        if(btn && !btn.disabled){\n            me.setValue(Ext.Date.clearTime(new Date()));\n            me.fireEvent('select', me, me.value);\n            if (handler) {\n                handler.call(me.scope || me, me, me.value);\n            }\n            me.onSelect();\n        }\n        return me;\n    },\n\n    /**\n     * Update the selected cell\n     * @private\n     * @param {Date} date The new date\n     */\n    selectedUpdate: function(date){\n        var me        = this,\n            t         = date.getTime(),\n            cells     = me.cells,\n            cls       = me.selectedCls,\n            cellItems = cells.elements,\n            c,\n            cLen      = cellItems.length,\n            cell;\n\n        cells.removeCls(cls);\n\n        for (c = 0; c < cLen; c++) {\n            cell = Ext.fly(cellItems[c]);\n\n            if (cell.dom.firstChild.dateValue == t) {\n                me.fireEvent('highlightitem', me, cell);\n                cell.addCls(cls);\n\n                if(me.isVisible() && !me.doCancelFocus){\n                    Ext.fly(cell.dom.firstChild).focus(50);\n                }\n\n                break;\n            }\n        }\n    },\n\n    /**\n     * Update the contents of the picker for a new month\n     * @private\n     * @param {Date} date The new date\n     */\n    fullUpdate: function(date){\n        var me = this,\n            cells = me.cells.elements,\n            textNodes = me.textNodes,\n            disabledCls = me.disabledCellCls,\n            eDate = Ext.Date,\n            i = 0,\n            extraDays = 0,\n            visible = me.isVisible(),\n            sel = +eDate.clearTime(date, true),\n            today = +eDate.clearTime(new Date()),\n            min = me.minDate ? eDate.clearTime(me.minDate, true) : Number.NEGATIVE_INFINITY,\n            max = me.maxDate ? eDate.clearTime(me.maxDate, true) : Number.POSITIVE_INFINITY,\n            ddMatch = me.disabledDatesRE,\n            ddText = me.disabledDatesText,\n            ddays = me.disabledDays ? me.disabledDays.join('') : false,\n            ddaysText = me.disabledDaysText,\n            format = me.format,\n            days = eDate.getDaysInMonth(date),\n            firstOfMonth = eDate.getFirstDateOfMonth(date),\n            startingPos = firstOfMonth.getDay() - me.startDay,\n            previousMonth = eDate.add(date, eDate.MONTH, -1),\n            longDayFormat = me.longDayFormat,\n            prevStart,\n            current,\n            disableToday,\n            tempDate,\n            setCellClass,\n            html,\n            cls,\n            formatValue,\n            value;\n\n        if (startingPos < 0) {\n            startingPos += 7;\n        }\n\n        days += startingPos;\n        prevStart = eDate.getDaysInMonth(previousMonth) - startingPos;\n        current = new Date(previousMonth.getFullYear(), previousMonth.getMonth(), prevStart, me.initHour);\n\n        if (me.showToday) {\n            tempDate = eDate.clearTime(new Date());\n            disableToday = (tempDate < min || tempDate > max ||\n                (ddMatch && format && ddMatch.test(eDate.dateFormat(tempDate, format))) ||\n                (ddays && ddays.indexOf(tempDate.getDay()) != -1));\n\n            if (!me.disabled) {\n                me.todayBtn.setDisabled(disableToday);\n                me.todayKeyListener.setDisabled(disableToday);\n            }\n        }\n\n        setCellClass = function(cell){\n            value = +eDate.clearTime(current, true);\n            cell.title = eDate.format(current, longDayFormat);\n            // store dateValue number as an expando\n            cell.firstChild.dateValue = value;\n            if(value == today){\n                cell.className += ' ' + me.todayCls;\n                cell.title = me.todayText;\n            }\n            if(value == sel){\n                cell.className += ' ' + me.selectedCls;\n                me.fireEvent('highlightitem', me, cell);\n                if (visible && me.floating) {\n                    Ext.fly(cell.firstChild).focus(50);\n                }\n            }\n            // disabling\n            if(value < min) {\n                cell.className = disabledCls;\n                cell.title = me.minText;\n                return;\n            }\n            if(value > max) {\n                cell.className = disabledCls;\n                cell.title = me.maxText;\n                return;\n            }\n            if(ddays){\n                if(ddays.indexOf(current.getDay()) != -1){\n                    cell.title = ddaysText;\n                    cell.className = disabledCls;\n                }\n            }\n            if(ddMatch && format){\n                formatValue = eDate.dateFormat(current, format);\n                if(ddMatch.test(formatValue)){\n                    cell.title = ddText.replace('%0', formatValue);\n                    cell.className = disabledCls;\n                }\n            }\n        };\n\n        for(; i < me.numDays; ++i) {\n            if (i < startingPos) {\n                html = (++prevStart);\n                cls = me.prevCls;\n            } else if (i >= days) {\n                html = (++extraDays);\n                cls = me.nextCls;\n            } else {\n                html = i - startingPos + 1;\n                cls = me.activeCls;\n            }\n            textNodes[i].innerHTML = html;\n            cells[i].className = cls;\n            current.setDate(current.getDate() + 1);\n            setCellClass(cells[i]);\n        }\n\n        me.monthBtn.setText(Ext.Date.format(date, me.monthYearFormat));\n    },\n\n    /**\n     * Update the contents of the picker\n     * @private\n     * @param {Date} date The new date\n     * @param {Boolean} forceRefresh True to force a full refresh\n     */\n    update : function(date, forceRefresh){\n        var me = this,\n            active = me.activeDate;\n\n        if (me.rendered) {\n            me.activeDate = date;\n            if(!forceRefresh && active && me.el && active.getMonth() == date.getMonth() && active.getFullYear() == date.getFullYear()){\n                me.selectedUpdate(date, active);\n            } else {\n                me.fullUpdate(date, active);\n            }\n            me.innerEl.dom.title = Ext.String.format(me.ariaTitle, Ext.Date.format(me.activeDate, me.ariaTitleDateFormat));\n        }\n        return me;\n    },\n\n    // private, inherit docs\n    beforeDestroy : function() {\n        var me = this;\n\n        if (me.rendered) {\n            Ext.destroy(\n                me.todayKeyListener,\n                me.keyNav,\n                me.monthPicker,\n                me.monthBtn,\n                me.nextRepeater,\n                me.prevRepeater,\n                me.todayBtn\n            );\n            delete me.textNodes;\n            delete me.cells.elements;\n        }\n        me.callParent();\n    },\n\n    // private, inherit docs\n    onShow: function() {\n        this.callParent(arguments);\n        if (this.focusOnShow) {\n            this.focus();\n        }\n    }\n},\n\n// After dependencies have loaded:\nfunction() {\n    var proto = this.prototype,\n        date = Ext.Date;\n\n    proto.monthNames = date.monthNames;\n    proto.dayNames   = date.dayNames;\n    proto.format     = date.defaultFormat;\n});\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * Provides a date input field with a {@link Ext.picker.Date date picker} dropdown and automatic date\n * validation.\n *\n * This field recognizes and uses the JavaScript Date object as its main {@link #value} type. In addition,\n * it recognizes string values which are parsed according to the {@link #format} and/or {@link #altFormats}\n * configs. These may be reconfigured to use date formats appropriate for the user's locale.\n *\n * The field may be limited to a certain range of dates by using the {@link #minValue}, {@link #maxValue},\n * {@link #disabledDays}, and {@link #disabledDates} config parameters. These configurations will be used both\n * in the field's validation, and in the date picker dropdown by preventing invalid dates from being selected.\n *\n * # Example usage\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         renderTo: Ext.getBody(),\n *         width: 300,\n *         bodyPadding: 10,\n *         title: 'Dates',\n *         items: [{\n *             xtype: 'datefield',\n *             anchor: '100%',\n *             fieldLabel: 'From',\n *             name: 'from_date',\n *             maxValue: new Date()  // limited to the current date or prior\n *         }, {\n *             xtype: 'datefield',\n *             anchor: '100%',\n *             fieldLabel: 'To',\n *             name: 'to_date',\n *             value: new Date()  // defaults to today\n *         }]\n *     });\n *\n * # Date Formats Examples\n *\n * This example shows a couple of different date format parsing scenarios. Both use custom date format\n * configurations; the first one matches the configured `format` while the second matches the `altFormats`.\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         renderTo: Ext.getBody(),\n *         width: 300,\n *         bodyPadding: 10,\n *         title: 'Dates',\n *         items: [{\n *             xtype: 'datefield',\n *             anchor: '100%',\n *             fieldLabel: 'Date',\n *             name: 'date',\n *             // The value matches the format; will be parsed and displayed using that format.\n *             format: 'm d Y',\n *             value: '2 4 1978'\n *         }, {\n *             xtype: 'datefield',\n *             anchor: '100%',\n *             fieldLabel: 'Date',\n *             name: 'date',\n *             // The value does not match the format, but does match an altFormat; will be parsed\n *             // using the altFormat and displayed using the format.\n *             format: 'm d Y',\n *             altFormats: 'm,d,Y|m.d.Y',\n *             value: '2.4.1978'\n *         }]\n *     });\n */\nExt.define('Ext.form.field.Date', {\n    extend:'Ext.form.field.Picker',\n    alias: 'widget.datefield',\n    requires: ['Ext.picker.Date'],\n    alternateClassName: ['Ext.form.DateField', 'Ext.form.Date'],\n\n    //<locale>\n    /**\n     * @cfg {String} format\n     * The default date format string which can be overriden for localization support. The format must be valid\n     * according to {@link Ext.Date#parse}.\n     */\n    format : \"m/d/Y\",\n    //</locale>\n    //<locale>\n    /**\n     * @cfg {String} altFormats\n     * Multiple date formats separated by \"|\" to try when parsing a user input value and it does not match the defined\n     * format.\n     */\n    altFormats : \"m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|n-j|n/j\",\n    //</locale>\n    //<locale>\n    /**\n     * @cfg {String} disabledDaysText\n     * The tooltip to display when the date falls on a disabled day.\n     */\n    disabledDaysText : \"Disabled\",\n    //</locale>\n    //<locale>\n    /**\n     * @cfg {String} disabledDatesText\n     * The tooltip text to display when the date falls on a disabled date.\n     */\n    disabledDatesText : \"Disabled\",\n    //</locale>\n    //<locale>\n    /**\n     * @cfg {String} minText\n     * The error text to display when the date in the cell is before {@link #minValue}.\n     */\n    minText : \"The date in this field must be equal to or after {0}\",\n    //</locale>\n    //<locale>\n    /**\n     * @cfg {String} maxText\n     * The error text to display when the date in the cell is after {@link #maxValue}.\n     */\n    maxText : \"The date in this field must be equal to or before {0}\",\n    //</locale>\n    //<locale>\n    /**\n     * @cfg {String} invalidText\n     * The error text to display when the date in the field is invalid.\n     */\n    invalidText : \"{0} is not a valid date - it must be in the format {1}\",\n    //</locale>\n    /**\n     * @cfg {String} [triggerCls='x-form-date-trigger']\n     * An additional CSS class used to style the trigger button. The trigger will always get the class 'x-form-trigger'\n     * and triggerCls will be **appended** if specified (default class displays a calendar icon).\n     */\n    triggerCls : Ext.baseCSSPrefix + 'form-date-trigger',\n    /**\n     * @cfg {Boolean} showToday\n     * false to hide the footer area of the Date picker containing the Today button and disable the keyboard handler for\n     * spacebar that selects the current date.\n     */\n    showToday : true,\n    /**\n     * @cfg {Date/String} minValue\n     * The minimum allowed date. Can be either a Javascript date object or a string date in a valid format.\n     */\n    /**\n     * @cfg {Date/String} maxValue\n     * The maximum allowed date. Can be either a Javascript date object or a string date in a valid format.\n     */\n    /**\n     * @cfg {Number[]} disabledDays\n     * An array of days to disable, 0 based. Some examples:\n     *\n     *     // disable Sunday and Saturday:\n     *     disabledDays:  [0, 6]\n     *     // disable weekdays:\n     *     disabledDays: [1,2,3,4,5]\n     */\n    /**\n     * @cfg {String[]} disabledDates\n     * An array of \"dates\" to disable, as strings. These strings will be used to build a dynamic regular expression so\n     * they are very powerful. Some examples:\n     *\n     *     // disable these exact dates:\n     *     disabledDates: [\"03/08/2003\", \"09/16/2003\"]\n     *     // disable these days for every year:\n     *     disabledDates: [\"03/08\", \"09/16\"]\n     *     // only match the beginning (useful if you are using short years):\n     *     disabledDates: [\"^03/08\"]\n     *     // disable every day in March 2006:\n     *     disabledDates: [\"03/../2006\"]\n     *     // disable every day in every March:\n     *     disabledDates: [\"^03\"]\n     *\n     * Note that the format of the dates included in the array should exactly match the {@link #format} config. In order\n     * to support regular expressions, if you are using a {@link #format date format} that has \".\" in it, you will have\n     * to escape the dot when restricting dates. For example: `[\"03\\\\.08\\\\.03\"]`.\n     */\n\n    /**\n     * @cfg {String} submitFormat\n     * The date format string which will be submitted to the server. The format must be valid according to\n     * {@link Ext.Date#parse}.\n     *\n     * Defaults to {@link #format}.\n     */\n    \n    /**\n     * @cfg {Boolean} useStrict\n     * True to enforce strict date parsing to prevent the default Javascript \"date rollover\".\n     * Defaults to the useStrict parameter set on Ext.Date\n     * See {@link Ext.Date#parse}.\n     */\n    useStrict: undefined,\n\n    // in the absence of a time value, a default value of 12 noon will be used\n    // (note: 12 noon was chosen because it steers well clear of all DST timezone changes)\n    initTime: '12', // 24 hour format\n\n    initTimeFormat: 'H',\n\n    matchFieldWidth: false,\n    //<locale>\n    /**\n     * @cfg {Number} [startDay=undefined]\n     * Day index at which the week should begin, 0-based.\n     *\n     * Defaults to `0` (Sunday).\n     */\n    startDay: 0,\n    //</locale>\n\n    initComponent : function(){\n        var me = this,\n            isString = Ext.isString,\n            min, max;\n\n        min = me.minValue;\n        max = me.maxValue;\n        if(isString(min)){\n            me.minValue = me.parseDate(min);\n        }\n        if(isString(max)){\n            me.maxValue = me.parseDate(max);\n        }\n        me.disabledDatesRE = null;\n        me.initDisabledDays();\n\n        me.callParent();\n    },\n\n    initValue: function() {\n        var me = this,\n            value = me.value;\n\n        // If a String value was supplied, try to convert it to a proper Date\n        if (Ext.isString(value)) {\n            me.value = me.rawToValue(value);\n        }\n\n        me.callParent();\n    },\n\n    // private\n    initDisabledDays : function(){\n        if(this.disabledDates){\n            var dd   = this.disabledDates,\n                len  = dd.length - 1,\n                re   = \"(?:\",\n                d,\n                dLen = dd.length,\n                date;\n\n            for (d = 0; d < dLen; d++) {\n                date = dd[d];\n\n                re += Ext.isDate(date) ? '^' + Ext.String.escapeRegex(date.dateFormat(this.format)) + '$' : date;\n                if (d !== len) {\n                    re += '|';\n                }\n            }\n\n            this.disabledDatesRE = new RegExp(re + ')');\n        }\n    },\n\n    /**\n     * Replaces any existing disabled dates with new values and refreshes the Date picker.\n     * @param {String[]} disabledDates An array of date strings (see the {@link #disabledDates} config for details on\n     * supported values) used to disable a pattern of dates.\n     */\n    setDisabledDates : function(dd){\n        var me = this,\n            picker = me.picker;\n\n        me.disabledDates = dd;\n        me.initDisabledDays();\n        if (picker) {\n            picker.setDisabledDates(me.disabledDatesRE);\n        }\n    },\n\n    /**\n     * Replaces any existing disabled days (by index, 0-6) with new values and refreshes the Date picker.\n     * @param {Number[]} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config for details on\n     * supported values.\n     */\n    setDisabledDays : function(dd){\n        var picker = this.picker;\n\n        this.disabledDays = dd;\n        if (picker) {\n            picker.setDisabledDays(dd);\n        }\n    },\n\n    /**\n     * Replaces any existing {@link #minValue} with the new value and refreshes the Date picker.\n     * @param {Date} value The minimum date that can be selected\n     */\n    setMinValue : function(dt){\n        var me = this,\n            picker = me.picker,\n            minValue = (Ext.isString(dt) ? me.parseDate(dt) : dt);\n\n        me.minValue = minValue;\n        if (picker) {\n            picker.minText = Ext.String.format(me.minText, me.formatDate(me.minValue));\n            picker.setMinDate(minValue);\n        }\n    },\n\n    /**\n     * Replaces any existing {@link #maxValue} with the new value and refreshes the Date picker.\n     * @param {Date} value The maximum date that can be selected\n     */\n    setMaxValue : function(dt){\n        var me = this,\n            picker = me.picker,\n            maxValue = (Ext.isString(dt) ? me.parseDate(dt) : dt);\n\n        me.maxValue = maxValue;\n        if (picker) {\n            picker.maxText = Ext.String.format(me.maxText, me.formatDate(me.maxValue));\n            picker.setMaxDate(maxValue);\n        }\n    },\n\n    /**\n     * Runs all of Date's validations and returns an array of any errors. Note that this first runs Text's validations,\n     * so the returned array is an amalgamation of all field errors. The additional validation checks are testing that\n     * the date format is valid, that the chosen date is within the min and max date constraints set, that the date\n     * chosen is not in the disabledDates regex and that the day chosed is not one of the disabledDays.\n     * @param {Object} [value] The value to get errors for (defaults to the current field value)\n     * @return {String[]} All validation errors for this field\n     */\n    getErrors: function(value) {\n        var me = this,\n            format = Ext.String.format,\n            clearTime = Ext.Date.clearTime,\n            errors = me.callParent(arguments),\n            disabledDays = me.disabledDays,\n            disabledDatesRE = me.disabledDatesRE,\n            minValue = me.minValue,\n            maxValue = me.maxValue,\n            len = disabledDays ? disabledDays.length : 0,\n            i = 0,\n            svalue,\n            fvalue,\n            day,\n            time;\n\n        value = me.formatDate(value || me.processRawValue(me.getRawValue()));\n\n        if (value === null || value.length < 1) { // if it's blank and textfield didn't flag it then it's valid\n             return errors;\n        }\n\n        svalue = value;\n        value = me.parseDate(value);\n        if (!value) {\n            errors.push(format(me.invalidText, svalue, Ext.Date.unescapeFormat(me.format)));\n            return errors;\n        }\n\n        time = value.getTime();\n        if (minValue && time < clearTime(minValue).getTime()) {\n            errors.push(format(me.minText, me.formatDate(minValue)));\n        }\n\n        if (maxValue && time > clearTime(maxValue).getTime()) {\n            errors.push(format(me.maxText, me.formatDate(maxValue)));\n        }\n\n        if (disabledDays) {\n            day = value.getDay();\n\n            for(; i < len; i++) {\n                if (day === disabledDays[i]) {\n                    errors.push(me.disabledDaysText);\n                    break;\n                }\n            }\n        }\n\n        fvalue = me.formatDate(value);\n        if (disabledDatesRE && disabledDatesRE.test(fvalue)) {\n            errors.push(format(me.disabledDatesText, fvalue));\n        }\n\n        return errors;\n    },\n\n    rawToValue: function(rawValue) {\n        return this.parseDate(rawValue) || rawValue || null;\n    },\n\n    valueToRaw: function(value) {\n        return this.formatDate(this.parseDate(value));\n    },\n\n    /**\n     * @method setValue\n     * Sets the value of the date field. You can pass a date object or any string that can be parsed into a valid date,\n     * using {@link #format} as the date format, according to the same rules as {@link Ext.Date#parse} (the default\n     * format used is \"m/d/Y\").\n     *\n     * Usage:\n     *\n     *     //All of these calls set the same date value (May 4, 2006)\n     *\n     *     //Pass a date object:\n     *     var dt = new Date('5/4/2006');\n     *     dateField.setValue(dt);\n     *\n     *     //Pass a date string (default format):\n     *     dateField.setValue('05/04/2006');\n     *\n     *     //Pass a date string (custom format):\n     *     dateField.format = 'Y-m-d';\n     *     dateField.setValue('2006-05-04');\n     *\n     * @param {String/Date} date The date or valid date string\n     * @return {Ext.form.field.Date} this\n     */\n\n    /**\n     * Attempts to parse a given string value using a given {@link Ext.Date#parse date format}.\n     * @param {String} value The value to attempt to parse\n     * @param {String} format A valid date format (see {@link Ext.Date#parse})\n     * @return {Date} The parsed Date object, or null if the value could not be successfully parsed.\n     */\n    safeParse : function(value, format) {\n        var me = this,\n            utilDate = Ext.Date,\n            result = null,\n            strict = me.useStrict,\n            parsedDate;\n\n        if (utilDate.formatContainsHourInfo(format)) {\n            // if parse format contains hour information, no DST adjustment is necessary\n            result = utilDate.parse(value, format, strict);\n        } else {\n            // set time to 12 noon, then clear the time\n            parsedDate = utilDate.parse(value + ' ' + me.initTime, format + ' ' + me.initTimeFormat, strict);\n            if (parsedDate) {\n                result = utilDate.clearTime(parsedDate);\n            }\n        }\n        return result;\n    },\n\n    // @private\n    getSubmitValue: function() {\n        var format = this.submitFormat || this.format,\n            value = this.getValue();\n\n        return value ? Ext.Date.format(value, format) : '';\n    },\n\n    /**\n     * @private\n     */\n    parseDate : function(value) {\n        if(!value || Ext.isDate(value)){\n            return value;\n        }\n\n        var me = this,\n            val = me.safeParse(value, me.format),\n            altFormats = me.altFormats,\n            altFormatsArray = me.altFormatsArray,\n            i = 0,\n            len;\n\n        if (!val && altFormats) {\n            altFormatsArray = altFormatsArray || altFormats.split('|');\n            len = altFormatsArray.length;\n            for (; i < len && !val; ++i) {\n                val = me.safeParse(value, altFormatsArray[i]);\n            }\n        }\n        return val;\n    },\n\n    // private\n    formatDate : function(date){\n        return Ext.isDate(date) ? Ext.Date.dateFormat(date, this.format) : date;\n    },\n\n    createPicker: function() {\n        var me = this,\n            format = Ext.String.format;\n\n        return new Ext.picker.Date({\n            pickerField: me,\n            ownerCt: me.ownerCt,\n            renderTo: document.body,\n            floating: true,\n            hidden: true,\n            focusOnShow: true,\n            minDate: me.minValue,\n            maxDate: me.maxValue,\n            disabledDatesRE: me.disabledDatesRE,\n            disabledDatesText: me.disabledDatesText,\n            disabledDays: me.disabledDays,\n            disabledDaysText: me.disabledDaysText,\n            format: me.format,\n            showToday: me.showToday,\n            startDay: me.startDay,\n            minText: format(me.minText, me.formatDate(me.minValue)),\n            maxText: format(me.maxText, me.formatDate(me.maxValue)),\n            listeners: {\n                scope: me,\n                select: me.onSelect\n            },\n            keyNavConfig: {\n                esc: function() {\n                    me.collapse();\n                }\n            }\n        });\n    },\n\n    onSelect: function(m, d) {\n        var me = this;\n\n        me.setValue(d);\n        me.fireEvent('select', me, d);\n        me.collapse();\n    },\n\n    /**\n     * @private\n     * Sets the Date picker's value to match the current field value when expanding.\n     */\n    onExpand: function() {\n        var value = this.getValue();\n        this.picker.setValue(Ext.isDate(value) ? value : new Date());\n    },\n\n    /**\n     * @private\n     * Focuses the field when collapsing the Date picker.\n     */\n    onCollapse: function() {\n        this.focus(false, 60);\n    },\n\n    // private\n    beforeBlur : function(){\n        var me = this,\n            v = me.parseDate(me.getRawValue()),\n            focusTask = me.focusTask;\n\n        if (focusTask) {\n            focusTask.cancel();\n        }\n\n        if (v) {\n            me.setValue(v);\n        }\n    }\n\n    /**\n     * @cfg {Boolean} grow\n     * @private\n     */\n    /**\n     * @cfg {Number} growMin\n     * @private\n     */\n    /**\n     * @cfg {Number} growMax\n     * @private\n     */\n    /**\n     * @method autoSize\n     * @private\n     */\n});\n\n/**\n * @docauthor Jason Johnston <jason@sencha.com>\n *\n * A file upload field which has custom styling and allows control over the button text and other\n * features of {@link Ext.form.field.Text text fields} like {@link Ext.form.field.Text#emptyText empty text}.\n * It uses a hidden file input element behind the scenes to allow user selection of a file and to\n * perform the actual upload during {@link Ext.form.Basic#submit form submit}.\n *\n * Because there is no secure cross-browser way to programmatically set the value of a file input,\n * the standard Field `setValue` method is not implemented. The `{@link #getValue}` method will return\n * a value that is browser-dependent; some have just the file name, some have a full path, some use\n * a fake path.\n *\n * **IMPORTANT:** File uploads are not performed using normal 'Ajax' techniques; see the description for\n * {@link Ext.form.Basic#hasUpload} for details.\n *\n * # Example Usage\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Upload a Photo',\n *         width: 400,\n *         bodyPadding: 10,\n *         frame: true,\n *         renderTo: Ext.getBody(),\n *         items: [{\n *             xtype: 'filefield',\n *             name: 'photo',\n *             fieldLabel: 'Photo',\n *             labelWidth: 50,\n *             msgTarget: 'side',\n *             allowBlank: false,\n *             anchor: '100%',\n *             buttonText: 'Select Photo...'\n *         }],\n *\n *         buttons: [{\n *             text: 'Upload',\n *             handler: function() {\n *                 var form = this.up('form').getForm();\n *                 if(form.isValid()){\n *                     form.submit({\n *                         url: 'photo-upload.php',\n *                         waitMsg: 'Uploading your photo...',\n *                         success: function(fp, o) {\n *                             Ext.Msg.alert('Success', 'Your photo \"' + o.result.file + '\" has been uploaded.');\n *                         }\n *                     });\n *                 }\n *             }\n *         }]\n *     });\n */\nExt.define(\"Ext.form.field.File\", {\n    extend: 'Ext.form.field.Trigger',\n    alias: ['widget.filefield', 'widget.fileuploadfield'],\n    alternateClassName: ['Ext.form.FileUploadField', 'Ext.ux.form.FileUploadField', 'Ext.form.File'],\n    uses: ['Ext.button.Button', 'Ext.layout.component.field.Field'],\n\n    //<locale>\n    /**\n     * @cfg {String} buttonText\n     * The button text to display on the upload button. Note that if you supply a value for\n     * {@link #buttonConfig}, the buttonConfig.text value will be used instead if available.\n     */\n    buttonText: 'Browse...',\n    //</locale>\n\n    /**\n     * @cfg {Boolean} buttonOnly\n     * True to display the file upload field as a button with no visible text field. If true, all\n     * inherited Text members will still be available.\n     */\n    buttonOnly: false,\n\n    /**\n     * @cfg {Number} buttonMargin\n     * The number of pixels of space reserved between the button and the text field. Note that this only\n     * applies if {@link #buttonOnly} = false.\n     */\n    buttonMargin: 3,\n\n    /**\n     * @cfg {Object} buttonConfig\n     * A standard {@link Ext.button.Button} config object.\n     */\n\n    /**\n     * @event change\n     * Fires when the underlying file input field's value has changed from the user selecting a new file from the system\n     * file selection dialog.\n     * @param {Ext.ux.form.FileUploadField} this\n     * @param {String} value The file value returned by the underlying file input field\n     */\n\n    /**\n     * @property {Ext.Element} fileInputEl\n     * A reference to the invisible file input element created for this upload field. Only populated after this\n     * component is rendered.\n     */\n\n    /**\n     * @property {Ext.button.Button} button\n     * A reference to the trigger Button component created for this upload field. Only populated after this component is\n     * rendered.\n     */\n\n    /**\n     * @cfg {String} [fieldBodyCls='x-form-file-wrap']\n     * An extra CSS class to be applied to the body content element in addition to {@link #fieldBodyCls}.\n     */\n    fieldBodyCls: Ext.baseCSSPrefix + 'form-file-wrap',\n\n    /**\n     * @cfg {Boolean} readOnly\n     * Unlike with other form fields, the readOnly config defaults to true in File field.\n     */\n    readOnly: true,\n\n    /**\n     * Do not show hand pointer over text field since file choose dialog is only shown when clicking in the button\n     * @private\n     */\n    triggerNoEditCls: '',\n\n    // private\n    componentLayout: 'triggerfield',\n\n    // private. Extract the file element, button outer element, and button active element.\n    childEls: ['fileInputEl', 'buttonEl', 'buttonEl-btnEl', 'browseButtonWrap'],\n\n    // private\n    onRender: function() {\n        var me = this,\n            inputEl;\n\n        me.callParent(arguments);\n\n        inputEl = me.inputEl;\n        inputEl.dom.name = ''; //name goes on the fileInput, not the text input\n\n        me.fileInputEl.dom.name = me.getName();\n        me.fileInputEl.on({\n            scope: me,\n            change: me.onFileChange\n        });\n\n        if (me.buttonOnly) {\n            me.inputCell.setDisplayed(false);\n        }\n\n        // Ensure the trigger cell is sized correctly upon render\n        me.browseButtonWrap.dom.style.width = (me.browseButtonWrap.dom.lastChild.offsetWidth + me.buttonEl.getMargin('lr')) + 'px';\n        if (Ext.isIE) {\n            me.buttonEl.repaint();\n        }\n    },\n\n    /**\n     * Gets the markup to be inserted into the subTplMarkup.\n     */\n    getTriggerMarkup: function() {\n        var me = this,\n            result,\n            btn = Ext.widget('button', Ext.apply({\n                id: me.id + '-buttonEl',\n                ui: me.ui,\n                disabled: me.disabled,\n                text: me.buttonText,\n                cls: Ext.baseCSSPrefix + 'form-file-btn',\n                preventDefault: false,\n                style: me.buttonOnly ? '' : 'margin-left:' + me.buttonMargin + 'px'\n            }, me.buttonConfig)),\n            btnCfg = btn.getRenderTree(),\n            inputElCfg = {\n                id: me.id + '-fileInputEl',\n                cls: Ext.baseCSSPrefix + 'form-file-input',\n                tag: 'input',\n                type: 'file',\n                size: 1\n            };\n        if (me.disabled) {\n            inputElCfg.disabled = true;\n        }\n        btnCfg.cn = inputElCfg;\n        result = '<td id=\"' + me.id + '-browseButtonWrap\">' + Ext.DomHelper.markup(btnCfg) + '</td>';\n        btn.destroy();\n        return result;\n    },\n\n    /**\n     * @private\n     * Creates the file input element. It is inserted into the trigger button component, made\n     * invisible, and floated on top of the button's other content so that it will receive the\n     * button's clicks.\n     */\n    createFileInput : function() {\n        var me = this;\n        me.fileInputEl = me.buttonEl.createChild({\n            name: me.getName(),\n            id: me.id + '-fileInputEl',\n            cls: Ext.baseCSSPrefix + 'form-file-input',\n            tag: 'input',\n            type: 'file',\n            size: 1\n        });\n        me.fileInputEl.on({\n            scope: me,\n            change: me.onFileChange\n        });\n    },\n\n    /**\n     * @private Event handler fired when the user selects a file.\n     */\n    onFileChange: function() {\n        this.lastValue = null; // force change event to get fired even if the user selects a file with the same name\n        Ext.form.field.File.superclass.setValue.call(this, this.fileInputEl.dom.value);\n    },\n\n    /**\n     * Overridden to do nothing\n     * @method\n     */\n    setValue: Ext.emptyFn,\n\n    reset : function(){\n        var me = this;\n        if (me.rendered) {\n            me.fileInputEl.remove();\n            me.createFileInput();\n            me.inputEl.dom.value = '';\n        }\n        me.callParent();\n    },\n\n    onDisable: function(){\n        this.callParent();\n        this.disableItems();\n    },\n    \n    disableItems: function(){\n        var file = this.fileInputEl;\n        if (file) {\n            file.dom.disabled = true;\n        }\n        this['buttonEl-btnEl'].dom.disabled = true;\n    },\n\n    onEnable: function(){\n        var me = this;\n        me.callParent();\n        me.fileInputEl.dom.disabled = false;\n        this['buttonEl-btnEl'].dom.disabled = false;\n    },\n\n    isFileUpload: function() {\n        return true;\n    },\n\n    extractFileInput: function() {\n        var fileInput = this.fileInputEl.dom;\n        this.reset();\n        return fileInput;\n    },\n\n    onDestroy: function(){\n        Ext.destroyMembers(this, 'fileInputEl', 'buttonEl');\n        this.callParent();\n    }\n});\n\n/**\n * A basic hidden field for storing hidden values in forms that need to be passed in the form submit.\n *\n * This creates an actual input element with type=\"submit\" in the DOM. While its label is\n * {@link #hideLabel not rendered} by default, it is still a real component and may be sized according\n * to its owner container's layout.\n *\n * Because of this, in most cases it is more convenient and less problematic to simply\n * {@link Ext.form.action.Action#params pass hidden parameters} directly when\n * {@link Ext.form.Basic#submit submitting the form}.\n *\n * Example:\n *\n *     new Ext.form.Panel({\n *         title: 'My Form',\n *         items: [{\n *             xtype: 'textfield',\n *             fieldLabel: 'Text Field',\n *             name: 'text_field',\n *             value: 'value from text field'\n *         }, {\n *             xtype: 'hiddenfield',\n *             name: 'hidden_field_1',\n *             value: 'value from hidden field'\n *         }],\n *\n *         buttons: [{\n *             text: 'Submit',\n *             handler: function() {\n *                 this.up('form').getForm().submit({\n *                     params: {\n *                         hidden_field_2: 'value from submit call'\n *                     }\n *                 });\n *             }\n *         }]\n *     });\n *\n * Submitting the above form will result in three values sent to the server:\n *\n *     text_field=value+from+text+field&hidden;_field_1=value+from+hidden+field&hidden_field_2=value+from+submit+call\n *\n */\nExt.define('Ext.form.field.Hidden', {\n    extend:'Ext.form.field.Base',\n    alias: ['widget.hiddenfield', 'widget.hidden'],\n    alternateClassName: 'Ext.form.Hidden',\n\n    // private\n    inputType : 'hidden',\n    hideLabel: true,\n    \n    initComponent: function(){\n        this.formItemCls += '-hidden';\n        this.callParent();    \n    },\n    \n    /**\n     * @private\n     * Override. Treat undefined and null values as equal to an empty string value.\n     */\n    isEqual: function(value1, value2) {\n        return this.isEqualAsString(value1, value2);\n    },\n\n    // These are all private overrides\n    initEvents: Ext.emptyFn,\n    setSize : Ext.emptyFn,\n    setWidth : Ext.emptyFn,\n    setHeight : Ext.emptyFn,\n    setPosition : Ext.emptyFn,\n    setPagePosition : Ext.emptyFn,\n    markInvalid : Ext.emptyFn,\n    clearInvalid : Ext.emptyFn\n});\n\n/**\n * Layout class for {@link Ext.form.field.HtmlEditor} fields. Sizes the toolbar, textarea, and iframe elements.\n * @private\n */\nExt.define('Ext.layout.component.field.HtmlEditor', {\n    extend: 'Ext.layout.component.field.Field',\n    alias: ['layout.htmleditor'],\n\n    type: 'htmleditor',\n\n    // Flags to say that the item is autosizing itself.\n    toolbarSizePolicy: {\n        setsWidth: 0,\n        setsHeight: 0\n    },\n\n    beginLayout: function(ownerContext) {\n        this.callParent(arguments);\n\n        ownerContext.textAreaContext = ownerContext.getEl('textareaEl');\n        ownerContext.iframeContext   = ownerContext.getEl('iframeEl');\n        ownerContext.toolbarContext  = ownerContext.context.getCmp(this.owner.getToolbar());\n    },\n    \n    // It's not a container, can never add/remove dynamically\n    renderItems: Ext.emptyFn,\n\n    getItemSizePolicy: function (item) {\n        // we are only ever called by the toolbar\n        return this.toolbarSizePolicy;\n    },\n\n    getLayoutItems: function () {\n        var toolbar = this.owner.getToolbar();\n        // The toolbar may not exist if we're destroying\n        return toolbar ? [toolbar] : [];\n    },\n\n    getRenderTarget: function() {\n        return this.owner.bodyEl;\n    },\n\n    publishInnerHeight: function (ownerContext, height) {\n        var me = this,\n            innerHeight = height - me.measureLabelErrorHeight(ownerContext) -\n                          ownerContext.toolbarContext.getProp('height') -\n                          ownerContext.bodyCellContext.getPaddingInfo().height;\n\n        // If the Toolbar has not acheieved a height yet, we are not done laying out.\n        if (Ext.isNumber(innerHeight)) {\n            ownerContext.textAreaContext.setHeight(innerHeight);\n            ownerContext.iframeContext.setHeight(innerHeight);\n        } else {\n            me.done = false;\n        }\n    }\n});\n\n/**\n * Color picker provides a simple color palette for choosing colors. The picker can be rendered to any container. The\n * available default to a standard 40-color palette; this can be customized with the {@link #colors} config.\n *\n * Typically you will need to implement a handler function to be notified when the user chooses a color from the picker;\n * you can register the handler using the {@link #event-select} event, or by implementing the {@link #handler} method.\n *\n *     @example\n *     Ext.create('Ext.picker.Color', {\n *         value: '993300',  // initial selected color\n *         renderTo: Ext.getBody(),\n *         listeners: {\n *             select: function(picker, selColor) {\n *                 alert(selColor);\n *             }\n *         }\n *     });\n */\nExt.define('Ext.picker.Color', {\n    extend: 'Ext.Component',\n    requires: 'Ext.XTemplate',\n    alias: 'widget.colorpicker',\n    alternateClassName: 'Ext.ColorPalette',\n\n    /**\n     * @cfg {String} [componentCls='x-color-picker']\n     * The CSS class to apply to the containing element.\n     */\n    componentCls : Ext.baseCSSPrefix + 'color-picker',\n\n    /**\n     * @cfg {String} [selectedCls='x-color-picker-selected']\n     * The CSS class to apply to the selected element\n     */\n    selectedCls: Ext.baseCSSPrefix + 'color-picker-selected',\n\n    /**\n     * @cfg {String} value\n     * The initial color to highlight (should be a valid 6-digit color hex code without the # symbol). Note that the hex\n     * codes are case-sensitive.\n     */\n    value : null,\n\n    /**\n     * @cfg {String} clickEvent\n     * The DOM event that will cause a color to be selected. This can be any valid event name (dblclick, contextmenu).\n     */\n    clickEvent :'click',\n\n    /**\n     * @cfg {Boolean} allowReselect\n     * If set to true then reselecting a color that is already selected fires the {@link #event-select} event\n     */\n    allowReselect : false,\n\n    /**\n     * @property {String[]} colors\n     * An array of 6-digit color hex code strings (without the # symbol). This array can contain any number of colors,\n     * and each hex code should be unique. The width of the picker is controlled via CSS by adjusting the width property\n     * of the 'x-color-picker' class (or assigning a custom class), so you can balance the number of colors with the\n     * width setting until the box is symmetrical.\n     *\n     * You can override individual colors if needed:\n     *\n     *     var cp = new Ext.picker.Color();\n     *     cp.colors[0] = 'FF0000';  // change the first box to red\n     *\n     * Or you can provide a custom array of your own for complete control:\n     *\n     *     var cp = new Ext.picker.Color();\n     *     cp.colors = ['000000', '993300', '333300'];\n     */\n    colors : [\n        '000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333',\n        '800000', 'FF6600', '808000', '008000', '008080', '0000FF', '666699', '808080',\n        'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '969696',\n        'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0',\n        'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', '99CCFF', 'CC99FF', 'FFFFFF'\n    ],\n\n    /**\n     * @cfg {Function} handler\n     * A function that will handle the select event of this picker. The handler is passed the following parameters:\n     *\n     * - `picker` : ColorPicker\n     *\n     *   The {@link Ext.picker.Color picker}.\n     *\n     * - `color` : String\n     *\n     *   The 6-digit color hex code (without the # symbol).\n     */\n\n    /**\n     * @cfg {Object} scope\n     * The scope (`this` reference) in which the `{@link #handler}` function will be called.\n     *\n     * Defaults to this Color picker instance.\n     */\n\n    colorRe: /(?:^|\\s)color-(.{6})(?:\\s|$)/,\n    \n    renderTpl: [\n        '<tpl for=\"colors\">',\n            '<a href=\"#\" class=\"color-{.}\" hidefocus=\"on\">',\n                '<em><span style=\"background:#{.}\" unselectable=\"on\">&#160;</span></em>',\n            '</a>',\n        '</tpl>'\n    ],\n\n    // private\n    initComponent : function(){\n        var me = this;\n\n        me.callParent(arguments);\n        me.addEvents(\n            /**\n             * @event select\n             * Fires when a color is selected\n             * @param {Ext.picker.Color} this\n             * @param {String} color The 6-digit color hex code (without the # symbol)\n             */\n            'select'\n        );\n\n        if (me.handler) {\n            me.on('select', me.handler, me.scope, true);\n        }\n    },\n\n\n    // private\n    initRenderData : function(){\n        var me = this;\n        return Ext.apply(me.callParent(), {\n            itemCls: me.itemCls,\n            colors: me.colors\n        });\n    },\n\n    onRender : function(){\n        var me = this,\n            clickEvent = me.clickEvent;\n\n        me.callParent(arguments);\n\n        me.mon(me.el, clickEvent, me.handleClick, me, {delegate: 'a'});\n        // always stop following the anchors\n        if(clickEvent != 'click'){\n            me.mon(me.el, 'click', Ext.emptyFn, me, {delegate: 'a', stopEvent: true});\n        }\n    },\n\n    // private\n    afterRender : function(){\n        var me = this,\n            value;\n\n        me.callParent(arguments);\n        if (me.value) {\n            value = me.value;\n            me.value = null;\n            me.select(value, true);\n        }\n    },\n\n    // private\n    handleClick : function(event, target){\n        var me = this,\n            color;\n\n        event.stopEvent();\n        if (!me.disabled) {\n            color = target.className.match(me.colorRe)[1];\n            me.select(color.toUpperCase());\n        }\n    },\n\n    /**\n     * Selects the specified color in the picker (fires the {@link #event-select} event)\n     * @param {String} color A valid 6-digit color hex code (# will be stripped if included)\n     * @param {Boolean} [suppressEvent=false] True to stop the select event from firing.\n     */\n    select : function(color, suppressEvent){\n\n        var me = this,\n            selectedCls = me.selectedCls,\n            value = me.value,\n            el;\n\n        color = color.replace('#', '');\n        if (!me.rendered) {\n            me.value = color;\n            return;\n        }\n\n\n        if (color != value || me.allowReselect) {\n            el = me.el;\n\n            if (me.value) {\n                el.down('a.color-' + value).removeCls(selectedCls);\n            }\n            el.down('a.color-' + color).addCls(selectedCls);\n            me.value = color;\n            if (suppressEvent !== true) {\n                me.fireEvent('select', me, color);\n            }\n        }\n    },\n\n    /**\n     * Get the currently selected color value.\n     * @return {String} value The selected value. Null if nothing is selected.\n     */\n    getValue: function(){\n        return this.value || null;\n    }\n});\n\n/**\n * Provides a lightweight HTML Editor component. Some toolbar features are not supported by Safari and will be\n * automatically hidden when needed. These are noted in the config options where appropriate.\n *\n * The editor's toolbar buttons have tooltips defined in the {@link #buttonTips} property, but they are not\n * enabled by default unless the global {@link Ext.tip.QuickTipManager} singleton is\n * {@link Ext.tip.QuickTipManager#init initialized}.\n *\n * An Editor is a sensitive component that can't be used in all spots standard fields can be used. Putting an\n * Editor within any element that has display set to 'none' can cause problems in Safari and Firefox due to their\n * default iframe reloading bugs.\n *\n * # Example usage\n *\n * Simple example rendered with default options:\n *\n *     @example\n *     Ext.tip.QuickTipManager.init();  // enable tooltips\n *     Ext.create('Ext.form.HtmlEditor', {\n *         width: 580,\n *         height: 250,\n *         renderTo: Ext.getBody()\n *     });\n *\n * Passed via xtype into a container and with custom options:\n *\n *     @example\n *     Ext.tip.QuickTipManager.init();  // enable tooltips\n *     new Ext.panel.Panel({\n *         title: 'HTML Editor',\n *         renderTo: Ext.getBody(),\n *         width: 550,\n *         height: 250,\n *         frame: true,\n *         layout: 'fit',\n *         items: {\n *             xtype: 'htmleditor',\n *             enableColors: false,\n *             enableAlignments: false\n *         }\n *     });\n *     \n * # Reflow issues\n * \n * In some browsers, a layout reflow will cause the underlying editor iframe to be reset. This\n * is most commonly seen when using the editor in collapsed panels with animation. In these cases\n * it is best to avoid animation. More information can be found here: https://bugzilla.mozilla.org/show_bug.cgi?id=90268 \n */\nExt.define('Ext.form.field.HtmlEditor', {\n    extend:'Ext.Component',\n    mixins: {\n        labelable: 'Ext.form.Labelable',\n        field: 'Ext.form.field.Field'\n    },\n    alias: 'widget.htmleditor',\n    alternateClassName: 'Ext.form.HtmlEditor',\n    requires: [\n        'Ext.tip.QuickTipManager',\n        'Ext.picker.Color',\n        'Ext.toolbar.Item',\n        'Ext.toolbar.Toolbar',\n        'Ext.util.Format',\n        'Ext.layout.component.field.HtmlEditor'\n    ],\n\n    childEls: [\n        'iframeEl', 'textareaEl'\n    ],\n\n    fieldSubTpl: [\n        '{beforeTextAreaTpl}',\n        '<textarea id=\"{cmpId}-textareaEl\" name=\"{name}\" tabIndex=\"-1\" {inputAttrTpl}',\n                 ' class=\"{textareaCls}\" style=\"{size}\" autocomplete=\"off\">',\n            '{[Ext.util.Format.htmlEncode(values.value)]}',\n        '</textarea>',\n        '{afterTextAreaTpl}',\n        '{beforeIFrameTpl}',\n        '<iframe id=\"{cmpId}-iframeEl\" name=\"{iframeName}\" frameBorder=\"0\" {iframeAttrTpl}',\n               ' style=\"overflow:auto;{size}\" src=\"{iframeSrc}\"></iframe>',\n        '{afterIFrameTpl}',\n        {\n            disableFormats: true\n        }\n    ],\n\n    subTplInsertions: [\n        /**\n         * @cfg {String/Array/Ext.XTemplate} beforeTextAreaTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * before the textarea element. If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'beforeTextAreaTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} afterTextAreaTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * after the textarea element. If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'afterTextAreaTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} beforeIFrameTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * before the iframe element. If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'beforeIFrameTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} afterIFrameTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * after the iframe element. If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'afterIFrameTpl',\n\n        /**\n         * @cfg {String/Array/Ext.XTemplate} iframeAttrTpl\n         * An optional string or `XTemplate` configuration to insert in the field markup\n         * inside the iframe element (as attributes). If an `XTemplate` is used, the component's\n         * {@link Ext.form.field.Base#getSubTplData subTpl data} serves as the context.\n         */\n        'iframeAttrTpl',\n\n        // inherited\n        'inputAttrTpl'\n    ],\n\n    /**\n     * @cfg {Boolean} enableFormat\n     * Enable the bold, italic and underline buttons\n     */\n    enableFormat : true,\n    /**\n     * @cfg {Boolean} enableFontSize\n     * Enable the increase/decrease font size buttons\n     */\n    enableFontSize : true,\n    /**\n     * @cfg {Boolean} enableColors\n     * Enable the fore/highlight color buttons\n     */\n    enableColors : true,\n    /**\n     * @cfg {Boolean} enableAlignments\n     * Enable the left, center, right alignment buttons\n     */\n    enableAlignments : true,\n    /**\n     * @cfg {Boolean} enableLists\n     * Enable the bullet and numbered list buttons. Not available in Safari.\n     */\n    enableLists : true,\n    /**\n     * @cfg {Boolean} enableSourceEdit\n     * Enable the switch to source edit button. Not available in Safari.\n     */\n    enableSourceEdit : true,\n    /**\n     * @cfg {Boolean} enableLinks\n     * Enable the create link button. Not available in Safari.\n     */\n    enableLinks : true,\n    /**\n     * @cfg {Boolean} enableFont\n     * Enable font selection. Not available in Safari.\n     */\n    enableFont : true,\n    //<locale>\n    /**\n     * @cfg {String} createLinkText\n     * The default text for the create link prompt\n     */\n    createLinkText : 'Please enter the URL for the link:',\n    //</locale>\n    /**\n     * @cfg {String} [defaultLinkValue='http://']\n     * The default value for the create link prompt\n     */\n    defaultLinkValue : 'http:/'+'/',\n    /**\n     * @cfg {String[]} fontFamilies\n     * An array of available font families\n     */\n    fontFamilies : [\n        'Arial',\n        'Courier New',\n        'Tahoma',\n        'Times New Roman',\n        'Verdana'\n    ],\n    defaultFont: 'tahoma',\n    /**\n     * @cfg {String} defaultValue\n     * A default value to be put into the editor to resolve focus issues.\n     *\n     * Defaults to (Non-breaking space) in Opera and IE6,\n     * (Zero-width space) in all other browsers.\n     */\n    defaultValue: (Ext.isOpera || Ext.isIE6) ? '&#160;' : '&#8203;',\n\n    editorWrapCls: Ext.baseCSSPrefix + 'html-editor-wrap',\n\n    componentLayout: 'htmleditor',\n\n    // private properties\n    initialized : false,\n    activated : false,\n    sourceEditMode : false,\n    iframePad:3,\n    hideMode:'offsets',\n\n    afterBodyEl: '</div>',\n\n    maskOnDisable: true,\n\n    // private\n    initComponent : function(){\n        var me = this;\n\n        me.addEvents(\n            /**\n             * @event initialize\n             * Fires when the editor is fully initialized (including the iframe)\n             * @param {Ext.form.field.HtmlEditor} this\n             */\n            'initialize',\n            /**\n             * @event activate\n             * Fires when the editor is first receives the focus. Any insertion must wait until after this event.\n             * @param {Ext.form.field.HtmlEditor} this\n             */\n            'activate',\n             /**\n             * @event beforesync\n             * Fires before the textarea is updated with content from the editor iframe. Return false to cancel the\n             * sync.\n             * @param {Ext.form.field.HtmlEditor} this\n             * @param {String} html\n             */\n            'beforesync',\n             /**\n             * @event beforepush\n             * Fires before the iframe editor is updated with content from the textarea. Return false to cancel the\n             * push.\n             * @param {Ext.form.field.HtmlEditor} this\n             * @param {String} html\n             */\n            'beforepush',\n             /**\n             * @event sync\n             * Fires when the textarea is updated with content from the editor iframe.\n             * @param {Ext.form.field.HtmlEditor} this\n             * @param {String} html\n             */\n            'sync',\n             /**\n             * @event push\n             * Fires when the iframe editor is updated with content from the textarea.\n             * @param {Ext.form.field.HtmlEditor} this\n             * @param {String} html\n             */\n            'push',\n             /**\n             * @event editmodechange\n             * Fires when the editor switches edit modes\n             * @param {Ext.form.field.HtmlEditor} this\n             * @param {Boolean} sourceEdit True if source edit, false if standard editing.\n             */\n            'editmodechange'\n        );\n\n        me.callParent(arguments);\n        me.createToolbar(me);\n\n        // Init mixins\n        me.initLabelable();\n        me.initField();\n    },\n\n    /**\n     * @private\n     * Must define this function to allow the Layout base class to collect all descendant layouts to be run.\n     */\n    getRefItems: function() {\n        return [ this.toolbar ];\n    },\n\n    /*\n     * Called when the editor creates its toolbar. Override this method if you need to\n     * add custom toolbar buttons.\n     * @param {Ext.form.field.HtmlEditor} editor\n     * @protected\n     */\n    createToolbar : function(editor){\n        var me = this,\n            items = [], i,\n            tipsEnabled = Ext.tip.QuickTipManager && Ext.tip.QuickTipManager.isEnabled(),\n            baseCSSPrefix = Ext.baseCSSPrefix,\n            fontSelectItem, toolbar, undef;\n\n        function btn(id, toggle, handler){\n            return {\n                itemId : id,\n                cls : baseCSSPrefix + 'btn-icon',\n                iconCls: baseCSSPrefix + 'edit-'+id,\n                enableToggle:toggle !== false,\n                scope: editor,\n                handler:handler||editor.relayBtnCmd,\n                clickEvent: 'mousedown',\n                tooltip: tipsEnabled ? editor.buttonTips[id] || undef : undef,\n                overflowText: editor.buttonTips[id].title || undef,\n                tabIndex: -1\n            };\n        }\n\n\n        if (me.enableFont && !Ext.isSafari2) {\n            fontSelectItem = Ext.widget('component', {\n                renderTpl: [\n                    '<select id=\"{id}-selectEl\" class=\"{cls}\">',\n                        '<tpl for=\"fonts\">',\n                            '<option value=\"{[values.toLowerCase()]}\" style=\"font-family:{.}\"<tpl if=\"values.toLowerCase()==parent.defaultFont\"> selected</tpl>>{.}</option>',\n                        '</tpl>',\n                    '</select>'\n                ],\n                renderData: {\n                    cls: baseCSSPrefix + 'font-select',\n                    fonts: me.fontFamilies,\n                    defaultFont: me.defaultFont\n                },\n                childEls: ['selectEl'],\n                afterRender: function() {\n                    me.fontSelect = this.selectEl;\n                    Ext.Component.prototype.afterRender.apply(this, arguments);\n                },\n                onDisable: function() {\n                    var selectEl = this.selectEl;\n                    if (selectEl) {\n                        selectEl.dom.disabled = true;\n                    }\n                    Ext.Component.prototype.onDisable.apply(this, arguments);\n                },\n                onEnable: function() {\n                    var selectEl = this.selectEl;\n                    if (selectEl) {\n                        selectEl.dom.disabled = false;\n                    }\n                    Ext.Component.prototype.onEnable.apply(this, arguments);\n                },\n                listeners: {\n                    change: function() {\n                        me.relayCmd('fontname', me.fontSelect.dom.value);\n                        me.deferFocus();\n                    },\n                    element: 'selectEl'\n                }\n            });\n\n            items.push(\n                fontSelectItem,\n                '-'\n            );\n        }\n\n        if (me.enableFormat) {\n            items.push(\n                btn('bold'),\n                btn('italic'),\n                btn('underline')\n            );\n        }\n\n        if (me.enableFontSize) {\n            items.push(\n                '-',\n                btn('increasefontsize', false, me.adjustFont),\n                btn('decreasefontsize', false, me.adjustFont)\n            );\n        }\n\n        if (me.enableColors) {\n            items.push(\n                '-', {\n                    itemId: 'forecolor',\n                    cls: baseCSSPrefix + 'btn-icon',\n                    iconCls: baseCSSPrefix + 'edit-forecolor',\n                    overflowText: editor.buttonTips.forecolor.title,\n                    tooltip: tipsEnabled ? editor.buttonTips.forecolor || undef : undef,\n                    tabIndex:-1,\n                    menu : Ext.widget('menu', {\n                        plain: true,\n                        items: [{\n                            xtype: 'colorpicker',\n                            allowReselect: true,\n                            focus: Ext.emptyFn,\n                            value: '000000',\n                            plain: true,\n                            clickEvent: 'mousedown',\n                            handler: function(cp, color) {\n                                me.execCmd('forecolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);\n                                me.deferFocus();\n                                this.up('menu').hide();\n                            }\n                        }]\n                    })\n                }, {\n                    itemId: 'backcolor',\n                    cls: baseCSSPrefix + 'btn-icon',\n                    iconCls: baseCSSPrefix + 'edit-backcolor',\n                    overflowText: editor.buttonTips.backcolor.title,\n                    tooltip: tipsEnabled ? editor.buttonTips.backcolor || undef : undef,\n                    tabIndex:-1,\n                    menu : Ext.widget('menu', {\n                        plain: true,\n                        items: [{\n                            xtype: 'colorpicker',\n                            focus: Ext.emptyFn,\n                            value: 'FFFFFF',\n                            plain: true,\n                            allowReselect: true,\n                            clickEvent: 'mousedown',\n                            handler: function(cp, color) {\n                                if (Ext.isGecko) {\n                                    me.execCmd('useCSS', false);\n                                    me.execCmd('hilitecolor', color);\n                                    me.execCmd('useCSS', true);\n                                    me.deferFocus();\n                                } else {\n                                    me.execCmd(Ext.isOpera ? 'hilitecolor' : 'backcolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);\n                                    me.deferFocus();\n                                }\n                                this.up('menu').hide();\n                            }\n                        }]\n                    })\n                }\n            );\n        }\n\n        if (me.enableAlignments) {\n            items.push(\n                '-',\n                btn('justifyleft'),\n                btn('justifycenter'),\n                btn('justifyright')\n            );\n        }\n\n        if (!Ext.isSafari2) {\n            if (me.enableLinks) {\n                items.push(\n                    '-',\n                    btn('createlink', false, me.createLink)\n                );\n            }\n\n            if (me.enableLists) {\n                items.push(\n                    '-',\n                    btn('insertorderedlist'),\n                    btn('insertunorderedlist')\n                );\n            }\n            if (me.enableSourceEdit) {\n                items.push(\n                    '-',\n                    btn('sourceedit', true, function(btn){\n                        me.toggleSourceEdit(!me.sourceEditMode);\n                    })\n                );\n            }\n        }\n        \n        // Everything starts disabled.\n        for (i = 0; i < items.length; i++) {\n            if (items[i].itemId !== 'sourceedit') {\n                items[i].disabled = true;\n            }\n        }\n\n        // build the toolbar\n        // Automatically rendered in AbstractComponent.afterRender's renderChildren call\n        toolbar = Ext.widget('toolbar', {\n            id: me.id + '-toolbar',\n            ownerCt: me,\n            cls: Ext.baseCSSPrefix + 'html-editor-tb',\n            enableOverflow: true,\n            items: items,\n            ownerLayout: me.getComponentLayout(),\n\n            // stop form submits\n            listeners: {\n                click: function(e){\n                    e.preventDefault();\n                },\n                element: 'el'\n            }\n        });\n\n        me.toolbar = toolbar;\n    },\n    \n    getMaskTarget: function(){\n        return this.bodyEl;    \n    },\n\n    /**\n     * Sets the read only state of this field.\n     * @param {Boolean} readOnly Whether the field should be read only.\n     */\n    setReadOnly: function(readOnly) {\n        var me = this,\n            textareaEl = me.textareaEl,\n            iframeEl = me.iframeEl,\n            body;\n\n        me.readOnly = readOnly;\n\n        if (textareaEl) {\n            textareaEl.dom.readOnly = readOnly;\n        }\n\n        if (me.initialized) {\n            body = me.getEditorBody();\n            if (Ext.isIE) {\n                // Hide the iframe while setting contentEditable so it doesn't grab focus\n                iframeEl.setDisplayed(false);\n                body.contentEditable = !readOnly;\n                iframeEl.setDisplayed(true);\n            } else {\n                me.setDesignMode(!readOnly);\n            }\n            if (body) {\n                body.style.cursor = readOnly ? 'default' : 'text';\n            }\n            me.disableItems(readOnly);\n        }\n    },\n\n    /**\n     * Called when the editor initializes the iframe with HTML contents. Override this method if you\n     * want to change the initialization markup of the iframe (e.g. to add stylesheets).\n     *\n     * **Note:** IE8-Standards has unwanted scroller behavior, so the default meta tag forces IE7 compatibility.\n     * Also note that forcing IE7 mode works when the page is loaded normally, but if you are using IE's Web\n     * Developer Tools to manually set the document mode, that will take precedence and override what this\n     * code sets by default. This can be confusing when developing, but is not a user-facing issue.\n     * @protected\n     */\n    getDocMarkup: function() {\n        var me = this,\n            h = me.iframeEl.getHeight() - me.iframePad * 2;\n        return Ext.String.format('<html><head><style type=\"text/css\">body{border:0;margin:0;padding:{0}px;height:{1}px;box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box;cursor:text}</style></head><body></body></html>', me.iframePad, h);\n    },\n\n    // private\n    getEditorBody: function() {\n        var doc = this.getDoc();\n        return doc.body || doc.documentElement;\n    },\n\n    // private\n    getDoc: function() {\n        return (!Ext.isIE && this.iframeEl.dom.contentDocument) || this.getWin().document;\n    },\n\n    // private\n    getWin: function() {\n        return Ext.isIE ? this.iframeEl.dom.contentWindow : window.frames[this.iframeEl.dom.name];\n    },\n\n    // Do the job of a container layout at this point even though we are not a Container.\n    // TODO: Refactor as a Container.\n    finishRenderChildren: function () {\n        this.callParent();\n        this.toolbar.finishRender();\n    },\n\n    // private\n    onRender: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        // The input element is interrogated by the layout to extract height when labelAlign is 'top'\n        // It must be set, and then switched between the iframe and the textarea\n        me.inputEl = me.iframeEl;\n\n        // Start polling for when the iframe document is ready to be manipulated\n        me.monitorTask = Ext.TaskManager.start({\n            run: me.checkDesignMode,\n            scope: me,\n            interval: 100\n        });\n    },\n\n    initRenderTpl: function() {\n        var me = this;\n        if (!me.hasOwnProperty('renderTpl')) {\n            me.renderTpl = me.getTpl('labelableRenderTpl');\n        }\n        return me.callParent();\n    },\n\n    initRenderData: function() {\n        this.beforeSubTpl = '<div class=\"' + this.editorWrapCls + '\">' + Ext.DomHelper.markup(this.toolbar.getRenderTree());\n        return Ext.applyIf(this.callParent(), this.getLabelableRenderData());\n    },\n\n    getSubTplData: function() {\n        return {\n            $comp       : this,\n            cmpId       : this.id,\n            id          : this.getInputId(),\n            textareaCls : Ext.baseCSSPrefix + 'hidden',\n            value       : this.value,\n            iframeName  : Ext.id(),\n            iframeSrc   : Ext.SSL_SECURE_URL,\n            size        : 'height:100px;width:100%'\n        };\n    },\n\n    getSubTplMarkup: function() {\n        return this.getTpl('fieldSubTpl').apply(this.getSubTplData());\n    },\n\n    initFrameDoc: function() {\n        var me = this,\n            doc, task;\n\n        Ext.TaskManager.stop(me.monitorTask);\n\n        doc = me.getDoc();\n        me.win = me.getWin();\n\n        doc.open();\n        doc.write(me.getDocMarkup());\n        doc.close();\n\n        task = { // must defer to wait for browser to be ready\n            run: function() {\n                var doc = me.getDoc();\n                if (doc.body || doc.readyState === 'complete') {\n                    Ext.TaskManager.stop(task);\n                    me.setDesignMode(true);\n                    Ext.defer(me.initEditor, 10, me);\n                }\n            },\n            interval : 10,\n            duration:10000,\n            scope: me\n        };\n        Ext.TaskManager.start(task);\n    },\n\n    checkDesignMode: function() {\n        var me = this,\n            doc = me.getDoc();\n        if (doc && (!doc.editorInitialized || me.getDesignMode() !== 'on')) {\n            me.initFrameDoc();\n        }\n    },\n\n    /**\n     * @private\n     * Sets current design mode. To enable, mode can be true or 'on', off otherwise\n     */\n    setDesignMode: function(mode) {\n        var me = this,\n            doc = me.getDoc();\n        if (doc) {\n            if (me.readOnly) {\n                mode = false;\n            }\n            doc.designMode = (/on|true/i).test(String(mode).toLowerCase()) ?'on':'off';\n        }\n    },\n\n    // private\n    getDesignMode: function() {\n        var doc = this.getDoc();\n        return !doc ? '' : String(doc.designMode).toLowerCase();\n    },\n\n    disableItems: function(disabled) {\n        var items = this.getToolbar().items.items,\n            i,\n            iLen  = items.length,\n            item;\n\n        for (i = 0; i < iLen; i++) {\n            item = items[i];\n\n            if (item.getItemId() !== 'sourceedit') {\n                item.setDisabled(disabled);\n            }\n        }\n    },\n\n    /**\n     * Toggles the editor between standard and source edit mode.\n     * @param {Boolean} [sourceEditMode] True for source edit, false for standard\n     */\n    toggleSourceEdit: function(sourceEditMode) {\n        var me = this,\n            iframe = me.iframeEl,\n            textarea = me.textareaEl,\n            hiddenCls = Ext.baseCSSPrefix + 'hidden',\n            btn = me.getToolbar().getComponent('sourceedit');\n\n        if (!Ext.isBoolean(sourceEditMode)) {\n            sourceEditMode = !me.sourceEditMode;\n        }\n        me.sourceEditMode = sourceEditMode;\n\n        if (btn.pressed !== sourceEditMode) {\n            btn.toggle(sourceEditMode);\n        }\n        if (sourceEditMode) {\n            me.disableItems(true);\n            me.syncValue();\n            iframe.addCls(hiddenCls);\n            textarea.removeCls(hiddenCls);\n            textarea.dom.removeAttribute('tabIndex');\n            textarea.focus();\n            me.inputEl = textarea;\n        }\n        else {\n            if (me.initialized) {\n                me.disableItems(me.readOnly);\n            }\n            me.pushValue();\n            iframe.removeCls(hiddenCls);\n            textarea.addCls(hiddenCls);\n            textarea.dom.setAttribute('tabIndex', -1);\n            me.deferFocus();\n            me.inputEl = iframe;\n        }\n        me.fireEvent('editmodechange', me, sourceEditMode);\n        me.updateLayout();\n    },\n\n    // private used internally\n    createLink : function() {\n        var url = prompt(this.createLinkText, this.defaultLinkValue);\n        if (url && url !== 'http:/'+'/') {\n            this.relayCmd('createlink', url);\n        }\n    },\n\n    clearInvalid: Ext.emptyFn,\n\n    // docs inherit from Field\n    setValue: function(value) {\n        var me = this,\n            textarea = me.textareaEl;\n        me.mixins.field.setValue.call(me, value);\n        if (value === null || value === undefined) {\n            value = '';\n        }\n        if (textarea) {\n            textarea.dom.value = value;\n        }\n        me.pushValue();\n        return this;\n    },\n\n    /**\n     * If you need/want custom HTML cleanup, this is the method you should override.\n     * @param {String} html The HTML to be cleaned\n     * @return {String} The cleaned HTML\n     * @protected\n     */\n    cleanHtml: function(html) {\n        html = String(html);\n        if (Ext.isWebKit) { // strip safari nonsense\n            html = html.replace(/\\sclass=\"(?:Apple-style-span|khtml-block-placeholder)\"/gi, '');\n        }\n\n        /*\n         * Neat little hack. Strips out all the non-digit characters from the default\n         * value and compares it to the character code of the first character in the string\n         * because it can cause encoding issues when posted to the server. We need the\n         * parseInt here because charCodeAt will return a number.\n         */\n        if (html.charCodeAt(0) === parseInt(this.defaultValue.replace(/\\D/g, ''), 10)) {\n            html = html.substring(1);\n        }\n        return html;\n    },\n\n    /**\n     * Syncs the contents of the editor iframe with the textarea.\n     * @protected\n     */\n    syncValue : function(){\n        var me = this,\n            body, changed, html, bodyStyle, match;\n\n        if (me.initialized) {\n            body = me.getEditorBody();\n            html = body.innerHTML;\n            if (Ext.isWebKit) {\n                bodyStyle = body.getAttribute('style'); // Safari puts text-align styles on the body element!\n                match = bodyStyle.match(/text-align:(.*?);/i);\n                if (match && match[1]) {\n                    html = '<div style=\"' + match[0] + '\">' + html + '</div>';\n                }\n            }\n            html = me.cleanHtml(html);\n            if (me.fireEvent('beforesync', me, html) !== false) {\n                if (me.textareaEl.dom.value != html) {\n                    me.textareaEl.dom.value = html;\n                    changed = true;\n                }\n\n                me.fireEvent('sync', me, html);\n\n                if (changed) {\n                    // we have to guard this to avoid infinite recursion because getValue\n                    // calls this method...\n                    me.checkChange();\n                }\n            }\n        }\n    },\n\n    //docs inherit from Field\n    getValue : function() {\n        var me = this,\n            value;\n        if (!me.sourceEditMode) {\n            me.syncValue();\n        }\n        value = me.rendered ? me.textareaEl.dom.value : me.value;\n        me.value = value;\n        return value;\n    },\n\n    /**\n     * Pushes the value of the textarea into the iframe editor.\n     * @protected\n     */\n    pushValue: function() {\n        var me = this,\n            v;\n        if(me.initialized){\n            v = me.textareaEl.dom.value || '';\n            if (!me.activated && v.length < 1) {\n                v = me.defaultValue;\n            }\n            if (me.fireEvent('beforepush', me, v) !== false) {\n                me.getEditorBody().innerHTML = v;\n                if (Ext.isGecko) {\n                    // Gecko hack, see: https://bugzilla.mozilla.org/show_bug.cgi?id=232791#c8\n                    me.setDesignMode(false);  //toggle off first\n                    me.setDesignMode(true);\n                }\n                me.fireEvent('push', me, v);\n            }\n        }\n    },\n\n    // private\n    deferFocus : function(){\n         this.focus(false, true);\n    },\n\n    getFocusEl: function() {\n        var me = this,\n            win = me.win;\n        return win && !me.sourceEditMode ? win : me.textareaEl;\n    },\n\n    // private\n    initEditor : function(){\n        //Destroying the component during/before initEditor can cause issues.\n        try {\n            var me = this,\n                dbody = me.getEditorBody(),\n                ss = me.textareaEl.getStyles('font-size', 'font-family', 'background-image', 'background-repeat', 'background-color', 'color'),\n                doc,\n                fn;\n\n            ss['background-attachment'] = 'fixed'; // w3c\n            dbody.bgProperties = 'fixed'; // ie\n\n            Ext.DomHelper.applyStyles(dbody, ss);\n\n            doc = me.getDoc();\n\n            if (doc) {\n                try {\n                    Ext.EventManager.removeAll(doc);\n                } catch(e) {}\n            }\n\n            /*\n             * We need to use createDelegate here, because when using buffer, the delayed task is added\n             * as a property to the function. When the listener is removed, the task is deleted from the function.\n             * Since onEditorEvent is shared on the prototype, if we have multiple html editors, the first time one of the editors\n             * is destroyed, it causes the fn to be deleted from the prototype, which causes errors. Essentially, we're just anonymizing the function.\n             */\n            fn = Ext.Function.bind(me.onEditorEvent, me);\n            Ext.EventManager.on(doc, {\n                mousedown: fn,\n                dblclick: fn,\n                click: fn,\n                keyup: fn,\n                buffer:100\n            });\n\n            // These events need to be relayed from the inner document (where they stop\n            // bubbling) up to the outer document. This has to be done at the DOM level so\n            // the event reaches listeners on elements like the document body. The effected\n            // mechanisms that depend on this bubbling behavior are listed to the right\n            // of the event.\n            fn = me.onRelayedEvent;\n            Ext.EventManager.on(doc, {\n                mousedown: fn, // menu dismisal (MenuManager) and Window onMouseDown (toFront)\n                mousemove: fn, // window resize drag detection\n                mouseup: fn,   // window resize termination\n                click: fn,     // not sure, but just to be safe\n                dblclick: fn,  // not sure again\n                scope: me\n            });\n\n            if (Ext.isGecko) {\n                Ext.EventManager.on(doc, 'keypress', me.applyCommand, me);\n            }\n            if (me.fixKeys) {\n                Ext.EventManager.on(doc, 'keydown', me.fixKeys, me);\n            }\n\n            // We need to be sure we remove all our events from the iframe on unload or we're going to LEAK!\n            Ext.EventManager.on(window, 'unload', me.beforeDestroy, me);\n            doc.editorInitialized = true;\n\n            me.initialized = true;\n            me.pushValue();\n            me.setReadOnly(me.readOnly);\n            me.fireEvent('initialize', me);\n        } catch(ex) {\n            // ignore (why?)\n        }\n    },\n\n    // private\n    beforeDestroy : function(){\n        var me = this,\n            monitorTask = me.monitorTask,\n            doc, prop;\n\n        if (monitorTask) {\n            Ext.TaskManager.stop(monitorTask);\n        }\n        if (me.rendered) {\n            try {\n                doc = me.getDoc();\n                if (doc) {\n                    // removeAll() doesn't currently know how to handle iframe document,\n                    // so for now we have to wrap it in an Ext.Element using Ext.fly,\n                    // or else IE6/7 will leak big time when the page is refreshed.\n                    // TODO: this may not be needed once we find a more permanent fix.\n                    // see EXTJSIV-5891.\n                    Ext.EventManager.removeAll(Ext.fly(doc));\n                    for (prop in doc) {\n                        if (doc.hasOwnProperty && doc.hasOwnProperty(prop)) {\n                            delete doc[prop];\n                        }\n                    }\n                }\n            } catch(e) {\n                // ignore (why?)\n            }\n            Ext.destroyMembers(me, 'toolbar', 'iframeEl', 'textareaEl');\n        }\n        me.callParent();\n    },\n\n    // private\n    onRelayedEvent: function (event) {\n        // relay event from the iframe's document to the document that owns the iframe...\n\n        var iframeEl = this.iframeEl,\n            iframeXY = iframeEl.getXY(),\n            eventXY = event.getXY();\n\n        // the event from the inner document has XY relative to that document's origin,\n        // so adjust it to use the origin of the iframe in the outer document:\n        event.xy = [iframeXY[0] + eventXY[0], iframeXY[1] + eventXY[1]];\n\n        event.injectEvent(iframeEl); // blame the iframe for the event...\n\n        event.xy = eventXY; // restore the original XY (just for safety)\n    },\n\n    // private\n    onFirstFocus : function(){\n        var me = this,\n            selection, range;\n        me.activated = true;\n        me.disableItems(me.readOnly);\n        if (Ext.isGecko) { // prevent silly gecko errors\n            me.win.focus();\n            selection = me.win.getSelection();\n            if (!selection.focusNode || selection.focusNode.nodeType !== 3) {\n                range = selection.getRangeAt(0);\n                range.selectNodeContents(me.getEditorBody());\n                range.collapse(true);\n                me.deferFocus();\n            }\n            try {\n                me.execCmd('useCSS', true);\n                me.execCmd('styleWithCSS', false);\n            } catch(e) {\n                // ignore (why?)\n            }\n        }\n        me.fireEvent('activate', me);\n    },\n\n    // private\n    adjustFont: function(btn) {\n        var adjust = btn.getItemId() === 'increasefontsize' ? 1 : -1,\n            size = this.getDoc().queryCommandValue('FontSize') || '2',\n            isPxSize = Ext.isString(size) && size.indexOf('px') !== -1,\n            isSafari;\n        size = parseInt(size, 10);\n        if (isPxSize) {\n            // Safari 3 values\n            // 1 = 10px, 2 = 13px, 3 = 16px, 4 = 18px, 5 = 24px, 6 = 32px\n            if (size <= 10) {\n                size = 1 + adjust;\n            }\n            else if (size <= 13) {\n                size = 2 + adjust;\n            }\n            else if (size <= 16) {\n                size = 3 + adjust;\n            }\n            else if (size <= 18) {\n                size = 4 + adjust;\n            }\n            else if (size <= 24) {\n                size = 5 + adjust;\n            }\n            else {\n                size = 6 + adjust;\n            }\n            size = Ext.Number.constrain(size, 1, 6);\n        } else {\n            isSafari = Ext.isSafari;\n            if (isSafari) { // safari\n                adjust *= 2;\n            }\n            size = Math.max(1, size + adjust) + (isSafari ? 'px' : 0);\n        }\n        this.execCmd('FontSize', size);\n    },\n\n    // private\n    onEditorEvent: function(e) {\n        this.updateToolbar();\n    },\n\n    /**\n     * Triggers a toolbar update by reading the markup state of the current selection in the editor.\n     * @protected\n     */\n    updateToolbar: function() {\n        var me = this,\n            btns, doc, name, fontSelect;\n\n        if (me.readOnly) {\n            return;\n        }\n\n        if (!me.activated) {\n            me.onFirstFocus();\n            return;\n        }\n\n        btns = me.getToolbar().items.map;\n        doc = me.getDoc();\n\n        if (me.enableFont && !Ext.isSafari2) {\n            name = (doc.queryCommandValue('FontName') || me.defaultFont).toLowerCase();\n            fontSelect = me.fontSelect.dom;\n            if (name !== fontSelect.value) {\n                fontSelect.value = name;\n            }\n        }\n\n        function updateButtons() {\n            for (var i = 0, l = arguments.length, name; i < l; i++) {\n                name = arguments[i];\n                btns[name].toggle(doc.queryCommandState(name));\n            }\n        }\n        if(me.enableFormat){\n            updateButtons('bold', 'italic', 'underline');\n        }\n        if(me.enableAlignments){\n            updateButtons('justifyleft', 'justifycenter', 'justifyright');\n        }\n        if(!Ext.isSafari2 && me.enableLists){\n            updateButtons('insertorderedlist', 'insertunorderedlist');\n        }\n\n        Ext.menu.Manager.hideAll();\n\n        me.syncValue();\n    },\n\n    // private\n    relayBtnCmd: function(btn) {\n        this.relayCmd(btn.getItemId());\n    },\n\n    /**\n     * Executes a Midas editor command on the editor document and performs necessary focus and toolbar updates.\n     * **This should only be called after the editor is initialized.**\n     * @param {String} cmd The Midas command\n     * @param {String/Boolean} [value=null] The value to pass to the command\n     */\n    relayCmd: function(cmd, value) {\n        Ext.defer(function() {\n            var me = this;\n            me.focus();\n            me.execCmd(cmd, value);\n            me.updateToolbar();\n        }, 10, this);\n    },\n\n    /**\n     * Executes a Midas editor command directly on the editor document. For visual commands, you should use\n     * {@link #relayCmd} instead. **This should only be called after the editor is initialized.**\n     * @param {String} cmd The Midas command\n     * @param {String/Boolean} [value=null] The value to pass to the command\n     */\n    execCmd : function(cmd, value){\n        var me = this,\n            doc = me.getDoc(),\n            undef;\n        doc.execCommand(cmd, false, value === undef ? null : value);\n        me.syncValue();\n    },\n\n    // private\n    applyCommand : function(e){\n        if (e.ctrlKey) {\n            var me = this,\n                c = e.getCharCode(), cmd;\n            if (c > 0) {\n                c = String.fromCharCode(c);\n                switch (c) {\n                    case 'b':\n                        cmd = 'bold';\n                    break;\n                    case 'i':\n                        cmd = 'italic';\n                    break;\n                    case 'u':\n                        cmd = 'underline';\n                    break;\n                }\n                if (cmd) {\n                    me.win.focus();\n                    me.execCmd(cmd);\n                    me.deferFocus();\n                    e.preventDefault();\n                }\n            }\n        }\n    },\n\n    /**\n     * Inserts the passed text at the current cursor position.\n     * Note: the editor must be initialized and activated to insert text.\n     * @param {String} text\n     */\n    insertAtCursor : function(text){\n        var me = this,\n            range;\n\n        if (me.activated) {\n            me.win.focus();\n            if (Ext.isIE) {\n                range = me.getDoc().selection.createRange();\n                if (range) {\n                    range.pasteHTML(text);\n                    me.syncValue();\n                    me.deferFocus();\n                }\n            }else{\n                me.execCmd('InsertHTML', text);\n                me.deferFocus();\n            }\n        }\n    },\n\n    // private\n    fixKeys: (function() { // load time branching for fastest keydown performance\n        if (Ext.isIE) {\n            return function(e){\n                var me = this,\n                    k = e.getKey(),\n                    doc = me.getDoc(),\n                    readOnly = me.readOnly,\n                    range, target;\n\n                if (k === e.TAB) {\n                    e.stopEvent();\n                    if (!readOnly) {\n                        range = doc.selection.createRange();\n                        if(range){\n                            range.collapse(true);\n                            range.pasteHTML('&#160;&#160;&#160;&#160;');\n                            me.deferFocus();\n                        }\n                    }\n                }\n                else if (k === e.ENTER) {\n                    if (!readOnly) {\n                        range = doc.selection.createRange();\n                        if (range) {\n                            target = range.parentElement();\n                            if(!target || target.tagName.toLowerCase() !== 'li'){\n                                e.stopEvent();\n                                range.pasteHTML('<br />');\n                                range.collapse(false);\n                                range.select();\n                            }\n                        }\n                    }\n                }\n            };\n        }\n\n        if (Ext.isOpera) {\n            return function(e){\n                var me = this;\n                if (e.getKey() === e.TAB) {\n                    e.stopEvent();\n                    if (!me.readOnly) {\n                        me.win.focus();\n                        me.execCmd('InsertHTML','&#160;&#160;&#160;&#160;');\n                        me.deferFocus();\n                    }\n                }\n            };\n        }\n\n        if (Ext.isWebKit) {\n            return function(e){\n                var me = this,\n                    k = e.getKey(),\n                    readOnly = me.readOnly;\n\n                if (k === e.TAB) {\n                    e.stopEvent();\n                    if (!readOnly) {\n                        me.execCmd('InsertText','\\t');\n                        me.deferFocus();\n                    }\n                }\n                else if (k === e.ENTER) {\n                    e.stopEvent();\n                    if (!readOnly) {\n                        me.execCmd('InsertHtml','<br /><br />');\n                        me.deferFocus();\n                    }\n                }\n            };\n        }\n\n        return null; // not needed, so null\n    }()),\n\n    /**\n     * Returns the editor's toolbar. **This is only available after the editor has been rendered.**\n     * @return {Ext.toolbar.Toolbar}\n     */\n    getToolbar : function(){\n        return this.toolbar;\n    },\n\n    //<locale>\n    /**\n     * @property {Object} buttonTips\n     * Object collection of toolbar tooltips for the buttons in the editor. The key is the command id associated with\n     * that button and the value is a valid QuickTips object. For example:\n     *\n     *     {\n     *         bold : {\n     *             title: 'Bold (Ctrl+B)',\n     *             text: 'Make the selected text bold.',\n     *             cls: 'x-html-editor-tip'\n     *         },\n     *         italic : {\n     *             title: 'Italic (Ctrl+I)',\n     *             text: 'Make the selected text italic.',\n     *             cls: 'x-html-editor-tip'\n     *         },\n     *         ...\n     */\n    buttonTips : {\n        bold : {\n            title: 'Bold (Ctrl+B)',\n            text: 'Make the selected text bold.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        italic : {\n            title: 'Italic (Ctrl+I)',\n            text: 'Make the selected text italic.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        underline : {\n            title: 'Underline (Ctrl+U)',\n            text: 'Underline the selected text.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        increasefontsize : {\n            title: 'Grow Text',\n            text: 'Increase the font size.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        decreasefontsize : {\n            title: 'Shrink Text',\n            text: 'Decrease the font size.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        backcolor : {\n            title: 'Text Highlight Color',\n            text: 'Change the background color of the selected text.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        forecolor : {\n            title: 'Font Color',\n            text: 'Change the color of the selected text.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        justifyleft : {\n            title: 'Align Text Left',\n            text: 'Align text to the left.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        justifycenter : {\n            title: 'Center Text',\n            text: 'Center text in the editor.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        justifyright : {\n            title: 'Align Text Right',\n            text: 'Align text to the right.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        insertunorderedlist : {\n            title: 'Bullet List',\n            text: 'Start a bulleted list.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        insertorderedlist : {\n            title: 'Numbered List',\n            text: 'Start a numbered list.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        createlink : {\n            title: 'Hyperlink',\n            text: 'Make the selected text a hyperlink.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        },\n        sourceedit : {\n            title: 'Source Edit',\n            text: 'Switch to source editing mode.',\n            cls: Ext.baseCSSPrefix + 'html-editor-tip'\n        }\n    }\n    //</locale>\n\n    // hide stuff that is not compatible\n    /**\n     * @event blur\n     * @private\n     */\n    /**\n     * @event focus\n     * @private\n     */\n    /**\n     * @event specialkey\n     * @private\n     */\n    /**\n     * @cfg {String} fieldCls\n     * @private\n     */\n    /**\n     * @cfg {String} focusCls\n     * @private\n     */\n    /**\n     * @cfg {String} autoCreate\n     * @private\n     */\n    /**\n     * @cfg {String} inputType\n     * @private\n     */\n    /**\n     * @cfg {String} invalidCls\n     * @private\n     */\n    /**\n     * @cfg {String} invalidText\n     * @private\n     */\n    /**\n     * @cfg {String} msgFx\n     * @private\n     */\n    /**\n     * @cfg {Boolean} allowDomMove\n     * @private\n     */\n    /**\n     * @cfg {String} applyTo\n     * @private\n     */\n    /**\n     * @cfg {String} readOnly\n     * @private\n     */\n    /**\n     * @cfg {String} tabIndex\n     * @private\n     */\n    /**\n     * @method validate\n     * @private\n     */\n});\n\n/**\n * @docauthor Robert Dougan <rob@sencha.com>\n *\n * Single radio field. Similar to checkbox, but automatically handles making sure only one radio is checked\n * at a time within a group of radios with the same name.\n *\n * # Labeling\n *\n * In addition to the {@link Ext.form.Labelable standard field labeling options}, radio buttons\n * may be given an optional {@link #boxLabel} which will be displayed immediately to the right of the input. Also\n * see {@link Ext.form.RadioGroup} for a convenient method of grouping related radio buttons.\n *\n * # Values\n *\n * The main value of a Radio field is a boolean, indicating whether or not the radio is checked.\n *\n * The following values will check the radio:\n *\n * - `true`\n * - `'true'`\n * - `'1'`\n * - `'on'`\n *\n * Any other value will uncheck it.\n *\n * In addition to the main boolean value, you may also specify a separate {@link #inputValue}. This will be sent\n * as the parameter value when the form is {@link Ext.form.Basic#submit submitted}. You will want to set this\n * value if you have multiple radio buttons with the same {@link #name}, as is almost always the case.\n *\n * # Example usage\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title      : 'Order Form',\n *         width      : 300,\n *         bodyPadding: 10,\n *         renderTo   : Ext.getBody(),\n *         items: [\n *             {\n *                 xtype      : 'fieldcontainer',\n *                 fieldLabel : 'Size',\n *                 defaultType: 'radiofield',\n *                 defaults: {\n *                     flex: 1\n *                 },\n *                 layout: 'hbox',\n *                 items: [\n *                     {\n *                         boxLabel  : 'M',\n *                         name      : 'size',\n *                         inputValue: 'm',\n *                         id        : 'radio1'\n *                     }, {\n *                         boxLabel  : 'L',\n *                         name      : 'size',\n *                         inputValue: 'l',\n *                         id        : 'radio2'\n *                     }, {\n *                         boxLabel  : 'XL',\n *                         name      : 'size',\n *                         inputValue: 'xl',\n *                         id        : 'radio3'\n *                     }\n *                 ]\n *             },\n *             {\n *                 xtype      : 'fieldcontainer',\n *                 fieldLabel : 'Color',\n *                 defaultType: 'radiofield',\n *                 defaults: {\n *                     flex: 1\n *                 },\n *                 layout: 'hbox',\n *                 items: [\n *                     {\n *                         boxLabel  : 'Blue',\n *                         name      : 'color',\n *                         inputValue: 'blue',\n *                         id        : 'radio4'\n *                     }, {\n *                         boxLabel  : 'Grey',\n *                         name      : 'color',\n *                         inputValue: 'grey',\n *                         id        : 'radio5'\n *                     }, {\n *                         boxLabel  : 'Black',\n *                         name      : 'color',\n *                         inputValue: 'black',\n *                         id        : 'radio6'\n *                     }\n *                 ]\n *             }\n *         ],\n *         bbar: [\n *             {\n *                 text: 'Smaller Size',\n *                 handler: function() {\n *                     var radio1 = Ext.getCmp('radio1'),\n *                         radio2 = Ext.getCmp('radio2'),\n *                         radio3 = Ext.getCmp('radio3');\n *\n *                     //if L is selected, change to M\n *                     if (radio2.getValue()) {\n *                         radio1.setValue(true);\n *                         return;\n *                     }\n *\n *                     //if XL is selected, change to L\n *                     if (radio3.getValue()) {\n *                         radio2.setValue(true);\n *                         return;\n *                     }\n *\n *                     //if nothing is set, set size to S\n *                     radio1.setValue(true);\n *                 }\n *             },\n *             {\n *                 text: 'Larger Size',\n *                 handler: function() {\n *                     var radio1 = Ext.getCmp('radio1'),\n *                         radio2 = Ext.getCmp('radio2'),\n *                         radio3 = Ext.getCmp('radio3');\n *\n *                     //if M is selected, change to L\n *                     if (radio1.getValue()) {\n *                         radio2.setValue(true);\n *                         return;\n *                     }\n *\n *                     //if L is selected, change to XL\n *                     if (radio2.getValue()) {\n *                         radio3.setValue(true);\n *                         return;\n *                     }\n *\n *                     //if nothing is set, set size to XL\n *                     radio3.setValue(true);\n *                 }\n *             },\n *             '-',\n *             {\n *                 text: 'Select color',\n *                 menu: {\n *                     indent: false,\n *                     items: [\n *                         {\n *                             text: 'Blue',\n *                             handler: function() {\n *                                 var radio = Ext.getCmp('radio4');\n *                                 radio.setValue(true);\n *                             }\n *                         },\n *                         {\n *                             text: 'Grey',\n *                             handler: function() {\n *                                 var radio = Ext.getCmp('radio5');\n *                                 radio.setValue(true);\n *                             }\n *                         },\n *                         {\n *                             text: 'Black',\n *                             handler: function() {\n *                                 var radio = Ext.getCmp('radio6');\n *                                 radio.setValue(true);\n *                             }\n *                         }\n *                     ]\n *                 }\n *             }\n *         ]\n *     });\n */\nExt.define('Ext.form.field.Radio', {\n    extend:'Ext.form.field.Checkbox',\n    alias: ['widget.radiofield', 'widget.radio'],\n    alternateClassName: 'Ext.form.Radio',\n    requires: ['Ext.form.RadioManager'],\n\n    /**\n     * @property {Boolean} isRadio\n     * `true` in this class to identify an object as an instantiated Radio, or subclass thereof.\n     */\n    isRadio: true,\n\n    /**\n     * @cfg {String} uncheckedValue\n     * @private\n     */\n\n    // private\n    inputType: 'radio',\n    ariaRole: 'radio',\n    \n    formId: null,\n\n    /**\n     * If this radio is part of a group, it will return the selected value\n     * @return {String}\n     */\n    getGroupValue: function() {\n        var selected = this.getManager().getChecked(this.name, this.getFormId());\n        return selected ? selected.inputValue : null;\n    },\n\n    /**\n     * @private Handle click on the radio button\n     */\n    onBoxClick: function(e) {\n        var me = this;\n        if (!me.disabled && !me.readOnly) {\n            this.setValue(true);\n        }\n    },\n    \n    onRemoved: function(){\n        this.callParent(arguments);\n        this.formId = null;\n    },\n\n    /**\n     * Sets either the checked/unchecked status of this Radio, or, if a string value is passed, checks a sibling Radio\n     * of the same name whose value is the value specified.\n     * @param {String/Boolean} value Checked value, or the value of the sibling radio button to check.\n     * @return {Ext.form.field.Radio} this\n     */\n    setValue: function(v) {\n        var me = this,\n            active;\n\n        if (Ext.isBoolean(v)) {\n            me.callParent(arguments);\n        } else {\n            active = me.getManager().getWithValue(me.name, v, me.getFormId()).getAt(0);\n            if (active) {\n                active.setValue(true);\n            }\n        }\n        return me;\n    },\n\n    /**\n     * Returns the submit value for the checkbox which can be used when submitting forms.\n     * @return {Boolean/Object} True if checked, null if not.\n     */\n    getSubmitValue: function() {\n        return this.checked ? this.inputValue : null;\n    },\n\n    getModelData: function() {\n        return this.getSubmitData();\n    },\n\n    // inherit docs\n    onChange: function(newVal, oldVal) {\n        var me = this,\n            r, rLen, radio, radios;\n\n        me.callParent(arguments);\n\n        if (newVal) {\n            radios = me.getManager().getByName(me.name, me.getFormId()).items;\n            rLen   = radios.length;\n\n            for (r = 0; r < rLen; r++) {\n                radio = radios[r];\n\n                if (radio !== me) {\n                    radio.setValue(false);\n                }\n            }\n        }\n    },\n\n    // inherit docs\n    getManager: function() {\n        return Ext.form.RadioManager;\n    }\n});\n\n/**\n * A time picker which provides a list of times from which to choose. This is used by the Ext.form.field.Time\n * class to allow browsing and selection of valid times, but could also be used with other components.\n *\n * By default, all times starting at midnight and incrementing every 15 minutes will be presented. This list of\n * available times can be controlled using the {@link #minValue}, {@link #maxValue}, and {@link #increment}\n * configuration properties. The format of the times presented in the list can be customized with the {@link #format}\n * config.\n *\n * To handle when the user selects a time from the list, you can subscribe to the {@link #selectionchange} event.\n *\n *     @example\n *     Ext.create('Ext.picker.Time', {\n *        width: 60,\n *        minValue: Ext.Date.parse('04:30:00 AM', 'h:i:s A'),\n *        maxValue: Ext.Date.parse('08:00:00 AM', 'h:i:s A'),\n *        renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.picker.Time', {\n    extend: 'Ext.view.BoundList',\n    alias: 'widget.timepicker',\n    requires: ['Ext.data.Store', 'Ext.Date'],\n\n    /**\n     * @cfg {Date} minValue\n     * The minimum time to be shown in the list of times. This must be a Date object (only the time fields will be\n     * used); no parsing of String values will be done.\n     */\n\n    /**\n     * @cfg {Date} maxValue\n     * The maximum time to be shown in the list of times. This must be a Date object (only the time fields will be\n     * used); no parsing of String values will be done.\n     */\n\n    /**\n     * @cfg {Number} increment\n     * The number of minutes between each time value in the list.\n     */\n    increment: 15,\n\n    //<locale>\n    /**\n     * @cfg {String} [format=undefined]\n     * The default time format string which can be overriden for localization support. The format must be valid\n     * according to {@link Ext.Date#parse}.\n     *\n     * Defaults to `'g:i A'`, e.g., `'3:15 PM'`. For 24-hour time format try `'H:i'` instead.\n     */\n    format : \"g:i A\",\n    //</locale>\n\n    /**\n     * @private\n     * The field in the implicitly-generated Model objects that gets displayed in the list. This is\n     * an internal field name only and is not useful to change via config.\n     */\n    displayField: 'disp',\n\n    /**\n     * @private\n     * Year, month, and day that all times will be normalized into internally.\n     */\n    initDate: [2008,0,1],\n\n    componentCls: Ext.baseCSSPrefix + 'timepicker',\n\n    /**\n     * @cfg\n     * @private\n     */\n    loadMask: false,\n\n    initComponent: function() {\n        var me = this,\n            dateUtil = Ext.Date,\n            clearTime = dateUtil.clearTime,\n            initDate = me.initDate;\n\n        // Set up absolute min and max for the entire day\n        me.absMin = clearTime(new Date(initDate[0], initDate[1], initDate[2]));\n        me.absMax = dateUtil.add(clearTime(new Date(initDate[0], initDate[1], initDate[2])), 'mi', (24 * 60) - 1);\n\n        me.store = me.createStore();\n        me.updateList();\n\n        me.callParent();\n    },\n\n    /**\n     * Set the {@link #minValue} and update the list of available times. This must be a Date object (only the time\n     * fields will be used); no parsing of String values will be done.\n     * @param {Date} value\n     */\n    setMinValue: function(value) {\n        this.minValue = value;\n        this.updateList();\n    },\n\n    /**\n     * Set the {@link #maxValue} and update the list of available times. This must be a Date object (only the time\n     * fields will be used); no parsing of String values will be done.\n     * @param {Date} value\n     */\n    setMaxValue: function(value) {\n        this.maxValue = value;\n        this.updateList();\n    },\n\n    /**\n     * @private\n     * Sets the year/month/day of the given Date object to the {@link #initDate}, so that only\n     * the time fields are significant. This makes values suitable for time comparison.\n     * @param {Date} date\n     */\n    normalizeDate: function(date) {\n        var initDate = this.initDate;\n        date.setFullYear(initDate[0], initDate[1], initDate[2]);\n        return date;\n    },\n\n    /**\n     * Update the list of available times in the list to be constrained within the {@link #minValue}\n     * and {@link #maxValue}.\n     */\n    updateList: function() {\n        var me = this,\n            min = me.normalizeDate(me.minValue || me.absMin),\n            max = me.normalizeDate(me.maxValue || me.absMax);\n\n        me.store.filterBy(function(record) {\n            var date = record.get('date');\n            return date >= min && date <= max;\n        });\n    },\n\n    /**\n     * @private\n     * Creates the internal {@link Ext.data.Store} that contains the available times. The store\n     * is loaded with all possible times, and it is later filtered to hide those times outside\n     * the minValue/maxValue.\n     */\n    createStore: function() {\n        var me = this,\n            utilDate = Ext.Date,\n            times = [],\n            min = me.absMin,\n            max = me.absMax;\n\n        while(min <= max){\n            times.push({\n                disp: utilDate.dateFormat(min, me.format),\n                date: min\n            });\n            min = utilDate.add(min, 'mi', me.increment);\n        }\n\n        return new Ext.data.Store({\n            fields: ['disp', 'date'],\n            data: times\n        });\n    }\n\n});\n\n/**\n * Provides a time input field with a time dropdown and automatic time validation.\n *\n * This field recognizes and uses JavaScript Date objects as its main {@link #value} type (only the time portion of the\n * date is used; the month/day/year are ignored). In addition, it recognizes string values which are parsed according to\n * the {@link #format} and/or {@link #altFormats} configs. These may be reconfigured to use time formats appropriate for\n * the user's locale.\n *\n * The field may be limited to a certain range of times by using the {@link #minValue} and {@link #maxValue} configs,\n * and the interval between time options in the dropdown can be changed with the {@link #increment} config.\n *\n * Example usage:\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Time Card',\n *         width: 300,\n *         bodyPadding: 10,\n *         renderTo: Ext.getBody(),\n *         items: [{\n *             xtype: 'timefield',\n *             name: 'in',\n *             fieldLabel: 'Time In',\n *             minValue: '6:00 AM',\n *             maxValue: '8:00 PM',\n *             increment: 30,\n *             anchor: '100%'\n *         }, {\n *             xtype: 'timefield',\n *             name: 'out',\n *             fieldLabel: 'Time Out',\n *             minValue: '6:00 AM',\n *             maxValue: '8:00 PM',\n *             increment: 30,\n *             anchor: '100%'\n *        }]\n *     });\n */\nExt.define('Ext.form.field.Time', {\n    extend:'Ext.form.field.ComboBox',\n    alias: 'widget.timefield',\n    requires: ['Ext.form.field.Date', 'Ext.picker.Time', 'Ext.view.BoundListKeyNav', 'Ext.Date'],\n    alternateClassName: ['Ext.form.TimeField', 'Ext.form.Time'],\n\n    /**\n     * @cfg {String} [triggerCls='x-form-time-trigger']\n     * An additional CSS class used to style the trigger button. The trigger will always get the {@link #triggerBaseCls}\n     * by default and triggerCls will be **appended** if specified.\n     */\n    triggerCls: Ext.baseCSSPrefix + 'form-time-trigger',\n\n    /**\n     * @cfg {Date/String} minValue\n     * The minimum allowed time. Can be either a Javascript date object with a valid time value or a string time in a\n     * valid format -- see {@link #format} and {@link #altFormats}.\n     */\n\n    /**\n     * @cfg {Date/String} maxValue\n     * The maximum allowed time. Can be either a Javascript date object with a valid time value or a string time in a\n     * valid format -- see {@link #format} and {@link #altFormats}.\n     */\n\n    //<locale>\n    /**\n     * @cfg {String} minText\n     * The error text to display when the entered time is before {@link #minValue}.\n     */\n    minText : \"The time in this field must be equal to or after {0}\",\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} maxText\n     * The error text to display when the entered time is after {@link #maxValue}.\n     */\n    maxText : \"The time in this field must be equal to or before {0}\",\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} invalidText\n     * The error text to display when the time in the field is invalid.\n     */\n    invalidText : \"{0} is not a valid time\",\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} [format=undefined]\n     * The default time format string which can be overriden for localization support. The format must be valid\n     * according to {@link Ext.Date#parse}.\n     *\n     * Defaults to `'g:i A'`, e.g., `'3:15 PM'`. For 24-hour time format try `'H:i'` instead.\n     */\n    format : \"g:i A\",\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} [submitFormat=undefined]\n     * The date format string which will be submitted to the server. The format must be valid according to\n     * {@link Ext.Date#parse}.\n     *\n     * Defaults to {@link #format}.\n     */\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} altFormats\n     * Multiple date formats separated by \"|\" to try when parsing a user input value and it doesn't match the defined\n     * format.\n     */\n    altFormats : \"g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H|gi a|hi a|giA|hiA|gi A|hi A\",\n    //</locale>\n\n    /**\n     * @cfg {Number} increment\n     * The number of minutes between each time value in the list.\n     */\n    increment: 15,\n\n    /**\n     * @cfg {Number} pickerMaxHeight\n     * The maximum height of the {@link Ext.picker.Time} dropdown.\n     */\n    pickerMaxHeight: 300,\n\n    /**\n     * @cfg {Boolean} selectOnTab\n     * Whether the Tab key should select the currently highlighted item.\n     */\n    selectOnTab: true,\n    \n    /**\n     * @cfg {Boolean} [snapToIncrement=false]\n     * Specify as `true` to enforce that only values on the {@link #increment} boundary are accepted.\n     */\n    snapToIncrement: false,\n\n    /**\n     * @private\n     * This is the date to use when generating time values in the absence of either minValue\n     * or maxValue.  Using the current date causes DST issues on DST boundary dates, so this is an\n     * arbitrary \"safe\" date that can be any date aside from DST boundary dates.\n     */\n    initDate: '1/1/2008',\n    initDateFormat: 'j/n/Y',\n    \n    ignoreSelection: 0,\n\n    queryMode: 'local',\n\n    displayField: 'disp',\n\n    valueField: 'date',\n\n    initComponent: function() {\n        var me = this,\n            min = me.minValue,\n            max = me.maxValue;\n        if (min) {\n            me.setMinValue(min);\n        }\n        if (max) {\n            me.setMaxValue(max);\n        }\n        me.displayTpl = new Ext.XTemplate(\n            '<tpl for=\".\">' +\n                '{[typeof values === \"string\" ? values : this.formatDate(values[\"' + me.displayField + '\"])]}' +\n                '<tpl if=\"xindex < xcount\">' + me.delimiter + '</tpl>' +\n            '</tpl>', {\n            formatDate: Ext.Function.bind(me.formatDate, me)\n        });\n        this.callParent();\n    },\n\n    /**\n     * @private\n     */\n    transformOriginalValue: function(value) {\n        if (Ext.isString(value)) {\n            return this.rawToValue(value);\n        }\n        return value;\n    },\n\n    /**\n     * @private\n     */\n    isEqual: function(v1, v2) {\n        return Ext.Date.isEqual(v1, v2);\n    },\n\n    /**\n     * Replaces any existing {@link #minValue} with the new time and refreshes the picker's range.\n     * @param {Date/String} value The minimum time that can be selected\n     */\n    setMinValue: function(value) {\n        var me = this,\n            picker = me.picker;\n        me.setLimit(value, true);\n        if (picker) {\n            picker.setMinValue(me.minValue);\n        }\n    },\n\n    /**\n     * Replaces any existing {@link #maxValue} with the new time and refreshes the picker's range.\n     * @param {Date/String} value The maximum time that can be selected\n     */\n    setMaxValue: function(value) {\n        var me = this,\n            picker = me.picker;\n        me.setLimit(value, false);\n        if (picker) {\n            picker.setMaxValue(me.maxValue);\n        }\n    },\n\n    /**\n     * @private\n     * Updates either the min or max value. Converts the user's value into a Date object whose\n     * year/month/day is set to the {@link #initDate} so that only the time fields are significant.\n     */\n    setLimit: function(value, isMin) {\n        var me = this,\n            d, val;\n        if (Ext.isString(value)) {\n            d = me.parseDate(value);\n        }\n        else if (Ext.isDate(value)) {\n            d = value;\n        }\n        if (d) {\n            val = Ext.Date.clearTime(new Date(me.initDate));\n            val.setHours(d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());\n        }\n        // Invalid min/maxValue config should result in a null so that defaulting takes over\n        else {\n            val = null;\n        }\n        me[isMin ? 'minValue' : 'maxValue'] = val;\n    },\n\n    rawToValue: function(rawValue) {\n        return this.parseDate(rawValue) || rawValue || null;\n    },\n\n    valueToRaw: function(value) {\n        return this.formatDate(this.parseDate(value));\n    },\n\n    /**\n     * Runs all of Time's validations and returns an array of any errors. Note that this first runs Text's validations,\n     * so the returned array is an amalgamation of all field errors. The additional validation checks are testing that\n     * the time format is valid, that the chosen time is within the {@link #minValue} and {@link #maxValue} constraints\n     * set.\n     * @param {Object} [value] The value to get errors for (defaults to the current field value)\n     * @return {String[]} All validation errors for this field\n     */\n    getErrors: function(value) {\n        var me = this,\n            format = Ext.String.format,\n            errors = me.callParent(arguments),\n            minValue = me.minValue,\n            maxValue = me.maxValue,\n            date;\n\n        value = me.formatDate(value || me.processRawValue(me.getRawValue()));\n\n        if (value === null || value.length < 1) { // if it's blank and textfield didn't flag it then it's valid\n             return errors;\n        }\n\n        date = me.parseDate(value);\n        if (!date) {\n            errors.push(format(me.invalidText, value, Ext.Date.unescapeFormat(me.format)));\n            return errors;\n        }\n\n        if (minValue && date < minValue) {\n            errors.push(format(me.minText, me.formatDate(minValue)));\n        }\n\n        if (maxValue && date > maxValue) {\n            errors.push(format(me.maxText, me.formatDate(maxValue)));\n        }\n\n        return errors;\n    },\n\n    formatDate: function() {\n        return Ext.form.field.Date.prototype.formatDate.apply(this, arguments);\n    },\n\n    /**\n     * @private\n     * Parses an input value into a valid Date object.\n     * @param {String/Date} value\n     */\n    parseDate: function(value) {\n        var me = this,\n            val = value,\n            altFormats = me.altFormats,\n            altFormatsArray = me.altFormatsArray,\n            i = 0,\n            len;\n\n        if (value && !Ext.isDate(value)) {\n            val = me.safeParse(value, me.format);\n\n            if (!val && altFormats) {\n                altFormatsArray = altFormatsArray || altFormats.split('|');\n                len = altFormatsArray.length;\n                for (; i < len && !val; ++i) {\n                    val = me.safeParse(value, altFormatsArray[i]);\n                }\n            }\n        }\n\n        // If configured to snap, snap resulting parsed Date to the closest increment.\n        if (val && me.snapToIncrement) {\n            val = new Date(Ext.Number.snap(val.getTime(), me.increment * 60 * 1000));\n        }\n        return val;\n    },\n\n    safeParse: function(value, format){\n        var me = this,\n            utilDate = Ext.Date,\n            parsedDate,\n            result = null;\n\n        if (utilDate.formatContainsDateInfo(format)) {\n            // assume we've been given a full date\n            result = utilDate.parse(value, format);\n        } else {\n            // Use our initial safe date\n            parsedDate = utilDate.parse(me.initDate + ' ' + value, me.initDateFormat + ' ' + format);\n            if (parsedDate) {\n                result = parsedDate;\n            }\n        }\n        return result;\n    },\n\n    // @private\n    getSubmitValue: function() {\n        var me = this,\n            format = me.submitFormat || me.format,\n            value = me.getValue();\n\n        return value ? Ext.Date.format(value, format) : null;\n    },\n\n    /**\n     * @private\n     * Creates the {@link Ext.picker.Time}\n     */\n    createPicker: function() {\n        var me = this,\n            picker;\n\n        me.listConfig = Ext.apply({\n            xtype: 'timepicker',\n            selModel: {\n                mode: 'SINGLE'\n            },\n            cls: undefined,\n            minValue: me.minValue,\n            maxValue: me.maxValue,\n            increment: me.increment,\n            format: me.format,\n            maxHeight: me.pickerMaxHeight\n        }, me.listConfig);\n        picker = me.callParent();\n        me.store = picker.store;\n        return picker;\n    },\n    \n    onItemClick: function(picker, record){\n        // The selection change events won't fire when clicking on the selected element. Detect it here.\n        var me = this,\n            selected = picker.getSelectionModel().getSelection();\n\n        if (selected.length > 0) {\n            selected = selected[0];\n            if (selected && Ext.Date.isEqual(record.get('date'), selected.get('date'))) {\n                me.collapse();\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Handles a time being selected from the Time picker.\n     */\n    onListSelectionChange: function(list, recordArray) {\n        var me = this,\n            record = recordArray[0],\n            val = record ? record.get('date') : null;\n            \n        if (!me.ignoreSelection) {\n            me.skipSync = true;\n            me.setValue(val);\n            me.skipSync = false;\n            me.fireEvent('select', me, val);\n            me.picker.clearHighlight();\n            me.collapse();\n            me.inputEl.focus();\n        }\n    },\n    \n    /**\n     * @private \n     * Synchronizes the selection in the picker to match the current value\n     */\n    syncSelection: function() {\n        var me = this,\n            picker = me.picker,\n            toSelect,\n            selModel,\n            value,\n            data, d, dLen, rec;\n            \n        if (picker && !me.skipSync) {\n            picker.clearHighlight();\n            value = me.getValue();\n            selModel = picker.getSelectionModel();\n            // Update the selection to match\n            me.ignoreSelection++;\n            if (value === null) {\n                selModel.deselectAll();\n            } else if(Ext.isDate(value)) {\n                // find value, select it\n                data = picker.store.data.items;\n                dLen = data.length;\n\n                for (d = 0; d < dLen; d++) {\n                    rec = data[d];\n\n                    if (Ext.Date.isEqual(rec.get('date'), value)) {\n                       toSelect = rec;\n                       break;\n                   }\n                }\n\n                selModel.select(toSelect);\n            }\n            me.ignoreSelection--;\n        }\n    },\n\n    postBlur: function() {\n        var me = this;\n\n        me.callParent(arguments);\n        me.setRawValue(me.formatDate(me.getValue()));\n    },\n\n    setValue: function() {\n\n        // Store MUST be created for parent setValue to function\n        this.getPicker();\n\n        this.callParent(arguments);\n    },\n\n    getValue: function() {\n        return this.parseDate(this.callParent(arguments));\n    }\n});\n\n/**\n * Internal utility class that provides default configuration for cell editing.\n * @private\n */\nExt.define('Ext.grid.CellEditor', {\n    extend: 'Ext.Editor',\n    constructor: function(config) {\n        config = Ext.apply({}, config);\n        \n        if (config.field) {\n            config.field.monitorTab = false;\n        }\n        this.callParent([config]);\n    },\n    \n    /**\n     * @private\n     * Hide the grid cell text when editor is shown.\n     *\n     * There are 2 reasons this needs to happen:\n     *\n     * 1. checkbox editor does not take up enough space to hide the underlying text.\n     *\n     * 2. When columnLines are turned off in browsers that don't support text-overflow:\n     *    ellipsis (firefox 6 and below and IE quirks), the text extends to the last pixel\n     *    in the cell, however the right border of the cell editor is always positioned 1px\n     *    offset from the edge of the cell (to give it the appearance of being \"inside\" the\n     *    cell.  This results in 1px of the underlying cell text being visible to the right\n     *    of the cell editor if the text is not hidden.\n     * \n     * We can't just hide the entire cell, because then treecolumn's icons would be hidden\n     * as well.  We also can't just set \"color: transparent\" to hide the text because it is\n     * not supported by IE8 and below.  The only remaining solution is to remove the text\n     * from the text node and then add it back when the editor is hidden.\n     */\n    onShow: function() {\n        var me = this,\n            innerCell = me.boundEl.first(),\n            lastChild,\n            textNode;\n\n        if (innerCell) {\n            lastChild = innerCell.dom.lastChild;\n            if(lastChild && lastChild.nodeType === 3) {\n                // if the cell has a text node, save a reference to it\n                textNode = me.cellTextNode = innerCell.dom.lastChild;\n                // save the cell text so we can add it back when we're done editing\n                me.cellTextValue = textNode.nodeValue;\n                // The text node has to have at least one character in it, or the cell borders\n                // in IE quirks mode will not show correctly, so let's use a non-breaking space.\n                textNode.nodeValue = '\\u00a0';\n            }\n        }\n        me.callParent(arguments);\n    },\n\n    /**\n     * @private\n     * Show the grid cell text when the editor is hidden by adding the text back to the text node\n     */\n    onHide: function() {\n        var me = this,\n            innerCell = me.boundEl.first();\n\n        if (innerCell && me.cellTextNode) {\n            me.cellTextNode.nodeValue = me.cellTextValue;\n            delete me.cellTextNode;\n            delete me.cellTextValue;\n        }\n        me.callParent(arguments);\n    },\n\n    /**\n     * @private\n     * Fix checkbox blur when it is clicked.\n     */\n    afterRender: function() {\n        var me = this,\n            field = me.field;\n\n        me.callParent(arguments);\n        if (field.isXType('checkboxfield')) {\n            field.mon(field.inputEl, {\n                mousedown: me.onCheckBoxMouseDown,\n                click: me.onCheckBoxClick,\n                scope: me\n            });\n        }\n    },\n    \n    /**\n     * @private\n     * Because when checkbox is clicked it loses focus  completeEdit is bypassed.\n     */\n    onCheckBoxMouseDown: function() {\n        this.completeEdit = Ext.emptyFn;\n    },\n    \n    /**\n     * @private\n     * Restore checkbox focus and completeEdit method.\n     */\n    onCheckBoxClick: function() {\n        delete this.completeEdit;\n        this.field.focus(false, 10);\n    },\n    \n    /**\n     * @private\n     * Realigns the Editor to the grid cell, or to the text node in the grid inner cell\n     * if the inner cell contains multiple child nodes.\n     */\n    realign: function(autoSize) {\n        var me = this,\n            boundEl = me.boundEl,\n            innerCell = boundEl.first(),\n            children = innerCell.dom.childNodes,\n            childCount = children.length,\n            offsets = Ext.Array.clone(me.offsets),\n            inputEl = me.field.inputEl,\n            lastChild, leftBound, rightBound, width;\n\n        // If the inner cell has more than one child, or the first child node is not a text node,\n        // let's assume this cell contains additional elements before the text node.\n        // This is the case for tree cells, but could also be used to accomodate grid cells that\n        // have a custom renderer that render, say, an icon followed by some text for example\n        // For now however, this support will only be used for trees.\n        if(me.isForTree && (childCount > 1 || (childCount === 1 && children[0].nodeType !== 3))) {\n            // get the inner cell's last child\n            lastChild = innerCell.last();\n            // calculate the left bound of the text node\n            leftBound = lastChild.getOffsetsTo(innerCell)[0] + lastChild.getWidth();\n            // calculate the right bound of the text node (this is assumed to be the right edge of\n            // the inner cell, since we are assuming the text node is always the last node in the\n            // inner cell)\n            rightBound = innerCell.getWidth();\n            // difference between right and left bound is the text node's allowed \"width\",\n            // this will be used as the width for the editor.\n            width = rightBound - leftBound;\n            // adjust width for column lines - this ensures the editor will be the same width\n            // regardless of columLines config\n            if(!me.editingPlugin.grid.columnLines) {\n                width --;\n            }\n            // set the editor's x offset to the left bound position\n            offsets[0] += leftBound;\n\n            me.addCls(Ext.baseCSSPrefix + 'grid-editor-on-text-node');\n        } else {\n            width = boundEl.getWidth() - 1;\n        }\n\n        if (autoSize === true) {\n            me.field.setWidth(width);\n        }\n\n        me.alignTo(boundEl, me.alignment, offsets);\n    },\n    \n    onEditorTab: function(e){\n        var field = this.field;\n        if (field.onEditorTab) {\n            field.onEditorTab(e);\n        }\n    },\n\n    alignment: \"tl-tl\",\n    hideEl : false,\n    cls: Ext.baseCSSPrefix + \"small-editor \" + Ext.baseCSSPrefix + \"grid-editor\",\n    shim: false,\n    shadow: false\n});\n\n/**\n * Component layout for grid column headers which have a title element at the top followed by content.\n * @private\n */\nExt.define('Ext.grid.ColumnComponentLayout', {\n    extend: 'Ext.layout.component.Auto',\n    alias: 'layout.columncomponent',\n\n    type: 'columncomponent',\n\n    setWidthInDom: true,\n\n    getContentHeight : function(ownerContext) {\n        // If we are a group header return container layout's contentHeight, else default to AutoComponent's answer\n        return this.owner.isGroupHeader ? ownerContext.getProp('contentHeight') : this.callParent(arguments);\n    },\n\n    calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {\n        var result = this.callParent(arguments);\n        if (this.owner.isGroupHeader) {\n            result += this.owner.titleEl.dom.offsetHeight;\n        }\n        return result;\n    },\n    \n    getContentWidth : function(ownerContext) {\n        // If we are a group header return container layout's contentHeight, else default to AutoComponent's answer\n        return this.owner.isGroupHeader ? ownerContext.getProp('contentWidth') : this.callParent(arguments);\n    },\n\n    calculateOwnerWidthFromContentWidth: function (ownerContext, contentWidth) {\n        return contentWidth + ownerContext.getPaddingInfo().width;\n    }\n});\n\n/**\n * @private\n *\n * This class is used only by the grid's HeaderContainer docked child.\n *\n * It adds the ability to shrink the vertical size of the inner container element back if a grouped\n * column header has all its child columns dragged out, and the whole HeaderContainer needs to shrink back down.\n *\n * Also, after every layout, after all headers have attained their 'stretchmax' height, it goes through and calls\n * `setPadding` on the columns so that they lay out correctly.\n */\nExt.define('Ext.grid.ColumnLayout', {\n    extend: 'Ext.layout.container.HBox',\n    alias: 'layout.gridcolumn',\n    type : 'gridcolumn',\n\n    reserveOffset: false,\n\n    firstHeaderCls: Ext.baseCSSPrefix + 'column-header-first',\n    lastHeaderCls: Ext.baseCSSPrefix + 'column-header-last',\n\n    initLayout: function() {\n        this.grid = this.owner.up('[scrollerOwner]');\n        this.callParent();\n    },\n\n    // Collect the height of the table of data upon layout begin\n    beginLayout: function (ownerContext) {\n        var me = this,\n            grid = me.grid,\n            view = grid.view,\n            i = 0,\n            items = me.getVisibleItems(),\n            len = items.length,\n            item;\n\n        ownerContext.gridContext = ownerContext.context.getCmp(me.grid);\n\n        // If we are one side of a locking grid, then if we are on the \"normal\" side, we have to grab the normal view\n        // for use in determining whether to subtract scrollbar width from available width.\n        // The locked side does not have scrollbars, so it should not look at the view.\n        if (grid.lockable) {\n            if (me.owner.up('tablepanel') === view.normalGrid) {\n                view = view.normalGrid.getView();\n            } else {\n                view = null;\n            }\n        }\n\n        me.callParent(arguments);\n\n        // Unstretch child items before the layout which stretches them.\n        for (; i < len; i++) {\n            item = items[i];\n            item.removeCls([me.firstHeaderCls, me.lastHeaderCls]);\n            item.el.setStyle({\n                height: 'auto'\n            });\n            item.titleEl.setStyle({\n                height: 'auto',\n                paddingTop: ''  // reset back to default padding of the style\n            });\n        }\n\n        // Add special first/last classes\n        if (len > 0) {\n            items[0].addCls(me.firstHeaderCls);\n            items[len - 1].addCls(me.lastHeaderCls);\n        }\n\n        // If the owner is the grid's HeaderContainer, and the UI displays old fashioned scrollbars and there is a rendered View with data in it,\n        // AND we are scrolling vertically:\n        // collect the View context to interrogate it for overflow, and possibly invalidate it if there is overflow\n        if (!me.owner.isHeader && Ext.getScrollbarSize().width && !grid.collapsed && view &&\n                view.table.dom && (view.autoScroll || view.overflowY)) {\n            ownerContext.viewContext = ownerContext.context.getCmp(view);\n        }\n    },\n\n    roundFlex: function(width) {\n        return Math.floor(width);\n    },\n\n    calculate: function(ownerContext) {\n        var me = this,\n            viewContext = ownerContext.viewContext,\n            tableHeight,\n            viewHeight;\n\n        me.callParent(arguments);\n\n        if (ownerContext.state.parallelDone) {\n            ownerContext.setProp('columnWidthsDone', true);\n        }\n\n        // If we have a viewContext (Only created if there is an existing <table> within the view, AND we are scolling vertically AND scrollbars take up space)\n        //     we are not already in the second pass, and we are not shrinkWrapping...\n        //     Then we have to see if we know enough to determine whether there is vertical opverflow so that we can\n        //     invalidate and loop back for the second pass with a narrower target width.\n        if (viewContext && !ownerContext.state.overflowAdjust.width && !ownerContext.gridContext.heightModel.shrinkWrap) {\n            tableHeight = viewContext.tableContext.getProp('height');\n            viewHeight = viewContext.getProp('height');\n\n            // Heights of both view and its table content have not both been published; we cannot complete\n            if (isNaN(tableHeight + viewHeight)) {\n                me.done = false;\n            }\n\n            // Heights have been published, and there is vertical overflow; invalidate with a width adjustment to allow for the scrollbar\n            else if (tableHeight >= viewHeight) {\n                ownerContext.gridContext.invalidate({\n                    after: function() {\n                        ownerContext.state.overflowAdjust = {\n                            width: Ext.getScrollbarSize().width,\n                            height: 0\n                        };\n                    }\n                });\n            }\n        }\n    },\n \n    completeLayout: function(ownerContext) {\n        var me = this,\n            owner = me.owner,\n            state = ownerContext.state,\n            needsInvalidate = false,\n            calculated = me.sizeModels.calculated,\n            childItems, len, i, childContext, item;\n\n        me.callParent(arguments);\n\n        // If we have not been through this already, and the owning Container is configured\n        // forceFit, is not a group column and and there is a valid width, then convert\n        // widths to flexes, and loop back.\n        if (!state.flexesCalculated && owner.forceFit && !owner.isHeader) {\n            childItems = ownerContext.childItems;\n            len = childItems.length;\n\n            for (i = 0; i < len; i++) {\n                childContext = childItems[i];\n                item = childContext.target;\n\n                // For forceFit, just use allocated width as the flex value, and the proportions\n                // will end up the same whatever HeaderContainer width they are being forced into.\n                if (item.width) {\n                    item.flex = ownerContext.childItems[i].flex = item.width;\n                    delete item.width;\n                    childContext.widthModel = calculated;\n                    needsInvalidate = true;\n                }\n            }\n\n            // Recalculate based upon all columns now being flexed instead of sized.\n            // Set flag, so that we do not do this infinitely\n            if (needsInvalidate) {\n                me.cacheFlexes(ownerContext);\n                ownerContext.invalidate({\n                    state: {\n                        flexesCalculated: true\n                    }\n                });\n            }\n        }\n    },\n\n    finalizeLayout: function() {\n        var me = this,\n            i = 0,\n            items,\n            len,\n            itemsHeight,\n            owner = me.owner,\n            titleEl = owner.titleEl;\n\n        // Set up padding in items\n        items = me.getVisibleItems();\n        len = items.length;\n        // header container's items take up the whole height\n        itemsHeight = owner.el.getViewSize().height;\n        if (titleEl) {\n        // if owner is a grouped column with children, we need to subtract the titleEl's height\n        // to determine the remaining available height for the child items\n            itemsHeight -= titleEl.getHeight();\n        }\n        for (; i < len; i++) {\n            items[i].setPadding(itemsHeight);\n        }\n    },\n\n    // FIX: when flexing we actually don't have enough space as we would\n    // typically because of the scrollOffset on the GridView, must reserve this\n    publishInnerCtSize: function(ownerContext) {\n        var me = this,\n            size = ownerContext.state.boxPlan.targetSize,\n            cw = ownerContext.peek('contentWidth'),\n            view;\n\n        // InnerCt MUST stretch to accommodate all columns so that left/right scrolling is enabled in the header container.\n        if ((cw != null) && !me.owner.isHeader) {\n            size.width = cw;\n\n            // innerCt must also encompass any vertical scrollbar width if there may be one\n            view = me.owner.ownerCt.view;\n            if (view.autoScroll || view.overflowY) {\n                size.width += Ext.getScrollbarSize().width;\n            }\n        }\n\n        return me.callParent(arguments);\n    }\n});\n\n/**\n * This class is used internally to provide a single interface when using\n * a locking grid. Internally, the locking grid creates two separate grids,\n * so this class is used to map calls appropriately.\n * @private\n */\nExt.define('Ext.grid.LockingView', {\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    eventRelayRe: /^(beforeitem|beforecontainer|item|container|cell)/,\n\n    constructor: function(config){\n        var me = this,\n            eventNames = [],\n            eventRe = me.eventRelayRe,\n            locked = config.locked.getView(),\n            normal = config.normal.getView(),\n            events,\n            event;\n\n        Ext.apply(me, {\n            lockedView: locked,\n            normalView: normal,\n            lockedGrid: config.locked,\n            normalGrid: config.normal,\n            panel: config.panel\n        });\n        me.mixins.observable.constructor.call(me, config);\n\n        // relay events\n        events = locked.events;\n        for (event in events) {\n            if (events.hasOwnProperty(event) && eventRe.test(event)) {\n                eventNames.push(event);\n            }\n        }\n        me.relayEvents(locked, eventNames);\n        me.relayEvents(normal, eventNames);\n\n        normal.on({\n            scope: me,\n            itemmouseleave: me.onItemMouseLeave,\n            itemmouseenter: me.onItemMouseEnter\n        });\n\n        locked.on({\n            scope: me,\n            itemmouseleave: me.onItemMouseLeave,\n            itemmouseenter: me.onItemMouseEnter\n        });\n    },\n\n    getGridColumns: function() {\n        var cols = this.lockedGrid.headerCt.getGridColumns();\n        return cols.concat(this.normalGrid.headerCt.getGridColumns());\n    },\n\n    getEl: function(column){\n        return this.getViewForColumn(column).getEl();\n    },\n\n    getViewForColumn: function(column) {\n        var view = this.lockedView,\n            inLocked;\n\n        view.headerCt.cascade(function(col){\n            if (col === column) {\n                inLocked = true;\n                return false;\n            }\n        });\n\n        return inLocked ? view : this.normalView;\n    },\n\n    onItemMouseEnter: function(view, record){\n        var me = this,\n            locked = me.lockedView,\n            other = me.normalView,\n            item;\n\n        if (view.trackOver) {\n            if (view !== locked) {\n                other = locked;\n            }\n            item = other.getNode(record);\n            other.highlightItem(item);\n        }\n    },\n\n    onItemMouseLeave: function(view, record){\n        var me = this,\n            locked = me.lockedView,\n            other = me.normalView;\n\n        if (view.trackOver) {\n            if (view !== locked) {\n                other = locked;\n            }\n            other.clearHighlight();\n        }\n    },\n\n    relayFn: function(name, args){\n        args = args || [];\n\n        var view = this.lockedView;\n        view[name].apply(view, args || []);\n        view = this.normalView;\n        view[name].apply(view, args || []);\n    },\n\n    getSelectionModel: function(){\n        return this.panel.getSelectionModel();\n    },\n\n    getStore: function(){\n        return this.panel.store;\n    },\n\n    getNode: function(nodeInfo){\n        // default to the normal view\n        return this.normalView.getNode(nodeInfo);\n    },\n\n    getCell: function(record, column){\n        var view = this.getViewForColumn(column),\n            row;\n\n        row = view.getNode(record);\n        return Ext.fly(row).down(column.getCellSelector());\n    },\n\n    getRecord: function(node){\n        var result = this.lockedView.getRecord(node);\n        if (!node) {\n            result = this.normalView.getRecord(node);\n        }\n        return result;\n    },\n\n    addElListener: function(eventName, fn, scope){\n        this.relayFn('addElListener', arguments);\n    },\n\n    refreshNode: function(){\n        this.relayFn('refreshNode', arguments);\n    },\n\n    refresh: function(){\n        this.relayFn('refresh', arguments);\n    },\n\n    bindStore: function(){\n        this.relayFn('bindStore', arguments);\n    },\n\n    addRowCls: function(){\n        this.relayFn('addRowCls', arguments);\n    },\n\n    removeRowCls: function(){\n        this.relayFn('removeRowCls', arguments);\n    }\n\n});\n\n/**\n *  Component layout for {@link Ext.view.Table}\n *  @private\n * \n */\nExt.define('Ext.view.TableLayout', {\n    extend: 'Ext.layout.component.Auto',\n\n    alias: ['layout.tableview'],\n    type: 'tableview',\n\n    beginLayout: function(ownerContext) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        // Grab ContextItem for the driving HeaderContainer and the table only if their is a table to size\n        if (me.owner.table.dom) {\n            ownerContext.tableContext = ownerContext.getEl(me.owner.table);\n\n            // Grab a ContextItem for the header container\n            ownerContext.headerContext = ownerContext.context.getCmp(me.headerCt);\n        }\n    },\n\n    calculate: function(ownerContext) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        if (ownerContext.tableContext) {\n            if (ownerContext.state.columnWidthsSynced) {\n                if (ownerContext.hasProp('columnWidthsFlushed')) {\n                    ownerContext.tableContext.setHeight(ownerContext.tableContext.el.dom.offsetHeight, false);\n                } else {\n                    me.done = false;\n                }\n            } else {\n                if (ownerContext.headerContext.hasProp('columnWidthsDone')) {\n                    ownerContext.context.queueFlush(me);\n                    ownerContext.state.columnWidthsSynced = true;\n                }\n\n                // Either our base class (Auto) needs to measureContentHeight\n                // if we are shrinkWrapHeight OR we need to measure the table\n                // element height if we are not shrinkWrapHeight\n                me.done = false;\n            }\n        }\n    },\n\n    measureContentHeight: function(ownerContext) {\n        // Only able to produce a valid contentHeight if we have flushed all column widths to the table (or there's no table at all).\n        if (!ownerContext.headerContext || ownerContext.hasProp('columnWidthsFlushed')) {\n            return this.callParent(arguments);\n        }\n    },\n\n    flush: function() {\n        var me = this,\n            context = me.ownerContext.context,\n            columns = me.headerCt.getGridColumns(),\n            i = 0, len = columns.length,\n            el = me.owner.el,\n            tableWidth = 0,\n            colWidth;\n\n        // So that the setProp can trigger this layout.\n        context.currentLayout = me;\n\n        // Set column width corresponding to each header\n        for (i = 0; i < len; i++) {\n            colWidth = columns[i].hidden ? 0 : context.getCmp(columns[i]).props.width;\n            tableWidth += colWidth;\n\n            // Grab the col and set the width.\n            // CSS class is generated in TableChunker.\n            // Select composites because there may be several chunks.\n            el.select(me.getColumnSelector(columns[i])).setWidth(colWidth);\n        }\n        el.select('table.' + Ext.baseCSSPrefix + 'grid-table-resizer').setWidth(tableWidth);\n\n        // Now we can measure contentHeight if necessary (if we are height shrinkwrapped)\n        me.ownerContext.setProp('columnWidthsFlushed', true);\n    },\n    \n    finishedLayout: function(){\n        var me = this,\n            first;\n            \n        me.callParent(arguments);   \n        // In FF, in some cases during a resize or column hide/show, the <td> cells in\n        // the grid won't respond to the new width set in the <th> at the top. So we\n        // force a reflow of the table which seems to correct it. Related to EXTJSIV-6410\n        if (Ext.isGecko) {\n            first = me.headerCt.getGridColumns()[0];\n            if (first) {\n                first = me.owner.el.down(me.getColumnSelector(first));\n                if (first) {\n                    first.setStyle('display', 'none');\n                    first.dom.scrollWidth;\n                    first.setStyle('display', '');\n                }\n            }\n        } \n    },\n\n    getColumnSelector: function(column) {\n        return 'th.' + Ext.baseCSSPrefix + 'grid-col-resizer-' + column.id;\n    }\n});\n\n/**\n * This class encapsulates the user interface for a tabular data set.\n * It acts as a centralized manager for controlling the various interface\n * elements of the view. This includes handling events, such as row and cell\n * level based DOM events. It also reacts to events from the underlying {@link Ext.selection.Model}\n * to provide visual feedback to the user.\n *\n * This class does not provide ways to manipulate the underlying data of the configured\n * {@link Ext.data.Store}.\n *\n * This is the base class for both {@link Ext.grid.View} and {@link Ext.tree.View} and is not\n * to be used directly.\n */\nExt.define('Ext.view.Table', {\n    extend: 'Ext.view.View',\n    alias: 'widget.tableview',\n    uses: [\n        'Ext.view.TableLayout',\n        'Ext.view.TableChunker',\n        'Ext.util.DelayedTask',\n        'Ext.util.MixedCollection'\n    ],\n\n    componentLayout: 'tableview',\n\n    baseCls: Ext.baseCSSPrefix + 'grid-view',\n\n    // row\n    itemSelector: 'tr.' + Ext.baseCSSPrefix + 'grid-row',\n    // cell\n    cellSelector: 'td.' + Ext.baseCSSPrefix + 'grid-cell',\n\n    // keep a separate rowSelector, since we may need to select the actual row elements\n    rowSelector: 'tr.' + Ext.baseCSSPrefix + 'grid-row',\n\n    /**\n     * @cfg {String} [firstCls='x-grid-cell-first']\n     * A CSS class to add to the *first* cell in every row to enable special styling for the first column.\n     * If no styling is needed on the first column, this may be configured as `null`.\n     */\n    firstCls: Ext.baseCSSPrefix + 'grid-cell-first',\n\n    /**\n     * @cfg {String} [lastCls='x-grid-cell-last']\n     * A CSS class to add to the *last* cell in every row to enable special styling for the last column.\n     * If no styling is needed on the last column, this may be configured as `null`.\n     */\n    lastCls: Ext.baseCSSPrefix + 'grid-cell-last',\n\n    headerRowSelector: 'tr.' + Ext.baseCSSPrefix + 'grid-header-row',\n\n    selectedItemCls: Ext.baseCSSPrefix + 'grid-row-selected',\n    selectedCellCls: Ext.baseCSSPrefix + 'grid-cell-selected',\n    focusedItemCls: Ext.baseCSSPrefix + 'grid-row-focused',\n    overItemCls: Ext.baseCSSPrefix + 'grid-row-over',\n    altRowCls:   Ext.baseCSSPrefix + 'grid-row-alt',\n    rowClsRe: new RegExp('(?:^|\\\\s*)' + Ext.baseCSSPrefix + 'grid-row-(first|last|alt)(?:\\\\s+|$)', 'g'),\n    cellRe: new RegExp(Ext.baseCSSPrefix + 'grid-cell-([^\\\\s]+) ', ''),\n\n    // cfg docs inherited\n    trackOver: true,\n\n    /**\n     * Override this function to apply custom CSS classes to rows during rendering. This function should return the\n     * CSS class name (or empty string '' for none) that will be added to the row's wrapping div. To apply multiple\n     * class names, simply return them space-delimited within the string (e.g. 'my-class another-class').\n     * Example usage:\n     *\n     *     viewConfig: {\n     *         getRowClass: function(record, rowIndex, rowParams, store){\n     *             return record.get(\"valid\") ? \"row-valid\" : \"row-error\";\n     *         }\n     *     }\n     *\n     * @param {Ext.data.Model} record The record corresponding to the current row.\n     * @param {Number} index The row index.\n     * @param {Object} rowParams **DEPRECATED.** For row body use the\n     * {@link Ext.grid.feature.RowBody#getAdditionalData getAdditionalData} method of the rowbody feature.\n     * @param {Ext.data.Store} store The store this grid is bound to\n     * @return {String} a CSS class name to add to the row.\n     * @method\n     */\n    getRowClass: null,\n\n    /**\n     * @cfg {Boolean} stripeRows\n     * True to stripe the rows.\n     *\n     * This causes the CSS class **`x-grid-row-alt`** to be added to alternate rows of\n     * the grid. A default CSS rule is provided which sets a background color, but you can override this\n     * with a rule which either overrides the **background-color** style using the `!important`\n     * modifier, or which uses a CSS selector of higher specificity.\n     */\n    stripeRows: true,\n    \n    /**\n     * @cfg {Boolean} markDirty\n     * True to show the dirty cell indicator when a cell has been modified.\n     */\n    markDirty : true,\n\n    /**\n     * @cfg {Boolean} enableTextSelection\n     * True to enable text selections.\n     */\n\n    /**\n     * @private\n     * Simple initial tpl for TableView just to satisfy the validation within AbstractView.initComponent.\n     */\n    initialTpl: '<div></div>',\n\n    initComponent: function() {\n        var me = this,\n            scroll = me.scroll;\n\n        /**\n         * @private\n         * @property {Ext.dom.AbstractElement.Fly} table\n         * A flyweight Ext.Element which encapsulates a reference to the transient `<table>` element within this View.\n         * *Note that the `dom` reference will not be present until the first data refresh*\n         */\n        me.table = new Ext.dom.Element.Fly();\n        me.table.id = me.id + 'gridTable';\n\n        // Scrolling within a TableView is controlled by the scroll config of its owning GridPanel\n        // It must see undefined in this property in order to leave the scroll styles alone at afterRender time\n        me.autoScroll = undefined;\n\n        // Convert grid scroll config to standard Component scrolling configurations.\n        if (scroll === true || scroll === 'both') {\n            me.autoScroll = true;\n        } else if (scroll === 'horizontal') {\n            me.overflowX = 'auto';\n        } else if (scroll === 'vertical') {\n            me.overflowY = 'auto';\n        }\n        me.selModel.view = me;\n        me.headerCt.view = me;\n        me.headerCt.markDirty = me.markDirty;\n\n        // Features need a reference to the grid.\n        me.initFeatures(me.grid);\n        delete me.grid;\n\n        // The real tpl is generated, but AbstractView.initComponent insists upon the presence of a fully instantiated XTemplate at construction time.\n        me.tpl = me.getTpl('initialTpl');\n        me.callParent();\n    },\n    \n    /**\n     * @private\n     * Move a grid column from one position to another\n     * @param {Number} fromIdx The index from which to move columns\n     * @param {Number} toIdx The index at which to insert columns.\n     * @param {Number} [colsToMove=1] The number of columns to move beginning at the `fromIdx`\n     */\n    moveColumn: function(fromIdx, toIdx, colsToMove) {\n        var me = this,\n            fragment = (colsToMove > 1) ? document.createDocumentFragment() : undefined,\n            destinationCellIdx = toIdx,\n            colCount = me.getGridColumns().length,\n            lastIdx = colCount - 1,\n            doFirstLastClasses = (me.firstCls || me.lastCls) && (toIdx === 0 || toIdx == colCount || fromIdx === 0 || fromIdx == lastIdx),\n            i,\n            j,\n            rows, len, tr, headerRows;\n\n        if (me.rendered) {\n            // Use select here. In most cases there will only be one row. In\n            // the case of a grouping grid, each group also has a header.\n            headerRows = me.el.query(me.headerRowSelector);\n            rows = me.el.query(me.rowSelector);\n\n            if (toIdx > fromIdx && fragment) {\n                destinationCellIdx -= colsToMove;\n            }\n\n            // Move the column sizing header to match\n            for (i = 0, len = headerRows.length; i < len; ++i) {\n                tr = headerRows[i];\n                if (fragment) {\n                    for (j = 0; j < colsToMove; j++) {\n                        fragment.appendChild(tr.cells[fromIdx]);\n                    }\n                    tr.insertBefore(fragment, tr.cells[destinationCellIdx] || null);\n                } else {\n                    tr.insertBefore(tr.cells[fromIdx], tr.cells[destinationCellIdx] || null);\n                }\n            }\n\n            for (i = 0, len = rows.length; i < len; i++) {\n                tr = rows[i];\n\n                // Keep first cell class and last cell class correct *only if needed*\n                if (doFirstLastClasses) {\n\n                    if (fromIdx === 0) {\n                        Ext.fly(tr.cells[0]).removeCls(me.firstCls);\n                        Ext.fly(tr.cells[1]).addCls(me.firstCls);\n                    } else if (fromIdx === lastIdx) {\n                        Ext.fly(tr.cells[lastIdx]).removeCls(me.lastCls);\n                        Ext.fly(tr.cells[lastIdx - 1]).addCls(me.lastCls);\n                    }\n                    if (toIdx === 0) {\n                        Ext.fly(tr.cells[0]).removeCls(me.firstCls);\n                        Ext.fly(tr.cells[fromIdx]).addCls(me.firstCls);\n                    } else if (toIdx === colCount) {\n                        Ext.fly(tr.cells[lastIdx]).removeCls(me.lastCls);\n                        Ext.fly(tr.cells[fromIdx]).addCls(me.lastCls);\n                    }\n                }\n\n                if (fragment) {\n                    for (j = 0; j < colsToMove; j++) {\n                        fragment.appendChild(tr.cells[fromIdx]);\n                    }\n                    tr.insertBefore(fragment, tr.cells[destinationCellIdx] || null);\n                } else {\n                    tr.insertBefore(tr.cells[fromIdx], tr.cells[destinationCellIdx] || null);\n                }\n            }\n            me.setNewTemplate();\n        }\n    },\n\n    // scroll the view to the top\n    scrollToTop: Ext.emptyFn,\n\n    /**\n     * Add a listener to the main view element. It will be destroyed with the view.\n     * @private\n     */\n    addElListener: function(eventName, fn, scope){\n        this.mon(this, eventName, fn, scope, {\n            element: 'el'\n        });\n    },\n\n    /**\n     * Get the columns used for generating a template via TableChunker.\n     * See {@link Ext.grid.header.Container#getGridColumns}.\n     * @private\n     */\n    getGridColumns: function() {\n        return this.headerCt.getGridColumns();\n    },\n\n    /**\n     * Get a leaf level header by index regardless of what the nesting\n     * structure is.\n     * @private\n     * @param {Number} index The index\n     */\n    getHeaderAtIndex: function(index) {\n        return this.headerCt.getHeaderAtIndex(index);\n    },\n\n    /**\n     * Get the cell (td) for a particular record and column.\n     * @param {Ext.data.Model} record\n     * @param {Ext.grid.column.Column} column\n     * @private\n     */\n    getCell: function(record, column) {\n        var row = this.getNode(record);\n        return Ext.fly(row).down(column.getCellSelector());\n    },\n\n    /**\n     * Get a reference to a feature\n     * @param {String} id The id of the feature\n     * @return {Ext.grid.feature.Feature} The feature. Undefined if not found\n     */\n    getFeature: function(id) {\n        var features = this.featuresMC;\n        if (features) {\n            return features.get(id);\n        }\n    },\n\n    /**\n     * Initializes each feature and bind it to this view.\n     * @private\n     */\n    initFeatures: function(grid) {\n        var me = this,\n            i,\n            features,\n            feature,\n            len;\n\n        me.featuresMC = new Ext.util.MixedCollection();\n        features = me.features = me.constructFeatures();\n        len = features ? features.length : 0;\n        for (i = 0; i < len; i++) {\n            feature = features[i];\n\n            // inject a reference to view and grid - Features need both\n            feature.view = me;\n            feature.grid = grid;\n            me.featuresMC.add(feature);\n            feature.init();\n        }\n    },\n\n    /**\n     * @private\n     * Converts the features array as configured, into an array of instantiated Feature objects.\n     * \n     * This is borrowed by Lockable which clones and distributes Features to both child grids of a locking grid.\n     * \n     * Must have no side effects other than Feature instantiation.\n     * \n     * MUST NOT update the this.features property, and MUST NOT update the instantiated Features.\n     */\n    constructFeatures: function() {\n        var me = this,\n            features = me.features,\n            feature,\n            result,\n            i = 0, len;\n        \n        if (features) {\n            result = [];\n            len = features.length;\n            for (; i < len; i++) {\n                feature = features[i];\n                if (!feature.isFeature) {\n                    feature = Ext.create('feature.' + feature.ftype, feature);\n                }\n                result[i] = feature;\n            }\n        }\n        return result;\n    },\n\n    /**\n     * Gives features an injection point to attach events to the markup that\n     * has been created for this view.\n     * @private\n     */\n    attachEventsForFeatures: function() {\n        var features = this.features,\n            ln       = features.length,\n            i        = 0;\n\n        for (; i < ln; i++) {\n            if (features[i].isFeature) {\n                features[i].attachEvents();\n            }\n        }\n    },\n\n    afterRender: function() {\n        var me = this;\n        me.callParent();\n\n        if (!me.enableTextSelection) {\n            me.el.unselectable();\n        }\n        me.attachEventsForFeatures();\n    },\n\n    // Private template method implemented starting at the AbstractView class.\n    onViewScroll: function(e, t) {\n        this.callParent(arguments);\n        this.fireEvent('bodyscroll', e, t);\n    },\n\n    /**\n     * Uses the headerCt (Which is the repository of all information relating to Column definitions)\n     * to transform data from dataIndex keys in a record to headerId keys in each header and then run\n     * them through each feature to get additional data for variables they have injected into the view template.\n     * @private\n     */\n    prepareData: function(data, idx, record) {\n        var me       = this,\n            result   = me.headerCt.prepareData(data, idx, record, me, me.ownerCt),\n            features = me.features,\n            ln       = features.length,\n            i        = 0,\n            feature;\n\n        for (; i < ln; i++) {\n            feature = features[i];\n            if (feature.isFeature) {\n                Ext.apply(result, feature.getAdditionalData(data, idx, record, result, me));\n            }\n        }\n\n        return result;\n    },\n\n    // TODO: Refactor headerCt dependency here to colModel\n    collectData: function(records, startIndex) {\n        var me = this,\n            preppedRecords = me.callParent(arguments),\n            headerCt  = me.headerCt,\n            fullWidth = headerCt.getFullWidth(),\n            features  = me.features,\n            ln = features.length,\n            o = {\n                rows: preppedRecords,\n                fullWidth: fullWidth\n            },\n            i  = 0,\n            feature,\n            j = 0,\n            jln,\n            rowParams,\n            rec,\n            cls;\n\n        jln = preppedRecords.length;\n        // process row classes, rowParams has been deprecated and has been moved\n        // to the individual features that implement the behavior.\n        if (me.getRowClass) {\n            for (; j < jln; j++) {\n                rowParams = {};\n                rec = preppedRecords[j];\n                cls = rec.rowCls || '';\n                rec.rowCls = this.getRowClass(records[j], j, rowParams, me.store) + ' ' + cls;\n                if (rowParams.alt) {\n                    Ext.Error.raise(\"The getRowClass alt property is no longer supported.\");\n                }\n                if (rowParams.tstyle) {\n                    Ext.Error.raise(\"The getRowClass tstyle property is no longer supported.\");\n                }\n                if (rowParams.cells) {\n                    Ext.Error.raise(\"The getRowClass cells property is no longer supported.\");\n                }\n                if (rowParams.body) {\n                    Ext.Error.raise(\"The getRowClass body property is no longer supported. Use the getAdditionalData method of the rowbody feature.\");\n                }\n                if (rowParams.bodyStyle) {\n                    Ext.Error.raise(\"The getRowClass bodyStyle property is no longer supported.\");\n                }\n                if (rowParams.cols) {\n                    Ext.Error.raise(\"The getRowClass cols property is no longer supported.\");\n                }\n            }\n        }\n        // currently only one feature may implement collectData. This is to modify\n        // what's returned to the view before its rendered\n        for (; i < ln; i++) {\n            feature = features[i];\n            if (feature.isFeature && feature.collectData && !feature.disabled) {\n                o = feature.collectData(records, preppedRecords, startIndex, fullWidth, o);\n                break;\n            }\n        }\n        return o;\n    },\n\n    // Private. Called when the table changes height.\n    // For example, see examples/grid/group-summary-grid.html\n    // If we have flexed column headers, we need to update the header layout\n    // because it may have to accommodate (or cease to accommodate) a vertical scrollbar.\n    // Only do this on platforms which have a space-consuming scrollbar.\n    // Only do it when vertical scrolling is enabled.\n    refreshSize: function() {\n        var me = this,\n            cmp;\n\n        // On every update of the layout system due to data update, capture the table's DOM in our private flyweight\n        me.table.attach(me.el.child('table', true));\n\n        if (!me.hasLoadingHeight) {\n            cmp = me.up('tablepanel');\n\n            // Suspend layouts in case the superclass requests a layout. We might too, so they\n            // must be coalescsed.\n            Ext.suspendLayouts();\n\n            me.callParent();\n\n            // If the OS displays scrollbars, and we are overflowing vertically, ensure the\n            // HeaderContainer accounts for the scrollbar.\n            if (cmp && Ext.getScrollbarSize().width && (me.autoScroll || me.overflowY)) {\n                cmp.updateLayout();\n            }\n\n            Ext.resumeLayouts(true);\n        }\n    },\n\n    /**\n     * Set a new template based on the current columns displayed in the grid.\n     * @private\n     */\n    setNewTemplate: function() {\n        var me = this,\n            columns = me.headerCt.getColumnsForTpl(true);\n\n        // Template generation requires the rowCount as well as the column definitions and features.\n        me.tpl = me.getTableChunker().getTableTpl({\n            rowCount: me.store.getCount(),\n            columns: columns,\n            features: me.features,\n            enableTextSelection: me.enableTextSelection\n        });\n    },\n\n    /**\n     * Returns the configured chunker or default of Ext.view.TableChunker\n     */\n    getTableChunker: function() {\n        return this.chunker || Ext.view.TableChunker;\n    },\n\n    /**\n     * Adds a CSS Class to a specific row.\n     * @param {HTMLElement/String/Number/Ext.data.Model} rowInfo An HTMLElement, index or instance of a model\n     * representing this row\n     * @param {String} cls\n     */\n    addRowCls: function(rowInfo, cls) {\n        var row = this.getNode(rowInfo);\n        if (row) {\n            Ext.fly(row).addCls(cls);\n        }\n    },\n\n    /**\n     * Removes a CSS Class from a specific row.\n     * @param {HTMLElement/String/Number/Ext.data.Model} rowInfo An HTMLElement, index or instance of a model\n     * representing this row\n     * @param {String} cls\n     */\n    removeRowCls: function(rowInfo, cls) {\n        var row = this.getNode(rowInfo);\n        if (row) {\n            Ext.fly(row).removeCls(cls);\n        }\n    },\n\n    // GridSelectionModel invokes onRowSelect as selection changes\n    onRowSelect : function(rowIdx) {\n        this.addRowCls(rowIdx, this.selectedItemCls);\n    },\n\n    // GridSelectionModel invokes onRowDeselect as selection changes\n    onRowDeselect : function(rowIdx) {\n        var me = this;\n\n        me.removeRowCls(rowIdx, me.selectedItemCls);\n        me.removeRowCls(rowIdx, me.focusedItemCls);\n    },\n\n    onCellSelect: function(position) {\n        var cell = this.getCellByPosition(position, true);\n        if (cell) {\n            Ext.fly(cell).addCls(this.selectedCellCls);\n        }\n    },\n\n    onCellDeselect: function(position) {\n        var cell = this.getCellByPosition(position, true);\n        if (cell) {\n            Ext.fly(cell).removeCls(this.selectedCellCls);\n        }\n\n    },\n\n    onCellFocus: function(position) {\n        this.focusCell(position);\n    },\n\n    getCellByPosition: function(position, returnDom) {\n        if (position) {\n            var node   = this.getNode(position.row),\n                header = this.headerCt.getHeaderAtIndex(position.column);\n\n            if (header && node) {\n                return Ext.fly(node).down(header.getCellSelector(), returnDom);\n            }\n        }\n        return false;\n    },\n\n    // GridSelectionModel invokes onRowFocus to 'highlight'\n    // the last row focused\n    onRowFocus: function(rowIdx, highlight, supressFocus) {\n        var me = this;\n\n        if (highlight) {\n            me.addRowCls(rowIdx, me.focusedItemCls);\n            if (!supressFocus) {\n                me.focusRow(rowIdx);\n            }\n            //this.el.dom.setAttribute('aria-activedescendant', row.id);\n        } else {\n            me.removeRowCls(rowIdx, me.focusedItemCls);\n        }\n    },\n\n    /**\n     * Focuses a particular row and brings it into view. Will fire the rowfocus event.\n     * @param {HTMLElement/String/Number/Ext.data.Model} rowIdx\n     * An HTMLElement template node, index of a template node, the id of a template node or the\n     * record associated with the node.\n     */\n    focusRow: function(rowIdx) {\n        var me         = this,\n            row        = me.getNode(rowIdx),\n            el         = me.el,\n            adjustment = 0,\n            panel      = me.ownerCt,\n            rowRegion,\n            elTop,\n            elBottom,\n            record;\n\n        if (row && el) {\n            // Viewable region must not include scrollbars, so use\n            // DOM clientHeight to determine height\n            elTop = el.getY();\n            elBottom = elTop + el.dom.clientHeight;\n            rowRegion = Ext.fly(row).getRegion();\n            // row is above\n            if (rowRegion.top < elTop) {\n                adjustment = rowRegion.top - elTop;\n            // row is below\n            } else if (rowRegion.bottom > elBottom) {\n                adjustment = rowRegion.bottom - elBottom;\n            }\n            record = me.getRecord(row);\n            rowIdx = me.store.indexOf(record);\n\n            if (adjustment) {\n                panel.scrollByDeltaY(adjustment);\n            }\n            me.fireEvent('rowfocus', record, row, rowIdx);\n        }\n    },\n\n    focusCell: function(position) {\n        var me          = this,\n            cell        = me.getCellByPosition(position),\n            el          = me.el,\n            adjustmentY = 0,\n            adjustmentX = 0,\n            elRegion    = el.getRegion(),\n            panel       = me.ownerCt,\n            cellRegion,\n            record;\n\n        // Viewable region must not include scrollbars, so use\n        // DOM client dimensions\n        elRegion.bottom = elRegion.top + el.dom.clientHeight;\n        elRegion.right = elRegion.left + el.dom.clientWidth;\n        if (cell) {\n            cellRegion = cell.getRegion();\n            // cell is above\n            if (cellRegion.top < elRegion.top) {\n                adjustmentY = cellRegion.top - elRegion.top;\n            // cell is below\n            } else if (cellRegion.bottom > elRegion.bottom) {\n                adjustmentY = cellRegion.bottom - elRegion.bottom;\n            }\n\n            // cell is left\n            if (cellRegion.left < elRegion.left) {\n                adjustmentX = cellRegion.left - elRegion.left;\n            // cell is right\n            } else if (cellRegion.right > elRegion.right) {\n                adjustmentX = cellRegion.right - elRegion.right;\n            }\n\n            if (adjustmentY) {\n                panel.scrollByDeltaY(adjustmentY);\n            }\n            if (adjustmentX) {\n                panel.scrollByDeltaX(adjustmentX);\n            }\n            el.focus();\n            me.fireEvent('cellfocus', record, cell, position);\n        }\n    },\n\n    /**\n     * Scrolls by delta. This affects this individual view ONLY and does not\n     * synchronize across views or scrollers.\n     * @param {Number} delta\n     * @param {String} [dir] Valid values are scrollTop and scrollLeft. Defaults to scrollTop.\n     * @private\n     */\n    scrollByDelta: function(delta, dir) {\n        dir = dir || 'scrollTop';\n        var elDom = this.el.dom;\n        elDom[dir] = (elDom[dir] += delta);\n    },\n\n    // private\n    onUpdate : function(store, record, operation, changedFieldNames) {\n        var me = this,\n            index,\n            newRow, newAttrs, attLen, i, attName, oldRow, oldRowDom,\n            oldCells, newCells, len, i,\n            columns, overItemCls,\n            isHovered, row,\n            // See if an editing plugin is active.\n            isEditing = me.editingPlugin && me.editingPlugin.editing;\n\n        if (me.viewReady) {\n\n            index = me.store.indexOf(record);\n            columns = me.headerCt.getGridColumns();\n            overItemCls = me.overItemCls;\n\n            // If we have columns which may *need* updating (think lockable grid child with all columns either locked or unlocked)\n            // and the changed record is within our view, then update the view\n            if (columns.length && index > -1) {\n                newRow = me.bufferRender([record], index)[0];\n                oldRow = me.all.item(index);\n                if (oldRow) {\n                    oldRowDom = oldRow.dom;\n                    isHovered = oldRow.hasCls(overItemCls);\n\n                    // Copy new row attributes across. Use IE-specific method if possible.\n                    if (oldRowDom.mergeAttributes) {\n                        oldRowDom.mergeAttributes(newRow, true);\n                    } else {\n                        newAttrs = newRow.attributes;\n                        attLen = newAttrs.length;\n                        for (i = 0; i < attLen; i++) {\n                            attName = newAttrs[i].name;\n                            if (attName !== 'id') {\n                                oldRowDom.setAttribute(attName, newAttrs[i].value);\n                            }\n                        }\n                    }\n\n                    if (isHovered) {\n                        oldRow.addCls(overItemCls);\n                    }\n\n                    // Replace changed cells in the existing row structure with the new version from the rendered row.\n                    oldCells = oldRow.query(me.cellSelector);\n                    newCells = Ext.fly(newRow).query(me.cellSelector);\n                    len = newCells.length;\n                    // row is the element that contains the cells.  This will be a different element from oldRow when using a rowwrap feature     \n                    row = oldCells[0].parentNode;\n                    for (i = 0; i < len; i++) {\n                        // If the field at this column index was changed, or column has a custom renderer\n                        // (which means value could rely on any other changed field) the update the cell's content.\n                        if (me.shouldUpdateCell(columns[i], changedFieldNames)) {\n                            // If an editor plugin is active, we carefully replace just the *contents* of the cell.\n                            if (isEditing) {\n                                Ext.fly(oldCells[i]).syncContent(newCells[i]);\n                            }\n                            // Otherwise, we simply replace whole TDs with a new version\n                            else {\n                                row.insertBefore(newCells[i], oldCells[i]);\n                                row.removeChild(oldCells[i]);\n                            }\n                        }\n                    }\n                }\n                me.fireEvent('itemupdate', record, index, newRow);\n            }\n        }\n    },\n    \n    shouldUpdateCell: function(column, changedFieldNames){\n        // Though this may not be the most efficient, a renderer could be dependent on any field in the\n        // store, so we must always update the cell\n        if (column.hasCustomRenderer) {\n            return true;\n        }\n        return !changedFieldNames || Ext.Array.contains(changedFieldNames, column.dataIndex);\n    },\n\n    /**\n     * Refreshes the grid view. Saves and restores the scroll state, generates a new template, stripes rows and\n     * invalidates the scrollers.\n     */\n    refresh: function() {\n        var me = this;\n        me.setNewTemplate();\n        me.callParent(arguments);\n        me.doStripeRows(0);\n        me.headerCt.setSortState();\n    },\n\n    clearViewEl: function() {\n        this.callParent();\n        delete this.table.dom;\n    },\n\n    processItemEvent: function(record, row, rowIndex, e) {\n        var me = this,\n            cell = e.getTarget(me.cellSelector, row),\n            cellIndex = cell ? cell.cellIndex : -1,\n            map = me.statics().EventMap,\n            selModel = me.getSelectionModel(),\n            type = e.type,\n            result;\n\n        if (type == 'keydown' && !cell && selModel.getCurrentPosition) {\n            // CellModel, otherwise we can't tell which cell to invoke\n            cell = me.getCellByPosition(selModel.getCurrentPosition());\n            if (cell) {\n                cell = cell.dom;\n                cellIndex = cell.cellIndex;\n            }\n        }\n\n        result = me.fireEvent('uievent', type, me, cell, rowIndex, cellIndex, e, record, row);\n\n        if (result === false || me.callParent(arguments) === false) {\n            return false;\n        }\n\n        // Don't handle cellmouseenter and cellmouseleave events for now\n        if (type == 'mouseover' || type == 'mouseout') {\n            return true;\n        }\n\n        if(!cell) {\n            // if the element whose event is being processed is not an actual cell (for example if using a rowbody\n            // feature and the rowbody element's event is being processed) then do not fire any \"cell\" events\n            return true;\n        }\n\n        return !(\n            // We are adding cell and feature events\n            (me['onBeforeCell' + map[type]](cell, cellIndex, record, row, rowIndex, e) === false) ||\n            (me.fireEvent('beforecell' + type, me, cell, cellIndex, record, row, rowIndex, e) === false) ||\n            (me['onCell' + map[type]](cell, cellIndex, record, row, rowIndex, e) === false) ||\n            (me.fireEvent('cell' + type, me, cell, cellIndex, record, row, rowIndex, e) === false)\n        );\n    },\n\n    processSpecialEvent: function(e) {\n        var me = this,\n            map = me.statics().EventMap,\n            features = me.features,\n            ln = features.length,\n            type = e.type,\n            i, feature, prefix, featureTarget,\n            beforeArgs, args,\n            panel = me.ownerCt;\n\n        me.callParent(arguments);\n\n        if (type == 'mouseover' || type == 'mouseout') {\n            return;\n        }\n\n        for (i = 0; i < ln; i++) {\n            feature = features[i];\n            if (feature.hasFeatureEvent) {\n                featureTarget = e.getTarget(feature.eventSelector, me.getTargetEl());\n                if (featureTarget) {\n                    prefix = feature.eventPrefix;\n                    // allows features to implement getFireEventArgs to change the\n                    // fireEvent signature\n                    beforeArgs = feature.getFireEventArgs('before' + prefix + type, me, featureTarget, e);\n                    args = feature.getFireEventArgs(prefix + type, me, featureTarget, e);\n\n                    if (\n                        // before view event\n                        (me.fireEvent.apply(me, beforeArgs) === false) ||\n                        // panel grid event\n                        (panel.fireEvent.apply(panel, beforeArgs) === false) ||\n                        // view event\n                        (me.fireEvent.apply(me, args) === false) ||\n                        // panel event\n                        (panel.fireEvent.apply(panel, args) === false)\n                    ) {\n                        return false;\n                    }\n                }\n            }\n        }\n        return true;\n    },\n\n    onCellMouseDown: Ext.emptyFn,\n    onCellMouseUp: Ext.emptyFn,\n    onCellClick: Ext.emptyFn,\n    onCellDblClick: Ext.emptyFn,\n    onCellContextMenu: Ext.emptyFn,\n    onCellKeyDown: Ext.emptyFn,\n    onBeforeCellMouseDown: Ext.emptyFn,\n    onBeforeCellMouseUp: Ext.emptyFn,\n    onBeforeCellClick: Ext.emptyFn,\n    onBeforeCellDblClick: Ext.emptyFn,\n    onBeforeCellContextMenu: Ext.emptyFn,\n    onBeforeCellKeyDown: Ext.emptyFn,\n\n    /**\n     * Expands a particular header to fit the max content width.\n     * This will ONLY expand, not contract.\n     * @private\n     */\n    expandToFit: function(header) {\n        if (header) {\n            var maxWidth = this.getMaxContentWidth(header);\n            delete header.flex;\n            header.setWidth(maxWidth);\n        }\n    },\n\n    /**\n     * Returns the max contentWidth of the header's text and all cells\n     * in the grid under this header.\n     * @private\n     */\n    getMaxContentWidth: function(header) {\n        var cellSelector = header.getCellInnerSelector(),\n            cells        = this.el.query(cellSelector),\n            i = 0,\n            ln = cells.length,\n            maxWidth = header.el.dom.scrollWidth,\n            scrollWidth;\n\n        for (; i < ln; i++) {\n            scrollWidth = cells[i].scrollWidth;\n            if (scrollWidth > maxWidth) {\n                maxWidth = scrollWidth;\n            }\n        }\n        return maxWidth;\n    },\n\n    getPositionByEvent: function(e) {\n        var me       = this,\n            cellNode = e.getTarget(me.cellSelector),\n            rowNode  = e.getTarget(me.itemSelector),\n            record   = me.getRecord(rowNode),\n            header   = me.getHeaderByCell(cellNode);\n\n        return me.getPosition(record, header);\n    },\n\n    getHeaderByCell: function(cell) {\n        if (cell) {\n            var m = cell.className.match(this.cellRe);\n            if (m && m[1]) {\n                return Ext.getCmp(m[1]);\n            }\n        }\n        return false;\n    },\n\n    /**\n     * @param {Object} position The current row and column: an object containing the following properties:\n     *\n     * - row - The row index\n     * - column - The column index\n     *\n     * @param {String} direction 'up', 'down', 'right' and 'left'\n     * @param {Ext.EventObject} e event\n     * @param {Boolean} preventWrap Set to true to prevent wrap around to the next or previous row.\n     * @param {Function} verifierFn A function to verify the validity of the calculated position.\n     * When using this function, you must return true to allow the newPosition to be returned.\n     * @param {Object} scope Scope to run the verifierFn in\n     * @returns {Object} newPosition An object containing the following properties:\n     *\n     * - row - The row index\n     * - column - The column index\n     *\n     * @private\n     */\n    walkCells: function(pos, direction, e, preventWrap, verifierFn, scope) {\n\n        // Caller (probably CellModel) had no current position. This can happen\n        // if the main el is focused and any navigation key is presssed.\n        if (!pos) {\n            return;\n        }\n\n        var me       = this,\n            row      = pos.row,\n            column   = pos.column,\n            rowCount = me.store.getCount(),\n            firstCol = me.getFirstVisibleColumnIndex(),\n            lastCol  = me.getLastVisibleColumnIndex(),\n            newPos   = {row: row, column: column},\n            activeHeader = me.headerCt.getHeaderAtIndex(column);\n\n        // no active header or its currently hidden\n        if (!activeHeader || activeHeader.hidden) {\n            return false;\n        }\n\n        e = e || {};\n        direction = direction.toLowerCase();\n        switch (direction) {\n            case 'right':\n                // has the potential to wrap if its last\n                if (column === lastCol) {\n                    // if bottom row and last column, deny right\n                    if (preventWrap || row === rowCount - 1) {\n                        return false;\n                    }\n                    if (!e.ctrlKey) {\n                        // otherwise wrap to nextRow and firstCol\n                        newPos.row = row + 1;\n                        newPos.column = firstCol;\n                    }\n                // go right\n                } else {\n                    if (!e.ctrlKey) {\n                        newPos.column = column + me.getRightGap(activeHeader);\n                    } else {\n                        newPos.column = lastCol;\n                    }\n                }\n                break;\n\n            case 'left':\n                // has the potential to wrap\n                if (column === firstCol) {\n                    // if top row and first column, deny left\n                    if (preventWrap || row === 0) {\n                        return false;\n                    }\n                    if (!e.ctrlKey) {\n                        // otherwise wrap to prevRow and lastCol\n                        newPos.row = row - 1;\n                        newPos.column = lastCol;\n                    }\n                // go left\n                } else {\n                    if (!e.ctrlKey) {\n                        newPos.column = column + me.getLeftGap(activeHeader);\n                    } else {\n                        newPos.column = firstCol;\n                    }\n                }\n                break;\n\n            case 'up':\n                // if top row, deny up\n                if (row === 0) {\n                    return false;\n                // go up\n                } else {\n                    if (!e.ctrlKey) {\n                        newPos.row = row - 1;\n                    } else {\n                        newPos.row = 0;\n                    }\n                }\n                break;\n\n            case 'down':\n                // if bottom row, deny down\n                if (row === rowCount - 1) {\n                    return false;\n                // go down\n                } else {\n                    if (!e.ctrlKey) {\n                        newPos.row = row + 1;\n                    } else {\n                        newPos.row = rowCount - 1;\n                    }\n                }\n                break;\n        }\n\n        if (verifierFn && verifierFn.call(scope || window, newPos) !== true) {\n            return false;\n        } else {\n            return newPos;\n        }\n    },\n    getFirstVisibleColumnIndex: function() {\n        var firstVisibleHeader = this.getHeaderCt().getVisibleGridColumns()[0];\n\n        return firstVisibleHeader ? firstVisibleHeader.getIndex() : -1;\n    },\n\n    getLastVisibleColumnIndex: function() {\n        var visHeaders = this.getHeaderCt().getVisibleGridColumns(),\n            lastHeader = visHeaders[visHeaders.length - 1];\n\n        return lastHeader.getIndex();\n    },\n\n    getHeaderCt: function() {\n        return this.headerCt;\n    },\n\n    // TODO: have this use the new Ext.grid.CellContext class\n    getPosition: function(record, header) {\n        var me = this,\n            store = me.store,\n            gridCols = me.headerCt.getGridColumns();\n\n        return {\n            row: store.indexOf(record),\n            column: Ext.Array.indexOf(gridCols, header)\n        };\n    },\n\n    /**\n     * Determines the 'gap' between the closest adjacent header to the right\n     * that is not hidden.\n     * @private\n     */\n    getRightGap: function(activeHeader) {\n        var headerCt        = this.getHeaderCt(),\n            headers         = headerCt.getGridColumns(),\n            activeHeaderIdx = Ext.Array.indexOf(headers, activeHeader),\n            i               = activeHeaderIdx + 1,\n            nextIdx;\n\n        for (; i <= headers.length; i++) {\n            if (!headers[i].hidden) {\n                nextIdx = i;\n                break;\n            }\n        }\n\n        return nextIdx - activeHeaderIdx;\n    },\n\n    beforeDestroy: function() {\n        if (this.rendered) {\n            this.el.removeAllListeners();\n        }\n        this.callParent(arguments);\n    },\n\n    /**\n     * Determines the 'gap' between the closest adjacent header to the left\n     * that is not hidden.\n     * @private\n     */\n    getLeftGap: function(activeHeader) {\n        var headerCt        = this.getHeaderCt(),\n            headers         = headerCt.getGridColumns(),\n            activeHeaderIdx = Ext.Array.indexOf(headers, activeHeader),\n            i               = activeHeaderIdx - 1,\n            prevIdx;\n\n        for (; i >= 0; i--) {\n            if (!headers[i].hidden) {\n                prevIdx = i;\n                break;\n            }\n        }\n\n        return prevIdx - activeHeaderIdx;\n    },\n\n    // after adding a row stripe rows from then on\n    onAdd: function(ds, records, index) {\n        this.callParent(arguments);\n        this.doStripeRows(index);\n    },\n    \n    // after removing a row stripe rows from then on\n    onRemove: function(ds, records, index) {\n        this.callParent(arguments);\n        this.doStripeRows(index);\n    },\n    \n    /**\n     * Stripes rows from a particular row index.\n     * @param {Number} startRow\n     * @param {Number} [endRow] argument specifying the last row to process.\n     * By default process up to the last row.\n     * @private\n     */\n    doStripeRows: function(startRow, endRow) {\n        var me = this,\n            rows,\n            rowsLn,\n            i,\n            row;\n            \n        // ensure stripeRows configuration is turned on\n        if (me.rendered && me.stripeRows) {\n            rows = me.getNodes(startRow, endRow);\n                \n            for (i = 0, rowsLn = rows.length; i < rowsLn; i++) {\n                row = rows[i];\n                // Remove prior applied row classes.\n                row.className = row.className.replace(me.rowClsRe, ' ');\n                startRow++;\n                // Every odd row will get an additional cls\n                if (startRow % 2 === 0) {\n                    row.className += (' ' + me.altRowCls);\n                }\n            }\n        }\n    }\n \n});\n\n/**\n * @private\n *\n * Lockable is a private mixin which injects lockable behavior into any\n * TablePanel subclass such as GridPanel or TreePanel. TablePanel will\n * automatically inject the Ext.grid.Lockable mixin in when one of the\n * these conditions are met:\n *\n *  - The TablePanel has the lockable configuration set to true\n *  - One of the columns in the TablePanel has locked set to true/false\n *\n * Each TablePanel subclass must register an alias. It should have an array\n * of configurations to copy to the 2 separate tablepanel's that will be generated\n * to note what configurations should be copied. These are named normalCfgCopy and\n * lockedCfgCopy respectively.\n *\n * Columns which are locked must specify a fixed width. They do NOT support a\n * flex width.\n *\n * Configurations which are specified in this class will be available on any grid or\n * tree which is using the lockable functionality.\n */\nExt.define('Ext.grid.Lockable', {\n\n    requires: [\n        'Ext.grid.LockingView',\n        'Ext.view.Table'\n    ],\n\n    /**\n     * @cfg {Boolean} syncRowHeight Synchronize rowHeight between the normal and\n     * locked grid view. This is turned on by default. If your grid is guaranteed\n     * to have rows of all the same height, you should set this to false to\n     * optimize performance.\n     */\n    syncRowHeight: true,\n\n    /**\n     * @cfg {String} subGridXType The xtype of the subgrid to specify. If this is\n     * not specified lockable will determine the subgrid xtype to create by the\n     * following rule. Use the superclasses xtype if the superclass is NOT\n     * tablepanel, otherwise use the xtype itself.\n     */\n\n    /**\n     * @cfg {Object} lockedViewConfig A view configuration to be applied to the\n     * locked side of the grid. Any conflicting configurations between lockedViewConfig\n     * and viewConfig will be overwritten by the lockedViewConfig.\n     */\n\n    /**\n     * @cfg {Object} normalViewConfig A view configuration to be applied to the\n     * normal/unlocked side of the grid. Any conflicting configurations between normalViewConfig\n     * and viewConfig will be overwritten by the normalViewConfig.\n     */\n\n    headerCounter: 0,\n\n    /**\n     * @cfg {Number} scrollDelta\n     * Number of pixels to scroll when scrolling the locked section with mousewheel.\n     */\n    scrollDelta: 40,\n    \n    /**\n     * @cfg {Object} lockedGridConfig\n     * Any special configuration options for the locked part of the grid\n     */\n    \n    /**\n     * @cfg {Object} normalGridConfig\n     * Any special configuration options for the normal part of the grid\n     */\n\n    // i8n text\n    //<locale>\n    unlockText: 'Unlock',\n    //</locale>\n    //<locale>\n    lockText: 'Lock',\n    //</locale>\n\n    determineXTypeToCreate: function() {\n        var me = this,\n            typeToCreate,\n            xtypes, xtypesLn, xtype, superxtype;\n\n        if (me.subGridXType) {\n            typeToCreate = me.subGridXType;\n        } else {\n            xtypes     = this.getXTypes().split('/');\n            xtypesLn   = xtypes.length;\n            xtype      = xtypes[xtypesLn - 1];\n            superxtype = xtypes[xtypesLn - 2];\n\n            if (superxtype !== 'tablepanel') {\n                typeToCreate = superxtype;\n            } else {\n                typeToCreate = xtype;\n            }\n        }\n\n        return typeToCreate;\n    },\n\n    // injectLockable will be invoked before initComponent's parent class implementation\n    // is called, so throughout this method this. are configurations\n    injectLockable: function() {\n        // ensure lockable is set to true in the TablePanel\n        this.lockable = true;\n        // Instruct the TablePanel it already has a view and not to create one.\n        // We are going to aggregate 2 copies of whatever TablePanel we are using\n        this.hasView = true;\n\n        var me = this,\n            // If the OS does not show a space-taking scrollbar, the locked view can be overflow:auto\n            scrollLocked = Ext.getScrollbarSize().width === 0,\n            store = me.store = Ext.StoreManager.lookup(me.store),\n            // xtype of this class, 'treepanel' or 'gridpanel'\n            // (Note: this makes it a requirement that any subclass that wants to use lockable functionality needs to register an\n            // alias.)\n            xtype = me.determineXTypeToCreate(),\n            // share the selection model\n            selModel = me.getSelectionModel(),\n            lockedFeatures,\n            normalFeatures,\n            lockedPlugins,\n            normalPlugins,\n            lockedGrid,\n            normalGrid,\n            i, len,\n            columns,\n            lockedHeaderCt,\n            normalHeaderCt,\n            lockedView,\n            normalView,\n            listeners;\n\n        lockedFeatures = me.constructFeatures();\n\n        // Clone any Features in the Array which are already instantiated\n        me.cloneFeatures();\n        normalFeatures = me.constructFeatures();\n\n        lockedPlugins = me.constructPlugins();\n\n        // Clone any Plugins in the Array which are already instantiated\n        me.clonePlugins();\n        normalPlugins = me.constructPlugins();\n\n        // The \"shell\" Panel which just acts as a Container for the two grids must not use the features and plugins\n        delete me.features;\n        delete me.plugins;\n\n        // Each Feature must have a reference to its counterpart on the opposite side of the locking view\n        for (i = 0, len = (lockedFeatures ? lockedFeatures.length : 0); i < len; i++) {\n            lockedFeatures[i].lockingPartner = normalFeatures[i];\n            normalFeatures[i].lockingPartner = lockedFeatures[i];\n        }\n\n        lockedGrid = Ext.apply({\n            xtype: xtype,\n            store: store,\n            scrollerOwner: false,\n            // Lockable does NOT support animations for Tree\n            enableAnimations: false,\n            scroll: scrollLocked ? 'vertical' : false,\n            selModel: selModel,\n            border: false,\n            cls: Ext.baseCSSPrefix + 'grid-inner-locked',\n            isLayoutRoot: function() {\n                return false;\n            },\n            features: lockedFeatures,\n            plugins: lockedPlugins\n        }, me.lockedGridConfig);\n\n        normalGrid = Ext.apply({\n            xtype: xtype,\n            store: store,\n            scrollerOwner: false,\n            enableAnimations: false,\n            selModel: selModel,\n            border: false,\n            isLayoutRoot: function() {\n                return false;\n            },\n            features: normalFeatures,\n            plugins: normalPlugins\n        }, me.normalGridConfig);\n\n        me.addCls(Ext.baseCSSPrefix + 'grid-locked');\n\n        // copy appropriate configurations to the respective\n        // aggregated tablepanel instances and then delete them\n        // from the master tablepanel.\n        Ext.copyTo(normalGrid, me, me.bothCfgCopy);\n        Ext.copyTo(lockedGrid, me, me.bothCfgCopy);\n        Ext.copyTo(normalGrid, me, me.normalCfgCopy);\n        Ext.copyTo(lockedGrid, me, me.lockedCfgCopy);\n        for (i = 0; i < me.normalCfgCopy.length; i++) {\n            delete me[me.normalCfgCopy[i]];\n        }\n        for (i = 0; i < me.lockedCfgCopy.length; i++) {\n            delete me[me.lockedCfgCopy[i]];\n        }\n\n        me.addEvents(\n            /**\n             * @event lockcolumn\n             * Fires when a column is locked.\n             * @param {Ext.grid.Panel} this The gridpanel.\n             * @param {Ext.grid.column.Column} column The column being locked.\n             */\n            'lockcolumn',\n\n            /**\n             * @event unlockcolumn\n             * Fires when a column is unlocked.\n             * @param {Ext.grid.Panel} this The gridpanel.\n             * @param {Ext.grid.column.Column} column The column being unlocked.\n             */\n            'unlockcolumn'\n        );\n\n        me.addStateEvents(['lockcolumn', 'unlockcolumn']);\n\n        me.lockedHeights = [];\n        me.normalHeights = [];\n\n        columns = me.processColumns(me.columns);\n\n        lockedGrid.width = columns.lockedWidth + Ext.num(selModel.headerWidth, 0);\n        lockedGrid.columns = columns.locked;\n        normalGrid.columns = columns.normal;\n\n        // normal grid should flex the rest of the width\n        normalGrid.flex = 1;\n        lockedGrid.viewConfig = me.lockedViewConfig || {};\n        lockedGrid.viewConfig.loadingUseMsg = false;\n        normalGrid.viewConfig = me.normalViewConfig || {};\n\n        Ext.applyIf(lockedGrid.viewConfig, me.viewConfig);\n        Ext.applyIf(normalGrid.viewConfig, me.viewConfig);\n\n        me.lockedGrid = Ext.ComponentManager.create(lockedGrid);\n        lockedView = me.lockedGrid.getView();\n        \n        normalGrid.viewConfig.lockingPartner = lockedView;\n        me.normalGrid = Ext.ComponentManager.create(normalGrid);\n        normalView = me.normalGrid.getView();\n\n        me.view = new Ext.grid.LockingView({\n            locked: me.lockedGrid,\n            normal: me.normalGrid,\n            panel: me\n        });\n\n        // Set up listeners for the locked view. If its SelModel ever scrolls it, the normal view must sync\n        listeners = {\n            scroll: {\n                fn: me.onLockedViewScroll,\n                element: 'el',\n                scope: me\n            }\n        };\n        // If there are system scrollbars, we have to monitor the mousewheel and fake a scroll\n        if (!scrollLocked) {\n            listeners.mousewheel = {\n                fn: me.onLockedViewMouseWheel,\n                element: 'el',\n                scope: me\n            };\n        }\n        if (me.syncRowHeight) {\n            listeners.refresh = me.onLockedViewRefresh;\n            listeners.itemupdate = me.onLockedViewItemUpdate;\n            listeners.scope = me;\n        }\n        lockedView.on(listeners);\n\n        // Set up listeners for the normal view\n        listeners = {\n            scroll: {\n                fn: me.onNormalViewScroll,\n                element: 'el',\n                scope: me\n            },\n            refresh: me.syncRowHeight ? me.onNormalViewRefresh : me.updateSpacer,\n            scope: me\n        };\n        normalView.on(listeners);\n\n        lockedHeaderCt = me.lockedGrid.headerCt;\n        normalHeaderCt = me.normalGrid.headerCt;\n\n        lockedHeaderCt.lockedCt = true;\n        lockedHeaderCt.lockableInjected = true;\n        normalHeaderCt.lockableInjected = true;\n\n        lockedHeaderCt.on({\n            columnshow: me.onLockedHeaderShow,\n            columnhide: me.onLockedHeaderHide,\n            columnmove: me.onLockedHeaderMove,\n            sortchange: me.onLockedHeaderSortChange,\n            columnresize: me.onLockedHeaderResize,\n            scope: me\n        });\n\n        normalHeaderCt.on({\n            columnmove: me.onNormalHeaderMove,\n            sortchange: me.onNormalHeaderSortChange,\n            scope: me\n        });\n\n        me.modifyHeaderCt();\n        me.items = [me.lockedGrid, me.normalGrid];\n\n        me.relayHeaderCtEvents(lockedHeaderCt);\n        me.relayHeaderCtEvents(normalHeaderCt);\n\n        me.layout = {\n            type: 'hbox',\n            align: 'stretch'\n        };\n    },\n\n    processColumns: function(columns){\n        // split apart normal and lockedWidths\n        var i = 0,\n            len = columns.length,\n            lockedWidth = 0,\n            lockedHeaders = [],\n            normalHeaders = [],\n            column;\n\n        for (; i < len; ++i) {\n            column = columns[i];\n            // MUST clone the column config because we mutate it, and we must not mutate passed in config objects in case they are re-used\n            // eg, in an extend-to-configure scenario.\n            if (!column.isComponent) {\n                column = Ext.apply({}, columns[i]);\n            }\n\n            // mark the column as processed so that the locked attribute does not\n            // trigger trying to aggregate the columns again.\n            column.processed = true;\n            if (column.locked) {\n                if (column.flex) {\n                    Ext.Error.raise(\"Columns which are locked do NOT support a flex width. You must set a width on the \" + columns[i].text + \"column.\");\n                }\n                if (!column.hidden) {\n                    lockedWidth += column.width || Ext.grid.header.Container.prototype.defaultWidth;\n                }\n                lockedHeaders.push(column);\n            } else {\n                normalHeaders.push(column);\n            }\n            if (!column.headerId) {\n                column.headerId = (column.initialConfig || column).id || ('L' + (++this.headerCounter));\n            }\n        }\n        return {\n            lockedWidth: lockedWidth,\n            locked: {\n                items: lockedHeaders,\n                itemId: 'lockedHeaderCt',\n                stretchMaxPartner: '^^>>#normalHeaderCt'\n            },\n            normal: {\n                items: normalHeaders,\n                itemId: 'normalHeaderCt',\n                stretchMaxPartner: '^^>>#lockedHeaderCt'\n            }\n        };\n    },\n\n    /**\n     * @private\n     * Listen for mousewheel events on the locked section which does not scroll.\n     * Scroll it in response, and the other section will automatically sync.\n     */\n    onLockedViewMouseWheel: function(e) {\n        var me = this,\n            scrollDelta = -me.scrollDelta,\n            deltaY = scrollDelta * e.getWheelDeltas().y,\n            vertScrollerEl = me.lockedGrid.getView().el.dom,\n            verticalCanScrollDown, verticalCanScrollUp;\n\n        if (vertScrollerEl) {\n            verticalCanScrollDown = vertScrollerEl.scrollTop !== vertScrollerEl.scrollHeight - vertScrollerEl.clientHeight;\n            verticalCanScrollUp   = vertScrollerEl.scrollTop !== 0;\n        }\n\n        if ((deltaY < 0 && verticalCanScrollUp) || (deltaY > 0 && verticalCanScrollDown)) {\n            e.stopEvent();\n\n            // Inhibit processing of any scroll events we *may* cause here.\n            // Some OSs do not fire a scroll event when we set the scrollTop of an overflow:hidden element,\n            // so we invoke the scroll handler programatically below.\n            me.scrolling = true;\n            vertScrollerEl.scrollTop += deltaY;\n            me.normalGrid.getView().el.dom.scrollTop = vertScrollerEl.scrollTop;\n            me.scrolling = false;\n\n            // Invoke the scroll event handler programatically to sync everything.\n            me.onNormalViewScroll();\n        }\n    },\n\n    onLockedViewScroll: function() {\n        var me = this,\n            lockedView = me.lockedGrid.getView(),\n            normalView = me.normalGrid.getView(),\n            normalTable,\n            lockedTable;\n\n        // Set a flag so that the scroll even doesn't bounce back when we set the normal view's scroll position\n        if (!me.scrolling) {\n            me.scrolling = true;\n            normalView.el.dom.scrollTop = lockedView.el.dom.scrollTop;\n    \n            // For buffered views, the absolute position is important as well as scrollTop\n            if (me.store.buffered) {\n                lockedTable = lockedView.el.child('table', true);\n                normalTable = normalView.el.child('table', true);\n                lockedTable.style.position = 'absolute';\n            }\n            me.scrolling = false;\n        }\n    },\n    \n    onNormalViewScroll: function() {\n        var me = this,\n            lockedView = me.lockedGrid.getView(),\n            normalView = me.normalGrid.getView(),\n            normalTable,\n            lockedTable;\n\n        // Set a flag so that the scroll even doesn't bounce back when we set the locked view's scroll position\n        if (!me.scrolling) {\n            me.scrolling = true;\n            lockedView.el.dom.scrollTop = normalView.el.dom.scrollTop;\n    \n            // For buffered views, the absolute position is important as well as scrollTop\n            if (me.store.buffered) {\n                lockedTable = lockedView.el.child('table', true);\n                normalTable = normalView.el.child('table', true);\n                lockedTable.style.position = 'absolute';\n                lockedTable.style.top = normalTable.style.top;\n            }\n            me.scrolling = false;\n        }\n    },\n\n    // trigger a pseudo refresh on the normal side\n    onLockedHeaderMove: function() {\n        if (this.syncRowHeight) {\n            this.onNormalViewRefresh();\n        }\n    },\n\n    // trigger a pseudo refresh on the locked side\n    onNormalHeaderMove: function() {\n        if (this.syncRowHeight) {\n            this.onLockedViewRefresh();\n        }\n    },\n    \n    // Create a spacer in lockedsection and store a reference.\n    // This is to allow the locked section to scroll past the bottom to\n    // take the mormal section's horizontal scrollbar into account\n    // TODO: Should destroy before refreshing content\n    updateSpacer: function() {\n        var me   = this,\n            // This affects scrolling all the way to the bottom of a locked grid\n            // additional test, sort a column and make sure it synchronizes\n            lockedViewEl   = me.lockedGrid.getView().el,\n            normalViewEl = me.normalGrid.getView().el.dom,\n            spacerId = lockedViewEl.dom.id + '-spacer',\n            spacerHeight = (normalViewEl.offsetHeight - normalViewEl.clientHeight) + 'px';\n\n        me.spacerEl = Ext.getDom(spacerId);\n        if (me.spacerEl) {\n            me.spacerEl.style.height = spacerHeight;\n        } else {\n            Ext.core.DomHelper.append(lockedViewEl, {\n                id: spacerId,\n                style: 'height: ' + spacerHeight\n            });\n        }\n    },\n\n    // cache the heights of all locked rows and sync rowheights\n    onLockedViewRefresh: function() {\n\n        // Only bother if there are some columns in the normal grid to sync\n        if (this.normalGrid.headerCt.getGridColumns().length) {\n            var me     = this,\n                view   = me.lockedGrid.getView(),\n                el     = view.el,\n                rowEls = el.query(view.getItemSelector()),\n                ln     = rowEls.length,\n                i = 0;\n    \n            // reset heights each time.\n            me.lockedHeights = [];\n\n            for (; i < ln; i++) {\n                me.lockedHeights[i] = rowEls[i].offsetHeight;\n            }\n            me.syncRowHeights();\n            me.updateSpacer();\n        }\n    },\n\n    // cache the heights of all normal rows and sync rowheights\n    onNormalViewRefresh: function() {\n\n        // Only bother if there are some columns in the locked grid to sync\n        if (this.lockedGrid.headerCt.getGridColumns().length) {\n            var me     = this,\n                view   = me.normalGrid.getView(),\n                el     = view.el,\n                rowEls = el.query(view.getItemSelector()),\n                ln     = rowEls.length,\n                i = 0;\n    \n            // reset heights each time.\n            me.normalHeights = [];\n    \n            for (; i < ln; i++) {\n                me.normalHeights[i] = rowEls[i].offsetHeight;\n            }\n            me.syncRowHeights();\n            me.updateSpacer();\n        }\n    },\n\n    // rows can get bigger/smaller\n    onLockedViewItemUpdate: function(record, index, node) {\n\n        // Only bother if there are some columns in the normal grid to sync\n        if (this.normalGrid.headerCt.getGridColumns().length) {\n            this.lockedHeights[index] = node.offsetHeight;\n            this.syncRowHeights();\n        }\n    },\n\n    // rows can get bigger/smaller\n    onNormalViewItemUpdate: function(record, index, node) {\n    \n        // Only bother if there are some columns in the locked grid to sync\n        if (this.lockedGrid.headerCt.getGridColumns().length) {\n            this.normalHeights[index] = node.offsetHeight;\n            this.syncRowHeights();\n        }\n    },\n\n    /**\n     * Synchronizes the row heights between the locked and non locked portion of the grid for each\n     * row. If one row is smaller than the other, the height will be increased to match the larger one.\n     */\n    syncRowHeights: function() {\n        var me = this,\n            lockedHeights = me.lockedHeights,\n            normalHeights = me.normalHeights,\n            ln = lockedHeights.length,\n            i  = 0,\n            lockedView, normalView,\n            lockedRowEls, normalRowEls,\n            scrollTop;\n\n        // ensure there are an equal num of locked and normal\n        // rows before synchronization\n        if (lockedHeights.length && normalHeights.length) {\n            lockedView = me.lockedGrid.getView();\n            normalView = me.normalGrid.getView();\n            lockedRowEls = lockedView.el.query(lockedView.getItemSelector());\n            normalRowEls = normalView.el.query(normalView.getItemSelector());\n\n            // loop thru all of the heights and sync to the other side\n            for (; i < ln; i++) {\n                // ensure both are numbers\n                if (!isNaN(lockedHeights[i]) && !isNaN(normalHeights[i])) {\n                    if (lockedHeights[i] > normalHeights[i]) {\n                        Ext.fly(normalRowEls[i]).setHeight(lockedHeights[i]);\n                    } else if (lockedHeights[i] < normalHeights[i]) {\n                        Ext.fly(lockedRowEls[i]).setHeight(normalHeights[i]);\n                    }\n                }\n            }\n\n            // Synchronize the scrollTop positions of the two views\n            scrollTop = normalView.el.dom.scrollTop;\n            normalView.el.dom.scrollTop = scrollTop;\n            lockedView.el.dom.scrollTop = scrollTop;\n            \n            // reset the heights\n            me.lockedHeights = [];\n            me.normalHeights = [];\n        }\n    },\n\n    // inject Lock and Unlock text\n    modifyHeaderCt: function() {\n        var me = this;\n        me.lockedGrid.headerCt.getMenuItems = me.getMenuItems(me.lockedGrid.headerCt.getMenuItems, true);\n        me.normalGrid.headerCt.getMenuItems = me.getMenuItems(me.normalGrid.headerCt.getMenuItems, false);\n    },\n\n    onUnlockMenuClick: function() {\n        this.unlock();\n    },\n\n    onLockMenuClick: function() {\n        this.lock();\n    },\n\n    getMenuItems: function(getMenuItems, locked) {\n        var me            = this,\n            unlockText    = me.unlockText,\n            lockText      = me.lockText,\n            unlockCls     = Ext.baseCSSPrefix + 'hmenu-unlock',\n            lockCls       = Ext.baseCSSPrefix + 'hmenu-lock',\n            unlockHandler = Ext.Function.bind(me.onUnlockMenuClick, me),\n            lockHandler   = Ext.Function.bind(me.onLockMenuClick, me);\n\n        // runs in the scope of headerCt\n        return function() {\n\n            // We cannot use the method from HeaderContainer's prototype here\n            // because other plugins or features may already have injected an implementation\n            var o = getMenuItems.call(this);\n            o.push('-', {\n                cls: unlockCls,\n                text: unlockText,\n                handler: unlockHandler,\n                disabled: !locked\n            });\n            o.push({\n                cls: lockCls,\n                text: lockText,\n                handler: lockHandler,\n                disabled: locked\n            });\n            return o;\n        };\n    },\n\n    // going from unlocked section to locked\n    /**\n     * Locks the activeHeader as determined by which menu is open OR a header\n     * as specified.\n     * @param {Ext.grid.column.Column} [header] Header to unlock from the locked section.\n     * Defaults to the header which has the menu open currently.\n     * @param {Number} [toIdx] The index to move the unlocked header to.\n     * Defaults to appending as the last item.\n     * @private\n     */\n    lock: function(activeHd, toIdx) {\n        var me         = this,\n            normalGrid = me.normalGrid,\n            lockedGrid = me.lockedGrid,\n            normalHCt  = normalGrid.headerCt,\n            lockedHCt  = lockedGrid.headerCt;\n\n        activeHd = activeHd || normalHCt.getMenu().activeHeader;\n\n        // if column was previously flexed, get/set current width\n        // and remove the flex\n        if (activeHd.flex) {\n            activeHd.width = activeHd.getWidth();\n            delete activeHd.flex;\n        }\n\n        Ext.suspendLayouts();\n        activeHd.ownerCt.remove(activeHd, false);\n        activeHd.locked = true;\n        if (Ext.isDefined(toIdx)) {\n            lockedHCt.insert(toIdx, activeHd);\n        } else {\n            lockedHCt.add(activeHd);\n        }\n        me.syncLockedSection();\n        Ext.resumeLayouts(true);\n        me.updateSpacer();\n\n        me.fireEvent('lockcolumn', me, activeHd);\n    },\n\n    syncLockedSection: function() {\n        var me = this;\n        me.syncLockedWidth();\n        me.lockedGrid.getView().refresh();\n        me.normalGrid.getView().refresh();\n    },\n\n    // adjust the locked section to the width of its respective\n    // headerCt\n    syncLockedWidth: function() {\n        var me = this,\n            locked = me.lockedGrid,\n            width = locked.headerCt.getFullWidth(true);\n            \n        Ext.suspendLayouts();\n        if (width > 0) {\n            locked.setWidth(width);\n            locked.show();\n        } else {\n            locked.hide();\n        }\n        Ext.resumeLayouts(true);\n        \n        return width > 0;\n    },\n\n    onLockedHeaderResize: function() {\n        this.syncLockedWidth();\n    },\n\n    onLockedHeaderHide: function() {\n        this.syncLockedWidth();\n    },\n\n    onLockedHeaderShow: function() {\n        this.syncLockedWidth();\n    },\n\n    onLockedHeaderSortChange: function(headerCt, header, sortState) {\n        if (sortState) {\n            // no real header, and silence the event so we dont get into an\n            // infinite loop\n            this.normalGrid.headerCt.clearOtherSortStates(null, true);\n        }\n    },\n\n    onNormalHeaderSortChange: function(headerCt, header, sortState) {\n        if (sortState) {\n            // no real header, and silence the event so we dont get into an\n            // infinite loop\n            this.lockedGrid.headerCt.clearOtherSortStates(null, true);\n        }\n    },\n\n    // going from locked section to unlocked\n    /**\n     * Unlocks the activeHeader as determined by which menu is open OR a header\n     * as specified.\n     * @param {Ext.grid.column.Column} [header] Header to unlock from the locked section.\n     * Defaults to the header which has the menu open currently.\n     * @param {Number} [toIdx=0] The index to move the unlocked header to.\n     * @private\n     */\n    unlock: function(activeHd, toIdx) {\n        var me         = this,\n            normalGrid = me.normalGrid,\n            lockedGrid = me.lockedGrid,\n            normalHCt  = normalGrid.headerCt,\n            lockedHCt  = lockedGrid.headerCt,\n            refreshLocked = false;\n\n        if (!Ext.isDefined(toIdx)) {\n            toIdx = 0;\n        }\n        activeHd = activeHd || lockedHCt.getMenu().activeHeader;\n\n        Ext.suspendLayouts();\n        activeHd.ownerCt.remove(activeHd, false);\n        if (me.syncLockedWidth()) {\n            refreshLocked = true;\n        }\n        activeHd.locked = false;\n\n        // Refresh the locked section first in case it was empty\n        normalHCt.insert(toIdx, activeHd);\n        me.normalGrid.getView().refresh();\n\n        if (refreshLocked) {\n            me.lockedGrid.getView().refresh();\n        }\n        Ext.resumeLayouts(true);\n\n        me.fireEvent('unlockcolumn', me, activeHd);\n    },\n\n    applyColumnsState: function (columns) {\n        var me             = this,\n            lockedGrid     = me.lockedGrid,\n            lockedHeaderCt = lockedGrid.headerCt,\n            normalHeaderCt = me.normalGrid.headerCt,\n            lockedCols     = Ext.Array.toMap(lockedHeaderCt.items, 'headerId'),\n            normalCols     = Ext.Array.toMap(normalHeaderCt.items, 'headerId'),\n            locked         = [],\n            normal         = [],\n            lockedWidth    = 1,\n            length         = columns.length,\n            i, existing,\n            lockedDefault,\n            col;\n\n        for (i = 0; i < length; i++) {\n            col = columns[i];\n\n            lockedDefault = lockedCols[col.id];\n            existing = lockedDefault || normalCols[col.id];\n\n            if (existing) {\n                if (existing.applyColumnState) {\n                    existing.applyColumnState(col);\n                }\n                if (existing.locked === undefined) {\n                    existing.locked = !!lockedDefault;\n                }\n                if (existing.locked) {\n                    locked.push(existing);\n                    if (!existing.hidden && typeof existing.width == 'number') {\n                        lockedWidth += existing.width;\n                    }\n                } else {\n                    normal.push(existing);\n                }\n            }\n        }\n\n        // state and config must have the same columns (compare counts for now):\n        if (locked.length + normal.length == lockedHeaderCt.items.getCount() + normalHeaderCt.items.getCount()) {\n            lockedHeaderCt.removeAll(false);\n            normalHeaderCt.removeAll(false);\n\n            lockedHeaderCt.add(locked);\n            normalHeaderCt.add(normal);\n\n            lockedGrid.setWidth(lockedWidth);\n        }\n    },\n\n    getColumnsState: function () {\n        var me = this,\n            locked = me.lockedGrid.headerCt.getColumnsState(),\n            normal = me.normalGrid.headerCt.getColumnsState();\n\n        return locked.concat(normal);\n    },\n\n    // we want to totally override the reconfigure behaviour here, since we're creating 2 sub-grids\n    reconfigureLockable: function(store, columns) {\n        var me = this,\n            lockedGrid = me.lockedGrid,\n            normalGrid = me.normalGrid;\n\n        if (columns) {\n            Ext.suspendLayouts();\n            lockedGrid.headerCt.removeAll();\n            normalGrid.headerCt.removeAll();\n\n            columns = me.processColumns(columns);\n            lockedGrid.setWidth(columns.lockedWidth);\n            lockedGrid.headerCt.add(columns.locked.items);\n            normalGrid.headerCt.add(columns.normal.items);\n            Ext.resumeLayouts(true);\n        }\n\n        if (store) {\n            store = Ext.data.StoreManager.lookup(store);\n            me.store = store;\n            lockedGrid.bindStore(store);\n            normalGrid.bindStore(store);\n        } else {\n            lockedGrid.getView().refresh();\n            normalGrid.getView().refresh();\n        }\n    },\n\n    /**\n     * Clones items in the features array if they are instantiated Features. If an item\n     * is just a feature config, it leaves it alone.\n     *\n     * This is so that features can be replicated on both sides of the LockingView\n     *\n     */\n    cloneFeatures: function() {\n        var me = this,\n            features = me.features,\n            feature,\n            i = 0, len;\n        \n        if (features) {\n            len = features.length;\n            for (; i < len; i++) {\n                feature = features[i];\n                if (feature.isFeature) {\n                    features[i] = feature.clone();\n                }\n            }\n        }\n    },\n\n    /**\n     * Clones items in the plugins array if they are instantiated Plugins. If an item\n     * is just a plugin config, it leaves it alone.\n     *\n     * This is so that plugins can be replicated on both sides of the LockingView\n     *\n     */\n    clonePlugins: function() {\n        var me = this,\n            plugins = me.plugins,\n            plugin,\n            i = 0, len;\n        \n        if (plugins) {\n            len = plugins.length;\n            for (; i < len; i++) {\n                plugin = plugins[i];\n                if (typeof plugin.init === 'function') {\n                    plugins[i] = plugin.clone();\n                }\n            }\n        }\n    }\n}, function() {\n    this.borrow(Ext.view.Table, ['constructFeatures']);\n    this.borrow(Ext.AbstractComponent, ['constructPlugins', 'constructPlugin']);\n});\n\n/**\n * Implements infinite scrolling of a grid, allowing users can scroll\n * through thousands of records without the performance penalties of\n * renderering all the records on screen at once. The grid should be\n * bound to a *buffered* store with a pageSize specified.\n *\n * The number of rows rendered outside the visible area, and the\n * buffering of pages of data from the remote server for immediate\n * rendering upon scroll can be controlled by configuring the\n * {@link Ext.grid.PagingScroller #verticalScroller}.\n *\n * You can tell it to create a larger table to provide more scrolling\n * before a refresh is needed, and also to keep more pages of records\n * in memory for faster refreshing when scrolling.\n *\n *     var myStore = Ext.create('Ext.data.Store', {\n *         // ...\n *         buffered: true,\n *         pageSize: 100,\n *         // ...\n *     });\n *\n *     var grid = Ext.create('Ext.grid.Panel', {\n *         // ...\n *         autoLoad: true,\n *         verticalScroller: {\n *             trailingBufferZone: 200,  // Keep 200 records buffered in memory behind scroll\n *             leadingBufferZone: 5000   // Keep 5000 records buffered in memory ahead of scroll\n *         },\n *         // ...\n *     });\n *\n * ## Implementation notes\n *\n * This class monitors scrolling of the {@link Ext.view.Table\n * TableView} within a {@link Ext.grid.Panel GridPanel} which is using\n * a buffered store to only cache and render a small section of a very\n * large dataset.\n *\n * **NB!** The GridPanel will instantiate this to perform monitoring,\n * this class should never be instantiated by user code.  Always use the\n * {@link Ext.panel.Table#verticalScroller verticalScroller} config.\n *\n */\nExt.define('Ext.grid.PagingScroller', {\n\n    /**\n     * @cfg\n     * @deprecated This config is now ignored.\n     */\n    percentageFromEdge: 0.35,\n\n    /**\n     * @cfg\n     * The zone which causes a refresh of the rendered viewport. As soon as the edge\n     * of the rendered grid is this number of rows from the edge of the viewport, the view is moved.\n     */\n    numFromEdge: 2,\n\n    /**\n     * @cfg\n     * The number of extra rows to render on the trailing side of scrolling\n     * **outside the {@link #numFromEdge}** buffer as scrolling proceeds.\n     */\n    trailingBufferZone: 5,\n\n    /**\n     * @cfg\n     * The number of extra rows to render on the leading side of scrolling\n     * **outside the {@link #numFromEdge}** buffer as scrolling proceeds.\n     */\n    leadingBufferZone: 15,\n\n    /**\n     * @cfg\n     * This is the time in milliseconds to buffer load requests when scrolling the PagingScrollbar.\n     */\n    scrollToLoadBuffer: 200,\n\n    // private. Initial value of zero.\n    viewSize: 0,\n    // private. Start at default value\n    rowHeight: 21,\n    // private. Table extent at startup time\n    tableStart: 0,\n    tableEnd: 0,\n\n    constructor: function(config) {\n        var me = this;\n        me.variableRowHeight = config.variableRowHeight;\n        me.bindView(config.view);\n        Ext.apply(me, config);\n        me.callParent(arguments);\n    },\n\n    bindView: function(view) {\n        var me = this,\n            viewListeners = {\n                scroll: {\n                    fn: me.onViewScroll,\n                    element: 'el',\n                    scope: me\n                },\n                render: me.onViewRender,\n                resize: me.onViewResize,\n                boxready: {\n                    fn: me.onViewResize,\n                    scope: me,\n                    single: true\n                },\n\n                // If there are variable row heights, then in beforeRefresh, we have to find a common\n                // row so that we can synchronize the table's top position after the refresh.\n                // Also flag whether the grid view has focus so that it can be refocused after refresh.\n                beforerefresh: me.beforeViewRefresh,\n\n                refresh: me.onViewRefresh,\n                scope: me\n            },\n            storeListeners = {\n                guaranteedrange: me.onGuaranteedRange,\n                scope: me\n            },\n            gridListeners = {\n                reconfigure: me.onGridReconfigure,\n                scope: me\n            }, partner;\n\n        // If we need unbinding...\n        if (me.view) {\n            if (me.view.el) {\n                me.view.el.un('scroll', me.onViewScroll, me); // un does not understand the element options\n            }\n            \n            partner = view.lockingPartner;\n            if (partner) {\n                partner.un('refresh', me.onLockRefresh, me);\n            }\n            \n            me.view.un(viewListeners);\n            me.store.un(storeListeners);\n            if (me.grid) {\n                me.grid.un(gridListeners);\n            }\n            delete me.view.refreshSize; // Remove the injected refreshSize implementation\n        }\n\n        me.view = view;\n        me.grid = me.view.up('tablepanel');\n        me.store = view.store;\n        if (view.rendered) {\n            me.viewSize = me.store.viewSize = Math.ceil(view.getHeight() / me.rowHeight) + me.trailingBufferZone + (me.numFromEdge * 2) + me.leadingBufferZone;\n        }\n        \n        partner = view.lockingPartner;\n        if (partner) {\n            partner.on('refresh', me.onLockRefresh, me);\n        }\n\n        me.view.mon(me.store.pageMap, {\n            scope: me,\n            clear: me.onCacheClear\n        });\n\n        // During scrolling we do not need to refresh the height - the Grid height must be set by config or layout in order to create a scrollable\n        // table just larger than that, so removing the layout call improves efficiency and removes the flicker when the\n        // HeaderContainer is reset to scrollLeft:0, and then resynced on the very next \"scroll\" event.\n        me.view.refreshSize = Ext.Function.createInterceptor(me.view.refreshSize, me.beforeViewrefreshSize, me);\n\n        /**\n         * @property {Number} position\n         * Current pixel scroll position of the associated {@link Ext.view.Table View}.\n         */\n        me.position = 0;\n\n        // We are created in View constructor. There won't be an ownerCt at this time.\n        if (me.grid) {\n            me.grid.on(gridListeners);\n        } else {\n            me.view.on({\n                added: function() {\n                    me.grid = me.view.up('tablepanel');\n                    me.grid.on(gridListeners);\n                },\n                single: true\n            });\n        }\n\n        me.view.on(me.viewListeners = viewListeners);\n        me.store.on(storeListeners);\n    },\n\n    onCacheClear: function() {\n        var me = this;\n\n        // Do not do anything if view is not rendered, or if the reason for cache clearing is store destruction\n        if (me.view.rendered && !me.store.isDestroyed) {\n            // Temporarily disable scroll monitoring until the scroll event caused by any following *change* of scrollTop has fired.\n            // Otherwise it will attempt to process a scroll on a stale view\n            me.ignoreNextScrollEvent = me.view.el.dom.scrollTop !== 0;\n\n            me.view.el.dom.scrollTop = 0;\n            delete me.lastScrollDirection;\n            delete me.scrollOffset;\n            delete me.scrollProportion;\n        }\n    },\n\n    onGridReconfigure: function (grid) {\n        this.bindView(grid.view);\n    },\n\n    // Ensure that the stretcher element is inserted into the View as the first element.\n    onViewRender: function() {\n        var me = this,\n            view = me.view,\n            el = me.view.el,\n            stretcher;\n\n        me.stretcher = me.createStretcher(view);\n        \n        view = view.lockingPartner;\n        if (view) {\n            stretcher = me.stretcher;\n            me.stretcher = new Ext.CompositeElement(stretcher);\n            me.stretcher.add(me.createStretcher(view));\n        }\n    },\n    \n    createStretcher: function(view) {\n        var el = view.el;\n        el.setStyle('position', 'relative');\n        \n        return el.createChild({\n            style:{\n                position: 'absolute',\n                width: '1px',\n                height: 0,\n                top: 0,\n                left: 0\n            }\n        }, el.dom.firstChild);\n    },\n    \n    onViewResize: function(view, width, height) {\n        var me = this,\n            newViewSize;\n\n        newViewSize = Math.ceil(height / me.rowHeight) + me.trailingBufferZone + (me.numFromEdge * 2) + me.leadingBufferZone;\n        if (newViewSize > me.viewSize) {\n            me.viewSize = me.store.viewSize = newViewSize;\n            me.handleViewScroll(me.lastScrollDirection || 1);\n        }\n    },\n\n    // Used for variable row heights. Try to find the offset from scrollTop of a common row\n    beforeViewRefresh: function() {\n        var me = this,\n            view = me.view,\n            rows,\n            direction;\n\n        // Refreshing can cause loss of focus.\n        me.focusOnRefresh = Ext.Element.getActiveElement === view.el.dom;\n\n        // Only need all this is variableRowHeight\n        if (me.variableRowHeight) {\n            direction = me.lastScrollDirection;\n            me.commonRecordIndex = undefined;\n            // If we are refreshing in response to a scroll,\n            // And we know where the previous start was,\n            // and we're not teleporting out of visible range\n            // and the view is not empty\n            if (direction && (me.previousStart !== undefined) && (me.scrollProportion === undefined) && (rows = view.getNodes()).length) {\n\n                // We have scrolled downwards\n                if (direction === 1) {\n\n                    // If the ranges overlap, we are going to be able to position the table exactly\n                    if (me.tableStart <= me.previousEnd) {\n                        me.commonRecordIndex = rows.length - 1;\n\n                    }\n                }\n                // We have scrolled upwards\n                else if (direction === -1) {\n\n                    // If the ranges overlap, we are going to be able to position the table exactly\n                    if (me.tableEnd >= me.previousStart) {\n                        me.commonRecordIndex = 0;\n                    }\n                }\n                // Cache the old offset of the common row from the scrollTop\n                me.scrollOffset = -view.el.getOffsetsTo(rows[me.commonRecordIndex])[1];\n\n                // In the new table the common row is at a different index\n                me.commonRecordIndex -= (me.tableStart - me.previousStart);\n            } else {\n                me.scrollOffset = undefined;\n            }\n        }\n    },\n\n    onLockRefresh: function(view) {\n        view.table.dom.style.position = 'absolute';\n    },\n\n    // Used for variable row heights. Try to find the offset from scrollTop of a common row\n    // Ensure, upon each refresh, that the stretcher element is the correct height\n    onViewRefresh: function() {\n        var me = this,\n            store = me.store,\n            newScrollHeight,\n            view = me.view,\n            viewEl = view.el,\n            viewDom = viewEl.dom,\n            rows,\n            newScrollOffset,\n            scrollDelta,\n            table = view.table.dom,\n            tableTop,\n            scrollTop;\n\n        // Refresh causes loss of focus\n        if (me.focusOnRefresh) {\n            viewEl.focus();\n            me.focusOnRefresh = false;\n        }\n\n        // Scroll events caused by processing in here must be ignored, so disable for the duration\n        me.disabled = true;\n\n        // No scroll monitoring is needed if\n        //    All data is in view OR\n        //  Store is filtered locally.\n        //    - scrolling a locally filtered page is obv a local operation within the context of a huge set of pages \n        //      so local scrolling is appropriate.\n        if (store.getCount() === store.getTotalCount() || (store.isFiltered() && !store.remoteFilter)) {\n            me.stretcher.setHeight(0);\n            me.position = viewDom.scrollTop = 0;\n\n            // Chrome's scrolling went crazy upon zeroing of the stretcher, and left the view's scrollTop stuck at -15\n            // This is the only thing that fixes that\n            me.setTablePosition('absolute');\n\n            // We remain disabled now because no scrolling is needed - we have the full dataset in the Store\n            return;\n        }\n\n        me.stretcher.setHeight(newScrollHeight = me.getScrollHeight());\n\n        scrollTop = viewDom.scrollTop;\n\n        // Flag to the refreshSize interceptor that regular refreshSize postprocessing should be vetoed.\n        me.isScrollRefresh = (scrollTop > 0);\n\n        // If we have had to calculate the store position from the pure scroll bar position,\n        // then we must calculate the table's vertical position from the scrollProportion\n        if (me.scrollProportion !== undefined) {\n            me.setTablePosition('absolute');\n            me.setTableTop((me.scrollProportion ? (newScrollHeight * me.scrollProportion) - (table.offsetHeight * me.scrollProportion) : 0) + 'px');\n        } else {\n            me.setTablePosition('absolute');\n            me.setTableTop((tableTop = (me.tableStart||0) * me.rowHeight) + 'px');\n\n            // ScrollOffset to a common row was calculated in beforeViewRefresh, so we can synch table position with how it was before\n            if (me.scrollOffset) {\n                rows = view.getNodes();\n                newScrollOffset = -viewEl.getOffsetsTo(rows[me.commonRecordIndex])[1];\n                scrollDelta = newScrollOffset - me.scrollOffset;\n                me.position = (viewDom.scrollTop += scrollDelta);\n            }\n\n            // If the table is not fully in view view, scroll to where it is in view.\n            // This will happen when the page goes out of view unexpectedly, outside the\n            // control of the PagingScroller. For example, a refresh caused by a remote sort or filter reverting\n            // back to page 1.\n            // Note that with buffered Stores, only remote sorting is allowed, otherwise the locally\n            // sorted page will be out of order with the whole dataset.\n            else if ((tableTop > scrollTop) || ((tableTop + table.offsetHeight) < scrollTop + viewDom.clientHeight)) {\n                me.lastScrollDirection = -1;\n                me.position = viewDom.scrollTop = tableTop;\n            }\n        }\n\n        // Re-enable upon function exit\n        me.disabled = false;\n    },\n    \n    setTablePosition: function(position) {\n        this.setViewTableStyle(this.view, 'position', position);\n    },\n    \n    setTableTop: function(top){\n        this.setViewTableStyle(this.view, 'top', top);\n    },\n    \n    setViewTableStyle: function(view, prop, value) {\n        view.el.child('table', true).style[prop] = value;\n        view = view.lockingPartner;\n        \n        if (view) {\n            view.el.child('table', true).style[prop] = value;\n        }\n    },\n\n    beforeViewrefreshSize: function() {\n        // Veto the refreshSize if the refresh is due to a scroll.\n        if (this.isScrollRefresh) {\n            // If we're vetoing refreshSize, attach the table DOM to the View's Flyweight.\n            this.view.table.attach(this.view.el.child('table', true));\n            return (this.isScrollRefresh = false);\n        }\n    },\n\n    onGuaranteedRange: function(range, start, end) {\n        var me = this,\n            ds = me.store;\n\n        // this should never happen\n        if (range.length && me.visibleStart < range[0].index) {\n            return;\n        }\n\n        // Cache last table position in dataset so that if we are using variableRowHeight,\n        // we can attempt to locate a common row to align the table on.\n        me.previousStart = me.tableStart;\n        me.previousEnd = me.tableEnd;\n\n        me.tableStart = start;\n        me.tableEnd = end;\n        ds.loadRecords(range, {\n            start: start\n        });\n    },\n\n    onViewScroll: function(e, t) {\n        var me = this,\n            view = me.view,\n            lastPosition = me.position;\n\n        me.position = view.el.dom.scrollTop;\n\n        // Flag set when the scrollTop is programatically set to zero upon cache clear.\n        // We must not attempt to process that as a scroll event.\n        if (me.ignoreNextScrollEvent) {\n            me.ignoreNextScrollEvent = false;\n            return;\n        }\n\n        // Only check for nearing the edge if we are enabled.\n        // If there is no paging to be done (Store's dataset is all in memory) we will be disabled.\n        if (!me.disabled) {\n            me.lastScrollDirection = me.position > lastPosition ? 1 : -1;\n            // Check the position so we ignore horizontal scrolling\n            if (lastPosition !== me.position) {\n                me.handleViewScroll(me.lastScrollDirection);\n            }\n        }\n    },\n\n    handleViewScroll: function(direction) {\n        var me                = this,\n            store             = me.store,\n            view              = me.view,\n            viewSize          = me.viewSize,\n            totalCount        = store.getTotalCount(),\n            highestStartPoint = totalCount - viewSize,\n            visibleStart      = me.getFirstVisibleRowIndex(),\n            visibleEnd        = me.getLastVisibleRowIndex(),\n            el                = view.el.dom,\n            requestStart,\n            requestEnd;\n\n        // Only process if the total rows is larger than the visible page size\n        if (totalCount >= viewSize) {\n\n            // This is only set if we are using variable row height, and the thumb is dragged so that\n            // There are no remaining visible rows to vertically anchor the new table to.\n            // In this case we use the scrollProprtion to anchor the table to the correct relative\n            // position on the vertical axis.\n            me.scrollProportion = undefined;\n\n            // We're scrolling up\n            if (direction == -1) {\n\n                // If table starts at record zero, we have nothing to do\n                if (me.tableStart) {\n                    if (visibleStart !== undefined) {\n                        if (visibleStart < (me.tableStart + me.numFromEdge)) {\n                            requestStart = Math.max(0, visibleEnd + me.trailingBufferZone - viewSize);\n                        }\n                    }\n\n                    // The only way we can end up without a visible start is if, in variableRowHeight mode, the user drags\n                    // the thumb up out of the visible range. In this case, we have to estimate the start row index\n                    else {\n                        // If we have no visible rows to orientate with, then use the scroll proportion\n                        me.scrollProportion = el.scrollTop / (el.scrollHeight - el.clientHeight);\n                        requestStart = Math.max(0, totalCount * me.scrollProportion - (viewSize / 2) - me.numFromEdge - ((me.leadingBufferZone + me.trailingBufferZone) / 2));\n                    }\n                }\n            }\n            // We're scrolling down\n            else {\n                if (visibleStart !== undefined) {\n                    if (visibleEnd > (me.tableEnd - me.numFromEdge)) {\n                        requestStart = Math.max(0, visibleStart - me.trailingBufferZone);\n                    }\n                }\n\n                // The only way we can end up without a visible end is if, in variableRowHeight mode, the user drags\n                // the thumb down out of the visible range. In this case, we have to estimate the start row index\n                else {\n                    // If we have no visible rows to orientate with, then use the scroll proportion\n                    me.scrollProportion = el.scrollTop / (el.scrollHeight - el.clientHeight);\n                    requestStart = totalCount * me.scrollProportion - (viewSize / 2) - me.numFromEdge - ((me.leadingBufferZone + me.trailingBufferZone) / 2);\n                }\n            }\n\n            // We scrolled close to the edge and the Store needs reloading\n            if (requestStart !== undefined) {\n                // The calculation walked off the end; Request the highest possible chunk which starts on an even row count (Because of row striping)\n                if (requestStart > highestStartPoint) {\n                    requestStart = highestStartPoint & ~1;\n                    requestEnd = totalCount - 1;\n                }\n                // Make sure first row is even to ensure correct even/odd row striping\n                else {\n                    requestStart = requestStart & ~1;\n                    requestEnd = requestStart + viewSize - 1;\n                }\n\n                // If range is satsfied within the prefetch buffer, then just draw it from the prefetch buffer\n                if (store.rangeCached(requestStart, requestEnd)) {\n                    me.cancelLoad();\n                    store.guaranteeRange(requestStart, requestEnd);\n                }\n\n                // Required range is not in the prefetch buffer. Ask the store to prefetch it.\n                // We will recieve a guaranteedrange event when that is done.\n                else {\n                    me.attemptLoad(requestStart, requestEnd);\n                }\n            }\n        }\n    },\n\n    getFirstVisibleRowIndex: function() {\n        var me = this,\n            view = me.view,\n            scrollTop = view.el.dom.scrollTop,\n            rows,\n            count,\n            i,\n            rowBottom;\n\n        if (me.variableRowHeight) {\n            rows = view.getNodes();\n            count = rows.length;\n            if (!count) {\n                return;\n            }\n            rowBottom = Ext.fly(rows[0]).getOffsetsTo(view.el)[1];\n            for (i = 0; i < count; i++) {\n                rowBottom += rows[i].offsetHeight;\n\n                // Searching for the first visible row, and off the bottom of the clientArea, then there's no visible first row!\n                if (rowBottom > view.el.dom.clientHeight) {\n                    return;\n                }\n\n                // Return the index *within the total dataset* of the first visible row\n                // We cannot use the loop index to offset from the table's start index because of possible intervening group headers.\n                if (rowBottom > 0) {\n                    return view.getRecord(rows[i]).index;\n                }\n            }\n        } else {\n            return Math.floor(scrollTop / me.rowHeight);\n        }\n    },\n\n    getLastVisibleRowIndex: function() {\n        var me = this,\n            store = me.store,\n            view = me.view,\n            clientHeight = view.el.dom.clientHeight,\n            rows,\n            count,\n            i,\n            rowTop;\n\n        if (me.variableRowHeight) {\n            rows = view.getNodes();\n            if (!rows.length) {\n                return;\n            }\n            count = store.getCount() - 1;\n            rowTop = Ext.fly(rows[count]).getOffsetsTo(view.el)[1] + rows[count].offsetHeight;\n            for (i = count; i >= 0; i--) {\n                rowTop -= rows[i].offsetHeight;\n\n                // Searching for the last visible row, and off the top of the clientArea, then there's no visible last row!\n                if (rowTop < 0) {\n                    return;\n                }\n\n                // Return the index *within the total dataset* of the last visible row.\n                // We cannot use the loop index to offset from the table's start index because of possible intervening group headers.\n                if (rowTop < clientHeight) {\n                    return view.getRecord(rows[i]).index;\n                }\n            }\n        } else {\n            return me.getFirstVisibleRowIndex() + Math.ceil(clientHeight / me.rowHeight) + 1;\n        }\n    },\n\n    getScrollHeight: function() {\n        var me = this,\n            view   = me.view,\n            table,\n            firstRow,\n            store  = me.store,\n            deltaHeight = 0,\n            doCalcHeight = !me.hasOwnProperty('rowHeight');\n\n        if (me.variableRowHeight) {\n            table = me.view.table.dom;\n            if (doCalcHeight) {\n                me.initialTableHeight = table.offsetHeight;\n                me.rowHeight = me.initialTableHeight / me.store.getCount();\n            } else {\n                deltaHeight = table.offsetHeight - me.initialTableHeight;\n\n                // Store size has been bumped because of odd end row.\n                if (store.getCount() > me.viewSize) {\n                    deltaHeight -= me.rowHeight;\n                }\n            }\n        } else if (doCalcHeight) {\n            firstRow = view.el.down(view.getItemSelector());\n            if (firstRow) {\n                me.rowHeight = firstRow.getHeight(false, true);\n            }\n        }\n\n        return Math.floor(store.getTotalCount() * me.rowHeight) + deltaHeight;\n    },\n\n    attemptLoad: function(start, end) {\n        var me = this;\n        if (me.scrollToLoadBuffer) {\n            if (!me.loadTask) {\n                me.loadTask = new Ext.util.DelayedTask(me.doAttemptLoad, me, []);\n            }\n            me.loadTask.delay(me.scrollToLoadBuffer, me.doAttemptLoad, me, [start, end]);\n        } else {\n            me.store.guaranteeRange(start, end);\n        }\n    },\n\n    cancelLoad: function() {\n        if (this.loadTask) {\n            this.loadTask.cancel();\n        }\n    },\n\n    doAttemptLoad:  function(start, end) {\n        this.store.guaranteeRange(start, end);\n    },\n\n    destroy: function() {\n        var me = this,\n            scrollListener = me.viewListeners.scroll;\n\n        me.store.un({\n            guaranteedrange: me.onGuaranteedRange,\n            scope: me\n        });\n        me.view.un(me.viewListeners);\n        if (me.view.rendered) {\n            me.stretcher.remove();\n            me.view.el.un('scroll', scrollListener.fn, scrollListener.scope);\n        }\n    }\n});\n\n/**\n * This is a base class for layouts that contain a single item that automatically expands to fill the layout's\n * container. This class is intended to be extended or created via the layout:'fit'\n * {@link Ext.container.Container#layout} config, and should generally not need to be created directly via the new keyword.\n *\n * Fit layout does not have any direct config options (other than inherited ones). To fit a panel to a container using\n * Fit layout, simply set `layout: 'fit'` on the container and add a single panel to it.\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Fit Layout',\n *         width: 300,\n *         height: 150,\n *         layout:'fit',\n *         items: {\n *             title: 'Inner Panel',\n *             html: 'This is the inner panel content',\n *             bodyPadding: 20,\n *             border: false\n *         },\n *         renderTo: Ext.getBody()\n *     });\n *\n * If the container has multiple items, all of the items will all be equally sized. This is usually not\n * desired, so to avoid this, place only a **single** item in the container. This sizing of all items\n * can be used to provide a background {@link Ext.Img image} that is \"behind\" another item\n * such as a {@link Ext.view.View dataview} if you also absolutely position the items.\n */\nExt.define('Ext.layout.container.Fit', {\n\n    /* Begin Definitions */\n    extend: 'Ext.layout.container.Container',\n    alternateClassName: 'Ext.layout.FitLayout',\n\n    alias: 'layout.fit',\n\n    /* End Definitions */\n\n    itemCls: Ext.baseCSSPrefix + 'fit-item',\n    targetCls: Ext.baseCSSPrefix + 'layout-fit',\n    type: 'fit',\n   \n    /**\n     * @cfg {Object} defaultMargins\n     * If the individual contained items do not have a margins property specified or margin specified via CSS, the\n     * default margins from this property will be applied to each item.\n     *\n     * This property may be specified as an object containing margins to apply in the format:\n     *\n     *     {\n     *         top: (top margin),\n     *         right: (right margin),\n     *         bottom: (bottom margin),\n     *         left: (left margin)\n     *     }\n     *\n     * This property may also be specified as a string containing space-separated, numeric margin values. The order of\n     * the sides associated with each value matches the way CSS processes margin values:\n     *\n     *   - If there is only one value, it applies to all sides.\n     *   - If there are two values, the top and bottom borders are set to the first value and the right and left are\n     *     set to the second.\n     *   - If there are three values, the top is set to the first value, the left and right are set to the second,\n     *     and the bottom is set to the third.\n     *   - If there are four values, they apply to the top, right, bottom, and left, respectively.\n     *\n     */\n    defaultMargins: {\n        top: 0,\n        right: 0,\n        bottom: 0,\n        left: 0\n    },\n\n    manageMargins: true,\n\n    sizePolicies: {\n        0: { setsWidth: 0, setsHeight: 0 },\n        1: { setsWidth: 1, setsHeight: 0 },\n        2: { setsWidth: 0, setsHeight: 1 },\n        3: { setsWidth: 1, setsHeight: 1 }\n    },\n\n    getItemSizePolicy: function (item, ownerSizeModel) {\n        // this layout's sizePolicy is derived from its owner's sizeModel:\n        var sizeModel = ownerSizeModel || this.owner.getSizeModel(),\n            mode = (sizeModel.width.shrinkWrap ? 0 : 1) |\n                   (sizeModel.height.shrinkWrap ? 0 : 2);\n\n       return this.sizePolicies[mode];\n    },\n\n    beginLayoutCycle: function (ownerContext, firstCycle) {\n        var me = this,\n            // determine these before the lastSizeModels get updated:\n            resetHeight = me.lastHeightModel && me.lastHeightModel.calculated,\n            resetWidth = me.lastWidthModel && me.lastWidthModel.calculated,\n            resetSizes = resetWidth || resetHeight,\n            maxChildMinHeight = 0, maxChildMinWidth = 0,\n            c, childItems, i, item, length, margins, minHeight, minWidth, style, undef;\n\n        me.callParent(arguments);\n\n        // Clear any dimensions which we set before calculation, in case the current\n        // settings affect the available size. This particularly effects self-sizing\n        // containers such as fields, in which the target element is naturally sized,\n        // and should not be stretched by a sized child item.\n        if (resetSizes && ownerContext.targetContext.el.dom.tagName.toUpperCase() != 'TD') {\n            resetSizes = resetWidth = resetHeight = false;\n        }\n\n        childItems = ownerContext.childItems;\n        length = childItems.length;\n\n        for (i = 0; i < length; ++i) {\n            item = childItems[i];\n\n            // On the firstCycle, we determine the max of the minWidth/Height of the items\n            // since these can cause the container to grow scrollbars despite our attempts\n            // to fit the child to the container.\n            if (firstCycle) {\n                c = item.target;\n                minHeight = c.minHeight;\n                minWidth = c.minWidth;\n\n                if (minWidth || minHeight) {\n                    margins = item.marginInfo || item.getMarginInfo();\n                    // if the child item has undefined minWidth/Height, these will become\n                    // NaN by adding the margins...\n                    minHeight += margins.height;\n                    minWidth += margins.height;\n\n                    // if the child item has undefined minWidth/Height, these comparisons\n                    // will evaluate to false... that is, \"0 < NaN\" == false...\n                    if (maxChildMinHeight < minHeight) {\n                        maxChildMinHeight = minHeight;\n                    }\n                    if (maxChildMinWidth < minWidth) {\n                        maxChildMinWidth = minWidth;\n                    }\n                }\n            }\n\n            if (resetSizes) {\n                style = item.el.dom.style;\n\n                if (resetHeight) {\n                    style.height = '';\n                }\n                if (resetWidth) {\n                    style.width = '';\n                }\n            }\n        }\n\n        if (firstCycle) {\n            ownerContext.maxChildMinHeight = maxChildMinHeight;\n            ownerContext.maxChildMinWidth = maxChildMinWidth;\n        }\n\n        // Cache the overflowX/Y flags, but make them false in shrinkWrap mode (since we\n        // won't be triggering overflow in that case) and false if we have no minSize (so\n        // no child to trigger an overflow).\n        c = ownerContext.target;\n        ownerContext.overflowX = (!ownerContext.widthModel.shrinkWrap && \n                                   ownerContext.maxChildMinWidth &&\n                                   (c.autoScroll || c.overflowX)) || undef;\n\n        ownerContext.overflowY = (!ownerContext.heightModel.shrinkWrap &&\n                                   ownerContext.maxChildMinHeight &&\n                                   (c.autoScroll || c.overflowY)) || undef;\n    },\n\n    calculate : function (ownerContext) {\n        var me = this,\n            childItems = ownerContext.childItems,\n            length = childItems.length,\n            containerSize = me.getContainerSize(ownerContext),\n            info = {\n                length: length,\n                ownerContext: ownerContext,\n                targetSize: containerSize\n            },\n            shrinkWrapWidth = ownerContext.widthModel.shrinkWrap,\n            shrinkWrapHeight = ownerContext.heightModel.shrinkWrap,\n            overflowX = ownerContext.overflowX,\n            overflowY = ownerContext.overflowY,\n            scrollbars, scrollbarSize, padding, i, contentWidth, contentHeight;\n\n        if (overflowX || overflowY) {\n            // If we have children that have minHeight/Width, we may be forced to overflow\n            // and gain scrollbars. If so, we want to remove their space from the other\n            // axis so that we fit things inside the scrollbars rather than under them.\n            scrollbars = me.getScrollbarsNeeded(\n                    overflowX && containerSize.width, overflowY && containerSize.height,\n                    ownerContext.maxChildMinWidth, ownerContext.maxChildMinHeight);\n\n            if (scrollbars) {\n                scrollbarSize = Ext.getScrollbarSize();\n                if (scrollbars & 1) { // if we need the hscrollbar, remove its height\n                    containerSize.height -= scrollbarSize.height;\n                }\n                if (scrollbars & 2) { // if we need the vscrollbar, remove its width\n                    containerSize.width -= scrollbarSize.width;\n                }\n            }\n        }\n\n        // Size the child items to the container (if non-shrinkWrap):\n        for (i = 0; i < length; ++i) {\n            info.index = i;\n            me.fitItem(childItems[i], info);\n        }\n        \n        if (shrinkWrapHeight || shrinkWrapWidth) {\n            padding = ownerContext.targetContext.getPaddingInfo();\n            \n            if (shrinkWrapWidth) {\n                if (overflowY && !containerSize.gotHeight) {\n                    // if we might overflow vertically and don't have the container height,\n                    // we don't know if we will need a vscrollbar or not, so we must wait\n                    // for that height so that we can determine the contentWidth...\n                    me.done = false;\n                } else {\n                    contentWidth = info.contentWidth + padding.width;\n                    // the scrollbar flag (if set) will indicate that an overflow exists on\n                    // the horz(1) or vert(2) axis... if not set, then there could never be\n                    // an overflow...\n                    if (scrollbars & 2) { // if we need the vscrollbar, add its width\n                        contentWidth += scrollbarSize.width;\n                    }\n                    if (!ownerContext.setContentWidth(contentWidth)) {\n                        me.done = false;\n                    }\n                }\n            }\n\n            if (shrinkWrapHeight) {\n                if (overflowX && !containerSize.gotWidth) {\n                    // if we might overflow horizontally and don't have the container width,\n                    // we don't know if we will need a hscrollbar or not, so we must wait\n                    // for that width so that we can determine the contentHeight...\n                    me.done = false;\n                } else {\n                    contentHeight = info.contentHeight + padding.height;\n                    // the scrollbar flag (if set) will indicate that an overflow exists on\n                    // the horz(1) or vert(2) axis... if not set, then there could never be\n                    // an overflow...\n                    if (scrollbars & 1) { // if we need the hscrollbar, add its height\n                        contentHeight += scrollbarSize.height;\n                    }\n                    if (!ownerContext.setContentHeight(contentHeight)) {\n                        me.done = false;\n                    }\n                }\n            }\n        }\n    },\n\n    fitItem: function (itemContext, info) {\n        var me = this;\n\n        if (itemContext.invalid) {\n            me.done = false;\n            return;\n        }\n\n        info.margins = itemContext.getMarginInfo();\n        info.needed = info.got = 0;\n\n        me.fitItemWidth(itemContext, info);\n        me.fitItemHeight(itemContext, info);\n\n        // If not all required dimensions have been satisfied, we're not done.\n        if (info.got != info.needed) {\n            me.done = false;\n        }\n    },\n\n    fitItemWidth: function (itemContext, info) {\n        var contentWidth, width;\n        // Attempt to set only dimensions that are being controlled, not shrinkWrap dimensions\n        if (info.ownerContext.widthModel.shrinkWrap) {\n            // contentWidth must include the margins to be consistent with setItemWidth\n            width = itemContext.getProp('width') + info.margins.width;\n            // because we add margins, width will be NaN or a number (not undefined)\n\n            contentWidth = info.contentWidth;\n            if (contentWidth === undefined) {\n                info.contentWidth = width;\n            } else {\n                info.contentWidth = Math.max(contentWidth, width);\n            }\n        } else if (itemContext.widthModel.calculated) {\n            ++info.needed;\n            if (info.targetSize.gotWidth) {\n                ++info.got;\n                this.setItemWidth(itemContext, info);\n            }\n        }\n\n        this.positionItemX(itemContext, info);\n    },\n\n    fitItemHeight: function (itemContext, info) {\n        var contentHeight, height;\n        if (info.ownerContext.heightModel.shrinkWrap) {\n            // contentHeight must include the margins to be consistent with setItemHeight\n            height = itemContext.getProp('height') + info.margins.height;\n            // because we add margins, height will be NaN or a number (not undefined)\n\n            contentHeight = info.contentHeight;\n            if (contentHeight === undefined) {\n                info.contentHeight = height;\n            } else {\n                info.contentHeight = Math.max(contentHeight, height);\n            }\n        } else if (itemContext.heightModel.calculated) {\n            ++info.needed;\n            if (info.targetSize.gotHeight) {\n                ++info.got;\n                this.setItemHeight(itemContext, info);\n            }\n        }\n\n        this.positionItemY(itemContext, info);\n    },\n\n    positionItemX: function (itemContext, info) {\n        var margins = info.margins;\n\n        // Adjust position to account for configured margins or if we have multiple items\n        // (all items should overlap):\n        if (info.index || margins.left) {\n            itemContext.setProp('x', margins.left);\n        }\n\n        if (margins.width) {\n            // Need the margins for shrink-wrapping but old IE sometimes collapses the left margin into the padding\n            itemContext.setProp('margin-right', margins.width);\n        }\n    },\n\n    positionItemY: function (itemContext, info) {\n        var margins = info.margins;\n\n        if (info.index || margins.top) {\n            itemContext.setProp('y', margins.top);\n        }\n\n        if (margins.height) {\n            // Need the margins for shrink-wrapping but old IE sometimes collapses the top margin into the padding\n            itemContext.setProp('margin-bottom', margins.height);\n        }\n    },\n\n    setItemHeight: function (itemContext, info) {\n        itemContext.setHeight(info.targetSize.height - info.margins.height);\n    },\n\n    setItemWidth: function (itemContext, info) {\n        itemContext.setWidth(info.targetSize.width - info.margins.width);\n    }\n});\n\n/**\n * @author Nicolas Ferrero\n *\n * TablePanel is the basis of both {@link Ext.tree.Panel TreePanel} and {@link Ext.grid.Panel GridPanel}.\n *\n * TablePanel aggregates:\n *\n *  - a Selection Model\n *  - a View\n *  - a Store\n *  - Scrollers\n *  - Ext.grid.header.Container\n */\nExt.define('Ext.panel.Table', {\n    extend: 'Ext.panel.Panel',\n\n    alias: 'widget.tablepanel',\n\n    uses: [\n        'Ext.selection.RowModel',\n        'Ext.selection.CellModel',\n        'Ext.selection.CheckboxModel',\n        'Ext.grid.PagingScroller',\n        'Ext.grid.header.Container',\n        'Ext.grid.Lockable'\n    ],\n\n    extraBaseCls: Ext.baseCSSPrefix + 'grid',\n    extraBodyCls: Ext.baseCSSPrefix + 'grid-body',\n\n    layout: 'fit',\n    /**\n     * @property {Boolean} hasView\n     * True to indicate that a view has been injected into the panel.\n     */\n    hasView: false,\n\n    // each panel should dictate what viewType and selType to use\n    /**\n     * @cfg {String} viewType\n     * An xtype of view to use. This is automatically set to 'gridview' by {@link Ext.grid.Panel Grid}\n     * and to 'treeview' by {@link Ext.tree.Panel Tree}.\n     * @protected\n     */\n    viewType: null,\n\n    /**\n     * @cfg {Object} viewConfig\n     * A config object that will be applied to the grid's UI view. Any of the config options available for\n     * {@link Ext.view.Table} can be specified here. This option is ignored if {@link #view} is specified.\n     */\n\n    /**\n     * @cfg {Ext.view.Table} view\n     * The {@link Ext.view.Table} used by the grid. Use {@link #viewConfig} to just supply some config options to\n     * view (instead of creating an entire View instance).\n     */\n\n    /**\n     * @cfg {String} selType\n     * An xtype of selection model to use. Defaults to 'rowmodel'. This is used to create selection model if just\n     * a config object or nothing at all given in {@link #selModel} config.\n     */\n    selType: 'rowmodel',\n\n    /**\n     * @cfg {Ext.selection.Model/Object} selModel\n     * A {@link Ext.selection.Model selection model} instance or config object.  In latter case the {@link #selType}\n     * config option determines to which type of selection model this config is applied.\n     */\n\n    /**\n     * @cfg {Boolean} [multiSelect=false]\n     * True to enable 'MULTI' selection mode on selection model.\n     * @deprecated 4.1.1 Use {@link Ext.selection.Model#mode} 'MULTI' instead.\n     */\n\n    /**\n     * @cfg {Boolean} [simpleSelect=false]\n     * True to enable 'SIMPLE' selection mode on selection model.\n     * @deprecated 4.1.1 Use {@link Ext.selection.Model#mode} 'SIMPLE' instead.\n     */\n\n    /**\n     * @cfg {Ext.data.Store} store (required)\n     * The {@link Ext.data.Store Store} the grid should use as its data source.\n     */\n\n    /**\n     * @cfg {String/Boolean} scroll\n     * Scrollers configuration. Valid values are 'both', 'horizontal' or 'vertical'.\n     * True implies 'both'. False implies 'none'.\n     */\n    scroll: true,\n\n    /**\n     * @cfg {Ext.grid.column.Column[]/Object} columns\n     * An array of {@link Ext.grid.column.Column column} definition objects which define all columns that appear in this\n     * grid. Each column definition provides the header text for the column, and a definition of where the data for that\n     * column comes from.\n     *\n     * This can also be a configuration object for a {Ext.grid.header.Container HeaderContainer} which may override\n     * certain default configurations if necessary. For example, the special layout may be overridden to use a simpler\n     * layout, or one can set default values shared by all columns:\n     * \n     *     columns: {\n     *         items: [\n     *             {\n     *                 text: \"Column A\"\n     *                 dataIndex: \"field_A\"\n     *             },{\n     *                 text: \"Column B\",\n     *                 dataIndex: \"field_B\"\n     *             }, \n     *             ...\n     *         ],\n     *         defaults: {\n     *             flex: 1\n     *         }\n     *     }\n     */\n\n    /**\n     * @cfg {Boolean} forceFit\n     * Ttrue to force the columns to fit into the available width. Headers are first sized according to configuration,\n     * whether that be a specific width, or flex. Then they are all proportionally changed in width so that the entire\n     * content width is used. For more accurate control, it is more optimal to specify a flex setting on the columns\n     * that are to be stretched & explicit widths on columns that are not.\n     */\n\n    /**\n     * @cfg {Ext.grid.feature.Feature[]} features\n     * An array of grid Features to be added to this grid. See {@link Ext.grid.feature.Feature} for usage.\n     */\n\n    /**\n     * @cfg {Boolean} [hideHeaders=false]\n     * True to hide column headers.\n     */\n\n    /**\n     * @cfg {Boolean} deferRowRender\n     * Defaults to true to enable deferred row rendering.\n     *\n     * This allows the View to execute a refresh quickly, with the expensive update of the row structure deferred so\n     * that layouts with GridPanels appear, and lay out more quickly.\n     */\n\n    /**\n     * @cfg {Object} verticalScroller\n     * A config object to be used when configuring the {@link Ext.grid.PagingScroller scroll monitor} to control\n     * refreshing of data in an \"infinite grid\".\n     * \n     * Configurations of this object allow fine tuning of data caching which can improve performance and usability\n     * of the infinite grid.\n     */\n\n    deferRowRender: true,\n     \n    /**\n     * @cfg {Boolean} sortableColumns\n     * False to disable column sorting via clicking the header and via the Sorting menu items.\n     */\n    sortableColumns: true,\n\n    /**\n     * @cfg {Boolean} [enableLocking=false]\n     * True to enable locking support for this grid. Alternatively, locking will also be automatically\n     * enabled if any of the columns in the column configuration contain the locked config option.\n     */\n    enableLocking: false,\n\n    // private property used to determine where to go down to find views\n    // this is here to support locking.\n    scrollerOwner: true,\n\n    /**\n     * @cfg {Boolean} [enableColumnMove=true]\n     * False to disable column dragging within this grid.\n     */\n    enableColumnMove: true,\n    \n    /**\n     * @cfg {Boolean} [sealedColumns=false]\n     * True to constrain column dragging so that a column cannot be dragged in or out of it's\n     * current group. Only relevant while {@link #enableColumnMove} is enabled.\n     */\n    sealedColumns: false,\n\n    /**\n     * @cfg {Boolean} [enableColumnResize=true]\n     * False to disable column resizing within this grid.\n     */\n    enableColumnResize: true,\n\n    /**\n     * @cfg {Boolean} [enableColumnHide=true]\n     * False to disable column hiding within this grid.\n     */\n    enableColumnHide: true,\n\n    /**\n     * @cfg {Boolean} columnLines Adds column line styling\n     */\n\n    /**\n     * @cfg {Boolean} [rowLines=true] Adds row line styling\n     */\n    rowLines: true,\n\n    /**\n     * @cfg {Boolean} [disableSelection=false]\n     * True to disable selection model.\n     */\n\n    /**\n     * @cfg {String} emptyText Default text (html tags are accepted) to display in the Panel body when the Store\n     * is empty. When specified, and the Store is empty, the text will be rendered inside a DIV with the CSS class \"x-grid-empty\".\n     */\n    \n    /**\n     * @cfg {Boolean} [allowDeselect=false]\n     * True to allow deselecting a record. This config is forwarded to {@link Ext.selection.Model#allowDeselect}.\n     */\n\n    /**\n     * @property {Boolean} optimizedColumnMove\n     * If you are writing a grid plugin or a {Ext.grid.feature.Feature Feature} which creates a column-based structure which\n     * needs a view refresh when columns are moved, then set this property in the grid.\n     *\n     * An example is the built in {@link Ext.grid.feature.AbstractSummary Summary} Feature. This creates summary rows, and the\n     * summary columns must be in the same order as the data columns. This plugin sets the `optimizedColumnMove` to `false.\n     */\n\n    initComponent: function() {\n        if (!this.viewType) {\n            Ext.Error.raise(\"You must specify a viewType config.\");\n        }\n        if (this.headers) {\n            Ext.Error.raise(\"The headers config is not supported. Please specify columns instead.\");\n        }\n\n        var me          = this,\n            scroll      = me.scroll,\n            vertical    = false,\n            horizontal  = false,\n            headerCtCfg = me.columns || me.colModel,\n            view,\n            border = me.border,\n            i, len;\n\n        if (me.columnLines) {\n            me.addCls(Ext.baseCSSPrefix + 'grid-with-col-lines');\n        }\n\n        if (me.rowLines) {\n            me.addCls(Ext.baseCSSPrefix + 'grid-with-row-lines');\n        }\n\n        // Look up the configured Store. If none configured, use the fieldless, empty Store defined in Ext.data.Store.\n        me.store = Ext.data.StoreManager.lookup(me.store || 'ext-empty-store');\n\n        if (!headerCtCfg) {\n            Ext.Error.raise(\"A column configuration must be specified\");\n        }\n\n        // The columns/colModel config may be either a fully instantiated HeaderContainer, or an array of Column definitions, or a config object of a HeaderContainer\n        // Either way, we extract a columns property referencing an array of Column definitions.\n        if (headerCtCfg instanceof Ext.grid.header.Container) {\n            me.headerCt = headerCtCfg;\n            me.headerCt.border = border;\n            me.columns = me.headerCt.items.items;\n        } else {\n            if (Ext.isArray(headerCtCfg)) {\n                headerCtCfg = {\n                    items: headerCtCfg,\n                    border: border\n                };\n            }\n            Ext.apply(headerCtCfg, {\n                forceFit: me.forceFit,\n                sortable: me.sortableColumns,\n                enableColumnMove: me.enableColumnMove,\n                enableColumnResize: me.enableColumnResize,\n                enableColumnHide: me.enableColumnHide,\n                border:  border,\n                sealed: me.sealedColumns\n            });\n            me.columns = headerCtCfg.items;\n\n             // If any of the Column objects contain a locked property, and are not processed, this is a lockable TablePanel, a\n             // special view will be injected by the Ext.grid.Lockable mixin, so no processing of .\n             if (me.enableLocking || Ext.ComponentQuery.query('{locked !== undefined}{processed != true}', me.columns).length) {\n                 me.self.mixin('lockable', Ext.grid.Lockable);\n                 me.injectLockable();\n             }\n        }\n\n        me.scrollTask = new Ext.util.DelayedTask(me.syncHorizontalScroll, me);\n\n        me.addEvents(\n            // documented on GridPanel\n            'reconfigure',\n            /**\n             * @event viewready\n             * Fires when the grid view is available (use this for selecting a default row).\n             * @param {Ext.panel.Table} this\n             */\n            'viewready'\n        );\n\n        me.bodyCls = me.bodyCls || '';\n        me.bodyCls += (' ' + me.extraBodyCls);\n        \n        me.cls = me.cls || '';\n        me.cls += (' ' + me.extraBaseCls);\n\n        // autoScroll is not a valid configuration\n        delete me.autoScroll;\n\n        // If this TablePanel is lockable (Either configured lockable, or any of the defined columns has a 'locked' property)\n        // than a special lockable view containing 2 side-by-side grids will have been injected so we do not need to set up any UI.\n        if (!me.hasView) {\n\n            // If we were not configured with a ready-made headerCt (either by direct config with a headerCt property, or by passing\n            // a HeaderContainer instance as the 'columns' property, then go ahead and create one from the config object created above.\n            if (!me.headerCt) {\n                me.headerCt = new Ext.grid.header.Container(headerCtCfg);\n            }\n\n            // Extract the array of Column objects\n            me.columns = me.headerCt.items.items;\n\n            // If the Store is paging blocks of the dataset in, then it can only be sorted remotely.\n            if (me.store.buffered && !me.store.remoteSort) {\n                for (i = 0, len = me.columns.length; i < len; i++) {\n                    me.columns[i].sortable = false;\n                }\n            }\n\n            if (me.hideHeaders) {\n                me.headerCt.height = 0;\n                me.headerCt.addCls(Ext.baseCSSPrefix + 'grid-header-ct-hidden');\n                me.addCls(Ext.baseCSSPrefix + 'grid-header-hidden');\n                // IE Quirks Mode fix\n                // If hidden configuration option was used, several layout calculations will be bypassed.\n                if (Ext.isIEQuirks) {\n                    me.headerCt.style = {\n                        display: 'none'\n                    };\n                }\n            }\n\n            // turn both on.\n            if (scroll === true || scroll === 'both') {\n                vertical = horizontal = true;\n            } else if (scroll === 'horizontal') {\n                horizontal = true;\n            } else if (scroll === 'vertical') {\n                vertical = true;\n            }\n\n            me.relayHeaderCtEvents(me.headerCt);\n            me.features = me.features || [];\n            if (!Ext.isArray(me.features)) {\n                me.features = [me.features];\n            }\n            me.dockedItems = [].concat(me.dockedItems || []);\n            me.dockedItems.unshift(me.headerCt);\n            me.viewConfig = me.viewConfig || {};\n\n            // Buffered scrolling must preserve scroll on refresh\n            if (me.store && me.store.buffered) {\n                me.viewConfig.preserveScrollOnRefresh = true;\n            } else if (me.invalidateScrollerOnRefresh !== undefined) {\n                me.viewConfig.preserveScrollOnRefresh = !me.invalidateScrollerOnRefresh;\n            }\n\n            // AbstractDataView will look up a Store configured as an object\n            // getView converts viewConfig into a View instance\n            view = me.getView();\n\n            me.items = [view];\n            me.hasView = true;\n\n            if (vertical) {\n                // If the Store is buffered, create a PagingScroller to monitor the View's scroll progress,\n                // load the Store's prefetch buffer when it detects we are nearing an edge.\n                if (me.store.buffered) {\n                    me.verticalScroller = new Ext.grid.PagingScroller(Ext.apply({\n                        panel: me,\n                        store: me.store,\n                        view: me.view\n                    }, me.verticalScroller));\n                }\n            }\n\n            if (horizontal) {\n                // Add a listener to synchronize the horizontal scroll position of the headers\n                // with the table view's element... Unless we are not showing headers!\n                if (!me.hideHeaders) {\n                    view.on({\n                        scroll: {\n                            fn: me.onHorizontalScroll,\n                            element: 'el',\n                            scope: me\n                        }\n                    });\n                }\n            }\n\n            me.mon(view.store, {\n                load: me.onStoreLoad,\n                scope: me\n            });\n            me.mon(view, {\n                viewready: me.onViewReady,\n                refresh: me.onRestoreHorzScroll,\n                scope: me\n            });\n        }\n\n        // Relay events from the View whether it be a LockingView, or a regular GridView\n        this.relayEvents(me.view, [\n            /**\n             * @event beforeitemmousedown\n             * @inheritdoc Ext.view.View#beforeitemmousedown\n             */\n            'beforeitemmousedown',\n            /**\n             * @event beforeitemmouseup\n             * @inheritdoc Ext.view.View#beforeitemmouseup\n             */\n            'beforeitemmouseup',\n            /**\n             * @event beforeitemmouseenter\n             * @inheritdoc Ext.view.View#beforeitemmouseenter\n             */\n            'beforeitemmouseenter',\n            /**\n             * @event beforeitemmouseleave\n             * @inheritdoc Ext.view.View#beforeitemmouseleave\n             */\n            'beforeitemmouseleave',\n            /**\n             * @event beforeitemclick\n             * @inheritdoc Ext.view.View#beforeitemclick\n             */\n            'beforeitemclick',\n            /**\n             * @event beforeitemdblclick\n             * @inheritdoc Ext.view.View#beforeitemdblclick\n             */\n            'beforeitemdblclick',\n            /**\n             * @event beforeitemcontextmenu\n             * @inheritdoc Ext.view.View#beforeitemcontextmenu\n             */\n            'beforeitemcontextmenu',\n            /**\n             * @event itemmousedown\n             * @inheritdoc Ext.view.View#itemmousedown\n             */\n            'itemmousedown',\n            /**\n             * @event itemmouseup\n             * @inheritdoc Ext.view.View#itemmouseup\n             */\n            'itemmouseup',\n            /**\n             * @event itemmouseenter\n             * @inheritdoc Ext.view.View#itemmouseenter\n             */\n            'itemmouseenter',\n            /**\n             * @event itemmouseleave\n             * @inheritdoc Ext.view.View#itemmouseleave\n             */\n            'itemmouseleave',\n            /**\n             * @event itemclick\n             * @inheritdoc Ext.view.View#itemclick\n             */\n            'itemclick',\n            /**\n             * @event itemdblclick\n             * @inheritdoc Ext.view.View#itemdblclick\n             */\n            'itemdblclick',\n            /**\n             * @event itemcontextmenu\n             * @inheritdoc Ext.view.View#itemcontextmenu\n             */\n            'itemcontextmenu',\n            /**\n             * @event beforecontainermousedown\n             * @inheritdoc Ext.view.View#beforecontainermousedown\n             */\n            'beforecontainermousedown',\n            /**\n             * @event beforecontainermouseup\n             * @inheritdoc Ext.view.View#beforecontainermouseup\n             */\n            'beforecontainermouseup',\n            /**\n             * @event beforecontainermouseover\n             * @inheritdoc Ext.view.View#beforecontainermouseover\n             */\n            'beforecontainermouseover',\n            /**\n             * @event beforecontainermouseout\n             * @inheritdoc Ext.view.View#beforecontainermouseout\n             */\n            'beforecontainermouseout',\n            /**\n             * @event beforecontainerclick\n             * @inheritdoc Ext.view.View#beforecontainerclick\n             */\n            'beforecontainerclick',\n            /**\n             * @event beforecontainerdblclick\n             * @inheritdoc Ext.view.View#beforecontainerdblclick\n             */\n            'beforecontainerdblclick',\n            /**\n             * @event beforecontainercontextmenu\n             * @inheritdoc Ext.view.View#beforecontainercontextmenu\n             */\n            'beforecontainercontextmenu',\n            /**\n             * @event containermouseup\n             * @inheritdoc Ext.view.View#containermouseup\n             */\n            'containermouseup',\n            /**\n             * @event containermouseover\n             * @inheritdoc Ext.view.View#containermouseover\n             */\n            'containermouseover',\n            /**\n             * @event containermouseout\n             * @inheritdoc Ext.view.View#containermouseout\n             */\n            'containermouseout',\n            /**\n             * @event containerclick\n             * @inheritdoc Ext.view.View#containerclick\n             */\n            'containerclick',\n            /**\n             * @event containerdblclick\n             * @inheritdoc Ext.view.View#containerdblclick\n             */\n            'containerdblclick',\n            /**\n             * @event containercontextmenu\n             * @inheritdoc Ext.view.View#containercontextmenu\n             */\n            'containercontextmenu',\n            /**\n             * @event selectionchange\n             * @inheritdoc Ext.selection.Model#selectionchange\n             */\n            'selectionchange',\n            /**\n             * @event beforeselect\n             * @inheritdoc Ext.selection.RowModel#beforeselect\n             */\n            'beforeselect',\n            /**\n             * @event select\n             * @inheritdoc Ext.selection.RowModel#select\n             */\n            'select',\n            /**\n             * @event beforedeselect\n             * @inheritdoc Ext.selection.RowModel#beforedeselect\n             */\n            'beforedeselect',\n            /**\n             * @event deselect\n             * @inheritdoc Ext.selection.RowModel#deselect\n             */\n            'deselect'\n        ]);\n\n        me.callParent(arguments);\n        me.addStateEvents(['columnresize', 'columnmove', 'columnhide', 'columnshow', 'sortchange']);\n\n        if (me.headerCt) {\n            me.headerCt.on('afterlayout', me.onRestoreHorzScroll, me);\n        }\n    },\n\n    relayHeaderCtEvents: function (headerCt) {\n        this.relayEvents(headerCt, [\n            /**\n             * @event columnresize\n             * @inheritdoc Ext.grid.header.Container#columnresize\n             */\n            'columnresize',\n            /**\n             * @event columnmove\n             * @inheritdoc Ext.grid.header.Container#columnmove\n             */\n            'columnmove',\n            /**\n             * @event columnhide\n             * @inheritdoc Ext.grid.header.Container#columnhide\n             */\n            'columnhide',\n            /**\n             * @event columnshow\n             * @inheritdoc Ext.grid.header.Container#columnshow\n             */\n            'columnshow',\n            /**\n             * @event sortchange\n             * @inheritdoc Ext.grid.header.Container#sortchange\n             */\n            'sortchange'\n        ]);\n    },\n\n    getState: function(){\n        var me = this,\n            state = me.callParent(),\n            sorter = me.store.sorters.first();\n\n        state = me.addPropertyToState(state, 'columns', (me.headerCt || me).getColumnsState());\n\n        if (sorter) {\n            state = me.addPropertyToState(state, 'sort', {\n                property: sorter.property,\n                direction: sorter.direction,\n                root: sorter.root\n            });\n        }\n        return state;\n    },\n\n    applyState: function(state) {\n        var me = this,\n            sorter = state.sort,\n            store = me.store,\n            columns = state.columns;\n\n        delete state.columns;\n\n        // Ensure superclass has applied *its* state.\n        // AbstractComponent saves dimensions (and anchor/flex) plus collapsed state.\n        me.callParent(arguments);\n\n        if (columns) {\n            (me.headerCt || me).applyColumnsState(columns);\n        }\n\n        if (sorter) {\n            if (store.remoteSort) {\n                // Pass false to prevent a sort from occurring\n                store.sort({\n                    property: sorter.property,\n                    direction: sorter.direction,\n                    root: sorter.root\n                }, null, false);\n            } else {\n                store.sort(sorter.property, sorter.direction);\n            }\n        }\n    },\n\n    /**\n     * Returns the store associated with this Panel.\n     * @return {Ext.data.Store} The store\n     */\n    getStore: function(){\n        return this.store;\n    },\n\n    /**\n     * Gets the view for this panel.\n     * @return {Ext.view.Table}\n     */\n    getView: function() {\n        var me = this,\n            sm;\n\n        if (!me.view) {\n            sm = me.getSelectionModel();\n            me.view = Ext.widget(Ext.apply({}, me.viewConfig, {\n\n                // Features need a reference to the grid, so configure a reference into the View\n                grid: me,\n                deferInitialRefresh: me.deferRowRender !== false,\n                scroll: me.scroll,\n                xtype: me.viewType,\n                store: me.store,\n                headerCt: me.headerCt,\n                selModel: sm,\n                features: me.features,\n                panel: me,\n                emptyText : me.emptyText ? '<div class=\"' + Ext.baseCSSPrefix + 'grid-empty\">' + me.emptyText + '</div>' : ''\n            }));\n\n            // TableView's custom component layout, Ext.view.TableLayout requires a reference to the headerCt because it depends on the headerCt doing its work.\n            me.view.getComponentLayout().headerCt = me.headerCt;\n\n            me.mon(me.view, {\n                uievent: me.processEvent,\n                scope: me\n            });\n            sm.view = me.view;\n            me.headerCt.view = me.view;\n            me.relayEvents(me.view, [\n                /**\n                 * @event cellclick\n                 * Fired when table cell is clicked.\n                 * @param {Ext.view.Table} this\n                 * @param {HTMLElement} td The TD element that was clicked.\n                 * @param {Number} cellIndex\n                 * @param {Ext.data.Model} record\n                 * @param {HTMLElement} tr The TR element that was clicked.\n                 * @param {Number} rowIndex\n                 * @param {Ext.EventObject} e\n                 */\n                'cellclick',\n                /**\n                 * @event celldblclick\n                 * Fired when table cell is double clicked.\n                 * @param {Ext.view.Table} this\n                 * @param {HTMLElement} td The TD element that was clicked.\n                 * @param {Number} cellIndex\n                 * @param {Ext.data.Model} record\n                 * @param {HTMLElement} tr The TR element that was clicked.\n                 * @param {Number} rowIndex\n                 * @param {Ext.EventObject} e\n                 */\n                'celldblclick'\n            ]);\n        }\n        return me.view;\n    },\n\n    /**\n     * @private\n     * autoScroll is never valid for all classes which extend TablePanel.\n     */\n    setAutoScroll: Ext.emptyFn,\n\n    /**\n     * @private\n     * Processes UI events from the view. Propagates them to whatever internal Components need to process them.\n     * @param {String} type Event type, eg 'click'\n     * @param {Ext.view.Table} view TableView Component\n     * @param {HTMLElement} cell Cell HtmlElement the event took place within\n     * @param {Number} recordIndex Index of the associated Store Model (-1 if none)\n     * @param {Number} cellIndex Cell index within the row\n     * @param {Ext.EventObject} e Original event\n     */\n    processEvent: function(type, view, cell, recordIndex, cellIndex, e) {\n        var me = this,\n            header;\n\n        if (cellIndex !== -1) {\n            header = me.headerCt.getGridColumns()[cellIndex];\n            return header.processEvent.apply(header, arguments);\n        }\n    },\n\n    /**\n     * This method is obsolete in 4.1. The closest equivalent in\n     * 4.1 is {@link #doLayout}, but it is also possible that no\n     * layout is needed.\n     * @deprecated 4.1\n     */\n    determineScrollbars: function () {\n        Ext.log.warn('Obsolete');\n    },\n\n    /**\n     * This method is obsolete in 4.1. The closest equivalent in 4.1 is\n     * {@link Ext.AbstractComponent#updateLayout}, but it is also possible that no layout\n     * is needed.\n     * @deprecated 4.1\n     */\n    invalidateScroller: function () {\n        Ext.log.warn('Obsolete');\n    },\n\n    scrollByDeltaY: function(yDelta, animate) {\n        this.getView().scrollBy(0, yDelta, animate);\n    },\n\n    scrollByDeltaX: function(xDelta, animate) {\n        this.getView().scrollBy(xDelta, 0, animate);\n    },\n\n    afterCollapse: function() {\n        var me = this;\n        me.saveScrollPos();\n        me.saveScrollPos();\n        me.callParent(arguments);\n    },\n\n    afterExpand: function() {\n        var me = this;\n        me.callParent(arguments);\n        me.restoreScrollPos();\n        me.restoreScrollPos();\n    },\n\n    saveScrollPos: Ext.emptyFn,\n\n    restoreScrollPos: Ext.emptyFn,\n    \n    onHeaderResize: function(){\n        this.delayScroll();\n    },\n\n    // Update the view when a header moves\n    onHeaderMove: function(headerCt, header, colsToMove, fromIdx, toIdx) {\n        var me = this;\n\n        // If there are Features or Plugins which create DOM which must match column order, they set the optimizedColumnMove flag to false.\n        // In this case we must refresh the view on column move.\n        if (me.optimizedColumnMove === false) {\n            me.view.refresh();\n        }\n\n        // Simplest case for default DOM structure is just to swap the columns round in the view.\n        else {\n            me.view.moveColumn(fromIdx, toIdx, colsToMove);\n        }\n        me.delayScroll();\n    },\n\n    // Section onHeaderHide is invoked after view.\n    onHeaderHide: function(headerCt, header) {\n        this.delayScroll();\n    },\n\n    onHeaderShow: function(headerCt, header) {\n        this.delayScroll();\n    },\n    \n    delayScroll: function(){\n        var target = this.getScrollTarget().el;\n        if (target) {\n            this.scrollTask.delay(10, null, null, [target.dom.scrollLeft]);\n        }\n    },\n\n    /**\n     * @private\n     * Fires the TablePanel's viewready event when the view declares that its internal DOM is ready\n     */\n    onViewReady: function() {\n         this.fireEvent('viewready', this);   \n    },\n\n    /**\n     * @private\n     * Tracks when things happen to the view and preserves the horizontal scroll position.\n     */\n    onRestoreHorzScroll: function() {\n        var left = this.scrollLeftPos;\n        if (left) {\n            // We need to restore the body scroll position here\n            this.syncHorizontalScroll(left, true);\n        }\n    },\n\n    getScrollerOwner: function() {\n        var rootCmp = this;\n        if (!this.scrollerOwner) {\n            rootCmp = this.up('[scrollerOwner]');\n        }\n        return rootCmp;\n    },\n\n    /**\n     * Gets left hand side marker for header resizing.\n     * @private\n     */\n    getLhsMarker: function() {\n        var me = this;\n        return me.lhsMarker || (me.lhsMarker = Ext.DomHelper.append(me.el, {\n            cls: Ext.baseCSSPrefix + 'grid-resize-marker'\n        }, true));\n    },\n\n    /**\n     * Gets right hand side marker for header resizing.\n     * @private\n     */\n    getRhsMarker: function() {\n        var me = this;\n\n        return me.rhsMarker || (me.rhsMarker = Ext.DomHelper.append(me.el, {\n            cls: Ext.baseCSSPrefix + 'grid-resize-marker'\n        }, true));\n    },\n\n    /**\n     * Returns the selection model being used and creates it via the configuration if it has not been created already.\n     * @return {Ext.selection.Model} selModel\n     */\n    getSelectionModel: function(){\n        if (!this.selModel) {\n            this.selModel = {};\n        }\n\n        var mode = 'SINGLE',\n            type;\n        if (this.simpleSelect) {\n            mode = 'SIMPLE';\n        } else if (this.multiSelect) {\n            mode = 'MULTI';\n        }\n\n        Ext.applyIf(this.selModel, {\n            allowDeselect: this.allowDeselect,\n            mode: mode\n        });\n\n        if (!this.selModel.events) {\n            type = this.selModel.selType || this.selType;\n            this.selModel = Ext.create('selection.' + type, this.selModel);\n        }\n\n        if (!this.selModel.hasRelaySetup) {\n            this.relayEvents(this.selModel, [\n                'selectionchange', 'beforeselect', 'beforedeselect', 'select', 'deselect'\n            ]);\n            this.selModel.hasRelaySetup = true;\n        }\n\n        // lock the selection model if user\n        // has disabled selection\n        if (this.disableSelection) {\n            this.selModel.locked = true;\n        }\n        return this.selModel;\n    },\n    \n    getScrollTarget: function(){\n        var owner = this.getScrollerOwner(),\n            items = owner.query('tableview');\n            \n        return items[1] || items[0];\n    },\n\n    onHorizontalScroll: function(event, target) {\n        this.syncHorizontalScroll(target.scrollLeft);\n    },\n    \n    syncHorizontalScroll: function(left, setBody) {\n        var me = this,\n            scrollTarget;\n            \n        setBody = setBody === true;\n        // Only set the horizontal scroll if we've changed position,\n        // so that we don't set this on vertical scrolls\n        if (me.rendered && (setBody || left !== me.scrollLeftPos)) {\n            // Only set the body position if we're reacting to a refresh, otherwise\n            // we just need to set the header.\n            if (setBody) {   \n                scrollTarget = me.getScrollTarget();\n                scrollTarget.el.dom.scrollLeft = left;\n            }\n            me.headerCt.el.dom.scrollLeft = left;\n            me.scrollLeftPos = left;\n        }\n    },\n\n    // template method meant to be overriden\n    onStoreLoad: Ext.emptyFn,\n\n    getEditorParent: function() {\n        return this.body;\n    },\n\n    bindStore: function(store) {\n        var me = this;\n        me.store = store;\n        me.getView().bindStore(store);\n    },\n    \n    beforeDestroy: function(){\n        Ext.destroy(this.verticalScroller);\n        this.callParent();    \n    },\n\n    // documented on GridPanel\n    reconfigure: function(store, columns) {\n        var me = this,\n            headerCt = me.headerCt;\n\n        if (me.lockable) {\n            me.reconfigureLockable(store, columns);\n        } else {\n            Ext.suspendLayouts();\n            if (columns) {\n                // new columns, delete scroll pos\n                delete me.scrollLeftPos;\n                headerCt.removeAll();\n                headerCt.add(columns);\n            }\n            if (store) {\n                store = Ext.StoreManager.lookup(store);\n                me.bindStore(store);\n            } else {\n                me.getView().refresh();\n            }\n            headerCt.setSortState();\n            Ext.resumeLayouts(true);\n        }\n        me.fireEvent('reconfigure', me, store, columns);\n    }\n});\n\n/**\n * The grid View class provides extra {@link Ext.grid.Panel} specific functionality to the\n * {@link Ext.view.Table}. In general, this class is not instanced directly, instead a viewConfig\n * option is passed to the grid:\n *\n *     Ext.create('Ext.grid.Panel', {\n *         // other options\n *         viewConfig: {\n *             stripeRows: false\n *         }\n *     });\n *\n * ## Drag Drop\n *\n * Drag and drop functionality can be achieved in the grid by attaching a {@link Ext.grid.plugin.DragDrop} plugin\n * when creating the view.\n *\n *     Ext.create('Ext.grid.Panel', {\n *         // other options\n *         viewConfig: {\n *             plugins: {\n *                 ddGroup: 'people-group',\n *                 ptype: 'gridviewdragdrop',\n *                 enableDrop: false\n *             }\n *         }\n *     });\n */\nExt.define('Ext.grid.View', {\n    extend: 'Ext.view.Table',\n    alias: 'widget.gridview',\n\n    /**\n     * @cfg\n     * True to stripe the rows.\n     *\n     * This causes the CSS class **`x-grid-row-alt`** to be added to alternate rows of the grid. A default CSS rule is\n     * provided which sets a background color, but you can override this with a rule which either overrides the\n     * **background-color** style using the `!important` modifier, or which uses a CSS selector of higher specificity.\n     */\n    stripeRows: true,\n\n    autoScroll: true\n});\n\n/**\n * @author Aaron Conran\n * @docauthor Ed Spencer\n *\n * Grids are an excellent way of showing large amounts of tabular data on the client side. Essentially a supercharged\n * `<table>`, GridPanel makes it easy to fetch, sort and filter large amounts of data.\n *\n * Grids are composed of two main pieces - a {@link Ext.data.Store Store} full of data and a set of columns to render.\n *\n * ## Basic GridPanel\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *         storeId:'simpsonsStore',\n *         fields:['name', 'email', 'phone'],\n *         data:{'items':[\n *             { 'name': 'Lisa',  \"email\":\"lisa@simpsons.com\",  \"phone\":\"555-111-1224\"  },\n *             { 'name': 'Bart',  \"email\":\"bart@simpsons.com\",  \"phone\":\"555-222-1234\" },\n *             { 'name': 'Homer', \"email\":\"home@simpsons.com\",  \"phone\":\"555-222-1244\"  },\n *             { 'name': 'Marge', \"email\":\"marge@simpsons.com\", \"phone\":\"555-222-1254\"  }\n *         ]},\n *         proxy: {\n *             type: 'memory',\n *             reader: {\n *                 type: 'json',\n *                 root: 'items'\n *             }\n *         }\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Simpsons',\n *         store: Ext.data.StoreManager.lookup('simpsonsStore'),\n *         columns: [\n *             { text: 'Name',  dataIndex: 'name' },\n *             { text: 'Email', dataIndex: 'email', flex: 1 },\n *             { text: 'Phone', dataIndex: 'phone' }\n *         ],\n *         height: 200,\n *         width: 400,\n *         renderTo: Ext.getBody()\n *     });\n *\n * The code above produces a simple grid with three columns. We specified a Store which will load JSON data inline.\n * In most apps we would be placing the grid inside another container and wouldn't need to use the\n * {@link #height}, {@link #width} and {@link #renderTo} configurations but they are included here to make it easy to get\n * up and running.\n *\n * The grid we created above will contain a header bar with a title ('Simpsons'), a row of column headers directly underneath\n * and finally the grid rows under the headers.\n *\n * ## Configuring columns\n *\n * By default, each column is sortable and will toggle between ASC and DESC sorting when you click on its header. Each\n * column header is also reorderable by default, and each gains a drop-down menu with options to hide and show columns.\n * It's easy to configure each column - here we use the same example as above and just modify the columns config:\n *\n *     columns: [\n *         {\n *             text: 'Name',\n *             dataIndex: 'name',\n *             sortable: false,\n *             hideable: false,\n *             flex: 1\n *         },\n *         {\n *             text: 'Email',\n *             dataIndex: 'email',\n *             hidden: true\n *         },\n *         {\n *             text: 'Phone',\n *             dataIndex: 'phone',\n *             width: 100\n *         }\n *     ]\n *\n * We turned off sorting and hiding on the 'Name' column so clicking its header now has no effect. We also made the Email\n * column hidden by default (it can be shown again by using the menu on any other column). We also set the Phone column to\n * a fixed with of 100px and flexed the Name column, which means it takes up all remaining width after the other columns\n * have been accounted for. See the {@link Ext.grid.column.Column column docs} for more details.\n *\n * ## Renderers\n *\n * As well as customizing columns, it's easy to alter the rendering of individual cells using renderers. A renderer is\n * tied to a particular column and is passed the value that would be rendered into each cell in that column. For example,\n * we could define a renderer function for the email column to turn each email address into a mailto link:\n *\n *     columns: [\n *         {\n *             text: 'Email',\n *             dataIndex: 'email',\n *             renderer: function(value) {\n *                 return Ext.String.format('<a href=\"mailto:{0}\">{1}</a>', value, value);\n *             }\n *         }\n *     ]\n *\n * See the {@link Ext.grid.column.Column column docs} for more information on renderers.\n *\n * ## Selection Models\n *\n * Sometimes all you want is to render data onto the screen for viewing, but usually it's necessary to interact with or\n * update that data. Grids use a concept called a Selection Model, which is simply a mechanism for selecting some part of\n * the data in the grid. The two main types of Selection Model are RowSelectionModel, where entire rows are selected, and\n * CellSelectionModel, where individual cells are selected.\n *\n * Grids use a Row Selection Model by default, but this is easy to customise like so:\n *\n *     Ext.create('Ext.grid.Panel', {\n *         selType: 'cellmodel',\n *         store: ...\n *     });\n *\n * Specifying the `cellmodel` changes a couple of things. Firstly, clicking on a cell now\n * selects just that cell (using a {@link Ext.selection.RowModel rowmodel} will select the entire row), and secondly the\n * keyboard navigation will walk from cell to cell instead of row to row. Cell-based selection models are usually used in\n * conjunction with editing.\n *\n * ## Sorting & Filtering\n *\n * Every grid is attached to a {@link Ext.data.Store Store}, which provides multi-sort and filtering capabilities. It's\n * easy to set up a grid to be sorted from the start:\n *\n *     var myGrid = Ext.create('Ext.grid.Panel', {\n *         store: {\n *             fields: ['name', 'email', 'phone'],\n *             sorters: ['name', 'phone']\n *         },\n *         columns: [\n *             { text: 'Name',  dataIndex: 'name' },\n *             { text: 'Email', dataIndex: 'email' }\n *         ]\n *     });\n *\n * Sorting at run time is easily accomplished by simply clicking each column header. If you need to perform sorting on\n * more than one field at run time it's easy to do so by adding new sorters to the store:\n *\n *     myGrid.store.sort([\n *         { property: 'name',  direction: 'ASC' },\n *         { property: 'email', direction: 'DESC' }\n *     ]);\n *\n * See {@link Ext.data.Store} for examples of filtering.\n *\n * ## State saving\n * \n * When configured {@link #stateful}, grids save their column state (order and width) encapsulated within the default\n * Panel state of changed width and height and collapsed/expanded state.\n *\n * Each {@link #columns column} of the grid may be configured with a {@link Ext.grid.column.Column#stateId stateId} which\n * identifies that column locally within the grid.\n *\n * ## Plugins and Features\n *\n * Grid supports addition of extra functionality through features and plugins:\n *\n * - {@link Ext.grid.plugin.CellEditing CellEditing} - editing grid contents one cell at a time.\n *\n * - {@link Ext.grid.plugin.RowEditing RowEditing} - editing grid contents an entire row at a time.\n *\n * - {@link Ext.grid.plugin.DragDrop DragDrop} - drag-drop reordering of grid rows.\n *\n * - {@link Ext.toolbar.Paging Paging toolbar} - paging through large sets of data.\n *\n * - {@link Ext.grid.PagingScroller Infinite scrolling} - another way to handle large sets of data.\n *\n * - {@link Ext.grid.RowNumberer RowNumberer} - automatically numbered rows.\n *\n * - {@link Ext.grid.feature.Grouping Grouping} - grouping together rows having the same value in a particular field.\n *\n * - {@link Ext.grid.feature.Summary Summary} - a summary row at the bottom of a grid.\n *\n * - {@link Ext.grid.feature.GroupingSummary GroupingSummary} - a summary row at the bottom of each group.\n */\nExt.define('Ext.grid.Panel', {\n    extend: 'Ext.panel.Table',\n    requires: ['Ext.grid.View'],\n    alias: ['widget.gridpanel', 'widget.grid'],\n    alternateClassName: ['Ext.list.ListView', 'Ext.ListView', 'Ext.grid.GridPanel'],\n    viewType: 'gridview',\n\n    lockable: false,\n\n    // Required for the Lockable Mixin. These are the configurations which will be copied to the\n    // normal and locked sub tablepanels\n    bothCfgCopy: [\n        'invalidateScrollerOnRefresh',\n        'hideHeaders',\n        'enableColumnHide',\n        'enableColumnMove',\n        'enableColumnResize',\n        'sortableColumns'\n    ],\n    normalCfgCopy: [ \n        'verticalScroller', \n        'verticalScrollDock', \n        'verticalScrollerType', \n        'scroll'\n    ],\n    lockedCfgCopy: [],\n\n    /**\n     * @cfg {Boolean} rowLines False to remove row line styling\n     */\n    rowLines: true\n\n    // Columns config is required in Grid\n    /**\n     * @cfg {Ext.grid.column.Column[]/Object} columns (required)\n     * @inheritdoc\n     */\n\n    /**\n     * @event reconfigure\n     * Fires after a reconfigure.\n     * @param {Ext.grid.Panel} this\n     * @param {Ext.data.Store} store The store that was passed to the {@link #method-reconfigure} method\n     * @param {Object[]} columns The column configs that were passed to the {@link #method-reconfigure} method\n     */\n\n    /**\n     * @method reconfigure\n     * Reconfigures the grid with a new store/columns. Either the store or the columns can be omitted if you don't wish\n     * to change them.\n     * @param {Ext.data.Store} store (Optional) The new store.\n     * @param {Object[]} columns (Optional) An array of column configs\n     */\n});\n\n// Currently has the following issues:\n// - Does not handle postEditValue\n// - Fields without editors need to sync with their values in Store\n// - starting to edit another record while already editing and dirty should probably prevent it\n// - aggregating validation messages\n// - tabIndex is not managed bc we leave elements in dom, and simply move via positioning\n// - layout issues when changing sizes/width while hidden (layout bug)\n\n/**\n * Internal utility class used to provide row editing functionality. For developers, they should use\n * the RowEditing plugin to use this functionality with a grid.\n *\n * @private\n */\nExt.define('Ext.grid.RowEditor', {\n    extend: 'Ext.form.Panel',\n    requires: [\n        'Ext.tip.ToolTip',\n        'Ext.util.HashMap',\n        'Ext.util.KeyNav'\n    ],\n\n    //<locale>\n    saveBtnText  : 'Update',\n    //</locale>\n    //<locale>\n    cancelBtnText: 'Cancel',\n    //</locale>\n    //<locale>\n    errorsText: 'Errors',\n    //</locale>\n    //<locale>\n    dirtyText: 'You need to commit or cancel your changes',\n    //</locale>\n\n    lastScrollLeft: 0,\n    lastScrollTop: 0,\n\n    border: false,\n    \n    // Change the hideMode to offsets so that we get accurate measurements when\n    // the roweditor is hidden for laying out things like a TriggerField.\n    hideMode: 'offsets',\n\n    initComponent: function() {\n        var me = this,\n            form;\n\n        me.cls = Ext.baseCSSPrefix + 'grid-row-editor';\n\n        me.layout = {\n            type: 'hbox',\n            align: 'middle'\n        };\n\n        // Maintain field-to-column mapping\n        // It's easy to get a field from a column, but not vice versa\n        me.columns = new Ext.util.HashMap();\n        me.columns.getKey = function(columnHeader) {\n            var f;\n            if (columnHeader.getEditor) {\n                f = columnHeader.getEditor();\n                if (f) {\n                    return f.id;\n                }\n            }\n            return columnHeader.id;\n        };\n        me.mon(me.columns, {\n            add: me.onFieldAdd,\n            remove: me.onFieldRemove,\n            replace: me.onFieldReplace,\n            scope: me\n        });\n\n        me.callParent(arguments);\n\n        if (me.fields) {\n            me.setField(me.fields);\n            delete me.fields;\n        }\n        \n        me.mon(Ext.container.Container.hierarchyEventSource, {\n            scope: me,\n            show: me.repositionIfVisible\n        });\n\n        form = me.getForm();\n        form.trackResetOnLoad = true;\n    },\n\n    onFieldChange: function() {\n        var me = this,\n            form = me.getForm(),\n            valid = form.isValid();\n        if (me.errorSummary && me.isVisible()) {\n            me[valid ? 'hideToolTip' : 'showToolTip']();\n        }\n        me.updateButton(valid);\n        me.isValid = valid;\n    },\n    \n    updateButton: function(valid){\n        var buttons = this.floatingButtons; \n        if (buttons) {\n            buttons.child('#update').setDisabled(!valid);\n        }    \n    },\n\n    afterRender: function() {\n        var me = this,\n            plugin = me.editingPlugin;\n\n        me.callParent(arguments);\n        me.mon(me.renderTo, 'scroll', me.onCtScroll, me, { buffer: 100 });\n\n        // Prevent from bubbling click events to the grid view\n        me.mon(me.el, {\n            click: Ext.emptyFn,\n            stopPropagation: true\n        });\n\n        me.el.swallowEvent([\n            'keypress',\n            'keydown'\n        ]);\n\n        me.keyNav = new Ext.util.KeyNav(me.el, {\n            enter: plugin.completeEdit,\n            esc: plugin.onEscKey,\n            scope: plugin\n        });\n\n        me.mon(plugin.view, {\n            beforerefresh: me.onBeforeViewRefresh,\n            refresh: me.onViewRefresh,\n            itemremove: me.onViewItemRemove,\n            scope: me\n        });\n    },\n\n    onBeforeViewRefresh: function(view) {\n        var me = this,\n            viewDom = view.el.dom;\n\n        if (me.el.dom.parentNode === viewDom) {\n            viewDom.removeChild(me.el.dom);\n        }\n    },\n\n    onViewRefresh: function(view) {\n        var me = this,\n            viewDom = view.el.dom,\n            context = me.context,\n            idx;\n\n        viewDom.appendChild(me.el.dom);\n\n        // Recover our row node after a view refresh\n        if (context && (idx = context.store.indexOf(context.record)) >= 0) {\n            context.row = view.getNode(idx);\n            me.reposition();\n            if (me.tooltip && me.tooltip.isVisible()) {\n                me.tooltip.setTarget(context.row);\n            }\n        } else {\n            me.editingPlugin.cancelEdit();\n        }\n    },\n\n    onViewItemRemove: function(record, index) {\n        var context = this.context;\n        if (context && record === context.record) {\n            // if the record being edited was removed, cancel editing\n            this.editingPlugin.cancelEdit();\n        }\n    },\n\n    onCtScroll: function(e, target) {\n        var me = this,\n            scrollTop  = target.scrollTop,\n            scrollLeft = target.scrollLeft;\n\n        if (scrollTop !== me.lastScrollTop) {\n            me.lastScrollTop = scrollTop;\n            if ((me.tooltip && me.tooltip.isVisible()) || me.hiddenTip) {\n                me.repositionTip();\n            }\n        }\n        if (scrollLeft !== me.lastScrollLeft) {\n            me.lastScrollLeft = scrollLeft;\n            me.reposition();\n        }\n    },\n\n    onColumnAdd: function(column) {\n        if (!column.isGroupHeader) {\n            this.setField(column);\n        }\n    },\n\n    onColumnRemove: function(column) {\n        this.columns.remove(column);\n    },\n\n    onColumnResize: function(column, width) {\n        if (!column.isGroupHeader) {\n            column.getEditor().setWidth(width - 2);\n            this.repositionIfVisible();\n        }\n    },\n\n    onColumnHide: function(column) {\n        if (!column.isGroupHeader) {\n            column.getEditor().hide();\n            this.repositionIfVisible();\n        }\n    },\n\n    onColumnShow: function(column) {\n        var field = column.getEditor();\n        field.setWidth(column.getWidth() - 2).show();\n        this.repositionIfVisible();\n    },\n\n    onColumnMove: function(column, fromIdx, toIdx) {\n        if (!column.isGroupHeader) {\n            var field = column.getEditor();\n            if (this.items.indexOf(field) != toIdx) {\n                this.move(fromIdx, toIdx);\n            }\n        }\n    },\n\n    onFieldAdd: function(map, fieldId, column) {\n        var me = this,\n            colIdx,\n            field;\n\n        if (!column.isGroupHeader) {\n            colIdx = me.editingPlugin.grid.headerCt.getHeaderIndex(column);\n            field = column.getEditor({ xtype: 'displayfield' });\n            me.insert(colIdx, field);\n        }\n    },\n\n    onFieldRemove: function(map, fieldId, column) {\n        var me = this,\n            field,\n            fieldEl;\n\n        if (!column.isGroupHeader) {\n            field = column.getEditor();\n            fieldEl = field.el;\n            me.remove(field, false);\n            if (fieldEl) {\n                fieldEl.remove();\n            }\n        }\n    },\n\n    onFieldReplace: function(map, fieldId, column, oldColumn) {\n        this.onFieldRemove(map, fieldId, oldColumn);\n    },\n\n    clearFields: function() {\n        var map = this.columns,\n            key;\n\n        for (key in map) {\n            if (map.hasOwnProperty(key)) {\n                map.removeAtKey(key);\n            }\n        }\n    },\n\n    getFloatingButtons: function() {\n        var me = this,\n            cssPrefix = Ext.baseCSSPrefix,\n            btnsCss = cssPrefix + 'grid-row-editor-buttons',\n            plugin = me.editingPlugin,\n            minWidth = Ext.panel.Panel.prototype.minButtonWidth,\n            btns;\n\n        if (!me.floatingButtons) {\n            btns = me.floatingButtons = new Ext.Container({\n                renderTpl: [\n                    '<div class=\"{baseCls}-ml\"></div>',\n                    '<div class=\"{baseCls}-mr\"></div>',\n                    '<div class=\"{baseCls}-bl\"></div>',\n                    '<div class=\"{baseCls}-br\"></div>',\n                    '<div class=\"{baseCls}-bc\"></div>',\n                    '{%this.renderContainer(out,values)%}'\n                ],\n                width: 200,\n                renderTo: me.el,\n                baseCls: btnsCss,\n                layout: {\n                    type: 'hbox',\n                    align: 'middle'\n                },\n                defaults: {\n                    flex: 1,\n                    margins: '0 1 0 1'\n                },\n                items: [{\n                    itemId: 'update',\n                    xtype: 'button',\n                    handler: plugin.completeEdit,\n                    scope: plugin,\n                    text: me.saveBtnText,\n                    minWidth: minWidth\n                }, {\n                    xtype: 'button',\n                    handler: plugin.cancelEdit,\n                    scope: plugin,\n                    text: me.cancelBtnText,\n                    minWidth: minWidth\n                }]\n            });\n\n            // Prevent from bubbling click events to the grid view\n            me.mon(btns.el, {\n                // BrowserBug: Opera 11.01\n                //   causes the view to scroll when a button is focused from mousedown\n                mousedown: Ext.emptyFn,\n                click: Ext.emptyFn,\n                stopEvent: true\n            });\n        }\n        return me.floatingButtons;\n    },\n    \n    repositionIfVisible: function(c){\n        var me = this,\n            view = me.view;\n        \n        // If we're showing ourselves, jump out\n        // If the component we're showing doesn't contain the view\n        if (c && (c == me || !view.isDescendantOf(c))) {\n            return;\n        }\n        \n        if (me.isVisible() && view.isVisible(true)) {\n            me.reposition();    \n        }\n    },\n\n    reposition: function(animateConfig) {\n        var me = this,\n            context = me.context,\n            row = context && Ext.get(context.row),\n            btns = me.getFloatingButtons(),\n            btnEl = btns.el,\n            grid = me.editingPlugin.grid,\n            viewEl = grid.view.el,\n\n            // always get data from ColumnModel as its what drives\n            // the GridView's sizing\n            mainBodyWidth = grid.headerCt.getFullWidth(),\n            scrollerWidth = grid.getWidth(),\n\n            // use the minimum as the columns may not fill up the entire grid\n            // width\n            width = Math.min(mainBodyWidth, scrollerWidth),\n            scrollLeft = grid.view.el.dom.scrollLeft,\n            btnWidth = btns.getWidth(),\n            left = (width - btnWidth) / 2 + scrollLeft,\n            y, rowH, newHeight,\n\n            invalidateScroller = function() {\n                btnEl.scrollIntoView(viewEl, false);\n                if (animateConfig && animateConfig.callback) {\n                    animateConfig.callback.call(animateConfig.scope || me);\n                }\n            },\n            \n            animObj;\n\n        // need to set both top/left\n        if (row && Ext.isElement(row.dom)) {\n            // Bring our row into view if necessary, so a row editor that's already\n            // visible and animated to the row will appear smooth\n            row.scrollIntoView(viewEl, false);\n\n            // Get the y position of the row relative to its top-most static parent.\n            // offsetTop will be relative to the table, and is incorrect\n            // when mixed with certain grid features (e.g., grouping).\n            y = row.getXY()[1] - 5;\n            rowH = row.getHeight();\n            newHeight = rowH + (me.editingPlugin.grid.rowLines ? 9 : 10);\n\n            // Set editor height to match the row height\n            if (me.getHeight() != newHeight) {\n                me.setHeight(newHeight);\n                me.el.setLeft(0);\n            }\n\n            if (animateConfig) {\n                animObj = {\n                    to: {\n                        y: y\n                    },\n                    duration: animateConfig.duration || 125,\n                    listeners: {\n                        afteranimate: function() {\n                            invalidateScroller();\n                            y = row.getXY()[1] - 5;\n                        }\n                    }\n                };\n                me.el.animate(animObj);\n            } else {\n                me.el.setY(y);\n                invalidateScroller();\n            }\n        }\n        if (me.getWidth() != mainBodyWidth) {\n            me.setWidth(mainBodyWidth);\n        }\n        btnEl.setLeft(left);\n    },\n\n    getEditor: function(fieldInfo) {\n        var me = this;\n\n        if (Ext.isNumber(fieldInfo)) {\n            // Query only form fields. This just future-proofs us in case we add\n            // other components to RowEditor later on.  Don't want to mess with\n            // indices.\n            return me.query('>[isFormField]')[fieldInfo];\n        } else if (fieldInfo.isHeader && !fieldInfo.isGroupHeader) {\n            return fieldInfo.getEditor();\n        }\n    },\n\n    removeField: function(field) {\n        var me = this;\n\n        // Incase we pass a column instead, which is fine\n        field = me.getEditor(field);\n        me.mun(field, 'validitychange', me.onValidityChange, me);\n\n        // Remove field/column from our mapping, which will fire the event to\n        // remove the field from our container\n        me.columns.removeAtKey(field.id);\n        Ext.destroy(field);\n    },\n\n    setField: function(column) {\n        var me = this,\n            i,\n            length, field;\n\n        if (Ext.isArray(column)) {\n            length = column.length;\n\n            for (i = 0; i < length; i++) {\n                me.setField(column[i]);\n            }\n\n            return;\n        }\n\n        // Get a default display field if necessary\n        field = column.getEditor(null, {\n            xtype: 'displayfield',\n            // Override Field's implementation so that the default display fields will not return values. This is done because\n            // the display field will pick up column renderers from the grid.\n            getModelData: function() {\n                return null;\n            }\n        });\n        field.margins = '0 0 0 2';\n        me.mon(field, 'change', me.onFieldChange, me);\n        \n        if (me.isVisible() && me.context) {\n            if (field.is('displayfield')) {\n                me.renderColumnData(field, me.context.record, column);\n            } else {\n                field.suspendEvents();\n                field.setValue(me.context.record.get(column.dataIndex));\n                field.resumeEvents();\n            }\n        }\n\n        // Maintain mapping of fields-to-columns\n        // This will fire events that maintain our container items\n        \n        me.columns.add(field.id, column);\n        if (column.hidden) {\n            me.onColumnHide(column);\n        } else if (column.rendered) {\n            // Setting after initial render\n            me.onColumnShow(column);\n        }\n    },\n\n    loadRecord: function(record) {\n        var me     = this,\n            form   = me.getForm(),\n            fields = form.getFields(),\n            items  = fields.items,\n            length = items.length,\n            i, displayFields,\n            isValid;\n            \n        // temporarily suspend events on form fields before loading record to prevent the fields' change events from firing\n        for (i = 0; i < length; i++) {\n            items[i].suspendEvents();\n        }\n\n        form.loadRecord(record);\n\n        for (i = 0; i < length; i++) {\n            items[i].resumeEvents();\n        }\n\n        isValid = form.isValid();\n        if (me.errorSummary) {\n            if (isValid) {\n                me.hideToolTip();\n            } else {\n                me.showToolTip();\n            }\n        }\n        \n        me.updateButton(isValid);\n\n        // render display fields so they honor the column renderer/template\n        displayFields = me.query('>displayfield');\n        length = displayFields.length;\n\n        for (i = 0; i < length; i++) {\n            me.renderColumnData(displayFields[i], record);\n        }\n    },\n\n    renderColumnData: function(field, record, activeColumn) {\n        var me = this,\n            grid = me.editingPlugin.grid,\n            headerCt = grid.headerCt,\n            view = grid.view,\n            store = view.store,\n            column = activeColumn || me.columns.get(field.id),\n            value = record.get(column.dataIndex),\n            renderer = column.editRenderer || column.renderer,\n            metaData,\n            rowIdx,\n            colIdx;\n\n        // honor our column's renderer (TemplateHeader sets renderer for us!)\n        if (renderer) {\n            metaData = { tdCls: '', style: '' };\n            rowIdx = store.indexOf(record);\n            colIdx = headerCt.getHeaderIndex(column);\n\n            value = renderer.call(\n                column.scope || headerCt.ownerCt,\n                value,\n                metaData,\n                record,\n                rowIdx,\n                colIdx,\n                store,\n                view\n            );\n        }\n\n        field.setRawValue(value);\n        field.resetOriginalValue();\n    },\n\n    beforeEdit: function() {\n        var me = this;\n\n        if (me.isVisible() && me.errorSummary && !me.autoCancel && me.isDirty()) {\n            me.showToolTip();\n            return false;\n        }\n    },\n\n    /**\n     * Start editing the specified grid at the specified position.\n     * @param {Ext.data.Model} record The Store data record which backs the row to be edited.\n     * @param {Ext.data.Model} columnHeader The Column object defining the column to be edited.\n     */\n    startEdit: function(record, columnHeader) {\n        var me = this,\n            grid = me.editingPlugin.grid,\n            store = grid.store,\n            context = me.context = Ext.apply(me.editingPlugin.context, {\n                view: grid.getView(),\n                store: store\n            });\n\n        // make sure our row is selected before editing\n        context.grid.getSelectionModel().select(record);\n\n        // Reload the record data\n        me.loadRecord(record);\n\n        if (!me.isVisible()) {\n            me.show();\n            me.focusContextCell();\n        } else {\n            me.reposition({\n                callback: this.focusContextCell\n            });\n        }\n    },\n\n    // Focus the cell on start edit based upon the current context\n    focusContextCell: function() {\n        var field = this.getEditor(this.context.colIdx);\n        if (field && field.focus) {\n            field.focus();\n        }\n    },\n\n    cancelEdit: function() {\n        var me     = this,\n            form   = me.getForm(),\n            fields = form.getFields(),\n            items  = fields.items,\n            length = items.length,\n            i;\n\n        me.hide();\n        form.clearInvalid();\n\n        // temporarily suspend events on form fields before reseting the form to prevent the fields' change events from firing\n        for (i = 0; i < length; i++) {\n            items[i].suspendEvents();\n        }\n\n        form.reset();\n\n        for (i = 0; i < length; i++) {\n            items[i].resumeEvents();\n        }\n    },\n\n    completeEdit: function() {\n        var me = this,\n            form = me.getForm();\n\n        if (!form.isValid()) {\n            return;\n        }\n\n        form.updateRecord(me.context.record);\n        me.hide();\n        return true;\n    },\n\n    onShow: function() {\n        this.callParent(arguments);\n        this.reposition();\n    },\n\n    onHide: function() {\n        var me = this;\n        me.callParent(arguments);\n        if (me.tooltip) {\n            me.hideToolTip();\n        }\n        if (me.context) {\n            me.context.view.focus();\n            me.context = null;\n        }\n    },\n\n    isDirty: function() {\n        var me = this,\n            form = me.getForm();\n        return form.isDirty();\n    },\n\n    getToolTip: function() {\n        return this.tooltip || (this.tooltip = new Ext.tip.ToolTip({\n            cls: Ext.baseCSSPrefix + 'grid-row-editor-errors',\n            title: this.errorsText,\n            autoHide: false,\n            closable: true,\n            closeAction: 'disable',\n            anchor: 'left'\n        }));\n    },\n\n    hideToolTip: function() {\n        var me = this,\n            tip = me.getToolTip();\n        if (tip.rendered) {\n            tip.disable();\n        }\n        me.hiddenTip = false;\n    },\n\n    showToolTip: function() {\n        var me = this,\n            tip = me.getToolTip(),\n            context = me.context,\n            row = Ext.get(context.row),\n            viewEl = context.grid.view.el;\n\n        tip.setTarget(row);\n        tip.showAt([-10000, -10000]);\n        tip.update(me.getErrors());\n        tip.mouseOffset = [viewEl.getWidth() - row.getWidth() + me.lastScrollLeft + 15, 0];\n        me.repositionTip();\n        tip.doLayout();\n        tip.enable();\n    },\n\n    repositionTip: function() {\n        var me = this,\n            tip = me.getToolTip(),\n            context = me.context,\n            row = Ext.get(context.row),\n            viewEl = context.grid.view.el,\n            viewHeight = viewEl.getHeight(),\n            viewTop = me.lastScrollTop,\n            viewBottom = viewTop + viewHeight,\n            rowHeight = row.getHeight(),\n            rowTop = row.dom.offsetTop,\n            rowBottom = rowTop + rowHeight;\n\n        if (rowBottom > viewTop && rowTop < viewBottom) {\n            tip.show();\n            me.hiddenTip = false;\n        } else {\n            tip.hide();\n            me.hiddenTip = true;\n        }\n    },\n\n    getErrors: function() {\n        var me        = this,\n            dirtyText = !me.autoCancel && me.isDirty() ? me.dirtyText + '<br />' : '',\n            errors    = [],\n            fields    = me.query('>[isFormField]'),\n            length    = fields.length,\n            i;\n\n        function createListItem(e) {\n            return '<li>' + e + '</li>';\n        }\n\n        for (i = 0; i < length; i++) {\n            errors = errors.concat(\n                Ext.Array.map(fields[i].getErrors(), createListItem)\n            );\n        }\n\n        return dirtyText + '<ul>' + errors.join('') + '</ul>';\n    },\n    \n    beforeDestroy: function(){\n        Ext.destroy(this.floatingButtons, this.tooltip);\n        this.callParent();    \n    }\n});\n\n/**\n * Plugin to add header resizing functionality to a HeaderContainer.\n * Always resizing header to the left of the splitter you are resizing.\n */\nExt.define('Ext.grid.plugin.HeaderResizer', {\n    extend: 'Ext.AbstractPlugin',\n    requires: ['Ext.dd.DragTracker', 'Ext.util.Region'],\n    alias: 'plugin.gridheaderresizer',\n\n    disabled: false,\n\n    config: {\n        /**\n         * @cfg {Boolean} dynamic\n         * True to resize on the fly rather than using a proxy marker.\n         * @accessor\n         */\n        dynamic: false\n    },\n\n    colHeaderCls: Ext.baseCSSPrefix + 'column-header',\n\n    minColWidth: 40,\n    maxColWidth: 1000,\n    wResizeCursor: 'col-resize',\n    eResizeCursor: 'col-resize',\n    // not using w and e resize bc we are only ever resizing one\n    // column\n    //wResizeCursor: Ext.isWebKit ? 'w-resize' : 'col-resize',\n    //eResizeCursor: Ext.isWebKit ? 'e-resize' : 'col-resize',\n\n    init: function(headerCt) {\n        this.headerCt = headerCt;\n        headerCt.on('render', this.afterHeaderRender, this, {single: true});\n    },\n\n    /**\n     * @private\n     * AbstractComponent calls destroy on all its plugins at destroy time.\n     */\n    destroy: function() {\n        if (this.tracker) {\n            this.tracker.destroy();\n        }\n    },\n\n    afterHeaderRender: function() {\n        var headerCt = this.headerCt,\n            el = headerCt.el;\n\n        headerCt.mon(el, 'mousemove', this.onHeaderCtMouseMove, this);\n\n        this.tracker = new Ext.dd.DragTracker({\n            disabled: this.disabled,\n            onBeforeStart: Ext.Function.bind(this.onBeforeStart, this),\n            onStart: Ext.Function.bind(this.onStart, this),\n            onDrag: Ext.Function.bind(this.onDrag, this),\n            onEnd: Ext.Function.bind(this.onEnd, this),\n            tolerance: 3,\n            autoStart: 300,\n            el: el\n        });\n    },\n\n    // As we mouse over individual headers, change the cursor to indicate\n    // that resizing is available, and cache the resize target header for use\n    // if/when they mousedown.\n    onHeaderCtMouseMove: function(e, t) {\n        var me = this,\n            prevSiblings,\n            headerEl, overHeader, resizeHeader, resizeHeaderOwnerGrid, ownerGrid;\n\n        if (me.headerCt.dragging) {\n            if (me.activeHd) {\n                me.activeHd.el.dom.style.cursor = '';\n                delete me.activeHd;\n            }\n        } else {\n            headerEl = e.getTarget('.' + me.colHeaderCls, 3, true);\n\n            if (headerEl){\n                overHeader = Ext.getCmp(headerEl.id);\n\n                // On left edge, go back to the previous non-hidden header.\n                if (overHeader.isOnLeftEdge(e)) {\n                    resizeHeader = overHeader.previousNode('gridcolumn:not([hidden]):not([isGroupHeader])')\n                    // There may not *be* a previous non-hidden header.\n                    if (resizeHeader) {\n\n                        ownerGrid = me.headerCt.up('tablepanel');\n                        resizeHeaderOwnerGrid = resizeHeader.up('tablepanel');\n\n                        // Need to check that previousNode didn't go outside the current grid/tree\n                        // But in the case of a Grid which contains a locked and normal grid, allow previousNode to jump\n                        // from the first column of the normalGrid to the last column of the lockedGrid\n                        if (!((resizeHeaderOwnerGrid === ownerGrid) || ((ownerGrid.ownerCt.isXType('tablepanel')) && ownerGrid.ownerCt.view.lockedGrid === resizeHeaderOwnerGrid))) {\n                            resizeHeader = null;\n                        }\n                    }\n                }\n                // Else, if on the right edge, we're resizing the column we are over\n                else if (overHeader.isOnRightEdge(e)) {\n                    resizeHeader = overHeader;\n                }\n                // Between the edges: we are not resizing\n                else {\n                    resizeHeader = null;\n                }\n\n                // We *are* resizing\n                if (resizeHeader) {\n                    // If we're attempting to resize a group header, that cannot be resized,\n                    // so find its last visible leaf header; Group headers are sized\n                    // by the size of their child headers.\n                    if (resizeHeader.isGroupHeader) {\n                        prevSiblings = resizeHeader.getGridColumns();\n                        resizeHeader = prevSiblings[prevSiblings.length - 1];\n                    }\n\n                    // Check if the header is resizable. Continue checking the old \"fixed\" property, bug also\n                    // check whether the resizablwe property is set to false.\n                    if (resizeHeader && !(resizeHeader.fixed || (resizeHeader.resizable === false) || me.disabled)) {\n                        me.activeHd = resizeHeader;\n                        overHeader.el.dom.style.cursor = me.eResizeCursor;\n                    }\n                // reset\n                } else {\n                    overHeader.el.dom.style.cursor = '';\n                    delete me.activeHd;\n                }\n            }\n        }\n    },\n\n    // only start when there is an activeHd\n    onBeforeStart : function(e){\n        var t = e.getTarget();\n        // cache the activeHd because it will be cleared.\n        this.dragHd = this.activeHd;\n\n        if (!!this.dragHd && !Ext.fly(t).hasCls(Ext.baseCSSPrefix + 'column-header-trigger') && !this.headerCt.dragging) {\n            //this.headerCt.dragging = true;\n            this.tracker.constrainTo = this.getConstrainRegion();\n            return true;\n        } else {\n            this.headerCt.dragging = false;\n            return false;\n        }\n    },\n\n    // get the region to constrain to, takes into account max and min col widths\n    getConstrainRegion: function() {\n        var me       = this,\n            dragHdEl = me.dragHd.el,\n            region   = Ext.util.Region.getRegion(dragHdEl),\n            nextHd;\n\n        // If forceFit, then right constraint is based upon not being able to force the next header\n        // beyond the minColWidth. If there is no next header, then the header may not be expanded.\n        if (me.headerCt.forceFit) {\n            nextHd = me.dragHd.nextNode('gridcolumn:not([hidden]):not([isGroupHeader])');\n        }\n\n         return region.adjust(\n            0,\n            me.headerCt.forceFit ? (nextHd ? nextHd.getWidth() - me.minColWidth : 0) : me.maxColWidth - dragHdEl.getWidth(),\n            0,\n            me.minColWidth\n        );\n    },\n\n    // initialize the left and right hand side markers around\n    // the header that we are resizing\n    onStart: function(e){\n        var me       = this,\n            dragHd   = me.dragHd,\n            dragHdEl = dragHd.el,\n            width    = dragHdEl.getWidth(),\n            headerCt = me.headerCt,\n            t        = e.getTarget(),\n            xy, gridSection, dragHct, firstSection, lhsMarker, rhsMarker, el, offsetLeft, offsetTop, topLeft, markerHeight, top;\n\n        if (me.dragHd && !Ext.fly(t).hasCls(Ext.baseCSSPrefix + 'column-header-trigger')) {\n            headerCt.dragging = true;\n        }\n\n        me.origWidth = width;\n\n        // setup marker proxies\n        if (!me.dynamic) {\n            xy           = dragHdEl.getXY();\n            gridSection  = headerCt.up('[scrollerOwner]');\n            dragHct      = me.dragHd.up(':not([isGroupHeader])');\n            firstSection = dragHct.up();\n            lhsMarker    = gridSection.getLhsMarker();\n            rhsMarker    = gridSection.getRhsMarker();\n            el           = rhsMarker.parent();\n            offsetLeft   = el.getLocalX();\n            offsetTop    = el.getLocalY();\n            topLeft      = el.translatePoints(xy);\n            markerHeight = firstSection.body.getHeight() + headerCt.getHeight();\n            top = topLeft.top - offsetTop;\n\n            lhsMarker.setTop(top);\n            rhsMarker.setTop(top);\n            lhsMarker.setHeight(markerHeight);\n            rhsMarker.setHeight(markerHeight);\n            lhsMarker.setLeft(topLeft.left - offsetLeft);\n            rhsMarker.setLeft(topLeft.left + width - offsetLeft);\n        }\n    },\n\n    // synchronize the rhsMarker with the mouse movement\n    onDrag: function(e){\n        if (!this.dynamic) {\n            var xy          = this.tracker.getXY('point'),\n                gridSection = this.headerCt.up('[scrollerOwner]'),\n                rhsMarker   = gridSection.getRhsMarker(),\n                el          = rhsMarker.parent(),\n                topLeft     = el.translatePoints(xy),\n                offsetLeft  = el.getLocalX();\n\n            rhsMarker.setLeft(topLeft.left - offsetLeft);\n        // Resize as user interacts\n        } else {\n            this.doResize();\n        }\n    },\n\n    onEnd: function(e){\n        this.headerCt.dragging = false;\n        if (this.dragHd) {\n            if (!this.dynamic) {\n                var dragHd      = this.dragHd,\n                    gridSection = this.headerCt.up('[scrollerOwner]'),\n                    lhsMarker   = gridSection.getLhsMarker(),\n                    rhsMarker   = gridSection.getRhsMarker(),\n                    offscreen   = -9999;\n\n                // hide markers\n                lhsMarker.setLeft(offscreen);\n                rhsMarker.setLeft(offscreen);\n            }\n            this.doResize();\n        }\n    },\n\n    doResize: function() {\n        if (this.dragHd) {\n            var dragHd = this.dragHd,\n                nextHd,\n                offset = this.tracker.getOffset('point');\n\n            // resize the dragHd\n            if (dragHd.flex) {\n                delete dragHd.flex;\n            }\n\n            Ext.suspendLayouts();\n\n            // Set the new column width.\n            dragHd.setWidth(this.origWidth + offset[0]);\n \n            // In the case of forceFit, change the following Header width.\n            // Constraining so that neither neighbour can be sized to below minWidth is handled in getConstrainRegion\n            if (this.headerCt.forceFit) {\n                nextHd = dragHd.nextNode('gridcolumn:not([hidden]):not([isGroupHeader])');\n                if (nextHd) {\n                    delete nextHd.flex;\n                    nextHd.setWidth(nextHd.getWidth() - offset[0]);\n                }\n            }\n\n            // Apply the two width changes by laying out the owning HeaderContainer\n            Ext.resumeLayouts(true);\n        }\n    },\n\n    disable: function() {\n        this.disabled = true;\n        if (this.tracker) {\n            this.tracker.disable();\n        }\n    },\n\n    enable: function() {\n        this.disabled = false;\n        if (this.tracker) {\n            this.tracker.enable();\n        }\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.grid.header.DragZone', {\n    extend: 'Ext.dd.DragZone',\n    colHeaderCls: Ext.baseCSSPrefix + 'column-header',\n    maxProxyWidth: 120,\n\n    constructor: function(headerCt) {\n        this.headerCt = headerCt;\n        this.ddGroup =  this.getDDGroup();\n        this.callParent([headerCt.el]);\n        this.proxy.el.addCls(Ext.baseCSSPrefix + 'grid-col-dd');\n    },\n\n    getDDGroup: function() {\n        return 'header-dd-zone-' + this.headerCt.up('[scrollerOwner]').id;\n    },\n\n    getDragData: function(e) {\n        var header = e.getTarget('.'+this.colHeaderCls),\n            headerCmp,\n            ddel;\n\n        if (header) {\n            headerCmp = Ext.getCmp(header.id);\n            if (!this.headerCt.dragging && headerCmp.draggable && !(headerCmp.isOnLeftEdge(e) || headerCmp.isOnRightEdge(e))) {\n                ddel = document.createElement('div');\n                ddel.innerHTML = Ext.getCmp(header.id).text;\n                return {\n                    ddel: ddel,\n                    header: headerCmp\n                };\n            }\n        }\n        return false;\n    },\n\n    onBeforeDrag: function() {\n        return !(this.headerCt.dragging || this.disabled);\n    },\n\n    onInitDrag: function() {\n        this.headerCt.dragging = true;\n        this.callParent(arguments);\n    },\n\n    onDragDrop: function() {\n        this.headerCt.dragging = false;\n        this.callParent(arguments);\n    },\n\n    afterRepair: function() {\n        this.callParent();\n        this.headerCt.dragging = false;\n    },\n\n    getRepairXY: function() {\n        return this.dragData.header.el.getXY();\n    },\n    \n    disable: function() {\n        this.disabled = true;\n    },\n    \n    enable: function() {\n        this.disabled = false;\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.grid.header.DropZone', {\n    extend: 'Ext.dd.DropZone',\n    colHeaderCls: Ext.baseCSSPrefix + 'column-header',\n    proxyOffsets: [-4, -9],\n\n    constructor: function(headerCt){\n        this.headerCt = headerCt;\n        this.ddGroup = this.getDDGroup();\n        this.callParent([headerCt.el]);\n    },\n\n    getDDGroup: function() {\n        return 'header-dd-zone-' + this.headerCt.up('[scrollerOwner]').id;\n    },\n\n    getTargetFromEvent : function(e){\n        return e.getTarget('.' + this.colHeaderCls);\n    },\n\n    getTopIndicator: function() {\n        if (!this.topIndicator) {\n            this.topIndicator = Ext.DomHelper.append(Ext.getBody(), {\n                cls: \"col-move-top\",\n                html: \"&#160;\"\n            }, true);\n        }\n        return this.topIndicator;\n    },\n\n    getBottomIndicator: function() {\n        if (!this.bottomIndicator) {\n            this.bottomIndicator = Ext.DomHelper.append(Ext.getBody(), {\n                cls: \"col-move-bottom\",\n                html: \"&#160;\"\n            }, true);\n        }\n        return this.bottomIndicator;\n    },\n\n    getLocation: function(e, t) {\n        var x      = e.getXY()[0],\n            region = Ext.fly(t).getRegion(),\n            pos, header;\n\n        if ((region.right - x) <= (region.right - region.left) / 2) {\n            pos = \"after\";\n        } else {\n            pos = \"before\";\n        }\n        return {\n            pos: pos,\n            header: Ext.getCmp(t.id),\n            node: t\n        };\n    },\n\n    positionIndicator: function(draggedHeader, node, e){\n        var location = this.getLocation(e, node),\n            header = location.header,\n            pos    = location.pos,\n            nextHd = draggedHeader.nextSibling('gridcolumn:not([hidden])'),\n            prevHd = draggedHeader.previousSibling('gridcolumn:not([hidden])'),\n            topIndicator, bottomIndicator, topAnchor, bottomAnchor,\n            topXY, bottomXY, headerCtEl, minX, maxX,\n            allDropZones, ln, i, dropZone;\n\n        // Cannot drag beyond non-draggable start column\n        if (!header.draggable && header.getIndex() === 0) {\n            return false;\n        }\n\n        this.lastLocation = location;\n\n        if ((draggedHeader !== header) &&\n            ((pos === \"before\" && nextHd !== header) ||\n            (pos === \"after\" && prevHd !== header)) &&\n            !header.isDescendantOf(draggedHeader)) {\n\n            // As we move in between different DropZones that are in the same\n            // group (such as the case when in a locked grid), invalidateDrop\n            // on the other dropZones.\n            allDropZones = Ext.dd.DragDropManager.getRelated(this);\n            ln = allDropZones.length;\n            i  = 0;\n\n            for (; i < ln; i++) {\n                dropZone = allDropZones[i];\n                if (dropZone !== this && dropZone.invalidateDrop) {\n                    dropZone.invalidateDrop();\n                }\n            }\n\n\n            this.valid = true;\n            topIndicator = this.getTopIndicator();\n            bottomIndicator = this.getBottomIndicator();\n            if (pos === 'before') {\n                topAnchor = 'tl';\n                bottomAnchor = 'bl';\n            } else {\n                topAnchor = 'tr';\n                bottomAnchor = 'br';\n            }\n            topXY = header.el.getAnchorXY(topAnchor);\n            bottomXY = header.el.getAnchorXY(bottomAnchor);\n\n            // constrain the indicators to the viewable section\n            headerCtEl = this.headerCt.el;\n            minX = headerCtEl.getLeft();\n            maxX = headerCtEl.getRight();\n\n            topXY[0] = Ext.Number.constrain(topXY[0], minX, maxX);\n            bottomXY[0] = Ext.Number.constrain(bottomXY[0], minX, maxX);\n\n            // adjust by offsets, this is to center the arrows so that they point\n            // at the split point\n            topXY[0] -= 4;\n            topXY[1] -= 9;\n            bottomXY[0] -= 4;\n\n            // position and show indicators\n            topIndicator.setXY(topXY);\n            bottomIndicator.setXY(bottomXY);\n            topIndicator.show();\n            bottomIndicator.show();\n        // invalidate drop operation and hide indicators\n        } else {\n            this.invalidateDrop();\n        }\n    },\n\n    invalidateDrop: function() {\n        this.valid = false;\n        this.hideIndicators();\n    },\n\n    onNodeOver: function(node, dragZone, e, data) {\n        var me = this,\n            header = me.headerCt,\n            doPosition = true,\n            from = data.header,\n            to;\n            \n        if (data.header.el.dom === node) {\n            doPosition = false;\n        } else {\n            to = me.getLocation(e, node).header;\n            doPosition = (from.ownerCt === to.ownerCt) || (!from.ownerCt.sealed && !to.ownerCt.sealed);\n        }\n        \n        if (doPosition) {\n            me.positionIndicator(data.header, node, e);\n        } else {\n            me.valid = false;\n        }\n        return me.valid ? me.dropAllowed : me.dropNotAllowed;\n    },\n\n    hideIndicators: function() {\n        this.getTopIndicator().hide();\n        this.getBottomIndicator().hide();\n    },\n\n    onNodeOut: function() {\n        this.hideIndicators();\n    },\n\n    onNodeDrop: function(node, dragZone, e, data) {\n        if (this.valid) {\n            var dragHeader   = data.header,\n                lastLocation = this.lastLocation,\n                targetHeader = lastLocation.header,\n                fromCt       = dragHeader.ownerCt,\n                fromHeader   = dragHeader.up('headercontainer:not(gridcolumn)'),\n                localFromIdx = fromCt.items.indexOf(dragHeader), // Container.items is a MixedCollection\n                toCt         = targetHeader.ownerCt,\n                toHeader     = targetHeader.up('headercontainer:not(gridcolumn)'),\n                localToIdx   = toCt.items.indexOf(targetHeader),\n                headerCt     = this.headerCt,\n                fromIdx      = headerCt.getHeaderIndex(dragHeader),\n                colsToMove   = dragHeader.isGroupHeader ? dragHeader.query(':not([isGroupHeader])').length : 1,\n                toIdx        = headerCt.getHeaderIndex(targetHeader),\n                groupCt,\n                scrollerOwner;\n\n            // Drop position is to the right of the targetHeader, increment the toIdx correctly\n            if (lastLocation.pos === 'after') {\n                localToIdx++;\n                toIdx += targetHeader.isGroupHeader ? targetHeader.query(':not([isGroupHeader])').length : 1;\n            }\n\n            // If we are dragging in between two HeaderContainers that have had the lockable\n            // mixin injected we will lock/unlock headers in between sections, and then continue\n            // with another execution of onNodeDrop to ensure the header is dropped into the correct group\n            if (fromHeader !== toHeader && fromHeader.lockableInjected && toHeader.lockableInjected && toHeader.lockedCt) {\n                scrollerOwner = fromCt.up('[scrollerOwner]');\n                scrollerOwner.lock(dragHeader, localToIdx);\n\n                // Now that the header has been transferred into the correct HeaderContainer, recurse, and continue the drop operation with the same dragData\n                this.onNodeDrop(node, dragZone, e, data);\n            } else if (fromHeader !== toHeader && fromHeader.lockableInjected && toHeader.lockableInjected && fromHeader.lockedCt) {\n                scrollerOwner = fromCt.up('[scrollerOwner]');\n                scrollerOwner.unlock(dragHeader, localToIdx);\n\n                // Now that the header has been transferred into the correct HeaderContainer, recurse, and continue the drop operation with the same dragData\n                this.onNodeDrop(node, dragZone, e, data);\n            }\n            \n            // This is a drop within the same HeaderContainer.\n            else {\n                this.invalidateDrop();\n\n                // If dragging rightwards, then after removal, the insertion index will be less when moving\n                // within the same container.\n                if ((fromCt === toCt) && (localToIdx > localFromIdx)) {\n\n                    // Wer're dragging whole headers, so locally, the adjustment is only one\n                    localToIdx -= 1;\n                }\n\n                // Suspend layouts while we sort all this out.\n                Ext.suspendLayouts();\n\n                // Remove dragged header from where it was.\n                if (fromCt !== toCt) {\n                    fromCt.remove(dragHeader, false);\n\n                    // Dragged the last header out of the fromCt group... The fromCt group must die\n                    if (fromCt.isGroupHeader) {\n                        if (!fromCt.items.getCount()) {\n                            groupCt = fromCt.ownerCt;\n                            groupCt.remove(fromCt, false);\n                            fromCt.el.dom.parentNode.removeChild(fromCt.el.dom);\n                        }\n                    }\n                }\n\n                // Move dragged header into its drop position\n                if (fromCt === toCt) {\n                    toCt.move(localFromIdx, localToIdx);\n                } else {\n                    toCt.insert(localToIdx, dragHeader);\n                }\n\n                // Group headers acquire the aggregate width of their child headers\n                // Therefore a child header may not flex; it must contribute a fixed width.\n                // But we restore the flex value when moving back into the main header container\n                if (toCt.isGroupHeader) {\n                    // Adjust the width of the \"to\" group header only if we dragged in from somewhere else.\n                    if (toCt !== fromCt) {\n                        dragHeader.savedFlex = dragHeader.flex;\n                        delete dragHeader.flex;\n                        dragHeader.width = dragHeader.getWidth();\n                    }\n                } else {\n                    if (dragHeader.savedFlex) {\n                        dragHeader.flex = dragHeader.savedFlex;\n                        delete dragHeader.width;\n                    }\n                }\n\n                // Refresh columns cache in case we remove an emptied group column\n                headerCt.purgeCache();\n                Ext.resumeLayouts(true);\n                headerCt.onHeaderMoved(dragHeader, colsToMove, fromIdx, toIdx);\n\n                // Emptied group header can only be destroyed after the header and grid have been refreshed\n                if (!fromCt.items.getCount()) {\n                    fromCt.destroy();\n                }\n            }\n        }\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.grid.plugin.HeaderReorderer', {\n    extend: 'Ext.AbstractPlugin',\n    requires: ['Ext.grid.header.DragZone', 'Ext.grid.header.DropZone'],\n    alias: 'plugin.gridheaderreorderer',\n\n    init: function(headerCt) {\n        this.headerCt = headerCt;\n        headerCt.on({\n            render: this.onHeaderCtRender,\n            single: true,\n            scope: this\n        });\n    },\n\n    /**\n     * @private\n     * AbstractComponent calls destroy on all its plugins at destroy time.\n     */\n    destroy: function() {\n        Ext.destroy(this.dragZone, this.dropZone);\n    },\n\n    onHeaderCtRender: function() {\n        var me = this;\n        \n        me.dragZone = new Ext.grid.header.DragZone(me.headerCt);\n        me.dropZone = new Ext.grid.header.DropZone(me.headerCt);\n        if (me.disabled) {\n            me.dragZone.disable();\n        }\n    },\n    \n    enable: function() {\n        this.disabled = false;\n        if (this.dragZone) {\n            this.dragZone.enable();\n        }\n    },\n    \n    disable: function() {\n        this.disabled = true;\n        if (this.dragZone) {\n            this.dragZone.disable();\n        }\n    }\n});\n\n/**\n * Container which holds headers and is docked at the top or bottom of a TablePanel.\n * The HeaderContainer drives resizing/moving/hiding of columns within the TableView.\n * As headers are hidden, moved or resized the headercontainer is responsible for\n * triggering changes within the view.\n */\nExt.define('Ext.grid.header.Container', {\n    extend: 'Ext.container.Container',\n    requires: [\n        'Ext.grid.ColumnLayout',\n        'Ext.grid.plugin.HeaderResizer',\n        'Ext.grid.plugin.HeaderReorderer'\n    ],\n    uses: [\n        'Ext.grid.column.Column',\n        'Ext.menu.Menu',\n        'Ext.menu.CheckItem',\n        'Ext.menu.Separator'\n    ],\n    border: true,\n\n    alias: 'widget.headercontainer',\n\n    baseCls: Ext.baseCSSPrefix + 'grid-header-ct',\n    dock: 'top',\n\n    /**\n     * @cfg {Number} weight\n     * HeaderContainer overrides the default weight of 0 for all docked items to 100.\n     * This is so that it has more priority over things like toolbars.\n     */\n    weight: 100,\n\n    defaultType: 'gridcolumn',\n    \n    detachOnRemove: false,\n\n    /**\n     * @cfg {Number} defaultWidth\n     * Width of the header if no width or flex is specified.\n     */\n    defaultWidth: 100,\n    \n    /**\n     * @cfg {Boolean} [sealed=false]\n     * Specify as `true` to constrain column dragging so that a column cannot be dragged into or out of this column.\n     *\n     * **Note that this config is only valid for column headers which contain child column headers, eg:**\n     *     {\n     *         sealed: true\n     *         text: 'ExtJS',\n     *         columns: [{\n     *             text: '3.0.4',\n     *             dataIndex: 'ext304'\n     *         }, {\n     *             text: '4.1.0',\n     *             dataIndex: 'ext410'\n     *         }\n     *     }\n     *\n     */\n\n    //<locale>\n    sortAscText: 'Sort Ascending',\n    //</locale>\n    //<locale>\n    sortDescText: 'Sort Descending',\n    //</locale>\n    //<locale>\n    sortClearText: 'Clear Sort',\n    //</locale>\n    //<locale>\n    columnsText: 'Columns',\n    //</locale>\n\n    headerOpenCls: Ext.baseCSSPrefix + 'column-header-open',\n\n    // private; will probably be removed by 4.0\n    triStateSort: false,\n\n    ddLock: false,\n\n    dragging: false,\n\n    /**\n     * @property {Boolean} isGroupHeader\n     * True if this HeaderContainer is in fact a group header which contains sub headers.\n     */\n\n    /**\n     * @cfg {Boolean} sortable\n     * Provides the default sortable state for all Headers within this HeaderContainer.\n     * Also turns on or off the menus in the HeaderContainer. Note that the menu is\n     * shared across every header and therefore turning it off will remove the menu\n     * items for every header.\n     */\n    sortable: true,\n\n    initComponent: function() {\n        var me = this;\n\n        me.headerCounter = 0;\n        me.plugins = me.plugins || [];\n\n        // TODO: Pass in configurations to turn on/off dynamic\n        //       resizing and disable resizing all together\n\n        // Only set up a Resizer and Reorderer for the topmost HeaderContainer.\n        // Nested Group Headers are themselves HeaderContainers\n        if (!me.isHeader) {\n            if (me.enableColumnResize) {\n                me.resizer = new Ext.grid.plugin.HeaderResizer();\n                me.plugins.push(me.resizer);\n            }\n            if (me.enableColumnMove) {\n                me.reorderer = new Ext.grid.plugin.HeaderReorderer();\n                me.plugins.push(me.reorderer);\n            }\n        }\n\n        // Base headers do not need a box layout\n        if (me.isHeader && !me.items) {\n            me.layout = me.layout || 'auto';\n        }\n        // HeaderContainer and Group header needs a gridcolumn layout.\n        else {\n            me.layout = Ext.apply({\n                type: 'gridcolumn',\n                align: 'stretchmax'\n            }, me.initialConfig.layout);\n        }\n        me.defaults = me.defaults || {};\n        Ext.applyIf(me.defaults, {\n            triStateSort: me.triStateSort,\n            sortable: me.sortable\n        });\n        \n        me.menuTask = new Ext.util.DelayedTask(me.updateMenuDisabledState, me);\n        me.callParent();\n        me.addEvents(\n            /**\n             * @event columnresize\n             * @param {Ext.grid.header.Container} ct The grid's header Container which encapsulates all column headers.\n             * @param {Ext.grid.column.Column} column The Column header Component which provides the column definition\n             * @param {Number} width\n             */\n            'columnresize',\n\n            /**\n             * @event headerclick\n             * @param {Ext.grid.header.Container} ct The grid's header Container which encapsulates all column headers.\n             * @param {Ext.grid.column.Column} column The Column header Component which provides the column definition\n             * @param {Ext.EventObject} e\n             * @param {HTMLElement} t\n             */\n            'headerclick',\n\n            /**\n             * @event headertriggerclick\n             * @param {Ext.grid.header.Container} ct The grid's header Container which encapsulates all column headers.\n             * @param {Ext.grid.column.Column} column The Column header Component which provides the column definition\n             * @param {Ext.EventObject} e\n             * @param {HTMLElement} t\n             */\n            'headertriggerclick',\n\n            /**\n             * @event columnmove\n             * @param {Ext.grid.header.Container} ct The grid's header Container which encapsulates all column headers.\n             * @param {Ext.grid.column.Column} column The Column header Component which provides the column definition\n             * @param {Number} fromIdx\n             * @param {Number} toIdx\n             */\n            'columnmove',\n            /**\n             * @event columnhide\n             * @param {Ext.grid.header.Container} ct The grid's header Container which encapsulates all column headers.\n             * @param {Ext.grid.column.Column} column The Column header Component which provides the column definition\n             */\n            'columnhide',\n            /**\n             * @event columnshow\n             * @param {Ext.grid.header.Container} ct The grid's header Container which encapsulates all column headers.\n             * @param {Ext.grid.column.Column} column The Column header Component which provides the column definition\n             */\n            'columnshow',\n            /**\n             * @event sortchange\n             * @param {Ext.grid.header.Container} ct The grid's header Container which encapsulates all column headers.\n             * @param {Ext.grid.column.Column} column The Column header Component which provides the column definition\n             * @param {String} direction\n             */\n            'sortchange',\n            /**\n             * @event menucreate\n             * Fired immediately after the column header menu is created.\n             * @param {Ext.grid.header.Container} ct This instance\n             * @param {Ext.menu.Menu} menu The Menu that was created\n             */\n            'menucreate'\n        );\n    },\n\n    onDestroy: function() {\n        var me = this;\n        \n        me.menuTask.cancel();\n        Ext.destroy(me.resizer, me.reorderer);\n        me.callParent();\n    },\n\n    applyColumnsState: function(columns) {\n        if (!columns || !columns.length) {\n            return;\n        }\n\n        var me     = this,\n            items  = me.items.items,\n            count  = items.length,\n            i      = 0,\n            length = columns.length,\n            c, col, columnState, index;\n\n        for (c = 0; c < length; c++) {\n            columnState = columns[c];\n\n            for (index = count; index--; ) {\n                col = items[index];\n                if (col.getStateId && col.getStateId() == columnState.id) {\n                    // If a column in the new grid matches up with a saved state...\n                    // Ensure that the column is restored to the state order.\n                    // i is incremented upon every column match, so all persistent\n                    // columns are ordered before any new columns.\n                    if (i !== index) {\n                        me.moveHeader(index, i);\n                    }\n\n                    if (col.applyColumnState) {\n                        col.applyColumnState(columnState);\n                    }\n                    ++i;\n                    break;\n                }\n            }\n        }\n    },\n\n    getColumnsState: function () {\n        var me = this,\n            columns = [],\n            state;\n\n        me.items.each(function (col) {\n            state = col.getColumnState && col.getColumnState();\n            if (state) {\n                columns.push(state);\n            }\n        });\n\n        return columns;\n    },\n\n    // Invalidate column cache on add\n    // We cannot refresh the View on every add because this method is called\n    // when the HeaderDropZone moves Headers around, that will also refresh the view\n    onAdd: function(c) {\n        var me = this,\n            headerCt = me.isHeader ? me.getOwnerHeaderCt() : me;\n\n        if (!c.headerId) {\n            c.headerId = c.initialConfig.id || Ext.id(null, 'header-');\n        }\n\n        if (!c.stateId) {\n            // This was the headerId generated in 4.0, so to preserve saved state, we now\n            // assign a default stateId in that same manner. The stateId's of a column are\n            // not global at the stateProvider, but are local to the grid state data. The\n            // headerId should still follow our standard naming convention.\n            c.stateId = c.initialConfig.id || ('h' + (++me.headerCounter));\n        }\n\n        if (Ext.global.console && Ext.global.console.warn) {\n            if (!me._usedIDs) {\n                me._usedIDs = {};\n            }\n            if (me._usedIDs[c.headerId]) {\n                Ext.global.console.warn(this.$className, 'attempted to reuse an existing id', c.headerId);\n            }\n            me._usedIDs[c.headerId] = true;\n        }\n        me.callParent(arguments);\n\n        // Upon add of any column we need to purge the *HeaderContainer's* cache of leaf view columns.\n        if (headerCt) {\n            headerCt.purgeCache();\n        }\n    },\n\n    // Invalidate column cache on remove\n    // We cannot refresh the View on every remove because this method is called\n    // when the HeaderDropZone moves Headers around, that will also refresh the view\n    onRemove: function(c) {\n        var me = this,\n            headerCt = me.isHeader ? me.getOwnerHeaderCt() : me;\n\n        me.callParent(arguments);\n        \n        if (!me._usedIDs) {\n            me._usedIDs = {};\n        }\n        delete me._usedIDs[c.headerId];\n\n        // Upon removal of any column we need to purge the *HeaderContainer's* cache of leaf view columns.\n        if (headerCt) {\n            me.purgeCache();\n        }\n    },\n\n    // @private\n    applyDefaults: function(config) {\n        var ret; \n        /*\n         * Ensure header.Container defaults don't get applied to a RowNumberer \n         * if an xtype is supplied. This isn't an ideal solution however it's \n         * much more likely that a RowNumberer with no options will be created, \n         * wanting to use the defaults specified on the class as opposed to \n         * those setup on the Container.\n         */\n        if (config && !config.isComponent && config.xtype == 'rownumberer') {\n            ret = config;\n        } else {\n            ret = this.callParent(arguments);\n            \n            // Apply default width unless it's a group header (in which case it must be left to shrinkwrap), or it's flexed\n            if (!config.isGroupHeader && !('width' in ret) && !ret.flex) {\n                ret.width = this.defaultWidth;\n            }\n        }\n        return ret;\n    },\n\n    afterRender: function() {\n        this.callParent();\n        this.setSortState();\n        \n    },\n    \n    setSortState: function(){\n        var store   = this.up('[store]').store,\n            // grab the first sorter, since there may also be groupers\n            // in this collection\n            first = store.getFirstSorter(),\n            hd;\n\n        if (first) {\n            hd = this.down('gridcolumn[dataIndex=' + first.property  +']');\n            if (hd) {\n                hd.setSortState(first.direction, false, true);\n            }\n        } else {\n            this.clearOtherSortStates(null);\n        }\n    },\n    \n    getHeaderMenu: function(){\n        var menu = this.getMenu(),\n            item;\n            \n        if (menu) {\n            item = menu.child('#columnItem');\n            if (item) {\n                return item.menu;\n            }\n        }   \n        return null; \n    },\n    \n    onHeaderVisibilityChange: function(header, visible){\n        var me = this,\n            menu = me.getHeaderMenu(),\n            item;\n        \n        if (menu) {\n            // If the header was hidden programmatically, sync the Menu state\n            item = me.getMenuItemForHeader(menu, header);\n            if (item) {\n                item.setChecked(visible, true);\n            }\n            // delay this since the headers may fire a number of times if we're hiding/showing groups\n            me.menuTask.delay(50);\n        }\n    },\n    \n    /**\n     * @private\n     * Gets all \"leaf\" menu nodes and returns the checked count for those leaves.\n     * Only includes columns that are hideable via the menu\n     */\n    getLeafMenuItems: function() {\n        var me = this,\n            columns = me.getGridColumns(),\n            items = [],\n            i = 0,\n            count = 0,\n            len = columns.length,\n            menu = me.getMenu(),\n            item;\n\n        for (; i < len; ++i) {\n            item = columns[i];\n            if (item.hideable) {\n                item = me.getMenuItemForHeader(menu, item);\n                if (item) {\n                    items.push(item);\n                    if (item.checked) {\n                        ++count;\n                    }\n                }\n            } else if (!item.hidden && !item.menuDisabled) {\n                ++count;\n            }\n        }\n\n        return {\n            items: items,\n            checkedCount: count    \n        };\n    },\n    \n    updateMenuDisabledState: function(){\n        var me = this,\n            result = me.getLeafMenuItems(),\n            total = result.checkedCount,\n            items = result.items,\n            len = items.length,\n            i = 0,\n            rootItem = me.getMenu().child('#columnItem');\n            \n        if (total <= 1) {\n            // only one column visible, prevent hiding of the remaining item\n            me.disableMenuItems(rootItem, Ext.ComponentQuery.query('[checked=true]', items)[0]);\n        } else {\n            // at least 2 visible, set the state appropriately\n            for (; i < len; ++i) {\n                me.setMenuItemState(total, rootItem, items[i]);\n            }\n        }\n    },\n    \n    disableMenuItems: function(rootItem, item){\n        while (item && item != rootItem) {\n            item.disableCheckChange();\n            item = item.parentMenu.ownerItem;\n        }\n    },\n    \n    setMenuItemState: function(total, rootItem, item){\n        var parentMenu,\n            checkedChildren;\n            \n        while (item && item != rootItem) {\n            parentMenu = item.parentMenu;\n            checkedChildren = item.parentMenu.query('[checked=true]:not([menu])').length;\n            item.enableCheckChange();\n            item = parentMenu.ownerItem;\n            if (checkedChildren === total) {\n                // contains all the checked children, jump out the item and all parents\n                break;\n            }\n        }\n        \n        // while we're not at the top, disable from the current item up\n        this.disableMenuItems(rootItem, item);\n    },\n    \n    getMenuItemForHeader: function(menu, header){\n        return header ? menu.down('menucheckitem[headerId=' + header.id + ']') : null;\n    },\n\n    onHeaderShow: function(header) {\n        // Pass up to the GridSection\n        var me = this,\n            gridSection = me.ownerCt;\n\n        me.onHeaderVisibilityChange(header, true);\n\n        // Only update the grid UI when we are notified about base level Header shows;\n        // Group header shows just cause a layout of the HeaderContainer\n        if (!header.isGroupHeader) {\n            if (gridSection) {\n                gridSection.onHeaderShow(me, header);\n            }\n        }\n        me.fireEvent('columnshow', me, header);\n    },\n\n    onHeaderHide: function(header) {\n        // Pass up to the GridSection\n        var me = this,\n            gridSection = me.ownerCt;\n\n        me.onHeaderVisibilityChange(header, false);\n\n        // Only update the UI when we are notified about base level Header hides;\n        if (!header.isGroupHeader) {\n            if (gridSection) {\n                gridSection.onHeaderHide(me, header);\n            }\n        }\n        me.fireEvent('columnhide', me, header);\n    },\n\n    /**\n     * Temporarily lock the headerCt. This makes it so that clicking on headers\n     * don't trigger actions like sorting or opening of the header menu. This is\n     * done because extraneous events may be fired on the headers after interacting\n     * with a drag drop operation.\n     * @private\n     */\n    tempLock: function() {\n        this.ddLock = true;\n        Ext.Function.defer(function() {\n            this.ddLock = false;\n        }, 200, this);\n    },\n\n    onHeaderResize: function(header, w, suppressFocus) {\n        var me = this,\n            view = me.view,\n            gridSection = me.ownerCt;\n\n        // Do not react to header sizing during initial Panel layout when there is no view content to size.\n        if (view && view.table.dom) {\n            me.tempLock();\n            if (gridSection) {\n                gridSection.onHeaderResize(me, header, w);\n            }\n        }\n        me.fireEvent('columnresize', this, header, w);\n    },\n\n    onHeaderClick: function(header, e, t) {\n        header.fireEvent('headerclick', this, header, e, t);\n        this.fireEvent(\"headerclick\", this, header, e, t);\n    },\n\n    onHeaderTriggerClick: function(header, e, t) {\n        // generate and cache menu, provide ability to cancel/etc\n        var me = this;\n        if (header.fireEvent('headertriggerclick', me, header, e, t) !== false && me.fireEvent(\"headertriggerclick\", me, header, e, t) !== false) {\n            me.showMenuBy(t, header);\n        }\n    },\n\n    showMenuBy: function(t, header) {\n        var menu = this.getMenu(),\n            ascItem  = menu.down('#ascItem'),\n            descItem = menu.down('#descItem'),\n            sortableMth;\n\n        menu.activeHeader = menu.ownerCt = header;\n        menu.setFloatParent(header);\n        // TODO: remove coupling to Header's titleContainer el\n        header.titleEl.addCls(this.headerOpenCls);\n\n        // enable or disable asc & desc menu items based on header being sortable\n        sortableMth = header.sortable ? 'enable' : 'disable';\n        if (ascItem) {\n            ascItem[sortableMth]();\n        }\n        if (descItem) {\n            descItem[sortableMth]();\n        }\n        menu.showBy(t);\n    },\n\n    // remove the trigger open class when the menu is hidden\n    onMenuDeactivate: function() {\n        var menu = this.getMenu();\n        // TODO: remove coupling to Header's titleContainer el\n        menu.activeHeader.titleEl.removeCls(this.headerOpenCls);\n    },\n\n    moveHeader: function(fromIdx, toIdx) {\n\n        // An automatically expiring lock\n        this.tempLock();\n        this.onHeaderMoved(this.move(fromIdx, toIdx), 1, fromIdx, toIdx);\n    },\n\n    purgeCache: function() {\n        var me = this;\n        // Delete column cache - column order has changed.\n        delete me.gridDataColumns;\n        delete me.hideableColumns;\n\n        // Menu changes when columns are moved. It will be recreated.\n        if (me.menu) {\n            // Must hide before destroy so that trigger el is deactivated\n            me.menu.hide();\n            me.menu.destroy();\n            delete me.menu;\n        }\n    },\n\n    onHeaderMoved: function(header, colsToMove, fromIdx, toIdx) {\n        var me = this,\n            gridSection = me.ownerCt;\n\n        if (gridSection && gridSection.onHeaderMove) {\n            gridSection.onHeaderMove(me, header, colsToMove, fromIdx, toIdx);\n        }\n        me.fireEvent(\"columnmove\", me, header, fromIdx, toIdx);\n    },\n\n    /**\n     * Gets the menu (and will create it if it doesn't already exist)\n     * @private\n     */\n    getMenu: function() {\n        var me = this;\n\n        if (!me.menu) {\n            me.menu = new Ext.menu.Menu({\n                hideOnParentHide: false,  // Persists when owning ColumnHeader is hidden\n                items: me.getMenuItems(),\n                listeners: {\n                    deactivate: me.onMenuDeactivate,\n                    scope: me\n                }\n            });\n            me.updateMenuDisabledState();\n            me.fireEvent('menucreate', me, me.menu);\n        }\n        return me.menu;\n    },\n\n    /**\n     * Returns an array of menu items to be placed into the shared menu\n     * across all headers in this header container.\n     * @returns {Array} menuItems\n     */\n    getMenuItems: function() {\n        var me = this,\n            menuItems = [],\n            hideableColumns = me.enableColumnHide ? me.getColumnMenu(me) : null;\n\n        if (me.sortable) {\n            menuItems = [{\n                itemId: 'ascItem',\n                text: me.sortAscText,\n                cls: Ext.baseCSSPrefix + 'hmenu-sort-asc',\n                handler: me.onSortAscClick,\n                scope: me\n            },{\n                itemId: 'descItem',\n                text: me.sortDescText,\n                cls: Ext.baseCSSPrefix + 'hmenu-sort-desc',\n                handler: me.onSortDescClick,\n                scope: me\n            }];\n        }\n        if (hideableColumns && hideableColumns.length) {\n            menuItems.push('-', {\n                itemId: 'columnItem',\n                text: me.columnsText,\n                cls: Ext.baseCSSPrefix + 'cols-icon',\n                menu: hideableColumns\n            });\n        }\n        return menuItems;\n    },\n\n    // sort asc when clicking on item in menu\n    onSortAscClick: function() {\n        var menu = this.getMenu(),\n            activeHeader = menu.activeHeader;\n\n        activeHeader.setSortState('ASC');\n    },\n\n    // sort desc when clicking on item in menu\n    onSortDescClick: function() {\n        var menu = this.getMenu(),\n            activeHeader = menu.activeHeader;\n\n        activeHeader.setSortState('DESC');\n    },\n\n    /**\n     * Returns an array of menu CheckItems corresponding to all immediate children\n     * of the passed Container which have been configured as hideable.\n     */\n    getColumnMenu: function(headerContainer) {\n        var menuItems = [],\n            i = 0,\n            item,\n            items = headerContainer.query('>gridcolumn[hideable]'),\n            itemsLn = items.length,\n            menuItem;\n\n        for (; i < itemsLn; i++) {\n            item = items[i];\n            menuItem = new Ext.menu.CheckItem({\n                text: item.menuText || item.text,\n                checked: !item.hidden,\n                hideOnClick: false,\n                headerId: item.id,\n                menu: item.isGroupHeader ? this.getColumnMenu(item) : undefined,\n                checkHandler: this.onColumnCheckChange,\n                scope: this\n            });\n            menuItems.push(menuItem);\n\n            // If the header is ever destroyed - for instance by dragging out the last remaining sub header,\n            // then the associated menu item must also be destroyed.\n            item.on({\n                destroy: Ext.Function.bind(menuItem.destroy, menuItem)\n            });\n        }\n        return menuItems;\n    },\n\n    onColumnCheckChange: function(checkItem, checked) {\n        var header = Ext.getCmp(checkItem.headerId);\n        header[checked ? 'show' : 'hide']();\n    },\n\n    /**\n     * Get the columns used for generating a template via TableChunker.\n     * Returns an array of all columns and their\n     *\n     *  - dataIndex\n     *  - align\n     *  - width\n     *  - id\n     *  - columnId - used to create an identifying CSS class\n     *  - cls The tdCls configuration from the Column object\n     *\n     * @private\n     */\n    getColumnsForTpl: function(flushCache) {\n        var cols    = [],\n            headers   = this.getGridColumns(flushCache),\n            headersLn = headers.length,\n            i = 0,\n            header,\n            width;\n\n        for (; i < headersLn; i++) {\n            header = headers[i];\n\n            if (header.hidden || header.up('headercontainer[hidden=true]')) {\n                width = 0;\n            } else {\n                width = header.getDesiredWidth();\n            }\n            cols.push({\n                dataIndex: header.dataIndex,\n                align: header.align,\n                width: width,\n                id: header.id,\n                cls: header.tdCls,\n                columnId: header.getItemId()\n            });\n        }\n        return cols;\n    },\n\n    /**\n     * Returns the number of <b>grid columns</b> descended from this HeaderContainer.\n     * Group Columns are HeaderContainers. All grid columns are returned, including hidden ones.\n     */\n    getColumnCount: function() {\n        return this.getGridColumns().length;\n    },\n\n    /**\n     * Gets the full width of all columns that are visible.\n     */\n    getFullWidth: function(flushCache) {\n        var fullWidth = 0,\n            headers = this.getVisibleGridColumns(flushCache),\n            headersLn = headers.length,\n            i = 0,\n            header;\n           \n\n        for (; i < headersLn; i++) {\n            header = headers[i];\n            // use headers getDesiredWidth if its there\n            if (header.getDesiredWidth) {\n                fullWidth += header.getDesiredWidth() || 0;\n            // if injected a diff cmp use getWidth\n            } else {\n                fullWidth += header.getWidth();\n            }\n        }\n        return fullWidth;\n    },\n\n    // invoked internally by a header when not using triStateSorting\n    clearOtherSortStates: function(activeHeader) {\n        var headers   = this.getGridColumns(),\n            headersLn = headers.length,\n            i         = 0;\n\n        for (; i < headersLn; i++) {\n            if (headers[i] !== activeHeader) {\n                // unset the sortstate and dont recurse\n                headers[i].setSortState(null, true);\n            }\n        }\n    },\n\n    /**\n     * Returns an array of the **visible** columns in the grid. This goes down to the lowest column header\n     * level, and does not return **grouped** headers which contain sub headers.\n     * @param {Boolean} refreshCache If omitted, the cached set of columns will be returned. Pass true to refresh the cache.\n     * @returns {Array}\n     */\n    getVisibleGridColumns: function(refreshCache) {\n        return Ext.ComponentQuery.query(':not([hidden])', this.getGridColumns(refreshCache));\n    }, \n\n    /**\n     * Returns an array of all columns which map to Store fields. This goes down to the lowest column header\n     * level, and does not return **grouped** headers which contain sub headers.\n     * @param {Boolean} refreshCache If omitted, the cached set of columns will be returned. Pass true to refresh the cache.\n     * @returns {Array}\n     */\n    getGridColumns: function(refreshCache) {\n        var me = this,\n            result = refreshCache ? null : me.gridDataColumns;\n\n        // Not already got the column cache, so collect the base columns\n        if (!result) {\n            me.gridDataColumns = result = [];\n            me.cascade(function(c) {\n                if ((c !== me) && !c.isGroupHeader) {\n                    result.push(c);\n                }\n            });\n        }\n\n        return result;\n    },\n\n    /**\n     * @private\n     * For use by column headers in determining whether there are any hideable columns when deciding whether or not\n     * the header menu should be disabled.\n     */\n    getHideableColumns: function(refreshCache) {\n        var me = this,\n            result = refreshCache ? null : me.hideableColumns;\n\n        if (!result) {\n            result = me.hideableColumns = me.query('[hideable]');\n        }\n        return result;\n    },\n\n    /**\n     * Returns the index of a leaf level header regardless of what the nesting\n     * structure is.\n     *\n     * If a group header is passed, the index of the first leaf level heder within it is returned.\n     *\n     * @param {Ext.grid.column.Column} header The header to find the index of\n     * @return {Number} The index of the specified column header\n     */\n    getHeaderIndex: function(header) {\n        // If we are being asked the index of a group header, find the first leaf header node, and return the index of that\n        if (header.isGroupHeader) {\n            header = header.down(':not([isgroupHeader])');\n        }\n        return Ext.Array.indexOf(this.getGridColumns(), header);\n    },\n\n    /**\n     * Get a leaf level header by index regardless of what the nesting\n     * structure is.\n     * @param {Number} The column index for which to retrieve the column.\n     */\n    getHeaderAtIndex: function(index) {\n        var columns = this.getGridColumns();\n        return columns.length ? columns[index] : null;\n    },\n\n    /**\n     * When passed a column index, returns the closet *visible* column to that. If the column at the passed index is visible,\n     * that is returned. If it is hidden, either the next visible, or the previous visible column is returned.\n     * @param {Number} index Position at which to find the closest visible column.\n     */\n    getVisibleHeaderClosestToIndex: function(index) {\n        var result = this.getHeaderAtIndex(index);\n        if (result && result.hidden) {\n            result = result.next(':not([hidden])') || result.prev(':not([hidden])');\n        }\n        return result;\n    },\n\n    /**\n     * Maps the record data to base it on the header id's.\n     * This correlates to the markup/template generated by\n     * TableChunker.\n     */\n    prepareData: function(data, rowIdx, record, view, panel) {\n        var me        = this,\n            obj       = {},\n            headers   = me.gridDataColumns || me.getGridColumns(),\n            headersLn = headers.length,\n            colIdx    = 0,\n            header,\n            headerId,\n            renderer,\n            value,\n            metaData,\n            store = panel.store;\n\n        for (; colIdx < headersLn; colIdx++) {\n            metaData = {\n                tdCls: '',\n                style: ''\n            };\n            header = headers[colIdx];\n            headerId = header.id;\n            renderer = header.renderer;\n            value = data[header.dataIndex];\n\n            if (typeof renderer == \"function\") {\n                value = renderer.call(\n                    header.scope || me.ownerCt,\n                    value,\n                    // metadata per cell passing an obj by reference so that\n                    // it can be manipulated inside the renderer\n                    metaData,\n                    record,\n                    rowIdx,\n                    colIdx,\n                    store,\n                    view\n                );\n            }\n\n            if (metaData.css) {\n                // This warning attribute is used by the compat layer\n                obj.cssWarning = true;\n                metaData.tdCls = metaData.css;\n                delete metaData.css;\n            }\n            if (me.markDirty) {\n                obj[headerId + '-modified'] = record.isModified(header.dataIndex) ? Ext.baseCSSPrefix + 'grid-dirty-cell' : '';\n            }\n            obj[headerId+'-tdCls'] = metaData.tdCls;\n            obj[headerId+'-tdAttr'] = metaData.tdAttr;\n            obj[headerId+'-style'] = metaData.style;\n            if (typeof value === 'undefined' || value === null || value === '') {\n                value = header.emptyCellText;\n            }\n            obj[headerId] = value;\n        }\n        return obj;\n    },\n\n    expandToFit: function(header) {\n        var view = this.view;\n        if (view) {\n            view.expandToFit(header);\n        }\n    }\n});\n\n/**\n * This class specifies the definition for a column inside a {@link Ext.grid.Panel}. It encompasses\n * both the grid header configuration as well as displaying data within the grid itself. If the\n * {@link #columns} configuration is specified, this column will become a column group and can\n * contain other columns inside. In general, this class will not be created directly, rather\n * an array of column configurations will be passed to the grid:\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *         storeId:'employeeStore',\n *         fields:['firstname', 'lastname', 'seniority', 'dep', 'hired'],\n *         data:[\n *             {firstname:\"Michael\", lastname:\"Scott\", seniority:7, dep:\"Management\", hired:\"01/10/2004\"},\n *             {firstname:\"Dwight\", lastname:\"Schrute\", seniority:2, dep:\"Sales\", hired:\"04/01/2004\"},\n *             {firstname:\"Jim\", lastname:\"Halpert\", seniority:3, dep:\"Sales\", hired:\"02/22/2006\"},\n *             {firstname:\"Kevin\", lastname:\"Malone\", seniority:4, dep:\"Accounting\", hired:\"06/10/2007\"},\n *             {firstname:\"Angela\", lastname:\"Martin\", seniority:5, dep:\"Accounting\", hired:\"10/21/2008\"}\n *         ]\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Column Demo',\n *         store: Ext.data.StoreManager.lookup('employeeStore'),\n *         columns: [\n *             {text: 'First Name',  dataIndex:'firstname'},\n *             {text: 'Last Name',  dataIndex:'lastname'},\n *             {text: 'Hired Month',  dataIndex:'hired', xtype:'datecolumn', format:'M'},\n *             {text: 'Department (Yrs)', xtype:'templatecolumn', tpl:'{dep} ({seniority})'}\n *         ],\n *         width: 400,\n *         forceFit: true,\n *         renderTo: Ext.getBody()\n *     });\n *\n * # Convenience Subclasses\n *\n * There are several column subclasses that provide default rendering for various data types\n *\n *  - {@link Ext.grid.column.Action}: Renders icons that can respond to click events inline\n *  - {@link Ext.grid.column.Boolean}: Renders for boolean values\n *  - {@link Ext.grid.column.Date}: Renders for date values\n *  - {@link Ext.grid.column.Number}: Renders for numeric values\n *  - {@link Ext.grid.column.Template}: Renders a value using an {@link Ext.XTemplate} using the record data\n *\n * # Setting Sizes\n *\n * The columns are laid out by a {@link Ext.layout.container.HBox} layout, so a column can either\n * be given an explicit width value or a flex configuration. If no width is specified the grid will\n * automatically the size the column to 100px. For column groups, the size is calculated by measuring\n * the width of the child columns, so a width option should not be specified in that case.\n *\n * # Header Options\n *\n *  - {@link #text}: Sets the header text for the column\n *  - {@link #sortable}: Specifies whether the column can be sorted by clicking the header or using the column menu\n *  - {@link #hideable}: Specifies whether the column can be hidden using the column menu\n *  - {@link #menuDisabled}: Disables the column header menu\n *  - {@link #cfg-draggable}: Specifies whether the column header can be reordered by dragging\n *  - {@link #groupable}: Specifies whether the grid can be grouped by the column dataIndex. See also {@link Ext.grid.feature.Grouping}\n *\n * # Data Options\n *\n *  - {@link #dataIndex}: The dataIndex is the field in the underlying {@link Ext.data.Store} to use as the value for the column.\n *  - {@link #renderer}: Allows the underlying store value to be transformed before being displayed in the grid\n */\nExt.define('Ext.grid.column.Column', {\n    extend: 'Ext.grid.header.Container',\n    alias: 'widget.gridcolumn',\n    requires: ['Ext.util.KeyNav', 'Ext.grid.ColumnComponentLayout', 'Ext.grid.ColumnLayout'],\n    alternateClassName: 'Ext.grid.Column',\n\n    baseCls: Ext.baseCSSPrefix + 'column-header ' + Ext.baseCSSPrefix + 'unselectable',\n\n    // Not the standard, automatically applied overCls because we must filter out overs of child headers.\n    hoverCls: Ext.baseCSSPrefix + 'column-header-over',\n\n    handleWidth: 5,\n\n    sortState: null,\n\n    possibleSortStates: ['ASC', 'DESC'],\n\n    childEls: [\n        'titleEl', 'triggerEl', 'textEl'\n    ],\n\n    renderTpl:\n        '<div id=\"{id}-titleEl\" {tipMarkup}class=\"' + Ext.baseCSSPrefix + 'column-header-inner\">' +\n            '<span id=\"{id}-textEl\" class=\"' + Ext.baseCSSPrefix + 'column-header-text\">' +\n                '{text}' +\n            '</span>' +\n            '<tpl if=\"!menuDisabled\">'+\n                '<div id=\"{id}-triggerEl\" class=\"' + Ext.baseCSSPrefix + 'column-header-trigger\"></div>'+\n            '</tpl>' +\n        '</div>' +\n        '{%this.renderContainer(out,values)%}',\n\n    /**\n     * @cfg {Object[]} columns\n     * An optional array of sub-column definitions. This column becomes a group, and houses the columns defined in the\n     * `columns` config.\n     *\n     * Group columns may not be sortable. But they may be hideable and moveable. And you may move headers into and out\n     * of a group. Note that if all sub columns are dragged out of a group, the group is destroyed.\n     */\n\n    /**\n     * @override\n     * @cfg {String} stateId\n     * An identifier which identifies this column uniquely within the owning grid's {@link #stateful state}.\n     * \n     * This does not have to be *globally* unique. A column's state is not saved standalone. It is encapsulated within\n     * the owning grid's state.\n     */\n\n    /**\n     * @cfg {String} dataIndex\n     * The name of the field in the grid's {@link Ext.data.Store}'s {@link Ext.data.Model} definition from\n     * which to draw the column's value. **Required.**\n     */\n    dataIndex: null,\n\n    /**\n     * @cfg {String} text\n     * The header text to be used as innerHTML (html tags are accepted) to display in the Grid.\n     * **Note**: to have a clickable header with no text displayed you can use the default of `&#160;` aka `&nbsp;`.\n     */\n    text: '&#160;',\n\n    /**\n     * @cfg {String} header\n     * The header text.\n     * @deprecated 4.0 Use {@link #text} instead.\n     */\n\n    /**\n     * @cfg {String} menuText\n     * The text to render in the column visibility selection menu for this column.  If not\n     * specified, will default to the text value.\n     */\n    menuText: null,\n\n    /**\n     * @cfg {String} [emptyCellText=undefined]\n     * The text to diplay in empty cells (cells with a value of `undefined`, `null`, or `''`).\n     *\n     * Defaults to `&#160;` aka `&nbsp;`.\n     */\n    emptyCellText: '&#160;',\n\n    /**\n     * @cfg {Boolean} sortable\n     * False to disable sorting of this column. Whether local/remote sorting is used is specified in\n     * `{@link Ext.data.Store#remoteSort}`.\n     */\n    sortable: true,\n\n    /**\n     * @cfg {Boolean} groupable\n     * If the grid uses a {@link Ext.grid.feature.Grouping}, this option may be used to disable the header menu\n     * item to group by the column selected. By default, the header menu group option is enabled. Set to false to\n     * disable (but still show) the group option in the header menu for the column.\n     */\n\n    /**\n     * @cfg {Boolean} fixed\n     * True to prevent the column from being resizable.\n     * @deprecated 4.0 Use {@link #resizable} instead.\n     */\n\n    /**\n     * @cfg {Boolean} [locked=false]\n     * True to lock this column in place.  Implicitly enables locking on the grid.\n     * See also {@link Ext.grid.Panel#enableLocking}.\n     */\n\n    /**\n     * @cfg {Boolean} resizable\n     * False to prevent the column from being resizable.\n     */\n    resizable: true,\n\n    /**\n     * @cfg {Boolean} hideable\n     * False to prevent the user from hiding this column.\n     */\n    hideable: true,\n\n    /**\n     * @cfg {Boolean} menuDisabled\n     * True to disable the column header menu containing sort/hide options.\n     */\n    menuDisabled: false,\n\n    /**\n     * @cfg {Function/String} renderer\n     * A renderer is an 'interceptor' method which can be used to transform data (value, appearance, etc.)\n     * before it is rendered. Example:\n     *\n     *     {\n     *         renderer: function(value){\n     *             if (value === 1) {\n     *                 return '1 person';\n     *             }\n     *             return value + ' people';\n     *         }\n     *     }\n     *\n     * Additionally a string naming an {@link Ext.util.Format} method can be passed:\n     *\n     *     {\n     *         renderer: 'uppercase'\n     *     }\n     *\n     * @cfg {Object} renderer.value The data value for the current cell\n     * @cfg {Object} renderer.metaData A collection of metadata about the current cell; can be used or modified\n     * by the renderer. Recognized properties are: tdCls, tdAttr, and style.\n     * @cfg {Ext.data.Model} renderer.record The record for the current row\n     * @cfg {Number} renderer.rowIndex The index of the current row\n     * @cfg {Number} renderer.colIndex The index of the current column\n     * @cfg {Ext.data.Store} renderer.store The data store\n     * @cfg {Ext.view.View} renderer.view The current view\n     * @cfg {String} renderer.return The HTML string to be rendered.\n     */\n    renderer: false,\n\n    /**\n     * @cfg {Object} scope\n     * The scope to use when calling the {@link #renderer} function.\n     */\n    \n    /**\n     * @method defaultRenderer\n     * When defined this will take precedence over the {@link Ext.grid.column.Column#renderer renderer} config.\n     * This is meant to be defined in subclasses that wish to supply their own renderer.\n     * @protected\n     * @template\n     */\n\n    /**\n     * @cfg {Function} editRenderer\n     * A renderer to be used in conjunction with {@link Ext.grid.plugin.RowEditing RowEditing}. This renderer is used to\n     * display a custom value for non-editable fields.\n     */\n    editRenderer: false,\n\n    /**\n     * @cfg {String} align\n     * Sets the alignment of the header and rendered columns.\n     * Possible values are: `'left'`, `'center'`, and `'right'`.\n     */\n    align: 'left',\n\n    /**\n     * @cfg {Boolean} draggable\n     * False to disable drag-drop reordering of this column.\n     */\n    draggable: true,\n    \n    /**\n     * @cfg {String} tooltip\n     * A tooltip to display for this column header\n     */\n    \n    /**\n     * @cfg {String} [tooltipType=\"qtip\"]\n     * The type of {@link #tooltip} to use. Either 'qtip' for QuickTips or 'title' for title attribute.\n     */\n    tooltipType: 'qtip',\n\n    // Header does not use the typical ComponentDraggable class and therefore we\n    // override this with an emptyFn. It is controlled at the HeaderDragZone.\n    initDraggable: Ext.emptyFn,\n\n    /**\n     * @cfg {String} tdCls\n     * A CSS class names to apply to the table cells for this column.\n     */\n\n    /**\n     * @cfg {Object/String} editor\n     * An optional xtype or config object for a {@link Ext.form.field.Field Field} to use for editing.\n     * Only applicable if the grid is using an {@link Ext.grid.plugin.Editing Editing} plugin.\n     */\n\n    /**\n     * @cfg {Object/String} field\n     * Alias for {@link #editor}.\n     * @deprecated 4.0.5 Use {@link #editor} instead.\n     */\n\n    /**\n     * @property {Ext.Element} triggerEl\n     * Element that acts as button for column header dropdown menu.\n     */\n\n    /**\n     * @property {Ext.Element} textEl\n     * Element that contains the text in column header.\n     */\n\n    /**\n     * @property {Boolean} isHeader\n     * Set in this class to identify, at runtime, instances which are not instances of the\n     * HeaderContainer base class, but are in fact, the subclass: Header.\n     */\n    isHeader: true,\n\n    componentLayout: 'columncomponent',\n    \n    // We need to override the default component resizable behaviour here\n    initResizable: Ext.emptyFn,\n\n    initComponent: function() {\n        var me = this,\n            renderer;\n\n        if (Ext.isDefined(me.header)) {\n            me.text = me.header;\n            delete me.header;\n        }\n\n        if (!me.triStateSort) {\n            me.possibleSortStates.length = 2;\n        }\n\n        // A group header; It contains items which are themselves Headers\n        if (Ext.isDefined(me.columns)) {\n            me.isGroupHeader = true;\n\n            if (me.dataIndex) {\n                Ext.Error.raise('Ext.grid.column.Column: Group header may not accept a dataIndex');\n            }\n            if ((me.width && me.width !== Ext.grid.header.Container.prototype.defaultWidth) || me.flex) {\n                Ext.Error.raise('Ext.grid.column.Column: Group header does not support setting explicit widths or flexs. The group header width is calculated by the sum of its children.');\n            }\n\n            // The headers become child items\n            me.items = me.columns;\n            delete me.columns;\n            delete me.flex;\n            delete me.width;\n            me.cls = (me.cls||'') + ' ' + Ext.baseCSSPrefix + 'group-header';\n            me.sortable = false;\n            me.resizable = false;\n            me.align = 'center';\n        } else {\n            // If we are not a group header, then this is not to be used as a container, and must not have a container layout executed, and it must\n            // acquire layout height from DOM content, not from child items.\n            me.isContainer = false;\n\n            // Flexed Headers need to have a minWidth defined so that they can never be squeezed out of existence by the\n            // HeaderContainer's specialized Box layout, the ColumnLayout. The ColumnLayout's overridden calculateChildboxes\n            // method extends the available layout space to accommodate the \"desiredWidth\" of all the columns.\n            if (me.flex) {\n                me.minWidth = me.minWidth || Ext.grid.plugin.HeaderResizer.prototype.minColWidth;\n            }\n        }\n        me.addCls(Ext.baseCSSPrefix + 'column-header-align-' + me.align);\n        \n        renderer = me.renderer;\n        if (renderer) {\n            // When specifying a renderer as a string, it always resolves\n            // to Ext.util.Format\n            if (typeof renderer == 'string') {\n                me.renderer = Ext.util.Format[renderer];\n            }\n            me.hasCustomRenderer = true;\n        } else if (me.defaultRenderer) {\n            me.scope = me;\n            me.renderer = me.defaultRenderer;\n        }\n\n        // Initialize as a HeaderContainer\n        me.callParent(arguments);\n\n        me.on({\n            element:  'el',\n            click:    me.onElClick,\n            dblclick: me.onElDblClick,\n            scope:    me\n        });\n        me.on({\n            element:    'titleEl',\n            mouseenter: me.onTitleMouseOver,\n            mouseleave: me.onTitleMouseOut,\n            scope:      me\n        });\n    },\n\n    onAdd: function(childHeader) {\n        childHeader.isSubHeader = true;\n        childHeader.addCls(Ext.baseCSSPrefix + 'group-sub-header');\n        this.callParent(arguments);\n    },\n\n    onRemove: function(childHeader) {\n        childHeader.isSubHeader = false;\n        childHeader.removeCls(Ext.baseCSSPrefix + 'group-sub-header');\n        this.callParent(arguments);\n    },\n\n    initRenderData: function() {\n        var me = this,\n            tipMarkup = '',\n            tip = me.tooltip,\n            attr = me.tooltipType == 'qtip' ? 'data-qtip' : 'title';\n            \n        if (!Ext.isEmpty(tip)) {\n            tipMarkup = attr + '=\"' + tip + '\" ';\n        }\n            \n        return Ext.applyIf(me.callParent(arguments), {\n            text: me.text,\n            menuDisabled: me.menuDisabled,\n            tipMarkup: tipMarkup\n        });\n    },\n\n    applyColumnState: function (state) {\n        var me = this,\n            defined = Ext.isDefined;\n            \n        // apply any columns\n        me.applyColumnsState(state.columns);\n\n        // Only state properties which were saved should be restored.\n        // (Only user-changed properties were saved by getState)\n        if (defined(state.hidden)) {\n            me.hidden = state.hidden;\n        }\n        if (defined(state.locked)) {\n            me.locked = state.locked;\n        }\n        if (defined(state.sortable)) {\n            me.sortable = state.sortable;\n        }\n        if (defined(state.width)) {\n            delete me.flex;\n            me.width = state.width;\n        } else if (defined(state.flex)) {\n            delete me.width;\n            me.flex = state.flex;\n        }\n    },\n\n    getColumnState: function () {\n        var me = this,\n            items = me.items.items,\n            // Check for the existence of items, since column.Action won't have them\n            iLen = items ? items.length : 0,\n            i,\n            columns = [],\n            state = {\n                id: me.getStateId()\n            };\n\n        me.savePropsToState(['hidden', 'sortable', 'locked', 'flex', 'width'], state);\n        \n        if (me.isGroupHeader) {\n            for (i = 0; i < iLen; i++) {\n                columns.push(items[i].getColumnState());\n            }\n\n            if (columns.length) {\n                state.columns = columns;\n            }\n        } else if (me.isSubHeader && me.ownerCt.hidden) {\n            // don't set hidden on the children so they can auto height\n            delete me.hidden;\n        }\n\n        if ('width' in state) {\n            delete state.flex; // width wins\n        }\n        return state;\n    },\n\n    getStateId: function () {\n        return this.stateId || this.headerId;\n    },\n\n    /**\n     * Sets the header text for this Column.\n     * @param {String} text The header to display on this Column.\n     */\n    setText: function(text) {\n        this.text = text;\n        if (this.rendered) {\n            this.textEl.update(text);\n        }\n    },\n\n    // Find the topmost HeaderContainer: An ancestor which is NOT a Header.\n    // Group Headers are themselves HeaderContainers\n    getOwnerHeaderCt: function() {\n        return this.up(':not([isHeader])');\n    },\n\n    /**\n     * Returns the index of this column only if this column is a base level Column. If it\n     * is a group column, it returns `false`.\n     * @return {Number}\n     */\n    getIndex: function() {\n        return this.isGroupColumn ? false : this.getOwnerHeaderCt().getHeaderIndex(this);\n    },\n    \n    /**\n     * Returns the index of this column in the list of *visible* columns only if this column is a base level Column. If it\n     * is a group column, it returns `false`.\n     * @return {Number}\n     */\n    getVisibleIndex: function() {\n        return this.isGroupColumn ? false : Ext.Array.indexOf(this.getOwnerHeaderCt().getVisibleGridColumns(), this);\n    },\n\n    beforeRender: function() {\n        var me = this,\n            grid = me.up('tablepanel');\n\n        me.callParent();\n\n        // Disable the menu if there's nothing to show in the menu, ie:\n        // Column cannot be sorted, grouped or locked, and there are no grid columns which may be hidden\n        if (grid && (!me.sortable || grid.sortableColumns === false) && !me.groupable &&\n                     !me.lockable && (grid.enableColumnHide === false ||\n                     !me.getOwnerHeaderCt().getHideableColumns().length)) {\n            me.menuDisabled = true;\n        }\n    },\n\n    afterRender: function() {\n        var me = this,\n            el = me.el;\n\n        me.callParent(arguments);\n\n        if (me.overCls) {\n            el.addClsOnOver(me.overCls);\n        }\n\n        // BrowserBug: Ie8 Strict Mode, this will break the focus for this browser,\n        // must be fixed when focus management will be implemented.\n        if (!Ext.isIE8 || !Ext.isStrict) {\n            me.mon(me.getFocusEl(), {\n                focus: me.onTitleMouseOver,\n                blur: me.onTitleMouseOut,\n                scope: me\n            });\n        }\n\n        me.keyNav = new Ext.util.KeyNav(el, {\n            enter: me.onEnterKey,\n            down: me.onDownKey,\n            scope: me\n        });\n    },\n\n    // private\n    // Inform the header container about the resize\n    afterComponentLayout: function(width, height, oldWidth, oldHeight) {\n        var me = this,\n            ownerHeaderCt = me.getOwnerHeaderCt();\n\n        me.callParent(arguments);\n\n        if (ownerHeaderCt && (oldWidth != null || me.flex) && width !== oldWidth) {\n            ownerHeaderCt.onHeaderResize(me, width, true);\n        }\n    },\n\n    // private\n    // After the container has laid out and stretched, it calls this to correctly pad the inner to center the text vertically\n    // Total available header height must be passed to enable padding for inner elements to be calculated.\n    setPadding: function(headerHeight) {\n        var me = this,\n            lineHeight = parseInt(me.textEl.getStyle('line-height'), 10),\n            textHeight = me.textEl.dom.offsetHeight,\n            titleEl = me.titleEl,\n            availableHeight = headerHeight - me.el.getBorderWidth('tb'),\n            titleElHeight;\n\n        // Top title containing element must stretch to match height of sibling group headers\n        if (!me.isGroupHeader) {\n            if (titleEl.getHeight() < availableHeight) {\n                titleEl.setHeight(availableHeight);\n                // the column el's parent element (the 'innerCt') may have an incorrect height\n                // at this point because it may have been shrink wrapped prior to the titleEl's\n                // height being set, so we need to sync it up here\n                me.ownerCt.layout.innerCt.setHeight(headerHeight);\n            }\n        }\n        titleElHeight = titleEl.getViewSize().height;\n\n        // Vertically center the header text in potentially vertically stretched header\n        if (textHeight) {\n            if(lineHeight) {\n                textHeight = Math.ceil(textHeight / lineHeight) * lineHeight;\n            }\n            titleEl.setStyle({\n                paddingTop: Math.floor(Math.max(((titleElHeight - textHeight) / 2), 0)) + 'px'\n            });\n        }\n\n        // Only IE needs this\n        if (Ext.isIE && me.triggerEl) {\n            me.triggerEl.setHeight(titleElHeight);\n        }\n    },\n\n    onDestroy: function() {\n        var me = this;\n        // force destroy on the textEl, IE reports a leak\n        Ext.destroy(me.textEl, me.keyNav, me.field);\n        delete me.keyNav;\n        me.callParent(arguments);\n    },\n\n    onTitleMouseOver: function() {\n        this.titleEl.addCls(this.hoverCls);\n    },\n\n    onTitleMouseOut: function() {\n        this.titleEl.removeCls(this.hoverCls);\n    },\n\n    onDownKey: function(e) {\n        if (this.triggerEl) {\n            this.onElClick(e, this.triggerEl.dom || this.el.dom);\n        }\n    },\n\n    onEnterKey: function(e) {\n        this.onElClick(e, this.el.dom);\n    },\n\n    /**\n     * @private\n     * Double click\n     * @param e\n     * @param t\n     */\n    onElDblClick: function(e, t) {\n        var me = this,\n            ownerCt = me.ownerCt;\n        if (ownerCt && Ext.Array.indexOf(ownerCt.items, me) !== 0 && me.isOnLeftEdge(e) ) {\n            ownerCt.expandToFit(me.previousSibling('gridcolumn'));\n        }\n    },\n\n    onElClick: function(e, t) {\n\n        // The grid's docked HeaderContainer.\n        var me = this,\n            ownerHeaderCt = me.getOwnerHeaderCt();\n\n        if (ownerHeaderCt && !ownerHeaderCt.ddLock) {\n            // Firefox doesn't check the current target in a within check.\n            // Therefore we check the target directly and then within (ancestors)\n            if (me.triggerEl && (e.target === me.triggerEl.dom || t === me.triggerEl.dom || e.within(me.triggerEl))) {\n                ownerHeaderCt.onHeaderTriggerClick(me, e, t);\n            // if its not on the left hand edge, sort\n            } else if (e.getKey() || (!me.isOnLeftEdge(e) && !me.isOnRightEdge(e))) {\n                me.toggleSortState();\n                ownerHeaderCt.onHeaderClick(me, e, t);\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Process UI events from the view. The owning TablePanel calls this method, relaying events from the TableView\n     * @param {String} type Event type, eg 'click'\n     * @param {Ext.view.Table} view TableView Component\n     * @param {HTMLElement} cell Cell HtmlElement the event took place within\n     * @param {Number} recordIndex Index of the associated Store Model (-1 if none)\n     * @param {Number} cellIndex Cell index within the row\n     * @param {Ext.EventObject} e Original event\n     */\n    processEvent: function(type, view, cell, recordIndex, cellIndex, e) {\n        return this.fireEvent.apply(this, arguments);\n    },\n\n    toggleSortState: function() {\n        var me = this,\n            idx,\n            nextIdx;\n\n        if (me.sortable) {\n            idx = Ext.Array.indexOf(me.possibleSortStates, me.sortState);\n\n            nextIdx = (idx + 1) % me.possibleSortStates.length;\n            me.setSortState(me.possibleSortStates[nextIdx]);\n        }\n    },\n\n    doSort: function(state) {\n        var ds = this.up('tablepanel').store;\n        ds.sort({\n            property: this.getSortParam(),\n            direction: state\n        });\n    },\n\n    /**\n     * Returns the parameter to sort upon when sorting this header. By default this returns the dataIndex and will not\n     * need to be overriden in most cases.\n     * @return {String}\n     */\n    getSortParam: function() {\n        return this.dataIndex;\n    },\n\n    //setSortState: function(state, updateUI) {\n    //setSortState: function(state, doSort) {\n    setSortState: function(state, skipClear, initial) {\n        var me = this,\n            colSortClsPrefix = Ext.baseCSSPrefix + 'column-header-sort-',\n            ascCls = colSortClsPrefix + 'ASC',\n            descCls = colSortClsPrefix + 'DESC',\n            nullCls = colSortClsPrefix + 'null',\n            ownerHeaderCt = me.getOwnerHeaderCt(),\n            oldSortState = me.sortState;\n\n        if (oldSortState !== state && me.getSortParam()) {\n            me.addCls(colSortClsPrefix + state);\n            // don't trigger a sort on the first time, we just want to update the UI\n            if (state && !initial) {\n                me.doSort(state);\n            }\n            switch (state) {\n                case 'DESC':\n                    me.removeCls([ascCls, nullCls]);\n                    break;\n                case 'ASC':\n                    me.removeCls([descCls, nullCls]);\n                    break;\n                case null:\n                    me.removeCls([ascCls, descCls]);\n                    break;\n            }\n            if (ownerHeaderCt && !me.triStateSort && !skipClear) {\n                ownerHeaderCt.clearOtherSortStates(me);\n            }\n            me.sortState = state;\n            // we only want to fire the event if we have a null state when using triStateSort\n            if (me.triStateSort || state != null) {\n                ownerHeaderCt.fireEvent('sortchange', ownerHeaderCt, me, state);\n            }\n        }\n    },\n\n    hide: function(fromOwner) {\n        var me = this,\n            ownerHeaderCt = me.getOwnerHeaderCt(),\n            owner = me.ownerCt,\n            ownerIsGroup = owner.isGroupHeader,\n            item, items, len, i;\n\n        // owner is a group, hide call didn't come from the owner\n        if (ownerIsGroup && !fromOwner) {\n            items = owner.query('>:not([hidden])');\n            // only have one item that isn't hidden, this is it.\n            if (items.length === 1 && items[0] == me) {\n                me.ownerCt.hide();\n                return;\n            }\n        }\n\n        Ext.suspendLayouts();\n\n        if (me.isGroupHeader) {\n            items = me.items.items;\n            for (i = 0, len = items.length; i < len; i++) {\n                item = items[i];\n                if (!item.hidden) {\n                    item.hide(true);\n                }\n            }\n        }\n\n        me.callParent();\n        // Notify owning HeaderContainer\n        ownerHeaderCt.onHeaderHide(me);\n\n        Ext.resumeLayouts(true);\n    },\n\n    show: function(fromOwner, fromChild) {\n        var me = this,\n            ownerCt = me.ownerCt,\n            items,\n            len, i,\n            item;\n\n        Ext.suspendLayouts();\n\n        // If a sub header, ensure that the group header is visible\n        if (me.isSubHeader && ownerCt.hidden) {\n            ownerCt.show(false, true);\n        }\n\n        me.callParent(arguments);\n\n        // If we've just shown a group with all its sub headers hidden, then show all its sub headers\n        if (me.isGroupHeader && fromChild !== true && !me.query(':not([hidden])').length) {\n            items = me.query('>*');\n            for (i = 0, len = items.length; i < len; i++) {\n                item = items[i];\n                if (item.hidden) {\n                    item.show(true);\n                }\n            }\n        }\n\n        Ext.resumeLayouts(true);\n\n        // Notify owning HeaderContainer AFTER layout has been flushed so that header and headerCt widths are all correct\n        ownerCt = me.getOwnerHeaderCt();\n        if (ownerCt) {\n            ownerCt.onHeaderShow(me);\n        }\n    },\n\n    getDesiredWidth: function() {\n        var me = this;\n        if (me.rendered && me.componentLayout && me.componentLayout.lastComponentSize) {\n            // headers always have either a width or a flex\n            // because HeaderContainer sets a defaults width\n            // therefore we can ignore the natural width\n            // we use the componentLayout's tracked width so that\n            // we can calculate the desired width when rendered\n            // but not visible because its being obscured by a layout\n            return me.componentLayout.lastComponentSize.width;\n        // Flexed but yet to be rendered this could be the case\n        // where a HeaderContainer and Headers are simply used as data\n        // structures and not rendered.\n        }\n        else if (me.flex) {\n            // this is going to be wrong, the defaultWidth\n            return me.width;\n        }\n        else {\n            return me.width;\n        }\n    },\n\n    getCellSelector: function() {\n        return '.' + Ext.baseCSSPrefix + 'grid-cell-' + this.getItemId();\n    },\n\n    getCellInnerSelector: function() {\n        return this.getCellSelector() + ' .' + Ext.baseCSSPrefix + 'grid-cell-inner';\n    },\n\n    isOnLeftEdge: function(e) {\n        return (e.getXY()[0] - this.el.getLeft() <= this.handleWidth);\n    },\n\n    isOnRightEdge: function(e) {\n        return (this.el.getRight() - e.getXY()[0] <= this.handleWidth);\n    }\n\n    // intentionally omit getEditor and setEditor definitions bc we applyIf into columns\n    // when the editing plugin is injected\n\n    /**\n     * @method getEditor\n     * Retrieves the editing field for editing associated with this header. Returns false if there is no field\n     * associated with the Header the method will return false. If the field has not been instantiated it will be\n     * created. Note: These methods only has an implementation if a Editing plugin has been enabled on the grid.\n     * @param {Object} record The {@link Ext.data.Model Model} instance being edited.\n     * @param {Object} defaultField An object representing a default field to be created\n     * @return {Ext.form.field.Field} field\n     */\n    /**\n     * @method setEditor\n     * Sets the form field to be used for editing. Note: This method only has an implementation if an Editing plugin has\n     * been enabled on the grid.\n     * @param {Object} field An object representing a field to be created. If no xtype is specified a 'textfield' is\n     * assumed.\n     */\n});\n\n/**\n * This is a utility class that can be passed into a {@link Ext.grid.column.Column} as a column config that provides\n * an automatic row numbering column.\n * \n * Usage:\n *\n *     columns: [\n *         {xtype: 'rownumberer'},\n *         {text: \"Company\", flex: 1, sortable: true, dataIndex: 'company'},\n *         {text: \"Price\", width: 120, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},\n *         {text: \"Change\", width: 120, sortable: true, dataIndex: 'change'},\n *         {text: \"% Change\", width: 120, sortable: true, dataIndex: 'pctChange'},\n *         {text: \"Last Updated\", width: 120, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}\n *     ]\n *\n */\nExt.define('Ext.grid.RowNumberer', {\n    extend: 'Ext.grid.column.Column',\n    alias: 'widget.rownumberer',\n\n    /**\n     * @cfg {String} text\n     * Any valid text or HTML fragment to display in the header cell for the row number column.\n     */\n    text: \"&#160\",\n\n    /**\n     * @cfg {Number} width\n     * The default width in pixels of the row number column.\n     */\n    width: 23,\n\n    /**\n     * @cfg {Boolean} sortable\n     * @hide\n     */\n    sortable: false,\n    \n    /**\n     * @cfg {Boolean} [draggable=false]\n     * False to disable drag-drop reordering of this column.\n     */\n    draggable: false,\n\n    align: 'right',\n\n    constructor : function(config){\n\n        // Copy the prototype's default width setting into an instance property to provide\n        // a default width which will not be overridden by AbstractContainer.applyDefaults use of Ext.applyIf\n        this.width = this.width;\n\n        this.callParent(arguments);\n        if (this.rowspan) {\n            this.renderer = Ext.Function.bind(this.renderer, this);\n        }\n    },\n\n    // private\n    resizable: false,\n    hideable: false,\n    menuDisabled: true,\n    dataIndex: '',\n    cls: Ext.baseCSSPrefix + 'row-numberer',\n    rowspan: undefined,\n\n    // private\n    renderer: function(value, metaData, record, rowIdx, colIdx, store) {\n        if (this.rowspan){\n            metaData.cellAttr = 'rowspan=\"'+this.rowspan+'\"';\n        }\n\n        metaData.tdCls = Ext.baseCSSPrefix + 'grid-cell-special';\n        return store.indexOfTotal(record) + 1;\n    }\n});\n\nExt.define('Ext.grid.Scroller', {\n    constructor: Ext.deprecated()\n});\n\n/**\n * @private\n */\nExt.define('Ext.view.DropZone', {\n    extend: 'Ext.dd.DropZone',\n\n    indicatorHtml: '<div class=\"' + Ext.baseCSSPrefix + 'grid-drop-indicator-left\"></div><div class=\"' + Ext.baseCSSPrefix + 'grid-drop-indicator-right\"></div>',\n    indicatorCls: Ext.baseCSSPrefix + 'grid-drop-indicator',\n\n    constructor: function(config) {\n        var me = this;\n        Ext.apply(me, config);\n\n        // Create a ddGroup unless one has been configured.\n        // User configuration of ddGroups allows users to specify which\n        // DD instances can interact with each other. Using one\n        // based on the id of the View would isolate it and mean it can only\n        // interact with a DragZone on the same View also using a generated ID.\n        if (!me.ddGroup) {\n            me.ddGroup = 'view-dd-zone-' + me.view.id;\n        }\n\n        // The DropZone's encapsulating element is the View's main element. It must be this because drop gestures\n        // may require scrolling on hover near a scrolling boundary. In Ext 4.x two DD instances may not use the\n        // same element, so a DragZone on this same View must use the View's parent element as its element.\n        me.callParent([me.view.el]);\n    },\n\n//  Fire an event through the client DataView. Lock this DropZone during the event processing so that\n//  its data does not become corrupted by processing mouse events.\n    fireViewEvent: function() {\n        var me = this,\n            result;\n\n        me.lock();\n        result = me.view.fireEvent.apply(me.view, arguments);\n        me.unlock();\n        return result;\n    },\n\n    getTargetFromEvent : function(e) {\n        var node = e.getTarget(this.view.getItemSelector()),\n            mouseY, nodeList, testNode, i, len, box;\n\n//      Not over a row node: The content may be narrower than the View's encapsulating element, so return the closest.\n//      If we fall through because the mouse is below the nodes (or there are no nodes), we'll get an onContainerOver call.\n        if (!node) {\n            mouseY = e.getPageY();\n            for (i = 0, nodeList = this.view.getNodes(), len = nodeList.length; i < len; i++) {\n                testNode = nodeList[i];\n                box = Ext.fly(testNode).getBox();\n                if (mouseY <= box.bottom) {\n                    return testNode;\n                }\n            }\n        }\n        return node;\n    },\n\n    getIndicator: function() {\n        var me = this;\n\n        if (!me.indicator) {\n            me.indicator = new Ext.Component({\n                html: me.indicatorHtml,\n                cls: me.indicatorCls,\n                ownerCt: me.view,\n                floating: true,\n                shadow: false\n            });\n        }\n        return me.indicator;\n    },\n\n    getPosition: function(e, node) {\n        var y      = e.getXY()[1],\n            region = Ext.fly(node).getRegion(),\n            pos;\n\n        if ((region.bottom - y) >= (region.bottom - region.top) / 2) {\n            pos = \"before\";\n        } else {\n            pos = \"after\";\n        }\n        return pos;\n    },\n\n    /**\n     * @private Determines whether the record at the specified offset from the passed record\n     * is in the drag payload.\n     * @param records\n     * @param record\n     * @param offset\n     * @returns {Boolean} True if the targeted record is in the drag payload\n     */\n    containsRecordAtOffset: function(records, record, offset) {\n        if (!record) {\n            return false;\n        }\n        var view = this.view,\n            recordIndex = view.indexOf(record),\n            nodeBefore = view.getNode(recordIndex + offset),\n            recordBefore = nodeBefore ? view.getRecord(nodeBefore) : null;\n\n        return recordBefore && Ext.Array.contains(records, recordBefore);\n    },\n\n    positionIndicator: function(node, data, e) {\n        var me = this,\n            view = me.view,\n            pos = me.getPosition(e, node),\n            overRecord = view.getRecord(node),\n            draggingRecords = data.records,\n            indicatorY;\n\n        if (!Ext.Array.contains(draggingRecords, overRecord) && (\n            pos == 'before' && !me.containsRecordAtOffset(draggingRecords, overRecord, -1) ||\n            pos == 'after' && !me.containsRecordAtOffset(draggingRecords, overRecord, 1)\n        )) {\n            me.valid = true;\n\n            if (me.overRecord != overRecord || me.currentPosition != pos) {\n\n                indicatorY = Ext.fly(node).getY() - view.el.getY() - 1;\n                if (pos == 'after') {\n                    indicatorY += Ext.fly(node).getHeight();\n                }\n                me.getIndicator().setWidth(Ext.fly(view.el).getWidth()).showAt(0, indicatorY);\n\n                // Cache the overRecord and the 'before' or 'after' indicator.\n                me.overRecord = overRecord;\n                me.currentPosition = pos;\n            }\n        } else {\n            me.invalidateDrop();\n        }\n    },\n\n    invalidateDrop: function() {\n        if (this.valid) {\n            this.valid = false;\n            this.getIndicator().hide();\n        }\n    },\n\n    // The mouse is over a View node\n    onNodeOver: function(node, dragZone, e, data) {\n        var me = this;\n\n        if (!Ext.Array.contains(data.records, me.view.getRecord(node))) {\n            me.positionIndicator(node, data, e);\n        }\n        return me.valid ? me.dropAllowed : me.dropNotAllowed;\n    },\n\n    // Moved out of the DropZone without dropping.\n    // Remove drop position indicator\n    notifyOut: function(node, dragZone, e, data) {\n        var me = this;\n\n        me.callParent(arguments);\n        delete me.overRecord;\n        delete me.currentPosition;\n        if (me.indicator) {\n            me.indicator.hide();\n        }\n    },\n\n    // The mouse is past the end of all nodes (or there are no nodes)\n    onContainerOver : function(dd, e, data) {\n        var me = this,\n            view = me.view,\n            count = view.store.getCount();\n\n        // There are records, so position after the last one\n        if (count) {\n            me.positionIndicator(view.getNode(count - 1), data, e);\n        }\n\n        // No records, position the indicator at the top\n        else {\n            delete me.overRecord;\n            delete me.currentPosition;\n            me.getIndicator().setWidth(Ext.fly(view.el).getWidth()).showAt(0, 0);\n            me.valid = true;\n        }\n        return me.dropAllowed;\n    },\n\n    onContainerDrop : function(dd, e, data) {\n        return this.onNodeDrop(dd, null, e, data);\n    },\n\n    onNodeDrop: function(node, dragZone, e, data) {\n        var me = this,\n            dropHandled = false,\n \n            // Create a closure to perform the operation which the event handler may use.\n            // Users may now set the wait parameter in the beforedrop handler, and perform any kind\n            // of asynchronous processing such as an Ext.Msg.confirm, or an Ajax request,\n            // and complete the drop gesture at some point in the future by calling either the\n            // processDrop or cancelDrop methods.\n            dropHandlers = {\n                wait: false,\n                processDrop: function () {\n                    me.invalidateDrop();\n                    me.handleNodeDrop(data, me.overRecord, me.currentPosition);\n                    dropHandled = true;\n                    me.fireViewEvent('drop', node, data, me.overRecord, me.currentPosition);\n                },\n \n                cancelDrop: function() {\n                    me.invalidateDrop();\n                    dropHandled = true;\n                }\n            },\n            performOperation = false;\n \n        if (me.valid) {\n            performOperation = me.fireViewEvent('beforedrop', node, data, me.overRecord, me.currentPosition, dropHandlers);\n            if (dropHandlers.wait) {\n                return;\n            }\n \n            if (performOperation !== false) {\n                // If either of the drop handlers were called in the event handler, do not do it again.\n                if (!dropHandled) {\n                    dropHandlers.processDrop();\n                }\n            }\n        }\n        return performOperation;\n    },\n    \n    destroy: function(){\n        Ext.destroy(this.indicator);\n        delete this.indicator;\n        this.callParent();\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.grid.ViewDropZone', {\n    extend: 'Ext.view.DropZone',\n\n    indicatorHtml: '<div class=\"' + Ext.baseCSSPrefix + 'grid-drop-indicator-left\"></div><div class=\"' + Ext.baseCSSPrefix + 'grid-drop-indicator-right\"></div>',\n    indicatorCls: Ext.baseCSSPrefix + 'grid-drop-indicator',\n\n    handleNodeDrop : function(data, record, position) {\n        var view = this.view,\n            store = view.getStore(),\n            index, records, i, len;\n\n        // If the copy flag is set, create a copy of the Models with the same IDs\n        if (data.copy) {\n            records = data.records;\n            data.records = [];\n            for (i = 0, len = records.length; i < len; i++) {\n                data.records.push(records[i].copy(records[i].getId()));\n            }\n        } else {\n            /*\n             * Remove from the source store. We do this regardless of whether the store\n             * is the same bacsue the store currently doesn't handle moving records\n             * within the store. In the future it should be possible to do this.\n             * Here was pass the isMove parameter if we're moving to the same view.\n             */\n            data.view.store.remove(data.records, data.view === view);\n        }\n\n        index = store.indexOf(record);\n\n        // 'after', or undefined (meaning a drop at index -1 on an empty View)...\n        if (position !== 'before') {\n            index++;\n        }\n        store.insert(index, data.records);\n        view.getSelectionModel().select(data.records);\n    }\n});\n\n/**\n * A Grid header type which renders an icon, or a series of icons in a grid cell, and offers a scoped click\n * handler for each icon.\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *         storeId:'employeeStore',\n *         fields:['firstname', 'lastname', 'seniority', 'dep', 'hired'],\n *         data:[\n *             {firstname:\"Michael\", lastname:\"Scott\"},\n *             {firstname:\"Dwight\", lastname:\"Schrute\"},\n *             {firstname:\"Jim\", lastname:\"Halpert\"},\n *             {firstname:\"Kevin\", lastname:\"Malone\"},\n *             {firstname:\"Angela\", lastname:\"Martin\"}\n *         ]\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Action Column Demo',\n *         store: Ext.data.StoreManager.lookup('employeeStore'),\n *         columns: [\n *             {text: 'First Name',  dataIndex:'firstname'},\n *             {text: 'Last Name',  dataIndex:'lastname'},\n *             {\n *                 xtype:'actioncolumn',\n *                 width:50,\n *                 items: [{\n *                     icon: 'extjs/examples/shared/icons/fam/cog_edit.png',  // Use a URL in the icon config\n *                     tooltip: 'Edit',\n *                     handler: function(grid, rowIndex, colIndex) {\n *                         var rec = grid.getStore().getAt(rowIndex);\n *                         alert(\"Edit \" + rec.get('firstname'));\n *                     }\n *                 },{\n *                     icon: 'extjs/examples/restful/images/delete.png',\n *                     tooltip: 'Delete',\n *                     handler: function(grid, rowIndex, colIndex) {\n *                         var rec = grid.getStore().getAt(rowIndex);\n *                         alert(\"Terminate \" + rec.get('firstname'));\n *                     }\n *                 }]\n *             }\n *         ],\n *         width: 250,\n *         renderTo: Ext.getBody()\n *     });\n *\n * The action column can be at any index in the columns array, and a grid can have any number of\n * action columns.\n */\nExt.define('Ext.grid.column.Action', {\n    extend: 'Ext.grid.column.Column',\n    alias: ['widget.actioncolumn'],\n    alternateClassName: 'Ext.grid.ActionColumn',\n\n    /**\n     * @cfg {String} icon\n     * The URL of an image to display as the clickable element in the column.\n     *\n     * Defaults to `{@link Ext#BLANK_IMAGE_URL}`.\n     */\n    /**\n     * @cfg {String} iconCls\n     * A CSS class to apply to the icon image. To determine the class dynamically, configure the Column with\n     * a `{@link #getClass}` function.\n     */\n    /**\n     * @cfg {Function} handler\n     * A function called when the icon is clicked.\n     * @cfg {Ext.view.Table} handler.view The owning TableView.\n     * @cfg {Number} handler.rowIndex The row index clicked on.\n     * @cfg {Number} handler.colIndex The column index clicked on.\n     * @cfg {Object} handler.item The clicked item (or this Column if multiple {@link #cfg-items} were not configured).\n     * @cfg {Event} handler.e The click event.\n     * @cfg {Ext.data.Model} handler.record The Record underlying the clicked row.\n     * @cfg {HtmlElement} row The table row clicked upon.\n     */\n    /**\n     * @cfg {Object} scope\n     * The scope (**this** reference) in which the `{@link #handler}` and `{@link #getClass}` fuctions are executed.\n     * Defaults to this Column.\n     */\n    /**\n     * @cfg {String} tooltip\n     * A tooltip message to be displayed on hover. {@link Ext.tip.QuickTipManager#init Ext.tip.QuickTipManager} must\n     * have been initialized.\n     */\n    /**\n     * @cfg {Boolean} disabled\n     * If true, the action will not respond to click events, and will be displayed semi-opaque.\n     */\n    /**\n     * @cfg {Boolean} [stopSelection=true]\n     * Prevent grid selection upon mousedown.\n     */\n    /**\n     * @cfg {Function} getClass\n     * A function which returns the CSS class to apply to the icon image.\n     *\n     * @cfg {Object} getClass.v The value of the column's configured field (if any).\n     *\n     * @cfg {Object} getClass.metadata An object in which you may set the following attributes:\n     * @cfg {String} getClass.metadata.css A CSS class name to add to the cell's TD element.\n     * @cfg {String} getClass.metadata.attr An HTML attribute definition string to apply to the data container\n     * element *within* the table cell (e.g. 'style=\"color:red;\"').\n     *\n     * @cfg {Ext.data.Model} getClass.r The Record providing the data.\n     *\n     * @cfg {Number} getClass.rowIndex The row index..\n     *\n     * @cfg {Number} getClass.colIndex The column index.\n     *\n     * @cfg {Ext.data.Store} getClass.store The Store which is providing the data Model.\n     */\n    /**\n     * @cfg {Object[]} items\n     * An Array which may contain multiple icon definitions, each element of which may contain:\n     *\n     * @cfg {String} items.icon The url of an image to display as the clickable element in the column.\n     *\n     * @cfg {String} items.iconCls A CSS class to apply to the icon image. To determine the class dynamically,\n     * configure the item with a `getClass` function.\n     *\n     * @cfg {Function} items.getClass A function which returns the CSS class to apply to the icon image.\n     * @cfg {Object} items.getClass.v The value of the column's configured field (if any).\n     * @cfg {Object} items.getClass.metadata An object in which you may set the following attributes:\n     * @cfg {String} items.getClass.metadata.css A CSS class name to add to the cell's TD element.\n     * @cfg {String} items.getClass.metadata.attr An HTML attribute definition string to apply to the data\n     * container element _within_ the table cell (e.g. 'style=\"color:red;\"').\n     * @cfg {Ext.data.Model} items.getClass.r The Record providing the data.\n     * @cfg {Number} items.getClass.rowIndex The row index..\n     * @cfg {Number} items.getClass.colIndex The column index.\n     * @cfg {Ext.data.Store} items.getClass.store The Store which is providing the data Model.\n     *\n     * @cfg {Function} items.handler A function called when the icon is clicked.\n     *\n     * @cfg {Object} items.scope The scope (`this` reference) in which the `handler` and `getClass` functions\n     * are executed. Fallback defaults are this Column's configured scope, then this Column.\n     *\n     * @cfg {String} items.tooltip A tooltip message to be displayed on hover.\n     * @cfg {Boolean} items.disabled If true, the action will not respond to click events, and will be displayed semi-opaque.\n     * {@link Ext.tip.QuickTipManager#init Ext.tip.QuickTipManager} must have been initialized.\n     */\n    /**\n     * @property {Array} items\n     * An array of action items copied from the configured {@link #cfg-items items} configuration. Each will have\n     * an `enable` and `disable` method added which will enable and disable the associated action, and\n     * update the displayed icon accordingly.\n     */\n\n    actionIdRe: new RegExp(Ext.baseCSSPrefix + 'action-col-(\\\\d+)'),\n\n    /**\n     * @cfg {String} altText\n     * The alt text to use for the image element.\n     */\n    altText: '',\n\n    /**\n     * @cfg {String} menuText=[<i>Actions</i>]\n     * Text to display in this column's menu item if no {@link #text} was specified as a header.\n     */\n    menuText: '<i>Actions</i>',\n\n    sortable: false,\n\n    constructor: function(config) {\n        var me = this,\n            cfg = Ext.apply({}, config),\n            items = cfg.items || [me],\n            hasGetClass,\n            i,\n            len;\n\n\n        me.origRenderer = cfg.renderer || me.renderer;\n        me.origScope = cfg.scope || me.scope;\n        \n        delete me.renderer;\n        delete me.scope;\n        delete cfg.renderer;\n        delete cfg.scope;\n        \n        // This is a Container. Delete the items config to be reinstated after construction.\n        delete cfg.items;\n        me.callParent([cfg]);\n\n        // Items is an array property of ActionColumns\n        me.items = items;\n        \n        for (i = 0, len = items.length; i < len; ++i) {\n            if (items[i].getClass) {\n                hasGetClass = true;\n                break;\n            }\n        }\n        \n        // Also need to check for getClass, since it changes how the cell renders\n        if (me.origRenderer || hasGetClass) {\n            me.hasCustomRenderer = true;\n        }\n    },\n    \n    // Renderer closure iterates through items creating an <img> element for each and tagging with an identifying\n    // class name x-action-col-{n}\n    defaultRenderer: function(v, meta){\n        var me = this,\n            prefix = Ext.baseCSSPrefix,\n            scope = me.origScope || me,\n            items = me.items,\n            len = items.length,\n            i = 0,\n            item;\n            \n        // Allow a configured renderer to create initial value (And set the other values in the \"metadata\" argument!)\n        v = Ext.isFunction(me.origRenderer) ? me.origRenderer.apply(scope, arguments) || '' : '';\n\n        meta.tdCls += ' ' + Ext.baseCSSPrefix + 'action-col-cell';\n        for (; i < len; i++) {\n            item = items[i];\n            \n            // Only process the item action setup once.\n            if (!item.hasActionConfiguration) {\n                \n                // Apply our documented default to all items\n                item.stopSelection = me.stopSelection;\n                item.disable = Ext.Function.bind(me.disableAction, me, [i], 0);\n                item.enable = Ext.Function.bind(me.enableAction, me, [i], 0);\n                item.hasActionConfiguration = true;\n            }\n            \n            v += '<img alt=\"' + (item.altText || me.altText) + '\" src=\"' + (item.icon || Ext.BLANK_IMAGE_URL) +\n                '\" class=\"' + prefix + 'action-col-icon ' + prefix + 'action-col-' + String(i) + ' ' + (item.disabled ? prefix + 'item-disabled' : ' ') +\n                ' ' + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope || scope, arguments) : (item.iconCls || me.iconCls || '')) + '\"' +\n                ((item.tooltip) ? ' data-qtip=\"' + item.tooltip + '\"' : '') + ' />';\n        }\n        return v;    \n    },\n\n    /**\n     * Enables this ActionColumn's action at the specified index.\n     * @param {Number/Ext.grid.column.Action} index\n     * @param {Boolean} [silent=false]\n     */\n    enableAction: function(index, silent) {\n        var me = this;\n\n        if (!index) {\n            index = 0;\n        } else if (!Ext.isNumber(index)) {\n            index = Ext.Array.indexOf(me.items, index);\n        }\n        me.items[index].disabled = false;\n        me.up('tablepanel').el.select('.' + Ext.baseCSSPrefix + 'action-col-' + index).removeCls(me.disabledCls);\n        if (!silent) {\n            me.fireEvent('enable', me);\n        }\n    },\n\n    /**\n     * Disables this ActionColumn's action at the specified index.\n     * @param {Number/Ext.grid.column.Action} index\n     * @param {Boolean} [silent=false]\n     */\n    disableAction: function(index, silent) {\n        var me = this;\n\n        if (!index) {\n            index = 0;\n        } else if (!Ext.isNumber(index)) {\n            index = Ext.Array.indexOf(me.items, index);\n        }\n        me.items[index].disabled = true;\n        me.up('tablepanel').el.select('.' + Ext.baseCSSPrefix + 'action-col-' + index).addCls(me.disabledCls);\n        if (!silent) {\n            me.fireEvent('disable', me);\n        }\n    },\n\n    destroy: function() {\n        delete this.items;\n        delete this.renderer;\n        return this.callParent(arguments);\n    },\n\n    /**\n     * @private\n     * Process and refire events routed from the GridView's processEvent method.\n     * Also fires any configured click handlers. By default, cancels the mousedown event to prevent selection.\n     * Returns the event handler's status to allow canceling of GridView's bubbling process.\n     */\n    processEvent : function(type, view, cell, recordIndex, cellIndex, e, record, row){\n        var me = this,\n            target = e.getTarget(),\n            match,\n            item, fn,\n            key = type == 'keydown' && e.getKey();\n\n        // If the target was not within a cell (ie it's a keydown event from the View), then\n        // rely on the selection data injected by View.processUIEvent to grab the\n        // first action icon from the selected cell.\n        if (key && !Ext.fly(target).findParent(view.cellSelector)) {\n            target = Ext.fly(cell).down('.' + Ext.baseCSSPrefix + 'action-col-icon', true);\n        }\n\n        // NOTE: The statement below tests the truthiness of an assignment.\n        if (target && (match = target.className.match(me.actionIdRe))) {\n            item = me.items[parseInt(match[1], 10)];\n            if (item) {\n                if (type == 'click' || (key == e.ENTER || key == e.SPACE)) {\n                    fn = item.handler || me.handler;\n                    if (fn && !item.disabled) {\n                        fn.call(item.scope || me.origScope || me, view, recordIndex, cellIndex, item, e, record, row);\n                    }\n                } else if (type == 'mousedown' && item.stopSelection !== false) {\n                    return false;\n                }\n            }\n        }\n        return me.callParent(arguments);\n    },\n\n    cascade: function(fn, scope) {\n        fn.call(scope||this, this);\n    },\n\n    // Private override because this cannot function as a Container, and it has an items property which is an Array, NOT a MixedCollection.\n    getRefItems: function() {\n        return [];\n    }\n});\n\n/**\n * A Column definition class which renders boolean data fields.  See the {@link Ext.grid.column.Column#xtype xtype}\n * config option of {@link Ext.grid.column.Column} for more details.\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *        storeId:'sampleStore',\n *        fields:[\n *            {name: 'framework', type: 'string'},\n *            {name: 'rocks', type: 'boolean'}\n *        ],\n *        data:{'items':[\n *            { 'framework': \"Ext JS 4\",     'rocks': true  },\n *            { 'framework': \"Sencha Touch\", 'rocks': true  },\n *            { 'framework': \"Ext GWT\",      'rocks': true  }, \n *            { 'framework': \"Other Guys\",   'rocks': false } \n *        ]},\n *        proxy: {\n *            type: 'memory',\n *            reader: {\n *                type: 'json',\n *                root: 'items'\n *            }\n *        }\n *     });\n *     \n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Boolean Column Demo',\n *         store: Ext.data.StoreManager.lookup('sampleStore'),\n *         columns: [\n *             { text: 'Framework',  dataIndex: 'framework', flex: 1 },\n *             {\n *                 xtype: 'booleancolumn', \n *                 text: 'Rocks',\n *                 trueText: 'Yes',\n *                 falseText: 'No', \n *                 dataIndex: 'rocks'\n *             }\n *         ],\n *         height: 200,\n *         width: 400,\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.grid.column.Boolean', {\n    extend: 'Ext.grid.column.Column',\n    alias: ['widget.booleancolumn'],\n    alternateClassName: 'Ext.grid.BooleanColumn',\n\n    //<locale>\n    /**\n     * @cfg {String} trueText\n     * The string returned by the renderer when the column value is not falsey.\n     */\n    trueText: 'true',\n    //</locale>\n\n    //<locale>\n    /**\n     * @cfg {String} falseText\n     * The string returned by the renderer when the column value is falsey (but not undefined).\n     */\n    falseText: 'false',\n    //</locale>\n\n    /**\n     * @cfg {String} undefinedText\n     * The string returned by the renderer when the column value is undefined.\n     */\n    undefinedText: '&#160;',\n\n    /**\n     * @cfg renderer\n     * @hide\n     */\n    /**\n     * @cfg scope\n     * @hide\n     */\n\n    defaultRenderer: function(value){\n        if (value === undefined) {\n            return this.undefinedText;\n        }\n        \n        if (!value || value === 'false') {\n            return this.falseText;\n        }\n        return this.trueText;\n    }\n});\n\n/**\n * A Column definition class which renders a passed date according to the default locale, or a configured\n * {@link #format}.\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *         storeId:'sampleStore',\n *         fields:[\n *             { name: 'symbol', type: 'string' },\n *             { name: 'date',   type: 'date' },\n *             { name: 'change', type: 'number' },\n *             { name: 'volume', type: 'number' },\n *             { name: 'topday', type: 'date' }                        \n *         ],\n *         data:[\n *             { symbol: \"msft\",   date: '2011/04/22', change: 2.43, volume: 61606325, topday: '04/01/2010' },\n *             { symbol: \"goog\",   date: '2011/04/22', change: 0.81, volume: 3053782,  topday: '04/11/2010' },\n *             { symbol: \"apple\",  date: '2011/04/22', change: 1.35, volume: 24484858, topday: '04/28/2010' },            \n *             { symbol: \"sencha\", date: '2011/04/22', change: 8.85, volume: 5556351,  topday: '04/22/2010' }            \n *         ]\n *     });\n *     \n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Date Column Demo',\n *         store: Ext.data.StoreManager.lookup('sampleStore'),\n *         columns: [\n *             { text: 'Symbol',   dataIndex: 'symbol', flex: 1 },\n *             { text: 'Date',     dataIndex: 'date',   xtype: 'datecolumn',   format:'Y-m-d' },\n *             { text: 'Change',   dataIndex: 'change', xtype: 'numbercolumn', format:'0.00' },\n *             { text: 'Volume',   dataIndex: 'volume', xtype: 'numbercolumn', format:'0,000' },\n *             { text: 'Top Day',  dataIndex: 'topday', xtype: 'datecolumn',   format:'l' }            \n *         ],\n *         height: 200,\n *         width: 450,\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.grid.column.Date', {\n    extend: 'Ext.grid.column.Column',\n    alias: ['widget.datecolumn'],\n    requires: ['Ext.Date'],\n    alternateClassName: 'Ext.grid.DateColumn',\n\n    /**\n     * @cfg {String} format\n     * A formatting string as used by {@link Ext.Date#format} to format a Date for this Column.\n     *\n     * Defaults to the default date from {@link Ext.Date#defaultFormat} which itself my be overridden\n     * in a locale file.\n     */\n    /**\n     * @cfg renderer\n     * @hide\n     */\n    /**\n     * @cfg scope\n     * @hide\n     */\n\n    initComponent: function(){\n        if (!this.format) {\n            this.format = Ext.Date.defaultFormat;\n        }\n        \n        this.callParent(arguments);\n    },\n    \n    defaultRenderer: function(value){\n        return Ext.util.Format.date(value, this.format);\n    }\n});\n\n/**\n * A Column definition class which renders a numeric data field according to a {@link #format} string.\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *        storeId:'sampleStore',\n *        fields:[\n *            { name: 'symbol', type: 'string' },\n *            { name: 'price',  type: 'number' },\n *            { name: 'change', type: 'number' },\n *            { name: 'volume', type: 'number' }\n *        ],\n *        data:[\n *            { symbol: \"msft\",   price: 25.76,  change: 2.43, volume: 61606325 },\n *            { symbol: \"goog\",   price: 525.73, change: 0.81, volume: 3053782  },\n *            { symbol: \"apple\",  price: 342.41, change: 1.35, volume: 24484858 },\n *            { symbol: \"sencha\", price: 142.08, change: 8.85, volume: 5556351  }\n *        ]\n *     });\n *     \n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Number Column Demo',\n *         store: Ext.data.StoreManager.lookup('sampleStore'),\n *         columns: [\n *             { text: 'Symbol',         dataIndex: 'symbol', flex: 1 },\n *             { text: 'Current Price',  dataIndex: 'price',  renderer: Ext.util.Format.usMoney },\n *             { text: 'Change',         dataIndex: 'change', xtype: 'numbercolumn', format:'0.00' },\n *             { text: 'Volume',         dataIndex: 'volume', xtype: 'numbercolumn', format:'0,000' }\n *         ],\n *         height: 200,\n *         width: 400,\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.grid.column.Number', {\n    extend: 'Ext.grid.column.Column',\n    alias: ['widget.numbercolumn'],\n    requires: ['Ext.util.Format'],\n    alternateClassName: 'Ext.grid.NumberColumn',\n\n    //<locale>\n    /**\n     * @cfg {String} format\n     * A formatting string as used by {@link Ext.util.Format#number} to format a numeric value for this Column.\n     */\n    format : '0,000.00',\n    //</locale>\n\n    /**\n     * @cfg renderer\n     * @hide\n     */\n    /**\n     * @cfg scope\n     * @hide\n     */\n\n    defaultRenderer: function(value){\n        return Ext.util.Format.number(value, this.format);\n    }\n});\n\n/**\n * A Column definition class which renders a value by processing a {@link Ext.data.Model Model}'s\n * {@link Ext.data.Model#persistenceProperty data} using a {@link #tpl configured}\n * {@link Ext.XTemplate XTemplate}.\n * \n *     @example\n *     Ext.create('Ext.data.Store', {\n *         storeId:'employeeStore',\n *         fields:['firstname', 'lastname', 'seniority', 'department'],\n *         groupField: 'department',\n *         data:[\n *             { firstname: \"Michael\", lastname: \"Scott\",   seniority: 7, department: \"Management\" },\n *             { firstname: \"Dwight\",  lastname: \"Schrute\", seniority: 2, department: \"Sales\" },\n *             { firstname: \"Jim\",     lastname: \"Halpert\", seniority: 3, department: \"Sales\" },\n *             { firstname: \"Kevin\",   lastname: \"Malone\",  seniority: 4, department: \"Accounting\" },\n *             { firstname: \"Angela\",  lastname: \"Martin\",  seniority: 5, department: \"Accounting\" }\n *         ]\n *     });\n *     \n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Column Template Demo',\n *         store: Ext.data.StoreManager.lookup('employeeStore'),\n *         columns: [\n *             { text: 'Full Name',       xtype: 'templatecolumn', tpl: '{firstname} {lastname}', flex:1 },\n *             { text: 'Department (Yrs)', xtype: 'templatecolumn', tpl: '{department} ({seniority})' }\n *         ],\n *         height: 200,\n *         width: 300,\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.grid.column.Template', {\n    extend: 'Ext.grid.column.Column',\n    alias: ['widget.templatecolumn'],\n    requires: ['Ext.XTemplate'],\n    alternateClassName: 'Ext.grid.TemplateColumn',\n\n    /**\n     * @cfg {String/Ext.XTemplate} tpl\n     * An {@link Ext.XTemplate XTemplate}, or an XTemplate *definition string* to use to process a\n     * {@link Ext.data.Model Model}'s {@link Ext.data.Model#persistenceProperty data} to produce a\n     * column's rendered value.\n     */\n    /**\n     * @cfg renderer\n     * @hide\n     */\n    /**\n     * @cfg scope\n     * @hide\n     */\n\n    initComponent: function(){\n        var me = this;\n        me.tpl = (!Ext.isPrimitive(me.tpl) && me.tpl.compile) ? me.tpl : new Ext.XTemplate(me.tpl);\n        // Set this here since the template may access any record values,\n        // so we must always run the update for this column\n        me.hasCustomRenderer = true;\n        me.callParent(arguments);\n    },\n    \n    defaultRenderer: function(value, meta, record) {\n        var data = Ext.apply({}, record.data, record.getAssociatedData());\n        return this.tpl.apply(data);\n    }\n});\n\n/**\n * A feature is a type of plugin that is specific to the {@link Ext.grid.Panel}. It provides several\n * hooks that allows the developer to inject additional functionality at certain points throughout the \n * grid creation cycle. This class provides the base template methods that are available to the developer,\n * it should be extended.\n * \n * There are several built in features that extend this class, for example:\n *\n *  - {@link Ext.grid.feature.Grouping} - Shows grid rows in groups as specified by the {@link Ext.data.Store}\n *  - {@link Ext.grid.feature.RowBody} - Adds a body section for each grid row that can contain markup.\n *  - {@link Ext.grid.feature.Summary} - Adds a summary row at the bottom of the grid with aggregate totals for a column.\n * \n * ## Using Features\n * A feature is added to the grid by specifying it an array of features in the configuration:\n * \n *     var groupingFeature = Ext.create('Ext.grid.feature.Grouping');\n *     Ext.create('Ext.grid.Panel', {\n *         // other options\n *         features: [groupingFeature]\n *     });\n * \n * @abstract\n */\nExt.define('Ext.grid.feature.Feature', {\n    extend: 'Ext.util.Observable',\n    alias: 'feature.feature',\n\n    /*\n     * @property {Boolean} isFeature\n     * `true` in this class to identify an object as an instantiated Feature, or subclass thereof.\n     */\n    isFeature: true,\n\n    /**\n     * True when feature is disabled.\n     */\n    disabled: false,\n\n    /**\n     * @property {Boolean}\n     * Most features will expose additional events, some may not and will\n     * need to change this to false.\n     */\n    hasFeatureEvent: true,\n\n    /**\n     * @property {String}\n     * Prefix to use when firing events on the view.\n     * For example a prefix of group would expose \"groupclick\", \"groupcontextmenu\", \"groupdblclick\".\n     */\n    eventPrefix: null,\n\n    /**\n     * @property {String}\n     * Selector used to determine when to fire the event with the eventPrefix.\n     */\n    eventSelector: null,\n\n    /**\n     * @property {Ext.view.Table}\n     * Reference to the TableView.\n     */\n    view: null,\n\n    /**\n     * @property {Ext.grid.Panel}\n     * Reference to the grid panel\n     */\n    grid: null,\n\n    /**\n     * Most features will not modify the data returned to the view.\n     * This is limited to one feature that manipulates the data per grid view.\n     */\n    collectData: false,\n    \n    constructor: function(config) {\n        this.initialConfig = config;\n        this.callParent(arguments);\n    },\n\n    clone: function() {\n        return new this.self(this.initialConfig);\n    },\n\n    init: Ext.emptyFn,\n\n    getFeatureTpl: function() {\n        return '';\n    },\n\n    /**\n     * Abstract method to be overriden when a feature should add additional\n     * arguments to its event signature. By default the event will fire:\n     *\n     * - view - The underlying Ext.view.Table\n     * - featureTarget - The matched element by the defined {@link #eventSelector}\n     *\n     * The method must also return the eventName as the first index of the array\n     * to be passed to fireEvent.\n     * @template\n     */\n    getFireEventArgs: function(eventName, view, featureTarget, e) {\n        return [eventName, view, featureTarget, e];\n    },\n\n    /**\n     * Approriate place to attach events to the view, selectionmodel, headerCt, etc\n     * @template\n     */\n    attachEvents: function() {\n\n    },\n\n    getFragmentTpl: Ext.emptyFn,\n\n    /**\n     * Allows a feature to mutate the metaRowTpl.\n     * The array received as a single argument can be manipulated to add things\n     * on the end/begining of a particular row.\n     * @param {Array} metaRowTplArray A String array to be used constructing an {@link Ext.XTemplate XTemplate}\n     * to render the rows. This Array may be changed to provide extra DOM structure.\n     * @template\n     */\n    mutateMetaRowTpl: Ext.emptyFn,\n\n    /**\n     * Allows a feature to inject member methods into the metaRowTpl. This is\n     * important for embedding functionality which will become part of the proper\n     * row tpl.\n     * @template\n     */\n    getMetaRowTplFragments: function() {\n        return {};\n    },\n\n    getTableFragments: function() {\n        return {};\n    },\n\n    /**\n     * Provide additional data to the prepareData call within the grid view.\n     * @param {Object} data The data for this particular record.\n     * @param {Number} idx The row index for this record.\n     * @param {Ext.data.Model} record The record instance\n     * @param {Object} orig The original result from the prepareData call to massage.\n     * @template\n     */\n    getAdditionalData: function(data, idx, record, orig) {\n        return {};\n    },\n\n    /**\n     * Enables the feature.\n     */\n    enable: function() {\n        this.disabled = false;\n    },\n\n    /**\n     * Disables the feature.\n     */\n    disable: function() {\n        this.disabled = true;\n    }\n\n});\n\n/**\n * A small abstract class that contains the shared behaviour for any summary\n * calculations to be used in the grid.\n */\nExt.define('Ext.grid.feature.AbstractSummary', {\n    \n    /* Begin Definitions */\n\n    extend: 'Ext.grid.feature.Feature',\n    \n    alias: 'feature.abstractsummary',\n\n    /* End Definitions */\n\n   /**\n    * @cfg\n    * True to show the summary row.\n    */\n    showSummaryRow: true,\n\n    // @private\n    nestedIdRe: /\\{\\{id\\}([\\w\\-]*)\\}/g,\n\n    // Listen for store updates. Eg, from an Editor.\n    init: function() {\n        var me = this;\n\n        // Summary rows must be kept in column order, so view must be refreshed on column move\n        me.grid.optimizedColumnMove = false;\n\n        me.view.mon(me.view.store, {\n            update: me.onStoreUpdate,\n            scope: me\n        });\n    },\n\n    // Refresh the whole view on edit so that the Summary gets updated\n    onStoreUpdate: function() {\n        var v = this.view;\n        if (this.showSummaryRow) {\n            v.saveScrollState();\n            v.refresh();\n            v.restoreScrollState();\n        }\n    },\n\n    /**\n     * Toggle whether or not to show the summary row.\n     * @param {Boolean} visible True to show the summary row\n     */\n    toggleSummaryRow: function(visible){\n        this.showSummaryRow = !!visible;\n    },\n\n    /**\n     * Gets any fragments to be used in the tpl\n     * @private\n     * @return {Object} The fragments\n     */\n    getSummaryFragments: function(){\n        var fragments = {};\n        if (this.showSummaryRow) {\n            Ext.apply(fragments, {\n                printSummaryRow: Ext.bind(this.printSummaryRow, this)\n            });\n        }\n        return fragments;\n    },\n\n    /**\n     * Prints a summary row\n     * @private\n     * @param {Object} index The index in the template\n     * @return {String} The value of the summary row\n     */\n    printSummaryRow: function(index){\n        var inner = this.view.getTableChunker().metaRowTpl.join(''),\n            prefix = Ext.baseCSSPrefix;\n\n        inner = inner.replace(prefix + 'grid-row', prefix + 'grid-row-summary');\n        inner = inner.replace('{{id}}', '{gridSummaryValue}');\n        inner = inner.replace(this.nestedIdRe, '{id$1}');  \n        inner = inner.replace('{[this.embedRowCls()]}', '{rowCls}');\n        inner = inner.replace('{[this.embedRowAttr()]}', '{rowAttr}');\n        inner = new Ext.XTemplate(inner, {\n            firstOrLastCls: Ext.view.TableChunker.firstOrLastCls\n        });\n\n        return inner.applyTemplate({\n            columns: this.getPrintData(index)\n        });\n    },\n\n    /**\n     * Gets the value for the column from the attached data.\n     * @param {Ext.grid.column.Column} column The header\n     * @param {Object} data The current data\n     * @return {String} The value to be rendered\n     */\n    getColumnValue: function(column, summaryData){\n        var comp     = Ext.getCmp(column.id),\n            value    = summaryData[column.id],\n            renderer = comp.summaryRenderer;\n            \n        if (!value && value !== 0) {\n            value = '\\u00a0';\n        }\n\n        if (renderer) {\n            value = renderer.call(\n                comp.scope || this,\n                value,\n                summaryData,\n                column.dataIndex\n            );\n        }\n        return value;\n    },\n\n    /**\n     * Get the summary data for a field.\n     * @private\n     * @param {Ext.data.Store} store The store to get the data from\n     * @param {String/Function} type The type of aggregation. If a function is specified it will\n     * be passed to the stores aggregate function.\n     * @param {String} field The field to aggregate on\n     * @param {Boolean} group True to aggregate in grouped mode \n     * @return {Number/String/Object} See the return type for the store functions.\n     */\n    getSummary: function(store, type, field, group){\n        if (type) {\n            if (Ext.isFunction(type)) {\n                return store.aggregate(type, null, group);\n            }\n\n            switch (type) {\n                case 'count':\n                    return store.count(group);\n                case 'min':\n                    return store.min(field, group);\n                case 'max':\n                    return store.max(field, group);\n                case 'sum':\n                    return store.sum(field, group);\n                case 'average':\n                    return store.average(field, group);\n                default:\n                    return group ? {} : '';\n                    \n            }\n        }\n    }\n\n});\n\n/**\n *\n */\nExt.define('Ext.grid.feature.Chunking', {\n    extend: 'Ext.grid.feature.Feature',\n    alias: 'feature.chunking',\n\n    chunkSize: 20,\n    rowHeight: Ext.isIE ? 27 : 26,\n    visibleChunk: 0,\n    hasFeatureEvent: false,\n    attachEvents: function() {\n        this.view.el.on('scroll', this.onBodyScroll, this, {buffer: 300});\n    },\n\n    onBodyScroll: function(e, t) {\n        var view = this.view,\n            top  = t.scrollTop,\n            nextChunk = Math.floor(top / this.rowHeight / this.chunkSize);\n        if (nextChunk !== this.visibleChunk) {\n\n            this.visibleChunk = nextChunk;\n            view.refresh();\n            view.el.dom.scrollTop = top;\n            //BrowserBug: IE6,7,8 quirks mode takes setting scrollTop 2x.\n            view.el.dom.scrollTop = top;\n        }\n    },\n\n    collectData: function(records, preppedRecords, startIndex, fullWidth, o) {\n        //headerCt = this.view.headerCt,\n        //colums = headerCt.getColumnsForTpl(),\n        var me = this,\n            recordCount = o.rows.length,\n            start = 0,\n            i = 0,\n            visibleChunk = me.visibleChunk,\n            rows,\n            chunkLength,\n            origRows = o.rows;\n\n        delete o.rows;\n        o.chunks = [];\n        for (; start < recordCount; start += me.chunkSize, i++) {\n            if (start + me.chunkSize > recordCount) {\n                chunkLength = recordCount - start;\n            } else {\n                chunkLength = me.chunkSize;\n            }\n            \n            if (i >= visibleChunk - 1 && i <= visibleChunk + 1) {\n                rows = origRows.slice(start, start + me.chunkSize);\n            } else {\n                rows = [];\n            }\n            o.chunks.push({\n                rows: rows,\n                fullWidth: fullWidth,\n                chunkHeight: chunkLength * me.rowHeight\n            });\n        }\n\n        return o;\n    },\n\n    getTableFragments: function() {\n        return {\n            openTableWrap: function() {\n                return '<tpl for=\"chunks\"><div class=\"' + Ext.baseCSSPrefix + 'grid-chunk\" style=\"height: {chunkHeight}px;\">';\n            },\n            closeTableWrap: function() {\n                return '</div></tpl>';\n            }\n        };\n    }\n});\n\n/**\n * This feature allows to display the grid rows aggregated into groups as specified by the {@link Ext.data.Store#groupers}\n * specified on the Store. The group will show the title for the group name and then the appropriate records for the group\n * underneath. The groups can also be expanded and collapsed.\n * \n * ## Extra Events\n *\n * This feature adds several extra events that will be fired on the grid to interact with the groups:\n *\n *  - {@link #groupclick}\n *  - {@link #groupdblclick}\n *  - {@link #groupcontextmenu}\n *  - {@link #groupexpand}\n *  - {@link #groupcollapse}\n * \n * ## Menu Augmentation\n *\n * This feature adds extra options to the grid column menu to provide the user with functionality to modify the grouping.\n * This can be disabled by setting the {@link #enableGroupingMenu} option. The option to disallow grouping from being turned off\n * by the user is {@link #enableNoGroups}.\n * \n * ## Controlling Group Text\n *\n * The {@link #groupHeaderTpl} is used to control the rendered title for each group. It can modified to customized\n * the default display.\n * \n * ## Example Usage\n * \n *     @example\n *     var store = Ext.create('Ext.data.Store', {\n *         storeId:'employeeStore',\n *         fields:['name', 'seniority', 'department'],\n *         groupField: 'department',\n *         data: {'employees':[\n *             { \"name\": \"Michael Scott\",  \"seniority\": 7, \"department\": \"Management\" },\n *             { \"name\": \"Dwight Schrute\", \"seniority\": 2, \"department\": \"Sales\" },\n *             { \"name\": \"Jim Halpert\",    \"seniority\": 3, \"department\": \"Sales\" },\n *             { \"name\": \"Kevin Malone\",   \"seniority\": 4, \"department\": \"Accounting\" },\n *             { \"name\": \"Angela Martin\",  \"seniority\": 5, \"department\": \"Accounting\" }\n *         ]},\n *         proxy: {\n *             type: 'memory',\n *             reader: {\n *                 type: 'json',\n *                 root: 'employees'\n *             }\n *         }\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Employees',\n *         store: Ext.data.StoreManager.lookup('employeeStore'),\n *         columns: [\n *             { text: 'Name',     dataIndex: 'name' },\n *             { text: 'Seniority', dataIndex: 'seniority' }\n *         ],\n *         features: [{ftype:'grouping'}],\n *         width: 200,\n *         height: 275,\n *         renderTo: Ext.getBody()\n *     });\n *\n * **Note:** To use grouping with a grid that has {@link Ext.grid.column.Column#locked locked columns}, you need to supply\n * the grouping feature as a config object - so the grid can create two instances of the grouping feature.\n *\n * @author Nicolas Ferrero\n */\nExt.define('Ext.grid.feature.Grouping', {\n    extend: 'Ext.grid.feature.Feature',\n    alias: 'feature.grouping',\n\n    eventPrefix: 'group',\n    eventSelector: '.' + Ext.baseCSSPrefix + 'grid-group-hd',\n    bodySelector: '.' + Ext.baseCSSPrefix + 'grid-group-body',\n\n    constructor: function() {\n        var me = this;\n\n        me.collapsedState = {};\n        me.callParent(arguments);\n    },\n    \n    /**\n     * @event groupclick\n     * @param {Ext.view.Table} view\n     * @param {HTMLElement} node\n     * @param {String} group The name of the group\n     * @param {Ext.EventObject} e\n     */\n\n    /**\n     * @event groupdblclick\n     * @param {Ext.view.Table} view\n     * @param {HTMLElement} node\n     * @param {String} group The name of the group\n     * @param {Ext.EventObject} e\n     */\n\n    /**\n     * @event groupcontextmenu\n     * @param {Ext.view.Table} view\n     * @param {HTMLElement} node\n     * @param {String} group The name of the group\n     * @param {Ext.EventObject} e\n     */\n\n    /**\n     * @event groupcollapse\n     * @param {Ext.view.Table} view\n     * @param {HTMLElement} node\n     * @param {String} group The name of the group\n     */\n\n    /**\n     * @event groupexpand\n     * @param {Ext.view.Table} view\n     * @param {HTMLElement} node\n     * @param {String} group The name of the group\n     */\n\n    /**\n     * @cfg {String/Array/Ext.Template} groupHeaderTpl\n     * A string Template snippet, an array of strings (optionally followed by an object containing Template methods) to be used to construct a Template, or a Template instance.\n     * \n     * - Example 1 (Template snippet):\n     * \n     *       groupHeaderTpl: 'Group: {name}'\n     *     \n     * - Example 2 (Array):\n     * \n     *       groupHeaderTpl: [\n     *           'Group: ',\n     *           '<div>{name:this.formatName}</div>',\n     *           {\n     *               formatName: function(name) {\n     *                   return Ext.String.trim(name);\n     *               }\n     *           }\n     *       ]\n     *     \n     * - Example 3 (Template Instance):\n     * \n     *       groupHeaderTpl: Ext.create('Ext.XTemplate',\n     *           'Group: ',\n     *           '<div>{name:this.formatName}</div>',\n     *           {\n     *               formatName: function(name) {\n     *                   return Ext.String.trim(name);\n     *               }\n     *           }\n     *       )\n     *\n     * @cfg {String}           groupHeaderTpl.groupField         The field name being grouped by.\n     * @cfg {String}           groupHeaderTpl.columnName         The column header associated with the field being grouped by *if there is a column for the field*, falls back to the groupField name.\n     * @cfg {Mixed}            groupHeaderTpl.groupValue         The value of the {@link Ext.data.Store#groupField groupField} for the group header being rendered.\n     * @cfg {String}           groupHeaderTpl.renderedGroupValue The rendered value of the {@link Ext.data.Store#groupField groupField} for the group header being rendered, as produced by the column renderer.\n     * @cfg {String}           groupHeaderTpl.name               An alias for renderedGroupValue\n     * @cfg {Object[]}         groupHeaderTpl.rows               An array of child row data objects as returned by the View's {@link Ext.view.AbstractView#prepareData prepareData} method.\n     * @cfg {Ext.data.Model[]} groupHeaderTpl.children           An array containing the child records for the group being rendered.\n     */\n    groupHeaderTpl: '{columnName}: {name}',\n    \n    /**\n     * @cfg {Number} [depthToIndent=17]\n     * Number of pixels to indent per grouping level\n     */\n    depthToIndent: 17,\n\n    collapsedCls: Ext.baseCSSPrefix + 'grid-group-collapsed',\n    hdCollapsedCls: Ext.baseCSSPrefix + 'grid-group-hd-collapsed',\n    hdCollapsibleCls: Ext.baseCSSPrefix + 'grid-group-hd-collapsible',\n\n    //<locale>\n    /**\n     * @cfg {String} [groupByText=\"Group by this field\"]\n     * Text displayed in the grid header menu for grouping by header.\n     */\n    groupByText : 'Group by this field',\n    //</locale>\n    //<locale>\n    /**\n     * @cfg {String} [showGroupsText=\"Show in groups\"]\n     * Text displayed in the grid header for enabling/disabling grouping.\n     */\n    showGroupsText : 'Show in groups',\n    //</locale>\n\n    /**\n     * @cfg {Boolean} [hideGroupedHeader=false]\n     * True to hide the header that is currently grouped.\n     */\n    hideGroupedHeader : false,\n\n    /**\n     * @cfg {Boolean} [startCollapsed=false]\n     * True to start all groups collapsed.\n     */\n    startCollapsed : false,\n\n    /**\n     * @cfg {Boolean} [enableGroupingMenu=true]\n     * True to enable the grouping control in the header menu.\n     */\n    enableGroupingMenu : true,\n\n    /**\n     * @cfg {Boolean} [enableNoGroups=true]\n     * True to allow the user to turn off grouping.\n     */\n    enableNoGroups : true,\n\n    /**\n     * @cfg {Boolean} [collapsible=true]\n     * Set to `falsee` to disable collapsing groups from the UI.\n     * \n     * This is set to `false` when the associated {@link Ext.data.Store store} is \n     * {@link Ext.data.Store#buffered buffered}.\n     */\n    collapsible: true,\n\n    enable: function() {\n        var me    = this,\n            view  = me.view,\n            store = view.store,\n            groupToggleMenuItem;\n\n        me.lastGroupField = me.getGroupField();\n\n        if (me.lastGroupIndex) {\n            me.block();\n            store.group(me.lastGroupIndex);\n            me.unblock();\n        }\n        me.callParent();\n        groupToggleMenuItem = me.view.headerCt.getMenu().down('#groupToggleMenuItem');\n        groupToggleMenuItem.setChecked(true, true);\n        me.refreshIf();\n    },\n\n    disable: function() {\n        var me    = this,\n            view  = me.view,\n            store = view.store,\n            remote = store.remoteGroup,\n            groupToggleMenuItem,\n            lastGroup;\n\n        lastGroup = store.groupers.first();\n        if (lastGroup) {\n            me.lastGroupIndex = lastGroup.property;\n            me.block();\n            store.clearGrouping();\n            me.unblock();\n        }\n\n        me.callParent();\n        groupToggleMenuItem = me.view.headerCt.getMenu().down('#groupToggleMenuItem');\n        groupToggleMenuItem.setChecked(true, true);\n        groupToggleMenuItem.setChecked(false, true);\n        me.refreshIf();\n    },\n\n    refreshIf: function() {\n        var ownerCt = this.grid.ownerCt,\n            view = this.view;\n            \n        if (!view.store.remoteGroup && !this.blockRefresh) {\n\n            // We are one side of a lockable grid, so refresh the locking view\n            if (ownerCt && ownerCt.lockable) {\n                ownerCt.view.refresh();\n            } else {\n                view.refresh();\n            }\n        }\n    },\n\n    getFeatureTpl: function(values, parent, x, xcount) {\n        return [\n            '<tpl if=\"typeof rows !== \\'undefined\\'\">',\n                // group row tpl\n                '<tr id=\"{groupHeaderId}\" class=\"' + Ext.baseCSSPrefix + 'grid-group-hd {hdCollapsedCls} {collapsibleClass}\"><td class=\"' + Ext.baseCSSPrefix + 'grid-cell\" colspan=\"' + parent.columns.length + '\" {[this.indentByDepth(values)]}><div class=\"' + Ext.baseCSSPrefix + 'grid-cell-inner\"><div class=\"' + Ext.baseCSSPrefix + 'grid-group-title\">{collapsed}{[this.renderGroupHeaderTpl(values, parent)]}</div></div></td></tr>',\n                // this is the rowbody\n                '<tr id=\"{groupBodyId}\" class=\"' + Ext.baseCSSPrefix + 'grid-group-body {collapsedCls}\"><td colspan=\"' + parent.columns.length + '\">{[this.recurse(values)]}</td></tr>',\n            '</tpl>'\n        ].join('');\n    },\n\n    getFragmentTpl: function() {\n        var me = this;\n        return {\n            indentByDepth: me.indentByDepth,\n            depthToIndent: me.depthToIndent,\n            renderGroupHeaderTpl: function(values, parent) {\n                return Ext.XTemplate.getTpl(me, 'groupHeaderTpl').apply(values, parent);\n            }\n        };\n    },\n\n    indentByDepth: function(values) {\n        return 'style=\"padding-left:'+ ((values.depth || 0) * this.depthToIndent) + 'px;\"';\n    },\n\n    // Containers holding these components are responsible for\n    // destroying them, we are just deleting references.\n    destroy: function() {\n        delete this.view;\n        delete this.prunedHeader;\n    },\n\n    // perhaps rename to afterViewRender\n    attachEvents: function() {\n        var me = this,\n            view = me.view;\n\n        view.on({\n            scope: me,\n            groupclick: me.onGroupClick,\n            rowfocus: me.onRowFocus\n        });\n\n        view.mon(view.store, {\n            scope: me,\n            groupchange: me.onGroupChange,\n            remove: me.onRemove,\n            add: me.onAdd,\n            update: me.onUpdate\n        });\n\n        if (me.enableGroupingMenu) {\n            me.injectGroupingMenu();\n        }\n\n        me.pruneGroupedHeader();\n\n        me.lastGroupField = me.getGroupField();\n        me.block();\n        me.onGroupChange();\n        me.unblock();\n    },\n\n    // If we add a new item that doesn't belong to a rendered group, refresh the view\n    onAdd: function(store, records){\n        var me = this,\n            view = me.view,\n            groupField = me.getGroupField(),\n            i = 0,\n            len = records.length,\n            activeGroups,\n            addedGroups,\n            groups,\n            needsRefresh,\n            group;\n\n        if (view.rendered) {\n            addedGroups = {};\n            activeGroups = {};\n\n            for (; i < len; ++i) {\n                group = records[i].get(groupField);\n                if (addedGroups[group] === undefined) {\n                    addedGroups[group] = 0;\n                }\n                addedGroups[group] += 1;\n            }\n            groups = store.getGroups();\n            for (i = 0, len = groups.length; i < len; ++i) {\n                group = groups[i];\n                activeGroups[group.name] = group.children.length;\n            }\n\n            for (group in addedGroups) {\n                if (addedGroups[group] === activeGroups[group]) {\n                    needsRefresh = true;\n                    break;\n                }\n            }\n            \n            if (needsRefresh) {\n                view.refresh();\n            }\n        }\n    },\n\n    onUpdate: function(store, record, type, changedFields){\n        var view = this.view;\n        if (view.rendered && !changedFields || Ext.Array.contains(changedFields, this.getGroupField())) {\n            view.refresh();\n        }\n    },\n\n    onRemove: function(store, record) {\n        var me = this,\n            groupField = me.getGroupField(),\n            removedGroup = record.get(groupField),\n            view = me.view;\n\n        if (view.rendered) {\n            // If that was the last one in the group, force a refresh\n            if (store.findExact(groupField, removedGroup) === -1) {\n                me.view.refresh(); \n            }\n        }\n    },\n\n    injectGroupingMenu: function() {\n        var me       = this,\n            headerCt = me.view.headerCt;\n\n        headerCt.showMenuBy = me.showMenuBy;\n        headerCt.getMenuItems = me.getMenuItems();\n    },\n\n    showMenuBy: function(t, header) {\n        var menu = this.getMenu(),\n            groupMenuItem  = menu.down('#groupMenuItem'),\n            groupableMth = header.groupable === false ?  'disable' : 'enable';\n            \n        groupMenuItem[groupableMth]();\n        Ext.grid.header.Container.prototype.showMenuBy.apply(this, arguments);\n    },\n\n    getMenuItems: function() {\n        var me                 = this,\n            groupByText        = me.groupByText,\n            disabled           = me.disabled || !me.getGroupField(),\n            showGroupsText     = me.showGroupsText,\n            enableNoGroups     = me.enableNoGroups,\n            getMenuItems       = me.view.headerCt.getMenuItems;\n\n        // runs in the scope of headerCt\n        return function() {\n\n            // We cannot use the method from HeaderContainer's prototype here\n            // because other plugins or features may already have injected an implementation\n            var o = getMenuItems.call(this);\n            o.push('-', {\n                iconCls: Ext.baseCSSPrefix + 'group-by-icon',\n                itemId: 'groupMenuItem',\n                text: groupByText,\n                handler: me.onGroupMenuItemClick,\n                scope: me\n            });\n            if (enableNoGroups) {\n                o.push({\n                    itemId: 'groupToggleMenuItem',\n                    text: showGroupsText,\n                    checked: !disabled,\n                    checkHandler: me.onGroupToggleMenuItemClick,\n                    scope: me\n                });\n            }\n            return o;\n        };\n    },\n\n    /**\n     * Group by the header the user has clicked on.\n     * @private\n     */\n    onGroupMenuItemClick: function(menuItem, e) {\n        var me = this,\n            menu = menuItem.parentMenu,\n            hdr  = menu.activeHeader,\n            view = me.view,\n            store = view.store;\n\n        delete me.lastGroupIndex;\n        me.block();\n        me.enable();\n        store.group(hdr.dataIndex);\n        me.pruneGroupedHeader();\n        me.unblock();\n        me.refreshIf();\n    },\n\n    block: function(){\n        this.blockRefresh = this.view.blockRefresh = true;\n    },\n\n    unblock: function(){\n        this.blockRefresh = this.view.blockRefresh = false;\n    },\n\n    /**\n     * Turn on and off grouping via the menu\n     * @private\n     */\n    onGroupToggleMenuItemClick: function(menuItem, checked) {\n        this[checked ? 'enable' : 'disable']();\n    },\n\n    /**\n     * Prunes the grouped header from the header container\n     * @private\n     */\n    pruneGroupedHeader: function() {\n        var me = this,\n            header = me.getGroupedHeader();\n\n        if (me.hideGroupedHeader && header) {\n            if (me.prunedHeader) {\n                me.prunedHeader.show();\n            }\n            me.prunedHeader = header;\n            header.hide();\n        }\n    },\n\n    getGroupedHeader: function(){\n        var groupField = this.getGroupField(),\n            headerCt = this.view.headerCt;\n\n        return groupField ? headerCt.down('[dataIndex=' + groupField + ']') : null;\n    },\n\n    getGroupField: function(){\n        var group = this.view.store.groupers.first();\n        if (group) {\n            return group.property;\n        }\n        return ''; \n    },\n\n    /**\n     * When a row gains focus, expand the groups above it\n     * @private\n     */\n    onRowFocus: function(rowIdx) {\n        var node    = this.view.getNode(rowIdx),\n            groupBd = Ext.fly(node).up('.' + this.collapsedCls);\n\n        if (groupBd) {\n            // for multiple level groups, should expand every groupBd\n            // above\n            this.expand(groupBd);\n        }\n    },\n\n    /**\n     * Returns `true` if the named group is expanded.\n     * @param {String} groupName The group name as returned from {@link Ext.data.Store#getGroupString getGroupString}. This is usually the value of\n     * the {@link Ext.data.Store#groupField groupField}.\n     * @return {Boolean} `true` if the group defined by that value is expanded.\n     */\n    isExpanded: function(groupName) {\n        return (this.collapsedState[groupName] === false);\n    },\n\n    /**\n     * Expand a group\n     * @param {String/Ext.Element} groupName The group name, or the element that contains the group body\n     * @param {Boolean} focus Pass `true` to focus the group after expand.\n     */\n    expand: function(groupName, focus, /*private*/ preventSizeCalculation) {\n        var me = this,\n            view = me.view,\n            groupHeader,\n            groupBody,\n            lockingPartner = me.lockingPartner;\n\n        // We've been passed the group name\n        if (Ext.isString(groupName)) {\n            groupBody = Ext.fly(me.getGroupBodyId(groupName), '_grouping');\n        }\n        // We've been passed an element\n        else {\n            groupBody = Ext.fly(groupName, '_grouping')\n            groupName = me.getGroupName(groupBody);\n        }\n        groupHeader = Ext.get(me.getGroupHeaderId(groupName));\n\n        // If we are collapsed...\n        if (me.collapsedState[groupName]) {\n            groupBody.removeCls(me.collapsedCls);\n            groupBody.prev().removeCls(me.hdCollapsedCls);\n\n            if (preventSizeCalculation !== true) {\n                view.refreshSize();\n            }\n            view.fireEvent('groupexpand', view, groupHeader, groupName);\n            me.collapsedState[groupName] = false;\n\n            // If we are one side of a locking view, the other side has to stay in sync\n            if (lockingPartner) {\n                lockingPartner.expand(groupName, focus, preventSizeCalculation);\n            }\n            if (focus) {\n                groupBody.scrollIntoView(view.el, null, true);\n            }\n        }\n    },\n\n    /**\n     * Expand all groups\n     */\n    expandAll: function(){\n        var me   = this,\n            view = me.view,\n            els  = view.el.select(me.eventSelector).elements,\n            e,\n            eLen = els.length;\n\n        for (e = 0; e < eLen; e++) {\n            me.expand(Ext.fly(els[e]).next(), false, true);\n        }\n\n        view.refreshSize();\n    },\n\n    /**\n     * Collapse a group\n     * @param {String/Ext.Element} groupName The group name, or the element that contains group body\n     * @param {Boolean} focus Pass `true` to focus the group after expand.\n     */\n    collapse: function(groupName, focus, /*private*/ preventSizeCalculation) {\n        var me = this,\n            view = me.view,\n            groupHeader,\n            groupBody,\n            lockingPartner = me.lockingPartner;\n\n        // We've been passed the group name\n        if (Ext.isString(groupName)) {\n            groupBody = Ext.fly(me.getGroupBodyId(groupName), '_grouping');\n        }\n        // We've been passed an element\n        else {\n            groupBody = Ext.fly(groupName, '_grouping')\n            groupName = me.getGroupName(groupBody);\n        }\n        groupHeader = Ext.get(me.getGroupHeaderId(groupName));\n \n        // If we are not collapsed...\n        if (!me.collapsedState[groupName]) {\n            groupBody.addCls(me.collapsedCls);\n            groupBody.prev().addCls(me.hdCollapsedCls);\n\n            if (preventSizeCalculation !== true) {\n                view.refreshSize();\n            }\n            view.fireEvent('groupcollapse', view, groupHeader, groupName);\n            me.collapsedState[groupName] = true;\n\n            // If we are one side of a locking view, the other side has to stay in sync\n            if (lockingPartner) {\n                lockingPartner.collapse(groupName, focus, preventSizeCalculation);\n            }\n            if (focus) {\n                groupHeader.scrollIntoView(view.el, null, true);\n            }\n        }\n    },\n\n    /**\n     * Collapse all groups\n     */\n    collapseAll: function() {\n        var me     = this,\n            view   = me.view,\n            els    = view.el.select(me.eventSelector).elements,\n            e,\n            eLen   = els.length;\n\n        for (e = 0; e < eLen; e++) {\n            me.collapse(Ext.fly(els[e]).next(), false, true);\n        }\n\n        view.refreshSize();\n    },\n\n    onGroupChange: function(){\n        var me = this,\n            field = me.getGroupField(),\n            menuItem,\n            visibleGridColumns,\n            groupingByLastVisibleColumn;\n\n        if (me.hideGroupedHeader) {\n            if (me.lastGroupField) {\n                menuItem = me.getMenuItem(me.lastGroupField);\n                if (menuItem) {\n                    menuItem.setChecked(true);\n                }\n            }\n            if (field) {\n                visibleGridColumns = me.view.headerCt.getVisibleGridColumns();\n\n                // See if we are being asked to group by the sole remaining visible column.\n                // If so, then do not hide that column.\n                groupingByLastVisibleColumn = ((visibleGridColumns.length === 1) && (visibleGridColumns[0].dataIndex == field));\n                menuItem = me.getMenuItem(field);\n                if (menuItem && !groupingByLastVisibleColumn) {\n                    menuItem.setChecked(false);\n                }\n            }\n        }\n        me.refreshIf();\n        me.lastGroupField = field;\n    },\n\n    /**\n     * Gets the related menu item for a dataIndex\n     * @private\n     * @return {Ext.grid.header.Container} The header\n     */\n    getMenuItem: function(dataIndex){\n        var view = this.view,\n            header = view.headerCt.down('gridcolumn[dataIndex=' + dataIndex + ']'),\n            menu = view.headerCt.getMenu();\n\n        return header ? menu.down('menuitem[headerId='+ header.id +']') : null;\n    },\n\n    /**\n     * Toggle between expanded/collapsed state when clicking on\n     * the group.\n     * @private\n     */\n    onGroupClick: function(view, rowElement, groupName, e) {\n        var me = this;\n\n        if (me.collapsible) {\n            if (me.collapsedState[groupName]) {\n                me.expand(groupName);\n            } else {\n                me.collapse(groupName);\n            }\n        }\n    },\n\n    // Injects isRow and closeRow into the metaRowTpl.\n    getMetaRowTplFragments: function() {\n        return {\n            isRow: this.isRow,\n            closeRow: this.closeRow\n        };\n    },\n\n    // injected into rowtpl and wrapped around metaRowTpl\n    // becomes part of the standard tpl\n    isRow: function() {\n        return '<tpl if=\"typeof rows === \\'undefined\\'\">';\n    },\n\n    // injected into rowtpl and wrapped around metaRowTpl\n    // becomes part of the standard tpl\n    closeRow: function() {\n        return '</tpl>';\n    },\n\n    // isRow and closeRow are injected via getMetaRowTplFragments\n    mutateMetaRowTpl: function(metaRowTpl) {\n        metaRowTpl.unshift('{[this.isRow()]}');\n        metaRowTpl.push('{[this.closeRow()]}');\n    },\n\n    // injects an additional style attribute via tdAttrKey with the proper\n    // amount of padding\n    getAdditionalData: function(data, idx, record, orig) {\n        var view = this.view,\n            hCt  = view.headerCt,\n            col  = hCt.items.getAt(0),\n            o = {},\n            tdAttrKey;\n\n        // If there *are* any columne in this grid (possible empty side of a locking grid)...\n        // Add the padding-left style to indent the row according to grouping depth.\n        // Preserve any current tdAttr that a user may have set.\n        if (col) {\n            tdAttrKey = col.id + '-tdAttr';\n            o[tdAttrKey] = this.indentByDepth(data) + \" \" + (orig[tdAttrKey] ? orig[tdAttrKey] : '');\n            o.collapsed = 'true';\n            o.data = record.getData();\n        }\n        return o;\n    },\n\n    // return matching preppedRecords\n    getGroupRows: function(group, records, preppedRecords, fullWidth) {\n        var me = this,\n            children = group.children,\n            rows = group.rows = [],\n            view = me.view,\n            header = me.getGroupedHeader(),\n            groupField = me.getGroupField(),\n            index = -1,\n            r,\n            rLen = records.length,\n            record;\n            \n        // Buffered rendering implies that user collapsing is disabled.\n        if (view.store.buffered) {\n            me.collapsible = false;\n        }\n            \n        group.viewId = view.id;\n\n        for (r = 0; r < rLen; r++) {\n            record = records[r];\n\n            if (record.get(groupField) == group.name) {\n                index = r;\n            }\n            if (Ext.Array.indexOf(children, record) != -1) {\n                rows.push(Ext.apply(preppedRecords[r], {\n                    depth : 1\n                }));\n            }\n        }\n\n        group.groupField = groupField,\n        group.groupHeaderId = me.getGroupHeaderId(group.name);\n        group.groupBodyId = me.getGroupBodyId(group.name);\n        group.fullWidth = fullWidth;\n        group.columnName = header ? header.text : groupField;\n        group.groupValue = group.name;\n\n        // Here we attempt to overwrite the group name value from the Store with\n        // the get the rendered value of the column from the *prepped* record\n        if (header && index > -1) {\n            group.name = group.renderedValue = preppedRecords[index][header.id];\n        }\n        if (me.collapsedState[group.name]) {\n            group.collapsedCls = me.collapsedCls;\n            group.hdCollapsedCls = me.hdCollapsedCls;\n        } else {\n            group.collapsedCls = group.hdCollapsedCls = '';\n        }\n\n        // Collapsibility of groups may be disabled.\n        if (me.collapsible) {\n            group.collapsibleClass = me.hdCollapsibleCls;\n        } else {\n            group.collapsibleClass = '';\n        }\n\n        return group;\n    },\n\n    // Create an associated DOM id for the group's header element given the group name\n    getGroupHeaderId: function(groupName) {\n        return this.view.id + '-hd-' + groupName;\n    },\n\n    // Create an associated DOM id for the group's body element given the group name\n    getGroupBodyId: function(groupName) {\n        return this.view.id + '-bd-' + groupName;\n    },\n\n    // Get the group name from an associated element whether it's within a header or a body\n    getGroupName: function(element) {\n        var me = this,\n            targetEl;\n                \n        // See if element is, or is within a group header. If so, we can extract its name\n        targetEl = Ext.fly(element).findParent(me.eventSelector);\n        if (targetEl) {\n            return targetEl.id.split(this.view.id + '-hd-')[1];\n        }\n\n        // See if element is, or is within a group body. If so, we can extract its name\n        targetEl = Ext.fly(element).findParent(me.bodySelector);\n        if (targetEl) {\n            return targetEl.id.split(this.view.id + '-bd-')[1];\n        }\n    },\n\n    // return the data in a grouped format.\n    collectData: function(records, preppedRecords, startIndex, fullWidth, o) {\n        var me    = this,\n            store = me.view.store,\n            collapsedState = me.collapsedState,\n            collapseGroups,\n            g,\n            groups, gLen, group;\n\n        if (me.startCollapsed) {\n            // If we start collapse, we'll set the state of the groups here\n            // and unset the flag so any subsequent expand/collapse is\n            // managed by the feature\n            me.startCollapsed = false;\n            collapseGroups = true;\n        }\n\n        if (!me.disabled && store.isGrouped()) {\n            o.rows = groups = store.getGroups();\n            gLen   = groups.length;\n\n            for (g = 0; g < gLen; g++) {\n                group = groups[g];\n                \n                if (collapseGroups) {\n                    collapsedState[group.name] = true;\n                }\n\n                me.getGroupRows(group, records, preppedRecords, fullWidth);\n            }\n        }\n        return o;\n    },\n\n    // adds the groupName to the groupclick, groupdblclick, groupcontextmenu\n    // events that are fired on the view. Chose not to return the actual\n    // group itself because of its expense and because developers can simply\n    // grab the group via store.getGroups(groupName)\n    getFireEventArgs: function(type, view, targetEl, e) {\n        return [type, view, targetEl, this.getGroupName(targetEl), e];\n    }\n});\n\n/**\n * This feature adds an aggregate summary row at the bottom of each group that is provided\n * by the {@link Ext.grid.feature.Grouping} feature. There are two aspects to the summary:\n *\n * ## Calculation\n *\n * The summary value needs to be calculated for each column in the grid. This is controlled\n * by the summaryType option specified on the column. There are several built in summary types,\n * which can be specified as a string on the column configuration. These call underlying methods\n * on the store:\n *\n *  - {@link Ext.data.Store#count count}\n *  - {@link Ext.data.Store#sum sum}\n *  - {@link Ext.data.Store#min min}\n *  - {@link Ext.data.Store#max max}\n *  - {@link Ext.data.Store#average average}\n *\n * Alternatively, the summaryType can be a function definition. If this is the case,\n * the function is called with an array of records to calculate the summary value.\n *\n * ## Rendering\n *\n * Similar to a column, the summary also supports a summaryRenderer function. This\n * summaryRenderer is called before displaying a value. The function is optional, if\n * not specified the default calculated value is shown. The summaryRenderer is called with:\n *\n *  - value {Object} - The calculated value.\n *  - summaryData {Object} - Contains all raw summary values for the row.\n *  - field {String} - The name of the field we are calculating\n *\n * ## Example Usage\n *\n *     @example\n *     Ext.define('TestResult', {\n *         extend: 'Ext.data.Model',\n *         fields: ['student', 'subject', {\n *             name: 'mark',\n *             type: 'int'\n *         }]\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         width: 200,\n *         height: 240,\n *         renderTo: document.body,\n *         features: [{\n *             groupHeaderTpl: 'Subject: {name}',\n *             ftype: 'groupingsummary'\n *         }],\n *         store: {\n *             model: 'TestResult',\n *             groupField: 'subject',\n *             data: [{\n *                 student: 'Student 1',\n *                 subject: 'Math',\n *                 mark: 84\n *             },{\n *                 student: 'Student 1',\n *                 subject: 'Science',\n *                 mark: 72\n *             },{\n *                 student: 'Student 2',\n *                 subject: 'Math',\n *                 mark: 96\n *             },{\n *                 student: 'Student 2',\n *                 subject: 'Science',\n *                 mark: 68\n *             }]\n *         },\n *         columns: [{\n *             dataIndex: 'student',\n *             text: 'Name',\n *             summaryType: 'count',\n *             summaryRenderer: function(value){\n *                 return Ext.String.format('{0} student{1}', value, value !== 1 ? 's' : '');\n *             }\n *         }, {\n *             dataIndex: 'mark',\n *             text: 'Mark',\n *             summaryType: 'average'\n *         }]\n *     });\n */\nExt.define('Ext.grid.feature.GroupingSummary', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.grid.feature.Grouping',\n\n    alias: 'feature.groupingsummary',\n\n    mixins: {\n        summary: 'Ext.grid.feature.AbstractSummary'\n    },\n\n    /* End Definitions */\n\n    init: function() {\n        this.mixins.summary.init.call(this);\n    },\n\n   /**\n    * Modifies the row template to include the summary row.\n    * @private\n    * @return {String} The modified template\n    */\n   getFeatureTpl: function() {\n        var tpl = this.callParent(arguments);\n\n        if (this.showSummaryRow) {\n            // lop off the end </tpl> so we can attach it\n            tpl = tpl.replace('</tpl>', '');\n            tpl += '{[this.printSummaryRow(xindex)]}</tpl>';\n        }\n        return tpl;\n    },\n\n    /**\n     * Gets any fragments needed for the template.\n     * @private\n     * @return {Object} The fragments\n     */\n    getFragmentTpl: function() {\n        var me = this,\n            fragments = me.callParent();\n\n        Ext.apply(fragments, me.getSummaryFragments());\n        if (me.showSummaryRow) {\n            // this gets called before render, so we'll setup the data here.\n            me.summaryGroups = me.view.store.getGroups();\n            me.summaryData = me.generateSummaryData();\n        }\n        return fragments;\n    },\n\n    /**\n     * Gets the data for printing a template row\n     * @private\n     * @param {Number} index The index in the template\n     * @return {Array} The template values\n     */\n    getPrintData: function(index){\n        var me = this,\n            columns = me.view.headerCt.getColumnsForTpl(),\n            i = 0,\n            length = columns.length,\n            data = [],\n            name = me.summaryGroups[index - 1].name,\n            active = me.summaryData[name],\n            column;\n\n        for (; i < length; ++i) {\n            column = columns[i];\n            column.gridSummaryValue = this.getColumnValue(column, active);\n            data.push(column);\n        }\n        return data;\n    },\n\n    /**\n     * Generates all of the summary data to be used when processing the template\n     * @private\n     * @return {Object} The summary data\n     */\n    generateSummaryData: function(){\n        var me = this,\n            data = {},\n            remoteData = {},\n            store = me.view.store,\n            groupField = this.getGroupField(),\n            reader = store.proxy.reader,\n            groups = me.summaryGroups,\n            columns = me.view.headerCt.getColumnsForTpl(),\n            remote,\n            i,\n            length,\n            fieldData,\n            root,\n            key,\n            comp,\n            summaryRows,\n            s,\n            sLen,\n            convertedSummaryRow;\n\n        for (i = 0, length = groups.length; i < length; ++i) {\n            data[groups[i].name] = {};\n        }\n\n        /**\n         * @cfg {String} [remoteRoot=undefined]\n         * The name of the property which contains the Array of summary objects.\n         * It allows to use server-side calculated summaries.\n         */\n        if (me.remoteRoot && reader.rawData) {\n            // reset reader root and rebuild extractors to extract summaries data\n            root = reader.root;\n            reader.root = me.remoteRoot;\n            reader.buildExtractors(true);\n            summaryRows = reader.getRoot(reader.rawData);\n            sLen      = summaryRows.length;\n\n            // Ensure the Reader has a data conversion function to convert a raw data row into a Record data hash\n            if (!reader.convertRecordData) {\n                reader.buildExtractors();\n            }\n\n            for (s = 0; s < sLen; s++) {\n                convertedSummaryRow = {};\n\n                // Convert a raw data row into a Record's hash object using the Reader\n                reader.convertRecordData(convertedSummaryRow, summaryRows[s]);\n                remoteData[convertedSummaryRow[groupField]] = convertedSummaryRow;\n            }\n\n            // restore initial reader configuration\n            reader.root = root;\n            reader.buildExtractors(true);\n        }\n\n        for (i = 0, length = columns.length; i < length; ++i) {\n            comp = Ext.getCmp(columns[i].id);\n            fieldData = me.getSummary(store, comp.summaryType, comp.dataIndex, true);\n\n            for (key in fieldData) {\n                if (fieldData.hasOwnProperty(key)) {\n                    data[key][comp.id] = fieldData[key];\n                }\n            }\n\n            for (key in remoteData) {\n                if (remoteData.hasOwnProperty(key)) {\n                    remote = remoteData[key][comp.dataIndex];\n                    if (remote !== undefined && data[key] !== undefined) {\n                        data[key][comp.id] = remote;\n                    }\n                }\n            }\n        }\n        return data;\n    }\n});\n\n/**\n * The rowbody feature enhances the grid's markup to have an additional\n * tr -> td -> div which spans the entire width of the original row.\n *\n * This is useful to to associate additional information with a particular\n * record in a grid.\n *\n * Rowbodies are initially hidden unless you override getAdditionalData.\n *\n * Will expose additional events on the gridview with the prefix of 'rowbody'.\n * For example: 'rowbodyclick', 'rowbodydblclick', 'rowbodycontextmenu'.\n *\n * # Example\n *\n *     @example\n *     Ext.define('Animal', {\n *         extend: 'Ext.data.Model',\n *         fields: ['name', 'latin', 'desc']\n *     });\n * \n *     Ext.create('Ext.grid.Panel', {\n *         width: 400,\n *         height: 300,\n *         renderTo: Ext.getBody(),\n *         store: {\n *             model: 'Animal',\n *             data: [\n *                 {name: 'Tiger', latin: 'Panthera tigris',\n *                  desc: 'The largest cat species, weighing up to 306 kg (670 lb).'},\n *                 {name: 'Roman snail', latin: 'Helix pomatia',\n *                  desc: 'A species of large, edible, air-breathing land snail.'},\n *                 {name: 'Yellow-winged darter', latin: 'Sympetrum flaveolum',\n *                  desc: 'A dragonfly found in Europe and mid and Northern China.'},\n *                 {name: 'Superb Fairy-wren', latin: 'Malurus cyaneus',\n *                  desc: 'Common and familiar across south-eastern Australia.'}\n *             ]\n *         },\n *         columns: [{\n *             dataIndex: 'name',\n *             text: 'Common name',\n *             width: 125\n *         }, {\n *             dataIndex: 'latin',\n *             text: 'Scientific name',\n *             flex: 1\n *         }],\n *         features: [{\n *             ftype: 'rowbody',\n *             getAdditionalData: function(data, rowIndex, record, orig) {\n *                 var headerCt = this.view.headerCt,\n *                     colspan = headerCt.getColumnCount();\n *                 // Usually you would style the my-body-class in CSS file\n *                 return {\n *                     rowBody: '<div style=\"padding: 1em\">'+record.get(\"desc\")+'</div>',\n *                     rowBodyCls: \"my-body-class\",\n *                     rowBodyColspan: colspan\n *                 };\n *             }\n *         }]\n *     });\n */\nExt.define('Ext.grid.feature.RowBody', {\n    extend: 'Ext.grid.feature.Feature',\n    alias: 'feature.rowbody',\n    rowBodyHiddenCls: Ext.baseCSSPrefix + 'grid-row-body-hidden',\n    rowBodyTrCls: Ext.baseCSSPrefix + 'grid-rowbody-tr',\n    rowBodyTdCls: Ext.baseCSSPrefix + 'grid-cell-rowbody',\n    rowBodyDivCls: Ext.baseCSSPrefix + 'grid-rowbody',\n\n    eventPrefix: 'rowbody',\n    eventSelector: '.' + Ext.baseCSSPrefix + 'grid-rowbody-tr',\n    \n    getRowBody: function(values) {\n        return [\n            '<tr class=\"' + this.rowBodyTrCls + ' {rowBodyCls}\">',\n                '<td class=\"' + this.rowBodyTdCls + '\" colspan=\"{rowBodyColspan}\">',\n                    '<div class=\"' + this.rowBodyDivCls + '\">{rowBody}</div>',\n                '</td>',\n            '</tr>'\n        ].join('');\n    },\n    \n    // injects getRowBody into the metaRowTpl.\n    getMetaRowTplFragments: function() {\n        return {\n            getRowBody: this.getRowBody,\n            rowBodyTrCls: this.rowBodyTrCls,\n            rowBodyTdCls: this.rowBodyTdCls,\n            rowBodyDivCls: this.rowBodyDivCls\n        };\n    },\n\n    mutateMetaRowTpl: function(metaRowTpl) {\n        metaRowTpl.push('{[this.getRowBody(values)]}');\n    },\n\n    /**\n     * Provides additional data to the prepareData call within the grid view.\n     * The rowbody feature adds 3 additional variables into the grid view's template.\n     * These are rowBodyCls, rowBodyColspan, and rowBody.\n     * @param {Object} data The data for this particular record.\n     * @param {Number} idx The row index for this record.\n     * @param {Ext.data.Model} record The record instance\n     * @param {Object} orig The original result from the prepareData call to massage.\n     */\n    getAdditionalData: function(data, idx, record, orig) {\n        var headerCt = this.view.headerCt,\n            colspan  = headerCt.getColumnCount();\n\n        return {\n            rowBody: \"\",\n            rowBodyCls: this.rowBodyCls,\n            rowBodyColspan: colspan\n        };\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.grid.feature.RowWrap', {\n    extend: 'Ext.grid.feature.Feature',\n    alias: 'feature.rowwrap',\n\n    // turn off feature events.\n    hasFeatureEvent: false,\n\n    init: function() {\n        if (!this.disabled) {\n            this.enable();\n        }\n    },\n\n    getRowSelector: function(){\n        return 'tr:has(> ' + this.view.cellSelector + ')';\n    },\n\n    enable: function(){\n        var me = this,\n            view = me.view;\n\n        me.callParent();\n        // we need to mutate the rowSelector since the template changes the ordering\n        me.savedRowSelector = view.rowSelector;\n        view.rowSelector = me.getRowSelector();\n\n        // Extra functionality needed on header resize when row is wrapped:\n        // Every individual cell in a column needs its width syncing.\n        // So we produce a different column selector which includes al TDs in a column\n        view.getComponentLayout().getColumnSelector = me.getColumnSelector;\n    },\n\n    disable: function(){\n        var me = this,\n            view = me.view,\n            saved = me.savedRowSelector;\n\n        me.callParent();\n        if (saved) {\n            view.rowSelector = saved;\n        }\n        delete me.savedRowSelector;\n    },\n\n    mutateMetaRowTpl: function(metaRowTpl) {  \n        var prefix = Ext.baseCSSPrefix;      \n        // Remove \"x-grid-row\" from the first row, note this could be wrong\n        // if some other feature unshifted things in front.\n        metaRowTpl[0] = metaRowTpl[0].replace(prefix + 'grid-row', '');\n        metaRowTpl[0] = metaRowTpl[0].replace(\"{[this.embedRowCls()]}\", \"\");\n        // 2\n        metaRowTpl.unshift('<table class=\"' + prefix + 'grid-table ' + prefix + 'grid-table-resizer\" style=\"width: {[this.embedFullWidth()]}px;\">');\n        // 1\n        metaRowTpl.unshift('<tr class=\"' + prefix + 'grid-row {[this.embedRowCls()]}\"><td colspan=\"{[this.embedColSpan()]}\"><div class=\"' + prefix + 'grid-rowwrap-div\">');\n\n        // 3\n        metaRowTpl.push('</table>');\n        // 4\n        metaRowTpl.push('</div></td></tr>');\n    },\n\n    embedColSpan: function() {\n        return '{colspan}';\n    },\n\n    embedFullWidth: function() {\n        return '{fullWidth}';\n    },\n\n    getAdditionalData: function(data, idx, record, orig) {\n        var headerCt = this.view.headerCt,\n            colspan  = headerCt.getColumnCount(),\n            fullWidth = headerCt.getFullWidth(),\n            items    = headerCt.query('gridcolumn'),\n            itemsLn  = items.length,\n            i = 0,\n            o = {\n                colspan: colspan,\n                fullWidth: fullWidth\n            },\n            id,\n            tdClsKey,\n            colResizerCls;\n\n        for (; i < itemsLn; i++) {\n            id = items[i].id;\n            tdClsKey = id + '-tdCls';\n            colResizerCls = Ext.baseCSSPrefix + 'grid-col-resizer-'+id;\n            // give the inner td's the resizer class\n            // while maintaining anything a user may have injected via a custom\n            // renderer\n            o[tdClsKey] = colResizerCls + \" \" + (orig[tdClsKey] ? orig[tdClsKey] : '');\n            // TODO: Unhackify the initial rendering width's\n            o[id+'-tdAttr'] = \" style=\\\"width: \" + (items[i].hidden ? 0 : items[i].getDesiredWidth()) + \"px;\\\" \"/* + (i === 0 ? \" rowspan=\\\"2\\\"\" : \"\")*/;\n            if (orig[id+'-tdAttr']) {\n                o[id+'-tdAttr'] += orig[id+'-tdAttr'];\n            }\n        }\n\n        return o;\n    },\n\n    getMetaRowTplFragments: function() {\n        return {\n            embedFullWidth: this.embedFullWidth,\n            embedColSpan: this.embedColSpan\n        };\n    },\n\n    getColumnSelector: function(header) {\n        var s = Ext.baseCSSPrefix + 'grid-col-resizer-' + header.id;\n        return 'th.' + s + ',td.' + s;\n    }\n});\n\n/**\n * This feature is used to place a summary row at the bottom of the grid. If using a grouping, \n * see {@link Ext.grid.feature.GroupingSummary}. There are 2 aspects to calculating the summaries, \n * calculation and rendering.\n * \n * ## Calculation\n * The summary value needs to be calculated for each column in the grid. This is controlled\n * by the summaryType option specified on the column. There are several built in summary types,\n * which can be specified as a string on the column configuration. These call underlying methods\n * on the store:\n *\n *  - {@link Ext.data.Store#count count}\n *  - {@link Ext.data.Store#sum sum}\n *  - {@link Ext.data.Store#min min}\n *  - {@link Ext.data.Store#max max}\n *  - {@link Ext.data.Store#average average}\n *\n * Alternatively, the summaryType can be a function definition. If this is the case,\n * the function is called with an array of records to calculate the summary value.\n * \n * ## Rendering\n * Similar to a column, the summary also supports a summaryRenderer function. This\n * summaryRenderer is called before displaying a value. The function is optional, if\n * not specified the default calculated value is shown. The summaryRenderer is called with:\n *\n *  - value {Object} - The calculated value.\n *  - summaryData {Object} - Contains all raw summary values for the row.\n *  - field {String} - The name of the field we are calculating\n * \n * ## Example Usage\n *\n *     @example\n *     Ext.define('TestResult', {\n *         extend: 'Ext.data.Model',\n *         fields: ['student', {\n *             name: 'mark',\n *             type: 'int'\n *         }]\n *     });\n *     \n *     Ext.create('Ext.grid.Panel', {\n *         width: 200,\n *         height: 140,\n *         renderTo: document.body,\n *         features: [{\n *             ftype: 'summary'\n *         }],\n *         store: {\n *             model: 'TestResult',\n *             data: [{\n *                 student: 'Student 1',\n *                 mark: 84\n *             },{\n *                 student: 'Student 2',\n *                 mark: 72\n *             },{\n *                 student: 'Student 3',\n *                 mark: 96\n *             },{\n *                 student: 'Student 4',\n *                 mark: 68\n *             }]\n *         },\n *         columns: [{\n *             dataIndex: 'student',\n *             text: 'Name',\n *             summaryType: 'count',\n *             summaryRenderer: function(value, summaryData, dataIndex) {\n *                 return Ext.String.format('{0} student{1}', value, value !== 1 ? 's' : ''); \n *             }\n *         }, {\n *             dataIndex: 'mark',\n *             text: 'Mark',\n *             summaryType: 'average'\n *         }]\n *     });\n */\nExt.define('Ext.grid.feature.Summary', {\n    \n    /* Begin Definitions */\n    \n    extend: 'Ext.grid.feature.AbstractSummary',\n    \n    alias: 'feature.summary',\n    \n    /* End Definitions */\n    \n    /**\n     * Gets any fragments needed for the template.\n     * @private\n     * @return {Object} The fragments\n     */\n    getFragmentTpl: function() {\n        // this gets called before render, so we'll setup the data here.\n        this.summaryData = this.generateSummaryData(); \n        return this.getSummaryFragments();\n    },\n    \n    /**\n     * Overrides the closeRows method on the template so we can include our own custom\n     * footer.\n     * @private\n     * @return {Object} The custom fragments\n     */\n    getTableFragments: function(){\n        if (this.showSummaryRow) {\n            return {\n                closeRows: this.closeRows\n            };\n        }\n    },\n    \n    /**\n     * Provide our own custom footer for the grid.\n     * @private\n     * @return {String} The custom footer\n     */\n    closeRows: function() {\n        return '</tpl>{[this.printSummaryRow()]}';\n    },\n    \n    /**\n     * Gets the data for printing a template row\n     * @private\n     * @param {Number} index The index in the template\n     * @return {Array} The template values\n     */\n    getPrintData: function(index){\n        var me = this,\n            columns = me.view.headerCt.getColumnsForTpl(),\n            i = 0,\n            length = columns.length,\n            data = [],\n            active = me.summaryData,\n            column;\n            \n        for (; i < length; ++i) {\n            column = columns[i];\n            column.gridSummaryValue = this.getColumnValue(column, active);\n            data.push(column);\n        }\n        return data;\n    },\n    \n    /**\n     * Generates all of the summary data to be used when processing the template\n     * @private\n     * @return {Object} The summary data\n     */\n    generateSummaryData: function(){\n        var me = this,\n            data = {},\n            store = me.view.store,\n            columns = me.view.headerCt.getColumnsForTpl(),\n            i = 0,\n            length = columns.length,\n            fieldData,\n            key,\n            comp;\n            \n        for (i = 0, length = columns.length; i < length; ++i) {\n            comp = Ext.getCmp(columns[i].id);\n            data[comp.id] = me.getSummary(store, comp.summaryType, comp.dataIndex, false);\n        }\n        return data;\n    }\n});\n\n/**\n * This class provides an abstract grid editing plugin on selected {@link Ext.grid.column.Column columns}.\n * The editable columns are specified by providing an {@link Ext.grid.column.Column#editor editor}\n * in the {@link Ext.grid.column.Column column configuration}.\n *\n * **Note:** This class should not be used directly. See {@link Ext.grid.plugin.CellEditing} and\n * {@link Ext.grid.plugin.RowEditing}.\n */\nExt.define('Ext.grid.plugin.Editing', {\n    alias: 'editing.editing',\n    extend: 'Ext.AbstractPlugin',\n\n    requires: [\n        'Ext.grid.column.Column',\n        'Ext.util.KeyNav'\n    ],\n\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @cfg {Number} clicksToEdit\n     * The number of clicks on a grid required to display the editor.\n     * The only accepted values are **1** and **2**.\n     */\n    clicksToEdit: 2,\n\n    /**\n     * @cfg {String} triggerEvent\n     * The event which triggers editing. Supercedes the {@link #clicksToEdit} configuration. Maybe one of:\n     *\n     *  * cellclick\n     *  * celldblclick\n     *  * cellfocus\n     *  * rowfocus\n     */\n    triggerEvent: undefined,\n\n    // private\n    defaultFieldXType: 'textfield',\n\n    // cell, row, form\n    editStyle: '',\n\n    constructor: function(config) {\n        var me = this;\n\n        me.addEvents(\n            /**\n             * @event beforeedit\n             * Fires before editing is triggered. Return false from event handler to stop the editing.\n             *\n             * @param {Ext.grid.plugin.Editing} editor\n             * @param {Object} e An edit event with the following properties:\n             *\n             * - grid - The grid\n             * - record - The record being edited\n             * - field - The field name being edited\n             * - value - The value for the field being edited.\n             * - row - The grid table row\n             * - column - The grid {@link Ext.grid.column.Column Column} defining the column that is being edited.\n             * - rowIdx - The row index that is being edited\n             * - colIdx - The column index that is being edited\n             * - cancel - Set this to true to cancel the edit or return false from your handler.\n             * - originalValue - Alias for value (only when using {@link Ext.grid.plugin.CellEditing CellEditing}).\n             */\n            'beforeedit',\n\n            /**\n             * @event edit\n             * Fires after a editing. Usage example:\n             *\n             *     grid.on('edit', function(editor, e) {\n             *         // commit the changes right after editing finished\n             *         e.record.commit();\n             *     });\n             *\n             * @param {Ext.grid.plugin.Editing} editor\n             * @param {Object} e An edit event with the following properties:\n             *\n             * - grid - The grid\n             * - record - The record that was edited\n             * - field - The field name that was edited\n             * - value - The value being set\n             * - row - The grid table row\n             * - column - The grid {@link Ext.grid.column.Column Column} defining the column that was edited.\n             * - rowIdx - The row index that was edited\n             * - colIdx - The column index that was edited\n             * - originalValue - The original value for the field, before the edit (only when using {@link Ext.grid.plugin.CellEditing CellEditing})\n             * - originalValues - The original values for the field, before the edit (only when using {@link Ext.grid.plugin.RowEditing RowEditing})\n             * - newValues - The new values being set (only when using {@link Ext.grid.plugin.RowEditing RowEditing})\n             * - view - The grid view (only when using {@link Ext.grid.plugin.RowEditing RowEditing})\n             * - store - The grid store (only when using {@link Ext.grid.plugin.RowEditing RowEditing})\n             */\n            'edit',\n\n            /**\n             * @event validateedit\n             * Fires after editing, but before the value is set in the record. Return false from event handler to\n             * cancel the change.\n             *\n             * Usage example showing how to remove the red triangle (dirty record indicator) from some records (not all). By\n             * observing the grid's validateedit event, it can be cancelled if the edit occurs on a targeted row (for example)\n             * and then setting the field's new value in the Record directly:\n             *\n             *     grid.on('validateedit', function(editor, e) {\n             *       var myTargetRow = 6;\n             *\n             *       if (e.rowIdx == myTargetRow) {\n             *         e.cancel = true;\n             *         e.record.data[e.field] = e.value;\n             *       }\n             *     });\n             *\n             * @param {Ext.grid.plugin.Editing} editor\n             * @param {Object} e An edit event with the following properties:\n             *\n             * - grid - The grid\n             * - record - The record being edited\n             * - field - The field name being edited\n             * - value - The value being set\n             * - row - The grid table row\n             * - column - The grid {@link Ext.grid.column.Column Column} defining the column that is being edited.\n             * - rowIdx - The row index that is being edited\n             * - colIdx - The column index that is being edited\n             * - cancel - Set this to true to cancel the edit or return false from your handler.\n             * - originalValue - The original value for the field, before the edit (only when using {@link Ext.grid.plugin.CellEditing CellEditing})\n             * - originalValues - The original values for the field, before the edit (only when using {@link Ext.grid.plugin.RowEditing RowEditing})\n             * - newValues - The new values being set (only when using {@link Ext.grid.plugin.RowEditing RowEditing})\n             * - view - The grid view (only when using {@link Ext.grid.plugin.RowEditing RowEditing})\n             * - store - The grid store (only when using {@link Ext.grid.plugin.RowEditing RowEditing})\n             */\n            'validateedit',\n            /**\n             * @event canceledit\n             * Fires when the user started editing but then cancelled the edit.\n             * @param {Ext.grid.plugin.Editing} editor\n             * @param {Object} e An edit event with the following properties:\n             * \n             * - grid - The grid\n             * - record - The record that was edited\n             * - field - The field name that was edited\n             * - value - The value being set\n             * - row - The grid table row\n             * - column - The grid {@link Ext.grid.column.Column Column} defining the column that was edited.\n             * - rowIdx - The row index that was edited\n             * - colIdx - The column index that was edited\n             * - view - The grid view\n             * - store - The grid store\n             */\n            'canceledit'\n\n        );\n        me.callParent(arguments);\n        me.mixins.observable.constructor.call(me);\n        // TODO: Deprecated, remove in 5.0\n        me.on(\"edit\", function(editor, e) {\n            me.fireEvent(\"afteredit\", editor, e);\n        });\n    },\n\n    // private\n    init: function(grid) {\n        var me = this;\n\n        me.grid = grid;\n        me.view = grid.view;\n        me.initEvents();\n        me.mon(grid, 'reconfigure', me.onReconfigure, me);\n        me.onReconfigure();\n\n        grid.relayEvents(me, [\n            /**\n             * @event beforeedit\n             * Forwarded event from Ext.grid.plugin.Editing.\n             * @member Ext.panel.Table\n             * @inheritdoc Ext.grid.plugin.Editing#beforeedit\n             */\n            'beforeedit',\n            /**\n             * @event edit\n             * Forwarded event from Ext.grid.plugin.Editing.\n             * @member Ext.panel.Table\n             * @inheritdoc Ext.grid.plugin.Editing#edit\n             */\n            'edit',\n            /**\n             * @event validateedit\n             * Forwarded event from Ext.grid.plugin.Editing.\n             * @member Ext.panel.Table\n             * @inheritdoc Ext.grid.plugin.Editing#validateedit\n             */\n            'validateedit',\n            /**\n             * @event canceledit\n             * Forwarded event from Ext.grid.plugin.Editing.\n             * @member Ext.panel.Table\n             * @inheritdoc Ext.grid.plugin.Editing#canceledit\n             */\n            'canceledit'\n        ]);\n        // Marks the grid as editable, so that the SelectionModel\n        // can make appropriate decisions during navigation\n        grid.isEditable = true;\n        grid.editingPlugin = grid.view.editingPlugin = me;\n    },\n\n    /**\n     * Fires after the grid is reconfigured\n     * @private\n     */\n    onReconfigure: function() {\n        this.initFieldAccessors(this.view.getGridColumns());\n    },\n\n    /**\n     * @private\n     * AbstractComponent calls destroy on all its plugins at destroy time.\n     */\n    destroy: function() {\n        var me = this,\n            grid = me.grid;\n\n        Ext.destroy(me.keyNav);\n        me.removeFieldAccessors(grid.getView().getGridColumns());\n\n        // Clear all listeners from all our events, clear all managed listeners we added to other Observables\n        me.clearListeners();\n\n        delete me.grid.editingPlugin;\n        delete me.grid.view.editingPlugin;\n        delete me.grid;\n        delete me.view;\n        delete me.editor;\n        delete me.keyNav;\n    },\n\n    // private\n    getEditStyle: function() {\n        return this.editStyle;\n    },\n\n    // private\n    initFieldAccessors: function(columns) {\n        columns = [].concat(columns);\n\n        var me   = this,\n            c,\n            cLen = columns.length,\n            column;\n\n        for (c = 0; c < cLen; c++) {\n            column = columns[c];\n\n            Ext.applyIf(column, {\n                getEditor: function(record, defaultField) {\n                    return me.getColumnField(this, defaultField);\n                },\n\n                setEditor: function(field) {\n                    me.setColumnField(this, field);\n                }\n            });\n        }\n    },\n\n    // private\n    removeFieldAccessors: function(columns) {\n        columns = [].concat(columns);\n\n        var c,\n            cLen = columns.length,\n            column;\n\n        for (c = 0; c < cLen; c++) {\n            column = columns[c];\n\n            delete column.getEditor;\n            delete column.setEditor;\n        }\n    },\n\n    // private\n    // remaps to the public API of Ext.grid.column.Column.getEditor\n    getColumnField: function(columnHeader, defaultField) {\n        var field = columnHeader.field;\n\n        if (!field && columnHeader.editor) {\n            field = columnHeader.editor;\n            delete columnHeader.editor;\n        }\n\n        if (!field && defaultField) {\n            field = defaultField;\n        }\n\n        if (field) {\n            if (Ext.isString(field)) {\n                field = { xtype: field };\n            }\n            if (!field.isFormField) {\n                field = Ext.ComponentManager.create(field, this.defaultFieldXType);\n            }\n            columnHeader.field = field;\n \n            Ext.apply(field, {\n                name: columnHeader.dataIndex\n            });\n\n            return field;\n        }\n    },\n\n    // private\n    // remaps to the public API of Ext.grid.column.Column.setEditor\n    setColumnField: function(column, field) {\n        if (Ext.isObject(field) && !field.isFormField) {\n            field = Ext.ComponentManager.create(field, this.defaultFieldXType);\n        }\n        column.field = field;\n    },\n\n    // private\n    initEvents: function() {\n        var me = this;\n        me.initEditTriggers();\n        me.initCancelTriggers();\n    },\n\n    // @abstract\n    initCancelTriggers: Ext.emptyFn,\n    \n    // private\n    initEditTriggers: function() {\n        var me = this,\n            view = me.view;\n\n        // Listen for the edit trigger event.\n        if (me.triggerEvent == 'cellfocus') {\n            me.mon(view, 'cellfocus', me.onCellFocus, me);\n        } else if (me.triggerEvent == 'rowfocus') {\n            me.mon(view, 'rowfocus', me.onRowFocus, me);\n        } else {\n\n            // Prevent the View from processing when the SelectionModel focuses.\n            // This is because the SelectionModel processes the mousedown event, and\n            // focusing causes a scroll which means that the subsequent mouseup might\n            // take place at a different document XY position, and will therefore\n            // not trigger a click.\n            // This Editor must call the View's focusCell method directly when we recieve a request to edit\n            if (view.selModel.isCellModel) {\n                view.onCellFocus = Ext.Function.bind(me.beforeViewCellFocus, me);\n            }\n\n            // Listen for whichever click event we are configured to use\n            me.mon(view, me.triggerEvent || ('cell' + (me.clicksToEdit === 1 ? 'click' : 'dblclick')), me.onCellClick, me);\n        }\n        \n        // add/remove header event listeners need to be added immediately because\n        // columns can be added/removed before render\n        me.initAddRemoveHeaderEvents()\n        // wait until render to initialize keynav events since they are attached to an element\n        view.on('render', me.initKeyNavHeaderEvents, me, {single: true});\n    },\n\n    // Override of View's method so that we can pre-empt the View's processing if the view is being triggered by a mousedown\n    beforeViewCellFocus: function(position) {\n        // Pass call on to view if the navigation is from the keyboard, or we are not going to edit this cell.\n        if (this.view.selModel.keyNavigation || !this.editing || !this.isCellEditable || !this.isCellEditable(position.row, position.columnHeader)) {\n            this.view.focusCell.apply(this.view, arguments);\n        }\n    },\n\n    // private. Used if we are triggered by the rowfocus event\n    onRowFocus: function(record, row, rowIdx) {\n        this.startEdit(row, 0);\n    },\n\n    // private. Used if we are triggered by the cellfocus event\n    onCellFocus: function(record, cell, position) {\n        this.startEdit(position.row, position.column);\n    },\n\n    // private. Used if we are triggered by a cellclick event\n    onCellClick: function(view, cell, colIdx, record, row, rowIdx, e) {\n        // cancel editing if the element that was clicked was a tree expander\n        if(!view.expanderSelector || !e.getTarget(view.expanderSelector)) {\n            this.startEdit(record, view.getHeaderAtIndex(colIdx));\n        }\n    },\n\n    initAddRemoveHeaderEvents: function(){\n        var me = this;\n        me.mon(me.grid.headerCt, {\n            scope: me,\n            add: me.onColumnAdd,\n            remove: me.onColumnRemove\n        });\n    },\n\n    initKeyNavHeaderEvents: function() {\n        var me = this;\n\n        me.keyNav = Ext.create('Ext.util.KeyNav', me.view.el, {\n            enter: me.onEnterKey,\n            esc: me.onEscKey,\n            scope: me\n        });\n    },\n    \n    // private\n    onColumnAdd: function(ct, column) {\n        if (column.isHeader) {\n            this.initFieldAccessors(column);\n        }\n    },\n\n    // private\n    onColumnRemove: function(ct, column) {\n        if (column.isHeader) {\n            this.removeFieldAccessors(column);\n        }\n    },\n\n    // private\n    onEnterKey: function(e) {\n        var me = this,\n            grid = me.grid,\n            selModel = grid.getSelectionModel(),\n            record,\n            pos,\n            columnHeader = grid.headerCt.getHeaderAtIndex(0);\n\n        // Calculate editing start position from SelectionModel\n        // CellSelectionModel\n        if (selModel.getCurrentPosition) {\n            pos = selModel.getCurrentPosition();\n            if (pos) {\n                record = grid.store.getAt(pos.row);\n                columnHeader = grid.headerCt.getHeaderAtIndex(pos.column);\n            }\n        }\n        // RowSelectionModel\n        else {\n            record = selModel.getLastSelected();\n        }\n\n        // If there was a selection to provide a starting context...\n        if (record && columnHeader) {\n            me.startEdit(record, columnHeader);\n        }\n    },\n\n    // private\n    onEscKey: function(e) {\n        this.cancelEdit();\n    },\n\n    /**\n     * @private\n     * @template\n     * Template method called before editing begins.\n     * @param {Object} context The current editing context\n     * @return {Boolean} Return false to cancel the editing process\n     */\n    beforeEdit: Ext.emptyFn,\n\n    /**\n     * Starts editing the specified record, using the specified Column definition to define which field is being edited.\n     * @param {Ext.data.Model/Number} record The Store data record which backs the row to be edited, or index of the record in Store.\n     * @param {Ext.grid.column.Column/Number} columnHeader The Column object defining the column to be edited, or index of the column.\n     */\n    startEdit: function(record, columnHeader) {\n        var me = this,\n            context = me.getEditingContext(record, columnHeader);\n\n        if (context == null || me.beforeEdit(context) === false || me.fireEvent('beforeedit', me, context) === false || context.cancel || !me.grid.view.isVisible(true)) {\n            return false;\n        }\n\n        me.context = context;\n\n        /**\n         * @property {Boolean} editing\n         * Set to `true` while the editing plugin is active and an Editor is visible.\n         */\n        me.editing = true;\n    },\n\n    // TODO: Have this use a new class Ext.grid.CellContext for use here, and in CellSelectionModel\n    /**\n     * @private\n     * Collects all information necessary for any subclasses to perform their editing functions.\n     * @param record\n     * @param columnHeader\n     * @returns {Object/undefined} The editing context based upon the passed record and column\n     */\n    getEditingContext: function(record, columnHeader) {\n        var me = this,\n            grid = me.grid,\n            view = grid.getView(),\n            node = view.getNode(record),\n            rowIdx, colIdx;\n\n        // An intervening listener may have deleted the Record\n        if (!node) {\n            return;\n        }\n\n        // Coerce the column index to the closest visible column\n        columnHeader = grid.headerCt.getVisibleHeaderClosestToIndex(Ext.isNumber(columnHeader) ? columnHeader : columnHeader.getIndex());\n\n        // No corresponding column. Possible if all columns have been moved to the other side of a lockable grid pair\n        if (!columnHeader) {\n            return;\n        }\n\n        colIdx = columnHeader.getIndex();\n\n        if (Ext.isNumber(record)) {\n            // look up record if numeric row index was passed\n            rowIdx = record;\n            record = view.getRecord(node);\n        } else {\n            rowIdx = view.indexOf(node);\n        }\n\n        return {\n            grid   : grid,\n            record : record,\n            field  : columnHeader.dataIndex,\n            value  : record.get(columnHeader.dataIndex),\n            row    : view.getNode(rowIdx),\n            column : columnHeader,\n            rowIdx : rowIdx,\n            colIdx : colIdx\n        };\n    },\n\n    /**\n     * Cancels any active edit that is in progress.\n     */\n    cancelEdit: function() {\n        var me = this;\n\n        me.editing = false;\n        me.fireEvent('canceledit', me, me.context);\n    },\n\n    /**\n     * Completes the edit if there is an active edit in progress.\n     */\n    completeEdit: function() {\n        var me = this;\n\n        if (me.editing && me.validateEdit()) {\n            me.fireEvent('edit', me, me.context);\n        }\n\n        delete me.context;\n        me.editing = false;\n    },\n\n    // @abstract\n    validateEdit: function() {\n        var me = this,\n            context = me.context;\n\n        return me.fireEvent('validateedit', me, context) !== false && !context.cancel;\n    }\n});\n\n/**\n * The Ext.grid.plugin.CellEditing plugin injects editing at a cell level for a Grid. Only a single\n * cell will be editable at a time. The field that will be used for the editor is defined at the\n * {@link Ext.grid.column.Column#editor editor}. The editor can be a field instance or a field configuration.\n *\n * If an editor is not specified for a particular column then that cell will not be editable and it will\n * be skipped when activated via the mouse or the keyboard.\n *\n * The editor may be shared for each column in the grid, or a different one may be specified for each column.\n * An appropriate field type should be chosen to match the data structure that it will be editing. For example,\n * to edit a date, it would be useful to specify {@link Ext.form.field.Date} as the editor.\n *\n * ## Example\n *\n * A grid with editor for the name and the email columns:\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *         storeId:'simpsonsStore',\n *         fields:['name', 'email', 'phone'],\n *         data:{'items':[\n *             {\"name\":\"Lisa\", \"email\":\"lisa@simpsons.com\", \"phone\":\"555-111-1224\"},\n *             {\"name\":\"Bart\", \"email\":\"bart@simpsons.com\", \"phone\":\"555-222-1234\"},\n *             {\"name\":\"Homer\", \"email\":\"home@simpsons.com\", \"phone\":\"555-222-1244\"},\n *             {\"name\":\"Marge\", \"email\":\"marge@simpsons.com\", \"phone\":\"555-222-1254\"}\n *         ]},\n *         proxy: {\n *             type: 'memory',\n *             reader: {\n *                 type: 'json',\n *                 root: 'items'\n *             }\n *         }\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Simpsons',\n *         store: Ext.data.StoreManager.lookup('simpsonsStore'),\n *         columns: [\n *             {header: 'Name',  dataIndex: 'name', editor: 'textfield'},\n *             {header: 'Email', dataIndex: 'email', flex:1,\n *                 editor: {\n *                     xtype: 'textfield',\n *                     allowBlank: false\n *                 }\n *             },\n *             {header: 'Phone', dataIndex: 'phone'}\n *         ],\n *         selType: 'cellmodel',\n *         plugins: [\n *             Ext.create('Ext.grid.plugin.CellEditing', {\n *                 clicksToEdit: 1\n *             })\n *         ],\n *         height: 200,\n *         width: 400,\n *         renderTo: Ext.getBody()\n *     });\n *\n * This requires a little explanation. We're passing in `store` and `columns` as normal, but\n * we also specify a {@link Ext.grid.column.Column#field field} on two of our columns. For the\n * Name column we just want a default textfield to edit the value, so we specify 'textfield'.\n * For the Email column we customized the editor slightly by passing allowBlank: false, which\n * will provide inline validation.\n *\n * To support cell editing, we also specified that the grid should use the 'cellmodel'\n * {@link Ext.grid.Panel#selType selType}, and created an instance of the CellEditing plugin,\n * which we configured to activate each editor after a single click.\n *\n */\nExt.define('Ext.grid.plugin.CellEditing', {\n    alias: 'plugin.cellediting',\n    extend: 'Ext.grid.plugin.Editing',\n    requires: ['Ext.grid.CellEditor', 'Ext.util.DelayedTask'],\n\n    constructor: function() {\n        /**\n         * @event beforeedit\n         * Fires before cell editing is triggered. Return false from event handler to stop the editing.\n         *\n         * @param {Ext.grid.plugin.CellEditing} editor\n         * @param {Object} e An edit event with the following properties:\n         *\n         * - grid - The grid\n         * - record - The record being edited\n         * - field - The field name being edited\n         * - value - The value for the field being edited.\n         * - row - The grid table row\n         * - column - The grid {@link Ext.grid.column.Column Column} defining the column that is being edited.\n         * - rowIdx - The row index that is being edited\n         * - colIdx - The column index that is being edited\n         * - cancel - Set this to true to cancel the edit or return false from your handler.\n         */\n        /**\n         * @event edit\n         * Fires after a cell is edited. Usage example:\n         *\n         *     grid.on('edit', function(editor, e) {\n         *         // commit the changes right after editing finished\n         *         e.record.commit();\n         *     });\n         *\n         * @param {Ext.grid.plugin.CellEditing} editor\n         * @param {Object} e An edit event with the following properties:\n         *\n         * - grid - The grid\n         * - record - The record that was edited\n         * - field - The field name that was edited\n         * - value - The value being set\n         * - originalValue - The original value for the field, before the edit.\n         * - row - The grid table row\n         * - column - The grid {@link Ext.grid.column.Column Column} defining the column that was edited.\n         * - rowIdx - The row index that was edited\n         * - colIdx - The column index that was edited\n         */\n        /**\n         * @event validateedit\n         * Fires after a cell is edited, but before the value is set in the record. Return false from event handler to\n         * cancel the change.\n         *\n         * Usage example showing how to remove the red triangle (dirty record indicator) from some records (not all). By\n         * observing the grid's validateedit event, it can be cancelled if the edit occurs on a targeted row (for\n         * example) and then setting the field's new value in the Record directly:\n         *\n         *     grid.on('validateedit', function(editor, e) {\n         *       var myTargetRow = 6;\n         *\n         *       if (e.row == myTargetRow) {\n         *         e.cancel = true;\n         *         e.record.data[e.field] = e.value;\n         *       }\n         *     });\n         *\n         * @param {Ext.grid.plugin.CellEditing} editor\n         * @param {Object} e An edit event with the following properties:\n         *\n         * - grid - The grid\n         * - record - The record being edited\n         * - field - The field name being edited\n         * - value - The value being set\n         * - originalValue - The original value for the field, before the edit.\n         * - row - The grid table row\n         * - column - The grid {@link Ext.grid.column.Column Column} defining the column that is being edited.\n         * - rowIdx - The row index that is being edited\n         * - colIdx - The column index that is being edited\n         * - cancel - Set this to true to cancel the edit or return false from your handler.\n         */\n        /**\n         * @event canceledit\n         * Fires when the user started editing a cell but then cancelled the edit.\n         * @param {Ext.grid.plugin.CellEditing} editor\n         * @param {Object} e An edit event with the following properties:\n         * \n         * - grid - The grid\n         * - record - The record that was edited\n         * - field - The field name that was edited\n         * - value - The value being set\n         * - row - The grid table row\n         * - column - The grid {@link Ext.grid.column.Column Column} defining the column that was edited.\n         * - rowIdx - The row index that was edited\n         * - colIdx - The column index that was edited\n         */\n\n        this.callParent(arguments);\n        this.editors = new Ext.util.MixedCollection(false, function(editor) {\n            return editor.editorId;\n        });\n        this.editTask = new Ext.util.DelayedTask();\n    },\n\n    onReconfigure: function(){\n        this.editors.clear();\n        this.callParent();    \n    },\n\n    /**\n     * @private\n     * AbstractComponent calls destroy on all its plugins at destroy time.\n     */\n    destroy: function() {\n        var me = this;\n        me.editTask.cancel();\n        me.editors.each(Ext.destroy, Ext);\n        me.editors.clear();\n        me.callParent(arguments);\n    },\n    \n    onBodyScroll: function() {\n        var me = this,\n            ed = me.getActiveEditor(),\n            scroll = me.view.el.getScroll();\n\n        // Scroll happened during editing...\n        if (ed && ed.editing) {\n            // Terminate editing only on vertical scroll. Horiz scroll can be caused by tabbing between cells.\n            if (scroll.top !== me.scroll.top) {\n                if (ed.field) {\n                    if (ed.field.triggerBlur) {\n                        ed.field.triggerBlur();\n                    } else {\n                        ed.field.blur();\n                    }\n                }\n            }\n            // Horiz scroll just requires that the editor be realigned.\n            else {\n                 ed.realign();\n            }\n        }\n        me.scroll = scroll;\n    },\n\n    // private\n    // Template method called from base class's initEvents\n    initCancelTriggers: function() {\n        var me   = this,\n            grid = me.grid,\n            view = grid.view;\n            \n        view.addElListener('mousewheel', me.cancelEdit, me);\n        me.mon(view, 'bodyscroll', me.onBodyScroll, me);\n        me.mon(grid, {\n            columnresize: me.cancelEdit,\n            columnmove: me.cancelEdit,\n            scope: me\n        });\n    },\n\n    isCellEditable: function(record, columnHeader) {\n        var me = this,\n            context = me.getEditingContext(record, columnHeader);\n\n        if (me.grid.view.isVisible(true) && context) {\n            columnHeader = context.column;\n            record = context.record;\n            if (columnHeader && me.getEditor(record, columnHeader)) {\n                return true;\n            }\n        }\n    },\n\n    /**\n     * Starts editing the specified record, using the specified Column definition to define which field is being edited.\n     * @param {Ext.data.Model} record The Store data record which backs the row to be edited.\n     * @param {Ext.grid.column.Column} columnHeader The Column object defining the column to be edited.\n     * @return `true` if editing was started, `false` otherwise.\n     */\n    startEdit: function(record, columnHeader) {\n        var me = this,\n            context = me.getEditingContext(record, columnHeader),\n            value, ed;\n\n        // Complete the edit now, before getting the editor's target\n        // cell DOM element. Completing the edit causes a row refresh.\n        // Also allows any post-edit events to take effect before continuing\n        me.completeEdit();\n\n        // Cancel editing if EditingContext could not be found (possibly because record has been deleted by an intervening listener), or if the grid view is not currently visible\n        if (!context || !me.grid.view.isVisible(true)) {\n            return false;\n        }\n\n        record = context.record;\n        columnHeader = context.column;\n\n        // See if the field is editable for the requested record\n        if (columnHeader && !columnHeader.getEditor(record)) {\n            return false;\n        }\n\n        value = record.get(columnHeader.dataIndex);\n        context.originalValue = context.value = value;\n        if (me.beforeEdit(context) === false || me.fireEvent('beforeedit', me, context) === false || context.cancel) {\n            return false;\n        }\n\n        ed = me.getEditor(record, columnHeader);\n\n        // Whether we are going to edit or not, ensure the edit cell is scrolled into view\n        me.grid.view.cancelFocus();\n        me.view.focusCell({\n            row: context.rowIdx,\n            column: context.colIdx\n        });\n        if (ed) {\n            me.editTask.delay(15, me.showEditor, me, [ed, context, value]);\n            return true;\n        }\n        return false;\n    },\n\n    showEditor: function(ed, context, value) {\n        var me = this,\n            record = context.record,\n            columnHeader = context.column,\n            sm = me.grid.getSelectionModel(),\n            selection = sm.getCurrentPosition();\n\n        me.context = context;\n        me.setActiveEditor(ed);\n        me.setActiveRecord(record);\n        me.setActiveColumn(columnHeader);\n\n        // Select cell on edit only if it's not the currently selected cell\n        if (sm.selectByPosition && (!selection || selection.column !== context.colIdx || selection.row !== context.rowIdx)) {\n            sm.selectByPosition({\n                row: context.rowIdx,\n                column: context.colIdx\n            });\n        }\n\n        ed.startEdit(me.getCell(record, columnHeader), value);\n        me.editing = true;\n        me.scroll = me.view.el.getScroll();\n    },\n\n    completeEdit: function() {\n        var activeEd = this.getActiveEditor();\n        if (activeEd) {\n            activeEd.completeEdit();\n            this.editing = false;\n        }\n    },\n\n    // internal getters/setters\n    setActiveEditor: function(ed) {\n        this.activeEditor = ed;\n    },\n\n    getActiveEditor: function() {\n        return this.activeEditor;\n    },\n\n    setActiveColumn: function(column) {\n        this.activeColumn = column;\n    },\n\n    getActiveColumn: function() {\n        return this.activeColumn;\n    },\n\n    setActiveRecord: function(record) {\n        this.activeRecord = record;\n    },\n\n    getActiveRecord: function() {\n        return this.activeRecord;\n    },\n\n    getEditor: function(record, column) {\n        var me = this,\n            editors = me.editors,\n            editorId = column.getItemId(),\n            editor = editors.getByKey(editorId);\n\n        if (editor) {\n            return editor;\n        } else {\n            editor = column.getEditor(record);\n            if (!editor) {\n                return false;\n            }\n\n            // Allow them to specify a CellEditor in the Column\n            // Either way, the Editor is a floating Component, and must be attached to an ownerCt\n            // which it uses to traverse upwards to find a ZIndexManager at render time.\n            if (!(editor instanceof Ext.grid.CellEditor)) {\n                editor = new Ext.grid.CellEditor({\n                    editorId: editorId,\n                    field: editor,\n                    ownerCt: me.grid\n                });\n            } else {\n                editor.ownerCt = me.grid;\n            }\n            editor.editingPlugin = me;\n            editor.isForTree = me.grid.isTree;\n            editor.on({\n                scope: me,\n                specialkey: me.onSpecialKey,\n                complete: me.onEditComplete,\n                canceledit: me.cancelEdit\n            });\n            editors.add(editor);\n            return editor;\n        }\n    },\n    \n    // inherit docs\n    setColumnField: function(column, field) {\n        var ed = this.editors.getByKey(column.getItemId());\n        Ext.destroy(ed, column.field);\n        this.editors.removeAtKey(column.getItemId());\n        this.callParent(arguments);\n    },\n\n    /**\n     * Gets the cell (td) for a particular record and column.\n     * @param {Ext.data.Model} record\n     * @param {Ext.grid.column.Column} column\n     * @private\n     */\n    getCell: function(record, column) {\n        return this.grid.getView().getCell(record, column);\n    },\n\n    onSpecialKey: function(ed, field, e) {\n        var me = this,\n            grid = me.grid,\n            sm;\n            \n        if (e.getKey() === e.TAB) {\n            e.stopEvent();\n            \n            if (ed) {\n                // Allow the field to act on tabs before onEditorTab, which ends\n                // up calling completeEdit. This is useful for picker type fields.\n                ed.onEditorTab(e);\n            }\n            \n            sm = grid.getSelectionModel();\n            if (sm.onEditorTab) {\n                sm.onEditorTab(me, e);\n            }\n        }\n    },\n\n    onEditComplete : function(ed, value, startValue) {\n        var me = this,\n            grid = me.grid,\n            activeColumn = me.getActiveColumn(),\n            sm = grid.getSelectionModel(),\n            record;\n\n        if (activeColumn) {\n            record = me.context.record;\n\n            me.setActiveEditor(null);\n            me.setActiveColumn(null);\n            me.setActiveRecord(null);\n    \n            if (!me.validateEdit()) {\n                return;\n            }\n\n            // Only update the record if the new value is different than the\n            // startValue. When the view refreshes its el will gain focus\n            if (!record.isEqual(value, startValue)) {\n                record.set(activeColumn.dataIndex, value);\n            }\n\n            // Restore focus back to the view's element.\n            if (sm.setCurrentPosition) {\n                sm.setCurrentPosition(sm.getCurrentPosition());\n            }\n            grid.getView().getEl(activeColumn).focus();\n\n            me.context.value = value;\n            me.fireEvent('edit', me, me.context);\n        }\n    },\n\n    /**\n     * Cancels any active editing.\n     */\n    cancelEdit: function() {\n        var me = this,\n            activeEd = me.getActiveEditor(),\n            viewEl = me.grid.getView().getEl(me.getActiveColumn());\n\n        me.setActiveEditor(null);\n        me.setActiveColumn(null);\n        me.setActiveRecord(null);\n        if (activeEd) {\n            activeEd.cancelEdit();\n            viewEl.focus();\n            me.callParent(arguments);\n        }\n    },\n\n    /**\n     * Starts editing by position (row/column)\n     * @param {Object} position A position with keys of row and column.\n     */\n    startEditByPosition: function(position) {\n\n        // Coerce the edit column to the closest visible column\n        position.column = this.view.getHeaderCt().getVisibleHeaderClosestToIndex(position.column).getIndex();\n\n        return this.startEdit(position.row, position.column);\n    }\n});\n\n/**\n * This plugin provides drag and/or drop functionality for a GridView.\n *\n * It creates a specialized instance of {@link Ext.dd.DragZone DragZone} which knows how to drag out of a {@link\n * Ext.grid.View GridView} and loads the data object which is passed to a cooperating {@link Ext.dd.DragZone DragZone}'s\n * methods with the following properties:\n *\n * - `copy` : Boolean\n *\n *   The value of the GridView's `copy` property, or `true` if the GridView was configured with `allowCopy: true` _and_\n *   the control key was pressed when the drag operation was begun.\n *\n * - `view` : GridView\n *\n *   The source GridView from which the drag originated.\n *\n * - `ddel` : HtmlElement\n *\n *   The drag proxy element which moves with the mouse\n *\n * - `item` : HtmlElement\n *\n *   The GridView node upon which the mousedown event was registered.\n *\n * - `records` : Array\n *\n *   An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.\n *\n * It also creates a specialized instance of {@link Ext.dd.DropZone} which cooperates with other DropZones which are\n * members of the same ddGroup which processes such data objects.\n *\n * Adding this plugin to a view means that two new events may be fired from the client GridView, `{@link #beforedrop\n * beforedrop}` and `{@link #drop drop}`\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *         storeId:'simpsonsStore',\n *         fields:['name'],\n *         data: [[\"Lisa\"], [\"Bart\"], [\"Homer\"], [\"Marge\"]],\n *         proxy: {\n *             type: 'memory',\n *             reader: 'array'\n *         }\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         store: 'simpsonsStore',\n *         columns: [\n *             {header: 'Name',  dataIndex: 'name', flex: true}\n *         ],\n *         viewConfig: {\n *             plugins: {\n *                 ptype: 'gridviewdragdrop',\n *                 dragText: 'Drag and drop to reorganize'\n *             }\n *         },\n *         height: 200,\n *         width: 400,\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.grid.plugin.DragDrop', {\n    extend: 'Ext.AbstractPlugin',\n    alias: 'plugin.gridviewdragdrop',\n\n    uses: [\n        'Ext.view.DragZone',\n        'Ext.grid.ViewDropZone'\n    ],\n\n    /**\n     * @event beforedrop\n     * **This event is fired through the GridView. Add listeners to the GridView object**\n     *\n     * Fired when a drop gesture has been triggered by a mouseup event in a valid drop position in the GridView.\n     *\n     * @param {HTMLElement} node The GridView node **if any** over which the mouse was positioned.\n     *\n     * Returning `false` to this event signals that the drop gesture was invalid, and if the drag proxy will animate\n     * back to the point from which the drag began.\n     *\n     * Returning `0` To this event signals that the data transfer operation should not take place, but that the gesture\n     * was valid, and that the repair operation should not take place.\n     *\n     * Any other return value continues with the data transfer operation.\n     *\n     * @param {Object} data The data object gathered at mousedown time by the cooperating {@link Ext.dd.DragZone\n     * DragZone}'s {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following properties:\n     *\n     * - copy : Boolean\n     *\n     *   The value of the GridView's `copy` property, or `true` if the GridView was configured with `allowCopy: true` and\n     *   the control key was pressed when the drag operation was begun\n     *\n     * - view : GridView\n     *\n     *   The source GridView from which the drag originated.\n     *\n     * - ddel : HtmlElement\n     *\n     *   The drag proxy element which moves with the mouse\n     *\n     * - item : HtmlElement\n     *\n     *   The GridView node upon which the mousedown event was registered.\n     *\n     * - records : Array\n     *\n     *   An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.\n     *\n     * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.\n     *\n     * @param {String} dropPosition `\"before\"` or `\"after\"` depending on whether the mouse is above or below the midline\n     * of the node.\n     *\n     * @param {Function} dropFunction\n     *\n     * A function to call to complete the data transfer operation and either move or copy Model instances from the\n     * source View's Store to the destination View's Store.\n     *\n     * This is useful when you want to perform some kind of asynchronous processing before confirming the drop, such as\n     * an {@link Ext.window.MessageBox#confirm confirm} call, or an Ajax request.\n     *\n     * Return `0` from this event handler, and call the `dropFunction` at any time to perform the data transfer.\n     */\n\n    /**\n     * @event drop\n     * **This event is fired through the GridView. Add listeners to the GridView object** Fired when a drop operation\n     * has been completed and the data has been moved or copied.\n     *\n     * @param {HTMLElement} node The GridView node **if any** over which the mouse was positioned.\n     *\n     * @param {Object} data The data object gathered at mousedown time by the cooperating {@link Ext.dd.DragZone\n     * DragZone}'s {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following properties:\n     *\n     * - copy : Boolean\n     *\n     *   The value of the GridView's `copy` property, or `true` if the GridView was configured with `allowCopy: true` and\n     *   the control key was pressed when the drag operation was begun\n     *\n     * - view : GridView\n     *\n     *   The source GridView from which the drag originated.\n     *\n     * - ddel : HtmlElement\n     *\n     *   The drag proxy element which moves with the mouse\n     *\n     * - item : HtmlElement\n     *\n     *   The GridView node upon which the mousedown event was registered.\n     *\n     * - records : Array\n     *\n     *   An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.\n     *\n     * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.\n     *\n     * @param {String} dropPosition `\"before\"` or `\"after\"` depending on whether the mouse is above or below the midline\n     * of the node.\n     */\n    //<locale>\n    /**\n     * @cfg\n     * The text to show while dragging.\n     *\n     * Two placeholders can be used in the text:\n     *\n     * - `{0}` The number of selected items.\n     * - `{1}` 's' when more than 1 items (only useful for English).\n     */\n    dragText : '{0} selected row{1}',\n    //</locale>\n\n    /**\n     * @cfg {String} ddGroup\n     * A named drag drop group to which this object belongs. If a group is specified, then both the DragZones and\n     * DropZone used by this plugin will only interact with other drag drop objects in the same group.\n     */\n    ddGroup : \"GridDD\",\n\n    /**\n     * @cfg {String} dragGroup\n     * The ddGroup to which the DragZone will belong.\n     *\n     * This defines which other DropZones the DragZone will interact with. Drag/DropZones only interact with other\n     * Drag/DropZones which are members of the same ddGroup.\n     */\n\n    /**\n     * @cfg {String} dropGroup\n     * The ddGroup to which the DropZone will belong.\n     *\n     * This defines which other DragZones the DropZone will interact with. Drag/DropZones only interact with other\n     * Drag/DropZones which are members of the same ddGroup.\n     */\n\n    /**\n     * @cfg {Boolean} enableDrop\n     * False to disallow the View from accepting drop gestures.\n     */\n    enableDrop: true,\n\n    /**\n     * @cfg {Boolean} enableDrag\n     * False to disallow dragging items from the View.\n     */\n    enableDrag: true,\n\n    init : function(view) {\n        view.on('render', this.onViewRender, this, {single: true});\n    },\n\n    /**\n     * @private\n     * AbstractComponent calls destroy on all its plugins at destroy time.\n     */\n    destroy: function() {\n        Ext.destroy(this.dragZone, this.dropZone);\n    },\n\n    enable: function() {\n        var me = this;\n        if (me.dragZone) {\n            me.dragZone.unlock();\n        }\n        if (me.dropZone) {\n            me.dropZone.unlock();\n        }\n        me.callParent();\n    },\n\n    disable: function() {\n        var me = this;\n        if (me.dragZone) {\n            me.dragZone.lock();\n        }\n        if (me.dropZone) {\n            me.dropZone.lock();\n        }\n        me.callParent();\n    },\n\n    onViewRender : function(view) {\n        var me = this;\n\n        if (me.enableDrag) {\n            me.dragZone = new Ext.view.DragZone({\n                view: view,\n                ddGroup: me.dragGroup || me.ddGroup,\n                dragText: me.dragText\n            });\n        }\n\n        if (me.enableDrop) {\n            me.dropZone = new Ext.grid.ViewDropZone({\n                view: view,\n                ddGroup: me.dropGroup || me.ddGroup\n            });\n        }\n    }\n});\n\n/**\n * The Ext.grid.plugin.RowEditing plugin injects editing at a row level for a Grid. When editing begins,\n * a small floating dialog will be shown for the appropriate row. Each editable column will show a field\n * for editing. There is a button to save or cancel all changes for the edit.\n *\n * The field that will be used for the editor is defined at the\n * {@link Ext.grid.column.Column#editor editor}. The editor can be a field instance or a field configuration.\n * If an editor is not specified for a particular column then that column won't be editable and the value of\n * the column will be displayed. To provide a custom renderer for non-editable values, use the \n * {@link Ext.grid.column.Column#editRenderer editRenderer} configuration on the column.\n *\n * The editor may be shared for each column in the grid, or a different one may be specified for each column.\n * An appropriate field type should be chosen to match the data structure that it will be editing. For example,\n * to edit a date, it would be useful to specify {@link Ext.form.field.Date} as the editor.\n *\n *     @example\n *     Ext.create('Ext.data.Store', {\n *         storeId:'simpsonsStore',\n *         fields:['name', 'email', 'phone'],\n *         data: [\n *             {\"name\":\"Lisa\", \"email\":\"lisa@simpsons.com\", \"phone\":\"555-111-1224\"},\n *             {\"name\":\"Bart\", \"email\":\"bart@simpsons.com\", \"phone\":\"555-222-1234\"},\n *             {\"name\":\"Homer\", \"email\":\"home@simpsons.com\", \"phone\":\"555-222-1244\"},\n *             {\"name\":\"Marge\", \"email\":\"marge@simpsons.com\", \"phone\":\"555-222-1254\"}\n *         ]\n *     });\n *\n *     Ext.create('Ext.grid.Panel', {\n *         title: 'Simpsons',\n *         store: Ext.data.StoreManager.lookup('simpsonsStore'),\n *         columns: [\n *             {header: 'Name',  dataIndex: 'name', editor: 'textfield'},\n *             {header: 'Email', dataIndex: 'email', flex:1,\n *                 editor: {\n *                     xtype: 'textfield',\n *                     allowBlank: false\n *                 }\n *             },\n *             {header: 'Phone', dataIndex: 'phone'}\n *         ],\n *         selType: 'rowmodel',\n *         plugins: [\n *             Ext.create('Ext.grid.plugin.RowEditing', {\n *                 clicksToEdit: 1\n *             })\n *         ],\n *         height: 200,\n *         width: 400,\n *         renderTo: Ext.getBody()\n *     });\n *\n */\nExt.define('Ext.grid.plugin.RowEditing', {\n    extend: 'Ext.grid.plugin.Editing',\n    alias: 'plugin.rowediting',\n\n    requires: [\n        'Ext.grid.RowEditor'\n    ],\n\n    editStyle: 'row',\n\n    /**\n     * @cfg {Boolean} autoCancel\n     * True to automatically cancel any pending changes when the row editor begins editing a new row.\n     * False to force the user to explicitly cancel the pending changes. Defaults to true.\n     */\n    autoCancel: true,\n\n    /**\n     * @cfg {Number} clicksToMoveEditor\n     * The number of clicks to move the row editor to a new row while it is visible and actively editing another row.\n     * This will default to the same value as {@link Ext.grid.plugin.Editing#clicksToEdit clicksToEdit}.\n     */\n\n    /**\n     * @cfg {Boolean} errorSummary\n     * True to show a {@link Ext.tip.ToolTip tooltip} that summarizes all validation errors present\n     * in the row editor. Set to false to prevent the tooltip from showing. Defaults to true.\n     */\n    errorSummary: true,\n\n    constructor: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        if (!me.clicksToMoveEditor) {\n            me.clicksToMoveEditor = me.clicksToEdit;\n        }\n\n        me.autoCancel = !!me.autoCancel;\n    },\n\n    init: function(grid) {\n        this.callParent([grid]);\n    },\n\n    /**\n     * @private\n     * AbstractComponent calls destroy on all its plugins at destroy time.\n     */\n    destroy: function() {\n        var me = this;\n        Ext.destroy(me.editor);\n        me.callParent(arguments);\n    },\n\n    /**\n     * Starts editing the specified record, using the specified Column definition to define which field is being edited.\n     * @param {Ext.data.Model} record The Store data record which backs the row to be edited.\n     * @param {Ext.data.Model} columnHeader The Column object defining the column to be edited.\n     * @return `true` if editing was started, `false` otherwise.\n     */\n    startEdit: function(record, columnHeader) {\n        var me = this,\n            editor = me.getEditor();\n\n        if ((editor.beforeEdit() !== false) && (me.callParent(arguments) !== false)) {\n            editor.startEdit(me.context.record, me.context.column);\n            return true;\n        }\n        return false;\n    },\n\n    // private\n    cancelEdit: function() {\n        var me = this;\n\n        if (me.editing) {\n            me.getEditor().cancelEdit();\n            me.callParent(arguments);\n        }\n    },\n\n    // private\n    completeEdit: function() {\n        var me = this;\n\n        if (me.editing && me.validateEdit()) {\n            me.editing = false;\n            me.fireEvent('edit', me, me.context);\n        }\n    },\n\n    // private\n    validateEdit: function() {\n        var me             = this,\n            editor         = me.editor,\n            context        = me.context,\n            record         = context.record,\n            newValues      = {},\n            originalValues = {},\n            editors        = editor.items.items,\n            e,\n            eLen           = editors.length,\n            name, item;\n\n        for (e = 0; e < eLen; e++) {\n            item = editors[e];\n            name = item.name;\n\n            newValues[name]      = item.getValue();\n            originalValues[name] = record.get(name);\n        }\n\n        Ext.apply(context, {\n            newValues      : newValues,\n            originalValues : originalValues\n        });\n\n        return me.callParent(arguments) && me.getEditor().completeEdit();\n    },\n\n    // private\n    getEditor: function() {\n        var me = this;\n\n        if (!me.editor) {\n            me.editor = me.initEditor();\n        }\n        return me.editor;\n    },\n\n    // private\n    initEditor: function() {\n        var me       = this,\n            grid     = me.grid,\n            view     = me.view,\n            headerCt = grid.headerCt,\n            btns     = ['saveBtnText', 'cancelBtnText', 'errorsText', 'dirtyText'],\n            b,\n            bLen     = btns.length,\n            cfg      = {\n                autoCancel: me.autoCancel,\n                errorSummary: me.errorSummary,\n                fields: headerCt.getGridColumns(),\n                hidden: true,\n                view: view,\n                // keep a reference..\n                editingPlugin: me,\n                renderTo: view.el\n            },\n            item;\n\n        for (b = 0; b < bLen; b++) {\n            item = btns[b];\n\n            if (Ext.isDefined(me[item])) {\n                cfg[item] = me[item];\n            }\n        }\n\n        return Ext.create('Ext.grid.RowEditor', cfg);\n    },\n\n    // private\n    initEditTriggers: function() {\n        var me = this,\n            view = me.view,\n            moveEditorEvent = me.clicksToMoveEditor === 1 ? 'click' : 'dblclick';\n\n        me.callParent(arguments);\n\n        if (me.clicksToMoveEditor !== me.clicksToEdit) {\n            me.mon(view, 'cell' + moveEditorEvent, me.moveEditorByClick, me);\n        }\n\n        view.on({\n            render: function() {\n                me.mon(me.grid.headerCt, {\n                    scope: me,\n                    columnresize: me.onColumnResize,\n                    columnhide: me.onColumnHide,\n                    columnshow: me.onColumnShow,\n                    columnmove: me.onColumnMove\n                });\n            },\n            single: true\n        });\n    },\n\n    startEditByClick: function() {\n        var me = this;\n        if (!me.editing || me.clicksToMoveEditor === me.clicksToEdit) {\n            me.callParent(arguments);\n        }\n    },\n\n    moveEditorByClick: function() {\n        var me = this;\n        if (me.editing) {\n            me.superclass.onCellClick.apply(me, arguments);\n        }\n    },\n    \n    // private\n    onColumnAdd: function(ct, column) {\n        if (column.isHeader) {\n            var me = this,\n                editor;\n\n            me.initFieldAccessors(column);\n\n            // Only inform the editor about a new column if the editor has already been instantiated,\n            // so do not use getEditor which instantiates the editor if not present.\n            editor = me.editor;\n            if (editor && editor.onColumnAdd) {\n                editor.onColumnAdd(column);\n            }\n        }\n    },\n\n    // private\n    onColumnRemove: function(ct, column) {\n        if (column.isHeader) {\n            var me = this,\n                editor = me.getEditor();\n\n            if (editor && editor.onColumnRemove) {\n                editor.onColumnRemove(column);\n            }\n            me.removeFieldAccessors(column);\n        }\n    },\n\n    // private\n    onColumnResize: function(ct, column, width) {\n        if (column.isHeader) {\n            var me = this,\n                editor = me.getEditor();\n\n            if (editor && editor.onColumnResize) {\n                editor.onColumnResize(column, width);\n            }\n        }\n    },\n\n    // private\n    onColumnHide: function(ct, column) {\n        // no isHeader check here since its already a columnhide event.\n        var me = this,\n            editor = me.getEditor();\n\n        if (editor && editor.onColumnHide) {\n            editor.onColumnHide(column);\n        }\n    },\n\n    // private\n    onColumnShow: function(ct, column) {\n        // no isHeader check here since its already a columnshow event.\n        var me = this,\n            editor = me.getEditor();\n\n        if (editor && editor.onColumnShow) {\n            editor.onColumnShow(column);\n        }\n    },\n\n    // private\n    onColumnMove: function(ct, column, fromIdx, toIdx) {\n        // no isHeader check here since its already a columnmove event.\n        var me = this,\n            editor = me.getEditor();\n\n        if (editor && editor.onColumnMove) {\n            // Must adjust the toIdx to account for removal if moving rightwards\n            // because RowEditor.onColumnMove just calls Container.move which does not do this.\n            editor.onColumnMove(column, fromIdx, toIdx - (toIdx > fromIdx ? 1 : 0));\n        }\n    },\n\n    // private\n    setColumnField: function(column, field) {\n        var me = this,\n            editor = me.getEditor();\n            \n        editor.removeField(column);\n        me.callParent(arguments);\n        me.getEditor().setField(column);\n    }\n});\n\n/**\n * A specialized grid implementation intended to mimic the traditional property grid as typically seen in\n * development IDEs.  Each row in the grid represents a property of some object, and the data is stored\n * as a set of name/value pairs in {@link Ext.grid.property.Property Properties}.  Example usage:\n *\n *     @example\n *     Ext.create('Ext.grid.property.Grid', {\n *         title: 'Properties Grid',\n *         width: 300,\n *         renderTo: Ext.getBody(),\n *         source: {\n *             \"(name)\": \"My Object\",\n *             \"Created\": Ext.Date.parse('10/15/2006', 'm/d/Y'),\n *             \"Available\": false,\n *             \"Version\": 0.01,\n *             \"Description\": \"A test object\"\n *         }\n *     });\n */\nExt.define('Ext.grid.property.Grid', {\n\n    extend: 'Ext.grid.Panel',\n\n    alias: 'widget.propertygrid',\n\n    alternateClassName: 'Ext.grid.PropertyGrid',\n\n    uses: [\n       'Ext.grid.plugin.CellEditing',\n       'Ext.grid.property.Store',\n       'Ext.grid.property.HeaderContainer',\n       'Ext.XTemplate',\n       'Ext.grid.CellEditor',\n       'Ext.form.field.Date',\n       'Ext.form.field.Text',\n       'Ext.form.field.Number',\n       'Ext.form.field.ComboBox'\n    ],\n\n   /**\n    * @cfg {Object} propertyNames\n    * An object containing custom property name/display name pairs.\n    * If specified, the display name will be shown in the name column instead of the property name.\n    */\n\n    /**\n     * @cfg {Object} source\n     * A data object to use as the data source of the grid (see {@link #setSource} for details).\n     */\n\n    /**\n     * @cfg {Object} customEditors\n     * An object containing name/value pairs of custom editor type definitions that allow\n     * the grid to support additional types of editable fields.  By default, the grid supports strongly-typed editing\n     * of strings, dates, numbers and booleans using built-in form editors, but any custom type can be supported and\n     * associated with a custom input control by specifying a custom editor.  The name of the editor\n     * type should correspond with the name of the property that will use the editor.  Example usage:\n     *\n     *     var grid = new Ext.grid.property.Grid({\n     *\n     *         // Custom editors for certain property names\n     *         customEditors: {\n     *             evtStart: Ext.create('Ext.form.TimeField', {selectOnFocus: true})\n     *         },\n     *\n     *         // Displayed name for property names in the source\n     *         propertyNames: {\n     *             evtStart: 'Start Time'\n     *         },\n     *\n     *         // Data object containing properties to edit\n     *         source: {\n     *             evtStart: '10:00 AM'\n     *         }\n     *     });\n     */\n\n    /**\n     * @cfg {Object} customRenderers\n     * An object containing name/value pairs of custom renderer type definitions that allow\n     * the grid to support custom rendering of fields.  By default, the grid supports strongly-typed rendering\n     * of strings, dates, numbers and booleans using built-in form editors, but any custom type can be supported and\n     * associated with the type of the value.  The name of the renderer type should correspond with the name of the property\n     * that it will render.  Example usage:\n     *\n     *     var grid = Ext.create('Ext.grid.property.Grid', {\n     *         customRenderers: {\n     *             Available: function(v){\n     *                 if (v) {\n     *                     return '<span style=\"color: green;\">Yes</span>';\n     *                 } else {\n     *                     return '<span style=\"color: red;\">No</span>';\n     *                 }\n     *             }\n     *         },\n     *         source: {\n     *             Available: true\n     *         }\n     *     });\n     */\n\n    /**\n     * @cfg {String} valueField\n     * The name of the field from the property store to use as the value field name.\n     * This may be useful if you do not configure the property Grid from an object, but use your own store configuration.\n     */\n    valueField: 'value',\n\n    /**\n     * @cfg {String} nameField\n     * The name of the field from the property store to use as the property field name.\n     * This may be useful if you do not configure the property Grid from an object, but use your own store configuration.\n     */\n    nameField: 'name',\n\n    /**\n     * @cfg {Number} [nameColumnWidth=115]\n     * Specify the width for the name column. The value column will take any remaining space.\n     */\n\n    // private config overrides\n    enableColumnMove: false,\n    columnLines: true,\n    stripeRows: false,\n    trackMouseOver: false,\n    clicksToEdit: 1,\n    enableHdMenu: false,\n\n    // private\n    initComponent : function(){\n        var me = this;\n\n        me.addCls(Ext.baseCSSPrefix + 'property-grid');\n        me.plugins = me.plugins || [];\n\n        // Enable cell editing. Inject a custom startEdit which always edits column 1 regardless of which column was clicked.\n        me.plugins.push(new Ext.grid.plugin.CellEditing({\n            clicksToEdit: me.clicksToEdit,\n\n            // Inject a startEdit which always edits the value column\n            startEdit: function(record, column) {\n                // Maintainer: Do not change this 'this' to 'me'! It is the CellEditing object's own scope.\n                return this.self.prototype.startEdit.call(this, record, me.headerCt.child('#' + me.valueField));\n            }\n        }));\n\n        me.selModel = {\n            selType: 'cellmodel',\n            onCellSelect: function(position) {\n                if (position.column != 1) {\n                    position.column = 1;\n                }\n                return this.self.prototype.onCellSelect.call(this, position);\n            }\n        };\n        me.customRenderers = me.customRenderers || {};\n        me.customEditors = me.customEditors || {};\n\n        // Create a property.Store from the source object unless configured with a store\n        if (!me.store) {\n            me.propStore = me.store = new Ext.grid.property.Store(me, me.source);\n        }\n\n        if (me.sortableColumns) {\n            me.store.sort('name', 'ASC');\n        }\n        me.columns = new Ext.grid.property.HeaderContainer(me, me.store);\n\n        me.addEvents(\n            /**\n             * @event beforepropertychange\n             * Fires before a property value changes.  Handlers can return false to cancel the property change\n             * (this will internally call {@link Ext.data.Model#reject} on the property's record).\n             * @param {Object} source The source data object for the grid (corresponds to the same object passed in\n             * as the {@link #source} config property).\n             * @param {String} recordId The record's id in the data store\n             * @param {Object} value The current edited property value\n             * @param {Object} oldValue The original property value prior to editing\n             */\n            'beforepropertychange',\n            /**\n             * @event propertychange\n             * Fires after a property value has changed.\n             * @param {Object} source The source data object for the grid (corresponds to the same object passed in\n             * as the {@link #source} config property).\n             * @param {String} recordId The record's id in the data store\n             * @param {Object} value The current edited property value\n             * @param {Object} oldValue The original property value prior to editing\n             */\n            'propertychange'\n        );\n        me.callParent();\n\n        // Inject a custom implementation of walkCells which only goes up or down\n        me.getView().walkCells = this.walkCells;\n\n        // Set up our default editor set for the 4 atomic data types\n        me.editors = {\n            'date'    : new Ext.grid.CellEditor({ field: new Ext.form.field.Date({selectOnFocus: true})}),\n            'string'  : new Ext.grid.CellEditor({ field: new Ext.form.field.Text({selectOnFocus: true})}),\n            'number'  : new Ext.grid.CellEditor({ field: new Ext.form.field.Number({selectOnFocus: true})}),\n            'boolean' : new Ext.grid.CellEditor({ field: new Ext.form.field.ComboBox({\n                editable: false,\n                store: [[ true, me.headerCt.trueText ], [false, me.headerCt.falseText ]]\n            })})\n        };\n\n        // Track changes to the data so we can fire our events.\n        me.store.on('update', me.onUpdate, me);\n    },\n\n    // private\n    onUpdate : function(store, record, operation) {\n        var me = this,\n            v, oldValue;\n\n        if (me.rendered && operation == Ext.data.Model.EDIT) {\n            v = record.get(me.valueField);\n            oldValue = record.modified.value;\n            if (me.fireEvent('beforepropertychange', me.source, record.getId(), v, oldValue) !== false) {\n                if (me.source) {\n                    me.source[record.getId()] = v;\n                }\n                record.commit();\n                me.fireEvent('propertychange', me.source, record.getId(), v, oldValue);\n            } else {\n                record.reject();\n            }\n        }\n    },\n\n    // Custom implementation of walkCells which only goes up and down.\n    walkCells: function(pos, direction, e, preventWrap, verifierFn, scope) {\n        if (direction == 'left') {\n            direction = 'up';\n        } else if (direction == 'right') {\n            direction = 'down';\n        }\n        pos = Ext.view.Table.prototype.walkCells.call(this, pos, direction, e, preventWrap, verifierFn, scope);\n        if (!pos.column) {\n            pos.column = 1;\n        }\n        return pos;\n    },\n\n    // private\n    // returns the correct editor type for the property type, or a custom one keyed by the property name\n    getCellEditor : function(record, column) {\n        var me = this,\n            propName = record.get(me.nameField),\n            val = record.get(me.valueField),\n            editor = me.customEditors[propName];\n\n        // A custom editor was found. If not already wrapped with a CellEditor, wrap it, and stash it back\n        // If it's not even a Field, just a config object, instantiate it before wrapping it.\n        if (editor) {\n            if (!(editor instanceof Ext.grid.CellEditor)) {\n                if (!(editor instanceof Ext.form.field.Base)) {\n                    editor = Ext.ComponentManager.create(editor, 'textfield');\n                }\n                editor = me.customEditors[propName] = new Ext.grid.CellEditor({ field: editor });\n            }\n        } else if (Ext.isDate(val)) {\n            editor = me.editors.date;\n        } else if (Ext.isNumber(val)) {\n            editor = me.editors.number;\n        } else if (Ext.isBoolean(val)) {\n            editor = me.editors['boolean'];\n        } else {\n            editor = me.editors.string;\n        }\n\n        // Give the editor a unique ID because the CellEditing plugin caches them\n        editor.editorId = propName;\n        return editor;\n    },\n\n    beforeDestroy: function() {\n        var me = this;\n        me.callParent();\n        me.destroyEditors(me.editors);\n        me.destroyEditors(me.customEditors);\n        delete me.source;\n    },\n\n    destroyEditors: function (editors) {\n        for (var ed in editors) {\n            if (editors.hasOwnProperty(ed)) {\n                Ext.destroy(editors[ed]);\n            }\n        }\n    },\n\n    /**\n     * Sets the source data object containing the property data.  The data object can contain one or more name/value\n     * pairs representing all of the properties of an object to display in the grid, and this data will automatically\n     * be loaded into the grid's {@link #store}.  The values should be supplied in the proper data type if needed,\n     * otherwise string type will be assumed.  If the grid already contains data, this method will replace any\n     * existing data.  See also the {@link #source} config value.  Example usage:\n     *\n     *     grid.setSource({\n     *         \"(name)\": \"My Object\",\n     *         \"Created\": Ext.Date.parse('10/15/2006', 'm/d/Y'),  // date type\n     *         \"Available\": false,  // boolean type\n     *         \"Version\": .01,      // decimal type\n     *         \"Description\": \"A test object\"\n     *     });\n     *\n     * @param {Object} source The data object\n     */\n    setSource: function(source) {\n        this.source = source;\n        this.propStore.setSource(source);\n    },\n\n    /**\n     * Gets the source data object containing the property data.  See {@link #setSource} for details regarding the\n     * format of the data object.\n     * @return {Object} The data object\n     */\n    getSource: function() {\n        return this.propStore.getSource();\n    },\n\n    /**\n     * Sets the value of a property.\n     * @param {String} prop The name of the property to set\n     * @param {Object} value The value to test\n     * @param {Boolean} [create=false] True to create the property if it doesn't already exist.\n     */\n    setProperty: function(prop, value, create) {\n        this.propStore.setValue(prop, value, create);\n    },\n\n    /**\n     * Removes a property from the grid.\n     * @param {String} prop The name of the property to remove\n     */\n    removeProperty: function(prop) {\n        this.propStore.remove(prop);\n    }\n\n    /**\n     * @cfg store\n     * @private\n     */\n    /**\n     * @cfg columns\n     * @private\n     */\n});\n\n/**\n * A custom HeaderContainer for the {@link Ext.grid.property.Grid}.\n * Generally it should not need to be used directly.\n */\nExt.define('Ext.grid.property.HeaderContainer', {\n\n    extend: 'Ext.grid.header.Container',\n\n    alternateClassName: 'Ext.grid.PropertyColumnModel',\n    \n    nameWidth: 115,\n\n    // private - strings used for locale support\n    //<locale>\n    nameText : 'Name',\n    //</locale>\n    //<locale>\n    valueText : 'Value',\n    //</locale>\n    //<locale>\n    dateFormat : 'm/j/Y',\n    //</locale>\n    //<locale>\n    trueText: 'true',\n    //</locale>\n    //<locale>\n    falseText: 'false',\n    //</locale>\n\n    // private\n    nameColumnCls: Ext.baseCSSPrefix + 'grid-property-name',\n\n    /**\n     * Creates new HeaderContainer.\n     * @param {Ext.grid.property.Grid} grid The grid this store will be bound to\n     * @param {Object} source The source data config object\n     */\n    constructor : function(grid, store) {\n        var me = this;\n        \n        me.grid = grid;\n        me.store = store;\n        me.callParent([{\n            items: [{\n                header: me.nameText,\n                width: grid.nameColumnWidth || me.nameWidth,\n                sortable: grid.sortableColumns,\n                dataIndex: grid.nameField,\n                renderer: Ext.Function.bind(me.renderProp, me),\n                itemId: grid.nameField,\n                menuDisabled :true,\n                tdCls: me.nameColumnCls\n            }, {\n                header: me.valueText,\n                renderer: Ext.Function.bind(me.renderCell, me),\n                getEditor: Ext.Function.bind(me.getCellEditor, me),\n                sortable: grid.sortableColumns,\n                flex: 1,\n                fixed: true,\n                dataIndex: grid.valueField,\n                itemId: grid.valueField,\n                menuDisabled: true\n            }]\n        }]);\n    },\n    \n    getCellEditor: function(record){\n        return this.grid.getCellEditor(record, this);\n    },\n\n    // private\n    // Render a property name cell\n    renderProp : function(v) {\n        return this.getPropertyName(v);\n    },\n\n    // private\n    // Render a property value cell\n    renderCell : function(val, meta, rec) {\n        var me = this,\n            renderer = me.grid.customRenderers[rec.get(me.grid.nameField)],\n            result = val;\n\n        if (renderer) {\n            return renderer.apply(me, arguments);\n        }\n        if (Ext.isDate(val)) {\n            result = me.renderDate(val);\n        } else if (Ext.isBoolean(val)) {\n            result = me.renderBool(val);\n        }\n        return Ext.util.Format.htmlEncode(result);\n    },\n\n    // private\n    renderDate : Ext.util.Format.date,\n\n    // private\n    renderBool : function(bVal) {\n        return this[bVal ? 'trueText' : 'falseText'];\n    },\n\n    // private\n    // Renders custom property names instead of raw names if defined in the Grid\n    getPropertyName : function(name) {\n        var pn = this.grid.propertyNames;\n        return pn && pn[name] ? pn[name] : name;\n    }\n});\n\n/**\n * A specific {@link Ext.data.Model} type that represents a name/value pair and is made to work with the\n * {@link Ext.grid.property.Grid}. Typically, Properties do not need to be created directly as they can be\n * created implicitly by simply using the appropriate data configs either via the\n * {@link Ext.grid.property.Grid#source} config property or by calling {@link Ext.grid.property.Grid#setSource}.\n * However, if the need arises, these records can also be created explicitly as shown below. Example usage:\n *\n *     var rec = new Ext.grid.property.Property({\n *         name: 'birthday',\n *         value: Ext.Date.parse('17/06/1962', 'd/m/Y')\n *     });\n *     // Add record to an already populated grid\n *     grid.store.addSorted(rec);\n *\n * @constructor\n * Creates new property.\n * @param {Object} config A data object in the format:\n * @param {String/String[]} config.name A name or names for the property.\n * @param {Mixed/Mixed[]} config.value A value or values for the property.\n * The specified value's type will be read automatically by the grid to determine the type of editor to use when\n * displaying it.\n * @return {Object}\n */\nExt.define('Ext.grid.property.Property', {\n    extend: 'Ext.data.Model',\n\n    alternateClassName: 'Ext.PropGridProperty',\n\n    fields: [{\n        name: 'name',\n        type: 'string'\n    }, {\n        name: 'value'\n    }],\n    idProperty: 'name'\n});\n\n/**\n * A custom {@link Ext.data.Store} for the {@link Ext.grid.property.Grid}. This class handles the mapping\n * between the custom data source objects supported by the grid and the {@link Ext.grid.property.Property} format\n * used by the {@link Ext.data.Store} base class.\n */\nExt.define('Ext.grid.property.Store', {\n\n    extend: 'Ext.data.Store',\n\n    alternateClassName: 'Ext.grid.PropertyStore',\n\n    sortOnLoad: false,\n\n    uses: ['Ext.data.reader.Reader', 'Ext.data.proxy.Proxy', 'Ext.data.ResultSet', 'Ext.grid.property.Property'],\n\n    /**\n     * Creates new property store.\n     * @param {Ext.grid.Panel} grid The grid this store will be bound to\n     * @param {Object} source The source data config object\n     */\n    constructor : function(grid, source){\n        var me = this;\n        \n        me.grid = grid;\n        me.source = source;\n        me.callParent([{\n            data: source,\n            model: Ext.grid.property.Property,\n            proxy: me.getProxy()\n        }]);\n    },\n\n    // Return a singleton, customized Proxy object which configures itself with a custom Reader\n    getProxy: function() {\n        if (!this.proxy) {\n            Ext.grid.property.Store.prototype.proxy = new Ext.data.proxy.Memory({\n                model: Ext.grid.property.Property,\n                reader: this.getReader()\n            });\n        }\n        return this.proxy;\n    },\n\n    // Return a singleton, customized Reader object which reads Ext.grid.property.Property records from an object.\n    getReader: function() {\n        if (!this.reader) {\n            Ext.grid.property.Store.prototype.reader = new Ext.data.reader.Reader({\n                model: Ext.grid.property.Property,\n\n                buildExtractors: Ext.emptyFn,\n\n                read: function(dataObject) {\n                    return this.readRecords(dataObject);\n                },\n\n                readRecords: function(dataObject) {\n                    var val,\n                        propName,\n                        result = {\n                            records: [],\n                            success: true\n                        };\n\n                    for (propName in dataObject) {\n                        if (dataObject.hasOwnProperty(propName)) {\n                            val = dataObject[propName];\n                            if (this.isEditableValue(val)) {\n                                result.records.push(new Ext.grid.property.Property({\n                                    name: propName,\n                                    value: val\n                                }, propName));\n                            }\n                        }\n                    }\n                    result.total = result.count = result.records.length;\n                    return new Ext.data.ResultSet(result);\n                },\n\n                // private\n                isEditableValue: function(val){\n                    return Ext.isPrimitive(val) || Ext.isDate(val);\n                }\n            });\n        }\n        return this.reader;\n    },\n\n    // protected - should only be called by the grid.  Use grid.setSource instead.\n    setSource : function(dataObject) {\n        var me = this;\n\n        me.source = dataObject;\n        me.suspendEvents();\n        me.removeAll();\n        me.proxy.data = dataObject;\n        me.load();\n        me.resumeEvents();\n        me.fireEvent('datachanged', me);\n        me.fireEvent('refresh', me);\n    },\n\n    // private\n    getProperty : function(row) {\n       return Ext.isNumber(row) ? this.getAt(row) : this.getById(row);\n    },\n\n    // private\n    setValue : function(prop, value, create){\n        var me = this,\n            rec = me.getRec(prop);\n            \n        if (rec) {\n            rec.set('value', value);\n            me.source[prop] = value;\n        } else if (create) {\n            // only create if specified.\n            me.source[prop] = value;\n            rec = new Ext.grid.property.Property({name: prop, value: value}, prop);\n            me.add(rec);\n        }\n    },\n\n    // private\n    remove : function(prop) {\n        var rec = this.getRec(prop);\n        if (rec) {\n            this.callParent([rec]);\n            delete this.source[prop];\n        }\n    },\n\n    // private\n    getRec : function(prop) {\n        return this.getById(prop);\n    },\n\n    // protected - should only be called by the grid.  Use grid.getSource instead.\n    getSource : function() {\n        return this.source;\n    }\n});\n\n/**\n * This class provides a DOM ClassList API to buffer access to an element's class.\n * Instances of this class are created by {@link Ext.layout.ContextItem#getClassList}.\n */\nExt.define('Ext.layout.ClassList', (function () {\n\n    var splitWords = Ext.String.splitWords,\n        toMap = Ext.Array.toMap;\n\n    return {\n        dirty: false,\n\n        constructor: function (owner) {\n            this.owner = owner;\n            this.map = toMap(this.classes = splitWords(owner.el.className));\n        },\n\n        /**\n         * Adds a single class to the class list.\n         */\n        add: function (cls) {\n            var me = this;\n\n            if (!me.map[cls]) {\n                me.map[cls] = true;\n                me.classes.push(cls);\n                if (!me.dirty) {\n                    me.dirty = true;\n                    me.owner.markDirty();\n                }\n            }\n        },\n\n        /**\n         * Adds one or more classes in an array or space-delimited string to the class list.\n         */\n        addMany: function (classes) {\n            Ext.each(splitWords(classes), this.add, this);\n        },\n\n        contains: function (cls) {\n            return this.map[cls];\n        },\n\n        flush: function () {\n            this.owner.el.className = this.classes.join(' ');\n            this.dirty = false;\n        },\n\n        /**\n         * Removes a single class from the class list.\n         */\n        remove: function (cls) {\n            var me = this;\n\n            if (me.map[cls]) {\n                delete me.map[cls];\n                me.classes = Ext.Array.filter(me.classes, function (c) {\n                    return c != cls;\n                });\n                if (!me.dirty) {\n                    me.dirty = true;\n                    me.owner.markDirty();\n                }\n            }\n        },\n\n        /**\n         * Removes one or more classes in an array or space-delimited string from the class\n         * list.\n         */\n        removeMany: function (classes) {\n            var me = this,\n                remove = toMap(splitWords(classes));\n\n            me.classes = Ext.Array.filter(me.classes, function (c) {\n                if (!remove[c]) {\n                    return true;\n                }\n\n                delete me.map[c];\n                if (!me.dirty) {\n                    me.dirty = true;\n                    me.owner.markDirty();\n                }\n                return false;\n            });\n        }\n    };\n}()));\n\n/**\n * An internal Queue class.\n * @private\n */\nExt.define('Ext.util.Queue', {\n\n    constructor: function() {\n        this.clear();\n    },\n\n    add : function(obj) {\n        var me = this,\n            key = me.getKey(obj);\n\n        if (!me.map[key]) {\n            ++me.length;\n            me.items.push(obj);\n            me.map[key] = obj;\n        }\n\n        return obj;\n    },\n\n    /**\n     * Removes all items from the collection.\n     */\n    clear : function(){\n        var me = this,\n            items = me.items;\n\n        me.items = [];\n        me.map = {};\n        me.length = 0;\n\n        return items;\n    },\n\n    contains: function (obj) {\n        var key = this.getKey(obj);\n\n        return this.map.hasOwnProperty(key);\n    },\n\n    /**\n     * Returns the number of items in the collection.\n     * @return {Number} the number of items in the collection.\n     */\n    getCount : function(){\n        return this.length;\n    },\n\n    getKey : function(obj){\n         return obj.id;\n    },\n\n    /**\n     * Remove an item from the collection.\n     * @param {Object} obj The item to remove.\n     * @return {Object} The item removed or false if no item was removed.\n     */\n    remove : function(obj){\n        var me = this,\n            key = me.getKey(obj),\n            items = me.items,\n            index;\n\n        if (me.map[key]) {\n            index = Ext.Array.indexOf(items, obj);\n            Ext.Array.erase(items, index, 1);\n            delete me.map[key];\n            --me.length;\n        }\n\n        return obj;\n    }\n});\n\n/**\n * This class manages state information for a component or element during a layout.\n * \n * # Blocks\n *\n * A \"block\" is a required value that is preventing further calculation. When a layout has\n * encountered a situation where it cannot possibly calculate results, it can associate\n * itself with the context item and missing property so that it will not be rescheduled\n * until that property is set.\n * \n * Blocks are a one-shot registration. Once the property changes, the block is removed.\n * \n * Be careful with blocks. If *any* further calculations can be made, a block is not the\n * right choice.\n * \n * # Triggers\n *\n * Whenever any call to {@link #getProp}, {@link #getDomProp}, {@link #hasProp} or\n * {@link #hasDomProp} is made, the current layout is automatically registered as being\n * dependent on that property in the appropriate state. Any changes to the property will\n * trigger the layout and it will be queued in the {@link Ext.layout.Context}.\n *\n * Triggers, once added, remain for the entire layout. Any changes to the property will\n * reschedule all unfinished layouts in their trigger set.\n *\n * @private\n */\nExt.define('Ext.layout.ContextItem', {\n    \n    requires: ['Ext.layout.ClassList'],\n\n    heightModel: null,\n    widthModel: null,\n    sizeModel: null,\n\n    boxChildren: null,\n\n    boxParent: null,\n\n    children: [],\n\n    dirty: null,\n\n    // The number of dirty properties\n    dirtyCount: 0,\n\n    hasRawContent: true,\n\n    isContextItem: true,\n\n    isTopLevel: false,\n\n    consumersContentHeight: 0,\n    consumersContentWidth: 0,\n    consumersContainerHeight: 0,\n    consumersContainerWidth: 0,\n    consumersHeight: 0,\n    consumersWidth: 0,\n\n    ownerCtContext: null,\n\n    remainingChildLayouts: 0,\n    remainingComponentChildLayouts: 0,\n    remainingContainerChildLayouts: 0,\n\n    // the current set of property values:\n    props: null,\n\n    /**\n     * @property {Object} state\n     * State variables that are cleared when invalidated. Only applies to component items.\n     */\n    state: null,\n\n    /**\n     * @property {Boolean} wrapsComponent\n     * True if this item wraps a Component (rather than an Element).\n     * @readonly\n     */\n    wrapsComponent: false,\n\n    constructor: function (config) {\n        var me = this,\n            el, ownerCt, ownerCtContext, sizeModel, target;\n\n        Ext.apply(me, config);\n\n        el = me.el;\n        me.id = el.id;\n        me.lastBox = el.lastBox;\n\n        // These hold collections of layouts that are either blocked or triggered by sets\n        // to our properties (either ASAP or after flushing to the DOM). All of them have\n        // the same structure:\n        //\n        //      me.blocks = {\n        //          width: {\n        //              'layout-1001': layout1001\n        //          }\n        //      }\n        //\n        // The property name is the primary key which yields an object keyed by layout id\n        // with the layout instance as the value. This prevents duplicate entries for one\n        // layout and gives O(1) access to the layout instance when we need to iterate and\n        // process them.\n        // \n        // me.blocks = {};\n        // me.domBlocks = {};\n        // me.domTriggers = {};\n        // me.triggers = {};\n\n        me.flushedProps = {};\n        me.props = {};\n\n        // the set of cached styles for the element:\n        me.styles = {};\n\n        target = me.target;\n        if (target.isComponent) {\n            me.wrapsComponent = true;\n\n            // These items are created top-down, so the ContextItem of our ownerCt should\n            // be available (if it is part of this layout run).\n            ownerCt = target.ownerCt;\n            if (ownerCt && (ownerCtContext = me.context.items[ownerCt.el.id])) {\n                me.ownerCtContext = ownerCtContext;\n            }\n\n            // If our ownerCtContext is in the run, it will have a SizeModel that we use to\n            // optimize the determination of our sizeModel.\n            me.sizeModel = sizeModel = target.getSizeModel(ownerCtContext &&\n                ownerCtContext.widthModel.pairsByHeightOrdinal[ownerCtContext.heightModel.ordinal]);\n\n            me.widthModel = sizeModel.width;\n            me.heightModel = sizeModel.height;\n\n            // NOTE: The initial determination of sizeModel is valid (thankfully) and is\n            // needed to cope with adding components to a layout run on-the-fly (e.g., in\n            // the menu overflow handler of a box layout). Since this is the case, we do\n            // not need to recompute the sizeModel in init unless it is a \"full\" init (as\n            // our ownerCt's sizeModel could have changed in that case).\n        }\n    },\n\n    /**\n     * Clears all properties on this object except (perhaps) those not calculated by this\n     * component. This is more complex than it would seem because a layout can decide to\n     * invalidate its results and run the component's layouts again, but since some of the\n     * values may be calculated by the container, care must be taken to preserve those\n     * values.\n     *\n     * @param {Boolean} full True if all properties are to be invalidated, false to keep\n     * those calculated by the ownerCt.\n     * @return {Mixed} A value to pass as the first argument to {@link #initContinue}.\n     * @private\n     */\n    init: function (full, options) {\n        var me = this,\n            oldProps = me.props,\n            oldDirty = me.dirty,\n            ownerCtContext = me.ownerCtContext,\n            ownerLayout = me.target.ownerLayout,\n            firstTime = !me.state,\n            ret = full || firstTime,\n            children, i, n, ownerCt, sizeModel, target,\n            oldHeightModel = me.heightModel,\n            oldWidthModel = me.widthModel,\n            newHeightModel, newWidthModel;\n\n        me.dirty = me.invalid = false;\n        me.props = {};\n\n        if (me.boxChildren) {\n            me.boxChildren.length = 0; // keep array (more GC friendly)\n        }\n\n        if (!firstTime) {\n            me.clearAllBlocks('blocks');\n            me.clearAllBlocks('domBlocks');\n        }\n\n        // For Element wrappers, we are done...\n        if (!me.wrapsComponent) {\n            return ret;\n        }\n\n        // From here on, we are only concerned with Component wrappers...\n        target = me.target;\n        me.state = {}; // only Component wrappers need a \"state\"\n\n        if (firstTime) {\n            // This must occur before we proceed since it can do many things (like add\n            // child items perhaps):\n            if (target.beforeLayout) {\n                target.beforeLayout();\n            }\n\n            // Determine the ownerCtContext if we aren't given one. Normally the firstTime\n            // we meet a component is before the context is run, but it is possible for\n            // components to be added to a run that is already in progress. If so, we have\n            // to lookup the ownerCtContext since the odds are very high that the new\n            // component is a child of something already in the run. It is currently\n            // unsupported to drag in the owner of a running component (needs testing).\n            if (!ownerCtContext && (ownerCt = target.ownerCt)) {\n                ownerCtContext = me.context.items[ownerCt.el.id];\n            }\n\n            if (ownerCtContext) {\n                me.ownerCtContext = ownerCtContext;\n                me.isBoxParent = target.ownerLayout.isItemBoxParent(me);\n            } else {\n                me.isTopLevel = true; // this is used by initAnimation...\n            }\n\n            me.frameBodyContext = me.getEl('frameBody');\n        } else {\n            ownerCtContext = me.ownerCtContext;\n\n            // In theory (though untested), this flag can change on-the-fly...\n            me.isTopLevel = !ownerCtContext;\n\n            // Init the children element items since they may have dirty state (no need to\n            // do this the firstTime).\n            children = me.children;\n            for (i = 0, n = children.length; i < n; ++i) {\n                children[i].init(true);\n            }\n        }\n\n        // We need to know how we will determine content size: containers can look at the\n        // results of their items but non-containers or item-less containers with just raw\n        // markup need to be measured in the DOM:\n        me.hasRawContent = !(target.isContainer && target.items.items.length > 0);\n\n        if (full) {\n            // We must null these out or getSizeModel will assume they are the correct,\n            // dynamic size model and return them (the previous dynamic sizeModel).\n            me.widthModel = me.heightModel = null;\n            sizeModel = target.getSizeModel(ownerCtContext && \n                ownerCtContext.widthModel.pairsByHeightOrdinal[ownerCtContext.heightModel.ordinal]);\n\n            if (firstTime) {\n                me.sizeModel = sizeModel;\n            }\n\n            me.widthModel = sizeModel.width;\n            me.heightModel = sizeModel.height;\n        } else if (oldProps) {\n            // these are almost always calculated by the ownerCt (we might need to track\n            // this at some point more carefully):\n            me.recoverProp('x', oldProps, oldDirty);\n            me.recoverProp('y', oldProps, oldDirty);\n\n            // if these are calculated by the ownerCt, don't trash them:\n            if (me.widthModel.calculated) {\n                me.recoverProp('width', oldProps, oldDirty);\n            }\n            if (me.heightModel.calculated) {\n                me.recoverProp('height', oldProps, oldDirty);\n            }\n        }\n\n        if (oldProps && ownerLayout && ownerLayout.manageMargins) {\n            me.recoverProp('margin-top', oldProps, oldDirty);\n            me.recoverProp('margin-right', oldProps, oldDirty);\n            me.recoverProp('margin-bottom', oldProps, oldDirty);\n            me.recoverProp('margin-left', oldProps, oldDirty);\n        }\n\n        // Process any invalidate options present. These can only come from explicit calls\n        // to the invalidate() method.\n        if (options) {\n            // Consider a container box with wrapping text. If the box is made wider, the\n            // text will take up less height (until there is no more wrapping). Conversely,\n            // if the box is made narrower, the height starts to increase due to wrapping.\n            //\n            // Imposing a minWidth constraint would increase the width. This may decrease\n            // the height. If the box is shrinkWrap, however, the width will already be\n            // such that there is no wrapping, so the height will not further decrease.\n            // Since the height will also not increase if we widen the box, there is no\n            // problem simultaneously imposing a minHeight or maxHeight constraint.\n            //\n            // When we impose as maxWidth constraint, however, we are shrinking the box\n            // which may increase the height. If we are imposing a maxHeight constraint,\n            // that is fine because a further increased height will still need to be\n            // constrained. But if we are imposing a minHeight constraint, we cannot know\n            // whether the increase in height due to wrapping will be greater than the\n            // minHeight. If we impose a minHeight constraint at the same time, then, we\n            // could easily be locking in the wrong height.\n            //\n            // It is important to note that this logic applies to simultaneously *adding*\n            // both a maxWidth and a minHeight constraint. It is perfectly fine to have\n            // a state with both constraints, but we cannot add them both at once.\n            newHeightModel = options.heightModel;\n            newWidthModel = options.widthModel;\n            if (newWidthModel && newHeightModel && oldWidthModel && oldHeightModel) {\n                if (oldWidthModel.shrinkWrap && oldHeightModel.shrinkWrap) {\n                    if (newWidthModel.constrainedMax && newHeightModel.constrainedMin) {\n                        newHeightModel = null;\n                    }\n                }\n            }\n\n            // Apply size model updates (if any) and state updates (if any).\n            if (newWidthModel) {\n                me.widthModel = newWidthModel;\n            }\n            if (newHeightModel) {\n                me.heightModel = newHeightModel;\n            }\n\n            if (options.state) {\n                Ext.apply(me.state, options.state);\n            }\n        }\n\n        return ret;\n    },\n\n    /**\n     * @private\n     */\n    initContinue: function (full) {\n        var me = this,\n            ownerCtContext = me.ownerCtContext,\n            widthModel = me.widthModel,\n            boxParent;\n\n        if (full) {\n            if (ownerCtContext && widthModel.shrinkWrap) {\n                boxParent = ownerCtContext.isBoxParent ? ownerCtContext : ownerCtContext.boxParent;\n                if (boxParent) {\n                    boxParent.addBoxChild(me);\n                }\n            } else if (widthModel.natural) {\n                me.boxParent = ownerCtContext;\n            }\n        }\n\n        return full;\n    },\n\n    /**\n     * @private\n     */\n    initDone: function (full, componentChildrenDone, containerChildrenDone, containerLayoutDone) {\n        var me = this,\n            props = me.props,\n            state = me.state;\n\n        // These properties are only set when they are true:\n        if (componentChildrenDone) {\n            props.componentChildrenDone = true;\n        }\n        if (containerChildrenDone) {\n            props.containerChildrenDone = true;\n        }\n        if (containerLayoutDone) {\n            props.containerLayoutDone = true;\n        }\n\n        if (me.boxChildren && me.boxChildren.length && me.widthModel.shrinkWrap) {\n            // set a very large width to allow the children to measure their natural\n            // widths (this is cleared once all children have been measured):\n            me.el.setWidth(10000);\n\n            // don't run layouts for this component until we clear this width...\n            state.blocks = (state.blocks || 0) + 1;\n        }\n    },\n\n    /**\n     * @private\n     */\n    initAnimation: function() {\n        var me = this,\n            target = me.target,\n            ownerCtContext = me.ownerCtContext;\n\n        if (ownerCtContext && ownerCtContext.isTopLevel) {\n            // See which properties we are supposed to animate to their new state.\n            // If there are any, queue ourself to be animated by the owning Context\n            me.animatePolicy = target.ownerLayout.getAnimatePolicy(me);\n        } else if (!ownerCtContext && target.isCollapsingOrExpanding && target.animCollapse) {\n            // Collapsing/expnding a top level Panel with animation. We need to fabricate\n            // an animatePolicy depending on which dimension the collapse is using,\n            // isCollapsingOrExpanding is set during the collapse/expand process.\n            me.animatePolicy = target.componentLayout.getAnimatePolicy(me);\n        }\n\n        if (me.animatePolicy) {\n            me.context.queueAnimation(me);\n        }\n    },\n\n    noFraming: { left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0 },\n\n    /**\n     * Queue the addition of a class name (or array of class names) to this ContextItem's target when next flushed.\n     */\n    addCls: function(newCls) {\n        this.getClassList().addMany(newCls);\n    },\n\n    /**\n     * Queue the removal of a class name (or array of class names) from this ContextItem's target when next flushed.\n     */\n    removeCls: function(removeCls) {\n        this.getClassList().removeMany(removeCls);\n    },\n\n    /**\n     * Adds a block.\n     * \n     * @param {String} name The name of the block list ('blocks' or 'domBlocks').\n     * @param {Ext.layout.Layout} layout The layout that is blocked.\n     * @param {String} propName The property name that blocked the layout (e.g., 'width').\n     * @private\n     */\n    addBlock: function (name, layout, propName) {\n        var me = this,\n            collection = me[name] || (me[name] = {}),\n            blockedLayouts = collection[propName] || (collection[propName] = {});\n\n        if (!blockedLayouts[layout.id]) {\n            blockedLayouts[layout.id] = layout;\n            ++layout.blockCount;\n            ++me.context.blockCount;\n        }\n    },\n\n    addBoxChild: function (boxChildItem) {\n        var me = this,\n            children,\n            widthModel = boxChildItem.widthModel;\n\n        boxChildItem.boxParent = this;\n\n        // Children that are widthModel.auto (regardless of heightModel) that measure the\n        // DOM (by virtue of hasRawContent), need to wait for their \"box parent\" to be sized.\n        // If they measure too early, they will be wrong results. In the widthModel.shrinkWrap\n        // case, the boxParent \"crushes\" the child. In the case of widthModel.natural, the\n        // boxParent's width is likely a key part of the child's width (e.g., \"50%\" or just\n        // normal block-level behavior of 100% width)\n        boxChildItem.measuresBox = widthModel.shrinkWrap ? boxChildItem.hasRawContent : widthModel.natural;\n\n        if (boxChildItem.measuresBox) {\n            children = me.boxChildren;\n\n            if (children) {\n                children.push(boxChildItem);\n            } else {\n                me.boxChildren = [ boxChildItem ];\n            }\n        }\n    },\n\n    /**\n     * Adds a trigger.\n     * \n     * @param {String} propName The property name that triggers the layout (e.g., 'width').\n     * @param {Boolean} inDom True if the trigger list is `domTriggers`, false if `triggers`.\n     * @private\n     */\n    addTrigger: function (propName, inDom) {\n        var me = this,\n            name = inDom ? 'domTriggers' : 'triggers',\n            collection = me[name] || (me[name] = {}),\n            context = me.context,\n            layout = context.currentLayout,\n            triggers = collection[propName] || (collection[propName] = {});\n\n        if (!triggers[layout.id]) {\n            triggers[layout.id] = layout;\n            ++layout.triggerCount;\n\n            triggers = context.triggers[inDom ? 'dom' : 'data'];\n            (triggers[layout.id] || (triggers[layout.id] = [])).push({\n                item: this,\n                prop: propName\n            });\n\n            if (me.props[propName] !== undefined) {\n                if (!inDom || !(me.dirty && (propName in me.dirty))) {\n                    ++layout.firedTriggers;\n                }\n            }\n        }\n    },\n\n    boxChildMeasured: function () {\n        var me = this,\n            state = me.state,\n            count = (state.boxesMeasured = (state.boxesMeasured || 0) + 1);\n\n        if (count == me.boxChildren.length) {\n            // all of our children have measured themselves, so we can clear the width\n            // and resume layouts for this component...\n            state.clearBoxWidth = 1;\n            ++me.context.progressCount;\n            me.markDirty();\n        }\n    },\n\n    borderNames: [ 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width'],\n    marginNames: [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ],\n    paddingNames: [ 'padding-top', 'padding-right', 'padding-bottom', 'padding-left' ],\n    trblNames: [ 'top', 'right', 'bottom', 'left' ],\n\n    cacheMissHandlers: {\n        borderInfo: function (me) {\n            var info = me.getStyles(me.borderNames, me.trblNames);\n\n            info.width = info.left + info.right;\n            info.height = info.top + info.bottom;\n\n            return info;\n        },\n\n        marginInfo: function (me) {\n            var info = me.getStyles(me.marginNames, me.trblNames);\n\n            info.width = info.left + info.right;\n            info.height = info.top + info.bottom;\n\n            return info;\n        },\n\n        paddingInfo: function (me) {\n            // if this context item's target is a framed component the padding is on the frameBody, not on the main el\n            var item = me.frameBodyContext || me,\n                info = item.getStyles(me.paddingNames, me.trblNames);\n\n            info.width = info.left + info.right;\n            info.height = info.top + info.bottom;\n\n            return info;\n        }\n    },\n\n    checkCache: function (entry) {\n        return this.cacheMissHandlers[entry](this);\n    },\n\n    clearAllBlocks: function (name) {\n        var collection = this[name],\n            propName;\n\n        if (collection) {\n            for (propName in collection) {\n                this.clearBlocks(name, propName);\n            }\n        }\n    },\n\n    /**\n     * Removes any blocks on a property in the specified set. Any layouts that were blocked\n     * by this property and are not still blocked (by other properties) will be rescheduled.\n     * \n     * @param {String} name The name of the block list ('blocks' or 'domBlocks').\n     * @param {String} propName The property name that blocked the layout (e.g., 'width').\n     * @private\n     */\n    clearBlocks: function (name, propName) {\n        var collection = this[name],\n            blockedLayouts = collection && collection[propName],\n            context, layout, layoutId;\n\n        if (blockedLayouts) {\n            delete collection[propName];\n\n            context = this.context;\n\n            for (layoutId in blockedLayouts) {\n                layout = blockedLayouts[layoutId];\n\n                --context.blockCount;\n                if (! --layout.blockCount && !layout.pending && !layout.done) {\n                    context.queueLayout(layout);\n                }\n            }\n        }\n    },\n\n    /**\n     * Registers a layout in the block list for the given property. Once the property is\n     * set in the {@link Ext.layout.Context}, the layout is unblocked.\n     * \n     * @param {Ext.layout.Layout} layout\n     * @param {String} propName The property name that blocked the layout (e.g., 'width').\n     */\n    block: function (layout, propName) {\n        this.addBlock('blocks', layout, propName);\n    },\n\n    /**\n     * Registers a layout in the DOM block list for the given property. Once the property\n     * flushed to the DOM by the {@link Ext.layout.Context}, the layout is unblocked.\n     * \n     * @param {Ext.layout.Layout} layout\n     * @param {String} propName The property name that blocked the layout (e.g., 'width').\n     */\n    domBlock: function (layout, propName) {\n        this.addBlock('domBlocks', layout, propName);\n    },\n\n    /**\n     * Reschedules any layouts associated with a given trigger.\n     * \n     * @param {String} name The name of the trigger list ('triggers' or 'domTriggers').\n     * @param {String} propName The property name that triggers the layout (e.g., 'width').\n     * @private\n     */\n    fireTriggers: function (name, propName) {\n        var collection = this[name],\n            triggers = collection && collection[propName],\n            context = this.context,\n            layout, layoutId;\n\n        if (triggers) {\n            for (layoutId in triggers) {\n                layout = triggers[layoutId];\n                ++layout.firedTriggers;\n                if (!layout.done && !layout.blockCount && !layout.pending) {\n                    context.queueLayout(layout);\n                }\n            }\n        }\n    },\n\n    /**\n     * Flushes any updates in the dirty collection to the DOM. This is only called if there\n     * are dirty entries because this object is only added to the flushQueue of the\n     * {@link Ext.layout.Context} when entries become dirty.\n     */\n    flush: function () {\n        var me = this,\n            dirty = me.dirty,\n            state = me.state,\n            targetEl = me.el;\n\n        me.dirtyCount = 0;\n\n        // Flush added/removed classes\n        if (me.classList && me.classList.dirty) {\n            me.classList.flush();\n        }\n\n        // Set any queued DOM attributes\n        if ('attributes' in me) {\n            targetEl.set(me.attributes);\n            delete me.attributes;\n        }\n\n        // Set any queued DOM HTML content\n        if ('innerHTML' in me) {\n            targetEl.innerHTML = me.innerHTML;\n            delete me.innerHTML;\n        }\n\n        if (state && state.clearBoxWidth) {\n            state.clearBoxWidth = 0;\n            me.el.setStyle('width', null);\n\n            if (! --state.blocks) {\n                me.context.queueItemLayouts(me);\n            }\n        }\n\n        if (dirty) {\n            delete me.dirty;\n            me.writeProps(dirty, true);\n        }\n    },\n\n    /**\n     * @private\n     */\n    flushAnimations: function() {\n        var me = this,\n            animateFrom = me.lastBox,\n            target, targetAnim, duration, animateProps, anim,\n            changeCount, j, propsLen, propName, oldValue, newValue;\n\n        // Only animate if the Component has been previously layed out: first layout should not animate\n        if (animateFrom) {\n            target = me.target;\n            targetAnim = target.layout && target.layout.animate;\n            if (targetAnim) {\n                duration = Ext.isNumber(targetAnim) ? targetAnim : targetAnim.duration;\n            }\n            animateProps = Ext.Object.getKeys(me.animatePolicy);\n\n            // Create an animation block using the targetAnim configuration to provide defaults.\n            // They may want custom duration, or easing, or listeners.\n            anim = Ext.apply({}, {\n                from: {},\n                to: {},\n                duration: duration || Ext.fx.Anim.prototype.duration\n            }, targetAnim);\n\n            for (changeCount = 0, j = 0, propsLen = animateProps.length; j < propsLen; j++) {\n                propName = animateProps[j];\n                oldValue = animateFrom[propName];\n                newValue = me.peek(propName);\n                if (oldValue != newValue) {\n                    propName = me.translateProps[propName]||propName;\n                    anim.from[propName] = oldValue;\n                    anim.to[propName] = newValue;\n                    ++changeCount;\n                }\n            }\n\n            // If any values have changed, kick off animation from the cached old values to the new values\n            if (changeCount) {\n                // It'a Panel being collapsed. rollback, and then fix the class name string\n                if (me.isCollapsingOrExpanding === 1) {\n                    target.componentLayout.undoLayout(me);\n                }\n\n                // Otherwise, undo just the animated properties so the animation can proceed from the old layout.\n                else {\n                    me.writeProps(anim.from);\n                }\n                me.el.animate(anim);\n                \n                Ext.fx.Manager.getFxQueue(me.el.id)[0].on({\n                    afteranimate: function() {\n                        if (me.isCollapsingOrExpanding === 1) {\n                            target.componentLayout.redoLayout(me);\n                            target.afterCollapse(true);\n                        } else if (me.isCollapsingOrExpanding === 2) {\n                            target.afterExpand(true);\n                        }\n                    }\n                });\n            }\n        }\n    },\n\n    /**\n     * Gets the border information for the element as an object with left, top, right and\n     * bottom properties holding border size in pixels. This object is only read from the\n     * DOM on first request and is cached.\n     * @return {Object}\n     */\n    getBorderInfo: function () {\n        var me = this,\n            info = me.borderInfo;\n\n        if (!info) {\n            me.borderInfo = info = me.checkCache('borderInfo');\n        }\n\n        return info;\n    },\n\n    /**\n     * Returns a ClassList-like object to buffer access to this item's element's classes.\n     */\n    getClassList: function () {\n        return this.classList || (this.classList = new Ext.layout.ClassList(this));\n    },\n\n    /**\n     * Returns the context item for an owned element. This should only be called on a\n     * component's item. The list of child items is used to manage invalidating calculated\n     * results.\n     */\n    getEl: function (nameOrEl, owner) {\n        var me = this,\n            src, el, elContext;\n\n        if (nameOrEl) {\n            if (nameOrEl.dom) {\n                el = nameOrEl;\n            } else {\n                src = me.target;\n                if (owner) {\n                    src = owner;\n                }\n\n                el = src[nameOrEl];\n                if (typeof el == 'function') { // ex 'getTarget'\n                    el = el.call(src);\n                    if (el === me.el) {\n                        return this; // comp.getTarget() often returns comp.el\n                    }\n                }\n            }\n\n            if (el) {\n                elContext = me.context.getEl(me, el);\n            }\n        }\n\n        return elContext || null;\n    },\n\n    getFraming: function () {\n        var me = this;\n        if (!me.framingInfo) {\n            me.framingInfo = me.target.frameSize || me.noFraming;\n        }\n        return me.framingInfo;\n    },\n\n    /**\n     * Gets the \"frame\" information for the element as an object with left, top, right and\n     * bottom properties holding border+framing size in pixels. This object is calculated\n     * on first request and is cached.\n     * @return {Object}\n     */\n    getFrameInfo: function () {\n        var me = this,\n            info = me.frameInfo,\n            frame, border;\n\n        if (!info) {\n            frame = me.getFraming();\n            border = me.getBorderInfo();\n            \n            me.frameInfo = info = {\n                top   : frame.top    + border.top,\n                right : frame.right  + border.right,\n                bottom: frame.bottom + border.bottom,\n                left  : frame.left   + border.left,\n                width : frame.width  + border.width,\n                height: frame.height + border.height\n            };\n        }\n\n        return info;\n    },\n\n    /**\n     * Gets the margin information for the element as an object with left, top, right and\n     * bottom properties holding margin size in pixels. This object is only read from the\n     * DOM on first request and is cached.\n     * @return {Object}\n     */\n    getMarginInfo: function () {\n        var me = this,\n            info = me.marginInfo,\n            comp, manageMargins, margins, ownerLayout, ownerLayoutId;\n\n        if (!info) {\n            if (!me.wrapsComponent) {\n                info = me.checkCache('marginInfo');\n            } else {\n                comp = me.target;\n                ownerLayout = comp.ownerLayout;\n                ownerLayoutId = ownerLayout ? ownerLayout.id : null;\n                manageMargins = ownerLayout && ownerLayout.manageMargins;\n\n                // Option #1 for configuring margins on components is the \"margin\" config\n                // property. When supplied, this config is written to the DOM during the\n                // render process (see AbstractComponent#initStyles).\n                //\n                // Option #2 is available to some layouts (e.g., Box, Border, Fit) that\n                // handle margin calculations themselves. These layouts support a \"margins\"\n                // config property on their items and they have a \"defaultMargins\" config\n                // property. These margin values are added to the \"natural\" margins read\n                // from the DOM and 0's are written to the DOM after they are added.\n\n                // To avoid having to do all this on every layout, we cache the results on\n                // the component in the (private) \"margin$\" property. We identify the cache\n                // results as belonging to the appropriate ownerLayout in case items are\n                // moved around.\n\n                info = comp.margin$;\n                if (info && info.ownerId !== ownerLayoutId) {\n                    // got one but from the wrong owner\n                    info = null;\n\n                    //  if (manageMargins) {\n                    //      TODO: clear inline margins (the 0's we wrote last time)???\n                    //  }\n                }\n\n                if (!info) { // if (no cache)\n                    // CSS margins are only checked if there isn't a margin property on the component\n                    info = me.parseMargins(comp.margin) || me.checkCache('marginInfo');\n\n                    // Some layouts also support margins and defaultMargins, e.g. Fit, Border, Box\n                    if (manageMargins) {\n                        margins = me.parseMargins(comp.margins, ownerLayout.defaultMargins);\n\n                        if (margins) { // if (using 'margins' and/or 'defaultMargins')\n                            // margin and margins can both be present at the same time and must be combined\n                            info = {\n                                top:    info.top    + margins.top,\n                                right:  info.right  + margins.right,\n                                bottom: info.bottom + margins.bottom,\n                                left:   info.left   + margins.left\n                            };\n                        }\n\n                        me.setProp('margin-top', 0);\n                        me.setProp('margin-right', 0);\n                        me.setProp('margin-bottom', 0);\n                        me.setProp('margin-left', 0);\n                    }\n\n                    // cache the layout margins and tag them with the layout id:\n                    info.ownerId = ownerLayoutId;\n                    comp.margin$ = info;\n                }\n\n                info.width  = info.left + info.right;\n                info.height = info.top  + info.bottom;\n            }\n\n            me.marginInfo = info;\n        }\n\n        return info;\n    },\n\n    /**\n     * clears the margin cache so that marginInfo get re-read from the dom on the next call to getMarginInfo()\n     * This is needed in some special cases where the margins have changed since the last layout, making the cached\n     * values invalid.  For example collapsed window headers have different margin than expanded ones.\n     */\n    clearMarginCache: function() {\n        delete this.marginInfo;\n        delete this.target.margin$;\n    },\n\n    /**\n     * Gets the padding information for the element as an object with left, top, right and\n     * bottom properties holding padding size in pixels. This object is only read from the\n     * DOM on first request and is cached.\n     * @return {Object}\n     */\n    getPaddingInfo: function () {\n        var me = this,\n            info = me.paddingInfo;\n\n        if (!info) {\n            me.paddingInfo = info = me.checkCache('paddingInfo');\n        }\n\n        return info;\n    },\n\n    /**\n     * Gets a property of this object. Also tracks the current layout as dependent on this\n     * property so that changes to it will trigger the layout to be recalculated.\n     * @param {String} propName The property name that blocked the layout (e.g., 'width').\n     * @return {Object} The property value or undefined if not yet set.\n     */\n    getProp: function (propName) {\n        var me = this,\n            result = me.props[propName];\n\n        me.addTrigger(propName);\n        return result;\n    },\n\n    /**\n     * Gets a property of this object if it is correct in the DOM. Also tracks the current\n     * layout as dependent on this property so that DOM writes of it will trigger the\n     * layout to be recalculated.\n     * @param {String} propName The property name (e.g., 'width').\n     * @return {Object} The property value or undefined if not yet set or is dirty.\n     */\n    getDomProp: function (propName) {\n        var me = this,\n            result = (me.dirty && (propName in me.dirty)) ? undefined : me.props[propName];\n\n        me.addTrigger(propName, true);\n        return result;\n    },\n\n    /**\n     * Returns a style for this item. Each style is read from the DOM only once on first\n     * request and is then cached. If the value is an integer, it is parsed automatically\n     * (so '5px' is not returned, but rather 5).\n     *\n     * @param {String} styleName The CSS style name.\n     * @return {Object} The value of the DOM style (parsed as necessary).\n     */\n    getStyle: function (styleName) {\n        var me = this,\n            styles = me.styles,\n            info, value;\n\n        if (styleName in styles) {\n            value = styles[styleName];\n        } else {\n            info = me.styleInfo[styleName];\n            value = me.el.getStyle(styleName);\n\n            if (info && info.parseInt) {\n                value = parseInt(value, 10) || 0;\n            }\n\n            styles[styleName] = value;\n        }\n\n        return value;\n    },\n\n    /**\n     * Returns styles for this item. Each style is read from the DOM only once on first\n     * request and is then cached. If the value is an integer, it is parsed automatically\n     * (so '5px' is not returned, but rather 5).\n     *\n     * @param {String[]} styleNames The CSS style names.\n     * @param {String[]} [altNames] The alternate names for the returned styles. If given,\n     * these names must correspond one-for-one to the `styleNames`.\n     * @return {Object} The values of the DOM styles (parsed as necessary).\n     */\n    getStyles: function (styleNames, altNames) {\n        var me = this,\n            styleCache = me.styles,\n            values = {},\n            hits = 0,\n            n = styleNames.length,\n            i, missing, missingAltNames, name, info, styleInfo, styles, value;\n\n        altNames = altNames || styleNames;\n\n        // We are optimizing this for all hits or all misses. If we hit on all styles, we\n        // don't create a missing[]. If we miss on all styles, we also don't create one.\n        for (i = 0; i < n; ++i) {\n            name = styleNames[i];\n\n            if (name in styleCache) {\n                values[altNames[i]] = styleCache[name];\n                ++hits;\n\n                if (i && hits==1) { // if (first hit was after some misses)\n                    missing = styleNames.slice(0, i);\n                    missingAltNames = altNames.slice(0, i);\n                }\n            } else if (hits) {\n                (missing || (missing = [])).push(name);\n                (missingAltNames || (missingAltNames = [])).push(altNames[i]);\n            }\n        }\n\n        if (hits < n) {\n            missing = missing || styleNames;\n            missingAltNames = missingAltNames || altNames;\n            styleInfo = me.styleInfo;\n\n            styles = me.el.getStyle(missing);\n\n            for (i = missing.length; i--; ) {\n                name = missing[i];\n                info = styleInfo[name];\n                value = styles[name];\n\n                if (info && info.parseInt) {\n                    value = parseInt(value, 10) || 0;\n                }\n\n                values[missingAltNames[i]] = value;\n                styleCache[name] = value;\n            }\n        }\n\n        return values;\n    },\n\n    /**\n     * Returns true if the given property has been set. This is equivalent to calling\n     * {@link #getProp} and not getting an undefined result. In particular, this call\n     * registers the current layout to be triggered by changes to this property.\n     * \n     * @param {String} propName The property name (e.g., 'width').\n     * @return {Boolean}\n     */\n    hasProp: function (propName) {\n        var value = this.getProp(propName);\n        return typeof value != 'undefined';\n    },\n\n    /**\n     * Returns true if the given property is correct in the DOM. This is equivalent to\n     * calling {@link #getDomProp} and not getting an undefined result. In particular,\n     * this call registers the current layout to be triggered by flushes of this property.\n     * \n     * @param {String} propName The property name (e.g., 'width').\n     * @return {Boolean}\n     */\n    hasDomProp: function (propName) {\n        var value = this.getDomProp(propName);\n        return typeof value != 'undefined';\n    },\n\n    /**\n     * Invalidates the component associated with this item. The layouts for this component\n     * and all of its contained items will be re-run after first clearing any computed\n     * values.\n     * \n     * If state needs to be carried forward beyond the invalidation, the `options` parameter\n     * can be used.\n     *\n     * @param {Object} options An object describing how to handle the invalidation.\n     * @param {Object} options.state An object to {@link Ext#apply} to the {@link #state}\n     *  of this item after invalidation clears all other properties.\n     * @param {Function} options.before A function to call after the context data is cleared\n     * and before the {@link Ext.layout.Layout#beginLayoutCycle} methods are called.\n     * @param {Ext.layout.ContextItem} options.before.item This ContextItem.\n     * @param {Object} options.before.options The options object passed to {@link #invalidate}.\n     * @param {Function} options.after A function to call after the context data is cleared\n     * and after the {@link Ext.layout.Layout#beginLayoutCycle} methods are called.\n     * @param {Ext.layout.ContextItem} options.after.item This ContextItem.\n     * @param {Object} options.after.options The options object passed to {@link #invalidate}.\n     * @param {Object} options.scope The scope to use when calling the callback functions.\n     */\n    invalidate: function (options) {\n        this.context.queueInvalidate(this, options);\n    },\n\n    markDirty: function () {\n        if (++this.dirtyCount == 1) {\n            // our first dirty property... queue us for flush\n            this.context.queueFlush(this);\n        }\n    },\n\n    onBoxMeasured: function () {\n        var boxParent = this.boxParent,\n            state = this.state;\n\n        if (boxParent && boxParent.widthModel.shrinkWrap && !state.boxMeasured && this.measuresBox) {\n            // since an autoWidth boxParent is holding a width on itself to allow each\n            // child to measure\n            state.boxMeasured = 1; // best to only call once per child\n            boxParent.boxChildMeasured();\n        }\n    },\n\n    parseMargins: function (margins, defaultMargins) {\n        if (margins === true) {\n            margins = 5;\n        }\n\n        var type = typeof margins,\n            ret;\n\n        if (type == 'string' || type == 'number') {\n            ret = Ext.util.Format.parseBox(margins);\n        } else if (margins || defaultMargins) {\n            ret = { top: 0, right: 0, bottom: 0, left: 0 }; // base defaults\n\n            if (defaultMargins) {\n                Ext.apply(ret, this.parseMargins(defaultMargins)); // + layout defaults\n            }\n\n            Ext.apply(ret, margins); // + config\n        }\n\n        return ret;\n    },\n\n    peek: function (propName) {\n        return this.props[propName];\n    },\n\n    /**\n     * Recovers a property value from the last computation and restores its value and\n     * dirty state.\n     * \n     * @param {String} propName The name of the property to recover.\n     * @param {Object} oldProps The old \"props\" object from which to recover values.\n     * @param {Object} oldDirty The old \"dirty\" object from which to recover state.\n     */\n    recoverProp: function (propName, oldProps, oldDirty) {\n        var me = this,\n            props = me.props,\n            dirty;\n\n        if (propName in oldProps) {\n            props[propName] = oldProps[propName];\n\n            if (oldDirty && propName in oldDirty) {\n                dirty = me.dirty || (me.dirty = {});\n                dirty[propName] = oldDirty[propName];\n            }\n        }\n    },\n\n    redo: function(deep) {\n        var me = this,\n            items, len, i;\n\n        me.revertProps(me.props);\n\n        if (deep && me.wrapsComponent) {\n            // Rollback the state of child Components\n            if (me.childItems) {\n                for (i = 0, items = me.childItems, len = items.length; i < len; i++) {\n                    items[i].redo(deep);\n                }\n            }\n\n            // Rollback the state of child Elements\n            for (i = 0, items = me.children, len = items.length; i < len; i++) {\n                items[i].redo();\n            }\n        }\n    },\n\n    revertProps: function (props) {\n        var name,\n            flushed = this.flushedProps,\n            reverted = {};\n\n        for (name in props) {\n            if (flushed.hasOwnProperty(name)) {\n                reverted[name] = props[name];\n            }\n        }\n\n        this.writeProps(reverted);\n    },\n\n    /**\n     * Queue the setting of a DOM attribute on this ContextItem's target when next flushed.\n     */\n    setAttribute: function(name, value) {\n        var me = this;\n        if (!me.attributes) {\n            me.attributes = {};\n        }\n        me.attributes[name] = value;\n        me.markDirty();\n    },\n\n    setBox: function (box) {\n        var me = this;\n\n        if ('left' in box) {\n            me.setProp('x', box.left);\n        }\n        if ('top' in box) {\n            me.setProp('y', box.top);\n        }\n\n        // if sizeModel says we should not be setting these, the appropriate calls will be\n        // null operations... otherwise, we must set these values, so what we have in box\n        // is what we go with (undefined, NaN and no change are handled at a lower level):\n        me.setSize(box.width, box.height);\n    },\n\n    /**\n     * Sets the contentHeight property. If the component uses raw content, then only the\n     * measured height is acceptable.\n     *\n     * Calculated values can sometimes be NaN or undefined, which generally mean the\n     * calculation is not done. To indicate that such as value was passed, 0 is returned.\n     * Otherwise, 1 is returned.\n     *\n     * If the caller is not measuring (i.e., they are calculating) and the component has raw\n     * content, 1 is returned indicating that the caller is done.\n     */\n    setContentHeight: function (height, measured) {\n        if (!measured && this.hasRawContent) {\n            return 1;\n        }\n\n        return this.setProp('contentHeight', height);\n    },\n\n    /**\n     * Sets the contentWidth property. If the component uses raw content, then only the\n     * measured width is acceptable.\n     * \n     * Calculated values can sometimes be NaN or undefined, which generally means that the\n     * calculation is not done. To indicate that such as value was passed, 0 is returned.\n     * Otherwise, 1 is returned.\n     *\n     * If the caller is not measuring (i.e., they are calculating) and the component has raw\n     * content, 1 is returned indicating that the caller is done.\n     */\n    setContentWidth: function (width, measured) {\n        if (!measured && this.hasRawContent) {\n            return 1;\n        }\n\n        return this.setProp('contentWidth', width);\n    },\n\n    /**\n     * Sets the contentWidth and contentHeight properties. If the component uses raw content,\n     * then only the measured values are acceptable.\n     * \n     * Calculated values can sometimes be NaN or undefined, which generally means that the\n     * calculation is not done. To indicate that either passed value was such a value, false\n     * returned. Otherwise, true is returned.\n     *\n     * If the caller is not measuring (i.e., they are calculating) and the component has raw\n     * content, true is returned indicating that the caller is done.\n     */\n    setContentSize: function (width, height, measured) {\n        return this.setContentWidth(width, measured) +\n               this.setContentHeight(height, measured) == 2;\n    },\n\n    /**\n     * Sets a property value. This will unblock and/or trigger dependent layouts if the\n     * property value is being changed. Values of NaN and undefined are not accepted by\n     * this method.\n     * \n     * @param {String} propName The property name (e.g., 'width').\n     * @param {Object} value The new value of the property.\n     * @param {Boolean} dirty Optionally specifies if the value is currently in the DOM\n     *  (default is `true` which indicates the value is not in the DOM and must be flushed\n     *  at some point).\n     * @return {Number} 1 if this call specified the property value, 0 if not.\n     */\n    setProp: function (propName, value, dirty) {\n        var me = this,\n            valueType = typeof value,\n            borderBox, info;\n\n        if (valueType == 'undefined' || (valueType === 'number' && isNaN(value))) {\n            return 0;\n        }\n        if (me.props[propName] === value) {\n            return 1;\n        }\n\n        me.props[propName] = value;\n        ++me.context.progressCount;\n\n        if (dirty === false) {\n            // if the prop is equivalent to what is in the DOM (we won't be writing it),\n            // we need to clear hard blocks (domBlocks) on that property.\n            me.fireTriggers('domTriggers', propName);\n            me.clearBlocks('domBlocks', propName);\n        } else {\n            info = me.styleInfo[propName];\n            if (info) {\n                if (!me.dirty) {\n                    me.dirty = {};\n                }\n\n                if (propName == 'width' || propName == 'height') {\n                    borderBox = me.isBorderBoxValue;\n                    if (borderBox == null) {\n                        me.isBorderBoxValue = borderBox = !!me.el.isBorderBox();\n                    }\n\n                    if (!borderBox) {\n                        me.borderInfo || me.getBorderInfo();\n                        me.paddingInfo || me.getPaddingInfo();\n                    }\n                }\n                me.dirty[propName] = value;\n                me.markDirty();\n            }\n        }\n\n        // we always clear soft blocks on set\n        me.fireTriggers('triggers', propName);\n        me.clearBlocks('blocks', propName);\n        return 1;\n    },\n\n    /**\n     * Sets the height and constrains the height to min/maxHeight range.\n     * \n     * @param {Number} height The height.\n     * @param {Boolean} [dirty=true] Specifies if the value is currently in the DOM. A\n     * value of `false` indicates that the value is already in the DOM.\n     * @return {Number} The actual height after constraining.\n     */\n    setHeight: function (height, dirty /*, private {Boolean} force */) {\n        var me = this,\n            comp = me.target,\n            frameBody, frameInfo, padding;\n\n        if (height < 0) {\n            height = 0;\n        }\n        if (!me.wrapsComponent) {\n            if (!me.setProp('height', height, dirty)) {\n                return NaN;\n            }\n        } else {\n            height = Ext.Number.constrain(height, comp.minHeight || 0, comp.maxHeight);\n            if (!me.setProp('height', height, dirty)) {\n                return NaN;\n            }\n\n            frameBody = me.frameBodyContext;\n            if (frameBody){\n                frameInfo = me.getFrameInfo();\n                frameBody.setHeight(height - frameInfo.height, dirty);\n            }\n        }\n\n        return height;\n    },\n\n    /**\n     * Sets the height and constrains the width to min/maxWidth range.\n     * \n     * @param {Number} width The width.\n     * @param {Boolean} [dirty=true] Specifies if the value is currently in the DOM. A\n     * value of `false` indicates that the value is already in the DOM.\n     * @return {Number} The actual width after constraining.\n     */\n    setWidth: function (width, dirty /*, private {Boolean} force */) {\n        var me = this,\n            comp = me.target,\n            frameBody, frameInfo, padding;\n\n        if (width < 0) {\n            width = 0;\n        }\n        if (!me.wrapsComponent) {\n            if (!me.setProp('width', width, dirty)) {\n                return NaN;\n            }\n        } else {\n            width = Ext.Number.constrain(width, comp.minWidth || 0, comp.maxWidth);\n            if (!me.setProp('width', width, dirty)) {\n                return NaN;\n            }\n\n            //if ((frameBody = me.target.frameBody) && (frameBody = me.getEl(frameBody))){\n            frameBody = me.frameBodyContext;\n            if (frameBody) {\n                frameInfo = me.getFrameInfo();\n                frameBody.setWidth(width - frameInfo.width, dirty);\n            }\n\n            /*if (owner.frameMC) {\n                frameContext = ownerContext.frameContext ||\n                        (ownerContext.frameContext = ownerContext.getEl('frameMC'));\n                width += (frameContext.paddingInfo || frameContext.getPaddingInfo()).width;\n            }*/\n        }\n\n        return width;\n    },\n\n    setSize: function (width, height, dirty) {\n        this.setWidth(width, dirty);\n        this.setHeight(height, dirty);\n    },\n\n    translateProps: {\n        x: 'left',\n        y: 'top'\n    },\n\n    undo: function(deep) {\n        var me = this,\n            items, len, i;\n\n        me.revertProps(me.lastBox);\n\n        if (deep && me.wrapsComponent) {\n            // Rollback the state of child Components\n            if (me.childItems) {\n                for (i = 0, items = me.childItems, len = items.length; i < len; i++) {\n                    items[i].undo(deep);\n                }\n            }\n\n            // Rollback the state of child Elements\n            for (i = 0, items = me.children, len = items.length; i < len; i++) {\n                items[i].undo();\n            }\n        }\n    },\n\n    unsetProp: function (propName) {\n        var dirty = this.dirty;\n\n        delete this.props[propName];\n        if (dirty) {\n            delete dirty[propName];\n        }\n    },\n\n    writeProps: function(dirtyProps, flushing) {\n        if (!(dirtyProps && typeof dirtyProps == 'object')) {\n            Ext.Logger.warn('writeProps expected dirtyProps to be an object');\n            return;\n        }\n\n        var me = this,\n            el = me.el,\n            styles = {},\n            styleCount = 0, // used as a boolean, the exact count doesn't matter\n            styleInfo = me.styleInfo,\n            \n            info,\n            propName,\n            numericValue,\n            \n            dirtyX = 'x' in dirtyProps,\n            dirtyY = 'y' in dirtyProps,\n            x = dirtyProps.x,\n            y = dirtyProps.y,\n            \n            width = dirtyProps.width,\n            height = dirtyProps.height,\n            isBorderBox = me.isBorderBoxValue,\n            target = me.target,\n            max = Math.max,\n            paddingWidth = 0,\n            paddingHeight = 0,\n            hasWidth, hasHeight, isAbsolute, scrollbarSize, style, targetEl;\n\n        // Process non-style properties:\n        if ('displayed' in dirtyProps) {\n            el.setDisplayed(dirtyProps.displayed);\n        }\n\n        // Unblock any hard blocks (domBlocks) and copy dom styles into 'styles'\n        for (propName in dirtyProps) {\n            if (flushing) {\n                me.fireTriggers('domTriggers', propName);\n                me.clearBlocks('domBlocks', propName);\n                me.flushedProps[propName] = 1;\n            }\n\n            info = styleInfo[propName];\n            if (info && info.dom) {\n                // Numeric dirty values should have their associated suffix added\n                if (info.suffix && (numericValue = parseInt(dirtyProps[propName], 10))) {\n                    styles[propName] = numericValue + info.suffix;\n                }\n                // Non-numeric (eg \"auto\") go in unchanged.\n                else {\n                    styles[propName] = dirtyProps[propName];\n                }\n                ++styleCount;\n            }\n        }\n\n        // convert x/y into setPosition (for a component) or left/top styles (for an el)\n        if (dirtyX || dirtyY) {\n            if (target.isComponent) {\n                // Ensure we always pass the current coordinate in if one coordinate has not been dirtied by a calculation cycle.\n                target.setPosition(x||me.props.x, y||me.props.y);\n            } else {\n                // we wrap an element, so convert x/y to styles:\n                if (dirtyX) {\n                    styles.left = x + 'px';\n                    ++styleCount;\n                }\n                if (dirtyY) {\n                    styles.top = y + 'px';\n                    ++styleCount;\n                }\n            }\n        }\n\n        // Support for the content-box box model...\n        if (!isBorderBox && (width > 0 || height > 0)) { // no need to subtract from 0\n            // The width and height values assume the border-box box model,\n            // so we must remove the padding & border to calculate the content-box.\n            if (!(me.borderInfo && me.paddingInfo)) {\n                throw Error(\"Needed to have gotten the borderInfo and paddingInfo when the width or height was setProp'd\");\n            }\n            if(!me.frameBodyContext) {\n                // Padding needs to be removed only if the element is not framed.\n                paddingWidth = me.paddingInfo.width;\n                paddingHeight = me.paddingInfo.height;\n            }\n            if (width) {\n                width = max(parseInt(width, 10) - (me.borderInfo.width + paddingWidth), 0);\n                styles.width = width + 'px';\n                ++styleCount;\n            }\n            if (height) {\n                height = max(parseInt(height, 10) - (me.borderInfo.height + paddingHeight), 0);\n                styles.height = height + 'px';\n                ++styleCount;\n            }\n        }\n\n        // IE9 strict subtracts the scrollbar size from the element size when the element\n        // is absolutely positioned and uses box-sizing: border-box. To workaround this\n        // issue we have to add the the scrollbar size.\n        // \n        // See http://social.msdn.microsoft.com/Forums/da-DK/iewebdevelopment/thread/47c5148f-a142-4a99-9542-5f230c78cb3b\n        //\n        if (me.wrapsComponent && Ext.isIE9 && Ext.isStrict) {\n            // when we set a width and we have a vertical scrollbar (overflowY), we need\n            // to add the scrollbar width... conversely for the height and overflowX\n            if ((hasWidth = width !== undefined && me.hasOverflowY) ||\n                (hasHeight = height !== undefined && me.hasOverflowX)) {\n                // check that the component is absolute positioned and border-box:\n                isAbsolute = me.isAbsolute;\n                if (isAbsolute === undefined) {\n                    isAbsolute = false;\n                    targetEl = me.target.getTargetEl();\n                    style = targetEl.getStyle('position');\n\n                    if (style == 'absolute') {\n                        style = targetEl.getStyle('box-sizing');\n                        isAbsolute = (style == 'border-box');\n                    }\n\n                    me.isAbsolute = isAbsolute; // cache it\n                }\n\n                if (isAbsolute) {\n                    scrollbarSize = Ext.getScrollbarSize();\n\n                    if (hasWidth) {\n                        width = parseInt(width, 10) + scrollbarSize.width;\n                        styles.width = width + 'px';\n                        ++styleCount;\n                    }\n                    if (hasHeight) {\n                        height = parseInt(height, 10) + scrollbarSize.height;\n                        styles.height = height + 'px';\n                        ++styleCount;\n                    }\n                }\n            }\n        }\n\n        // we make only one call to setStyle to allow it to optimize itself:\n        if (styleCount) {\n            el.setStyle(styles);\n        }\n    }\n}, function () {\n    \n    var px =    { dom: true, parseInt: true, suffix: 'px' },\n        isDom = { dom: true },\n        faux =  { dom: false };\n\n    // If a property exists in styleInfo, it participates in some way with the DOM. It may\n    // be virtualized (like 'x' and y') and be indirect, but still requires a flush cycle\n    // to reach the DOM. Properties (like 'contentWidth' and 'contentHeight') have no real\n    // presence in the DOM and hence have no flush intanglements.\n    // \n    // For simple styles, the object value on the right contains properties that help in\n    // decoding values read by getStyle and preparing values to pass to setStyle.\n    //\n    this.prototype.styleInfo = {\n        childrenDone:           faux,\n        componentChildrenDone:  faux,\n        containerChildrenDone:  faux,\n        containerLayoutDone:    faux,\n        displayed:              faux,\n        done:                   faux,\n        x:                      faux,\n        y:                      faux,\n\n        // For Ext.grid.ColumnLayout\n        columnWidthsDone:       faux,\n\n        left:                   px,\n        top:                    px,\n        right:                  px,\n        bottom:                 px,\n        width:                  px,\n        height:                 px,\n\n        'border-top-width':     px,\n        'border-right-width':   px,\n        'border-bottom-width':  px,\n        'border-left-width':    px,\n\n        'margin-top':           px,\n        'margin-right':         px,\n        'margin-bottom':        px,\n        'margin-left':          px,\n\n        'padding-top':          px,\n        'padding-right':        px,\n        'padding-bottom':       px,\n        'padding-left':         px,\n\n        'line-height':          isDom,\n        display:                isDom\n    };\n});\n\n/**\n * Manages context information during a layout.\n *\n * # Algorithm\n *\n * This class performs the following jobs:\n *\n *  - Cache DOM reads to avoid reading the same values repeatedly.\n *  - Buffer DOM writes and flush them as a block to avoid read/write interleaving.\n *  - Track layout dependencies so each layout does not have to figure out the source of\n *    its dependent values.\n *  - Intelligently run layouts when the values on which they depend change (a trigger).\n *  - Allow layouts to avoid processing when required values are unavailable (a block).\n *\n * Work done during layout falls into either a \"read phase\" or a \"write phase\" and it is\n * essential to always be aware of the current phase. Most methods in\n * {@link Ext.layout.Layout Layout} are called during a read phase:\n * {@link Ext.layout.Layout#calculate calculate},\n * {@link Ext.layout.Layout#completeLayout completeLayout} and\n * {@link Ext.layout.Layout#finalizeLayout finalizeLayout}. The exceptions to this are\n * {@link Ext.layout.Layout#beginLayout beginLayout},\n * {@link Ext.layout.Layout#beginLayoutCycle beginLayoutCycle} and\n * {@link Ext.layout.Layout#finishedLayout finishedLayout} which are called during\n * a write phase. While {@link Ext.layout.Layout#finishedLayout finishedLayout} is called\n * a write phase, it is really intended to be a catch-all for post-processing after a\n * layout run.\n * \n * In a read phase, it is OK to read the DOM but this should be done using the appropriate\n * {@link Ext.layout.ContextItem ContextItem} where possible since that provides a cache\n * to avoid redundant reads. No writes should be made to the DOM in a read phase! Instead,\n * the values should be written to the proper ContextItem for later write-back.\n * \n * The rules flip-flop in a write phase. The only difference is that ContextItem methods\n * like {@link Ext.layout.ContextItem#getStyle getStyle} will still read the DOM unless the\n * value was previously read. This detail is unknowable from the outside of ContextItem, so\n * read calls to ContextItem should also be avoided in a write phase.\n *\n * Calculating interdependent layouts requires a certain amount of iteration. In a given\n * cycle, some layouts will contribute results that allow other layouts to proceed. The\n * general flow then is to gather all of the layouts (both component and container) in a\n * component tree and queue them all for processing. The initial queue order is bottom-up\n * and component layout first, then container layout (if applicable) for each component.\n *\n * This initial step also calls the beginLayout method on all layouts to clear any values\n * from the DOM that might interfere with calculations and measurements. In other words,\n * this is a \"write phase\" and reads from the DOM should be strictly avoided.\n * \n * Next the layout enters into its iterations or \"cycles\". Each cycle consists of calling\n * the {@link Ext.layout.Layout#calculate calculate} method on all layouts in the\n * {@link #layoutQueue}. These calls are part of a \"read phase\" and writes to the DOM should\n * be strictly avoided.\n *\n * # Considerations\n *\n * **RULE 1**: Respect the read/write cycles. Always use the {@link Ext.layout.ContextItem#getProp getProp}\n * or {@link Ext.layout.ContextItem#getDomProp getDomProp} methods to get calculated values;\n * only use the {@link Ext.layout.ContextItem#getStyle getStyle} method to read styles; use\n * {@link Ext.layout.ContextItem#setProp setProp} to set DOM values. Some reads will, of\n * course, still go directly to the DOM, but if there is a method in\n * {@link Ext.layout.ContextItem ContextItem} to do a certain job, it should be used instead\n * of a lower-level equivalent.\n *\n * The basic logic flow in {@link Ext.layout.Layout#calculate calculate} consists of gathering\n * values by calling {@link Ext.layout.ContextItem#getProp getProp} or\n * {@link Ext.layout.ContextItem#getDomProp getDomProp}, calculating results and publishing\n * them by calling {@link Ext.layout.ContextItem#setProp setProp}. It is important to realize\n * that {@link Ext.layout.ContextItem#getProp getProp} will return `undefined` if the value\n * is not yet known. But the act of calling the method is enough to track the fact that the\n * calling layout depends (in some way) on this value. In other words, the calling layout is\n * \"triggered\" by the properties it requests.\n *\n * **RULE 2**: Avoid calling {@link Ext.layout.ContextItem#getProp getProp} unless the value\n * is needed. Gratuitous calls cause inefficiency because the layout will appear to depend on\n * values that it never actually uses. This applies equally to\n * {@link Ext.layout.ContextItem#getDomProp getDomProp} and the test-only methods\n * {@link Ext.layout.ContextItem#hasProp hasProp} and {@link Ext.layout.ContextItem#hasDomProp hasDomProp}.\n *\n * Because {@link Ext.layout.ContextItem#getProp getProp} can return `undefined`, it is often\n * the case that subsequent math will produce NaN's. This is usually not a problem as the\n * NaN's simply propagate along and result in final results that are NaN. Both `undefined`\n * and NaN are ignored by {@link Ext.layout.ContextItem#setProp}, so it is often not necessary\n * to even know that this is happening. It does become important for determining if a layout\n * is not done or if it might lead to publishing an incorrect (but not NaN or `undefined`)\n * value.\n * \n * **RULE 3**: If a layout has not calculated all the values it is required to calculate, it\n * must set {@link Ext.layout.Layout#done done} to `false` before returning from\n * {@link Ext.layout.Layout#calculate calculate}. This value is always `true` on entry because\n * it is simpler to detect the incomplete state rather than the complete state (especially up\n * and down a class hierarchy).\n * \n * **RULE 4**: A layout must never publish an incomplete (wrong) result. Doing so would cause\n * dependent layouts to run their calculations on those wrong values, producing more wrong\n * values and some layouts may even incorrectly flag themselves as {@link Ext.layout.Layout#done done}\n * before the correct values are determined and republished. Doing this will poison the\n * calculations.\n *\n * **RULE 5**: Each value should only be published by one layout. If multiple layouts attempt\n * to publish the same values, it would be nearly impossible to avoid breaking **RULE 4**. To\n * help detect this problem, the layout diagnostics will trap on an attempt to set a value\n * from different layouts.\n *\n * Complex layouts can produce many results as part of their calculations. These values are\n * important for other layouts to proceed and need to be published by the earliest possible\n * call to {@link Ext.layout.Layout#calculate} to avoid unnecessary cycles and poor performance. It is\n * also possible, however, for some results to be related in a way such that publishing them\n * may be an all-or-none proposition (typically to avoid breaking *RULE 4*).\n * \n * **RULE 6**: Publish results as soon as they are known to be correct rather than wait for\n * all values to be calculated. Waiting for everything to be complete can lead to deadlock.\n * The key here is not to forget **RULE 4** in the process.\n *\n * Some layouts depend on certain critical values as part of their calculations. For example,\n * HBox depends on width and cannot do anything until the width is known. In these cases, it\n * is best to use {@link Ext.layout.ContextItem#block block} or\n * {@link Ext.layout.ContextItem#domBlock domBlock} and thereby avoid processing the layout\n * until the needed value is available.\n *\n * **RULE 7**: Use {@link Ext.layout.ContextItem#block block} or\n * {@link Ext.layout.ContextItem#domBlock domBlock} when values are required to make progress.\n * This will mimize wasted recalculations.\n *\n * **RULE 8**: Blocks should only be used when no forward progress can be made. If even one\n * value could still be calculated, a block could result in a deadlock.\n *\n * Historically, layouts have been invoked directly by component code, sometimes in places\n * like an `afterLayout` method for a child component. With the flexibility now available\n * to solve complex, iterative issues, such things should be done in a responsible layout\n * (be it component or container).\n *\n * **RULE 9**: Use layouts to solve layout issues and don't wait for the layout to finish to\n * perform further layouts. This is especially important now that layouts process entire\n * component trees and not each layout in isolation.\n *\n * # Sequence Diagram\n *\n * The simplest sequence diagram for a layout run looks roughly like this:\n *\n *       Context         Layout 1     Item 1     Layout 2     Item 2\n *          |               |           |           |           |\n *     ---->X-------------->X           |           |           |\n *     run  X---------------|-----------|---------->X           |\n *          X beginLayout   |           |           |           |\n *          X               |           |           |           |\n *        A X-------------->X           |           |           |\n *          X  calculate    X---------->X           |           |\n *          X             C X  getProp  |           |           |\n *        B X               X---------->X           |           |\n *          X               |  setProp  |           |           |\n *          X               |           |           |           |\n *        D X---------------|-----------|---------->X           |\n *          X  calculate    |           |           X---------->X\n *          X               |           |           |  setProp  |\n *        E X               |           |           |           |\n *          X---------------|-----------|---------->X           |\n *          X completeLayout|           |         F |           |\n *          X               |           |           |           |\n *        G X               |           |           |           |\n *        H X-------------->X           |           |           |\n *          X  calculate    X---------->X           |           |\n *          X             I X  getProp  |           |           |\n *          X               X---------->X           |           |\n *          X               |  setProp  |           |           |\n *        J X-------------->X           |           |           |\n *          X completeLayout|           |           |           |\n *          X               |           |           |           |\n *        K X-------------->X           |           |           |\n *          X---------------|-----------|---------->X           |\n *          X finalizeLayout|           |           |           |\n *          X               |           |           |           |\n *        L X-------------->X           |           |           |\n *          X---------------|-----------|---------->X           |\n *          X finishedLayout|           |           |           |\n *          X               |           |           |           |\n *        M X-------------->X           |           |           |\n *          X---------------|-----------|---------->X           |\n *          X notifyOwner   |           |           |           |\n *        N |               |           |           |           |\n *          -               -           -           -           -\n *\n *\n * Notes:\n *\n * **A.** This is a call from the {@link #run} method to the {@link #runCycle} method.\n * Each layout in the queue will have its {@link Ext.layout.Layout#calculate calculate}\n * method called.\n *\n * **B.** After each {@link Ext.layout.Layout#calculate calculate} method is called the\n * {@link Ext.layout.Layout#done done} flag is checked to see if the Layout has completed.\n * If it has completed and that layout object implements a\n * {@link Ext.layout.Layout#completeLayout completeLayout} method, this layout is queued to\n * receive its call. Otherwise, the layout will be queued again unless there are blocks or\n * triggers that govern its requeueing.\n * \n * **C.** The call to {@link Ext.layout.ContextItem#getProp getProp} is made to the Item\n * and that will be tracked as a trigger (keyed by the name of the property being requested).\n * Changes to this property will cause this layout to be requeued. The call to\n * {@link Ext.layout.ContextItem#setProp setProp} will place a value in the item and not\n * directly into the DOM.\n * \n * **D.** Call the other layouts now in the first cycle (repeat **B** and **C** for each\n * layout).\n * \n * **E.** After completing a cycle, if progress was made (new properties were written to\n * the context) and if the {@link #layoutQueue} is not empty, the next cycle is run. If no\n * progress was made or no layouts are ready to run, all buffered values are written to\n * the DOM (a flush).\n *\n * **F.** After flushing, any layouts that were marked as {@link Ext.layout.Layout#done done}\n * that also have a {@link Ext.layout.Layout#completeLayout completeLayout} method are called.\n * This can cause them to become no longer done (see {@link #invalidate}). As with\n * {@link Ext.layout.Layout#calculate calculate}, this is considered a \"read phase\" and\n * direct DOM writes should be avoided.\n * \n * **G.** Flushing and calling any pending {@link Ext.layout.Layout#completeLayout completeLayout}\n * methods will likely trigger layouts that called {@link Ext.layout.ContextItem#getDomProp getDomProp}\n * and unblock layouts that have called {@link Ext.layout.ContextItem#domBlock domBlock}.\n * These variants are used when a layout needs the value to be correct in the DOM and not\n * simply known. If this does not cause at least one layout to enter the queue, we have a\n * layout FAILURE. Otherwise, we continue with the next cycle.\n * \n * **H.** Call {@link Ext.layout.Layout#calculate calculate} on any layouts in the queue\n * at the start of this cycle. Just a repeat of **B** through **G**.\n * \n * **I.** Once the layout has calculated all that it is resposible for, it can leave itself\n * in the {@link Ext.layout.Layout#done done} state. This is the value on entry to\n * {@link Ext.layout.Layout#calculate calculate} and must be cleared in that call if the\n * layout has more work to do.\n * \n * **J.** Now that all layouts are done, flush any DOM values and\n * {@link Ext.layout.Layout#completeLayout completeLayout} calls. This can again cause\n * layouts to become not done, and so we will be back on another cycle if that happens.\n * \n * **K.** After all layouts are done, call the {@link Ext.layout.Layout#finalizeLayout finalizeLayout}\n * method on any layouts that have one. As with {@link Ext.layout.Layout#completeLayout completeLayout},\n * this can cause layouts to become no longer done. This is less desirable than using\n * {@link Ext.layout.Layout#completeLayout completeLayout} because it will cause all\n * {@link Ext.layout.Layout#finalizeLayout finalizeLayout} methods to be called again\n * when we think things are all wrapped up.\n *\n * **L.** After finishing the last iteration, layouts that have a\n * {@link Ext.layout.Layout#finishedLayout finishedLayout} method will be called. This\n * call will only happen once per run and cannot cause layouts to be run further.\n *\n * **M.** After calling finahedLayout, layouts that have a\n * {@link Ext.layout.Layout#notifyOwner notifyOwner} method will be called. This\n * call will only happen once per run and cannot cause layouts to be run further.\n *\n * **N.** One last flush to make sure everything has been written to the DOM.\n *\n * # Inter-Layout Collaboration\n * \n * Many layout problems require collaboration between multiple layouts. In some cases, this\n * is as simple as a component's container layout providing results used by its component\n * layout or vise-versa. A slightly more distant collaboration occurs in a box layout when\n * stretchmax is used: the child item's component layout provides results that are consumed\n * by the ownerCt's box layout to determine the size of the children.\n *\n * The various forms of interdependence between a container and its children are described by\n * each components' {@link Ext.AbstractComponent#getSizeModel size model}.\n *\n * To facilitate this collaboration, the following pairs of properties are published to the\n * component's {@link Ext.layout.ContextItem ContextItem}:\n *\n *  - width/height: These hold the final size of the component. The layout indicated by the\n *    {@link Ext.AbstractComponent#getSizeModel size model} is responsible for setting these.\n *  - contentWidth/contentHeight: These hold size information published by the container\n *    layout or from DOM measurement. These describe the content only. These values are\n *    used by the component layout to determine the outer width/height when that component\n *    is {@link Ext.AbstractComponent#shrinkWrap shrink-wrapped}. They are also used to\n *    determine overflow. All container layouts must publish these values for dimensions\n *    that are shrink-wrapped. If a component has raw content (not container items), the\n *    componentLayout must publish these values instead.\n * \n * @protected\n */\nExt.define('Ext.layout.Context', {\n    requires: [\n        'Ext.util.Queue',\n        'Ext.layout.ContextItem',\n        'Ext.layout.Layout',\n        'Ext.fx.Anim',\n        'Ext.fx.Manager'\n    ],\n\n    remainingLayouts: 0,\n\n    /**\n     * @property {Number} state One of these values:\n     *\n     *  - 0 - Before run\n     *  - 1 - Running\n     *  - 2 - Run complete\n     */\n    state: 0,\n\n    constructor: function (config) {\n        var me = this;\n\n        Ext.apply(me, config);\n\n        // holds the ContextItem collection, keyed by element id\n        me.items = {};\n\n        // a collection of layouts keyed by layout id\n        me.layouts = {};\n\n        // the number of blocks of any kind:\n        me.blockCount = 0;\n        // the number of cycles that have been run:\n        me.cycleCount = 0;\n        // the number of flushes to the DOM:\n        me.flushCount = 0;\n        // the number of layout calculate calls:\n        me.calcCount = 0;\n\n        me.animateQueue = me.newQueue();\n        me.completionQueue = me.newQueue();\n        me.finalizeQueue = me.newQueue();\n        me.finishQueue = me.newQueue();\n        me.flushQueue = me.newQueue();\n\n        me.invalidateData = {};\n\n        /**\n         * @property {Ext.util.Queue} layoutQueue\n         * List of layouts to perform.\n         */\n        me.layoutQueue = me.newQueue();\n\n        // this collection is special because we ensure that there are no parent/child pairs\n        // present, only distinct top-level components\n        me.invalidQueue = [];\n\n        me.triggers = {\n            data: {\n                /*\n                layoutId: [\n                    { item: contextItem, prop: propertyName }\n                ]\n                */\n            },\n            dom: {}\n        };\n    },\n\n    callLayout: function (layout, methodName) {\n        this.currentLayout = layout;\n        layout[methodName](this.getCmp(layout.owner));\n    },\n\n    cancelComponent: function (comp, isChild, isDestroying) {\n        var me = this,\n            components = comp,\n            isArray = !comp.isComponent,\n            length = isArray ? components.length : 1,\n            i, k, klen, items, layout, newQueue, oldQueue, entry, temp,\n            ownerCtContext;\n\n        for (i = 0; i < length; ++i) {\n            if (isArray) {\n                comp = components[i];\n            }\n\n            // If the component is being destroyed, remove the component's ContextItem from its parent's contextItem.childItems array\n            if (isDestroying && comp.ownerCt) {\n                ownerCtContext = this.items[comp.ownerCt.el.id];\n                if (ownerCtContext) {\n                    Ext.Array.remove(ownerCtContext.childItems, me.getCmp(comp));\n                }\n            }\n\n            if (!isChild) {\n                oldQueue = me.invalidQueue;\n                klen = oldQueue.length;\n\n                if (klen) {\n                    me.invalidQueue = newQueue = [];\n                    for (k = 0; k < klen; ++k) {\n                        entry = oldQueue[k];\n                        temp = entry.item.target;\n                        if (temp != comp && !temp.isDescendant(comp)) {\n                            newQueue.push(entry);\n                        }\n                    }\n                }\n            }\n\n            layout = comp.componentLayout;\n            me.cancelLayout(layout);\n\n            if (layout.getLayoutItems) {\n                items = layout.getLayoutItems();\n                if (items.length) {\n                    me.cancelComponent(items, true);\n                }\n            }\n\n            if (comp.isContainer && !comp.collapsed) {\n                layout = comp.layout;\n                me.cancelLayout(layout);\n\n                items = layout.getVisibleItems();\n                if (items.length) {\n                    me.cancelComponent(items, true);\n                }\n            }\n        }\n    },\n\n    cancelLayout: function (layout) {\n        var me = this;\n\n        me.completionQueue.remove(layout);\n        me.finalizeQueue.remove(layout);\n        me.finishQueue.remove(layout);\n        me.layoutQueue.remove(layout);\n\n        if (layout.running) {\n            me.layoutDone(layout);\n        }\n\n        layout.ownerContext = null;\n    },\n\n    clearTriggers: function (layout, inDom) {\n        var id = layout.id,\n            collection = this.triggers[inDom ? 'dom' : 'data'],\n            triggers = collection && collection[id],\n            length = (triggers && triggers.length) || 0,\n            collection, i, item, trigger;\n\n        for (i = 0; i < length; ++i) {\n            trigger = triggers[i];\n            item = trigger.item;\n\n            collection = inDom ? item.domTriggers : item.triggers;\n            delete collection[trigger.prop][id];\n        }\n    },\n\n    /**\n     * Flushes any pending writes to the DOM by calling each ContextItem in the flushQueue.\n     */\n    flush: function () {\n        var me = this,\n            items = me.flushQueue.clear(),\n            length = items.length, i;\n\n        if (length) {\n            ++me.flushCount;\n\n            for (i = 0; i < length; ++i) {\n                items[i].flush();\n            }\n        }\n    },\n\n    flushAnimations: function() {\n        var me = this,\n            items = me.animateQueue.clear(),\n            len = items.length,\n            i;\n\n        if (len) {\n            for (i = 0; i < len; i++) {\n                // Each Component may refuse to participate in animations.\n                // This is used by the BoxReorder plugin which drags a Component,\n                // during which that Component must be exempted from layout positioning.\n                if (items[i].target.animate !== false) {\n                    items[i].flushAnimations();\n                }\n            }\n\n            // Ensure the first frame fires now to avoid a browser repaint with the elements in the \"to\" state\n            // before they are returned to their \"from\" state by the animation.\n            Ext.fx.Manager.runner();\n        }\n    },\n\n    flushInvalidates: function () {\n        var me = this,\n            queue = me.invalidQueue,\n            length = queue && queue.length,\n            comp, components, entry, i;\n\n        me.invalidQueue = [];\n\n        if (length) {\n            components = [];\n            for (i = 0; i < length; ++i) {\n                comp = (entry = queue[i]).item.target;\n                // we filter out-of-body components here but allow them into the queue to\n                // ensure that their child components are coalesced out (w/no additional\n                // cost beyond our normal effort to avoid parent/child components in the\n                // queue)\n                if (!comp.container.isDetachedBody) {\n                    components.push(comp);\n\n                    if (entry.options) {\n                        me.invalidateData[comp.id] = entry.options;\n                    }\n                }\n            }\n\n            me.invalidate(components, null);\n        }\n    },\n\n    flushLayouts: function (queueName, methodName, dontClear) {\n        var me = this,\n            layouts = dontClear ? me[queueName].items : me[queueName].clear(),\n            length = layouts.length,\n            i, layout;\n\n        if (length) {\n            for (i = 0; i < length; ++i) {\n                layout = layouts[i];\n                if (!layout.running) {\n                    me.callLayout(layout, methodName);\n                }\n            }\n            me.currentLayout = null;\n        }\n    },\n\n    /**\n     * Returns the ContextItem for a component.\n     * @param {Ext.Component} cmp\n     */\n    getCmp: function (cmp) {\n        return this.getItem(cmp, cmp.el);\n    },\n\n    /**\n     * Returns the ContextItem for an element.\n     * @param {Ext.layout.ContextItem} parent\n     * @param {Ext.dom.Element} el\n     */\n    getEl: function (parent, el) {\n        var item = this.getItem(el, el);\n\n        if (!item.parent) {\n            item.parent = parent;\n\n            // all items share an empty children array (to avoid null checks), so we can\n            // only push on to the children array if there is already something there (we\n            // copy-on-write):\n            if (parent.children.length) {\n                parent.children.push(item);\n            } else {\n                parent.children = [ item ]; // now parent has its own children[] (length=1)\n            }\n        }\n\n        return item;\n    },\n\n    getItem: function (target, el) {\n        var id = el.id,\n            items = this.items,\n            item = items[id] ||\n                  (items[id] = new Ext.layout.ContextItem({\n                                    context: this,\n                                    target: target,\n                                    el: el\n                                }));\n\n        return item;\n    },\n\n    handleFailure: function () {\n        // This method should never be called, but is need when layouts fail (hence the\n        // \"should never\"). We just disconnect any of the layouts from the run and return\n        // them to the state they would be in had the layout completed properly.\n        var layouts = this.layouts,\n            layout, key;\n\n        Ext.failedLayouts = (Ext.failedLayouts || 0) + 1;\n        Ext.log('Layout run failed');\n\n        for (key in layouts) {\n            layout = layouts[key];\n\n            if (layouts.hasOwnProperty(key)) {\n                layout.running      = false;\n                layout.ownerContext = null;\n            }\n        }\n    },\n\n    /**\n     * Invalidates one or more components' layouts (component and container). This can be\n     * called before run to identify the components that need layout or during the run to\n     * restart the layout of a component. This is called internally to flush any queued\n     * invalidations at the start of a cycle. If called during a run, it is not expected\n     * that new components will be introduced to the layout.\n     * \n     * @param {Ext.Component/Array} components An array of Components or a single Component.\n     * @param {Ext.layout.ContextItem} ownerCtContext The ownerCt's ContextItem.\n     * @param {Boolean} full True if all properties should be invalidated, otherwise only\n     *  those calculated by the component should be invalidated.\n     */\n    invalidate: function (components, full) {\n        var me = this,\n            isArray = !components.isComponent,\n            componentChildrenDone, containerChildrenDone, containerLayoutDone,\n            firstTime, i, comp, item, items, length, componentLayout, layout,\n            invalidateOptions, token;\n\n        for (i = 0, length = isArray ? components.length : 1; i < length; ++i) {\n            comp = isArray ? components[i] : components;\n\n            if (comp.rendered && !comp.hidden) {\n                item = me.getCmp(comp);\n                componentLayout = comp.componentLayout;\n                firstTime = !componentLayout.ownerContext;\n                layout = (comp.isContainer && !comp.collapsed) ? comp.layout : null;\n\n                // Extract any invalidate() options for this item.\n                invalidateOptions = me.invalidateData[item.id];\n                delete me.invalidateData[item.id];\n\n                // We invalidate the contextItem's in a top-down manner so that SizeModel\n                // info for containers is available to their children. This is a critical\n                // optimization since sizeModel determination often requires knowing the\n                // sizeModel of the ownerCt. If this weren't cached as we descend, this\n                // would be an O(N^2) operation! (where N=number of components, or 300+/-\n                // in Themes)\n                token = item.init(full, invalidateOptions);\n\n                if (invalidateOptions) {\n                    me.processInvalidate(invalidateOptions, item, 'before');\n                }\n\n                // Allow the component layout a chance to effect its size model before we\n                // recurse down the component hierarchy (since children need to know the\n                // size model of their ownerCt).\n                if (componentLayout.beforeLayoutCycle) {\n                    componentLayout.beforeLayoutCycle(item);\n                }\n\n                // Finish up the item-level processing that is based on the size model of\n                // the component.\n                token = item.initContinue(token);\n\n                // Start these state variables at true, since that is the value we want if\n                // they do not apply (i.e., no work of this kind on which to wait).\n                componentChildrenDone = containerChildrenDone = containerLayoutDone = true;\n\n                // A ComponentLayout MUST implement getLayoutItems to allow its children\n                // to be collected. Ext.container.Container does this, but non-Container\n                // Components which manage Components as part of their structure (e.g.,\n                // HtmlEditor) must still return child Components via getLayoutItems.\n                if (componentLayout.getLayoutItems) {\n                    componentLayout.renderChildren();\n\n                    items = componentLayout.getLayoutItems();\n                    if (items.length) {\n                        me.invalidate(items, true);\n                        componentChildrenDone = false;\n                    }\n                }\n\n                if (layout) {\n                    containerLayoutDone = false;\n                    layout.renderChildren();\n\n                    items = layout.getVisibleItems();\n                    if (items.length) {\n                        me.invalidate(items, true);\n                        containerChildrenDone = false;\n                    }\n                }\n\n                // Finish the processing that requires the size models of child items to\n                // be determined (and some misc other stuff).\n                item.initDone(token, componentChildrenDone, containerChildrenDone,\n                              containerLayoutDone);\n\n                // Inform the layouts that we are about to begin (or begin again) now that\n                // the size models of the component and its children are setup.\n                me.resetLayout(componentLayout, item, firstTime);\n                if (layout) {\n                    me.resetLayout(layout, item, firstTime);\n                }\n\n                // This has to occur after the component layout has had a chance to begin\n                // so that we can determine what kind of animation might be needed. TODO-\n                // move this determination into the layout itself.\n                item.initAnimation();\n\n                if (invalidateOptions) {\n                    me.processInvalidate(invalidateOptions, item, 'after');\n                }\n            }\n        }\n\n        me.currentLayout = null;\n    },\n\n    layoutDone: function (layout) {\n        var ownerContext = layout.ownerContext,\n            ownerCtContext;\n\n        layout.running = false;\n\n        // Once a component layout completes, we can mark it as \"done\" but we can also\n        // decrement the remainingChildLayouts property on the ownerCtContext. When that\n        // goes to 0, we can mark the ownerCtContext as \"childrenDone\".\n        if (layout.isComponentLayout) {\n            if (ownerContext.measuresBox) {\n                ownerContext.onBoxMeasured(); // be sure to release our boxParent\n            }\n\n            ownerContext.setProp('done', true);\n\n            ownerCtContext = ownerContext.ownerCtContext;\n            if (ownerCtContext) {\n                if (ownerContext.target.ownerLayout.isComponentLayout) {\n                    if (! --ownerCtContext.remainingComponentChildLayouts) {\n                        ownerCtContext.setProp('componentChildrenDone', true);\n                    }\n                } else {\n                    if (! --ownerCtContext.remainingContainerChildLayouts) {\n                        ownerCtContext.setProp('containerChildrenDone', true);\n                    }\n                }\n                if (! --ownerCtContext.remainingChildLayouts) {\n                    ownerCtContext.setProp('childrenDone', true);\n                }\n            }\n        } else {\n            ownerContext.setProp('containerLayoutDone', true);\n        }\n\n        --this.remainingLayouts;\n        ++this.progressCount; // a layout completion is progress\n    },\n\n    newQueue: function () {\n        return new Ext.util.Queue();\n    },\n\n    processInvalidate: function (options, item, name) {\n        // When calling a callback, the currentLayout needs to be adjusted so\n        // that whichever layout caused the invalidate is the currentLayout...\n        if (options[name]) {\n            var me = this,\n                currentLayout = me.currentLayout;\n\n            me.currentLayout = options.layout || null;\n\n            options[name](item, options);\n\n            me.currentLayout = currentLayout;\n        }\n    },\n\n    /**\n     * Queues a ContextItem to have its {@link Ext.layout.ContextItem#flushAnimations} method called.\n     *\n     * @param {Ext.layout.ContextItem} item\n     * @private\n     */\n    queueAnimation: function (item) {\n        this.animateQueue.add(item);\n    },\n\n    /**\n     * Queues a layout to have its {@link Ext.layout.Layout#completeLayout} method called.\n     *\n     * @param {Ext.layout.Layout} layout\n     * @private\n     */\n    queueCompletion: function (layout) {\n        this.completionQueue.add(layout);\n    },\n\n    /**\n     * Queues a layout to have its {@link Ext.layout.Layout#finalizeLayout} method called.\n     *\n     * @param {Ext.layout.Layout} layout\n     * @private\n     */\n    queueFinalize: function (layout) {\n        this.finalizeQueue.add(layout);\n    },\n\n    /**\n     * Queues a ContextItem for the next flush to the DOM. This should only be called by\n     * the {@link Ext.layout.ContextItem} class.\n     *\n     * @param {Ext.layout.ContextItem} item\n     * @private\n     */\n    queueFlush: function (item) {\n        this.flushQueue.add(item);\n    },\n\n    chainFns: function (oldOptions, newOptions, funcName) {\n        var me = this,\n            oldLayout = oldOptions.layout,\n            newLayout = newOptions.layout,\n            oldFn = oldOptions[funcName],\n            newFn = newOptions[funcName];\n\n        // Call newFn last so it can get the final word on things... also, the \"this\"\n        // pointer will be passed correctly by createSequence with oldFn first.\n        return function (contextItem) {\n            var prev = me.currentLayout;\n            if (oldFn) {\n                me.currentLayout = oldLayout;\n                oldFn.call(oldOptions.scope || oldOptions, contextItem, oldOptions);\n            }\n            me.currentLayout = newLayout;\n            newFn.call(newOptions.scope || newOptions, contextItem, newOptions);\n            me.currentLayout = prev;\n        };\n    },\n\n    /**\n     * Queue a component (and its tree) to be invalidated on the next cycle.\n     *\n     * @param {Ext.Component/Ext.layout.ContextItem} item The component or ContextItem to invalidate.\n     * @param {Object} options An object describing how to handle the invalidation (see\n     *  {@link Ext.layout.ContextItem#invalidate} for details).\n     * @private\n     */\n    queueInvalidate: function (item, options) {\n        var me = this,\n            newQueue = [],\n            oldQueue = me.invalidQueue,\n            index = oldQueue.length,\n            comp, old, oldComp, oldOptions, oldState;\n\n        if (item.isComponent) {\n            item = me.getCmp(comp = item);\n        } else {\n            comp = item.target;\n        }\n\n        item.invalid = true;\n\n        // See if comp is contained by any component already in the queue (ignore comp if\n        // that is the case). Eliminate any components in the queue that are contained by\n        // comp (by not adding them to newQueue).\n        while (index--) {\n            old = oldQueue[index];\n            oldComp = old.item.target;\n\n            if (comp.isDescendant(oldComp)) {\n                return; // oldComp contains comp, so this invalidate is redundant\n            }\n\n            if (oldComp == comp) {\n                // if already in the queue, update the options...\n                if (!(oldOptions = old.options)) {\n                    old.options = options;\n                } else if (options) {\n                    if (options.widthModel) {\n                        oldOptions.widthModel = options.widthModel;\n                    }\n                    if (options.heightModel) {\n                        oldOptions.heightModel = options.heightModel;\n                    }\n                    if (!(oldState = oldOptions.state)) {\n                        oldOptions.state = options.state;\n                    } else if (options.state) {\n                        Ext.apply(oldState, options.state);\n                    }\n\n                    if (options.before) {\n                        oldOptions.before = me.chainFns(oldOptions, options, 'before');\n                    }\n                    if (options.after) {\n                        oldOptions.after = me.chainFns(oldOptions, options, 'after');\n                    }\n                }\n\n                // leave the old queue alone now that we've update this comp's entry...\n                return;\n            }\n\n            if (!oldComp.isDescendant(comp)) {\n                newQueue.push(old); // comp does not contain oldComp\n            }\n            // else if (oldComp isDescendant of comp) skip\n        }\n        // newQueue contains only those components not a descendant of comp\n\n        // to get here, comp must not be a child of anything already in the queue, so it\n        // needs to be added along with its \"options\":\n        newQueue.push({ item: item, options: options });\n\n        me.invalidQueue = newQueue;\n    },\n\n    queueItemLayouts: function (item) {\n        var comp = item.isComponent ? item : item.target,\n            layout = comp.componentLayout;\n\n        if (!layout.pending && !layout.invalid && !layout.done) {\n            this.queueLayout(layout);\n        }\n\n        layout = comp.layout;\n        if (layout && !layout.pending && !layout.invalid && !layout.done) {\n            this.queueLayout(layout);\n        }\n    },\n\n    /**\n     * Queues a layout for the next calculation cycle. This should not be called if the\n     * layout is done, blocked or already in the queue. The only classes that should call\n     * this method are this class and {@link Ext.layout.ContextItem}.\n     *\n     * @param {Ext.layout.Layout} layout The layout to add to the queue.\n     * @private\n     */\n    queueLayout: function (layout) {\n        this.layoutQueue.add(layout);\n        layout.pending = true;\n    },\n\n    /**\n     * Resets the given layout object. This is called at the start of the run and can also\n     * be called during the run by calling {@link #invalidate}.\n     */\n    resetLayout: function (layout, ownerContext, firstTime) {\n        var me = this,\n            ownerCtContext;\n\n        me.currentLayout = layout;\n\n        layout.done = false;\n        layout.pending = true;\n        layout.firedTriggers = 0;\n\n        me.layoutQueue.add(layout);\n\n        if (firstTime) {\n            me.layouts[layout.id] = layout; // track the layout for this run by its id\n            layout.running = true;\n\n            if (layout.finishedLayout) {\n                me.finishQueue.add(layout);\n            }\n\n            // reset or update per-run counters:\n\n            ++me.remainingLayouts;\n            ++layout.layoutCount; // the number of whole layouts run for the layout\n\n            layout.ownerContext = ownerContext;\n            layout.beginCount = 0; // the number of beginLayout calls\n            layout.blockCount = 0; // the number of blocks set for the layout\n            layout.calcCount = 0; // the number of times calculate is called\n            layout.triggerCount = 0; // the number of triggers set for the layout\n\n            // Count the children of each ownerCt so we can tell when they are all done:\n            if (layout.isComponentLayout && (ownerCtContext = ownerContext.ownerCtContext)) {\n                // This layout's ownerCt is in this run... The component associated with\n                // this layout (the \"target\") could be owned by the ownerCt's container\n                // layout or component layout (e.g. docked items)! To manage this, we keep\n                // two counters for these and one for the combined total:\n                if (ownerContext.target.ownerLayout.isComponentLayout) {\n                    ++ownerCtContext.remainingComponentChildLayouts;\n                } else {\n                    ++ownerCtContext.remainingContainerChildLayouts;\n                }\n                ++ownerCtContext.remainingChildLayouts;\n            }\n\n            if (!layout.initialized) {\n                layout.initLayout();\n            }\n\n            layout.beginLayout(ownerContext);\n        } else {\n            ++layout.beginCount;\n\n            if (!layout.running) {\n                // back into the mahem with this one:\n                ++me.remainingLayouts;\n                layout.running = true;\n\n                if (layout.isComponentLayout) {\n                    // this one is fun... if we call setProp('done', false) that would still\n                    // trigger/unblock layouts, but what layouts are really looking for with\n                    // this property is for it to go to true, not just be set to a value...\n                    ownerContext.unsetProp('done');\n\n                    // On subsequent resets we increment the child layout count properties\n                    // on ownerCtContext and clear 'childrenDone' and the appropriate other\n                    // indicator as we transition to 1:\n                    ownerCtContext = ownerContext.ownerCtContext;\n                    if (ownerCtContext) {\n                        if (ownerContext.target.ownerLayout.isComponentLayout) {\n                            if (++ownerCtContext.remainingComponentChildLayouts == 1) {\n                                ownerCtContext.unsetProp('componentChildrenDone');\n                            }\n                        } else {\n                            if (++ownerCtContext.remainingContainerChildLayouts == 1) {\n                                ownerCtContext.unsetProp('containerChildrenDone');\n                            }\n                        }\n                        if (++ownerCtContext.remainingChildLayouts == 1) {\n                            ownerCtContext.unsetProp('childrenDone');\n                        }\n                    }\n                }\n\n                // and it needs to be removed from the completion and/or finalize queues...\n                me.completionQueue.remove(layout);\n                me.finalizeQueue.remove(layout);\n            }\n        }\n\n        layout.beginLayoutCycle(ownerContext, firstTime);\n    },\n\n    /**\n     * Runs the layout calculations. This can be called only once on this object.\n     * @return {Boolean} True if all layouts were completed, false if not.\n     */\n    run: function () {\n        var me = this,\n            flushed = false,\n            watchDog = 100;\n\n        me.flushInvalidates();\n\n        me.state = 1;\n        me.totalCount = me.layoutQueue.getCount();\n\n        // We may start with unflushed data placed by beginLayout calls. Since layouts may\n        // use setProp as a convenience, even in a write phase, we don't want to transition\n        // to a read phase with unflushed data since we can write it now \"cheaply\". Also,\n        // these value could easily be needed in the DOM in order to really get going with\n        // the calculations. In particular, fixed (configured) dimensions fall into this\n        // category.\n        me.flush();\n\n        // While we have layouts that have not completed...\n        while ((me.remainingLayouts || me.invalidQueue.length) && watchDog--) {\n            if (me.invalidQueue.length) {\n                me.flushInvalidates();\n            }\n\n            // if any of them can run right now, run them\n            if (me.runCycle()) {\n                flushed = false; // progress means we probably need to flush something\n                // but not all progress appears in the flushQueue (e.g. 'contentHeight')\n            } else if (!flushed) {\n                // as long as we are making progress, flush updates to the DOM and see if\n                // that triggers or unblocks any layouts...\n                me.flush();\n                flushed = true; // all flushed now, so more progress is required\n\n                me.flushLayouts('completionQueue', 'completeLayout');\n            } else {\n                // after a flush, we must make progress or something is WRONG\n                me.state = 2;\n                break;\n            }\n\n            if (!(me.remainingLayouts || me.invalidQueue.length)) {\n                me.flush();\n                me.flushLayouts('completionQueue', 'completeLayout');\n                me.flushLayouts('finalizeQueue', 'finalizeLayout');\n            }\n        }\n\n        return me.runComplete();\n    },\n\n    runComplete: function () {\n        var me = this;\n\n        me.state = 2;\n\n        if (me.remainingLayouts) {\n            me.handleFailure();\n            return false;\n        }\n\n        me.flush();\n\n        // Call finishedLayout on all layouts, but do not clear the queue.\n        me.flushLayouts('finishQueue', 'finishedLayout', true);\n\n        // Call notifyOwner on all layouts and then clear the queue.\n        me.flushLayouts('finishQueue', 'notifyOwner');\n\n        me.flush(); // in case any setProp calls were made\n\n        me.flushAnimations();\n\n        return true;\n    },\n\n    /**\n     * Performs one layout cycle by calling each layout in the layout queue.\n     * @return {Boolean} True if some progress was made, false if not.\n     * @protected\n     */\n    runCycle: function () {\n        var me = this,\n            layouts = me.layoutQueue.clear(),\n            length = layouts.length,\n            i;\n\n        ++me.cycleCount;\n\n        // This value is incremented by ContextItem#setProp whenever new values are set\n        // (thereby detecting forward progress):\n        me.progressCount = 0;\n\n        for (i = 0; i < length; ++i) {\n            me.runLayout(me.currentLayout = layouts[i]);\n        }\n\n        me.currentLayout = null;\n\n        return me.progressCount > 0;\n    },\n\n    /**\n     * Runs one layout as part of a cycle.\n     * @private\n     */\n    runLayout: function (layout) {\n        var me = this,\n            ownerContext = me.getCmp(layout.owner);\n\n        layout.pending = false;\n\n        if (ownerContext.state.blocks) {\n            return;\n        }\n\n        // We start with the assumption that the layout will finish and if it does not, it\n        // must clear this flag. It turns out this is much simpler than knowing when a layout\n        // is done (100% correctly) when base classes and derived classes are collaborating.\n        // Knowing that some part of the layout is not done is much more obvious.\n        layout.done = true;\n\n        ++layout.calcCount;\n        ++me.calcCount;\n\n        layout.calculate(ownerContext);\n\n        if (layout.done) {\n            me.layoutDone(layout);\n\n            if (layout.completeLayout) {\n                me.queueCompletion(layout);\n            }\n            if (layout.finalizeLayout) {\n                me.queueFinalize(layout);\n            }\n        } else if (!layout.pending && !layout.invalid && !(layout.blockCount + layout.triggerCount - layout.firedTriggers)) {\n            // A layout that is not done and has no blocks or triggers that will queue it\n            // automatically, must be queued now:\n            me.queueLayout(layout);\n        }\n    },\n\n    /**\n     * Set the size of a component, element or composite or an array of components or elements.\n     * @param {Ext.Component/Ext.Component[]/Ext.dom.Element/Ext.dom.Element[]/Ext.dom.CompositeElement}\n     * The item(s) to size.\n     * @param {Number} width The new width to set (ignored if undefined or NaN).\n     * @param {Number} height The new height to set (ignored if undefined or NaN).\n     */\n    setItemSize: function(item, width, height) {\n        var items = item,\n            len = 1,\n            contextItem, i;\n\n        // NOTE: we don't pre-check for validity because:\n        //  - maybe only one dimension is valid\n        //  - the diagnostics layer will track the setProp call to help find who is trying\n        //      (but failing) to set a property\n        //  - setProp already checks this anyway\n\n        if (item.isComposite) {\n            items = item.elements;\n            len = items.length;\n            item = items[0];\n        } else if (!item.dom && !item.el) { // array by process of elimination\n            len = items.length;\n            item = items[0];\n        }\n        // else len = 1 and items = item (to avoid error on \"items[++i]\")\n\n        for (i = 0; i < len; ) {\n            contextItem = this.get(item);\n            contextItem.setSize(width, height);\n\n            item = items[++i]; // this accomodation avoids making an array of 1\n        }\n    }\n});\n\n/**\n * Component layout for tabs\n * @private\n */\nExt.define('Ext.layout.component.Tab', {\n\n    extend: 'Ext.layout.component.Button',\n    alias: 'layout.tab',\n\n    beginLayout: function(ownerContext) {\n        var me = this,\n            closable = me.owner.closable;\n\n        // Changing the close button visibility causes our cached measurements to be wrong,\n        // so we must convince our base class to re-cache those adjustments...\n        if (me.lastClosable !== closable) {\n            me.lastClosable = closable;\n            me.clearTargetCache();\n        }\n\n        me.callParent(arguments);\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.layout.component.field.Slider', {\n\n    /* Begin Definitions */\n\n    alias: ['layout.sliderfield'],\n\n    extend: 'Ext.layout.component.field.Field',\n\n    /* End Definitions */\n\n    type: 'sliderfield',\n\n    beginLayout: function(ownerContext) {\n        this.callParent(arguments);\n\n        ownerContext.endElContext   = ownerContext.getEl('endEl');\n        ownerContext.innerElContext = ownerContext.getEl('innerEl');\n        ownerContext.bodyElContext  = ownerContext.getEl('bodyEl');\n    },\n\n    publishInnerHeight: function (ownerContext, height) {\n        var innerHeight = height - this.measureLabelErrorHeight(ownerContext),\n            endElPad,\n            inputPad;\n        if (this.owner.vertical) {\n            endElPad = ownerContext.endElContext.getPaddingInfo();\n            inputPad = ownerContext.inputContext.getPaddingInfo();\n            ownerContext.innerElContext.setHeight(innerHeight - inputPad.height - endElPad.height);\n        } else {\n            ownerContext.bodyElContext.setHeight(innerHeight);\n        }\n    },\n\n    publishInnerWidth: function (ownerContext, width) {\n        if (!this.owner.vertical) {\n            var endElPad = ownerContext.endElContext.getPaddingInfo(),\n                inputPad = ownerContext.inputContext.getPaddingInfo();\n\n            ownerContext.innerElContext.setWidth(width - inputPad.left - endElPad.right - ownerContext.labelContext.getProp('width'));\n        }\n    },\n\n    beginLayoutFixed: function(ownerContext, width, suffix) {\n        var me = this,\n            ieInputWidthAdjustment = me.ieInputWidthAdjustment;\n\n        if (ieInputWidthAdjustment) {\n            // adjust for IE 6/7 strict content-box model\n            // RTL: This might have to be padding-left unless the senses of the padding styles switch when in RTL mode.\n            me.owner.bodyEl.setStyle('padding-right', ieInputWidthAdjustment + 'px');\n        }\n\n        me.callParent(arguments);\n    }\n});\n\n/**\n * This is a layout that inherits the anchoring of {@link Ext.layout.container.Anchor} and adds the\n * ability for x/y positioning using the standard x and y component config options.\n *\n * This class is intended to be extended or created via the {@link Ext.container.Container#layout layout}\n * configuration property.  See {@link Ext.container.Container#layout} for additional details.\n *\n *     @example\n *     Ext.create('Ext.form.Panel', {\n *         title: 'Absolute Layout',\n *         width: 300,\n *         height: 275,\n *         layout: {\n *             type: 'absolute'\n *             // layout-specific configs go here\n *             //itemCls: 'x-abs-layout-item',\n *         },\n *         url:'save-form.php',\n *         defaultType: 'textfield',\n *         items: [{\n *             x: 10,\n *             y: 10,\n *             xtype:'label',\n *             text: 'Send To:'\n *         },{\n *             x: 80,\n *             y: 10,\n *             name: 'to',\n *             anchor:'90%'  // anchor width by percentage\n *         },{\n *             x: 10,\n *             y: 40,\n *             xtype:'label',\n *             text: 'Subject:'\n *         },{\n *             x: 80,\n *             y: 40,\n *             name: 'subject',\n *             anchor: '90%'  // anchor width by percentage\n *         },{\n *             x:0,\n *             y: 80,\n *             xtype: 'textareafield',\n *             name: 'msg',\n *             anchor: '100% 100%'  // anchor width and height\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.layout.container.Absolute', {\n\n    /* Begin Definitions */\n\n    alias: 'layout.absolute',\n    extend: 'Ext.layout.container.Anchor',\n    alternateClassName: 'Ext.layout.AbsoluteLayout',\n\n    /* End Definitions */\n\n    targetCls: Ext.baseCSSPrefix + 'abs-layout-ct',\n    itemCls: Ext.baseCSSPrefix + 'abs-layout-item',\n\n    /**\n     * @cfg {Boolean} ignoreOnContentChange\n     * True indicates that changes to one item in this layout do not effect the layout in\n     * general. This may need to be set to false if {@link Ext.Component#autoScroll}\n     * is enabled for the container.\n     */\n    ignoreOnContentChange: true,\n\n    type: 'absolute',\n\n    // private\n    adjustWidthAnchor: function(value, childContext) {\n        var padding = this.targetPadding,\n            x = childContext.getStyle('left');\n\n        return value - x + padding.left;\n    },\n\n    // private\n    adjustHeightAnchor: function(value, childContext) {\n        var padding = this.targetPadding,\n            y = childContext.getStyle('top');\n\n        return value - y + padding.top;\n    },\n\n    isItemLayoutRoot: function (item) {\n        return this.ignoreOnContentChange || this.callParent(arguments);\n    },\n\n    isItemShrinkWrap: function (item) {\n        return true;\n    },\n\n    beginLayout: function (ownerContext) {\n        var me = this,\n            target = me.getTarget();\n\n        me.callParent(arguments);\n\n        // Do not set position: relative; when the absolute layout target is the body\n        if (target.dom !== document.body) {\n            target.position();\n        }\n\n        me.targetPadding = ownerContext.targetContext.getPaddingInfo();\n    },\n\n    isItemBoxParent: function (itemContext) {\n        return true;\n    },\n\n    onContentChange: function () {\n        if (this.ignoreOnContentChange) {\n            return false;\n        }\n        return this.callParent(arguments);\n    }\n});\n\n/**\n * This is a layout that manages multiple Panels in an expandable accordion style such that by default only\n * one Panel can be expanded at any given time (set {@link #multi} config to have more open). Each Panel has\n * built-in support for expanding and collapsing.\n *\n * Note: Only Ext Panels and all subclasses of Ext.panel.Panel may be used in an accordion layout Container.\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Accordion Layout',\n *         width: 300,\n *         height: 300,\n *         defaults: {\n *             // applied to each contained panel\n *             bodyStyle: 'padding:15px'\n *         },\n *         layout: {\n *             // layout-specific configs go here\n *             type: 'accordion',\n *             titleCollapse: false,\n *             animate: true,\n *             activeOnTop: true\n *         },\n *         items: [{\n *             title: 'Panel 1',\n *             html: 'Panel content!'\n *         },{\n *             title: 'Panel 2',\n *             html: 'Panel content!'\n *         },{\n *             title: 'Panel 3',\n *             html: 'Panel content!'\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.layout.container.Accordion', {\n    extend: 'Ext.layout.container.VBox',\n    alias: ['layout.accordion'],\n    alternateClassName: 'Ext.layout.AccordionLayout',\n\n    itemCls: [Ext.baseCSSPrefix + 'box-item', Ext.baseCSSPrefix + 'accordion-item'],\n\n    align: 'stretch',\n\n    /**\n     * @cfg {Boolean} fill\n     * True to adjust the active item's height to fill the available space in the container, false to use the\n     * item's current height, or auto height if not explicitly set.\n     */\n    fill : true,\n\n    /**\n     * @cfg {Boolean} autoWidth\n     * Child Panels have their width actively managed to fit within the accordion's width.\n     * @removed This config is ignored in ExtJS 4\n     */\n\n    /**\n     * @cfg {Boolean} titleCollapse\n     * True to allow expand/collapse of each contained panel by clicking anywhere on the title bar, false to allow\n     * expand/collapse only when the toggle tool button is clicked.  When set to false,\n     * {@link #hideCollapseTool} should be false also.\n     */\n    titleCollapse : true,\n\n    /**\n     * @cfg {Boolean} hideCollapseTool\n     * True to hide the contained Panels' collapse/expand toggle buttons, false to display them.\n     * When set to true, {@link #titleCollapse} is automatically set to true.\n     */\n    hideCollapseTool : false,\n\n    /**\n     * @cfg {Boolean} collapseFirst\n     * True to make sure the collapse/expand toggle button always renders first (to the left of) any other tools\n     * in the contained Panels' title bars, false to render it last.\n     */\n    collapseFirst : false,\n\n    /**\n     * @cfg {Boolean} animate\n     * True to slide the contained panels open and closed during expand/collapse using animation, false to open and\n     * close directly with no animation. Note: The layout performs animated collapsing\n     * and expanding, *not* the child Panels.\n     */\n    animate : true,\n    /**\n     * @cfg {Boolean} activeOnTop\n     * Only valid when {@link #multi} is `false` and {@link #animate} is `false`.\n     *\n     * True to swap the position of each panel as it is expanded so that it becomes the first item in the container,\n     * false to keep the panels in the rendered order.\n     */\n    activeOnTop : false,\n    /**\n     * @cfg {Boolean} multi\n     * Set to true to enable multiple accordion items to be open at once.\n     */\n    multi: false,\n    \n    defaultAnimatePolicy: {\n        y: true,\n        height: true\n    },\n\n    constructor: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        if (me.animate) {\n            me.animatePolicy = Ext.apply({}, me.defaultAnimatePolicy);\n        } else {\n            me.animatePolicy = null;\n        }\n    },\n\n    beforeRenderItems: function (items) {\n        var me = this,\n            ln = items.length,\n            i = 0,\n            comp;\n\n        for (; i < ln; i++) {\n            comp = items[i];\n            if (!comp.rendered) {\n                // Set up initial properties for Panels in an accordion.\n                if (me.collapseFirst) {\n                    comp.collapseFirst = me.collapseFirst;\n                }\n                if (me.hideCollapseTool) {\n                    comp.hideCollapseTool = me.hideCollapseTool;\n                    comp.titleCollapse = true;\n                }\n                else if (me.titleCollapse) {\n                    comp.titleCollapse = me.titleCollapse;\n                }\n\n                delete comp.hideHeader;\n                delete comp.width;\n                comp.collapsible = true;\n                comp.title = comp.title || '&#160;';\n                comp.addBodyCls(Ext.baseCSSPrefix + 'accordion-body');\n\n                // If only one child Panel is allowed to be expanded\n                // then collapse all except the first one found with collapsed:false\n                if (!me.multi) {\n                    // If there is an expanded item, all others must be rendered collapsed.\n                    if (me.expandedItem !== undefined) {\n                        comp.collapsed = true;\n                    }\n                    // Otherwise expand the first item with collapsed explicitly configured as false\n                    else if (comp.hasOwnProperty('collapsed') && comp.collapsed === false) {\n                        me.expandedItem = i;\n                    } else {\n                        comp.collapsed = true;\n                    }\n\n                    // If only one child Panel may be expanded, then intercept expand/show requests.\n                    me.owner.mon(comp, {\n                        show: me.onComponentShow,\n                        beforeexpand: me.onComponentExpand,\n                        scope: me\n                    });\n                }\n\n                // If we must fill available space, a collapse must be listened for and a sibling must\n                // be expanded.\n                if (me.fill) {\n                    me.owner.mon(comp, {\n                        beforecollapse: me.onComponentCollapse,\n                        scope: me\n                    });\n                }\n            }\n        }\n\n        // If no collapsed:false Panels found, make the first one expanded.\n        if (ln && me.expandedItem === undefined) {\n            me.expandedItem = 0;\n            items[0].collapsed = false;\n        }\n    },\n\n    getItemsRenderTree: function(items) {\n        this.beforeRenderItems(items);\n\n        return this.callParent(arguments);\n    },\n\n    renderItems : function(items, target) {\n        this.beforeRenderItems(items);\n\n        this.callParent(arguments);\n    },\n\n    configureItem: function(item) {\n        this.callParent(arguments);\n\n        // We handle animations for the expand/collapse of items.\n        // Items do not have individual borders\n        item.animCollapse = item.border = false;\n\n        // If filling available space, all Panels flex.\n        if (this.fill) {\n            item.flex = 1;\n        }\n    },\n\n    onChildPanelRender: function(panel) {\n        panel.header.addCls(Ext.baseCSSPrefix + 'accordion-hd');\n    },\n\n    beginLayout: function (ownerContext) {\n        this.callParent(arguments);\n        this.updatePanelClasses(ownerContext);\n    },\n\n    updatePanelClasses: function(ownerContext) {\n        var children = ownerContext.visibleItems,\n            ln = children.length,\n            siblingCollapsed = true,\n            i, child, header;\n\n        for (i = 0; i < ln; i++) {\n            child = children[i];\n            header = child.header;\n            header.addCls(Ext.baseCSSPrefix + 'accordion-hd');\n\n            if (siblingCollapsed) {\n                header.removeCls(Ext.baseCSSPrefix + 'accordion-hd-sibling-expanded');\n            } else {\n                header.addCls(Ext.baseCSSPrefix + 'accordion-hd-sibling-expanded');\n            }\n\n            if (i + 1 == ln && child.collapsed) {\n                header.addCls(Ext.baseCSSPrefix + 'accordion-hd-last-collapsed');\n            } else {\n                header.removeCls(Ext.baseCSSPrefix + 'accordion-hd-last-collapsed');\n            }\n\n            siblingCollapsed = child.collapsed;\n        }\n    },\n\n    // When a Component expands, adjust the heights of the other Components to be just enough to accommodate\n    // their headers.\n    // The expanded Component receives the only flex value, and so gets all remaining space.\n    onComponentExpand: function(toExpand) {\n        var me = this,\n            owner = me.owner,\n            expanded,\n            expandedCount, i,\n            previousValue;\n\n        if (!me.processing) {\n            me.processing = true;\n            previousValue = owner.deferLayouts;\n            owner.deferLayouts = true;\n            expanded = me.multi ? [] : owner.query('>panel:not([collapsed])');\n            expandedCount = expanded.length;\n            \n            // Collapse all other expanded child items (Won't loop if multi is true)\n            for (i = 0; i < expandedCount; i++) {\n                expanded[i].collapse();\n            }\n            owner.deferLayouts = previousValue;\n            me.processing = false;\n        }\n    },\n\n    onComponentCollapse: function(comp) {\n        var me = this,\n            owner = me.owner,\n            toExpand,\n            expanded,\n            previousValue;\n\n        if (me.owner.items.getCount() === 1) {\n            // do not allow collapse if there is only one item\n            return false;\n        }\n\n        if (!me.processing) {\n            me.processing = true;\n            previousValue = owner.deferLayouts;\n            owner.deferLayouts = true;\n            toExpand = comp.next() || comp.prev();\n\n            // If we are allowing multi, and the \"toCollapse\" component is NOT the only expanded Component,\n            // then ask the box layout to collapse it to its header.\n            if (me.multi) {\n                expanded = me.owner.query('>panel:not([collapsed])');\n\n                // If the collapsing Panel is the only expanded one, expand the following Component.\n                // All this is handling fill: true, so there must be at least one expanded,\n                if (expanded.length === 1) {\n                    toExpand.expand();\n                }\n\n            } else if (toExpand) {\n                toExpand.expand();\n            }\n            owner.deferLayouts = previousValue;\n            me.processing = false;\n        }\n    },\n\n    onComponentShow: function(comp) {\n        // Showing a Component means that you want to see it, so expand it.\n        this.onComponentExpand(comp);\n    }\n});\n\n/**\n * This class functions **between siblings of a {@link Ext.layout.container.VBox VBox} or {@link Ext.layout.container.HBox HBox}\n * layout** to resize both immediate siblings.\n *\n * A Splitter will preserve the flex ratio of any flexed siblings it is required to resize. It does this by setting the `flex` property of *all* flexed siblings\n * to equal their pixel size. The actual numerical `flex` property in the Components will change, but the **ratio** to the total flex value will be preserved.\n *\n * A Splitter may be configured to show a centered mini-collapse tool orientated to collapse the {@link #collapseTarget}.\n * The Splitter will then call that sibling Panel's {@link Ext.panel.Panel#method-collapse collapse} or {@link Ext.panel.Panel#method-expand expand} method\n * to perform the appropriate operation (depending on the sibling collapse state). To create the mini-collapse tool but take care\n * of collapsing yourself, configure the splitter with `{@link #performCollapse}: false`.\n */\nExt.define('Ext.resizer.Splitter', {\n    extend: 'Ext.Component',\n    requires: ['Ext.XTemplate'],\n    uses: ['Ext.resizer.SplitterTracker'],\n    alias: 'widget.splitter',\n\n    childEls: [\n        'collapseEl'\n    ],\n\n    renderTpl: [\n        '<tpl if=\"collapsible===true\">',\n            '<div id=\"{id}-collapseEl\" class=\"', Ext.baseCSSPrefix, 'collapse-el ',\n                Ext.baseCSSPrefix, 'layout-split-{collapseDir}\">&#160;</div>',\n        '</tpl>'\n    ],\n\n    baseCls: Ext.baseCSSPrefix + 'splitter',\n    collapsedClsInternal: Ext.baseCSSPrefix + 'splitter-collapsed',\n    \n    // Default to tree, allow internal classes to disable resizing\n    canResize: true,\n\n    /**\n     * @cfg {Boolean} collapsible\n     * True to show a mini-collapse tool in the Splitter to toggle expand and collapse on the {@link #collapseTarget} Panel.\n     * Defaults to the {@link Ext.panel.Panel#collapsible collapsible} setting of the Panel.\n     */\n    collapsible: false,\n\n    /**\n     * @cfg {Boolean} performCollapse\n     * Set to false to prevent this Splitter's mini-collapse tool from managing the collapse\n     * state of the {@link #collapseTarget}.\n     */\n\n    /**\n     * @cfg {Boolean} collapseOnDblClick\n     * True to enable dblclick to toggle expand and collapse on the {@link #collapseTarget} Panel.\n     */\n    collapseOnDblClick: true,\n\n    /**\n     * @cfg {Number} defaultSplitMin\n     * Provides a default minimum width or height for the two components\n     * that the splitter is between.\n     */\n    defaultSplitMin: 40,\n\n    /**\n     * @cfg {Number} defaultSplitMax\n     * Provides a default maximum width or height for the two components\n     * that the splitter is between.\n     */\n    defaultSplitMax: 1000,\n\n    /**\n     * @cfg {String} collapsedCls\n     * A class to add to the splitter when it is collapsed. See {@link #collapsible}.\n     */\n\n    /**\n     * @cfg {String/Ext.panel.Panel} collapseTarget\n     * A string describing the relative position of the immediate sibling Panel to collapse. May be 'prev' or 'next'.\n     *\n     * Or the immediate sibling Panel to collapse.\n     *\n     * The orientation of the mini-collapse tool will be inferred from this setting.\n     *\n     * **Note that only Panels may be collapsed.**\n     */\n    collapseTarget: 'next',\n\n    /**\n     * @property {String} orientation\n     * Orientation of this Splitter. `'vertical'` when used in an hbox layout, `'horizontal'`\n     * when used in a vbox layout.\n     */\n\n    horizontal: false,\n    vertical: false,\n\n    /**\n     * Returns the config object (with an `xclass` property) for the splitter tracker. This\n     * is overridden by {@link Ext.resizer.BorderSplitter BorderSplitter} to create a\n     * {@link Ext.resizer.BorderSplitterTracker BorderSplitterTracker}.\n     * @protected\n     */\n    getTrackerConfig: function () {\n        return {\n            xclass: 'Ext.resizer.SplitterTracker',\n            el: this.el,\n            splitter: this\n        };\n    },\n\n    beforeRender: function() {\n        var me = this,\n            target = me.getCollapseTarget(),\n            collapseDir = me.getCollapseDirection(),\n            vertical = me.vertical,\n            fixedSizeProp = vertical ? 'width' : 'height',\n            stretchSizeProp = vertical ? 'height' : 'width',\n            cls;\n\n        me.callParent();\n\n        if (!me.hasOwnProperty(stretchSizeProp)) {\n            me[stretchSizeProp] = '100%';\n        }\n        if (!me.hasOwnProperty(fixedSizeProp)) {\n            me[fixedSizeProp] = 5;\n        }\n\n        if (target.collapsed) {\n            me.addCls(me.collapsedClsInternal);\n        }\n        \n        cls = me.baseCls + '-' + me.orientation;\n        me.addCls(cls);\n        if (!me.canResize) {\n            me.addCls(cls + '-noresize');\n        }\n        \n        Ext.applyIf(me.renderData, {\n            collapseDir: collapseDir,\n            collapsible: me.collapsible || target.collapsible\n        });\n    },\n\n    onRender: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        // Add listeners on the mini-collapse tool unless performCollapse is set to false\n        if (me.performCollapse !== false) {\n            if (me.renderData.collapsible) {\n                me.mon(me.collapseEl, 'click', me.toggleTargetCmp, me);\n            }\n            if (me.collapseOnDblClick) {\n                me.mon(me.el, 'dblclick', me.toggleTargetCmp, me);\n            }\n        }\n\n        // Ensure the mini collapse icon is set to the correct direction when the target is collapsed/expanded by any means\n        me.mon(me.getCollapseTarget(), {\n            collapse: me.onTargetCollapse,\n            expand: me.onTargetExpand,\n            scope: me\n        });\n\n        me.el.unselectable();\n        if (me.canResize) {\n            me.tracker = Ext.create(me.getTrackerConfig());\n            // Relay the most important events to our owner (could open wider later):\n            me.relayEvents(me.tracker, [ 'beforedragstart', 'dragstart', 'dragend' ]);\n        }\n    },\n\n    getCollapseDirection: function() {\n        var me = this,\n            dir = me.collapseDirection,\n            collapseTarget, idx, items, type;\n\n        if (!dir) {\n            collapseTarget = me.collapseTarget;\n            if (collapseTarget.isComponent) {\n                dir = collapseTarget.collapseDirection;\n            }\n\n            if (!dir) {\n                // Avoid duplication of string tests.\n                // Create a two bit truth table of the configuration of the Splitter:\n                // Collapse Target | orientation\n                //        0              0             = next, horizontal\n                //        0              1             = next, vertical\n                //        1              0             = prev, horizontal\n                //        1              1             = prev, vertical\n                type = me.ownerCt.layout.type;\n                if (collapseTarget.isComponent) {\n                    items = me.ownerCt.items;\n                    idx = Number(items.indexOf(collapseTarget) == items.indexOf(me) - 1) << 1 | Number(type == 'hbox');\n                } else {\n                    idx = Number(me.collapseTarget == 'prev') << 1 | Number(type == 'hbox');\n                }\n\n                // Read the data out the truth table\n                dir = ['bottom', 'right', 'top', 'left'][idx];\n            }\n\n            me.collapseDirection = dir;\n        }\n\n        me.orientation = (dir == 'top' || dir == 'bottom') ? 'horizontal' : 'vertical';\n        me[me.orientation] = true;\n\n        return dir;\n    },\n\n    getCollapseTarget: function() {\n        var me = this;\n\n        return me.collapseTarget.isComponent ? me.collapseTarget : me.collapseTarget == 'prev' ? me.previousSibling() : me.nextSibling();\n    },\n\n    onTargetCollapse: function(target) {\n        this.el.addCls([this.collapsedClsInternal, this.collapsedCls]);\n    },\n\n    onTargetExpand: function(target) {\n        this.el.removeCls([this.collapsedClsInternal, this.collapsedCls]);\n    },\n\n    toggleTargetCmp: function(e, t) {\n        var cmp = this.getCollapseTarget(),\n            placeholder = cmp.placeholder,\n            toggle;\n\n        if (placeholder && !placeholder.hidden) {\n            toggle = true;\n        } else {\n            toggle = !cmp.hidden;\n        }\n\n        if (toggle) {\n            if (cmp.collapsed) {\n                cmp.expand();\n            } else if (cmp.collapseDirection) {\n                cmp.collapse();\n            } else {\n                cmp.collapse(this.renderData.collapseDir);\n            }\n        }\n    },\n\n    /*\n     * Work around IE bug. %age margins do not get recalculated on element resize unless repaint called.\n     */\n    setSize: function() {\n        var me = this;\n        me.callParent(arguments);\n        if (Ext.isIE && me.el) {\n            me.el.repaint();\n        }\n    },\n    \n    beforeDestroy: function(){\n        Ext.destroy(this.tracker);\n        this.callParent();\n    }\n});\n\n/**\n * Private utility class for Ext.layout.container.Border.\n * @private\n */\nExt.define('Ext.resizer.BorderSplitter', {\n    extend: 'Ext.resizer.Splitter',\n\n    uses: ['Ext.resizer.BorderSplitterTracker'],\n\n    alias: 'widget.bordersplitter',\n\n    // must be configured in by the border layout:\n    collapseTarget: null,\n\n    getTrackerConfig: function () {\n        var trackerConfig = this.callParent();\n\n        trackerConfig.xclass = 'Ext.resizer.BorderSplitterTracker';\n\n        return trackerConfig;\n    }\n});\n\n/**\n * This is a multi-pane, application-oriented UI layout style that supports multiple nested panels, automatic bars\n * between regions and built-in {@link Ext.panel.Panel#collapsible expanding and collapsing} of regions.\n *\n * This class is intended to be extended or created via the `layout:'border'` {@link Ext.container.Container#layout}\n * config, and should generally not need to be created directly via the new keyword.\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         width: 500,\n *         height: 300,\n *         title: 'Border Layout',\n *         layout: 'border',\n *         items: [{\n *             title: 'South Region is resizable',\n *             region: 'south',     // position for region\n *             xtype: 'panel',\n *             height: 100,\n *             split: true,         // enable resizing\n *             margins: '0 5 5 5'\n *         },{\n *             // xtype: 'panel' implied by default\n *             title: 'West Region is collapsible',\n *             region:'west',\n *             xtype: 'panel',\n *             margins: '5 0 0 5',\n *             width: 200,\n *             collapsible: true,   // make collapsible\n *             id: 'west-region-container',\n *             layout: 'fit'\n *         },{\n *             title: 'Center Region',\n *             region: 'center',     // center region is required, no width/height specified\n *             xtype: 'panel',\n *             layout: 'fit',\n *             margins: '5 5 0 0'\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n *\n * # Notes\n * \n *   - When using the split option, the layout will automatically insert a {@link Ext.resizer.Splitter}\n *     into the appropriate place. This will modify the underlying\n *     {@link Ext.container.Container#property-items items} collection in the container.\n *\n *   - Any Container using the Border layout **must** have a child item with `region:'center'`.\n *     The child item in the center region will always be resized to fill the remaining space\n *     not used by the other regions in the layout.\n *\n *   - Any child items with a region of `west` or `east` may be configured with either an initial\n *     `width`, or a {@link Ext.layout.container.Box#flex} value, or an initial percentage width\n *     **string** (Which is simply divided by 100 and used as a flex value).\n *     The 'center' region has a flex value of `1`.\n *\n *   - Any child items with a region of `north` or `south` may be configured with either an initial\n *     `height`, or a {@link Ext.layout.container.Box#flex} value, or an initial percentage height\n *     **string** (Which is simply divided by 100 and used as a flex value).\n *     The 'center' region has a flex value of `1`.\n *\n *   - **There is no BorderLayout.Region class in ExtJS 4.0+**\n */\nExt.define('Ext.layout.container.Border', {\n\n    alias: 'layout.border',\n\n    extend: 'Ext.layout.container.Container',\n\n    requires: ['Ext.resizer.BorderSplitter', 'Ext.Component', 'Ext.fx.Anim'],\n\n    alternateClassName: 'Ext.layout.BorderLayout',\n\n\n    targetCls: Ext.baseCSSPrefix + 'border-layout-ct',\n\n    itemCls: [Ext.baseCSSPrefix + 'border-item', Ext.baseCSSPrefix + 'box-item'],\n\n    type: 'border',\n\n    /**\n     * @cfg {Boolean} split\n     * This configuration option is to be applied to the **child `items`** managed by this layout.\n     * Each region with `split:true` will get a {@link Ext.resizer.BorderSplitter Splitter} that\n     * allows for manual resizing of the container. Except for the `center` region.\n     */\n    \n    /**\n     * @cfg {Boolean} [splitterResize=true]\n     * This configuration option is to be applied to the **child `items`** managed by this layout and\n     * is used in conjunction with {@link #split}. By default, when specifying {@link #split}, the region\n     * can be dragged to be resized. Set this option to false to show the split bar but prevent resizing.\n     */\n\n    /**\n     * @cfg {Number/String/Object} padding\n     * Sets the padding to be applied to all child items managed by this layout.\n     * \n     * This property can be specified as a string containing space-separated, numeric\n     * padding values. The order of the sides associated with each value matches the way\n     * CSS processes padding values:\n     *\n     *  - If there is only one value, it applies to all sides.\n     *  - If there are two values, the top and bottom borders are set to the first value\n     *    and the right and left are set to the second.\n     *  - If there are three values, the top is set to the first value, the left and right\n     *    are set to the second, and the bottom is set to the third.\n     *  - If there are four values, they apply to the top, right, bottom, and left,\n     *    respectively.\n     *\n     */\n    padding: undefined,\n\n    percentageRe: /(\\d+)%/,\n\n    /**\n     * Reused meta-data objects that describe axis properties.\n     * @private\n     */\n    axisProps: {\n        horz: {\n            borderBegin: 'west',\n            borderEnd: 'east',\n            horizontal: true,\n            posProp: 'x',\n            sizeProp: 'width',\n            sizePropCap: 'Width'\n        },\n        vert: {\n            borderBegin: 'north',\n            borderEnd: 'south',\n            horizontal: false,\n            posProp: 'y',\n            sizeProp: 'height',\n            sizePropCap: 'Height'\n        }\n    },\n\n    // @private\n    centerRegion: null,\n\n    /**\n     * Maps from region name to collapseDirection for panel.\n     * @private\n     */\n    collapseDirections: {\n        north: 'top',\n        south: 'bottom',\n        east: 'right',\n        west: 'left'\n    },\n\n    manageMargins: true,\n\n    panelCollapseAnimate: true,\n\n    panelCollapseMode: 'placeholder',\n\n    /**\n     * @cfg {Object} regionWeights\n     * The default weights to assign to regions in the border layout. These values are\n     * used when a region does not contain a `weight` property. This object must have\n     * properties for all regions (\"north\", \"south\", \"east\" and \"west\").\n     * \n     * **IMPORTANT:** Since this is an object, changing its properties will impact ALL\n     * instances of Border layout. If this is not desired, provide a replacement object as\n     * a config option instead:\n     * \n     *      layout: {\n     *          type: 'border',\n     *          regionWeights: {\n     *              west: 20,\n     *              north: 10,\n     *              south: -10,\n     *              east: -20\n     *          }\n     *      }\n     *\n     * The region with the highest weight is assigned space from the border before other\n     * regions. Regions of equal weight are assigned space based on their position in the\n     * owner's items list (first come, first served).\n     */\n    regionWeights: {\n        north: 20,\n        south: 10,\n        center: 0,\n        west: -10,\n        east: -20\n    },\n\n    //----------------------------------\n    // Layout processing\n\n    /**\n     * Creates the axis objects for the layout. These are only missing size information\n     * which is added during {@link #calculate}.\n     * @private\n     */\n    beginAxis: function (ownerContext, regions, name) {\n        var me = this,\n            props = me.axisProps[name],\n            isVert = !props.horizontal,\n            sizeProp = props.sizeProp,\n            totalFlex = 0,\n            childItems = ownerContext.childItems,\n            length = childItems.length,\n            center, i, childContext, centerFlex, comp, region, match, size, type, target, placeholder;\n\n        for (i = 0; i < length; ++i) {\n            childContext = childItems[i];\n            comp = childContext.target;\n\n            childContext.layoutPos = {};\n\n            if (comp.region) {\n                childContext.region = region = comp.region;\n\n                childContext.isCenter = comp.isCenter;\n                childContext.isHorz = comp.isHorz;\n                childContext.isVert = comp.isVert;\n\n                childContext.weight = comp.weight || me.regionWeights[region] || 0;\n                regions[comp.id] = childContext;\n\n                if (comp.isCenter) {\n                    center = childContext;\n                    centerFlex = comp.flex;\n                    ownerContext.centerRegion = center;\n\n                    continue;\n                }\n\n                if (isVert !== childContext.isVert) {\n                    continue;\n                }\n\n                // process regions \"isVert ? north||south : east||center||west\"\n\n                childContext.reverseWeighting = (region == props.borderEnd);\n\n                size = comp[sizeProp];\n                type = typeof size;\n\n                if (!comp.collapsed) {\n                    if (type == 'string' && (match = me.percentageRe.exec(size))) {\n                        childContext.percentage = parseInt(match[1], 10);\n                    } else if (comp.flex) {\n                        totalFlex += childContext.flex = comp.flex;\n                    }\n                }\n            }\n        }\n\n        // Special cases for a collapsed center region\n        if (center) {\n            target = center.target;\n\n            if (placeholder = target.placeholderFor) {\n                if (!centerFlex && isVert === placeholder.collapsedVertical()) {\n                    // The center region is a placeholder, collapsed in this axis\n                    centerFlex = 0;\n                    center.collapseAxis = name;\n                }\n            } else if (target.collapsed && (isVert === target.collapsedVertical())) {\n                // The center region is a collapsed header, collapsed in this axis\n                centerFlex = 0;\n                center.collapseAxis = name;\n            }\n        }\n\n        if (centerFlex == null) {\n            // If we still don't have a center flex, default to 1\n            centerFlex = 1;\n        }\n\n        totalFlex += centerFlex;\n\n        return Ext.apply({\n            before         : isVert ? 'top' : 'left',\n            totalFlex      : totalFlex\n        }, props);\n    },\n\n    beginLayout: function (ownerContext) {\n        var me = this,\n            items = me.getLayoutItems(),\n            pad = me.padding,\n            type = typeof pad,\n            padOnContainer = false,\n            childContext, item, length, i, regions, collapseTarget,\n            doShow, hidden, region;\n\n        // We sync the visibility state of splitters with their region:\n        if (pad) {\n            if (type == 'string' || type == 'number') {\n                pad = Ext.util.Format.parseBox(pad);\n            }\n        } else {\n            pad = ownerContext.getEl('getTargetEl').getPaddingInfo();\n            padOnContainer = true;\n        }\n        ownerContext.outerPad = pad;\n        ownerContext.padOnContainer = padOnContainer;\n\n        for (i = 0, length = items.length; i < length; ++i) {\n            item = items[i];\n            collapseTarget = me.getSplitterTarget(item);\n            if (collapseTarget) {\n                hidden = !!item.hidden;\n                if (!collapseTarget.split) {\n                    if (collapseTarget.isCollapsingOrExpanding) {\n                        doShow = !!collapseTarget.collapsed;\n                    }\n                } else if (hidden !== collapseTarget.hidden) {\n                    doShow = !collapseTarget.hidden;\n                }\n                \n                if (doShow === true) {\n                    item.show();\n                } else if (doShow === false) {\n                    item.hide();\n                }\n            }\n        }\n\n        // The above synchronized visibility of splitters with their regions, so we need\n        // to make this call after that so that childItems and visibleItems are correct:\n        //\n        me.callParent(arguments);\n\n        items = ownerContext.childItems;\n        length = items.length;\n        regions = {};\n\n        ownerContext.borderAxisHorz = me.beginAxis(ownerContext, regions, 'horz');\n        ownerContext.borderAxisVert = me.beginAxis(ownerContext, regions, 'vert');\n\n        // Now that weights are assigned to the region's contextItems, we assign those\n        // same weights to the contextItem for the splitters. We also cross link the\n        // contextItems for the collapseTarget and its splitter.\n        for (i = 0; i < length; ++i) {\n            childContext = items[i];\n            collapseTarget = me.getSplitterTarget(childContext.target);\n\n            if (collapseTarget) { // if (splitter)\n                region = regions[collapseTarget.id]\n                if (!region) {\n                        // if the region was hidden it will not be part of childItems, and\n                        // so beginAxis() won't add it to the regions object, so we have\n                        // to create the context item here.\n                        region = ownerContext.getEl(collapseTarget.el, me);\n                        region.region = collapseTarget.region;\n                }\n                childContext.collapseTarget = collapseTarget = region;\n                childContext.weight = collapseTarget.weight;\n                childContext.reverseWeighting = collapseTarget.reverseWeighting;\n                collapseTarget.splitter = childContext;\n                childContext.isHorz = collapseTarget.isHorz;\n                childContext.isVert = collapseTarget.isVert;\n            }\n        }\n\n        // Now we want to sort the childItems by their weight.\n        me.sortWeightedItems(items, 'reverseWeighting');\n        me.setupSplitterNeighbors(items);\n    },\n\n    calculate: function (ownerContext) {\n        var me = this,\n            containerSize = me.getContainerSize(ownerContext),\n            childItems = ownerContext.childItems,\n            length = childItems.length,\n            horz = ownerContext.borderAxisHorz,\n            vert = ownerContext.borderAxisVert,\n            pad = ownerContext.outerPad,\n            padOnContainer = ownerContext.padOnContainer,\n            i, childContext, childMargins, size, horzPercentTotal, vertPercentTotal;\n\n        horz.begin = pad.left;\n        vert.begin = pad.top;\n        // If the padding is already on the container we need to add it to the space\n        // If not on the container, it's \"virtual\" padding.\n        horzPercentTotal = horz.end = horz.flexSpace = containerSize.width + (padOnContainer ? pad.left : -pad.right);\n        vertPercentTotal = vert.end = vert.flexSpace = containerSize.height + (padOnContainer ? pad.top : -pad.bottom);\n\n        // Reduce flexSpace on each axis by the fixed/auto sized dimensions of items that\n        // aren't flexed along that axis.\n        for (i = 0; i < length; ++i) {\n            childContext = childItems[i];\n            childMargins = childContext.getMarginInfo();\n\n            // Margins are always fixed size and must be removed from the space used for percentages and flexes\n            if (childContext.isHorz || childContext.isCenter) {\n                horz.addUnflexed(childMargins.width);\n                horzPercentTotal -= childMargins.width;\n            }\n\n            if (childContext.isVert || childContext.isCenter) {\n                vert.addUnflexed(childMargins.height);\n                vertPercentTotal -= childMargins.height;\n            }\n\n            // Fixed size components must have their sizes removed from the space used for flex\n            if (!childContext.flex && !childContext.percentage) {\n                if (childContext.isHorz || (childContext.isCenter && childContext.collapseAxis === 'horz')) {\n                    size = childContext.getProp('width');\n\n                    horz.addUnflexed(size);\n\n                    // splitters should not count towards percentages\n                    if (childContext.collapseTarget) {\n                        horzPercentTotal -= size;\n                    }\n                } else if (childContext.isVert || (childContext.isCenter && childContext.collapseAxis === 'vert')) {\n                    size = childContext.getProp('height');\n\n                    vert.addUnflexed(size);\n\n                    // splitters should not count towards percentages\n                    if (childContext.collapseTarget) {\n                        vertPercentTotal -= size;\n                    }\n                }\n                // else ignore center since it is fully flexed\n            }\n        }\n\n        for (i = 0; i < length; ++i) {\n            childContext = childItems[i];\n            childMargins = childContext.getMarginInfo();\n\n            // Calculate the percentage sizes. After this calculation percentages are very similar to fixed sizes\n            if (childContext.percentage) {\n                if (childContext.isHorz) {\n                    size = Math.ceil(horzPercentTotal * childContext.percentage / 100);\n                    size = childContext.setWidth(size);\n                    horz.addUnflexed(size);\n                } else if (childContext.isVert) {\n                    size = Math.ceil(vertPercentTotal * childContext.percentage / 100);\n                    size = childContext.setHeight(size);\n                    vert.addUnflexed(size);\n                }\n                // center shouldn't have a percentage but if it does it should be ignored\n            }\n        }\n\n\n        // If we haven't gotten sizes for all unflexed dimensions on an axis, the flexSpace\n        // will be NaN so we won't be calculating flexed dimensions until that is resolved.\n\n        for (i = 0; i < length; ++i) {\n            childContext = childItems[i];\n\n            if (!childContext.isCenter) {\n                me.calculateChildAxis(childContext, horz);\n                me.calculateChildAxis(childContext, vert);\n            }\n        }\n\n        // Once all items are placed, the final size of the center can be determined. If we\n        // can determine both width and height, we are done. We use '+' instead of '&&' to\n        // avoid short-circuiting (we want to call both):\n        if (me.finishAxis(ownerContext, vert) + me.finishAxis(ownerContext, horz) < 2) {\n            me.done = false;\n        } else {\n            // Size information is published as we place regions but position is hard to do\n            // that way (while avoiding published multiple times) so we publish all the\n            // positions at the end.\n            me.finishPositions(childItems);\n        }\n    },\n\n    /**\n     * Performs the calculations for a region on a specified axis.\n     * @private\n     */\n    calculateChildAxis: function (childContext, axis) {\n        var collapseTarget = childContext.collapseTarget,\n            setSizeMethod = 'set' + axis.sizePropCap,\n            sizeProp = axis.sizeProp,\n            childMarginSize = childContext.getMarginInfo()[sizeProp],\n            region, isBegin, flex, pos, size;\n\n        if (collapseTarget) { // if (splitter)\n            region = collapseTarget.region;\n        } else {\n            region = childContext.region;\n            flex = childContext.flex;\n        }\n\n        isBegin = region == axis.borderBegin;\n\n        if (!isBegin && region != axis.borderEnd) {\n            // a north/south region on the horizontal axis or an east/west region on the\n            // vertical axis: stretch to fill remaining space:\n            childContext[setSizeMethod](axis.end - axis.begin - childMarginSize);\n            pos = axis.begin;\n        } else {\n            if (flex) {\n                size = Math.ceil(axis.flexSpace * (flex / axis.totalFlex));\n                size = childContext[setSizeMethod](size);\n            } else if (childContext.percentage) {\n                // Like getProp but without registering a dependency - we calculated the size, we don't depend on it\n                size = childContext.peek(sizeProp);\n            } else {\n                size = childContext.getProp(sizeProp);\n            }\n\n            size += childMarginSize;\n\n            if (isBegin) {\n                pos = axis.begin;\n                axis.begin += size;\n            } else {\n                axis.end = pos = axis.end - size;\n            }\n        }\n\n        childContext.layoutPos[axis.posProp] = pos;\n    },\n\n    /**\n     * Finishes the calculations on an axis. This basically just assigns the remaining\n     * space to the center region.\n     * @private\n     */\n    finishAxis: function (ownerContext, axis) {\n        var size = axis.end - axis.begin,\n            center = ownerContext.centerRegion;\n\n        if (center) {\n            center['set' + axis.sizePropCap](size - center.getMarginInfo()[axis.sizeProp]);\n            center.layoutPos[axis.posProp] = axis.begin;\n        }\n\n        return Ext.isNumber(size) ? 1 : 0;\n    },\n\n    /**\n     * Finishes by setting the positions on the child items.\n     * @private\n     */\n    finishPositions: function (childItems) {\n        var length = childItems.length,\n            index, childContext;\n\n        for (index = 0; index < length; ++index) {\n            childContext = childItems[index];\n\n            childContext.setProp('x', childContext.layoutPos.x + childContext.marginInfo.left);\n            childContext.setProp('y', childContext.layoutPos.y + childContext.marginInfo.top);\n        }\n    },\n\n    getPlaceholder: function (comp) {\n        return comp.getPlaceholder && comp.getPlaceholder();\n    },\n\n    getSplitterTarget: function (splitter) {\n        var collapseTarget = splitter.collapseTarget;\n\n        if (collapseTarget && collapseTarget.collapsed) {\n            return collapseTarget.placeholder || collapseTarget;\n        }\n\n        return collapseTarget;\n    },\n\n    isItemBoxParent: function (itemContext) {\n        return true;\n    },\n\n    isItemShrinkWrap: function (item) {\n        return true;\n    },\n\n    //----------------------------------\n    // Event handlers\n\n    /**\n     * Inserts the splitter for a given region. A reference to the splitter is also stored\n     * on the component as \"splitter\".\n     * @private\n     */\n    insertSplitter: function (item, index, hidden) {\n        var region = item.region,\n            splitter = {\n                xtype: 'bordersplitter',\n                collapseTarget: item,\n                id: item.id + '-splitter',\n                hidden: hidden,\n                canResize: item.splitterResize !== false\n            },\n            at = index + ((region == 'south' || region == 'east') ? 0 : 1);\n\n        // remove the default fixed width or height depending on orientation:\n        if (item.isHorz) {\n            splitter.height = null;\n        } else {\n            splitter.width = null;\n        }\n\n        if (item.collapseMode == 'mini') {\n            splitter.collapsedCls = item.collapsedCls;\n        }\n\n        item.splitter = this.owner.add(at, splitter);\n    },\n\n    /**\n     * Called when a region (actually when any component) is added to the container. The\n     * region is decorated with some helpful properties (isCenter, isHorz, isVert) and its\n     * splitter is added if its \"split\" property is true.\n     * @private\n     */\n    onAdd: function (item, index) {\n        var me = this,\n            placeholderFor = item.placeholderFor,\n            region = item.region,\n            split,\n            hidden;\n\n        me.callParent(arguments);\n\n        if (region) {\n            Ext.apply(item, me.regionFlags[region]);\n\n            if (region == 'center') {\n                if (me.centerRegion) {\n                    Ext.Error.raise(\"Cannot have multiple center regions in a BorderLayout.\");\n                }\n                me.centerRegion = item;\n            } else {\n                item.collapseDirection = this.collapseDirections[region];\n                split = item.split;\n                hidden = !!item.hidden;\n                if ((item.isHorz || item.isVert) && (split || item.collapseMode == 'mini')) {\n                    me.insertSplitter(item, index, hidden || !split);\n                }\n            }\n\n            if (!item.hasOwnProperty('collapseMode')) {\n                item.collapseMode = me.panelCollapseMode;\n            }\n\n            if (!item.hasOwnProperty('animCollapse')) {\n                if (item.collapseMode != 'placeholder') {\n                    // other collapse modes do not animate nicely in a border layout, so\n                    // default them to off:\n                    item.animCollapse = false;\n                } else {\n                    item.animCollapse = me.panelCollapseAnimate;\n                }\n            }\n        } else if (placeholderFor) {\n            Ext.apply(item, me.regionFlags[placeholderFor.region]);\n            item.region = placeholderFor.region;\n            item.weight = placeholderFor.weight;\n        }\n    },\n\n    onDestroy: function() {\n        this.centerRegion = null;\n        this.callParent();\n    },\n\n    onRemove: function (item) {\n        var me = this,\n            region = item.region,\n            splitter = item.splitter;\n\n        if (region) {\n            if (item.isCenter) {\n                me.centerRegion = null;\n            }\n\n            delete item.isCenter;\n            delete item.isHorz;\n            delete item.isVert;\n\n            if (splitter) {\n                me.owner.doRemove(splitter, true); // avoid another layout\n                delete item.splitter;\n            }\n        }\n\n        me.callParent(arguments);\n    },\n\n    //----------------------------------\n    // Misc\n\n    regionFlags: {\n        center: { isCenter: true, isHorz: false, isVert: false },\n\n        north: { isCenter: false, isHorz: false, isVert: true },\n        south: { isCenter: false, isHorz: false, isVert: true },\n\n        west: { isCenter: false, isHorz: true, isVert: false },\n        east: { isCenter: false, isHorz: true, isVert: false }\n    },\n\n    setupSplitterNeighbors: function (items) {\n        var edgeRegions = {\n                //north: null,\n                //south: null,\n                //east: null,\n                //west: null\n            },\n            length = items.length,\n            touchedRegions = this.touchedRegions,\n            i, j, center, count, edge, comp, region, splitter, touched;\n\n        for (i = 0; i < length; ++i) {\n            comp = items[i].target;\n            region = comp.region;\n\n            if (comp.isCenter) {\n                center = comp;\n            } else if (region) {\n                touched = touchedRegions[region];\n\n                for (j = 0, count = touched.length; j < count; ++j) {\n                    edge = edgeRegions[touched[j]];\n                    if (edge) {\n                        edge.neighbors.push(comp);\n                    }\n                }\n                \n                if (comp.placeholderFor) {\n                    // placeholder, so grab the splitter for the actual panel\n                    splitter = comp.placeholderFor.splitter;\n                } else {\n                    splitter = comp.splitter;\n                }\n                if (splitter) {\n                    splitter.neighbors = [];\n                }\n\n                edgeRegions[region] = splitter;\n            }\n        }\n\n        if (center) {\n            touched = touchedRegions.center;\n\n            for (j = 0, count = touched.length; j < count; ++j) {\n                edge = edgeRegions[touched[j]];\n                if (edge) {\n                    edge.neighbors.push(center);\n                }\n            }\n        }\n    },\n\n    /**\n     * Lists the regions that would consider an interior region a neighbor. For example,\n     * a north region would consider an east or west region its neighbords (as well as\n     * an inner north region).\n     * @private\n     */\n    touchedRegions: {\n        center: [ 'north', 'south', 'east',  'west' ],\n\n        north:  [ 'north', 'east',  'west'  ],\n        south:  [ 'south', 'east',  'west'  ],\n        east:   [ 'east',  'north', 'south' ],\n        west:   [ 'west',  'north', 'south' ]\n    },\n\n    sizePolicies: {\n        vert: {\n            setsWidth: 1,\n            setsHeight: 0\n        },\n        horz: {\n            setsWidth: 0,\n            setsHeight: 1\n        },\n        flexAll: {\n            setsWidth: 1,\n            setsHeight: 1\n        }\n    },\n\n    getItemSizePolicy: function (item) {\n        var me = this,\n            policies = this.sizePolicies,\n            collapseTarget, size, policy, placeholderFor;\n\n        if (item.isCenter) {\n            placeholderFor = item.placeholderFor;\n\n            if (placeholderFor) {\n                if (placeholderFor.collapsedVertical()) {\n                    return policies.vert;\n                }\n                return policies.horz;\n            }\n            if (item.collapsed) {\n                if (item.collapsedVertical()) {\n                    return policies.vert;\n                }\n                return policies.horz;\n            }\n            return policies.flexAll;\n        }\n\n        collapseTarget = item.collapseTarget;\n\n        if (collapseTarget) {\n            return collapseTarget.isVert ? policies.vert : policies.horz;\n        }\n\n        if (item.region) {\n            if (item.isVert) {\n                size = item.height;\n                policy = policies.vert;\n            } else {\n                size = item.width;\n                policy = policies.horz;\n            }\n\n            if (item.flex || (typeof size == 'string' && me.percentageRe.test(size))) {\n                return policies.flexAll;\n            }\n\n            return policy;\n        }\n\n        return me.autoSizePolicy;\n    }\n}, function () {\n    var methods = {\n        addUnflexed: function (px) {\n            this.flexSpace = Math.max(this.flexSpace - px, 0);\n        }\n    },\n    props = this.prototype.axisProps;\n\n    Ext.apply(props.horz, methods);\n    Ext.apply(props.vert, methods);\n});\n\n/**\n * This layout manages multiple child Components, each fitted to the Container, where only a single child Component can be\n * visible at any given time.  This layout style is most commonly used for wizards, tab implementations, etc.\n * This class is intended to be extended or created via the layout:'card' {@link Ext.container.Container#layout} config,\n * and should generally not need to be created directly via the new keyword.\n *\n * The CardLayout's focal method is {@link #setActiveItem}.  Since only one panel is displayed at a time,\n * the only way to move from one Component to the next is by calling setActiveItem, passing the next panel to display\n * (or its id or index).  The layout itself does not provide a user interface for handling this navigation,\n * so that functionality must be provided by the developer.\n *\n * To change the active card of a container, call the setActiveItem method of its layout:\n *\n *     @example\n *     var p = Ext.create('Ext.panel.Panel', {\n *         layout: 'card',\n *         items: [\n *             { html: 'Card 1' },\n *             { html: 'Card 2' }\n *         ],\n *         renderTo: Ext.getBody()\n *     });\n *\n *     p.getLayout().setActiveItem(1);\n *\n * In the following example, a simplistic wizard setup is demonstrated.  A button bar is added\n * to the footer of the containing panel to provide navigation buttons.  The buttons will be handled by a\n * common navigation routine.  Note that other uses of a CardLayout (like a tab control) would require a\n * completely different implementation.  For serious implementations, a better approach would be to extend\n * CardLayout to provide the custom functionality needed.\n *\n *     @example\n *     var navigate = function(panel, direction){\n *         // This routine could contain business logic required to manage the navigation steps.\n *         // It would call setActiveItem as needed, manage navigation button state, handle any\n *         // branching logic that might be required, handle alternate actions like cancellation\n *         // or finalization, etc.  A complete wizard implementation could get pretty\n *         // sophisticated depending on the complexity required, and should probably be\n *         // done as a subclass of CardLayout in a real-world implementation.\n *         var layout = panel.getLayout();\n *         layout[direction]();\n *         Ext.getCmp('move-prev').setDisabled(!layout.getPrev());\n *         Ext.getCmp('move-next').setDisabled(!layout.getNext());\n *     };\n *\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Example Wizard',\n *         width: 300,\n *         height: 200,\n *         layout: 'card',\n *         bodyStyle: 'padding:15px',\n *         defaults: {\n *             // applied to each contained panel\n *             border: false\n *         },\n *         // just an example of one possible navigation scheme, using buttons\n *         bbar: [\n *             {\n *                 id: 'move-prev',\n *                 text: 'Back',\n *                 handler: function(btn) {\n *                     navigate(btn.up(\"panel\"), \"prev\");\n *                 },\n *                 disabled: true\n *             },\n *             '->', // greedy spacer so that the buttons are aligned to each side\n *             {\n *                 id: 'move-next',\n *                 text: 'Next',\n *                 handler: function(btn) {\n *                     navigate(btn.up(\"panel\"), \"next\");\n *                 }\n *             }\n *         ],\n *         // the panels (or \"cards\") within the layout\n *         items: [{\n *             id: 'card-0',\n *             html: '<h1>Welcome to the Wizard!</h1><p>Step 1 of 3</p>'\n *         },{\n *             id: 'card-1',\n *             html: '<p>Step 2 of 3</p>'\n *         },{\n *             id: 'card-2',\n *             html: '<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>'\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.layout.container.Card', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.layout.container.Fit',\n\n    alternateClassName: 'Ext.layout.CardLayout',\n\n    alias: 'layout.card',\n\n    /* End Definitions */\n\n    type: 'card',\n\n    hideInactive: true,\n\n    /**\n     * @cfg {Boolean} deferredRender\n     * True to render each contained item at the time it becomes active, false to render all contained items\n     * as soon as the layout is rendered (defaults to false).  If there is a significant amount of content or\n     * a lot of heavy controls being rendered into panels that are not displayed by default, setting this to\n     * true might improve performance.\n     */\n    deferredRender : false,\n    \n    getRenderTree: function () {\n        var me = this,\n            activeItem = me.getActiveItem();\n\n        if (activeItem) {\n\n            // If they veto the activate, we have no active item\n            if (activeItem.hasListeners.beforeactivate && activeItem.fireEvent('beforeactivate', activeItem) === false) {\n \n                // We must null our activeItem reference, AND the one in our owning Container.\n                // Because upon layout invalidation, renderChildren will use this.getActiveItem which\n                // uses this.activeItem || this.owner.activeItem\n                activeItem = me.activeItem = me.owner.activeItem = null;\n            }\n            \n            // Item is to be the active one. Fire event after it is first layed out\n            else if (activeItem.hasListeners.activate) {\n                activeItem.on({\n                    boxready: function() {\n                        activeItem.fireEvent('activate', activeItem);\n                    },\n                    single: true\n                });\n            }\n\n            if (me.deferredRender) {\n                if (activeItem) {\n                    return me.getItemsRenderTree([activeItem]);\n                }\n            } else {\n                return me.callParent(arguments);\n            }\n        }\n    },\n\n    renderChildren: function () {\n        var me = this,\n            active = me.getActiveItem();\n            \n        if (!me.deferredRender) {\n            me.callParent();\n        } else if (active) {\n            // ensure the active item is configured for the layout\n            me.renderItems([active], me.getRenderTarget());\n        }\n    },\n\n    isValidParent : function(item, target, position) {\n        // Note: Card layout does not care about order within the target because only one is ever visible.\n        // We only care whether the item is a direct child of the target.\n        var itemEl = item.el ? item.el.dom : Ext.getDom(item);\n        return (itemEl && itemEl.parentNode === (target.dom || target)) || false;\n    },\n\n    /**\n     * Return the active (visible) component in the layout.\n     * @returns {Ext.Component}\n     */\n    getActiveItem: function() {\n        var me = this,\n            // Ensure the calculated result references a Component\n            result = me.parseActiveItem(me.activeItem || (me.owner && me.owner.activeItem));\n\n        // Sanitize the result in case the active item is no longer there.\n        if (result && me.owner.items.indexOf(result) != -1) {\n            me.activeItem = result;\n        } else {\n            me.activeItem = null;\n        }\n\n        return me.activeItem;\n    },\n\n    // @private\n    parseActiveItem: function(item) {\n        if (item && item.isComponent) {\n            return item;\n        } else if (typeof item == 'number' || item === undefined) {\n            return this.getLayoutItems()[item || 0];\n        } else {\n            return this.owner.getComponent(item);\n        }\n    },\n\n    // @private. Called before both dynamic render, and bulk render.\n    // Ensure that the active item starts visible, and inactive ones start invisible\n    configureItem: function(item) {\n        if (item === this.getActiveItem()) {\n            item.hidden = false;\n        } else {\n            item.hidden = true;\n        }\n        this.callParent(arguments);\n    },\n\n    onRemove: function(component) {\n        var me = this;\n        \n        if (component === me.activeItem) {\n            me.activeItem = null;\n        }\n    },\n\n    // @private\n    getAnimation: function(newCard, owner) {\n        var newAnim = (newCard || {}).cardSwitchAnimation;\n        if (newAnim === false) {\n            return false;\n        }\n        return newAnim || owner.cardSwitchAnimation;\n    },\n\n    /**\n     * Return the active (visible) component in the layout to the next card\n     * @returns {Ext.Component} The next component or false.\n     */\n    getNext: function() {\n        //NOTE: Removed the JSDoc for this function's arguments because it is not actually supported in 4.0. This \n        //should come back in 4.1\n        var wrap = arguments[0],\n            items = this.getLayoutItems(),\n            index = Ext.Array.indexOf(items, this.activeItem);\n            \n        return items[index + 1] || (wrap ? items[0] : false);\n    },\n\n    /**\n     * Sets the active (visible) component in the layout to the next card\n     * @return {Ext.Component} the activated component or false when nothing activated.\n     */\n    next: function() {\n        //NOTE: Removed the JSDoc for this function's arguments because it is not actually supported in 4.0. This \n        //should come back in 4.1\n        var anim = arguments[0], \n            wrap = arguments[1];\n        return this.setActiveItem(this.getNext(wrap), anim);\n    },\n\n    /**\n     * Return the active (visible) component in the layout to the previous card\n     * @returns {Ext.Component} The previous component or false.\n     */\n    getPrev: function() {\n        //NOTE: Removed the JSDoc for this function's arguments because it is not actually supported in 4.0. This \n        //should come back in 4.1\n        var wrap = arguments[0],\n            items = this.getLayoutItems(),\n            index = Ext.Array.indexOf(items, this.activeItem);\n            \n        return items[index - 1] || (wrap ? items[items.length - 1] : false);\n    },\n\n    /**\n     * Sets the active (visible) component in the layout to the previous card\n     * @return {Ext.Component} the activated component or false when nothing activated.\n     */\n    prev: function() {\n        //NOTE: Removed the JSDoc for this function's arguments because it is not actually supported in 4.0. This \n        //should come back in 4.1\n        var anim = arguments[0], \n            wrap = arguments[1];\n        return this.setActiveItem(this.getPrev(wrap), anim);\n    },\n\n    /**\n     * Makes the given card active.\n     *\n     *     var card1 = Ext.create('Ext.panel.Panel', {itemId: 'card-1'});\n     *     var card2 = Ext.create('Ext.panel.Panel', {itemId: 'card-2'});\n     *     var panel = Ext.create('Ext.panel.Panel', {\n     *         layout: 'card',\n     *         activeItem: 0,\n     *         items: [card1, card2]\n     *     });\n     *     // These are all equivalent\n     *     panel.getLayout().setActiveItem(card2);\n     *     panel.getLayout().setActiveItem('card-2');\n     *     panel.getLayout().setActiveItem(1);\n     *\n     * @param {Ext.Component/Number/String} newCard  The component, component {@link Ext.Component#id id},\n     * {@link Ext.Component#itemId itemId}, or index of component.\n     * @return {Ext.Component} the activated component or false when nothing activated.\n     * False is returned also when trying to activate an already active card.\n     */\n    setActiveItem: function(newCard) {\n        var me = this,\n            owner = me.owner,\n            oldCard = me.activeItem,\n            rendered = owner.rendered,\n            newIndex;\n\n        newCard = me.parseActiveItem(newCard);\n        newIndex = owner.items.indexOf(newCard);\n\n        // If the card is not a child of the owner, then add it.\n        // Without doing a layout!\n        if (newIndex == -1) {\n            newIndex = owner.items.items.length;\n            Ext.suspendLayouts();\n            newCard = owner.add(newCard);\n            Ext.resumeLayouts();\n        }\n\n        // Is this a valid, different card?\n        if (newCard && oldCard != newCard) {\n            // Fire the beforeactivate and beforedeactivate events on the cards\n            if (newCard.fireEvent('beforeactivate', newCard, oldCard) === false) {\n                return false;\n            }\n            if (oldCard && oldCard.fireEvent('beforedeactivate', oldCard, newCard) === false) {\n                return false;\n            }\n\n            if (rendered) {\n                Ext.suspendLayouts();\n\n                // If the card has not been rendered yet, now is the time to do so.\n                if (!newCard.rendered) {\n                    me.renderItem(newCard, me.getRenderTarget(), owner.items.length);\n                }\n\n                if (oldCard) {\n                    if (me.hideInactive) {\n                        oldCard.hide();\n                        oldCard.hiddenByLayout = true;\n                    }\n                    oldCard.fireEvent('deactivate', oldCard, newCard);\n                }\n                // Make sure the new card is shown\n                if (newCard.hidden) {\n                    newCard.show();\n                }\n\n                // Layout needs activeItem to be correct, so set it if the show has not been vetoed\n                if (!newCard.hidden) {\n                    me.activeItem = newCard;\n                }\n                Ext.resumeLayouts(true);\n            } else {\n                me.activeItem = newCard;\n            }\n\n            newCard.fireEvent('activate', newCard, oldCard);\n\n            return me.activeItem;\n        }\n        return false;\n    }\n});\n\n/**\n * This is the layout style of choice for creating structural layouts in a multi-column format where the width of each\n * column can be specified as a percentage or fixed width, but the height is allowed to vary based on the content. This\n * class is intended to be extended or created via the layout:'column' {@link Ext.container.Container#layout} config,\n * and should generally not need to be created directly via the new keyword.\n *\n * ColumnLayout does not have any direct config options (other than inherited ones), but it does support a specific\n * config property of `columnWidth` that can be included in the config of any panel added to it. The layout will use\n * the columnWidth (if present) or width of each panel during layout to determine how to size each panel. If width or\n * columnWidth is not specified for a given panel, its width will default to the panel's width (or auto).\n *\n * The width property is always evaluated as pixels, and must be a number greater than or equal to 1. The columnWidth\n * property is always evaluated as a percentage, and must be a decimal value greater than 0 and less than 1 (e.g., .25).\n *\n * The basic rules for specifying column widths are pretty simple. The logic makes two passes through the set of\n * contained panels. During the first layout pass, all panels that either have a fixed width or none specified (auto)\n * are skipped, but their widths are subtracted from the overall container width.\n *\n * During the second pass, all panels with columnWidths are assigned pixel widths in proportion to their percentages\n * based on the total **remaining** container width. In other words, percentage width panels are designed to fill\n * the space left over by all the fixed-width and/or auto-width panels. Because of this, while you can specify any\n * number of columns with different percentages, the columnWidths must always add up to 1 (or 100%) when added\n * together, otherwise your layout may not render as expected.\n *\n *     @example\n *     // All columns are percentages -- they must add up to 1\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Column Layout - Percentage Only',\n *         width: 350,\n *         height: 250,\n *         layout:'column',\n *         items: [{\n *             title: 'Column 1',\n *             columnWidth: 0.25\n *         },{\n *             title: 'Column 2',\n *             columnWidth: 0.55\n *         },{\n *             title: 'Column 3',\n *             columnWidth: 0.20\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n *\n *     // Mix of width and columnWidth -- all columnWidth values must add up\n *     // to 1. The first column will take up exactly 120px, and the last two\n *     // columns will fill the remaining container width.\n *\n *     Ext.create('Ext.Panel', {\n *         title: 'Column Layout - Mixed',\n *         width: 350,\n *         height: 250,\n *         layout:'column',\n *         items: [{\n *             title: 'Column 1',\n *             width: 120\n *         },{\n *             title: 'Column 2',\n *             columnWidth: 0.7\n *         },{\n *             title: 'Column 3',\n *             columnWidth: 0.3\n *         }],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.layout.container.Column', {\n\n    extend: 'Ext.layout.container.Container',\n    alias: ['layout.column'],\n    alternateClassName: 'Ext.layout.ColumnLayout',\n\n    type: 'column',\n\n    itemCls: Ext.baseCSSPrefix + 'column',\n\n    targetCls: Ext.baseCSSPrefix + 'column-layout-ct',\n\n    // Columns with a columnWidth have their width managed.\n    columnWidthSizePolicy: {\n        setsWidth: 1,\n        setsHeight: 0\n    },\n\n    childEls: [\n        'innerCt'\n    ],\n\n    manageOverflow: 2,\n\n    renderTpl: [\n        '<div id=\"{ownerId}-innerCt\" class=\"',Ext.baseCSSPrefix,'column-inner\">',\n            '{%this.renderBody(out,values)%}',\n            '<div class=\"',Ext.baseCSSPrefix,'clear\"></div>',\n        '</div>',\n        '{%this.renderPadder(out,values)%}'\n    ],\n\n    getItemSizePolicy: function (item) {\n        if (item.columnWidth) {\n            return this.columnWidthSizePolicy;\n        }\n        return this.autoSizePolicy;\n    },\n\n    beginLayout: function() {\n        this.callParent(arguments);\n        this.innerCt.dom.style.width = '';\n    },\n\n    calculate: function (ownerContext) {\n        var me = this,\n            containerSize = me.getContainerSize(ownerContext),\n            state = ownerContext.state;\n\n        if (state.calculatedColumns || (state.calculatedColumns = me.calculateColumns(ownerContext))) {\n            if (me.calculateHeights(ownerContext)) {\n                me.calculateOverflow(ownerContext, containerSize);\n                return;\n            }\n        }\n\n        me.done = false;\n    },\n\n    calculateColumns: function (ownerContext) {\n        var me = this,\n            containerSize = me.getContainerSize(ownerContext),\n            innerCtContext = ownerContext.getEl('innerCt', me),\n            items = ownerContext.childItems,\n            len = items.length,\n            contentWidth = 0,\n            blocked, availableWidth, i, itemContext, itemMarginWidth, itemWidth;\n\n        // Can never decide upon necessity of vertical scrollbar (and therefore, narrower\n        // content width) until the component layout has published a height for the target\n        // element.\n        if (!ownerContext.heightModel.shrinkWrap && !ownerContext.targetContext.hasProp('height')) {\n            return false;\n        }\n\n        // No parallel measurement, cannot lay out boxes.\n        if (!containerSize.gotWidth) { //\\\\ TODO: Deal with target padding width\n            ownerContext.targetContext.block(me, 'width');\n            blocked = true;\n        } else {\n            availableWidth = containerSize.width;\n\n            innerCtContext.setWidth(availableWidth);\n        }\n\n        // we need the widths of the columns we don't manage to proceed so we block on them\n        // if they are not ready...\n        for (i = 0; i < len; ++i) {\n            itemContext = items[i];\n\n            // this is needed below for non-calculated columns, but is also needed in the\n            // next loop for calculated columns... this way we only call getMarginInfo in\n            // this loop and use the marginInfo property in the next...\n            itemMarginWidth = itemContext.getMarginInfo().width;\n\n            if (!itemContext.widthModel.calculated) {\n                itemWidth = itemContext.getProp('width');\n                if (typeof itemWidth != 'number') {\n                    itemContext.block(me, 'width');\n                    blocked = true;\n                }\n\n                contentWidth += itemWidth + itemMarginWidth;\n            }\n        }\n\n        if (!blocked) {\n            availableWidth = (availableWidth < contentWidth) ? 0 : availableWidth - contentWidth;\n\n            for (i = 0; i < len; ++i) {\n                itemContext = items[i];\n                if (itemContext.widthModel.calculated) {\n                    itemMarginWidth = itemContext.marginInfo.width; // always set by above loop\n                    itemWidth = itemContext.target.columnWidth;\n                    itemWidth = Math.floor(itemWidth * availableWidth) - itemMarginWidth;\n                    itemWidth = itemContext.setWidth(itemWidth); // constrains to min/maxWidth\n                    contentWidth += itemWidth + itemMarginWidth;\n                }\n            }\n\n            ownerContext.setContentWidth(contentWidth);\n        }\n\n        // we registered all the values that block this calculation, so abort now if blocked...\n        return !blocked;\n    },\n\n    calculateHeights: function (ownerContext) {\n        var me = this,\n            items = ownerContext.childItems,\n            len = items.length,\n            blocked, i, itemContext;\n\n        // in order for innerCt to have the proper height, all the items must have height\n        // correct in the DOM...\n        blocked = false;\n        for (i = 0; i < len; ++i) {\n            itemContext = items[i];\n\n            if (!itemContext.hasDomProp('height')) {\n                itemContext.domBlock(me, 'height');\n                blocked = true;\n            }\n        }\n\n        if (!blocked) {\n            ownerContext.setContentHeight(me.innerCt.getHeight() + ownerContext.targetContext.getPaddingInfo().height);\n        }\n\n        return !blocked;\n    },\n\n    finishedLayout: function (ownerContext) {\n        var bc = ownerContext.bodyContext;\n\n        // Owner may not have a body - this seems to only be needed for Panels.\n        if (bc && (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks)) {\n            // Fix for https://sencha.jira.com/browse/EXTJSIV-4979\n            bc.el.repaint();\n        }\n\n        this.callParent(arguments);\n    },\n\n    getRenderTarget : function() {\n        return this.innerCt;\n    }\n});\n\n/**\n * This is a layout that will render form Fields, one under the other all stretched to the Container width.\n *\n *     @example\n *     Ext.create('Ext.Panel', {\n *         width: 500,\n *         height: 300,\n *         title: \"FormLayout Panel\",\n *         layout: 'form',\n *         renderTo: Ext.getBody(),\n *         bodyPadding: 5,\n *         defaultType: 'textfield',\n *         items: [{\n *            fieldLabel: 'First Name',\n *             name: 'first',\n *             allowBlank:false\n *         },{\n *             fieldLabel: 'Last Name',\n *             name: 'last'\n *         },{\n *             fieldLabel: 'Company',\n *             name: 'company'\n *         }, {\n *             fieldLabel: 'Email',\n *             name: 'email',\n *             vtype:'email'\n *         }, {\n *             fieldLabel: 'DOB',\n *             name: 'dob',\n *             xtype: 'datefield'\n *         }, {\n *             fieldLabel: 'Age',\n *             name: 'age',\n *             xtype: 'numberfield',\n *             minValue: 0,\n *             maxValue: 100\n *         }, {\n *             xtype: 'timefield',\n *             fieldLabel: 'Time',\n *             name: 'time',\n *             minValue: '8:00am',\n *             maxValue: '6:00pm'\n *         }]\n *     });\n *\n * Note that any configured {@link Ext.Component#padding padding} will be ignored on items within a Form layout.\n */\nExt.define('Ext.layout.container.Form', {\n\n    /* Begin Definitions */\n\n    alias: 'layout.form',\n    extend: 'Ext.layout.container.Auto',\n    alternateClassName: 'Ext.layout.FormLayout',\n\n    /* End Definitions */\n   \n    tableCls: Ext.baseCSSPrefix + 'form-layout-table',\n\n    type: 'form',\n\n    manageOverflow: 2,\n\n    childEls: ['formTable'],\n    \n    padRow: '<tr><td class=\"' + Ext.baseCSSPrefix + 'form-item-pad\" colspan=\"3\"></td></tr>',\n\n    renderTpl: [\n        '<table id=\"{ownerId}-formTable\" class=\"{tableCls}\" style=\"width:100%\" cellpadding=\"0\">',\n            '{%this.renderBody(out,values)%}',\n        '</table>',\n        '{%this.renderPadder(out,values)%}'\n    ],\n    \n    getRenderData: function(){\n        var data = this.callParent();\n        data.tableCls = this.tableCls;\n        return data;    \n    },\n\n    calculate : function (ownerContext) {\n        var me = this,\n            containerSize = me.getContainerSize(ownerContext, true),\n            tableWidth,\n            childItems,\n            i = 0, length;\n\n        // Once we have been widthed, we can impose that width (in a non-dirty setting) upon all children at once\n        if (containerSize.gotWidth) {\n            this.callParent(arguments);\n            tableWidth = me.formTable.dom.offsetWidth;\n            childItems = ownerContext.childItems;\n\n            for (length = childItems.length; i < length; ++i) {\n                childItems[i].setWidth(tableWidth, false);\n            }\n        } else {\n            me.done = false;\n        }\n    },\n\n    getRenderTarget: function() {\n        return this.formTable;\n    },\n\n    getRenderTree: function() {\n        var me = this,\n            result = me.callParent(arguments),\n            i, len;\n\n        for (i = 0, len = result.length; i < len; i++) {\n            result[i] = me.transformItemRenderTree(result[i]);\n        }\n        return result;\n    },\n\n    transformItemRenderTree: function(item) {\n\n        if (item.tag && item.tag == 'table') {\n            item.tag = 'tbody';\n            delete item.cellspacing;\n            delete item.cellpadding;\n\n            // IE6 doesn't separate cells nicely to provide input field\n            // vertical separation. It also does not support transparent borders\n            // which is how the extra 1px is added to the 2px each side cell spacing.\n            // So it needs a 5px high pad row.\n            if (Ext.isIE6) {\n                item.cn = this.padRow;\n            }\n\n            return item;\n        }\n\n        return {\n            tag: 'tbody',\n            cn: {\n                tag: 'tr',\n                cn: {\n                    tag: 'td',\n                    colspan: 3,\n                    style: 'width:100%',\n                    cn: item\n                }\n            }\n        };\n\n    },\n\n    isValidParent: function(item, target, position) {\n        return true;\n    },\n\n    isItemShrinkWrap: function(item) {\n        return ((item.shrinkWrap === true) ? 3 : item.shrinkWrap||0) & 2;\n    },\n\n    getItemSizePolicy: function(item) {\n        return {\n            setsWidth: 1,\n            setsHeight: 0\n        };\n    }\n});\n\n/**\n * A base class for all menu items that require menu-related functionality such as click handling,\n * sub-menus, icons, etc.\n *\n *     @example\n *     Ext.create('Ext.menu.Menu', {\n *         width: 100,\n *         height: 100,\n *         floating: false,  // usually you want this set to True (default)\n *         renderTo: Ext.getBody(),  // usually rendered by it's containing component\n *         items: [{\n *             text: 'icon item',\n *             iconCls: 'add16'\n *         },{\n *             text: 'text item'\n *         },{\n *             text: 'plain item',\n *             plain: true\n *         }]\n *     });\n */\nExt.define('Ext.menu.Item', {\n    extend: 'Ext.Component',\n    alias: 'widget.menuitem',\n    alternateClassName: 'Ext.menu.TextItem',\n\n    /**\n     * @property {Boolean} activated\n     * Whether or not this item is currently activated\n     */\n\n    /**\n     * @property {Ext.menu.Menu} parentMenu\n     * The parent Menu of this item.\n     */\n\n    /**\n     * @cfg {String} activeCls\n     * The CSS class added to the menu item when the item is activated (focused/mouseover).\n     */\n    activeCls: Ext.baseCSSPrefix + 'menu-item-active',\n\n    /**\n     * @cfg {String} ariaRole\n     * @private\n     */\n    ariaRole: 'menuitem',\n\n    /**\n     * @cfg {Boolean} canActivate\n     * Whether or not this menu item can be activated when focused/mouseovered.\n     */\n    canActivate: true,\n\n    /**\n     * @cfg {Number} clickHideDelay\n     * The delay in milliseconds to wait before hiding the menu after clicking the menu item.\n     * This only has an effect when `hideOnClick: true`.\n     */\n    clickHideDelay: 1,\n\n    /**\n     * @cfg {Boolean} destroyMenu\n     * Whether or not to destroy any associated sub-menu when this item is destroyed.\n     */\n    destroyMenu: true,\n\n    /**\n     * @cfg {String} disabledCls\n     * The CSS class added to the menu item when the item is disabled.\n     */\n    disabledCls: Ext.baseCSSPrefix + 'menu-item-disabled',\n\n    /**\n     * @cfg {String} [href='#']\n     * The href attribute to use for the underlying anchor link.\n     */\n\n    /**\n     * @cfg {String} hrefTarget\n     * The target attribute to use for the underlying anchor link.\n     */\n\n    /**\n     * @cfg {Boolean} hideOnClick\n     * Whether to not to hide the owning menu when this item is clicked.\n     */\n    hideOnClick: true,\n\n    /**\n     * @cfg {String} icon\n     * The path to an icon to display in this item.\n     *\n     * Defaults to `Ext.BLANK_IMAGE_URL`.\n     */\n\n    /**\n     * @cfg {String} iconCls\n     * A CSS class that specifies a `background-image` to use as the icon for this item.\n     */\n\n    isMenuItem: true,\n\n    /**\n     * @cfg {Ext.menu.Menu/Object} menu\n     * Either an instance of {@link Ext.menu.Menu} or a config object for an {@link Ext.menu.Menu}\n     * which will act as a sub-menu to this item.\n     */\n\n    /**\n     * @property {Ext.menu.Menu} menu The sub-menu associated with this item, if one was configured.\n     */\n\n    /**\n     * @cfg {String} menuAlign\n     * The default {@link Ext.Element#getAlignToXY Ext.Element.getAlignToXY} anchor position value for this\n     * item's sub-menu relative to this item's position.\n     */\n    menuAlign: 'tl-tr?',\n\n    /**\n     * @cfg {Number} menuExpandDelay\n     * The delay in milliseconds before this item's sub-menu expands after this item is moused over.\n     */\n    menuExpandDelay: 200,\n\n    /**\n     * @cfg {Number} menuHideDelay\n     * The delay in milliseconds before this item's sub-menu hides after this item is moused out.\n     */\n    menuHideDelay: 200,\n\n    /**\n     * @cfg {Boolean} plain\n     * Whether or not this item is plain text/html with no icon or visual activation.\n     */\n\n    /**\n     * @cfg {String/Object} tooltip\n     * The tooltip for the button - can be a string to be used as innerHTML (html tags are accepted) or\n     * QuickTips config object.\n     */\n\n    /**\n     * @cfg {String} tooltipType\n     * The type of tooltip to use. Either 'qtip' for QuickTips or 'title' for title attribute.\n     */\n    tooltipType: 'qtip',\n\n    arrowCls: Ext.baseCSSPrefix + 'menu-item-arrow',\n\n    childEls: [\n        'itemEl', 'iconEl', 'textEl', 'arrowEl'\n    ],\n\n    renderTpl: [\n        '<tpl if=\"plain\">',\n            '{text}',\n        '<tpl else>',\n            '<a id=\"{id}-itemEl\" class=\"' + Ext.baseCSSPrefix + 'menu-item-link\" href=\"{href}\" <tpl if=\"hrefTarget\">target=\"{hrefTarget}\"</tpl> hidefocus=\"true\" unselectable=\"on\">',\n                '<img id=\"{id}-iconEl\" src=\"{icon}\" class=\"' + Ext.baseCSSPrefix + 'menu-item-icon {iconCls}\" />',\n                '<span id=\"{id}-textEl\" class=\"' + Ext.baseCSSPrefix + 'menu-item-text\" <tpl if=\"arrowCls\">style=\"margin-right: 17px;\"</tpl> >{text}</span>',\n                '<img id=\"{id}-arrowEl\" src=\"{blank}\" class=\"{arrowCls}\" />',\n            '</a>',\n        '</tpl>'\n    ],\n\n    maskOnDisable: false,\n\n    /**\n     * @cfg {String} text\n     * The text/html to display in this item.\n     */\n\n    /**\n     * @cfg {Function} handler\n     * A function called when the menu item is clicked (can be used instead of {@link #click} event).\n     * @cfg {Ext.menu.Item} handler.item The item that was clicked\n     * @cfg {Ext.EventObject} handler.e The underyling {@link Ext.EventObject}.\n     */\n\n    activate: function() {\n        var me = this;\n\n        if (!me.activated && me.canActivate && me.rendered && !me.isDisabled() && me.isVisible()) {\n            me.el.addCls(me.activeCls);\n            me.focus();\n            me.activated = true;\n            me.fireEvent('activate', me);\n        }\n    },\n\n    getFocusEl: function() {\n        return this.itemEl;\n    },\n\n    deactivate: function() {\n        var me = this;\n\n        if (me.activated) {\n            me.el.removeCls(me.activeCls);\n            me.blur();\n            me.hideMenu();\n            me.activated = false;\n            me.fireEvent('deactivate', me);\n        }\n    },\n\n    deferExpandMenu: function() {\n        var me = this;\n\n        if (me.activated && (!me.menu.rendered || !me.menu.isVisible())) {\n            me.parentMenu.activeChild = me.menu;\n            me.menu.parentItem = me;\n            me.menu.parentMenu = me.menu.ownerCt = me.parentMenu;\n            me.menu.showBy(me, me.menuAlign);\n        }\n    },\n\n    deferHideMenu: function() {\n        if (this.menu.isVisible()) {\n            this.menu.hide();\n        }\n    },\n    \n    cancelDeferHide: function(){\n        clearTimeout(this.hideMenuTimer);\n    },\n\n    deferHideParentMenus: function() {\n        var ancestor;\n        Ext.menu.Manager.hideAll();\n\n        if (!Ext.Element.getActiveElement()) {\n            // If we have just hidden all Menus, and there is no currently focused element in the dom, transfer focus to the first visible ancestor if any.\n            ancestor = this.up(':not([hidden])');\n            if (ancestor) {\n                ancestor.focus();\n            }\n        }\n    },\n\n    expandMenu: function(delay) {\n        var me = this;\n\n        if (me.menu) {\n            me.cancelDeferHide();\n            if (delay === 0) {\n                me.deferExpandMenu();\n            } else {\n                me.expandMenuTimer = Ext.defer(me.deferExpandMenu, Ext.isNumber(delay) ? delay : me.menuExpandDelay, me);\n            }\n        }\n    },\n\n    getRefItems: function(deep){\n        var menu = this.menu,\n            items;\n\n        if (menu) {\n            items = menu.getRefItems(deep);\n            items.unshift(menu);\n        }\n        return items || [];\n    },\n\n    hideMenu: function(delay) {\n        var me = this;\n\n        if (me.menu) {\n            clearTimeout(me.expandMenuTimer);\n            me.hideMenuTimer = Ext.defer(me.deferHideMenu, Ext.isNumber(delay) ? delay : me.menuHideDelay, me);\n        }\n    },\n\n    initComponent: function() {\n        var me = this,\n            prefix = Ext.baseCSSPrefix,\n            cls = [prefix + 'menu-item'],\n            menu;\n\n        me.addEvents(\n            /**\n             * @event activate\n             * Fires when this item is activated\n             * @param {Ext.menu.Item} item The activated item\n             */\n            'activate',\n\n            /**\n             * @event click\n             * Fires when this item is clicked\n             * @param {Ext.menu.Item} item The item that was clicked\n             * @param {Ext.EventObject} e The underyling {@link Ext.EventObject}.\n             */\n            'click',\n\n            /**\n             * @event deactivate\n             * Fires when this tiem is deactivated\n             * @param {Ext.menu.Item} item The deactivated item\n             */\n            'deactivate'\n        );\n\n        if (me.plain) {\n            cls.push(prefix + 'menu-item-plain');\n        }\n\n        if (me.cls) {\n            cls.push(me.cls);\n        }\n\n        me.cls = cls.join(' ');\n\n        if (me.menu) {\n            menu = me.menu;\n            delete me.menu;\n            me.setMenu(menu);\n        }\n\n        me.callParent(arguments);\n    },\n\n    onClick: function(e) {\n        var me = this;\n\n        if (!me.href) {\n            e.stopEvent();\n        }\n\n        if (me.disabled) {\n            return;\n        }\n\n        if (me.hideOnClick) {\n            me.deferHideParentMenusTimer = Ext.defer(me.deferHideParentMenus, me.clickHideDelay, me);\n        }\n\n        Ext.callback(me.handler, me.scope || me, [me, e]);\n        me.fireEvent('click', me, e);\n\n        if (!me.hideOnClick) {\n            me.focus();\n        }\n    },\n\n    onRemoved: function() {\n        var me = this;\n\n        // Removing the active item, must deactivate it.\n        if (me.activated && me.parentMenu.activeItem === me) {\n            me.parentMenu.deactivateActiveItem();\n        }\n        me.callParent(arguments);\n        delete me.parentMenu;\n        delete me.ownerButton;\n    },\n\n    // private\n    beforeDestroy: function() {\n        var me = this;\n        if (me.rendered) {\n            me.clearTip();\n        }\n        me.callParent();\n    },\n\n    onDestroy: function() {\n        var me = this;\n\n        clearTimeout(me.expandMenuTimer);\n        me.cancelDeferHide();\n        clearTimeout(me.deferHideParentMenusTimer);\n\n        me.setMenu(null);\n        me.callParent(arguments);\n    },\n\n    beforeRender: function() {\n        var me = this,\n            blank = Ext.BLANK_IMAGE_URL,\n            iconCls,\n            arrowCls;\n\n        me.callParent();\n\n        if (me.iconAlign === 'right') {\n            iconCls = me.checkChangeDisabled ? me.disabledCls : '';\n            arrowCls = Ext.baseCSSPrefix + 'menu-item-icon-right ' + me.iconCls;\n        } else {\n            iconCls = me.iconCls + (me.checkChangeDisabled ? ' ' + me.disabledCls : '');\n            arrowCls = me.menu ? me.arrowCls : '';\n        }\n        Ext.applyIf(me.renderData, {\n            href: me.href || '#',\n            hrefTarget: me.hrefTarget,\n            icon: me.icon || blank,\n            iconCls: iconCls,\n            plain: me.plain,\n            text: me.text,\n            arrowCls: arrowCls,\n            blank: blank\n        });\n    },\n\n    onRender: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        if (me.tooltip) {\n            me.setTooltip(me.tooltip, true);\n        }\n    },\n    \n    /**\n     * Set a child menu for this item. See the {@link #cfg-menu} configuration.\n     * @param {Ext.menu.Menu/Object} menu A menu, or menu configuration. null may be\n     * passed to remove the menu.\n     * @param {Boolean} [destroyMenu] True to destroy any existing menu. False to\n     * prevent destruction. If not specified, the {@link #destroyMenu} configuration\n     * will be used.\n     */\n    setMenu: function(menu, destroyMenu) {\n        var me = this,\n            oldMenu = me.menu,\n            arrowEl = me.arrowEl;\n            \n        if (oldMenu) {\n            delete oldMenu.parentItem;\n            delete oldMenu.parentMenu;\n            delete oldMenu.ownerCt;\n            delete oldMenu.ownerItem;\n            \n            if (destroyMenu === true || (destroyMenu !== false && me.destroyMenu)) {\n                Ext.destroy(oldMenu);\n            }\n        }\n        if (menu) {\n            me.menu = Ext.menu.Manager.get(menu);\n            me.menu.ownerItem = me;\n        } else {\n            me.menu = null;\n        }\n        \n        if (me.rendered && !me.destroying && arrowEl) {\n            arrowEl[me.menu ? 'addCls' : 'removeCls'](me.arrowCls);\n        }\n    },\n\n    /**\n     * Sets the {@link #click} handler of this item\n     * @param {Function} fn The handler function\n     * @param {Object} [scope] The scope of the handler function\n     */\n    setHandler: function(fn, scope) {\n        this.handler = fn || null;\n        this.scope = scope;\n    },\n    \n    /**\n     * Sets the {@link #icon} on this item.\n     * @param {String} icon The new icon \n     */\n    setIcon: function(icon){\n        var iconEl = this.iconEl;\n        if (iconEl) {\n            iconEl.src = icon || Ext.BLANK_IMAGE_URL;\n        }\n        this.icon = icon;\n    },\n\n    /**\n     * Sets the {@link #iconCls} of this item\n     * @param {String} iconCls The CSS class to set to {@link #iconCls}\n     */\n    setIconCls: function(iconCls) {\n        var me = this,\n            iconEl = me.iconEl;\n\n        if (iconEl) {\n            if (me.iconCls) {\n                iconEl.removeCls(me.iconCls);\n            }\n\n            if (iconCls) {\n                iconEl.addCls(iconCls);\n            }\n        }\n\n        me.iconCls = iconCls;\n    },\n\n    /**\n     * Sets the {@link #text} of this item\n     * @param {String} text The {@link #text}\n     */\n    setText: function(text) {\n        var me = this,\n            el = me.textEl || me.el;\n\n        me.text = text;\n\n        if (me.rendered) {\n            el.update(text || '');\n            // cannot just call layout on the component due to stretchmax\n            me.ownerCt.updateLayout();\n        }\n    },\n\n    getTipAttr: function(){\n        return this.tooltipType == 'qtip' ? 'data-qtip' : 'title';\n    },\n\n    //private\n    clearTip: function() {\n        if (Ext.isObject(this.tooltip)) {\n            Ext.tip.QuickTipManager.unregister(this.itemEl);\n        }\n    },\n\n    /**\n     * Sets the tooltip for this menu item.\n     *\n     * @param {String/Object} tooltip This may be:\n     *\n     *   - **String** : A string to be used as innerHTML (html tags are accepted) to show in a tooltip\n     *   - **Object** : A configuration object for {@link Ext.tip.QuickTipManager#register}.\n     *\n     * @return {Ext.menu.Item} this\n     */\n    setTooltip: function(tooltip, initial) {\n        var me = this;\n\n        if (me.rendered) {\n            if (!initial) {\n                me.clearTip();\n            }\n\n            if (Ext.isObject(tooltip)) {\n                Ext.tip.QuickTipManager.register(Ext.apply({\n                    target: me.itemEl.id\n                },\n                tooltip));\n                me.tooltip = tooltip;\n            } else {\n                me.itemEl.dom.setAttribute(me.getTipAttr(), tooltip);\n            }\n        } else {\n            me.tooltip = tooltip;\n        }\n\n        return me;\n    }\n});\n\n/**\n * A menu item that contains a togglable checkbox by default, but that can also be a part of a radio group.\n *\n *     @example\n *     Ext.create('Ext.menu.Menu', {\n *         width: 100,\n *         height: 110,\n *         floating: false,  // usually you want this set to True (default)\n *         renderTo: Ext.getBody(),  // usually rendered by it's containing component\n *         items: [{\n *             xtype: 'menucheckitem',\n *             text: 'select all'\n *         },{\n *             xtype: 'menucheckitem',\n *             text: 'select specific'\n *         },{\n *             iconCls: 'add16',\n *             text: 'icon item'\n *         },{\n *             text: 'regular item'\n *         }]\n *     });\n */\nExt.define('Ext.menu.CheckItem', {\n    extend: 'Ext.menu.Item',\n    alias: 'widget.menucheckitem',\n    \n    /**\n     * @cfg {Boolean} [checked=false]\n     * True to render the menuitem initially checked.\n     */\n    \n    /**\n     * @cfg {Function} checkHandler\n     * Alternative for the {@link #checkchange} event.  Gets called with the same parameters.\n     */\n\n    /**\n     * @cfg {Object} scope\n     * Scope for the {@link #checkHandler} callback.\n     */\n    \n    /**\n     * @cfg {String} group\n     * Name of a radio group that the item belongs.\n     *\n     * Specifying this option will turn check item into a radio item.\n     *\n     * Note that the group name must be globally unique.\n     */\n\n    /**\n     * @cfg {String} checkedCls\n     * The CSS class used by {@link #cls} to show the checked state.\n     * Defaults to `Ext.baseCSSPrefix + 'menu-item-checked'`.\n     */\n    checkedCls: Ext.baseCSSPrefix + 'menu-item-checked',\n    /**\n     * @cfg {String} uncheckedCls\n     * The CSS class used by {@link #cls} to show the unchecked state.\n     * Defaults to `Ext.baseCSSPrefix + 'menu-item-unchecked'`.\n     */\n    uncheckedCls: Ext.baseCSSPrefix + 'menu-item-unchecked',\n    /**\n     * @cfg {String} groupCls\n     * The CSS class applied to this item's icon image to denote being a part of a radio group.\n     * Defaults to `Ext.baseCSSClass + 'menu-group-icon'`.\n     * Any specified {@link #iconCls} overrides this.\n     */\n    groupCls: Ext.baseCSSPrefix + 'menu-group-icon',\n\n    /**\n     * @cfg {Boolean} [hideOnClick=false]\n     * Whether to not to hide the owning menu when this item is clicked.\n     * Defaults to `false` for checkbox items, and to `true` for radio group items.\n     */\n    hideOnClick: false,\n    \n    /**\n     * @cfg {Boolean} [checkChangeDisabled=false]\n     * True to prevent the checked item from being toggled. Any submenu will still be accessible.\n     */\n    checkChangeDisabled: false,\n\n    afterRender: function() {\n        var me = this;\n        me.callParent();\n        me.checked = !me.checked;\n        me.setChecked(!me.checked, true);\n        if (me.checkChangeDisabled) {\n            me.disableCheckChange();\n        }\n    },\n\n    initComponent: function() {\n        var me = this;\n        me.addEvents(\n            /**\n             * @event beforecheckchange\n             * Fires before a change event. Return false to cancel.\n             * @param {Ext.menu.CheckItem} this\n             * @param {Boolean} checked\n             */\n            'beforecheckchange',\n\n            /**\n             * @event checkchange\n             * Fires after a change event.\n             * @param {Ext.menu.CheckItem} this\n             * @param {Boolean} checked\n             */\n            'checkchange'\n        );\n\n        me.callParent(arguments);\n\n        Ext.menu.Manager.registerCheckable(me);\n\n        if (me.group) {\n            if (!me.iconCls) {\n                me.iconCls = me.groupCls;\n            }\n            if (me.initialConfig.hideOnClick !== false) {\n                me.hideOnClick = true;\n            }\n        }\n    },\n\n    /**\n     * Disables just the checkbox functionality of this menu Item. If this menu item has a submenu, that submenu\n     * will still be accessible\n     */\n    disableCheckChange: function() {\n        var me = this,\n            iconEl = me.iconEl;\n\n        if (iconEl) {\n            iconEl.addCls(me.disabledCls);\n        }\n        // In some cases the checkbox will disappear until repainted\n        // Happens in everything except IE9 strict, see: EXTJSIV-6412\n        if (!(Ext.isIE9 && Ext.isStrict) && me.rendered) {\n            me.el.repaint();\n        }\n        me.checkChangeDisabled = true;\n    },\n\n    /**\n     * Reenables the checkbox functionality of this menu item after having been disabled by {@link #disableCheckChange}\n     */\n    enableCheckChange: function() {\n        var me = this,\n            iconEl = me.iconEl;\n            \n        if (iconEl) {\n            iconEl.removeCls(me.disabledCls);\n        }\n        me.checkChangeDisabled = false;\n    },\n\n    onClick: function(e) {\n        var me = this;\n        if(!me.disabled && !me.checkChangeDisabled && !(me.checked && me.group)) {\n            me.setChecked(!me.checked);\n        }\n        this.callParent([e]);\n    },\n\n    onDestroy: function() {\n        Ext.menu.Manager.unregisterCheckable(this);\n        this.callParent(arguments);\n    },\n\n    /**\n     * Sets the checked state of the item\n     * @param {Boolean} checked True to check, false to uncheck\n     * @param {Boolean} [suppressEvents=false] True to prevent firing the checkchange events.\n     */\n    setChecked: function(checked, suppressEvents) {\n        var me = this;\n        if (me.checked !== checked && (suppressEvents || me.fireEvent('beforecheckchange', me, checked) !== false)) {\n            if (me.el) {\n                me.el[checked  ? 'addCls' : 'removeCls'](me.checkedCls)[!checked ? 'addCls' : 'removeCls'](me.uncheckedCls);\n            }\n            me.checked = checked;\n            Ext.menu.Manager.onCheckChange(me, checked);\n            if (!suppressEvents) {\n                Ext.callback(me.checkHandler, me.scope, [me, checked]);\n                me.fireEvent('checkchange', me, checked);\n            }\n        }\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.menu.KeyNav', {\n    extend: 'Ext.util.KeyNav',\n\n    requires: ['Ext.FocusManager'],\n    \n    constructor: function(menu) {\n        var me = this;\n\n        me.menu = menu;\n        me.callParent([menu.el, {\n            down: me.down,\n            enter: me.enter,\n            esc: me.escape,\n            left: me.left,\n            right: me.right,\n            space: me.enter,\n            tab: me.tab,\n            up: me.up\n        }]);\n    },\n\n    down: function(e) {\n        var me = this,\n            fi = me.menu.focusedItem;\n\n        if (fi && e.getKey() == Ext.EventObject.DOWN && me.isWhitelisted(fi)) {\n            return true;\n        }\n        me.focusNextItem(1);\n    },\n\n    enter: function(e) {\n        var menu = this.menu,\n            focused = menu.focusedItem;\n \n        if (menu.activeItem) {\n            menu.onClick(e);\n        } else if (focused && focused.isFormField) {\n            // prevent stopEvent being called\n            return true;\n        }\n    },\n\n    escape: function(e) {\n        Ext.menu.Manager.hideAll();\n    },\n\n    focusNextItem: function(step) {\n        var menu = this.menu,\n            items = menu.items,\n            focusedItem = menu.focusedItem,\n            startIdx = focusedItem ? items.indexOf(focusedItem) : -1,\n            idx = startIdx + step,\n            item;\n\n        while (idx != startIdx) {\n            if (idx < 0) {\n                idx = items.length - 1;\n            } else if (idx >= items.length) {\n                idx = 0;\n            }\n\n            item = items.getAt(idx);\n            if (menu.canActivateItem(item)) {\n                menu.setActiveItem(item);\n                break;\n            }\n            idx += step;\n        }\n    },\n\n    isWhitelisted: function(item) {\n        return Ext.FocusManager.isWhitelisted(item);\n    },\n\n    left: function(e) {\n        var menu = this.menu,\n            fi = menu.focusedItem,\n            ai = menu.activeItem;\n\n        if (fi && this.isWhitelisted(fi)) {\n            return true;\n        }\n\n        menu.hide();\n        if (menu.parentMenu) {\n            menu.parentMenu.focus();\n        }\n    },\n\n    right: function(e) {\n        var menu = this.menu,\n            fi = menu.focusedItem,\n            ai = menu.activeItem,\n            am;\n\n        if (fi && this.isWhitelisted(fi)) {\n            return true;\n        }\n\n        if (ai) {\n            am = menu.activeItem.menu;\n            if (am) {\n                ai.expandMenu(0);\n                Ext.defer(function() {\n                    am.setActiveItem(am.items.getAt(0));\n                }, 25);\n            }\n        }\n    },\n\n    tab: function(e) {\n        var me = this;\n\n        if (e.shiftKey) {\n            me.up(e);\n        } else {\n            me.down(e);\n        }\n    },\n\n    up: function(e) {\n        var me = this,\n            fi = me.menu.focusedItem;\n\n        if (fi && e.getKey() == Ext.EventObject.UP && me.isWhitelisted(fi)) {\n            return true;\n        }\n        me.focusNextItem(-1);\n    }\n});\n\n/**\n * Adds a separator bar to a menu, used to divide logical groups of menu items. Generally you will\n * add one of these by using \"-\" in your call to add() or in your items config rather than creating one directly.\n *\n *     @example\n *     Ext.create('Ext.menu.Menu', {\n *         width: 100,\n *         height: 100,\n *         floating: false,  // usually you want this set to True (default)\n *         renderTo: Ext.getBody(),  // usually rendered by it's containing component\n *         items: [{\n *             text: 'icon item',\n *             iconCls: 'add16'\n *         },{\n *             xtype: 'menuseparator'\n *         },{\n *            text: 'separator above'\n *         },{\n *            text: 'regular item'\n *         }]\n *     });\n */\nExt.define('Ext.menu.Separator', {\n    extend: 'Ext.menu.Item',\n    alias: 'widget.menuseparator',\n\n    /**\n     * @cfg {String} activeCls\n     * @private\n     */\n\n    /**\n     * @cfg {Boolean} canActivate\n     * @private\n     */\n    canActivate: false,\n\n    /**\n     * @cfg {Boolean} clickHideDelay\n     * @private\n     */\n\n    /**\n     * @cfg {Boolean} destroyMenu\n     * @private\n     */\n\n    /**\n     * @cfg {Boolean} disabledCls\n     * @private\n     */\n\n    focusable: false,\n\n    /**\n     * @cfg {String} href\n     * @private\n     */\n\n    /**\n     * @cfg {String} hrefTarget\n     * @private\n     */\n\n    /**\n     * @cfg {Boolean} hideOnClick\n     * @private\n     */\n    hideOnClick: false,\n\n    /**\n     * @cfg {String} icon\n     * @private\n     */\n\n    /**\n     * @cfg {String} iconCls\n     * @private\n     */\n\n    /**\n     * @cfg {Object} menu\n     * @private\n     */\n\n    /**\n     * @cfg {String} menuAlign\n     * @private\n     */\n\n    /**\n     * @cfg {Number} menuExpandDelay\n     * @private\n     */\n\n    /**\n     * @cfg {Number} menuHideDelay\n     * @private\n     */\n\n    /**\n     * @cfg {Boolean} plain\n     * @private\n     */\n    plain: true,\n\n    /**\n     * @cfg {String} separatorCls\n     * The CSS class used by the separator item to show the incised line.\n     */\n    separatorCls: Ext.baseCSSPrefix + 'menu-item-separator',\n\n    /**\n     * @cfg {String} text\n     * @private\n     */\n    text: '&#160;',\n\n    beforeRender: function(ct, pos) {\n        var me = this;\n\n        me.callParent();\n\n        me.addCls(me.separatorCls);\n    }\n});\n\n/**\n * A menu object. This is the container to which you may add {@link Ext.menu.Item menu items}.\n *\n * Menus may contain either {@link Ext.menu.Item menu items}, or general {@link Ext.Component Components}.\n * Menus may also contain {@link Ext.panel.AbstractPanel#dockedItems docked items} because it extends {@link Ext.panel.Panel}.\n *\n * To make a contained general {@link Ext.Component Component} line up with other {@link Ext.menu.Item menu items},\n * specify `{@link Ext.menu.Item#plain plain}: true`. This reserves a space for an icon, and indents the Component\n * in line with the other menu items.\n *\n * By default, Menus are absolutely positioned, floating Components. By configuring a Menu with `{@link #floating}: false`,\n * a Menu may be used as a child of a {@link Ext.container.Container Container}.\n *\n *     @example\n *     Ext.create('Ext.menu.Menu', {\n *         width: 100,\n *         margin: '0 0 10 0',\n *         floating: false,  // usually you want this set to True (default)\n *         renderTo: Ext.getBody(),  // usually rendered by it's containing component\n *         items: [{\n *             text: 'regular item 1'\n *         },{\n *             text: 'regular item 2'\n *         },{\n *             text: 'regular item 3'\n *         }]\n *     });\n *\n *     Ext.create('Ext.menu.Menu', {\n *         width: 100,\n *         plain: true,\n *         floating: false,  // usually you want this set to True (default)\n *         renderTo: Ext.getBody(),  // usually rendered by it's containing component\n *         items: [{\n *             text: 'plain item 1'\n *         },{\n *             text: 'plain item 2'\n *         },{\n *             text: 'plain item 3'\n *         }]\n *     });\n */\nExt.define('Ext.menu.Menu', {\n    extend: 'Ext.panel.Panel',\n    alias: 'widget.menu',\n    requires: [\n        'Ext.layout.container.Fit',\n        'Ext.layout.container.VBox',\n        'Ext.menu.CheckItem',\n        'Ext.menu.Item',\n        'Ext.menu.KeyNav',\n        'Ext.menu.Manager',\n        'Ext.menu.Separator'\n    ],\n\n    /**\n     * @property {Ext.menu.Menu} parentMenu\n     * The parent Menu of this Menu.\n     */\n    \n    /**\n     * @cfg {Boolean} [enableKeyNav=true]\n     * True to enable keyboard navigation for controlling the menu.\n     * This option should generally be disabled when form fields are\n     * being used inside the menu.\n     */\n    enableKeyNav: true,\n\n    /**\n     * @cfg {Boolean} [allowOtherMenus=false]\n     * True to allow multiple menus to be displayed at the same time.\n     */\n    allowOtherMenus: false,\n\n    /**\n     * @cfg {String} ariaRole\n     * @private\n     */\n    ariaRole: 'menu',\n\n    /**\n     * @cfg {Boolean} autoRender\n     * Floating is true, so autoRender always happens.\n     * @private\n     */\n\n    /**\n     * @cfg {String} [defaultAlign=\"tl-bl?\"]\n     * The default {@link Ext.Element#getAlignToXY Ext.Element#getAlignToXY} anchor position value for this menu\n     * relative to its element of origin.\n     */\n    defaultAlign: 'tl-bl?',\n\n    /**\n     * @cfg {Boolean} [floating=true]\n     * A Menu configured as `floating: true` (the default) will be rendered as an absolutely positioned,\n     * {@link Ext.Component#floating floating} {@link Ext.Component Component}. If configured as `floating: false`, the Menu may be\n     * used as a child item of another {@link Ext.container.Container Container}.\n     */\n    floating: true,\n\n    /**\n     * @cfg {Boolean} constrain\n     * Menus are constrained to the document body by default.\n     * @private\n     */\n    constrain: true,\n\n    /**\n     * @cfg {Boolean} [hidden=undefined]\n     * True to initially render the Menu as hidden, requiring to be shown manually.\n     *\n     * Defaults to `true` when `floating: true`, and defaults to `false` when `floating: false`.\n     */\n    hidden: true,\n\n    hideMode: 'visibility',\n\n    /**\n     * @cfg {Boolean} [ignoreParentClicks=false]\n     * True to ignore clicks on any item in this menu that is a parent item (displays a submenu)\n     * so that the submenu is not dismissed when clicking the parent item.\n     */\n    ignoreParentClicks: false,\n\n    /**\n     * @property {Boolean} isMenu\n     * `true` in this class to identify an object as an instantiated Menu, or subclass thereof.\n     */\n    isMenu: true,\n\n    /**\n     * @cfg {String/Object} layout\n     * @private\n     */\n\n    /**\n     * @cfg {Boolean} [showSeparator=true]\n     * True to show the icon separator.\n     */\n    showSeparator : true,\n\n    /**\n     * @cfg {Number} [minWidth=120]\n     * The minimum width of the Menu. The default minWidth only applies when the {@link #floating} config is true.\n     */\n    minWidth: undefined,\n    \n    defaultMinWidth: 120,\n\n    /**\n     * @cfg {Boolean} [plain=false]\n     * True to remove the incised line down the left side of the menu and to not indent general Component items.\n     */\n\n    initComponent: function() {\n        var me = this,\n            prefix = Ext.baseCSSPrefix,\n            cls = [prefix + 'menu'],\n            bodyCls = me.bodyCls ? [me.bodyCls] : [],\n            isFloating = me.floating !== false;\n\n        me.addEvents(\n            /**\n             * @event click\n             * Fires when this menu is clicked\n             * @param {Ext.menu.Menu} menu The menu which has been clicked\n             * @param {Ext.Component} item The menu item that was clicked. `undefined` if not applicable.\n             * @param {Ext.EventObject} e The underlying {@link Ext.EventObject}.\n             */\n            'click',\n\n            /**\n             * @event mouseenter\n             * Fires when the mouse enters this menu\n             * @param {Ext.menu.Menu} menu The menu\n             * @param {Ext.EventObject} e The underlying {@link Ext.EventObject}\n             */\n            'mouseenter',\n\n            /**\n             * @event mouseleave\n             * Fires when the mouse leaves this menu\n             * @param {Ext.menu.Menu} menu The menu\n             * @param {Ext.EventObject} e The underlying {@link Ext.EventObject}\n             */\n            'mouseleave',\n\n            /**\n             * @event mouseover\n             * Fires when the mouse is hovering over this menu\n             * @param {Ext.menu.Menu} menu The menu\n             * @param {Ext.Component} item The menu item that the mouse is over. `undefined` if not applicable.\n             * @param {Ext.EventObject} e The underlying {@link Ext.EventObject}\n             */\n            'mouseover'\n        );\n\n        Ext.menu.Manager.register(me);\n\n        // Menu classes\n        if (me.plain) {\n            cls.push(prefix + 'menu-plain');\n        }\n        me.cls = cls.join(' ');\n\n        // Menu body classes\n        bodyCls.unshift(prefix + 'menu-body');\n        me.bodyCls = bodyCls.join(' ');\n\n        // Internal vbox layout, with scrolling overflow\n        // Placed in initComponent (rather than prototype) in order to support dynamic layout/scroller\n        // options if we wish to allow for such configurations on the Menu.\n        // e.g., scrolling speed, vbox align stretch, etc.\n        if (!me.layout) {\n            me.layout = {\n                type: 'vbox',\n                align: 'stretchmax',\n                overflowHandler: 'Scroller'\n            };\n        }\n        \n        // only apply the minWidth when we're floating & one hasn't already been set\n        if (isFloating && me.minWidth === undefined) {\n            me.minWidth = me.defaultMinWidth;\n        }\n\n        // hidden defaults to false if floating is configured as false\n        if (!isFloating && me.initialConfig.hidden !== true) {\n            me.hidden = false;\n        }\n\n        me.callParent(arguments);\n\n        me.on('beforeshow', function() {\n            var hasItems = !!me.items.length;\n            // FIXME: When a menu has its show cancelled because of no items, it\n            // gets a visibility: hidden applied to it (instead of the default display: none)\n            // Not sure why, but we remove this style when we want to show again.\n            if (hasItems && me.rendered) {\n                me.el.setStyle('visibility', null);\n            }\n            return hasItems;\n        });\n    },\n\n    beforeRender: function() {\n        this.callParent(arguments);\n\n        // Menus are usually floating: true, which means they shrink wrap their items.\n        // However, when they are contained, and not auto sized, we must stretch the items.\n        if (!this.getSizeModel().width.shrinkWrap) {\n            this.layout.align = 'stretch';\n        }\n    },\n\n    onBoxReady: function() {\n        var me = this,\n            separatorSpec;\n\n        me.callParent(arguments);\n\n        // TODO: Move this to a subTemplate When we support them in the future\n        if (me.showSeparator) {\n            separatorSpec = {\n                cls: Ext.baseCSSPrefix + 'menu-icon-separator',\n                html: '&#160;'\n            };\n            if ((!Ext.isStrict && Ext.isIE) || Ext.isIE6) {\n                separatorSpec.style = 'height:' + me.el.getHeight() + 'px';\n            }\n            me.iconSepEl = me.layout.getElementTarget().insertFirst(separatorSpec);\n        }\n\n        me.mon(me.el, {\n            click: me.onClick,\n            mouseover: me.onMouseOver,\n            scope: me\n        });\n        me.mouseMonitor = me.el.monitorMouseLeave(100, me.onMouseLeave, me);\n\n        if (me.enableKeyNav) {\n            me.keyNav = new Ext.menu.KeyNav(me);\n        }\n    },\n\n    getBubbleTarget: function() {\n        // If a submenu, this will have a parentMenu property\n        // If a menu of a Button, it will have an ownerButton property\n        // Else use the default method.\n        return this.parentMenu || this.ownerButton || this.callParent(arguments);\n    },\n\n    /**\n     * Returns whether a menu item can be activated or not.\n     * @return {Boolean}\n     */\n    canActivateItem: function(item) {\n        return item && !item.isDisabled() && item.isVisible() && (item.canActivate || item.getXTypes().indexOf('menuitem') < 0);\n    },\n\n    /**\n     * Deactivates the current active item on the menu, if one exists.\n     */\n    deactivateActiveItem: function(andBlurFocusedItem) {\n        var me = this,\n            activeItem = me.activeItem,\n            focusedItem = me.focusedItem;\n\n        if (activeItem) {\n            activeItem.deactivate();\n            if (!activeItem.activated) {\n                delete me.activeItem;\n            }\n        }\n\n        // Blur the focused item if we are being asked to do that too\n        // Only needed if we are being hidden - mouseout does not blur.\n        if (focusedItem && andBlurFocusedItem) {\n            focusedItem.blur();\n            delete me.focusedItem;\n        }\n    },\n\n    // inherit docs\n    getFocusEl: function() {\n        return this.focusedItem || this.el;\n    },\n\n    // inherit docs\n    hide: function() {\n        this.deactivateActiveItem(true);\n        this.callParent(arguments);\n    },\n\n    // private\n    getItemFromEvent: function(e) {\n        return this.getChildByElement(e.getTarget());\n    },\n\n    lookupComponent: function(cmp) {\n        var me = this;\n\n        if (typeof cmp == 'string') {\n            cmp = me.lookupItemFromString(cmp);\n        } else if (Ext.isObject(cmp)) {\n            cmp = me.lookupItemFromObject(cmp);\n        }\n\n        // Apply our minWidth to all of our child components so it's accounted\n        // for in our VBox layout\n        cmp.minWidth = cmp.minWidth || me.minWidth;\n\n        return cmp;\n    },\n\n    // private\n    lookupItemFromObject: function(cmp) {\n        var me = this,\n            prefix = Ext.baseCSSPrefix,\n            cls;\n\n        if (!cmp.isComponent) {\n            if (!cmp.xtype) {\n                cmp = Ext.create('Ext.menu.' + (Ext.isBoolean(cmp.checked) ? 'Check': '') + 'Item', cmp);\n            } else {\n                cmp = Ext.ComponentManager.create(cmp, cmp.xtype);\n            }\n        }\n\n        if (cmp.isMenuItem) {\n            cmp.parentMenu = me;\n        }\n\n        if (!cmp.isMenuItem && !cmp.dock) {\n            cls = [prefix + 'menu-item', prefix + 'menu-item-cmp'];\n\n            if (!me.plain && (cmp.indent === true || cmp.iconCls === 'no-icon')) {\n                cls.push(prefix + 'menu-item-indent');\n            }\n\n            if (cmp.rendered) {\n                cmp.el.addCls(cls);\n            } else {\n                cmp.cls = (cmp.cls ? cmp.cls : '') + ' ' + cls.join(' ');\n            }\n        }\n        return cmp;\n    },\n\n    // private\n    lookupItemFromString: function(cmp) {\n        return (cmp == 'separator' || cmp == '-') ?\n            new Ext.menu.Separator()\n            : new Ext.menu.Item({\n                canActivate: false,\n                hideOnClick: false,\n                plain: true,\n                text: cmp\n            });\n    },\n\n    onClick: function(e) {\n        var me = this,\n            item;\n\n        if (me.disabled) {\n            e.stopEvent();\n            return;\n        }\n\n        item = (e.type === 'click') ? me.getItemFromEvent(e) : me.activeItem;\n        if (item && item.isMenuItem) {\n            if (!item.menu || !me.ignoreParentClicks) {\n                item.onClick(e);\n            } else {\n                e.stopEvent();\n            }\n        }\n        // Click event may be fired without an item, so we need a second check\n        if (!item || item.disabled) {\n            item = undefined;\n        }\n        me.fireEvent('click', me, item, e);\n    },\n\n    onDestroy: function() {\n        var me = this;\n\n        Ext.menu.Manager.unregister(me);\n        delete me.parentMenu;\n        delete me.ownerButton;\n        if (me.rendered) {\n            me.el.un(me.mouseMonitor);\n            Ext.destroy(me.keyNav);\n            delete me.keyNav;\n        }\n        me.callParent(arguments);\n    },\n\n    onMouseLeave: function(e) {\n        var me = this;\n\n        me.deactivateActiveItem();\n\n        if (me.disabled) {\n            return;\n        }\n\n        me.fireEvent('mouseleave', me, e);\n    },\n\n    onMouseOver: function(e) {\n        var me = this,\n            fromEl = e.getRelatedTarget(),\n            mouseEnter = !me.el.contains(fromEl),\n            item = me.getItemFromEvent(e),\n            parentMenu = me.parentMenu,\n            parentItem = me.parentItem;\n\n        if (mouseEnter && parentMenu) {\n            parentMenu.setActiveItem(parentItem);\n            parentItem.cancelDeferHide();\n            parentMenu.mouseMonitor.mouseenter();\n        }\n\n        if (me.disabled) {\n            return;\n        }\n\n        // Do not activate the item if the mouseover was within the item, and it's already active\n        if (item && !item.activated) {\n            me.setActiveItem(item);\n            if (item.activated && item.expandMenu) {\n                item.expandMenu();\n            }\n        }\n        if (mouseEnter) {\n            me.fireEvent('mouseenter', me, e);\n        }\n        me.fireEvent('mouseover', me, item, e);\n    },\n\n    setActiveItem: function(item) {\n        var me = this;\n\n        if (item && (item != me.activeItem)) {\n            me.deactivateActiveItem();\n            if (me.canActivateItem(item)) {\n                if (item.activate) {\n                    item.activate();\n                    if (item.activated) {\n                        me.activeItem = item;\n                        me.focusedItem = item;\n                        me.focus();\n                    }\n                } else {\n                    item.focus();\n                    me.focusedItem = item;\n                }\n            }\n            item.el.scrollIntoView(me.layout.getRenderTarget());\n        }\n    },\n\n    /**\n     * Shows the floating menu by the specified {@link Ext.Component Component} or {@link Ext.Element Element}.\n     * @param {Ext.Component/Ext.Element} component The {@link Ext.Component} or {@link Ext.Element} to show the menu by.\n     * @param {String} [position] Alignment position as used by {@link Ext.Element#getAlignToXY}.\n     * Defaults to `{@link #defaultAlign}`.\n     * @param {Number[]} [offsets] Alignment offsets as used by {@link Ext.Element#getAlignToXY}.\n     * @return {Ext.menu.Menu} This Menu.\n     */\n    showBy: function(cmp, pos, off) {\n        var me = this;\n\n        if (me.floating && cmp) {\n            me.show();\n\n            // Align to Component or Element using setPagePosition because normal show\n            // methods are container-relative, and we must align to the requested element\n            // or Component:\n            me.setPagePosition(me.el.getAlignToXY(cmp.el || cmp, pos || me.defaultAlign, off));\n            me.setVerticalPosition();\n        }\n        return me;\n    },\n\n    show: function() {\n        var me = this,\n            parentEl, viewHeight, result,\n            maxWas = me.maxHeight;\n\n        // we need to get scope parent for height constraint\n        if (!me.rendered){\n            me.doAutoRender();\n        }\n\n        // constrain the height to the curren viewable area\n        if (me.floating) {\n            //if our reset css is scoped, there will be a x-reset wrapper on this menu which we need to skip\n            parentEl = Ext.fly(me.el.getScopeParent());\n            viewHeight = parentEl.getViewSize().height;\n            me.maxHeight  =  Math.min(maxWas || viewHeight, viewHeight);\n        }\n\n        result = me.callParent(arguments);\n        me.maxHeight = maxWas;\n        return result;\n    },\n\n    afterComponentLayout: function(width, height, oldWidth, oldHeight){\n        var me = this;\n        me.callParent(arguments);\n        // fixup the separator\n        if (me.showSeparator){\n            me.iconSepEl.setHeight(me.componentLayout.lastComponentSize.contentHeight);\n        }\n    },\n\n    // private\n    // adjust the vertical position of the menu if the height of the\n    // menu is equal (or greater than) the viewport size\n    setVerticalPosition: function(){\n        var me = this,\n            max,\n            y = me.el.getY(),\n            returnY = y,\n            height = me.getHeight(),\n            viewportHeight = Ext.Element.getViewportHeight().height,\n            parentEl = Ext.fly(me.el.getScopeParent()),\n            viewHeight = parentEl.getViewSize().height,\n            normalY = y - parentEl.getScroll().top; // factor in scrollTop of parent\n\n        parentEl = null;\n\n        if (me.floating) {\n            max = me.maxHeight ? me.maxHeight : viewHeight - normalY;\n            if (height > viewHeight) {\n                returnY = y - normalY;\n            } else if (max < height) {\n                returnY = y - (height - max);\n            } else if((y + height) > viewportHeight){ // keep the document from scrolling\n                returnY = viewportHeight - height;\n            }\n        }\n        me.el.setY(returnY);\n    }\n});\n\n/**\n * A menu containing a Ext.picker.Color Component.\n *\n * Notes:\n *\n *   - Although not listed here, the **constructor** for this class accepts all of the\n *     configuration options of {@link Ext.picker.Color}.\n *   - If subclassing ColorMenu, any configuration options for the ColorPicker must be\n *     applied to the **initialConfig** property of the ColorMenu. Applying\n *     {@link Ext.picker.Color ColorPicker} configuration settings to `this` will **not**\n *     affect the ColorPicker's configuration.\n *\n * Example:\n *\n *     @example\n *     var colorPicker = Ext.create('Ext.menu.ColorPicker', {\n *         value: '000000'\n *     });\n *\n *     Ext.create('Ext.menu.Menu', {\n *         width: 100,\n *         height: 90,\n *         floating: false,  // usually you want this set to True (default)\n *         renderTo: Ext.getBody(),  // usually rendered by it's containing component\n *         items: [{\n *             text: 'choose a color',\n *             menu: colorPicker\n *         },{\n *             iconCls: 'add16',\n *             text: 'icon item'\n *         },{\n *             text: 'regular item'\n *         }]\n *     });\n */\n Ext.define('Ext.menu.ColorPicker', {\n     extend: 'Ext.menu.Menu',\n\n     alias: 'widget.colormenu',\n\n     requires: [\n        'Ext.picker.Color'\n     ],\n\n    /**\n     * @cfg {Boolean} hideOnClick\n     * False to continue showing the menu after a date is selected.\n     */\n    hideOnClick : true,\n\n    /**\n     * @cfg {String} pickerId\n     * An id to assign to the underlying color picker.\n     */\n    pickerId : null,\n\n    /**\n     * @cfg {Number} maxHeight\n     * @private\n     */\n\n    /**\n     * @property {Ext.picker.Color} picker\n     * The {@link Ext.picker.Color} instance for this ColorMenu\n     */\n\n    /**\n     * @event click\n     * @private\n     */\n\n    initComponent : function(){\n        var me = this,\n            cfg = Ext.apply({}, me.initialConfig);\n\n        // Ensure we don't get duplicate listeners\n        delete cfg.listeners;\n        Ext.apply(me, {\n            plain: true,\n            showSeparator: false,\n            items: Ext.applyIf({\n                cls: Ext.baseCSSPrefix + 'menu-color-item',\n                id: me.pickerId,\n                xtype: 'colorpicker'\n            }, cfg)\n        });\n\n        me.callParent(arguments);\n\n        me.picker = me.down('colorpicker');\n\n        /**\n         * @event select\n         * @inheritdoc Ext.picker.Color#select\n         */\n        me.relayEvents(me.picker, ['select']);\n\n        if (me.hideOnClick) {\n            me.on('select', me.hidePickerOnSelect, me);\n        }\n    },\n\n    /**\n     * Hides picker on select if hideOnClick is true\n     * @private\n     */\n    hidePickerOnSelect: function() {\n        Ext.menu.Manager.hideAll();\n    }\n });\n\n/**\n * A menu containing an Ext.picker.Date Component.\n *\n * Notes:\n *\n * - Although not listed here, the **constructor** for this class accepts all of the\n *   configuration options of **{@link Ext.picker.Date}**.\n * - If subclassing DateMenu, any configuration options for the DatePicker must be applied\n *   to the **initialConfig** property of the DateMenu. Applying {@link Ext.picker.Date Date Picker}\n *   configuration settings to **this** will **not** affect the Date Picker's configuration.\n *\n * Example:\n *\n *     @example\n *     var dateMenu = Ext.create('Ext.menu.DatePicker', {\n *         handler: function(dp, date){\n *             Ext.Msg.alert('Date Selected', 'You selected ' + Ext.Date.format(date, 'M j, Y'));\n *         }\n *     });\n *\n *     Ext.create('Ext.menu.Menu', {\n *         width: 100,\n *         height: 90,\n *         floating: false,  // usually you want this set to True (default)\n *         renderTo: Ext.getBody(),  // usually rendered by it's containing component\n *         items: [{\n *             text: 'choose a date',\n *             menu: dateMenu\n *         },{\n *             iconCls: 'add16',\n *             text: 'icon item'\n *         },{\n *             text: 'regular item'\n *         }]\n *     });\n */\n Ext.define('Ext.menu.DatePicker', {\n     extend: 'Ext.menu.Menu',\n\n     alias: 'widget.datemenu',\n\n     requires: [\n        'Ext.picker.Date'\n     ],\n\n    /**\n     * @cfg {Boolean} hideOnClick\n     * False to continue showing the menu after a date is selected.\n     */\n    hideOnClick : true,\n\n    /**\n     * @cfg {String} pickerId\n     * An id to assign to the underlying date picker.\n     */\n    pickerId : null,\n\n    /**\n     * @cfg {Number} maxHeight\n     * @private\n     */\n\n    /**\n     * @property {Ext.picker.Date} picker\n     * The {@link Ext.picker.Date} instance for this DateMenu\n     */\n\n    initComponent : function(){\n        var me = this,\n            cfg = Ext.apply({}, me.initialConfig);\n            \n        // Ensure we clear any listeners so they aren't duplicated\n        delete cfg.listeners;\n            \n        Ext.apply(me, {\n            showSeparator: false,\n            plain: true,\n            border: false,\n            bodyPadding: 0, // remove the body padding from the datepicker menu item so it looks like 3.3\n            items: Ext.applyIf({\n                cls: Ext.baseCSSPrefix + 'menu-date-item',\n                id: me.pickerId,\n                xtype: 'datepicker'\n            }, cfg)\n        });\n\n        me.callParent(arguments);\n\n        me.picker = me.down('datepicker');\n        /**\n         * @event select\n         * @inheritdoc Ext.picker.Date#select\n         */\n        me.relayEvents(me.picker, ['select']);\n\n        if (me.hideOnClick) {\n            me.on('select', me.hidePickerOnSelect, me);\n        }\n    },\n\n    hidePickerOnSelect: function() {\n        Ext.menu.Manager.hideAll();\n    }\n });\n\n/**\n * This class is used to display small visual icons in the header of a panel. There are a set of\n * 25 icons that can be specified by using the {@link #type} config. The {@link #handler} config\n * can be used to provide a function that will respond to any click events. In general, this class\n * will not be instantiated directly, rather it will be created by specifying the {@link Ext.panel.Panel#tools}\n * configuration on the Panel itself.\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         width: 200,\n *         height: 200,\n *         renderTo: document.body,\n *         title: 'A Panel',\n *         tools: [{\n *             type: 'help',\n *             handler: function(){\n *                 // show help here\n *             }\n *         }, {\n *             itemId: 'refresh',\n *             type: 'refresh',\n *             hidden: true,\n *             handler: function(){\n *                 // do refresh\n *             }\n *         }, {\n *             type: 'search',\n *             handler: function(event, target, owner, tool){\n *                 // do search\n *                 owner.child('#refresh').show();\n *             }\n *         }]\n *     });\n */\nExt.define('Ext.panel.Tool', {\n    extend: 'Ext.Component',\n    requires: ['Ext.tip.QuickTipManager'],\n    alias: 'widget.tool',\n\n    baseCls: Ext.baseCSSPrefix + 'tool',\n    disabledCls: Ext.baseCSSPrefix + 'tool-disabled',\n    \n    /**\n     * @cfg\n     * @private\n     */\n    toolPressedCls: Ext.baseCSSPrefix + 'tool-pressed',\n    /**\n     * @cfg\n     * @private\n     */\n    toolOverCls: Ext.baseCSSPrefix + 'tool-over',\n\n    ariaRole: 'button',\n\n    childEls: [\n        'toolEl'\n    ],\n\n    renderTpl: [\n        '<img id=\"{id}-toolEl\" src=\"{blank}\" class=\"{baseCls}-{type}\" role=\"presentation\"/>'\n    ],\n\n    /**\n     * @cfg {Function} handler\n     * A function to execute when the tool is clicked. Arguments passed are:\n     *\n     * - **event** : Ext.EventObject - The click event.\n     * - **toolEl** : Ext.Element - The tool Element.\n     * - **owner** : Ext.panel.Header - The host panel header.\n     * - **tool** : Ext.panel.Tool - The tool object\n     */\n\n    /**\n     * @cfg {Object} scope\n     * The scope to execute the {@link #handler} function. Defaults to the tool.\n     */\n\n    /**\n     * @cfg {String} type\n     * The type of tool to render. The following types are available:\n     *\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-close\"></span> close\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-minimize\"></span> minimize\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-maximize\"></span> maximize\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-restore\"></span> restore\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-toggle\"></span> toggle\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-gear\"></span> gear\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-prev\"></span> prev\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-next\"></span> next\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-pin\"></span> pin\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-unpin\"></span> unpin\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-right\"></span> right\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-left\"></span> left\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-down\"></span> down\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-up\"></span> up\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-refresh\"></span> refresh\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-plus\"></span> plus\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-minus\"></span> minus\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-search\"></span> search\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-save\"></span> save\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-help\"></span> help\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-print\"></span> print\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-expand\"></span> expand\n     * - <span class=\"x-tool\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"x-tool-collapse\"></span> collapse\n     */\n\n    /**\n     * @cfg {String/Object} tooltip\n     * The tooltip for the tool - can be a string to be used as innerHTML (html tags are accepted) or QuickTips config\n     * object\n     */\n\n     /**\n     * @cfg {String} tooltipType\n     * The type of tooltip to use. Either 'qtip' (default) for QuickTips or 'title' for title attribute.\n     */\n    tooltipType: 'qtip',\n\n    /**\n     * @cfg {Boolean} stopEvent\n     * Specify as false to allow click event to propagate.\n     */\n    stopEvent: true,\n    \n    height: 15,\n    width: 15,\n\n    _toolTypes: {\n        close:1,\n        collapse:1,\n        down:1,\n        expand:1,\n        gear:1,\n        help:1,\n        left:1,\n        maximize:1,\n        minimize:1,\n        minus:1,\n        //move:1,\n        next:1,\n        pin:1,\n        plus:1,\n        prev:1,\n        print:1,\n        refresh:1,\n        //resize:1,\n        restore:1,\n        right:1,\n        save:1,\n        search:1,\n        toggle:1,\n        unpin:1,\n        up:1\n    },\n\n    initComponent: function() {\n        var me = this;\n        me.addEvents(\n            /**\n             * @event click\n             * Fires when the tool is clicked\n             * @param {Ext.panel.Tool} this\n             * @param {Ext.EventObject} e The event object\n             */\n            'click'\n        );\n\n        if (me.id && me._toolTypes[me.id] && Ext.global.console) {\n            Ext.global.console.warn('When specifying a tool you should use the type option, the id can conflict now that tool is a Component');\n        }\n\n        me.type = me.type || me.id;\n\n        Ext.applyIf(me.renderData, {\n            baseCls: me.baseCls,\n            blank: Ext.BLANK_IMAGE_URL,\n            type: me.type\n        });\n\n        // alias qtip, should use tooltip since it's what we have in the docs\n        me.tooltip = me.tooltip || me.qtip;\n        me.callParent();\n        me.on({\n            element: 'toolEl',\n            click: me.onClick,\n            mousedown: me.onMouseDown,\n            mouseover: me.onMouseOver,\n            mouseout: me.onMouseOut,\n            scope: me\n        });\n    },\n\n    // inherit docs\n    afterRender: function() {\n        var me = this,\n            attr;\n\n        me.callParent(arguments);\n        if (me.tooltip) {\n            if (Ext.isObject(me.tooltip)) {\n                Ext.tip.QuickTipManager.register(Ext.apply({\n                    target: me.id\n                }, me.tooltip));\n            }\n            else {\n                attr = me.tooltipType == 'qtip' ? 'data-qtip' : 'title';\n                me.toolEl.dom.setAttribute(attr, me.tooltip);\n            }\n        }\n    },\n\n    getFocusEl: function() {\n        return this.el;\n    },\n\n    /**\n     * Sets the type of the tool. Allows the icon to be changed.\n     * @param {String} type The new type. See the {@link #type} config.\n     * @return {Ext.panel.Tool} this\n     */\n    setType: function(type) {\n        var me = this;\n\n        me.type = type;\n        if (me.rendered) {\n            me.toolEl.dom.className = me.baseCls + '-' + type;\n        }\n        return me;\n    },\n\n    /**\n     * Binds this tool to a component.\n     * @private\n     * @param {Ext.Component} component The component\n     */\n    bindTo: function(component) {\n        this.owner = component;\n    },\n\n    /**\n     * Called when the tool element is clicked\n     * @private\n     * @param {Ext.EventObject} e\n     * @param {HTMLElement} target The target element\n     */\n    onClick: function(e, target) {\n        var me = this,\n            owner;\n\n        if (me.disabled) {\n            return false;\n        }\n        owner = me.owner || me.ownerCt;\n\n        //remove the pressed + over class\n        me.el.removeCls(me.toolPressedCls);\n        me.el.removeCls(me.toolOverCls);\n\n        if (me.stopEvent !== false) {\n            e.stopEvent();\n        }\n\n        Ext.callback(me.handler, me.scope || me, [e, target, owner, me]);\n        me.fireEvent('click', me, e);\n        return true;\n    },\n\n    // inherit docs\n    onDestroy: function(){\n        if (Ext.isObject(this.tooltip)) {\n            Ext.tip.QuickTipManager.unregister(this.id);\n        }\n        this.callParent();\n    },\n\n    /**\n     * Called when the user presses their mouse button down on a tool\n     * Adds the press class ({@link #toolPressedCls})\n     * @private\n     */\n    onMouseDown: function() {\n        if (this.disabled) {\n            return false;\n        }\n\n        this.el.addCls(this.toolPressedCls);\n    },\n\n    /**\n     * Called when the user rolls over a tool\n     * Adds the over class ({@link #toolOverCls})\n     * @private\n     */\n    onMouseOver: function() {\n        if (this.disabled) {\n            return false;\n        }\n        this.el.addCls(this.toolOverCls);\n    },\n\n    /**\n     * Called when the user rolls out from a tool.\n     * Removes the over class ({@link #toolOverCls})\n     * @private\n     */\n    onMouseOut: function() {\n        this.el.removeCls(this.toolOverCls);\n    }\n});\n\n/**\n * Private utility class for Ext.Splitter.\n * @private\n */\nExt.define('Ext.resizer.SplitterTracker', {\n    extend: 'Ext.dd.DragTracker',\n    requires: ['Ext.util.Region'],\n    enabled: true,\n    \n    overlayCls: Ext.baseCSSPrefix + 'resizable-overlay',\n\n    createDragOverlay: function () {\n        var overlay;\n\n        overlay = this.overlay =  Ext.getBody().createChild({\n            cls: this.overlayCls, \n            html: '&#160;'\n        });\n\n        overlay.unselectable();\n        overlay.setSize(Ext.Element.getViewWidth(true), Ext.Element.getViewHeight(true));\n        overlay.show();\n    },\n\n    getPrevCmp: function() {\n        var splitter = this.getSplitter();\n        return splitter.previousSibling();\n    },\n\n    getNextCmp: function() {\n        var splitter = this.getSplitter();\n        return splitter.nextSibling();\n    },\n\n    // ensure the tracker is enabled, store boxes of previous and next\n    // components and calculate the constrain region\n    onBeforeStart: function(e) {\n        var me = this,\n            prevCmp = me.getPrevCmp(),\n            nextCmp = me.getNextCmp(),\n            collapseEl = me.getSplitter().collapseEl,\n            target = e.getTarget(),\n            box;\n\n        if (collapseEl && target === me.getSplitter().collapseEl.dom) {\n            return false;\n        }\n\n        // SplitterTracker is disabled if any of its adjacents are collapsed.\n        if (nextCmp.collapsed || prevCmp.collapsed) {\n            return false;\n        }\n\n        // store boxes of previous and next\n        me.prevBox  = prevCmp.getEl().getBox();\n        me.nextBox  = nextCmp.getEl().getBox();\n        me.constrainTo = box = me.calculateConstrainRegion();\n\n        if (!box) {\n            return false;\n        }\n\n        me.createDragOverlay();\n\n        return box;\n    },\n\n    // We move the splitter el. Add the proxy class.\n    onStart: function(e) {\n        var splitter = this.getSplitter();\n        splitter.addCls(splitter.baseCls + '-active');\n    },\n\n    // calculate the constrain Region in which the splitter el may be moved.\n    calculateConstrainRegion: function() {\n        var me         = this,\n            splitter   = me.getSplitter(),\n            splitWidth = splitter.getWidth(),\n            defaultMin = splitter.defaultSplitMin,\n            orient     = splitter.orientation,\n            prevBox    = me.prevBox,\n            prevCmp    = me.getPrevCmp(),\n            nextBox    = me.nextBox,\n            nextCmp    = me.getNextCmp(),\n            // prev and nextConstrainRegions are the maximumBoxes minus the\n            // minimumBoxes. The result is always the intersection\n            // of these two boxes.\n            prevConstrainRegion, nextConstrainRegion;\n\n        // vertical splitters, so resizing left to right\n        if (orient === 'vertical') {\n\n            // Region constructor accepts (top, right, bottom, left)\n            // anchored/calculated from the left\n            prevConstrainRegion = new Ext.util.Region(\n                prevBox.y,\n                // Right boundary is x + maxWidth if there IS a maxWidth.\n                // Otherwise it is calculated based upon the minWidth of the next Component\n                (prevCmp.maxWidth ? prevBox.x + prevCmp.maxWidth : nextBox.right - (nextCmp.minWidth || defaultMin)) + splitWidth,\n                prevBox.bottom,\n                prevBox.x + (prevCmp.minWidth || defaultMin)\n            );\n            // anchored/calculated from the right\n            nextConstrainRegion = new Ext.util.Region(\n                nextBox.y,\n                nextBox.right - (nextCmp.minWidth || defaultMin),\n                nextBox.bottom,\n                // Left boundary is right - maxWidth if there IS a maxWidth.\n                // Otherwise it is calculated based upon the minWidth of the previous Component\n                (nextCmp.maxWidth ? nextBox.right - nextCmp.maxWidth : prevBox.x + (prevBox.minWidth || defaultMin)) - splitWidth\n            );\n        } else {\n            // anchored/calculated from the top\n            prevConstrainRegion = new Ext.util.Region(\n                prevBox.y + (prevCmp.minHeight || defaultMin),\n                prevBox.right,\n                // Bottom boundary is y + maxHeight if there IS a maxHeight.\n                // Otherwise it is calculated based upon the minWidth of the next Component\n                (prevCmp.maxHeight ? prevBox.y + prevCmp.maxHeight : nextBox.bottom - (nextCmp.minHeight || defaultMin)) + splitWidth,\n                prevBox.x\n            );\n            // anchored/calculated from the bottom\n            nextConstrainRegion = new Ext.util.Region(\n                // Top boundary is bottom - maxHeight if there IS a maxHeight.\n                // Otherwise it is calculated based upon the minHeight of the previous Component\n                (nextCmp.maxHeight ? nextBox.bottom - nextCmp.maxHeight : prevBox.y + (prevCmp.minHeight || defaultMin)) - splitWidth,\n                nextBox.right,\n                nextBox.bottom - (nextCmp.minHeight || defaultMin),\n                nextBox.x\n            );\n        }\n\n        // intersection of the two regions to provide region draggable\n        return prevConstrainRegion.intersect(nextConstrainRegion);\n    },\n\n    // Performs the actual resizing of the previous and next components\n    performResize: function(e, offset) {\n        var me        = this,\n            splitter  = me.getSplitter(),\n            orient    = splitter.orientation,\n            prevCmp   = me.getPrevCmp(),\n            nextCmp   = me.getNextCmp(),\n            owner     = splitter.ownerCt,\n            flexedSiblings = owner.query('>[flex]'),\n            len       = flexedSiblings.length,\n            i         = 0,\n            dimension,\n            size,\n            totalFlex = 0;\n\n        // Convert flexes to pixel values proportional to the total pixel width of all flexes.\n        for (; i < len; i++) {\n            size = flexedSiblings[i].getWidth();\n            totalFlex += size;\n            flexedSiblings[i].flex = size;\n        }\n\n        offset = offset || me.getOffset('dragTarget');\n\n        if (orient === 'vertical') {\n            offset = offset[0];\n            dimension = 'width';\n        } else {\n            dimension = 'height';\n            offset = offset[1];\n        }\n        if (prevCmp) {\n            size = me.prevBox[dimension] + offset;\n            if (prevCmp.flex) {\n                prevCmp.flex = size;\n            } else {\n                prevCmp[dimension] = size;\n            }\n        }\n        if (nextCmp) {\n            size = me.nextBox[dimension] - offset;\n            if (nextCmp.flex) {\n                nextCmp.flex = size;\n            } else {\n                nextCmp[dimension] = size;\n            }\n        }\n\n        owner.updateLayout();\n    },\n\n    // Cleans up the overlay (if we have one) and calls the base. This cannot be done in\n    // onEnd, because onEnd is only called if a drag is detected but the overlay is created\n    // regardless (by onBeforeStart).\n    endDrag: function () {\n        var me = this;\n\n        if (me.overlay) {\n             me.overlay.remove();\n             delete me.overlay;\n        }\n\n        me.callParent(arguments); // this calls onEnd\n    },\n\n    // perform the resize and remove the proxy class from the splitter el\n    onEnd: function(e) {\n        var me = this,\n            splitter = me.getSplitter();\n            \n        splitter.removeCls(splitter.baseCls + '-active');\n        me.performResize(e, me.getOffset('dragTarget'));\n    },\n\n    // Track the proxy and set the proper XY coordinates\n    // while constraining the drag\n    onDrag: function(e) {\n        var me        = this,\n            offset    = me.getOffset('dragTarget'),\n            splitter  = me.getSplitter(),\n            splitEl   = splitter.getEl(),\n            orient    = splitter.orientation;\n\n        if (orient === \"vertical\") {\n            splitEl.setX(me.startRegion.left + offset[0]);\n        } else {\n            splitEl.setY(me.startRegion.top + offset[1]);\n        }\n    },\n\n    getSplitter: function() {\n        return this.splitter;\n    }\n});\n\n/**\n * Private utility class for Ext.BorderSplitter.\n * @private\n */\nExt.define('Ext.resizer.BorderSplitterTracker', {\n    extend: 'Ext.resizer.SplitterTracker',\n    requires: ['Ext.util.Region'],\n\n    getPrevCmp: null,\n    getNextCmp: null,\n\n    // calculate the constrain Region in which the splitter el may be moved.\n    calculateConstrainRegion: function() {\n        var me = this,\n            splitter = me.splitter,\n            collapseTarget = splitter.collapseTarget,\n            defaultSplitMin = splitter.defaultSplitMin,\n            sizePropCap = splitter.vertical ? 'Width' : 'Height',\n            minSizeProp = 'min' + sizePropCap,\n            maxSizeProp = 'max' + sizePropCap,\n            getSizeMethod = 'get' + sizePropCap,\n            neighbors = splitter.neighbors,\n            length = neighbors.length,\n            box = collapseTarget.el.getBox(),\n            left = box.x,\n            top = box.y,\n            right = box.right,\n            bottom = box.bottom,\n            size = splitter.vertical ? (right - left) : (bottom - top),\n            //neighborSizes = [],\n            i, neighbor, minRange, maxRange, maxGrowth, maxShrink, targetSize;\n\n        // if size=100 and minSize=80, we can reduce by 20 so minRange = minSize-size = -20\n        minRange = (collapseTarget[minSizeProp] || Math.min(size,defaultSplitMin)) - size;\n\n        // if maxSize=150, maxRange = maxSize - size = 50\n        maxRange = collapseTarget[maxSizeProp];\n        if (!maxRange) {\n            maxRange = 1e9;\n        } else {\n            maxRange -= size;\n        }\n        targetSize = size;\n\n        for (i = 0; i < length; ++i) {\n            neighbor = neighbors[i];\n            size = neighbor[getSizeMethod]();\n            //neighborSizes.push(size);\n\n            maxGrowth = size - neighbor[maxSizeProp]; // NaN if no maxSize or negative\n            maxShrink = size - (neighbor[minSizeProp] || Math.min(size,defaultSplitMin));\n\n            if (!isNaN(maxGrowth)) {\n                // if neighbor can only grow by 10 (maxGrowth = -10), minRange cannot be\n                // -20 anymore, but now only -10:\n                if (minRange < maxGrowth) {\n                    minRange = maxGrowth;\n                }\n            }\n\n            // if neighbor can shrink by 20 (maxShrink=20), maxRange cannot be 50 anymore,\n            // but now only 20:\n            if (maxRange > maxShrink) {\n                maxRange = maxShrink;\n            }\n        }\n\n        if (maxRange - minRange < 2) {\n            return null;\n        }\n\n        box = new Ext.util.Region(top, right, bottom, left);\n\n        me.constraintAdjusters[splitter.collapseDirection](box, minRange, maxRange, splitter);\n\n        me.dragInfo = {\n            minRange: minRange,\n            maxRange: maxRange,\n            //neighborSizes: neighborSizes,\n            targetSize: targetSize\n        };\n\n        return box;\n    },\n\n    constraintAdjusters: {\n        // splitter is to the right of the box\n        left: function (box, minRange, maxRange, splitter) {\n            box[0] = box.x = box.left = box.right + minRange;\n            box.right += maxRange + splitter.getWidth();\n        },\n\n        // splitter is below the box\n        top: function (box, minRange, maxRange, splitter) {\n            box[1] = box.y = box.top = box.bottom + minRange;\n            box.bottom += maxRange + splitter.getHeight();\n        },\n\n        // splitter is above the box\n        bottom: function (box, minRange, maxRange, splitter) {\n            box.bottom = box.top - minRange;\n            box.top -= maxRange + splitter.getHeight();\n        },\n\n        // splitter is to the left of the box\n        right: function (box, minRange, maxRange, splitter) {\n            box.right = box.left - minRange;\n            box.left -= maxRange + splitter.getWidth();\n        }\n    },\n\n    onBeforeStart: function(e) {\n        var me = this,\n            splitter = me.splitter,\n            collapseTarget = splitter.collapseTarget,\n            neighbors = splitter.neighbors,\n            collapseEl = me.getSplitter().collapseEl,\n            target = e.getTarget(),\n            length = neighbors.length,\n            i, neighbor;\n            \n        if (collapseEl && target === splitter.collapseEl.dom) {\n            return false;\n        }\n\n        if (collapseTarget.collapsed) {\n            return false;\n        }\n\n        // disabled if any neighbors are collapsed in parallel direction.\n        for (i = 0; i < length; ++i) {\n            neighbor = neighbors[i];\n\n            if (neighbor.collapsed && neighbor.isHorz === collapseTarget.isHorz) {\n                return false;\n            }\n        }\n\n        if (!(me.constrainTo = me.calculateConstrainRegion())) {\n            return false;\n        }\n\n        me.createDragOverlay();\n        return true;\n    },\n\n    performResize: function(e, offset) {\n        var me = this,\n            splitter = me.splitter,\n            collapseDirection = splitter.collapseDirection,\n            collapseTarget = splitter.collapseTarget,\n            // a vertical splitter adjusts horizontal dimensions\n            adjusters = me.splitAdjusters[splitter.vertical ? 'horz' : 'vert'],\n            delta = offset[adjusters.index],\n            dragInfo = me.dragInfo,\n            //neighbors = splitter.neighbors,\n            //length = neighbors.length,\n            //neighborSizes = dragInfo.neighborSizes,\n            //isVert = collapseTarget.isVert,\n            //i, neighbor,\n            owner;\n\n        if (collapseDirection == 'right' || collapseDirection == 'bottom') {\n            // these splitters grow by moving left/up, so flip the sign of delta...\n            delta = -delta;\n        }\n\n        // now constrain delta to our computed range:\n        delta = Math.min(Math.max(dragInfo.minRange, delta), dragInfo.maxRange);\n\n        if (delta) {\n            (owner = splitter.ownerCt).suspendLayouts();\n\n            adjusters.adjustTarget(collapseTarget, dragInfo.targetSize, delta);\n\n            //for (i = 0; i < length; ++i) {\n            //    neighbor = neighbors[i];\n            //    if (!neighbor.isCenter && !neighbor.maintainFlex && neighbor.isVert == isVert) {\n            //        delete neighbor.flex;\n            //        adjusters.adjustNeighbor(neighbor, neighborSizes[i], delta);\n            //    }\n            //}\n\n            owner.resumeLayouts(true);\n        }\n    },\n\n    splitAdjusters: {\n        horz: {\n            index: 0,\n            //adjustNeighbor: function (neighbor, size, delta) {\n            //    neighbor.setSize(size - delta);\n            //},\n            adjustTarget: function (target, size, delta) {\n                target.flex = null;\n                target.setSize(size + delta);\n            }\n        },\n        vert: {\n            index: 1,\n            //adjustNeighbor: function (neighbor, size, delta) {\n            //    neighbor.setSize(undefined, size - delta);\n            //},\n            adjustTarget: function (target, targetSize, delta) {\n                target.flex = null;\n                target.setSize(undefined, targetSize + delta);\n            }\n        }\n    }\n});\n\n/**\n * Provides a handle for 9-point resizing of Elements or Components.\n */\nExt.define('Ext.resizer.Handle', {\n    extend: 'Ext.Component',\n    handleCls: '',\n    baseHandleCls: Ext.baseCSSPrefix + 'resizable-handle',\n    // Ext.resizer.Resizer.prototype.possiblePositions define the regions\n    // which will be passed in as a region configuration.\n    region: '',\n\n    beforeRender: function() {\n        var me = this;\n\n        me.callParent();\n\n        me.addCls(\n            me.baseHandleCls,\n            me.baseHandleCls + '-' + me.region,\n            me.handleCls\n        );\n    },\n\n    onRender: function() {\n        this.callParent(arguments);\n\n        this.el.unselectable();\n    }\n});\n\n/**\n * Private utility class for Ext.resizer.Resizer.\n * @private\n */\nExt.define('Ext.resizer.ResizeTracker', {\n    extend: 'Ext.dd.DragTracker',\n    dynamic: true,\n    preserveRatio: false,\n\n    // Default to no constraint\n    constrainTo: null,\n    \n    proxyCls:  Ext.baseCSSPrefix + 'resizable-proxy',\n\n    constructor: function(config) {\n        var me = this,\n            widthRatio, heightRatio,\n            throttledResizeFn;\n\n        if (!config.el) {\n            if (config.target.isComponent) {\n                me.el = config.target.getEl();\n            } else {\n                me.el = config.target;\n            }\n        }\n        this.callParent(arguments);\n\n        // Ensure that if we are preserving aspect ratio, the largest minimum is honoured\n        if (me.preserveRatio && me.minWidth && me.minHeight) {\n            widthRatio = me.minWidth / me.el.getWidth();\n            heightRatio = me.minHeight / me.el.getHeight();\n\n            // largest ratio of minimum:size must be preserved.\n            // So if a 400x200 pixel image has\n            // minWidth: 50, maxWidth: 50, the maxWidth will be 400 * (50/200)... that is 100\n            if (heightRatio > widthRatio) {\n                me.minWidth = me.el.getWidth() * heightRatio;\n            } else {\n                me.minHeight = me.el.getHeight() * widthRatio;\n            }\n        }\n\n        // If configured as throttled, create an instance version of resize which calls\n        // a throttled function to perform the resize operation.\n        if (me.throttle) {\n            throttledResizeFn = Ext.Function.createThrottled(function() {\n                    Ext.resizer.ResizeTracker.prototype.resize.apply(me, arguments);\n                }, me.throttle);\n\n            me.resize = function(box, direction, atEnd) {\n                if (atEnd) {\n                    Ext.resizer.ResizeTracker.prototype.resize.apply(me, arguments);\n                } else {\n                    throttledResizeFn.apply(null, arguments);\n                }\n            };\n        }\n    },\n\n    onBeforeStart: function(e) {\n        // record the startBox\n        this.startBox = this.el.getBox();\n    },\n\n    /**\n     * @private\n     * Returns the object that will be resized on every mousemove event.\n     * If dynamic is false, this will be a proxy, otherwise it will be our actual target.\n     */\n    getDynamicTarget: function() {\n        var me = this,\n            target = me.target;\n            \n        if (me.dynamic) {\n            return target;\n        } else if (!me.proxy) {\n            me.proxy = me.createProxy(target);\n        }\n        me.proxy.show();\n        return me.proxy;\n    },\n    \n    /**\n     * Create a proxy for this resizer\n     * @param {Ext.Component/Ext.Element} target The target\n     * @return {Ext.Element} A proxy element\n     */\n    createProxy: function(target){\n        var proxy,\n            cls = this.proxyCls,\n            renderTo;\n            \n        if (target.isComponent) {\n            proxy = target.getProxy().addCls(cls);\n        } else {\n            renderTo = Ext.getBody();\n            if (Ext.scopeResetCSS) {\n                renderTo = Ext.getBody().createChild({\n                    cls: Ext.resetCls\n                });\n            }\n            proxy = target.createProxy({\n                tag: 'div',\n                cls: cls,\n                id: target.id + '-rzproxy'\n            }, renderTo);\n        }\n        proxy.removeCls(Ext.baseCSSPrefix + 'proxy-el');\n        return proxy;\n    },\n\n    onStart: function(e) {\n        // returns the Ext.ResizeHandle that the user started dragging\n        this.activeResizeHandle = Ext.get(this.getDragTarget().id);\n\n        // If we are using a proxy, ensure it is sized.\n        if (!this.dynamic) {\n            this.resize(this.startBox, {\n                horizontal: 'none',\n                vertical: 'none'\n            });\n        }\n    },\n\n    onDrag: function(e) {\n        // dynamic resizing, update dimensions during resize\n        if (this.dynamic || this.proxy) {\n            this.updateDimensions(e);\n        }\n    },\n\n    updateDimensions: function(e, atEnd) {\n        var me = this,\n            region = me.activeResizeHandle.region,\n            offset = me.getOffset(me.constrainTo ? 'dragTarget' : null),\n            box = me.startBox,\n            ratio,\n            widthAdjust = 0,\n            heightAdjust = 0,\n            snappedWidth,\n            snappedHeight,\n            adjustX = 0,\n            adjustY = 0,\n            dragRatio,\n            horizDir = offset[0] < 0 ? 'right' : 'left',\n            vertDir = offset[1] < 0 ? 'down' : 'up',\n            oppositeCorner,\n            axis, // 1 = x, 2 = y, 3 = x and y.\n            newBox,\n            newHeight, newWidth;\n\n        switch (region) {\n            case 'south':\n                heightAdjust = offset[1];\n                axis = 2;\n                break;\n            case 'north':\n                heightAdjust = -offset[1];\n                adjustY = -heightAdjust;\n                axis = 2;\n                break;\n            case 'east':\n                widthAdjust = offset[0];\n                axis = 1;\n                break;\n            case 'west':\n                widthAdjust = -offset[0];\n                adjustX = -widthAdjust;\n                axis = 1;\n                break;\n            case 'northeast':\n                heightAdjust = -offset[1];\n                adjustY = -heightAdjust;\n                widthAdjust = offset[0];\n                oppositeCorner = [box.x, box.y + box.height];\n                axis = 3;\n                break;\n            case 'southeast':\n                heightAdjust = offset[1];\n                widthAdjust = offset[0];\n                oppositeCorner = [box.x, box.y];\n                axis = 3;\n                break;\n            case 'southwest':\n                widthAdjust = -offset[0];\n                adjustX = -widthAdjust;\n                heightAdjust = offset[1];\n                oppositeCorner = [box.x + box.width, box.y];\n                axis = 3;\n                break;\n            case 'northwest':\n                heightAdjust = -offset[1];\n                adjustY = -heightAdjust;\n                widthAdjust = -offset[0];\n                adjustX = -widthAdjust;\n                oppositeCorner = [box.x + box.width, box.y + box.height];\n                axis = 3;\n                break;\n        }\n\n        newBox = {\n            width: box.width + widthAdjust,\n            height: box.height + heightAdjust,\n            x: box.x + adjustX,\n            y: box.y + adjustY\n        };\n\n        // Snap value between stops according to configured increments\n        snappedWidth = Ext.Number.snap(newBox.width, me.widthIncrement);\n        snappedHeight = Ext.Number.snap(newBox.height, me.heightIncrement);\n        if (snappedWidth != newBox.width || snappedHeight != newBox.height){\n            switch (region) {\n                case 'northeast':\n                    newBox.y -= snappedHeight - newBox.height;\n                    break;\n                case 'north':\n                    newBox.y -= snappedHeight - newBox.height;\n                    break;\n                case 'southwest':\n                    newBox.x -= snappedWidth - newBox.width;\n                    break;\n                case 'west':\n                    newBox.x -= snappedWidth - newBox.width;\n                    break;\n                case 'northwest':\n                    newBox.x -= snappedWidth - newBox.width;\n                    newBox.y -= snappedHeight - newBox.height;\n            }\n            newBox.width = snappedWidth;\n            newBox.height = snappedHeight;\n        }\n\n        // out of bounds\n        if (newBox.width < me.minWidth || newBox.width > me.maxWidth) {\n            newBox.width = Ext.Number.constrain(newBox.width, me.minWidth, me.maxWidth);\n\n            // Re-adjust the X position if we were dragging the west side\n            if (adjustX) {\n                newBox.x = box.x + (box.width - newBox.width);\n            }\n        } else {\n            me.lastX = newBox.x;\n        }\n        if (newBox.height < me.minHeight || newBox.height > me.maxHeight) {\n            newBox.height = Ext.Number.constrain(newBox.height, me.minHeight, me.maxHeight);\n\n            // Re-adjust the Y position if we were dragging the north side\n            if (adjustY) {\n                newBox.y = box.y + (box.height - newBox.height);\n            }\n        } else {\n            me.lastY = newBox.y;\n        }\n\n        // If this is configured to preserve the aspect ratio, or they are dragging using the shift key\n        if (me.preserveRatio || e.shiftKey) {\n            ratio = me.startBox.width / me.startBox.height;\n\n            // Calculate aspect ratio constrained values.\n            newHeight = Math.min(Math.max(me.minHeight, newBox.width / ratio), me.maxHeight);\n            newWidth = Math.min(Math.max(me.minWidth, newBox.height * ratio), me.maxWidth);\n\n            // X axis: width-only change, height must obey\n            if (axis == 1) {\n                newBox.height = newHeight;\n            }\n\n            // Y axis: height-only change, width must obey\n            else if (axis == 2) {\n                newBox.width = newWidth;\n            }\n\n            // Corner drag.\n            else {\n                // Drag ratio is the ratio of the mouse point from the opposite corner.\n                // Basically what edge we are dragging, a horizontal edge or a vertical edge.\n                dragRatio = Math.abs(oppositeCorner[0] - this.lastXY[0]) / Math.abs(oppositeCorner[1] - this.lastXY[1]);\n\n                // If drag ratio > aspect ratio then width is dominant and height must obey\n                if (dragRatio > ratio) {\n                    newBox.height = newHeight;\n                } else {\n                    newBox.width = newWidth;\n                }\n\n                // Handle dragging start coordinates\n                if (region == 'northeast') {\n                    newBox.y = box.y - (newBox.height - box.height);\n                } else if (region == 'northwest') {\n                    newBox.y = box.y - (newBox.height - box.height);\n                    newBox.x = box.x - (newBox.width - box.width);\n                } else if (region == 'southwest') {\n                    newBox.x = box.x - (newBox.width - box.width);\n                }\n            }\n        }\n\n        if (heightAdjust === 0) {\n            vertDir = 'none';\n        }\n        if (widthAdjust === 0) {\n            horizDir = 'none';\n        }\n        me.resize(newBox, {\n            horizontal: horizDir,\n            vertical: vertDir\n        }, atEnd);\n    },\n\n    getResizeTarget: function(atEnd) {\n        return atEnd ? this.target : this.getDynamicTarget();\n    },\n\n    resize: function(box, direction, atEnd) {\n        var target = this.getResizeTarget(atEnd);\n        if (target.isComponent) {\n            target.setSize(box.width, box.height);\n            if (target.floating) {\n                target.setPagePosition(box.x, box.y);\n            }\n        } else {\n            target.setBox(box);\n        }\n\n        // update the originalTarget if it was wrapped, and the target passed in was the wrap el.\n        target = this.originalTarget;\n        if (target && (this.dynamic || atEnd)) {\n            if (target.isComponent) {\n                target.setSize(box.width, box.height);\n                if (target.floating) {\n                    target.setPagePosition(box.x, box.y);\n                }\n            } else {\n                target.setBox(box);\n            }\n        }\n    },\n\n    onEnd: function(e) {\n        this.updateDimensions(e, true);\n        if (this.proxy) {\n            this.proxy.hide();\n        }\n    }\n});\n\n/**\n * Applies drag handles to an element or component to make it resizable. The drag handles are inserted into the element\n * (or component's element) and positioned absolute.\n *\n * Textarea and img elements will be wrapped with an additional div because these elements do not support child nodes.\n * The original element can be accessed through the originalTarget property.\n *\n * Here is the list of valid resize handles:\n *\n *     Value   Description\n *     ------  -------------------\n *      'n'     north\n *      's'     south\n *      'e'     east\n *      'w'     west\n *      'nw'    northwest\n *      'sw'    southwest\n *      'se'    southeast\n *      'ne'    northeast\n *      'all'   all\n *\n * {@img Ext.resizer.Resizer/Ext.resizer.Resizer.png Ext.resizer.Resizer component}\n *\n * Here's an example showing the creation of a typical Resizer:\n *\n *     Ext.create('Ext.resizer.Resizer', {\n *         el: 'elToResize',\n *         handles: 'all',\n *         minWidth: 200,\n *         minHeight: 100,\n *         maxWidth: 500,\n *         maxHeight: 400,\n *         pinned: true\n *     });\n */\nExt.define('Ext.resizer.Resizer', {\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n    uses: ['Ext.resizer.ResizeTracker', 'Ext.Component'],\n\n    alternateClassName: 'Ext.Resizable',\n\n    handleCls: Ext.baseCSSPrefix + 'resizable-handle',\n    pinnedCls: Ext.baseCSSPrefix + 'resizable-pinned',\n    overCls:   Ext.baseCSSPrefix + 'resizable-over',\n    wrapCls:   Ext.baseCSSPrefix + 'resizable-wrap',\n\n    /**\n     * @cfg {Boolean} dynamic\n     * Specify as true to update the {@link #target} (Element or {@link Ext.Component Component}) dynamically during\n     * dragging. This is `true` by default, but the {@link Ext.Component Component} class passes `false` when it is\n     * configured as {@link Ext.Component#resizable}.\n     *\n     * If specified as `false`, a proxy element is displayed during the resize operation, and the {@link #target} is\n     * updated on mouseup.\n     */\n    dynamic: true,\n\n    /**\n     * @cfg {String} handles\n     * String consisting of the resize handles to display. Defaults to 's e se' for Elements and fixed position\n     * Components. Defaults to 8 point resizing for floating Components (such as Windows). Specify either `'all'` or any\n     * of `'n s e w ne nw se sw'`.\n     */\n    handles: 's e se',\n\n    /**\n     * @cfg {Number} height\n     * Optional. The height to set target to in pixels\n     */\n    height : null,\n\n    /**\n     * @cfg {Number} width\n     * Optional. The width to set the target to in pixels\n     */\n    width : null,\n\n    /**\n     * @cfg {Number} heightIncrement\n     * The increment to snap the height resize in pixels.\n     */\n    heightIncrement : 0,\n\n    /**\n     * @cfg {Number} widthIncrement\n     * The increment to snap the width resize in pixels.\n     */\n    widthIncrement : 0,\n\n    /**\n     * @cfg {Number} minHeight\n     * The minimum height for the element\n     */\n    minHeight : 20,\n\n    /**\n     * @cfg {Number} minWidth\n     * The minimum width for the element\n     */\n    minWidth : 20,\n\n    /**\n     * @cfg {Number} maxHeight\n     * The maximum height for the element\n     */\n    maxHeight : 10000,\n\n    /**\n     * @cfg {Number} maxWidth\n     * The maximum width for the element\n     */\n    maxWidth : 10000,\n\n    /**\n     * @cfg {Boolean} pinned\n     * True to ensure that the resize handles are always visible, false indicates resizing by cursor changes only\n     */\n    pinned: false,\n\n    /**\n     * @cfg {Boolean} preserveRatio\n     * True to preserve the original ratio between height and width during resize\n     */\n    preserveRatio: false,\n\n    /**\n     * @cfg {Boolean} transparent\n     * True for transparent handles. This is only applied at config time.\n     */\n    transparent: false,\n\n    /**\n     * @cfg {Ext.Element/Ext.util.Region} constrainTo\n     * An element, or a {@link Ext.util.Region Region} into which the resize operation must be constrained.\n     */\n\n    possiblePositions: {\n        n:  'north',\n        s:  'south',\n        e:  'east',\n        w:  'west',\n        se: 'southeast',\n        sw: 'southwest',\n        nw: 'northwest',\n        ne: 'northeast'\n    },\n\n    /**\n     * @cfg {Ext.Element/Ext.Component} target\n     * The Element or Component to resize.\n     */\n\n    /**\n     * @property {Ext.Element} el\n     * Outer element for resizing behavior.\n     */\n\n    constructor: function(config) {\n        var me = this,\n            target,\n            targetEl,\n            tag,\n            handles = me.handles,\n            handleCls,\n            possibles,\n            len,\n            i = 0,\n            pos, \n            handleEls = [],\n            eastWestStyle, style,\n            box;\n\n        me.addEvents(\n            /**\n             * @event beforeresize\n             * Fired before resize is allowed. Return false to cancel resize.\n             * @param {Ext.resizer.Resizer} this\n             * @param {Number} width The start width\n             * @param {Number} height The start height\n             * @param {Ext.EventObject} e The mousedown event\n             */\n            'beforeresize',\n            /**\n             * @event resizedrag\n             * Fires during resizing. Return false to cancel resize.\n             * @param {Ext.resizer.Resizer} this\n             * @param {Number} width The new width\n             * @param {Number} height The new height\n             * @param {Ext.EventObject} e The mousedown event\n             */\n            'resizedrag',\n            /**\n             * @event resize\n             * Fired after a resize.\n             * @param {Ext.resizer.Resizer} this\n             * @param {Number} width The new width\n             * @param {Number} height The new height\n             * @param {Ext.EventObject} e The mouseup event\n             */\n            'resize'\n        );\n\n        if (Ext.isString(config) || Ext.isElement(config) || config.dom) {\n            target = config;\n            config = arguments[1] || {};\n            config.target = target;\n        }\n        // will apply config to this\n        me.mixins.observable.constructor.call(me, config);\n\n        // If target is a Component, ensure that we pull the element out.\n        // Resizer must examine the underlying Element.\n        target = me.target;\n        if (target) {\n            if (target.isComponent) {\n                me.el = target.getEl();\n                if (target.minWidth) {\n                    me.minWidth = target.minWidth;\n                }\n                if (target.minHeight) {\n                    me.minHeight = target.minHeight;\n                }\n                if (target.maxWidth) {\n                    me.maxWidth = target.maxWidth;\n                }\n                if (target.maxHeight) {\n                    me.maxHeight = target.maxHeight;\n                }\n                if (target.floating) {\n                    if (!me.hasOwnProperty('handles')) {\n                        me.handles = 'n ne e se s sw w nw';\n                    }\n                }\n            } else {\n                me.el = me.target = Ext.get(target);\n            }\n        }\n        // Backwards compatibility with Ext3.x's Resizable which used el as a config.\n        else {\n            me.target = me.el = Ext.get(me.el);\n        }\n\n        // Tags like textarea and img cannot\n        // have children and therefore must\n        // be wrapped\n        tag = me.el.dom.tagName.toUpperCase();\n        if (tag == 'TEXTAREA' || tag == 'IMG' || tag == 'TABLE') {\n            /**\n             * @property {Ext.Element/Ext.Component} originalTarget\n             * Reference to the original resize target if the element of the original resize target was a\n             * {@link Ext.form.field.Field Field}, or an IMG or a TEXTAREA which must be wrapped in a DIV.\n             */\n            me.originalTarget = me.target;\n            targetEl = me.el;\n            box = targetEl.getBox();\n            me.target = me.el = me.el.wrap({\n                cls: me.wrapCls,\n                id: me.el.id + '-rzwrap',\n                style: targetEl.getStyles('margin-top', 'margin-bottom')\n            });\n\n            // Transfer originalTarget's positioning+sizing+margins\n            me.el.setPositioning(targetEl.getPositioning());\n            targetEl.clearPositioning();\n            me.el.setBox(box);\n\n            // Position the wrapped element absolute so that it does not stretch the wrapper\n            targetEl.setStyle('position', 'absolute');\n        }\n\n        // Position the element, this enables us to absolute position\n        // the handles within this.el\n        me.el.position();\n        if (me.pinned) {\n            me.el.addCls(me.pinnedCls);\n        }\n\n        /**\n         * @property {Ext.resizer.ResizeTracker} resizeTracker\n         */\n        me.resizeTracker = new Ext.resizer.ResizeTracker({\n            disabled: me.disabled,\n            target: me.target,\n            constrainTo: me.constrainTo,\n            overCls: me.overCls,\n            throttle: me.throttle,\n            originalTarget: me.originalTarget,\n            delegate: '.' + me.handleCls,\n            dynamic: me.dynamic,\n            preserveRatio: me.preserveRatio,\n            heightIncrement: me.heightIncrement,\n            widthIncrement: me.widthIncrement,\n            minHeight: me.minHeight,\n            maxHeight: me.maxHeight,\n            minWidth: me.minWidth,\n            maxWidth: me.maxWidth\n        });\n\n        // Relay the ResizeTracker's superclass events as our own resize events\n        me.resizeTracker.on({\n            mousedown: me.onBeforeResize,\n            drag: me.onResize,\n            dragend: me.onResizeEnd,\n            scope: me\n        });\n\n        if (me.handles == 'all') {\n            me.handles = 'n s e w ne nw se sw';\n        }\n\n        handles = me.handles = me.handles.split(/ |\\s*?[,;]\\s*?/);\n        possibles = me.possiblePositions;\n        len = handles.length;\n        handleCls = me.handleCls + ' ' + (me.target.isComponent ? (me.target.baseCls + '-handle ') : '') + me.handleCls + '-';\n\n        // Needs heighting on IE6!\n        eastWestStyle = Ext.isIE6 ? ' style=\"height:' + me.el.getHeight() + 'px\"' : '';\n\n        for (; i < len; i++){\n            // if specified and possible, create\n            if (handles[i] && possibles[handles[i]]) {\n                pos = possibles[handles[i]];\n                if (pos === 'east' || pos === 'west') {\n                    style = eastWestStyle;\n                } else {\n                    style = '';\n                }\n                handleEls.push('<div id=\"' + me.el.id + '-' + pos + '-handle\" class=\"' + handleCls + pos + ' ' + Ext.baseCSSPrefix + 'unselectable\"' + style + '></div>');\n            }\n        }\n        Ext.DomHelper.append(me.el, handleEls.join(''));\n\n        // store a reference to each handle elelemtn in this.east, this.west, etc\n        for (i = 0; i < len; i++){\n            // if specified and possible, create\n            if (handles[i] && possibles[handles[i]]) {\n                pos = possibles[handles[i]];\n                me[pos] = me.el.getById(me.el.id + '-' + pos + '-handle');\n                me[pos].region = pos;\n                me[pos].unselectable();\n                if (me.transparent) {\n                    me[pos].setOpacity(0);\n                }\n            }\n        }\n\n        // Constrain within configured maxima\n        if (Ext.isNumber(me.width)) {\n            me.width = Ext.Number.constrain(me.width, me.minWidth, me.maxWidth);\n        }\n        if (Ext.isNumber(me.height)) {\n            me.height = Ext.Number.constrain(me.height, me.minHeight, me.maxHeight);\n        }\n\n        // Size the target (and originalTarget)\n        if (me.width !== null || me.height !== null) {\n            if (me.originalTarget) {\n                me.originalTarget.setWidth(me.width);\n                me.originalTarget.setHeight(me.height);\n            }\n            me.resizeTo(me.width, me.height);\n        }\n\n        me.forceHandlesHeight();\n    },\n\n    disable: function() {\n        this.resizeTracker.disable();\n    },\n\n    enable: function() {\n        this.resizeTracker.enable();\n    },\n\n    /**\n     * @private Relay the Tracker's mousedown event as beforeresize\n     * @param tracker The Resizer\n     * @param e The Event\n     */\n    onBeforeResize: function(tracker, e) {\n        var box = this.el.getBox();\n        return this.fireEvent('beforeresize', this, box.width, box.height, e);\n    },\n\n    /**\n     * @private Relay the Tracker's drag event as resizedrag\n     * @param tracker The Resizer\n     * @param e The Event\n     */\n    onResize: function(tracker, e) {\n        var me = this,\n            box = me.el.getBox();\n            \n        me.forceHandlesHeight();\n        return me.fireEvent('resizedrag', me, box.width, box.height, e);\n    },\n\n    /**\n     * @private Relay the Tracker's dragend event as resize\n     * @param tracker The Resizer\n     * @param e The Event\n     */\n    onResizeEnd: function(tracker, e) {\n        var me = this,\n            box = me.el.getBox();\n            \n        me.forceHandlesHeight();\n        return me.fireEvent('resize', me, box.width, box.height, e);\n    },\n\n    /**\n     * Perform a manual resize and fires the 'resize' event.\n     * @param {Number} width\n     * @param {Number} height\n     */\n    resizeTo : function(width, height) {\n        var me = this;\n        me.target.setSize(width, height);\n        me.fireEvent('resize', me, width, height, null);\n    },\n\n    /**\n     * Returns the element that was configured with the el or target config property. If a component was configured with\n     * the target property then this will return the element of this component.\n     *\n     * Textarea and img elements will be wrapped with an additional div because these elements do not support child\n     * nodes. The original element can be accessed through the originalTarget property.\n     * @return {Ext.Element} element\n     */\n    getEl : function() {\n        return this.el;\n    },\n\n    /**\n     * Returns the element or component that was configured with the target config property.\n     *\n     * Textarea and img elements will be wrapped with an additional div because these elements do not support child\n     * nodes. The original element can be accessed through the originalTarget property.\n     * @return {Ext.Element/Ext.Component}\n     */\n    getTarget: function() {\n        return this.target;\n    },\n\n    destroy: function() {\n        var i = 0,\n            handles = this.handles,\n            len = handles.length,\n            positions = this.possiblePositions;\n\n        for (; i < len; i++) {\n            this[positions[handles[i]]].remove();\n        }\n    },\n\n    /**\n     * @private\n     * Fix IE6 handle height issue.\n     */\n    forceHandlesHeight : function() {\n        var me = this,\n            handle;\n        if (Ext.isIE6) {\n            handle = me.east;\n            if (handle) {\n                handle.setHeight(me.el.getHeight());\n            }\n            handle = me.west;\n            if (handle) {\n                handle.setHeight(me.el.getHeight());\n            }\n            me.el.repaint();\n        }\n    }\n});\n\n/**\n *\n */\nExt.define('Ext.selection.CellModel', {\n    extend: 'Ext.selection.Model',\n    alias: 'selection.cellmodel',\n    requires: ['Ext.util.KeyNav'],\n\n    isCellModel: true,\n\n    /**\n     * @cfg {Boolean} enableKeyNav\n     * Turns on/off keyboard navigation within the grid.\n     */\n    enableKeyNav: true,\n\n    /**\n     * @cfg {Boolean} preventWrap\n     * Set this configuration to true to prevent wrapping around of selection as\n     * a user navigates to the first or last column.\n     */\n    preventWrap: false,\n\n    // private property to use when firing a deselect when no old selection exists.\n    noSelection: {\n        row: -1,\n        column: -1\n    },\n\n    constructor: function() {\n        this.addEvents(\n            /**\n             * @event deselect\n             * Fired after a cell is deselected\n             * @param {Ext.selection.CellModel} this\n             * @param {Ext.data.Model} record The record of the deselected cell\n             * @param {Number} row The row index deselected\n             * @param {Number} column The column index deselected\n             */\n            'deselect',\n\n            /**\n             * @event select\n             * Fired after a cell is selected\n             * @param {Ext.selection.CellModel} this\n             * @param {Ext.data.Model} record The record of the selected cell\n             * @param {Number} row The row index selected\n             * @param {Number} column The column index selected\n             */\n            'select'\n        );\n        this.callParent(arguments);\n    },\n\n    bindComponent: function(view) {\n        var me = this,\n            grid = view.ownerCt;\n        me.primaryView = view;\n        me.views = me.views || [];\n        me.views.push(view);\n        me.bindStore(view.getStore(), true);\n\n        view.on({\n            cellmousedown: me.onMouseDown,\n            refresh: me.onViewRefresh,\n            scope: me\n        });\n        if (grid.optimizedColumnMove !== false) {\n            grid.on('columnmove', me.onColumnMove, me);\n        }\n\n        if (me.enableKeyNav) {\n            me.initKeyNav(view);\n        }\n    },\n\n    initKeyNav: function(view) {\n        var me = this;\n\n        if (!view.rendered) {\n            view.on('render', Ext.Function.bind(me.initKeyNav, me, [view], 0), me, {single: true});\n            return;\n        }\n\n        view.el.set({\n            tabIndex: -1\n        });\n\n        // view.el has tabIndex -1 to allow for\n        // keyboard events to be passed to it.\n        me.keyNav = new Ext.util.KeyNav({\n            target: view.el,\n            ignoreInputFields: true,\n            up: me.onKeyUp,\n            down: me.onKeyDown,\n            right: me.onKeyRight,\n            left: me.onKeyLeft,\n            tab: me.onKeyTab,\n            scope: me\n        });\n    },\n\n    getHeaderCt: function() {\n        var selection = this.getCurrentPosition(),\n            view = selection ? selection.view : this.primaryView;\n\n        return view.headerCt;\n    },\n\n    onKeyUp: function(e, t) {\n        this.keyNavigation = true;\n        this.move('up', e);\n        this.keyNavigation = false;\n    },\n\n    onKeyDown: function(e, t) {\n        this.keyNavigation = true;\n        this.move('down', e);\n        this.keyNavigation = false;\n    },\n\n    onKeyLeft: function(e, t) {\n        this.keyNavigation = true;\n        this.move('left', e);\n        this.keyNavigation = false;\n    },\n\n    onKeyRight: function(e, t) {\n        this.keyNavigation = true;\n        this.move('right', e);\n        this.keyNavigation = false;\n    },\n\n    move: function(dir, e) {\n        var me = this,\n            pos = me.getCurrentPosition(),\n            \n            // Calculate the new row and column position\n            newPos = pos.view.walkCells(pos, dir, e, me.preventWrap);\n\n        // If walk was successful, select new Position\n        if (newPos) {\n            newPos.view = pos.view;\n            return me.setCurrentPosition(newPos);\n        }\n        // Enforce code correctness in unbuilt source.\n        return null;\n    },\n\n    /**\n     * Returns the current position in the format {row: row, column: column}\n     */\n    getCurrentPosition: function() {\n        return this.selection;\n    },\n\n    /**\n     * Sets the current position\n     * @param {Object} position The position to set.\n     */\n    setCurrentPosition: function(pos) {\n        var me = this;\n\n        // onSelectChange uses lastSelection and nextSelection\n        me.lastSelection = me.selection;\n        if (me.selection) {\n            me.onCellDeselect(me.selection);\n        }\n\n        if (pos) {\n            me.nextSelection = new me.Selection(me);\n            me.nextSelection.setPosition(pos);\n            me.onCellSelect(me.nextSelection);\n\n            // Deselect triggered by new selection will kill the selection property, so restore it here.\n            return me.selection = me.nextSelection;\n        }\n        // Enforce code correctness in unbuilt source.\n        return null;\n    },\n\n    // Keep selection model in consistent state upon record deletion.\n    onStoreRemove: function(store, record, index) {\n        var me = this,\n            pos = me.getCurrentPosition();\n\n        me.callParent(arguments);\n        if (pos) {\n            // Deleting the row containing the selection.\n            // Attempt to reselect the same cell which has moved up if there is one\n            if (pos.row == index) {\n                if (index < store.getCount() - 1) {\n                    pos.setPosition(index, pos.column);\n                    me.setCurrentPosition(pos);\n                } else {\n                    delete me.selection;\n                }\n            }\n            // Deleting a row before the selection.\n            // Move the selection up by one row\n            else if (index < pos.row) {\n                pos.setPosition(pos.row - 1, pos.column);\n                me.setCurrentPosition(pos);\n            }\n        }\n    },\n\n    /**\n     * Set the current position based on where the user clicks.\n     * @private\n     */\n    onMouseDown: function(view, cell, cellIndex, record, row, rowIndex, e) {\n        this.setCurrentPosition({\n            view: view,\n            row: rowIndex,\n            column: cellIndex\n        });\n    },\n\n    // notify the view that the cell has been selected to update the ui\n    // appropriately and bring the cell into focus\n    onCellSelect: function(position, supressEvent) {\n        if (position && position.row !== undefined && position.row > -1) {\n            this.doSelect(position.view.getStore().getAt(position.row), /*keepExisting*/false, supressEvent);\n        }\n    },\n\n    // notify view that the cell has been deselected to update the ui\n    // appropriately\n    onCellDeselect: function(position, supressEvent) {\n        if (position && position.row !== undefined) {\n            this.doDeselect(position.view.getStore().getAt(position.row), supressEvent);\n        }\n    },\n\n    onSelectChange: function(record, isSelected, suppressEvent, commitFn) {\n        var me = this,\n            pos,\n            eventName,\n            view;\n\n        if (isSelected) {\n            pos = me.nextSelection;\n            eventName = 'select';\n        } else {\n            pos = me.lastSelection || me.noSelection;\n            eventName = 'deselect';\n        }\n\n        // CellModel may be shared between two sides of a Lockable.\n        // The position must include a reference to the view in which the selection is current.\n        // Ensure we use the view specifiied by the position.\n        view = pos.view || me.primaryView;\n\n        if ((suppressEvent || me.fireEvent('before' + eventName, me, record, pos.row, pos.column)) !== false &&\n                commitFn() !== false) {\n\n            if (isSelected) {\n                view.onCellSelect(pos);\n                view.onCellFocus(pos);\n            } else {\n                view.onCellDeselect(pos);\n                delete me.selection;\n            }\n\n            if (!suppressEvent) {\n                me.fireEvent(eventName, me, record, pos.row, pos.column);\n            }\n        }\n    },\n\n    // Tab key from the View's KeyNav, *not* from an editor.\n    onKeyTab: function(e, t) {\n        var me = this,\n            editingPlugin = me.getCurrentPosition().view.editingPlugin;\n\n        // If we were in editing mode, but just focused on a non-editable cell, behave as if we tabbed off an editable field\n        if (editingPlugin && me.wasEditing) {\n            me.onEditorTab(editingPlugin, e)\n        } else {\n            me.move(e.shiftKey ? 'left' : 'right', e);\n        }\n    },\n\n    onEditorTab: function(editingPlugin, e) {\n        var me = this,\n            direction = e.shiftKey ? 'left' : 'right',\n            position  = me.move(direction, e);\n\n        // Navigation had somewhere to go.... not hit the buffers.\n        if (position) {\n            // If we were able to begin editing clear the wasEditing flag. It gets set during navigation off an active edit.\n            if (editingPlugin.startEditByPosition(position)) {\n                me.wasEditing = false;\n            }\n            // If we could not continue editing...\n            // Set a flag that we should go back into editing mode upon next onKeyTab call\n            else {\n                me.wasEditing = true;\n                if (!position.columnHeader.dataIndex) {\n                    me.onEditorTab(editingPlugin, e);\n                }\n            }\n        }\n    },\n\n    refresh: function() {\n        var pos = this.getCurrentPosition(),\n            selRowIdx;\n\n        // Synchronize the current position's row with the row of the last selected record.\n        if (pos && (selRowIdx = this.store.indexOf(this.selected.last())) !== -1) {\n            pos.row = selRowIdx;\n        }\n    },\n\n    /**\n     * @private\n     * When grid uses {@link Ext.panel.Table#optimizedColumnMove optimizedColumnMove} (the default), this is added as a\n     * {@link Ext.panel.Table#columnmove columnmove} handler to correctly maintain the\n     * selected column using the same column header.\n     * \n     * If optimizedColumnMove === false, (which some grid Features set) then the view is refreshed,\n     * so this is not added as a handler because the selected column.\n     */\n    onColumnMove: function(headerCt, header, fromIdx, toIdx) {\n        var grid = headerCt.up('tablepanel');\n        if (grid) {\n            this.onViewRefresh(grid.view);\n        }\n    },\n\n    onViewRefresh: function(view) {\n        var me = this,\n            pos = me.getCurrentPosition(),\n            headerCt = view.headerCt,\n            record, columnHeader;\n\n        // Re-establish selection of the same cell coordinate.\n        // DO NOT fire events because the selected \n        if (pos && pos.view === view) {\n            record = pos.record;\n            columnHeader = pos.columnHeader;\n\n            // After a refresh, recreate the selection using the same record and grid column as before\n            if (!columnHeader.isDescendantOf(headerCt)) {\n                // column header is not a child of the header container\n                // this happens when the grid is reconfigured with new columns\n                // make a best effor to select something by matching on id, then text, then dataIndex\n                columnHeader = headerCt.queryById(columnHeader.id) || \n                               headerCt.down('[text=\"' + columnHeader.text + '\"]') ||\n                               headerCt.down('[dataIndex=\"' + columnHeader.dataIndex + '\"]');\n            }\n\n            // If we have a columnHeader (either the column header that already exists in\n            // the headerCt, or a suitable match that was found after reconfiguration)\n            // AND the record still exists in the store (or a record matching the id of\n            // the previously selected record) We are ok to go ahead and set the selection\n            if (columnHeader && (view.store.indexOfId(record.getId()) !== -1)) {\n                me.setCurrentPosition({\n                    row: record,\n                    column: columnHeader,\n                    view: view\n                });\n            }\n        }\n    },\n\n    selectByPosition: function(position) {\n        this.setCurrentPosition(position);\n    }\n}, function() {\n    \n    // Encapsulate a single selection position.\n    // Maintains { row: n, column: n, record: r, columnHeader: c}\n    var Selection = this.prototype.Selection = function(model) {\n        this.model = model;\n    };\n    // Selection row/record & column/columnHeader\n    Selection.prototype.setPosition = function(row, col) {\n        var me = this,\n            view;\n\n        // We were passed {row: 1, column: 2, view: myView}\n        if (arguments.length === 1) {\n            \n            // SelectionModel is shared between both sides of a locking grid.\n            // It can be positioned on either view.\n            if (row.view) {\n                me.view = view = row.view;\n            }\n            col = row.column;\n            row = row.row;\n        }\n        \n        // If setting the position without specifying a view, and the position is already without a view\n        // use the owning Model's primary view\n        if (!view) {\n            me.view = view = me.model.primaryView;\n        }\n\n        // Row index passed\n        if (typeof row === 'number') {\n            me.row = row;\n            me.record = view.store.getAt(row);\n        }\n        // row is a Record\n        else if (row.isModel) {\n            me.record = row;\n            me.row = view.indexOf(row);\n        }\n        // row is a grid row\n        else if (row.tagName) {\n            me.record = view.getRecord(row);\n            me.row = view.indexOf(me.record);\n        }\n        \n        // column index passed\n        if (typeof col === 'number') {\n            me.column = col;\n            me.columnHeader = view.getHeaderAtIndex(col);\n        }\n        // col is a column Header\n        else {\n            me.columnHeader = col;\n            me.column = col.getIndex();\n        }\n        return me;\n    }\n});\n\n/**\n * Implements row based navigation via keyboard.\n *\n * Must synchronize across grid sections.\n */\nExt.define('Ext.selection.RowModel', {\n    extend: 'Ext.selection.Model',\n    alias: 'selection.rowmodel',\n    requires: ['Ext.util.KeyNav'],\n\n    /**\n     * @private\n     * Number of pixels to scroll to the left/right when pressing\n     * left/right keys.\n     */\n    deltaScroll: 5,\n\n    /**\n     * @cfg {Boolean} enableKeyNav\n     *\n     * Turns on/off keyboard navigation within the grid.\n     */\n    enableKeyNav: true,\n    \n    /**\n     * @cfg {Boolean} [ignoreRightMouseSelection=false]\n     * True to ignore selections that are made when using the right mouse button if there are\n     * records that are already selected. If no records are selected, selection will continue \n     * as normal\n     */\n    ignoreRightMouseSelection: false,\n\n    constructor: function() {\n        this.addEvents(\n            /**\n             * @event beforedeselect\n             * Fired before a record is deselected. If any listener returns false, the\n             * deselection is cancelled.\n             * @param {Ext.selection.RowModel} this\n             * @param {Ext.data.Model} record The deselected record\n             * @param {Number} index The row index deselected\n             */\n            'beforedeselect',\n\n            /**\n             * @event beforeselect\n             * Fired before a record is selected. If any listener returns false, the\n             * selection is cancelled.\n             * @param {Ext.selection.RowModel} this\n             * @param {Ext.data.Model} record The selected record\n             * @param {Number} index The row index selected\n             */\n            'beforeselect',\n\n            /**\n             * @event deselect\n             * Fired after a record is deselected\n             * @param {Ext.selection.RowModel} this\n             * @param {Ext.data.Model} record The deselected record\n             * @param {Number} index The row index deselected\n             */\n            'deselect',\n\n            /**\n             * @event select\n             * Fired after a record is selected\n             * @param {Ext.selection.RowModel} this\n             * @param {Ext.data.Model} record The selected record\n             * @param {Number} index The row index selected\n             */\n            'select'\n        );\n        this.views = [];\n        this.callParent(arguments);\n    },\n\n    bindComponent: function(view) {\n        var me = this;\n\n        me.views = me.views || [];\n        me.views.push(view);\n        me.bindStore(view.getStore(), true);\n\n        view.on({\n            itemmousedown: me.onRowMouseDown,\n            scope: me\n        });\n\n        if (me.enableKeyNav) {\n            me.initKeyNav(view);\n        }\n    },\n\n    initKeyNav: function(view) {\n        var me = this;\n\n        if (!view.rendered) {\n            view.on('render', Ext.Function.bind(me.initKeyNav, me, [view], 0), me, {single: true});\n            return;\n        }\n\n        // view.el has tabIndex -1 to allow for\n        // keyboard events to be passed to it.\n        view.el.set({\n            tabIndex: -1\n        });\n\n        // Drive the KeyNav off the View's itemkeydown event so that beforeitemkeydown listeners may veto\n        me.keyNav = new Ext.util.KeyNav({\n            target: view,\n            ignoreInputFields: true,\n            eventName: 'itemkeydown',\n            processEvent: function(view, record, node, index, event) {\n                event.record = record;\n                event.recordIndex = index;\n                return event;\n            },\n            up: me.onKeyUp,\n            down: me.onKeyDown,\n            right: me.onKeyRight,\n            left: me.onKeyLeft,\n            pageDown: me.onKeyPageDown,\n            pageUp: me.onKeyPageUp,\n            home: me.onKeyHome,\n            end: me.onKeyEnd,\n            space: me.onKeySpace,\n            enter: me.onKeyEnter,\n            scope: me\n        });\n    },\n\n    // Returns the number of rows currently visible on the screen or\n    // false if there were no rows. This assumes that all rows are\n    // of the same height and the first view is accurate.\n    getRowsVisible: function() {\n        var rowsVisible = false,\n            view = this.views[0],\n            row = view.getNode(0),\n            rowHeight, gridViewHeight;\n\n        if (row) {\n            rowHeight = Ext.fly(row).getHeight();\n            gridViewHeight = view.el.getHeight();\n            rowsVisible = Math.floor(gridViewHeight / rowHeight);\n        }\n\n        return rowsVisible;\n    },\n\n    // go to last visible record in grid.\n    onKeyEnd: function(e) {\n        var me = this,\n            last = me.store.getAt(me.store.getCount() - 1);\n\n        if (last) {\n            if (e.shiftKey) {\n                me.selectRange(last, me.lastFocused || 0);\n                me.setLastFocused(last);\n            } else if (e.ctrlKey) {\n                me.setLastFocused(last);\n            } else {\n                me.doSelect(last);\n            }\n        }\n    },\n\n    // go to first visible record in grid.\n    onKeyHome: function(e) {\n        var me = this,\n            first = me.store.getAt(0);\n\n        if (first) {\n            if (e.shiftKey) {\n                me.selectRange(first, me.lastFocused || 0);\n                me.setLastFocused(first);\n            } else if (e.ctrlKey) {\n                me.setLastFocused(first);\n            } else {\n                me.doSelect(first, false);\n            }\n        }\n    },\n\n    // Go one page up from the lastFocused record in the grid.\n    onKeyPageUp: function(e) {\n        var me = this,\n            rowsVisible = me.getRowsVisible(),\n            selIdx,\n            prevIdx,\n            prevRecord;\n\n        if (rowsVisible) {\n            selIdx = e.recordIndex;\n            prevIdx = selIdx - rowsVisible;\n            if (prevIdx < 0) {\n                prevIdx = 0;\n            }\n            prevRecord = me.store.getAt(prevIdx);\n            if (e.shiftKey) {\n                me.selectRange(prevRecord, e.record, e.ctrlKey, 'up');\n                me.setLastFocused(prevRecord);\n            } else if (e.ctrlKey) {\n                e.preventDefault();\n                me.setLastFocused(prevRecord);\n            } else {\n                me.doSelect(prevRecord);\n            }\n\n        }\n    },\n\n    // Go one page down from the lastFocused record in the grid.\n    onKeyPageDown: function(e) {\n        var me = this,\n            rowsVisible = me.getRowsVisible(),\n            selIdx,\n            nextIdx,\n            nextRecord;\n\n        if (rowsVisible) {\n            selIdx = e.recordIndex;\n            nextIdx = selIdx + rowsVisible;\n            if (nextIdx >= me.store.getCount()) {\n                nextIdx = me.store.getCount() - 1;\n            }\n            nextRecord = me.store.getAt(nextIdx);\n            if (e.shiftKey) {\n                me.selectRange(nextRecord, e.record, e.ctrlKey, 'down');\n                me.setLastFocused(nextRecord);\n            } else if (e.ctrlKey) {\n                // some browsers, this means go thru browser tabs\n                // attempt to stop.\n                e.preventDefault();\n                me.setLastFocused(nextRecord);\n            } else {\n                me.doSelect(nextRecord);\n            }\n        }\n    },\n\n    // Select/Deselect based on pressing Spacebar.\n    // Assumes a SIMPLE selectionmode style\n    onKeySpace: function(e) {\n        var me = this,\n            record = me.lastFocused;\n\n        if (record) {\n            if (me.isSelected(record)) {\n                me.doDeselect(record, false);\n            } else {\n                me.doSelect(record, true);\n            }\n        }\n    },\n    \n    onKeyEnter: Ext.emptyFn,\n\n    // Navigate one record up. This could be a selection or\n    // could be simply focusing a record for discontiguous\n    // selection. Provides bounds checking.\n    onKeyUp: function(e) {\n        var me = this,\n            idx  = me.store.indexOf(me.lastFocused),\n            record;\n\n        if (idx > 0) {\n            // needs to be the filtered count as thats what\n            // will be visible.\n            record = me.store.getAt(idx - 1);\n            if (e.shiftKey && me.lastFocused) {\n                if (me.isSelected(me.lastFocused) && me.isSelected(record)) {\n                    me.doDeselect(me.lastFocused, true);\n                    me.setLastFocused(record);\n                } else if (!me.isSelected(me.lastFocused)) {\n                    me.doSelect(me.lastFocused, true);\n                    me.doSelect(record, true);\n                } else {\n                    me.doSelect(record, true);\n                }\n            } else if (e.ctrlKey) {\n                me.setLastFocused(record);\n            } else {\n                me.doSelect(record);\n                //view.focusRow(idx - 1);\n            }\n        }\n        // There was no lastFocused record, and the user has pressed up\n        // Ignore??\n        //else if (this.selected.getCount() == 0) {\n        //\n        //    this.doSelect(record);\n        //    //view.focusRow(idx - 1);\n        //}\n    },\n\n    // Navigate one record down. This could be a selection or\n    // could be simply focusing a record for discontiguous\n    // selection. Provides bounds checking.\n    onKeyDown: function(e) {\n        var me = this,\n            idx  = me.store.indexOf(me.lastFocused),\n            record;\n\n        // needs to be the filtered count as thats what\n        // will be visible.\n        if (idx + 1 < me.store.getCount()) {\n            record = me.store.getAt(idx + 1);\n            if (me.selected.getCount() === 0) {\n                if (!e.ctrlKey) {\n                    me.doSelect(record);\n                } else {\n                    me.setLastFocused(record);\n                }\n                //view.focusRow(idx + 1);\n            } else if (e.shiftKey && me.lastFocused) {\n                if (me.isSelected(me.lastFocused) && me.isSelected(record)) {\n                    me.doDeselect(me.lastFocused, true);\n                    me.setLastFocused(record);\n                } else if (!me.isSelected(me.lastFocused)) {\n                    me.doSelect(me.lastFocused, true);\n                    me.doSelect(record, true);\n                } else {\n                    me.doSelect(record, true);\n                }\n            } else if (e.ctrlKey) {\n                me.setLastFocused(record);\n            } else {\n                me.doSelect(record);\n                //view.focusRow(idx + 1);\n            }\n        }\n    },\n\n    scrollByDeltaX: function(delta) {\n        var view    = this.views[0],\n            section = view.up(),\n            hScroll = section.horizontalScroller;\n\n        if (hScroll) {\n            hScroll.scrollByDeltaX(delta);\n        }\n    },\n\n    onKeyLeft: function(e) {\n        this.scrollByDeltaX(-this.deltaScroll);\n    },\n\n    onKeyRight: function(e) {\n        this.scrollByDeltaX(this.deltaScroll);\n    },\n\n    // Select the record with the event included so that\n    // we can take into account ctrlKey, shiftKey, etc\n    onRowMouseDown: function(view, record, item, index, e) {\n        if (!this.allowRightMouseSelection(e)) {\n            return;\n        }\n\n        if (e.button === 0 || !this.isSelected(record)) {\n            this.selectWithEvent(record, e);\n        }\n    },\n    \n    /**\n     * Checks whether a selection should proceed based on the ignoreRightMouseSelection\n     * option.\n     * @private\n     * @param {Ext.EventObject} e The event\n     * @return {Boolean} False if the selection should not proceed\n     */\n    allowRightMouseSelection: function(e) {\n        var disallow = this.ignoreRightMouseSelection && e.button !== 0;\n        if (disallow) {\n            disallow = this.hasSelection();\n        }\n        return !disallow;\n    },\n\n    // Allow the GridView to update the UI by\n    // adding/removing a CSS class from the row.\n    onSelectChange: function(record, isSelected, suppressEvent, commitFn) {\n        var me      = this,\n            views   = me.views,\n            viewsLn = views.length,\n            store   = me.store,\n            rowIdx  = store.indexOf(record),\n            eventName = isSelected ? 'select' : 'deselect',\n            i = 0;\n\n        if ((suppressEvent || me.fireEvent('before' + eventName, me, record, rowIdx)) !== false &&\n                commitFn() !== false) {\n\n            for (; i < viewsLn; i++) {\n                if (isSelected) {\n                    views[i].onRowSelect(rowIdx, suppressEvent);\n                } else {\n                    views[i].onRowDeselect(rowIdx, suppressEvent);\n                }\n            }\n\n            if (!suppressEvent) {\n                me.fireEvent(eventName, me, record, rowIdx);\n            }\n        }\n    },\n\n    // Provide indication of what row was last focused via\n    // the gridview.\n    onLastFocusChanged: function(oldFocused, newFocused, supressFocus) {\n        var views   = this.views,\n            viewsLn = views.length,\n            store   = this.store,\n            rowIdx,\n            i = 0;\n\n        if (oldFocused) {\n            rowIdx = store.indexOf(oldFocused);\n            if (rowIdx != -1) {\n                for (; i < viewsLn; i++) {\n                    views[i].onRowFocus(rowIdx, false);\n                }\n            }\n        }\n\n        if (newFocused) {\n            rowIdx = store.indexOf(newFocused);\n            if (rowIdx != -1) {\n                for (i = 0; i < viewsLn; i++) {\n                    views[i].onRowFocus(rowIdx, true, supressFocus);\n                }\n            }\n        }\n        this.callParent();\n    },\n\n    onEditorTab: function(editingPlugin, e) {\n        var me = this,\n            view = me.views[0],\n            record = editingPlugin.getActiveRecord(),\n            header = editingPlugin.getActiveColumn(),\n            position = view.getPosition(record, header),\n            direction = e.shiftKey ? 'left' : 'right';\n\n        do {\n            position  = view.walkCells(position, direction, e, me.preventWrap);\n        } while(position && !view.headerCt.getHeaderAtIndex(position.column).getEditor());\n\n        if (position) {\n            editingPlugin.startEditByPosition(position);\n        }\n    },\n\n\n    /**\n     * Returns position of the first selected cell in the selection in the format {row: row, column: column}\n     */\n    getCurrentPosition: function() {\n        var firstSelection = this.selected.items[0];\n        if (firstSelection) {\n            return {\n                row: this.store.indexOf(firstSelection),\n                column: 0\n            };\n        }\n    },\n\n    selectByPosition: function(position) {\n        var record = this.store.getAt(position.row);\n        this.select(record);\n    },\n\n\n    /**\n     * Selects the record immediately following the currently selected record.\n     * @param {Boolean} [keepExisting] True to retain existing selections\n     * @param {Boolean} [suppressEvent] Set to false to not fire a select event\n     * @return {Boolean} `true` if there is a next record, else `false`\n     */\n    selectNext: function(keepExisting, suppressEvent) {\n        var me = this,\n            store = me.store,\n            selection = me.getSelection(),\n            record = selection[selection.length - 1],\n            index = store.indexOf(record) + 1,\n            success;\n\n        if(index === store.getCount() || index === 0) {\n            success = false;\n        } else {\n            me.doSelect(index, keepExisting, suppressEvent);\n            success = true;\n        }\n        return success;\n    },\n\n    /**\n     * Selects the record that precedes the currently selected record.\n     * @param {Boolean} [keepExisting] True to retain existing selections\n     * @param {Boolean} [suppressEvent] Set to false to not fire a select event\n     * @return {Boolean} `true` if there is a previous record, else `false`\n     */\n    selectPrevious: function(keepExisting, suppressEvent) {\n        var me = this,\n            selection = me.getSelection(),\n            record = selection[0],\n            index = me.store.indexOf(record) - 1,\n            success;\n\n        if (index < 0) {\n            success = false;\n        } else {\n            me.doSelect(index, keepExisting, suppressEvent);\n            success = true;\n        }\n        return success;\n    }\n});\n\n/**\n * A selection model that renders a column of checkboxes that can be toggled to\n * select or deselect rows. The default mode for this selection model is MULTI.\n *\n * The selection model will inject a header for the checkboxes in the first view\n * and according to the 'injectCheckbox' configuration.\n */\nExt.define('Ext.selection.CheckboxModel', {\n    alias: 'selection.checkboxmodel',\n    extend: 'Ext.selection.RowModel',\n\n    /**\n     * @cfg {String} mode\n     * Modes of selection.\n     * Valid values are SINGLE, SIMPLE, and MULTI.\n     */\n    mode: 'MULTI',\n\n    /**\n     * @cfg {Number/String} [injectCheckbox=0]\n     * The index at which to insert the checkbox column.\n     * Supported values are a numeric index, and the strings 'first' and 'last'.\n     */\n    injectCheckbox: 0,\n\n    /**\n     * @cfg {Boolean} checkOnly\n     * True if rows can only be selected by clicking on the checkbox column.\n     */\n    checkOnly: false,\n    \n    /**\n     * @cfg {Boolean} showHeaderCheckbox\n     * Configure as `false` to not display the header checkbox at the top of the column.\n     */\n    showHeaderCheckbox: true,\n\n    headerWidth: 24,\n\n    // private\n    checkerOnCls: Ext.baseCSSPrefix + 'grid-hd-checker-on',\n\n    // private\n    refreshOnRemove: true,\n\n    beforeViewRender: function(view) {\n        var me = this;\n        me.callParent(arguments);\n\n        // if we have a locked header, only hook up to the first\n        if (!me.hasLockedHeader() || view.headerCt.lockedCt) {\n            if (me.showHeaderCheckbox !== false) {\n                view.headerCt.on('headerclick', me.onHeaderClick, me);\n            }\n            me.addCheckbox(view, true);\n            me.mon(view.ownerCt, 'reconfigure', me.onReconfigure, me);\n        }\n    },\n\n    bindComponent: function(view) {\n        var me = this;\n        me.sortable = false;\n        me.callParent(arguments);\n    },\n\n    hasLockedHeader: function(){\n        var views     = this.views,\n            vLen      = views.length,\n            v;\n\n        for (v = 0; v < vLen; v++) {\n            if (views[v].headerCt.lockedCt) {\n                return true;\n            }\n        }\n        return false;\n    },\n\n    /**\n     * Add the header checkbox to the header row\n     * @private\n     * @param {Boolean} initial True if we're binding for the first time.\n     */\n    addCheckbox: function(view, initial){\n        var me = this,\n            checkbox = me.injectCheckbox,\n            headerCt = view.headerCt;\n\n        // Preserve behaviour of false, but not clear why that would ever be done.\n        if (checkbox !== false) {\n            if (checkbox == 'first') {\n                checkbox = 0;\n            } else if (checkbox == 'last') {\n                checkbox = headerCt.getColumnCount();\n            }\n            Ext.suspendLayouts();\n            headerCt.add(checkbox,  me.getHeaderConfig());\n            Ext.resumeLayouts();\n        }\n\n        if (initial !== true) {\n            view.refresh();\n        }\n    },\n\n    /**\n     * Handles the grid's reconfigure event.  Adds the checkbox header if the columns have been reconfigured.\n     * @private\n     * @param {Ext.panel.Table} grid\n     * @param {Ext.data.Store} store\n     * @param {Object[]} columns\n     */\n    onReconfigure: function(grid, store, columns) {\n        if(columns) {\n            this.addCheckbox(this.views[0]);\n        }\n    },\n\n    /**\n     * Toggle the ui header between checked and unchecked state.\n     * @param {Boolean} isChecked\n     * @private\n     */\n    toggleUiHeader: function(isChecked) {\n        var view     = this.views[0],\n            headerCt = view.headerCt,\n            checkHd  = headerCt.child('gridcolumn[isCheckerHd]');\n\n        if (checkHd) {\n            if (isChecked) {\n                checkHd.el.addCls(this.checkerOnCls);\n            } else {\n                checkHd.el.removeCls(this.checkerOnCls);\n            }\n        }\n    },\n\n    /**\n     * Toggle between selecting all and deselecting all when clicking on\n     * a checkbox header.\n     */\n    onHeaderClick: function(headerCt, header, e) {\n        if (header.isCheckerHd) {\n            e.stopEvent();\n            var me = this,\n                isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');\n                \n            // Prevent focus changes on the view, since we're selecting/deselecting all records\n            me.preventFocus = true;\n            if (isChecked) {\n                me.deselectAll();\n            } else {\n                me.selectAll();\n            }\n            delete me.preventFocus;\n        }\n    },\n\n    /**\n     * Retrieve a configuration to be used in a HeaderContainer.\n     * This should be used when injectCheckbox is set to false.\n     */\n    getHeaderConfig: function() {\n        var me = this,\n            showCheck = me.showHeaderCheckbox !== false;\n\n        return {\n            isCheckerHd: showCheck,\n            text : '&#160;',\n            width: me.headerWidth,\n            sortable: false,\n            draggable: false,\n            resizable: false,\n            hideable: false,\n            menuDisabled: true,\n            dataIndex: '',\n            cls: showCheck ? Ext.baseCSSPrefix + 'column-header-checkbox ' : '',\n            renderer: Ext.Function.bind(me.renderer, me),\n            editRenderer: me.editRenderer || me.renderEmpty,\n            locked: me.hasLockedHeader()\n        };\n    },\n    \n    renderEmpty: function(){\n        return '&#160;';    \n    },\n\n    /**\n     * Generates the HTML to be rendered in the injected checkbox column for each row.\n     * Creates the standard checkbox markup by default; can be overridden to provide custom rendering.\n     * See {@link Ext.grid.column.Column#renderer} for description of allowed parameters.\n     */\n    renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {\n        var baseCSSPrefix = Ext.baseCSSPrefix;\n        metaData.tdCls = baseCSSPrefix + 'grid-cell-special ' + baseCSSPrefix + 'grid-cell-row-checker';\n        return '<div class=\"' + baseCSSPrefix + 'grid-row-checker\">&#160;</div>';\n    },\n\n    // override\n    onRowMouseDown: function(view, record, item, index, e) {\n        view.el.focus();\n        var me = this,\n            checker = e.getTarget('.' + Ext.baseCSSPrefix + 'grid-row-checker'),\n            mode;\n            \n        if (!me.allowRightMouseSelection(e)) {\n            return;\n        }\n\n        // checkOnly set, but we didn't click on a checker.\n        if (me.checkOnly && !checker) {\n            return;\n        }\n\n        if (checker) {\n            mode = me.getSelectionMode();\n            // dont change the mode if its single otherwise\n            // we would get multiple selection\n            if (mode !== 'SINGLE') {\n                me.setSelectionMode('SIMPLE');\n            }\n            me.selectWithEvent(record, e);\n            me.setSelectionMode(mode);\n        } else {\n            me.selectWithEvent(record, e);\n        }\n    },\n\n    /**\n     * Synchronize header checker value as selection changes.\n     * @private\n     */\n    onSelectChange: function() {\n        var me = this;\n        me.callParent(arguments);\n        me.updateHeaderState();\n    },\n\n    /**\n     * @private\n     */\n    onStoreLoad: function() {\n        var me = this;\n        me.callParent(arguments);\n        me.updateHeaderState();\n    },\n\n    /**\n     * @private\n     */\n    updateHeaderState: function() {\n        // check to see if all records are selected\n        var hdSelectStatus = this.selected.getCount() === this.store.getCount();\n        this.toggleUiHeader(hdSelectStatus);\n    }\n});\n\n/**\n * Adds custom behavior for left/right keyboard navigation for use with a tree.\n * Depends on the view having an expand and collapse method which accepts a\n * record.\n * \n * @private\n */\nExt.define('Ext.selection.TreeModel', {\n    extend: 'Ext.selection.RowModel',\n    alias: 'selection.treemodel',\n    \n    // typically selection models prune records from the selection\n    // model when they are removed, because the TreeView constantly\n    // adds/removes records as they are expanded/collapsed\n    pruneRemoved: false,\n    \n    onKeyRight: function(e, t) {\n        var focused = this.getLastFocused(),\n            view    = this.view;\n            \n        if (focused) {\n            // tree node is already expanded, go down instead\n            // this handles both the case where we navigate to firstChild and if\n            // there are no children to the nextSibling\n            if (focused.isExpanded()) {\n                this.onKeyDown(e, t);\n            // if its not a leaf node, expand it\n            } else if (focused.isExpandable()) {\n                view.expand(focused);\n            }\n        }\n    },\n    \n    onKeyLeft: function(e, t) {\n        var focused = this.getLastFocused(),\n            view    = this.view,\n            viewSm  = view.getSelectionModel(),\n            parentNode, parentRecord;\n\n        if (focused) {\n            parentNode = focused.parentNode;\n            // if focused node is already expanded, collapse it\n            if (focused.isExpanded()) {\n                view.collapse(focused);\n            // has a parentNode and its not root\n            // TODO: this needs to cover the case where the root isVisible\n            } else if (parentNode && !parentNode.isRoot()) {\n                // Select a range of records when doing multiple selection.\n                if (e.shiftKey) {\n                    viewSm.selectRange(parentNode, focused, e.ctrlKey, 'up');\n                    viewSm.setLastFocused(parentNode);\n                // just move focus, not selection\n                } else if (e.ctrlKey) {\n                    viewSm.setLastFocused(parentNode);\n                // select it\n                } else {\n                    viewSm.select(parentNode);\n                }\n            }\n        }\n    },\n    \n    onKeySpace: function(e, t) {\n        this.toggleCheck(e);\n    },\n    \n    onKeyEnter: function(e, t) {\n        this.toggleCheck(e);\n    },\n    \n    toggleCheck: function(e){\n        e.stopEvent();\n        var selected = this.getLastSelected();\n        if (selected) {\n            this.view.onCheckChange(selected);\n        }\n    }\n});\n\n/**\n * @class Ext.slider.Thumb\n * @private\n * Represents a single thumb element on a Slider. This would not usually be created manually and would instead\n * be created internally by an {@link Ext.slider.Multi Multi slider}.\n */\nExt.define('Ext.slider.Thumb', {\n    requires: ['Ext.dd.DragTracker', 'Ext.util.Format'],\n    /**\n     * @private\n     * @property {Number} topThumbZIndex\n     * The number used internally to set the z index of the top thumb (see promoteThumb for details)\n     */\n    topZIndex: 10000,\n\n    /**\n     * @cfg {Ext.slider.MultiSlider} slider (required)\n     * The Slider to render to.\n     */\n\n    /**\n     * Creates new slider thumb.\n     * @param {Object} [config] Config object.\n     */\n    constructor: function(config) {\n        var me = this;\n\n        /**\n         * @property {Ext.slider.MultiSlider} slider\n         * The slider this thumb is contained within\n         */\n        Ext.apply(me, config || {}, {\n            cls: Ext.baseCSSPrefix + 'slider-thumb',\n\n            /**\n             * @cfg {Boolean} constrain True to constrain the thumb so that it cannot overlap its siblings\n             */\n            constrain: false\n        });\n        me.callParent([config]);\n    },\n\n    /**\n     * Renders the thumb into a slider\n     */\n    render: function() {\n        var me = this;\n        me.el = me.slider.innerEl.insertFirst(me.getElConfig());\n        me.onRender();\n    },\n    \n    onRender: function() {\n        if (this.disabled) {\n            this.disable();\n        }\n        this.initEvents();\n    },\n\n    getElConfig: function() {\n        var me = this,\n            slider = me.slider,\n            style = {};\n\n        style[slider.vertical ? 'bottom' : 'left'] = slider.calculateThumbPosition(slider.normalizeValue(me.value)) + '%';\n        return {\n            style: style,\n            id  : this.id,\n            cls : this.cls\n        };\n    },\n\n    /**\n     * @private\n     * move the thumb\n     */\n    move: function(v, animate) {\n        var el = this.el,\n            styleProp = this.slider.vertical ? 'bottom' : 'left',\n            to,\n            from;\n\n        v += '%';\n        \n        if (!animate) {\n            el.dom.style[styleProp] = v;\n        } else {\n            to = {};\n            to[styleProp] = v;\n            \n            if (!Ext.supports.GetPositionPercentage) {\n                from = {};\n                from[styleProp] = el.dom.style[styleProp];\n            }\n            \n            new Ext.fx.Anim({\n                target: el,\n                duration: 350,\n                from: from,\n                to: to\n            });\n        }\n    },\n\n    /**\n     * @private\n     * Bring thumb dom element to front.\n     */\n    bringToFront: function() {\n        this.el.setStyle('zIndex', this.topZIndex);\n    },\n\n    /**\n     * @private\n     * Send thumb dom element to back.\n     */\n    sendToBack: function() {\n        this.el.setStyle('zIndex', '');\n    },\n\n    /**\n     * Enables the thumb if it is currently disabled\n     */\n    enable: function() {\n        var me = this;\n\n        me.disabled = false;\n        if (me.el) {\n            me.el.removeCls(me.slider.disabledCls);\n        }\n    },\n\n    /**\n     * Disables the thumb if it is currently enabled\n     */\n    disable: function() {\n        var me = this;\n\n        me.disabled = true;\n        if (me.el) {\n            me.el.addCls(me.slider.disabledCls);\n        }\n    },\n\n    /**\n     * Sets up an Ext.dd.DragTracker for this thumb\n     */\n    initEvents: function() {\n        var me = this,\n            el = me.el;\n\n        me.tracker = new Ext.dd.DragTracker({\n            onBeforeStart: Ext.Function.bind(me.onBeforeDragStart, me),\n            onStart      : Ext.Function.bind(me.onDragStart, me),\n            onDrag       : Ext.Function.bind(me.onDrag, me),\n            onEnd        : Ext.Function.bind(me.onDragEnd, me),\n            tolerance    : 3,\n            autoStart    : 300,\n            overCls      : Ext.baseCSSPrefix + 'slider-thumb-over'\n        });\n\n        me.tracker.initEl(el);\n    },\n\n    /**\n     * @private\n     * This is tied into the internal Ext.dd.DragTracker. If the slider is currently disabled,\n     * this returns false to disable the DragTracker too.\n     * @return {Boolean} False if the slider is currently disabled\n     */\n    onBeforeDragStart : function(e) {\n        if (this.disabled) {\n            return false;\n        } else {\n            this.slider.promoteThumb(this);\n            return true;\n        }\n    },\n\n    /**\n     * @private\n     * This is tied into the internal Ext.dd.DragTracker's onStart template method. Adds the drag CSS class\n     * to the thumb and fires the 'dragstart' event\n     */\n    onDragStart: function(e){\n        var me = this;\n\n        me.el.addCls(Ext.baseCSSPrefix + 'slider-thumb-drag');\n        me.dragging = me.slider.dragging = true;\n        me.dragStartValue = me.value;\n\n        me.slider.fireEvent('dragstart', me.slider, e, me);\n    },\n\n    /**\n     * @private\n     * This is tied into the internal Ext.dd.DragTracker's onDrag template method. This is called every time\n     * the DragTracker detects a drag movement. It updates the Slider's value using the position of the drag\n     */\n    onDrag: function(e) {\n        var me       = this,\n            slider   = me.slider,\n            index    = me.index,\n            newValue = me.getValueFromTracker(),\n            above,\n            below;\n\n        // If dragged out of range, value will be undefined\n        if (newValue !== undefined) {\n            if (me.constrain) {\n                above = slider.thumbs[index + 1];\n                below = slider.thumbs[index - 1];\n\n                if (below !== undefined && newValue <= below.value) {\n                    newValue = below.value;\n                }\n\n                if (above !== undefined && newValue >= above.value) {\n                    newValue = above.value;\n                }\n            }\n            slider.setValue(index, newValue, false);\n            slider.fireEvent('drag', slider, e, me);\n        }\n    },\n\n    getValueFromTracker: function() {\n        var slider = this.slider,\n            trackPoint = slider.getTrackpoint(this.tracker.getXY());\n\n        // If dragged out of range, value will be undefined\n        if (trackPoint !== undefined) {\n            return slider.reversePixelValue(trackPoint);\n        }\n    },\n\n    /**\n     * @private\n     * This is tied to the internal Ext.dd.DragTracker's onEnd template method. Removes the drag CSS class and\n     * fires the 'changecomplete' event with the new value\n     */\n    onDragEnd: function(e) {\n        var me     = this,\n            slider = me.slider,\n            value  = me.value;\n\n        me.el.removeCls(Ext.baseCSSPrefix + 'slider-thumb-drag');\n\n        me.dragging = slider.dragging = false;\n        slider.fireEvent('dragend', slider, e);\n\n        if (me.dragStartValue != value) {\n            slider.fireEvent('changecomplete', slider, value, me);\n        }\n    },\n\n    destroy: function() {\n        Ext.destroy(this.tracker);\n    }\n});\n\n/**\n * Simple plugin for using an Ext.tip.Tip with a slider to show the slider value. In general this class is not created\n * directly, instead pass the {@link Ext.slider.Multi#useTips} and {@link Ext.slider.Multi#tipText} configuration\n * options to the slider directly.\n *\n *     @example\n *     Ext.create('Ext.slider.Single', {\n *         width: 214,\n *         minValue: 0,\n *         maxValue: 100,\n *         useTips: true,\n *         renderTo: Ext.getBody()\n *     });\n *\n * Optionally provide your own tip text by passing tipText:\n *\n *     @example\n *     Ext.create('Ext.slider.Single', {\n *         width: 214,\n *         minValue: 0,\n *         maxValue: 100,\n *         useTips: true,\n *         tipText: function(thumb){\n *             return Ext.String.format('**{0}% complete**', thumb.value);\n *         },\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.slider.Tip', {\n    extend: 'Ext.tip.Tip',\n    minWidth: 10,\n    alias: 'widget.slidertip',\n    \n    /**\n     * @cfg {Array} [offsets=null]\n     * Offsets for aligning the tip to the slider. See {@link Ext.dom.Element#alignTo}. Default values\n     * for offsets are provided by specifying the {@link #position} config.\n     */\n    offsets : null,\n    \n    /**\n     * @cfg {String} [align=null]\n     * Alignment configuration for the tip to the slider. See {@link Ext.dom.Element#alignTo}. Default\n     * values for alignment are provided by specifying the {@link #position} config.\n     */\n    align: null,\n    \n    /**\n     * @cfg {String} [position=For horizontal sliders, \"top\", for vertical sliders, \"left\"] \n     * Sets the position for where the tip will be displayed related to the thumb. This sets\n     * defaults for {@link #align} and {@link #offsets} configurations. If {@link #align} or \n     * {@link #offsets} configurations are specified, they will override the defaults defined\n     * by position.\n     */\n    position: '',\n    \n    defaultVerticalPosition: 'left',\n    \n    defaultHorizontalPosition: 'top',\n\n    isSliderTip: true,\n\n    init: function(slider) {\n        var me = this,\n            align,\n            offsets;\n        \n        if (!me.position) {\n            me.position = slider.vertical ? me.defaultVerticalPosition : me.defaultHorizontalPosition;\n        }\n            \n        switch (me.position) {\n            case 'top':\n                offsets = [0, -10];\n                align = 'b-t?';\n                break;\n            case 'bottom':\n                offsets = [0, 10];\n                align = 't-b?';\n                break;\n            case 'left':\n                offsets = [-10, 0];\n                align = 'r-l?';\n                break;\n            case 'right':\n                offsets = [10, 0];\n                align = 'l-r?';\n        }\n        \n        if (!me.align) {\n            me.align = align;\n        }\n        \n        if (!me.offsets) {\n            me.offsets = offsets;\n        }\n\n        slider.on({\n            scope    : me,\n            dragstart: me.onSlide,\n            drag     : me.onSlide,\n            dragend  : me.hide,\n            destroy  : me.destroy\n        });\n    },\n    /**\n     * @private\n     * Called whenever a dragstart or drag event is received on the associated Thumb.\n     * Aligns the Tip with the Thumb's new position.\n     * @param {Ext.slider.MultiSlider} slider The slider\n     * @param {Ext.EventObject} e The Event object\n     * @param {Ext.slider.Thumb} thumb The thumb that the Tip is attached to\n     */\n    onSlide : function(slider, e, thumb) {\n        var me = this;\n        me.show();\n        me.update(me.getText(thumb));\n        me.el.alignTo(thumb.el, me.align, me.offsets);\n    },\n\n    /**\n     * Used to create the text that appears in the Tip's body. By default this just returns the value of the Slider\n     * Thumb that the Tip is attached to. Override to customize.\n     * @param {Ext.slider.Thumb} thumb The Thumb that the Tip is attached to\n     * @return {String} The text to display in the tip\n     * @protected\n     * @template\n     */\n    getText : function(thumb) {\n        return String(thumb.value);\n    }\n});\n\n/**\n * Slider which supports vertical or horizontal orientation, keyboard adjustments, configurable snapping, axis clicking\n * and animation. Can be added as an item to any container.\n *\n * Sliders can be created with more than one thumb handle by passing an array of values instead of a single one:\n *\n *     @example\n *     Ext.create('Ext.slider.Multi', {\n *         width: 200,\n *         values: [25, 50, 75],\n *         increment: 5,\n *         minValue: 0,\n *         maxValue: 100,\n *\n *         // this defaults to true, setting to false allows the thumbs to pass each other\n *         constrainThumbs: false,\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.slider.Multi', {\n    extend: 'Ext.form.field.Base',\n    alias: 'widget.multislider',\n    alternateClassName: 'Ext.slider.MultiSlider',\n\n    requires: [\n        'Ext.slider.Thumb',\n        'Ext.slider.Tip',\n        'Ext.Number',\n        'Ext.util.Format',\n        'Ext.Template',\n        'Ext.layout.component.field.Slider'\n    ],\n\n    childEls: [\n        'endEl', 'innerEl'\n    ],\n\n    // note: {id} here is really {inputId}, but {cmpId} is available\n    fieldSubTpl: [\n        '<div id=\"{id}\" class=\"' + Ext.baseCSSPrefix + 'slider {fieldCls} {vertical}\" aria-valuemin=\"{minValue}\" aria-valuemax=\"{maxValue}\" aria-valuenow=\"{value}\" aria-valuetext=\"{value}\">',\n            '<div id=\"{cmpId}-endEl\" class=\"' + Ext.baseCSSPrefix + 'slider-end\" role=\"presentation\">',\n                '<div id=\"{cmpId}-innerEl\" class=\"' + Ext.baseCSSPrefix + 'slider-inner\" role=\"presentation\">',\n                    '{%this.renderThumbs(out, values)%}',\n                '</div>',\n            '</div>',\n        '</div>',\n        {\n            renderThumbs: function(out, values) {\n                var me = values.$comp,\n                    i = 0,\n                    thumbs = me.thumbs,\n                    len = thumbs.length,\n                    thumb,\n                    thumbConfig;\n\n                for (; i < len; i++) {\n                    thumb = thumbs[i];\n                    thumbConfig = thumb.getElConfig();\n                    thumbConfig.id = me.id + '-thumb-' + i;\n                    Ext.DomHelper.generateMarkup(thumbConfig, out);\n                }\n            },\n            disableFormats: true\n        }\n    ],\n\n    /**\n     * @cfg {Number} value\n     * A value with which to initialize the slider. Setting this will only result in the creation\n     * of a single slider thumb; if you want multiple thumbs then use the {@link #values} config instead.\n     *\n     * Defaults to #minValue.\n     */\n\n    /**\n     * @cfg {Number[]} values\n     * Array of Number values with which to initalize the slider. A separate slider thumb will be created for each value\n     * in this array. This will take precedence over the single {@link #value} config.\n     */\n\n    /**\n     * @cfg {Boolean} vertical\n     * Orient the Slider vertically rather than horizontally.\n     */\n    vertical: false,\n\n    /**\n     * @cfg {Number} minValue\n     * The minimum value for the Slider.\n     */\n    minValue: 0,\n\n    /**\n     * @cfg {Number} maxValue\n     * The maximum value for the Slider.\n     */\n    maxValue: 100,\n\n    /**\n     * @cfg {Number/Boolean} decimalPrecision The number of decimal places to which to round the Slider's value.\n     *\n     * To disable rounding, configure as **false**.\n     */\n    decimalPrecision: 0,\n\n    /**\n     * @cfg {Number} keyIncrement\n     * How many units to change the Slider when adjusting with keyboard navigation. If the increment\n     * config is larger, it will be used instead.\n     */\n    keyIncrement: 1,\n\n    /**\n     * @cfg {Number} increment\n     * How many units to change the slider when adjusting by drag and drop. Use this option to enable 'snapping'.\n     */\n    increment: 0,\n\n    /**\n     * @cfg {Boolean} [zeroBasedSnapping=false]\n     * Set to `true` to calculate snap points based on {@link #increment}s from zero as opposed to\n     * from this Slider's {@link #minValue}.\n     *\n     * By Default, valid snap points are calculated starting {@link #increment}s from the {@link #minValue}\n     */\n\n    /**\n     * @private\n     * @property {Number[]} clickRange\n     * Determines whether or not a click to the slider component is considered to be a user request to change the value. Specified as an array of [top, bottom],\n     * the click event's 'top' property is compared to these numbers and the click only considered a change request if it falls within them. e.g. if the 'top'\n     * value of the click event is 4 or 16, the click is not considered a change request as it falls outside of the [5, 15] range\n     */\n    clickRange: [5,15],\n\n    /**\n     * @cfg {Boolean} clickToChange\n     * Determines whether or not clicking on the Slider axis will change the slider.\n     */\n    clickToChange : true,\n\n    /**\n     * @cfg {Boolean} animate\n     * Turn on or off animation.\n     */\n    animate: true,\n\n    /**\n     * @property {Boolean} dragging\n     * True while the thumb is in a drag operation\n     */\n    dragging: false,\n\n    /**\n     * @cfg {Boolean} constrainThumbs\n     * True to disallow thumbs from overlapping one another.\n     */\n    constrainThumbs: true,\n\n    componentLayout: 'sliderfield',\n\n    /**\n     * @cfg {Object/Boolean} useTips\n     * True to use an {@link Ext.slider.Tip} to display tips for the value. This option may also\n     * provide a configuration object for an {@link Ext.slider.Tip}.\n     */\n    useTips : true,\n\n    /**\n     * @cfg {Function} [tipText=undefined]\n     * A function used to display custom text for the slider tip.\n     *\n     * Defaults to null, which will use the default on the plugin.\n     *\n     * @cfg {Ext.slider.Thumb} tipText.thumb The Thumb that the Tip is attached to\n     * @cfg {String} tipText.return The text to display in the tip\n     */\n    tipText : null,\n\n    ariaRole: 'slider',\n\n    // private override\n    initValue: function() {\n        var me = this,\n            extValue = Ext.value,\n            // Fallback for initial values: values config -> value config -> minValue config -> 0\n            values = extValue(me.values, [extValue(me.value, extValue(me.minValue, 0))]),\n            i = 0,\n            len = values.length;\n\n        // Store for use in dirty check\n        me.originalValue = values;\n\n        // Add a thumb for each value\n        for (; i < len; i++) {\n            me.addThumb(values[i]);\n        }\n    },\n\n    // private override\n    initComponent : function() {\n        var me = this,\n            tipPlug,\n            hasTip,\n            p, pLen, plugins;\n\n        /**\n         * @property {Array} thumbs\n         * Array containing references to each thumb\n         */\n        me.thumbs = [];\n\n        me.keyIncrement = Math.max(me.increment, me.keyIncrement);\n\n        me.addEvents(\n            /**\n             * @event beforechange\n             * Fires before the slider value is changed. By returning false from an event handler, you can cancel the\n             * event and prevent the slider from changing.\n             * @param {Ext.slider.Multi} slider The slider\n             * @param {Number} newValue The new value which the slider is being changed to.\n             * @param {Number} oldValue The old value which the slider was previously.\n             */\n            'beforechange',\n\n            /**\n             * @event change\n             * Fires when the slider value is changed.\n             * @param {Ext.slider.Multi} slider The slider\n             * @param {Number} newValue The new value which the slider has been changed to.\n             * @param {Ext.slider.Thumb} thumb The thumb that was changed\n             */\n            'change',\n\n            /**\n             * @event changecomplete\n             * Fires when the slider value is changed by the user and any drag operations have completed.\n             * @param {Ext.slider.Multi} slider The slider\n             * @param {Number} newValue The new value which the slider has been changed to.\n             * @param {Ext.slider.Thumb} thumb The thumb that was changed\n             */\n            'changecomplete',\n\n            /**\n             * @event dragstart\n             * Fires after a drag operation has started.\n             * @param {Ext.slider.Multi} slider The slider\n             * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\n             */\n            'dragstart',\n\n            /**\n             * @event drag\n             * Fires continuously during the drag operation while the mouse is moving.\n             * @param {Ext.slider.Multi} slider The slider\n             * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\n             */\n            'drag',\n\n            /**\n             * @event dragend\n             * Fires after the drag operation has completed.\n             * @param {Ext.slider.Multi} slider The slider\n             * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\n             */\n            'dragend'\n        );\n\n        // Ensure that the maxValue is a snap point, and that the initial value is snapped.\n        if (me.increment) {\n            me.maxValue = Ext.Number.snapInRange(me.maxValue, me.increment, me.minValue);\n            me.value = me.normalizeValue(me.value);\n        }\n\n        me.callParent();\n\n        // only can use it if it exists.\n        if (me.useTips) {\n            if (Ext.isObject(me.useTips)) {\n                tipPlug = Ext.apply({}, me.useTips);\n            } else {\n                tipPlug = me.tipText ? {getText: me.tipText} : {};    \n            }\n\n            plugins = me.plugins = me.plugins || [];\n            pLen    = plugins.length;\n            \n            for (p = 0; p < pLen; p++) {\n                if (plugins[p].isSliderTip) {\n                    hasTip = true;\n                    break;\n                }\n            }\n\n            if (!hasTip) {\n                me.plugins.push(new Ext.slider.Tip(tipPlug));\n            }\n        }\n    },\n\n    /**\n     * Creates a new thumb and adds it to the slider\n     * @param {Number} [value=0] The initial value to set on the thumb.\n     * @return {Ext.slider.Thumb} The thumb\n     */\n    addThumb: function(value) {\n        var me = this,\n            thumb = new Ext.slider.Thumb({\n                ownerCt     : me,\n                ownerLayout : me.getComponentLayout(),\n                value       : value,\n                slider      : me,\n                index       : me.thumbs.length,\n                constrain   : me.constrainThumbs,\n                disabled    : !!me.readOnly\n            });\n\n        me.thumbs.push(thumb);\n\n        //render the thumb now if needed\n        if (me.rendered) {\n            thumb.render();\n        }\n\n        return thumb;\n    },\n\n    /**\n     * @private\n     * Moves the given thumb above all other by increasing its z-index. This is called when as drag\n     * any thumb, so that the thumb that was just dragged is always at the highest z-index. This is\n     * required when the thumbs are stacked on top of each other at one of the ends of the slider's\n     * range, which can result in the user not being able to move any of them.\n     * @param {Ext.slider.Thumb} topThumb The thumb to move to the top\n     */\n    promoteThumb: function(topThumb) {\n        var thumbs = this.thumbs,\n            ln = thumbs.length,\n            zIndex, thumb, i;\n\n        for (i = 0; i < ln; i++) {\n            thumb = thumbs[i];\n\n            if (thumb == topThumb) {\n                thumb.bringToFront();\n            } else {\n                thumb.sendToBack();\n            }\n        }\n    },\n\n    // private override\n    getSubTplData : function() {\n        var me = this;\n\n        return Ext.apply(me.callParent(), {\n            $comp: me,\n            vertical: me.vertical ? Ext.baseCSSPrefix + 'slider-vert' : Ext.baseCSSPrefix + 'slider-horz',\n            minValue: me.minValue,\n            maxValue: me.maxValue,\n            value: me.value\n        });\n    },\n\n    onRender : function() {\n        var me = this,\n            thumbs = me.thumbs,\n            len = thumbs.length,\n            i = 0,\n            thumb;\n\n        me.callParent(arguments);\n\n        for (i = 0; i < len; i++) {\n            thumb = thumbs[i];\n            thumb.el = me.el.getById(me.id + '-thumb-' + i);\n            thumb.onRender();\n        }\n    },\n\n    /**\n     * @private\n     * Adds keyboard and mouse listeners on this.el. Ignores click events on the internal focus element.\n     */\n    initEvents : function() {\n        var me = this;\n        me.mon(me.el, {\n            scope    : me,\n            mousedown: me.onMouseDown,\n            keydown  : me.onKeyDown\n        });\n    },\n\n    /**\n     * @private\n     * Given an `[x, y]` position within the slider's track (Points outside the slider's track are coerced to either the minimum or maximum value),\n     * calculate how many pixels **from the slider origin** (left for horizontal Sliders and bottom for vertical Sliders) that point is.\n     *\n     * If the point is outside the range of the Slider's track, the return value is `undefined`\n     * @param {Number[]} xy The point to calculate the track point for\n     */\n    getTrackpoint : function(xy) {\n        var me = this,\n            result,\n            positionProperty,\n            sliderTrack = me.innerEl,\n            trackLength;\n\n        if (me.vertical) {\n            positionProperty = 'top';\n            trackLength = sliderTrack.getHeight();\n        } else {\n            positionProperty = 'left';\n            trackLength = sliderTrack.getWidth();\n        }\n        result = Ext.Number.constrain(sliderTrack.translatePoints(xy)[positionProperty], 0, trackLength);\n        return me.vertical ? trackLength - result : result;\n    },\n\n    /**\n     * @private\n     * Mousedown handler for the slider. If the clickToChange is enabled and the click was not on the draggable 'thumb',\n     * this calculates the new value of the slider and tells the implementation (Horizontal or Vertical) to move the thumb\n     * @param {Ext.EventObject} e The click event\n     */\n    onMouseDown : function(e) {\n        var me = this,\n            thumbClicked = false,\n            i = 0,\n            thumbs = me.thumbs,\n            len = thumbs.length,\n            trackPoint;\n\n        if (me.disabled) {\n            return;\n        }\n\n        //see if the click was on any of the thumbs\n        for (; i < len; i++) {\n            thumbClicked = thumbClicked || e.target == thumbs[i].el.dom;\n        }\n\n        if (me.clickToChange && !thumbClicked) {\n            trackPoint = me.getTrackpoint(e.getXY());\n            if (trackPoint !== undefined) {\n                me.onClickChange(trackPoint);\n            }\n        }\n        me.focus();\n    },\n\n    /**\n     * @private\n     * Moves the thumb to the indicated position.\n     * Only changes the value if the click was within this.clickRange.\n     * @param {Number} trackPoint local pixel offset **from the origin** (left for horizontal and bottom for vertical) along the Slider's axis at which the click event occured.\n     */\n    onClickChange : function(trackPoint) {\n        var me = this,\n            thumb, index;\n\n        // How far along the track *from the origin* was the click.\n        // If vertical, the origin is the bottom of the slider track.\n\n        //find the nearest thumb to the click event\n        thumb = me.getNearest(trackPoint);\n        if (!thumb.disabled) {\n            index = thumb.index;\n            me.setValue(index, Ext.util.Format.round(me.reversePixelValue(trackPoint), me.decimalPrecision), undefined, true);\n        }\n    },\n\n    /**\n     * @private\n     * Returns the nearest thumb to a click event, along with its distance\n     * @param {Number} trackPoint local pixel position along the Slider's axis to find the Thumb for\n     * @return {Object} The closest thumb object and its distance from the click event\n     */\n    getNearest: function(trackPoint) {\n        var me = this,\n            clickValue = me.reversePixelValue(trackPoint),\n            nearestDistance = (me.maxValue - me.minValue) + 5, //add a small fudge for the end of the slider\n            nearest = null,\n            thumbs = me.thumbs,\n            i = 0,\n            len = thumbs.length,\n            thumb,\n            value,\n            dist;\n\n        for (; i < len; i++) {\n            thumb = me.thumbs[i];\n            value = thumb.value;\n            dist  = Math.abs(value - clickValue);\n\n            if (Math.abs(dist <= nearestDistance)) {\n                nearest = thumb;\n                nearestDistance = dist;\n            }\n        }\n        return nearest;\n    },\n\n    /**\n     * @private\n     * Handler for any keypresses captured by the slider. If the key is UP or RIGHT, the thumb is moved along to the right\n     * by this.keyIncrement. If DOWN or LEFT it is moved left. Pressing CTRL moves the slider to the end in either direction\n     * @param {Ext.EventObject} e The Event object\n     */\n    onKeyDown : function(e) {\n        /*\n         * The behaviour for keyboard handling with multiple thumbs is currently undefined.\n         * There's no real sane default for it, so leave it like this until we come up\n         * with a better way of doing it.\n         */\n        var me = this,\n            k,\n            val;\n\n        if(me.disabled || me.thumbs.length !== 1) {\n            e.preventDefault();\n            return;\n        }\n        k = e.getKey();\n\n        switch(k) {\n            case e.UP:\n            case e.RIGHT:\n                e.stopEvent();\n                val = e.ctrlKey ? me.maxValue : me.getValue(0) + me.keyIncrement;\n                me.setValue(0, val, undefined, true);\n            break;\n            case e.DOWN:\n            case e.LEFT:\n                e.stopEvent();\n                val = e.ctrlKey ? me.minValue : me.getValue(0) - me.keyIncrement;\n                me.setValue(0, val, undefined, true);\n            break;\n            default:\n                e.preventDefault();\n        }\n    },\n\n    /**\n     * @private\n     * Returns a snapped, constrained value when given a desired value\n     * @param {Number} value Raw number value\n     * @return {Number} The raw value rounded to the correct d.p. and constrained within the set max and min values\n     */\n    normalizeValue : function(v) {\n        var me = this,\n            Num = Ext.Number,\n            snapFn = Num[me.zeroBasedSnapping ? 'snap' : 'snapInRange'];\n\n        v = snapFn.call(Num, v, me.increment, me.minValue, me.maxValue);\n        v = Ext.util.Format.round(v, me.decimalPrecision);\n        v = Ext.Number.constrain(v, me.minValue, me.maxValue);\n        return v;\n    },\n\n    /**\n     * Sets the minimum value for the slider instance. If the current value is less than the minimum value, the current\n     * value will be changed.\n     * @param {Number} val The new minimum value\n     */\n    setMinValue : function(val) {\n        var me = this,\n            i = 0,\n            thumbs = me.thumbs,\n            len = thumbs.length,\n            t;\n\n        me.minValue = val;\n        if (me.rendered) {\n            me.inputEl.dom.setAttribute('aria-valuemin', val);\n        }\n\n        for (; i < len; ++i) {\n            t = thumbs[i];\n            t.value = t.value < val ? val : t.value;\n        }\n        me.syncThumbs();\n    },\n\n    /**\n     * Sets the maximum value for the slider instance. If the current value is more than the maximum value, the current\n     * value will be changed.\n     * @param {Number} val The new maximum value\n     */\n    setMaxValue : function(val) {\n        var me = this,\n            i = 0,\n            thumbs = me.thumbs,\n            len = thumbs.length,\n            t;\n\n        me.maxValue = val;\n        if (me.rendered) {\n            me.inputEl.dom.setAttribute('aria-valuemax', val);\n        }\n\n        for (; i < len; ++i) {\n            t = thumbs[i];\n            t.value = t.value > val ? val : t.value;\n        }\n        me.syncThumbs();\n    },\n\n    /**\n     * Programmatically sets the value of the Slider. Ensures that the value is constrained within the minValue and\n     * maxValue.\n     * @param {Number} index Index of the thumb to move\n     * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)\n     * @param {Boolean} [animate=true] Turn on or off animation\n     */\n    setValue : function(index, value, animate, changeComplete) {\n        var me = this,\n            thumb = me.thumbs[index];\n\n        // ensures value is contstrained and snapped\n        value = me.normalizeValue(value);\n\n        if (value !== thumb.value && me.fireEvent('beforechange', me, value, thumb.value, thumb) !== false) {\n            thumb.value = value;\n            if (me.rendered) {\n                // TODO this only handles a single value; need a solution for exposing multiple values to aria.\n                // Perhaps this should go on each thumb element rather than the outer element.\n                me.inputEl.set({\n                    'aria-valuenow': value,\n                    'aria-valuetext': value\n                });\n\n                thumb.move(me.calculateThumbPosition(value), Ext.isDefined(animate) ? animate !== false : me.animate);\n\n                me.fireEvent('change', me, value, thumb);\n                me.checkDirty();\n                if (changeComplete) {\n                    me.fireEvent('changecomplete', me, value, thumb);\n                }\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Given a value within this Slider's range, calculates a Thumb's percentage CSS position to map that value.\n     */\n    calculateThumbPosition : function(v) {\n        return (v - this.minValue) / (this.maxValue - this.minValue) * 100;\n    },\n\n    /**\n     * @private\n     * Returns the ratio of pixels to mapped values. e.g. if the slider is 200px wide and maxValue - minValue is 100,\n     * the ratio is 2\n     * @return {Number} The ratio of pixels to mapped values\n     */\n    getRatio : function() {\n        var me = this,\n            trackLength = this.vertical ? this.innerEl.getHeight() : this.innerEl.getWidth(),\n            valueRange = this.maxValue - this.minValue;\n        return valueRange === 0 ? trackLength : (trackLength / valueRange);\n    },\n\n    /**\n     * @private\n     * Given a pixel location along the slider, returns the mapped slider value for that pixel.\n     * E.g. if we have a slider 200px wide with minValue = 100 and maxValue = 500, reversePixelValue(50)\n     * returns 200\n     * @param {Number} pos The position along the slider to return a mapped value for\n     * @return {Number} The mapped value for the given position\n     */\n    reversePixelValue : function(pos) {\n        return this.minValue + (pos / this.getRatio());\n    },\n\n    /**\n     * @private\n     * Given a Thumb's percentage position along the slider, returns the mapped slider value for that pixel.\n     * E.g. if we have a slider 200px wide with minValue = 100 and maxValue = 500, reversePercentageValue(25)\n     * returns 200\n     * @param {Number} pos The percentage along the slider track to return a mapped value for\n     * @return {Number} The mapped value for the given position\n     */\n    reversePercentageValue : function(pos) {\n        return this.minValue + (this.maxValue - this.minValue) * (pos / 100);\n    },\n\n    //private\n    onDisable: function() {\n        var me = this,\n            i = 0,\n            thumbs = me.thumbs,\n            len = thumbs.length,\n            thumb,\n            el,\n            xy;\n\n        me.callParent();\n\n        for (; i < len; i++) {\n            thumb = thumbs[i];\n            el = thumb.el;\n\n            thumb.disable();\n\n            if(Ext.isIE) {\n                //IE breaks when using overflow visible and opacity other than 1.\n                //Create a place holder for the thumb and display it.\n                xy = el.getXY();\n                el.hide();\n\n                me.innerEl.addCls(me.disabledCls).dom.disabled = true;\n\n                if (!me.thumbHolder) {\n                    me.thumbHolder = me.endEl.createChild({cls: Ext.baseCSSPrefix + 'slider-thumb ' + me.disabledCls});\n                }\n\n                me.thumbHolder.show().setXY(xy);\n            }\n        }\n    },\n\n    //private\n    onEnable: function() {\n        var me = this,\n            i = 0,\n            thumbs = me.thumbs,\n            len = thumbs.length,\n            thumb,\n            el;\n\n        this.callParent();\n\n        for (; i < len; i++) {\n            thumb = thumbs[i];\n            el = thumb.el;\n\n            thumb.enable();\n\n            if (Ext.isIE) {\n                me.innerEl.removeCls(me.disabledCls).dom.disabled = false;\n\n                if (me.thumbHolder) {\n                    me.thumbHolder.hide();\n                }\n\n                el.show();\n                me.syncThumbs();\n            }\n        }\n    },\n\n    /**\n     * Synchronizes thumbs position to the proper proportion of the total component width based on the current slider\n     * {@link #value}. This will be called automatically when the Slider is resized by a layout, but if it is rendered\n     * auto width, this method can be called from another resize handler to sync the Slider if necessary.\n     */\n    syncThumbs : function() {\n        if (this.rendered) {\n            var thumbs = this.thumbs,\n                length = thumbs.length,\n                i = 0;\n\n            for (; i < length; i++) {\n                thumbs[i].move(this.calculateThumbPosition(thumbs[i].value));\n            }\n        }\n    },\n\n    /**\n     * Returns the current value of the slider\n     * @param {Number} index The index of the thumb to return a value for\n     * @return {Number/Number[]} The current value of the slider at the given index, or an array of all thumb values if\n     * no index is given.\n     */\n    getValue : function(index) {\n        return Ext.isNumber(index) ? this.thumbs[index].value : this.getValues();\n    },\n\n    /**\n     * Returns an array of values - one for the location of each thumb\n     * @return {Number[]} The set of thumb values\n     */\n    getValues: function() {\n        var values = [],\n            i = 0,\n            thumbs = this.thumbs,\n            len = thumbs.length;\n\n        for (; i < len; i++) {\n            values.push(thumbs[i].value);\n        }\n\n        return values;\n    },\n\n    getSubmitValue: function() {\n        var me = this;\n        return (me.disabled || !me.submitValue) ? null : me.getValue();\n    },\n\n    reset: function() {\n        var me = this,\n            arr = [].concat(me.originalValue),\n            a     = 0,\n            aLen  = arr.length,\n            val;\n\n        for (; a < aLen; a++) {\n            val = arr[a];\n\n            me.setValue(a, val);\n        }\n\n        me.clearInvalid();\n        // delete here so we reset back to the original state\n        delete me.wasValid;\n    },\n    \n    setReadOnly: function(readOnly){\n        var me = this,\n            thumbs = me.thumbs,\n            len = thumbs.length,\n            i = 0;\n            \n        me.callParent(arguments); \n        readOnly = me.readOnly;\n        \n        for (; i < len; ++i) {\n            if (readOnly) {\n                thumbs[i].disable();\n            } else {\n                thumbs[i].enable();\n            }\n            \n        }\n           \n    },\n\n    // private\n    beforeDestroy : function() {\n        var me     = this,\n            thumbs = me.thumbs,\n            t      = 0,\n            tLen   = thumbs.length,\n            thumb;\n\n        Ext.destroy(me.innerEl, me.endEl, me.focusEl);\n\n        for (; t < tLen; t++) {\n            thumb = thumbs[t];\n\n            Ext.destroy(thumb);\n        }\n\n        me.callParent();\n    }\n});\n\n/**\n * Slider which supports vertical or horizontal orientation, keyboard adjustments, configurable snapping, axis clicking\n * and animation. Can be added as an item to any container.\n *\n *     @example\n *     Ext.create('Ext.slider.Single', {\n *         width: 200,\n *         value: 50,\n *         increment: 10,\n *         minValue: 0,\n *         maxValue: 100,\n *         renderTo: Ext.getBody()\n *     });\n *\n * The class Ext.slider.Single is aliased to Ext.Slider for backwards compatibility.\n */\nExt.define('Ext.slider.Single', {\n    extend: 'Ext.slider.Multi',\n    alias: ['widget.slider', 'widget.sliderfield'],\n    alternateClassName: ['Ext.Slider', 'Ext.form.SliderField', 'Ext.slider.SingleSlider', 'Ext.slider.Slider'],\n\n    /**\n     * Returns the current value of the slider\n     * @return {Number} The current value of the slider\n     */\n    getValue: function() {\n        // just returns the value of the first thumb, which should be the only one in a single slider\n        return this.callParent([0]);\n    },\n\n    /**\n     * Programmatically sets the value of the Slider. Ensures that the value is constrained within the minValue and\n     * maxValue.\n     * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)\n     * @param {Boolean} [animate] Turn on or off animation\n     */\n    setValue: function(value, animate) {\n        var args = arguments,\n            len  = args.length;\n\n        // this is to maintain backwards compatiblity for sliders with only one thunb. Usually you must pass the thumb\n        // index to setValue, but if we only have one thumb we inject the index here first if given the multi-slider\n        // signature without the required index. The index will always be 0 for a single slider\n        if (len == 1 || (len <= 3 && typeof args[1] != 'number')) {\n            args = Ext.toArray(args);\n            args.unshift(0);\n        }\n        return this.callParent(args);\n    },\n\n    // private\n    getNearest : function(){\n        // Since there's only 1 thumb, it's always the nearest\n        return this.thumbs[0];\n    }\n});\n\n/**\n * A Provider implementation which saves and retrieves state via cookies. The CookieProvider supports the usual cookie\n * options, such as:\n *\n * - {@link #path}\n * - {@link #expires}\n * - {@link #domain}\n * - {@link #secure}\n *\n * Example:\n *\n *     var cp = Ext.create('Ext.state.CookieProvider', {\n *         path: \"/cgi-bin/\",\n *         expires: new Date(new Date().getTime()+(1000*60*60*24*30)), //30 days\n *         domain: \"sencha.com\"\n *     });\n *\n *     Ext.state.Manager.setProvider(cp);\n *\n */\nExt.define('Ext.state.CookieProvider', {\n    extend: 'Ext.state.Provider',\n\n    /**\n     * @cfg {String} path\n     * The path for which the cookie is active. Defaults to root '/' which makes it active for all pages in the site.\n     */\n\n    /**\n     * @cfg {Date} expires\n     * The cookie expiration date. Defaults to 7 days from now.\n     */\n\n    /**\n     * @cfg {String} domain\n     * The domain to save the cookie for. Note that you cannot specify a different domain than your page is on, but you can\n     * specify a sub-domain, or simply the domain itself like 'sencha.com' to include all sub-domains if you need to access\n     * cookies across different sub-domains. Defaults to null which uses the same domain the page is running on including\n     * the 'www' like 'www.sencha.com'.\n     */\n\n    /**\n     * @cfg {Boolean} [secure=false]\n     * True if the site is using SSL\n     */\n\n    /**\n     * Creates a new CookieProvider.\n     * @param {Object} [config] Config object.\n     */\n    constructor : function(config){\n        var me = this;\n        me.path = \"/\";\n        me.expires = new Date(new Date().getTime()+(1000*60*60*24*7)); //7 days\n        me.domain = null;\n        me.secure = false;\n        me.callParent(arguments);\n        me.state = me.readCookies();\n    },\n\n    // private\n    set : function(name, value){\n        var me = this;\n\n        if(typeof value == \"undefined\" || value === null){\n            me.clear(name);\n            return;\n        }\n        me.setCookie(name, value);\n        me.callParent(arguments);\n    },\n\n    // private\n    clear : function(name){\n        this.clearCookie(name);\n        this.callParent(arguments);\n    },\n\n    // private\n    readCookies : function(){\n        var cookies = {},\n            c = document.cookie + \";\",\n            re = /\\s?(.*?)=(.*?);/g,\n            prefix = this.prefix,\n            len = prefix.length,\n            matches,\n            name,\n            value;\n\n        while((matches = re.exec(c)) != null){\n            name = matches[1];\n            value = matches[2];\n            if (name && name.substring(0, len) == prefix){\n                cookies[name.substr(len)] = this.decodeValue(value);\n            }\n        }\n        return cookies;\n    },\n\n    // private\n    setCookie : function(name, value){\n        var me = this;\n\n        document.cookie = me.prefix + name + \"=\" + me.encodeValue(value) +\n           ((me.expires == null) ? \"\" : (\"; expires=\" + me.expires.toGMTString())) +\n           ((me.path == null) ? \"\" : (\"; path=\" + me.path)) +\n           ((me.domain == null) ? \"\" : (\"; domain=\" + me.domain)) +\n           ((me.secure == true) ? \"; secure\" : \"\");\n    },\n\n    // private\n    clearCookie : function(name){\n        var me = this;\n\n        document.cookie = me.prefix + name + \"=null; expires=Thu, 01-Jan-70 00:00:01 GMT\" +\n           ((me.path == null) ? \"\" : (\"; path=\" + me.path)) +\n           ((me.domain == null) ? \"\" : (\"; domain=\" + me.domain)) +\n           ((me.secure == true) ? \"; secure\" : \"\");\n    }\n});\n\n/**\n * @class Ext.state.LocalStorageProvider\n * A Provider implementation which saves and retrieves state via the HTML5 localStorage object.\n * If the browser does not support local storage, an exception will be thrown upon instantiating\n * this class.\n */\n\nExt.define('Ext.state.LocalStorageProvider', {\n    /* Begin Definitions */\n    \n    extend: 'Ext.state.Provider',\n    \n    alias: 'state.localstorage',\n    \n    /* End Definitions */\n   \n    constructor: function(){\n        var me = this;\n        me.callParent(arguments);\n        me.store = me.getStorageObject();\n        me.state = me.readLocalStorage();\n    },\n    \n    readLocalStorage: function(){\n        var store = this.store,\n            i = 0,\n            len = store.length,\n            prefix = this.prefix,\n            prefixLen = prefix.length,\n            data = {},\n            key;\n            \n        for (; i < len; ++i) {\n            key = store.key(i);\n            if (key.substring(0, prefixLen) == prefix) {\n                data[key.substr(prefixLen)] = this.decodeValue(store.getItem(key));\n            }            \n        }\n        return data;\n    },\n    \n    set : function(name, value){\n        var me = this;\n        \n        me.clear(name);\n        if (typeof value == \"undefined\" || value === null) {\n            return;\n        }\n        me.store.setItem(me.prefix + name, me.encodeValue(value));\n        me.callParent(arguments);\n    },\n\n    // private\n    clear : function(name){\n        this.store.removeItem(this.prefix + name);\n        this.callParent(arguments);\n    },\n    \n    getStorageObject: function(){\n        try {\n            var supports = 'localStorage' in window && window['localStorage'] !== null;\n            if (supports) {\n                return window.localStorage;\n            }\n        } catch (e) {\n            return false;\n        }\n        Ext.Error.raise('LocalStorage is not supported by the current browser');\n    }    \n});\n\n/**\n * @author Ed Spencer\n * \n * Represents a single Tab in a {@link Ext.tab.Panel TabPanel}. A Tab is simply a slightly customized {@link Ext.button.Button Button}, \n * styled to look like a tab. Tabs are optionally closable, and can also be disabled. 99% of the time you will not\n * need to create Tabs manually as the framework does so automatically when you use a {@link Ext.tab.Panel TabPanel}\n */\nExt.define('Ext.tab.Tab', {\n    extend: 'Ext.button.Button',\n    alias: 'widget.tab',\n\n    requires: [\n        'Ext.layout.component.Tab',\n        'Ext.util.KeyNav'\n    ],\n\n    componentLayout: 'tab',\n\n    /**\n     * @property {Boolean} isTab\n     * `true` in this class to identify an object as an instantiated Tab, or subclass thereof.\n     */\n    isTab: true,\n\n    baseCls: Ext.baseCSSPrefix + 'tab',\n\n    /**\n     * @cfg {String} activeCls\n     * The CSS class to be applied to a Tab when it is active.\n     * Providing your own CSS for this class enables you to customize the active state.\n     */\n    activeCls: 'active',\n\n    /**\n     * @cfg {String} [disabledCls='x-tab-disabled']\n     * The CSS class to be applied to a Tab when it is disabled.\n     */\n\n    /**\n     * @cfg {String} closableCls\n     * The CSS class which is added to the tab when it is closable\n     */\n    closableCls: 'closable',\n\n    /**\n     * @cfg {Boolean} closable\n     * True to make the Tab start closable (the close icon will be visible).\n     */\n    closable: true,\n\n    //<locale>\n    /**\n     * @cfg {String} closeText\n     * The accessible text label for the close button link; only used when {@link #cfg-closable} = true.\n     */\n    closeText: 'Close Tab',\n    //</locale>\n\n    /**\n     * @property {Boolean} active\n     * Indicates that this tab is currently active. This is NOT a public configuration.\n     * @readonly\n     */\n    active: false,\n\n    /**\n     * @property {Boolean} closable\n     * True if the tab is currently closable\n     */\n\n    childEls: [\n        'closeEl'\n    ],\n\n    scale: false,\n\n    position: 'top',\n\n    initComponent: function() {\n        var me = this;\n\n        me.addEvents(\n            /**\n             * @event activate\n             * Fired when the tab is activated.\n             * @param {Ext.tab.Tab} this\n             */\n            'activate',\n\n            /**\n             * @event deactivate\n             * Fired when the tab is deactivated.\n             * @param {Ext.tab.Tab} this\n             */\n            'deactivate',\n\n            /**\n             * @event beforeclose\n             * Fires if the user clicks on the Tab's close button, but before the {@link #close} event is fired. Return\n             * false from any listener to stop the close event being fired\n             * @param {Ext.tab.Tab} tab The Tab object\n             */\n            'beforeclose',\n\n            /**\n             * @event close\n             * Fires to indicate that the tab is to be closed, usually because the user has clicked the close button.\n             * @param {Ext.tab.Tab} tab The Tab object\n             */\n            'close'\n        );\n\n        me.callParent(arguments);\n\n        if (me.card) {\n            me.setCard(me.card);\n        }\n    },\n\n    getTemplateArgs: function() {\n        var me = this,\n            result = me.callParent();\n\n        result.closable = me.closable;\n        result.closeText = me.closeText;\n\n        return result;\n    },\n\n    beforeRender: function() {\n        var me = this,\n            tabBar = me.up('tabbar'),\n            tabPanel = me.up('tabpanel');\n        \n        me.callParent();\n        \n        me.addClsWithUI(me.position);\n\n        // Set all the state classNames, as they need to include the UI\n        // me.disabledCls = me.getClsWithUIs('disabled');\n\n        me.syncClosableUI();\n\n        // Propagate minTabWidth and maxTabWidth settings from the owning TabBar then TabPanel\n        if (!me.minWidth) {\n            me.minWidth = (tabBar) ? tabBar.minTabWidth : me.minWidth;\n            if (!me.minWidth && tabPanel) {\n                me.minWidth = tabPanel.minTabWidth;\n            }\n            if (me.minWidth && me.iconCls) {\n                me.minWidth += 25;\n            }\n        }\n        if (!me.maxWidth) {\n            me.maxWidth = (tabBar) ? tabBar.maxTabWidth : me.maxWidth;\n            if (!me.maxWidth && tabPanel) {\n                me.maxWidth = tabPanel.maxTabWidth;\n            }\n        }\n    },\n\n    onRender: function() {\n        var me = this;\n\n        me.callParent(arguments);\n\n        me.keyNav = new Ext.util.KeyNav(me.el, {\n            enter: me.onEnterKey,\n            del: me.onDeleteKey,\n            scope: me\n        });\n    },\n\n    // inherit docs\n    enable : function(silent) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        me.removeClsWithUI(me.position + '-disabled');\n\n        return me;\n    },\n\n    // inherit docs\n    disable : function(silent) {\n        var me = this;\n\n        me.callParent(arguments);\n\n        me.addClsWithUI(me.position + '-disabled');\n\n        return me;\n    },\n\n    onDestroy: function() {\n        var me = this;\n\n        Ext.destroy(me.keyNav);\n        delete me.keyNav;\n\n        me.callParent(arguments);\n    },\n\n    /**\n     * Sets the tab as either closable or not.\n     * @param {Boolean} closable Pass false to make the tab not closable. Otherwise the tab will be made closable (eg a\n     * close button will appear on the tab)\n     */\n    setClosable: function(closable) {\n        var me = this;\n\n        // Closable must be true if no args\n        closable = (!arguments.length || !!closable);\n\n        if (me.closable != closable) {\n            me.closable = closable;\n\n            // set property on the user-facing item ('card'):\n            if (me.card) {\n                me.card.closable = closable;\n            }\n\n            me.syncClosableUI();\n\n            if (me.rendered) {\n                me.syncClosableElements();\n\n                // Tab will change width to accommodate close icon\n                me.updateLayout();\n            }\n        }\n    },\n\n    /**\n     * This method ensures that the closeBtn element exists or not based on 'closable'.\n     * @private\n     */\n    syncClosableElements: function () {\n        var me = this,\n            closeEl = me.closeEl;\n\n        if (me.closable) {\n            if (!closeEl) {\n                me.closeEl = me.btnWrap.insertSibling({\n                    tag: 'a',\n                    cls: me.baseCls + '-close-btn',\n                    href: '#',\n                    title: me.closeText\n                }, 'after');\n            }\n        } else if (closeEl) {\n            closeEl.remove();\n            delete me.closeEl;\n        }\n    },\n\n    /**\n     * This method ensures that the UI classes are added or removed based on 'closable'.\n     * @private\n     */\n    syncClosableUI: function () {\n        var me = this,\n            classes = [me.closableCls, me.closableCls + '-' + me.position];\n\n        if (me.closable) {\n            me.addClsWithUI(classes);\n        } else {\n            me.removeClsWithUI(classes);\n        }\n    },\n\n    /**\n     * Sets this tab's attached card. Usually this is handled automatically by the {@link Ext.tab.Panel} that this Tab\n     * belongs to and would not need to be done by the developer\n     * @param {Ext.Component} card The card to set\n     */\n    setCard: function(card) {\n        var me = this;\n\n        me.card = card;\n        me.setText(me.title || card.title);\n        me.setIconCls(me.iconCls || card.iconCls);\n        me.setIcon(me.icon || card.icon);\n    },\n\n    /**\n     * @private\n     * Listener attached to click events on the Tab's close button\n     */\n    onCloseClick: function() {\n        var me = this;\n\n        if (me.fireEvent('beforeclose', me) !== false) {\n            if (me.tabBar) {\n                if (me.tabBar.closeTab(me) === false) {\n                    // beforeclose on the panel vetoed the event, stop here\n                    return;\n                }\n            } else {\n                // if there's no tabbar, fire the close event\n                me.fireClose();\n            }\n        }\n    },\n\n    /**\n     * Fires the close event on the tab.\n     * @private\n     */\n    fireClose: function(){\n        this.fireEvent('close', this);\n    },\n\n    /**\n     * @private\n     */\n    onEnterKey: function(e) {\n        var me = this;\n\n        if (me.tabBar) {\n            me.tabBar.onClick(e, me.el);\n        }\n    },\n\n   /**\n     * @private\n     */\n    onDeleteKey: function(e) {\n        if (this.closable) {\n            this.onCloseClick();\n        }\n    },\n\n    // @private\n    activate : function(supressEvent) {\n        var me = this;\n\n        me.active = true;\n        me.addClsWithUI([me.activeCls, me.position + '-' + me.activeCls]);\n\n        if (supressEvent !== true) {\n            me.fireEvent('activate', me);\n        }\n    },\n\n    // @private\n    deactivate : function(supressEvent) {\n        var me = this;\n\n        me.active = false;\n        me.removeClsWithUI([me.activeCls, me.position + '-' + me.activeCls]);\n\n        if (supressEvent !== true) {\n            me.fireEvent('deactivate', me);\n        }\n    }\n});\n\n/**\n * @author Ed Spencer\n * TabBar is used internally by a {@link Ext.tab.Panel TabPanel} and typically should not need to be created manually.\n * The tab bar automatically removes the default title provided by {@link Ext.panel.Header}\n */\nExt.define('Ext.tab.Bar', {\n    extend: 'Ext.panel.Header',\n    alias: 'widget.tabbar',\n    baseCls: Ext.baseCSSPrefix + 'tab-bar',\n\n    requires: ['Ext.tab.Tab'],\n\n    /**\n     * @property {Boolean} isTabBar\n     * `true` in this class to identify an objact as an instantiated Tab Bar, or subclass thereof.\n     */\n    isTabBar: true,\n    \n    /**\n     * @cfg {String} title @hide\n     */\n    \n    /**\n     * @cfg {String} iconCls @hide\n     */\n\n    // @private\n    defaultType: 'tab',\n\n    /**\n     * @cfg {Boolean} plain\n     * True to not show the full background on the tabbar\n     */\n    plain: false,\n\n    childEls: [\n        'body', 'strip'\n    ],\n\n    // @private\n    renderTpl: [\n        '<div id=\"{id}-body\" class=\"{baseCls}-body {bodyCls}<tpl if=\"ui\"> {baseCls}-body-{ui}<tpl for=\"uiCls\"> {parent.baseCls}-body-{parent.ui}-{.}</tpl></tpl>\"<tpl if=\"bodyStyle\"> style=\"{bodyStyle}\"</tpl>>',\n            '{%this.renderContainer(out,values)%}',\n        '</div>',\n        '<div id=\"{id}-strip\" class=\"{baseCls}-strip<tpl if=\"ui\"> {baseCls}-strip-{ui}<tpl for=\"uiCls\"> {parent.baseCls}-strip-{parent.ui}-{.}</tpl></tpl>\"></div>'\n    ],\n\n    /**\n     * @cfg {Number} minTabWidth\n     * The minimum width for a tab in this tab Bar. Defaults to the tab Panel's {@link Ext.tab.Panel#minTabWidth minTabWidth} value.\n     * @deprecated This config is deprecated. It is much easier to use the {@link Ext.tab.Panel#minTabWidth minTabWidth} config on the TabPanel.\n     */\n\n    /**\n     * @cfg {Number} maxTabWidth\n     * The maximum width for a tab in this tab Bar. Defaults to the tab Panel's {@link Ext.tab.Panel#maxTabWidth maxTabWidth} value.\n     * @deprecated This config is deprecated. It is much easier to use the {@link Ext.tab.Panel#maxTabWidth maxTabWidth} config on the TabPanel.\n     */\n\n    // @private\n    initComponent: function() {\n        var me = this;\n\n        if (me.plain) {\n            me.setUI(me.ui + '-plain');\n        }\n\n        me.addClsWithUI(me.dock);\n\n        me.addEvents(\n            /**\n             * @event change\n             * Fired when the currently-active tab has changed\n             * @param {Ext.tab.Bar} tabBar The TabBar\n             * @param {Ext.tab.Tab} tab The new Tab\n             * @param {Ext.Component} card The card that was just shown in the TabPanel\n             */\n            'change'\n        );\n\n        // Element onClick listener added by Header base class\n        me.callParent(arguments);\n\n        // TabBar must override the Header's align setting.\n        me.layout.align = (me.orientation == 'vertical') ? 'left' : 'top';\n        me.layout.overflowHandler = new Ext.layout.container.boxOverflow.Scroller(me.layout);\n\n        me.remove(me.titleCmp);\n        delete me.titleCmp;\n\n        Ext.apply(me.renderData, {\n            bodyCls: me.bodyCls\n        });\n    },\n\n    getLayout: function() {\n        var me = this;\n        me.layout.type = (me.dock === 'top' || me.dock === 'bottom') ? 'hbox' : 'vbox';\n        return me.callParent(arguments);\n    },\n\n    // @private\n    onAdd: function(tab) {\n        tab.position = this.dock;\n        this.callParent(arguments);\n    },\n    \n    onRemove: function(tab) {\n        var me = this;\n        \n        if (tab === me.previousTab) {\n            me.previousTab = null;\n        }\n        me.callParent(arguments);    \n    },\n\n    afterComponentLayout : function(width) {\n        this.callParent(arguments);\n        this.strip.setWidth(width);\n    },\n\n    // @private\n    onClick: function(e, target) {\n        // The target might not be a valid tab el.\n        var me = this,\n            tabEl = e.getTarget('.' + Ext.tab.Tab.prototype.baseCls),\n            tab = tabEl && Ext.getCmp(tabEl.id),\n            tabPanel = me.tabPanel,\n            isCloseClick = tab && tab.closeEl && (target === tab.closeEl.dom);\n\n        if (isCloseClick) {\n            e.preventDefault();\n        }\n        if (tab && tab.isDisabled && !tab.isDisabled()) {\n            if (tab.closable && isCloseClick) {\n                tab.onCloseClick();\n            } else {\n                if (tabPanel) {\n                    // TabPanel will card setActiveTab of the TabBar\n                    tabPanel.setActiveTab(tab.card);\n                } else {\n                    me.setActiveTab(tab);\n                }\n                tab.focus();\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Closes the given tab by removing it from the TabBar and removing the corresponding card from the TabPanel\n     * @param {Ext.tab.Tab} toClose The tab to close\n     */\n    closeTab: function(toClose) {\n        var me = this,\n            card = toClose.card,\n            tabPanel = me.tabPanel,\n            toActivate;\n\n        if (card && card.fireEvent('beforeclose', card) === false) {\n            return false;\n        }\n        \n        // If we are closing the active tab, revert to the previously active tab (or the previous or next enabled sibling if\n        // there *is* no previously active tab, or the previously active tab is the one that's being closed or the previously\n        // active tab has since been disabled)\n        toActivate = me.findNextActivatable(toClose);\n\n        // We are going to remove the associated card, and then, if that was sucessful, remove the Tab,\n        // And then potentially activate another Tab. We should not layout for each of these operations.\n        Ext.suspendLayouts();\n\n        if (tabPanel && card) {\n            // Remove the ownerCt so the tab doesn't get destroyed if the remove is successful\n            // We need this so we can have the tab fire it's own close event.\n            delete toClose.ownerCt;\n            \n            // we must fire 'close' before removing the card from panel, otherwise\n            // the event will no loger have any listener\n            card.fireEvent('close', card);\n            tabPanel.remove(card);\n            \n            // Remove succeeded\n            if (!tabPanel.getComponent(card)) {\n                /*\n                 * Force the close event to fire. By the time this function returns,\n                 * the tab is already destroyed and all listeners have been purged\n                 * so the tab can't fire itself.\n                 */\n                toClose.fireClose();\n                me.remove(toClose);\n            } else {\n                // Restore the ownerCt from above\n                toClose.ownerCt = me;\n                Ext.resumeLayouts(true);\n                return false;\n            }\n        }\n\n        // If we are closing the active tab, revert to the previously active tab (or the previous sibling or the nnext sibling)\n        if (toActivate) {\n            // Our owning TabPanel calls our setActiveTab method, so only call that if this Bar is being used\n            // in some other context (unlikely)\n            if (tabPanel) {\n                tabPanel.setActiveTab(toActivate.card);\n            } else {\n                me.setActiveTab(toActivate);\n            }\n            toActivate.focus();\n        }\n        Ext.resumeLayouts(true);\n    },\n\n    // private - used by TabPanel too.\n    // Works out the next tab to activate when one tab is closed.\n    findNextActivatable: function(toClose) {\n        var me = this;\n        if (toClose.active && me.items.getCount() > 1) {\n            return (me.previousTab && me.previousTab !== toClose && !me.previousTab.disabled) ? me.previousTab : (toClose.next('tab[disabled=false]') || toClose.prev('tab[disabled=false]'));\n        }\n    },\n\n    /**\n     * @private\n     * Marks the given tab as active\n     * @param {Ext.tab.Tab} tab The tab to mark active\n     */\n    setActiveTab: function(tab) {\n        var me = this;\n\n        if (!tab.disabled && tab !== me.activeTab) {\n            if (me.activeTab) {\n                if (me.activeTab.isDestroyed) {\n                    me.previousTab = null;\n                } else {\n                    me.previousTab = me.activeTab;\n                    me.activeTab.deactivate();\n                }\n            }\n            tab.activate();\n\n            me.activeTab = tab;\n            me.fireEvent('change', me, tab, tab.card);\n\n            // Ensure that after the currently in progress layout, the active tab is scrolled into view\n            me.on({\n                afterlayout: me.afterTabActivate,\n                scope: me,\n                single: true\n            });\n            me.updateLayout();\n        }\n    },\n\n    afterTabActivate: function() {\n        this.layout.overflowHandler.scrollToItem(this.activeTab);\n    }\n});\n\n/**\n * @author Ed Spencer, Tommy Maintz, Brian Moeskau\n *\n * A basic tab container. TabPanels can be used exactly like a standard {@link Ext.panel.Panel} for\n * layout purposes, but also have special support for containing child Components\n * (`{@link Ext.container.Container#cfg-items items}`) that are managed using a\n * {@link Ext.layout.container.Card CardLayout layout manager}, and displayed as separate tabs.\n *\n * **Note:** By default, a tab's close tool _destroys_ the child tab Component and all its descendants.\n * This makes the child tab Component, and all its descendants **unusable**.  To enable re-use of a tab,\n * configure the TabPanel with `{@link #autoDestroy autoDestroy: false}`.\n *\n * ## TabPanel's layout\n *\n * TabPanels use a Dock layout to position the {@link Ext.tab.Bar TabBar} at the top of the widget.\n * Panels added to the TabPanel will have their header hidden by default because the Tab will\n * automatically take the Panel's configured title and icon.\n *\n * TabPanels use their {@link Ext.panel.Header header} or {@link Ext.panel.Panel#fbar footer}\n * element (depending on the {@link #tabPosition} configuration) to accommodate the tab selector buttons.\n * This means that a TabPanel will not display any configured title, and will not display any configured\n * header {@link Ext.panel.Panel#tools tools}.\n *\n * To display a header, embed the TabPanel in a {@link Ext.panel.Panel Panel} which uses\n * `{@link Ext.container.Container#layout layout: 'fit'}`.\n *\n * ## Controlling tabs\n *\n * Configuration options for the {@link Ext.tab.Tab} that represents the component can be passed in\n * by specifying the tabConfig option:\n *\n *     @example\n *     Ext.create('Ext.tab.Panel', {\n *         width: 400,\n *         height: 400,\n *         renderTo: document.body,\n *         items: [{\n *             title: 'Foo'\n *         }, {\n *             title: 'Bar',\n *             tabConfig: {\n *                 title: 'Custom Title',\n *                 tooltip: 'A button tooltip'\n *             }\n *         }]\n *     });\n *\n * # Examples\n *\n * Here is a basic TabPanel rendered to the body. This also shows the useful configuration {@link #activeTab},\n * which allows you to set the active tab on render. If you do not set an {@link #activeTab}, no tabs will be\n * active by default.\n *\n *     @example\n *     Ext.create('Ext.tab.Panel', {\n *         width: 300,\n *         height: 200,\n *         activeTab: 0,\n *         items: [\n *             {\n *                 title: 'Tab 1',\n *                 bodyPadding: 10,\n *                 html : 'A simple tab'\n *             },\n *             {\n *                 title: 'Tab 2',\n *                 html : 'Another one'\n *             }\n *         ],\n *         renderTo : Ext.getBody()\n *     });\n *\n * It is easy to control the visibility of items in the tab bar. Specify hidden: true to have the\n * tab button hidden initially. Items can be subsequently hidden and show by accessing the\n * tab property on the child item.\n *\n *     @example\n *     var tabs = Ext.create('Ext.tab.Panel', {\n *         width: 400,\n *         height: 400,\n *         renderTo: document.body,\n *         items: [{\n *             title: 'Home',\n *             html: 'Home',\n *             itemId: 'home'\n *         }, {\n *             title: 'Users',\n *             html: 'Users',\n *             itemId: 'users',\n *             hidden: true\n *         }, {\n *             title: 'Tickets',\n *             html: 'Tickets',\n *             itemId: 'tickets'\n *         }]\n *     });\n *\n *     setTimeout(function(){\n *         tabs.child('#home').tab.hide();\n *         var users = tabs.child('#users');\n *         users.tab.show();\n *         tabs.setActiveTab(users);\n *     }, 1000);\n *\n * You can remove the background of the TabBar by setting the {@link #plain} property to `true`.\n *\n *     @example\n *     Ext.create('Ext.tab.Panel', {\n *         width: 300,\n *         height: 200,\n *         activeTab: 0,\n *         plain: true,\n *         items: [\n *             {\n *                 title: 'Tab 1',\n *                 bodyPadding: 10,\n *                 html : 'A simple tab'\n *             },\n *             {\n *                 title: 'Tab 2',\n *                 html : 'Another one'\n *             }\n *         ],\n *         renderTo : Ext.getBody()\n *     });\n *\n * Another useful configuration of TabPanel is {@link #tabPosition}. This allows you to change the\n * position where the tabs are displayed. The available options for this are `'top'` (default) and\n * `'bottom'`.\n *\n *     @example\n *     Ext.create('Ext.tab.Panel', {\n *         width: 300,\n *         height: 200,\n *         activeTab: 0,\n *         bodyPadding: 10,\n *         tabPosition: 'bottom',\n *         items: [\n *             {\n *                 title: 'Tab 1',\n *                 html : 'A simple tab'\n *             },\n *             {\n *                 title: 'Tab 2',\n *                 html : 'Another one'\n *             }\n *         ],\n *         renderTo : Ext.getBody()\n *     });\n *\n * The {@link #setActiveTab} is a very useful method in TabPanel which will allow you to change the\n * current active tab. You can either give it an index or an instance of a tab. For example:\n *\n *     @example\n *     var tabs = Ext.create('Ext.tab.Panel', {\n *         items: [\n *             {\n *                 id   : 'my-tab',\n *                 title: 'Tab 1',\n *                 html : 'A simple tab'\n *             },\n *             {\n *                 title: 'Tab 2',\n *                 html : 'Another one'\n *             }\n *         ],\n *         renderTo : Ext.getBody()\n *     });\n *\n *     var tab = Ext.getCmp('my-tab');\n *\n *     Ext.create('Ext.button.Button', {\n *         renderTo: Ext.getBody(),\n *         text    : 'Select the first tab',\n *         scope   : this,\n *         handler : function() {\n *             tabs.setActiveTab(tab);\n *         }\n *     });\n *\n *     Ext.create('Ext.button.Button', {\n *         text    : 'Select the second tab',\n *         scope   : this,\n *         handler : function() {\n *             tabs.setActiveTab(1);\n *         },\n *         renderTo : Ext.getBody()\n *     });\n *\n * The {@link #getActiveTab} is a another useful method in TabPanel which will return the current active tab.\n *\n *     @example\n *     var tabs = Ext.create('Ext.tab.Panel', {\n *         items: [\n *             {\n *                 title: 'Tab 1',\n *                 html : 'A simple tab'\n *             },\n *             {\n *                 title: 'Tab 2',\n *                 html : 'Another one'\n *             }\n *         ],\n *         renderTo : Ext.getBody()\n *     });\n *\n *     Ext.create('Ext.button.Button', {\n *         text    : 'Get active tab',\n *         scope   : this,\n *         handler : function() {\n *             var tab = tabs.getActiveTab();\n *             alert('Current tab: ' + tab.title);\n *         },\n *         renderTo : Ext.getBody()\n *     });\n *\n * Adding a new tab is very simple with a TabPanel. You simple call the {@link #method-add} method with an config\n * object for a panel.\n *\n *     @example\n *     var tabs = Ext.create('Ext.tab.Panel', {\n *         items: [\n *             {\n *                 title: 'Tab 1',\n *                 html : 'A simple tab'\n *             },\n *             {\n *                 title: 'Tab 2',\n *                 html : 'Another one'\n *             }\n *         ],\n *         renderTo : Ext.getBody()\n *     });\n *\n *     Ext.create('Ext.button.Button', {\n *         text    : 'New tab',\n *         scope   : this,\n *         handler : function() {\n *             var tab = tabs.add({\n *                 // we use the tabs.items property to get the length of current items/tabs\n *                 title: 'Tab ' + (tabs.items.length + 1),\n *                 html : 'Another one'\n *             });\n *\n *             tabs.setActiveTab(tab);\n *         },\n *         renderTo : Ext.getBody()\n *     });\n *\n * Additionally, removing a tab is very also simple with a TabPanel. You simple call the {@link #method-remove} method\n * with an config object for a panel.\n *\n *     @example\n *     var tabs = Ext.create('Ext.tab.Panel', {\n *         items: [\n *             {\n *                 title: 'Tab 1',\n *                 html : 'A simple tab'\n *             },\n *             {\n *                 id   : 'remove-this-tab',\n *                 title: 'Tab 2',\n *                 html : 'Another one'\n *             }\n *         ],\n *         renderTo : Ext.getBody()\n *     });\n *\n *     Ext.create('Ext.button.Button', {\n *         text    : 'Remove tab',\n *         scope   : this,\n *         handler : function() {\n *             var tab = Ext.getCmp('remove-this-tab');\n *             tabs.remove(tab);\n *         },\n *         renderTo : Ext.getBody()\n *     });\n */\nExt.define('Ext.tab.Panel', {\n    extend: 'Ext.panel.Panel',\n    alias: 'widget.tabpanel',\n    alternateClassName: ['Ext.TabPanel'],\n\n    requires: ['Ext.layout.container.Card', 'Ext.tab.Bar'],\n\n    /**\n     * @cfg {String} tabPosition\n     * The position where the tab strip should be rendered. Can be `top` or `bottom`.\n     */\n    tabPosition : 'top',\n\n    /**\n     * @cfg {String/Number} activeItem\n     * Doesn't apply for {@link Ext.tab.Panel TabPanel}, use {@link #activeTab} instead.\n     */\n\n    /**\n     * @cfg {String/Number/Ext.Component} activeTab\n     * The tab to activate initially. Either an ID, index or the tab component itself.\n     */\n\n    /**\n     * @cfg {Object} tabBar\n     * Optional configuration object for the internal {@link Ext.tab.Bar}.\n     * If present, this is passed straight through to the TabBar's constructor\n     */\n\n    /**\n     * @cfg {Object} layout\n     * Optional configuration object for the internal {@link Ext.layout.container.Card card layout}.\n     * If present, this is passed straight through to the layout's constructor\n     */\n\n    /**\n     * @cfg {Boolean} removePanelHeader\n     * True to instruct each Panel added to the TabContainer to not render its header element.\n     * This is to ensure that the title of the panel does not appear twice.\n     */\n    removePanelHeader: true,\n\n    /**\n     * @cfg {Boolean} plain\n     * True to not show the full background on the TabBar.\n     */\n    plain: false,\n\n    /**\n     * @cfg {String} [itemCls='x-tabpanel-child']\n     * The class added to each child item of this TabPanel.\n     */\n    itemCls: Ext.baseCSSPrefix + 'tabpanel-child',\n\n    /**\n     * @cfg {Number} minTabWidth\n     * The minimum width for a tab in the {@link #cfg-tabBar}.\n     */\n    minTabWidth: undefined,\n\n    /**\n     * @cfg {Number} maxTabWidth The maximum width for each tab.\n     */\n    maxTabWidth: undefined,\n\n    /**\n     * @cfg {Boolean} deferredRender\n     *\n     * True by default to defer the rendering of child {@link Ext.container.Container#cfg-items items} to the browsers DOM\n     * until a tab is activated. False will render all contained {@link Ext.container.Container#cfg-items items} as soon as\n     * the {@link Ext.layout.container.Card layout} is rendered. If there is a significant amount of content or a lot of\n     * heavy controls being rendered into panels that are not displayed by default, setting this to true might improve\n     * performance.\n     *\n     * The deferredRender property is internally passed to the layout manager for TabPanels ({@link\n     * Ext.layout.container.Card}) as its {@link Ext.layout.container.Card#deferredRender} configuration value.\n     *\n     * **Note**: leaving deferredRender as true means that the content within an unactivated tab will not be available\n     */\n    deferredRender : true,\n\n    //inherit docs\n    initComponent: function() {\n        var me = this,\n            dockedItems = [].concat(me.dockedItems || []),\n            activeTab = me.activeTab || (me.activeTab = 0);\n\n        // Configure the layout with our deferredRender, and with our activeTeb\n        me.layout = new Ext.layout.container.Card(Ext.apply({\n            owner: me,\n            deferredRender: me.deferredRender,\n            itemCls: me.itemCls,\n            activeItem: me.activeTab\n        }, me.layout));\n\n        /**\n         * @property {Ext.tab.Bar} tabBar Internal reference to the docked TabBar\n         */\n        me.tabBar = new Ext.tab.Bar(Ext.apply({\n            dock: me.tabPosition,\n            plain: me.plain,\n            border: me.border,\n            cardLayout: me.layout,\n            tabPanel: me\n        }, me.tabBar));\n\n        dockedItems.push(me.tabBar);\n        me.dockedItems = dockedItems;\n\n        me.addEvents(\n            /**\n             * @event\n             * Fires before a tab change (activated by {@link #setActiveTab}). Return false in any listener to cancel\n             * the tabchange\n             * @param {Ext.tab.Panel} tabPanel The TabPanel\n             * @param {Ext.Component} newCard The card that is about to be activated\n             * @param {Ext.Component} oldCard The card that is currently active\n             */\n            'beforetabchange',\n\n            /**\n             * @event\n             * Fires when a new tab has been activated (activated by {@link #setActiveTab}).\n             * @param {Ext.tab.Panel} tabPanel The TabPanel\n             * @param {Ext.Component} newCard The newly activated item\n             * @param {Ext.Component} oldCard The previously active item\n             */\n            'tabchange'\n        );\n\n        me.callParent(arguments);\n\n        // We have to convert the numeric index/string ID config into its component reference\n        me.activeTab = me.getComponent(activeTab);\n\n        // Ensure that the active child's tab is rendered in the active UI state\n        if (me.activeTab) {\n            me.activeTab.tab.activate(true);\n\n            // So that it knows what to deactivate in subsequent tab changes \n            me.tabBar.activeTab = me.activeTab.tab;\n        }\n    },\n\n    /**\n     * Makes the given card active. Makes it the visible card in the TabPanel's CardLayout and highlights the Tab.\n     * @param {String/Number/Ext.Component} card The card to make active. Either an ID, index or the component itself.\n     * @return {Ext.Component} The resulting active child Component. The call may have been vetoed, or otherwise\n     * modified by an event listener.\n     */\n    setActiveTab: function(card) {\n        var me = this,\n            previous;\n\n        card = me.getComponent(card);\n        if (card) {\n            previous = me.getActiveTab();\n\n            if (previous !== card && me.fireEvent('beforetabchange', me, card, previous) === false) {\n                return false;\n            }\n\n            // We may be passed a config object, so add it.\n            // Without doing a layout!\n            if (!card.isComponent) {\n                Ext.suspendLayouts();\n                card = me.add(card);\n                Ext.resumeLayouts();\n            }\n\n            // MUST set the activeTab first so that the machinery which listens for show doesn't\n            // think that the show is \"driving\" the activation and attempt to recurse into here.\n            me.activeTab = card;\n\n            // Attempt to switch to the requested card. Suspend layouts because if that was successful\n            // we have to also update the active tab in the tab bar which is another layout operation\n            // and we must coalesce them.\n            Ext.suspendLayouts();\n            me.layout.setActiveItem(card);\n\n            // Read the result of the card layout. Events dear boy, events!\n            card = me.activeTab = me.layout.getActiveItem();\n\n            // Card switch was not vetoed by an event listener\n            if (card && card !== previous) {\n\n                // Update the active tab in the tab bar and resume layouts.\n                me.tabBar.setActiveTab(card.tab);\n                Ext.resumeLayouts(true);\n\n                // previous will be undefined or this.activeTab at instantiation\n                if (previous !== card) {\n                    me.fireEvent('tabchange', me, card, previous);\n                }\n            }\n            // Card switch was vetoed by an event listener. Resume layouts (Nothing should have changed on a veto).\n            else {\n                Ext.resumeLayouts(true);\n            }\n            return card;\n        }\n    },\n\n    /**\n     * Returns the item that is currently active inside this TabPanel.\n     * @return {Ext.Component} The currently active item.\n     */\n    getActiveTab: function() {\n        var me = this,\n            // Ensure the calculated result references a Component\n            result = me.getComponent(me.activeTab);\n\n        // Sanitize the result in case the active tab is no longer there.\n        if (result && me.items.indexOf(result) != -1) {\n            me.activeTab = result;\n        } else {\n            me.activeTab = null;\n        }\n\n        return me.activeTab;\n    },\n\n    /**\n     * Returns the {@link Ext.tab.Bar} currently used in this TabPanel\n     * @return {Ext.tab.Bar} The TabBar\n     */\n    getTabBar: function() {\n        return this.tabBar;\n    },\n\n    /**\n     * @protected\n     * Makes sure we have a Tab for each item added to the TabPanel\n     */\n    onAdd: function(item, index) {\n        var me = this,\n            cfg = item.tabConfig || {},\n            defaultConfig = {\n                xtype: 'tab',\n                card: item,\n                disabled: item.disabled,\n                closable: item.closable,\n                hidden: item.hidden && !item.hiddenByLayout, // only hide if it wasn't hidden by the layout itself\n                tooltip: item.tooltip,\n                tabBar: me.tabBar,\n                closeText: item.closeText\n            };\n\n        cfg = Ext.applyIf(cfg, defaultConfig);\n\n        // Create the correspondiong tab in the tab bar\n        item.tab = me.tabBar.insert(index, cfg);\n\n        item.on({\n            scope : me,\n            enable: me.onItemEnable,\n            disable: me.onItemDisable,\n            beforeshow: me.onItemBeforeShow,\n            iconchange: me.onItemIconChange,\n            iconclschange: me.onItemIconClsChange,\n            titlechange: me.onItemTitleChange\n        });\n\n        if (item.isPanel) {\n            if (me.removePanelHeader) {\n                if (item.rendered) {\n                    if (item.header) {\n                        item.header.hide();\n                    }\n                } else {\n                    item.header = false;\n                }\n            }\n            if (item.isPanel && me.border) {\n                item.setBorder(false);\n            }\n        }\n    },\n\n    /**\n     * @private\n     * Enable corresponding tab when item is enabled.\n     */\n    onItemEnable: function(item){\n        item.tab.enable();\n    },\n\n    /**\n     * @private\n     * Disable corresponding tab when item is enabled.\n     */\n    onItemDisable: function(item){\n        item.tab.disable();\n    },\n\n    /**\n     * @private\n     * Sets activeTab before item is shown.\n     */\n    onItemBeforeShow: function(item) {\n        if (item !== this.activeTab) {\n            this.setActiveTab(item);\n            return false;\n        }\n    },\n\n    /**\n     * @private\n     * Update the tab icon when panel icon has been set or changed.\n     */\n    onItemIconChange: function(item, newIcon) {\n        item.tab.setIcon(newIcon);\n    },\n    \n    /**\n     * @private\n     * Update the tab iconCls when panel iconCls has been set or changed.\n     */\n    onItemIconClsChange: function(item, newIconCls) {\n        item.tab.setIconCls(newIconCls);\n    },\n\n    /**\n     * @private\n     * Update the tab title when panel title has been set or changed.\n     */\n    onItemTitleChange: function(item, newTitle) {\n        item.tab.setText(newTitle);\n    },\n\n    /**\n     * @private\n     * Unlink the removed child item from its (@link Ext.tab.Tab Tab}.\n     * \n     * If we're removing the currently active tab, activate the nearest one. The item is removed when we call super,\n     * so we can do preprocessing before then to find the card's index\n     */\n    doRemove: function(item, autoDestroy) {\n        var me = this,\n            toActivate;\n\n        // Destroying, or removing the last item, nothing to activate\n        if (me.destroying || me.items.getCount() == 1) {\n            me.activeTab = null;\n        }\n\n        // Ask the TabBar which tab to activate next.\n        // Set the active child panel using the index of that tab\n        else if ((toActivate = me.tabBar.items.indexOf(me.tabBar.findNextActivatable(item.tab))) !== -1) {\n             me.setActiveTab(toActivate);\n        }\n        this.callParent(arguments);\n\n        // Remove the two references\n        delete item.tab.card;\n        delete item.tab;\n    },\n\n    /**\n     * @private\n     * Makes sure we remove the corresponding Tab when an item is removed\n     */\n    onRemove: function(item, destroying) {\n        var me = this;\n\n        item.un({\n            scope : me,\n            enable: me.onItemEnable,\n            disable: me.onItemDisable,\n            beforeshow: me.onItemBeforeShow\n        });\n        if (!me.destroying && item.tab.ownerCt === me.tabBar) {\n            me.tabBar.remove(item.tab);\n        }\n    }\n});\n\n/**\n * A simple element that adds extra horizontal space between items in a toolbar.\n * By default a 2px wide space is added via CSS specification:\n *\n *     .x-toolbar .x-toolbar-spacer {\n *         width: 2px;\n *     }\n *\n * Example:\n *\n *     @example\n *     Ext.create('Ext.panel.Panel', {\n *         title: 'Toolbar Spacer Example',\n *         width: 300,\n *         height: 200,\n *         tbar : [\n *             'Item 1',\n *             { xtype: 'tbspacer' }, // or ' '\n *             'Item 2',\n *             // space width is also configurable via javascript\n *             { xtype: 'tbspacer', width: 50 }, // add a 50px space\n *             'Item 3'\n *         ],\n *         renderTo: Ext.getBody()\n *     });\n */\nExt.define('Ext.toolbar.Spacer', {\n    extend: 'Ext.Component',\n    alias: 'widget.tbspacer',\n    alternateClassName: 'Ext.Toolbar.Spacer',\n    baseCls: Ext.baseCSSPrefix + 'toolbar-spacer',\n    focusable: false\n});\n\n/**\n * Provides indentation and folder structure markup for a Tree taking into account\n * depth and position within the tree hierarchy.\n * \n * @private\n */\nExt.define('Ext.tree.Column', {\n    extend: 'Ext.grid.column.Column',\n    alias: 'widget.treecolumn',\n\n    tdCls: Ext.baseCSSPrefix + 'grid-cell-treecolumn',\n    \n    treePrefix: Ext.baseCSSPrefix + 'tree-',\n    elbowPrefix: Ext.baseCSSPrefix + 'tree-elbow-',\n    expanderCls: Ext.baseCSSPrefix + 'tree-expander',\n    imgText: '<img src=\"{1}\" class=\"{0}\" />',\n    checkboxText: '<input type=\"button\" role=\"checkbox\" class=\"{0}\" {1} />',\n\n    initComponent: function() {\n        var me = this;\n        \n        me.origRenderer = me.renderer || me.defaultRenderer;\n        me.origScope = me.scope || window;\n\n        me.renderer = me.treeRenderer;\n        me.scope = me;\n        \n        me.callParent();\n    },\n    \n    treeRenderer: function(value, metaData, record, rowIdx, colIdx, store, view){\n        var me = this,\n            buf = [],\n            format = Ext.String.format,\n            depth = record.getDepth(),\n            treePrefix  = me.treePrefix,\n            elbowPrefix = me.elbowPrefix,\n            expanderCls = me.expanderCls,\n            imgText     = me.imgText,\n            checkboxText= me.checkboxText,\n            formattedValue = me.origRenderer.apply(me.origScope, arguments),\n            blank = Ext.BLANK_IMAGE_URL,\n            href = record.get('href'),\n            target = record.get('hrefTarget'),\n            cls = record.get('cls');\n\n        while (record) {\n            if (!record.isRoot() || (record.isRoot() && view.rootVisible)) {\n                if (record.getDepth() === depth) {\n                    buf.unshift(format(imgText,\n                        treePrefix + 'icon ' + \n                        treePrefix + 'icon' + (record.get('icon') ? '-inline ' : (record.isLeaf() ? '-leaf ' : '-parent ')) +\n                        (record.get('iconCls') || ''),\n                        record.get('icon') || blank\n                    ));\n                    if (record.get('checked') !== null) {\n                        buf.unshift(format(\n                            checkboxText,\n                            (treePrefix + 'checkbox') + (record.get('checked') ? ' ' + treePrefix + 'checkbox-checked' : ''),\n                            record.get('checked') ? 'aria-checked=\"true\"' : ''\n                        ));\n                        if (record.get('checked')) {\n                            metaData.tdCls += (' ' + treePrefix + 'checked');\n                        }\n                    }\n                    if (record.isLast()) {\n                        if (record.isExpandable()) {\n                            buf.unshift(format(imgText, (elbowPrefix + 'end-plus ' + expanderCls), blank));\n                        } else {\n                            buf.unshift(format(imgText, (elbowPrefix + 'end'), blank));\n                        }\n                            \n                    } else {\n                        if (record.isExpandable()) {\n                            buf.unshift(format(imgText, (elbowPrefix + 'plus ' + expanderCls), blank));\n                        } else {\n                            buf.unshift(format(imgText, (treePrefix + 'elbow'), blank));\n                        }\n                    }\n                } else {\n                    if (record.isLast() || record.getDepth() === 0) {\n                        buf.unshift(format(imgText, (elbowPrefix + 'empty'), blank));\n                    } else if (record.getDepth() !== 0) {\n                        buf.unshift(format(imgText, (elbowPrefix + 'line'), blank));\n                    }                      \n                }\n            }\n            record = record.parentNode;\n        }\n        if (href) {\n            buf.push('<a href=\"', href, '\" target=\"', target, '\">', formattedValue, '</a>');\n        } else {\n            buf.push(formattedValue);\n        }\n        if (cls) {\n            metaData.tdCls += ' ' + cls;\n        }\n        return buf.join('');\n    },\n\n    defaultRenderer: function(value) {\n        return value;\n    }\n});\n\n/**\n * Used as a view by {@link Ext.tree.Panel TreePanel}.\n */\nExt.define('Ext.tree.View', {\n    extend: 'Ext.view.Table',\n    alias: 'widget.treeview',\n\n    requires: [\n        'Ext.data.NodeStore'\n    ],\n\n    loadingCls: Ext.baseCSSPrefix + 'grid-tree-loading',\n    expandedCls: Ext.baseCSSPrefix + 'grid-tree-node-expanded',\n    leafCls: Ext.baseCSSPrefix + 'grid-tree-node-leaf',\n\n    expanderSelector: '.' + Ext.baseCSSPrefix + 'tree-expander',\n    checkboxSelector: '.' + Ext.baseCSSPrefix + 'tree-checkbox',\n    expanderIconOverCls: Ext.baseCSSPrefix + 'tree-expander-over',\n\n    // Class to add to the node wrap element used to hold nodes when a parent is being\n    // collapsed or expanded. During the animation, UI interaction is forbidden by testing\n    // for an ancestor node with this class.\n    nodeAnimWrapCls: Ext.baseCSSPrefix + 'tree-animator-wrap',\n\n    blockRefresh: true,\n    \n    /**\n     * @cfg\n     * @inheritdoc\n     */\n    loadMask: false,\n\n    /** \n     * @cfg {Boolean} rootVisible\n     * False to hide the root node.\n     */\n    rootVisible: true,\n\n    /**\n     * @cfg {Boolean} deferInitialRefresh\n     * Must be false for Tree Views because the root node must be rendered in order to be updated with its child nodes.\n     */\n    deferInitialRefresh: false,\n\n    /** \n     * @cfg {Boolean} animate\n     * True to enable animated expand/collapse (defaults to the value of {@link Ext#enableFx Ext.enableFx})\n     */\n\n    expandDuration: 250,\n    collapseDuration: 250,\n\n    toggleOnDblClick: true,\n\n    stripeRows: false,\n\n    // fields that will trigger a change in the ui that aren't likely to be bound to a column\n    uiFields: ['expanded', 'loaded', 'checked', 'expandable', 'leaf', 'icon', 'iconCls', 'loading', 'qtip', 'qtitle'],\n\n    initComponent: function() {\n        var me = this,\n            treeStore = me.panel.getStore();\n\n        if (me.initialConfig.animate === undefined) {\n            me.animate = Ext.enableFx;\n        }\n\n        me.store = new Ext.data.NodeStore({\n            treeStore: treeStore,\n            recursive: true,\n            rootVisible: me.rootVisible,\n            listeners: {\n                beforeexpand: me.onBeforeExpand,\n                expand: me.onExpand,\n                beforecollapse: me.onBeforeCollapse,\n                collapse: me.onCollapse,\n                write: me.onStoreWrite,\n                datachanged: me.onStoreDataChanged,\n                scope: me\n            }\n        });\n\n        if (me.node) {\n            me.setRootNode(me.node);\n        }\n        me.animQueue = {};\n        me.animWraps = {};\n        me.addEvents(\n            /**\n             * @event afteritemexpand\n             * Fires after an item has been visually expanded and is visible in the tree. \n             * @param {Ext.data.NodeInterface} node         The node that was expanded\n             * @param {Number} index                        The index of the node\n             * @param {HTMLElement} item                    The HTML element for the node that was expanded\n             */\n            'afteritemexpand',\n            /**\n             * @event afteritemcollapse\n             * Fires after an item has been visually collapsed and is no longer visible in the tree. \n             * @param {Ext.data.NodeInterface} node         The node that was collapsed\n             * @param {Number} index                        The index of the node\n             * @param {HTMLElement} item                    The HTML element for the node that was collapsed\n             */\n            'afteritemcollapse'\n        );\n        me.callParent(arguments);\n        me.on({\n            element: 'el',\n            scope: me,\n            delegate: me.expanderSelector,\n            mouseover: me.onExpanderMouseOver,\n            mouseout: me.onExpanderMouseOut\n        });\n        me.on({\n            element: 'el',\n            scope: me,\n            delegate: me.checkboxSelector,\n            click: me.onCheckboxChange\n        });\n    },\n    \n    getMaskStore: function(){\n        return this.panel.getStore();    \n    },\n\n    afterComponentLayout: function(){\n        this.callParent(arguments);\n        var stretcher = this.stretcher;\n        if (stretcher) {\n            stretcher.setWidth((this.getWidth() - Ext.getScrollbarSize().width));\n        }\n    },\n\n    processUIEvent: function(e) {\n        // If the clicked node is part of an animation, ignore the click.\n        // This is because during a collapse animation, the associated Records\n        // will already have been removed from the Store, and the event is not processable.\n        if (e.getTarget('.' + this.nodeAnimWrapCls, this.el)) {\n            return false;\n        }\n        return this.callParent(arguments);\n    },\n\n    onClear: function(){\n        this.store.removeAll();    \n    },\n\n    setRootNode: function(node) {\n        var me = this;        \n        me.store.setNode(node);\n        me.node = node;\n    },\n\n    onCheckboxChange: function(e, t) {\n        var me = this,\n            item = e.getTarget(me.getItemSelector(), me.getTargetEl());\n\n        if (item) {\n            me.onCheckChange(me.getRecord(item));\n        }\n    },\n\n    onCheckChange: function(record){\n        var checked = record.get('checked');\n        if (Ext.isBoolean(checked)) {\n            checked = !checked;\n            record.set('checked', checked);\n            this.fireEvent('checkchange', record, checked);\n        }\n    },\n\n    getChecked: function() {\n        var checked = [];\n        this.node.cascadeBy(function(rec){\n            if (rec.get('checked')) {\n                checked.push(rec);\n            }\n        });\n        return checked;\n    },\n\n    isItemChecked: function(rec){\n        return rec.get('checked');\n    },\n\n    /**\n     * @private\n     */\n    createAnimWrap: function(record, index) {\n        var thHtml = '',\n            headerCt = this.panel.headerCt,\n            headers = headerCt.getGridColumns(),\n            i = 0, len = headers.length, item,\n            node = this.getNode(record),\n            tmpEl, nodeEl;\n\n        for (; i < len; i++) {\n            item = headers[i];\n            thHtml += '<th style=\"width: ' + (item.hidden ? 0 : item.getDesiredWidth()) + 'px; height: 0px;\"></th>';\n        }\n\n        nodeEl = Ext.get(node);        \n        tmpEl = nodeEl.insertSibling({\n            tag: 'tr',\n            html: [\n                '<td colspan=\"' + headerCt.getColumnCount() + '\">',\n                    '<div class=\"' + this.nodeAnimWrapCls + '\">',\n                        '<table class=\"' + Ext.baseCSSPrefix + 'grid-table\" style=\"width: ' + headerCt.getFullWidth() + 'px;\"><tbody>',\n                            thHtml,\n                        '</tbody></table>',\n                    '</div>',\n                '</td>'\n            ].join('')\n        }, 'after');\n\n        return {\n            record: record,\n            node: node,\n            el: tmpEl,\n            expanding: false,\n            collapsing: false,\n            animating: false,\n            animateEl: tmpEl.down('div'),\n            targetEl: tmpEl.down('tbody')\n        };\n    },\n\n    /**\n     * @private\n     * Returns the animation wrapper element for the specified parent node, used to wrap the child nodes as\n     * they slide up or down during expand/collapse.\n     * \n     * @param parent The parent node to be expanded or collapsed\n     * \n     * @param [bubble=true] If the passed parent node does not already have a wrap element created, by default\n     * this function will bubble up to each parent node looking for a valid wrap element to reuse, returning \n     * the first one it finds. This is the appropriate behavior, e.g., for the collapse direction, so that the\n     * entire expanded set of branch nodes can collapse as a single unit.\n     * \n     * However for expanding each parent node should instead always create its own animation wrap if one \n     * doesn't exist, so that its children can expand independently of any other nodes -- this is crucial \n     * when executing the \"expand all\" behavior. If multiple nodes attempt to reuse the same ancestor wrap\n     * element concurrently during expansion it will lead to problems as the first animation to complete will\n     * delete the wrap el out from under other running animations. For that reason, when expanding you should\n     * always pass `bubble: false` to be on the safe side.\n     * \n     * If the passed parent has no wrap (or there is no valid ancestor wrap after bubbling), this function \n     * will return null and the calling code should then call {@link #createAnimWrap} if needed.\n     * \n     * @return {Ext.Element} The wrapping element as created in {@link #createAnimWrap}, or null\n     */\n    getAnimWrap: function(parent, bubble) {\n        if (!this.animate) {\n            return null;\n        }\n\n        var wraps = this.animWraps,\n            wrap = wraps[parent.internalId];\n\n        if (bubble !== false) {\n            while (!wrap && parent) {\n                parent = parent.parentNode;\n                if (parent) {\n                    wrap = wraps[parent.internalId];\n                }\n            }\n        }\n        return wrap;\n    },\n\n    doAdd: function(nodes, records, index) {\n        // If we are adding records which have a parent that is currently expanding\n        // lets add them to the animation wrap\n        var me = this,\n            record = records[0],\n            parent = record.parentNode,\n            a = me.all.elements,\n            relativeIndex = 0,\n            animWrap = me.getAnimWrap(parent),\n            targetEl, children, len;\n\n        if (!animWrap || !animWrap.expanding) {\n            return me.callParent(arguments);\n        }\n\n        // We need the parent that has the animWrap, not the nodes parent\n        parent = animWrap.record;\n\n        // If there is an anim wrap we do our special magic logic\n        targetEl = animWrap.targetEl;\n        children = targetEl.dom.childNodes;\n\n        // We subtract 1 from the childrens length because we have a tr in there with the th'es\n        len = children.length - 1;\n\n        // The relative index is the index in the full flat collection minus the index of the wraps parent\n        relativeIndex = index - me.indexOf(parent) - 1;\n\n        // If we are adding records to the wrap that have a higher relative index then there are currently children\n        // it means we have to append the nodes to the wrap\n        if (!len || relativeIndex >= len) {\n            targetEl.appendChild(nodes);\n        }\n        // If there are already more children then the relative index it means we are adding child nodes of\n        // some expanded node in the anim wrap. In this case we have to insert the nodes in the right location\n        else {\n            // +1 because of the tr with th'es that is already there\n            Ext.fly(children[relativeIndex + 1]).insertSibling(nodes, 'before', true);\n        }\n\n        // We also have to update the CompositeElementLite collection of the DataView\n        Ext.Array.insert(a, index, nodes);\n\n        // If we were in an animation we need to now change the animation\n        // because the targetEl just got higher.\n        if (animWrap.isAnimating) {\n            me.onExpand(parent);\n        }\n    },\n\n    beginBulkUpdate: function(){\n        this.bulkUpdate = true;  \n    },\n\n    endBulkUpdate: function(){\n        this.bulkUpdate = false;\n    },\n\n    onRemove : function(ds, record, index) {\n        var me = this,\n            bulk = me.bulkUpdate;\n            \n        if (me.viewReady) {\n            me.doRemove(record, index);\n            if (!bulk) {\n                me.updateIndexes(index);\n            }\n            if (me.store.getCount() === 0){\n                me.refresh();\n            }\n            if (!bulk) {\n                me.fireEvent('itemremove', record, index);\n            }\n        }\n    },\n\n    doRemove: function(record, index) {\n        // If we are adding records which have a parent that is currently expanding\n        // lets add them to the animation wrap\n        var me = this,\n            all = me.all,\n            animWrap = me.getAnimWrap(record),\n            item = all.item(index),\n            node = item ? item.dom : null;\n\n        if (!node || !animWrap || !animWrap.collapsing) {\n            return me.callParent(arguments);\n        }\n\n        animWrap.targetEl.appendChild(node);\n        all.removeElement(index);\n    },\n\n    onBeforeExpand: function(parent, records, index) {\n        var me = this,\n            animWrap;\n\n        if (!me.rendered || !me.animate) {\n            return;\n        }\n\n        if (me.getNode(parent)) {\n            animWrap = me.getAnimWrap(parent, false);\n            if (!animWrap) {\n                animWrap = me.animWraps[parent.internalId] = me.createAnimWrap(parent);\n                animWrap.animateEl.setHeight(0);\n            }\n            else if (animWrap.collapsing) {\n                // If we expand this node while it is still expanding then we\n                // have to remove the nodes from the animWrap.\n                animWrap.targetEl.select(me.itemSelector).remove();\n            } \n            animWrap.expanding = true;\n            animWrap.collapsing = false;\n        }\n    },\n\n    onExpand: function(parent) {\n        var me = this,\n            queue = me.animQueue,\n            id = parent.getId(),\n            node = me.getNode(parent),\n            index = node ? me.indexOf(node) : -1,\n            animWrap,\n            animateEl, \n            targetEl;        \n\n        if (me.singleExpand) {\n            me.ensureSingleExpand(parent);\n        }\n\n        // The item is not visible yet\n        if (index === -1) {\n            return;\n        }\n\n        animWrap = me.getAnimWrap(parent, false);\n\n        if (!animWrap) {\n            me.isExpandingOrCollapsing = false;\n            me.fireEvent('afteritemexpand', parent, index, node);\n            return;\n        }\n\n        animateEl = animWrap.animateEl;\n        targetEl = animWrap.targetEl;\n\n        animateEl.stopAnimation();\n        // @TODO: we are setting it to 1 because quirks mode on IE seems to have issues with 0\n        queue[id] = true;\n        animateEl.slideIn('t', {\n            duration: me.expandDuration,\n            listeners: {\n                scope: me,\n                lastframe: function() {\n                    // Move all the nodes out of the anim wrap to their proper location\n                    animWrap.el.insertSibling(targetEl.query(me.itemSelector), 'before');\n                    animWrap.el.remove();\n                    me.refreshSize();\n                    delete me.animWraps[animWrap.record.internalId];\n                    delete queue[id];\n                }\n            },\n            callback: function() {\n                me.isExpandingOrCollapsing = false;\n                me.fireEvent('afteritemexpand', parent, index, node);\n            }\n        });\n\n        animWrap.isAnimating = true;\n    },\n\n    onBeforeCollapse: function(parent, records, index) {\n        var me = this,\n            animWrap;\n\n        if (!me.rendered || !me.animate) {\n            return;\n        }\n\n        if (me.getNode(parent)) {\n            animWrap = me.getAnimWrap(parent);\n            if (!animWrap) {\n                animWrap = me.animWraps[parent.internalId] = me.createAnimWrap(parent, index);\n            }\n            else if (animWrap.expanding) {\n                // If we collapse this node while it is still expanding then we\n                // have to remove the nodes from the animWrap.\n                animWrap.targetEl.select(this.itemSelector).remove();\n            }\n            animWrap.expanding = false;\n            animWrap.collapsing = true;\n        }\n    },\n\n    onCollapse: function(parent) {\n        var me = this,\n            queue = me.animQueue,\n            id = parent.getId(),\n            node = me.getNode(parent),\n            index = node ? me.indexOf(node) : -1,\n            animWrap = me.getAnimWrap(parent),\n            animateEl, targetEl;\n\n        // The item has already been removed by a parent node\n        if (index === -1) {\n            return;\n        }\n\n        if (!animWrap) {\n            me.isExpandingOrCollapsing = false;\n            me.fireEvent('afteritemcollapse', parent, index, node);\n            return;\n        }\n\n        animateEl = animWrap.animateEl;\n        targetEl = animWrap.targetEl;\n\n        queue[id] = true;\n\n        // @TODO: we are setting it to 1 because quirks mode on IE seems to have issues with 0\n        animateEl.stopAnimation();\n        animateEl.slideOut('t', {\n            duration: me.collapseDuration,\n            listeners: {\n                scope: me,\n                lastframe: function() {\n                    animWrap.el.remove();\n                    me.refreshSize();\n                    delete me.animWraps[animWrap.record.internalId];\n                    delete queue[id];\n                }             \n            },\n            callback: function() {\n                me.isExpandingOrCollapsing = false;\n                me.fireEvent('afteritemcollapse', parent, index, node);\n            }\n        });\n        animWrap.isAnimating = true;\n    },\n\n    /**\n     * Checks if a node is currently undergoing animation\n     * @private\n     * @param {Ext.data.Model} node The node\n     * @return {Boolean} True if the node is animating\n     */\n    isAnimating: function(node) {\n        return !!this.animQueue[node.getId()];    \n    },\n\n    collectData: function(records) {\n        var data = this.callParent(arguments),\n            rows = data.rows,\n            len = rows.length,\n            i = 0,\n            row, record;\n\n        for (; i < len; i++) {\n            row = rows[i];\n            record = records[i];\n            if (record.get('qtip')) {\n                row.rowAttr = 'data-qtip=\"' + record.get('qtip') + '\"';\n                if (record.get('qtitle')) {\n                    row.rowAttr += ' ' + 'data-qtitle=\"' + record.get('qtitle') + '\"';\n                }\n            }\n            if (record.isExpanded()) {\n                row.rowCls = (row.rowCls || '') + ' ' + this.expandedCls;\n            }\n            if (record.isLeaf()) {\n                row.rowCls = (row.rowCls || '') + ' ' + this.leafCls;\n            }\n            if (record.isLoading()) {\n                row.rowCls = (row.rowCls || '') + ' ' + this.loadingCls;\n            }\n        }\n\n        return data;\n    },\n\n    /**\n     * Expands a record that is loaded in the view.\n     * @param {Ext.data.Model} record The record to expand\n     * @param {Boolean} [deep] True to expand nodes all the way down the tree hierarchy.\n     * @param {Function} [callback] The function to run after the expand is completed\n     * @param {Object} [scope] The scope of the callback function.\n     */\n    expand: function(record, deep, callback, scope) {\n        return record.expand(deep, callback, scope);\n    },\n\n    /**\n     * Collapses a record that is loaded in the view.\n     * @param {Ext.data.Model} record The record to collapse\n     * @param {Boolean} [deep] True to collapse nodes all the way up the tree hierarchy.\n     * @param {Function} [callback] The function to run after the collapse is completed\n     * @param {Object} [scope] The scope of the callback function.\n     */\n    collapse: function(record, deep, callback, scope) {\n        return record.collapse(deep, callback, scope);\n    },\n\n    /**\n     * Toggles a record between expanded and collapsed.\n     * @param {Ext.data.Model} record\n     * @param {Boolean} [deep] True to collapse nodes all the way up the tree hierarchy.\n     * @param {Function} [callback] The function to run after the expand/collapse is completed\n     * @param {Object} [scope] The scope of the callback function.\n     */\n    toggle: function(record, deep, callback, scope) {\n        var me = this,\n            doAnimate = !!this.animate;\n\n        // Block toggling if we are already animating an expand or collapse operation.\n        if (!doAnimate || !this.isExpandingOrCollapsing) {\n            if (!record.isLeaf()) {\n                this.isExpandingOrCollapsing = doAnimate;\n            }\n            if (record.isExpanded()) {\n                me.collapse(record, deep, callback, scope);\n            } else {\n                me.expand(record, deep, callback, scope);\n            }\n        }\n    },\n\n    onItemDblClick: function(record, item, index) {\n        var me = this,\n            editingPlugin = me.editingPlugin;\n            \n        me.callParent(arguments);\n        if (me.toggleOnDblClick && record.isExpandable() && !(editingPlugin && editingPlugin.clicksToEdit === 2)) {\n            me.toggle(record);\n        }\n    },\n\n    onBeforeItemMouseDown: function(record, item, index, e) {\n        if (e.getTarget(this.expanderSelector, item)) {\n            return false;\n        }\n        return this.callParent(arguments);\n    },\n\n    onItemClick: function(record, item, index, e) {\n        if (e.getTarget(this.expanderSelector, item) && record.isExpandable()) {\n            this.toggle(record, e.ctrlKey);\n            return false;\n        }\n        return this.callParent(arguments);\n    },\n\n    onExpanderMouseOver: function(e, t) {\n        e.getTarget(this.cellSelector, 10, true).addCls(this.expanderIconOverCls);\n    },\n\n    onExpanderMouseOut: function(e, t) {\n        e.getTarget(this.cellSelector, 10, true).removeCls(this.expanderIconOverCls);\n    },\n\n    /**\n     * Gets the base TreeStore from the bound TreePanel.\n     */\n    getTreeStore: function() {\n        return this.panel.store;\n    },    \n\n    ensureSingleExpand: function(node) {\n        var parent = node.parentNode;\n        if (parent) {\n            parent.eachChild(function(child) {\n                if (child !== node && child.isExpanded()) {\n                    child.collapse();\n                }\n            });\n        }\n    },\n\n    shouldUpdateCell: function(column, changedFieldNames){\n        if (changedFieldNames) {\n            var i = 0,\n                len = changedFieldNames.length;\n                \n            for (; i < len; ++i) {\n                if (Ext.Array.contains(this.uiFields, changedFieldNames[i])) {\n                    return true;\n                }\n            }\n        }\n        return this.callParent(arguments);\n    },\n\n    /**\n     * Re-fires the NodeStore's \"write\" event as a TreeStore event\n     * @private\n     * @param {Ext.data.NodeStore} store\n     * @param {Ext.data.Operation} operation\n     */\n    onStoreWrite: function(store, operation) {\n        var treeStore = this.panel.store;\n        treeStore.fireEvent('write', treeStore, operation);\n    },\n\n    /**\n     * Re-fires the NodeStore's \"datachanged\" event as a TreeStore event\n     * @private\n     * @param {Ext.data.NodeStore} store\n     * @param {Ext.data.Operation} operation\n     */\n    onStoreDataChanged: function(store, operation) {\n        var treeStore = this.panel.store;\n        treeStore.fireEvent('datachanged', treeStore);\n    }\n});\n\n/**\n * The TreePanel provides tree-structured UI representation of tree-structured data.\n * A TreePanel must be bound to a {@link Ext.data.TreeStore}. TreePanel's support\n * multiple columns through the {@link #columns} configuration.\n *\n * Simple TreePanel using inline data:\n *\n *     @example\n *     var store = Ext.create('Ext.data.TreeStore', {\n *         root: {\n *             expanded: true,\n *             children: [\n *                 { text: \"detention\", leaf: true },\n *                 { text: \"homework\", expanded: true, children: [\n *                     { text: \"book report\", leaf: true },\n *                     { text: \"alegrbra\", leaf: true}\n *                 ] },\n *                 { text: \"buy lottery tickets\", leaf: true }\n *             ]\n *         }\n *     });\n *\n *     Ext.create('Ext.tree.Panel', {\n *         title: 'Simple Tree',\n *         width: 200,\n *         height: 150,\n *         store: store,\n *         rootVisible: false,\n *         renderTo: Ext.getBody()\n *     });\n *\n * For the tree node config options (like `text`, `leaf`, `expanded`), see the documentation of\n * {@link Ext.data.NodeInterface NodeInterface} config options.\n */\nExt.define('Ext.tree.Panel', {\n    extend: 'Ext.panel.Table',\n    alias: 'widget.treepanel',\n    alternateClassName: ['Ext.tree.TreePanel', 'Ext.TreePanel'],\n    requires: ['Ext.tree.View', 'Ext.selection.TreeModel', 'Ext.tree.Column', 'Ext.data.TreeStore'],\n    viewType: 'treeview',\n    selType: 'treemodel',\n\n    treeCls: Ext.baseCSSPrefix + 'tree-panel',\n\n    deferRowRender: false,\n\n    /**\n     * @cfg {Boolean} rowLines\n     * False so that rows are not separated by lines.\n     */\n    rowLines: false,\n\n    /**\n     * @cfg {Boolean} lines\n     * False to disable tree lines.\n     */\n    lines: true,\n\n    /**\n     * @cfg {Boolean} useArrows\n     * True to use Vista-style arrows in the tree.\n     */\n    useArrows: false,\n\n    /**\n     * @cfg {Boolean} singleExpand\n     * True if only 1 node per branch may be expanded.\n     */\n    singleExpand: false,\n\n    ddConfig: {\n        enableDrag: true,\n        enableDrop: true\n    },\n\n    /**\n     * @cfg {Boolean} animate\n     * True to enable animated expand/collapse. Defaults to the value of {@link Ext#enableFx}.\n     */\n\n    /**\n     * @cfg {Boolean} rootVisible\n     * False to hide the root node.\n     */\n    rootVisible: true,\n\n    /**\n     * @cfg {String} displayField\n     * The field inside the model that will be used as the node's text.\n     */\n    displayField: 'text',\n\n    /**\n     * @cfg {Ext.data.Model/Ext.data.NodeInterface/Object} root\n     * Allows you to not specify a store on this TreePanel. This is useful for creating a simple tree with preloaded\n     * data without having to specify a TreeStore and Model. A store and model will be created and root will be passed\n     * to that store. For example:\n     *\n     *     Ext.create('Ext.tree.Panel', {\n     *         title: 'Simple Tree',\n     *         root: {\n     *             text: \"Root node\",\n     *             expanded: true,\n     *             children: [\n     *                 { text: \"Child 1\", leaf: true },\n     *                 { text: \"Child 2\", leaf: true }\n     *             ]\n     *         },\n     *         renderTo: Ext.getBody()\n     *     });\n     */\n    root: null,\n\n    // Required for the Lockable Mixin. These are the configurations which will be copied to the\n    // normal and locked sub tablepanels\n    normalCfgCopy: ['displayField', 'root', 'singleExpand', 'useArrows', 'lines', 'rootVisible', 'scroll'],\n    lockedCfgCopy: ['displayField', 'root', 'singleExpand', 'useArrows', 'lines', 'rootVisible'],\n    \n    isTree: true,\n\n    /**\n     * @cfg {Boolean} hideHeaders\n     * True to hide the headers.\n     */\n\n    /**\n     * @cfg {Boolean} folderSort\n     * True to automatically prepend a leaf sorter to the store.\n     */\n     \n    /**\n     * @cfg {Ext.data.TreeStore} store (required)\n     * The {@link Ext.data.TreeStore Store} the tree should use as its data source.\n     */\n\n    constructor: function(config) {\n        config = config || {};\n        if (config.animate === undefined) {\n            config.animate = Ext.isDefined(this.animate) ? this.animate : Ext.enableFx;\n        }\n        this.enableAnimations = config.animate;\n        delete config.animate;\n\n        this.callParent([config]);\n    },\n\n    initComponent: function() {\n        var me = this,\n            cls = [me.treeCls],\n            view;\n\n        if (me.useArrows) {\n            cls.push(Ext.baseCSSPrefix + 'tree-arrows');\n            me.lines = false;\n        }\n\n        if (me.lines) {\n            cls.push(Ext.baseCSSPrefix + 'tree-lines');\n        } else if (!me.useArrows) {\n            cls.push(Ext.baseCSSPrefix + 'tree-no-lines');\n        }\n\n        if (Ext.isString(me.store)) {\n            me.store = Ext.StoreMgr.lookup(me.store);\n        } else if (!me.store || Ext.isObject(me.store) && !me.store.isStore) {\n            me.store = new Ext.data.TreeStore(Ext.apply({}, me.store || {}, {\n                root: me.root,\n                fields: me.fields,\n                model: me.model,\n                folderSort: me.folderSort\n            }));\n        } else if (me.root) {\n            me.store = Ext.data.StoreManager.lookup(me.store);\n            me.store.setRootNode(me.root);\n            if (me.folderSort !== undefined) {\n                me.store.folderSort = me.folderSort;\n                me.store.sort();\n            }\n        }\n\n        // I'm not sure if we want to this. It might be confusing\n        // if (me.initialConfig.rootVisible === undefined && !me.getRootNode()) {\n        //     me.rootVisible = false;\n        // }\n\n        me.viewConfig = Ext.apply({}, me.viewConfig);\n        me.viewConfig = Ext.applyIf(me.viewConfig, {\n            rootVisible: me.rootVisible,\n            animate: me.enableAnimations,\n            singleExpand: me.singleExpand,\n            node: me.store.getRootNode(),\n            hideHeaders: me.hideHeaders\n        });\n\n        me.mon(me.store, {\n            scope: me,\n            rootchange: me.onRootChange,\n            clear: me.onClear\n        });\n\n        me.relayEvents(me.store, [\n            /**\n             * @event beforeload\n             * @inheritdoc Ext.data.TreeStore#beforeload\n             */\n            'beforeload',\n\n            /**\n             * @event load\n             * @inheritdoc Ext.data.TreeStore#load\n             */\n            'load'\n        ]);\n\n        me.mon(me.store, {\n            /**\n             * @event itemappend\n             * @inheritdoc Ext.data.TreeStore#append\n             */\n            append: me.createRelayer('itemappend'),\n\n            /**\n             * @event itemremove\n             * @inheritdoc Ext.data.TreeStore#remove\n             */\n            remove: me.createRelayer('itemremove'),\n\n            /**\n             * @event itemmove\n             * @inheritdoc Ext.data.TreeStore#move\n             */\n            move: me.createRelayer('itemmove', [0, 4]),\n\n            /**\n             * @event iteminsert\n             * @inheritdoc Ext.data.TreeStore#insert\n             */\n            insert: me.createRelayer('iteminsert'),\n\n            /**\n             * @event beforeitemappend\n             * @inheritdoc Ext.data.TreeStore#beforeappend\n             */\n            beforeappend: me.createRelayer('beforeitemappend'),\n\n            /**\n             * @event beforeitemremove\n             * @inheritdoc Ext.data.TreeStore#beforeremove\n             */\n            beforeremove: me.createRelayer('beforeitemremove'),\n\n            /**\n             * @event beforeitemmove\n             * @inheritdoc Ext.data.TreeStore#beforemove\n             */\n            beforemove: me.createRelayer('beforeitemmove'),\n\n            /**\n             * @event beforeiteminsert\n             * @inheritdoc Ext.data.TreeStore#beforeinsert\n             */\n            beforeinsert: me.createRelayer('beforeiteminsert'),\n\n            /**\n             * @event itemexpand\n             * @inheritdoc Ext.data.TreeStore#expand\n             */\n            expand: me.createRelayer('itemexpand', [0, 1]),\n\n            /**\n             * @event itemcollapse\n             * @inheritdoc Ext.data.TreeStore#collapse\n             */\n            collapse: me.createRelayer('itemcollapse', [0, 1]),\n\n            /**\n             * @event beforeitemexpand\n             * @inheritdoc Ext.data.TreeStore#beforeexpand\n             */\n            beforeexpand: me.createRelayer('beforeitemexpand', [0, 1]),\n\n            /**\n             * @event beforeitemcollapse\n             * @inheritdoc Ext.data.TreeStore#beforecollapse\n             */\n            beforecollapse: me.createRelayer('beforeitemcollapse', [0, 1])\n        });\n\n        // If the user specifies the headers collection manually then dont inject our own\n        if (!me.columns) {\n            if (me.initialConfig.hideHeaders === undefined) {\n                me.hideHeaders = true;\n            }\n            me.addCls(Ext.baseCSSPrefix + 'autowidth-table');\n            me.columns = [{\n                xtype    : 'treecolumn',\n                text     : 'Name',\n                width    : Ext.isIE6 ? null : 10000,\n                dataIndex: me.displayField         \n            }];\n        }\n\n        if (me.cls) {\n            cls.push(me.cls);\n        }\n        me.cls = cls.join(' ');\n        me.callParent();\n        \n        view = me.getView();\n\n        me.relayEvents(view, [\n            /**\n             * @event checkchange\n             * Fires when a node with a checkbox's checked property changes\n             * @param {Ext.data.NodeInterface} node The node who's checked property was changed\n             * @param {Boolean} checked The node's new checked state\n             */\n            'checkchange',\n            /**\n             * @event afteritemexpand\n             * @inheritdoc Ext.tree.View#afteritemexpand\n             */\n            'afteritemexpand',\n            /**\n             * @event afteritemcollapse\n             * @inheritdoc Ext.tree.View#afteritemcollapse\n             */\n            'afteritemcollapse'\n        ]);\n\n        // If the root is not visible and there is no rootnode defined, then just lets load the store\n        if (!view.rootVisible && !me.getRootNode()) {\n            me.setRootNode({\n                expanded: true\n            });\n        }\n    },\n    \n    onClear: function(){\n        this.view.onClear();\n    },\n\n    /**\n     * Sets root node of this tree.\n     * @param {Ext.data.Model/Ext.data.NodeInterface/Object} root\n     * @return {Ext.data.NodeInterface} The new root\n     */\n    setRootNode: function() {\n        return this.store.setRootNode.apply(this.store, arguments);\n    },\n\n    /**\n     * Returns the root node for this tree.\n     * @return {Ext.data.NodeInterface}\n     */\n    getRootNode: function() {\n        return this.store.getRootNode();\n    },\n\n    onRootChange: function(root) {\n        this.view.setRootNode(root);\n    },\n\n    /**\n     * Retrieve an array of checked records.\n     * @return {Ext.data.NodeInterface[]} An array containing the checked records\n     */\n    getChecked: function() {\n        return this.getView().getChecked();\n    },\n\n    isItemChecked: function(rec) {\n        return rec.get('checked');\n    },\n    \n    /**\n     * Expands a record that is loaded in the tree.\n     * @param {Ext.data.Model} record The record to expand\n     * @param {Boolean} [deep] True to expand nodes all the way down the tree hierarchy.\n     * @param {Function} [callback] The function to run after the expand is completed\n     * @param {Object} [scope] The scope of the callback function.\n     */\n    expandNode: function(record, deep, callback, scope) {\n        return this.getView().expand(record, deep, callback, scope || this);\n    },\n\n    /**\n     * Collapses a record that is loaded in the tree.\n     * @param {Ext.data.Model} record The record to collapse\n     * @param {Boolean} [deep] True to collapse nodes all the way up the tree hierarchy.\n     * @param {Function} [callback] The function to run after the collapse is completed\n     * @param {Object} [scope] The scope of the callback function.\n     */\n    collapseNode: function(record, deep, callback, scope) {\n        return this.getView().collapse(record, deep, callback, scope || this);\n    },\n\n    /**\n     * Expand all nodes\n     * @param {Function} [callback] A function to execute when the expand finishes.\n     * @param {Object} [scope] The scope of the callback function\n     */\n    expandAll : function(callback, scope) {\n        var me = this,\n            root = me.getRootNode(),\n            animate = me.enableAnimations,\n            view = me.getView();\n        if (root) {\n            if (!animate) {\n                view.beginBulkUpdate();\n            }\n            root.expand(true, callback, scope || me);\n            if (!animate) {\n                view.endBulkUpdate();\n            }\n        }\n    },\n\n    /**\n     * Collapse all nodes\n     * @param {Function} [callback] A function to execute when the collapse finishes.\n     * @param {Object} [scope] The scope of the callback function\n     */\n    collapseAll : function(callback, scope) {\n        var me = this,\n            root = me.getRootNode(),\n            animate = me.enableAnimations,\n            view = me.getView();\n\n        if (root) {\n            if (!animate) {\n                view.beginBulkUpdate();\n            }\n            scope = scope || me;\n            if (view.rootVisible) {\n                root.collapse(true, callback, scope);\n            } else {\n                root.collapseChildren(true, callback, scope);\n            }\n            if (!animate) {\n                view.endBulkUpdate();\n            }\n        }\n    },\n\n    /**\n     * Expand the tree to the path of a particular node.\n     * @param {String} path The path to expand. The path should include a leading separator.\n     * @param {String} [field] The field to get the data from. Defaults to the model idProperty.\n     * @param {String} [separator='/'] A separator to use.\n     * @param {Function} [callback] A function to execute when the expand finishes. The callback will be called with\n     * (success, lastNode) where success is if the expand was successful and lastNode is the last node that was expanded.\n     * @param {Object} [scope] The scope of the callback function\n     */\n    expandPath: function(path, field, separator, callback, scope) {\n        var me = this,\n            current = me.getRootNode(),\n            index = 1,\n            view = me.getView(),\n            keys,\n            expander;\n\n        field = field || me.getRootNode().idProperty;\n        separator = separator || '/';\n\n        if (Ext.isEmpty(path)) {\n            Ext.callback(callback, scope || me, [false, null]);\n            return;\n        }\n\n        keys = path.split(separator);\n        if (current.get(field) != keys[1]) {\n            // invalid root\n            Ext.callback(callback, scope || me, [false, current]);\n            return;\n        }\n\n        expander = function(){\n            if (++index === keys.length) {\n                Ext.callback(callback, scope || me, [true, current]);\n                return;\n            }\n            var node = current.findChild(field, keys[index]);\n            if (!node) {\n                Ext.callback(callback, scope || me, [false, current]);\n                return;\n            }\n            current = node;\n            current.expand(false, expander);\n        };\n        current.expand(false, expander);\n    },\n\n    /**\n     * Expand the tree to the path of a particular node, then select it.\n     * @param {String} path The path to select. The path should include a leading separator.\n     * @param {String} [field] The field to get the data from. Defaults to the model idProperty.\n     * @param {String} [separator='/'] A separator to use.\n     * @param {Function} [callback] A function to execute when the select finishes. The callback will be called with\n     * (bSuccess, oLastNode) where bSuccess is if the select was successful and oLastNode is the last node that was expanded.\n     * @param {Object} [scope] The scope of the callback function\n     */\n    selectPath: function(path, field, separator, callback, scope) {\n        var me = this,\n            root,\n            keys,\n            last;\n\n        field = field || me.getRootNode().idProperty;\n        separator = separator || '/';\n\n        keys = path.split(separator);\n        last = keys.pop();\n        if (keys.length > 1) {\n            me.expandPath(keys.join(separator), field, separator, function(success, node){\n                var lastNode = node;\n                if (success && node) {\n                    node = node.findChild(field, last);\n                    if (node) {\n                        me.getSelectionModel().select(node);\n                        Ext.callback(callback, scope || me, [true, node]);\n                        return;\n                    }\n                }\n                Ext.callback(callback, scope || me, [false, lastNode]);\n            }, me);\n        } else {\n            root = me.getRootNode();\n            if (root.getId() === last) {\n                me.getSelectionModel().select(root);\n                Ext.callback(callback, scope || me, [true, root]);\n            } else {\n                Ext.callback(callback, scope || me, [false, null]);\n            }\n        }\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.view.DragZone', {\n    extend: 'Ext.dd.DragZone',\n    containerScroll: false,\n\n    constructor: function(config) {\n        var me = this,\n            view,\n            ownerCt,\n            el;\n\n        Ext.apply(me, config);\n\n        // Create a ddGroup unless one has been configured.\n        // User configuration of ddGroups allows users to specify which\n        // DD instances can interact with each other. Using one\n        // based on the id of the View would isolate it and mean it can only\n        // interact with a DropZone on the same View also using a generated ID.\n        if (!me.ddGroup) {\n            me.ddGroup = 'view-dd-zone-' + me.view.id;\n        }\n\n        // Ext.dd.DragDrop instances are keyed by the ID of their encapsulating element.\n        // So a View's DragZone cannot use the View's main element because the DropZone must use that\n        // because the DropZone may need to scroll on hover at a scrolling boundary, and it is the View's\n        // main element which handles scrolling.\n        // We use the View's parent element to drag from. Ideally, we would use the internal structure, but that\n        // is transient; DataView's recreate the internal structure dynamically as data changes.\n        // TODO: Ext 5.0 DragDrop must allow multiple DD objects to share the same element.\n        view = me.view;\n        ownerCt = view.ownerCt;\n        // We don't just grab the parent el, since the parent el may be\n        // some el injected by the layout\n        if (ownerCt) {\n            el = ownerCt.getTargetEl().dom;\n        } else {\n            el = view.el.dom.parentNode;\n        }\n        me.callParent([el]);\n\n        me.ddel = Ext.get(document.createElement('div'));\n        me.ddel.addCls(Ext.baseCSSPrefix + 'grid-dd-wrap');\n    },\n\n    init: function(id, sGroup, config) {\n        this.initTarget(id, sGroup, config);\n        this.view.mon(this.view, {\n            itemmousedown: this.onItemMouseDown,\n            scope: this\n        });\n    },\n\n    onValidDrop: function(target, e, id) {\n        this.callParent();\n        // focus the view that the node was dropped onto so that keynav will be enabled.\n        target.el.focus();\n    },\n    \n    onItemMouseDown: function(view, record, item, index, e) {\n        if (!this.isPreventDrag(e, record, item, index)) {\n            // Since handleMouseDown prevents the default behavior of the event, which\n            // is to focus the view, we focus the view now.  This ensures that the view\n            // remains focused if the drag is cancelled, or if no drag occurs.\n            this.view.focus();\n            this.handleMouseDown(e);\n\n            // If we want to allow dragging of multi-selections, then veto the following handlers (which, in the absence of ctrlKey, would deselect)\n            // if the mousedowned record is selected\n            if (view.getSelectionModel().selectionMode == 'MULTI' && !e.ctrlKey && view.getSelectionModel().isSelected(record)) {\n                return false;\n            }\n        }\n    },\n\n    // private template method\n    isPreventDrag: function(e) {\n        return false;\n    },\n\n    getDragData: function(e) {\n        var view = this.view,\n            item = e.getTarget(view.getItemSelector());\n\n        if (item) {\n            return {\n                copy: view.copy || (view.allowCopy && e.ctrlKey),\n                event: new Ext.EventObjectImpl(e),\n                view: view,\n                ddel: this.ddel,\n                item: item,\n                records: view.getSelectionModel().getSelection(),\n                fromPosition: Ext.fly(item).getXY()\n            };\n        }\n    },\n\n    onInitDrag: function(x, y) {\n        var me = this,\n            data = me.dragData,\n            view = data.view,\n            selectionModel = view.getSelectionModel(),\n            record = view.getRecord(data.item),\n            e = data.event;\n\n        // Update the selection to match what would have been selected if the user had\n        // done a full click on the target node rather than starting a drag from it\n        if (!selectionModel.isSelected(record)) {\n            selectionModel.select(record, true);\n        }\n        data.records = selectionModel.getSelection();\n\n        me.ddel.update(me.getDragText());\n        me.proxy.update(me.ddel.dom);\n        me.onStartDrag(x, y);\n        return true;\n    },\n\n    getDragText: function() {\n        var count = this.dragData.records.length;\n        return Ext.String.format(this.dragText, count, count == 1 ? '' : 's');\n    },\n\n    getRepairXY : function(e, data){\n        return data ? data.fromPosition : false;\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.tree.ViewDragZone', {\n    extend: 'Ext.view.DragZone',\n\n    isPreventDrag: function(e, record) {\n        return (record.get('allowDrag') === false) || !!e.getTarget(this.view.expanderSelector);\n    },\n    \n    afterRepair: function() {\n        var me = this,\n            view = me.view,\n            selectedRowCls = view.selectedItemCls,\n            records = me.dragData.records,\n            r,\n            rLen    = records.length,\n            fly = Ext.fly,\n            item;\n        \n        if (Ext.enableFx && me.repairHighlight) {\n            // Roll through all records and highlight all the ones we attempted to drag.\n            for (r = 0; r < rLen; r++) {\n                // anonymous fns below, don't hoist up unless below is wrapped in\n                // a self-executing function passing in item.\n                item = view.getNode(records[r]);\n\n                // We must remove the selected row class before animating, because\n                // the selected row class declares !important on its background-color.\n                fly(item.firstChild).highlight(me.repairHighlightColor, {\n                    listeners: {\n                        beforeanimate: function() {\n                            if (view.isSelected(item)) {\n                                fly(item).removeCls(selectedRowCls);\n                            }\n                        },\n                        afteranimate: function() {\n                            if (view.isSelected(item)) {\n                                fly(item).addCls(selectedRowCls);\n                            }\n                        }\n                    }\n                });\n            }\n\n        }\n        me.dragging = false;\n    }\n});\n\n/**\n * @private\n */\nExt.define('Ext.tree.ViewDropZone', {\n    extend: 'Ext.view.DropZone',\n\n    /**\n     * @cfg {Boolean} allowParentInsert\n     * Allow inserting a dragged node between an expanded parent node and its first child that will become a\n     * sibling of the parent when dropped.\n     */\n    allowParentInserts: false,\n \n    /**\n     * @cfg {String} allowContainerDrop\n     * True if drops on the tree container (outside of a specific tree node) are allowed.\n     */\n    allowContainerDrops: false,\n\n    /**\n     * @cfg {String} appendOnly\n     * True if the tree should only allow append drops (use for trees which are sorted).\n     */\n    appendOnly: false,\n\n    /**\n     * @cfg {String} expandDelay\n     * The delay in milliseconds to wait before expanding a target tree node while dragging a droppable node\n     * over the target.\n     */\n    expandDelay : 500,\n\n    indicatorCls: Ext.baseCSSPrefix + 'tree-ddindicator',\n\n    // private\n    expandNode : function(node) {\n        var view = this.view;\n        if (!node.isLeaf() && !node.isExpanded()) {\n            view.expand(node);\n            this.expandProcId = false;\n        }\n    },\n\n    // private\n    queueExpand : function(node) {\n        this.expandProcId = Ext.Function.defer(this.expandNode, this.expandDelay, this, [node]);\n    },\n\n    // private\n    cancelExpand : function() {\n        if (this.expandProcId) {\n            clearTimeout(this.expandProcId);\n            this.expandProcId = false;\n        }\n    },\n\n    getPosition: function(e, node) {\n        var view = this.view,\n            record = view.getRecord(node),\n            y = e.getPageY(),\n            noAppend = record.isLeaf(),\n            noBelow = false,\n            region = Ext.fly(node).getRegion(),\n            fragment;\n\n        // If we are dragging on top of the root node of the tree, we always want to append.\n        if (record.isRoot()) {\n            return 'append';\n        }\n\n        // Return 'append' if the node we are dragging on top of is not a leaf else return false.\n        if (this.appendOnly) {\n            return noAppend ? false : 'append';\n        }\n\n        if (!this.allowParentInsert) {\n            noBelow = record.hasChildNodes() && record.isExpanded();\n        }\n\n        fragment = (region.bottom - region.top) / (noAppend ? 2 : 3);\n        if (y >= region.top && y < (region.top + fragment)) {\n            return 'before';\n        }\n        else if (!noBelow && (noAppend || (y >= (region.bottom - fragment) && y <= region.bottom))) {\n            return 'after';\n        }\n        else {\n            return 'append';\n        }\n    },\n\n    isValidDropPoint : function(node, position, dragZone, e, data) {\n        if (!node || !data.item) {\n            return false;\n        }\n\n        var view = this.view,\n            targetNode = view.getRecord(node),\n            draggedRecords = data.records,\n            dataLength = draggedRecords.length,\n            ln = draggedRecords.length,\n            i, record;\n\n        // No drop position, or dragged records: invalid drop point\n        if (!(targetNode && position && dataLength)) {\n            return false;\n        }\n\n        // If the targetNode is within the folder we are dragging\n        for (i = 0; i < ln; i++) {\n            record = draggedRecords[i];\n            if (record.isNode && record.contains(targetNode)) {\n                return false;\n            }\n        }\n        \n        // Respect the allowDrop field on Tree nodes\n        if (position === 'append' && targetNode.get('allowDrop') === false) {\n            return false;\n        }\n        else if (position != 'append' && targetNode.parentNode.get('allowDrop') === false) {\n            return false;\n        }\n\n        // If the target record is in the dragged dataset, then invalid drop\n        if (Ext.Array.contains(draggedRecords, targetNode)) {\n             return false;\n        }\n\n        // @TODO: fire some event to notify that there is a valid drop possible for the node you're dragging\n        // Yes: this.fireViewEvent(blah....) fires an event through the owning View.\n        return true;\n    },\n\n    onNodeOver : function(node, dragZone, e, data) {\n        var position = this.getPosition(e, node),\n            returnCls = this.dropNotAllowed,\n            view = this.view,\n            targetNode = view.getRecord(node),\n            indicator = this.getIndicator(),\n            indicatorX = 0,\n            indicatorY = 0;\n\n        // auto node expand check\n        this.cancelExpand();\n        if (position == 'append' && !this.expandProcId && !Ext.Array.contains(data.records, targetNode) && !targetNode.isLeaf() && !targetNode.isExpanded()) {\n            this.queueExpand(targetNode);\n        }\n            \n            \n        if (this.isValidDropPoint(node, position, dragZone, e, data)) {\n            this.valid = true;\n            this.currentPosition = position;\n            this.overRecord = targetNode;\n\n            indicator.setWidth(Ext.fly(node).getWidth());\n            indicatorY = Ext.fly(node).getY() - Ext.fly(view.el).getY() - 1;\n\n            /*\n             * In the code below we show the proxy again. The reason for doing this is showing the indicator will\n             * call toFront, causing it to get a new z-index which can sometimes push the proxy behind it. We always \n             * want the proxy to be above, so calling show on the proxy will call toFront and bring it forward.\n             */\n            if (position == 'before') {\n                returnCls = targetNode.isFirst() ? Ext.baseCSSPrefix + 'tree-drop-ok-above' : Ext.baseCSSPrefix + 'tree-drop-ok-between';\n                indicator.showAt(0, indicatorY);\n                dragZone.proxy.show();\n            } else if (position == 'after') {\n                returnCls = targetNode.isLast() ? Ext.baseCSSPrefix + 'tree-drop-ok-below' : Ext.baseCSSPrefix + 'tree-drop-ok-between';\n                indicatorY += Ext.fly(node).getHeight();\n                indicator.showAt(0, indicatorY);\n                dragZone.proxy.show();\n            } else {\n                returnCls = Ext.baseCSSPrefix + 'tree-drop-ok-append';\n                // @TODO: set a class on the parent folder node to be able to style it\n                indicator.hide();\n            }\n        } else {\n            this.valid = false;\n        }\n\n        this.currentCls = returnCls;\n        return returnCls;\n    },\n\n    onContainerOver : function(dd, e, data) {\n        return e.getTarget('.' + this.indicatorCls) ? this.currentCls : this.dropNotAllowed;\n    },\n    \n    notifyOut: function() {\n        this.callParent(arguments);\n        this.cancelExpand();\n    },\n\n    handleNodeDrop : function(data, targetNode, position) {\n        var me = this,\n            view = me.view,\n            parentNode = targetNode.parentNode,\n            store = view.getStore(),\n            recordDomNodes = [],\n            records, i, len,\n            insertionMethod, argList,\n            needTargetExpand,\n            transferData,\n            processDrop;\n\n        // If the copy flag is set, create a copy of the Models with the same IDs\n        if (data.copy) {\n            records = data.records;\n            data.records = [];\n            for (i = 0, len = records.length; i < len; i++) {\n                data.records.push(Ext.apply({}, records[i].data));\n            }\n        }\n\n        // Cancel any pending expand operation\n        me.cancelExpand();\n\n        // Grab a reference to the correct node insertion method.\n        // Create an arg list array intended for the apply method of the\n        // chosen node insertion method.\n        // Ensure the target object for the method is referenced by 'targetNode'\n        if (position == 'before') {\n            insertionMethod = parentNode.insertBefore;\n            argList = [null, targetNode];\n            targetNode = parentNode;\n        }\n        else if (position == 'after') {\n            if (targetNode.nextSibling) {\n                insertionMethod = parentNode.insertBefore;\n                argList = [null, targetNode.nextSibling];\n            }\n            else {\n                insertionMethod = parentNode.appendChild;\n                argList = [null];\n            }\n            targetNode = parentNode;\n        }\n        else {\n            if (!targetNode.isExpanded()) {\n                needTargetExpand = true;\n            }\n            insertionMethod = targetNode.appendChild;\n            argList = [null];\n        }\n\n        // A function to transfer the data into the destination tree\n        transferData = function() {\n            var node,\n                r, rLen, color, n;\n            for (i = 0, len = data.records.length; i < len; i++) {\n                argList[0] = data.records[i];\n                node = insertionMethod.apply(targetNode, argList);\n                \n                if (Ext.enableFx && me.dropHighlight) {\n                    recordDomNodes.push(view.getNode(node));\n                }\n            }\n            \n            // Kick off highlights after everything's been inserted, so they are\n            // more in sync without insertion/render overhead.\n            if (Ext.enableFx && me.dropHighlight) {\n                //FIXME: the check for n.firstChild is not a great solution here. Ideally the line should simply read \n                //Ext.fly(n.firstChild) but this yields errors in IE6 and 7. See ticket EXTJSIV-1705 for more details\n                rLen  = recordDomNodes.length;\n                color = me.dropHighlightColor;\n\n                for (r = 0; r < rLen; r++) {\n                    n = recordDomNodes[r];\n\n                    if (n) {\n                        Ext.fly(n.firstChild ? n.firstChild : n).highlight(color);\n                    }\n                }\n            }\n        };\n\n        // If dropping right on an unexpanded node, transfer the data after it is expanded.\n        if (needTargetExpand) {\n            targetNode.expand(false, transferData);\n        }\n        // Otherwise, call the data transfer function immediately\n        else {\n            transferData();\n        }\n    }\n});\n\n/**\n * This plugin provides drag and/or drop functionality for a TreeView.\n *\n * It creates a specialized instance of {@link Ext.dd.DragZone DragZone} which knows how to drag out of a\n * {@link Ext.tree.View TreeView} and loads the data object which is passed to a cooperating\n * {@link Ext.dd.DragZone DragZone}'s methods with the following properties:\n *\n *   - copy : Boolean\n *\n *     The value of the TreeView's `copy` property, or `true` if the TreeView was configured with `allowCopy: true` *and*\n *     the control key was pressed when the drag operation was begun.\n *\n *   - view : TreeView\n *\n *     The source TreeView from which the drag originated.\n *\n *   - ddel : HtmlElement\n *\n *     The drag proxy element which moves with the mouse\n *\n *   - item : HtmlElement\n *\n *     The TreeView node upon which the mousedown event was registered.\n *\n *   - records : Array\n *\n *     An Array of {@link Ext.data.Model Models} representing the selected data being dragged from the source TreeView.\n *\n * It also creates a specialized instance of {@link Ext.dd.DropZone} which cooperates with other DropZones which are\n * members of the same ddGroup which processes such data objects.\n *\n * Adding this plugin to a view means that two new events may be fired from the client TreeView, {@link #beforedrop} and\n * {@link #drop}.\n *\n * Note that the plugin must be added to the tree view, not to the tree panel. For example using viewConfig:\n *\n *     viewConfig: {\n *         plugins: { ptype: 'treeviewdragdrop' }\n *     }\n */\nExt.define('Ext.tree.plugin.TreeViewDragDrop', {\n    extend: 'Ext.AbstractPlugin',\n    alias: 'plugin.treeviewdragdrop',\n\n    uses: [\n        'Ext.tree.ViewDragZone',\n        'Ext.tree.ViewDropZone'\n    ],\n\n    /**\n     * @event beforedrop\n     *\n     * **This event is fired through the TreeView. Add listeners to the TreeView object**\n     *\n     * Fired when a drop gesture has been triggered by a mouseup event in a valid drop position in the TreeView.\n     *\n     * @param {HTMLElement} node The TreeView node **if any** over which the mouse was positioned.\n     *\n     * Returning `false` to this event signals that the drop gesture was invalid, and if the drag proxy will animate\n     * back to the point from which the drag began.\n     *\n     * Returning `0` To this event signals that the data transfer operation should not take place, but that the gesture\n     * was valid, and that the repair operation should not take place.\n     *\n     * Any other return value continues with the data transfer operation.\n     *\n     * @param {Object} data The data object gathered at mousedown time by the cooperating\n     * {@link Ext.dd.DragZone DragZone}'s {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following\n     * properties:\n     * @param {Boolean} data.copy The value of the TreeView's `copy` property, or `true` if the TreeView was configured with\n     * `allowCopy: true` and the control key was pressed when the drag operation was begun\n     * @param {Ext.tree.View} data.view The source TreeView from which the drag originated.\n     * @param {HTMLElement} data.ddel The drag proxy element which moves with the mouse\n     * @param {HTMLElement} data.item The TreeView node upon which the mousedown event was registered.\n     * @param {Ext.data.Model[]} data.records An Array of {@link Ext.data.Model Model}s representing the selected data being\n     * dragged from the source TreeView.\n     *\n     * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.\n     *\n     * @param {String} dropPosition `\"before\"`, `\"after\"` or `\"append\"` depending on whether the mouse is above or below\n     * the midline of the node, or the node is a branch node which accepts new child nodes.\n     *\n     * @param {Object} dropHandler An object containing methods to complete/cancel the data transfer operation and either\n     * move or copy Model instances from the source View's Store to the destination View's Store.\n     *\n     * This is useful when you want to perform some kind of asynchronous processing before confirming/cancelling\n     * the drop, such as an {@link Ext.window.MessageBox#confirm confirm} call, or an Ajax request.\n     *\n     * Set dropHandler.wait = true in this event handler to delay processing. When you want to complete the event, call\n     * dropHandler.processDrop(). To cancel the drop, call dropHandler.cancelDrop.\n     */\n\n    /**\n     * @event drop\n     *\n     * **This event is fired through the TreeView. Add listeners to the TreeView object** Fired when a drop operation\n     * has been completed and the data has been moved or copied.\n     *\n     * @param {HTMLElement} node The TreeView node **if any** over which the mouse was positioned.\n     *\n     * @param {Object} data The data object gathered at mousedown time by the cooperating\n     * {@link Ext.dd.DragZone DragZone}'s {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following\n     * properties:\n     * @param {Boolean} data.copy The value of the TreeView's `copy` property, or `true` if the TreeView was configured with\n     * `allowCopy: true` and the control key was pressed when the drag operation was begun\n     * @param {Ext.tree.View} data.view The source TreeView from which the drag originated.\n     * @param {HTMLElement} data.ddel The drag proxy element which moves with the mouse\n     * @param {HTMLElement} data.item The TreeView node upon which the mousedown event was registered.\n     * @param {Ext.data.Model[]} data.records An Array of {@link Ext.data.Model Model}s representing the selected data being\n     * dragged from the source TreeView.\n     *\n     * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.\n     *\n     * @param {String} dropPosition `\"before\"`, `\"after\"` or `\"append\"` depending on whether the mouse is above or below\n     * the midline of the node, or the node is a branch node which accepts new child nodes.\n     */\n\n    //<locale>\n    /**\n     * @cfg\n     * The text to show while dragging.\n     *\n     * Two placeholders can be used in the text:\n     *\n     * - `{0}` The number of selected items.\n     * - `{1}` 's' when more than 1 items (only useful for English).\n     */\n    dragText : '{0} selected node{1}',\n    //</locale>\n\n    /**\n     * @cfg {Boolean} allowParentInserts\n     * Allow inserting a dragged node between an expanded parent node and its first child that will become a sibling of\n     * the parent when dropped.\n     */\n    allowParentInserts: false,\n\n    /**\n     * @cfg {Boolean} allowContainerDrops\n     * True if drops on the tree container (outside of a specific tree node) are allowed.\n     */\n    allowContainerDrops: false,\n\n    /**\n     * @cfg {Boolean} appendOnly\n     * True if the tree should only allow append drops (use for trees which are sorted).\n     */\n    appendOnly: false,\n\n    /**\n     * @cfg {String} ddGroup\n     * A named drag drop group to which this object belongs. If a group is specified, then both the DragZones and\n     * DropZone used by this plugin will only interact with other drag drop objects in the same group.\n     */\n    ddGroup : \"TreeDD\",\n\n    /**\n     * @cfg {String} dragGroup\n     * The ddGroup to which the DragZone will belong.\n     *\n     * This defines which other DropZones the DragZone will interact with. Drag/DropZones only interact with other\n     * Drag/DropZones which are members of the same ddGroup.\n     */\n\n    /**\n     * @cfg {String} dropGroup\n     * The ddGroup to which the DropZone will belong.\n     *\n     * This defines which other DragZones the DropZone will interact with. Drag/DropZones only interact with other\n     * Drag/DropZones which are members of the same ddGroup.\n     */\n\n    /**\n     * @cfg {String} expandDelay\n     * The delay in milliseconds to wait before expanding a target tree node while dragging a droppable node over the\n     * target.\n     */\n    expandDelay : 1000,\n\n    /**\n     * @cfg {Boolean} enableDrop\n     * Set to `false` to disallow the View from accepting drop gestures.\n     */\n    enableDrop: true,\n\n    /**\n     * @cfg {Boolean} enableDrag\n     * Set to `false` to disallow dragging items from the View.\n     */\n    enableDrag: true,\n\n    /**\n     * @cfg {String} nodeHighlightColor\n     * The color to use when visually highlighting the dragged or dropped node (default value is light blue).\n     * The color must be a 6 digit hex value, without a preceding '#'. See also {@link #nodeHighlightOnDrop} and\n     * {@link #nodeHighlightOnRepair}.\n     */\n    nodeHighlightColor: 'c3daf9',\n\n    /**\n     * @cfg {Boolean} nodeHighlightOnDrop\n     * Whether or not to highlight any nodes after they are\n     * successfully dropped on their target. Defaults to the value of `Ext.enableFx`.\n     * See also {@link #nodeHighlightColor} and {@link #nodeHighlightOnRepair}.\n     */\n    nodeHighlightOnDrop: Ext.enableFx,\n\n    /**\n     * @cfg {Boolean} nodeHighlightOnRepair\n     * Whether or not to highlight any nodes after they are\n     * repaired from an unsuccessful drag/drop. Defaults to the value of `Ext.enableFx`.\n     * See also {@link #nodeHighlightColor} and {@link #nodeHighlightOnDrop}.\n     */\n    nodeHighlightOnRepair: Ext.enableFx,\n\n    init : function(view) {\n        view.on('render', this.onViewRender, this, {single: true});\n    },\n\n    /**\n     * @private\n     * AbstractComponent calls destroy on all its plugins at destroy time.\n     */\n    destroy: function() {\n        Ext.destroy(this.dragZone, this.dropZone);\n    },\n\n    onViewRender : function(view) {\n        var me = this;\n\n        if (me.enableDrag) {\n            me.dragZone = new Ext.tree.ViewDragZone({\n                view: view,\n                ddGroup: me.dragGroup || me.ddGroup,\n                dragText: me.dragText,\n                repairHighlightColor: me.nodeHighlightColor,\n                repairHighlight: me.nodeHighlightOnRepair\n            });\n        }\n\n        if (me.enableDrop) {\n            me.dropZone = new Ext.tree.ViewDropZone({\n                view: view,\n                ddGroup: me.dropGroup || me.ddGroup,\n                allowContainerDrops: me.allowContainerDrops,\n                appendOnly: me.appendOnly,\n                allowParentInserts: me.allowParentInserts,\n                expandDelay: me.expandDelay,\n                dropHighlightColor: me.nodeHighlightColor,\n                dropHighlight: me.nodeHighlightOnDrop\n            });\n        }\n    }\n});\n\n/**\n * Utility class for manipulating CSS rules\n * @singleton\n */\nExt.define('Ext.util.CSS', (function() {\n    var rules = null,\n        doc = document,\n        camelRe = /(-[a-z])/gi,\n        camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };\n\n    return {\n\n        singleton: true,\n\n        constructor: function() {\n            this.rules = {};\n            this.initialized = false;\n        },\n\n        /**\n         * Creates a stylesheet from a text blob of rules.\n         * These rules will be wrapped in a STYLE tag and appended to the HEAD of the document.\n         * @param {String} cssText The text containing the css rules\n         * @param {String} id An id to add to the stylesheet for later removal\n         * @return {CSSStyleSheet}\n         */\n        createStyleSheet : function(cssText, id) {\n            var ss,\n                head = doc.getElementsByTagName(\"head\")[0],\n                styleEl = doc.createElement(\"style\");\n\n            styleEl.setAttribute(\"type\", \"text/css\");\n            if (id) {\n               styleEl.setAttribute(\"id\", id);\n            }\n\n            if (Ext.isIE) {\n               head.appendChild(styleEl);\n               ss = styleEl.styleSheet;\n               ss.cssText = cssText;\n            } else {\n                try{\n                    styleEl.appendChild(doc.createTextNode(cssText));\n                } catch(e) {\n                   styleEl.cssText = cssText;\n                }\n                head.appendChild(styleEl);\n                ss = styleEl.styleSheet ? styleEl.styleSheet : (styleEl.sheet || doc.styleSheets[doc.styleSheets.length-1]);\n            }\n            this.cacheStyleSheet(ss);\n            return ss;\n        },\n\n        /**\n         * Removes a style or link tag by id\n         * @param {String} id The id of the tag\n         */\n        removeStyleSheet : function(id) {\n            var existing = document.getElementById(id);\n            if (existing) {\n                existing.parentNode.removeChild(existing);\n            }\n        },\n\n        /**\n         * Dynamically swaps an existing stylesheet reference for a new one\n         * @param {String} id The id of an existing link tag to remove\n         * @param {String} url The href of the new stylesheet to include\n         */\n        swapStyleSheet : function(id, url) {\n            var doc = document,\n                ss;\n            this.removeStyleSheet(id);\n            ss = doc.createElement(\"link\");\n            ss.setAttribute(\"rel\", \"stylesheet\");\n            ss.setAttribute(\"type\", \"text/css\");\n            ss.setAttribute(\"id\", id);\n            ss.setAttribute(\"href\", url);\n            doc.getElementsByTagName(\"head\")[0].appendChild(ss);\n        },\n\n        /**\n         * Refresh the rule cache if you have dynamically added stylesheets\n         * @return {Object} An object (hash) of rules indexed by selector\n         */\n        refreshCache : function() {\n            return this.getRules(true);\n        },\n\n        // private\n        cacheStyleSheet : function(ss) {\n            if(!rules){\n                rules = {};\n            }\n            try {// try catch for cross domain access issue\n                var ssRules = ss.cssRules || ss.rules,\n                    selectorText,\n                    i = ssRules.length - 1,\n                    j,\n                    selectors;\n\n                for (; i >= 0; --i) {\n                    selectorText = ssRules[i].selectorText;\n                    if (selectorText) {\n\n                        // Split in case there are multiple, comma-delimited selectors\n                        selectorText = selectorText.split(',');\n                        selectors = selectorText.length;\n                        for (j = 0; j < selectors; j++) {\n                            rules[Ext.String.trim(selectorText[j]).toLowerCase()] = ssRules[i];\n                        }\n                    }\n                }\n            } catch(e) {}\n        },\n\n        /**\n         * Gets all css rules for the document\n         * @param {Boolean} refreshCache true to refresh the internal cache\n         * @return {Object} An object (hash) of rules indexed by selector\n         */\n        getRules : function(refreshCache) {\n            if (rules === null || refreshCache) {\n                rules = {};\n                var ds = doc.styleSheets,\n                    i = 0,\n                    len = ds.length;\n\n                for (; i < len; i++) {\n                    try {\n                        if (!ds[i].disabled) {\n                            this.cacheStyleSheet(ds[i]);\n                        }\n                    } catch(e) {}\n                }\n            }\n            return rules;\n        },\n\n        /**\n         * Gets an an individual CSS rule by selector(s)\n         * @param {String/String[]} selector The CSS selector or an array of selectors to try. The first selector that is found is returned.\n         * @param {Boolean} refreshCache true to refresh the internal cache if you have recently updated any rules or added styles dynamically\n         * @return {CSSStyleRule} The CSS rule or null if one is not found\n         */\n        getRule: function(selector, refreshCache) {\n            var rs = this.getRules(refreshCache),\n                i;\n            if (!Ext.isArray(selector)) {\n                return rs[selector.toLowerCase()];\n            }\n            for (i = 0; i < selector.length; i++) {\n                if (rs[selector[i]]) {\n                    return rs[selector[i].toLowerCase()];\n                }\n            }\n            return null;\n        },\n\n        /**\n         * Updates a rule property\n         * @param {String/String[]} selector If it's an array it tries each selector until it finds one. Stops immediately once one is found.\n         * @param {String} property The css property\n         * @param {String} value The new value for the property\n         * @return {Boolean} true If a rule was found and updated\n         */\n        updateRule : function(selector, property, value){\n            var rule, i;\n            if (!Ext.isArray(selector)) {\n                rule = this.getRule(selector);\n                if (rule) {\n                    rule.style[property.replace(camelRe, camelFn)] = value;\n                    return true;\n                }\n            } else {\n                for (i = 0; i < selector.length; i++) {\n                    if (this.updateRule(selector[i], property, value)) {\n                        return true;\n                    }\n                }\n            }\n            return false;\n        }\n    };\n}()));\n\n/**\n * Utility class for setting/reading values from browser cookies.\n * Values can be written using the {@link #set} method.\n * Values can be read using the {@link #get} method.\n * A cookie can be invalidated on the client machine using the {@link #clear} method.\n */\nExt.define('Ext.util.Cookies', {\n    singleton: true,\n    \n    /**\n     * Creates a cookie with the specified name and value. Additional settings for the cookie may be optionally specified\n     * (for example: expiration, access restriction, SSL).\n     * @param {String} name The name of the cookie to set.\n     * @param {Object} value The value to set for the cookie.\n     * @param {Object} [expires] Specify an expiration date the cookie is to persist until. Note that the specified Date\n     * object will be converted to Greenwich Mean Time (GMT).\n     * @param {String} [path] Setting a path on the cookie restricts access to pages that match that path. Defaults to all\n     * pages ('/').\n     * @param {String} [domain] Setting a domain restricts access to pages on a given domain (typically used to allow\n     * cookie access across subdomains). For example, \"sencha.com\" will create a cookie that can be accessed from any\n     * subdomain of sencha.com, including www.sencha.com, support.sencha.com, etc.\n     * @param {Boolean} [secure] Specify true to indicate that the cookie should only be accessible via SSL on a page\n     * using the HTTPS protocol. Defaults to false. Note that this will only work if the page calling this code uses the\n     * HTTPS protocol, otherwise the cookie will be created with default options.\n     */\n    set : function(name, value){\n        var argv = arguments,\n            argc = arguments.length,\n            expires = (argc > 2) ? argv[2] : null,\n            path = (argc > 3) ? argv[3] : '/',\n            domain = (argc > 4) ? argv[4] : null,\n            secure = (argc > 5) ? argv[5] : false;\n            \n        document.cookie = name + \"=\" + escape(value) + ((expires === null) ? \"\" : (\"; expires=\" + expires.toGMTString())) + ((path === null) ? \"\" : (\"; path=\" + path)) + ((domain === null) ? \"\" : (\"; domain=\" + domain)) + ((secure === true) ? \"; secure\" : \"\");\n    },\n\n    /**\n     * Retrieves cookies that are accessible by the current page. If a cookie does not exist, `get()` returns null. The\n     * following example retrieves the cookie called \"valid\" and stores the String value in the variable validStatus.\n     *\n     *     var validStatus = Ext.util.Cookies.get(\"valid\");\n     *\n     * @param {String} name The name of the cookie to get\n     * @return {Object} Returns the cookie value for the specified name;\n     * null if the cookie name does not exist.\n     */\n    get : function(name){\n        var arg = name + \"=\",\n            alen = arg.length,\n            clen = document.cookie.length,\n            i = 0,\n            j = 0;\n            \n        while(i < clen){\n            j = i + alen;\n            if(document.cookie.substring(i, j) == arg){\n                return this.getCookieVal(j);\n            }\n            i = document.cookie.indexOf(\" \", i) + 1;\n            if(i === 0){\n                break;\n            }\n        }\n        return null;\n    },\n\n    /**\n     * Removes a cookie with the provided name from the browser\n     * if found by setting its expiration date to sometime in the past.\n     * @param {String} name The name of the cookie to remove\n     * @param {String} [path] The path for the cookie.\n     * This must be included if you included a path while setting the cookie.\n     */\n    clear : function(name, path){\n        if(this.get(name)){\n            path = path || '/';\n            document.cookie = name + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT; path=' + path;\n        }\n    },\n    \n    /**\n     * @private\n     */\n    getCookieVal : function(offset){\n        var endstr = document.cookie.indexOf(\";\", offset);\n        if(endstr == -1){\n            endstr = document.cookie.length;\n        }\n        return unescape(document.cookie.substring(offset, endstr));\n    }\n});\n\n/**\n * @class Ext.util.Grouper\n\nRepresents a single grouper that can be applied to a Store. The grouper works\nin the same fashion as the {@link Ext.util.Sorter}.\n\n * @markdown\n */\n \nExt.define('Ext.util.Grouper', {\n\n    /* Begin Definitions */\n\n    extend: 'Ext.util.Sorter',\n\n    /* End Definitions */\n   \n   isGrouper: true,\n\n    /**\n     * Returns the value for grouping to be used.\n     * @param {Ext.data.Model} instance The Model instance\n     * @return {String} The group string for this model\n     */\n    getGroupString: function(instance) {\n        return instance.get(this.property);\n    }\n});\n\n/**\n * History management component that allows you to register arbitrary tokens that signify application\n * history state on navigation actions.  You can then handle the history {@link #change} event in order\n * to reset your application UI to the appropriate state when the user navigates forward or backward through\n * the browser history stack.\n *\n * ## Initializing\n *\n * The {@link #init} method of the History object must be called before using History. This sets up the internal\n * state and must be the first thing called before using History.\n */\nExt.define('Ext.util.History', {\n    singleton: true,\n    alternateClassName: 'Ext.History',\n    mixins: {\n        observable: 'Ext.util.Observable'\n    },\n\n    /**\n     * @property\n     * True to use `window.top.location.hash` or false to use `window.location.hash`.\n     */\n    useTopWindow: true,\n\n    /**\n     * @property\n     * The id of the hidden field required for storing the current history token.\n     */\n    fieldId: Ext.baseCSSPrefix + 'history-field',\n    /**\n     * @property\n     * The id of the iframe required by IE to manage the history stack.\n     */\n    iframeId: Ext.baseCSSPrefix + 'history-frame',\n\n    constructor: function() {\n        var me = this;\n        me.oldIEMode = Ext.isIE6 || Ext.isIE7 || !Ext.isStrict && Ext.isIE8;\n        me.iframe = null;\n        me.hiddenField = null;\n        me.ready = false;\n        me.currentToken = null;\n        me.mixins.observable.constructor.call(me);\n    },\n\n    getHash: function() {\n        var href = window.location.href,\n            i = href.indexOf(\"#\");\n\n        return i >= 0 ? href.substr(i + 1) : null;\n    },\n\n    setHash: function (hash) {\n        var me = this,\n            win = me.useTopWindow ? window.top : window;\n        try {\n            win.location.hash = hash;\n        } catch (e) {\n            // IE can give Access Denied (esp. in popup windows)\n        }\n    },\n\n    doSave: function() {\n        this.hiddenField.value = this.currentToken;\n    },\n\n\n    handleStateChange: function(token) {\n        this.currentToken = token;\n        this.fireEvent('change', token);\n    },\n\n    updateIFrame: function(token) {\n        var html = '<html><body><div id=\"state\">' +\n                    Ext.util.Format.htmlEncode(token) +\n                    '</div></body></html>',\n            doc;\n\n        try {\n            doc = this.iframe.contentWindow.document;\n            doc.open();\n            doc.write(html);\n            doc.close();\n            return true;\n        } catch (e) {\n            return false;\n        }\n    },\n\n    checkIFrame: function () {\n        var me = this,\n            contentWindow = me.iframe.contentWindow,\n            doc, elem, oldToken, oldHash;\n\n        if (!contentWindow || !contentWindow.document) {\n            Ext.Function.defer(this.checkIFrame, 10, this);\n            return;\n        }\n\n        doc = contentWindow.document;\n        elem = doc.getElementById(\"state\");\n        oldToken = elem ? elem.innerText : null;\n        oldHash = me.getHash();\n\n        Ext.TaskManager.start({\n            run: function () {\n                var doc = contentWindow.document,\n                    elem = doc.getElementById(\"state\"),\n                    newToken = elem ? elem.innerText : null,\n                    newHash = me.getHash();\n\n                if (newToken !== oldToken) {\n                    oldToken = newToken;\n                    me.handleStateChange(newToken);\n                    me.setHash(newToken);\n                    oldHash = newToken;\n                    me.doSave();\n                } else if (newHash !== oldHash) {\n                    oldHash = newHash;\n                    me.updateIFrame(newHash);\n                }\n            },\n            interval: 50,\n            scope: me\n        });\n        me.ready = true;\n        me.fireEvent('ready', me);\n    },\n\n    startUp: function () {\n        var me = this,\n            hash;\n\n        me.currentToken = me.hiddenField.value || this.getHash();\n\n        if (me.oldIEMode) {\n            me.checkIFrame();\n        } else {\n            hash = me.getHash();\n            Ext.TaskManager.start({\n                run: function () {\n                    var newHash = me.getHash();\n                    if (newHash !== hash) {\n                        hash = newHash;\n                        me.handleStateChange(hash);\n                        me.doSave();\n                    }\n                },\n                interval: 50,\n                scope: me\n            });\n            me.ready = true;\n            me.fireEvent('ready', me);\n        }\n\n    },\n\n    /**\n     * Initializes the global History instance.\n     * @param {Function} [onReady] A callback function that will be called once the history\n     * component is fully initialized.\n     * @param {Object} [scope] The scope (`this` reference) in which the callback is executed.\n     * Defaults to the browser window.\n     */\n    init: function (onReady, scope) {\n        var me = this,\n            DomHelper = Ext.DomHelper;\n\n        if (me.ready) {\n            Ext.callback(onReady, scope, [me]);\n            return;\n        }\n\n        if (!Ext.isReady) {\n            Ext.onReady(function() {\n                me.init(onReady, scope);\n            });\n            return;\n        }\n\n        /*\n        <form id=\"history-form\" class=\"x-hide-display\">\n            <input type=\"hidden\" id=\"x-history-field\" />\n            <iframe id=\"x-history-frame\"></iframe>\n        </form>\n        */\n        me.hiddenField = Ext.getDom(me.fieldId);\n        if (!me.hiddenField) {\n            me.hiddenField = Ext.getBody().createChild({\n                id: Ext.id(),\n                tag: 'form',\n                cls: Ext.baseCSSPrefix + 'hide-display',\n                children: [{\n                    tag: 'input',\n                    type: 'hidden',\n                    id: me.fieldId\n                }]\n            }, false, true).firstChild;\n        }\n\n        if (me.oldIEMode) {\n            me.iframe = Ext.getDom(me.iframeId);\n            if (!me.iframe) {\n                me.iframe = DomHelper.append(me.hiddenField.parentNode, {\n                    tag: 'iframe',\n                    id: me.iframeId,\n                    src: Ext.SSL_SECURE_URL\n                });\n            }\n        }\n\n        me.addEvents(\n            /**\n             * @event ready\n             * Fires when the Ext.util.History singleton has been initialized and is ready for use.\n             * @param {Ext.util.History} The Ext.util.History singleton.\n             */\n            'ready',\n            /**\n             * @event change\n             * Fires when navigation back or forwards within the local page's history occurs.\n             * @param {String} token An identifier associated with the page state at that point in its history.\n             */\n            'change'\n        );\n\n        if (onReady) {\n            me.on('ready', onReady, scope, {single: true});\n        }\n        me.startUp();\n    },\n\n    /**\n     * Add a new token to the history stack. This can be any arbitrary value, although it would\n     * commonly be the concatenation of a component id and another id marking the specific history\n     * state of that component. Example usage:\n     *\n     *     // Handle tab changes on a TabPanel\n     *     tabPanel.on('tabchange', function(tabPanel, tab){\n     *          Ext.History.add(tabPanel.id + ':' + tab.id);\n     *     });\n     *\n     * @param {String} token The value that defines a particular application-specific history state\n     * @param {Boolean} [preventDuplicates=true] When true, if the passed token matches the current token\n     * it will not save a new history step. Set to false if the same state can be saved more than once\n     * at the same history stack location.\n     */\n    add: function (token, preventDup) {\n        var me = this;\n\n        if (preventDup !== false) {\n            if (me.getToken() === token) {\n                return true;\n            }\n        }\n\n        if (me.oldIEMode) {\n            return me.updateIFrame(token);\n        } else {\n            me.setHash(token);\n            return true;\n        }\n    },\n\n    /**\n     * Programmatically steps back one step in browser history (equivalent to the user pressing the Back button).\n     */\n    back: function() {\n        window.history.go(-1);\n    },\n\n    /**\n     * Programmatically steps forward one step in browser history (equivalent to the user pressing the Forward button).\n     */\n    forward: function(){\n        window.history.go(1);\n    },\n\n    /**\n     * Retrieves the currently-active history token.\n     * @return {String} The token\n     */\n    getToken: function() {\n        return this.ready ? this.currentToken : this.getHash();\n    }\n});\n\n/**\n * Represents a 2D point with x and y properties, useful for comparison and instantiation\n * from an event:\n *\n *     var point = Ext.util.Point.fromEvent(e);\n *\n */\nExt.define('Ext.util.Point', {\n\n    /* Begin Definitions */\n    extend: 'Ext.util.Region',\n\n    statics: {\n\n        /**\n         * Returns a new instance of Ext.util.Point base on the pageX / pageY values of the given event\n         * @static\n         * @param {Event} e The event\n         * @return {Ext.util.Point}\n         */\n        fromEvent: function(e) {\n            e = (e.changedTouches && e.changedTouches.length > 0) ? e.changedTouches[0] : e;\n            return new this(e.pageX, e.pageY);\n        }\n    },\n\n    /* End Definitions */\n\n    /**\n     * Creates a point from two coordinates.\n     * @param {Number} x X coordinate.\n     * @param {Number} y Y coordinate.\n     */\n    constructor: function(x, y) {\n        this.callParent([y, x, y, x]);\n    },\n\n    /**\n     * Returns a human-eye-friendly string that represents this point,\n     * useful for debugging\n     * @return {String}\n     */\n    toString: function() {\n        return \"Point[\" + this.x + \",\" + this.y + \"]\";\n    },\n\n    /**\n     * Compare this point and another point\n     * @param {Ext.util.Point/Object} The point to compare with, either an instance\n     * of Ext.util.Point or an object with left and top properties\n     * @return {Boolean} Returns whether they are equivalent\n     */\n    equals: function(p) {\n        return (this.x == p.x && this.y == p.y);\n    },\n\n    /**\n     * Whether the given point is not away from this point within the given threshold amount.\n     * @param {Ext.util.Point/Object} p The point to check with, either an instance\n     * of Ext.util.Point or an object with left and top properties\n     * @param {Object/Number} threshold Can be either an object with x and y properties or a number\n     * @return {Boolean}\n     */\n    isWithin: function(p, threshold) {\n        if (!Ext.isObject(threshold)) {\n            threshold = {\n                x: threshold,\n                y: threshold\n            };\n        }\n\n        return (this.x <= p.x + threshold.x && this.x >= p.x - threshold.x &&\n                this.y <= p.y + threshold.y && this.y >= p.y - threshold.y);\n    },\n\n    /**\n     * Compare this point with another point when the x and y values of both points are rounded. E.g:\n     * [100.3,199.8] will equals to [100, 200]\n     * @param {Ext.util.Point/Object} p The point to compare with, either an instance\n     * of Ext.util.Point or an object with x and y properties\n     * @return {Boolean}\n     */\n    roundedEquals: function(p) {\n        return (Math.round(this.x) == Math.round(p.x) && Math.round(this.y) == Math.round(p.y));\n    }\n}, function() {\n    /**\n     * @method\n     * Alias for {@link #translateBy}\n     * @inheritdoc Ext.util.Region#translateBy\n     */\n    this.prototype.translate = Ext.util.Region.prototype.translateBy;\n});\n\n/**\n * Produces optimized XTemplates for chunks of tables to be\n * used in grids, trees and other table based widgets.\n */\nExt.define('Ext.view.TableChunker', {\n    singleton: true,\n    requires: ['Ext.XTemplate'],\n    metaTableTpl: [\n        '{%if (this.openTableWrap)out.push(this.openTableWrap())%}',\n        '<table class=\"' + Ext.baseCSSPrefix + 'grid-table ' + Ext.baseCSSPrefix + 'grid-table-resizer\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" {[this.embedFullWidth(values)]}>',\n            '<tbody>',\n            '<tr class=\"' + Ext.baseCSSPrefix + 'grid-header-row\">',\n            '<tpl for=\"columns\">',\n                '<th class=\"' + Ext.baseCSSPrefix + 'grid-col-resizer-{id}\" style=\"width: {width}px; height: 0px;\"></th>',\n            '</tpl>',\n            '</tr>',\n            '{[this.openRows()]}',\n                '{row}',\n                '<tpl for=\"features\">',\n                    '{[this.embedFeature(values, parent, xindex, xcount)]}',\n                '</tpl>',\n            '{[this.closeRows()]}',\n            '</tbody>',\n        '</table>',\n        '{%if (this.closeTableWrap)out.push(this.closeTableWrap())%}'\n    ],\n\n    constructor: function() {\n        Ext.XTemplate.prototype.recurse = function(values, reference) {\n            return this.apply(reference ? values[reference] : values);\n        };\n    },\n\n    embedFeature: function(values, parent, x, xcount) {\n        var tpl = '';\n        if (!values.disabled) {\n            tpl = values.getFeatureTpl(values, parent, x, xcount);\n        }\n        return tpl;\n    },\n\n    embedFullWidth: function(values) {\n        var result = 'style=\"width:{fullWidth}px;';\n\n        // If there are no records, we need to give the table a height so that it\n        // is displayed and causes q scrollbar if the width exceeds the View's width.\n        if (!values.rowCount) {\n            result += 'height:1px;';\n        }\n        return result + '\"';\n    },\n\n    openRows: function() {\n        return '<tpl for=\"rows\">';\n    },\n\n    closeRows: function() {\n        return '</tpl>';\n    },\n\n    metaRowTpl: [\n        '<tr class=\"' + Ext.baseCSSPrefix + 'grid-row {[this.embedRowCls()]}\" {[this.embedRowAttr()]}>',\n            '<tpl for=\"columns\">',\n                '<td class=\"{cls} ' + Ext.baseCSSPrefix + 'grid-cell ' + Ext.baseCSSPrefix + 'grid-cell-{columnId} {{id}-modified} {{id}-tdCls} {[this.firstOrLastCls(xindex, xcount)]}\" {{id}-tdAttr}>',\n                    '<div {unselectableAttr} class=\"' + Ext.baseCSSPrefix + 'grid-cell-inner {unselectableCls}\" style=\"text-align: {align}; {{id}-style};\">{{id}}</div>',\n                '</td>',\n            '</tpl>',\n        '</tr>'\n    ],\n\n    firstOrLastCls: function(xindex, xcount) {\n        if (xindex === 1) {\n            return Ext.view.Table.prototype.firstCls;\n        } else if (xindex === xcount) {\n            return Ext.view.Table.prototype.lastCls;\n        }\n    },\n    \n    embedRowCls: function() {\n        return '{rowCls}';\n    },\n    \n    embedRowAttr: function() {\n        return '{rowAttr}';\n    },\n    \n    openTableWrap: undefined,\n    \n    closeTableWrap: undefined,\n\n    getTableTpl: function(cfg, textOnly) {\n        var tpl,\n            tableTplMemberFns = {\n                openRows: this.openRows,\n                closeRows: this.closeRows,\n                embedFeature: this.embedFeature,\n                embedFullWidth: this.embedFullWidth,\n                openTableWrap: this.openTableWrap,\n                closeTableWrap: this.closeTableWrap\n            },\n            tplMemberFns = {},\n            features = cfg.features || [],\n            ln = features.length,\n            i  = 0,\n            memberFns = {\n                embedRowCls: this.embedRowCls,\n                embedRowAttr: this.embedRowAttr,\n                firstOrLastCls: this.firstOrLastCls,\n                unselectableAttr: cfg.enableTextSelection ? '' : 'unselectable=\"on\"',\n                unselectableCls: cfg.enableTextSelection ? '' : Ext.baseCSSPrefix + 'unselectable'\n            },\n            // copy the default\n            metaRowTpl = Array.prototype.slice.call(this.metaRowTpl, 0),\n            metaTableTpl;\n            \n        for (; i < ln; i++) {\n            if (!features[i].disabled) {\n                features[i].mutateMetaRowTpl(metaRowTpl);\n                Ext.apply(memberFns, features[i].getMetaRowTplFragments());\n                Ext.apply(tplMemberFns, features[i].getFragmentTpl());\n                Ext.apply(tableTplMemberFns, features[i].getTableFragments());\n            }\n        }\n        \n        metaRowTpl = new Ext.XTemplate(metaRowTpl.join(''), memberFns);\n        cfg.row = metaRowTpl.applyTemplate(cfg);\n        \n        metaTableTpl = new Ext.XTemplate(this.metaTableTpl.join(''), tableTplMemberFns);\n        \n        tpl = metaTableTpl.applyTemplate(cfg);\n        \n        // TODO: Investigate eliminating.\n        if (!textOnly) {\n            tpl = new Ext.XTemplate(tpl, tplMemberFns);\n        }\n        return tpl;\n        \n    }\n});\n\n//@tail\n\n/*\n * This file represents the very last stage of the Ext definition process and is ensured\n * to be included at the end of the build via the 'tail' package of extjs.jsb3.\n *\n */\n\nExt._endTime = new Date().getTime();\nif (Ext._beforereadyhandler){\n    Ext._beforereadyhandler();\n}\n\n"
  },
  {
    "path": "vendor/jquery.js",
    "content": "/*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license\n //@ sourceMappingURL=jquery.min.map\n */(function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],p=\"1.9.1\",f=c.concat,d=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/.source,w=/\\S+/g,T=/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g,N=/^(?:(<[\\w\\W]+>)[^>]*|#([\\w-]*))$/,C=/^<(\\w+)\\s*\\/?>(?:<\\/\\1>|)$/,k=/^[\\],:{}\\s]*$/,E=/(?:^|:|,)(?:\\s*\\[)+/g,S=/\\\\(?:[\"\\\\\\/bfnrt]|u[\\da-fA-F]{4})/g,A=/\"[^\"\\\\\\r\\n]*\"|true|false|null|-?(?:\\d+\\.|)\\d+(?:[eE][+-]?\\d+|)/g,j=/^-ms-/,D=/-([\\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||\"load\"===e.type||\"complete\"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener(\"DOMContentLoaded\",H,!1),e.removeEventListener(\"load\",H,!1)):(o.detachEvent(\"onreadystatechange\",H),e.detachEvent(\"onload\",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if(\"string\"==typeof e){if(i=\"<\"===e.charAt(0)&&\">\"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:\"\",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for(\"boolean\"==typeof s&&(c=s,s=arguments[1]||{},u=2),\"object\"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger(\"ready\").off(\"ready\"))}},isFunction:function(e){return\"function\"===b.type(e)},isArray:Array.isArray||function(e){return\"array\"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+\"\":\"object\"==typeof e||\"function\"==typeof e?l[m.call(e)]||\"object\":typeof e},isPlainObject:function(e){if(!e||\"object\"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,\"constructor\")&&!y.call(e.constructor.prototype,\"isPrototypeOf\"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||\"string\"!=typeof e)return null;\"boolean\"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:\"string\"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,\"@\").replace(A,\"]\").replace(E,\"\")))?Function(\"return \"+n)():(b.error(\"Invalid JSON: \"+n),t)},parseXML:function(n){var r,i;if(!n||\"string\"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,\"text/xml\")):(r=new ActiveXObject(\"Microsoft.XMLDOM\"),r.async=\"false\",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName(\"parsererror\").length||b.error(\"Invalid XML: \"+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,\"ms-\").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call(\"\\ufeff\\u00a0\")?function(e){return null==e?\"\":v.call(e)}:function(e){return null==e?\"\":(e+\"\").replace(T,\"\")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,\"string\"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if(\"number\"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return\"string\"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if(\"object\"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),\"complete\"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener(\"DOMContentLoaded\",H,!1),e.addEventListener(\"load\",H,!1);else{o.attachEvent(\"onreadystatechange\",H),e.attachEvent(\"onload\",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll(\"left\")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each(\"Boolean Number String Function Array Date RegExp Object Error\".split(\" \"),function(e,t){l[\"[object \"+t+\"]\"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:\"array\"===n||\"function\"!==n&&(0===t||\"number\"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e=\"string\"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);\"function\"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&\"string\"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[[\"resolve\",\"done\",b.Callbacks(\"once memory\"),\"resolved\"],[\"reject\",\"fail\",b.Callbacks(\"once memory\"),\"rejected\"],[\"notify\",\"progress\",b.Callbacks(\"memory\")]],n=\"pending\",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+\"With\"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+\"With\"](this===i?r:this,arguments),this},i[o[0]+\"With\"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement(\"div\");if(d.setAttribute(\"className\",\"t\"),d.innerHTML=\"  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>\",n=d.getElementsByTagName(\"*\"),r=d.getElementsByTagName(\"a\")[0],!n||!r||!n.length)return{};s=o.createElement(\"select\"),l=s.appendChild(o.createElement(\"option\")),a=d.getElementsByTagName(\"input\")[0],r.style.cssText=\"top:1px;float:left;opacity:.5\",t={getSetAttribute:\"t\"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName(\"tbody\").length,htmlSerialize:!!d.getElementsByTagName(\"link\").length,style:/top/.test(r.getAttribute(\"style\")),hrefNormalized:\"/a\"===r.getAttribute(\"href\"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement(\"form\").enctype,html5Clone:\"<:nav></:nav>\"!==o.createElement(\"nav\").cloneNode(!0).outerHTML,boxModel:\"CSS1Compat\"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement(\"input\"),a.setAttribute(\"value\",\"\"),t.input=\"\"===a.getAttribute(\"value\"),a.value=\"t\",a.setAttribute(\"type\",\"radio\"),t.radioValue=\"t\"===a.value,a.setAttribute(\"checked\",\"t\"),a.setAttribute(\"name\",\"t\"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent(\"onclick\",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c=\"on\"+f,\"t\"),t[f+\"Bubbles\"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip=\"content-box\",d.cloneNode(!0).style.backgroundClip=\"\",t.clearCloneStyle=\"content-box\"===d.style.backgroundClip,b(function(){var n,r,a,s=\"padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;\",u=o.getElementsByTagName(\"body\")[0];u&&(n=o.createElement(\"div\"),n.style.cssText=\"border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px\",u.appendChild(n).appendChild(d),d.innerHTML=\"<table><tr><td></td><td>t</td></tr></table>\",a=d.getElementsByTagName(\"td\"),a[0].style.cssText=\"padding:0;margin:0;border:0;display:none\",p=0===a[0].offsetHeight,a[0].style.display=\"\",a[1].style.display=\"none\",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML=\"\",d.style.cssText=\"box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;\",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition=\"1%\"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable=\"4px\"===(e.getComputedStyle(d,null)||{width:\"4px\"}).width,r=d.appendChild(o.createElement(\"div\")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width=\"0\",d.style.width=\"1px\",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML=\"\",d.style.cssText=s+\"width:1px;padding:1px;display:inline;zoom:1\",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display=\"block\",d.innerHTML=\"<div></div>\",d.firstChild.style.width=\"5px\",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\\{[\\s\\S]*\\}|\\[[\\s\\S]*\\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u=\"string\"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),(\"object\"==typeof n||\"function\"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(\" \"));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:\"jQuery\"+(p+Math.random()).replace(/\\D/g,\"\"),noData:{embed:!0,object:\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute(\"classid\")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,\"parsedAttrs\"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf(\"data-\")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,\"parsedAttrs\",!0)}return s}return\"object\"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i=\"data-\"+n.replace(B,\"-$1\").toLowerCase();if(r=e.getAttribute(i),\"string\"==typeof r){try{r=\"true\"===r?!0:\"false\"===r?!1:\"null\"===r?null:+r+\"\"===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if((\"data\"!==t||!b.isEmptyObject(e[t]))&&\"toJSON\"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||\"fx\")+\"queue\",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||\"fx\";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};\"inprogress\"===i&&(i=n.shift(),r--),o.cur=i,i&&(\"fx\"===t&&n.unshift(\"inprogress\"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+\"queueHooks\";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks(\"once memory\").add(function(){b._removeData(e,t+\"queue\"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return\"string\"!=typeof e&&(n=e,e=\"fx\",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),\"fx\"===e&&\"inprogress\"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||\"fx\",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||\"fx\",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};\"string\"!=typeof e&&(n=e,e=t),e=e||\"fx\";while(s--)r=b._data(a[s],e+\"queueHooks\"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\\t\\r\\n]/g,U=/\\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=\"string\"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||\"\").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(\" \"+n.className+\" \").replace(X,\" \"):\" \")){o=0;while(i=t[o++])0>r.indexOf(\" \"+i+\" \")&&(r+=i+\" \");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||\"string\"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||\"\").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(\" \"+n.className+\" \").replace(X,\" \"):\"\")){o=0;while(i=t[o++])while(r.indexOf(\" \"+i+\" \")>=0)r=r.replace(\" \"+i+\" \",\" \");n.className=e?b.trim(r):\"\"}return this},toggleClass:function(e,t){var n=typeof e,r=\"boolean\"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(\"string\"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?\"addClass\":\"removeClass\"](o)}else(n===i||\"boolean\"===n)&&(this.className&&b._data(this,\"__className__\",this.className),this.className=this.className||e===!1?\"\":b._data(this,\"__className__\")||\"\")})},hasClass:function(e){var t=\" \"+e+\" \",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(\" \"+this[n].className+\" \").replace(X,\" \").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o=\"\":\"number\"==typeof o?o+=\"\":b.isArray(o)&&(o=b.map(o,function(e){return null==e?\"\":e+\"\"})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&\"set\"in r&&r.set(this,o,\"value\")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&\"get\"in r&&(n=r.get(o,\"value\"))!==t?n:(n=o.value,\"string\"==typeof n?n.replace(U,\"\"):null==n?\"\":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o=\"select-one\"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute(\"disabled\"))||n.parentNode.disabled&&b.nodeName(n.parentNode,\"optgroup\"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find(\"option\").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&\"get\"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&\"set\"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+\"\"),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase(\"default-\"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,\"\"),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&\"radio\"===t&&b.nodeName(e,\"input\")){var n=e.value;return e.setAttribute(\"type\",t),n&&(e.value=n),t}}}},propFix:{tabindex:\"tabIndex\",readonly:\"readOnly\",\"for\":\"htmlFor\",\"class\":\"className\",maxlength:\"maxLength\",cellspacing:\"cellSpacing\",cellpadding:\"cellPadding\",rowspan:\"rowSpan\",colspan:\"colSpan\",usemap:\"useMap\",frameborder:\"frameBorder\",contenteditable:\"contentEditable\"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&\"set\"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&\"get\"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode(\"tabindex\");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i=\"boolean\"==typeof r&&e.getAttribute(n),o=\"boolean\"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase(\"default-\"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase(\"default-\"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,\"input\")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,\"input\")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&(\"id\"===n||\"name\"===n||\"coords\"===n?\"\"!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+=\"\",\"value\"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,\"\"===t?!1:t,n)}},b.each([\"width\",\"height\"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return\"\"===r?(e.setAttribute(n,\"auto\"),r):t}})})),b.support.hrefNormalized||(b.each([\"href\",\"src\",\"width\",\"height\"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each([\"href\",\"src\"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+\"\"}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype=\"encoding\"),b.support.checkOn||b.each([\"radio\",\"checkbox\"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute(\"value\")?\"on\":e.value}}}),b.each([\"radio\",\"checkbox\"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||\"\").match(w)||[\"\"],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||\"\").split(\".\").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(\".\")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent(\"on\"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||\"\").match(w)||[\"\"],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||\"\").split(\".\").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp(\"(^|\\\\.)\"+h.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&(\"**\"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,\"events\"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,\"type\")?n.type:n,m=y.call(n,\"namespace\")?n.namespace.split(\".\"):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(\".\")>=0&&(m=g.split(\".\"),g=m.shift(),m.sort()),u=0>g.indexOf(\":\")&&\"on\"+g,n=n[b.expando]?n:new b.Event(g,\"object\"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join(\".\"),n.namespace_re=n.namespace?RegExp(\"(^|\\\\.)\"+m.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,\"events\")||{})[n.type]&&b._data(l,\"handle\"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||\"click\"===g&&b.nodeName(i,\"a\")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,\"events\")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||\"click\"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||\"click\"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+\" \",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:\"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which\".split(\" \"),fixHooks:{},keyHooks:{props:\"char charCode key keyCode\".split(\" \"),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:\"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement\".split(\" \"),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,\"input\")&&\"checkbox\"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:\"focusin\"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:\"focusout\"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r=\"on\"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:\"mouseover\",mouseleave:\"mouseout\"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;\n    return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,\"form\")?!1:(b.event.add(this,\"click._submit keypress._submit\",function(e){var n=e.target,r=b.nodeName(n,\"input\")||b.nodeName(n,\"button\")?n.form:t;r&&!b._data(r,\"submitBubbles\")&&(b.event.add(r,\"submit._submit\",function(e){e._submit_bubble=!0}),b._data(r,\"submitBubbles\",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate(\"submit\",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,\"form\")?!1:(b.event.remove(this,\"._submit\"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?((\"checkbox\"===this.type||\"radio\"===this.type)&&(b.event.add(this,\"propertychange._change\",function(e){\"checked\"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,\"click._change\",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate(\"change\",this,e,!0)})),!1):(b.event.add(this,\"beforeactivate._change\",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,\"changeBubbles\")&&(b.event.add(t,\"change._change\",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate(\"change\",this.parentNode,e,!0)}),b._data(t,\"changeBubbles\",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||\"radio\"!==n.type&&\"checkbox\"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,\"._change\"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:\"focusin\",blur:\"focusout\"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if(\"object\"==typeof e){\"string\"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&(\"string\"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+\".\"+i.namespace:i.origType,i.selector,i.handler),this;if(\"object\"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||\"function\"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,\"**\"):this.off(t,e||\"**\",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x=\"sizzle\"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_=\"[\\\\x20\\\\t\\\\r\\\\n\\\\f]\",F=\"(?:\\\\\\\\.|[\\\\w-]|[^\\\\x00-\\\\xa0])+\",O=F.replace(\"w\",\"w#\"),B=\"([*^$|!~]?=)\",P=\"\\\\[\"+_+\"*(\"+F+\")\"+_+\"*(?:\"+B+_+\"*(?:(['\\\"])((?:\\\\\\\\.|[^\\\\\\\\])*?)\\\\3|(\"+O+\")|)|)\"+_+\"*\\\\]\",R=\":(\"+F+\")(?:\\\\(((['\\\"])((?:\\\\\\\\.|[^\\\\\\\\])*?)\\\\3|((?:\\\\\\\\.|[^\\\\\\\\()[\\\\]]|\"+P.replace(3,8)+\")*)|.*)\\\\)|)\",W=RegExp(\"^\"+_+\"+|((?:^|[^\\\\\\\\])(?:\\\\\\\\.)*)\"+_+\"+$\",\"g\"),$=RegExp(\"^\"+_+\"*,\"+_+\"*\"),I=RegExp(\"^\"+_+\"*([\\\\x20\\\\t\\\\r\\\\n\\\\f>+~])\"+_+\"*\"),z=RegExp(R),X=RegExp(\"^\"+O+\"$\"),U={ID:RegExp(\"^#(\"+F+\")\"),CLASS:RegExp(\"^\\\\.(\"+F+\")\"),NAME:RegExp(\"^\\\\[name=['\\\"]?(\"+F+\")['\\\"]?\\\\]\"),TAG:RegExp(\"^(\"+F.replace(\"w\",\"w*\")+\")\"),ATTR:RegExp(\"^\"+P),PSEUDO:RegExp(\"^\"+R),CHILD:RegExp(\"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\"+_+\"*(even|odd|(([+-]|)(\\\\d*)n|)\"+_+\"*(?:([+-]|)\"+_+\"*(\\\\d+)|))\"+_+\"*\\\\)|)\",\"i\"),needsContext:RegExp(\"^\"+_+\"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\"+_+\"*((?:-\\\\d)?\\\\d*)\"+_+\"*\\\\)|)(?=[^-]|$)\",\"i\")},V=/[\\x20\\t\\r\\n\\f]*[+~]/,Y=/^[^{]+\\{\\s*\\[native code/,J=/^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\\d$/i,K=/'|\\\\/g,Z=/\\=[\\x20\\t\\r\\n\\f]*([^'\"\\]]*)[\\x20\\t\\r\\n\\f]*\\]/g,et=/\\\\([\\da-fA-F]{1,6}[\\x20\\t\\r\\n\\f]?|.)/g,tt=function(e,t){var n=\"0x\"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+\"\")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=\" \")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement(\"div\");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||\"string\"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&\"object\"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute(\"id\"))?g=f.replace(K,\"\\\\$&\"):t.setAttribute(\"id\",g),g=\"[id='\"+g+\"'] \",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(\",\")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute(\"id\")}}}return wt(e.replace(W,\"$1\"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?\"HTML\"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment(\"\")),!e.getElementsByTagName(\"*\").length}),T.attributes=at(function(e){e.innerHTML=\"<select></select>\";var t=typeof e.lastChild.getAttribute(\"multiple\");return\"boolean\"!==t&&\"string\"!==t}),T.getByClassName=at(function(e){return e.innerHTML=\"<div class='hidden e'></div><div class='hidden'></div>\",e.getElementsByClassName&&e.getElementsByClassName(\"e\").length?(e.lastChild.className=\"e\",2===e.getElementsByClassName(\"e\").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML=\"<a name='\"+x+\"'></a><div name='\"+x+\"'></div>\",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML=\"<a href='#'></a>\",e.firstChild&&typeof e.firstChild.getAttribute!==A&&\"#\"===e.firstChild.getAttribute(\"href\")})?{}:{href:function(e){return e.getAttribute(\"href\",2)},type:function(e){return e.getAttribute(\"type\")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute(\"id\")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode(\"id\").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode(\"id\");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if(\"*\"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[\":focus\"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML=\"<select><option selected=''></option></select>\",e.querySelectorAll(\"[selected]\").length||h.push(\"\\\\[\"+_+\"*(?:checked|disabled|ismap|multiple|readonly|selected|value)\"),e.querySelectorAll(\":checked\").length||h.push(\":checked\")}),at(function(e){e.innerHTML=\"<input type='hidden' i=''/>\",e.querySelectorAll(\"[i^='']\").length&&h.push(\"[*^$]=\"+_+\"*(?:\\\"\\\"|'')\"),e.querySelectorAll(\":enabled\").length||h.push(\":enabled\",\":disabled\"),e.querySelectorAll(\"*,:x\"),h.push(\",.*:\")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,\"div\"),m.call(e,\"[s!='']:x\"),g.push(\"!=\",R)}),h=RegExp(h.join(\"|\")),g=RegExp(g.join(\"|\")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,\"='$1']\"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error(\"Syntax error, unrecognized expression: \"+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return\"input\"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return(\"input\"===n||\"button\"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n=\"\",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if(\"string\"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{\">\":{dir:\"parentNode\",first:!0},\" \":{dir:\"parentNode\"},\"+\":{dir:\"previousSibling\",first:!0},\"~\":{dir:\"previousSibling\"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||\"\").replace(et,tt),\"~=\"===e[2]&&(e[3]=\" \"+e[3]+\" \"),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),\"nth\"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*(\"even\"===e[3]||\"odd\"===e[3])),e[5]=+(e[7]+e[8]||\"odd\"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(\")\",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return\"*\"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+\" \"];return t||(t=RegExp(\"(^|\"+_+\")\"+e+\"(\"+_+\"|$)\"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute(\"class\")||\"\")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?\"!=\"===t:t?(i+=\"\",\"=\"===t?i===n:\"!=\"===t?i!==n:\"^=\"===t?n&&0===i.indexOf(n):\"*=\"===t?n&&i.indexOf(n)>-1:\"$=\"===t?n&&i.slice(-n.length)===n:\"~=\"===t?(\" \"+i+\" \").indexOf(n)>-1:\"|=\"===t?i===n||i.slice(0,n.length+1)===n+\"-\":!1):!0}},CHILD:function(e,t,n,r,i){var o=\"nth\"!==e.slice(0,3),a=\"last\"!==e.slice(-4),s=\"of-type\"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?\"nextSibling\":\"previousSibling\",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g=\"only\"===e&&!h&&\"nextSibling\"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error(\"unsupported pseudo: \"+e);return r[x]?r(t):r.length>1?(n=[e,e,\"\",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,\"$1\"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||\"\")||st.error(\"unsupported lang: \"+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute(\"xml:lang\")||t.getAttribute(\"lang\"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+\"-\");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&!!e.checked||\"option\"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>\"@\"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return\"input\"===t&&\"button\"===e.type||\"button\"===t},text:function(e){var t;return\"input\"===e.nodeName.toLowerCase()&&\"text\"===e.type&&(null==(t=e.getAttribute(\"type\"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+\" \"];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W,\" \")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r=\"\";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&\"parentNode\"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+\" \"+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||\"*\",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[\" \"],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&&gt(f),u>1&&dt(e.slice(0,u-1)).replace(W,\"$1\"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b=\"0\",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG(\"*\",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+\" \"];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&\"ID\"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[\":\"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\\[\\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if(\"string\"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+\" \":\"\")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&(\"string\"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||\"string\"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?\"string\"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n=\"string\"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,\"parentNode\")},parentsUntil:function(e,t,n){return b.dir(e,\"parentNode\",n)},next:function(e){return pt(e,\"nextSibling\")},prev:function(e){return pt(e,\"previousSibling\")},nextAll:function(e){return b.dir(e,\"nextSibling\")},prevAll:function(e){return b.dir(e,\"previousSibling\")},nextUntil:function(e,t,n){return b.dir(e,\"nextSibling\",n)},prevUntil:function(e,t,n){return b.dir(e,\"previousSibling\",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,\"iframe\")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&\"string\"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=\":not(\"+e+\")\"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if(\"string\"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split(\"|\"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht=\"abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video\",gt=/ jQuery\\d+=\"(?:null|\\d+)\"/g,mt=RegExp(\"<(?:\"+ht+\")[\\\\s/>]\",\"i\"),yt=/^\\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\\w:]+)[^>]*)\\/>/gi,bt=/<([\\w:]+)/,xt=/<tbody/i,wt=/<|&#?\\w+;/,Tt=/<(?:script|style|link)/i,Nt=/^(?:checkbox|radio)$/i,Ct=/checked\\s*(?:[^=]|=\\s*.checked.)/i,kt=/^$|\\/(?:java|ecma)script/i,Et=/^true\\/(.*)/,St=/^\\s*<!(?:\\[CDATA\\[|--)|(?:\\]\\]|--)>\\s*$/g,At={option:[1,\"<select multiple='multiple'>\",\"</select>\"],legend:[1,\"<fieldset>\",\"</fieldset>\"],area:[1,\"<map>\",\"</map>\"],param:[1,\"<object>\",\"</object>\"],thead:[1,\"<table>\",\"</table>\"],tr:[2,\"<table><tbody>\",\"</tbody></table>\"],col:[2,\"<table><tbody></tbody><colgroup>\",\"</colgroup></table>\"],td:[3,\"<table><tbody><tr>\",\"</tr></tbody></table>\"],_default:b.support.htmlSerialize?[0,\"\",\"\"]:[1,\"X<div>\",\"</div>\"]},jt=dt(o),Dt=jt.appendChild(o.createElement(\"div\"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,\"body\")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,\"script\")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,\"select\")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,\"\"):t;if(!(\"string\"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||[\"\",\"\"])[1].toLowerCase()])){e=e.replace(vt,\"<$1></$2>\");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||\"string\"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||\"string\"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,\"tr\"),s=b.map(Ot(l,\"script\"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,\"script\"))),r.call(n&&b.nodeName(this[c],\"table\")?Lt(this[c],\"tbody\"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||\"\")&&!b._data(o,\"globalEval\")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:\"GET\",dataType:\"script\",async:!1,global:!1,\"throws\":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||\"\").replace(St,\"\")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode(\"type\");return e.type=(t&&t.specified)+\"/\"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute(\"type\"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,\"globalEval\",!t||b._data(t[r],\"globalEval\"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}\"script\"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):\"object\"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):\"input\"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):\"option\"===n?t.defaultSelected=t.selected=e.defaultSelected:(\"input\"===n||\"textarea\"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:\"append\",prependTo:\"prepend\",insertBefore:\"before\",insertAfter:\"after\",replaceAll:\"replaceWith\"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||\"*\"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||\"*\"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test(\"<\"+e.nodeName+\">\")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,\"script\"),r.length>0&&Mt(r,!u&&Ot(e,\"script\")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if(\"object\"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement(\"div\")),u=(bt.exec(o)||[\"\",\"\"])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,\"<$1></$2>\")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o=\"table\"!==u||xt.test(o)?\"<table>\"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],\"tbody\")&&!l.childNodes.length&&o.removeChild(l)\n}b.merge(d,s.childNodes),s.textContent=\"\";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,\"input\"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),\"script\"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||\"\")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\\([^)]*\\)/i,It=/opacity\\s*=\\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp(\"^(\"+x+\")(.*)$\",\"i\"),Yt=RegExp(\"^(\"+x+\")(?!px)[a-z%]+$\",\"i\"),Jt=RegExp(\"^([+-])=(\"+x+\")\",\"i\"),Gt={BODY:\"block\"},Qt={position:\"absolute\",visibility:\"hidden\",display:\"block\"},Kt={letterSpacing:0,fontWeight:400},Zt=[\"Top\",\"Right\",\"Bottom\",\"Left\"],en=[\"Webkit\",\"O\",\"Moz\",\"ms\"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,\"none\"===b.css(e,\"display\")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,\"olddisplay\"),n=r.style.display,t?(o[a]||\"none\"!==n||(r.style.display=\"\"),\"\"===r.style.display&&nn(r)&&(o[a]=b._data(r,\"olddisplay\",un(r.nodeName)))):o[a]||(i=nn(r),(n&&\"none\"!==n||!i)&&b._data(r,\"olddisplay\",i?n:b.css(r,\"display\"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&\"none\"!==r.style.display&&\"\"!==r.style.display||(r.style.display=t?o[a]||\"\":\"none\"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t=\"boolean\"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,\"opacity\");return\"\"===n?\"1\":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{\"float\":b.support.cssFloat?\"cssFloat\":\"styleFloat\"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&\"get\"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,\"string\"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a=\"number\"),!(null==r||\"number\"===a&&isNaN(r)||(\"number\"!==a||b.cssNumber[u]||(r+=\"px\"),b.support.clearCloneStyle||\"\"!==r||0!==n.indexOf(\"background\")||(l[n]=\"inherit\"),s&&\"set\"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&\"get\"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),\"normal\"===a&&n in Kt&&(a=Kt[n]),\"\"===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(\"\"!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left=\"fontSize\"===n?\"1em\":u,u=l.pixelLeft+\"px\",l.left=i,a&&(o.left=a)),\"\"===u?\"auto\":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||\"px\"):t}function an(e,t,n,r,i){var o=n===(r?\"border\":\"content\")?4:\"width\"===t?1:0,a=0;for(;4>o;o+=2)\"margin\"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?(\"content\"===n&&(a-=b.css(e,\"padding\"+Zt[o],!0,i)),\"margin\"!==n&&(a-=b.css(e,\"border\"+Zt[o]+\"Width\",!0,i))):(a+=b.css(e,\"padding\"+Zt[o],!0,i),\"padding\"!==n&&(a+=b.css(e,\"border\"+Zt[o]+\"Width\",!0,i)));return a}function sn(e,t,n){var r=!0,i=\"width\"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&\"border-box\"===b.css(e,\"boxSizing\",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?\"border\":\"content\"),r,o)+\"px\"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),\"none\"!==n&&n||(Pt=(Pt||b(\"<iframe frameborder='0' width='0' height='0'/>\").css(\"cssText\",\"display:block !important\")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write(\"<!doctype html><html><body>\"),t.close(),n=ln(e,t),Pt.detach()),Gt[e]=n),n}function ln(e,t){var n=b(t.createElement(e)).appendTo(t.body),r=b.css(n[0],\"display\");return n.remove(),r}b.each([\"height\",\"width\"],function(e,n){b.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(b.css(e,\"display\"))?b.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,b.support.boxSizing&&\"border-box\"===b.css(e,\"boxSizing\",!1,i),i):0)}}}),b.support.opacity||(b.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||\"\")?.01*parseFloat(RegExp.$1)+\"\":t?\"1\":\"\"},set:function(e,t){var n=e.style,r=e.currentStyle,i=b.isNumeric(t)?\"alpha(opacity=\"+100*t+\")\":\"\",o=r&&r.filter||n.filter||\"\";n.zoom=1,(t>=1||\"\"===t)&&\"\"===b.trim(o.replace($t,\"\"))&&n.removeAttribute&&(n.removeAttribute(\"filter\"),\"\"===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+\" \"+i)}}),b(function(){b.support.reliableMarginRight||(b.cssHooks.marginRight={get:function(e,n){return n?b.swap(e,{display:\"inline-block\"},Wt,[e,\"marginRight\"]):t}}),!b.support.pixelPosition&&b.fn.position&&b.each([\"top\",\"left\"],function(e,n){b.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?b(e).position()[n]+\"px\":r):t}}})}),b.expr&&b.expr.filters&&(b.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!b.support.reliableHiddenOffsets&&\"none\"===(e.style&&e.style.display||b.css(e,\"display\"))},b.expr.filters.visible=function(e){return!b.expr.filters.hidden(e)}),b.each({margin:\"\",padding:\"\",border:\"Width\"},function(e,t){b.cssHooks[e+t]={expand:function(n){var r=0,i={},o=\"string\"==typeof n?n.split(\" \"):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(b.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\\[\\]$/,fn=/\\r?\\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;b.fn.extend({serialize:function(){return b.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=b.prop(this,\"elements\");return e?b.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!b(this).is(\":disabled\")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Nt.test(e))}).map(function(e,t){var n=b(this).val();return null==n?null:b.isArray(n)?b.map(n,function(e){return{name:t.name,value:e.replace(fn,\"\\r\\n\")}}):{name:t.name,value:n.replace(fn,\"\\r\\n\")}}).get()}}),b.param=function(e,n){var r,i=[],o=function(e,t){t=b.isFunction(t)?t():null==t?\"\":t,i[i.length]=encodeURIComponent(e)+\"=\"+encodeURIComponent(t)};if(n===t&&(n=b.ajaxSettings&&b.ajaxSettings.traditional),b.isArray(e)||e.jquery&&!b.isPlainObject(e))b.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join(\"&\").replace(cn,\"+\")};function gn(e,t,n,r){var i;if(b.isArray(t))b.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+\"[\"+(\"object\"==typeof i?t:\"\")+\"]\",i,n,r)});else if(n||\"object\"!==b.type(t))r(e,t);else for(i in t)gn(e+\"[\"+i+\"]\",t[i],n,r)}b.each(\"blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu\".split(\" \"),function(e,t){b.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),b.fn.hover=function(e,t){return this.mouseenter(e).mouseleave(t||e)};var mn,yn,vn=b.now(),bn=/\\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \\t]*([^\\r\\n]*)\\r?$/gm,Nn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Cn=/^(?:GET|HEAD)$/,kn=/^\\/\\//,En=/^([\\w.+-]+:)(?:\\/\\/([^\\/?#:]*)(?::(\\d+)|)|)/,Sn=b.fn.load,An={},jn={},Dn=\"*/\".concat(\"*\");try{yn=a.href}catch(Ln){yn=o.createElement(\"a\"),yn.href=\"\",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){\"string\"!=typeof t&&(n=t,t=\"*\");var r,i=0,o=t.toLowerCase().match(w)||[];if(b.isFunction(n))while(r=o[i++])\"+\"===r[0]?(r=r.slice(1)||\"*\",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(u){var l;return o[u]=!0,b.each(e[u]||[],function(e,u){var c=u(n,r,i);return\"string\"!=typeof c||a||o[c]?a?!(l=c):t:(n.dataTypes.unshift(c),s(c),!1)}),l}return s(n.dataTypes[0])||!o[\"*\"]&&s(\"*\")}function Mn(e,n){var r,i,o=b.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&b.extend(!0,e,r),e}b.fn.load=function(e,n,r){if(\"string\"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,u=e.indexOf(\" \");return u>=0&&(i=e.slice(u,e.length),e=e.slice(0,u)),b.isFunction(n)?(r=n,n=t):n&&\"object\"==typeof n&&(a=\"POST\"),s.length>0&&b.ajax({url:e,type:a,dataType:\"html\",data:n}).done(function(e){o=arguments,s.html(i?b(\"<div>\").append(b.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},b.each([\"ajaxStart\",\"ajaxStop\",\"ajaxComplete\",\"ajaxError\",\"ajaxSuccess\",\"ajaxSend\"],function(e,t){b.fn[t]=function(e){return this.on(t,e)}}),b.each([\"get\",\"post\"],function(e,n){b[n]=function(e,r,i,o){return b.isFunction(r)&&(o=o||i,i=r,r=t),b.ajax({url:e,type:n,dataType:o,data:r,success:i})}}),b.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:\"GET\",isLocal:Nn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:\"application/x-www-form-urlencoded; charset=UTF-8\",accepts:{\"*\":Dn,text:\"text/plain\",html:\"text/html\",xml:\"application/xml, text/xml\",json:\"application/json, text/javascript\"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:\"responseXML\",text:\"responseText\"},converters:{\"* text\":e.String,\"text html\":!0,\"text json\":b.parseJSON,\"text xml\":b.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Mn(Mn(e,b.ajaxSettings),t):Mn(b.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){\"object\"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,u,l,c,p=b.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?b(f):b.event,h=b.Deferred(),g=b.Callbacks(\"once memory\"),m=p.statusCode||{},y={},v={},x=0,T=\"canceled\",N={readyState:0,getResponseHeader:function(e){var t;if(2===x){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===x?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return x||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return x||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>x)for(t in e)m[t]=[m[t],e[t]];else N.always(e[N.status]);return this},abort:function(e){var t=e||T;return l&&l.abort(t),k(0,t),this}};if(h.promise(N).complete=g.add,N.success=N.done,N.error=N.fail,p.url=((e||p.url||yn)+\"\").replace(xn,\"\").replace(kn,mn[1]+\"//\"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=b.trim(p.dataType||\"*\").toLowerCase().match(w)||[\"\"],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||(\"http:\"===r[1]?80:443))==(mn[3]||(\"http:\"===mn[1]?80:443)))),p.data&&p.processData&&\"string\"!=typeof p.data&&(p.data=b.param(p.data,p.traditional)),qn(An,p,n,N),2===x)return N;u=p.global,u&&0===b.active++&&b.event.trigger(\"ajaxStart\"),p.type=p.type.toUpperCase(),p.hasContent=!Cn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?\"&\":\"?\")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,\"$1_=\"+vn++):o+(bn.test(o)?\"&\":\"?\")+\"_=\"+vn++)),p.ifModified&&(b.lastModified[o]&&N.setRequestHeader(\"If-Modified-Since\",b.lastModified[o]),b.etag[o]&&N.setRequestHeader(\"If-None-Match\",b.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&N.setRequestHeader(\"Content-Type\",p.contentType),N.setRequestHeader(\"Accept\",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+(\"*\"!==p.dataTypes[0]?\", \"+Dn+\"; q=0.01\":\"\"):p.accepts[\"*\"]);for(i in p.headers)N.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,N,p)===!1||2===x))return N.abort();T=\"abort\";for(i in{success:1,error:1,complete:1})N[i](p[i]);if(l=qn(jn,p,n,N)){N.readyState=1,u&&d.trigger(\"ajaxSend\",[N,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){N.abort(\"timeout\")},p.timeout));try{x=1,l.send(y,k)}catch(C){if(!(2>x))throw C;k(-1,C)}}else k(-1,\"No Transport\");function k(e,n,r,i){var c,y,v,w,T,C=n;2!==x&&(x=2,s&&clearTimeout(s),l=t,a=i||\"\",N.readyState=e>0?4:0,r&&(w=_n(p,N,r)),e>=200&&300>e||304===e?(p.ifModified&&(T=N.getResponseHeader(\"Last-Modified\"),T&&(b.lastModified[o]=T),T=N.getResponseHeader(\"etag\"),T&&(b.etag[o]=T)),204===e?(c=!0,C=\"nocontent\"):304===e?(c=!0,C=\"notmodified\"):(c=Fn(p,w),C=c.state,y=c.data,v=c.error,c=!v)):(v=C,(e||!C)&&(C=\"error\",0>e&&(e=0))),N.status=e,N.statusText=(n||C)+\"\",c?h.resolveWith(f,[y,C,N]):h.rejectWith(f,[N,C,v]),N.statusCode(m),m=t,u&&d.trigger(c?\"ajaxSuccess\":\"ajaxError\",[N,p,c?y:v]),g.fireWith(f,[N,C]),u&&(d.trigger(\"ajaxComplete\",[N,p]),--b.active||b.event.trigger(\"ajaxStop\")))}return N},getScript:function(e,n){return b.get(e,t,n,\"script\")},getJSON:function(e,t,n){return b.get(e,t,n,\"json\")}});function _n(e,n,r){var i,o,a,s,u=e.contents,l=e.dataTypes,c=e.responseFields;for(s in c)s in r&&(n[c[s]]=r[s]);while(\"*\"===l[0])l.shift(),o===t&&(o=e.mimeType||n.getResponseHeader(\"Content-Type\"));if(o)for(s in u)if(u[s]&&u[s].test(o)){l.unshift(s);break}if(l[0]in r)a=l[0];else{for(s in r){if(!l[0]||e.converters[s+\" \"+l[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==l[0]&&l.unshift(a),r[a]):t}function Fn(e,t){var n,r,i,o,a={},s=0,u=e.dataTypes.slice(),l=u[0];if(e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u[1])for(i in e.converters)a[i.toLowerCase()]=e.converters[i];for(;r=u[++s];)if(\"*\"!==r){if(\"*\"!==l&&l!==r){if(i=a[l+\" \"+r]||a[\"* \"+r],!i)for(n in a)if(o=n.split(\" \"),o[1]===r&&(i=a[l+\" \"+o[0]]||a[\"* \"+o[0]])){i===!0?i=a[n]:a[n]!==!0&&(r=o[0],u.splice(s--,0,r));break}if(i!==!0)if(i&&e[\"throws\"])t=i(t);else try{t=i(t)}catch(c){return{state:\"parsererror\",error:i?c:\"No conversion from \"+l+\" to \"+r}}}l=r}return{state:\"success\",data:t}}b.ajaxSetup({accepts:{script:\"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript\"},contents:{script:/(?:java|ecma)script/},converters:{\"text script\":function(e){return b.globalEval(e),e}}}),b.ajaxPrefilter(\"script\",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type=\"GET\",e.global=!1)}),b.ajaxTransport(\"script\",function(e){if(e.crossDomain){var n,r=o.head||b(\"head\")[0]||o.documentElement;return{send:function(t,i){n=o.createElement(\"script\"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,\"success\"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var On=[],Bn=/(=)\\?(?=&|$)|\\?\\?/;b.ajaxSetup({jsonp:\"callback\",jsonpCallback:function(){var e=On.pop()||b.expando+\"_\"+vn++;return this[e]=!0,e}}),b.ajaxPrefilter(\"json jsonp\",function(n,r,i){var o,a,s,u=n.jsonp!==!1&&(Bn.test(n.url)?\"url\":\"string\"==typeof n.data&&!(n.contentType||\"\").indexOf(\"application/x-www-form-urlencoded\")&&Bn.test(n.data)&&\"data\");return u||\"jsonp\"===n.dataTypes[0]?(o=n.jsonpCallback=b.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,u?n[u]=n[u].replace(Bn,\"$1\"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?\"&\":\"?\")+n.jsonp+\"=\"+o),n.converters[\"script json\"]=function(){return s||b.error(o+\" was not called\"),s[0]},n.dataTypes[0]=\"json\",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,On.push(o)),s&&b.isFunction(a)&&a(s[0]),s=a=t}),\"script\"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject(\"Microsoft.XMLHTTP\")}catch(t){}}b.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=b.ajaxSettings.xhr(),b.support.cors=!!Rn&&\"withCredentials\"in Rn,Rn=b.support.ajax=!!Rn,Rn&&b.ajaxTransport(function(n){if(!n.crossDomain||b.support.cors){var r;return{send:function(i,o){var a,s,u=n.xhr();if(n.username?u.open(n.type,n.url,n.async,n.username,n.password):u.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)u[s]=n.xhrFields[s];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType),n.crossDomain||i[\"X-Requested-With\"]||(i[\"X-Requested-With\"]=\"XMLHttpRequest\");try{for(s in i)u.setRequestHeader(s,i[s])}catch(l){}u.send(n.hasContent&&n.data||null),r=function(e,i){var s,l,c,p;try{if(r&&(i||4===u.readyState))if(r=t,a&&(u.onreadystatechange=b.noop,$n&&delete Pn[a]),i)4!==u.readyState&&u.abort();else{p={},s=u.status,l=u.getAllResponseHeaders(),\"string\"==typeof u.responseText&&(p.text=u.responseText);try{c=u.statusText}catch(f){c=\"\"}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,l)},n.async?4===u.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},b(e).unload($n)),Pn[a]=r),u.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp(\"^(?:([+-])=|)(\"+x+\")([a-z%]*)$\",\"i\"),Jn=/queueHooks$/,Gn=[nr],Qn={\"*\":[function(e,t){var n,r,i=this.createTween(e,t),o=Yn.exec(t),a=i.cur(),s=+a||0,u=1,l=20;if(o){if(n=+o[2],r=o[3]||(b.cssNumber[e]?\"\":\"px\"),\"px\"!==r&&s){s=b.css(i.elem,e,!0)||n||1;do u=u||\".5\",s/=u,b.style(i.elem,e,s+r);while(u!==(u=i.cur()/a)&&1!==u&&--l)}i.unit=r,i.start=s,i.end=o[1]?s+(o[1]+1)*n:n}return i}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=b.now()}function Zn(e,t){b.each(t,function(t,n){var r=(Qn[t]||[]).concat(Qn[\"*\"]),i=0,o=r.length;for(;o>i;i++)if(r[i].call(e,t,n))return})}function er(e,t,n){var r,i,o=0,a=Gn.length,s=b.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;for(;u>a;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),1>o&&u?n:(s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:b.extend({},t),opts:b.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=b.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)l.tweens[n].run(1);return t?s.resolveWith(e,[l,t]):s.rejectWith(e,[l,t]),this}}),c=l.props;for(tr(c,l.opts.specialEasing);a>o;o++)if(r=Gn[o].call(l,e,c,l.opts))return r;return Zn(l,c),b.isFunction(l.opts.start)&&l.opts.start.call(e,l),b.fx.timer(b.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always)}function tr(e,t){var n,r,i,o,a;for(i in e)if(r=b.camelCase(i),o=t[r],n=e[i],b.isArray(n)&&(o=n[1],n=e[i]=n[0]),i!==r&&(e[r]=n,delete e[i]),a=b.cssHooks[r],a&&\"expand\"in a){n=a.expand(n),delete e[r];for(i in n)i in e||(e[i]=n[i],t[i]=o)}else t[r]=o}b.Animation=b.extend(er,{tweener:function(e,t){b.isFunction(e)?(t=e,e=[\"*\"]):e=e.split(\" \");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,u,l,c,p,f=this,d=e.style,h={},g=[],m=e.nodeType&&nn(e);n.queue||(c=b._queueHooks(e,\"fx\"),null==c.unqueued&&(c.unqueued=0,p=c.empty.fire,c.empty.fire=function(){c.unqueued||p()}),c.unqueued++,f.always(function(){f.always(function(){c.unqueued--,b.queue(e,\"fx\").length||c.empty.fire()})})),1===e.nodeType&&(\"height\"in t||\"width\"in t)&&(n.overflow=[d.overflow,d.overflowX,d.overflowY],\"inline\"===b.css(e,\"display\")&&\"none\"===b.css(e,\"float\")&&(b.support.inlineBlockNeedsLayout&&\"inline\"!==un(e.nodeName)?d.zoom=1:d.display=\"inline-block\")),n.overflow&&(d.overflow=\"hidden\",b.support.shrinkWrapBlocks||f.always(function(){d.overflow=n.overflow[0],d.overflowX=n.overflow[1],d.overflowY=n.overflow[2]}));for(i in t)if(a=t[i],Vn.exec(a)){if(delete t[i],u=u||\"toggle\"===a,a===(m?\"hide\":\"show\"))continue;g.push(i)}if(o=g.length){s=b._data(e,\"fxshow\")||b._data(e,\"fxshow\",{}),\"hidden\"in s&&(m=s.hidden),u&&(s.hidden=!m),m?b(e).show():f.done(function(){b(e).hide()}),f.done(function(){var t;b._removeData(e,\"fxshow\");for(t in h)b.style(e,t,h[t])});for(i=0;o>i;i++)r=g[i],l=f.createTween(r,m?s[r]:0),h[r]=s[r]||b.style(e,r),r in s||(s[r]=l.start,m&&(l.end=l.start,l.start=\"width\"===r||\"height\"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}b.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||\"swing\",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(b.cssNumber[n]?\"\":\"px\")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?b.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=b.css(e.elem,e.prop,\"\"),t&&\"auto\"!==t?t:0):e.elem[e.prop]},set:function(e){b.fx.step[e.prop]?b.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[b.cssProps[e.prop]]||b.cssHooks[e.prop])?b.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},b.each([\"toggle\",\"show\",\"hide\"],function(e,t){var n=b.fn[t];b.fn[t]=function(e,r,i){return null==e||\"boolean\"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),b.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css(\"opacity\",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=b.isEmptyObject(e),o=b.speed(t,n,r),a=function(){var t=er(this,b.extend({},e),o);a.finish=function(){t.stop(!0)},(i||b._data(this,\"finish\"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return\"string\"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||\"fx\",[]),this.each(function(){var t=!0,n=null!=e&&e+\"queueHooks\",o=b.timers,a=b._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&b.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||\"fx\"),this.each(function(){var t,n=b._data(this),r=n[e+\"queue\"],i=n[e+\"queueHooks\"],o=b.timers,a=r?r.length:0;for(n.finish=!0,b.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r[\"margin\"+n]=r[\"padding\"+n]=e;return t&&(r.opacity=r.width=e),r}b.each({slideDown:ir(\"show\"),slideUp:ir(\"hide\"),slideToggle:ir(\"toggle\"),fadeIn:{opacity:\"show\"},fadeOut:{opacity:\"hide\"},fadeToggle:{opacity:\"toggle\"}},function(e,t){b.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),b.speed=function(e,t,n){var r=e&&\"object\"==typeof e?b.extend({},e):{complete:n||!n&&t||b.isFunction(e)&&e,duration:e,easing:n&&t||t&&!b.isFunction(t)&&t};return r.duration=b.fx.off?0:\"number\"==typeof r.duration?r.duration:r.duration in b.fx.speeds?b.fx.speeds[r.duration]:b.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue=\"fx\"),r.old=r.complete,r.complete=function(){b.isFunction(r.old)&&r.old.call(this),r.queue&&b.dequeue(this,r.queue)},r},b.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},b.timers=[],b.fx=rr.prototype.init,b.fx.tick=function(){var e,n=b.timers,r=0;for(Xn=b.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||b.fx.stop(),Xn=t},b.fx.timer=function(e){e()&&b.timers.push(e)&&b.fx.start()},b.fx.interval=13,b.fx.start=function(){Un||(Un=setInterval(b.fx.tick,b.fx.interval))},b.fx.stop=function(){clearInterval(Un),Un=null},b.fx.speeds={slow:600,fast:200,_default:400},b.fx.step={},b.expr&&b.expr.filters&&(b.expr.filters.animated=function(e){return b.grep(b.timers,function(t){return e===t.elem}).length}),b.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){b.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,b.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},b.offset={setOffset:function(e,t,n){var r=b.css(e,\"position\");\"static\"===r&&(e.style.position=\"relative\");var i=b(e),o=i.offset(),a=b.css(e,\"top\"),s=b.css(e,\"left\"),u=(\"absolute\"===r||\"fixed\"===r)&&b.inArray(\"auto\",[a,s])>-1,l={},c={},p,f;u?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),b.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(l.top=t.top-o.top+p),null!=t.left&&(l.left=t.left-o.left+f),\"using\"in t?t.using.call(e,l):i.css(l)}},b.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return\"fixed\"===b.css(r,\"position\")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),b.nodeName(e[0],\"html\")||(n=e.offset()),n.top+=b.css(e[0],\"borderTopWidth\",!0),n.left+=b.css(e[0],\"borderLeftWidth\",!0)),{top:t.top-n.top-b.css(r,\"marginTop\",!0),left:t.left-n.left-b.css(r,\"marginLeft\",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||o.documentElement;while(e&&!b.nodeName(e,\"html\")&&\"static\"===b.css(e,\"position\"))e=e.offsetParent;return e||o.documentElement})}}),b.each({scrollLeft:\"pageXOffset\",scrollTop:\"pageYOffset\"},function(e,n){var r=/Y/.test(n);b.fn[e]=function(i){return b.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?b(a).scrollLeft():o,r?o:b(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return b.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}b.each({Height:\"height\",Width:\"width\"},function(e,n){b.each({padding:\"inner\"+e,content:n,\"\":\"outer\"+e},function(r,i){b.fn[i]=function(i,o){var a=arguments.length&&(r||\"boolean\"!=typeof i),s=r||(i===!0||o===!0?\"margin\":\"border\");return b.access(this,function(n,r,i){var o;return b.isWindow(n)?n.document.documentElement[\"client\"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body[\"scroll\"+e],o[\"scroll\"+e],n.body[\"offset\"+e],o[\"offset\"+e],o[\"client\"+e])):i===t?b.css(n,r,s):b.style(n,r,i,s)},n,a?i:t,a,null)}})}),e.jQuery=e.$=b,\"function\"==typeof define&&define.amd&&define.amd.jQuery&&define(\"jquery\",[],function(){return b})})(window);"
  },
  {
    "path": "vendor/mootools.js",
    "content": "/*\n---\nMooTools: the javascript framework\n\nweb build:\n - http://mootools.net/core/76bf47062d6c1983d66ce47ad66aa0e0\n\npackager build:\n - packager build Core/Core Core/Array Core/String Core/Number Core/Function Core/Object Core/Event Core/Browser Core/Class Core/Class.Extras Core/Slick.Parser Core/Slick.Finder Core/Element Core/Element.Style Core/Element.Event Core/Element.Delegation Core/Element.Dimensions Core/Fx Core/Fx.CSS Core/Fx.Tween Core/Fx.Morph Core/Fx.Transitions Core/Request Core/Request.HTML Core/Request.JSON Core/Cookie Core/JSON Core/DOMReady Core/Swiff\n\n...\n*/\n\n/*\n---\n\nname: Core\n\ndescription: The heart of MooTools.\n\nlicense: MIT-style license.\n\ncopyright: Copyright (c) 2006-2012 [Valerio Proietti](http://mad4milk.net/).\n\nauthors: The MooTools production team (http://mootools.net/developers/)\n\ninspiration:\n  - Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php)\n  - Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php)\n\nprovides: [Core, MooTools, Type, typeOf, instanceOf, Native]\n\n...\n*/\n\n(function(){\n\nthis.MooTools = {\n\tversion: '1.4.5',\n\tbuild: '74e34796f5f76640cdb98853004650aea1499d69'\n};\n\n// typeOf, instanceOf\n\nvar typeOf = this.typeOf = function(item){\n\tif (item == null) return 'null';\n\tif (item.$family != null) return item.$family();\n\n\tif (item.nodeName){\n\t\tif (item.nodeType == 1) return 'element';\n\t\tif (item.nodeType == 3) return (/\\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';\n\t} else if (typeof item.length == 'number'){\n\t\tif (item.callee) return 'arguments';\n\t\tif ('item' in item) return 'collection';\n\t}\n\n\treturn typeof item;\n};\n\nvar instanceOf = this.instanceOf = function(item, object){\n\tif (item == null) return false;\n\tvar constructor = item.$constructor || item.constructor;\n\twhile (constructor){\n\t\tif (constructor === object) return true;\n\t\tconstructor = constructor.parent;\n\t}\n\t/*<ltIE8>*/\n\tif (!item.hasOwnProperty) return false;\n\t/*</ltIE8>*/\n\treturn item instanceof object;\n};\n\n// Function overloading\n\nvar Function = this.Function;\n\nvar enumerables = true;\nfor (var i in {toString: 1}) enumerables = null;\nif (enumerables) enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor'];\n\nFunction.prototype.overloadSetter = function(usePlural){\n\tvar self = this;\n\treturn function(a, b){\n\t\tif (a == null) return this;\n\t\tif (usePlural || typeof a != 'string'){\n\t\t\tfor (var k in a) self.call(this, k, a[k]);\n\t\t\tif (enumerables) for (var i = enumerables.length; i--;){\n\t\t\t\tk = enumerables[i];\n\t\t\t\tif (a.hasOwnProperty(k)) self.call(this, k, a[k]);\n\t\t\t}\n\t\t} else {\n\t\t\tself.call(this, a, b);\n\t\t}\n\t\treturn this;\n\t};\n};\n\nFunction.prototype.overloadGetter = function(usePlural){\n\tvar self = this;\n\treturn function(a){\n\t\tvar args, result;\n\t\tif (typeof a != 'string') args = a;\n\t\telse if (arguments.length > 1) args = arguments;\n\t\telse if (usePlural) args = [a];\n\t\tif (args){\n\t\t\tresult = {};\n\t\t\tfor (var i = 0; i < args.length; i++) result[args[i]] = self.call(this, args[i]);\n\t\t} else {\n\t\t\tresult = self.call(this, a);\n\t\t}\n\t\treturn result;\n\t};\n};\n\nFunction.prototype.extend = function(key, value){\n\tthis[key] = value;\n}.overloadSetter();\n\nFunction.prototype.implement = function(key, value){\n\tthis.prototype[key] = value;\n}.overloadSetter();\n\n// From\n\nvar slice = Array.prototype.slice;\n\nFunction.from = function(item){\n\treturn (typeOf(item) == 'function') ? item : function(){\n\t\treturn item;\n\t};\n};\n\nArray.from = function(item){\n\tif (item == null) return [];\n\treturn (Type.isEnumerable(item) && typeof item != 'string') ? (typeOf(item) == 'array') ? item : slice.call(item) : [item];\n};\n\nNumber.from = function(item){\n\tvar number = parseFloat(item);\n\treturn isFinite(number) ? number : null;\n};\n\nString.from = function(item){\n\treturn item + '';\n};\n\n// hide, protect\n\nFunction.implement({\n\n\thide: function(){\n\t\tthis.$hidden = true;\n\t\treturn this;\n\t},\n\n\tprotect: function(){\n\t\tthis.$protected = true;\n\t\treturn this;\n\t}\n\n});\n\n// Type\n\nvar Type = this.Type = function(name, object){\n\tif (name){\n\t\tvar lower = name.toLowerCase();\n\t\tvar typeCheck = function(item){\n\t\t\treturn (typeOf(item) == lower);\n\t\t};\n\n\t\tType['is' + name] = typeCheck;\n\t\tif (object != null){\n\t\t\tobject.prototype.$family = (function(){\n\t\t\t\treturn lower;\n\t\t\t}).hide();\n\t\t\t\n\t\t}\n\t}\n\n\tif (object == null) return null;\n\n\tobject.extend(this);\n\tobject.$constructor = Type;\n\tobject.prototype.$constructor = object;\n\n\treturn object;\n};\n\nvar toString = Object.prototype.toString;\n\nType.isEnumerable = function(item){\n\treturn (item != null && typeof item.length == 'number' && toString.call(item) != '[object Function]' );\n};\n\nvar hooks = {};\n\nvar hooksOf = function(object){\n\tvar type = typeOf(object.prototype);\n\treturn hooks[type] || (hooks[type] = []);\n};\n\nvar implement = function(name, method){\n\tif (method && method.$hidden) return;\n\n\tvar hooks = hooksOf(this);\n\n\tfor (var i = 0; i < hooks.length; i++){\n\t\tvar hook = hooks[i];\n\t\tif (typeOf(hook) == 'type') implement.call(hook, name, method);\n\t\telse hook.call(this, name, method);\n\t}\n\n\tvar previous = this.prototype[name];\n\tif (previous == null || !previous.$protected) this.prototype[name] = method;\n\n\tif (this[name] == null && typeOf(method) == 'function') extend.call(this, name, function(item){\n\t\treturn method.apply(item, slice.call(arguments, 1));\n\t});\n};\n\nvar extend = function(name, method){\n\tif (method && method.$hidden) return;\n\tvar previous = this[name];\n\tif (previous == null || !previous.$protected) this[name] = method;\n};\n\nType.implement({\n\n\timplement: implement.overloadSetter(),\n\n\textend: extend.overloadSetter(),\n\n\talias: function(name, existing){\n\t\timplement.call(this, name, this.prototype[existing]);\n\t}.overloadSetter(),\n\n\tmirror: function(hook){\n\t\thooksOf(this).push(hook);\n\t\treturn this;\n\t}\n\n});\n\nnew Type('Type', Type);\n\n// Default Types\n\nvar force = function(name, object, methods){\n\tvar isType = (object != Object),\n\t\tprototype = object.prototype;\n\n\tif (isType) object = new Type(name, object);\n\n\tfor (var i = 0, l = methods.length; i < l; i++){\n\t\tvar key = methods[i],\n\t\t\tgeneric = object[key],\n\t\t\tproto = prototype[key];\n\n\t\tif (generic) generic.protect();\n\t\tif (isType && proto) object.implement(key, proto.protect());\n\t}\n\n\tif (isType){\n\t\tvar methodsEnumerable = prototype.propertyIsEnumerable(methods[0]);\n\t\tobject.forEachMethod = function(fn){\n\t\t\tif (!methodsEnumerable) for (var i = 0, l = methods.length; i < l; i++){\n\t\t\t\tfn.call(prototype, prototype[methods[i]], methods[i]);\n\t\t\t}\n\t\t\tfor (var key in prototype) fn.call(prototype, prototype[key], key)\n\t\t};\n\t}\n\n\treturn force;\n};\n\nforce('String', String, [\n\t'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',\n\t'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'\n])('Array', Array, [\n\t'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',\n\t'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'\n])('Number', Number, [\n\t'toExponential', 'toFixed', 'toLocaleString', 'toPrecision'\n])('Function', Function, [\n\t'apply', 'call', 'bind'\n])('RegExp', RegExp, [\n\t'exec', 'test'\n])('Object', Object, [\n\t'create', 'defineProperty', 'defineProperties', 'keys',\n\t'getPrototypeOf', 'getOwnPropertyDescriptor', 'getOwnPropertyNames',\n\t'preventExtensions', 'isExtensible', 'seal', 'isSealed', 'freeze', 'isFrozen'\n])('Date', Date, ['now']);\n\nObject.extend = extend.overloadSetter();\n\nDate.extend('now', function(){\n\treturn +(new Date);\n});\n\nnew Type('Boolean', Boolean);\n\n// fixes NaN returning as Number\n\nNumber.prototype.$family = function(){\n\treturn isFinite(this) ? 'number' : 'null';\n}.hide();\n\n// Number.random\n\nNumber.extend('random', function(min, max){\n\treturn Math.floor(Math.random() * (max - min + 1) + min);\n});\n\n// forEach, each\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nObject.extend('forEach', function(object, fn, bind){\n\tfor (var key in object){\n\t\tif (hasOwnProperty.call(object, key)) fn.call(bind, object[key], key, object);\n\t}\n});\n\nObject.each = Object.forEach;\n\nArray.implement({\n\n\tforEach: function(fn, bind){\n\t\tfor (var i = 0, l = this.length; i < l; i++){\n\t\t\tif (i in this) fn.call(bind, this[i], i, this);\n\t\t}\n\t},\n\n\teach: function(fn, bind){\n\t\tArray.forEach(this, fn, bind);\n\t\treturn this;\n\t}\n\n});\n\n// Array & Object cloning, Object merging and appending\n\nvar cloneOf = function(item){\n\tswitch (typeOf(item)){\n\t\tcase 'array': return item.clone();\n\t\tcase 'object': return Object.clone(item);\n\t\tdefault: return item;\n\t}\n};\n\nArray.implement('clone', function(){\n\tvar i = this.length, clone = new Array(i);\n\twhile (i--) clone[i] = cloneOf(this[i]);\n\treturn clone;\n});\n\nvar mergeOne = function(source, key, current){\n\tswitch (typeOf(current)){\n\t\tcase 'object':\n\t\t\tif (typeOf(source[key]) == 'object') Object.merge(source[key], current);\n\t\t\telse source[key] = Object.clone(current);\n\t\tbreak;\n\t\tcase 'array': source[key] = current.clone(); break;\n\t\tdefault: source[key] = current;\n\t}\n\treturn source;\n};\n\nObject.extend({\n\n\tmerge: function(source, k, v){\n\t\tif (typeOf(k) == 'string') return mergeOne(source, k, v);\n\t\tfor (var i = 1, l = arguments.length; i < l; i++){\n\t\t\tvar object = arguments[i];\n\t\t\tfor (var key in object) mergeOne(source, key, object[key]);\n\t\t}\n\t\treturn source;\n\t},\n\n\tclone: function(object){\n\t\tvar clone = {};\n\t\tfor (var key in object) clone[key] = cloneOf(object[key]);\n\t\treturn clone;\n\t},\n\n\tappend: function(original){\n\t\tfor (var i = 1, l = arguments.length; i < l; i++){\n\t\t\tvar extended = arguments[i] || {};\n\t\t\tfor (var key in extended) original[key] = extended[key];\n\t\t}\n\t\treturn original;\n\t}\n\n});\n\n// Object-less types\n\n['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each(function(name){\n\tnew Type(name);\n});\n\n// Unique ID\n\nvar UID = Date.now();\n\nString.extend('uniqueID', function(){\n\treturn (UID++).toString(36);\n});\n\n\n\n})();\n\n\n/*\n---\n\nname: Array\n\ndescription: Contains Array Prototypes like each, contains, and erase.\n\nlicense: MIT-style license.\n\nrequires: Type\n\nprovides: Array\n\n...\n*/\n\nArray.implement({\n\n\t/*<!ES5>*/\n\tevery: function(fn, bind){\n\t\tfor (var i = 0, l = this.length >>> 0; i < l; i++){\n\t\t\tif ((i in this) && !fn.call(bind, this[i], i, this)) return false;\n\t\t}\n\t\treturn true;\n\t},\n\n\tfilter: function(fn, bind){\n\t\tvar results = [];\n\t\tfor (var value, i = 0, l = this.length >>> 0; i < l; i++) if (i in this){\n\t\t\tvalue = this[i];\n\t\t\tif (fn.call(bind, value, i, this)) results.push(value);\n\t\t}\n\t\treturn results;\n\t},\n\n\tindexOf: function(item, from){\n\t\tvar length = this.length >>> 0;\n\t\tfor (var i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++){\n\t\t\tif (this[i] === item) return i;\n\t\t}\n\t\treturn -1;\n\t},\n\n\tmap: function(fn, bind){\n\t\tvar length = this.length >>> 0, results = Array(length);\n\t\tfor (var i = 0; i < length; i++){\n\t\t\tif (i in this) results[i] = fn.call(bind, this[i], i, this);\n\t\t}\n\t\treturn results;\n\t},\n\n\tsome: function(fn, bind){\n\t\tfor (var i = 0, l = this.length >>> 0; i < l; i++){\n\t\t\tif ((i in this) && fn.call(bind, this[i], i, this)) return true;\n\t\t}\n\t\treturn false;\n\t},\n\t/*</!ES5>*/\n\n\tclean: function(){\n\t\treturn this.filter(function(item){\n\t\t\treturn item != null;\n\t\t});\n\t},\n\n\tinvoke: function(methodName){\n\t\tvar args = Array.slice(arguments, 1);\n\t\treturn this.map(function(item){\n\t\t\treturn item[methodName].apply(item, args);\n\t\t});\n\t},\n\n\tassociate: function(keys){\n\t\tvar obj = {}, length = Math.min(this.length, keys.length);\n\t\tfor (var i = 0; i < length; i++) obj[keys[i]] = this[i];\n\t\treturn obj;\n\t},\n\n\tlink: function(object){\n\t\tvar result = {};\n\t\tfor (var i = 0, l = this.length; i < l; i++){\n\t\t\tfor (var key in object){\n\t\t\t\tif (object[key](this[i])){\n\t\t\t\t\tresult[key] = this[i];\n\t\t\t\t\tdelete object[key];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t},\n\n\tcontains: function(item, from){\n\t\treturn this.indexOf(item, from) != -1;\n\t},\n\n\tappend: function(array){\n\t\tthis.push.apply(this, array);\n\t\treturn this;\n\t},\n\n\tgetLast: function(){\n\t\treturn (this.length) ? this[this.length - 1] : null;\n\t},\n\n\tgetRandom: function(){\n\t\treturn (this.length) ? this[Number.random(0, this.length - 1)] : null;\n\t},\n\n\tinclude: function(item){\n\t\tif (!this.contains(item)) this.push(item);\n\t\treturn this;\n\t},\n\n\tcombine: function(array){\n\t\tfor (var i = 0, l = array.length; i < l; i++) this.include(array[i]);\n\t\treturn this;\n\t},\n\n\terase: function(item){\n\t\tfor (var i = this.length; i--;){\n\t\t\tif (this[i] === item) this.splice(i, 1);\n\t\t}\n\t\treturn this;\n\t},\n\n\tempty: function(){\n\t\tthis.length = 0;\n\t\treturn this;\n\t},\n\n\tflatten: function(){\n\t\tvar array = [];\n\t\tfor (var i = 0, l = this.length; i < l; i++){\n\t\t\tvar type = typeOf(this[i]);\n\t\t\tif (type == 'null') continue;\n\t\t\tarray = array.concat((type == 'array' || type == 'collection' || type == 'arguments' || instanceOf(this[i], Array)) ? Array.flatten(this[i]) : this[i]);\n\t\t}\n\t\treturn array;\n\t},\n\n\tpick: function(){\n\t\tfor (var i = 0, l = this.length; i < l; i++){\n\t\t\tif (this[i] != null) return this[i];\n\t\t}\n\t\treturn null;\n\t},\n\n\thexToRgb: function(array){\n\t\tif (this.length != 3) return null;\n\t\tvar rgb = this.map(function(value){\n\t\t\tif (value.length == 1) value += value;\n\t\t\treturn value.toInt(16);\n\t\t});\n\t\treturn (array) ? rgb : 'rgb(' + rgb + ')';\n\t},\n\n\trgbToHex: function(array){\n\t\tif (this.length < 3) return null;\n\t\tif (this.length == 4 && this[3] == 0 && !array) return 'transparent';\n\t\tvar hex = [];\n\t\tfor (var i = 0; i < 3; i++){\n\t\t\tvar bit = (this[i] - 0).toString(16);\n\t\t\thex.push((bit.length == 1) ? '0' + bit : bit);\n\t\t}\n\t\treturn (array) ? hex : '#' + hex.join('');\n\t}\n\n});\n\n\n\n\n/*\n---\n\nname: String\n\ndescription: Contains String Prototypes like camelCase, capitalize, test, and toInt.\n\nlicense: MIT-style license.\n\nrequires: Type\n\nprovides: String\n\n...\n*/\n\nString.implement({\n\n\ttest: function(regex, params){\n\t\treturn ((typeOf(regex) == 'regexp') ? regex : new RegExp('' + regex, params)).test(this);\n\t},\n\n\tcontains: function(string, separator){\n\t\treturn (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;\n\t},\n\n\ttrim: function(){\n\t\treturn String(this).replace(/^\\s+|\\s+$/g, '');\n\t},\n\n\tclean: function(){\n\t\treturn String(this).replace(/\\s+/g, ' ').trim();\n\t},\n\n\tcamelCase: function(){\n\t\treturn String(this).replace(/-\\D/g, function(match){\n\t\t\treturn match.charAt(1).toUpperCase();\n\t\t});\n\t},\n\n\thyphenate: function(){\n\t\treturn String(this).replace(/[A-Z]/g, function(match){\n\t\t\treturn ('-' + match.charAt(0).toLowerCase());\n\t\t});\n\t},\n\n\tcapitalize: function(){\n\t\treturn String(this).replace(/\\b[a-z]/g, function(match){\n\t\t\treturn match.toUpperCase();\n\t\t});\n\t},\n\n\tescapeRegExp: function(){\n\t\treturn String(this).replace(/([-.*+?^${}()|[\\]\\/\\\\])/g, '\\\\$1');\n\t},\n\n\ttoInt: function(base){\n\t\treturn parseInt(this, base || 10);\n\t},\n\n\ttoFloat: function(){\n\t\treturn parseFloat(this);\n\t},\n\n\thexToRgb: function(array){\n\t\tvar hex = String(this).match(/^#?(\\w{1,2})(\\w{1,2})(\\w{1,2})$/);\n\t\treturn (hex) ? hex.slice(1).hexToRgb(array) : null;\n\t},\n\n\trgbToHex: function(array){\n\t\tvar rgb = String(this).match(/\\d{1,3}/g);\n\t\treturn (rgb) ? rgb.rgbToHex(array) : null;\n\t},\n\n\tsubstitute: function(object, regexp){\n\t\treturn String(this).replace(regexp || (/\\\\?\\{([^{}]+)\\}/g), function(match, name){\n\t\t\tif (match.charAt(0) == '\\\\') return match.slice(1);\n\t\t\treturn (object[name] != null) ? object[name] : '';\n\t\t});\n\t}\n\n});\n\n\n/*\n---\n\nname: Number\n\ndescription: Contains Number Prototypes like limit, round, times, and ceil.\n\nlicense: MIT-style license.\n\nrequires: Type\n\nprovides: Number\n\n...\n*/\n\nNumber.implement({\n\n\tlimit: function(min, max){\n\t\treturn Math.min(max, Math.max(min, this));\n\t},\n\n\tround: function(precision){\n\t\tprecision = Math.pow(10, precision || 0).toFixed(precision < 0 ? -precision : 0);\n\t\treturn Math.round(this * precision) / precision;\n\t},\n\n\ttimes: function(fn, bind){\n\t\tfor (var i = 0; i < this; i++) fn.call(bind, i, this);\n\t},\n\n\ttoFloat: function(){\n\t\treturn parseFloat(this);\n\t},\n\n\ttoInt: function(base){\n\t\treturn parseInt(this, base || 10);\n\t}\n\n});\n\nNumber.alias('each', 'times');\n\n(function(math){\n\tvar methods = {};\n\tmath.each(function(name){\n\t\tif (!Number[name]) methods[name] = function(){\n\t\t\treturn Math[name].apply(null, [this].concat(Array.from(arguments)));\n\t\t};\n\t});\n\tNumber.implement(methods);\n})(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);\n\n\n/*\n---\n\nname: Function\n\ndescription: Contains Function Prototypes like create, bind, pass, and delay.\n\nlicense: MIT-style license.\n\nrequires: Type\n\nprovides: Function\n\n...\n*/\n\nFunction.extend({\n\n\tattempt: function(){\n\t\tfor (var i = 0, l = arguments.length; i < l; i++){\n\t\t\ttry {\n\t\t\t\treturn arguments[i]();\n\t\t\t} catch (e){}\n\t\t}\n\t\treturn null;\n\t}\n\n});\n\nFunction.implement({\n\n\tattempt: function(args, bind){\n\t\ttry {\n\t\t\treturn this.apply(bind, Array.from(args));\n\t\t} catch (e){}\n\n\t\treturn null;\n\t},\n\n\t/*<!ES5-bind>*/\n\tbind: function(that){\n\t\tvar self = this,\n\t\t\targs = arguments.length > 1 ? Array.slice(arguments, 1) : null,\n\t\t\tF = function(){};\n\n\t\tvar bound = function(){\n\t\t\tvar context = that, length = arguments.length;\n\t\t\tif (this instanceof bound){\n\t\t\t\tF.prototype = self.prototype;\n\t\t\t\tcontext = new F;\n\t\t\t}\n\t\t\tvar result = (!args && !length)\n\t\t\t\t? self.call(context)\n\t\t\t\t: self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);\n\t\t\treturn context == that ? result : context;\n\t\t};\n\t\treturn bound;\n\t},\n\t/*</!ES5-bind>*/\n\n\tpass: function(args, bind){\n\t\tvar self = this;\n\t\tif (args != null) args = Array.from(args);\n\t\treturn function(){\n\t\t\treturn self.apply(bind, args || arguments);\n\t\t};\n\t},\n\n\tdelay: function(delay, bind, args){\n\t\treturn setTimeout(this.pass((args == null ? [] : args), bind), delay);\n\t},\n\n\tperiodical: function(periodical, bind, args){\n\t\treturn setInterval(this.pass((args == null ? [] : args), bind), periodical);\n\t}\n\n});\n\n\n\n\n/*\n---\n\nname: Object\n\ndescription: Object generic methods\n\nlicense: MIT-style license.\n\nrequires: Type\n\nprovides: [Object, Hash]\n\n...\n*/\n\n(function(){\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nObject.extend({\n\n\tsubset: function(object, keys){\n\t\tvar results = {};\n\t\tfor (var i = 0, l = keys.length; i < l; i++){\n\t\t\tvar k = keys[i];\n\t\t\tif (k in object) results[k] = object[k];\n\t\t}\n\t\treturn results;\n\t},\n\n\tmap: function(object, fn, bind){\n\t\tvar results = {};\n\t\tfor (var key in object){\n\t\t\tif (hasOwnProperty.call(object, key)) results[key] = fn.call(bind, object[key], key, object);\n\t\t}\n\t\treturn results;\n\t},\n\n\tfilter: function(object, fn, bind){\n\t\tvar results = {};\n\t\tfor (var key in object){\n\t\t\tvar value = object[key];\n\t\t\tif (hasOwnProperty.call(object, key) && fn.call(bind, value, key, object)) results[key] = value;\n\t\t}\n\t\treturn results;\n\t},\n\n\tevery: function(object, fn, bind){\n\t\tfor (var key in object){\n\t\t\tif (hasOwnProperty.call(object, key) && !fn.call(bind, object[key], key)) return false;\n\t\t}\n\t\treturn true;\n\t},\n\n\tsome: function(object, fn, bind){\n\t\tfor (var key in object){\n\t\t\tif (hasOwnProperty.call(object, key) && fn.call(bind, object[key], key)) return true;\n\t\t}\n\t\treturn false;\n\t},\n\n\tkeys: function(object){\n\t\tvar keys = [];\n\t\tfor (var key in object){\n\t\t\tif (hasOwnProperty.call(object, key)) keys.push(key);\n\t\t}\n\t\treturn keys;\n\t},\n\n\tvalues: function(object){\n\t\tvar values = [];\n\t\tfor (var key in object){\n\t\t\tif (hasOwnProperty.call(object, key)) values.push(object[key]);\n\t\t}\n\t\treturn values;\n\t},\n\n\tgetLength: function(object){\n\t\treturn Object.keys(object).length;\n\t},\n\n\tkeyOf: function(object, value){\n\t\tfor (var key in object){\n\t\t\tif (hasOwnProperty.call(object, key) && object[key] === value) return key;\n\t\t}\n\t\treturn null;\n\t},\n\n\tcontains: function(object, value){\n\t\treturn Object.keyOf(object, value) != null;\n\t},\n\n\ttoQueryString: function(object, base){\n\t\tvar queryString = [];\n\n\t\tObject.each(object, function(value, key){\n\t\t\tif (base) key = base + '[' + key + ']';\n\t\t\tvar result;\n\t\t\tswitch (typeOf(value)){\n\t\t\t\tcase 'object': result = Object.toQueryString(value, key); break;\n\t\t\t\tcase 'array':\n\t\t\t\t\tvar qs = {};\n\t\t\t\t\tvalue.each(function(val, i){\n\t\t\t\t\t\tqs[i] = val;\n\t\t\t\t\t});\n\t\t\t\t\tresult = Object.toQueryString(qs, key);\n\t\t\t\tbreak;\n\t\t\t\tdefault: result = key + '=' + encodeURIComponent(value);\n\t\t\t}\n\t\t\tif (value != null) queryString.push(result);\n\t\t});\n\n\t\treturn queryString.join('&');\n\t}\n\n});\n\n})();\n\n\n\n\n/*\n---\n\nname: Browser\n\ndescription: The Browser Object. Contains Browser initialization, Window and Document, and the Browser Hash.\n\nlicense: MIT-style license.\n\nrequires: [Array, Function, Number, String]\n\nprovides: [Browser, Window, Document]\n\n...\n*/\n\n(function(){\n\nvar document = this.document;\nvar window = document.window = this;\n\nvar ua = navigator.userAgent.toLowerCase(),\n\tplatform = navigator.platform.toLowerCase(),\n\tUA = ua.match(/(opera|ie|firefox|chrome|version)[\\s\\/:]([\\w\\d\\.]+)?.*?(safari|version[\\s\\/:]([\\w\\d\\.]+)|$)/) || [null, 'unknown', 0],\n\tmode = UA[1] == 'ie' && document.documentMode;\n\nvar Browser = this.Browser = {\n\n\textend: Function.prototype.extend,\n\n\tname: (UA[1] == 'version') ? UA[3] : UA[1],\n\n\tversion: mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),\n\n\tPlatform: {\n\t\tname: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]\n\t},\n\n\tFeatures: {\n\t\txpath: !!(document.evaluate),\n\t\tair: !!(window.runtime),\n\t\tquery: !!(document.querySelector),\n\t\tjson: !!(window.JSON)\n\t},\n\n\tPlugins: {}\n\n};\n\nBrowser[Browser.name] = true;\nBrowser[Browser.name + parseInt(Browser.version, 10)] = true;\nBrowser.Platform[Browser.Platform.name] = true;\n\n// Request\n\nBrowser.Request = (function(){\n\n\tvar XMLHTTP = function(){\n\t\treturn new XMLHttpRequest();\n\t};\n\n\tvar MSXML2 = function(){\n\t\treturn new ActiveXObject('MSXML2.XMLHTTP');\n\t};\n\n\tvar MSXML = function(){\n\t\treturn new ActiveXObject('Microsoft.XMLHTTP');\n\t};\n\n\treturn Function.attempt(function(){\n\t\tXMLHTTP();\n\t\treturn XMLHTTP;\n\t}, function(){\n\t\tMSXML2();\n\t\treturn MSXML2;\n\t}, function(){\n\t\tMSXML();\n\t\treturn MSXML;\n\t});\n\n})();\n\nBrowser.Features.xhr = !!(Browser.Request);\n\n// Flash detection\n\nvar version = (Function.attempt(function(){\n\treturn navigator.plugins['Shockwave Flash'].description;\n}, function(){\n\treturn new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');\n}) || '0 r0').match(/\\d+/g);\n\nBrowser.Plugins.Flash = {\n\tversion: Number(version[0] || '0.' + version[1]) || 0,\n\tbuild: Number(version[2]) || 0\n};\n\n// String scripts\n\nBrowser.exec = function(text){\n\tif (!text) return text;\n\tif (window.execScript){\n\t\twindow.execScript(text);\n\t} else {\n\t\tvar script = document.createElement('script');\n\t\tscript.setAttribute('type', 'text/javascript');\n\t\tscript.text = text;\n\t\tdocument.head.appendChild(script);\n\t\tdocument.head.removeChild(script);\n\t}\n\treturn text;\n};\n\nString.implement('stripScripts', function(exec){\n\tvar scripts = '';\n\tvar text = this.replace(/<script[^>]*>([\\s\\S]*?)<\\/script>/gi, function(all, code){\n\t\tscripts += code + '\\n';\n\t\treturn '';\n\t});\n\tif (exec === true) Browser.exec(scripts);\n\telse if (typeOf(exec) == 'function') exec(scripts, text);\n\treturn text;\n});\n\n// Window, Document\n\nBrowser.extend({\n\tDocument: this.Document,\n\tWindow: this.Window,\n\tElement: this.Element,\n\tEvent: this.Event\n});\n\nthis.Window = this.$constructor = new Type('Window', function(){});\n\nthis.$family = Function.from('window').hide();\n\nWindow.mirror(function(name, method){\n\twindow[name] = method;\n});\n\nthis.Document = document.$constructor = new Type('Document', function(){});\n\ndocument.$family = Function.from('document').hide();\n\nDocument.mirror(function(name, method){\n\tdocument[name] = method;\n});\n\ndocument.html = document.documentElement;\nif (!document.head) document.head = document.getElementsByTagName('head')[0];\n\nif (document.execCommand) try {\n\tdocument.execCommand(\"BackgroundImageCache\", false, true);\n} catch (e){}\n\n/*<ltIE9>*/\nif (this.attachEvent && !this.addEventListener){\n\tvar unloadEvent = function(){\n\t\tthis.detachEvent('onunload', unloadEvent);\n\t\tdocument.head = document.html = document.window = null;\n\t};\n\tthis.attachEvent('onunload', unloadEvent);\n}\n\n// IE fails on collections and <select>.options (refers to <select>)\nvar arrayFrom = Array.from;\ntry {\n\tarrayFrom(document.html.childNodes);\n} catch(e){\n\tArray.from = function(item){\n\t\tif (typeof item != 'string' && Type.isEnumerable(item) && typeOf(item) != 'array'){\n\t\t\tvar i = item.length, array = new Array(i);\n\t\t\twhile (i--) array[i] = item[i];\n\t\t\treturn array;\n\t\t}\n\t\treturn arrayFrom(item);\n\t};\n\n\tvar prototype = Array.prototype,\n\t\tslice = prototype.slice;\n\t['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice'].each(function(name){\n\t\tvar method = prototype[name];\n\t\tArray[name] = function(item){\n\t\t\treturn method.apply(Array.from(item), slice.call(arguments, 1));\n\t\t};\n\t});\n}\n/*</ltIE9>*/\n\n\n\n})();\n\n\n/*\n---\n\nname: Event\n\ndescription: Contains the Event Type, to make the event object cross-browser.\n\nlicense: MIT-style license.\n\nrequires: [Window, Document, Array, Function, String, Object]\n\nprovides: Event\n\n...\n*/\n\n(function() {\n\nvar _keys = {};\n\nvar DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){\n\tif (!win) win = window;\n\tevent = event || win.event;\n\tif (event.$extended) return event;\n\tthis.event = event;\n\tthis.$extended = true;\n\tthis.shift = event.shiftKey;\n\tthis.control = event.ctrlKey;\n\tthis.alt = event.altKey;\n\tthis.meta = event.metaKey;\n\tvar type = this.type = event.type;\n\tvar target = event.target || event.srcElement;\n\twhile (target && target.nodeType == 3) target = target.parentNode;\n\tthis.target = document.id(target);\n\n\tif (type.indexOf('key') == 0){\n\t\tvar code = this.code = (event.which || event.keyCode);\n\t\tthis.key = _keys[code];\n\t\tif (type == 'keydown'){\n\t\t\tif (code > 111 && code < 124) this.key = 'f' + (code - 111);\n\t\t\telse if (code > 95 && code < 106) this.key = code - 96;\n\t\t}\n\t\tif (this.key == null) this.key = String.fromCharCode(code).toLowerCase();\n\t} else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type == 'DOMMouseScroll' || type.indexOf('mouse') == 0){\n\t\tvar doc = win.document;\n\t\tdoc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;\n\t\tthis.page = {\n\t\t\tx: (event.pageX != null) ? event.pageX : event.clientX + doc.scrollLeft,\n\t\t\ty: (event.pageY != null) ? event.pageY : event.clientY + doc.scrollTop\n\t\t};\n\t\tthis.client = {\n\t\t\tx: (event.pageX != null) ? event.pageX - win.pageXOffset : event.clientX,\n\t\t\ty: (event.pageY != null) ? event.pageY - win.pageYOffset : event.clientY\n\t\t};\n\t\tif (type == 'DOMMouseScroll' || type == 'mousewheel')\n\t\t\tthis.wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;\n\n\t\tthis.rightClick = (event.which == 3 || event.button == 2);\n\t\tif (type == 'mouseover' || type == 'mouseout'){\n\t\t\tvar related = event.relatedTarget || event[(type == 'mouseover' ? 'from' : 'to') + 'Element'];\n\t\t\twhile (related && related.nodeType == 3) related = related.parentNode;\n\t\t\tthis.relatedTarget = document.id(related);\n\t\t}\n\t} else if (type.indexOf('touch') == 0 || type.indexOf('gesture') == 0){\n\t\tthis.rotation = event.rotation;\n\t\tthis.scale = event.scale;\n\t\tthis.targetTouches = event.targetTouches;\n\t\tthis.changedTouches = event.changedTouches;\n\t\tvar touches = this.touches = event.touches;\n\t\tif (touches && touches[0]){\n\t\t\tvar touch = touches[0];\n\t\t\tthis.page = {x: touch.pageX, y: touch.pageY};\n\t\t\tthis.client = {x: touch.clientX, y: touch.clientY};\n\t\t}\n\t}\n\n\tif (!this.client) this.client = {};\n\tif (!this.page) this.page = {};\n});\n\nDOMEvent.implement({\n\n\tstop: function(){\n\t\treturn this.preventDefault().stopPropagation();\n\t},\n\n\tstopPropagation: function(){\n\t\tif (this.event.stopPropagation) this.event.stopPropagation();\n\t\telse this.event.cancelBubble = true;\n\t\treturn this;\n\t},\n\n\tpreventDefault: function(){\n\t\tif (this.event.preventDefault) this.event.preventDefault();\n\t\telse this.event.returnValue = false;\n\t\treturn this;\n\t}\n\n});\n\nDOMEvent.defineKey = function(code, key){\n\t_keys[code] = key;\n\treturn this;\n};\n\nDOMEvent.defineKeys = DOMEvent.defineKey.overloadSetter(true);\n\nDOMEvent.defineKeys({\n\t'38': 'up', '40': 'down', '37': 'left', '39': 'right',\n\t'27': 'esc', '32': 'space', '8': 'backspace', '9': 'tab',\n\t'46': 'delete', '13': 'enter'\n});\n\n})();\n\n\n\n\n\n\n/*\n---\n\nname: Class\n\ndescription: Contains the Class Function for easily creating, extending, and implementing reusable Classes.\n\nlicense: MIT-style license.\n\nrequires: [Array, String, Function, Number]\n\nprovides: Class\n\n...\n*/\n\n(function(){\n\nvar Class = this.Class = new Type('Class', function(params){\n\tif (instanceOf(params, Function)) params = {initialize: params};\n\n\tvar newClass = function(){\n\t\treset(this);\n\t\tif (newClass.$prototyping) return this;\n\t\tthis.$caller = null;\n\t\tvar value = (this.initialize) ? this.initialize.apply(this, arguments) : this;\n\t\tthis.$caller = this.caller = null;\n\t\treturn value;\n\t}.extend(this).implement(params);\n\n\tnewClass.$constructor = Class;\n\tnewClass.prototype.$constructor = newClass;\n\tnewClass.prototype.parent = parent;\n\n\treturn newClass;\n});\n\nvar parent = function(){\n\tif (!this.$caller) throw new Error('The method \"parent\" cannot be called.');\n\tvar name = this.$caller.$name,\n\t\tparent = this.$caller.$owner.parent,\n\t\tprevious = (parent) ? parent.prototype[name] : null;\n\tif (!previous) throw new Error('The method \"' + name + '\" has no parent.');\n\treturn previous.apply(this, arguments);\n};\n\nvar reset = function(object){\n\tfor (var key in object){\n\t\tvar value = object[key];\n\t\tswitch (typeOf(value)){\n\t\t\tcase 'object':\n\t\t\t\tvar F = function(){};\n\t\t\t\tF.prototype = value;\n\t\t\t\tobject[key] = reset(new F);\n\t\t\tbreak;\n\t\t\tcase 'array': object[key] = value.clone(); break;\n\t\t}\n\t}\n\treturn object;\n};\n\nvar wrap = function(self, key, method){\n\tif (method.$origin) method = method.$origin;\n\tvar wrapper = function(){\n\t\tif (method.$protected && this.$caller == null) throw new Error('The method \"' + key + '\" cannot be called.');\n\t\tvar caller = this.caller, current = this.$caller;\n\t\tthis.caller = current; this.$caller = wrapper;\n\t\tvar result = method.apply(this, arguments);\n\t\tthis.$caller = current; this.caller = caller;\n\t\treturn result;\n\t}.extend({$owner: self, $origin: method, $name: key});\n\treturn wrapper;\n};\n\nvar implement = function(key, value, retain){\n\tif (Class.Mutators.hasOwnProperty(key)){\n\t\tvalue = Class.Mutators[key].call(this, value);\n\t\tif (value == null) return this;\n\t}\n\n\tif (typeOf(value) == 'function'){\n\t\tif (value.$hidden) return this;\n\t\tthis.prototype[key] = (retain) ? value : wrap(this, key, value);\n\t} else {\n\t\tObject.merge(this.prototype, key, value);\n\t}\n\n\treturn this;\n};\n\nvar getInstance = function(klass){\n\tklass.$prototyping = true;\n\tvar proto = new klass;\n\tdelete klass.$prototyping;\n\treturn proto;\n};\n\nClass.implement('implement', implement.overloadSetter());\n\nClass.Mutators = {\n\n\tExtends: function(parent){\n\t\tthis.parent = parent;\n\t\tthis.prototype = getInstance(parent);\n\t},\n\n\tImplements: function(items){\n\t\tArray.from(items).each(function(item){\n\t\t\tvar instance = new item;\n\t\t\tfor (var key in instance) implement.call(this, key, instance[key], true);\n\t\t}, this);\n\t}\n};\n\n})();\n\n\n/*\n---\n\nname: Class.Extras\n\ndescription: Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.\n\nlicense: MIT-style license.\n\nrequires: Class\n\nprovides: [Class.Extras, Chain, Events, Options]\n\n...\n*/\n\n(function(){\n\nthis.Chain = new Class({\n\n\t$chain: [],\n\n\tchain: function(){\n\t\tthis.$chain.append(Array.flatten(arguments));\n\t\treturn this;\n\t},\n\n\tcallChain: function(){\n\t\treturn (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false;\n\t},\n\n\tclearChain: function(){\n\t\tthis.$chain.empty();\n\t\treturn this;\n\t}\n\n});\n\nvar removeOn = function(string){\n\treturn string.replace(/^on([A-Z])/, function(full, first){\n\t\treturn first.toLowerCase();\n\t});\n};\n\nthis.Events = new Class({\n\n\t$events: {},\n\n\taddEvent: function(type, fn, internal){\n\t\ttype = removeOn(type);\n\n\t\t\n\n\t\tthis.$events[type] = (this.$events[type] || []).include(fn);\n\t\tif (internal) fn.internal = true;\n\t\treturn this;\n\t},\n\n\taddEvents: function(events){\n\t\tfor (var type in events) this.addEvent(type, events[type]);\n\t\treturn this;\n\t},\n\n\tfireEvent: function(type, args, delay){\n\t\ttype = removeOn(type);\n\t\tvar events = this.$events[type];\n\t\tif (!events) return this;\n\t\targs = Array.from(args);\n\t\tevents.each(function(fn){\n\t\t\tif (delay) fn.delay(delay, this, args);\n\t\t\telse fn.apply(this, args);\n\t\t}, this);\n\t\treturn this;\n\t},\n\n\tremoveEvent: function(type, fn){\n\t\ttype = removeOn(type);\n\t\tvar events = this.$events[type];\n\t\tif (events && !fn.internal){\n\t\t\tvar index =  events.indexOf(fn);\n\t\t\tif (index != -1) delete events[index];\n\t\t}\n\t\treturn this;\n\t},\n\n\tremoveEvents: function(events){\n\t\tvar type;\n\t\tif (typeOf(events) == 'object'){\n\t\t\tfor (type in events) this.removeEvent(type, events[type]);\n\t\t\treturn this;\n\t\t}\n\t\tif (events) events = removeOn(events);\n\t\tfor (type in this.$events){\n\t\t\tif (events && events != type) continue;\n\t\t\tvar fns = this.$events[type];\n\t\t\tfor (var i = fns.length; i--;) if (i in fns){\n\t\t\t\tthis.removeEvent(type, fns[i]);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n});\n\nthis.Options = new Class({\n\n\tsetOptions: function(){\n\t\tvar options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments));\n\t\tif (this.addEvent) for (var option in options){\n\t\t\tif (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;\n\t\t\tthis.addEvent(option, options[option]);\n\t\t\tdelete options[option];\n\t\t}\n\t\treturn this;\n\t}\n\n});\n\n})();\n\n\n/*\n---\nname: Slick.Parser\ndescription: Standalone CSS3 Selector parser\nprovides: Slick.Parser\n...\n*/\n\n;(function(){\n\nvar parsed,\n\tseparatorIndex,\n\tcombinatorIndex,\n\treversed,\n\tcache = {},\n\treverseCache = {},\n\treUnescape = /\\\\/g;\n\nvar parse = function(expression, isReversed){\n\tif (expression == null) return null;\n\tif (expression.Slick === true) return expression;\n\texpression = ('' + expression).replace(/^\\s+|\\s+$/g, '');\n\treversed = !!isReversed;\n\tvar currentCache = (reversed) ? reverseCache : cache;\n\tif (currentCache[expression]) return currentCache[expression];\n\tparsed = {\n\t\tSlick: true,\n\t\texpressions: [],\n\t\traw: expression,\n\t\treverse: function(){\n\t\t\treturn parse(this.raw, true);\n\t\t}\n\t};\n\tseparatorIndex = -1;\n\twhile (expression != (expression = expression.replace(regexp, parser)));\n\tparsed.length = parsed.expressions.length;\n\treturn currentCache[parsed.raw] = (reversed) ? reverse(parsed) : parsed;\n};\n\nvar reverseCombinator = function(combinator){\n\tif (combinator === '!') return ' ';\n\telse if (combinator === ' ') return '!';\n\telse if ((/^!/).test(combinator)) return combinator.replace(/^!/, '');\n\telse return '!' + combinator;\n};\n\nvar reverse = function(expression){\n\tvar expressions = expression.expressions;\n\tfor (var i = 0; i < expressions.length; i++){\n\t\tvar exp = expressions[i];\n\t\tvar last = {parts: [], tag: '*', combinator: reverseCombinator(exp[0].combinator)};\n\n\t\tfor (var j = 0; j < exp.length; j++){\n\t\t\tvar cexp = exp[j];\n\t\t\tif (!cexp.reverseCombinator) cexp.reverseCombinator = ' ';\n\t\t\tcexp.combinator = cexp.reverseCombinator;\n\t\t\tdelete cexp.reverseCombinator;\n\t\t}\n\n\t\texp.reverse().push(last);\n\t}\n\treturn expression;\n};\n\nvar escapeRegExp = function(string){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan <http://stevenlevithan.com/regex/xregexp/> MIT License\n\treturn string.replace(/[-[\\]{}()*+?.\\\\^$|,#\\s]/g, function(match){\n\t\treturn '\\\\' + match;\n\t});\n};\n\nvar regexp = new RegExp(\n/*\n#!/usr/bin/env ruby\nputs \"\\t\\t\" + DATA.read.gsub(/\\(\\?x\\)|\\s+#.*$|\\s+|\\\\$|\\\\n/,'')\n__END__\n\t\"(?x)^(?:\\\n\t  \\\\s* ( , ) \\\\s*               # Separator          \\n\\\n\t| \\\\s* ( <combinator>+ ) \\\\s*   # Combinator         \\n\\\n\t|      ( \\\\s+ )                 # CombinatorChildren \\n\\\n\t|      ( <unicode>+ | \\\\* )     # Tag                \\n\\\n\t| \\\\#  ( <unicode>+       )     # ID                 \\n\\\n\t| \\\\.  ( <unicode>+       )     # ClassName          \\n\\\n\t|                               # Attribute          \\n\\\n\t\\\\[  \\\n\t\t\\\\s* (<unicode1>+)  (?:  \\\n\t\t\t\\\\s* ([*^$!~|]?=)  (?:  \\\n\t\t\t\t\\\\s* (?:\\\n\t\t\t\t\t([\\\"']?)(.*?)\\\\9 \\\n\t\t\t\t)\\\n\t\t\t)  \\\n\t\t)?  \\\\s*  \\\n\t\\\\](?!\\\\]) \\n\\\n\t|   :+ ( <unicode>+ )(?:\\\n\t\\\\( (?:\\\n\t\t(?:([\\\"'])([^\\\\12]*)\\\\12)|((?:\\\\([^)]+\\\\)|[^()]*)+)\\\n\t) \\\\)\\\n\t)?\\\n\t)\"\n*/\n\t\"^(?:\\\\s*(,)\\\\s*|\\\\s*(<combinator>+)\\\\s*|(\\\\s+)|(<unicode>+|\\\\*)|\\\\#(<unicode>+)|\\\\.(<unicode>+)|\\\\[\\\\s*(<unicode1>+)(?:\\\\s*([*^$!~|]?=)(?:\\\\s*(?:([\\\"']?)(.*?)\\\\9)))?\\\\s*\\\\](?!\\\\])|(:+)(<unicode>+)(?:\\\\((?:(?:([\\\"'])([^\\\\13]*)\\\\13)|((?:\\\\([^)]+\\\\)|[^()]*)+))\\\\))?)\"\n\t.replace(/<combinator>/, '[' + escapeRegExp(\">+~`!@$%^&={}\\\\;</\") + ']')\n\t.replace(/<unicode>/g, '(?:[\\\\w\\\\u00a1-\\\\uFFFF-]|\\\\\\\\[^\\\\s0-9a-f])')\n\t.replace(/<unicode1>/g, '(?:[:\\\\w\\\\u00a1-\\\\uFFFF-]|\\\\\\\\[^\\\\s0-9a-f])')\n);\n\nfunction parser(\n\trawMatch,\n\n\tseparator,\n\tcombinator,\n\tcombinatorChildren,\n\n\ttagName,\n\tid,\n\tclassName,\n\n\tattributeKey,\n\tattributeOperator,\n\tattributeQuote,\n\tattributeValue,\n\n\tpseudoMarker,\n\tpseudoClass,\n\tpseudoQuote,\n\tpseudoClassQuotedValue,\n\tpseudoClassValue\n){\n\tif (separator || separatorIndex === -1){\n\t\tparsed.expressions[++separatorIndex] = [];\n\t\tcombinatorIndex = -1;\n\t\tif (separator) return '';\n\t}\n\n\tif (combinator || combinatorChildren || combinatorIndex === -1){\n\t\tcombinator = combinator || ' ';\n\t\tvar currentSeparator = parsed.expressions[separatorIndex];\n\t\tif (reversed && currentSeparator[combinatorIndex])\n\t\t\tcurrentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator);\n\t\tcurrentSeparator[++combinatorIndex] = {combinator: combinator, tag: '*'};\n\t}\n\n\tvar currentParsed = parsed.expressions[separatorIndex][combinatorIndex];\n\n\tif (tagName){\n\t\tcurrentParsed.tag = tagName.replace(reUnescape, '');\n\n\t} else if (id){\n\t\tcurrentParsed.id = id.replace(reUnescape, '');\n\n\t} else if (className){\n\t\tclassName = className.replace(reUnescape, '');\n\n\t\tif (!currentParsed.classList) currentParsed.classList = [];\n\t\tif (!currentParsed.classes) currentParsed.classes = [];\n\t\tcurrentParsed.classList.push(className);\n\t\tcurrentParsed.classes.push({\n\t\t\tvalue: className,\n\t\t\tregexp: new RegExp('(^|\\\\s)' + escapeRegExp(className) + '(\\\\s|$)')\n\t\t});\n\n\t} else if (pseudoClass){\n\t\tpseudoClassValue = pseudoClassValue || pseudoClassQuotedValue;\n\t\tpseudoClassValue = pseudoClassValue ? pseudoClassValue.replace(reUnescape, '') : null;\n\n\t\tif (!currentParsed.pseudos) currentParsed.pseudos = [];\n\t\tcurrentParsed.pseudos.push({\n\t\t\tkey: pseudoClass.replace(reUnescape, ''),\n\t\t\tvalue: pseudoClassValue,\n\t\t\ttype: pseudoMarker.length == 1 ? 'class' : 'element'\n\t\t});\n\n\t} else if (attributeKey){\n\t\tattributeKey = attributeKey.replace(reUnescape, '');\n\t\tattributeValue = (attributeValue || '').replace(reUnescape, '');\n\n\t\tvar test, regexp;\n\n\t\tswitch (attributeOperator){\n\t\t\tcase '^=' : regexp = new RegExp(       '^'+ escapeRegExp(attributeValue)            ); break;\n\t\t\tcase '$=' : regexp = new RegExp(            escapeRegExp(attributeValue) +'$'       ); break;\n\t\t\tcase '~=' : regexp = new RegExp( '(^|\\\\s)'+ escapeRegExp(attributeValue) +'(\\\\s|$)' ); break;\n\t\t\tcase '|=' : regexp = new RegExp(       '^'+ escapeRegExp(attributeValue) +'(-|$)'   ); break;\n\t\t\tcase  '=' : test = function(value){\n\t\t\t\treturn attributeValue == value;\n\t\t\t}; break;\n\t\t\tcase '*=' : test = function(value){\n\t\t\t\treturn value && value.indexOf(attributeValue) > -1;\n\t\t\t}; break;\n\t\t\tcase '!=' : test = function(value){\n\t\t\t\treturn attributeValue != value;\n\t\t\t}; break;\n\t\t\tdefault   : test = function(value){\n\t\t\t\treturn !!value;\n\t\t\t};\n\t\t}\n\n\t\tif (attributeValue == '' && (/^[*$^]=$/).test(attributeOperator)) test = function(){\n\t\t\treturn false;\n\t\t};\n\n\t\tif (!test) test = function(value){\n\t\t\treturn value && regexp.test(value);\n\t\t};\n\n\t\tif (!currentParsed.attributes) currentParsed.attributes = [];\n\t\tcurrentParsed.attributes.push({\n\t\t\tkey: attributeKey,\n\t\t\toperator: attributeOperator,\n\t\t\tvalue: attributeValue,\n\t\t\ttest: test\n\t\t});\n\n\t}\n\n\treturn '';\n};\n\n// Slick NS\n\nvar Slick = (this.Slick || {});\n\nSlick.parse = function(expression){\n\treturn parse(expression);\n};\n\nSlick.escapeRegExp = escapeRegExp;\n\nif (!this.Slick) this.Slick = Slick;\n\n}).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);\n\n\n/*\n---\nname: Slick.Finder\ndescription: The new, superfast css selector engine.\nprovides: Slick.Finder\nrequires: Slick.Parser\n...\n*/\n\n;(function(){\n\nvar local = {},\n\tfeaturesCache = {},\n\ttoString = Object.prototype.toString;\n\n// Feature / Bug detection\n\nlocal.isNativeCode = function(fn){\n\treturn (/\\{\\s*\\[native code\\]\\s*\\}/).test('' + fn);\n};\n\nlocal.isXML = function(document){\n\treturn (!!document.xmlVersion) || (!!document.xml) || (toString.call(document) == '[object XMLDocument]') ||\n\t(document.nodeType == 9 && document.documentElement.nodeName != 'HTML');\n};\n\nlocal.setDocument = function(document){\n\n\t// convert elements / window arguments to document. if document cannot be extrapolated, the function returns.\n\tvar nodeType = document.nodeType;\n\tif (nodeType == 9); // document\n\telse if (nodeType) document = document.ownerDocument; // node\n\telse if (document.navigator) document = document.document; // window\n\telse return;\n\n\t// check if it's the old document\n\n\tif (this.document === document) return;\n\tthis.document = document;\n\n\t// check if we have done feature detection on this document before\n\n\tvar root = document.documentElement,\n\t\trootUid = this.getUIDXML(root),\n\t\tfeatures = featuresCache[rootUid],\n\t\tfeature;\n\n\tif (features){\n\t\tfor (feature in features){\n\t\t\tthis[feature] = features[feature];\n\t\t}\n\t\treturn;\n\t}\n\n\tfeatures = featuresCache[rootUid] = {};\n\n\tfeatures.root = root;\n\tfeatures.isXMLDocument = this.isXML(document);\n\n\tfeatures.brokenStarGEBTN\n\t= features.starSelectsClosedQSA\n\t= features.idGetsName\n\t= features.brokenMixedCaseQSA\n\t= features.brokenGEBCN\n\t= features.brokenCheckedQSA\n\t= features.brokenEmptyAttributeQSA\n\t= features.isHTMLDocument\n\t= features.nativeMatchesSelector\n\t= false;\n\n\tvar starSelectsClosed, starSelectsComments,\n\t\tbrokenSecondClassNameGEBCN, cachedGetElementsByClassName,\n\t\tbrokenFormAttributeGetter;\n\n\tvar selected, id = 'slick_uniqueid';\n\tvar testNode = document.createElement('div');\n\n\tvar testRoot = document.body || document.getElementsByTagName('body')[0] || root;\n\ttestRoot.appendChild(testNode);\n\n\t// on non-HTML documents innerHTML and getElementsById doesnt work properly\n\ttry {\n\t\ttestNode.innerHTML = '<a id=\"'+id+'\"></a>';\n\t\tfeatures.isHTMLDocument = !!document.getElementById(id);\n\t} catch(e){};\n\n\tif (features.isHTMLDocument){\n\n\t\ttestNode.style.display = 'none';\n\n\t\t// IE returns comment nodes for getElementsByTagName('*') for some documents\n\t\ttestNode.appendChild(document.createComment(''));\n\t\tstarSelectsComments = (testNode.getElementsByTagName('*').length > 1);\n\n\t\t// IE returns closed nodes (EG:\"</foo>\") for getElementsByTagName('*') for some documents\n\t\ttry {\n\t\t\ttestNode.innerHTML = 'foo</foo>';\n\t\t\tselected = testNode.getElementsByTagName('*');\n\t\t\tstarSelectsClosed = (selected && !!selected.length && selected[0].nodeName.charAt(0) == '/');\n\t\t} catch(e){};\n\n\t\tfeatures.brokenStarGEBTN = starSelectsComments || starSelectsClosed;\n\n\t\t// IE returns elements with the name instead of just id for getElementsById for some documents\n\t\ttry {\n\t\t\ttestNode.innerHTML = '<a name=\"'+ id +'\"></a><b id=\"'+ id +'\"></b>';\n\t\t\tfeatures.idGetsName = document.getElementById(id) === testNode.firstChild;\n\t\t} catch(e){};\n\n\t\tif (testNode.getElementsByClassName){\n\n\t\t\t// Safari 3.2 getElementsByClassName caches results\n\t\t\ttry {\n\t\t\t\ttestNode.innerHTML = '<a class=\"f\"></a><a class=\"b\"></a>';\n\t\t\t\ttestNode.getElementsByClassName('b').length;\n\t\t\t\ttestNode.firstChild.className = 'b';\n\t\t\t\tcachedGetElementsByClassName = (testNode.getElementsByClassName('b').length != 2);\n\t\t\t} catch(e){};\n\n\t\t\t// Opera 9.6 getElementsByClassName doesnt detects the class if its not the first one\n\t\t\ttry {\n\t\t\t\ttestNode.innerHTML = '<a class=\"a\"></a><a class=\"f b a\"></a>';\n\t\t\t\tbrokenSecondClassNameGEBCN = (testNode.getElementsByClassName('a').length != 2);\n\t\t\t} catch(e){};\n\n\t\t\tfeatures.brokenGEBCN = cachedGetElementsByClassName || brokenSecondClassNameGEBCN;\n\t\t}\n\n\t\tif (testNode.querySelectorAll){\n\t\t\t// IE 8 returns closed nodes (EG:\"</foo>\") for querySelectorAll('*') for some documents\n\t\t\ttry {\n\t\t\t\ttestNode.innerHTML = 'foo</foo>';\n\t\t\t\tselected = testNode.querySelectorAll('*');\n\t\t\t\tfeatures.starSelectsClosedQSA = (selected && !!selected.length && selected[0].nodeName.charAt(0) == '/');\n\t\t\t} catch(e){};\n\n\t\t\t// Safari 3.2 querySelectorAll doesnt work with mixedcase on quirksmode\n\t\t\ttry {\n\t\t\t\ttestNode.innerHTML = '<a class=\"MiX\"></a>';\n\t\t\t\tfeatures.brokenMixedCaseQSA = !testNode.querySelectorAll('.MiX').length;\n\t\t\t} catch(e){};\n\n\t\t\t// Webkit and Opera dont return selected options on querySelectorAll\n\t\t\ttry {\n\t\t\t\ttestNode.innerHTML = '<select><option selected=\"selected\">a</option></select>';\n\t\t\t\tfeatures.brokenCheckedQSA = (testNode.querySelectorAll(':checked').length == 0);\n\t\t\t} catch(e){};\n\n\t\t\t// IE returns incorrect results for attr[*^$]=\"\" selectors on querySelectorAll\n\t\t\ttry {\n\t\t\t\ttestNode.innerHTML = '<a class=\"\"></a>';\n\t\t\t\tfeatures.brokenEmptyAttributeQSA = (testNode.querySelectorAll('[class*=\"\"]').length != 0);\n\t\t\t} catch(e){};\n\n\t\t}\n\n\t\t// IE6-7, if a form has an input of id x, form.getAttribute(x) returns a reference to the input\n\t\ttry {\n\t\t\ttestNode.innerHTML = '<form action=\"s\"><input id=\"action\"/></form>';\n\t\t\tbrokenFormAttributeGetter = (testNode.firstChild.getAttribute('action') != 's');\n\t\t} catch(e){};\n\n\t\t// native matchesSelector function\n\n\t\tfeatures.nativeMatchesSelector = root.matchesSelector || /*root.msMatchesSelector ||*/ root.mozMatchesSelector || root.webkitMatchesSelector;\n\t\tif (features.nativeMatchesSelector) try {\n\t\t\t// if matchesSelector trows errors on incorrect sintaxes we can use it\n\t\t\tfeatures.nativeMatchesSelector.call(root, ':slick');\n\t\t\tfeatures.nativeMatchesSelector = null;\n\t\t} catch(e){};\n\n\t}\n\n\ttry {\n\t\troot.slick_expando = 1;\n\t\tdelete root.slick_expando;\n\t\tfeatures.getUID = this.getUIDHTML;\n\t} catch(e) {\n\t\tfeatures.getUID = this.getUIDXML;\n\t}\n\n\ttestRoot.removeChild(testNode);\n\ttestNode = selected = testRoot = null;\n\n\t// getAttribute\n\n\tfeatures.getAttribute = (features.isHTMLDocument && brokenFormAttributeGetter) ? function(node, name){\n\t\tvar method = this.attributeGetters[name];\n\t\tif (method) return method.call(node);\n\t\tvar attributeNode = node.getAttributeNode(name);\n\t\treturn (attributeNode) ? attributeNode.nodeValue : null;\n\t} : function(node, name){\n\t\tvar method = this.attributeGetters[name];\n\t\treturn (method) ? method.call(node) : node.getAttribute(name);\n\t};\n\n\t// hasAttribute\n\n\tfeatures.hasAttribute = (root && this.isNativeCode(root.hasAttribute)) ? function(node, attribute) {\n\t\treturn node.hasAttribute(attribute);\n\t} : function(node, attribute) {\n\t\tnode = node.getAttributeNode(attribute);\n\t\treturn !!(node && (node.specified || node.nodeValue));\n\t};\n\n\t// contains\n\t// FIXME: Add specs: local.contains should be different for xml and html documents?\n\tvar nativeRootContains = root && this.isNativeCode(root.contains),\n\t\tnativeDocumentContains = document && this.isNativeCode(document.contains);\n\n\tfeatures.contains = (nativeRootContains && nativeDocumentContains) ? function(context, node){\n\t\treturn context.contains(node);\n\t} : (nativeRootContains && !nativeDocumentContains) ? function(context, node){\n\t\t// IE8 does not have .contains on document.\n\t\treturn context === node || ((context === document) ? document.documentElement : context).contains(node);\n\t} : (root && root.compareDocumentPosition) ? function(context, node){\n\t\treturn context === node || !!(context.compareDocumentPosition(node) & 16);\n\t} : function(context, node){\n\t\tif (node) do {\n\t\t\tif (node === context) return true;\n\t\t} while ((node = node.parentNode));\n\t\treturn false;\n\t};\n\n\t// document order sorting\n\t// credits to Sizzle (http://sizzlejs.com/)\n\n\tfeatures.documentSorter = (root.compareDocumentPosition) ? function(a, b){\n\t\tif (!a.compareDocumentPosition || !b.compareDocumentPosition) return 0;\n\t\treturn a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;\n\t} : ('sourceIndex' in root) ? function(a, b){\n\t\tif (!a.sourceIndex || !b.sourceIndex) return 0;\n\t\treturn a.sourceIndex - b.sourceIndex;\n\t} : (document.createRange) ? function(a, b){\n\t\tif (!a.ownerDocument || !b.ownerDocument) return 0;\n\t\tvar aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();\n\t\taRange.setStart(a, 0);\n\t\taRange.setEnd(a, 0);\n\t\tbRange.setStart(b, 0);\n\t\tbRange.setEnd(b, 0);\n\t\treturn aRange.compareBoundaryPoints(Range.START_TO_END, bRange);\n\t} : null ;\n\n\troot = null;\n\n\tfor (feature in features){\n\t\tthis[feature] = features[feature];\n\t}\n};\n\n// Main Method\n\nvar reSimpleSelector = /^([#.]?)((?:[\\w-]+|\\*))$/,\n\treEmptyAttribute = /\\[.+[*$^]=(?:\"\"|'')?\\]/,\n\tqsaFailExpCache = {};\n\nlocal.search = function(context, expression, append, first){\n\n\tvar found = this.found = (first) ? null : (append || []);\n\n\tif (!context) return found;\n\telse if (context.navigator) context = context.document; // Convert the node from a window to a document\n\telse if (!context.nodeType) return found;\n\n\t// setup\n\n\tvar parsed, i,\n\t\tuniques = this.uniques = {},\n\t\thasOthers = !!(append && append.length),\n\t\tcontextIsDocument = (context.nodeType == 9);\n\n\tif (this.document !== (contextIsDocument ? context : context.ownerDocument)) this.setDocument(context);\n\n\t// avoid duplicating items already in the append array\n\tif (hasOthers) for (i = found.length; i--;) uniques[this.getUID(found[i])] = true;\n\n\t// expression checks\n\n\tif (typeof expression == 'string'){ // expression is a string\n\n\t\t/*<simple-selectors-override>*/\n\t\tvar simpleSelector = expression.match(reSimpleSelector);\n\t\tsimpleSelectors: if (simpleSelector) {\n\n\t\t\tvar symbol = simpleSelector[1],\n\t\t\t\tname = simpleSelector[2],\n\t\t\t\tnode, nodes;\n\n\t\t\tif (!symbol){\n\n\t\t\t\tif (name == '*' && this.brokenStarGEBTN) break simpleSelectors;\n\t\t\t\tnodes = context.getElementsByTagName(name);\n\t\t\t\tif (first) return nodes[0] || null;\n\t\t\t\tfor (i = 0; node = nodes[i++];){\n\t\t\t\t\tif (!(hasOthers && uniques[this.getUID(node)])) found.push(node);\n\t\t\t\t}\n\n\t\t\t} else if (symbol == '#'){\n\n\t\t\t\tif (!this.isHTMLDocument || !contextIsDocument) break simpleSelectors;\n\t\t\t\tnode = context.getElementById(name);\n\t\t\t\tif (!node) return found;\n\t\t\t\tif (this.idGetsName && node.getAttributeNode('id').nodeValue != name) break simpleSelectors;\n\t\t\t\tif (first) return node || null;\n\t\t\t\tif (!(hasOthers && uniques[this.getUID(node)])) found.push(node);\n\n\t\t\t} else if (symbol == '.'){\n\n\t\t\t\tif (!this.isHTMLDocument || ((!context.getElementsByClassName || this.brokenGEBCN) && context.querySelectorAll)) break simpleSelectors;\n\t\t\t\tif (context.getElementsByClassName && !this.brokenGEBCN){\n\t\t\t\t\tnodes = context.getElementsByClassName(name);\n\t\t\t\t\tif (first) return nodes[0] || null;\n\t\t\t\t\tfor (i = 0; node = nodes[i++];){\n\t\t\t\t\t\tif (!(hasOthers && uniques[this.getUID(node)])) found.push(node);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvar matchClass = new RegExp('(^|\\\\s)'+ Slick.escapeRegExp(name) +'(\\\\s|$)');\n\t\t\t\t\tnodes = context.getElementsByTagName('*');\n\t\t\t\t\tfor (i = 0; node = nodes[i++];){\n\t\t\t\t\t\tclassName = node.className;\n\t\t\t\t\t\tif (!(className && matchClass.test(className))) continue;\n\t\t\t\t\t\tif (first) return node;\n\t\t\t\t\t\tif (!(hasOthers && uniques[this.getUID(node)])) found.push(node);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif (hasOthers) this.sort(found);\n\t\t\treturn (first) ? null : found;\n\n\t\t}\n\t\t/*</simple-selectors-override>*/\n\n\t\t/*<query-selector-override>*/\n\t\tquerySelector: if (context.querySelectorAll) {\n\n\t\t\tif (!this.isHTMLDocument\n\t\t\t\t|| qsaFailExpCache[expression]\n\t\t\t\t//TODO: only skip when expression is actually mixed case\n\t\t\t\t|| this.brokenMixedCaseQSA\n\t\t\t\t|| (this.brokenCheckedQSA && expression.indexOf(':checked') > -1)\n\t\t\t\t|| (this.brokenEmptyAttributeQSA && reEmptyAttribute.test(expression))\n\t\t\t\t|| (!contextIsDocument //Abort when !contextIsDocument and...\n\t\t\t\t\t//  there are multiple expressions in the selector\n\t\t\t\t\t//  since we currently only fix non-document rooted QSA for single expression selectors\n\t\t\t\t\t&& expression.indexOf(',') > -1\n\t\t\t\t)\n\t\t\t\t|| Slick.disableQSA\n\t\t\t) break querySelector;\n\n\t\t\tvar _expression = expression, _context = context;\n\t\t\tif (!contextIsDocument){\n\t\t\t\t// non-document rooted QSA\n\t\t\t\t// credits to Andrew Dupont\n\t\t\t\tvar currentId = _context.getAttribute('id'), slickid = 'slickid__';\n\t\t\t\t_context.setAttribute('id', slickid);\n\t\t\t\t_expression = '#' + slickid + ' ' + _expression;\n\t\t\t\tcontext = _context.parentNode;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tif (first) return context.querySelector(_expression) || null;\n\t\t\t\telse nodes = context.querySelectorAll(_expression);\n\t\t\t} catch(e) {\n\t\t\t\tqsaFailExpCache[expression] = 1;\n\t\t\t\tbreak querySelector;\n\t\t\t} finally {\n\t\t\t\tif (!contextIsDocument){\n\t\t\t\t\tif (currentId) _context.setAttribute('id', currentId);\n\t\t\t\t\telse _context.removeAttribute('id');\n\t\t\t\t\tcontext = _context;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.starSelectsClosedQSA) for (i = 0; node = nodes[i++];){\n\t\t\t\tif (node.nodeName > '@' && !(hasOthers && uniques[this.getUID(node)])) found.push(node);\n\t\t\t} else for (i = 0; node = nodes[i++];){\n\t\t\t\tif (!(hasOthers && uniques[this.getUID(node)])) found.push(node);\n\t\t\t}\n\n\t\t\tif (hasOthers) this.sort(found);\n\t\t\treturn found;\n\n\t\t}\n\t\t/*</query-selector-override>*/\n\n\t\tparsed = this.Slick.parse(expression);\n\t\tif (!parsed.length) return found;\n\t} else if (expression == null){ // there is no expression\n\t\treturn found;\n\t} else if (expression.Slick){ // expression is a parsed Slick object\n\t\tparsed = expression;\n\t} else if (this.contains(context.documentElement || context, expression)){ // expression is a node\n\t\t(found) ? found.push(expression) : found = expression;\n\t\treturn found;\n\t} else { // other junk\n\t\treturn found;\n\t}\n\n\t/*<pseudo-selectors>*//*<nth-pseudo-selectors>*/\n\n\t// cache elements for the nth selectors\n\n\tthis.posNTH = {};\n\tthis.posNTHLast = {};\n\tthis.posNTHType = {};\n\tthis.posNTHTypeLast = {};\n\n\t/*</nth-pseudo-selectors>*//*</pseudo-selectors>*/\n\n\t// if append is null and there is only a single selector with one expression use pushArray, else use pushUID\n\tthis.push = (!hasOthers && (first || (parsed.length == 1 && parsed.expressions[0].length == 1))) ? this.pushArray : this.pushUID;\n\n\tif (found == null) found = [];\n\n\t// default engine\n\n\tvar j, m, n;\n\tvar combinator, tag, id, classList, classes, attributes, pseudos;\n\tvar currentItems, currentExpression, currentBit, lastBit, expressions = parsed.expressions;\n\n\tsearch: for (i = 0; (currentExpression = expressions[i]); i++) for (j = 0; (currentBit = currentExpression[j]); j++){\n\n\t\tcombinator = 'combinator:' + currentBit.combinator;\n\t\tif (!this[combinator]) continue search;\n\n\t\ttag        = (this.isXMLDocument) ? currentBit.tag : currentBit.tag.toUpperCase();\n\t\tid         = currentBit.id;\n\t\tclassList  = currentBit.classList;\n\t\tclasses    = currentBit.classes;\n\t\tattributes = currentBit.attributes;\n\t\tpseudos    = currentBit.pseudos;\n\t\tlastBit    = (j === (currentExpression.length - 1));\n\n\t\tthis.bitUniques = {};\n\n\t\tif (lastBit){\n\t\t\tthis.uniques = uniques;\n\t\t\tthis.found = found;\n\t\t} else {\n\t\t\tthis.uniques = {};\n\t\t\tthis.found = [];\n\t\t}\n\n\t\tif (j === 0){\n\t\t\tthis[combinator](context, tag, id, classes, attributes, pseudos, classList);\n\t\t\tif (first && lastBit && found.length) break search;\n\t\t} else {\n\t\t\tif (first && lastBit) for (m = 0, n = currentItems.length; m < n; m++){\n\t\t\t\tthis[combinator](currentItems[m], tag, id, classes, attributes, pseudos, classList);\n\t\t\t\tif (found.length) break search;\n\t\t\t} else for (m = 0, n = currentItems.length; m < n; m++) this[combinator](currentItems[m], tag, id, classes, attributes, pseudos, classList);\n\t\t}\n\n\t\tcurrentItems = this.found;\n\t}\n\n\t// should sort if there are nodes in append and if you pass multiple expressions.\n\tif (hasOthers || (parsed.expressions.length > 1)) this.sort(found);\n\n\treturn (first) ? (found[0] || null) : found;\n};\n\n// Utils\n\nlocal.uidx = 1;\nlocal.uidk = 'slick-uniqueid';\n\nlocal.getUIDXML = function(node){\n\tvar uid = node.getAttribute(this.uidk);\n\tif (!uid){\n\t\tuid = this.uidx++;\n\t\tnode.setAttribute(this.uidk, uid);\n\t}\n\treturn uid;\n};\n\nlocal.getUIDHTML = function(node){\n\treturn node.uniqueNumber || (node.uniqueNumber = this.uidx++);\n};\n\n// sort based on the setDocument documentSorter method.\n\nlocal.sort = function(results){\n\tif (!this.documentSorter) return results;\n\tresults.sort(this.documentSorter);\n\treturn results;\n};\n\n/*<pseudo-selectors>*//*<nth-pseudo-selectors>*/\n\nlocal.cacheNTH = {};\n\nlocal.matchNTH = /^([+-]?\\d*)?([a-z]+)?([+-]\\d+)?$/;\n\nlocal.parseNTHArgument = function(argument){\n\tvar parsed = argument.match(this.matchNTH);\n\tif (!parsed) return false;\n\tvar special = parsed[2] || false;\n\tvar a = parsed[1] || 1;\n\tif (a == '-') a = -1;\n\tvar b = +parsed[3] || 0;\n\tparsed =\n\t\t(special == 'n')\t? {a: a, b: b} :\n\t\t(special == 'odd')\t? {a: 2, b: 1} :\n\t\t(special == 'even')\t? {a: 2, b: 0} : {a: 0, b: a};\n\n\treturn (this.cacheNTH[argument] = parsed);\n};\n\nlocal.createNTHPseudo = function(child, sibling, positions, ofType){\n\treturn function(node, argument){\n\t\tvar uid = this.getUID(node);\n\t\tif (!this[positions][uid]){\n\t\t\tvar parent = node.parentNode;\n\t\t\tif (!parent) return false;\n\t\t\tvar el = parent[child], count = 1;\n\t\t\tif (ofType){\n\t\t\t\tvar nodeName = node.nodeName;\n\t\t\t\tdo {\n\t\t\t\t\tif (el.nodeName != nodeName) continue;\n\t\t\t\t\tthis[positions][this.getUID(el)] = count++;\n\t\t\t\t} while ((el = el[sibling]));\n\t\t\t} else {\n\t\t\t\tdo {\n\t\t\t\t\tif (el.nodeType != 1) continue;\n\t\t\t\t\tthis[positions][this.getUID(el)] = count++;\n\t\t\t\t} while ((el = el[sibling]));\n\t\t\t}\n\t\t}\n\t\targument = argument || 'n';\n\t\tvar parsed = this.cacheNTH[argument] || this.parseNTHArgument(argument);\n\t\tif (!parsed) return false;\n\t\tvar a = parsed.a, b = parsed.b, pos = this[positions][uid];\n\t\tif (a == 0) return b == pos;\n\t\tif (a > 0){\n\t\t\tif (pos < b) return false;\n\t\t} else {\n\t\t\tif (b < pos) return false;\n\t\t}\n\t\treturn ((pos - b) % a) == 0;\n\t};\n};\n\n/*</nth-pseudo-selectors>*//*</pseudo-selectors>*/\n\nlocal.pushArray = function(node, tag, id, classes, attributes, pseudos){\n\tif (this.matchSelector(node, tag, id, classes, attributes, pseudos)) this.found.push(node);\n};\n\nlocal.pushUID = function(node, tag, id, classes, attributes, pseudos){\n\tvar uid = this.getUID(node);\n\tif (!this.uniques[uid] && this.matchSelector(node, tag, id, classes, attributes, pseudos)){\n\t\tthis.uniques[uid] = true;\n\t\tthis.found.push(node);\n\t}\n};\n\nlocal.matchNode = function(node, selector){\n\tif (this.isHTMLDocument && this.nativeMatchesSelector){\n\t\ttry {\n\t\t\treturn this.nativeMatchesSelector.call(node, selector.replace(/\\[([^=]+)=\\s*([^'\"\\]]+?)\\s*\\]/g, '[$1=\"$2\"]'));\n\t\t} catch(matchError) {}\n\t}\n\n\tvar parsed = this.Slick.parse(selector);\n\tif (!parsed) return true;\n\n\t// simple (single) selectors\n\tvar expressions = parsed.expressions, simpleExpCounter = 0, i;\n\tfor (i = 0; (currentExpression = expressions[i]); i++){\n\t\tif (currentExpression.length == 1){\n\t\t\tvar exp = currentExpression[0];\n\t\t\tif (this.matchSelector(node, (this.isXMLDocument) ? exp.tag : exp.tag.toUpperCase(), exp.id, exp.classes, exp.attributes, exp.pseudos)) return true;\n\t\t\tsimpleExpCounter++;\n\t\t}\n\t}\n\n\tif (simpleExpCounter == parsed.length) return false;\n\n\tvar nodes = this.search(this.document, parsed), item;\n\tfor (i = 0; item = nodes[i++];){\n\t\tif (item === node) return true;\n\t}\n\treturn false;\n};\n\nlocal.matchPseudo = function(node, name, argument){\n\tvar pseudoName = 'pseudo:' + name;\n\tif (this[pseudoName]) return this[pseudoName](node, argument);\n\tvar attribute = this.getAttribute(node, name);\n\treturn (argument) ? argument == attribute : !!attribute;\n};\n\nlocal.matchSelector = function(node, tag, id, classes, attributes, pseudos){\n\tif (tag){\n\t\tvar nodeName = (this.isXMLDocument) ? node.nodeName : node.nodeName.toUpperCase();\n\t\tif (tag == '*'){\n\t\t\tif (nodeName < '@') return false; // Fix for comment nodes and closed nodes\n\t\t} else {\n\t\t\tif (nodeName != tag) return false;\n\t\t}\n\t}\n\n\tif (id && node.getAttribute('id') != id) return false;\n\n\tvar i, part, cls;\n\tif (classes) for (i = classes.length; i--;){\n\t\tcls = this.getAttribute(node, 'class');\n\t\tif (!(cls && classes[i].regexp.test(cls))) return false;\n\t}\n\tif (attributes) for (i = attributes.length; i--;){\n\t\tpart = attributes[i];\n\t\tif (part.operator ? !part.test(this.getAttribute(node, part.key)) : !this.hasAttribute(node, part.key)) return false;\n\t}\n\tif (pseudos) for (i = pseudos.length; i--;){\n\t\tpart = pseudos[i];\n\t\tif (!this.matchPseudo(node, part.key, part.value)) return false;\n\t}\n\treturn true;\n};\n\nvar combinators = {\n\n\t' ': function(node, tag, id, classes, attributes, pseudos, classList){ // all child nodes, any level\n\n\t\tvar i, item, children;\n\n\t\tif (this.isHTMLDocument){\n\t\t\tgetById: if (id){\n\t\t\t\titem = this.document.getElementById(id);\n\t\t\t\tif ((!item && node.all) || (this.idGetsName && item && item.getAttributeNode('id').nodeValue != id)){\n\t\t\t\t\t// all[id] returns all the elements with that name or id inside node\n\t\t\t\t\t// if theres just one it will return the element, else it will be a collection\n\t\t\t\t\tchildren = node.all[id];\n\t\t\t\t\tif (!children) return;\n\t\t\t\t\tif (!children[0]) children = [children];\n\t\t\t\t\tfor (i = 0; item = children[i++];){\n\t\t\t\t\t\tvar idNode = item.getAttributeNode('id');\n\t\t\t\t\t\tif (idNode && idNode.nodeValue == id){\n\t\t\t\t\t\t\tthis.push(item, tag, null, classes, attributes, pseudos);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!item){\n\t\t\t\t\t// if the context is in the dom we return, else we will try GEBTN, breaking the getById label\n\t\t\t\t\tif (this.contains(this.root, node)) return;\n\t\t\t\t\telse break getById;\n\t\t\t\t} else if (this.document !== node && !this.contains(node, item)) return;\n\t\t\t\tthis.push(item, tag, null, classes, attributes, pseudos);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgetByClass: if (classes && node.getElementsByClassName && !this.brokenGEBCN){\n\t\t\t\tchildren = node.getElementsByClassName(classList.join(' '));\n\t\t\t\tif (!(children && children.length)) break getByClass;\n\t\t\t\tfor (i = 0; item = children[i++];) this.push(item, tag, id, null, attributes, pseudos);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tgetByTag: {\n\t\t\tchildren = node.getElementsByTagName(tag);\n\t\t\tif (!(children && children.length)) break getByTag;\n\t\t\tif (!this.brokenStarGEBTN) tag = null;\n\t\t\tfor (i = 0; item = children[i++];) this.push(item, tag, id, classes, attributes, pseudos);\n\t\t}\n\t},\n\n\t'>': function(node, tag, id, classes, attributes, pseudos){ // direct children\n\t\tif ((node = node.firstChild)) do {\n\t\t\tif (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);\n\t\t} while ((node = node.nextSibling));\n\t},\n\n\t'+': function(node, tag, id, classes, attributes, pseudos){ // next sibling\n\t\twhile ((node = node.nextSibling)) if (node.nodeType == 1){\n\t\t\tthis.push(node, tag, id, classes, attributes, pseudos);\n\t\t\tbreak;\n\t\t}\n\t},\n\n\t'^': function(node, tag, id, classes, attributes, pseudos){ // first child\n\t\tnode = node.firstChild;\n\t\tif (node){\n\t\t\tif (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);\n\t\t\telse this['combinator:+'](node, tag, id, classes, attributes, pseudos);\n\t\t}\n\t},\n\n\t'~': function(node, tag, id, classes, attributes, pseudos){ // next siblings\n\t\twhile ((node = node.nextSibling)){\n\t\t\tif (node.nodeType != 1) continue;\n\t\t\tvar uid = this.getUID(node);\n\t\t\tif (this.bitUniques[uid]) break;\n\t\t\tthis.bitUniques[uid] = true;\n\t\t\tthis.push(node, tag, id, classes, attributes, pseudos);\n\t\t}\n\t},\n\n\t'++': function(node, tag, id, classes, attributes, pseudos){ // next sibling and previous sibling\n\t\tthis['combinator:+'](node, tag, id, classes, attributes, pseudos);\n\t\tthis['combinator:!+'](node, tag, id, classes, attributes, pseudos);\n\t},\n\n\t'~~': function(node, tag, id, classes, attributes, pseudos){ // next siblings and previous siblings\n\t\tthis['combinator:~'](node, tag, id, classes, attributes, pseudos);\n\t\tthis['combinator:!~'](node, tag, id, classes, attributes, pseudos);\n\t},\n\n\t'!': function(node, tag, id, classes, attributes, pseudos){ // all parent nodes up to document\n\t\twhile ((node = node.parentNode)) if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos);\n\t},\n\n\t'!>': function(node, tag, id, classes, attributes, pseudos){ // direct parent (one level)\n\t\tnode = node.parentNode;\n\t\tif (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos);\n\t},\n\n\t'!+': function(node, tag, id, classes, attributes, pseudos){ // previous sibling\n\t\twhile ((node = node.previousSibling)) if (node.nodeType == 1){\n\t\t\tthis.push(node, tag, id, classes, attributes, pseudos);\n\t\t\tbreak;\n\t\t}\n\t},\n\n\t'!^': function(node, tag, id, classes, attributes, pseudos){ // last child\n\t\tnode = node.lastChild;\n\t\tif (node){\n\t\t\tif (node.nodeType == 1) this.push(node, tag, id, classes, attributes, pseudos);\n\t\t\telse this['combinator:!+'](node, tag, id, classes, attributes, pseudos);\n\t\t}\n\t},\n\n\t'!~': function(node, tag, id, classes, attributes, pseudos){ // previous siblings\n\t\twhile ((node = node.previousSibling)){\n\t\t\tif (node.nodeType != 1) continue;\n\t\t\tvar uid = this.getUID(node);\n\t\t\tif (this.bitUniques[uid]) break;\n\t\t\tthis.bitUniques[uid] = true;\n\t\t\tthis.push(node, tag, id, classes, attributes, pseudos);\n\t\t}\n\t}\n\n};\n\nfor (var c in combinators) local['combinator:' + c] = combinators[c];\n\nvar pseudos = {\n\n\t/*<pseudo-selectors>*/\n\n\t'empty': function(node){\n\t\tvar child = node.firstChild;\n\t\treturn !(child && child.nodeType == 1) && !(node.innerText || node.textContent || '').length;\n\t},\n\n\t'not': function(node, expression){\n\t\treturn !this.matchNode(node, expression);\n\t},\n\n\t'contains': function(node, text){\n\t\treturn (node.innerText || node.textContent || '').indexOf(text) > -1;\n\t},\n\n\t'first-child': function(node){\n\t\twhile ((node = node.previousSibling)) if (node.nodeType == 1) return false;\n\t\treturn true;\n\t},\n\n\t'last-child': function(node){\n\t\twhile ((node = node.nextSibling)) if (node.nodeType == 1) return false;\n\t\treturn true;\n\t},\n\n\t'only-child': function(node){\n\t\tvar prev = node;\n\t\twhile ((prev = prev.previousSibling)) if (prev.nodeType == 1) return false;\n\t\tvar next = node;\n\t\twhile ((next = next.nextSibling)) if (next.nodeType == 1) return false;\n\t\treturn true;\n\t},\n\n\t/*<nth-pseudo-selectors>*/\n\n\t'nth-child': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTH'),\n\n\t'nth-last-child': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHLast'),\n\n\t'nth-of-type': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTHType', true),\n\n\t'nth-last-of-type': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHTypeLast', true),\n\n\t'index': function(node, index){\n\t\treturn this['pseudo:nth-child'](node, '' + (index + 1));\n\t},\n\n\t'even': function(node){\n\t\treturn this['pseudo:nth-child'](node, '2n');\n\t},\n\n\t'odd': function(node){\n\t\treturn this['pseudo:nth-child'](node, '2n+1');\n\t},\n\n\t/*</nth-pseudo-selectors>*/\n\n\t/*<of-type-pseudo-selectors>*/\n\n\t'first-of-type': function(node){\n\t\tvar nodeName = node.nodeName;\n\t\twhile ((node = node.previousSibling)) if (node.nodeName == nodeName) return false;\n\t\treturn true;\n\t},\n\n\t'last-of-type': function(node){\n\t\tvar nodeName = node.nodeName;\n\t\twhile ((node = node.nextSibling)) if (node.nodeName == nodeName) return false;\n\t\treturn true;\n\t},\n\n\t'only-of-type': function(node){\n\t\tvar prev = node, nodeName = node.nodeName;\n\t\twhile ((prev = prev.previousSibling)) if (prev.nodeName == nodeName) return false;\n\t\tvar next = node;\n\t\twhile ((next = next.nextSibling)) if (next.nodeName == nodeName) return false;\n\t\treturn true;\n\t},\n\n\t/*</of-type-pseudo-selectors>*/\n\n\t// custom pseudos\n\n\t'enabled': function(node){\n\t\treturn !node.disabled;\n\t},\n\n\t'disabled': function(node){\n\t\treturn node.disabled;\n\t},\n\n\t'checked': function(node){\n\t\treturn node.checked || node.selected;\n\t},\n\n\t'focus': function(node){\n\t\treturn this.isHTMLDocument && this.document.activeElement === node && (node.href || node.type || this.hasAttribute(node, 'tabindex'));\n\t},\n\n\t'root': function(node){\n\t\treturn (node === this.root);\n\t},\n\n\t'selected': function(node){\n\t\treturn node.selected;\n\t}\n\n\t/*</pseudo-selectors>*/\n};\n\nfor (var p in pseudos) local['pseudo:' + p] = pseudos[p];\n\n// attributes methods\n\nvar attributeGetters = local.attributeGetters = {\n\n\t'for': function(){\n\t\treturn ('htmlFor' in this) ? this.htmlFor : this.getAttribute('for');\n\t},\n\n\t'href': function(){\n\t\treturn ('href' in this) ? this.getAttribute('href', 2) : this.getAttribute('href');\n\t},\n\n\t'style': function(){\n\t\treturn (this.style) ? this.style.cssText : this.getAttribute('style');\n\t},\n\n\t'tabindex': function(){\n\t\tvar attributeNode = this.getAttributeNode('tabindex');\n\t\treturn (attributeNode && attributeNode.specified) ? attributeNode.nodeValue : null;\n\t},\n\n\t'type': function(){\n\t\treturn this.getAttribute('type');\n\t},\n\n\t'maxlength': function(){\n\t\tvar attributeNode = this.getAttributeNode('maxLength');\n\t\treturn (attributeNode && attributeNode.specified) ? attributeNode.nodeValue : null;\n\t}\n\n};\n\nattributeGetters.MAXLENGTH = attributeGetters.maxLength = attributeGetters.maxlength;\n\n// Slick\n\nvar Slick = local.Slick = (this.Slick || {});\n\nSlick.version = '1.1.7';\n\n// Slick finder\n\nSlick.search = function(context, expression, append){\n\treturn local.search(context, expression, append);\n};\n\nSlick.find = function(context, expression){\n\treturn local.search(context, expression, null, true);\n};\n\n// Slick containment checker\n\nSlick.contains = function(container, node){\n\tlocal.setDocument(container);\n\treturn local.contains(container, node);\n};\n\n// Slick attribute getter\n\nSlick.getAttribute = function(node, name){\n\tlocal.setDocument(node);\n\treturn local.getAttribute(node, name);\n};\n\nSlick.hasAttribute = function(node, name){\n\tlocal.setDocument(node);\n\treturn local.hasAttribute(node, name);\n};\n\n// Slick matcher\n\nSlick.match = function(node, selector){\n\tif (!(node && selector)) return false;\n\tif (!selector || selector === node) return true;\n\tlocal.setDocument(node);\n\treturn local.matchNode(node, selector);\n};\n\n// Slick attribute accessor\n\nSlick.defineAttributeGetter = function(name, fn){\n\tlocal.attributeGetters[name] = fn;\n\treturn this;\n};\n\nSlick.lookupAttributeGetter = function(name){\n\treturn local.attributeGetters[name];\n};\n\n// Slick pseudo accessor\n\nSlick.definePseudo = function(name, fn){\n\tlocal['pseudo:' + name] = function(node, argument){\n\t\treturn fn.call(node, argument);\n\t};\n\treturn this;\n};\n\nSlick.lookupPseudo = function(name){\n\tvar pseudo = local['pseudo:' + name];\n\tif (pseudo) return function(argument){\n\t\treturn pseudo.call(this, argument);\n\t};\n\treturn null;\n};\n\n// Slick overrides accessor\n\nSlick.override = function(regexp, fn){\n\tlocal.override(regexp, fn);\n\treturn this;\n};\n\nSlick.isXML = local.isXML;\n\nSlick.uidOf = function(node){\n\treturn local.getUIDHTML(node);\n};\n\nif (!this.Slick) this.Slick = Slick;\n\n}).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);\n\n\n/*\n---\n\nname: Element\n\ndescription: One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser, time-saver methods to let you easily work with HTML Elements.\n\nlicense: MIT-style license.\n\nrequires: [Window, Document, Array, String, Function, Object, Number, Slick.Parser, Slick.Finder]\n\nprovides: [Element, Elements, $, $$, Iframe, Selectors]\n\n...\n*/\n\nvar Element = function(tag, props){\n\tvar konstructor = Element.Constructors[tag];\n\tif (konstructor) return konstructor(props);\n\tif (typeof tag != 'string') return document.id(tag).set(props);\n\n\tif (!props) props = {};\n\n\tif (!(/^[\\w-]+$/).test(tag)){\n\t\tvar parsed = Slick.parse(tag).expressions[0][0];\n\t\ttag = (parsed.tag == '*') ? 'div' : parsed.tag;\n\t\tif (parsed.id && props.id == null) props.id = parsed.id;\n\n\t\tvar attributes = parsed.attributes;\n\t\tif (attributes) for (var attr, i = 0, l = attributes.length; i < l; i++){\n\t\t\tattr = attributes[i];\n\t\t\tif (props[attr.key] != null) continue;\n\n\t\t\tif (attr.value != null && attr.operator == '=') props[attr.key] = attr.value;\n\t\t\telse if (!attr.value && !attr.operator) props[attr.key] = true;\n\t\t}\n\n\t\tif (parsed.classList && props['class'] == null) props['class'] = parsed.classList.join(' ');\n\t}\n\n\treturn document.newElement(tag, props);\n};\n\n\nif (Browser.Element){\n\tElement.prototype = Browser.Element.prototype;\n\t// IE8 and IE9 require the wrapping.\n\tElement.prototype._fireEvent = (function(fireEvent){\n\t\treturn function(type, event){\n\t\t\treturn fireEvent.call(this, type, event);\n\t\t};\n\t})(Element.prototype.fireEvent);\n}\n\nnew Type('Element', Element).mirror(function(name){\n\tif (Array.prototype[name]) return;\n\n\tvar obj = {};\n\tobj[name] = function(){\n\t\tvar results = [], args = arguments, elements = true;\n\t\tfor (var i = 0, l = this.length; i < l; i++){\n\t\t\tvar element = this[i], result = results[i] = element[name].apply(element, args);\n\t\t\telements = (elements && typeOf(result) == 'element');\n\t\t}\n\t\treturn (elements) ? new Elements(results) : results;\n\t};\n\n\tElements.implement(obj);\n});\n\nif (!Browser.Element){\n\tElement.parent = Object;\n\n\tElement.Prototype = {\n\t\t'$constructor': Element,\n\t\t'$family': Function.from('element').hide()\n\t};\n\n\tElement.mirror(function(name, method){\n\t\tElement.Prototype[name] = method;\n\t});\n}\n\nElement.Constructors = {};\n\n\n\nvar IFrame = new Type('IFrame', function(){\n\tvar params = Array.link(arguments, {\n\t\tproperties: Type.isObject,\n\t\tiframe: function(obj){\n\t\t\treturn (obj != null);\n\t\t}\n\t});\n\n\tvar props = params.properties || {}, iframe;\n\tif (params.iframe) iframe = document.id(params.iframe);\n\tvar onload = props.onload || function(){};\n\tdelete props.onload;\n\tprops.id = props.name = [props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + String.uniqueID()].pick();\n\tiframe = new Element(iframe || 'iframe', props);\n\n\tvar onLoad = function(){\n\t\tonload.call(iframe.contentWindow);\n\t};\n\n\tif (window.frames[props.id]) onLoad();\n\telse iframe.addListener('load', onLoad);\n\treturn iframe;\n});\n\nvar Elements = this.Elements = function(nodes){\n\tif (nodes && nodes.length){\n\t\tvar uniques = {}, node;\n\t\tfor (var i = 0; node = nodes[i++];){\n\t\t\tvar uid = Slick.uidOf(node);\n\t\t\tif (!uniques[uid]){\n\t\t\t\tuniques[uid] = true;\n\t\t\t\tthis.push(node);\n\t\t\t}\n\t\t}\n\t}\n};\n\nElements.prototype = {length: 0};\nElements.parent = Array;\n\nnew Type('Elements', Elements).implement({\n\n\tfilter: function(filter, bind){\n\t\tif (!filter) return this;\n\t\treturn new Elements(Array.filter(this, (typeOf(filter) == 'string') ? function(item){\n\t\t\treturn item.match(filter);\n\t\t} : filter, bind));\n\t}.protect(),\n\n\tpush: function(){\n\t\tvar length = this.length;\n\t\tfor (var i = 0, l = arguments.length; i < l; i++){\n\t\t\tvar item = document.id(arguments[i]);\n\t\t\tif (item) this[length++] = item;\n\t\t}\n\t\treturn (this.length = length);\n\t}.protect(),\n\n\tunshift: function(){\n\t\tvar items = [];\n\t\tfor (var i = 0, l = arguments.length; i < l; i++){\n\t\t\tvar item = document.id(arguments[i]);\n\t\t\tif (item) items.push(item);\n\t\t}\n\t\treturn Array.prototype.unshift.apply(this, items);\n\t}.protect(),\n\n\tconcat: function(){\n\t\tvar newElements = new Elements(this);\n\t\tfor (var i = 0, l = arguments.length; i < l; i++){\n\t\t\tvar item = arguments[i];\n\t\t\tif (Type.isEnumerable(item)) newElements.append(item);\n\t\t\telse newElements.push(item);\n\t\t}\n\t\treturn newElements;\n\t}.protect(),\n\n\tappend: function(collection){\n\t\tfor (var i = 0, l = collection.length; i < l; i++) this.push(collection[i]);\n\t\treturn this;\n\t}.protect(),\n\n\tempty: function(){\n\t\twhile (this.length) delete this[--this.length];\n\t\treturn this;\n\t}.protect()\n\n});\n\n\n\n(function(){\n\n// FF, IE\nvar splice = Array.prototype.splice, object = {'0': 0, '1': 1, length: 2};\n\nsplice.call(object, 1, 1);\nif (object[1] == 1) Elements.implement('splice', function(){\n\tvar length = this.length;\n\tvar result = splice.apply(this, arguments);\n\twhile (length >= this.length) delete this[length--];\n\treturn result;\n}.protect());\n\nArray.forEachMethod(function(method, name){\n\tElements.implement(name, method);\n});\n\nArray.mirror(Elements);\n\n/*<ltIE8>*/\nvar createElementAcceptsHTML;\ntry {\n    createElementAcceptsHTML = (document.createElement('<input name=x>').name == 'x');\n} catch (e){}\n\nvar escapeQuotes = function(html){\n\treturn ('' + html).replace(/&/g, '&amp;').replace(/\"/g, '&quot;');\n};\n/*</ltIE8>*/\n\nDocument.implement({\n\n\tnewElement: function(tag, props){\n\t\tif (props && props.checked != null) props.defaultChecked = props.checked;\n\t\t/*<ltIE8>*/// Fix for readonly name and type properties in IE < 8\n\t\tif (createElementAcceptsHTML && props){\n\t\t\ttag = '<' + tag;\n\t\t\tif (props.name) tag += ' name=\"' + escapeQuotes(props.name) + '\"';\n\t\t\tif (props.type) tag += ' type=\"' + escapeQuotes(props.type) + '\"';\n\t\t\ttag += '>';\n\t\t\tdelete props.name;\n\t\t\tdelete props.type;\n\t\t}\n\t\t/*</ltIE8>*/\n\t\treturn this.id(this.createElement(tag)).set(props);\n\t}\n\n});\n\n})();\n\n(function(){\n\nSlick.uidOf(window);\nSlick.uidOf(document);\n\nDocument.implement({\n\n\tnewTextNode: function(text){\n\t\treturn this.createTextNode(text);\n\t},\n\n\tgetDocument: function(){\n\t\treturn this;\n\t},\n\n\tgetWindow: function(){\n\t\treturn this.window;\n\t},\n\n\tid: (function(){\n\n\t\tvar types = {\n\n\t\t\tstring: function(id, nocash, doc){\n\t\t\t\tid = Slick.find(doc, '#' + id.replace(/(\\W)/g, '\\\\$1'));\n\t\t\t\treturn (id) ? types.element(id, nocash) : null;\n\t\t\t},\n\n\t\t\telement: function(el, nocash){\n\t\t\t\tSlick.uidOf(el);\n\t\t\t\tif (!nocash && !el.$family && !(/^(?:object|embed)$/i).test(el.tagName)){\n\t\t\t\t\tvar fireEvent = el.fireEvent;\n\t\t\t\t\t// wrapping needed in IE7, or else crash\n\t\t\t\t\tel._fireEvent = function(type, event){\n\t\t\t\t\t\treturn fireEvent(type, event);\n\t\t\t\t\t};\n\t\t\t\t\tObject.append(el, Element.Prototype);\n\t\t\t\t}\n\t\t\t\treturn el;\n\t\t\t},\n\n\t\t\tobject: function(obj, nocash, doc){\n\t\t\t\tif (obj.toElement) return types.element(obj.toElement(doc), nocash);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t};\n\n\t\ttypes.textnode = types.whitespace = types.window = types.document = function(zero){\n\t\t\treturn zero;\n\t\t};\n\n\t\treturn function(el, nocash, doc){\n\t\t\tif (el && el.$family && el.uniqueNumber) return el;\n\t\t\tvar type = typeOf(el);\n\t\t\treturn (types[type]) ? types[type](el, nocash, doc || document) : null;\n\t\t};\n\n\t})()\n\n});\n\nif (window.$ == null) Window.implement('$', function(el, nc){\n\treturn document.id(el, nc, this.document);\n});\n\nWindow.implement({\n\n\tgetDocument: function(){\n\t\treturn this.document;\n\t},\n\n\tgetWindow: function(){\n\t\treturn this;\n\t}\n\n});\n\n[Document, Element].invoke('implement', {\n\n\tgetElements: function(expression){\n\t\treturn Slick.search(this, expression, new Elements);\n\t},\n\n\tgetElement: function(expression){\n\t\treturn document.id(Slick.find(this, expression));\n\t}\n\n});\n\nvar contains = {contains: function(element){\n\treturn Slick.contains(this, element);\n}};\n\nif (!document.contains) Document.implement(contains);\nif (!document.createElement('div').contains) Element.implement(contains);\n\n\n\n// tree walking\n\nvar injectCombinator = function(expression, combinator){\n\tif (!expression) return combinator;\n\n\texpression = Object.clone(Slick.parse(expression));\n\n\tvar expressions = expression.expressions;\n\tfor (var i = expressions.length; i--;)\n\t\texpressions[i][0].combinator = combinator;\n\n\treturn expression;\n};\n\nObject.forEach({\n\tgetNext: '~',\n\tgetPrevious: '!~',\n\tgetParent: '!'\n}, function(combinator, method){\n\tElement.implement(method, function(expression){\n\t\treturn this.getElement(injectCombinator(expression, combinator));\n\t});\n});\n\nObject.forEach({\n\tgetAllNext: '~',\n\tgetAllPrevious: '!~',\n\tgetSiblings: '~~',\n\tgetChildren: '>',\n\tgetParents: '!'\n}, function(combinator, method){\n\tElement.implement(method, function(expression){\n\t\treturn this.getElements(injectCombinator(expression, combinator));\n\t});\n});\n\nElement.implement({\n\n\tgetFirst: function(expression){\n\t\treturn document.id(Slick.search(this, injectCombinator(expression, '>'))[0]);\n\t},\n\n\tgetLast: function(expression){\n\t\treturn document.id(Slick.search(this, injectCombinator(expression, '>')).getLast());\n\t},\n\n\tgetWindow: function(){\n\t\treturn this.ownerDocument.window;\n\t},\n\n\tgetDocument: function(){\n\t\treturn this.ownerDocument;\n\t},\n\n\tgetElementById: function(id){\n\t\treturn document.id(Slick.find(this, '#' + ('' + id).replace(/(\\W)/g, '\\\\$1')));\n\t},\n\n\tmatch: function(expression){\n\t\treturn !expression || Slick.match(this, expression);\n\t}\n\n});\n\n\n\nif (window.$$ == null) Window.implement('$$', function(selector){\n\tif (arguments.length == 1){\n\t\tif (typeof selector == 'string') return Slick.search(this.document, selector, new Elements);\n\t\telse if (Type.isEnumerable(selector)) return new Elements(selector);\n\t}\n\treturn new Elements(arguments);\n});\n\n// Inserters\n\nvar inserters = {\n\n\tbefore: function(context, element){\n\t\tvar parent = element.parentNode;\n\t\tif (parent) parent.insertBefore(context, element);\n\t},\n\n\tafter: function(context, element){\n\t\tvar parent = element.parentNode;\n\t\tif (parent) parent.insertBefore(context, element.nextSibling);\n\t},\n\n\tbottom: function(context, element){\n\t\telement.appendChild(context);\n\t},\n\n\ttop: function(context, element){\n\t\telement.insertBefore(context, element.firstChild);\n\t}\n\n};\n\ninserters.inside = inserters.bottom;\n\n\n\n// getProperty / setProperty\n\nvar propertyGetters = {}, propertySetters = {};\n\n// properties\n\nvar properties = {};\nArray.forEach([\n\t'type', 'value', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan',\n\t'frameBorder', 'rowSpan', 'tabIndex', 'useMap'\n], function(property){\n\tproperties[property.toLowerCase()] = property;\n});\n\nproperties.html = 'innerHTML';\nproperties.text = (document.createElement('div').textContent == null) ? 'innerText': 'textContent';\n\nObject.forEach(properties, function(real, key){\n\tpropertySetters[key] = function(node, value){\n\t\tnode[real] = value;\n\t};\n\tpropertyGetters[key] = function(node){\n\t\treturn node[real];\n\t};\n});\n\n// Booleans\n\nvar bools = [\n\t'compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked',\n\t'disabled', 'readOnly', 'multiple', 'selected', 'noresize',\n\t'defer', 'defaultChecked', 'autofocus', 'controls', 'autoplay',\n\t'loop'\n];\n\nvar booleans = {};\nArray.forEach(bools, function(bool){\n\tvar lower = bool.toLowerCase();\n\tbooleans[lower] = bool;\n\tpropertySetters[lower] = function(node, value){\n\t\tnode[bool] = !!value;\n\t};\n\tpropertyGetters[lower] = function(node){\n\t\treturn !!node[bool];\n\t};\n});\n\n// Special cases\n\nObject.append(propertySetters, {\n\n\t'class': function(node, value){\n\t\t('className' in node) ? node.className = (value || '') : node.setAttribute('class', value);\n\t},\n\n\t'for': function(node, value){\n\t\t('htmlFor' in node) ? node.htmlFor = value : node.setAttribute('for', value);\n\t},\n\n\t'style': function(node, value){\n\t\t(node.style) ? node.style.cssText = value : node.setAttribute('style', value);\n\t},\n\n\t'value': function(node, value){\n\t\tnode.value = (value != null) ? value : '';\n\t}\n\n});\n\npropertyGetters['class'] = function(node){\n\treturn ('className' in node) ? node.className || null : node.getAttribute('class');\n};\n\n/* <webkit> */\nvar el = document.createElement('button');\n// IE sets type as readonly and throws\ntry { el.type = 'button'; } catch(e){}\nif (el.type != 'button') propertySetters.type = function(node, value){\n\tnode.setAttribute('type', value);\n};\nel = null;\n/* </webkit> */\n\n/*<IE>*/\nvar input = document.createElement('input');\ninput.value = 't';\ninput.type = 'submit';\nif (input.value != 't') propertySetters.type = function(node, type){\n\tvar value = node.value;\n\tnode.type = type;\n\tnode.value = value;\n};\ninput = null;\n/*</IE>*/\n\n/* getProperty, setProperty */\n\n/* <ltIE9> */\nvar pollutesGetAttribute = (function(div){\n\tdiv.random = 'attribute';\n\treturn (div.getAttribute('random') == 'attribute');\n})(document.createElement('div'));\n\n/* <ltIE9> */\n\nElement.implement({\n\n\tsetProperty: function(name, value){\n\t\tvar setter = propertySetters[name.toLowerCase()];\n\t\tif (setter){\n\t\t\tsetter(this, value);\n\t\t} else {\n\t\t\t/* <ltIE9> */\n\t\t\tif (pollutesGetAttribute) var attributeWhiteList = this.retrieve('$attributeWhiteList', {});\n\t\t\t/* </ltIE9> */\n\n\t\t\tif (value == null){\n\t\t\t\tthis.removeAttribute(name);\n\t\t\t\t/* <ltIE9> */\n\t\t\t\tif (pollutesGetAttribute) delete attributeWhiteList[name];\n\t\t\t\t/* </ltIE9> */\n\t\t\t} else {\n\t\t\t\tthis.setAttribute(name, '' + value);\n\t\t\t\t/* <ltIE9> */\n\t\t\t\tif (pollutesGetAttribute) attributeWhiteList[name] = true;\n\t\t\t\t/* </ltIE9> */\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\tsetProperties: function(attributes){\n\t\tfor (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);\n\t\treturn this;\n\t},\n\n\tgetProperty: function(name){\n\t\tvar getter = propertyGetters[name.toLowerCase()];\n\t\tif (getter) return getter(this);\n\t\t/* <ltIE9> */\n\t\tif (pollutesGetAttribute){\n\t\t\tvar attr = this.getAttributeNode(name), attributeWhiteList = this.retrieve('$attributeWhiteList', {});\n\t\t\tif (!attr) return null;\n\t\t\tif (attr.expando && !attributeWhiteList[name]){\n\t\t\t\tvar outer = this.outerHTML;\n\t\t\t\t// segment by the opening tag and find mention of attribute name\n\t\t\t\tif (outer.substr(0, outer.search(/\\/?['\"]?>(?![^<]*<['\"])/)).indexOf(name) < 0) return null;\n\t\t\t\tattributeWhiteList[name] = true;\n\t\t\t}\n\t\t}\n\t\t/* </ltIE9> */\n\t\tvar result = Slick.getAttribute(this, name);\n\t\treturn (!result && !Slick.hasAttribute(this, name)) ? null : result;\n\t},\n\n\tgetProperties: function(){\n\t\tvar args = Array.from(arguments);\n\t\treturn args.map(this.getProperty, this).associate(args);\n\t},\n\n\tremoveProperty: function(name){\n\t\treturn this.setProperty(name, null);\n\t},\n\n\tremoveProperties: function(){\n\t\tArray.each(arguments, this.removeProperty, this);\n\t\treturn this;\n\t},\n\n\tset: function(prop, value){\n\t\tvar property = Element.Properties[prop];\n\t\t(property && property.set) ? property.set.call(this, value) : this.setProperty(prop, value);\n\t}.overloadSetter(),\n\n\tget: function(prop){\n\t\tvar property = Element.Properties[prop];\n\t\treturn (property && property.get) ? property.get.apply(this) : this.getProperty(prop);\n\t}.overloadGetter(),\n\n\terase: function(prop){\n\t\tvar property = Element.Properties[prop];\n\t\t(property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);\n\t\treturn this;\n\t},\n\n\thasClass: function(className){\n\t\treturn this.className.clean().contains(className, ' ');\n\t},\n\n\taddClass: function(className){\n\t\tif (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();\n\t\treturn this;\n\t},\n\n\tremoveClass: function(className){\n\t\tthis.className = this.className.replace(new RegExp('(^|\\\\s)' + className + '(?:\\\\s|$)'), '$1');\n\t\treturn this;\n\t},\n\n\ttoggleClass: function(className, force){\n\t\tif (force == null) force = !this.hasClass(className);\n\t\treturn (force) ? this.addClass(className) : this.removeClass(className);\n\t},\n\n\tadopt: function(){\n\t\tvar parent = this, fragment, elements = Array.flatten(arguments), length = elements.length;\n\t\tif (length > 1) parent = fragment = document.createDocumentFragment();\n\n\t\tfor (var i = 0; i < length; i++){\n\t\t\tvar element = document.id(elements[i], true);\n\t\t\tif (element) parent.appendChild(element);\n\t\t}\n\n\t\tif (fragment) this.appendChild(fragment);\n\n\t\treturn this;\n\t},\n\n\tappendText: function(text, where){\n\t\treturn this.grab(this.getDocument().newTextNode(text), where);\n\t},\n\n\tgrab: function(el, where){\n\t\tinserters[where || 'bottom'](document.id(el, true), this);\n\t\treturn this;\n\t},\n\n\tinject: function(el, where){\n\t\tinserters[where || 'bottom'](this, document.id(el, true));\n\t\treturn this;\n\t},\n\n\treplaces: function(el){\n\t\tel = document.id(el, true);\n\t\tel.parentNode.replaceChild(this, el);\n\t\treturn this;\n\t},\n\n\twraps: function(el, where){\n\t\tel = document.id(el, true);\n\t\treturn this.replaces(el).grab(el, where);\n\t},\n\n\tgetSelected: function(){\n\t\tthis.selectedIndex; // Safari 3.2.1\n\t\treturn new Elements(Array.from(this.options).filter(function(option){\n\t\t\treturn option.selected;\n\t\t}));\n\t},\n\n\ttoQueryString: function(){\n\t\tvar queryString = [];\n\t\tthis.getElements('input, select, textarea').each(function(el){\n\t\t\tvar type = el.type;\n\t\t\tif (!el.name || el.disabled || type == 'submit' || type == 'reset' || type == 'file' || type == 'image') return;\n\n\t\t\tvar value = (el.get('tag') == 'select') ? el.getSelected().map(function(opt){\n\t\t\t\t// IE\n\t\t\t\treturn document.id(opt).get('value');\n\t\t\t}) : ((type == 'radio' || type == 'checkbox') && !el.checked) ? null : el.get('value');\n\n\t\t\tArray.from(value).each(function(val){\n\t\t\t\tif (typeof val != 'undefined') queryString.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(val));\n\t\t\t});\n\t\t});\n\t\treturn queryString.join('&');\n\t}\n\n});\n\nvar collected = {}, storage = {};\n\nvar get = function(uid){\n\treturn (storage[uid] || (storage[uid] = {}));\n};\n\nvar clean = function(item){\n\tvar uid = item.uniqueNumber;\n\tif (item.removeEvents) item.removeEvents();\n\tif (item.clearAttributes) item.clearAttributes();\n\tif (uid != null){\n\t\tdelete collected[uid];\n\t\tdelete storage[uid];\n\t}\n\treturn item;\n};\n\nvar formProps = {input: 'checked', option: 'selected', textarea: 'value'};\n\nElement.implement({\n\n\tdestroy: function(){\n\t\tvar children = clean(this).getElementsByTagName('*');\n\t\tArray.each(children, clean);\n\t\tElement.dispose(this);\n\t\treturn null;\n\t},\n\n\tempty: function(){\n\t\tArray.from(this.childNodes).each(Element.dispose);\n\t\treturn this;\n\t},\n\n\tdispose: function(){\n\t\treturn (this.parentNode) ? this.parentNode.removeChild(this) : this;\n\t},\n\n\tclone: function(contents, keepid){\n\t\tcontents = contents !== false;\n\t\tvar clone = this.cloneNode(contents), ce = [clone], te = [this], i;\n\n\t\tif (contents){\n\t\t\tce.append(Array.from(clone.getElementsByTagName('*')));\n\t\t\tte.append(Array.from(this.getElementsByTagName('*')));\n\t\t}\n\n\t\tfor (i = ce.length; i--;){\n\t\t\tvar node = ce[i], element = te[i];\n\t\t\tif (!keepid) node.removeAttribute('id');\n\t\t\t/*<ltIE9>*/\n\t\t\tif (node.clearAttributes){\n\t\t\t\tnode.clearAttributes();\n\t\t\t\tnode.mergeAttributes(element);\n\t\t\t\tnode.removeAttribute('uniqueNumber');\n\t\t\t\tif (node.options){\n\t\t\t\t\tvar no = node.options, eo = element.options;\n\t\t\t\t\tfor (var j = no.length; j--;) no[j].selected = eo[j].selected;\n\t\t\t\t}\n\t\t\t}\n\t\t\t/*</ltIE9>*/\n\t\t\tvar prop = formProps[element.tagName.toLowerCase()];\n\t\t\tif (prop && element[prop]) node[prop] = element[prop];\n\t\t}\n\n\t\t/*<ltIE9>*/\n\t\tif (Browser.ie){\n\t\t\tvar co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object');\n\t\t\tfor (i = co.length; i--;) co[i].outerHTML = to[i].outerHTML;\n\t\t}\n\t\t/*</ltIE9>*/\n\t\treturn document.id(clone);\n\t}\n\n});\n\n[Element, Window, Document].invoke('implement', {\n\n\taddListener: function(type, fn){\n\t\tif (type == 'unload'){\n\t\t\tvar old = fn, self = this;\n\t\t\tfn = function(){\n\t\t\t\tself.removeListener('unload', fn);\n\t\t\t\told();\n\t\t\t};\n\t\t} else {\n\t\t\tcollected[Slick.uidOf(this)] = this;\n\t\t}\n\t\tif (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]);\n\t\telse this.attachEvent('on' + type, fn);\n\t\treturn this;\n\t},\n\n\tremoveListener: function(type, fn){\n\t\tif (this.removeEventListener) this.removeEventListener(type, fn, !!arguments[2]);\n\t\telse this.detachEvent('on' + type, fn);\n\t\treturn this;\n\t},\n\n\tretrieve: function(property, dflt){\n\t\tvar storage = get(Slick.uidOf(this)), prop = storage[property];\n\t\tif (dflt != null && prop == null) prop = storage[property] = dflt;\n\t\treturn prop != null ? prop : null;\n\t},\n\n\tstore: function(property, value){\n\t\tvar storage = get(Slick.uidOf(this));\n\t\tstorage[property] = value;\n\t\treturn this;\n\t},\n\n\teliminate: function(property){\n\t\tvar storage = get(Slick.uidOf(this));\n\t\tdelete storage[property];\n\t\treturn this;\n\t}\n\n});\n\n/*<ltIE9>*/\nif (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){\n\tObject.each(collected, clean);\n\tif (window.CollectGarbage) CollectGarbage();\n});\n/*</ltIE9>*/\n\nElement.Properties = {};\n\n\n\nElement.Properties.style = {\n\n\tset: function(style){\n\t\tthis.style.cssText = style;\n\t},\n\n\tget: function(){\n\t\treturn this.style.cssText;\n\t},\n\n\terase: function(){\n\t\tthis.style.cssText = '';\n\t}\n\n};\n\nElement.Properties.tag = {\n\n\tget: function(){\n\t\treturn this.tagName.toLowerCase();\n\t}\n\n};\n\nElement.Properties.html = {\n\n\tset: function(html){\n\t\tif (html == null) html = '';\n\t\telse if (typeOf(html) == 'array') html = html.join('');\n\t\tthis.innerHTML = html;\n\t},\n\n\terase: function(){\n\t\tthis.innerHTML = '';\n\t}\n\n};\n\n/*<ltIE9>*/\n// technique by jdbarlett - http://jdbartlett.com/innershiv/\nvar div = document.createElement('div');\ndiv.innerHTML = '<nav></nav>';\nvar supportsHTML5Elements = (div.childNodes.length == 1);\nif (!supportsHTML5Elements){\n\tvar tags = 'abbr article aside audio canvas datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video'.split(' '),\n\t\tfragment = document.createDocumentFragment(), l = tags.length;\n\twhile (l--) fragment.createElement(tags[l]);\n}\ndiv = null;\n/*</ltIE9>*/\n\n/*<IE>*/\nvar supportsTableInnerHTML = Function.attempt(function(){\n\tvar table = document.createElement('table');\n\ttable.innerHTML = '<tr><td></td></tr>';\n\treturn true;\n});\n\n/*<ltFF4>*/\nvar tr = document.createElement('tr'), html = '<td></td>';\ntr.innerHTML = html;\nvar supportsTRInnerHTML = (tr.innerHTML == html);\ntr = null;\n/*</ltFF4>*/\n\nif (!supportsTableInnerHTML || !supportsTRInnerHTML || !supportsHTML5Elements){\n\n\tElement.Properties.html.set = (function(set){\n\n\t\tvar translations = {\n\t\t\ttable: [1, '<table>', '</table>'],\n\t\t\tselect: [1, '<select>', '</select>'],\n\t\t\ttbody: [2, '<table><tbody>', '</tbody></table>'],\n\t\t\ttr: [3, '<table><tbody><tr>', '</tr></tbody></table>']\n\t\t};\n\n\t\ttranslations.thead = translations.tfoot = translations.tbody;\n\n\t\treturn function(html){\n\t\t\tvar wrap = translations[this.get('tag')];\n\t\t\tif (!wrap && !supportsHTML5Elements) wrap = [0, '', ''];\n\t\t\tif (!wrap) return set.call(this, html);\n\n\t\t\tvar level = wrap[0], wrapper = document.createElement('div'), target = wrapper;\n\t\t\tif (!supportsHTML5Elements) fragment.appendChild(wrapper);\n\t\t\twrapper.innerHTML = [wrap[1], html, wrap[2]].flatten().join('');\n\t\t\twhile (level--) target = target.firstChild;\n\t\t\tthis.empty().adopt(target.childNodes);\n\t\t\tif (!supportsHTML5Elements) fragment.removeChild(wrapper);\n\t\t\twrapper = null;\n\t\t};\n\n\t})(Element.Properties.html.set);\n}\n/*</IE>*/\n\n/*<ltIE9>*/\nvar testForm = document.createElement('form');\ntestForm.innerHTML = '<select><option>s</option></select>';\n\nif (testForm.firstChild.value != 's') Element.Properties.value = {\n\n\tset: function(value){\n\t\tvar tag = this.get('tag');\n\t\tif (tag != 'select') return this.setProperty('value', value);\n\t\tvar options = this.getElements('option');\n\t\tfor (var i = 0; i < options.length; i++){\n\t\t\tvar option = options[i],\n\t\t\t\tattr = option.getAttributeNode('value'),\n\t\t\t\toptionValue = (attr && attr.specified) ? option.value : option.get('text');\n\t\t\tif (optionValue == value) return option.selected = true;\n\t\t}\n\t},\n\n\tget: function(){\n\t\tvar option = this, tag = option.get('tag');\n\n\t\tif (tag != 'select' && tag != 'option') return this.getProperty('value');\n\n\t\tif (tag == 'select' && !(option = option.getSelected()[0])) return '';\n\n\t\tvar attr = option.getAttributeNode('value');\n\t\treturn (attr && attr.specified) ? option.value : option.get('text');\n\t}\n\n};\ntestForm = null;\n/*</ltIE9>*/\n\n/*<IE>*/\nif (document.createElement('div').getAttributeNode('id')) Element.Properties.id = {\n\tset: function(id){\n\t\tthis.id = this.getAttributeNode('id').value = id;\n\t},\n\tget: function(){\n\t\treturn this.id || null;\n\t},\n\terase: function(){\n\t\tthis.id = this.getAttributeNode('id').value = '';\n\t}\n};\n/*</IE>*/\n\n})();\n\n\n/*\n---\n\nname: Element.Style\n\ndescription: Contains methods for interacting with the styles of Elements in a fashionable way.\n\nlicense: MIT-style license.\n\nrequires: Element\n\nprovides: Element.Style\n\n...\n*/\n\n(function(){\n\nvar html = document.html;\n\n//<ltIE9>\n// Check for oldIE, which does not remove styles when they're set to null\nvar el = document.createElement('div');\nel.style.color = 'red';\nel.style.color = null;\nvar doesNotRemoveStyles = el.style.color == 'red';\nel = null;\n//</ltIE9>\n\nElement.Properties.styles = {set: function(styles){\n\tthis.setStyles(styles);\n}};\n\nvar hasOpacity = (html.style.opacity != null),\n\thasFilter = (html.style.filter != null),\n\treAlpha = /alpha\\(opacity=([\\d.]+)\\)/i;\n\nvar setVisibility = function(element, opacity){\n\telement.store('$opacity', opacity);\n\telement.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden';\n};\n\nvar setOpacity = (hasOpacity ? function(element, opacity){\n\telement.style.opacity = opacity;\n} : (hasFilter ? function(element, opacity){\n\tvar style = element.style;\n\tif (!element.currentStyle || !element.currentStyle.hasLayout) style.zoom = 1;\n\tif (opacity == null || opacity == 1) opacity = '';\n\telse opacity = 'alpha(opacity=' + (opacity * 100).limit(0, 100).round() + ')';\n\tvar filter = style.filter || element.getComputedStyle('filter') || '';\n\tstyle.filter = reAlpha.test(filter) ? filter.replace(reAlpha, opacity) : filter + opacity;\n\tif (!style.filter) style.removeAttribute('filter');\n} : setVisibility));\n\nvar getOpacity = (hasOpacity ? function(element){\n\tvar opacity = element.style.opacity || element.getComputedStyle('opacity');\n\treturn (opacity == '') ? 1 : opacity.toFloat();\n} : (hasFilter ? function(element){\n\tvar filter = (element.style.filter || element.getComputedStyle('filter')),\n\t\topacity;\n\tif (filter) opacity = filter.match(reAlpha);\n\treturn (opacity == null || filter == null) ? 1 : (opacity[1] / 100);\n} : function(element){\n\tvar opacity = element.retrieve('$opacity');\n\tif (opacity == null) opacity = (element.style.visibility == 'hidden' ? 0 : 1);\n\treturn opacity;\n}));\n\nvar floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat';\n\nElement.implement({\n\n\tgetComputedStyle: function(property){\n\t\tif (this.currentStyle) return this.currentStyle[property.camelCase()];\n\t\tvar defaultView = Element.getDocument(this).defaultView,\n\t\t\tcomputed = defaultView ? defaultView.getComputedStyle(this, null) : null;\n\t\treturn (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : null;\n\t},\n\n\tsetStyle: function(property, value){\n\t\tif (property == 'opacity'){\n\t\t\tif (value != null) value = parseFloat(value);\n\t\t\tsetOpacity(this, value);\n\t\t\treturn this;\n\t\t}\n\t\tproperty = (property == 'float' ? floatName : property).camelCase();\n\t\tif (typeOf(value) != 'string'){\n\t\t\tvar map = (Element.Styles[property] || '@').split(' ');\n\t\t\tvalue = Array.from(value).map(function(val, i){\n\t\t\t\tif (!map[i]) return '';\n\t\t\t\treturn (typeOf(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;\n\t\t\t}).join(' ');\n\t\t} else if (value == String(Number(value))){\n\t\t\tvalue = Math.round(value);\n\t\t}\n\t\tthis.style[property] = value;\n\t\t//<ltIE9>\n\t\tif ((value == '' || value == null) && doesNotRemoveStyles && this.style.removeAttribute){\n\t\t\tthis.style.removeAttribute(property);\n\t\t}\n\t\t//</ltIE9>\n\t\treturn this;\n\t},\n\n\tgetStyle: function(property){\n\t\tif (property == 'opacity') return getOpacity(this);\n\t\tproperty = (property == 'float' ? floatName : property).camelCase();\n\t\tvar result = this.style[property];\n\t\tif (!result || property == 'zIndex'){\n\t\t\tresult = [];\n\t\t\tfor (var style in Element.ShortStyles){\n\t\t\t\tif (property != style) continue;\n\t\t\t\tfor (var s in Element.ShortStyles[style]) result.push(this.getStyle(s));\n\t\t\t\treturn result.join(' ');\n\t\t\t}\n\t\t\tresult = this.getComputedStyle(property);\n\t\t}\n\t\tif (result){\n\t\t\tresult = String(result);\n\t\t\tvar color = result.match(/rgba?\\([\\d\\s,]+\\)/);\n\t\t\tif (color) result = result.replace(color[0], color[0].rgbToHex());\n\t\t}\n\t\tif (Browser.ie && isNaN(parseFloat(result))){\n\t\t\tif ((/^(height|width)$/).test(property)){\n\t\t\t\tvar values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;\n\t\t\t\tvalues.each(function(value){\n\t\t\t\t\tsize += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();\n\t\t\t\t}, this);\n\t\t\t\treturn this['offset' + property.capitalize()] - size + 'px';\n\t\t\t}\n\t\t\tif (Browser.opera && String(result).indexOf('px') != -1) return result;\n\t\t\tif ((/^border(.+)Width|margin|padding/).test(property)) return '0px';\n\t\t}\n\t\treturn result;\n\t},\n\n\tsetStyles: function(styles){\n\t\tfor (var style in styles) this.setStyle(style, styles[style]);\n\t\treturn this;\n\t},\n\n\tgetStyles: function(){\n\t\tvar result = {};\n\t\tArray.flatten(arguments).each(function(key){\n\t\t\tresult[key] = this.getStyle(key);\n\t\t}, this);\n\t\treturn result;\n\t}\n\n});\n\nElement.Styles = {\n\tleft: '@px', top: '@px', bottom: '@px', right: '@px',\n\twidth: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',\n\tbackgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)',\n\tfontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)',\n\tmargin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',\n\tborderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',\n\tzIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'\n};\n\n\n\n\n\nElement.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}};\n\n['Top', 'Right', 'Bottom', 'Left'].each(function(direction){\n\tvar Short = Element.ShortStyles;\n\tvar All = Element.Styles;\n\t['margin', 'padding'].each(function(style){\n\t\tvar sd = style + direction;\n\t\tShort[style][sd] = All[sd] = '@px';\n\t});\n\tvar bd = 'border' + direction;\n\tShort.border[bd] = All[bd] = '@px @ rgb(@, @, @)';\n\tvar bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color';\n\tShort[bd] = {};\n\tShort.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px';\n\tShort.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';\n\tShort.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';\n});\n\n})();\n\n\n/*\n---\n\nname: Element.Event\n\ndescription: Contains Element methods for dealing with events. This file also includes mouseenter and mouseleave custom Element Events, if necessary.\n\nlicense: MIT-style license.\n\nrequires: [Element, Event]\n\nprovides: Element.Event\n\n...\n*/\n\n(function(){\n\nElement.Properties.events = {set: function(events){\n\tthis.addEvents(events);\n}};\n\n[Element, Window, Document].invoke('implement', {\n\n\taddEvent: function(type, fn){\n\t\tvar events = this.retrieve('events', {});\n\t\tif (!events[type]) events[type] = {keys: [], values: []};\n\t\tif (events[type].keys.contains(fn)) return this;\n\t\tevents[type].keys.push(fn);\n\t\tvar realType = type,\n\t\t\tcustom = Element.Events[type],\n\t\t\tcondition = fn,\n\t\t\tself = this;\n\t\tif (custom){\n\t\t\tif (custom.onAdd) custom.onAdd.call(this, fn, type);\n\t\t\tif (custom.condition){\n\t\t\t\tcondition = function(event){\n\t\t\t\t\tif (custom.condition.call(this, event, type)) return fn.call(this, event);\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (custom.base) realType = Function.from(custom.base).call(this, type);\n\t\t}\n\t\tvar defn = function(){\n\t\t\treturn fn.call(self);\n\t\t};\n\t\tvar nativeEvent = Element.NativeEvents[realType];\n\t\tif (nativeEvent){\n\t\t\tif (nativeEvent == 2){\n\t\t\t\tdefn = function(event){\n\t\t\t\t\tevent = new DOMEvent(event, self.getWindow());\n\t\t\t\t\tif (condition.call(self, event) === false) event.stop();\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis.addListener(realType, defn, arguments[2]);\n\t\t}\n\t\tevents[type].values.push(defn);\n\t\treturn this;\n\t},\n\n\tremoveEvent: function(type, fn){\n\t\tvar events = this.retrieve('events');\n\t\tif (!events || !events[type]) return this;\n\t\tvar list = events[type];\n\t\tvar index = list.keys.indexOf(fn);\n\t\tif (index == -1) return this;\n\t\tvar value = list.values[index];\n\t\tdelete list.keys[index];\n\t\tdelete list.values[index];\n\t\tvar custom = Element.Events[type];\n\t\tif (custom){\n\t\t\tif (custom.onRemove) custom.onRemove.call(this, fn, type);\n\t\t\tif (custom.base) type = Function.from(custom.base).call(this, type);\n\t\t}\n\t\treturn (Element.NativeEvents[type]) ? this.removeListener(type, value, arguments[2]) : this;\n\t},\n\n\taddEvents: function(events){\n\t\tfor (var event in events) this.addEvent(event, events[event]);\n\t\treturn this;\n\t},\n\n\tremoveEvents: function(events){\n\t\tvar type;\n\t\tif (typeOf(events) == 'object'){\n\t\t\tfor (type in events) this.removeEvent(type, events[type]);\n\t\t\treturn this;\n\t\t}\n\t\tvar attached = this.retrieve('events');\n\t\tif (!attached) return this;\n\t\tif (!events){\n\t\t\tfor (type in attached) this.removeEvents(type);\n\t\t\tthis.eliminate('events');\n\t\t} else if (attached[events]){\n\t\t\tattached[events].keys.each(function(fn){\n\t\t\t\tthis.removeEvent(events, fn);\n\t\t\t}, this);\n\t\t\tdelete attached[events];\n\t\t}\n\t\treturn this;\n\t},\n\n\tfireEvent: function(type, args, delay){\n\t\tvar events = this.retrieve('events');\n\t\tif (!events || !events[type]) return this;\n\t\targs = Array.from(args);\n\n\t\tevents[type].keys.each(function(fn){\n\t\t\tif (delay) fn.delay(delay, this, args);\n\t\t\telse fn.apply(this, args);\n\t\t}, this);\n\t\treturn this;\n\t},\n\n\tcloneEvents: function(from, type){\n\t\tfrom = document.id(from);\n\t\tvar events = from.retrieve('events');\n\t\tif (!events) return this;\n\t\tif (!type){\n\t\t\tfor (var eventType in events) this.cloneEvents(from, eventType);\n\t\t} else if (events[type]){\n\t\t\tevents[type].keys.each(function(fn){\n\t\t\t\tthis.addEvent(type, fn);\n\t\t\t}, this);\n\t\t}\n\t\treturn this;\n\t}\n\n});\n\nElement.NativeEvents = {\n\tclick: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons\n\tmousewheel: 2, DOMMouseScroll: 2, //mouse wheel\n\tmouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement\n\tkeydown: 2, keypress: 2, keyup: 2, //keyboard\n\torientationchange: 2, // mobile\n\ttouchstart: 2, touchmove: 2, touchend: 2, touchcancel: 2, // touch\n\tgesturestart: 2, gesturechange: 2, gestureend: 2, // gesture\n\tfocus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, paste: 2, input: 2, //form elements\n\tload: 2, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window\n\terror: 1, abort: 1, scroll: 1 //misc\n};\n\nElement.Events = {mousewheel: {\n\tbase: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel'\n}};\n\nif ('onmouseenter' in document.documentElement){\n\tElement.NativeEvents.mouseenter = Element.NativeEvents.mouseleave = 2;\n} else {\n\tvar check = function(event){\n\t\tvar related = event.relatedTarget;\n\t\tif (related == null) return true;\n\t\tif (!related) return false;\n\t\treturn (related != this && related.prefix != 'xul' && typeOf(this) != 'document' && !this.contains(related));\n\t};\n\n\tElement.Events.mouseenter = {\n\t\tbase: 'mouseover',\n\t\tcondition: check\n\t};\n\n\tElement.Events.mouseleave = {\n\t\tbase: 'mouseout',\n\t\tcondition: check\n\t};\n}\n\n/*<ltIE9>*/\nif (!window.addEventListener){\n\tElement.NativeEvents.propertychange = 2;\n\tElement.Events.change = {\n\t\tbase: function(){\n\t\t\tvar type = this.type;\n\t\t\treturn (this.get('tag') == 'input' && (type == 'radio' || type == 'checkbox')) ? 'propertychange' : 'change'\n\t\t},\n\t\tcondition: function(event){\n\t\t\treturn this.type != 'radio' || (event.event.propertyName == 'checked' && this.checked);\n\t\t}\n\t}\n}\n/*</ltIE9>*/\n\n\n\n})();\n\n\n/*\n---\n\nname: Element.Delegation\n\ndescription: Extends the Element native object to include the delegate method for more efficient event management.\n\nlicense: MIT-style license.\n\nrequires: [Element.Event]\n\nprovides: [Element.Delegation]\n\n...\n*/\n\n(function(){\n\nvar eventListenerSupport = !!window.addEventListener;\n\nElement.NativeEvents.focusin = Element.NativeEvents.focusout = 2;\n\nvar bubbleUp = function(self, match, fn, event, target){\n\twhile (target && target != self){\n\t\tif (match(target, event)) return fn.call(target, event, target);\n\t\ttarget = document.id(target.parentNode);\n\t}\n};\n\nvar map = {\n\tmouseenter: {\n\t\tbase: 'mouseover'\n\t},\n\tmouseleave: {\n\t\tbase: 'mouseout'\n\t},\n\tfocus: {\n\t\tbase: 'focus' + (eventListenerSupport ? '' : 'in'),\n\t\tcapture: true\n\t},\n\tblur: {\n\t\tbase: eventListenerSupport ? 'blur' : 'focusout',\n\t\tcapture: true\n\t}\n};\n\n/*<ltIE9>*/\nvar _key = '$delegation:';\nvar formObserver = function(type){\n\n\treturn {\n\n\t\tbase: 'focusin',\n\n\t\tremove: function(self, uid){\n\t\t\tvar list = self.retrieve(_key + type + 'listeners', {})[uid];\n\t\t\tif (list && list.forms) for (var i = list.forms.length; i--;){\n\t\t\t\tlist.forms[i].removeEvent(type, list.fns[i]);\n\t\t\t}\n\t\t},\n\n\t\tlisten: function(self, match, fn, event, target, uid){\n\t\t\tvar form = (target.get('tag') == 'form') ? target : event.target.getParent('form');\n\t\t\tif (!form) return;\n\n\t\t\tvar listeners = self.retrieve(_key + type + 'listeners', {}),\n\t\t\t\tlistener = listeners[uid] || {forms: [], fns: []},\n\t\t\t\tforms = listener.forms, fns = listener.fns;\n\n\t\t\tif (forms.indexOf(form) != -1) return;\n\t\t\tforms.push(form);\n\n\t\t\tvar _fn = function(event){\n\t\t\t\tbubbleUp(self, match, fn, event, target);\n\t\t\t};\n\t\t\tform.addEvent(type, _fn);\n\t\t\tfns.push(_fn);\n\n\t\t\tlisteners[uid] = listener;\n\t\t\tself.store(_key + type + 'listeners', listeners);\n\t\t}\n\t};\n};\n\nvar inputObserver = function(type){\n\treturn {\n\t\tbase: 'focusin',\n\t\tlisten: function(self, match, fn, event, target){\n\t\t\tvar events = {blur: function(){\n\t\t\t\tthis.removeEvents(events);\n\t\t\t}};\n\t\t\tevents[type] = function(event){\n\t\t\t\tbubbleUp(self, match, fn, event, target);\n\t\t\t};\n\t\t\tevent.target.addEvents(events);\n\t\t}\n\t};\n};\n\nif (!eventListenerSupport) Object.append(map, {\n\tsubmit: formObserver('submit'),\n\treset: formObserver('reset'),\n\tchange: inputObserver('change'),\n\tselect: inputObserver('select')\n});\n/*</ltIE9>*/\n\nvar proto = Element.prototype,\n\taddEvent = proto.addEvent,\n\tremoveEvent = proto.removeEvent;\n\nvar relay = function(old, method){\n\treturn function(type, fn, useCapture){\n\t\tif (type.indexOf(':relay') == -1) return old.call(this, type, fn, useCapture);\n\t\tvar parsed = Slick.parse(type).expressions[0][0];\n\t\tif (parsed.pseudos[0].key != 'relay') return old.call(this, type, fn, useCapture);\n\t\tvar newType = parsed.tag;\n\t\tparsed.pseudos.slice(1).each(function(pseudo){\n\t\t\tnewType += ':' + pseudo.key + (pseudo.value ? '(' + pseudo.value + ')' : '');\n\t\t});\n\t\told.call(this, type, fn);\n\t\treturn method.call(this, newType, parsed.pseudos[0].value, fn);\n\t};\n};\n\nvar delegation = {\n\n\taddEvent: function(type, match, fn){\n\t\tvar storage = this.retrieve('$delegates', {}), stored = storage[type];\n\t\tif (stored) for (var _uid in stored){\n\t\t\tif (stored[_uid].fn == fn && stored[_uid].match == match) return this;\n\t\t}\n\n\t\tvar _type = type, _match = match, _fn = fn, _map = map[type] || {};\n\t\ttype = _map.base || _type;\n\n\t\tmatch = function(target){\n\t\t\treturn Slick.match(target, _match);\n\t\t};\n\n\t\tvar elementEvent = Element.Events[_type];\n\t\tif (elementEvent && elementEvent.condition){\n\t\t\tvar __match = match, condition = elementEvent.condition;\n\t\t\tmatch = function(target, event){\n\t\t\t\treturn __match(target, event) && condition.call(target, event, type);\n\t\t\t};\n\t\t}\n\n\t\tvar self = this, uid = String.uniqueID();\n\t\tvar delegator = _map.listen ? function(event, target){\n\t\t\tif (!target && event && event.target) target = event.target;\n\t\t\tif (target) _map.listen(self, match, fn, event, target, uid);\n\t\t} : function(event, target){\n\t\t\tif (!target && event && event.target) target = event.target;\n\t\t\tif (target) bubbleUp(self, match, fn, event, target);\n\t\t};\n\n\t\tif (!stored) stored = {};\n\t\tstored[uid] = {\n\t\t\tmatch: _match,\n\t\t\tfn: _fn,\n\t\t\tdelegator: delegator\n\t\t};\n\t\tstorage[_type] = stored;\n\t\treturn addEvent.call(this, type, delegator, _map.capture);\n\t},\n\n\tremoveEvent: function(type, match, fn, _uid){\n\t\tvar storage = this.retrieve('$delegates', {}), stored = storage[type];\n\t\tif (!stored) return this;\n\n\t\tif (_uid){\n\t\t\tvar _type = type, delegator = stored[_uid].delegator, _map = map[type] || {};\n\t\t\ttype = _map.base || _type;\n\t\t\tif (_map.remove) _map.remove(this, _uid);\n\t\t\tdelete stored[_uid];\n\t\t\tstorage[_type] = stored;\n\t\t\treturn removeEvent.call(this, type, delegator);\n\t\t}\n\n\t\tvar __uid, s;\n\t\tif (fn) for (__uid in stored){\n\t\t\ts = stored[__uid];\n\t\t\tif (s.match == match && s.fn == fn) return delegation.removeEvent.call(this, type, match, fn, __uid);\n\t\t} else for (__uid in stored){\n\t\t\ts = stored[__uid];\n\t\t\tif (s.match == match) delegation.removeEvent.call(this, type, match, s.fn, __uid);\n\t\t}\n\t\treturn this;\n\t}\n\n};\n\n[Element, Window, Document].invoke('implement', {\n\taddEvent: relay(addEvent, delegation.addEvent),\n\tremoveEvent: relay(removeEvent, delegation.removeEvent)\n});\n\n})();\n\n\n/*\n---\n\nname: Element.Dimensions\n\ndescription: Contains methods to work with size, scroll, or positioning of Elements and the window object.\n\nlicense: MIT-style license.\n\ncredits:\n  - Element positioning based on the [qooxdoo](http://qooxdoo.org/) code and smart browser fixes, [LGPL License](http://www.gnu.org/licenses/lgpl.html).\n  - Viewport dimensions based on [YUI](http://developer.yahoo.com/yui/) code, [BSD License](http://developer.yahoo.com/yui/license.html).\n\nrequires: [Element, Element.Style]\n\nprovides: [Element.Dimensions]\n\n...\n*/\n\n(function(){\n\nvar element = document.createElement('div'),\n\tchild = document.createElement('div');\nelement.style.height = '0';\nelement.appendChild(child);\nvar brokenOffsetParent = (child.offsetParent === element);\nelement = child = null;\n\nvar isOffset = function(el){\n\treturn styleString(el, 'position') != 'static' || isBody(el);\n};\n\nvar isOffsetStatic = function(el){\n\treturn isOffset(el) || (/^(?:table|td|th)$/i).test(el.tagName);\n};\n\nElement.implement({\n\n\tscrollTo: function(x, y){\n\t\tif (isBody(this)){\n\t\t\tthis.getWindow().scrollTo(x, y);\n\t\t} else {\n\t\t\tthis.scrollLeft = x;\n\t\t\tthis.scrollTop = y;\n\t\t}\n\t\treturn this;\n\t},\n\n\tgetSize: function(){\n\t\tif (isBody(this)) return this.getWindow().getSize();\n\t\treturn {x: this.offsetWidth, y: this.offsetHeight};\n\t},\n\n\tgetScrollSize: function(){\n\t\tif (isBody(this)) return this.getWindow().getScrollSize();\n\t\treturn {x: this.scrollWidth, y: this.scrollHeight};\n\t},\n\n\tgetScroll: function(){\n\t\tif (isBody(this)) return this.getWindow().getScroll();\n\t\treturn {x: this.scrollLeft, y: this.scrollTop};\n\t},\n\n\tgetScrolls: function(){\n\t\tvar element = this.parentNode, position = {x: 0, y: 0};\n\t\twhile (element && !isBody(element)){\n\t\t\tposition.x += element.scrollLeft;\n\t\t\tposition.y += element.scrollTop;\n\t\t\telement = element.parentNode;\n\t\t}\n\t\treturn position;\n\t},\n\n\tgetOffsetParent: brokenOffsetParent ? function(){\n\t\tvar element = this;\n\t\tif (isBody(element) || styleString(element, 'position') == 'fixed') return null;\n\n\t\tvar isOffsetCheck = (styleString(element, 'position') == 'static') ? isOffsetStatic : isOffset;\n\t\twhile ((element = element.parentNode)){\n\t\t\tif (isOffsetCheck(element)) return element;\n\t\t}\n\t\treturn null;\n\t} : function(){\n\t\tvar element = this;\n\t\tif (isBody(element) || styleString(element, 'position') == 'fixed') return null;\n\n\t\ttry {\n\t\t\treturn element.offsetParent;\n\t\t} catch(e) {}\n\t\treturn null;\n\t},\n\n\tgetOffsets: function(){\n\t\tif (this.getBoundingClientRect && !Browser.Platform.ios){\n\t\t\tvar bound = this.getBoundingClientRect(),\n\t\t\t\thtml = document.id(this.getDocument().documentElement),\n\t\t\t\thtmlScroll = html.getScroll(),\n\t\t\t\telemScrolls = this.getScrolls(),\n\t\t\t\tisFixed = (styleString(this, 'position') == 'fixed');\n\n\t\t\treturn {\n\t\t\t\tx: bound.left.toInt() + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,\n\t\t\t\ty: bound.top.toInt()  + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop\n\t\t\t};\n\t\t}\n\n\t\tvar element = this, position = {x: 0, y: 0};\n\t\tif (isBody(this)) return position;\n\n\t\twhile (element && !isBody(element)){\n\t\t\tposition.x += element.offsetLeft;\n\t\t\tposition.y += element.offsetTop;\n\n\t\t\tif (Browser.firefox){\n\t\t\t\tif (!borderBox(element)){\n\t\t\t\t\tposition.x += leftBorder(element);\n\t\t\t\t\tposition.y += topBorder(element);\n\t\t\t\t}\n\t\t\t\tvar parent = element.parentNode;\n\t\t\t\tif (parent && styleString(parent, 'overflow') != 'visible'){\n\t\t\t\t\tposition.x += leftBorder(parent);\n\t\t\t\t\tposition.y += topBorder(parent);\n\t\t\t\t}\n\t\t\t} else if (element != this && Browser.safari){\n\t\t\t\tposition.x += leftBorder(element);\n\t\t\t\tposition.y += topBorder(element);\n\t\t\t}\n\n\t\t\telement = element.offsetParent;\n\t\t}\n\t\tif (Browser.firefox && !borderBox(this)){\n\t\t\tposition.x -= leftBorder(this);\n\t\t\tposition.y -= topBorder(this);\n\t\t}\n\t\treturn position;\n\t},\n\n\tgetPosition: function(relative){\n\t\tvar offset = this.getOffsets(),\n\t\t\tscroll = this.getScrolls();\n\t\tvar position = {\n\t\t\tx: offset.x - scroll.x,\n\t\t\ty: offset.y - scroll.y\n\t\t};\n\n\t\tif (relative && (relative = document.id(relative))){\n\t\t\tvar relativePosition = relative.getPosition();\n\t\t\treturn {x: position.x - relativePosition.x - leftBorder(relative), y: position.y - relativePosition.y - topBorder(relative)};\n\t\t}\n\t\treturn position;\n\t},\n\n\tgetCoordinates: function(element){\n\t\tif (isBody(this)) return this.getWindow().getCoordinates();\n\t\tvar position = this.getPosition(element),\n\t\t\tsize = this.getSize();\n\t\tvar obj = {\n\t\t\tleft: position.x,\n\t\t\ttop: position.y,\n\t\t\twidth: size.x,\n\t\t\theight: size.y\n\t\t};\n\t\tobj.right = obj.left + obj.width;\n\t\tobj.bottom = obj.top + obj.height;\n\t\treturn obj;\n\t},\n\n\tcomputePosition: function(obj){\n\t\treturn {\n\t\t\tleft: obj.x - styleNumber(this, 'margin-left'),\n\t\t\ttop: obj.y - styleNumber(this, 'margin-top')\n\t\t};\n\t},\n\n\tsetPosition: function(obj){\n\t\treturn this.setStyles(this.computePosition(obj));\n\t}\n\n});\n\n\n[Document, Window].invoke('implement', {\n\n\tgetSize: function(){\n\t\tvar doc = getCompatElement(this);\n\t\treturn {x: doc.clientWidth, y: doc.clientHeight};\n\t},\n\n\tgetScroll: function(){\n\t\tvar win = this.getWindow(), doc = getCompatElement(this);\n\t\treturn {x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop};\n\t},\n\n\tgetScrollSize: function(){\n\t\tvar doc = getCompatElement(this),\n\t\t\tmin = this.getSize(),\n\t\t\tbody = this.getDocument().body;\n\n\t\treturn {x: Math.max(doc.scrollWidth, body.scrollWidth, min.x), y: Math.max(doc.scrollHeight, body.scrollHeight, min.y)};\n\t},\n\n\tgetPosition: function(){\n\t\treturn {x: 0, y: 0};\n\t},\n\n\tgetCoordinates: function(){\n\t\tvar size = this.getSize();\n\t\treturn {top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x};\n\t}\n\n});\n\n// private methods\n\nvar styleString = Element.getComputedStyle;\n\nfunction styleNumber(element, style){\n\treturn styleString(element, style).toInt() || 0;\n}\n\nfunction borderBox(element){\n\treturn styleString(element, '-moz-box-sizing') == 'border-box';\n}\n\nfunction topBorder(element){\n\treturn styleNumber(element, 'border-top-width');\n}\n\nfunction leftBorder(element){\n\treturn styleNumber(element, 'border-left-width');\n}\n\nfunction isBody(element){\n\treturn (/^(?:body|html)$/i).test(element.tagName);\n}\n\nfunction getCompatElement(element){\n\tvar doc = element.getDocument();\n\treturn (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;\n}\n\n})();\n\n//aliases\nElement.alias({position: 'setPosition'}); //compatability\n\n[Window, Document, Element].invoke('implement', {\n\n\tgetHeight: function(){\n\t\treturn this.getSize().y;\n\t},\n\n\tgetWidth: function(){\n\t\treturn this.getSize().x;\n\t},\n\n\tgetScrollTop: function(){\n\t\treturn this.getScroll().y;\n\t},\n\n\tgetScrollLeft: function(){\n\t\treturn this.getScroll().x;\n\t},\n\n\tgetScrollHeight: function(){\n\t\treturn this.getScrollSize().y;\n\t},\n\n\tgetScrollWidth: function(){\n\t\treturn this.getScrollSize().x;\n\t},\n\n\tgetTop: function(){\n\t\treturn this.getPosition().y;\n\t},\n\n\tgetLeft: function(){\n\t\treturn this.getPosition().x;\n\t}\n\n});\n\n\n/*\n---\n\nname: Fx\n\ndescription: Contains the basic animation logic to be extended by all other Fx Classes.\n\nlicense: MIT-style license.\n\nrequires: [Chain, Events, Options]\n\nprovides: Fx\n\n...\n*/\n\n(function(){\n\nvar Fx = this.Fx = new Class({\n\n\tImplements: [Chain, Events, Options],\n\n\toptions: {\n\t\t/*\n\t\tonStart: nil,\n\t\tonCancel: nil,\n\t\tonComplete: nil,\n\t\t*/\n\t\tfps: 60,\n\t\tunit: false,\n\t\tduration: 500,\n\t\tframes: null,\n\t\tframeSkip: true,\n\t\tlink: 'ignore'\n\t},\n\n\tinitialize: function(options){\n\t\tthis.subject = this.subject || this;\n\t\tthis.setOptions(options);\n\t},\n\n\tgetTransition: function(){\n\t\treturn function(p){\n\t\t\treturn -(Math.cos(Math.PI * p) - 1) / 2;\n\t\t};\n\t},\n\n\tstep: function(now){\n\t\tif (this.options.frameSkip){\n\t\t\tvar diff = (this.time != null) ? (now - this.time) : 0, frames = diff / this.frameInterval;\n\t\t\tthis.time = now;\n\t\t\tthis.frame += frames;\n\t\t} else {\n\t\t\tthis.frame++;\n\t\t}\n\n\t\tif (this.frame < this.frames){\n\t\t\tvar delta = this.transition(this.frame / this.frames);\n\t\t\tthis.set(this.compute(this.from, this.to, delta));\n\t\t} else {\n\t\t\tthis.frame = this.frames;\n\t\t\tthis.set(this.compute(this.from, this.to, 1));\n\t\t\tthis.stop();\n\t\t}\n\t},\n\n\tset: function(now){\n\t\treturn now;\n\t},\n\n\tcompute: function(from, to, delta){\n\t\treturn Fx.compute(from, to, delta);\n\t},\n\n\tcheck: function(){\n\t\tif (!this.isRunning()) return true;\n\t\tswitch (this.options.link){\n\t\t\tcase 'cancel': this.cancel(); return true;\n\t\t\tcase 'chain': this.chain(this.caller.pass(arguments, this)); return false;\n\t\t}\n\t\treturn false;\n\t},\n\n\tstart: function(from, to){\n\t\tif (!this.check(from, to)) return this;\n\t\tthis.from = from;\n\t\tthis.to = to;\n\t\tthis.frame = (this.options.frameSkip) ? 0 : -1;\n\t\tthis.time = null;\n\t\tthis.transition = this.getTransition();\n\t\tvar frames = this.options.frames, fps = this.options.fps, duration = this.options.duration;\n\t\tthis.duration = Fx.Durations[duration] || duration.toInt();\n\t\tthis.frameInterval = 1000 / fps;\n\t\tthis.frames = frames || Math.round(this.duration / this.frameInterval);\n\t\tthis.fireEvent('start', this.subject);\n\t\tpushInstance.call(this, fps);\n\t\treturn this;\n\t},\n\n\tstop: function(){\n\t\tif (this.isRunning()){\n\t\t\tthis.time = null;\n\t\t\tpullInstance.call(this, this.options.fps);\n\t\t\tif (this.frames == this.frame){\n\t\t\t\tthis.fireEvent('complete', this.subject);\n\t\t\t\tif (!this.callChain()) this.fireEvent('chainComplete', this.subject);\n\t\t\t} else {\n\t\t\t\tthis.fireEvent('stop', this.subject);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\tcancel: function(){\n\t\tif (this.isRunning()){\n\t\t\tthis.time = null;\n\t\t\tpullInstance.call(this, this.options.fps);\n\t\t\tthis.frame = this.frames;\n\t\t\tthis.fireEvent('cancel', this.subject).clearChain();\n\t\t}\n\t\treturn this;\n\t},\n\n\tpause: function(){\n\t\tif (this.isRunning()){\n\t\t\tthis.time = null;\n\t\t\tpullInstance.call(this, this.options.fps);\n\t\t}\n\t\treturn this;\n\t},\n\n\tresume: function(){\n\t\tif ((this.frame < this.frames) && !this.isRunning()) pushInstance.call(this, this.options.fps);\n\t\treturn this;\n\t},\n\n\tisRunning: function(){\n\t\tvar list = instances[this.options.fps];\n\t\treturn list && list.contains(this);\n\t}\n\n});\n\nFx.compute = function(from, to, delta){\n\treturn (to - from) * delta + from;\n};\n\nFx.Durations = {'short': 250, 'normal': 500, 'long': 1000};\n\n// global timers\n\nvar instances = {}, timers = {};\n\nvar loop = function(){\n\tvar now = Date.now();\n\tfor (var i = this.length; i--;){\n\t\tvar instance = this[i];\n\t\tif (instance) instance.step(now);\n\t}\n};\n\nvar pushInstance = function(fps){\n\tvar list = instances[fps] || (instances[fps] = []);\n\tlist.push(this);\n\tif (!timers[fps]) timers[fps] = loop.periodical(Math.round(1000 / fps), list);\n};\n\nvar pullInstance = function(fps){\n\tvar list = instances[fps];\n\tif (list){\n\t\tlist.erase(this);\n\t\tif (!list.length && timers[fps]){\n\t\t\tdelete instances[fps];\n\t\t\ttimers[fps] = clearInterval(timers[fps]);\n\t\t}\n\t}\n};\n\n})();\n\n\n/*\n---\n\nname: Fx.CSS\n\ndescription: Contains the CSS animation logic. Used by Fx.Tween, Fx.Morph, Fx.Elements.\n\nlicense: MIT-style license.\n\nrequires: [Fx, Element.Style]\n\nprovides: Fx.CSS\n\n...\n*/\n\nFx.CSS = new Class({\n\n\tExtends: Fx,\n\n\t//prepares the base from/to object\n\n\tprepare: function(element, property, values){\n\t\tvalues = Array.from(values);\n\t\tvar from = values[0], to = values[1];\n\t\tif (to == null){\n\t\t\tto = from;\n\t\t\tfrom = element.getStyle(property);\n\t\t\tvar unit = this.options.unit;\n\t\t\t// adapted from: https://github.com/ryanmorr/fx/blob/master/fx.js#L299\n\t\t\tif (unit && from.slice(-unit.length) != unit && parseFloat(from) != 0){\n\t\t\t\telement.setStyle(property, to + unit);\n\t\t\t\tvar value = element.getComputedStyle(property);\n\t\t\t\t// IE and Opera support pixelLeft or pixelWidth\n\t\t\t\tif (!(/px$/.test(value))){\n\t\t\t\t\tvalue = element.style[('pixel-' + property).camelCase()];\n\t\t\t\t\tif (value == null){\n\t\t\t\t\t\t// adapted from Dean Edwards' http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291\n\t\t\t\t\t\tvar left = element.style.left;\n\t\t\t\t\t\telement.style.left = to + unit;\n\t\t\t\t\t\tvalue = element.style.pixelLeft;\n\t\t\t\t\t\telement.style.left = left;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfrom = (to || 1) / (parseFloat(value) || 1) * (parseFloat(from) || 0);\n\t\t\t\telement.setStyle(property, from + unit);\n\t\t\t}\n\t\t}\n\t\treturn {from: this.parse(from), to: this.parse(to)};\n\t},\n\n\t//parses a value into an array\n\n\tparse: function(value){\n\t\tvalue = Function.from(value)();\n\t\tvalue = (typeof value == 'string') ? value.split(' ') : Array.from(value);\n\t\treturn value.map(function(val){\n\t\t\tval = String(val);\n\t\t\tvar found = false;\n\t\t\tObject.each(Fx.CSS.Parsers, function(parser, key){\n\t\t\t\tif (found) return;\n\t\t\t\tvar parsed = parser.parse(val);\n\t\t\t\tif (parsed || parsed === 0) found = {value: parsed, parser: parser};\n\t\t\t});\n\t\t\tfound = found || {value: val, parser: Fx.CSS.Parsers.String};\n\t\t\treturn found;\n\t\t});\n\t},\n\n\t//computes by a from and to prepared objects, using their parsers.\n\n\tcompute: function(from, to, delta){\n\t\tvar computed = [];\n\t\t(Math.min(from.length, to.length)).times(function(i){\n\t\t\tcomputed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser});\n\t\t});\n\t\tcomputed.$family = Function.from('fx:css:value');\n\t\treturn computed;\n\t},\n\n\t//serves the value as settable\n\n\tserve: function(value, unit){\n\t\tif (typeOf(value) != 'fx:css:value') value = this.parse(value);\n\t\tvar returned = [];\n\t\tvalue.each(function(bit){\n\t\t\treturned = returned.concat(bit.parser.serve(bit.value, unit));\n\t\t});\n\t\treturn returned;\n\t},\n\n\t//renders the change to an element\n\n\trender: function(element, property, value, unit){\n\t\telement.setStyle(property, this.serve(value, unit));\n\t},\n\n\t//searches inside the page css to find the values for a selector\n\n\tsearch: function(selector){\n\t\tif (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector];\n\t\tvar to = {}, selectorTest = new RegExp('^' + selector.escapeRegExp() + '$');\n\t\tArray.each(document.styleSheets, function(sheet, j){\n\t\t\tvar href = sheet.href;\n\t\t\tif (href && href.contains('://') && !href.contains(document.domain)) return;\n\t\t\tvar rules = sheet.rules || sheet.cssRules;\n\t\t\tArray.each(rules, function(rule, i){\n\t\t\t\tif (!rule.style) return;\n\t\t\t\tvar selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\\w+/, function(m){\n\t\t\t\t\treturn m.toLowerCase();\n\t\t\t\t}) : null;\n\t\t\t\tif (!selectorText || !selectorTest.test(selectorText)) return;\n\t\t\t\tObject.each(Element.Styles, function(value, style){\n\t\t\t\t\tif (!rule.style[style] || Element.ShortStyles[style]) return;\n\t\t\t\t\tvalue = String(rule.style[style]);\n\t\t\t\t\tto[style] = ((/^rgb/).test(value)) ? value.rgbToHex() : value;\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t\treturn Fx.CSS.Cache[selector] = to;\n\t}\n\n});\n\nFx.CSS.Cache = {};\n\nFx.CSS.Parsers = {\n\n\tColor: {\n\t\tparse: function(value){\n\t\t\tif (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hexToRgb(true);\n\t\t\treturn ((value = value.match(/(\\d+),\\s*(\\d+),\\s*(\\d+)/))) ? [value[1], value[2], value[3]] : false;\n\t\t},\n\t\tcompute: function(from, to, delta){\n\t\t\treturn from.map(function(value, i){\n\t\t\t\treturn Math.round(Fx.compute(from[i], to[i], delta));\n\t\t\t});\n\t\t},\n\t\tserve: function(value){\n\t\t\treturn value.map(Number);\n\t\t}\n\t},\n\n\tNumber: {\n\t\tparse: parseFloat,\n\t\tcompute: Fx.compute,\n\t\tserve: function(value, unit){\n\t\t\treturn (unit) ? value + unit : value;\n\t\t}\n\t},\n\n\tString: {\n\t\tparse: Function.from(false),\n\t\tcompute: function(zero, one){\n\t\t\treturn one;\n\t\t},\n\t\tserve: function(zero){\n\t\t\treturn zero;\n\t\t}\n\t}\n\n};\n\n\n\n\n/*\n---\n\nname: Fx.Tween\n\ndescription: Formerly Fx.Style, effect to transition any CSS property for an element.\n\nlicense: MIT-style license.\n\nrequires: Fx.CSS\n\nprovides: [Fx.Tween, Element.fade, Element.highlight]\n\n...\n*/\n\nFx.Tween = new Class({\n\n\tExtends: Fx.CSS,\n\n\tinitialize: function(element, options){\n\t\tthis.element = this.subject = document.id(element);\n\t\tthis.parent(options);\n\t},\n\n\tset: function(property, now){\n\t\tif (arguments.length == 1){\n\t\t\tnow = property;\n\t\t\tproperty = this.property || this.options.property;\n\t\t}\n\t\tthis.render(this.element, property, now, this.options.unit);\n\t\treturn this;\n\t},\n\n\tstart: function(property, from, to){\n\t\tif (!this.check(property, from, to)) return this;\n\t\tvar args = Array.flatten(arguments);\n\t\tthis.property = this.options.property || args.shift();\n\t\tvar parsed = this.prepare(this.element, this.property, args);\n\t\treturn this.parent(parsed.from, parsed.to);\n\t}\n\n});\n\nElement.Properties.tween = {\n\n\tset: function(options){\n\t\tthis.get('tween').cancel().setOptions(options);\n\t\treturn this;\n\t},\n\n\tget: function(){\n\t\tvar tween = this.retrieve('tween');\n\t\tif (!tween){\n\t\t\ttween = new Fx.Tween(this, {link: 'cancel'});\n\t\t\tthis.store('tween', tween);\n\t\t}\n\t\treturn tween;\n\t}\n\n};\n\nElement.implement({\n\n\ttween: function(property, from, to){\n\t\tthis.get('tween').start(property, from, to);\n\t\treturn this;\n\t},\n\n\tfade: function(how){\n\t\tvar fade = this.get('tween'), method, args = ['opacity'].append(arguments), toggle;\n\t\tif (args[1] == null) args[1] = 'toggle';\n\t\tswitch (args[1]){\n\t\t\tcase 'in': method = 'start'; args[1] = 1; break;\n\t\t\tcase 'out': method = 'start'; args[1] = 0; break;\n\t\t\tcase 'show': method = 'set'; args[1] = 1; break;\n\t\t\tcase 'hide': method = 'set'; args[1] = 0; break;\n\t\t\tcase 'toggle':\n\t\t\t\tvar flag = this.retrieve('fade:flag', this.getStyle('opacity') == 1);\n\t\t\t\tmethod = 'start';\n\t\t\t\targs[1] = flag ? 0 : 1;\n\t\t\t\tthis.store('fade:flag', !flag);\n\t\t\t\ttoggle = true;\n\t\t\tbreak;\n\t\t\tdefault: method = 'start';\n\t\t}\n\t\tif (!toggle) this.eliminate('fade:flag');\n\t\tfade[method].apply(fade, args);\n\t\tvar to = args[args.length - 1];\n\t\tif (method == 'set' || to != 0) this.setStyle('visibility', to == 0 ? 'hidden' : 'visible');\n\t\telse fade.chain(function(){\n\t\t\tthis.element.setStyle('visibility', 'hidden');\n\t\t\tthis.callChain();\n\t\t});\n\t\treturn this;\n\t},\n\n\thighlight: function(start, end){\n\t\tif (!end){\n\t\t\tend = this.retrieve('highlight:original', this.getStyle('background-color'));\n\t\t\tend = (end == 'transparent') ? '#fff' : end;\n\t\t}\n\t\tvar tween = this.get('tween');\n\t\ttween.start('background-color', start || '#ffff88', end).chain(function(){\n\t\t\tthis.setStyle('background-color', this.retrieve('highlight:original'));\n\t\t\ttween.callChain();\n\t\t}.bind(this));\n\t\treturn this;\n\t}\n\n});\n\n\n/*\n---\n\nname: Fx.Morph\n\ndescription: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules.\n\nlicense: MIT-style license.\n\nrequires: Fx.CSS\n\nprovides: Fx.Morph\n\n...\n*/\n\nFx.Morph = new Class({\n\n\tExtends: Fx.CSS,\n\n\tinitialize: function(element, options){\n\t\tthis.element = this.subject = document.id(element);\n\t\tthis.parent(options);\n\t},\n\n\tset: function(now){\n\t\tif (typeof now == 'string') now = this.search(now);\n\t\tfor (var p in now) this.render(this.element, p, now[p], this.options.unit);\n\t\treturn this;\n\t},\n\n\tcompute: function(from, to, delta){\n\t\tvar now = {};\n\t\tfor (var p in from) now[p] = this.parent(from[p], to[p], delta);\n\t\treturn now;\n\t},\n\n\tstart: function(properties){\n\t\tif (!this.check(properties)) return this;\n\t\tif (typeof properties == 'string') properties = this.search(properties);\n\t\tvar from = {}, to = {};\n\t\tfor (var p in properties){\n\t\t\tvar parsed = this.prepare(this.element, p, properties[p]);\n\t\t\tfrom[p] = parsed.from;\n\t\t\tto[p] = parsed.to;\n\t\t}\n\t\treturn this.parent(from, to);\n\t}\n\n});\n\nElement.Properties.morph = {\n\n\tset: function(options){\n\t\tthis.get('morph').cancel().setOptions(options);\n\t\treturn this;\n\t},\n\n\tget: function(){\n\t\tvar morph = this.retrieve('morph');\n\t\tif (!morph){\n\t\t\tmorph = new Fx.Morph(this, {link: 'cancel'});\n\t\t\tthis.store('morph', morph);\n\t\t}\n\t\treturn morph;\n\t}\n\n};\n\nElement.implement({\n\n\tmorph: function(props){\n\t\tthis.get('morph').start(props);\n\t\treturn this;\n\t}\n\n});\n\n\n/*\n---\n\nname: Fx.Transitions\n\ndescription: Contains a set of advanced transitions to be used with any of the Fx Classes.\n\nlicense: MIT-style license.\n\ncredits:\n  - Easing Equations by Robert Penner, <http://www.robertpenner.com/easing/>, modified and optimized to be used with MooTools.\n\nrequires: Fx\n\nprovides: Fx.Transitions\n\n...\n*/\n\nFx.implement({\n\n\tgetTransition: function(){\n\t\tvar trans = this.options.transition || Fx.Transitions.Sine.easeInOut;\n\t\tif (typeof trans == 'string'){\n\t\t\tvar data = trans.split(':');\n\t\t\ttrans = Fx.Transitions;\n\t\t\ttrans = trans[data[0]] || trans[data[0].capitalize()];\n\t\t\tif (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];\n\t\t}\n\t\treturn trans;\n\t}\n\n});\n\nFx.Transition = function(transition, params){\n\tparams = Array.from(params);\n\tvar easeIn = function(pos){\n\t\treturn transition(pos, params);\n\t};\n\treturn Object.append(easeIn, {\n\t\teaseIn: easeIn,\n\t\teaseOut: function(pos){\n\t\t\treturn 1 - transition(1 - pos, params);\n\t\t},\n\t\teaseInOut: function(pos){\n\t\t\treturn (pos <= 0.5 ? transition(2 * pos, params) : (2 - transition(2 * (1 - pos), params))) / 2;\n\t\t}\n\t});\n};\n\nFx.Transitions = {\n\n\tlinear: function(zero){\n\t\treturn zero;\n\t}\n\n};\n\n\n\nFx.Transitions.extend = function(transitions){\n\tfor (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);\n};\n\nFx.Transitions.extend({\n\n\tPow: function(p, x){\n\t\treturn Math.pow(p, x && x[0] || 6);\n\t},\n\n\tExpo: function(p){\n\t\treturn Math.pow(2, 8 * (p - 1));\n\t},\n\n\tCirc: function(p){\n\t\treturn 1 - Math.sin(Math.acos(p));\n\t},\n\n\tSine: function(p){\n\t\treturn 1 - Math.cos(p * Math.PI / 2);\n\t},\n\n\tBack: function(p, x){\n\t\tx = x && x[0] || 1.618;\n\t\treturn Math.pow(p, 2) * ((x + 1) * p - x);\n\t},\n\n\tBounce: function(p){\n\t\tvar value;\n\t\tfor (var a = 0, b = 1; 1; a += b, b /= 2){\n\t\t\tif (p >= (7 - 4 * a) / 11){\n\t\t\t\tvalue = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn value;\n\t},\n\n\tElastic: function(p, x){\n\t\treturn Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x && x[0] || 1) / 3);\n\t}\n\n});\n\n['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){\n\tFx.Transitions[transition] = new Fx.Transition(function(p){\n\t\treturn Math.pow(p, i + 2);\n\t});\n});\n\n\n/*\n---\n\nname: Request\n\ndescription: Powerful all purpose Request Class. Uses XMLHTTPRequest.\n\nlicense: MIT-style license.\n\nrequires: [Object, Element, Chain, Events, Options, Browser]\n\nprovides: Request\n\n...\n*/\n\n(function(){\n\nvar empty = function(){},\n\tprogressSupport = ('onprogress' in new Browser.Request);\n\nvar Request = this.Request = new Class({\n\n\tImplements: [Chain, Events, Options],\n\n\toptions: {/*\n\t\tonRequest: function(){},\n\t\tonLoadstart: function(event, xhr){},\n\t\tonProgress: function(event, xhr){},\n\t\tonComplete: function(){},\n\t\tonCancel: function(){},\n\t\tonSuccess: function(responseText, responseXML){},\n\t\tonFailure: function(xhr){},\n\t\tonException: function(headerName, value){},\n\t\tonTimeout: function(){},\n\t\tuser: '',\n\t\tpassword: '',*/\n\t\turl: '',\n\t\tdata: '',\n\t\theaders: {\n\t\t\t'X-Requested-With': 'XMLHttpRequest',\n\t\t\t'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'\n\t\t},\n\t\tasync: true,\n\t\tformat: false,\n\t\tmethod: 'post',\n\t\tlink: 'ignore',\n\t\tisSuccess: null,\n\t\temulation: true,\n\t\turlEncoded: true,\n\t\tencoding: 'utf-8',\n\t\tevalScripts: false,\n\t\tevalResponse: false,\n\t\ttimeout: 0,\n\t\tnoCache: false\n\t},\n\n\tinitialize: function(options){\n\t\tthis.xhr = new Browser.Request();\n\t\tthis.setOptions(options);\n\t\tthis.headers = this.options.headers;\n\t},\n\n\tonStateChange: function(){\n\t\tvar xhr = this.xhr;\n\t\tif (xhr.readyState != 4 || !this.running) return;\n\t\tthis.running = false;\n\t\tthis.status = 0;\n\t\tFunction.attempt(function(){\n\t\t\tvar status = xhr.status;\n\t\t\tthis.status = (status == 1223) ? 204 : status;\n\t\t}.bind(this));\n\t\txhr.onreadystatechange = empty;\n\t\tif (progressSupport) xhr.onprogress = xhr.onloadstart = empty;\n\t\tclearTimeout(this.timer);\n\n\t\tthis.response = {text: this.xhr.responseText || '', xml: this.xhr.responseXML};\n\t\tif (this.options.isSuccess.call(this, this.status))\n\t\t\tthis.success(this.response.text, this.response.xml);\n\t\telse\n\t\t\tthis.failure();\n\t},\n\n\tisSuccess: function(){\n\t\tvar status = this.status;\n\t\treturn (status >= 200 && status < 300);\n\t},\n\n\tisRunning: function(){\n\t\treturn !!this.running;\n\t},\n\n\tprocessScripts: function(text){\n\t\tif (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return Browser.exec(text);\n\t\treturn text.stripScripts(this.options.evalScripts);\n\t},\n\n\tsuccess: function(text, xml){\n\t\tthis.onSuccess(this.processScripts(text), xml);\n\t},\n\n\tonSuccess: function(){\n\t\tthis.fireEvent('complete', arguments).fireEvent('success', arguments).callChain();\n\t},\n\n\tfailure: function(){\n\t\tthis.onFailure();\n\t},\n\n\tonFailure: function(){\n\t\tthis.fireEvent('complete').fireEvent('failure', this.xhr);\n\t},\n\n\tloadstart: function(event){\n\t\tthis.fireEvent('loadstart', [event, this.xhr]);\n\t},\n\n\tprogress: function(event){\n\t\tthis.fireEvent('progress', [event, this.xhr]);\n\t},\n\n\ttimeout: function(){\n\t\tthis.fireEvent('timeout', this.xhr);\n\t},\n\n\tsetHeader: function(name, value){\n\t\tthis.headers[name] = value;\n\t\treturn this;\n\t},\n\n\tgetHeader: function(name){\n\t\treturn Function.attempt(function(){\n\t\t\treturn this.xhr.getResponseHeader(name);\n\t\t}.bind(this));\n\t},\n\n\tcheck: function(){\n\t\tif (!this.running) return true;\n\t\tswitch (this.options.link){\n\t\t\tcase 'cancel': this.cancel(); return true;\n\t\t\tcase 'chain': this.chain(this.caller.pass(arguments, this)); return false;\n\t\t}\n\t\treturn false;\n\t},\n\n\tsend: function(options){\n\t\tif (!this.check(options)) return this;\n\n\t\tthis.options.isSuccess = this.options.isSuccess || this.isSuccess;\n\t\tthis.running = true;\n\n\t\tvar type = typeOf(options);\n\t\tif (type == 'string' || type == 'element') options = {data: options};\n\n\t\tvar old = this.options;\n\t\toptions = Object.append({data: old.data, url: old.url, method: old.method}, options);\n\t\tvar data = options.data, url = String(options.url), method = options.method.toLowerCase();\n\n\t\tswitch (typeOf(data)){\n\t\t\tcase 'element': data = document.id(data).toQueryString(); break;\n\t\t\tcase 'object': case 'hash': data = Object.toQueryString(data);\n\t\t}\n\n\t\tif (this.options.format){\n\t\t\tvar format = 'format=' + this.options.format;\n\t\t\tdata = (data) ? format + '&' + data : format;\n\t\t}\n\n\t\tif (this.options.emulation && !['get', 'post'].contains(method)){\n\t\t\tvar _method = '_method=' + method;\n\t\t\tdata = (data) ? _method + '&' + data : _method;\n\t\t\tmethod = 'post';\n\t\t}\n\n\t\tif (this.options.urlEncoded && ['post', 'put'].contains(method)){\n\t\t\tvar encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';\n\t\t\tthis.headers['Content-type'] = 'application/x-www-form-urlencoded' + encoding;\n\t\t}\n\n\t\tif (!url) url = document.location.pathname;\n\n\t\tvar trimPosition = url.lastIndexOf('/');\n\t\tif (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);\n\n\t\tif (this.options.noCache)\n\t\t\turl += (url.contains('?') ? '&' : '?') + String.uniqueID();\n\n\t\tif (data && method == 'get'){\n\t\t\turl += (url.contains('?') ? '&' : '?') + data;\n\t\t\tdata = null;\n\t\t}\n\n\t\tvar xhr = this.xhr;\n\t\tif (progressSupport){\n\t\t\txhr.onloadstart = this.loadstart.bind(this);\n\t\t\txhr.onprogress = this.progress.bind(this);\n\t\t}\n\n\t\txhr.open(method.toUpperCase(), url, this.options.async, this.options.user, this.options.password);\n\t\tif (this.options.user && 'withCredentials' in xhr) xhr.withCredentials = true;\n\n\t\txhr.onreadystatechange = this.onStateChange.bind(this);\n\n\t\tObject.each(this.headers, function(value, key){\n\t\t\ttry {\n\t\t\t\txhr.setRequestHeader(key, value);\n\t\t\t} catch (e){\n\t\t\t\tthis.fireEvent('exception', [key, value]);\n\t\t\t}\n\t\t}, this);\n\n\t\tthis.fireEvent('request');\n\t\txhr.send(data);\n\t\tif (!this.options.async) this.onStateChange();\n\t\telse if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this);\n\t\treturn this;\n\t},\n\n\tcancel: function(){\n\t\tif (!this.running) return this;\n\t\tthis.running = false;\n\t\tvar xhr = this.xhr;\n\t\txhr.abort();\n\t\tclearTimeout(this.timer);\n\t\txhr.onreadystatechange = empty;\n\t\tif (progressSupport) xhr.onprogress = xhr.onloadstart = empty;\n\t\tthis.xhr = new Browser.Request();\n\t\tthis.fireEvent('cancel');\n\t\treturn this;\n\t}\n\n});\n\nvar methods = {};\n['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){\n\tmethods[method] = function(data){\n\t\tvar object = {\n\t\t\tmethod: method\n\t\t};\n\t\tif (data != null) object.data = data;\n\t\treturn this.send(object);\n\t};\n});\n\nRequest.implement(methods);\n\nElement.Properties.send = {\n\n\tset: function(options){\n\t\tvar send = this.get('send').cancel();\n\t\tsend.setOptions(options);\n\t\treturn this;\n\t},\n\n\tget: function(){\n\t\tvar send = this.retrieve('send');\n\t\tif (!send){\n\t\t\tsend = new Request({\n\t\t\t\tdata: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action')\n\t\t\t});\n\t\t\tthis.store('send', send);\n\t\t}\n\t\treturn send;\n\t}\n\n};\n\nElement.implement({\n\n\tsend: function(url){\n\t\tvar sender = this.get('send');\n\t\tsender.send({data: this, url: url || sender.options.url});\n\t\treturn this;\n\t}\n\n});\n\n})();\n\n\n/*\n---\n\nname: Request.HTML\n\ndescription: Extends the basic Request Class with additional methods for interacting with HTML responses.\n\nlicense: MIT-style license.\n\nrequires: [Element, Request]\n\nprovides: Request.HTML\n\n...\n*/\n\nRequest.HTML = new Class({\n\n\tExtends: Request,\n\n\toptions: {\n\t\tupdate: false,\n\t\tappend: false,\n\t\tevalScripts: true,\n\t\tfilter: false,\n\t\theaders: {\n\t\t\tAccept: 'text/html, application/xml, text/xml, */*'\n\t\t}\n\t},\n\n\tsuccess: function(text){\n\t\tvar options = this.options, response = this.response;\n\n\t\tresponse.html = text.stripScripts(function(script){\n\t\t\tresponse.javascript = script;\n\t\t});\n\n\t\tvar match = response.html.match(/<body[^>]*>([\\s\\S]*?)<\\/body>/i);\n\t\tif (match) response.html = match[1];\n\t\tvar temp = new Element('div').set('html', response.html);\n\n\t\tresponse.tree = temp.childNodes;\n\t\tresponse.elements = temp.getElements(options.filter || '*');\n\n\t\tif (options.filter) response.tree = response.elements;\n\t\tif (options.update){\n\t\t\tvar update = document.id(options.update).empty();\n\t\t\tif (options.filter) update.adopt(response.elements);\n\t\t\telse update.set('html', response.html);\n\t\t} else if (options.append){\n\t\t\tvar append = document.id(options.append);\n\t\t\tif (options.filter) response.elements.reverse().inject(append);\n\t\t\telse append.adopt(temp.getChildren());\n\t\t}\n\t\tif (options.evalScripts) Browser.exec(response.javascript);\n\n\t\tthis.onSuccess(response.tree, response.elements, response.html, response.javascript);\n\t}\n\n});\n\nElement.Properties.load = {\n\n\tset: function(options){\n\t\tvar load = this.get('load').cancel();\n\t\tload.setOptions(options);\n\t\treturn this;\n\t},\n\n\tget: function(){\n\t\tvar load = this.retrieve('load');\n\t\tif (!load){\n\t\t\tload = new Request.HTML({data: this, link: 'cancel', update: this, method: 'get'});\n\t\t\tthis.store('load', load);\n\t\t}\n\t\treturn load;\n\t}\n\n};\n\nElement.implement({\n\n\tload: function(){\n\t\tthis.get('load').send(Array.link(arguments, {data: Type.isObject, url: Type.isString}));\n\t\treturn this;\n\t}\n\n});\n\n\n/*\n---\n\nname: JSON\n\ndescription: JSON encoder and decoder.\n\nlicense: MIT-style license.\n\nSeeAlso: <http://www.json.org/>\n\nrequires: [Array, String, Number, Function]\n\nprovides: JSON\n\n...\n*/\n\nif (typeof JSON == 'undefined') this.JSON = {};\n\n\n\n(function(){\n\nvar special = {'\\b': '\\\\b', '\\t': '\\\\t', '\\n': '\\\\n', '\\f': '\\\\f', '\\r': '\\\\r', '\"' : '\\\\\"', '\\\\': '\\\\\\\\'};\n\nvar escape = function(chr){\n\treturn special[chr] || '\\\\u' + ('0000' + chr.charCodeAt(0).toString(16)).slice(-4);\n};\n\nJSON.validate = function(string){\n\tstring = string.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').\n\t\t\t\t\treplace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']').\n\t\t\t\t\treplace(/(?:^|:|,)(?:\\s*\\[)+/g, '');\n\n\treturn (/^[\\],:{}\\s]*$/).test(string);\n};\n\nJSON.encode = JSON.stringify ? function(obj){\n\treturn JSON.stringify(obj);\n} : function(obj){\n\tif (obj && obj.toJSON) obj = obj.toJSON();\n\n\tswitch (typeOf(obj)){\n\t\tcase 'string':\n\t\t\treturn '\"' + obj.replace(/[\\x00-\\x1f\\\\\"]/g, escape) + '\"';\n\t\tcase 'array':\n\t\t\treturn '[' + obj.map(JSON.encode).clean() + ']';\n\t\tcase 'object': case 'hash':\n\t\t\tvar string = [];\n\t\t\tObject.each(obj, function(value, key){\n\t\t\t\tvar json = JSON.encode(value);\n\t\t\t\tif (json) string.push(JSON.encode(key) + ':' + json);\n\t\t\t});\n\t\t\treturn '{' + string + '}';\n\t\tcase 'number': case 'boolean': return '' + obj;\n\t\tcase 'null': return 'null';\n\t}\n\n\treturn null;\n};\n\nJSON.decode = function(string, secure){\n\tif (!string || typeOf(string) != 'string') return null;\n\n\tif (secure || JSON.secure){\n\t\tif (JSON.parse) return JSON.parse(string);\n\t\tif (!JSON.validate(string)) throw new Error('JSON could not decode the input; security is enabled and the value is not secure.');\n\t}\n\n\treturn eval('(' + string + ')');\n};\n\n})();\n\n\n/*\n---\n\nname: Request.JSON\n\ndescription: Extends the basic Request Class with additional methods for sending and receiving JSON data.\n\nlicense: MIT-style license.\n\nrequires: [Request, JSON]\n\nprovides: Request.JSON\n\n...\n*/\n\nRequest.JSON = new Class({\n\n\tExtends: Request,\n\n\toptions: {\n\t\t/*onError: function(text, error){},*/\n\t\tsecure: true\n\t},\n\n\tinitialize: function(options){\n\t\tthis.parent(options);\n\t\tObject.append(this.headers, {\n\t\t\t'Accept': 'application/json',\n\t\t\t'X-Request': 'JSON'\n\t\t});\n\t},\n\n\tsuccess: function(text){\n\t\tvar json;\n\t\ttry {\n\t\t\tjson = this.response.json = JSON.decode(text, this.options.secure);\n\t\t} catch (error){\n\t\t\tthis.fireEvent('error', [text, error]);\n\t\t\treturn;\n\t\t}\n\t\tif (json == null) this.onFailure();\n\t\telse this.onSuccess(json, text);\n\t}\n\n});\n\n\n/*\n---\n\nname: Cookie\n\ndescription: Class for creating, reading, and deleting browser Cookies.\n\nlicense: MIT-style license.\n\ncredits:\n  - Based on the functions by Peter-Paul Koch (http://quirksmode.org).\n\nrequires: [Options, Browser]\n\nprovides: Cookie\n\n...\n*/\n\nvar Cookie = new Class({\n\n\tImplements: Options,\n\n\toptions: {\n\t\tpath: '/',\n\t\tdomain: false,\n\t\tduration: false,\n\t\tsecure: false,\n\t\tdocument: document,\n\t\tencode: true\n\t},\n\n\tinitialize: function(key, options){\n\t\tthis.key = key;\n\t\tthis.setOptions(options);\n\t},\n\n\twrite: function(value){\n\t\tif (this.options.encode) value = encodeURIComponent(value);\n\t\tif (this.options.domain) value += '; domain=' + this.options.domain;\n\t\tif (this.options.path) value += '; path=' + this.options.path;\n\t\tif (this.options.duration){\n\t\t\tvar date = new Date();\n\t\t\tdate.setTime(date.getTime() + this.options.duration * 24 * 60 * 60 * 1000);\n\t\t\tvalue += '; expires=' + date.toGMTString();\n\t\t}\n\t\tif (this.options.secure) value += '; secure';\n\t\tthis.options.document.cookie = this.key + '=' + value;\n\t\treturn this;\n\t},\n\n\tread: function(){\n\t\tvar value = this.options.document.cookie.match('(?:^|;)\\\\s*' + this.key.escapeRegExp() + '=([^;]*)');\n\t\treturn (value) ? decodeURIComponent(value[1]) : null;\n\t},\n\n\tdispose: function(){\n\t\tnew Cookie(this.key, Object.merge({}, this.options, {duration: -1})).write('');\n\t\treturn this;\n\t}\n\n});\n\nCookie.write = function(key, value, options){\n\treturn new Cookie(key, options).write(value);\n};\n\nCookie.read = function(key){\n\treturn new Cookie(key).read();\n};\n\nCookie.dispose = function(key, options){\n\treturn new Cookie(key, options).dispose();\n};\n\n\n/*\n---\n\nname: DOMReady\n\ndescription: Contains the custom event domready.\n\nlicense: MIT-style license.\n\nrequires: [Browser, Element, Element.Event]\n\nprovides: [DOMReady, DomReady]\n\n...\n*/\n\n(function(window, document){\n\nvar ready,\n\tloaded,\n\tchecks = [],\n\tshouldPoll,\n\ttimer,\n\ttestElement = document.createElement('div');\n\nvar domready = function(){\n\tclearTimeout(timer);\n\tif (ready) return;\n\tBrowser.loaded = ready = true;\n\tdocument.removeListener('DOMContentLoaded', domready).removeListener('readystatechange', check);\n\n\tdocument.fireEvent('domready');\n\twindow.fireEvent('domready');\n};\n\nvar check = function(){\n\tfor (var i = checks.length; i--;) if (checks[i]()){\n\t\tdomready();\n\t\treturn true;\n\t}\n\treturn false;\n};\n\nvar poll = function(){\n\tclearTimeout(timer);\n\tif (!check()) timer = setTimeout(poll, 10);\n};\n\ndocument.addListener('DOMContentLoaded', domready);\n\n/*<ltIE8>*/\n// doScroll technique by Diego Perini http://javascript.nwbox.com/IEContentLoaded/\n// testElement.doScroll() throws when the DOM is not ready, only in the top window\nvar doScrollWorks = function(){\n\ttry {\n\t\ttestElement.doScroll();\n\t\treturn true;\n\t} catch (e){}\n\treturn false;\n};\n// If doScroll works already, it can't be used to determine domready\n//   e.g. in an iframe\nif (testElement.doScroll && !doScrollWorks()){\n\tchecks.push(doScrollWorks);\n\tshouldPoll = true;\n}\n/*</ltIE8>*/\n\nif (document.readyState) checks.push(function(){\n\tvar state = document.readyState;\n\treturn (state == 'loaded' || state == 'complete');\n});\n\nif ('onreadystatechange' in document) document.addListener('readystatechange', check);\nelse shouldPoll = true;\n\nif (shouldPoll) poll();\n\nElement.Events.domready = {\n\tonAdd: function(fn){\n\t\tif (ready) fn.call(this);\n\t}\n};\n\n// Make sure that domready fires before load\nElement.Events.load = {\n\tbase: 'load',\n\tonAdd: function(fn){\n\t\tif (loaded && this == window) fn.call(this);\n\t},\n\tcondition: function(){\n\t\tif (this == window){\n\t\t\tdomready();\n\t\t\tdelete Element.Events.load;\n\t\t}\n\t\treturn true;\n\t}\n};\n\n// This is based on the custom load event\nwindow.addEvent('load', function(){\n\tloaded = true;\n});\n\n})(window, document);\n\n\n/*\n---\n\nname: Swiff\n\ndescription: Wrapper for embedding SWF movies. Supports External Interface Communication.\n\nlicense: MIT-style license.\n\ncredits:\n  - Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject.\n\nrequires: [Options, Object, Element]\n\nprovides: Swiff\n\n...\n*/\n\n(function(){\n\nvar Swiff = this.Swiff = new Class({\n\n\tImplements: Options,\n\n\toptions: {\n\t\tid: null,\n\t\theight: 1,\n\t\twidth: 1,\n\t\tcontainer: null,\n\t\tproperties: {},\n\t\tparams: {\n\t\t\tquality: 'high',\n\t\t\tallowScriptAccess: 'always',\n\t\t\twMode: 'window',\n\t\t\tswLiveConnect: true\n\t\t},\n\t\tcallBacks: {},\n\t\tvars: {}\n\t},\n\n\ttoElement: function(){\n\t\treturn this.object;\n\t},\n\n\tinitialize: function(path, options){\n\t\tthis.instance = 'Swiff_' + String.uniqueID();\n\n\t\tthis.setOptions(options);\n\t\toptions = this.options;\n\t\tvar id = this.id = options.id || this.instance;\n\t\tvar container = document.id(options.container);\n\n\t\tSwiff.CallBacks[this.instance] = {};\n\n\t\tvar params = options.params, vars = options.vars, callBacks = options.callBacks;\n\t\tvar properties = Object.append({height: options.height, width: options.width}, options.properties);\n\n\t\tvar self = this;\n\n\t\tfor (var callBack in callBacks){\n\t\t\tSwiff.CallBacks[this.instance][callBack] = (function(option){\n\t\t\t\treturn function(){\n\t\t\t\t\treturn option.apply(self.object, arguments);\n\t\t\t\t};\n\t\t\t})(callBacks[callBack]);\n\t\t\tvars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack;\n\t\t}\n\n\t\tparams.flashVars = Object.toQueryString(vars);\n\t\tif (Browser.ie){\n\t\t\tproperties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';\n\t\t\tparams.movie = path;\n\t\t} else {\n\t\t\tproperties.type = 'application/x-shockwave-flash';\n\t\t}\n\t\tproperties.data = path;\n\n\t\tvar build = '<object id=\"' + id + '\"';\n\t\tfor (var property in properties) build += ' ' + property + '=\"' + properties[property] + '\"';\n\t\tbuild += '>';\n\t\tfor (var param in params){\n\t\t\tif (params[param]) build += '<param name=\"' + param + '\" value=\"' + params[param] + '\" />';\n\t\t}\n\t\tbuild += '</object>';\n\t\tthis.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild;\n\t},\n\n\treplaces: function(element){\n\t\telement = document.id(element, true);\n\t\telement.parentNode.replaceChild(this.toElement(), element);\n\t\treturn this;\n\t},\n\n\tinject: function(element){\n\t\tdocument.id(element, true).appendChild(this.toElement());\n\t\treturn this;\n\t},\n\n\tremote: function(){\n\t\treturn Swiff.remote.apply(Swiff, [this.toElement()].append(arguments));\n\t}\n\n});\n\nSwiff.CallBacks = {};\n\nSwiff.remote = function(obj, fn){\n\tvar rs = obj.CallFunction('<invoke name=\"' + fn + '\" returntype=\"javascript\">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');\n\treturn eval(rs);\n};\n\n})();\n\n"
  },
  {
    "path": "vendor/qunit/.gitignore",
    "content": ".project\n*~\n*.diff\n*.patch\n.DS_Store\n.settings\nnode_modules\ndist/\n"
  },
  {
    "path": "vendor/qunit/AUTHORS.txt",
    "content": "Jörn Zaefferer <joern.zaefferer@gmail.com>\nAriel Flesler <aflesler@gmail.com>\nScott González <scott.gonzalez@gmail.com>\nRichard Worth <rdworth@gmail.com>\nPhilippe Rathé <prathe@gmail.com>\nJohn Resig <jeresig@gmail.com>\nWill Moffat <will_git@hamstersoup.com>\nJan Kassens <jan@kassens.net>\nZiling Zhao <zizhao@cisco.com>\nRyan Szulczewski <musicmanryan@gmail.com>\nChris Lloyd <christopher.lloyd@gmail.com>\nLouis-Rémi Babé <public@lrbabe.com>\nJake Archibald <jake.archibald@bbc.co.uk>\nFrances Berriman <frances.berriman@bbc.co.uk>\nRune Halvorsen <runefh@gmail.com>\nChris Thatcher <thatcher.christopher@gmail.com>\nFábio Rehm <fgrehm@gmail.com>\nLeon Sorokin <leeoniya@gmail.com>\nDouglas Neiner <doug@pixelgraphics.us>\nPaul Elliott <paul@hashrocket.com>\nNikita Vasilyev <me@elv1s.ru>\nBenjamin Lee <leebenjp@gmail.com>\nPaul Irish <paul.irish@gmail.com>\nOleg Slobodskoi <oleg008@gmail.com>\nAnton Matzneller <obhvsbypqghgc@gmail.com>\nAurélien Bombo\nMathias Bynens <mathias@qiwi.be>\nErik Vold <erikvvold@gmail.com>\nWesley Walser <waw325@gmail.com>\nRob Kinninmont <robk@twitter.com>\nMarc Portier <marc.portier@gmail.com>\nMichael Righi <michael@righi.me>\nTimo Tijhof <krinklemail@gmail.com>\nJan Alonzo <jmalonzo@taguchimail.com>\nDaniel Trebbien <dtrebbien@gmail.com>\nBob Fanger <bfanger@gmail.com>\nMarkus Messner-Chaney <markus.messner-chaney@xing.com>\nTrevor Parscal <trevorparscal@gmail.com>\nAshar Voultoiz <hashar@free.fr>\nJimmy Mabey <jimmy@velsoft.com>\nDomenic Denicola <domenic@domenicdenicola.com>\nMike Sherov <mike.sherov@gmail.com>\nSeong-A Kong <simonz@daumcorp.com>\nGraham Conzett <conzett@gmail.com>\nNiall Smart <niall@pobox.com>\nJohan Sörlin <spocke@moxiecode.com>\nGijs Kruitbosch <gijskruitbosch@gmail.com>\nErkan Yilmaz <erkan77@gmail.com>\nJonathan Sanchez <jsanchezpando@cirb.irisnet.be>\nKeith Cirkel <github@keithcirkel.co.uk>\nRick Waldron <waldron.rick@gmail.com>\nHerbert Vojčík <herby@mailbox.sk>\nRichard Gibson <richard.gibson@gmail.com>\nAlex J Burke <alex@alexjeffburke.com>\nSergii Kliuchnyk <sergiikliuchnyk@gmail.com>\n"
  },
  {
    "path": "vendor/qunit/History.md",
    "content": "1.11.0 / 2013-01-20\n==================\n\n  * Diff: Fix exception on property \"constructor\". Fixes #394.\n  * Composite Add-on: Test suites can be named by including an obj with name & path props within array param for .testSuites()\n  * Fix URL generator to take protocol and host into account to fix usage with file protocol in IE7/8\n  * Fix issue with Error.prototype.toString in IE 7\n  * Refactor jsDump for \"node\". Fixes #381.\n  * Show contents of text nodes in jsDump.node. Fixes #380.\n  * Escape text. Fixes #379.\n  * Rewrote most of the JUnitLogger addon as it was in bad shape: unused variables, duplicate effort that QUnit handles internally (e.g. tallying number of total assertions, failed assertions, etc.), sub-optimal XmlWriter implementation, etc.\n  * Phantomjs: Include source in assertion details\n  * Phantomjs: Removed the polling mechanism in favor of PhantomJS 1.6+'s `WebPage#onCallback`\n  * Delay start() until init() happened. Fixes #358. Closes #373.\n  * urlConfig: Fix checkbox event for oldIE. Fixes #369. Closes #370.\n  * Issue #365: Fix module picker for oldIE. Closes #366.\n  * Fixes #344 - Capture and show test duration.\n  * Rename tests to assertions in summary. Fixes #336 - Summary counts assertions but mentions 'tests'.\n  * Assert: Implement propEqual and notPropEqual. Fixes #317.\n  * Canvas addon: Use 0.6 as alpha value to avoid inconsistencies between browsers. Fixes #342\n  * Remove global variable \"assert\". Fixes #341.\n  * Add a test for loading tests asynchronously\n  * Improve start()-called-too-often fix, initialize semaphore at 1, fixes autostart=false case. Also provide stack for the offending start() call\n  * There's type-free objects in Firefox, extend objectType() to allow null match. Fixes #315\n  * Push a failing assertion when calling start() while already running. Resets anyway to keep other tests going. Fixes #314\n  * Adds Ninja Theme\n  * Extend jsdump to output Error objects as such, including the message property. Extend throws to provide 'expected' value when possible. Fixes #307\n  * Use classes to collapse assertion groups. Fixes #269\n  * Readme for junitlogger addon\n  * Better readme for composite addon\n  * Make `throws` ES3 compatible\n  * Composite: Adds test whether iframe contains content. Fixes #318 - Composite: Raises \"global failure\" in Opera\n  * Apply the same exception handling for test and teardown try/catch as for setup\n\n1.10.0 / 2012-08-30\n==================\n\n  * Simplify licensing: Only MIT, no more MIT/GPL dual licensing.\n  * Scroll the window back to top after tests finished running. Fixes #304\n  * Simplify phantomjs runner to use module property in testDone callback\n  * Adds module and test name to the information that is returned in the callback provided to QUnit.log(Function). Fixes #296\n  * Make QUnit.expect() (without arguments) a getter. Fixes #226\n  * Compare the ES6 sticky (y) property for RegExp. Can't add to tests yet. Fixes #284 - deepEqual for RegExp should compare\n  * onerror: force display of global errors despite URL parameters. Fixes #288 - Global failures can be filtered out by test-limiting URL parameters\n  * Remove conditional codepath based on jQuery presence from reset().\n  * Add module filter to UI\n  * Keep a local reference to Date. Fixes #283.\n  * Update copyright to jQuery Foundation.\n\n1.9.0 / 2012-07-11\n==================\n  * added jsdoc for QUnit.assert functions\n  * Styling: radius to 5px and small pass/error border, remove inner shadow\n  * Move checkboxes into toolbar and give them labels and descriptions (as tooltip). Fixes #274 - Improve urlFilter API and UI\n  * Where we recieve no exception in throws() use a relevant message.\n  * Also make module filter case-insensitive. Follow-up to #252\n  * Banner: Link should ignore \"testNumber\" and \"module\". Fixes #270\n  * Rename assert.raises to assert.throws. Fixes #267\n  * Change package.json name property to 'qunitjs' to avoid conflicht with node-qunit; will publish next release to npm\n\n1.8.0 / 2012-06-14\n==================\n  * Improve window.onerror handling\n  * (issue #260) config.current should be reset at the right time.\n  * Filter: Implement 'module' url parameter. Fixes #252\n  * raises: ignore global exceptions stemming from test. Fixes #257 - Globally-executed errors sneak past raises in IE\n\n1.7.0 / 2012-06-07\n==================\n\n  * Add config.requireExpects. Fixes #207 - Add option to require all tests to call expect().\n  * Improve extractStacktrace() implementation. Fixes #254 - Include all relevant stack lines\n  * Make filters case-insensitive. Partial fix for #252\n  * is() expects lowercase types. Fixes #250 - Expected Date value is not displayed properly\n  * Fix phantomjs addon header and add readme. Fixes #239\n  * Add some hints to composite addon readme. Fixes #251\n  * Track tests by the order in which they were run and create rerun links based on that number. Fixes #241 - Make Rerun link run only a single test.\n  * Use QUnit.push for raises implementation. Fixes #243\n  * CLI runner for phantomjs\n  * Fix jshint validation until they deal with /** */ comments properly\n  * Update validTest() : Simplify logic, clarify vars and add comments\n  * Refactor assertion helpers into QUnit.assert (backwards compatible)\n  * Add Rerun link to placeholders. Fixes #240\n\n1.6.0 / 2012-05-04\n==================\n\n  * Save stack for each test, use that for failed expect() results, points at the line where test() was called. Fixes #209\n  * Prefix test-output id and ignore that in noglobals check. Fixes #212\n  * Only check for an exports object to detect a CommonJS enviroment. Fixes #237 - Incompatibility with require.js\n  * Add testswarm integration as grunt task\n  * Added padding on URL config checkboxes.\n  * Cleanup composite addon: Use callback registration instead of overwriting them. Set the correct src on rerun link (and dblclick). Remove the composite test itself, as that was a crazy hack not worth maintaining\n  * Cleanup reset() test and usage - run testDone callback first, to allow listeneres ignoring reset assertions\n  * Double clicking on composite test rows opens individual test page\n  * test-message for all message-bearing API reporting details\n\n1.5.0 / 2012-04-04\n==================\n\n  * Modify \"Running...\" to display test name. Fixes #220\n  * Fixed clearing of sessionStorage in Firefox 3.6.\n  * Fixes #217 by calling \"block\" with config.current.testEnvironment\n  * Add stats results to data. QUnit.jUnitReport function take one argument {   xml:'<?xml ...',   results:{failed:0, passed:0, total:0, time:0} }\n  * Add link to MDN about stack property\n\n1.4.0 / 2012-03-10\n==================\n\n  * Prefix test-related session-storage items to make removal more specific. Fixes #213 - Keep hide-passed state when clearing session storage\n  * Update grunt.js with seperate configs for qunit.js and grunt.js, also add tests but disable for now, not passing yet. Add grunt to devDependencies\n  * typo\n  * Cleanup grunt.js, no need for the banner\n  * Fix lint errors and some formatting issues. Use QUnit.pushFailure for noglobals and global error handler.\n  * Fix a missing expect in logs test\n  * Add grunt.js configuration and include some usage instructions in the readme\n  * Update package.json\n  * Partially revert af27eae841c3e1c01c46de72d676f1047e1ee375 - can't move reset around, so also don't wrap in try-catch, as the result of that is effectively swallowed. Can't output the result as the outputting is already done.\n  * Add QUnit.pushFailure to log error conditions like exceptions. Accepts stacktrace as second argument, allowing extraction with catched exceptions (useful even in Safari). Remove old fail() function that would just log to console, not useful anymore as regular test output is much more useful by now. Move up QUnit.reset() call to just make that another failed assertion. Used to not make a test fail. Fixes #210\n  * Update equals and same deprecations to use QUnit.push to provide correct source lines. Fixes #211\n  * Add a test file for narwhal integration. Has to use print instead of console.log. Fails when an assertion fails, something about setInterval...\n  * Apply notrycatch option to setup and teardown as well. Fixes #203. Reorder noglobals check to allow teardown to remove globals that were introduced intentionally. Fixes #204\n  * Extend exports object with QUnit properties at the end of the file to export everything.\n  * Output source line for ok() assertions. Fixes #202\n  * Make test fail if no assertions run. Fixes #178\n  * Sort object output alphabetically in order to improve diffs of objects where properties were set in a different order. Fixes #206\n  * Revert \"Change fixture reset behavior\", changing #194 and #195 to wontfix.\n\n1.3.0 / 2012-02-26\n==================\n\n  * Cleanup test markup\n  * Fix the jQuery branch of fixture reset. Would break when no fixture exists.\n  * Added initial version of a junitlogger addon.\n  * Escape document.title before inserting into markup. Extends fix for #127\n  * Catch assertions running outside of test() context, make sure source is provided even for ok(). Fixes #98\n  * Improve global object access, based on comments for 1a9120651d5464773256d8a1f2cf2eabe38ea5b3\n  * Clear all sessionStorage entries once all tests passed. Helps getting rid of items from renamed tests. Fixes #101\n  * Set fixed dimensions for #qunit-fixture. Fixes #114\n  * Extend nodejs test runner to check for stacktrace output, twice\n  * Extend nodejs test runner to check for stacktrace output\n  * Generate more base markup, but allow the user to exclude that completelty or choose their own. Fixes #127\n  * Add a simple test file to check basic nodejs integration works\n  * Check for global object to find setTimeout in node\n  * Fix CommonJS export by assigning QUnit to module.exports.\n  * Remove the testEnviromentArg to test(). Most obscure, never used anywhere. test() is still heavily overloaded with argument shifting, this makes it a little more sane. Fixes #172\n  * Serialize expected and actual values only when test fails. Speeds up output of valid tests, especially for lots of large objects. Fixes #183\n  * Fix sourceFromsTacktrace to get the right line in Firefox. Shift the 'error' line away in Chrome to get a match.\n  * Fix references to test/deepEqual.js\n  * In autorun mode, moduleDone is called without matching moduleStart. Fix issue #184\n  * Fixture test: allow anything falsy in test as getAttribute in oldIE will return empty string instead of null. We don't really care.\n  * Keep label and checkbox together ( http://i.imgur.com/5Wk3A.png )\n  * Add readme for themes\n  * Fix bad global in reset()\n  * Some cleanup in theme addons\n  * Update headers\n  * Update nv.html, add gabe theme based on https://github.com/jquery/qunit/pull/188\n  * Experiemental custom theme based on https://github.com/jquery/qunit/pull/62 by NV\n  * Replace deprecated same and equals aliases with placeholders that just throw errors, providing a hint at what to use instead. Rename test file to match that.\n  * Can't rely on outerHTML for Firefox < 11. Use cloneNode instead.\n  * Merge remote branch 'conzett/master'\n  * Cleanup whitespace\n  * Update sessionStorage support test to latest version from Modernizr, trying to setItem to avoid QUOTA_EXCEEDED_EXCEPTION\n  * Change fixture reset behavior\n  * Merge pull request #181 from simonz/development\n  * Escaping test names\n  * Show exception stack when test failed\n\n1.2.0 / 2011-11-24\n==================\n\n  * remove uses of equals(), as it's deprecated in favor of equal()\n  * Code review of \"Allow objects with no prototype to be tested against object literals.\"\n  * Allow objects with no prototype to tested against object literals.\n  * Fix IE8 \"Member not found\" error\n  * Using node-qunit port, the start/stop function are not exposed so we need to prefix any call to them with 'QUnit'. Aka: start() -> QUnit.start()\n  * Remove the 'let teardown clean up globals test' - IE<9 doesn't support (==buggy) deleting window properties, and that's not worth the trouble, as everything else passes just fine. Fixes #155\n  * Fix globals in test.js, part 2\n  * Fix globals in test.js. ?tell wwalser to use ?noglobals everyonce in a while\n  * Extend readme regarding release process\n\n1.1.0 / 2011-10-11\n==================\n\n  * Fixes #134 - Add a window.onerror handler. Makes uncaught errors actually fail the testsuite, instead of going by unnoticed.\n  * Whitespace cleanup\n  * Merge remote branch 'trevorparscal/master'\n  * Fixed IE compatibility issues with using toString on NodeList objects, which in some browsers results in [object Object] rather than [object NodeList]. Now using duck typing for NodeList objects based on the presence of length, length being a number, presence of item method (which will be typeof string in IE and function in others, so we just check that it's not undefined) and that item(0) returns the same value as [0], unless it's empty, in which case item(0) will return 0, while [0] would return undefined. Tested in IE6, IE8, Firefox 6, Safari 5 and Chrome 16.\n  * Update readme with basic notes on releases\n  * More whitespace/parens cleanup\n  * Check if setTimeout is available before trying to delay running the next task. Fixes #160\n  * Whitespace/formatting fix, remove unnecessary parens\n  * Use alias for Object.prototype.toString\n  * Merge remote branch 'trevorparscal/master'\n  * Merge remote branch 'wwalser/recursionBug'\n  * Default 'expected' to null in asyncTest(), same as in test() itself.\n  * Whitespace cleanup\n  * Merge remote branch 'mmchaney/master'\n  * Merge remote branch 'Krinkle/master'\n  * Using === instead of ==\n  * Added more strict array type detection for dump output, and allowed NodeList objects to be output as arrays\n  * Fixes a bug where after an async test, assertions could move between test cases because of internal state (config.current) being incorrectly set\n  * Simplified check for assertion count and adjusted whitespace\n  * Redo of fixing issue #156 (Support Object.prototype extending environment). * QUnit.diff: Throws exception without this if Object.prototype is set (Property 'length' of undefined. Since Object.prototype.foo doesn't have a property 'rows') * QUnit.url: Without this fix, if Object.prototype.foo is set, the url will be set to ?foo=...&the=rest. * saveGlobals: Without this fix, whenever a member is added to Object.prototype, saveGlobals will think it was a global variable in this loop. --- This time using the call method instead of obj.hasOwnProperty(key), which may fail if the object has that as it's own property (touché!).\n  * Handle expect(0) as expected, i.e. expect(0); ok(true, foo); will cause a test to fail\n\n1.0.0 / 2011-10-06\n==================\n\n  * Make QUnit work with TestSwarm\n  * Run other addons tests as composite addon demo. Need to move that to /test folder once this setup actually works\n  * Add-on: New assertion-type: step()\n  * added parameter to start and stop allowing a user to increment/decrement the semaphore more than once per call\n  * Update readmes with .md extension for GitHub to render them as markdown\n  * Update close-enough addon to include readme and match (new) naming convetions\n  * Merge remote branch 'righi/close-enough-addon'\n  * Canvas addon: Update file referneces\n  * Update canvas addon: Rename files and add README\n  * Merge remote branch 'wwalser/composite'\n  * Fix #142 - Backslash characters in messages should not be escaped\n  * Add module name to testStart and testDone callbacks\n  * Removed extra columns in object literals. Closes #153\n  * Remove dead links in comments.\n  * Merge remote branch 'wwalser/multipleCallbacks'\n  * Fixed syntax error and CommonJS incompatibilities in package.json\n  * Allow multiple callbacks to be registered.\n  * Add placeholder for when Safari may end up providing useful error handling\n  * changed file names to match addon naming convention\n  * Whitespace\n  * Created the composite addon.\n  * Using array and object literals.\n  * Issue #140: Make toggle system configurable.\n  * Merge remote branch 'tweetdeck/master'\n  * Adds the 'close enough' addon to determine if numbers are acceptably close enough in value.\n  * Fix recursion support in jsDump, along with tests. Fixes #63 and #100\n  * Adding a QUnit.config.altertitle flag which will allow users to opt-out of the functionality introduced in 60147ca0164e3d810b8a9bf46981c3d9cc569efc\n  * Refactor window.load handler into QUnit.load, makes it possible to call it manually.\n  * More whitespace cleanup\n  * Merge remote branch 'erikvold/one-chk-in-title'\n  * Whitespace\n  * Merge remote branch 'wwalser/syncStopCalls'\n  * Introducing the first QUnit addon, based on https://github.com/jquery/qunit/pull/84 - adds QUnit.pixelEqual assertion method, along with example tests.\n  * Remove config.hidepassed setting in test.js, wasn't intended to land in master.\n  * Expose QUnit.config.hidepassed setting. Overrides sessionStorage and enables enabling the feature programmatically. Fixes #133\n  * Fix formatting (css whitespace) for tracebacks.\n  * Expose extend, id, and addEvent methods.\n  * minor comment typo correction\n  * Ignore Eclipse WTP .settings\n  * Set 'The jQuery Project' as author in package.json\n  * Fixes a bug where synchronous calls to stop would cause tests to end before start was called again\n  * Point to planning testing wiki in readme\n  * only add one checkmark to the document.title\n  * Escape the stacktrace output before setting it as innerHTML, since it tends to contain `<` and `>` characters.\n  * Cleanup whitespace\n  * Run module.teardown before checking for pollution. Fixes #109 - noglobals should run after module teardown\n  * Fix accidental global variable \"not\"\n  * Update document.title status to use more robust unicode escape sequences, works even when served with non-utf-8-charset.\n  * Modify document.title when suite is done to show success/failure in tab, allows you to see the overall result without seeing the tab content.\n  * Merge pull request #107 from sexyprout/master\n  * Set a generic font\n  * Add/update headers\n  * Drop support for deprecated #main in favor of #qunit-fixture. If this breaks your testsuite, replace id=\"main\" with id=\"qunit-fixture\". Fixes #103\n  * Remove the same key as the one being set. Partial fix for #101\n  * Don't modify expected-count when checking pollution. The failing assertion isn't expected, so shouldn't be counted. And if expect wasn't used, the count is misleading.\n  * Fix order of noglobals check to produce correct introduced/delete error messages\n  * Prepend module name to sessionStorage keys to avoid conflicts\n  * Store filter-tests only when checked\n  * Write to sessionStorage only bad tests\n  * Moved QUnit.url() defintion after QUnit properties are merged into the global scope. Fixes #93 - QUnit url/extend function breaking urls in jQuery ajax test component\n  * Add a \"Rerun\" link to each test to replce the dblclick (still supported, for now).\n  * Fixed the regex for parsing the name of a test when double clicking to filter.\n  * Merge remote branch 'scottgonzalez/url'\n  * Added checkboxes to show which flags are currently on and allow toggling them.\n  * Retain all querystring parameters when filtering a test via double click.\n  * Added better querystring parsing. Now storing all querystring params in QUnit.urlParams so that we can carry the params forward when filtering to a specific test. This removes the ability to specify multiple filters.\n  * Make reordering optional (QUnit.config.reorder = false) and optimize \"Hide passed tests\" mode by also hiding \"Running [testname]\" entries.\n  * Added missing semicolons and wrapped undefined key in quotes.\n  * Optimize test hiding, add class on page load if stored in sessionStorage\n  * Optimize the hiding of passed tests.\n  * Position test results above test list, making it visible without ever having to scroll. Create a placeholder to avoid pushing down results later.\n  * Don't check for existing qunit-testresult element, it gets killed on init anyway.\n  * Added URL flag ?notrycatch (ala ?noglobals) for debugging exceptions. Won't try/catch test code, giving better debugging changes on the original exceptions. Fixes #72\n  * Always show quni-toolbar (if at all specified), persist checkbox via sessionStorage. Fixes #47\n  * Use non-html testname for calls to fail(). Fixes #77\n  * Overhaul of QUnit.callbacks. Consistent single argument with related properties, with additonal runtime property for QUnit.done\n  * Extended test/logs.html to capture more of the callbacks.\n  * Fixed moduleStart/Done callbacks. Added test/logs.html to test these callbacks. To be extended.\n  * Update copyright and license header. Fixes #61\n  * Formatting fix.\n  * Use a semaphore to synchronize stop() and start() calls. Fixes #76\n  * Merge branch 'master' of https://github.com/paulirish/qunit into paulirish-master\n  * Added two tests for previous QUnit.raises behaviour. For #69\n  * add optional 2. arg to QUnit.raises #69.\n  * fix references inside Complex Instances Nesting to what was originally intended.\n  * Qualify calls to ok() in raises() for compability with CLI enviroments.\n  * Fix done() handling, check for blocking, not block property\n  * Fix moduleStart/Done and done callbacks.\n  * Replacing sessionStorage test with the one from Modernizr/master (instead of current release). Here's hoping it'll work for some time.\n  * Updated test for availibility of sessionStorage, based on test from Modernizr. Fixes #64\n  * Defer test execution when previous run passed, persisted via sessionStorage. Fixes #49\n  * Refactored module handling and queuing to enable selective defer of test runs.\n  * Move assertions property from config to Test\n  * Move expected-tests property from config to Test\n  * Refactored test() method to delegate to a Test object to encapsulate all properties and methods of a single test, allowing further modifications.\n  * Adding output of sourcefile and linenumber of failed assertions (except ok()). Only limited cross-browser support for now. Fixes #60\n  * Drop 'hide missing tests' feature. Fixes #48\n  * Adding readme. Fixes #58\n  * Merge branch 'prettydiff'\n  * Improve jsDump output with formatted diffs.\n  * Cleanup whitespace\n  * Cleanup whitespace\n  * Added additional guards around browser specific code and cleaned up jsDump code\n  * Added guards around tests which are only for browsers\n  * cleaned up setTimeout undefined checking and double done on test finish\n  * fixing .gitignore\n  * making window setTimeout query more consistent\n  * Moved expect-code back to beginning of function, where it belongs. Fixes #52\n  * Bread crumb in header: Link to suite without filters, add link to current page based on the filter, if present. Fixes #50\n  * Make the toolbar element optional when checking for show/hide of test results. Fixes #46\n  * Adding headless.html to manually test logging and verify that QUnit works without output elements. Keeping #qunit-fixture as a few tests actually use that.\n  * Fix for QUnit.moduleDone, get rid of initial bogus log. Fixes #33\n  * Pass raw data (result, message, actual, expected) as third argument to QUnit.log. Fixes #32\n  * Dump full exception. Not pretty, but functional (see issue Pretty diff for pretty output). Fixes #31\n  * Don't let QUnit.reset() cause assertions to run. Manually applied from Scott Gonzalez branch. Fixes #34\n  * Added missing semicolons. Fixes #37\n  * Show okay/failed instead of undefined. Fixes #38\n  * Expose push as QUnit.push to build custom assertions. Fixes #39\n  * Respect filter pass selection when writing new results. Fixes #43\n  * Cleanup tests, removing asyncTest-undefined check and formatting\n  * Reset: Fall back to innerHTML when jQuery isn't available. Fixes #44\n  * Merge branch 'master' of github.com:jquery/qunit\n  * reset doesn't exist here - fixes #28.\n  * - less css cruft, better readability - replaced inline style for test counts with \"counts\" class - test counts now use a \"failed\"/\"passed\" vs \"pass\"/\"fail\", shorter/more distinct selectors - pulled all test counts styling together and up (they're always the same regardless of section pass/fail state)\n  * Adding .gitignore file\n  * Removing diff test - diffing works fine, as the browser collapses whitespace in its output, but the test can't do that and isn't worth fixing.\n  * Always synchronize the done-step (it'll set the timeout when necessary), fixes timing race conditions.\n  * Insert location.href as an anchor around the header. Fixes issue #29\n  * - kill double ;; in escapeHtml. oops\n  * Removed html escaping from QUnit.diff, as input is already escaped, only leads to double escaping. Replaced newlines with single whitespace.\n  * Optimized and cleaned up CSS file\n  * Making the reset-method non-global (only module, test and assertions should be global), and fixing the fixture reset by using jQuery's html() method again, doesn't work with innerHTML, yet\n  * Introducing #qunit-fixture element, deprecating the (never documented) #main element. Doesn't require inline styles and is now independent of jQuery.\n  * Ammending previous commit: Remove jQuery-core specific resets (will be replaced within jQuery testsuite). Fixes issue #19 - QUnit.reset() removes global jQuery ajax event handlers\n  * Remove jQuery-core specific resets (will be replaced within jQuery testsuite). Fixes issue #19 - QUnit.reset() removes global jQuery ajax event handlers\n  * Cleaning up rubble from the previous commit.\n  * Added raises assertion, reusing some of kennsnyder's code.\n  * Merged kensnyder's object detection code. Original message: Streamlined object detection and exposed QUnit.objectType as a function.\n  * Fixed some bad formatting.\n  * Move various QUnit properties below the globals-export to avoid init becoming a global method. Fixes issue #11 - Remove 'init' function from a global namespace\n  * Improved output when expected != actual: Output both only then, and add a diff. Fixes issue #10 - Show diff if equal() or deepEqual() failed\n  * Expand failed tests on load. Fixes issue #8 - Failed tests expanded on load\n  * Set location.search for url-filtering instead of location.href. Fixes issue #7 - Modify location.search instead of location.href on test double-click\n  * Add QUnit.begin() callback. Fixes issue #6 - Add 'start' callback.\n  * add css style for result (\".test-actual\") in passed tests\n  * Fixed output escaping by using leeoniya's custom escaping along with innerHTML. Also paves the way for outputting diffs.\n  * Cleanup\n  * Revert \"Revert part of bad merge, back to using createTextNode\"\n  * Revert part of bad merge, back to using createTextNode\n  * Fixed doubleclick-handler and filtering to rerun only a single test.\n  * Add ability to css style a test's messages, expected and actual results. Merged from Leon Sorokin (leeoniya).\n  * Remove space between module name and colon\n  * - removed \"module\" wording from reports (unneeded and cluttery) - added and modified css to make module & test names styleable\n  * Logging support for  Each test can extend the module testEnvironment\n  * Fixing whitespace\n  * Update tests to use equal() and deepEqual() rather than the deprecated equals() and same()\n  * Consistent argument names for deepEqual\n  * Skip DOM part of jsDump test if using a SSJS environment without a DOM\n  * Improve async testing by creating the result element before running the test, updating it later. If the test fails, its clear which test is the culprit.\n  * Add autostart option to config. Set via QUnit.config.autostart = false; start later via QUnit.start()\n  * Expose QUnit.config, but don't make config a global\n  * Expose QUnit.config as global to make external workarounds easier\n  * Merge branch 'asyncsetup'\n  * Allowing async setup and teardown. Fixes http://github.com/jquery/qunit/issues#issue/20\n  * Always output expected and actual result (no reason not to). Fixes http://github.com/jquery/qunit/issues#issue/21\n  * More changes to the detection of types in jsDump's typeOf.\n  * Change the typeOf checks in QUnit to be more accurate.\n  * Added test for jsDump and modified its options to properly output results when document.createTextNode is used; currently tests for DOM elements cause a stackoverflow error in IEs, works fine, with the correct output, elsewhere\n  * Always use jsDump to output result objects into messages, making the output for passing assertions more useful\n  * Make it so that the display is updated, at least, once a second - also prevents scripts from executing for too long and causing problems.\n  * added tests and patch for qunit.equiv to avoid circular references in objects and arrays\n  * No reason to continue looping, we can stop at this point. Thanks to Chris Thatcher for the suggestion.\n  * Use createTextNode instead of innerHTML for showing test result since expected and actual might be something that looks like a tag.\n  * 'Test card' design added\n  * switched green to blue for top-level pass + reduced padding\n  * Bringing the QUnit API in line with the CommonJS API.\n  * Explicitly set list-style-position: inside on result LIs.\n  * Madness with border-radius.\n  * Corrected banner styles for new class names\n  * Added rounded corners and removed body rules for embedded tests\n  * Resolving merge conflicts.\n  * added colouring for value summary\n  * adding some extra text colours\n  * added styles for toolbar\n  * added new styles\n  * IE 6 and 7 weren't respecting the CSS rules for the banner, used a different technique instead.\n  * Went a bit further and made extra-sure that the target was specified correctly.\n  * Fixed problem where double-clicking an entry in IE caused an error to occur.\n  * Path for http://dev.jquery.com/ticket/5426 - fix the microformat test result\n  * Fixed test() to use 'expected' 2nd param\n  * Remove the named function expressions, to stop Safari 2 from freaking out. Fixes #5.\n  * Each test can extend the module testEnvironment\n  * Extra test for current test environment\n  * Make the current testEnvironment available to utility functions\n  * typeOf in QUnit.jsDump now uses QUnit.is\n  * hoozit in QUnit.equiv now uses QUnit.is\n  * Properly set label attributes.\n  * Some minor tweaks to RyanS' GETParams change.\n  * left a console.log in :(\n  * Took into account a fringe case when using qunit with testswarm. Trying to run all the tests with the extra url params from testswarm would make qunit look for a testsuite that did not exist\n  * need to set config.currentModule to have correct names and working filters\n  * Support logging of testEnvironment\n  * async tests aren't possible on rhino\n  * Fixed a missing QUnit.reset().\n  * The QUnit. prefix was missing from the uses of the start() method.\n  * Merged lifecycle object into testEnvironment\n  * \"replacing totally wrong diff algorithm with a working one\" Patch from kassens (manually applied).\n  * fixing jslint errors in test.js\n  * Fixed: testDone() was always called with 0 failures in CommonJS mode\n  * Fixed: moduleDone() was invoked on first call to module()\n  * Added a new asyncTest method - removes the need for having to call start() at the beginning of an asynchronous test.\n  * Added support for expected numbers in the test method.\n  * Fixed broken dynamic loading of tests (can now dynamically load tests and done still works properly).\n  * Simplified the logic for calling 'done' and pushing off new tests - was causing too many inconsistencies otherwise.\n  * Simplified the markup for the QUnit test test suite.\n  * Realized that it's really easy to handle the case where stop() has been called and then an exception is thrown.\n  * Added in better logging support. Now handle moduleStart/moduleDone and testStart/testDone. Also make sure that done only fires once at the end.\n  * Made it so that you can reset the suite to an initial state (at which point tests can be dynamically loaded and run, for example).\n  * Re-worked QUnit to handle dynamic loading of additional code (the 'done' code will be re-run after additional code is loaded).\n  * Removed the old SVN version stuff.\n  * Moved the QUnit source into a separate directory and updated the test suite/packages files.\n  * Added in CommonJS support for exporting the QUnit functionality.\n  * Missing quote from package.json.\n  * Fixed trailing comma in package.json.\n  * Added a CommonJS/Narwhal package.json file.\n  * Accidentally reverted the jsDump/equiv changes that had been made.\n  * Hide the filter toolbar if it's not needed. Also exposed the jsDump and equiv objects on QUnit.\n  * Retooled the QUnit CSS to be more generic.\n  * Renamed the QUnit files from testrunner/testsuite to QUnit.\n  * Expose QUnit.equiv and QUnit.jsDump in QUnit.\n  * Moved the QUnit test directory into the QUnit directory.\n  * Reworked the QUnit CSS (moved jQuery-specific stuff out, made all the other selectors more specific).\n  * Removed the #main reset for non-jQuery code (QUnit.reset can be overwritten with your own reset code).\n  * Moved the QUnit toolbar inline.\n  * Switched to using a qunit- prefix for special elements (banner, userAgent, and tests).\n  * Missed a case in QUnit where an element was assumed to exist.\n  * QUnit's isSet and isObj are no longer needed - you should use same instead.\n  * Make sure that QUnit's equiv entity escaping is enabled by default (otherwise the output gets kind of crazy).\n  * Refactored QUnit, completely reorganized the structure of the file. Additionally made it so that QUnit can run outside of a browser (inside Rhino, for example).\n  * Removed some legacy and jQuery-specific test methods.\n  * Added callbacks for tests and modules. It's now possible to reproduce the full display of the testrunner without using the regular rendering.\n  * QUnit no longer depends upon rendering the results (it can work simply by using the logging callbacks).\n  * Made QUnit no longer require jQuery (it is now a standalone, framework independent, test runner).\n  * Reverted the noglobals changed from QUnit - causing chaos in the jQuery test suite.\n  * qunit: removed noglobals flag, instead always check for globals after teardown; if a test has to introduce a global \"myVar\", use delete window.myVar in teardown or at the end of a test\n  * qunit: don't child selectors when IE should behave nicely, too\n  * qunit: improvment for the test-scope: create a new object and call setup, the test, and teardown in the scope of that object - allows you to provide test fixtures to each test without messing with global data; kudos to Martin Häcker for the contribution\n  * qunit: added missing semicolons\n  * qunit: fixed a semicolon, that should have been a comma\n  * QUnit: implemented error handling for Opera as proposed by #3628\n  * qunit: fix for http://dev.jquery.com/ticket/3215 changing wording of testresults, to something more positive (x of y passed, z failed)\n  * QUnit: testrunner.js: Ensures equality of types (String, Boolean, Number) declared with the 'new' prefix. See comments #3, #4 and #5 on http://philrathe.com/articles/equiv\n  * qunit: wrap name of test in span when a module is used for better styling\n  * qunit: auto-prepend default mark (#header, #banner, #userAgent, #tests) when not present\n  * Landing some changes to add logging to QUnit (so that it's easier to hook in to when a test finishes).\n  * Added checkbox for hiding missing tests (tests that fail with the text 'missing test - untested code is broken code')\n  * qunit: eol-style:native and mime-type\n  * HTML being injected for the test result wasn't valid HTML.\n  * qunit: setting mimetype for testsuite.css\n  * qunit: update to Ariel's noglobals patch to support async tests as well\n  * Landing Ariel's change - checks for global variable leakage.\n  * qunit: run module-teardown in its own synchronize block to synchronize with async tests (ugh)\n  * qunit: same: equiv - completely refactored in the testrunner.\n  * testrunner.js:     - Update equiv to support Date and RegExp.     - Change behavior when comparing function:         - abort when in an instance of Object (when references comparison failed)         - skip otherwise (like before)\n  * qunit: code refactoring and cleanup\n  * QUnit: update equiv to latest version, handling multiple arguments and NaN, see http://philrathe.com/articles/equiv\n  * QUnit: cleanup, deprecating compare, compare2 and serialArray: usage now throws an error with a helpful message\n  * QUnit: optional timeout argument for stop, while making tests undetermined, useful for debugging\n  * QUnit: added toolbar with \"hide passed tests\" checkbox to help focus on failed tests\n  * QUnit: minor output formatting\n  * QUnit: adding same-assertion for a recursive comparsion of primite values, arrays  and objects, thanks to Philippe Rathé for the contribution, including tests\n  * QUnit: adding same-assertion for a recursive comparsion of primite values, arrays  and objects, thanks to Philippe Rathé for the contribution, including tests\n  * QUnit: adding same-assertion for a recursive comparsion of primite values, arrays  and objects, thanks to Philippe Rathé for the contribution, including tests\n  * qunit: use window.load to initialize tests, allowing other code to run on document-ready before starting to run tests\n  * qunit: allow either setup or teardown, instead of both or nothing\n  * qunit: make everything private by default, expose only public API; removed old timeout-option (non-deterministic, disabled for a long time anyway); use local $ reference instead of global jQuery reference; minor code cleanup (var config instead of _config; queue.shift instead of slice)\n  * qunit: added support for module level setup/teardown callbacks\n  * qunit: modified example for equals to avoid confusion with parameter ordering\n  * qunit: added id/classes to result element to enable integration with browser automation tools, see http://docs.jquery.com/QUnit#Integration_into_Browser_Automation_Tools\n  * qunit: replaced $ alias with jQuery (merged from jquery/test/data/testrunner.js)\n  * qunit: fixed inline documentation for equals\n  * qunit testrunner - catch and log possible error during reset()\n  * QUnit: Switched out Date and Rev for Id.\n  * qunit: when errors are thrown in a test, the message is successfully show on all browsers.\n  * qunit: added license header\n  * qunit: moved jquery testrunner to top-level project, see http://docs.jquery.com/QUnit\n  * Share project 'qunit' into 'https://jqueryjs.googlecode.com/svn'\n"
  },
  {
    "path": "vendor/qunit/README.md",
    "content": "[QUnit](http://qunitjs.com) - A JavaScript Unit Testing Framework.\n================================\n\nQUnit is a powerful, easy-to-use, JavaScript unit testing framework. It's used by the jQuery\nproject to test its code and plugins but is capable of testing any generic\nJavaScript code (and even capable of testing JavaScript code on the server-side).\n\nQUnit is especially useful for regression testing: Whenever a bug is reported,\nwrite a test that asserts the existence of that particular bug. Then fix it and\ncommit both. Every time you work on the code again, run the tests. If the bug\ncomes up again - a regression - you'll spot it immediately and know how to fix\nit, because you know what code you just changed.\n\nHaving good unit test coverage makes safe refactoring easy and cheap. You can\nrun the tests after each small refactoring step and always know what change\nbroke something.\n\nQUnit is similar to other unit testing frameworks like JUnit, but makes use of\nthe features JavaScript provides and helps with testing code in the browser, e.g.\nwith its stop/start facilities for testing asynchronous code.\n\nIf you are interested in helping developing QUnit, you are in the right place.\nFor related discussions, visit the\n[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing).\n\nDevelopment\n-----------\n\nTo submit patches, fork the repository, create a branch for the change. Then implement\nthe change, run `grunt` to lint and test it, then commit, push and create a pull request.\n\nInclude some background for the change in the commit message and `Fixes #nnn`, referring\nto the issue number you're addressing.\n\nTo run `grunt`, you need `node` and `npm`, then `npm install grunt -g`. That gives you a global\ngrunt binary. For additional grunt tasks, also run `npm install`.\n\nReleases\n--------\n\nInstall git-extras and run `git changelog` to update History.md. Clean up the\nchangelog, removing merge commits or whitespace cleanups.\n\nUpdate qunit/qunit.js|css and package.json to the release version, commit and\ntag (Put the 'v' in front of the tag, e.g. `v1.8.0`), update them again to\nthe next version, commit and push commits and tags:\n\n\tgit push --tags origin master\n\nTo upload to code.jquery.com (replace $version accordingly), ssh to code.origin.jquery.com:\n\n\tcp qunit/qunit.js /var/www/html/code.jquery.com/qunit/qunit-$version.js\n\tcp qunit/qunit.css /var/www/html/code.jquery.com/qunit/qunit-$version.css\n\nThen update /var/www/html/code.jquery.com/index.html and purge it with:\n\n\tcurl -s http://code.origin.jquery.com/?reload\n\nUpdate web-base-template to link to those files for qunitjs.com.\n\nPublish to npm via\n\n\tnpm publish\n"
  },
  {
    "path": "vendor/qunit/grunt.js",
    "content": "/*global config:true, task:true*/\nmodule.exports = function( grunt ) {\n\ngrunt.loadNpmTasks( \"grunt-git-authors\" );\n\ngrunt.initConfig({\n\tpkg: '<json:package.json>',\n\tqunit: {\n\t\tqunit: [\n\t\t\t'test/index.html',\n\t\t\t'test/async.html'\n\t\t\t// TODO figure out why this fails on our Jenkins server (Linux)\n\t\t\t// 'test/logs.html'\n\t\t],\n\t\taddons: [\n\t\t\t'addons/canvas/canvas.html',\n\t\t\t'addons/close-enough/close-enough.html',\n\t\t\t'addons/composite/composite-demo-test.html'\n\t\t\t// TODO same as above\n\t\t\t// 'addons/step/step.html'\n\t\t]\n\t},\n\tlint: {\n\t\tqunit: 'qunit/qunit.js',\n\t\taddons: 'addons/**.js',\n\t\ttests: 'test/**.js',\n\t\tgrunt: 'grunt.js'\n\t},\n\t// TODO remove this once grunt 0.4 is out, see jquery-ui for other details\n\tjshint: (function() {\n\t\tfunction parserc( path ) {\n\t\t\tvar rc = grunt.file.readJSON( (path || \"\") + \".jshintrc\" ),\n\t\t\t\tsettings = {\n\t\t\t\t\toptions: rc,\n\t\t\t\t\tglobals: {}\n\t\t\t\t};\n\n\t\t\t(rc.predef || []).forEach(function( prop ) {\n\t\t\t\tsettings.globals[ prop ] = true;\n\t\t\t});\n\t\t\tdelete rc.predef;\n\n\t\t\treturn settings;\n\t\t}\n\n\t\treturn {\n\t\t\tqunit: parserc( \"qunit/\" ),\n\t\t\taddons: parserc( \"addons/\" ),\n\t\t\ttests: parserc( \"test/\" )\n\t\t};\n\t})()\n});\n\ngrunt.registerTask( \"build-git\", function( sha ) {\n\tfunction processor( content ) {\n\t\tvar tagline = \" - A JavaScript Unit Testing Framework\";\n\t\treturn content.replace( tagline, \"-\" + sha + \" \" + grunt.template.today('isoDate') + tagline );\n\t}\n\tgrunt.file.copy( \"qunit/qunit.css\", \"dist/qunit-git.css\", {\n\t\tprocess: processor\n\t});\n\tgrunt.file.copy( \"qunit/qunit.js\", \"dist/qunit-git.js\", {\n\t\tprocess: processor\n\t});\n});\n\ngrunt.registerTask( \"testswarm\", function( commit, configFile ) {\n\tvar testswarm = require( \"testswarm\" ),\n\t\tconfig = grunt.file.readJSON( configFile ).qunit,\n\t\truns = {},\n\t\tdone = this.async();\n\t[\"index\", \"async\"].forEach(function (suite) {\n\t\truns[suite] = config.testUrl + commit + \"/test/\" + suite + \".html\";\n\t});\n\ttestswarm.createClient( {\n\t\turl: config.swarmUrl,\n\t\tpollInterval: 10000,\n\t\ttimeout: 1000 * 60 * 30\n\t} )\n\t.addReporter( testswarm.reporters.cli )\n\t.auth( {\n\t\tid: config.authUsername,\n\t\ttoken: config.authToken\n\t} )\n\t.addjob(\n\t\t{\n\t\t\tname: 'QUnit commit #<a href=\"https://github.com/jquery/qunit/commit/' + commit + '\">' + commit.substr( 0, 10 ) + '</a>',\n\t\t\truns: runs,\n\t\t\tbrowserSets: config.browserSets\n\t\t}, function( err, passed ) {\n\t\t\tif ( err ) {\n\t\t\t\tgrunt.log.error( err );\n\t\t\t}\n\t\t\tdone( passed );\n\t\t}\n\t);\n});\n\ngrunt.registerTask('default', 'lint qunit');\n\n};\n"
  },
  {
    "path": "vendor/qunit/package.json",
    "content": "{\n  \"name\": \"qunitjs\",\n  \"title\": \"QUnit\",\n  \"description\": \"An easy-to-use JavaScript Unit Testing framework.\",\n  \"version\": \"1.12.0pre\",\n  \"author\": {\n    \"name\": \"jQuery Foundation and other contributors\",\n    \"url\": \"https://github.com/jquery/qunit/blob/master/AUTHORS.txt\"\n  },\n  \"contributors\": [\n    \"John Resig <jeresig@gmail.com> (http://ejohn.org/)\",\n    \"Jörn Zaefferer <joern.zaefferer@gmail.com> (http://bassistance.de/)\"\n  ],\n  \"homepage\": \"http://qunitjs.com\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/jquery/qunit.git\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/jquery/qunit/issues\"\n  },\n  \"license\": {\n    \"name\": \"MIT\",\n    \"url\": \"http://www.opensource.org/licenses/mit-license.php\"\n  },\n  \"keywords\": [\n    \"testing\",\n    \"unit\",\n    \"jquery\"\n  ],\n  \"main\": \"qunit/qunit.js\",\n  \"devDependencies\": {\n    \"grunt\": \"0.3.x\",\n    \"grunt-git-authors\": \"1.0.0\",\n    \"testswarm\": \"1.0.0-alpha\"\n  }\n}\n"
  },
  {
    "path": "vendor/qunit/qunit/.jshintrc",
    "content": "{\n\t\"predef\": [\n\t\t\"jQuery\",\n\t\t\"exports\"\n\t],\n\n\t\"bitwise\": true,\n\t\"camelcase\": false,\n\t\"curly\": true,\n\t\"eqeqeq\": true,\n\t\"immed\": true,\n\t\"latedef\": false,\n\t\"newcap\": true,\n\t\"noarg\": false,\n\t\"noempty\": true,\n\t\"nonew\": true,\n\t\"undef\": true,\n\t\"unused\": true,\n\n\t\"proto\": true,\n\t\"smarttabs\": true,\n\t\"sub\": true,\n\t\"trailing\": true,\n\n\t\"browser\": true,\n\n\t\"onevar\": true\n}\n"
  },
  {
    "path": "vendor/qunit/qunit/qunit.css",
    "content": "/**\n * QUnit v1.12.0pre - A JavaScript Unit Testing Framework\n *\n * http://qunitjs.com\n *\n * Copyright 2012 jQuery Foundation and other contributors\n * Released under the MIT license.\n * http://jquery.org/license\n */\n\n/** Font Family and Sizes */\n\n#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {\n\tfont-family: \"Helvetica Neue Light\", \"HelveticaNeue-Light\", \"Helvetica Neue\", Calibri, Helvetica, Arial, sans-serif;\n}\n\n#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }\n#qunit-tests { font-size: smaller; }\n\n\n/** Resets */\n\n#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {\n\tmargin: 0;\n\tpadding: 0;\n}\n\n\n/** Header */\n\n#qunit-header {\n\tpadding: 0.5em 0 0.5em 1em;\n\n\tcolor: #8699a4;\n\tbackground-color: #0d3349;\n\n\tfont-size: 1.5em;\n\tline-height: 1em;\n\tfont-weight: normal;\n\n\tborder-radius: 5px 5px 0 0;\n\t-moz-border-radius: 5px 5px 0 0;\n\t-webkit-border-top-right-radius: 5px;\n\t-webkit-border-top-left-radius: 5px;\n}\n\n#qunit-header a {\n\ttext-decoration: none;\n\tcolor: #c2ccd1;\n}\n\n#qunit-header a:hover,\n#qunit-header a:focus {\n\tcolor: #fff;\n}\n\n#qunit-testrunner-toolbar label {\n\tdisplay: inline-block;\n\tpadding: 0 .5em 0 .1em;\n}\n\n#qunit-banner {\n\theight: 5px;\n}\n\n#qunit-testrunner-toolbar {\n\tpadding: 0.5em 0 0.5em 2em;\n\tcolor: #5E740B;\n\tbackground-color: #eee;\n\toverflow: hidden;\n}\n\n#qunit-userAgent {\n\tpadding: 0.5em 0 0.5em 2.5em;\n\tbackground-color: #2b81af;\n\tcolor: #fff;\n\ttext-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;\n}\n\n#qunit-modulefilter-container {\n\tfloat: right;\n}\n\n/** Tests: Pass/Fail */\n\n#qunit-tests {\n\tlist-style-position: inside;\n}\n\n#qunit-tests li {\n\tpadding: 0.4em 0.5em 0.4em 2.5em;\n\tborder-bottom: 1px solid #fff;\n\tlist-style-position: inside;\n}\n\n#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running  {\n\tdisplay: none;\n}\n\n#qunit-tests li strong {\n\tcursor: pointer;\n}\n\n#qunit-tests li a {\n\tpadding: 0.5em;\n\tcolor: #c2ccd1;\n\ttext-decoration: none;\n}\n#qunit-tests li a:hover,\n#qunit-tests li a:focus {\n\tcolor: #000;\n}\n\n#qunit-tests li .runtime {\n\tfloat: right;\n\tfont-size: smaller;\n}\n\n.qunit-assert-list {\n\tmargin-top: 0.5em;\n\tpadding: 0.5em;\n\n\tbackground-color: #fff;\n\n\tborder-radius: 5px;\n\t-moz-border-radius: 5px;\n\t-webkit-border-radius: 5px;\n}\n\n.qunit-collapsed {\n\tdisplay: none;\n}\n\n#qunit-tests table {\n\tborder-collapse: collapse;\n\tmargin-top: .2em;\n}\n\n#qunit-tests th {\n\ttext-align: right;\n\tvertical-align: top;\n\tpadding: 0 .5em 0 0;\n}\n\n#qunit-tests td {\n\tvertical-align: top;\n}\n\n#qunit-tests pre {\n\tmargin: 0;\n\twhite-space: pre-wrap;\n\tword-wrap: break-word;\n}\n\n#qunit-tests del {\n\tbackground-color: #e0f2be;\n\tcolor: #374e0c;\n\ttext-decoration: none;\n}\n\n#qunit-tests ins {\n\tbackground-color: #ffcaca;\n\tcolor: #500;\n\ttext-decoration: none;\n}\n\n/*** Test Counts */\n\n#qunit-tests b.counts                       { color: black; }\n#qunit-tests b.passed                       { color: #5E740B; }\n#qunit-tests b.failed                       { color: #710909; }\n\n#qunit-tests li li {\n\tpadding: 5px;\n\tbackground-color: #fff;\n\tborder-bottom: none;\n\tlist-style-position: inside;\n}\n\n/*** Passing Styles */\n\n#qunit-tests li li.pass {\n\tcolor: #3c510c;\n\tbackground-color: #fff;\n\tborder-left: 10px solid #C6E746;\n}\n\n#qunit-tests .pass                          { color: #528CE0; background-color: #D2E0E6; }\n#qunit-tests .pass .test-name               { color: #366097; }\n\n#qunit-tests .pass .test-actual,\n#qunit-tests .pass .test-expected           { color: #999999; }\n\n#qunit-banner.qunit-pass                    { background-color: #C6E746; }\n\n/*** Failing Styles */\n\n#qunit-tests li li.fail {\n\tcolor: #710909;\n\tbackground-color: #fff;\n\tborder-left: 10px solid #EE5757;\n\twhite-space: pre;\n}\n\n#qunit-tests > li:last-child {\n\tborder-radius: 0 0 5px 5px;\n\t-moz-border-radius: 0 0 5px 5px;\n\t-webkit-border-bottom-right-radius: 5px;\n\t-webkit-border-bottom-left-radius: 5px;\n}\n\n#qunit-tests .fail                          { color: #000000; background-color: #EE5757; }\n#qunit-tests .fail .test-name,\n#qunit-tests .fail .module-name             { color: #000000; }\n\n#qunit-tests .fail .test-actual             { color: #EE5757; }\n#qunit-tests .fail .test-expected           { color: green;   }\n\n#qunit-banner.qunit-fail                    { background-color: #EE5757; }\n\n\n/** Result */\n\n#qunit-testresult {\n\tpadding: 0.5em 0.5em 0.5em 2.5em;\n\n\tcolor: #2b81af;\n\tbackground-color: #D2E0E6;\n\n\tborder-bottom: 1px solid white;\n}\n#qunit-testresult .module-name {\n\tfont-weight: bold;\n}\n\n/** Fixture */\n\n#qunit-fixture {\n\tposition: absolute;\n\ttop: -10000px;\n\tleft: -10000px;\n\twidth: 1000px;\n\theight: 1000px;\n}\n"
  },
  {
    "path": "vendor/qunit/qunit/qunit.js",
    "content": "/**\n * QUnit v1.12.0pre - A JavaScript Unit Testing Framework\n *\n * http://qunitjs.com\n *\n * Copyright 2012 jQuery Foundation and other contributors\n * Released under the MIT license.\n * http://jquery.org/license\n */\n\n(function( window ) {\n\nvar QUnit,\n\tassert,\n\tconfig,\n\tonErrorFnPrev,\n\ttestId = 0,\n\tfileName = (sourceFromStacktrace( 0 ) || \"\" ).replace(/(:\\d+)+\\)?/, \"\").replace(/.+\\//, \"\"),\n\ttoString = Object.prototype.toString,\n\thasOwn = Object.prototype.hasOwnProperty,\n\t// Keep a local reference to Date (GH-283)\n\tDate = window.Date,\n\tdefined = {\n\t\tsetTimeout: typeof window.setTimeout !== \"undefined\",\n\t\tsessionStorage: (function() {\n\t\t\tvar x = \"qunit-test-string\";\n\t\t\ttry {\n\t\t\t\tsessionStorage.setItem( x, x );\n\t\t\t\tsessionStorage.removeItem( x );\n\t\t\t\treturn true;\n\t\t\t} catch( e ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}())\n\t},\n\t/**\n\t * Provides a normalized error string, correcting an issue\n\t * with IE 7 (and prior) where Error.prototype.toString is\n\t * not properly implemented\n\t *\n\t * Based on http://es5.github.com/#x15.11.4.4\n\t *\n\t * @param {String|Error} error\n\t * @return {String} error message\n\t */\n\terrorString = function( error ) {\n\t\tvar name, message,\n\t\t\terrorString = error.toString();\n\t\tif ( errorString.substring( 0, 7 ) === \"[object\" ) {\n\t\t\tname = error.name ? error.name.toString() : \"Error\";\n\t\t\tmessage = error.message ? error.message.toString() : \"\";\n\t\t\tif ( name && message ) {\n\t\t\t\treturn name + \": \" + message;\n\t\t\t} else if ( name ) {\n\t\t\t\treturn name;\n\t\t\t} else if ( message ) {\n\t\t\t\treturn message;\n\t\t\t} else {\n\t\t\t\treturn \"Error\";\n\t\t\t}\n\t\t} else {\n\t\t\treturn errorString;\n\t\t}\n\t},\n\t/**\n\t * Makes a clone of an object using only Array or Object as base,\n\t * and copies over the own enumerable properties.\n\t *\n\t * @param {Object} obj\n\t * @return {Object} New object with only the own properties (recursively).\n\t */\n\tobjectValues = function( obj ) {\n\t\t// Grunt 0.3.x uses an older version of jshint that still has jshint/jshint#392.\n\t\t/*jshint newcap: false */\n\t\tvar key, val,\n\t\t\tvals = QUnit.is( \"array\", obj ) ? [] : {};\n\t\tfor ( key in obj ) {\n\t\t\tif ( hasOwn.call( obj, key ) ) {\n\t\t\t\tval = obj[key];\n\t\t\t\tvals[key] = val === Object(val) ? objectValues(val) : val;\n\t\t\t}\n\t\t}\n\t\treturn vals;\n\t};\n\nfunction Test( settings ) {\n\textend( this, settings );\n\tthis.assertions = [];\n\tthis.testNumber = ++Test.count;\n}\n\nTest.count = 0;\n\nTest.prototype = {\n\tinit: function() {\n\t\tvar a, b, li,\n\t\t\ttests = id( \"qunit-tests\" );\n\n\t\tif ( tests ) {\n\t\t\tb = document.createElement( \"strong\" );\n\t\t\tb.innerHTML = this.nameHtml;\n\n\t\t\t// `a` initialized at top of scope\n\t\t\ta = document.createElement( \"a\" );\n\t\t\ta.innerHTML = \"Rerun\";\n\t\t\ta.href = QUnit.url({ testNumber: this.testNumber });\n\n\t\t\tli = document.createElement( \"li\" );\n\t\t\tli.appendChild( b );\n\t\t\tli.appendChild( a );\n\t\t\tli.className = \"running\";\n\t\t\tli.id = this.id = \"qunit-test-output\" + testId++;\n\n\t\t\ttests.appendChild( li );\n\t\t}\n\t},\n\tsetup: function() {\n\t\tif ( this.module !== config.previousModule ) {\n\t\t\tif ( config.previousModule ) {\n\t\t\t\trunLoggingCallbacks( \"moduleDone\", QUnit, {\n\t\t\t\t\tname: config.previousModule,\n\t\t\t\t\tfailed: config.moduleStats.bad,\n\t\t\t\t\tpassed: config.moduleStats.all - config.moduleStats.bad,\n\t\t\t\t\ttotal: config.moduleStats.all\n\t\t\t\t});\n\t\t\t}\n\t\t\tconfig.previousModule = this.module;\n\t\t\tconfig.moduleStats = { all: 0, bad: 0 };\n\t\t\trunLoggingCallbacks( \"moduleStart\", QUnit, {\n\t\t\t\tname: this.module\n\t\t\t});\n\t\t} else if ( config.autorun ) {\n\t\t\trunLoggingCallbacks( \"moduleStart\", QUnit, {\n\t\t\t\tname: this.module\n\t\t\t});\n\t\t}\n\n\t\tconfig.current = this;\n\n\t\tthis.testEnvironment = extend({\n\t\t\tsetup: function() {},\n\t\t\tteardown: function() {}\n\t\t}, this.moduleTestEnvironment );\n\n\t\tthis.started = +new Date();\n\t\trunLoggingCallbacks( \"testStart\", QUnit, {\n\t\t\tname: this.testName,\n\t\t\tmodule: this.module\n\t\t});\n\n\t\t// allow utility functions to access the current test environment\n\t\t// TODO why??\n\t\tQUnit.current_testEnvironment = this.testEnvironment;\n\n\t\tif ( !config.pollution ) {\n\t\t\tsaveGlobal();\n\t\t}\n\t\tif ( config.notrycatch ) {\n\t\t\tthis.testEnvironment.setup.call( this.testEnvironment );\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.testEnvironment.setup.call( this.testEnvironment );\n\t\t} catch( e ) {\n\t\t\tQUnit.pushFailure( \"Setup failed on \" + this.testName + \": \" + ( e.message || e ), extractStacktrace( e, 1 ) );\n\t\t}\n\t},\n\trun: function() {\n\t\tconfig.current = this;\n\n\t\tvar running = id( \"qunit-testresult\" );\n\n\t\tif ( running ) {\n\t\t\trunning.innerHTML = \"Running: <br/>\" + this.nameHtml;\n\t\t}\n\n\t\tif ( this.async ) {\n\t\t\tQUnit.stop();\n\t\t}\n\n\t\tthis.callbackStarted = +new Date();\n\n\t\tif ( config.notrycatch ) {\n\t\t\tthis.callback.call( this.testEnvironment, QUnit.assert );\n\t\t\tthis.callbackRuntime = +new Date() - this.callbackStarted;\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tthis.callback.call( this.testEnvironment, QUnit.assert );\n\t\t\tthis.callbackRuntime = +new Date() - this.callbackStarted;\n\t\t} catch( e ) {\n\t\t\tthis.callbackRuntime = +new Date() - this.callbackStarted;\n\n\t\t\tQUnit.pushFailure( \"Died on test #\" + (this.assertions.length + 1) + \" \" + this.stack + \": \" + ( e.message || e ), extractStacktrace( e, 0 ) );\n\t\t\t// else next test will carry the responsibility\n\t\t\tsaveGlobal();\n\n\t\t\t// Restart the tests if they're blocking\n\t\t\tif ( config.blocking ) {\n\t\t\t\tQUnit.start();\n\t\t\t}\n\t\t}\n\t},\n\tteardown: function() {\n\t\tconfig.current = this;\n\t\tif ( config.notrycatch ) {\n\t\t\tif ( typeof this.callbackRuntime === \"undefined\" ) {\n\t\t\t\tthis.callbackRuntime = +new Date() - this.callbackStarted;\n\t\t\t}\n\t\t\tthis.testEnvironment.teardown.call( this.testEnvironment );\n\t\t\treturn;\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tthis.testEnvironment.teardown.call( this.testEnvironment );\n\t\t\t} catch( e ) {\n\t\t\t\tQUnit.pushFailure( \"Teardown failed on \" + this.testName + \": \" + ( e.message || e ), extractStacktrace( e, 1 ) );\n\t\t\t}\n\t\t}\n\t\tcheckPollution();\n\t},\n\tfinish: function() {\n\t\tconfig.current = this;\n\t\tif ( config.requireExpects && this.expected === null ) {\n\t\t\tQUnit.pushFailure( \"Expected number of assertions to be defined, but expect() was not called.\", this.stack );\n\t\t} else if ( this.expected !== null && this.expected !== this.assertions.length ) {\n\t\t\tQUnit.pushFailure( \"Expected \" + this.expected + \" assertions, but \" + this.assertions.length + \" were run\", this.stack );\n\t\t} else if ( this.expected === null && !this.assertions.length ) {\n\t\t\tQUnit.pushFailure( \"Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.\", this.stack );\n\t\t}\n\n\t\tvar i, assertion, a, b, time, li, ol,\n\t\t\ttest = this,\n\t\t\tgood = 0,\n\t\t\tbad = 0,\n\t\t\ttests = id( \"qunit-tests\" );\n\n\t\tthis.runtime = +new Date() - this.started;\n\t\tconfig.stats.all += this.assertions.length;\n\t\tconfig.moduleStats.all += this.assertions.length;\n\n\t\tif ( tests ) {\n\t\t\tol = document.createElement( \"ol\" );\n\t\t\tol.className = \"qunit-assert-list\";\n\n\t\t\tfor ( i = 0; i < this.assertions.length; i++ ) {\n\t\t\t\tassertion = this.assertions[i];\n\n\t\t\t\tli = document.createElement( \"li\" );\n\t\t\t\tli.className = assertion.result ? \"pass\" : \"fail\";\n\t\t\t\tli.innerHTML = assertion.message || ( assertion.result ? \"okay\" : \"failed\" );\n\t\t\t\tol.appendChild( li );\n\n\t\t\t\tif ( assertion.result ) {\n\t\t\t\t\tgood++;\n\t\t\t\t} else {\n\t\t\t\t\tbad++;\n\t\t\t\t\tconfig.stats.bad++;\n\t\t\t\t\tconfig.moduleStats.bad++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// store result when possible\n\t\t\tif ( QUnit.config.reorder && defined.sessionStorage ) {\n\t\t\t\tif ( bad ) {\n\t\t\t\t\tsessionStorage.setItem( \"qunit-test-\" + this.module + \"-\" + this.testName, bad );\n\t\t\t\t} else {\n\t\t\t\t\tsessionStorage.removeItem( \"qunit-test-\" + this.module + \"-\" + this.testName );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( bad === 0 ) {\n\t\t\t\taddClass( ol, \"qunit-collapsed\" );\n\t\t\t}\n\n\t\t\t// `b` initialized at top of scope\n\t\t\tb = document.createElement( \"strong\" );\n\t\t\tb.innerHTML = this.nameHtml + \" <b class='counts'>(<b class='failed'>\" + bad + \"</b>, <b class='passed'>\" + good + \"</b>, \" + this.assertions.length + \")</b>\";\n\n\t\t\taddEvent(b, \"click\", function() {\n\t\t\t\tvar next = b.parentNode.lastChild,\n\t\t\t\t\tcollapsed = hasClass( next, \"qunit-collapsed\" );\n\t\t\t\t( collapsed ? removeClass : addClass )( next, \"qunit-collapsed\" );\n\t\t\t});\n\n\t\t\taddEvent(b, \"dblclick\", function( e ) {\n\t\t\t\tvar target = e && e.target ? e.target : window.event.srcElement;\n\t\t\t\tif ( target.nodeName.toLowerCase() === \"span\" || target.nodeName.toLowerCase() === \"b\" ) {\n\t\t\t\t\ttarget = target.parentNode;\n\t\t\t\t}\n\t\t\t\tif ( window.location && target.nodeName.toLowerCase() === \"strong\" ) {\n\t\t\t\t\twindow.location = QUnit.url({ testNumber: test.testNumber });\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// `time` initialized at top of scope\n\t\t\ttime = document.createElement( \"span\" );\n\t\t\ttime.className = \"runtime\";\n\t\t\ttime.innerHTML = this.runtime + \" ms\";\n\n\t\t\t// `li` initialized at top of scope\n\t\t\tli = id( this.id );\n\t\t\tli.className = bad ? \"fail\" : \"pass\";\n\t\t\tli.removeChild( li.firstChild );\n\t\t\ta = li.firstChild;\n\t\t\tli.appendChild( b );\n\t\t\tli.appendChild( a );\n\t\t\tli.appendChild( time );\n\t\t\tli.appendChild( ol );\n\n\t\t} else {\n\t\t\tfor ( i = 0; i < this.assertions.length; i++ ) {\n\t\t\t\tif ( !this.assertions[i].result ) {\n\t\t\t\t\tbad++;\n\t\t\t\t\tconfig.stats.bad++;\n\t\t\t\t\tconfig.moduleStats.bad++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\trunLoggingCallbacks( \"testDone\", QUnit, {\n\t\t\tname: this.testName,\n\t\t\tmodule: this.module,\n\t\t\tfailed: bad,\n\t\t\tpassed: this.assertions.length - bad,\n\t\t\ttotal: this.assertions.length,\n\t\t\tduration: this.runtime\n\t\t});\n\n\t\tQUnit.reset();\n\n\t\tconfig.current = undefined;\n\t},\n\n\tqueue: function() {\n\t\tvar bad,\n\t\t\ttest = this;\n\n\t\tsynchronize(function() {\n\t\t\ttest.init();\n\t\t});\n\t\tfunction run() {\n\t\t\t// each of these can by async\n\t\t\tsynchronize(function() {\n\t\t\t\ttest.setup();\n\t\t\t});\n\t\t\tsynchronize(function() {\n\t\t\t\ttest.run();\n\t\t\t});\n\t\t\tsynchronize(function() {\n\t\t\t\ttest.teardown();\n\t\t\t});\n\t\t\tsynchronize(function() {\n\t\t\t\ttest.finish();\n\t\t\t});\n\t\t}\n\n\t\t// `bad` initialized at top of scope\n\t\t// defer when previous test run passed, if storage is available\n\t\tbad = QUnit.config.reorder && defined.sessionStorage &&\n\t\t\t\t\t\t+sessionStorage.getItem( \"qunit-test-\" + this.module + \"-\" + this.testName );\n\n\t\tif ( bad ) {\n\t\t\trun();\n\t\t} else {\n\t\t\tsynchronize( run, true );\n\t\t}\n\t}\n};\n\n// Root QUnit object.\n// `QUnit` initialized at top of scope\nQUnit = {\n\n\t// call on start of module test to prepend name to all tests\n\tmodule: function( name, testEnvironment ) {\n\t\tconfig.currentModule = name;\n\t\tconfig.currentModuleTestEnvironment = testEnvironment;\n\t\tconfig.modules[name] = true;\n\t},\n\n\tasyncTest: function( testName, expected, callback ) {\n\t\tif ( arguments.length === 2 ) {\n\t\t\tcallback = expected;\n\t\t\texpected = null;\n\t\t}\n\n\t\tQUnit.test( testName, expected, callback, true );\n\t},\n\n\ttest: function( testName, expected, callback, async ) {\n\t\tvar test,\n\t\t\tnameHtml = \"<span class='test-name'>\" + escapeText( testName ) + \"</span>\";\n\n\t\tif ( arguments.length === 2 ) {\n\t\t\tcallback = expected;\n\t\t\texpected = null;\n\t\t}\n\n\t\tif ( config.currentModule ) {\n\t\t\tnameHtml = \"<span class='module-name'>\" + escapeText( config.currentModule ) + \"</span>: \" + nameHtml;\n\t\t}\n\n\t\ttest = new Test({\n\t\t\tnameHtml: nameHtml,\n\t\t\ttestName: testName,\n\t\t\texpected: expected,\n\t\t\tasync: async,\n\t\t\tcallback: callback,\n\t\t\tmodule: config.currentModule,\n\t\t\tmoduleTestEnvironment: config.currentModuleTestEnvironment,\n\t\t\tstack: sourceFromStacktrace( 2 )\n\t\t});\n\n\t\tif ( !validTest( test ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttest.queue();\n\t},\n\n\t// Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.\n\texpect: function( asserts ) {\n\t\tif (arguments.length === 1) {\n\t\t\tconfig.current.expected = asserts;\n\t\t} else {\n\t\t\treturn config.current.expected;\n\t\t}\n\t},\n\n\tstart: function( count ) {\n\t\t// QUnit hasn't been initialized yet.\n\t\t// Note: RequireJS (et al) may delay onLoad\n\t\tif ( config.semaphore === undefined ) {\n\t\t\tQUnit.begin(function() {\n\t\t\t\t// This is triggered at the top of QUnit.load, push start() to the event loop, to allow QUnit.load to finish first\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tQUnit.start( count );\n\t\t\t\t});\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconfig.semaphore -= count || 1;\n\t\t// don't start until equal number of stop-calls\n\t\tif ( config.semaphore > 0 ) {\n\t\t\treturn;\n\t\t}\n\t\t// ignore if start is called more often then stop\n\t\tif ( config.semaphore < 0 ) {\n\t\t\tconfig.semaphore = 0;\n\t\t\tQUnit.pushFailure( \"Called start() while already started (QUnit.config.semaphore was 0 already)\", null, sourceFromStacktrace(2) );\n\t\t\treturn;\n\t\t}\n\t\t// A slight delay, to avoid any current callbacks\n\t\tif ( defined.setTimeout ) {\n\t\t\twindow.setTimeout(function() {\n\t\t\t\tif ( config.semaphore > 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( config.timeout ) {\n\t\t\t\t\tclearTimeout( config.timeout );\n\t\t\t\t}\n\n\t\t\t\tconfig.blocking = false;\n\t\t\t\tprocess( true );\n\t\t\t}, 13);\n\t\t} else {\n\t\t\tconfig.blocking = false;\n\t\t\tprocess( true );\n\t\t}\n\t},\n\n\tstop: function( count ) {\n\t\tconfig.semaphore += count || 1;\n\t\tconfig.blocking = true;\n\n\t\tif ( config.testTimeout && defined.setTimeout ) {\n\t\t\tclearTimeout( config.timeout );\n\t\t\tconfig.timeout = window.setTimeout(function() {\n\t\t\t\tQUnit.ok( false, \"Test timed out\" );\n\t\t\t\tconfig.semaphore = 1;\n\t\t\t\tQUnit.start();\n\t\t\t}, config.testTimeout );\n\t\t}\n\t}\n};\n\n// `assert` initialized at top of scope\n// Asssert helpers\n// All of these must either call QUnit.push() or manually do:\n// - runLoggingCallbacks( \"log\", .. );\n// - config.current.assertions.push({ .. });\n// We attach it to the QUnit object *after* we expose the public API,\n// otherwise `assert` will become a global variable in browsers (#341).\nassert = {\n\t/**\n\t * Asserts rough true-ish result.\n\t * @name ok\n\t * @function\n\t * @example ok( \"asdfasdf\".length > 5, \"There must be at least 5 chars\" );\n\t */\n\tok: function( result, msg ) {\n\t\tif ( !config.current ) {\n\t\t\tthrow new Error( \"ok() assertion outside test context, was \" + sourceFromStacktrace(2) );\n\t\t}\n\t\tresult = !!result;\n\n\t\tvar source,\n\t\t\tdetails = {\n\t\t\t\tmodule: config.current.module,\n\t\t\t\tname: config.current.testName,\n\t\t\t\tresult: result,\n\t\t\t\tmessage: msg\n\t\t\t};\n\n\t\tmsg = escapeText( msg || (result ? \"okay\" : \"failed\" ) );\n\t\tmsg = \"<span class='test-message'>\" + msg + \"</span>\";\n\n\t\tif ( !result ) {\n\t\t\tsource = sourceFromStacktrace( 2 );\n\t\t\tif ( source ) {\n\t\t\t\tdetails.source = source;\n\t\t\t\tmsg += \"<table><tr class='test-source'><th>Source: </th><td><pre>\" + escapeText( source ) + \"</pre></td></tr></table>\";\n\t\t\t}\n\t\t}\n\t\trunLoggingCallbacks( \"log\", QUnit, details );\n\t\tconfig.current.assertions.push({\n\t\t\tresult: result,\n\t\t\tmessage: msg\n\t\t});\n\t},\n\n\t/**\n\t * Assert that the first two arguments are equal, with an optional message.\n\t * Prints out both actual and expected values.\n\t * @name equal\n\t * @function\n\t * @example equal( format( \"Received {0} bytes.\", 2), \"Received 2 bytes.\", \"format() replaces {0} with next argument\" );\n\t */\n\tequal: function( actual, expected, message ) {\n\t\t/*jshint eqeqeq:false */\n\t\tQUnit.push( expected == actual, actual, expected, message );\n\t},\n\n\t/**\n\t * @name notEqual\n\t * @function\n\t */\n\tnotEqual: function( actual, expected, message ) {\n\t\t/*jshint eqeqeq:false */\n\t\tQUnit.push( expected != actual, actual, expected, message );\n\t},\n\n\t/**\n\t * @name propEqual\n\t * @function\n\t */\n\tpropEqual: function( actual, expected, message ) {\n\t\tactual = objectValues(actual);\n\t\texpected = objectValues(expected);\n\t\tQUnit.push( QUnit.equiv(actual, expected), actual, expected, message );\n\t},\n\n\t/**\n\t * @name notPropEqual\n\t * @function\n\t */\n\tnotPropEqual: function( actual, expected, message ) {\n\t\tactual = objectValues(actual);\n\t\texpected = objectValues(expected);\n\t\tQUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );\n\t},\n\n\t/**\n\t * @name deepEqual\n\t * @function\n\t */\n\tdeepEqual: function( actual, expected, message ) {\n\t\tQUnit.push( QUnit.equiv(actual, expected), actual, expected, message );\n\t},\n\n\t/**\n\t * @name notDeepEqual\n\t * @function\n\t */\n\tnotDeepEqual: function( actual, expected, message ) {\n\t\tQUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );\n\t},\n\n\t/**\n\t * @name strictEqual\n\t * @function\n\t */\n\tstrictEqual: function( actual, expected, message ) {\n\t\tQUnit.push( expected === actual, actual, expected, message );\n\t},\n\n\t/**\n\t * @name notStrictEqual\n\t * @function\n\t */\n\tnotStrictEqual: function( actual, expected, message ) {\n\t\tQUnit.push( expected !== actual, actual, expected, message );\n\t},\n\n\t\"throws\": function( block, expected, message ) {\n\t\tvar actual,\n\t\t\texpectedOutput = expected,\n\t\t\tok = false;\n\n\t\t// 'expected' is optional\n\t\tif ( typeof expected === \"string\" ) {\n\t\t\tmessage = expected;\n\t\t\texpected = null;\n\t\t}\n\n\t\tconfig.current.ignoreGlobalErrors = true;\n\t\ttry {\n\t\t\tblock.call( config.current.testEnvironment );\n\t\t} catch (e) {\n\t\t\tactual = e;\n\t\t}\n\t\tconfig.current.ignoreGlobalErrors = false;\n\n\t\tif ( actual ) {\n\t\t\t// we don't want to validate thrown error\n\t\t\tif ( !expected ) {\n\t\t\t\tok = true;\n\t\t\t\texpectedOutput = null;\n\t\t\t// expected is a regexp\n\t\t\t} else if ( QUnit.objectType( expected ) === \"regexp\" ) {\n\t\t\t\tok = expected.test( errorString( actual ) );\n\t\t\t// expected is a constructor\n\t\t\t} else if ( actual instanceof expected ) {\n\t\t\t\tok = true;\n\t\t\t// expected is a validation function which returns true is validation passed\n\t\t\t} else if ( expected.call( {}, actual ) === true ) {\n\t\t\t\texpectedOutput = null;\n\t\t\t\tok = true;\n\t\t\t}\n\n\t\t\tQUnit.push( ok, actual, expectedOutput, message );\n\t\t} else {\n\t\t\tQUnit.pushFailure( message, null, 'No exception was thrown.' );\n\t\t}\n\t}\n};\n\n/**\n * @deprecate since 1.8.0\n * Kept assertion helpers in root for backwards compatibility.\n */\nextend( QUnit, assert );\n\n/**\n * @deprecated since 1.9.0\n * Kept root \"raises()\" for backwards compatibility.\n * (Note that we don't introduce assert.raises).\n */\nQUnit.raises = assert[ \"throws\" ];\n\n/**\n * @deprecated since 1.0.0, replaced with error pushes since 1.3.0\n * Kept to avoid TypeErrors for undefined methods.\n */\nQUnit.equals = function() {\n\tQUnit.push( false, false, false, \"QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead\" );\n};\nQUnit.same = function() {\n\tQUnit.push( false, false, false, \"QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead\" );\n};\n\n// We want access to the constructor's prototype\n(function() {\n\tfunction F() {}\n\tF.prototype = QUnit;\n\tQUnit = new F();\n\t// Make F QUnit's constructor so that we can add to the prototype later\n\tQUnit.constructor = F;\n}());\n\n/**\n * Config object: Maintain internal state\n * Later exposed as QUnit.config\n * `config` initialized at top of scope\n */\nconfig = {\n\t// The queue of tests to run\n\tqueue: [],\n\n\t// block until document ready\n\tblocking: true,\n\n\t// when enabled, show only failing tests\n\t// gets persisted through sessionStorage and can be changed in UI via checkbox\n\thidepassed: false,\n\n\t// by default, run previously failed tests first\n\t// very useful in combination with \"Hide passed tests\" checked\n\treorder: true,\n\n\t// by default, modify document.title when suite is done\n\taltertitle: true,\n\n\t// when enabled, all tests must call expect()\n\trequireExpects: false,\n\n\t// add checkboxes that are persisted in the query-string\n\t// when enabled, the id is set to `true` as a `QUnit.config` property\n\turlConfig: [\n\t\t{\n\t\t\tid: \"noglobals\",\n\t\t\tlabel: \"Check for Globals\",\n\t\t\ttooltip: \"Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings.\"\n\t\t},\n\t\t{\n\t\t\tid: \"notrycatch\",\n\t\t\tlabel: \"No try-catch\",\n\t\t\ttooltip: \"Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings.\"\n\t\t}\n\t],\n\n\t// Set of all modules.\n\tmodules: {},\n\n\t// logging callback queues\n\tbegin: [],\n\tdone: [],\n\tlog: [],\n\ttestStart: [],\n\ttestDone: [],\n\tmoduleStart: [],\n\tmoduleDone: []\n};\n\n// Export global variables, unless an 'exports' object exists,\n// in that case we assume we're in CommonJS (dealt with on the bottom of the script)\nif ( typeof exports === \"undefined\" ) {\n\textend( window, QUnit );\n\n\t// Expose QUnit object\n\twindow.QUnit = QUnit;\n}\n\n// Initialize more QUnit.config and QUnit.urlParams\n(function() {\n\tvar i,\n\t\tlocation = window.location || { search: \"\", protocol: \"file:\" },\n\t\tparams = location.search.slice( 1 ).split( \"&\" ),\n\t\tlength = params.length,\n\t\turlParams = {},\n\t\tcurrent;\n\n\tif ( params[ 0 ] ) {\n\t\tfor ( i = 0; i < length; i++ ) {\n\t\t\tcurrent = params[ i ].split( \"=\" );\n\t\t\tcurrent[ 0 ] = decodeURIComponent( current[ 0 ] );\n\t\t\t// allow just a key to turn on a flag, e.g., test.html?noglobals\n\t\t\tcurrent[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true;\n\t\t\turlParams[ current[ 0 ] ] = current[ 1 ];\n\t\t}\n\t}\n\n\tQUnit.urlParams = urlParams;\n\n\t// String search anywhere in moduleName+testName\n\tconfig.filter = urlParams.filter;\n\n\t// Exact match of the module name\n\tconfig.module = urlParams.module;\n\n\tconfig.testNumber = parseInt( urlParams.testNumber, 10 ) || null;\n\n\t// Figure out if we're running the tests from a server or not\n\tQUnit.isLocal = location.protocol === \"file:\";\n}());\n\n// Extend QUnit object,\n// these after set here because they should not be exposed as global functions\nextend( QUnit, {\n\tassert: assert,\n\n\tconfig: config,\n\n\t// Initialize the configuration options\n\tinit: function() {\n\t\textend( config, {\n\t\t\tstats: { all: 0, bad: 0 },\n\t\t\tmoduleStats: { all: 0, bad: 0 },\n\t\t\tstarted: +new Date(),\n\t\t\tupdateRate: 1000,\n\t\t\tblocking: false,\n\t\t\tautostart: true,\n\t\t\tautorun: false,\n\t\t\tfilter: \"\",\n\t\t\tqueue: [],\n\t\t\tsemaphore: 1\n\t\t});\n\n\t\tvar tests, banner, result,\n\t\t\tqunit = id( \"qunit\" );\n\n\t\tif ( qunit ) {\n\t\t\tqunit.innerHTML =\n\t\t\t\t\"<h1 id='qunit-header'>\" + escapeText( document.title ) + \"</h1>\" +\n\t\t\t\t\"<h2 id='qunit-banner'></h2>\" +\n\t\t\t\t\"<div id='qunit-testrunner-toolbar'></div>\" +\n\t\t\t\t\"<h2 id='qunit-userAgent'></h2>\" +\n\t\t\t\t\"<ol id='qunit-tests'></ol>\";\n\t\t}\n\n\t\ttests = id( \"qunit-tests\" );\n\t\tbanner = id( \"qunit-banner\" );\n\t\tresult = id( \"qunit-testresult\" );\n\n\t\tif ( tests ) {\n\t\t\ttests.innerHTML = \"\";\n\t\t}\n\n\t\tif ( banner ) {\n\t\t\tbanner.className = \"\";\n\t\t}\n\n\t\tif ( result ) {\n\t\t\tresult.parentNode.removeChild( result );\n\t\t}\n\n\t\tif ( tests ) {\n\t\t\tresult = document.createElement( \"p\" );\n\t\t\tresult.id = \"qunit-testresult\";\n\t\t\tresult.className = \"result\";\n\t\t\ttests.parentNode.insertBefore( result, tests );\n\t\t\tresult.innerHTML = \"Running...<br/>&nbsp;\";\n\t\t}\n\t},\n\n\t// Resets the test setup. Useful for tests that modify the DOM.\n\treset: function() {\n\t\tvar fixture = id( \"qunit-fixture\" );\n\t\tif ( fixture ) {\n\t\t\tfixture.innerHTML = config.fixture;\n\t\t}\n\t},\n\n\t// Trigger an event on an element.\n\t// @example triggerEvent( document.body, \"click\" );\n\ttriggerEvent: function( elem, type, event ) {\n\t\tif ( document.createEvent ) {\n\t\t\tevent = document.createEvent( \"MouseEvents\" );\n\t\t\tevent.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,\n\t\t\t\t0, 0, 0, 0, 0, false, false, false, false, 0, null);\n\n\t\t\telem.dispatchEvent( event );\n\t\t} else if ( elem.fireEvent ) {\n\t\t\telem.fireEvent( \"on\" + type );\n\t\t}\n\t},\n\n\t// Safe object type checking\n\tis: function( type, obj ) {\n\t\treturn QUnit.objectType( obj ) === type;\n\t},\n\n\tobjectType: function( obj ) {\n\t\tif ( typeof obj === \"undefined\" ) {\n\t\t\t\treturn \"undefined\";\n\t\t// consider: typeof null === object\n\t\t}\n\t\tif ( obj === null ) {\n\t\t\t\treturn \"null\";\n\t\t}\n\n\t\tvar match = toString.call( obj ).match(/^\\[object\\s(.*)\\]$/),\n\t\t\ttype = match && match[1] || \"\";\n\n\t\tswitch ( type ) {\n\t\t\tcase \"Number\":\n\t\t\t\tif ( isNaN(obj) ) {\n\t\t\t\t\treturn \"nan\";\n\t\t\t\t}\n\t\t\t\treturn \"number\";\n\t\t\tcase \"String\":\n\t\t\tcase \"Boolean\":\n\t\t\tcase \"Array\":\n\t\t\tcase \"Date\":\n\t\t\tcase \"RegExp\":\n\t\t\tcase \"Function\":\n\t\t\t\treturn type.toLowerCase();\n\t\t}\n\t\tif ( typeof obj === \"object\" ) {\n\t\t\treturn \"object\";\n\t\t}\n\t\treturn undefined;\n\t},\n\n\tpush: function( result, actual, expected, message ) {\n\t\tif ( !config.current ) {\n\t\t\tthrow new Error( \"assertion outside test context, was \" + sourceFromStacktrace() );\n\t\t}\n\n\t\tvar output, source,\n\t\t\tdetails = {\n\t\t\t\tmodule: config.current.module,\n\t\t\t\tname: config.current.testName,\n\t\t\t\tresult: result,\n\t\t\t\tmessage: message,\n\t\t\t\tactual: actual,\n\t\t\t\texpected: expected\n\t\t\t};\n\n\t\tmessage = escapeText( message ) || ( result ? \"okay\" : \"failed\" );\n\t\tmessage = \"<span class='test-message'>\" + message + \"</span>\";\n\t\toutput = message;\n\n\t\tif ( !result ) {\n\t\t\texpected = escapeText( QUnit.jsDump.parse(expected) );\n\t\t\tactual = escapeText( QUnit.jsDump.parse(actual) );\n\t\t\toutput += \"<table><tr class='test-expected'><th>Expected: </th><td><pre>\" + expected + \"</pre></td></tr>\";\n\n\t\t\tif ( actual !== expected ) {\n\t\t\t\toutput += \"<tr class='test-actual'><th>Result: </th><td><pre>\" + actual + \"</pre></td></tr>\";\n\t\t\t\toutput += \"<tr class='test-diff'><th>Diff: </th><td><pre>\" + QUnit.diff( expected, actual ) + \"</pre></td></tr>\";\n\t\t\t}\n\n\t\t\tsource = sourceFromStacktrace();\n\n\t\t\tif ( source ) {\n\t\t\t\tdetails.source = source;\n\t\t\t\toutput += \"<tr class='test-source'><th>Source: </th><td><pre>\" + escapeText( source ) + \"</pre></td></tr>\";\n\t\t\t}\n\n\t\t\toutput += \"</table>\";\n\t\t}\n\n\t\trunLoggingCallbacks( \"log\", QUnit, details );\n\n\t\tconfig.current.assertions.push({\n\t\t\tresult: !!result,\n\t\t\tmessage: output\n\t\t});\n\t},\n\n\tpushFailure: function( message, source, actual ) {\n\t\tif ( !config.current ) {\n\t\t\tthrow new Error( \"pushFailure() assertion outside test context, was \" + sourceFromStacktrace(2) );\n\t\t}\n\n\t\tvar output,\n\t\t\tdetails = {\n\t\t\t\tmodule: config.current.module,\n\t\t\t\tname: config.current.testName,\n\t\t\t\tresult: false,\n\t\t\t\tmessage: message\n\t\t\t};\n\n\t\tmessage = escapeText( message ) || \"error\";\n\t\tmessage = \"<span class='test-message'>\" + message + \"</span>\";\n\t\toutput = message;\n\n\t\toutput += \"<table>\";\n\n\t\tif ( actual ) {\n\t\t\toutput += \"<tr class='test-actual'><th>Result: </th><td><pre>\" + escapeText( actual ) + \"</pre></td></tr>\";\n\t\t}\n\n\t\tif ( source ) {\n\t\t\tdetails.source = source;\n\t\t\toutput += \"<tr class='test-source'><th>Source: </th><td><pre>\" + escapeText( source ) + \"</pre></td></tr>\";\n\t\t}\n\n\t\toutput += \"</table>\";\n\n\t\trunLoggingCallbacks( \"log\", QUnit, details );\n\n\t\tconfig.current.assertions.push({\n\t\t\tresult: false,\n\t\t\tmessage: output\n\t\t});\n\t},\n\n\turl: function( params ) {\n\t\tparams = extend( extend( {}, QUnit.urlParams ), params );\n\t\tvar key,\n\t\t\tquerystring = \"?\";\n\n\t\tfor ( key in params ) {\n\t\t\tif ( !hasOwn.call( params, key ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tquerystring += encodeURIComponent( key ) + \"=\" +\n\t\t\t\tencodeURIComponent( params[ key ] ) + \"&\";\n\t\t}\n\t\treturn window.location.protocol + \"//\" + window.location.host +\n\t\t\twindow.location.pathname + querystring.slice( 0, -1 );\n\t},\n\n\textend: extend,\n\tid: id,\n\taddEvent: addEvent\n\t// load, equiv, jsDump, diff: Attached later\n});\n\n/**\n * @deprecated: Created for backwards compatibility with test runner that set the hook function\n * into QUnit.{hook}, instead of invoking it and passing the hook function.\n * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here.\n * Doing this allows us to tell if the following methods have been overwritten on the actual\n * QUnit object.\n */\nextend( QUnit.constructor.prototype, {\n\n\t// Logging callbacks; all receive a single argument with the listed properties\n\t// run test/logs.html for any related changes\n\tbegin: registerLoggingCallback( \"begin\" ),\n\n\t// done: { failed, passed, total, runtime }\n\tdone: registerLoggingCallback( \"done\" ),\n\n\t// log: { result, actual, expected, message }\n\tlog: registerLoggingCallback( \"log\" ),\n\n\t// testStart: { name }\n\ttestStart: registerLoggingCallback( \"testStart\" ),\n\n\t// testDone: { name, failed, passed, total, duration }\n\ttestDone: registerLoggingCallback( \"testDone\" ),\n\n\t// moduleStart: { name }\n\tmoduleStart: registerLoggingCallback( \"moduleStart\" ),\n\n\t// moduleDone: { name, failed, passed, total }\n\tmoduleDone: registerLoggingCallback( \"moduleDone\" )\n});\n\nif ( typeof document === \"undefined\" || document.readyState === \"complete\" ) {\n\tconfig.autorun = true;\n}\n\nQUnit.load = function() {\n\trunLoggingCallbacks( \"begin\", QUnit, {} );\n\n\t// Initialize the config, saving the execution queue\n\tvar banner, filter, i, label, len, main, ol, toolbar, userAgent, val,\n\t\turlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter,\n\t\tnumModules = 0,\n\t\tmoduleNames = [],\n\t\tmoduleFilterHtml = \"\",\n\t\turlConfigHtml = \"\",\n\t\toldconfig = extend( {}, config );\n\n\tQUnit.init();\n\textend(config, oldconfig);\n\n\tconfig.blocking = false;\n\n\tlen = config.urlConfig.length;\n\n\tfor ( i = 0; i < len; i++ ) {\n\t\tval = config.urlConfig[i];\n\t\tif ( typeof val === \"string\" ) {\n\t\t\tval = {\n\t\t\t\tid: val,\n\t\t\t\tlabel: val,\n\t\t\t\ttooltip: \"[no tooltip available]\"\n\t\t\t};\n\t\t}\n\t\tconfig[ val.id ] = QUnit.urlParams[ val.id ];\n\t\turlConfigHtml += \"<input id='qunit-urlconfig-\" + escapeText( val.id ) +\n\t\t\t\"' name='\" + escapeText( val.id ) +\n\t\t\t\"' type='checkbox'\" + ( config[ val.id ] ? \" checked='checked'\" : \"\" ) +\n\t\t\t\" title='\" + escapeText( val.tooltip ) +\n\t\t\t\"'><label for='qunit-urlconfig-\" + escapeText( val.id ) +\n\t\t\t\"' title='\" + escapeText( val.tooltip ) + \"'>\" + val.label + \"</label>\";\n\t}\n\tfor ( i in config.modules ) {\n\t\tif ( config.modules.hasOwnProperty( i ) ) {\n\t\t\tmoduleNames.push(i);\n\t\t}\n\t}\n\tnumModules = moduleNames.length;\n\tmoduleNames.sort( function( a, b ) {\n\t\treturn a.localeCompare( b );\n\t});\n\tmoduleFilterHtml += \"<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' \" +\n\t\t( config.module === undefined  ? \"selected='selected'\" : \"\" ) +\n\t\t\">< All Modules ></option>\";\n\n\n\tfor ( i = 0; i < numModules; i++) {\n\t\t\tmoduleFilterHtml += \"<option value='\" + escapeText( encodeURIComponent(moduleNames[i]) ) + \"' \" +\n\t\t\t\t( config.module === moduleNames[i] ? \"selected='selected'\" : \"\" ) +\n\t\t\t\t\">\" + escapeText(moduleNames[i]) + \"</option>\";\n\t}\n\tmoduleFilterHtml += \"</select>\";\n\n\t// `userAgent` initialized at top of scope\n\tuserAgent = id( \"qunit-userAgent\" );\n\tif ( userAgent ) {\n\t\tuserAgent.innerHTML = navigator.userAgent;\n\t}\n\n\t// `banner` initialized at top of scope\n\tbanner = id( \"qunit-header\" );\n\tif ( banner ) {\n\t\tbanner.innerHTML = \"<a href='\" + QUnit.url({ filter: undefined, module: undefined, testNumber: undefined }) + \"'>\" + banner.innerHTML + \"</a> \";\n\t}\n\n\t// `toolbar` initialized at top of scope\n\ttoolbar = id( \"qunit-testrunner-toolbar\" );\n\tif ( toolbar ) {\n\t\t// `filter` initialized at top of scope\n\t\tfilter = document.createElement( \"input\" );\n\t\tfilter.type = \"checkbox\";\n\t\tfilter.id = \"qunit-filter-pass\";\n\n\t\taddEvent( filter, \"click\", function() {\n\t\t\tvar tmp,\n\t\t\t\tol = document.getElementById( \"qunit-tests\" );\n\n\t\t\tif ( filter.checked ) {\n\t\t\t\tol.className = ol.className + \" hidepass\";\n\t\t\t} else {\n\t\t\t\ttmp = \" \" + ol.className.replace( /[\\n\\t\\r]/g, \" \" ) + \" \";\n\t\t\t\tol.className = tmp.replace( / hidepass /, \" \" );\n\t\t\t}\n\t\t\tif ( defined.sessionStorage ) {\n\t\t\t\tif (filter.checked) {\n\t\t\t\t\tsessionStorage.setItem( \"qunit-filter-passed-tests\", \"true\" );\n\t\t\t\t} else {\n\t\t\t\t\tsessionStorage.removeItem( \"qunit-filter-passed-tests\" );\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tif ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem( \"qunit-filter-passed-tests\" ) ) {\n\t\t\tfilter.checked = true;\n\t\t\t// `ol` initialized at top of scope\n\t\t\tol = document.getElementById( \"qunit-tests\" );\n\t\t\tol.className = ol.className + \" hidepass\";\n\t\t}\n\t\ttoolbar.appendChild( filter );\n\n\t\t// `label` initialized at top of scope\n\t\tlabel = document.createElement( \"label\" );\n\t\tlabel.setAttribute( \"for\", \"qunit-filter-pass\" );\n\t\tlabel.setAttribute( \"title\", \"Only show tests and assertons that fail. Stored in sessionStorage.\" );\n\t\tlabel.innerHTML = \"Hide passed tests\";\n\t\ttoolbar.appendChild( label );\n\n\t\turlConfigCheckboxesContainer = document.createElement(\"span\");\n\t\turlConfigCheckboxesContainer.innerHTML = urlConfigHtml;\n\t\turlConfigCheckboxes = urlConfigCheckboxesContainer.getElementsByTagName(\"input\");\n\t\t// For oldIE support:\n\t\t// * Add handlers to the individual elements instead of the container\n\t\t// * Use \"click\" instead of \"change\"\n\t\t// * Fallback from event.target to event.srcElement\n\t\taddEvents( urlConfigCheckboxes, \"click\", function( event ) {\n\t\t\tvar params = {},\n\t\t\t\ttarget = event.target || event.srcElement;\n\t\t\tparams[ target.name ] = target.checked ? true : undefined;\n\t\t\twindow.location = QUnit.url( params );\n\t\t});\n\t\ttoolbar.appendChild( urlConfigCheckboxesContainer );\n\n\t\tif (numModules > 1) {\n\t\t\tmoduleFilter = document.createElement( 'span' );\n\t\t\tmoduleFilter.setAttribute( 'id', 'qunit-modulefilter-container' );\n\t\t\tmoduleFilter.innerHTML = moduleFilterHtml;\n\t\t\taddEvent( moduleFilter.lastChild, \"change\", function() {\n\t\t\t\tvar selectBox = moduleFilter.getElementsByTagName(\"select\")[0],\n\t\t\t\t\tselectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value);\n\n\t\t\t\twindow.location = QUnit.url( { module: ( selectedModule === \"\" ) ? undefined : selectedModule } );\n\t\t\t});\n\t\t\ttoolbar.appendChild(moduleFilter);\n\t\t}\n\t}\n\n\t// `main` initialized at top of scope\n\tmain = id( \"qunit-fixture\" );\n\tif ( main ) {\n\t\tconfig.fixture = main.innerHTML;\n\t}\n\n\tif ( config.autostart ) {\n\t\tQUnit.start();\n\t}\n};\n\naddEvent( window, \"load\", QUnit.load );\n\n// `onErrorFnPrev` initialized at top of scope\n// Preserve other handlers\nonErrorFnPrev = window.onerror;\n\n// Cover uncaught exceptions\n// Returning true will surpress the default browser handler,\n// returning false will let it run.\nwindow.onerror = function ( error, filePath, linerNr ) {\n\tvar ret = false;\n\tif ( onErrorFnPrev ) {\n\t\tret = onErrorFnPrev( error, filePath, linerNr );\n\t}\n\n\t// Treat return value as window.onerror itself does,\n\t// Only do our handling if not surpressed.\n\tif ( ret !== true ) {\n\t\tif ( QUnit.config.current ) {\n\t\t\tif ( QUnit.config.current.ignoreGlobalErrors ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tQUnit.pushFailure( error, filePath + \":\" + linerNr );\n\t\t} else {\n\t\t\tQUnit.test( \"global failure\", extend( function() {\n\t\t\t\tQUnit.pushFailure( error, filePath + \":\" + linerNr );\n\t\t\t}, { validTest: validTest } ) );\n\t\t}\n\t\treturn false;\n\t}\n\n\treturn ret;\n};\n\nfunction done() {\n\tconfig.autorun = true;\n\n\t// Log the last module results\n\tif ( config.currentModule ) {\n\t\trunLoggingCallbacks( \"moduleDone\", QUnit, {\n\t\t\tname: config.currentModule,\n\t\t\tfailed: config.moduleStats.bad,\n\t\t\tpassed: config.moduleStats.all - config.moduleStats.bad,\n\t\t\ttotal: config.moduleStats.all\n\t\t});\n\t}\n\n\tvar i, key,\n\t\tbanner = id( \"qunit-banner\" ),\n\t\ttests = id( \"qunit-tests\" ),\n\t\truntime = +new Date() - config.started,\n\t\tpassed = config.stats.all - config.stats.bad,\n\t\thtml = [\n\t\t\t\"Tests completed in \",\n\t\t\truntime,\n\t\t\t\" milliseconds.<br/>\",\n\t\t\t\"<span class='passed'>\",\n\t\t\tpassed,\n\t\t\t\"</span> assertions of <span class='total'>\",\n\t\t\tconfig.stats.all,\n\t\t\t\"</span> passed, <span class='failed'>\",\n\t\t\tconfig.stats.bad,\n\t\t\t\"</span> failed.\"\n\t\t].join( \"\" );\n\n\tif ( banner ) {\n\t\tbanner.className = ( config.stats.bad ? \"qunit-fail\" : \"qunit-pass\" );\n\t}\n\n\tif ( tests ) {\n\t\tid( \"qunit-testresult\" ).innerHTML = html;\n\t}\n\n\tif ( config.altertitle && typeof document !== \"undefined\" && document.title ) {\n\t\t// show ✖ for good, ✔ for bad suite result in title\n\t\t// use escape sequences in case file gets loaded with non-utf-8-charset\n\t\tdocument.title = [\n\t\t\t( config.stats.bad ? \"\\u2716\" : \"\\u2714\" ),\n\t\t\tdocument.title.replace( /^[\\u2714\\u2716] /i, \"\" )\n\t\t].join( \" \" );\n\t}\n\n\t// clear own sessionStorage items if all tests passed\n\tif ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) {\n\t\t// `key` & `i` initialized at top of scope\n\t\tfor ( i = 0; i < sessionStorage.length; i++ ) {\n\t\t\tkey = sessionStorage.key( i++ );\n\t\t\tif ( key.indexOf( \"qunit-test-\" ) === 0 ) {\n\t\t\t\tsessionStorage.removeItem( key );\n\t\t\t}\n\t\t}\n\t}\n\n\t// scroll back to top to show results\n\tif ( window.scrollTo ) {\n\t\twindow.scrollTo(0, 0);\n\t}\n\n\trunLoggingCallbacks( \"done\", QUnit, {\n\t\tfailed: config.stats.bad,\n\t\tpassed: passed,\n\t\ttotal: config.stats.all,\n\t\truntime: runtime\n\t});\n}\n\n/** @return Boolean: true if this test should be ran */\nfunction validTest( test ) {\n\tvar include,\n\t\tfilter = config.filter && config.filter.toLowerCase(),\n\t\tmodule = config.module && config.module.toLowerCase(),\n\t\tfullName = (test.module + \": \" + test.testName).toLowerCase();\n\n\t// Internally-generated tests are always valid\n\tif ( test.callback && test.callback.validTest === validTest ) {\n\t\tdelete test.callback.validTest;\n\t\treturn true;\n\t}\n\n\tif ( config.testNumber ) {\n\t\treturn test.testNumber === config.testNumber;\n\t}\n\n\tif ( module && ( !test.module || test.module.toLowerCase() !== module ) ) {\n\t\treturn false;\n\t}\n\n\tif ( !filter ) {\n\t\treturn true;\n\t}\n\n\tinclude = filter.charAt( 0 ) !== \"!\";\n\tif ( !include ) {\n\t\tfilter = filter.slice( 1 );\n\t}\n\n\t// If the filter matches, we need to honour include\n\tif ( fullName.indexOf( filter ) !== -1 ) {\n\t\treturn include;\n\t}\n\n\t// Otherwise, do the opposite\n\treturn !include;\n}\n\n// so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions)\n// Later Safari and IE10 are supposed to support error.stack as well\n// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack\nfunction extractStacktrace( e, offset ) {\n\toffset = offset === undefined ? 3 : offset;\n\n\tvar stack, include, i;\n\n\tif ( e.stacktrace ) {\n\t\t// Opera\n\t\treturn e.stacktrace.split( \"\\n\" )[ offset + 3 ];\n\t} else if ( e.stack ) {\n\t\t// Firefox, Chrome\n\t\tstack = e.stack.split( \"\\n\" );\n\t\tif (/^error$/i.test( stack[0] ) ) {\n\t\t\tstack.shift();\n\t\t}\n\t\tif ( fileName ) {\n\t\t\tinclude = [];\n\t\t\tfor ( i = offset; i < stack.length; i++ ) {\n\t\t\t\tif ( stack[ i ].indexOf( fileName ) !== -1 ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tinclude.push( stack[ i ] );\n\t\t\t}\n\t\t\tif ( include.length ) {\n\t\t\t\treturn include.join( \"\\n\" );\n\t\t\t}\n\t\t}\n\t\treturn stack[ offset ];\n\t} else if ( e.sourceURL ) {\n\t\t// Safari, PhantomJS\n\t\t// hopefully one day Safari provides actual stacktraces\n\t\t// exclude useless self-reference for generated Error objects\n\t\tif ( /qunit.js$/.test( e.sourceURL ) ) {\n\t\t\treturn;\n\t\t}\n\t\t// for actual exceptions, this is useful\n\t\treturn e.sourceURL + \":\" + e.line;\n\t}\n}\nfunction sourceFromStacktrace( offset ) {\n\ttry {\n\t\tthrow new Error();\n\t} catch ( e ) {\n\t\treturn extractStacktrace( e, offset );\n\t}\n}\n\n/**\n * Escape text for attribute or text content.\n */\nfunction escapeText( s ) {\n\tif ( !s ) {\n\t\treturn \"\";\n\t}\n\ts = s + \"\";\n\t// Both single quotes and double quotes (for attributes)\n\treturn s.replace( /['\"<>&]/g, function( s ) {\n\t\tswitch( s ) {\n\t\t\tcase '\\'':\n\t\t\t\treturn '&#039;';\n\t\t\tcase '\"':\n\t\t\t\treturn '&quot;';\n\t\t\tcase '<':\n\t\t\t\treturn '&lt;';\n\t\t\tcase '>':\n\t\t\t\treturn '&gt;';\n\t\t\tcase '&':\n\t\t\t\treturn '&amp;';\n\t\t}\n\t});\n}\n\nfunction synchronize( callback, last ) {\n\tconfig.queue.push( callback );\n\n\tif ( config.autorun && !config.blocking ) {\n\t\tprocess( last );\n\t}\n}\n\nfunction process( last ) {\n\tfunction next() {\n\t\tprocess( last );\n\t}\n\tvar start = new Date().getTime();\n\tconfig.depth = config.depth ? config.depth + 1 : 1;\n\n\twhile ( config.queue.length && !config.blocking ) {\n\t\tif ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) {\n\t\t\tconfig.queue.shift()();\n\t\t} else {\n\t\t\twindow.setTimeout( next, 13 );\n\t\t\tbreak;\n\t\t}\n\t}\n\tconfig.depth--;\n\tif ( last && !config.blocking && !config.queue.length && config.depth === 0 ) {\n\t\tdone();\n\t}\n}\n\nfunction saveGlobal() {\n\tconfig.pollution = [];\n\n\tif ( config.noglobals ) {\n\t\tfor ( var key in window ) {\n\t\t\t// in Opera sometimes DOM element ids show up here, ignore them\n\t\t\tif ( !hasOwn.call( window, key ) || /^qunit-test-output/.test( key ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconfig.pollution.push( key );\n\t\t}\n\t}\n}\n\nfunction checkPollution() {\n\tvar newGlobals,\n\t\tdeletedGlobals,\n\t\told = config.pollution;\n\n\tsaveGlobal();\n\n\tnewGlobals = diff( config.pollution, old );\n\tif ( newGlobals.length > 0 ) {\n\t\tQUnit.pushFailure( \"Introduced global variable(s): \" + newGlobals.join(\", \") );\n\t}\n\n\tdeletedGlobals = diff( old, config.pollution );\n\tif ( deletedGlobals.length > 0 ) {\n\t\tQUnit.pushFailure( \"Deleted global variable(s): \" + deletedGlobals.join(\", \") );\n\t}\n}\n\n// returns a new Array with the elements that are in a but not in b\nfunction diff( a, b ) {\n\tvar i, j,\n\t\tresult = a.slice();\n\n\tfor ( i = 0; i < result.length; i++ ) {\n\t\tfor ( j = 0; j < b.length; j++ ) {\n\t\t\tif ( result[i] === b[j] ) {\n\t\t\t\tresult.splice( i, 1 );\n\t\t\t\ti--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction extend( a, b ) {\n\tfor ( var prop in b ) {\n\t\tif ( b[ prop ] === undefined ) {\n\t\t\tdelete a[ prop ];\n\n\t\t// Avoid \"Member not found\" error in IE8 caused by setting window.constructor\n\t\t} else if ( prop !== \"constructor\" || a !== window ) {\n\t\t\ta[ prop ] = b[ prop ];\n\t\t}\n\t}\n\n\treturn a;\n}\n\n/**\n * @param {HTMLElement} elem\n * @param {string} type\n * @param {Function} fn\n */\nfunction addEvent( elem, type, fn ) {\n\t// Standards-based browsers\n\tif ( elem.addEventListener ) {\n\t\telem.addEventListener( type, fn, false );\n\t// IE\n\t} else {\n\t\telem.attachEvent( \"on\" + type, fn );\n\t}\n}\n\n/**\n * @param {Array|NodeList} elems\n * @param {string} type\n * @param {Function} fn\n */\nfunction addEvents( elems, type, fn ) {\n\tvar i = elems.length;\n\twhile ( i-- ) {\n\t\taddEvent( elems[i], type, fn );\n\t}\n}\n\nfunction hasClass( elem, name ) {\n\treturn (\" \" + elem.className + \" \").indexOf(\" \" + name + \" \") > -1;\n}\n\nfunction addClass( elem, name ) {\n\tif ( !hasClass( elem, name ) ) {\n\t\telem.className += (elem.className ? \" \" : \"\") + name;\n\t}\n}\n\nfunction removeClass( elem, name ) {\n\tvar set = \" \" + elem.className + \" \";\n\t// Class name may appear multiple times\n\twhile ( set.indexOf(\" \" + name + \" \") > -1 ) {\n\t\tset = set.replace(\" \" + name + \" \" , \" \");\n\t}\n\t// If possible, trim it for prettiness, but not neccecarily\n\telem.className = window.jQuery ? jQuery.trim( set ) : ( set.trim ? set.trim() : set );\n}\n\nfunction id( name ) {\n\treturn !!( typeof document !== \"undefined\" && document && document.getElementById ) &&\n\t\tdocument.getElementById( name );\n}\n\nfunction registerLoggingCallback( key ) {\n\treturn function( callback ) {\n\t\tconfig[key].push( callback );\n\t};\n}\n\n// Supports deprecated method of completely overwriting logging callbacks\nfunction runLoggingCallbacks( key, scope, args ) {\n\tvar i, callbacks;\n\tif ( QUnit.hasOwnProperty( key ) ) {\n\t\tQUnit[ key ].call(scope, args );\n\t} else {\n\t\tcallbacks = config[ key ];\n\t\tfor ( i = 0; i < callbacks.length; i++ ) {\n\t\t\tcallbacks[ i ].call( scope, args );\n\t\t}\n\t}\n}\n\n// Test for equality any JavaScript type.\n// Author: Philippe Rathé <prathe@gmail.com>\nQUnit.equiv = (function() {\n\n\t// Call the o related callback with the given arguments.\n\tfunction bindCallbacks( o, callbacks, args ) {\n\t\tvar prop = QUnit.objectType( o );\n\t\tif ( prop ) {\n\t\t\tif ( QUnit.objectType( callbacks[ prop ] ) === \"function\" ) {\n\t\t\t\treturn callbacks[ prop ].apply( callbacks, args );\n\t\t\t} else {\n\t\t\t\treturn callbacks[ prop ]; // or undefined\n\t\t\t}\n\t\t}\n\t}\n\n\t// the real equiv function\n\tvar innerEquiv,\n\t\t// stack to decide between skip/abort functions\n\t\tcallers = [],\n\t\t// stack to avoiding loops from circular referencing\n\t\tparents = [],\n\t\tparentsB = [],\n\n\t\tgetProto = Object.getPrototypeOf || function ( obj ) {\n\t\t\treturn obj.__proto__;\n\t\t},\n\t\tcallbacks = (function () {\n\n\t\t\t// for string, boolean, number and null\n\t\t\tfunction useStrictEquality( b, a ) {\n\t\t\t\t/*jshint eqeqeq:false */\n\t\t\t\tif ( b instanceof a.constructor || a instanceof b.constructor ) {\n\t\t\t\t\t// to catch short annotaion VS 'new' annotation of a\n\t\t\t\t\t// declaration\n\t\t\t\t\t// e.g. var i = 1;\n\t\t\t\t\t// var j = new Number(1);\n\t\t\t\t\treturn a == b;\n\t\t\t\t} else {\n\t\t\t\t\treturn a === b;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t\"string\": useStrictEquality,\n\t\t\t\t\"boolean\": useStrictEquality,\n\t\t\t\t\"number\": useStrictEquality,\n\t\t\t\t\"null\": useStrictEquality,\n\t\t\t\t\"undefined\": useStrictEquality,\n\n\t\t\t\t\"nan\": function( b ) {\n\t\t\t\t\treturn isNaN( b );\n\t\t\t\t},\n\n\t\t\t\t\"date\": function( b, a ) {\n\t\t\t\t\treturn QUnit.objectType( b ) === \"date\" && a.valueOf() === b.valueOf();\n\t\t\t\t},\n\n\t\t\t\t\"regexp\": function( b, a ) {\n\t\t\t\t\treturn QUnit.objectType( b ) === \"regexp\" &&\n\t\t\t\t\t\t// the regex itself\n\t\t\t\t\t\ta.source === b.source &&\n\t\t\t\t\t\t// and its modifers\n\t\t\t\t\t\ta.global === b.global &&\n\t\t\t\t\t\t// (gmi) ...\n\t\t\t\t\t\ta.ignoreCase === b.ignoreCase &&\n\t\t\t\t\t\ta.multiline === b.multiline &&\n\t\t\t\t\t\ta.sticky === b.sticky;\n\t\t\t\t},\n\n\t\t\t\t// - skip when the property is a method of an instance (OOP)\n\t\t\t\t// - abort otherwise,\n\t\t\t\t// initial === would have catch identical references anyway\n\t\t\t\t\"function\": function() {\n\t\t\t\t\tvar caller = callers[callers.length - 1];\n\t\t\t\t\treturn caller !== Object && typeof caller !== \"undefined\";\n\t\t\t\t},\n\n\t\t\t\t\"array\": function( b, a ) {\n\t\t\t\t\tvar i, j, len, loop, aCircular, bCircular;\n\n\t\t\t\t\t// b could be an object literal here\n\t\t\t\t\tif ( QUnit.objectType( b ) !== \"array\" ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\tlen = a.length;\n\t\t\t\t\tif ( len !== b.length ) {\n\t\t\t\t\t\t// safe and faster\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// track reference to avoid circular references\n\t\t\t\t\tparents.push( a );\n\t\t\t\t\tparentsB.push( b );\n\t\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\t\tloop = false;\n\t\t\t\t\t\tfor ( j = 0; j < parents.length; j++ ) {\n\t\t\t\t\t\t\taCircular = parents[j] === a[i];\n\t\t\t\t\t\t\tbCircular = parentsB[j] === b[i];\n\t\t\t\t\t\t\tif ( aCircular || bCircular ) {\n\t\t\t\t\t\t\t\tif ( a[i] === b[i] || aCircular && bCircular ) {\n\t\t\t\t\t\t\t\t\tloop = true;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tparents.pop();\n\t\t\t\t\t\t\t\t\tparentsB.pop();\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( !loop && !innerEquiv(a[i], b[i]) ) {\n\t\t\t\t\t\t\tparents.pop();\n\t\t\t\t\t\t\tparentsB.pop();\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tparents.pop();\n\t\t\t\t\tparentsB.pop();\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\n\t\t\t\t\"object\": function( b, a ) {\n\t\t\t\t\tvar i, j, loop, aCircular, bCircular,\n\t\t\t\t\t\t// Default to true\n\t\t\t\t\t\teq = true,\n\t\t\t\t\t\taProperties = [],\n\t\t\t\t\t\tbProperties = [];\n\n\t\t\t\t\t// comparing constructors is more strict than using\n\t\t\t\t\t// instanceof\n\t\t\t\t\tif ( a.constructor !== b.constructor ) {\n\t\t\t\t\t\t// Allow objects with no prototype to be equivalent to\n\t\t\t\t\t\t// objects with Object as their constructor.\n\t\t\t\t\t\tif ( !(( getProto(a) === null && getProto(b) === Object.prototype ) ||\n\t\t\t\t\t\t\t( getProto(b) === null && getProto(a) === Object.prototype ) ) ) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// stack constructor before traversing properties\n\t\t\t\t\tcallers.push( a.constructor );\n\n\t\t\t\t\t// track reference to avoid circular references\n\t\t\t\t\tparents.push( a );\n\t\t\t\t\tparentsB.push( b );\n\n\t\t\t\t\t// be strict: don't ensures hasOwnProperty and go deep\n\t\t\t\t\tfor ( i in a ) {\n\t\t\t\t\t\tloop = false;\n\t\t\t\t\t\tfor ( j = 0; j < parents.length; j++ ) {\n\t\t\t\t\t\t\taCircular = parents[j] === a[i];\n\t\t\t\t\t\t\tbCircular = parentsB[j] === b[i];\n\t\t\t\t\t\t\tif ( aCircular || bCircular ) {\n\t\t\t\t\t\t\t\tif ( a[i] === b[i] || aCircular && bCircular ) {\n\t\t\t\t\t\t\t\t\tloop = true;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\teq = false;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\taProperties.push(i);\n\t\t\t\t\t\tif ( !loop && !innerEquiv(a[i], b[i]) ) {\n\t\t\t\t\t\t\teq = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tparents.pop();\n\t\t\t\t\tparentsB.pop();\n\t\t\t\t\tcallers.pop(); // unstack, we are done\n\n\t\t\t\t\tfor ( i in b ) {\n\t\t\t\t\t\tbProperties.push( i ); // collect b's properties\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensures identical properties name\n\t\t\t\t\treturn eq && innerEquiv( aProperties.sort(), bProperties.sort() );\n\t\t\t\t}\n\t\t\t};\n\t\t}());\n\n\tinnerEquiv = function() { // can take multiple arguments\n\t\tvar args = [].slice.apply( arguments );\n\t\tif ( args.length < 2 ) {\n\t\t\treturn true; // end transition\n\t\t}\n\n\t\treturn (function( a, b ) {\n\t\t\tif ( a === b ) {\n\t\t\t\treturn true; // catch the most you can\n\t\t\t} else if ( a === null || b === null || typeof a === \"undefined\" ||\n\t\t\t\t\ttypeof b === \"undefined\" ||\n\t\t\t\t\tQUnit.objectType(a) !== QUnit.objectType(b) ) {\n\t\t\t\treturn false; // don't lose time with error prone cases\n\t\t\t} else {\n\t\t\t\treturn bindCallbacks(a, callbacks, [ b, a ]);\n\t\t\t}\n\n\t\t\t// apply transition with (1..n) arguments\n\t\t}( args[0], args[1] ) && arguments.callee.apply( this, args.splice(1, args.length - 1 )) );\n\t};\n\n\treturn innerEquiv;\n}());\n\n/**\n * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com |\n * http://flesler.blogspot.com Licensed under BSD\n * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008\n *\n * @projectDescription Advanced and extensible data dumping for Javascript.\n * @version 1.0.0\n * @author Ariel Flesler\n * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}\n */\nQUnit.jsDump = (function() {\n\tfunction quote( str ) {\n\t\treturn '\"' + str.toString().replace( /\"/g, '\\\\\"' ) + '\"';\n\t}\n\tfunction literal( o ) {\n\t\treturn o + \"\";\n\t}\n\tfunction join( pre, arr, post ) {\n\t\tvar s = jsDump.separator(),\n\t\t\tbase = jsDump.indent(),\n\t\t\tinner = jsDump.indent(1);\n\t\tif ( arr.join ) {\n\t\t\tarr = arr.join( \",\" + s + inner );\n\t\t}\n\t\tif ( !arr ) {\n\t\t\treturn pre + post;\n\t\t}\n\t\treturn [ pre, inner + arr, base + post ].join(s);\n\t}\n\tfunction array( arr, stack ) {\n\t\tvar i = arr.length, ret = new Array(i);\n\t\tthis.up();\n\t\twhile ( i-- ) {\n\t\t\tret[i] = this.parse( arr[i] , undefined , stack);\n\t\t}\n\t\tthis.down();\n\t\treturn join( \"[\", ret, \"]\" );\n\t}\n\n\tvar reName = /^function (\\w+)/,\n\t\tjsDump = {\n\t\t\t// type is used mostly internally, you can fix a (custom)type in advance\n\t\t\tparse: function( obj, type, stack ) {\n\t\t\t\tstack = stack || [ ];\n\t\t\t\tvar inStack, res,\n\t\t\t\t\tparser = this.parsers[ type || this.typeOf(obj) ];\n\n\t\t\t\ttype = typeof parser;\n\t\t\t\tinStack = inArray( obj, stack );\n\n\t\t\t\tif ( inStack !== -1 ) {\n\t\t\t\t\treturn \"recursion(\" + (inStack - stack.length) + \")\";\n\t\t\t\t}\n\t\t\t\tif ( type === \"function\" )  {\n\t\t\t\t\tstack.push( obj );\n\t\t\t\t\tres = parser.call( this, obj, stack );\n\t\t\t\t\tstack.pop();\n\t\t\t\t\treturn res;\n\t\t\t\t}\n\t\t\t\treturn ( type === \"string\" ) ? parser : this.parsers.error;\n\t\t\t},\n\t\t\ttypeOf: function( obj ) {\n\t\t\t\tvar type;\n\t\t\t\tif ( obj === null ) {\n\t\t\t\t\ttype = \"null\";\n\t\t\t\t} else if ( typeof obj === \"undefined\" ) {\n\t\t\t\t\ttype = \"undefined\";\n\t\t\t\t} else if ( QUnit.is( \"regexp\", obj) ) {\n\t\t\t\t\ttype = \"regexp\";\n\t\t\t\t} else if ( QUnit.is( \"date\", obj) ) {\n\t\t\t\t\ttype = \"date\";\n\t\t\t\t} else if ( QUnit.is( \"function\", obj) ) {\n\t\t\t\t\ttype = \"function\";\n\t\t\t\t} else if ( typeof obj.setInterval !== undefined && typeof obj.document !== \"undefined\" && typeof obj.nodeType === \"undefined\" ) {\n\t\t\t\t\ttype = \"window\";\n\t\t\t\t} else if ( obj.nodeType === 9 ) {\n\t\t\t\t\ttype = \"document\";\n\t\t\t\t} else if ( obj.nodeType ) {\n\t\t\t\t\ttype = \"node\";\n\t\t\t\t} else if (\n\t\t\t\t\t// native arrays\n\t\t\t\t\ttoString.call( obj ) === \"[object Array]\" ||\n\t\t\t\t\t// NodeList objects\n\t\t\t\t\t( typeof obj.length === \"number\" && typeof obj.item !== \"undefined\" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === \"undefined\" ) ) )\n\t\t\t\t) {\n\t\t\t\t\ttype = \"array\";\n\t\t\t\t} else if ( obj.constructor === Error.prototype.constructor ) {\n\t\t\t\t\ttype = \"error\";\n\t\t\t\t} else {\n\t\t\t\t\ttype = typeof obj;\n\t\t\t\t}\n\t\t\t\treturn type;\n\t\t\t},\n\t\t\tseparator: function() {\n\t\t\t\treturn this.multiline ?\tthis.HTML ? \"<br />\" : \"\\n\" : this.HTML ? \"&nbsp;\" : \" \";\n\t\t\t},\n\t\t\t// extra can be a number, shortcut for increasing-calling-decreasing\n\t\t\tindent: function( extra ) {\n\t\t\t\tif ( !this.multiline ) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t\tvar chr = this.indentChar;\n\t\t\t\tif ( this.HTML ) {\n\t\t\t\t\tchr = chr.replace( /\\t/g, \"   \" ).replace( / /g, \"&nbsp;\" );\n\t\t\t\t}\n\t\t\t\treturn new Array( this._depth_ + (extra||0) ).join(chr);\n\t\t\t},\n\t\t\tup: function( a ) {\n\t\t\t\tthis._depth_ += a || 1;\n\t\t\t},\n\t\t\tdown: function( a ) {\n\t\t\t\tthis._depth_ -= a || 1;\n\t\t\t},\n\t\t\tsetParser: function( name, parser ) {\n\t\t\t\tthis.parsers[name] = parser;\n\t\t\t},\n\t\t\t// The next 3 are exposed so you can use them\n\t\t\tquote: quote,\n\t\t\tliteral: literal,\n\t\t\tjoin: join,\n\t\t\t//\n\t\t\t_depth_: 1,\n\t\t\t// This is the list of parsers, to modify them, use jsDump.setParser\n\t\t\tparsers: {\n\t\t\t\twindow: \"[Window]\",\n\t\t\t\tdocument: \"[Document]\",\n\t\t\t\terror: function(error) {\n\t\t\t\t\treturn \"Error(\\\"\" + error.message + \"\\\")\";\n\t\t\t\t},\n\t\t\t\tunknown: \"[Unknown]\",\n\t\t\t\t\"null\": \"null\",\n\t\t\t\t\"undefined\": \"undefined\",\n\t\t\t\t\"function\": function( fn ) {\n\t\t\t\t\tvar ret = \"function\",\n\t\t\t\t\t\t// functions never have name in IE\n\t\t\t\t\t\tname = \"name\" in fn ? fn.name : (reName.exec(fn) || [])[1];\n\n\t\t\t\t\tif ( name ) {\n\t\t\t\t\t\tret += \" \" + name;\n\t\t\t\t\t}\n\t\t\t\t\tret += \"( \";\n\n\t\t\t\t\tret = [ ret, QUnit.jsDump.parse( fn, \"functionArgs\" ), \"){\" ].join( \"\" );\n\t\t\t\t\treturn join( ret, QUnit.jsDump.parse(fn,\"functionCode\" ), \"}\" );\n\t\t\t\t},\n\t\t\t\tarray: array,\n\t\t\t\tnodelist: array,\n\t\t\t\t\"arguments\": array,\n\t\t\t\tobject: function( map, stack ) {\n\t\t\t\t\tvar ret = [ ], keys, key, val, i;\n\t\t\t\t\tQUnit.jsDump.up();\n\t\t\t\t\tkeys = [];\n\t\t\t\t\tfor ( key in map ) {\n\t\t\t\t\t\tkeys.push( key );\n\t\t\t\t\t}\n\t\t\t\t\tkeys.sort();\n\t\t\t\t\tfor ( i = 0; i < keys.length; i++ ) {\n\t\t\t\t\t\tkey = keys[ i ];\n\t\t\t\t\t\tval = map[ key ];\n\t\t\t\t\t\tret.push( QUnit.jsDump.parse( key, \"key\" ) + \": \" + QUnit.jsDump.parse( val, undefined, stack ) );\n\t\t\t\t\t}\n\t\t\t\t\tQUnit.jsDump.down();\n\t\t\t\t\treturn join( \"{\", ret, \"}\" );\n\t\t\t\t},\n\t\t\t\tnode: function( node ) {\n\t\t\t\t\tvar len, i, val,\n\t\t\t\t\t\topen = QUnit.jsDump.HTML ? \"&lt;\" : \"<\",\n\t\t\t\t\t\tclose = QUnit.jsDump.HTML ? \"&gt;\" : \">\",\n\t\t\t\t\t\ttag = node.nodeName.toLowerCase(),\n\t\t\t\t\t\tret = open + tag,\n\t\t\t\t\t\tattrs = node.attributes;\n\n\t\t\t\t\tif ( attrs ) {\n\t\t\t\t\t\tfor ( i = 0, len = attrs.length; i < len; i++ ) {\n\t\t\t\t\t\t\tval = attrs[i].nodeValue;\n\t\t\t\t\t\t\t// IE6 includes all attributes in .attributes, even ones not explicitly set.\n\t\t\t\t\t\t\t// Those have values like undefined, null, 0, false, \"\" or \"inherit\".\n\t\t\t\t\t\t\tif ( val && val !== \"inherit\" ) {\n\t\t\t\t\t\t\t\tret += \" \" + attrs[i].nodeName + \"=\" + QUnit.jsDump.parse( val, \"attribute\" );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tret += close;\n\n\t\t\t\t\t// Show content of TextNode or CDATASection\n\t\t\t\t\tif ( node.nodeType === 3 || node.nodeType === 4 ) {\n\t\t\t\t\t\tret += node.nodeValue;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn ret + open + \"/\" + tag + close;\n\t\t\t\t},\n\t\t\t\t// function calls it internally, it's the arguments part of the function\n\t\t\t\tfunctionArgs: function( fn ) {\n\t\t\t\t\tvar args,\n\t\t\t\t\t\tl = fn.length;\n\n\t\t\t\t\tif ( !l ) {\n\t\t\t\t\t\treturn \"\";\n\t\t\t\t\t}\n\n\t\t\t\t\targs = new Array(l);\n\t\t\t\t\twhile ( l-- ) {\n\t\t\t\t\t\t// 97 is 'a'\n\t\t\t\t\t\targs[l] = String.fromCharCode(97+l);\n\t\t\t\t\t}\n\t\t\t\t\treturn \" \" + args.join( \", \" ) + \" \";\n\t\t\t\t},\n\t\t\t\t// object calls it internally, the key part of an item in a map\n\t\t\t\tkey: quote,\n\t\t\t\t// function calls it internally, it's the content of the function\n\t\t\t\tfunctionCode: \"[code]\",\n\t\t\t\t// node calls it internally, it's an html attribute value\n\t\t\t\tattribute: quote,\n\t\t\t\tstring: quote,\n\t\t\t\tdate: quote,\n\t\t\t\tregexp: literal,\n\t\t\t\tnumber: literal,\n\t\t\t\t\"boolean\": literal\n\t\t\t},\n\t\t\t// if true, entities are escaped ( <, >, \\t, space and \\n )\n\t\t\tHTML: false,\n\t\t\t// indentation unit\n\t\t\tindentChar: \"  \",\n\t\t\t// if true, items in a collection, are separated by a \\n, else just a space.\n\t\t\tmultiline: true\n\t\t};\n\n\treturn jsDump;\n}());\n\n// from jquery.js\nfunction inArray( elem, array ) {\n\tif ( array.indexOf ) {\n\t\treturn array.indexOf( elem );\n\t}\n\n\tfor ( var i = 0, length = array.length; i < length; i++ ) {\n\t\tif ( array[ i ] === elem ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\n/*\n * Javascript Diff Algorithm\n *  By John Resig (http://ejohn.org/)\n *  Modified by Chu Alan \"sprite\"\n *\n * Released under the MIT license.\n *\n * More Info:\n *  http://ejohn.org/projects/javascript-diff-algorithm/\n *\n * Usage: QUnit.diff(expected, actual)\n *\n * QUnit.diff( \"the quick brown fox jumped over\", \"the quick fox jumps over\" ) == \"the  quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over\"\n */\nQUnit.diff = (function() {\n\t/*jshint eqeqeq:false, eqnull:true */\n\tfunction diff( o, n ) {\n\t\tvar i,\n\t\t\tns = {},\n\t\t\tos = {};\n\n\t\tfor ( i = 0; i < n.length; i++ ) {\n\t\t\tif ( !hasOwn.call( ns, n[i] ) ) {\n\t\t\t\tns[ n[i] ] = {\n\t\t\t\t\trows: [],\n\t\t\t\t\to: null\n\t\t\t\t};\n\t\t\t}\n\t\t\tns[ n[i] ].rows.push( i );\n\t\t}\n\n\t\tfor ( i = 0; i < o.length; i++ ) {\n\t\t\tif ( !hasOwn.call( os, o[i] ) ) {\n\t\t\t\tos[ o[i] ] = {\n\t\t\t\t\trows: [],\n\t\t\t\t\tn: null\n\t\t\t\t};\n\t\t\t}\n\t\t\tos[ o[i] ].rows.push( i );\n\t\t}\n\n\t\tfor ( i in ns ) {\n\t\t\tif ( !hasOwn.call( ns, i ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) {\n\t\t\t\tn[ ns[i].rows[0] ] = {\n\t\t\t\t\ttext: n[ ns[i].rows[0] ],\n\t\t\t\t\trow: os[i].rows[0]\n\t\t\t\t};\n\t\t\t\to[ os[i].rows[0] ] = {\n\t\t\t\t\ttext: o[ os[i].rows[0] ],\n\t\t\t\t\trow: ns[i].rows[0]\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tfor ( i = 0; i < n.length - 1; i++ ) {\n\t\t\tif ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null &&\n\t\t\t\t\t\tn[ i + 1 ] == o[ n[i].row + 1 ] ) {\n\n\t\t\t\tn[ i + 1 ] = {\n\t\t\t\t\ttext: n[ i + 1 ],\n\t\t\t\t\trow: n[i].row + 1\n\t\t\t\t};\n\t\t\t\to[ n[i].row + 1 ] = {\n\t\t\t\t\ttext: o[ n[i].row + 1 ],\n\t\t\t\t\trow: i + 1\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tfor ( i = n.length - 1; i > 0; i-- ) {\n\t\t\tif ( n[i].text != null && n[ i - 1 ].text == null && n[i].row > 0 && o[ n[i].row - 1 ].text == null &&\n\t\t\t\t\t\tn[ i - 1 ] == o[ n[i].row - 1 ]) {\n\n\t\t\t\tn[ i - 1 ] = {\n\t\t\t\t\ttext: n[ i - 1 ],\n\t\t\t\t\trow: n[i].row - 1\n\t\t\t\t};\n\t\t\t\to[ n[i].row - 1 ] = {\n\t\t\t\t\ttext: o[ n[i].row - 1 ],\n\t\t\t\t\trow: i - 1\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\to: o,\n\t\t\tn: n\n\t\t};\n\t}\n\n\treturn function( o, n ) {\n\t\to = o.replace( /\\s+$/, \"\" );\n\t\tn = n.replace( /\\s+$/, \"\" );\n\n\t\tvar i, pre,\n\t\t\tstr = \"\",\n\t\t\tout = diff( o === \"\" ? [] : o.split(/\\s+/), n === \"\" ? [] : n.split(/\\s+/) ),\n\t\t\toSpace = o.match(/\\s+/g),\n\t\t\tnSpace = n.match(/\\s+/g);\n\n\t\tif ( oSpace == null ) {\n\t\t\toSpace = [ \" \" ];\n\t\t}\n\t\telse {\n\t\t\toSpace.push( \" \" );\n\t\t}\n\n\t\tif ( nSpace == null ) {\n\t\t\tnSpace = [ \" \" ];\n\t\t}\n\t\telse {\n\t\t\tnSpace.push( \" \" );\n\t\t}\n\n\t\tif ( out.n.length === 0 ) {\n\t\t\tfor ( i = 0; i < out.o.length; i++ ) {\n\t\t\t\tstr += \"<del>\" + out.o[i] + oSpace[i] + \"</del>\";\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif ( out.n[0].text == null ) {\n\t\t\t\tfor ( n = 0; n < out.o.length && out.o[n].text == null; n++ ) {\n\t\t\t\t\tstr += \"<del>\" + out.o[n] + oSpace[n] + \"</del>\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor ( i = 0; i < out.n.length; i++ ) {\n\t\t\t\tif (out.n[i].text == null) {\n\t\t\t\t\tstr += \"<ins>\" + out.n[i] + nSpace[i] + \"</ins>\";\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// `pre` initialized at top of scope\n\t\t\t\t\tpre = \"\";\n\n\t\t\t\t\tfor ( n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++ ) {\n\t\t\t\t\t\tpre += \"<del>\" + out.o[n] + oSpace[n] + \"</del>\";\n\t\t\t\t\t}\n\t\t\t\t\tstr += \" \" + out.n[i].text + nSpace[i] + pre;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn str;\n\t};\n}());\n\n// for CommonJS enviroments, export everything\nif ( typeof exports !== \"undefined\" ) {\n\textend( exports, QUnit );\n}\n\n// get at whatever the global object is, like window in browsers\n}( (function() {return this;}.call()) ));\n"
  },
  {
    "path": "vendor/qunit/test/.jshintrc",
    "content": "{\n\t\"predef\": [\n\t\t\"QUnit\"\n\t],\n\n\t\"smarttabs\": true,\n\n\t\"browser\": true\n}\n"
  },
  {
    "path": "vendor/qunit/test/async.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>QUnit Test Suite</title>\n\t<link rel=\"stylesheet\" href=\"../qunit/qunit.css\">\n</head>\n<body>\n\t<div id=\"qunit\"></div>\n\t<div id=\"qunit-fixture\">test markup</div>\n\t<script src=\"../qunit/qunit.js\"></script>\n\t<script>\n\tQUnit.config.autostart = false;\n\n\t// Simulate a delay in loading the tests, as when they are loaded\n\t// asynchronously using requirejs, steal, etc.\n\tsetTimeout(function() {\n\t\tvar script = document.createElement( \"script\" );\n\t\tscript.src = \"async.js\";\n\t\tdocument.getElementsByTagName( \"head\" )[0].appendChild( script );\n\n\t}, 1000);\n\t</script>\n\t<script src=\"swarminject.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "vendor/qunit/test/async.js",
    "content": "QUnit.start();\n\ntest(\"just a test\", function() {\n\texpect(1);\n\tok(true);\n});\n"
  },
  {
    "path": "vendor/qunit/test/deepEqual.js",
    "content": "module(\"equiv\");\n\n\ntest(\"Primitive types and constants\", function () {\n\tequal(QUnit.equiv(null, null), true, \"null\");\n\tequal(QUnit.equiv(null, {}), false, \"null\");\n\tequal(QUnit.equiv(null, undefined), false, \"null\");\n\tequal(QUnit.equiv(null, 0), false, \"null\");\n\tequal(QUnit.equiv(null, false), false, \"null\");\n\tequal(QUnit.equiv(null, ''), false, \"null\");\n\tequal(QUnit.equiv(null, []), false, \"null\");\n\n\tequal(QUnit.equiv(undefined, undefined), true, \"undefined\");\n\tequal(QUnit.equiv(undefined, null), false, \"undefined\");\n\tequal(QUnit.equiv(undefined, 0), false, \"undefined\");\n\tequal(QUnit.equiv(undefined, false), false, \"undefined\");\n\tequal(QUnit.equiv(undefined, {}), false, \"undefined\");\n\tequal(QUnit.equiv(undefined, []), false, \"undefined\");\n\tequal(QUnit.equiv(undefined, \"\"), false, \"undefined\");\n\n\t// Nan usually doest not equal to Nan using the '==' operator.\n\t// Only isNaN() is able to do it.\n\tequal(QUnit.equiv(0/0, 0/0), true, \"NaN\"); // NaN VS NaN\n\tequal(QUnit.equiv(1/0, 2/0), true, \"Infinity\"); // Infinity VS Infinity\n\tequal(QUnit.equiv(-1/0, 2/0), false, \"-Infinity, Infinity\"); // -Infinity VS Infinity\n\tequal(QUnit.equiv(-1/0, -2/0), true, \"-Infinity, -Infinity\"); // -Infinity VS -Infinity\n\tequal(QUnit.equiv(0/0, 1/0), false, \"NaN, Infinity\"); // Nan VS Infinity\n\tequal(QUnit.equiv(1/0, 0/0), false, \"NaN, Infinity\"); // Nan VS Infinity\n\tequal(QUnit.equiv(0/0, null), false, \"NaN\");\n\tequal(QUnit.equiv(0/0, undefined), false, \"NaN\");\n\tequal(QUnit.equiv(0/0, 0), false, \"NaN\");\n\tequal(QUnit.equiv(0/0, false), false, \"NaN\");\n\tequal(QUnit.equiv(0/0, function () {}), false, \"NaN\");\n\tequal(QUnit.equiv(1/0, null), false, \"NaN, Infinity\");\n\tequal(QUnit.equiv(1/0, undefined), false, \"NaN, Infinity\");\n\tequal(QUnit.equiv(1/0, 0), false, \"NaN, Infinity\");\n\tequal(QUnit.equiv(1/0, 1), false, \"NaN, Infinity\");\n\tequal(QUnit.equiv(1/0, false), false, \"NaN, Infinity\");\n\tequal(QUnit.equiv(1/0, true), false, \"NaN, Infinity\");\n\tequal(QUnit.equiv(1/0, function () {}), false, \"NaN, Infinity\");\n\n\tequal(QUnit.equiv(0, 0), true, \"number\");\n\tequal(QUnit.equiv(0, 1), false, \"number\");\n\tequal(QUnit.equiv(1, 0), false, \"number\");\n\tequal(QUnit.equiv(1, 1), true, \"number\");\n\tequal(QUnit.equiv(1.1, 1.1), true, \"number\");\n\tequal(QUnit.equiv(0.0000005, 0.0000005), true, \"number\");\n\tequal(QUnit.equiv(0, ''), false, \"number\");\n\tequal(QUnit.equiv(0, '0'), false, \"number\");\n\tequal(QUnit.equiv(1, '1'), false, \"number\");\n\tequal(QUnit.equiv(0, false), false, \"number\");\n\tequal(QUnit.equiv(1, true), false, \"number\");\n\n\tequal(QUnit.equiv(true, true), true, \"boolean\");\n\tequal(QUnit.equiv(true, false), false, \"boolean\");\n\tequal(QUnit.equiv(false, true), false, \"boolean\");\n\tequal(QUnit.equiv(false, 0), false, \"boolean\");\n\tequal(QUnit.equiv(false, null), false, \"boolean\");\n\tequal(QUnit.equiv(false, undefined), false, \"boolean\");\n\tequal(QUnit.equiv(true, 1), false, \"boolean\");\n\tequal(QUnit.equiv(true, null), false, \"boolean\");\n\tequal(QUnit.equiv(true, undefined), false, \"boolean\");\n\n\tequal(QUnit.equiv('', ''), true, \"string\");\n\tequal(QUnit.equiv('a', 'a'), true, \"string\");\n\tequal(QUnit.equiv(\"foobar\", \"foobar\"), true, \"string\");\n\tequal(QUnit.equiv(\"foobar\", \"foo\"), false, \"string\");\n\tequal(QUnit.equiv('', 0), false, \"string\");\n\tequal(QUnit.equiv('', false), false, \"string\");\n\tequal(QUnit.equiv('', null), false, \"string\");\n\tequal(QUnit.equiv('', undefined), false, \"string\");\n\n\t// Rename for lint validation.\n\t// We know this is bad, we are asserting whether we can coop with bad code like this.\n\tvar SafeNumber = Number, SafeString = String, SafeBoolean = Boolean, SafeObject = Object;\n\n\t// primitives vs. objects\n\n\tequal(QUnit.equiv(0, new SafeNumber()), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeNumber(), 0), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(1, new SafeNumber(1)), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeNumber(1), 1), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeNumber(0), 1), false, \"primitives vs. objects\");\n\tequal(QUnit.equiv(0, new SafeNumber(1)), false, \"primitives vs. objects\");\n\n\tequal(QUnit.equiv(new SafeString(), \"\"), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(\"\", new SafeString()), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeString(\"My String\"), \"My String\"), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(\"My String\", new SafeString(\"My String\")), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(\"Bad String\", new SafeString(\"My String\")), false, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeString(\"Bad String\"), \"My String\"), false, \"primitives vs. objects\");\n\n\tequal(QUnit.equiv(false, new SafeBoolean()), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeBoolean(), false), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(true, new SafeBoolean(true)), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeBoolean(true), true), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(true, new SafeBoolean(1)), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(false, new SafeBoolean(false)), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeBoolean(false), false), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(false, new SafeBoolean(0)), true, \"primitives vs. objects\");\n\tequal(QUnit.equiv(true, new SafeBoolean(false)), false, \"primitives vs. objects\");\n\tequal(QUnit.equiv(new SafeBoolean(false), true), false, \"primitives vs. objects\");\n\n\tequal(QUnit.equiv(new SafeObject(), {}), true, \"object literal vs. instantiation\");\n\tequal(QUnit.equiv({}, new SafeObject()), true, \"object literal vs. instantiation\");\n\tequal(QUnit.equiv(new SafeObject(), {a:1}), false, \"object literal vs. instantiation\");\n\tequal(QUnit.equiv({a:1}, new SafeObject()), false, \"object literal vs. instantiation\");\n\tequal(QUnit.equiv({a:undefined}, new SafeObject()), false, \"object literal vs. instantiation\");\n\tequal(QUnit.equiv(new SafeObject(), {a:undefined}), false, \"object literal vs. instantiation\");\n});\n\ntest(\"Objects Basics.\", function() {\n\tequal(QUnit.equiv({}, {}), true);\n\tequal(QUnit.equiv({}, null), false);\n\tequal(QUnit.equiv({}, undefined), false);\n\tequal(QUnit.equiv({}, 0), false);\n\tequal(QUnit.equiv({}, false), false);\n\n\t// This test is a hard one, it is very important\n\t// REASONS:\n\t//      1) They are of the same type \"object\"\n\t//      2) [] instanceof Object is true\n\t//      3) Their properties are the same (doesn't exists)\n\tequal(QUnit.equiv({}, []), false);\n\n\tequal(QUnit.equiv({a:1}, {a:1}), true);\n\tequal(QUnit.equiv({a:1}, {a:\"1\"}), false);\n\tequal(QUnit.equiv({a:[]}, {a:[]}), true);\n\tequal(QUnit.equiv({a:{}}, {a:null}), false);\n\tequal(QUnit.equiv({a:1}, {}), false);\n\tequal(QUnit.equiv({}, {a:1}), false);\n\n\t// Hard ones\n\tequal(QUnit.equiv({a:undefined}, {}), false);\n\tequal(QUnit.equiv({}, {a:undefined}), false);\n\tequal(QUnit.equiv(\n\t\t{\n\t\t\ta: [{ bar: undefined }]\n\t\t},\n\t\t{\n\t\t\ta: [{ bat: undefined }]\n\t\t}\n\t), false);\n\n\t// Objects with no prototype, created via Object.create(null), are used e.g. as dictionaries.\n\t// Being able to test equivalence against object literals is quite useful.\n\tif (typeof Object.create === 'function') {\n\t\tequal(QUnit.equiv(Object.create(null), {}), true, \"empty object without prototype VS empty object\");\n\n\t\tvar nonEmptyWithNoProto = Object.create(null);\n\t\tnonEmptyWithNoProto.foo = \"bar\";\n\n\t\tequal(QUnit.equiv(nonEmptyWithNoProto, { foo: \"bar\" }), true, \"object without prototype VS object\");\n\t}\n});\n\n\ntest(\"Arrays Basics.\", function() {\n\n\tequal(QUnit.equiv([], []), true);\n\n\t// May be a hard one, can invoke a crash at execution.\n\t// because their types are both \"object\" but null isn't\n\t// like a true object, it doesn't have any property at all.\n\tequal(QUnit.equiv([], null), false);\n\n\tequal(QUnit.equiv([], undefined), false);\n\tequal(QUnit.equiv([], false), false);\n\tequal(QUnit.equiv([], 0), false);\n\tequal(QUnit.equiv([], \"\"), false);\n\n\t// May be a hard one, but less hard\n\t// than {} with [] (note the order)\n\tequal(QUnit.equiv([], {}), false);\n\n\tequal(QUnit.equiv([null],[]), false);\n\tequal(QUnit.equiv([undefined],[]), false);\n\tequal(QUnit.equiv([],[null]), false);\n\tequal(QUnit.equiv([],[undefined]), false);\n\tequal(QUnit.equiv([null],[undefined]), false);\n\tequal(QUnit.equiv([[]],[[]]), true);\n\tequal(QUnit.equiv([[],[],[]],[[],[],[]]), true);\n\tequal(QUnit.equiv(\n\t\t\t\t\t\t\t[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],\n\t\t\t\t\t\t\t[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]),\n\t\t\t\t\t\t\ttrue);\n\tequal(QUnit.equiv(\n\t\t\t\t\t\t\t[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],\n\t\t\t\t\t\t\t[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // shorter\n\t\t\t\t\t\t\tfalse);\n\tequal(QUnit.equiv(\n\t\t\t\t\t\t\t[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],\n\t\t\t\t\t\t\t[[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // deepest element not an array\n\t\t\t\t\t\t\tfalse);\n\n\t// same multidimensional\n\tequal(QUnit.equiv(\n\t\t\t\t\t\t\t[1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t\t1,2,3,4,5,[\n\t\t\t\t\t\t\t\t\t\t[6,7,8,9, [\n\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],1,2,3,4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t],4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t]]],\n\t\t\t\t\t\t\t[1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t\t1,2,3,4,5,[\n\t\t\t\t\t\t\t\t\t\t[6,7,8,9, [\n\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],1,2,3,4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t],4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t]]]),\n\t\t\t\t\t\t\ttrue, \"Multidimensional\");\n\n\t// different multidimensional\n\tequal(QUnit.equiv(\n\t\t\t\t\t\t\t[1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t\t1,2,3,4,5,[\n\t\t\t\t\t\t\t\t\t\t[6,7,8,9, [\n\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],1,2,3,4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t],4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t]]],\n\t\t\t\t\t\t\t[1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t\t1,2,3,4,5,[\n\t\t\t\t\t\t\t\t\t\t[6,7,8,9, [\n\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'1',2,3,4,[                 // string instead of number\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],1,2,3,4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t],4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t]]]),\n\t\t\t\t\t\t\tfalse, \"Multidimensional\");\n\n\t// different multidimensional\n\tequal(QUnit.equiv(\n\t\t\t\t\t\t\t[1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t\t1,2,3,4,5,[\n\t\t\t\t\t\t\t\t\t\t[6,7,8,9, [\n\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],1,2,3,4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t],4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t]]],\n\t\t\t\t\t\t\t[1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9, [\n\t\t\t\t\t\t\t\t\t1,2,3,4,5,[\n\t\t\t\t\t\t\t\t\t\t[6,7,8,9, [\n\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t2,3,[                   // missing an element (4)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t1,2,3,4,5,6,7,8,9,[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],1,2,3,4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t],4,5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7,8,9\n\t\t\t\t\t\t\t\t\t\t\t\t],5,6,7\n\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t]]]),\n\t\t\t\t\t\t\tfalse, \"Multidimensional\");\n});\n\ntest(\"Functions.\", function() {\n\tvar f0 = function () {};\n\tvar f1 = function () {};\n\n\t// f2 and f3 have the same code, formatted differently\n\tvar f2 = function () {var i = 0;};\n\tvar f3 = function () {\n\t\t/*jshint asi:true */\n\t\tvar i = 0 // this comment and no semicoma as difference\n\t};\n\n\tequal(QUnit.equiv(function() {}, function() {}), false, \"Anonymous functions\"); // exact source code\n\tequal(QUnit.equiv(function() {}, function() {return true;}), false, \"Anonymous functions\");\n\n\tequal(QUnit.equiv(f0, f0), true, \"Function references\"); // same references\n\tequal(QUnit.equiv(f0, f1), false, \"Function references\"); // exact source code, different references\n\tequal(QUnit.equiv(f2, f3), false, \"Function references\"); // equivalent source code, different references\n\tequal(QUnit.equiv(f1, f2), false, \"Function references\"); // different source code, different references\n\tequal(QUnit.equiv(function() {}, true), false);\n\tequal(QUnit.equiv(function() {}, undefined), false);\n\tequal(QUnit.equiv(function() {}, null), false);\n\tequal(QUnit.equiv(function() {}, {}), false);\n});\n\n\ntest(\"Date instances.\", function() {\n\t// Date, we don't need to test Date.parse() because it returns a number.\n\t// Only test the Date instances by setting them a fix date.\n\t// The date use is midnight January 1, 1970\n\n\tvar d1 = new Date();\n\td1.setTime(0); // fix the date\n\n\tvar d2 = new Date();\n\td2.setTime(0); // fix the date\n\n\tvar d3 = new Date(); // The very now\n\n\t// Anyway their types differs, just in case the code fails in the order in which it deals with date\n\tequal(QUnit.equiv(d1, 0), false); // d1.valueOf() returns 0, but d1 and 0 are different\n\t// test same values date and different instances equality\n\tequal(QUnit.equiv(d1, d2), true);\n\t// test different date and different instances difference\n\tequal(QUnit.equiv(d1, d3), false);\n});\n\n\ntest(\"RegExp.\", function() {\n\t// Must test cases that imply those traps:\n\t// var a = /./;\n\t// a instanceof Object;        // Oops\n\t// a instanceof RegExp;        // Oops\n\t// typeof a === \"function\";    // Oops, false in IE and Opera, true in FF and Safari (\"object\")\n\n\t// Tests same regex with same modifiers in different order\n\tvar r = /foo/;\n\tvar r5 = /foo/gim;\n\tvar r6 = /foo/gmi;\n\tvar r7 = /foo/igm;\n\tvar r8 = /foo/img;\n\tvar r9 = /foo/mig;\n\tvar r10 = /foo/mgi;\n\tvar ri1 = /foo/i;\n\tvar ri2 = /foo/i;\n\tvar rm1 = /foo/m;\n\tvar rm2 = /foo/m;\n\tvar rg1 = /foo/g;\n\tvar rg2 = /foo/g;\n\n\tequal(QUnit.equiv(r5, r6), true, \"Modifier order\");\n\tequal(QUnit.equiv(r5, r7), true, \"Modifier order\");\n\tequal(QUnit.equiv(r5, r8), true, \"Modifier order\");\n\tequal(QUnit.equiv(r5, r9), true, \"Modifier order\");\n\tequal(QUnit.equiv(r5, r10), true, \"Modifier order\");\n\tequal(QUnit.equiv(r, r5), false, \"Modifier\");\n\n\tequal(QUnit.equiv(ri1, ri2), true, \"Modifier\");\n\tequal(QUnit.equiv(r, ri1), false, \"Modifier\");\n\tequal(QUnit.equiv(ri1, rm1), false, \"Modifier\");\n\tequal(QUnit.equiv(r, rm1), false, \"Modifier\");\n\tequal(QUnit.equiv(rm1, ri1), false, \"Modifier\");\n\tequal(QUnit.equiv(rm1, rm2), true, \"Modifier\");\n\tequal(QUnit.equiv(rg1, rm1), false, \"Modifier\");\n\tequal(QUnit.equiv(rm1, rg1), false, \"Modifier\");\n\tequal(QUnit.equiv(rg1, rg2), true, \"Modifier\");\n\n\t// Different regex, same modifiers\n\tvar r11 = /[a-z]/gi;\n\tvar r13 = /[0-9]/gi; // oops! different\n\tequal(QUnit.equiv(r11, r13), false, \"Regex pattern\");\n\n\tvar r14 = /0/ig;\n\tvar r15 = /\"0\"/ig; // oops! different\n\tequal(QUnit.equiv(r14, r15), false, \"Regex pattern\");\n\n\tvar r1 = /[\\n\\r\\u2028\\u2029]/g;\n\tvar r2 = /[\\n\\r\\u2028\\u2029]/g;\n\tvar r3 = /[\\n\\r\\u2028\\u2028]/g; // differs from r1\n\tvar r4 = /[\\n\\r\\u2028\\u2029]/;  // differs from r1\n\n\tequal(QUnit.equiv(r1, r2), true, \"Regex pattern\");\n\tequal(QUnit.equiv(r1, r3), false, \"Regex pattern\");\n\tequal(QUnit.equiv(r1, r4), false, \"Regex pattern\");\n\n\t// More complex regex\n\tvar regex1 = \"^[-_.a-z0-9]+@([-_a-z0-9]+\\\\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$\";\n\tvar regex2 = \"^[-_.a-z0-9]+@([-_a-z0-9]+\\\\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$\";\n\t// regex 3 is different: '.' not escaped\n\tvar regex3 = \"^[-_.a-z0-9]+@([-_a-z0-9]+.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$\";\n\n\tvar r21 = new RegExp(regex1);\n\tvar r22 = new RegExp(regex2);\n\tvar r23 = new RegExp(regex3); // diff from r21, not same pattern\n\tvar r23a = new RegExp(regex3, \"gi\"); // diff from r23, not same modifier\n\tvar r24a = new RegExp(regex3, \"ig\"); // same as r23a\n\n\tequal(QUnit.equiv(r21, r22), true, \"Complex Regex\");\n\tequal(QUnit.equiv(r21, r23), false, \"Complex Regex\");\n\tequal(QUnit.equiv(r23, r23a), false, \"Complex Regex\");\n\tequal(QUnit.equiv(r23a, r24a), true, \"Complex Regex\");\n\n\t// typeof r1 is \"function\" in some browsers and \"object\" in others so we must cover this test\n\tvar re = / /;\n\tequal(QUnit.equiv(re, function () {}), false, \"Regex internal\");\n\tequal(QUnit.equiv(re, {}), false, \"Regex internal\");\n});\n\n\ntest(\"Complex Objects.\", function() {\n\n\tfunction fn1() {\n\t\treturn \"fn1\";\n\t}\n\tfunction fn2() {\n\t\treturn \"fn2\";\n\t}\n\n\t// Try to invert the order of some properties to make sure it is covered.\n\t// It can failed when properties are compared between unsorted arrays.\n\tequal(QUnit.equiv(\n\t\t{\n\t\t\ta: 1,\n\t\t\tb: null,\n\t\t\tc: [{}],\n\t\t\td: {\n\t\t\t\ta: 3.14159,\n\t\t\t\tb: false,\n\t\t\t\tc: {\n\t\t\t\t\te: fn1,\n\t\t\t\t\tf: [[[]]],\n\t\t\t\t\tg: {\n\t\t\t\t\t\tj: {\n\t\t\t\t\t\t\tk: {\n\t\t\t\t\t\t\t\tn: {\n\t\t\t\t\t\t\t\t\tr: \"r\",\n\t\t\t\t\t\t\t\t\ts: [1,2,3],\n\t\t\t\t\t\t\t\t\tt: undefined,\n\t\t\t\t\t\t\t\t\tu: 0,\n\t\t\t\t\t\t\t\t\tv: {\n\t\t\t\t\t\t\t\t\t\tw: {\n\t\t\t\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\t\t\t\ty: \"Yahoo!\",\n\t\t\t\t\t\t\t\t\t\t\t\tz: null\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tq: [],\n\t\t\t\t\t\t\t\tp: 1/0,\n\t\t\t\t\t\t\t\to: 99\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tl: undefined,\n\t\t\t\t\t\t\tm: null\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\td: 0,\n\t\t\t\t\ti: true,\n\t\t\t\t\th: \"false\"\n\t\t\t\t}\n\t\t\t},\n\t\t\te: undefined,\n\t\t\tg: \"\",\n\t\t\th: \"h\",\n\t\t\tf: {},\n\t\t\ti: []\n\t\t},\n\t\t{\n\t\t\ta: 1,\n\t\t\tb: null,\n\t\t\tc: [{}],\n\t\t\td: {\n\t\t\t\tb: false,\n\t\t\t\ta: 3.14159,\n\t\t\t\tc: {\n\t\t\t\t\td: 0,\n\t\t\t\t\te: fn1,\n\t\t\t\t\tf: [[[]]],\n\t\t\t\t\tg: {\n\t\t\t\t\t\tj: {\n\t\t\t\t\t\t\tk: {\n\t\t\t\t\t\t\t\tn: {\n\t\t\t\t\t\t\t\t\tr: \"r\",\n\t\t\t\t\t\t\t\t\tt: undefined,\n\t\t\t\t\t\t\t\t\tu: 0,\n\t\t\t\t\t\t\t\t\ts: [1,2,3],\n\t\t\t\t\t\t\t\t\tv: {\n\t\t\t\t\t\t\t\t\t\tw: {\n\t\t\t\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\t\t\t\tz: null,\n\t\t\t\t\t\t\t\t\t\t\t\ty: \"Yahoo!\"\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\to: 99,\n\t\t\t\t\t\t\t\tp: 1/0,\n\t\t\t\t\t\t\t\tq: []\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tl: undefined,\n\t\t\t\t\t\t\tm: null\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\ti: true,\n\t\t\t\t\th: \"false\"\n\t\t\t\t}\n\t\t\t},\n\t\t\te: undefined,\n\t\t\tg: \"\",\n\t\t\tf: {},\n\t\t\th: \"h\",\n\t\t\ti: []\n\t\t}\n\t), true);\n\n\tequal(QUnit.equiv(\n\t\t{\n\t\t\ta: 1,\n\t\t\tb: null,\n\t\t\tc: [{}],\n\t\t\td: {\n\t\t\t\ta: 3.14159,\n\t\t\t\tb: false,\n\t\t\t\tc: {\n\t\t\t\t\td: 0,\n\t\t\t\t\te: fn1,\n\t\t\t\t\tf: [[[]]],\n\t\t\t\t\tg: {\n\t\t\t\t\t\tj: {\n\t\t\t\t\t\t\tk: {\n\t\t\t\t\t\t\t\tn: {\n\t\t\t\t\t\t\t\t\t//r: \"r\",   // different: missing a property\n\t\t\t\t\t\t\t\t\ts: [1,2,3],\n\t\t\t\t\t\t\t\t\tt: undefined,\n\t\t\t\t\t\t\t\t\tu: 0,\n\t\t\t\t\t\t\t\t\tv: {\n\t\t\t\t\t\t\t\t\t\tw: {\n\t\t\t\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\t\t\t\ty: \"Yahoo!\",\n\t\t\t\t\t\t\t\t\t\t\t\tz: null\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\to: 99,\n\t\t\t\t\t\t\t\tp: 1/0,\n\t\t\t\t\t\t\t\tq: []\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tl: undefined,\n\t\t\t\t\t\t\tm: null\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\th: \"false\",\n\t\t\t\t\ti: true\n\t\t\t\t}\n\t\t\t},\n\t\t\te: undefined,\n\t\t\tf: {},\n\t\t\tg: \"\",\n\t\t\th: \"h\",\n\t\t\ti: []\n\t\t},\n\t\t{\n\t\t\ta: 1,\n\t\t\tb: null,\n\t\t\tc: [{}],\n\t\t\td: {\n\t\t\t\ta: 3.14159,\n\t\t\t\tb: false,\n\t\t\t\tc: {\n\t\t\t\t\td: 0,\n\t\t\t\t\te: fn1,\n\t\t\t\t\tf: [[[]]],\n\t\t\t\t\tg: {\n\t\t\t\t\t\tj: {\n\t\t\t\t\t\t\tk: {\n\t\t\t\t\t\t\t\tn: {\n\t\t\t\t\t\t\t\t\tr: \"r\",\n\t\t\t\t\t\t\t\t\ts: [1,2,3],\n\t\t\t\t\t\t\t\t\tt: undefined,\n\t\t\t\t\t\t\t\t\tu: 0,\n\t\t\t\t\t\t\t\t\tv: {\n\t\t\t\t\t\t\t\t\t\tw: {\n\t\t\t\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\t\t\t\ty: \"Yahoo!\",\n\t\t\t\t\t\t\t\t\t\t\t\tz: null\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\to: 99,\n\t\t\t\t\t\t\t\tp: 1/0,\n\t\t\t\t\t\t\t\tq: []\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tl: undefined,\n\t\t\t\t\t\t\tm: null\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\th: \"false\",\n\t\t\t\t\ti: true\n\t\t\t\t}\n\t\t\t},\n\t\t\te: undefined,\n\t\t\tf: {},\n\t\t\tg: \"\",\n\t\t\th: \"h\",\n\t\t\ti: []\n\t\t}\n\t), false);\n\n\tequal(QUnit.equiv(\n\t\t{\n\t\t\ta: 1,\n\t\t\tb: null,\n\t\t\tc: [{}],\n\t\t\td: {\n\t\t\t\ta: 3.14159,\n\t\t\t\tb: false,\n\t\t\t\tc: {\n\t\t\t\t\td: 0,\n\t\t\t\t\te: fn1,\n\t\t\t\t\tf: [[[]]],\n\t\t\t\t\tg: {\n\t\t\t\t\t\tj: {\n\t\t\t\t\t\t\tk: {\n\t\t\t\t\t\t\t\tn: {\n\t\t\t\t\t\t\t\t\tr: \"r\",\n\t\t\t\t\t\t\t\t\ts: [1,2,3],\n\t\t\t\t\t\t\t\t\tt: undefined,\n\t\t\t\t\t\t\t\t\tu: 0,\n\t\t\t\t\t\t\t\t\tv: {\n\t\t\t\t\t\t\t\t\t\tw: {\n\t\t\t\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\t\t\t\ty: \"Yahoo!\",\n\t\t\t\t\t\t\t\t\t\t\t\tz: null\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\to: 99,\n\t\t\t\t\t\t\t\tp: 1/0,\n\t\t\t\t\t\t\t\tq: []\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tl: undefined,\n\t\t\t\t\t\t\tm: null\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\th: \"false\",\n\t\t\t\t\ti: true\n\t\t\t\t}\n\t\t\t},\n\t\t\te: undefined,\n\t\t\tf: {},\n\t\t\tg: \"\",\n\t\t\th: \"h\",\n\t\t\ti: []\n\t\t},\n\t\t{\n\t\t\ta: 1,\n\t\t\tb: null,\n\t\t\tc: [{}],\n\t\t\td: {\n\t\t\t\ta: 3.14159,\n\t\t\t\tb: false,\n\t\t\t\tc: {\n\t\t\t\t\td: 0,\n\t\t\t\t\te: fn1,\n\t\t\t\t\tf: [[[]]],\n\t\t\t\t\tg: {\n\t\t\t\t\t\tj: {\n\t\t\t\t\t\t\tk: {\n\t\t\t\t\t\t\t\tn: {\n\t\t\t\t\t\t\t\t\tr: \"r\",\n\t\t\t\t\t\t\t\t\ts: [1,2,3],\n\t\t\t\t\t\t\t\t\t//t: undefined,                 // different: missing a property with an undefined value\n\t\t\t\t\t\t\t\t\tu: 0,\n\t\t\t\t\t\t\t\t\tv: {\n\t\t\t\t\t\t\t\t\t\tw: {\n\t\t\t\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\t\t\t\ty: \"Yahoo!\",\n\t\t\t\t\t\t\t\t\t\t\t\tz: null\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\to: 99,\n\t\t\t\t\t\t\t\tp: 1/0,\n\t\t\t\t\t\t\t\tq: []\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tl: undefined,\n\t\t\t\t\t\t\tm: null\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\th: \"false\",\n\t\t\t\t\ti: true\n\t\t\t\t}\n\t\t\t},\n\t\t\te: undefined,\n\t\t\tf: {},\n\t\t\tg: \"\",\n\t\t\th: \"h\",\n\t\t\ti: []\n\t\t}\n\t), false);\n\n\tequal(QUnit.equiv(\n\t\t{\n\t\t\ta: 1,\n\t\t\tb: null,\n\t\t\tc: [{}],\n\t\t\td: {\n\t\t\t\ta: 3.14159,\n\t\t\t\tb: false,\n\t\t\t\tc: {\n\t\t\t\t\td: 0,\n\t\t\t\t\te: fn1,\n\t\t\t\t\tf: [[[]]],\n\t\t\t\t\tg: {\n\t\t\t\t\t\tj: {\n\t\t\t\t\t\t\tk: {\n\t\t\t\t\t\t\t\tn: {\n\t\t\t\t\t\t\t\t\tr: \"r\",\n\t\t\t\t\t\t\t\t\ts: [1,2,3],\n\t\t\t\t\t\t\t\t\tt: undefined,\n\t\t\t\t\t\t\t\t\tu: 0,\n\t\t\t\t\t\t\t\t\tv: {\n\t\t\t\t\t\t\t\t\t\tw: {\n\t\t\t\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\t\t\t\ty: \"Yahoo!\",\n\t\t\t\t\t\t\t\t\t\t\t\tz: null\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\to: 99,\n\t\t\t\t\t\t\t\tp: 1/0,\n\t\t\t\t\t\t\t\tq: []\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tl: undefined,\n\t\t\t\t\t\t\tm: null\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\th: \"false\",\n\t\t\t\t\ti: true\n\t\t\t\t}\n\t\t\t},\n\t\t\te: undefined,\n\t\t\tf: {},\n\t\t\tg: \"\",\n\t\t\th: \"h\",\n\t\t\ti: []\n\t\t},\n\t\t{\n\t\t\ta: 1,\n\t\t\tb: null,\n\t\t\tc: [{}],\n\t\t\td: {\n\t\t\t\ta: 3.14159,\n\t\t\t\tb: false,\n\t\t\t\tc: {\n\t\t\t\t\td: 0,\n\t\t\t\t\te: fn1,\n\t\t\t\t\tf: [[[]]],\n\t\t\t\t\tg: {\n\t\t\t\t\t\tj: {\n\t\t\t\t\t\t\tk: {\n\t\t\t\t\t\t\t\tn: {\n\t\t\t\t\t\t\t\t\tr: \"r\",\n\t\t\t\t\t\t\t\t\ts: [1,2,3],\n\t\t\t\t\t\t\t\t\tt: undefined,\n\t\t\t\t\t\t\t\t\tu: 0,\n\t\t\t\t\t\t\t\t\tv: {\n\t\t\t\t\t\t\t\t\t\tw: {\n\t\t\t\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\t\t\t\ty: \"Yahoo!\",\n\t\t\t\t\t\t\t\t\t\t\t\tz: null\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\to: 99,\n\t\t\t\t\t\t\t\tp: 1/0,\n\t\t\t\t\t\t\t\tq: {}           // different was []\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tl: undefined,\n\t\t\t\t\t\t\tm: null\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\th: \"false\",\n\t\t\t\t\ti: true\n\t\t\t\t}\n\t\t\t},\n\t\t\te: undefined,\n\t\t\tf: {},\n\t\t\tg: \"\",\n\t\t\th: \"h\",\n\t\t\ti: []\n\t\t}\n\t), false);\n\n\tvar same1 = {\n\t\ta: [\n\t\t\t\"string\", null, 0, \"1\", 1, {\n\t\t\t\tprop: null,\n\t\t\t\tfoo: [1,2,null,{}, [], [1,2,3]],\n\t\t\t\tbar: undefined\n\t\t\t}, 3, \"Hey!\", \"ÎšÎ¬Î½Îµ Ï€Î¬Î½Ï„Î± Î³Î½Ï‰ÏÎ¯Î¶Î¿Ï…Î¼Îµ Î±Ï‚ Ï„Ï‰Î½, Î¼Î·Ï‡Î±Î½Î®Ï‚ ÎµÏ€Î¹Î´Î¹ÏŒÏÎ¸Ï‰ÏƒÎ·Ï‚ ÎµÏ€Î¹Î´Î¹Î¿ÏÎ¸ÏŽÏƒÎµÎ¹Ï‚ ÏŽÏ‚ Î¼Î¹Î±. ÎšÎ»Ï€ Î±Ï‚\"\n\t\t],\n\t\tunicode: \"è€ æ±‰è¯ä¸å˜åœ¨ æ¸¯æ¾³å’Œæµ·å¤–çš„åŽäººåœˆä¸ è´µå·ž æˆ‘åŽ»äº†ä¹¦åº— çŽ°åœ¨å°šæœ‰äº‰\",\n\t\tb: \"b\",\n\t\tc: fn1\n\t};\n\n\tvar same2 = {\n\t\ta: [\n\t\t\t\"string\", null, 0, \"1\", 1, {\n\t\t\t\tprop: null,\n\t\t\t\tfoo: [1,2,null,{}, [], [1,2,3]],\n\t\t\t\tbar: undefined\n\t\t\t}, 3, \"Hey!\", \"ÎšÎ¬Î½Îµ Ï€Î¬Î½Ï„Î± Î³Î½Ï‰ÏÎ¯Î¶Î¿Ï…Î¼Îµ Î±Ï‚ Ï„Ï‰Î½, Î¼Î·Ï‡Î±Î½Î®Ï‚ ÎµÏ€Î¹Î´Î¹ÏŒÏÎ¸Ï‰ÏƒÎ·Ï‚ ÎµÏ€Î¹Î´Î¹Î¿ÏÎ¸ÏŽÏƒÎµÎ¹Ï‚ ÏŽÏ‚ Î¼Î¹Î±. ÎšÎ»Ï€ Î±Ï‚\"\n\t\t],\n\t\tunicode: \"è€ æ±‰è¯ä¸å˜åœ¨ æ¸¯æ¾³å’Œæµ·å¤–çš„åŽäººåœˆä¸ è´µå·ž æˆ‘åŽ»äº†ä¹¦åº— çŽ°åœ¨å°šæœ‰äº‰\",\n\t\tb: \"b\",\n\t\tc: fn1\n\t};\n\n\tvar diff1 = {\n\t\ta: [\n\t\t\t\"string\", null, 0, \"1\", 1, {\n\t\t\t\tprop: null,\n\t\t\t\tfoo: [1,2,null,{}, [], [1,2,3,4]], // different: 4 was add to the array\n\t\t\t\tbar: undefined\n\t\t\t}, 3, \"Hey!\", \"ÎšÎ¬Î½Îµ Ï€Î¬Î½Ï„Î± Î³Î½Ï‰ÏÎ¯Î¶Î¿Ï…Î¼Îµ Î±Ï‚ Ï„Ï‰Î½, Î¼Î·Ï‡Î±Î½Î®Ï‚ ÎµÏ€Î¹Î´Î¹ÏŒÏÎ¸Ï‰ÏƒÎ·Ï‚ ÎµÏ€Î¹Î´Î¹Î¿ÏÎ¸ÏŽÏƒÎµÎ¹Ï‚ ÏŽÏ‚ Î¼Î¹Î±. ÎšÎ»Ï€ Î±Ï‚\"\n\t\t],\n\t\tunicode: \"è€ æ±‰è¯ä¸å˜åœ¨ æ¸¯æ¾³å’Œæµ·å¤–çš„åŽäººåœˆä¸ è´µå·ž æˆ‘åŽ»äº†ä¹¦åº— çŽ°åœ¨å°šæœ‰äº‰\",\n\t\tb: \"b\",\n\t\tc: fn1\n\t};\n\n\tvar diff2 = {\n\t\ta: [\n\t\t\t\"string\", null, 0, \"1\", 1, {\n\t\t\t\tprop: null,\n\t\t\t\tfoo: [1,2,null,{}, [], [1,2,3]],\n\t\t\t\tnewprop: undefined, // different: newprop was added\n\t\t\t\tbar: undefined\n\t\t\t}, 3, \"Hey!\", \"ÎšÎ¬Î½Îµ Ï€Î¬Î½Ï„Î± Î³Î½Ï‰ÏÎ¯Î¶Î¿Ï…Î¼Îµ Î±Ï‚ Ï„Ï‰Î½, Î¼Î·Ï‡Î±Î½Î®Ï‚ ÎµÏ€Î¹Î´Î¹ÏŒÏÎ¸Ï‰ÏƒÎ·Ï‚ ÎµÏ€Î¹Î´Î¹Î¿ÏÎ¸ÏŽÏƒÎµÎ¹Ï‚ ÏŽÏ‚ Î¼Î¹Î±. ÎšÎ»Ï€ Î±Ï‚\"\n\t\t],\n\t\tunicode: \"è€ æ±‰è¯ä¸å˜åœ¨ æ¸¯æ¾³å’Œæµ·å¤–çš„åŽäººåœˆä¸ è´µå·ž æˆ‘åŽ»äº†ä¹¦åº— çŽ°åœ¨å°šæœ‰äº‰\",\n\t\tb: \"b\",\n\t\tc: fn1\n\t};\n\n\tvar diff3 = {\n\t\ta: [\n\t\t\t\"string\", null, 0, \"1\", 1, {\n\t\t\t\tprop: null,\n\t\t\t\tfoo: [1,2,null,{}, [], [1,2,3]],\n\t\t\t\tbar: undefined\n\t\t\t}, 3, \"Hey!\", \"ÎšÎ¬Î½Îµ Ï€Î¬Î½Ï„Î± Î³Î½Ï‰ÏÎ¯Î¶Î¿Ï…Î¼Îµ Î±Ï‚ Ï„Ï‰Î½, Î¼Î·Ï‡Î±Î½Î®Ï‚ ÎµÏ€Î¹Î´Î¹ÏŒÏÎ¸Ï‰ÏƒÎ·Ï‚ ÎµÏ€Î¹Î´Î¹Î¿ÏÎ¸ÏŽÏƒÎµÎ¹Ï‚ ÏŽÏ‚ Î¼Î¹Î±. ÎšÎ»Ï€ Î±\" // different: missing last char\n\t\t],\n\t\tunicode: \"è€ æ±‰è¯ä¸å˜åœ¨ æ¸¯æ¾³å’Œæµ·å¤–çš„åŽäººåœˆä¸ è´µå·ž æˆ‘åŽ»äº†ä¹¦åº— çŽ°åœ¨å°šæœ‰äº‰\",\n\t\tb: \"b\",\n\t\tc: fn1\n\t};\n\n\tvar diff4 = {\n\t\ta: [\n\t\t\t\"string\", null, 0, \"1\", 1, {\n\t\t\t\tprop: null,\n\t\t\t\tfoo: [1,2,undefined,{}, [], [1,2,3]], // different: undefined instead of null\n\t\t\t\tbar: undefined\n\t\t\t}, 3, \"Hey!\", \"ÎšÎ¬Î½Îµ Ï€Î¬Î½Ï„Î± Î³Î½Ï‰ÏÎ¯Î¶Î¿Ï…Î¼Îµ Î±Ï‚ Ï„Ï‰Î½, Î¼Î·Ï‡Î±Î½Î®Ï‚ ÎµÏ€Î¹Î´Î¹ÏŒÏÎ¸Ï‰ÏƒÎ·Ï‚ ÎµÏ€Î¹Î´Î¹Î¿ÏÎ¸ÏŽÏƒÎµÎ¹Ï‚ ÏŽÏ‚ Î¼Î¹Î±. ÎšÎ»Ï€ Î±Ï‚\"\n\t\t],\n\t\tunicode: \"è€ æ±‰è¯ä¸å˜åœ¨ æ¸¯æ¾³å’Œæµ·å¤–çš„åŽäººåœˆä¸ è´µå·ž æˆ‘åŽ»äº†ä¹¦åº— çŽ°åœ¨å°šæœ‰äº‰\",\n\t\tb: \"b\",\n\t\tc: fn1\n\t};\n\n\tvar diff5 = {\n\t\ta: [\n\t\t\t\"string\", null, 0, \"1\", 1, {\n\t\t\t\tprop: null,\n\t\t\t\tfoo: [1,2,null,{}, [], [1,2,3]],\n\t\t\t\tbat: undefined // different: property name not \"bar\"\n\t\t\t}, 3, \"Hey!\", \"ÎšÎ¬Î½Îµ Ï€Î¬Î½Ï„Î± Î³Î½Ï‰ÏÎ¯Î¶Î¿Ï…Î¼Îµ Î±Ï‚ Ï„Ï‰Î½, Î¼Î·Ï‡Î±Î½Î®Ï‚ ÎµÏ€Î¹Î´Î¹ÏŒÏÎ¸Ï‰ÏƒÎ·Ï‚ ÎµÏ€Î¹Î´Î¹Î¿ÏÎ¸ÏŽÏƒÎµÎ¹Ï‚ ÏŽÏ‚ Î¼Î¹Î±. ÎšÎ»Ï€ Î±Ï‚\"\n\t\t],\n\t\tunicode: \"è€ æ±‰è¯ä¸å˜åœ¨ æ¸¯æ¾³å’Œæµ·å¤–çš„åŽäººåœˆä¸ è´µå·ž æˆ‘åŽ»äº†ä¹¦åº— çŽ°åœ¨å°šæœ‰äº‰\",\n\t\tb: \"b\",\n\t\tc: fn1\n\t};\n\n\tequal(QUnit.equiv(same1, same2), true);\n\tequal(QUnit.equiv(same2, same1), true);\n\tequal(QUnit.equiv(same2, diff1), false);\n\tequal(QUnit.equiv(diff1, same2), false);\n\n\tequal(QUnit.equiv(same1, diff1), false);\n\tequal(QUnit.equiv(same1, diff2), false);\n\tequal(QUnit.equiv(same1, diff3), false);\n\tequal(QUnit.equiv(same1, diff3), false);\n\tequal(QUnit.equiv(same1, diff4), false);\n\tequal(QUnit.equiv(same1, diff5), false);\n\tequal(QUnit.equiv(diff5, diff1), false);\n});\n\n\ntest(\"Complex Arrays.\", function() {\n\n\tfunction fn() {\n\t}\n\n\tequal(QUnit.equiv(\n\t\t\t\t[1, 2, 3, true, {}, null, [\n\t\t\t\t\t{\n\t\t\t\t\t\ta: [\"\", '1', 0]\n\t\t\t\t\t},\n\t\t\t\t\t5, 6, 7\n\t\t\t\t], \"foo\"],\n\t\t\t\t[1, 2, 3, true, {}, null, [\n\t\t\t\t\t{\n\t\t\t\t\t\ta: [\"\", '1', 0]\n\t\t\t\t\t},\n\t\t\t\t\t5, 6, 7\n\t\t\t\t], \"foo\"]),\n\t\t\ttrue);\n\n\tequal(QUnit.equiv(\n\t\t\t\t[1, 2, 3, true, {}, null, [\n\t\t\t\t\t{\n\t\t\t\t\t\ta: [\"\", '1', 0]\n\t\t\t\t\t},\n\t\t\t\t\t5, 6, 7\n\t\t\t\t], \"foo\"],\n\t\t\t\t[1, 2, 3, true, {}, null, [\n\t\t\t\t\t{\n\t\t\t\t\t\tb: [\"\", '1', 0]         // not same property name\n\t\t\t\t\t},\n\t\t\t\t\t5, 6, 7\n\t\t\t\t], \"foo\"]),\n\t\t\tfalse);\n\n\tvar a = [{\n\t\tb: fn,\n\t\tc: false,\n\t\t\"do\": \"reserved word\",\n\t\t\"for\": {\n\t\t\tar: [3,5,9,\"hey!\", [], {\n\t\t\t\tar: [1,[\n\t\t\t\t\t3,4,6,9, null, [], []\n\t\t\t\t]],\n\t\t\t\te: fn,\n\t\t\t\tf: undefined\n\t\t\t}]\n\t\t},\n\t\te: 0.43445\n\t}, 5, \"string\", 0, fn, false, null, undefined, 0, [\n\t\t4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n\t], [], [[[], \"foo\", null, {\n\t\tn: 1/0,\n\t\tz: {\n\t\t\ta: [3,4,5,6,\"yep!\", undefined, undefined],\n\t\t\tb: {}\n\t\t}\n\t}, {}]]];\n\n\tequal(QUnit.equiv(a,\n\t\t\t[{\n\t\t\t\tb: fn,\n\t\t\t\tc: false,\n\t\t\t\t\"do\": \"reserved word\",\n\t\t\t\t\"for\": {\n\t\t\t\t\tar: [3,5,9,\"hey!\", [], {\n\t\t\t\t\t\tar: [1,[\n\t\t\t\t\t\t\t3,4,6,9, null, [], []\n\t\t\t\t\t\t]],\n\t\t\t\t\t\te: fn,\n\t\t\t\t\t\tf: undefined\n\t\t\t\t\t}]\n\t\t\t\t},\n\t\t\t\te: 0.43445\n\t\t\t}, 5, \"string\", 0, fn, false, null, undefined, 0, [\n\t\t\t\t4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n\t\t\t], [], [[[], \"foo\", null, {\n\t\t\t\tn: 1/0,\n\t\t\t\tz: {\n\t\t\t\t\ta: [3,4,5,6,\"yep!\", undefined, undefined],\n\t\t\t\t\tb: {}\n\t\t\t\t}\n\t\t\t}, {}]]]), true);\n\n\tequal(QUnit.equiv(a,\n\t\t\t[{\n\t\t\t\tb: fn,\n\t\t\t\tc: false,\n\t\t\t\t\"do\": \"reserved word\",\n\t\t\t\t\"for\": {\n\t\t\t\t\tar: [3,5,9,\"hey!\", [], {\n\t\t\t\t\t\tar: [1,[\n\t\t\t\t\t\t\t3,4,6,9, null, [], []\n\t\t\t\t\t\t]],\n\t\t\t\t\t\te: fn,\n\t\t\t\t\t\tf: undefined\n\t\t\t\t\t}]\n\t\t\t\t},\n\t\t\t\te: 0.43445\n\t\t\t}, 5, \"string\", 0, fn, false, null, undefined, 0, [\n\t\t\t\t4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[2]]]], \"3\"], {}, 1/0    // different: [[[[[2]]]]] instead of [[[[[3]]]]]\n\t\t\t], [], [[[], \"foo\", null, {\n\t\t\t\tn: 1/0,\n\t\t\t\tz: {\n\t\t\t\t\ta: [3,4,5,6,\"yep!\", undefined, undefined],\n\t\t\t\t\tb: {}\n\t\t\t\t}\n\t\t\t}, {}]]]), false);\n\n\tequal(QUnit.equiv(a,\n\t\t\t[{\n\t\t\t\tb: fn,\n\t\t\t\tc: false,\n\t\t\t\t\"do\": \"reserved word\",\n\t\t\t\t\"for\": {\n\t\t\t\t\tar: [3,5,9,\"hey!\", [], {\n\t\t\t\t\t\tar: [1,[\n\t\t\t\t\t\t\t3,4,6,9, null, [], []\n\t\t\t\t\t\t]],\n\t\t\t\t\t\te: fn,\n\t\t\t\t\t\tf: undefined\n\t\t\t\t\t}]\n\t\t\t\t},\n\t\t\t\te: 0.43445\n\t\t\t}, 5, \"string\", 0, fn, false, null, undefined, 0, [\n\t\t\t\t4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n\t\t\t], [], [[[], \"foo\", null, {\n\t\t\t\tn: -1/0,                                                                // different, -Infinity instead of Infinity\n\t\t\t\tz: {\n\t\t\t\t\ta: [3,4,5,6,\"yep!\", undefined, undefined],\n\t\t\t\t\tb: {}\n\t\t\t\t}\n\t\t\t}, {}]]]), false);\n\n\tequal(QUnit.equiv(a,\n\t\t\t[{\n\t\t\t\tb: fn,\n\t\t\t\tc: false,\n\t\t\t\t\"do\": \"reserved word\",\n\t\t\t\t\"for\": {\n\t\t\t\t\tar: [3,5,9,\"hey!\", [], {\n\t\t\t\t\t\tar: [1,[\n\t\t\t\t\t\t\t3,4,6,9, null, [], []\n\t\t\t\t\t\t]],\n\t\t\t\t\t\te: fn,\n\t\t\t\t\t\tf: undefined\n\t\t\t\t\t}]\n\t\t\t\t},\n\t\t\t\te: 0.43445\n\t\t\t}, 5, \"string\", 0, fn, false, null, undefined, 0, [\n\t\t\t\t4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n\t\t\t], [], [[[], \"foo\", {                                                       // different: null is missing\n\t\t\t\tn: 1/0,\n\t\t\t\tz: {\n\t\t\t\t\ta: [3,4,5,6,\"yep!\", undefined, undefined],\n\t\t\t\t\tb: {}\n\t\t\t\t}\n\t\t\t}, {}]]]), false);\n\n\tequal(QUnit.equiv(a,\n\t\t\t[{\n\t\t\t\tb: fn,\n\t\t\t\tc: false,\n\t\t\t\t\"do\": \"reserved word\",\n\t\t\t\t\"for\": {\n\t\t\t\t\tar: [3,5,9,\"hey!\", [], {\n\t\t\t\t\t\tar: [1,[\n\t\t\t\t\t\t\t3,4,6,9, null, [], []\n\t\t\t\t\t\t]],\n\t\t\t\t\t\te: fn\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// different: missing property f: undefined\n\t\t\t\t\t}]\n\t\t\t\t},\n\t\t\t\te: 0.43445\n\t\t\t}, 5, \"string\", 0, fn, false, null, undefined, 0, [\n\t\t\t\t4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n\t\t\t], [], [[[], \"foo\", null, {\n\t\t\t\tn: 1/0,\n\t\t\t\tz: {\n\t\t\t\t\ta: [3,4,5,6,\"yep!\", undefined, undefined],\n\t\t\t\t\tb: {}\n\t\t\t\t}\n\t\t\t}, {}]]]), false);\n});\n\n\ntest(\"Prototypal inheritance\", function() {\n\tfunction Gizmo(id) {\n\t\tthis.id = id;\n\t}\n\n\tfunction Hoozit(id) {\n\t\tthis.id = id;\n\t}\n\tHoozit.prototype = new Gizmo();\n\n\tvar gizmo = new Gizmo(\"ok\");\n\tvar hoozit = new Hoozit(\"ok\");\n\n\t// Try this test many times after test on instances that hold function\n\t// to make sure that our code does not mess with last object constructor memoization.\n\tequal(QUnit.equiv(function () {}, function () {}), false);\n\n\t// Hoozit inherit from Gizmo\n\t// hoozit instanceof Hoozit; // true\n\t// hoozit instanceof Gizmo; // true\n\tequal(QUnit.equiv(hoozit, gizmo), true);\n\n\tGizmo.prototype.bar = true; // not a function just in case we skip them\n\n\t// Hoozit inherit from Gizmo\n\t// They are equivalent\n\tequal(QUnit.equiv(hoozit, gizmo), true);\n\n\t// Make sure this is still true !important\n\t// The reason for this is that I forgot to reset the last\n\t// caller to where it were called from.\n\tequal(QUnit.equiv(function () {}, function () {}), false);\n\n\t// Make sure this is still true !important\n\tequal(QUnit.equiv(hoozit, gizmo), true);\n\n\tHoozit.prototype.foo = true; // not a function just in case we skip them\n\n\t// Gizmo does not inherit from Hoozit\n\t// gizmo instanceof Gizmo; // true\n\t// gizmo instanceof Hoozit; // false\n\t// They are not equivalent\n\tequal(QUnit.equiv(hoozit, gizmo), false);\n\n\t// Make sure this is still true !important\n\tequal(QUnit.equiv(function () {}, function () {}), false);\n});\n\n\ntest(\"Instances\", function() {\n\tfunction A() {}\n\tvar a1 = new A();\n\tvar a2 = new A();\n\n\tfunction B() {\n\t\tthis.fn = function () {};\n\t}\n\tvar b1 = new B();\n\tvar b2 = new B();\n\n\tequal(QUnit.equiv(a1, a2), true, \"Same property, same constructor\");\n\n\t// b1.fn and b2.fn are functions but they are different references\n\t// But we decided to skip function for instances.\n\tequal(QUnit.equiv(b1, b2), true, \"Same property, same constructor\");\n\tequal(QUnit.equiv(a1, b1), false, \"Same properties but different constructor\"); // failed\n\n\tfunction Car(year) {\n\t\tvar privateVar = 0;\n\t\tthis.year = year;\n\t\tthis.isOld = function() {\n\t\t\treturn year > 10;\n\t\t};\n\t}\n\n\tfunction Human(year) {\n\t\tvar privateVar = 1;\n\t\tthis.year = year;\n\t\tthis.isOld = function() {\n\t\t\treturn year > 80;\n\t\t};\n\t}\n\n\tvar car = new Car(30);\n\tvar carSame = new Car(30);\n\tvar carDiff = new Car(10);\n\tvar human = new Human(30);\n\n\tvar diff = {\n\t\tyear: 30\n\t};\n\n\tvar same = {\n\t\tyear: 30,\n\t\tisOld: function () {}\n\t};\n\n\tequal(QUnit.equiv(car, car), true);\n\tequal(QUnit.equiv(car, carDiff), false);\n\tequal(QUnit.equiv(car, carSame), true);\n\tequal(QUnit.equiv(car, human), false);\n});\n\n\ntest(\"Complex Instances Nesting (with function value in literals and/or in nested instances)\", function() {\n\tfunction A(fn) {\n\t\tthis.a = {};\n\t\tthis.fn = fn;\n\t\tthis.b = {a: []};\n\t\tthis.o = {};\n\t\tthis.fn1 = fn;\n\t}\n\tfunction B(fn) {\n\t\tthis.fn = fn;\n\t\tthis.fn1 = function () {};\n\t\tthis.a = new A(function () {});\n\t}\n\n\tfunction fnOutside() {\n\t}\n\n\tfunction C(fn) {\n\t\tfunction fnInside() {\n\t\t}\n\t\tthis.x = 10;\n\t\tthis.fn = fn;\n\t\tthis.fn1 = function () {};\n\t\tthis.fn2 = fnInside;\n\t\tthis.fn3 = {\n\t\t\ta: true,\n\t\t\tb: fnOutside // ok make reference to a function in all instances scope\n\t\t};\n\t\tthis.o1 = {};\n\n\t\t// This function will be ignored.\n\t\t// Even if it is not visible for all instances (e.g. locked in a closures),\n\t\t// it is from a  property that makes part of an instance (e.g. from the C constructor)\n\t\tthis.b1 = new B(function () {});\n\t\tthis.b2 = new B({\n\t\t\tx: {\n\t\t\t\tb2: new B(function() {})\n\t\t\t}\n\t\t});\n\t}\n\n\tfunction D(fn) {\n\t\tfunction fnInside() {\n\t\t}\n\t\tthis.x = 10;\n\t\tthis.fn = fn;\n\t\tthis.fn1 = function () {};\n\t\tthis.fn2 = fnInside;\n\t\tthis.fn3 = {\n\t\t\ta: true,\n\t\t\tb: fnOutside, // ok make reference to a function in all instances scope\n\n\t\t\t// This function won't be ingored.\n\t\t\t// It isn't visible for all C insances\n\t\t\t// and it is not in a property of an instance. (in an Object instances e.g. the object literal)\n\t\t\tc: fnInside\n\t\t};\n\t\tthis.o1 = {};\n\n\t\t// This function will be ignored.\n\t\t// Even if it is not visible for all instances (e.g. locked in a closures),\n\t\t// it is from a  property that makes part of an instance (e.g. from the C constructor)\n\t\tthis.b1 = new B(function () {});\n\t\tthis.b2 = new B({\n\t\t\tx: {\n\t\t\t\tb2: new B(function() {})\n\t\t\t}\n\t\t});\n\t}\n\n\tfunction E(fn) {\n\t\tfunction fnInside() {\n\t\t}\n\t\tthis.x = 10;\n\t\tthis.fn = fn;\n\t\tthis.fn1 = function () {};\n\t\tthis.fn2 = fnInside;\n\t\tthis.fn3 = {\n\t\t\ta: true,\n\t\t\tb: fnOutside // ok make reference to a function in all instances scope\n\t\t};\n\t\tthis.o1 = {};\n\n\t\t// This function will be ignored.\n\t\t// Even if it is not visible for all instances (e.g. locked in a closures),\n\t\t// it is from a  property that makes part of an instance (e.g. from the C constructor)\n\t\tthis.b1 = new B(function () {});\n\t\tthis.b2 = new B({\n\t\t\tx: {\n\t\t\t\tb1: new B({a: function() {}}),\n\t\t\t\tb2: new B(function() {})\n\t\t\t}\n\t\t});\n\t}\n\n\n\tvar a1 = new A(function () {});\n\tvar a2 = new A(function () {});\n\tequal(QUnit.equiv(a1, a2), true);\n\n\tequal(QUnit.equiv(a1, a2), true); // different instances\n\n\tvar b1 = new B(function () {});\n\tvar b2 = new B(function () {});\n\tequal(QUnit.equiv(b1, b2), true);\n\n\tvar c1 = new C(function () {});\n\tvar c2 = new C(function () {});\n\tequal(QUnit.equiv(c1, c2), true);\n\n\tvar d1 = new D(function () {});\n\tvar d2 = new D(function () {});\n\tequal(QUnit.equiv(d1, d2), false);\n\n\tvar e1 = new E(function () {});\n\tvar e2 = new E(function () {});\n\tequal(QUnit.equiv(e1, e2), false);\n\n});\n\n\ntest('object with references to self wont loop', function() {\n\tvar circularA = {\n\t\tabc:null\n\t}, circularB = {\n\t\tabc:null\n\t};\n\tcircularA.abc = circularA;\n\tcircularB.abc = circularB;\n\tequal(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on object (ambigous test)\");\n\n\tcircularA.def = 1;\n\tcircularB.def = 1;\n\tequal(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on object (ambigous test)\");\n\n\tcircularA.def = 1;\n\tcircularB.def = 0;\n\tequal(QUnit.equiv(circularA, circularB), false, \"Should not repeat test on object (unambigous test)\");\n});\n\ntest('array with references to self wont loop', function() {\n\tvar circularA = [],\n\t\tcircularB = [];\n\tcircularA.push(circularA);\n\tcircularB.push(circularB);\n\tequal(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on array (ambigous test)\");\n\n\tcircularA.push( 'abc' );\n\tcircularB.push( 'abc' );\n\tequal(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on array (ambigous test)\");\n\n\tcircularA.push( 'hello' );\n\tcircularB.push( 'goodbye' );\n\tequal(QUnit.equiv(circularA, circularB), false, \"Should not repeat test on array (unambigous test)\");\n});\n\ntest('mixed object/array with references to self wont loop', function() {\n\tvar circularA = [{abc:null}],\n\t\tcircularB = [{abc:null}];\n\tcircularA[0].abc = circularA;\n\tcircularB[0].abc = circularB;\n\n\tcircularA.push(circularA);\n\tcircularB.push(circularB);\n\tequal(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on object/array (ambigous test)\");\n\n\tcircularA[0].def = 1;\n\tcircularB[0].def = 1;\n\tequal(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on object/array (ambigous test)\");\n\n\tcircularA[0].def = 1;\n\tcircularB[0].def = 0;\n\tequal(QUnit.equiv(circularA, circularB), false, \"Should not repeat test on object/array (unambigous test)\");\n});\n\ntest('compare self-referent to tree', function () {\n\tvar temp,\n\t\tcircularA = [0],\n\t\ttreeA = [0, null],\n\t\tcircularO = {},\n\t\ttreeO = {\n\t\t\to: null\n\t\t};\n\n\tcircularA[1] = circularA;\n\tcircularO.o = circularO;\n\n\tequal(QUnit.equiv(circularA, treeA), false, \"Array: Should not consider circular equal to tree\");\n\tequal(QUnit.equiv(circularO, treeO), false, \"Object: Should not consider circular equal to tree\");\n\n\ttemp = [ 0, circularA ];\n\tequal(QUnit.equiv(circularA, temp), true, \"Array: Reference is circular for one, but equal on other\");\n\tequal(QUnit.equiv(temp, circularA), true, \"Array: Reference is circular for one, but equal on other\");\n\n\ttemp = {\n\t\to: circularO\n\t};\n\tequal(QUnit.equiv(circularO, temp), true, \"Object: Reference is circular for one, but equal on other\");\n\tequal(QUnit.equiv(temp, circularO), true, \"Object: Reference is circular for one, but equal on other\");\n});\n\ntest(\"Test that must be done at the end because they extend some primitive's prototype\", function() {\n\t// Try that a function looks like our regular expression.\n\t// This tests if we check that a and b are really both instance of RegExp\n\tFunction.prototype.global = true;\n\tFunction.prototype.multiline = true;\n\tFunction.prototype.ignoreCase = false;\n\tFunction.prototype.source = \"my regex\";\n\tvar re = /my regex/gm;\n\tequal(QUnit.equiv(re, function () {}), false, \"A function that looks that a regex isn't a regex\");\n\t// This test will ensures it works in both ways, and ALSO especially that we can make differences\n\t// between RegExp and Function constructor because typeof on a RegExpt instance is \"function\"\n\tequal(QUnit.equiv(function () {}, re), false, \"Same conversely, but ensures that function and regexp are distinct because their constructor are different\");\n});\n"
  },
  {
    "path": "vendor/qunit/test/headless.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>QUnit Test Suite</title>\n\t<link rel=\"stylesheet\" href=\"../qunit/qunit.css\">\n\t<script src=\"../qunit/qunit.js\"></script>\n\t<script src=\"test.js\"></script>\n\t<script src=\"deepEqual.js\"></script>\n\t<script>\n\t\t(function () {\n\t\t\tfunction createCallback(logType) {\n\t\t\t\tQUnit[logType](function () {\n\t\t\t\t\tconsole.log(logType, arguments);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tvar logs = [\"begin\", \"testStart\", \"testDone\", \"log\", \"moduleStart\", \"moduleDone\", \"done\"];\n\t\t\tfor (var i = 0; i < logs.length; i++) {\n\t\t\t\tcreateCallback(logs[i]);\n\t\t\t}\n\t\t}());\n\t</script>\n</head>\n<body>\n\t<div id=\"qunit-fixture\">test markup</div>\n</body>\n</html>\n"
  },
  {
    "path": "vendor/qunit/test/index.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>QUnit Test Suite</title>\n\t<link rel=\"stylesheet\" href=\"../qunit/qunit.css\">\n\t<script src=\"../qunit/qunit.js\"></script>\n\t<script src=\"test.js\"></script>\n\t<script src=\"deepEqual.js\"></script>\n\t<script src=\"swarminject.js\"></script>\n</head>\n<body>\n\t<div id=\"qunit\"></div>\n\t<div id=\"qunit-fixture\">test markup</div>\n</body>\n</html>\n"
  },
  {
    "path": "vendor/qunit/test/logs.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>QUnit Test Suite</title>\n\t<link rel=\"stylesheet\" href=\"../qunit/qunit.css\">\n\t<script src=\"../qunit/qunit.js\"></script>\n\t<script src=\"logs.js\"></script>\n</head>\n<body>\n\t<div id=\"qunit\"></div>\n\t<div id=\"qunit-fixture\">test markup</div>\n</body>\n</html>\n"
  },
  {
    "path": "vendor/qunit/test/logs.js",
    "content": "// TODO disable reordering for this suite!\n\nvar begin = 0,\n\tmoduleStart = 0,\n\tmoduleDone = 0,\n\ttestStart = 0,\n\ttestDone = 0,\n\tlog = 0,\n\tmoduleContext,\n\tmoduleDoneContext,\n\ttestContext,\n\ttestDoneContext,\n\tlogContext;\n\nQUnit.begin(function() {\n\tbegin++;\n});\nQUnit.done(function() {\n});\nQUnit.moduleStart(function(context) {\n\tmoduleStart++;\n\tmoduleContext = context;\n});\nQUnit.moduleDone(function(context) {\n\tmoduleDone++;\n\tmoduleDoneContext = context;\n});\nQUnit.testStart(function(context) {\n\ttestStart++;\n\ttestContext = context;\n});\nQUnit.testDone(function(context) {\n\ttestDone++;\n\ttestDoneContext = context;\n});\nQUnit.log(function(context) {\n\tlog++;\n\tlogContext = context;\n});\n\nmodule(\"logs1\");\n\ntest(\"test1\", 15, function() {\n\tequal( begin, 1, \"QUnit.begin calls\" );\n\tequal( moduleStart, 1, \"QUnit.moduleStart calls\" );\n\tequal( testStart, 1, \"QUnit.testStart calls\" );\n\tequal( testDone, 0, \"QUnit.testDone calls\" );\n\tequal( moduleDone, 0, \"QUnit.moduleDone calls\" );\n\tdeepEqual( logContext, {\n\t\tname: \"test1\",\n\t\tmodule: \"logs1\",\n\t\tresult: true,\n\t\tmessage: \"QUnit.moduleDone calls\",\n\t\tactual: 0,\n\t\texpected: 0\n\t}, \"log context after equal(actual, expected, message)\" );\n\n\tequal( \"foo\", \"foo\" );\n\tdeepEqual(logContext, {\n\t\tname: \"test1\",\n\t\tmodule: \"logs1\",\n\t\tresult: true,\n\t\tmessage: undefined,\n\t\tactual: \"foo\",\n\t\texpected: \"foo\"\n\t}, \"log context after equal(actual, expected)\" );\n\n\tok( true, \"ok(true, message)\" );\n\tdeepEqual( logContext, {\n\t\tmodule: \"logs1\",\n\t\tname: \"test1\",\n\t\tresult: true,\n\t\tmessage: \"ok(true, message)\"\n\t}, \"log context after ok(true, message)\" );\n\n\tstrictEqual( testDoneContext, undefined, \"testDone context\" );\n\tdeepEqual( testContext, {\n\t\tmodule: \"logs1\",\n\t\tname: \"test1\"\n\t}, \"test context\" );\n\tstrictEqual( moduleDoneContext, undefined, \"moduleDone context\" );\n\tdeepEqual( moduleContext, {\n\t\tname: \"logs1\"\n\t}, \"module context\" );\n\n\tequal( log, 14, \"QUnit.log calls\" );\n});\ntest(\"test2\", 11, function() {\n\tequal( begin, 1, \"QUnit.begin calls\" );\n\tequal( moduleStart, 1, \"QUnit.moduleStart calls\" );\n\tequal( testStart, 2, \"QUnit.testStart calls\" );\n\tequal( testDone, 1, \"QUnit.testDone calls\" );\n\tequal( moduleDone, 0, \"QUnit.moduleDone calls\" );\n\n\tok( typeof testDoneContext.duration === \"number\" , \"testDone context: duration\" );\n\tdelete testDoneContext.duration;\n\tdeepEqual( testDoneContext, {\n\t\tmodule: \"logs1\",\n\t\tname: \"test1\",\n\t\tfailed: 0,\n\t\tpassed: 15,\n\t\ttotal: 15\n\t}, \"testDone context\" );\n\tdeepEqual( testContext, {\n\t\tmodule: \"logs1\",\n\t\tname: \"test2\"\n\t}, \"test context\" );\n\tstrictEqual( moduleDoneContext, undefined, \"moduleDone context\" );\n\tdeepEqual( moduleContext, {\n\t\tname: \"logs1\"\n\t}, \"module context\" );\n\n\tequal( log, 25, \"QUnit.log calls\" );\n});\n\nmodule(\"logs2\");\n\ntest( \"test1\", 9, function() {\n\tequal( begin, 1, \"QUnit.begin calls\" );\n\tequal( moduleStart, 2, \"QUnit.moduleStart calls\" );\n\tequal( testStart, 3, \"QUnit.testStart calls\" );\n\tequal( testDone, 2, \"QUnit.testDone calls\" );\n\tequal( moduleDone, 1, \"QUnit.moduleDone calls\" );\n\n\tdeepEqual( testContext, {\n\t\tmodule: \"logs2\",\n\t\tname: \"test1\"\n\t}, \"test context\" );\n\tdeepEqual( moduleDoneContext, {\n\t\tname: \"logs1\",\n\t\tfailed: 0,\n\t\tpassed: 26,\n\t\ttotal: 26\n\t}, \"moduleDone context\" );\n\tdeepEqual( moduleContext, {\n\t\tname: \"logs2\"\n\t}, \"module context\" );\n\n\tequal( log, 34, \"QUnit.log calls\" );\n});\ntest( \"test2\", 8, function() {\n\tequal( begin, 1, \"QUnit.begin calls\" );\n\tequal( moduleStart, 2, \"QUnit.moduleStart calls\" );\n\tequal( testStart, 4, \"QUnit.testStart calls\" );\n\tequal( testDone, 3, \"QUnit.testDone calls\" );\n\tequal( moduleDone, 1, \"QUnit.moduleDone calls\" );\n\n\tdeepEqual( testContext, {\n\t\tmodule: \"logs2\",\n\t\tname: \"test2\"\n\t}, \"test context\" );\n\tdeepEqual( moduleContext, {\n\t\tname: \"logs2\"\n\t}, \"module context\" );\n\n\tequal( log, 42, \"QUnit.log calls\" );\n});\n\nvar testAutorun = true;\n\nQUnit.done(function() {\n\n\tif (!testAutorun) {\n\t\treturn;\n\t}\n\n\ttestAutorun = false;\n\n\tmodule(\"autorun\");\n\n\ttest(\"reset\", 0, function() {});\n\n\tmoduleStart = moduleDone = 0;\n\n\ttest(\"first\", function() {\n\t\tequal(moduleStart, 1, \"test started\");\n\t\tequal(moduleDone, 0, \"test in progress\");\n\t});\n\n\ttest(\"second\", function() {\n\t\tequal(moduleStart, 2, \"test started\");\n\t\tequal(moduleDone, 1, \"test in progress\");\n\t});\n});\n"
  },
  {
    "path": "vendor/qunit/test/narwhal-test.js",
    "content": "// Run with: $ narwhal test/narwhal-test.js\nvar QUnit = require(\"../qunit/qunit\");\n\nQUnit.log(function(details) {\n\tif (!details.result) {\n\t\tvar output = \"FAILED: \" + (details.message ? details.message + \", \" : \"\");\n\t\tif (details.actual) {\n\t\t\toutput += \"expected: \" + details.expected + \", actual: \" + details.actual;\n\t\t}\n\t\tif (details.source) {\n\t\t\toutput += \", \" + details.source;\n\t\t}\n\t\tprint(output);\n\t}\n});\n\nQUnit.test(\"fail twice with stacktrace\", function(assert) {\n\t/*jshint expr:true */\n\tassert.equal(true, false);\n\tassert.equal(true, false, \"gotta fail\");\n\tx.y.z; // Throws ReferenceError\n});\n"
  },
  {
    "path": "vendor/qunit/test/node-test.js",
    "content": "// Run with: $ node test/node-test.js\nvar QUnit = require(\"../qunit/qunit\");\n\nQUnit.log(function(details) {\n\tif (!details.result) {\n\t\tvar output = \"FAILED: \" + (details.message ? details.message + \", \" : \"\");\n\t\tif (details.actual) {\n\t\t\toutput += \"expected: \" + details.expected + \", actual: \" + details.actual;\n\t\t}\n\t\tif (details.source) {\n\t\t\toutput += \", \" + details.source;\n\t\t}\n\t\tconsole.log(output);\n\t}\n});\n\nQUnit.test(\"fail twice with stacktrace\", function(assert) {\n\t/*jshint expr:true */\n\tassert.equal(true, false);\n\tassert.equal(true, false, \"gotta fail\");\n\tx.y.z; // Throws ReferenceError\n});\n"
  },
  {
    "path": "vendor/qunit/test/same.js",
    "content": "module(\"equiv\");\n\n\ntest(\"Primitive types and constants\", function () {\n    equals(QUnit.equiv(null, null), true, \"null\");\n    equals(QUnit.equiv(null, {}), false, \"null\");\n    equals(QUnit.equiv(null, undefined), false, \"null\");\n    equals(QUnit.equiv(null, 0), false, \"null\");\n    equals(QUnit.equiv(null, false), false, \"null\");\n    equals(QUnit.equiv(null, ''), false, \"null\");\n    equals(QUnit.equiv(null, []), false, \"null\");\n\n    equals(QUnit.equiv(undefined, undefined), true, \"undefined\");\n    equals(QUnit.equiv(undefined, null), false, \"undefined\");\n    equals(QUnit.equiv(undefined, 0), false, \"undefined\");\n    equals(QUnit.equiv(undefined, false), false, \"undefined\");\n    equals(QUnit.equiv(undefined, {}), false, \"undefined\");\n    equals(QUnit.equiv(undefined, []), false, \"undefined\");\n    equals(QUnit.equiv(undefined, \"\"), false, \"undefined\");\n\n    // Nan usually doest not equal to Nan using the '==' operator.\n    // Only isNaN() is able to do it.\n    equals(QUnit.equiv(0/0, 0/0), true, \"NaN\"); // NaN VS NaN\n    equals(QUnit.equiv(1/0, 2/0), true, \"Infinity\"); // Infinity VS Infinity\n    equals(QUnit.equiv(-1/0, 2/0), false, \"-Infinity, Infinity\"); // -Infinity VS Infinity\n    equals(QUnit.equiv(-1/0, -2/0), true, \"-Infinity, -Infinity\"); // -Infinity VS -Infinity\n    equals(QUnit.equiv(0/0, 1/0), false, \"NaN, Infinity\"); // Nan VS Infinity\n    equals(QUnit.equiv(1/0, 0/0), false, \"NaN, Infinity\"); // Nan VS Infinity\n    equals(QUnit.equiv(0/0, null), false, \"NaN\");\n    equals(QUnit.equiv(0/0, undefined), false, \"NaN\");\n    equals(QUnit.equiv(0/0, 0), false, \"NaN\");\n    equals(QUnit.equiv(0/0, false), false, \"NaN\");\n    equals(QUnit.equiv(0/0, function () {}), false, \"NaN\");\n    equals(QUnit.equiv(1/0, null), false, \"NaN, Infinity\");\n    equals(QUnit.equiv(1/0, undefined), false, \"NaN, Infinity\");\n    equals(QUnit.equiv(1/0, 0), false, \"NaN, Infinity\");\n    equals(QUnit.equiv(1/0, 1), false, \"NaN, Infinity\");\n    equals(QUnit.equiv(1/0, false), false, \"NaN, Infinity\");\n    equals(QUnit.equiv(1/0, true), false, \"NaN, Infinity\");\n    equals(QUnit.equiv(1/0, function () {}), false, \"NaN, Infinity\");\n\n    equals(QUnit.equiv(0, 0), true, \"number\");\n    equals(QUnit.equiv(0, 1), false, \"number\");\n    equals(QUnit.equiv(1, 0), false, \"number\");\n    equals(QUnit.equiv(1, 1), true, \"number\");\n    equals(QUnit.equiv(1.1, 1.1), true, \"number\");\n    equals(QUnit.equiv(0.0000005, 0.0000005), true, \"number\");\n    equals(QUnit.equiv(0, ''), false, \"number\");\n    equals(QUnit.equiv(0, '0'), false, \"number\");\n    equals(QUnit.equiv(1, '1'), false, \"number\");\n    equals(QUnit.equiv(0, false), false, \"number\");\n    equals(QUnit.equiv(1, true), false, \"number\");\n\n    equals(QUnit.equiv(true, true), true, \"boolean\");\n    equals(QUnit.equiv(true, false), false, \"boolean\");\n    equals(QUnit.equiv(false, true), false, \"boolean\");\n    equals(QUnit.equiv(false, 0), false, \"boolean\");\n    equals(QUnit.equiv(false, null), false, \"boolean\");\n    equals(QUnit.equiv(false, undefined), false, \"boolean\");\n    equals(QUnit.equiv(true, 1), false, \"boolean\");\n    equals(QUnit.equiv(true, null), false, \"boolean\");\n    equals(QUnit.equiv(true, undefined), false, \"boolean\");\n\n    equals(QUnit.equiv('', ''), true, \"string\");\n    equals(QUnit.equiv('a', 'a'), true, \"string\");\n    equals(QUnit.equiv(\"foobar\", \"foobar\"), true, \"string\");\n    equals(QUnit.equiv(\"foobar\", \"foo\"), false, \"string\");\n    equals(QUnit.equiv('', 0), false, \"string\");\n    equals(QUnit.equiv('', false), false, \"string\");\n    equals(QUnit.equiv('', null), false, \"string\");\n    equals(QUnit.equiv('', undefined), false, \"string\");\n\n    // Short annotation VS new annotation\n    equals(QUnit.equiv(0, new Number()), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Number(), 0), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(1, new Number(1)), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Number(1), 1), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Number(0), 1), false, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(0, new Number(1)), false, \"short annotation VS new annotation\");\n\n    equals(QUnit.equiv(new String(), \"\"), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(\"\", new String()), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new String(\"My String\"), \"My String\"), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(\"My String\", new String(\"My String\")), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(\"Bad String\", new String(\"My String\")), false, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new String(\"Bad String\"), \"My String\"), false, \"short annotation VS new annotation\");\n\n    equals(QUnit.equiv(false, new Boolean()), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Boolean(), false), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(true, new Boolean(true)), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Boolean(true), true), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(true, new Boolean(1)), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(false, new Boolean(false)), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Boolean(false), false), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(false, new Boolean(0)), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(true, new Boolean(false)), false, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Boolean(false), true), false, \"short annotation VS new annotation\");\n\n    equals(QUnit.equiv(new Object(), {}), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv({}, new Object()), true, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Object(), {a:1}), false, \"short annotation VS new annotation\");\n    equals(QUnit.equiv({a:1}, new Object()), false, \"short annotation VS new annotation\");\n    equals(QUnit.equiv({a:undefined}, new Object()), false, \"short annotation VS new annotation\");\n    equals(QUnit.equiv(new Object(), {a:undefined}), false, \"short annotation VS new annotation\");\n});\n\ntest(\"Objects Basics.\", function() {\n    equals(QUnit.equiv({}, {}), true);\n    equals(QUnit.equiv({}, null), false);\n    equals(QUnit.equiv({}, undefined), false);\n    equals(QUnit.equiv({}, 0), false);\n    equals(QUnit.equiv({}, false), false);\n\n    // This test is a hard one, it is very important\n    // REASONS:\n    //      1) They are of the same type \"object\"\n    //      2) [] instanceof Object is true\n    //      3) Their properties are the same (doesn't exists)\n    equals(QUnit.equiv({}, []), false);\n\n    equals(QUnit.equiv({a:1}, {a:1}), true);\n    equals(QUnit.equiv({a:1}, {a:\"1\"}), false);\n    equals(QUnit.equiv({a:[]}, {a:[]}), true);\n    equals(QUnit.equiv({a:{}}, {a:null}), false);\n    equals(QUnit.equiv({a:1}, {}), false);\n    equals(QUnit.equiv({}, {a:1}), false);\n\n    // Hard ones\n    equals(QUnit.equiv({a:undefined}, {}), false);\n    equals(QUnit.equiv({}, {a:undefined}), false);\n    equals(QUnit.equiv(\n        {\n            a: [{ bar: undefined }]\n        },\n        {\n            a: [{ bat: undefined }]\n        }\n    ), false);\n});\n\n\ntest(\"Arrays Basics.\", function() {\n\n    equals(QUnit.equiv([], []), true);\n\n    // May be a hard one, can invoke a crash at execution.\n    // because their types are both \"object\" but null isn't\n    // like a true object, it doesn't have any property at all.\n    equals(QUnit.equiv([], null), false);\n\n    equals(QUnit.equiv([], undefined), false);\n    equals(QUnit.equiv([], false), false);\n    equals(QUnit.equiv([], 0), false);\n    equals(QUnit.equiv([], \"\"), false);\n\n    // May be a hard one, but less hard\n    // than {} with [] (note the order)\n    equals(QUnit.equiv([], {}), false);\n\n    equals(QUnit.equiv([null],[]), false);\n    equals(QUnit.equiv([undefined],[]), false);\n    equals(QUnit.equiv([],[null]), false);\n    equals(QUnit.equiv([],[undefined]), false);\n    equals(QUnit.equiv([null],[undefined]), false);\n    equals(QUnit.equiv([[]],[[]]), true);\n    equals(QUnit.equiv([[],[],[]],[[],[],[]]), true);\n    equals(QUnit.equiv(\n                            [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],\n                            [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]),\n                            true);\n    equals(QUnit.equiv(\n                            [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],\n                            [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // shorter\n                            false);\n    equals(QUnit.equiv(\n                            [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{}]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],\n                            [[],[],[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]), // deepest element not an array\n                            false);\n\n    // same multidimensional\n    equals(QUnit.equiv(\n                            [1,2,3,4,5,6,7,8,9, [\n                                1,2,3,4,5,6,7,8,9, [\n                                    1,2,3,4,5,[\n                                        [6,7,8,9, [\n                                            [\n                                                1,2,3,4,[\n                                                    2,3,4,[\n                                                        1,2,[\n                                                            1,2,3,4,[\n                                                                1,2,3,4,5,6,7,8,9,[\n                                                                    0\n                                                                ],1,2,3,4,5,6,7,8,9\n                                                            ],5,6,7,8,9\n                                                        ],4,5,6,7,8,9\n                                                    ],5,6,7,8,9\n                                                ],5,6,7\n                                            ]\n                                        ]\n                                    ]\n                                ]\n                            ]]],\n                            [1,2,3,4,5,6,7,8,9, [\n                                1,2,3,4,5,6,7,8,9, [\n                                    1,2,3,4,5,[\n                                        [6,7,8,9, [\n                                            [\n                                                1,2,3,4,[\n                                                    2,3,4,[\n                                                        1,2,[\n                                                            1,2,3,4,[\n                                                                1,2,3,4,5,6,7,8,9,[\n                                                                    0\n                                                                ],1,2,3,4,5,6,7,8,9\n                                                            ],5,6,7,8,9\n                                                        ],4,5,6,7,8,9\n                                                    ],5,6,7,8,9\n                                                ],5,6,7\n                                            ]\n                                        ]\n                                    ]\n                                ]\n                            ]]]),\n                            true, \"Multidimensional\");\n\n    // different multidimensional\n    equals(QUnit.equiv(\n                            [1,2,3,4,5,6,7,8,9, [\n                                1,2,3,4,5,6,7,8,9, [\n                                    1,2,3,4,5,[\n                                        [6,7,8,9, [\n                                            [\n                                                1,2,3,4,[\n                                                    2,3,4,[\n                                                        1,2,[\n                                                            1,2,3,4,[\n                                                                1,2,3,4,5,6,7,8,9,[\n                                                                    0\n                                                                ],1,2,3,4,5,6,7,8,9\n                                                            ],5,6,7,8,9\n                                                        ],4,5,6,7,8,9\n                                                    ],5,6,7,8,9\n                                                ],5,6,7\n                                            ]\n                                        ]\n                                    ]\n                                ]\n                            ]]],\n                            [1,2,3,4,5,6,7,8,9, [\n                                1,2,3,4,5,6,7,8,9, [\n                                    1,2,3,4,5,[\n                                        [6,7,8,9, [\n                                            [\n                                                1,2,3,4,[\n                                                    2,3,4,[\n                                                        1,2,[\n                                                            '1',2,3,4,[                 // string instead of number\n                                                                1,2,3,4,5,6,7,8,9,[\n                                                                    0\n                                                                ],1,2,3,4,5,6,7,8,9\n                                                            ],5,6,7,8,9\n                                                        ],4,5,6,7,8,9\n                                                    ],5,6,7,8,9\n                                                ],5,6,7\n                                            ]\n                                        ]\n                                    ]\n                                ]\n                            ]]]),\n                            false, \"Multidimensional\");\n\n    // different multidimensional\n    equals(QUnit.equiv(\n                            [1,2,3,4,5,6,7,8,9, [\n                                1,2,3,4,5,6,7,8,9, [\n                                    1,2,3,4,5,[\n                                        [6,7,8,9, [\n                                            [\n                                                1,2,3,4,[\n                                                    2,3,4,[\n                                                        1,2,[\n                                                            1,2,3,4,[\n                                                                1,2,3,4,5,6,7,8,9,[\n                                                                    0\n                                                                ],1,2,3,4,5,6,7,8,9\n                                                            ],5,6,7,8,9\n                                                        ],4,5,6,7,8,9\n                                                    ],5,6,7,8,9\n                                                ],5,6,7\n                                            ]\n                                        ]\n                                    ]\n                                ]\n                            ]]],\n                            [1,2,3,4,5,6,7,8,9, [\n                                1,2,3,4,5,6,7,8,9, [\n                                    1,2,3,4,5,[\n                                        [6,7,8,9, [\n                                            [\n                                                1,2,3,4,[\n                                                    2,3,[                   // missing an element (4)\n                                                        1,2,[\n                                                            1,2,3,4,[\n                                                                1,2,3,4,5,6,7,8,9,[\n                                                                    0\n                                                                ],1,2,3,4,5,6,7,8,9\n                                                            ],5,6,7,8,9\n                                                        ],4,5,6,7,8,9\n                                                    ],5,6,7,8,9\n                                                ],5,6,7\n                                            ]\n                                        ]\n                                    ]\n                                ]\n                            ]]]),\n                            false, \"Multidimensional\");\n});\n\ntest(\"Functions.\", function() {\n    var f0 = function () {};\n    var f1 = function () {};\n\n    // f2 and f3 have the same code, formatted differently\n    var f2 = function () {var i = 0;};\n    var f3 = function () {\n        var i = 0 // this comment and no semicoma as difference\n    };\n\n    equals(QUnit.equiv(function() {}, function() {}), false, \"Anonymous functions\"); // exact source code\n    equals(QUnit.equiv(function() {}, function() {return true;}), false, \"Anonymous functions\");\n\n    equals(QUnit.equiv(f0, f0), true, \"Function references\"); // same references\n    equals(QUnit.equiv(f0, f1), false, \"Function references\"); // exact source code, different references\n    equals(QUnit.equiv(f2, f3), false, \"Function references\"); // equivalent source code, different references\n    equals(QUnit.equiv(f1, f2), false, \"Function references\"); // different source code, different references\n    equals(QUnit.equiv(function() {}, true), false);\n    equals(QUnit.equiv(function() {}, undefined), false);\n    equals(QUnit.equiv(function() {}, null), false);\n    equals(QUnit.equiv(function() {}, {}), false);\n});\n\n\ntest(\"Date instances.\", function() {\n    // Date, we don't need to test Date.parse() because it returns a number.\n    // Only test the Date instances by setting them a fix date.\n    // The date use is midnight January 1, 1970\n\n    var d1 = new Date();\n    d1.setTime(0); // fix the date\n\n    var d2 = new Date();\n    d2.setTime(0); // fix the date\n\n    var d3 = new Date(); // The very now\n\n    // Anyway their types differs, just in case the code fails in the order in which it deals with date\n    equals(QUnit.equiv(d1, 0), false); // d1.valueOf() returns 0, but d1 and 0 are different\n    // test same values date and different instances equality\n    equals(QUnit.equiv(d1, d2), true);\n    // test different date and different instances difference\n    equals(QUnit.equiv(d1, d3), false);\n});\n\n\ntest(\"RegExp.\", function() {\n    // Must test cases that imply those traps:\n    // var a = /./;\n    // a instanceof Object;        // Oops\n    // a instanceof RegExp;        // Oops\n    // typeof a === \"function\";    // Oops, false in IE and Opera, true in FF and Safari (\"object\")\n\n    // Tests same regex with same modifiers in different order\n    var r = /foo/;\n    var r5 = /foo/gim;\n    var r6 = /foo/gmi;\n    var r7 = /foo/igm;\n    var r8 = /foo/img;\n    var r9 = /foo/mig;\n    var r10 = /foo/mgi;\n    var ri1 = /foo/i;\n    var ri2 = /foo/i;\n    var rm1 = /foo/m;\n    var rm2 = /foo/m;\n    var rg1 = /foo/g;\n    var rg2 = /foo/g;\n\n    equals(QUnit.equiv(r5, r6), true, \"Modifier order\");\n    equals(QUnit.equiv(r5, r7), true, \"Modifier order\");\n    equals(QUnit.equiv(r5, r8), true, \"Modifier order\");\n    equals(QUnit.equiv(r5, r9), true, \"Modifier order\");\n    equals(QUnit.equiv(r5, r10), true, \"Modifier order\");\n    equals(QUnit.equiv(r, r5), false, \"Modifier\");\n\n    equals(QUnit.equiv(ri1, ri2), true, \"Modifier\");\n    equals(QUnit.equiv(r, ri1), false, \"Modifier\");\n    equals(QUnit.equiv(ri1, rm1), false, \"Modifier\");\n    equals(QUnit.equiv(r, rm1), false, \"Modifier\");\n    equals(QUnit.equiv(rm1, ri1), false, \"Modifier\");\n    equals(QUnit.equiv(rm1, rm2), true, \"Modifier\");\n    equals(QUnit.equiv(rg1, rm1), false, \"Modifier\");\n    equals(QUnit.equiv(rm1, rg1), false, \"Modifier\");\n    equals(QUnit.equiv(rg1, rg2), true, \"Modifier\");\n\n    // Different regex, same modifiers\n    var r11 = /[a-z]/gi;\n    var r13 = /[0-9]/gi; // oops! different\n    equals(QUnit.equiv(r11, r13), false, \"Regex pattern\");\n\n    var r14 = /0/ig;\n    var r15 = /\"0\"/ig; // oops! different\n    equals(QUnit.equiv(r14, r15), false, \"Regex pattern\");\n\n    var r1 = /[\\n\\r\\u2028\\u2029]/g;\n    var r2 = /[\\n\\r\\u2028\\u2029]/g;\n    var r3 = /[\\n\\r\\u2028\\u2028]/g; // differs from r1\n    var r4 = /[\\n\\r\\u2028\\u2029]/;  // differs from r1\n\n    equals(QUnit.equiv(r1, r2), true, \"Regex pattern\");\n    equals(QUnit.equiv(r1, r3), false, \"Regex pattern\");\n    equals(QUnit.equiv(r1, r4), false, \"Regex pattern\");\n\n    // More complex regex\n    var regex1 = \"^[-_.a-z0-9]+@([-_a-z0-9]+\\\\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$\";\n    var regex2 = \"^[-_.a-z0-9]+@([-_a-z0-9]+\\\\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$\";\n    // regex 3 is different: '.' not escaped\n    var regex3 = \"^[-_.a-z0-9]+@([-_a-z0-9]+.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$\";\n\n    var r21 = new RegExp(regex1);\n    var r22 = new RegExp(regex2);\n    var r23 = new RegExp(regex3); // diff from r21, not same pattern\n    var r23a = new RegExp(regex3, \"gi\"); // diff from r23, not same modifier\n    var r24a = new RegExp(regex3, \"ig\"); // same as r23a\n\n    equals(QUnit.equiv(r21, r22), true, \"Complex Regex\");\n    equals(QUnit.equiv(r21, r23), false, \"Complex Regex\");\n    equals(QUnit.equiv(r23, r23a), false, \"Complex Regex\");\n    equals(QUnit.equiv(r23a, r24a), true, \"Complex Regex\");\n\n    // typeof r1 is \"function\" in some browsers and \"object\" in others so we must cover this test\n    var re = / /;\n    equals(QUnit.equiv(re, function () {}), false, \"Regex internal\");\n    equals(QUnit.equiv(re, {}), false, \"Regex internal\");\n});\n\n\ntest(\"Complex Objects.\", function() {\n\n    function fn1() {\n        return \"fn1\";\n    }\n    function fn2() {\n        return \"fn2\";\n    }\n\n    // Try to invert the order of some properties to make sure it is covered.\n    // It can failed when properties are compared between unsorted arrays.\n    equals(QUnit.equiv(\n        {\n            a: 1,\n            b: null,\n            c: [{}],\n            d: {\n                a: 3.14159,\n                b: false,\n                c: {\n                    e: fn1,\n                    f: [[[]]],\n                    g: {\n                        j: {\n                            k: {\n                                n: {\n                                    r: \"r\",\n                                    s: [1,2,3],\n                                    t: undefined,\n                                    u: 0,\n                                    v: {\n                                        w: {\n                                            x: {\n                                                y: \"Yahoo!\",\n                                                z: null\n                                            }\n                                        }\n                                    }\n                                },\n                                q: [],\n                                p: 1/0,\n                                o: 99\n                            },\n                            l: undefined,\n                            m: null\n                        }\n                    },\n                    d: 0,\n                    i: true,\n                    h: \"false\"\n                }\n            },\n            e: undefined,\n            g: \"\",\n            h: \"h\",\n            f: {},\n            i: []\n        },\n        {\n            a: 1,\n            b: null,\n            c: [{}],\n            d: {\n                b: false,\n                a: 3.14159,\n                c: {\n                    d: 0,\n                    e: fn1,\n                    f: [[[]]],\n                    g: {\n                        j: {\n                            k: {\n                                n: {\n                                    r: \"r\",\n                                    t: undefined,\n                                    u: 0,\n                                    s: [1,2,3],\n                                    v: {\n                                        w: {\n                                            x: {\n                                                z: null,\n                                                y: \"Yahoo!\"\n                                            }\n                                        }\n                                    }\n                                },\n                                o: 99,\n                                p: 1/0,\n                                q: []\n                            },\n                            l: undefined,\n                            m: null\n                        }\n                    },\n                    i: true,\n                    h: \"false\"\n                }\n            },\n            e: undefined,\n            g: \"\",\n            f: {},\n            h: \"h\",\n            i: []\n        }\n    ), true);\n\n    equals(QUnit.equiv(\n        {\n            a: 1,\n            b: null,\n            c: [{}],\n            d: {\n                a: 3.14159,\n                b: false,\n                c: {\n                    d: 0,\n                    e: fn1,\n                    f: [[[]]],\n                    g: {\n                        j: {\n                            k: {\n                                n: {\n                                    //r: \"r\",   // different: missing a property\n                                    s: [1,2,3],\n                                    t: undefined,\n                                    u: 0,\n                                    v: {\n                                        w: {\n                                            x: {\n                                                y: \"Yahoo!\",\n                                                z: null\n                                            }\n                                        }\n                                    }\n                                },\n                                o: 99,\n                                p: 1/0,\n                                q: []\n                            },\n                            l: undefined,\n                            m: null\n                        }\n                    },\n                    h: \"false\",\n                    i: true\n                }\n            },\n            e: undefined,\n            f: {},\n            g: \"\",\n            h: \"h\",\n            i: []\n        },\n        {\n            a: 1,\n            b: null,\n            c: [{}],\n            d: {\n                a: 3.14159,\n                b: false,\n                c: {\n                    d: 0,\n                    e: fn1,\n                    f: [[[]]],\n                    g: {\n                        j: {\n                            k: {\n                                n: {\n                                    r: \"r\",\n                                    s: [1,2,3],\n                                    t: undefined,\n                                    u: 0,\n                                    v: {\n                                        w: {\n                                            x: {\n                                                y: \"Yahoo!\",\n                                                z: null\n                                            }\n                                        }\n                                    }\n                                },\n                                o: 99,\n                                p: 1/0,\n                                q: []\n                            },\n                            l: undefined,\n                            m: null\n                        }\n                    },\n                    h: \"false\",\n                    i: true\n                }\n            },\n            e: undefined,\n            f: {},\n            g: \"\",\n            h: \"h\",\n            i: []\n        }\n    ), false);\n\n    equals(QUnit.equiv(\n        {\n            a: 1,\n            b: null,\n            c: [{}],\n            d: {\n                a: 3.14159,\n                b: false,\n                c: {\n                    d: 0,\n                    e: fn1,\n                    f: [[[]]],\n                    g: {\n                        j: {\n                            k: {\n                                n: {\n                                    r: \"r\",\n                                    s: [1,2,3],\n                                    t: undefined,\n                                    u: 0,\n                                    v: {\n                                        w: {\n                                            x: {\n                                                y: \"Yahoo!\",\n                                                z: null\n                                            }\n                                        }\n                                    }\n                                },\n                                o: 99,\n                                p: 1/0,\n                                q: []\n                            },\n                            l: undefined,\n                            m: null\n                        }\n                    },\n                    h: \"false\",\n                    i: true\n                }\n            },\n            e: undefined,\n            f: {},\n            g: \"\",\n            h: \"h\",\n            i: []\n        },\n        {\n            a: 1,\n            b: null,\n            c: [{}],\n            d: {\n                a: 3.14159,\n                b: false,\n                c: {\n                    d: 0,\n                    e: fn1,\n                    f: [[[]]],\n                    g: {\n                        j: {\n                            k: {\n                                n: {\n                                    r: \"r\",\n                                    s: [1,2,3],\n                                    //t: undefined,                 // different: missing a property with an undefined value\n                                    u: 0,\n                                    v: {\n                                        w: {\n                                            x: {\n                                                y: \"Yahoo!\",\n                                                z: null\n                                            }\n                                        }\n                                    }\n                                },\n                                o: 99,\n                                p: 1/0,\n                                q: []\n                            },\n                            l: undefined,\n                            m: null\n                        }\n                    },\n                    h: \"false\",\n                    i: true\n                }\n            },\n            e: undefined,\n            f: {},\n            g: \"\",\n            h: \"h\",\n            i: []\n        }\n    ), false);\n\n    equals(QUnit.equiv(\n        {\n            a: 1,\n            b: null,\n            c: [{}],\n            d: {\n                a: 3.14159,\n                b: false,\n                c: {\n                    d: 0,\n                    e: fn1,\n                    f: [[[]]],\n                    g: {\n                        j: {\n                            k: {\n                                n: {\n                                    r: \"r\",\n                                    s: [1,2,3],\n                                    t: undefined,\n                                    u: 0,\n                                    v: {\n                                        w: {\n                                            x: {\n                                                y: \"Yahoo!\",\n                                                z: null\n                                            }\n                                        }\n                                    }\n                                },\n                                o: 99,\n                                p: 1/0,\n                                q: []\n                            },\n                            l: undefined,\n                            m: null\n                        }\n                    },\n                    h: \"false\",\n                    i: true\n                }\n            },\n            e: undefined,\n            f: {},\n            g: \"\",\n            h: \"h\",\n            i: []\n        },\n        {\n            a: 1,\n            b: null,\n            c: [{}],\n            d: {\n                a: 3.14159,\n                b: false,\n                c: {\n                    d: 0,\n                    e: fn1,\n                    f: [[[]]],\n                    g: {\n                        j: {\n                            k: {\n                                n: {\n                                    r: \"r\",\n                                    s: [1,2,3],\n                                    t: undefined,\n                                    u: 0,\n                                    v: {\n                                        w: {\n                                            x: {\n                                                y: \"Yahoo!\",\n                                                z: null\n                                            }\n                                        }\n                                    }\n                                },\n                                o: 99,\n                                p: 1/0,\n                                q: {}           // different was []\n                            },\n                            l: undefined,\n                            m: null\n                        }\n                    },\n                    h: \"false\",\n                    i: true\n                }\n            },\n            e: undefined,\n            f: {},\n            g: \"\",\n            h: \"h\",\n            i: []\n        }\n    ), false);\n\n    var same1 = {\n        a: [\n            \"string\", null, 0, \"1\", 1, {\n                prop: null,\n                foo: [1,2,null,{}, [], [1,2,3]],\n                bar: undefined\n            }, 3, \"Hey!\", \"Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας\"\n        ],\n        unicode: \"老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争\",\n        b: \"b\",\n        c: fn1\n    };\n\n    var same2 = {\n        a: [\n            \"string\", null, 0, \"1\", 1, {\n                prop: null,\n                foo: [1,2,null,{}, [], [1,2,3]],\n                bar: undefined\n            }, 3, \"Hey!\", \"Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας\"\n        ],\n        unicode: \"老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争\",\n        b: \"b\",\n        c: fn1\n    };\n\n    var diff1 = {\n        a: [\n            \"string\", null, 0, \"1\", 1, {\n                prop: null,\n                foo: [1,2,null,{}, [], [1,2,3,4]], // different: 4 was add to the array\n                bar: undefined\n            }, 3, \"Hey!\", \"Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας\"\n        ],\n        unicode: \"老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争\",\n        b: \"b\",\n        c: fn1\n    };\n\n    var diff2 = {\n        a: [\n            \"string\", null, 0, \"1\", 1, {\n                prop: null,\n                foo: [1,2,null,{}, [], [1,2,3]],\n                newprop: undefined, // different: newprop was added\n                bar: undefined\n            }, 3, \"Hey!\", \"Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας\"\n        ],\n        unicode: \"老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争\",\n        b: \"b\",\n        c: fn1\n    };\n\n    var diff3 = {\n        a: [\n            \"string\", null, 0, \"1\", 1, {\n                prop: null,\n                foo: [1,2,null,{}, [], [1,2,3]],\n                bar: undefined\n            }, 3, \"Hey!\", \"Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ α\" // different: missing last char\n        ],\n        unicode: \"老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争\",\n        b: \"b\",\n        c: fn1\n    };\n\n    var diff4 = {\n        a: [\n            \"string\", null, 0, \"1\", 1, {\n                prop: null,\n                foo: [1,2,undefined,{}, [], [1,2,3]], // different: undefined instead of null\n                bar: undefined\n            }, 3, \"Hey!\", \"Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας\"\n        ],\n        unicode: \"老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争\",\n        b: \"b\",\n        c: fn1\n    };\n\n    var diff5 = {\n        a: [\n            \"string\", null, 0, \"1\", 1, {\n                prop: null,\n                foo: [1,2,null,{}, [], [1,2,3]],\n                bat: undefined // different: property name not \"bar\"\n            }, 3, \"Hey!\", \"Κάνε πάντα γνωρίζουμε ας των, μηχανής επιδιόρθωσης επιδιορθώσεις ώς μια. Κλπ ας\"\n        ],\n        unicode: \"老 汉语中存在 港澳和海外的华人圈中 贵州 我去了书店 现在尚有争\",\n        b: \"b\",\n        c: fn1\n    };\n\n    equals(QUnit.equiv(same1, same2), true);\n    equals(QUnit.equiv(same2, same1), true);\n    equals(QUnit.equiv(same2, diff1), false);\n    equals(QUnit.equiv(diff1, same2), false);\n\n    equals(QUnit.equiv(same1, diff1), false);\n    equals(QUnit.equiv(same1, diff2), false);\n    equals(QUnit.equiv(same1, diff3), false);\n    equals(QUnit.equiv(same1, diff3), false);\n    equals(QUnit.equiv(same1, diff4), false);\n    equals(QUnit.equiv(same1, diff5), false);\n    equals(QUnit.equiv(diff5, diff1), false);\n});\n\n\ntest(\"Complex Arrays.\", function() {\n\n    function fn() {\n    }\n\n    equals(QUnit.equiv(\n                [1, 2, 3, true, {}, null, [\n                    {\n                        a: [\"\", '1', 0]\n                    },\n                    5, 6, 7\n                ], \"foo\"],\n                [1, 2, 3, true, {}, null, [\n                    {\n                        a: [\"\", '1', 0]\n                    },\n                    5, 6, 7\n                ], \"foo\"]),\n            true);\n\n    equals(QUnit.equiv(\n                [1, 2, 3, true, {}, null, [\n                    {\n                        a: [\"\", '1', 0]\n                    },\n                    5, 6, 7\n                ], \"foo\"],\n                [1, 2, 3, true, {}, null, [\n                    {\n                        b: [\"\", '1', 0]         // not same property name\n                    },\n                    5, 6, 7\n                ], \"foo\"]),\n            false);\n\n    var a = [{\n        b: fn,\n        c: false,\n        \"do\": \"reserved word\",\n        \"for\": {\n            ar: [3,5,9,\"hey!\", [], {\n                ar: [1,[\n                    3,4,6,9, null, [], []\n                ]],\n                e: fn,\n                f: undefined\n            }]\n        },\n        e: 0.43445\n    }, 5, \"string\", 0, fn, false, null, undefined, 0, [\n        4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n    ], [], [[[], \"foo\", null, {\n        n: 1/0,\n        z: {\n            a: [3,4,5,6,\"yep!\", undefined, undefined],\n            b: {}\n        }\n    }, {}]]];\n\n    equals(QUnit.equiv(a,\n            [{\n                b: fn,\n                c: false,\n                \"do\": \"reserved word\",\n                \"for\": {\n                    ar: [3,5,9,\"hey!\", [], {\n                        ar: [1,[\n                            3,4,6,9, null, [], []\n                        ]],\n                        e: fn,\n                        f: undefined\n                    }]\n                },\n                e: 0.43445\n            }, 5, \"string\", 0, fn, false, null, undefined, 0, [\n                4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n            ], [], [[[], \"foo\", null, {\n                n: 1/0,\n                z: {\n                    a: [3,4,5,6,\"yep!\", undefined, undefined],\n                    b: {}\n                }\n            }, {}]]]), true);\n\n    equals(QUnit.equiv(a,\n            [{\n                b: fn,\n                c: false,\n                \"do\": \"reserved word\",\n                \"for\": {\n                    ar: [3,5,9,\"hey!\", [], {\n                        ar: [1,[\n                            3,4,6,9, null, [], []\n                        ]],\n                        e: fn,\n                        f: undefined\n                    }]\n                },\n                e: 0.43445\n            }, 5, \"string\", 0, fn, false, null, undefined, 0, [\n                4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[2]]]], \"3\"], {}, 1/0    // different: [[[[[2]]]]] instead of [[[[[3]]]]]\n            ], [], [[[], \"foo\", null, {\n                n: 1/0,\n                z: {\n                    a: [3,4,5,6,\"yep!\", undefined, undefined],\n                    b: {}\n                }\n            }, {}]]]), false);\n\n    equals(QUnit.equiv(a,\n            [{\n                b: fn,\n                c: false,\n                \"do\": \"reserved word\",\n                \"for\": {\n                    ar: [3,5,9,\"hey!\", [], {\n                        ar: [1,[\n                            3,4,6,9, null, [], []\n                        ]],\n                        e: fn,\n                        f: undefined\n                    }]\n                },\n                e: 0.43445\n            }, 5, \"string\", 0, fn, false, null, undefined, 0, [\n                4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n            ], [], [[[], \"foo\", null, {\n                n: -1/0,                                                                // different, -Infinity instead of Infinity\n                z: {\n                    a: [3,4,5,6,\"yep!\", undefined, undefined],\n                    b: {}\n                }\n            }, {}]]]), false);\n\n    equals(QUnit.equiv(a,\n            [{\n                b: fn,\n                c: false,\n                \"do\": \"reserved word\",\n                \"for\": {\n                    ar: [3,5,9,\"hey!\", [], {\n                        ar: [1,[\n                            3,4,6,9, null, [], []\n                        ]],\n                        e: fn,\n                        f: undefined\n                    }]\n                },\n                e: 0.43445\n            }, 5, \"string\", 0, fn, false, null, undefined, 0, [\n                4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n            ], [], [[[], \"foo\", {                                                       // different: null is missing\n                n: 1/0,\n                z: {\n                    a: [3,4,5,6,\"yep!\", undefined, undefined],\n                    b: {}\n                }\n            }, {}]]]), false);\n\n    equals(QUnit.equiv(a,\n            [{\n                b: fn,\n                c: false,\n                \"do\": \"reserved word\",\n                \"for\": {\n                    ar: [3,5,9,\"hey!\", [], {\n                        ar: [1,[\n                            3,4,6,9, null, [], []\n                        ]],\n                        e: fn\n                                                                                // different: missing property f: undefined\n                    }]\n                },\n                e: 0.43445\n            }, 5, \"string\", 0, fn, false, null, undefined, 0, [\n                4,5,6,7,8,9,11,22,33,44,55,\"66\", null, [], [[[[[3]]]], \"3\"], {}, 1/0\n            ], [], [[[], \"foo\", null, {\n                n: 1/0,\n                z: {\n                    a: [3,4,5,6,\"yep!\", undefined, undefined],\n                    b: {}\n                }\n            }, {}]]]), false);\n});\n\n\ntest(\"Prototypal inheritance\", function() {\n    function Gizmo(id) {\n        this.id = id;\n    }\n\n    function Hoozit(id) {\n        this.id = id;\n    }\n    Hoozit.prototype = new Gizmo();\n\n    var gizmo = new Gizmo(\"ok\");\n    var hoozit = new Hoozit(\"ok\");\n\n    // Try this test many times after test on instances that hold function\n    // to make sure that our code does not mess with last object constructor memoization.\n    equals(QUnit.equiv(function () {}, function () {}), false);\n\n    // Hoozit inherit from Gizmo\n    // hoozit instanceof Hoozit; // true\n    // hoozit instanceof Gizmo; // true\n    equals(QUnit.equiv(hoozit, gizmo), true);\n\n    Gizmo.prototype.bar = true; // not a function just in case we skip them\n\n    // Hoozit inherit from Gizmo\n    // They are equivalent\n    equals(QUnit.equiv(hoozit, gizmo), true);\n\n    // Make sure this is still true !important\n    // The reason for this is that I forgot to reset the last\n    // caller to where it were called from.\n    equals(QUnit.equiv(function () {}, function () {}), false);\n\n    // Make sure this is still true !important\n    equals(QUnit.equiv(hoozit, gizmo), true);\n\n    Hoozit.prototype.foo = true; // not a function just in case we skip them\n\n    // Gizmo does not inherit from Hoozit\n    // gizmo instanceof Gizmo; // true\n    // gizmo instanceof Hoozit; // false\n    // They are not equivalent\n    equals(QUnit.equiv(hoozit, gizmo), false);\n\n    // Make sure this is still true !important\n    equals(QUnit.equiv(function () {}, function () {}), false);\n});\n\n\ntest(\"Instances\", function() {\n    function A() {}\n    var a1 = new A();\n    var a2 = new A();\n\n    function B() {\n        this.fn = function () {};\n    }\n    var b1 = new B();\n    var b2 = new B();\n\n    equals(QUnit.equiv(a1, a2), true, \"Same property, same constructor\");\n\n    // b1.fn and b2.fn are functions but they are different references\n    // But we decided to skip function for instances.\n    equals(QUnit.equiv(b1, b2), true, \"Same property, same constructor\");\n    equals(QUnit.equiv(a1, b1), false, \"Same properties but different constructor\"); // failed\n\n    function Car(year) {\n        var privateVar = 0;\n        this.year = year;\n        this.isOld = function() {\n            return year > 10;\n        };\n    }\n\n    function Human(year) {\n        var privateVar = 1;\n        this.year = year;\n        this.isOld = function() {\n            return year > 80;\n        };\n    }\n\n    var car = new Car(30);\n    var carSame = new Car(30);\n    var carDiff = new Car(10);\n    var human = new Human(30);\n\n    var diff = {\n        year: 30\n    };\n\n    var same = {\n        year: 30,\n        isOld: function () {}\n    };\n\n    equals(QUnit.equiv(car, car), true);\n    equals(QUnit.equiv(car, carDiff), false);\n    equals(QUnit.equiv(car, carSame), true);\n    equals(QUnit.equiv(car, human), false);\n});\n\n\ntest(\"Complex Instances Nesting (with function value in literals and/or in nested instances)\", function() {\n    function A(fn) {\n        this.a = {};\n        this.fn = fn;\n        this.b = {a: []};\n        this.o = {};\n        this.fn1 = fn;\n    }\n    function B(fn) {\n        this.fn = fn;\n        this.fn1 = function () {};\n        this.a = new A(function () {});\n    }\n\n    function fnOutside() {\n    }\n\n    function C(fn) {\n        function fnInside() {\n        }\n        this.x = 10;\n        this.fn = fn;\n        this.fn1 = function () {};\n        this.fn2 = fnInside;\n        this.fn3 = {\n            a: true,\n            b: fnOutside // ok make reference to a function in all instances scope\n        };\n        this.o1 = {};\n\n        // This function will be ignored.\n        // Even if it is not visible for all instances (e.g. locked in a closures),\n        // it is from a  property that makes part of an instance (e.g. from the C constructor)\n        this.b1 = new B(function () {});\n        this.b2 = new B({\n            x: {\n                b2: new B(function() {})\n            }\n        });\n    }\n\n    function D(fn) {\n        function fnInside() {\n        }\n        this.x = 10;\n        this.fn = fn;\n        this.fn1 = function () {};\n        this.fn2 = fnInside;\n        this.fn3 = {\n            a: true,\n            b: fnOutside, // ok make reference to a function in all instances scope\n\n            // This function won't be ingored.\n            // It isn't visible for all C insances\n            // and it is not in a property of an instance. (in an Object instances e.g. the object literal)\n            c: fnInside\n        };\n        this.o1 = {};\n\n        // This function will be ignored.\n        // Even if it is not visible for all instances (e.g. locked in a closures),\n        // it is from a  property that makes part of an instance (e.g. from the C constructor)\n        this.b1 = new B(function () {});\n        this.b2 = new B({\n            x: {\n                b2: new B(function() {})\n            }\n        });\n    }\n\n    function E(fn) {\n        function fnInside() {\n        }\n        this.x = 10;\n        this.fn = fn;\n        this.fn1 = function () {};\n        this.fn2 = fnInside;\n        this.fn3 = {\n            a: true,\n            b: fnOutside // ok make reference to a function in all instances scope\n        };\n        this.o1 = {};\n\n        // This function will be ignored.\n        // Even if it is not visible for all instances (e.g. locked in a closures),\n        // it is from a  property that makes part of an instance (e.g. from the C constructor)\n        this.b1 = new B(function () {});\n        this.b2 = new B({\n            x: {\n                b1: new B({a: function() {}}),\n                b2: new B(function() {})\n            }\n        });\n    }\n\n\n    var a1 = new A(function () {});\n    var a2 = new A(function () {});\n    equals(QUnit.equiv(a1, a2), true);\n\n    equals(QUnit.equiv(a1, a2), true); // different instances\n\n    var b1 = new B(function () {});\n    var b2 = new B(function () {});\n    equals(QUnit.equiv(b1, b2), true);\n\n    var c1 = new C(function () {});\n    var c2 = new C(function () {});\n    equals(QUnit.equiv(c1, c2), true);\n\n    var d1 = new D(function () {});\n    var d2 = new D(function () {});\n    equals(QUnit.equiv(d1, d2), false);\n\n    var e1 = new E(function () {});\n    var e2 = new E(function () {});\n    equals(QUnit.equiv(e1, e2), false);\n\n});\n\n\ntest('object with references to self wont loop', function(){\n    var circularA = {\n        abc:null\n    }, circularB = {\n        abc:null\n    };\n    circularA.abc = circularA;\n    circularB.abc = circularB;\n    equals(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on object (ambigous test)\");\n\n    circularA.def = 1;\n    circularB.def = 1;\n    equals(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on object (ambigous test)\");\n\n    circularA.def = 1;\n    circularB.def = 0;\n    equals(QUnit.equiv(circularA, circularB), false, \"Should not repeat test on object (unambigous test)\");\n});\n\ntest('array with references to self wont loop', function(){\n    var circularA = [],\n        circularB = [];\n    circularA.push(circularA);\n    circularB.push(circularB);\n    equals(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on array (ambigous test)\");\n\n    circularA.push( 'abc' );\n    circularB.push( 'abc' );\n    equals(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on array (ambigous test)\");\n\n    circularA.push( 'hello' );\n    circularB.push( 'goodbye' );\n    equals(QUnit.equiv(circularA, circularB), false, \"Should not repeat test on array (unambigous test)\");\n});\n\ntest('mixed object/array with references to self wont loop', function(){\n    var circularA = [{abc:null}],\n        circularB = [{abc:null}];\n    circularA[0].abc = circularA;\n    circularB[0].abc = circularB;\n\n    circularA.push(circularA);\n    circularB.push(circularB);\n    equals(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on object/array (ambigous test)\");\n\n    circularA[0].def = 1;\n    circularB[0].def = 1;\n    equals(QUnit.equiv(circularA, circularB), true, \"Should not repeat test on object/array (ambigous test)\");\n\n    circularA[0].def = 1;\n    circularB[0].def = 0;\n    equals(QUnit.equiv(circularA, circularB), false, \"Should not repeat test on object/array (unambigous test)\");\n});\n\ntest(\"Test that must be done at the end because they extend some primitive's prototype\", function() {\n    // Try that a function looks like our regular expression.\n    // This tests if we check that a and b are really both instance of RegExp\n    Function.prototype.global = true;\n    Function.prototype.multiline = true;\n    Function.prototype.ignoreCase = false;\n    Function.prototype.source = \"my regex\";\n    var re = /my regex/gm;\n    equals(QUnit.equiv(re, function () {}), false, \"A function that looks that a regex isn't a regex\");\n    // This test will ensures it works in both ways, and ALSO especially that we can make differences\n    // between RegExp and Function constructor because typeof on a RegExpt instance is \"function\"\n    equals(QUnit.equiv(function () {}, re), false, \"Same conversely, but ensures that function and regexp are distinct because their constructor are different\");\n});\n"
  },
  {
    "path": "vendor/qunit/test/swarminject.js",
    "content": "// load testswarm agent\n(function() {\n    var url = window.location.search;\n\turl = decodeURIComponent( url.slice( url.indexOf(\"swarmURL=\") + 9 ) );\n\tif ( !url || url.indexOf(\"http\") !== 0 ) {\n\t\treturn;\n\t}\n\t/*jshint evil:true */\n    document.write(\"<scr\" + \"ipt src='http://swarm.jquery.org/js/inject.js?\" + (new Date()).getTime() + \"'></scr\" + \"ipt>\");\n})();\n"
  },
  {
    "path": "vendor/qunit/test/test.js",
    "content": "function getPreviousTests( rTestName, rModuleName ) {\n\tvar testSpan, moduleSpan,\n\t\tmatches = [],\n\t\ti = 0,\n\t\trModule = /(^| )module-name( |$)/,\n\t\ttestNames = typeof document.getElementsByClassName !== \"undefined\" ?\n\t\t\tdocument.getElementsByClassName(\"test-name\") :\n\t\t\t(function( spans ) {\n\t\t\t\tvar span,\n\t\t\t\t\ttests = [],\n\t\t\t\t\ti = 0,\n\t\t\t\t\trTest = /(^| )test-name( |$)/;\n\t\t\t\tfor ( ; (span = spans[i]); i++ ) {\n\t\t\t\t\tif ( rTest.test( span.className ) ) {\n\t\t\t\t\t\ttests.push( span );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn tests;\n\t\t\t})( document.getElementsByTagName(\"span\") );\n\n\tfor ( ; (testSpan = testNames[i]); i++ ) {\n\t\tmoduleSpan = testSpan;\n\t\twhile ( (moduleSpan = moduleSpan.previousSibling) ) {\n\t\t\tif ( rModule.test( moduleSpan.className ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif ( (!rTestName || rTestName.test( testSpan.innerHTML )) &&\n\t\t\t(!rModuleName || moduleSpan && rModuleName.test( moduleSpan.innerHTML )) ) {\n\n\t\t\twhile ( (testSpan = testSpan.parentNode) ) {\n\t\t\t\tif ( testSpan.nodeName.toLowerCase() === \"li\" ) {\n\t\t\t\t\tmatches.push( testSpan );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn matches;\n}\n\ntest(\"module without setup/teardown (default)\", function() {\n\texpect(1);\n\tok(true);\n});\n\ntest(\"expect in test\", 3, function() {\n\tok(true);\n\tok(true);\n\tok(true);\n});\n\ntest(\"expect in test\", 1, function() {\n\tok(true);\n});\n\ntest(\"expect query and multiple issue\", function() {\n\texpect(2);\n\tok(true);\n\tvar expected = expect();\n\tequal(expected, 2);\n\texpect(expected + 1);\n\tok(true);\n});\n\nQUnit.module(\"assertion helpers\");\n\nQUnit.test( \"QUnit.assert compatibility\", 5, function( assert ) {\n\tassert.ok( true, \"Calling method on `assert` argument to test() callback\" );\n\n\t// Should also work, although discouraged and not documented\n\tQUnit.assert.ok( true, \"Calling method on QUnit.assert object\" );\n\n\t// Test compatibility aliases\n\tQUnit.ok( true, \"Calling aliased method in QUnit root object\" );\n\tok( true, \"Calling aliased function in global namespace\" );\n\n\t// Regression fix for #341\n\t// The assert-context way of testing discouraged global variables,\n\t// it doesn't make sense of it itself to be a global variable.\n\t// Only allows for mistakes (e.g. forgetting to list 'assert' as parameter)\n\tassert.notStrictEqual( window.assert, QUnit.assert, \"Assert does not get exposed as a global variable\" );\n});\n\nmodule(\"setup test\", {\n\tsetup: function() {\n\t\tok(true);\n\t}\n});\n\ntest(\"module with setup\", function() {\n\texpect(2);\n\tok(true);\n});\n\ntest(\"module with setup, expect in test call\", 2, function() {\n\tok(true);\n});\n\nmodule(\"<script id='qunit-unescaped-module'>'module';</script>\", {\n\tsetup: function() {\n\t},\n\tteardown: function() {\n\t\t// We can't use ok(false) inside script tags since some browsers\n\t\t// don't evaluate script tags inserted through innerHTML after domready.\n\t\t// Counting them before/after doesn't cover everything either as qunit-modulefilter\n\t\t// is created before any test is ran. So use ids instead.\n\t\tif (document.getElementById('qunit-unescaped-module')) {\n\t\t\t// This can either be from in #qunit-modulefilter or #qunit-testresult\n\t\t\tok(false, 'Unscaped module name');\n\t\t}\n\t\tif (document.getElementById('qunit-unescaped-test')) {\n\t\t\tok(false, 'Unscaped test name');\n\t\t}\n\t\tif (document.getElementById('qunit-unescaped-assertion')) {\n\t\t\tok(false, 'Unscaped test name');\n\t\t}\n\t}\n});\n\ntest(\"<script id='qunit-unescaped-test'>'test';</script>\", 1, function() {\n\tok(true, \"<script id='qunit-unescaped-asassertionsert'>'assertion';</script>\");\n});\n\nvar state;\n\nmodule(\"setup/teardown test\", {\n\tsetup: function() {\n\t\tstate = true;\n\t\tok(true);\n\t\t// Assert that we can introduce and delete globals in setup/teardown\n\t\t// without noglobals sounding any alarm.\n\n\t\t// Using an implied global variable instead of explicit window property\n\t\t// because there is no way to delete a window.property in IE6-8\n\t\t// `delete x` only works for `x = 1, and `delete window.x` throws exception.\n\t\t// No one-code fits all solution possible afaic. Resort to @cc.\n\n\t\t/*@cc_on\n\t\t\t@if (@_jscript_version < 9)\n\t\t\t\tx = 1;\n\t\t\t@else @*/\n\t\t\t\twindow.x = 1;\n\t\t\t/*@end\n\t\t@*/\n\t},\n\tteardown: function() {\n\t\tok(true);\n\n\t\t/*@cc_on\n\t\t\t@if (@_jscript_version < 9)\n\t\t\t\tdelete x;\n\t\t\t@else @*/\n\t\t\t\tdelete window.x;\n\t\t\t/*@end\n\t\t@*/\n\t}\n});\n\ntest(\"module with setup/teardown\", function() {\n\texpect(3);\n\tok(true);\n});\n\nmodule(\"setup/teardown test 2\");\n\ntest(\"module without setup/teardown\", function() {\n\texpect(1);\n\tok(true);\n});\n\nvar orgDate;\n\nmodule(\"Date test\", {\n\tsetup: function() {\n\t\torgDate = Date;\n\t\twindow.Date = function () {\n\t\t\tok( false, 'QUnit should internally be independant from Date-related manipulation and testing' );\n\t\t\treturn new orgDate();\n\t\t};\n\t},\n\tteardown: function() {\n\t\twindow.Date = orgDate;\n\t}\n});\n\ntest(\"sample test for Date test\", function () {\n\texpect(1);\n\tok(true);\n});\n\nif (typeof setTimeout !== 'undefined') {\nstate = 'fail';\n\nmodule(\"teardown and stop\", {\n\tteardown: function() {\n\t\tequal(state, \"done\", \"Test teardown.\");\n\t}\n});\n\ntest(\"teardown must be called after test ended\", function() {\n\texpect(1);\n\tstop();\n\tsetTimeout(function() {\n\t\tstate = \"done\";\n\t\tstart();\n\t}, 13);\n});\n\ntest(\"parameter passed to stop increments semaphore n times\", function() {\n\texpect(1);\n\tstop(3);\n\tsetTimeout(function() {\n\t\tstate = \"not enough starts\";\n\t\tstart();\n\t\tstart();\n\t}, 13);\n\tsetTimeout(function() {\n\t\tstate = \"done\";\n\t\tstart();\n\t}, 15);\n});\n\ntest(\"parameter passed to start decrements semaphore n times\", function() {\n\texpect(1);\n\tstop();\n\tstop();\n\tstop();\n\tsetTimeout(function() {\n\t\tstate = \"done\";\n\t\tstart(3);\n\t}, 18);\n});\n\nmodule(\"async setup test\", {\n\tsetup: function() {\n\t\tstop();\n\t\tsetTimeout(function() {\n\t\t\tok(true);\n\t\t\tstart();\n\t\t}, 500);\n\t}\n});\n\nasyncTest(\"module with async setup\", function() {\n\texpect(2);\n\tok(true);\n\tstart();\n});\n\nmodule(\"async teardown test\", {\n\tteardown: function() {\n\t\tstop();\n\t\tsetTimeout(function() {\n\t\t\tok(true);\n\t\t\tstart();\n\t\t}, 500);\n\t}\n});\n\nasyncTest(\"module with async teardown\", function() {\n\texpect(2);\n\tok(true);\n\tstart();\n});\n\nmodule(\"asyncTest\");\n\nasyncTest(\"asyncTest\", function() {\n\texpect(2);\n\tok(true);\n\tsetTimeout(function() {\n\t\tstate = \"done\";\n\t\tok(true);\n\t\tstart();\n\t}, 13);\n});\n\nasyncTest(\"asyncTest\", 2, function() {\n\tok(true);\n\tsetTimeout(function() {\n\t\tstate = \"done\";\n\t\tok(true);\n\t\tstart();\n\t}, 13);\n});\n\ntest(\"sync\", 2, function() {\n\tstop();\n\tsetTimeout(function() {\n\t\tok(true);\n\t\tstart();\n\t}, 13);\n\tstop();\n\tsetTimeout(function() {\n\t\tok(true);\n\t\tstart();\n\t}, 125);\n});\n\ntest(\"test synchronous calls to stop\", 2, function() {\n\tstop();\n\tsetTimeout(function() {\n\t\tok(true, 'first');\n\t\tstart();\n\t\tstop();\n\t\tsetTimeout(function() {\n\t\t\tok(true, 'second');\n\t\t\tstart();\n\t\t}, 150);\n\t}, 150);\n});\n}\n\nmodule(\"save scope\", {\n\tsetup: function() {\n\t\tthis.foo = \"bar\";\n\t},\n\tteardown: function() {\n\t\tdeepEqual(this.foo, \"bar\");\n\t}\n});\ntest(\"scope check\", function() {\n\texpect(2);\n\tdeepEqual(this.foo, \"bar\");\n});\n\nmodule(\"simple testEnvironment setup\", {\n\tfoo: \"bar\",\n\t// example of meta-data\n\tbugid: \"#5311\"\n});\ntest(\"scope check\", function() {\n\tdeepEqual(this.foo, \"bar\");\n});\ntest(\"modify testEnvironment\",function() {\n\texpect(0);\n\tthis.foo=\"hamster\";\n});\ntest(\"testEnvironment reset for next test\",function() {\n\tdeepEqual(this.foo, \"bar\");\n});\n\nmodule(\"testEnvironment with object\", {\n\toptions:{\n\t\trecipe:\"soup\",\n\t\tingredients:[\"hamster\",\"onions\"]\n\t}\n});\ntest(\"scope check\", function() {\n\tdeepEqual(this.options, {recipe:\"soup\",ingredients:[\"hamster\",\"onions\"]}) ;\n});\ntest(\"modify testEnvironment\",function() {\n\texpect(0);\n\t// since we do a shallow copy, the testEnvironment can be modified\n\tthis.options.ingredients.push(\"carrots\");\n});\ntest(\"testEnvironment reset for next test\",function() {\n\tdeepEqual(this.options, {recipe:\"soup\",ingredients:[\"hamster\",\"onions\",\"carrots\"]}, \"Is this a bug or a feature? Could do a deep copy\") ;\n});\n\n\nmodule(\"testEnvironment tests\");\n\nfunction makeurl() {\n\tvar testEnv = QUnit.current_testEnvironment;\n\tvar url = testEnv.url || 'http://example.com/search';\n\tvar q   = testEnv.q   || 'a search test';\n\treturn url + '?q='+encodeURIComponent(q);\n}\n\ntest(\"makeurl working\",function() {\n\tequal( QUnit.current_testEnvironment, this, 'The current testEnvironment is global');\n\tequal( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment');\n});\n\nmodule(\"testEnvironment with makeurl settings\", {\n\turl: 'http://google.com/',\n\tq: 'another_search_test'\n});\ntest(\"makeurl working with settings from testEnvironment\", function() {\n\tequal( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to from the url');\n});\n\nmodule(\"jsDump\");\ntest(\"jsDump output\", function() {\n\tequal( QUnit.jsDump.parse([1, 2]), \"[\\n  1,\\n  2\\n]\" );\n\tequal( QUnit.jsDump.parse({top: 5, left: 0}), \"{\\n  \\\"left\\\": 0,\\n  \\\"top\\\": 5\\n}\" );\n\tif (typeof document !== 'undefined' && document.getElementById(\"qunit-header\")) {\n\t\tequal( QUnit.jsDump.parse(document.getElementById(\"qunit-header\")), \"<h1 id=\\\"qunit-header\\\"></h1>\" );\n\t\tequal( QUnit.jsDump.parse(document.getElementsByTagName(\"h1\")), \"[\\n  <h1 id=\\\"qunit-header\\\"></h1>\\n]\" );\n\t}\n});\n\nmodule(\"assertions\");\n\ntest(\"propEqual\", 5, function( assert ) {\n\tvar objectCreate = Object.create || function ( origin ) {\n\t\tfunction O() {}\n\t\tO.prototype = origin;\n\t\tvar r = new O();\n\t\treturn r;\n\t};\n\n\tfunction Foo( x, y, z ) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t}\n\tFoo.prototype.doA = function () {};\n\tFoo.prototype.doB = function () {};\n\tFoo.prototype.bar = 'prototype';\n\n\tfunction Bar() {\n\t}\n\tBar.prototype = objectCreate( Foo.prototype );\n\tBar.prototype.constructor = Bar;\n\n\tassert.propEqual(\n\t\tnew Foo( 1, '2', [] ),\n\t\t{\n\t\t\tx: 1,\n\t\t\ty: '2',\n\t\t\tz: []\n\t\t}\n\t);\n\n\tassert.notPropEqual(\n\t\tnew Foo( '1', 2, 3 ),\n\t\t{\n\t\t\tx: 1,\n\t\t\ty: '2',\n\t\t\tz: 3\n\t\t},\n\t\t'Primitive values are strictly compared'\n\t);\n\n\tassert.notPropEqual(\n\t\tnew Foo( 1, '2', [] ),\n\t\t{\n\t\t\tx: 1,\n\t\t\ty: '2',\n\t\t\tz: {}\n\t\t},\n\t\t'Array type is preserved'\n\t);\n\n\tassert.notPropEqual(\n\t\tnew Foo( 1, '2', {} ),\n\t\t{\n\t\t\tx: 1,\n\t\t\ty: '2',\n\t\t\tz: []\n\t\t},\n\t\t'Empty array is not the same as empty object'\n\t);\n\n\tassert.propEqual(\n\t\tnew Foo( 1, '2', new Foo( [ 3 ], new Bar(), null ) ),\n\t\t{\n\t\t\tx: 1,\n\t\t\ty: '2',\n\t\t\tz: {\n\t\t\t\tx: [ 3 ],\n\t\t\t\ty: {},\n\t\t\t\tz: null\n\t\t\t}\n\t\t},\n\t\t'Complex nesting of different types, inheritance and constructors'\n\t);\n});\n\ntest(\"raises\", 9, function() {\n\tfunction CustomError( message ) {\n\t\tthis.message = message;\n\t}\n\n\tCustomError.prototype.toString = function() {\n\t\treturn this.message;\n\t};\n\n\tthrows(\n\t\tfunction() {\n\t\t\tthrow \"my error\";\n\t\t}\n\t);\n\n\tthrows(\n\t\tfunction() {\n\t\t\tthrow \"my error\";\n\t\t},\n\t\t\"simple string throw, no 'expected' value given\"\n\t);\n\n\t// This test is for IE 7 and prior which does not properly\n\t// implement Error.prototype.toString\n\tthrows(\n\t\tfunction() {\n\t\t\tthrow new Error(\"error message\");\n\t\t},\n\t\t/error message/,\n\t\t\"use regexp against instance of Error\"\n\t);\n\n\tthrows(\n\t\tfunction() {\n\t\t\tthrow new CustomError();\n\t\t},\n\t\tCustomError,\n\t\t'thrown error is an instance of CustomError'\n\t);\n\n\tthrows(\n\t\tfunction() {\n\t\t\tthrow new CustomError(\"some error description\");\n\t\t},\n\t\t/description/,\n\t\t\"use a regex to match against the stringified error\"\n\t);\n\n\tthrows(\n\t\tfunction() {\n\t\t\tthrow new CustomError(\"some error description\");\n\t\t},\n\t\tfunction( err ) {\n\t\t\tif ( (err instanceof CustomError) && /description/.test(err) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t\t\"custom validation function\"\n\t);\n\n\tthrows(\n\t\tfunction() {\n\t\t\t/*jshint evil:true */\n\t\t\t( window.execScript || function( data ) {\n\t\t\t\twindow[\"eval\"].call( window, data );\n\t\t\t})( \"throw 'error';\" );\n\t\t},\n\t\t'globally-executed errors caught'\n\t);\n\n    this.CustomError = CustomError;\n\n    throws(\n        function() {\n            throw new this.CustomError(\"some error description\");\n        },\n        /description/,\n        \"throw error from property of 'this' context\"\n    );\n\n    raises(\n        function() {\n            throw \"error\";\n        },\n        \"simple throw, asserting with deprecated raises() function\"\n    );\n\n});\n\nif (typeof document !== \"undefined\") {\n\nmodule(\"fixture\");\ntest(\"setup\", function() {\n\texpect(0);\n\tdocument.getElementById(\"qunit-fixture\").innerHTML = \"foobar\";\n});\n\ntest(\"basics\", function() {\n\tequal( document.getElementById(\"qunit-fixture\").innerHTML, \"test markup\", \"automatically reset\" );\n});\n\ntest(\"running test name displayed\", function() {\n\texpect(2);\n\n\tvar displaying = document.getElementById(\"qunit-testresult\");\n\n\tok( /running test name displayed/.test(displaying.innerHTML), \"Expect test name to be found in displayed text\" );\n\tok( /fixture/.test(displaying.innerHTML), \"Expect module name to be found in displayed text\" );\n});\n\n(function() {\n\tvar delayNextSetup,\n\t\tsleep = function( n ) {\n\t\t\tstop();\n\t\t\tsetTimeout( function() { start(); }, n );\n\t\t};\n\n\tmodule(\"timing\", {\n\t\tsetup: function() {\n\t\t\tif ( delayNextSetup ) {\n\t\t\t\tdelayNextSetup = false;\n\t\t\t\tsleep( 250 );\n\t\t\t}\n\t\t}\n\t});\n\n\ttest(\"setup\", 0, function() {\n\t\tdelayNextSetup = true;\n\t});\n\n\ttest(\"basics\", 2, function() {\n\t\tvar previous = getPreviousTests(/^setup$/, /^timing$/)[0],\n\t\t\truntime = previous.lastChild.previousSibling;\n\t\tok( /(^| )runtime( |$)/.test( runtime.className ), \"Runtime element exists\" );\n\t\tok( /^\\d+ ms$/.test( runtime.innerHTML ), \"Runtime reported in ms\" );\n\t});\n\n\ttest(\"values\", 2, function() {\n\t\tvar basics = getPreviousTests(/^setup$/, /^timing$/)[0],\n\t\t\tslow = getPreviousTests(/^basics$/, /^timing$/)[0];\n\t\tok( parseInt( basics.lastChild.previousSibling.innerHTML, 10 ) < 50, \"Fast runtime for trivial test\" );\n\t\tok( parseInt( slow.lastChild.previousSibling.innerHTML, 10 ) > 250, \"Runtime includes setup\" );\n\t});\n})();\n\n}\n\nmodule(\"custom assertions\");\n(function() {\n\tfunction mod2(value, expected, message) {\n\t\tvar actual = value % 2;\n\t\tQUnit.push(actual == expected, actual, expected, message);\n\t}\n\ttest(\"mod2\", function() {\n\t\tmod2(2, 0, \"2 % 2 == 0\");\n\t\tmod2(3, 1, \"3 % 2 == 1\");\n\t});\n})();\n\n\nmodule(\"recursions\");\n\nfunction Wrap(x) {\n\tthis.wrap = x;\n\tif (x === undefined) {\n\t\tthis.first = true;\n\t}\n}\n\nfunction chainwrap(depth, first, prev) {\n\tdepth = depth || 0;\n\tvar last = prev || new Wrap();\n\tfirst = first || last;\n\n\tif (depth == 1) {\n\t\tfirst.wrap = last;\n\t}\n\tif (depth > 1) {\n\t\tlast = chainwrap(depth-1, first, new Wrap(last));\n\t}\n\n\treturn last;\n}\n\ntest(\"check jsDump recursion\", function() {\n\texpect(4);\n\n\tvar noref = chainwrap(0);\n\tvar nodump = QUnit.jsDump.parse(noref);\n\tequal(nodump, '{\\n  \"first\": true,\\n  \"wrap\": undefined\\n}');\n\n\tvar selfref = chainwrap(1);\n\tvar selfdump = QUnit.jsDump.parse(selfref);\n\tequal(selfdump, '{\\n  \"first\": true,\\n  \"wrap\": recursion(-1)\\n}');\n\n\tvar parentref = chainwrap(2);\n\tvar parentdump = QUnit.jsDump.parse(parentref);\n\tequal(parentdump, '{\\n  \"wrap\": {\\n    \"first\": true,\\n    \"wrap\": recursion(-2)\\n  }\\n}');\n\n\tvar circref = chainwrap(10);\n\tvar circdump = QUnit.jsDump.parse(circref);\n\tok(new RegExp(\"recursion\\\\(-10\\\\)\").test(circdump), \"(\" +circdump + \") should show -10 recursion level\");\n});\n\ntest(\"check (deep-)equal recursion\", function() {\n\tvar noRecursion = chainwrap(0);\n\tequal(noRecursion, noRecursion, \"I should be equal to me.\");\n\tdeepEqual(noRecursion, noRecursion, \"... and so in depth.\");\n\n\tvar selfref = chainwrap(1);\n\tequal(selfref, selfref, \"Even so if I nest myself.\");\n\tdeepEqual(selfref, selfref, \"... into the depth.\");\n\n\tvar circref = chainwrap(10);\n\tequal(circref, circref, \"Or hide that through some levels of indirection.\");\n\tdeepEqual(circref, circref, \"... and checked on all levels!\");\n});\n\n\ntest('Circular reference with arrays', function() {\n\n\t// pure array self-ref\n\tvar arr = [];\n\tarr.push(arr);\n\n\tvar arrdump = QUnit.jsDump.parse(arr);\n\n\tequal(arrdump, '[\\n  recursion(-1)\\n]');\n\tequal(arr, arr[0], 'no endless stack when trying to dump arrays with circular ref');\n\n\n\t// mix obj-arr circular ref\n\tvar obj = {};\n\tvar childarr = [obj];\n\tobj.childarr = childarr;\n\n\tvar objdump = QUnit.jsDump.parse(obj);\n\tvar childarrdump = QUnit.jsDump.parse(childarr);\n\n\tequal(objdump, '{\\n  \"childarr\": [\\n    recursion(-2)\\n  ]\\n}');\n\tequal(childarrdump, '[\\n  {\\n    \"childarr\": recursion(-2)\\n  }\\n]');\n\n\tequal(obj.childarr, childarr, 'no endless stack when trying to dump array/object mix with circular ref');\n\tequal(childarr[0], obj, 'no endless stack when trying to dump array/object mix with circular ref');\n\n});\n\n\ntest('Circular reference - test reported by soniciq in #105', function() {\n\tvar MyObject = function() {};\n\tMyObject.prototype.parent = function(obj) {\n\t\tif (obj === undefined) { return this._parent; }\n\t\tthis._parent = obj;\n\t};\n\tMyObject.prototype.children = function(obj) {\n\t\tif (obj === undefined) { return this._children; }\n\t\tthis._children = obj;\n\t};\n\n\tvar a = new MyObject(),\n\t\tb = new MyObject();\n\n\tvar barr = [b];\n\ta.children(barr);\n\tb.parent(a);\n\n\tequal(a.children(), barr);\n\tdeepEqual(a.children(), [b]);\n});\n\n(function() {\n\tvar reset = QUnit.reset;\n\tmodule(\"reset\");\n\ttest(\"reset runs assertions\", function() {\n\t\texpect(0);\n\t\tQUnit.reset = function() {\n\t\t\tok( false, \"reset should not modify test status\" );\n\t\t\treset.apply( this, arguments );\n\t\t};\n\t});\n\ttest(\"reset runs assertions, cleanup\", function() {\n\t\texpect(0);\n\t\tQUnit.reset = reset;\n\t});\n})();\n\nfunction testAfterDone() {\n\tvar testName = \"ensure has correct number of assertions\";\n\n\tfunction secondAfterDoneTest() {\n\t\tQUnit.config.done = [];\n\t\t// Because when this does happen, the assertion count parameter doesn't actually\n\t\t// work we use this test to check the assertion count.\n\t\tmodule(\"check previous test's assertion counts\");\n\t\ttest('count previous two test\\'s assertions', function () {\n\t\t\tvar tests = getPreviousTests(/^ensure has correct number of assertions/, /^Synchronous test after load of page$/);\n\n\t\t\tequal(tests[0].firstChild.lastChild.getElementsByTagName(\"b\")[1].innerHTML, \"99\");\n\t\t\tequal(tests[1].firstChild.lastChild.getElementsByTagName(\"b\")[1].innerHTML, \"99\");\n\t\t});\n\t}\n\tQUnit.config.done = [];\n\tQUnit.done(secondAfterDoneTest);\n\n\tmodule(\"Synchronous test after load of page\");\n\n\tasyncTest('Async test', function() {\n\t\tstart();\n\t\tfor (var i = 1; i < 100; i++) {\n\t\t\tok(i);\n\t\t}\n\t});\n\n\ttest(testName, 99, function() {\n\t\tfor (var i = 1; i < 100; i++) {\n\t\t\tok(i);\n\t\t}\n\t});\n\n\t// We need two of these types of tests in order to ensure that assertions\n\t// don't move between tests.\n\ttest(testName + ' 2', 99, function() {\n\t\tfor (var i = 1; i < 100; i++) {\n\t\t\tok(i);\n\t\t}\n\t});\n\n\n}\n\nif (typeof setTimeout !== 'undefined') {\n\tQUnit.done(testAfterDone);\n}\n"
  },
  {
    "path": "vendor/right.js",
    "content": "/**\n * RightJS v2.3.1 - http://rightjs.org\n * Released under the terms of MIT license\n *\n * Copyright (C) 2008-2012 Nikolay Nemshilov\n */\n/**\n * The basic layout for RightJS builds\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nvar RightJS = (function(window, document, Object, Array, String, Function, Number, Math, undefined) {\n\n/**\n * The framework description object\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nvar RightJS = function(value) {\n  return value; // <- a dummy method to emulate the safe-mode\n};\n\nRightJS.version = \"2.3.1\";\nRightJS.modules =[\"core\", \"dom\", \"form\", \"events\", \"xhr\", \"fx\", \"cookie\"];\n\n\n\n/**\n * There are some util methods\n *\n * Credits:\n *   Some of the functionality and names are inspired or copied from\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\n\n/**\n * Some top-level variables to shortify the things\n */\nvar A_proto = Array.prototype,\nto_s = Object.prototype.toString, slice = A_proto.slice,\nHTML = document.documentElement, UID = 1,       // !#server\nWrappers_Cache = [], UID_KEY = 'uniqueNumber',  // DON'T change the UID_KEY!\n\n/**\n * extends the first object with the keys and values of the second one\n *\n * NOTE: the third optional argument tells if the existing values\n *       of the first object should _NOT_ get updated by the values of the second object\n *\n * @param oritinal Object destintation object\n * @param source Object source object\n * @param Boolean flag if the function should not overwrite intersecting values\n * @return Object extended destination object\n */\n$ext = RightJS.$ext = function(dest, source, dont_overwrite) {\n  var src = source || {}, key;\n\n  for (key in src) {\n    if (!dont_overwrite || !(key in dest)) {\n      dest[key] = src[key];\n    }\n  }\n\n  return dest;\n},\n\n/** !#server\n * evals the given javascript text in the context of the current window\n *\n * @param String javascript\n * @return void\n */\n$eval = RightJS.$eval = function(text) {\n  if (text) {\n    if ('execScript' in window) {\n      current_Document.win()._.execScript(text);\n    } else {\n      $E('script', {text: text}).insertTo(HTML);\n    }\n  }\n},\n\n/**\n * throws an exception to break iterations throw a callback\n *\n * @return void\n * @throws Break\n */\n$break = RightJS.$break = function() {\n  throw new Break();\n},\n\n/**\n * generates aliases for the object properties\n *\n * @param object Object object\n * @param names Object aliases hash\n * @return Object the extended objects\n */\n$alias = RightJS.$alias = function(object, names) {\n  for (var new_name in names) {\n    object[new_name] = object[names[new_name]];\n  }\n  return object;\n},\n\n/**\n * checks if the given value or a reference points\n * to a really defined value\n *\n * NOTE: will return true for variables equal to null, false, 0, and so one.\n *\n * EXAMPLE:\n *\n *   var smth = null;\n *   defined(smth); <- will return true\n *\n *   var obj = {};\n *   defined(obj['smth']); <- will return false\n *\n * @param mixed value\n * @return boolean check result\n */\ndefined = RightJS.defined = function(value) {\n  return typeof(value) !== 'undefined';\n},\n\n\n/**\n * checks if the given value is a function\n *\n * @param mixed value\n * @return boolean check result\n */\nisFunction = RightJS.isFunction = function(value) {\n  return typeof(value) === 'function';\n},\n\n/**\n * checks if the given value is a string\n *\n * @param mixed value\n * @return boolean check result\n */\nisString = RightJS.isString = function(value) {\n  return typeof(value) === 'string';\n},\n\n\n/**\n * checks if the given value is a number\n *\n * @param mixed value to check\n * @return boolean check result\n */\nisNumber = RightJS.isNumber = function(value) {\n  return typeof(value) === 'number' && !isNaN(value);\n},\n\n/**\n * checks if the given value is a hash-like object\n *\n * @param mixed value\n * @return boolean check result\n */\nisHash = RightJS.isHash = function(value) {\n  return to_s.call(value) === '[object Object]';\n},\n\n/**\n * checks if the given value is an array\n *\n * @param mixed value to check\n * @return boolean check result\n */\nisArray = RightJS.isArray = function(value) {\n  return to_s.call(value) === '[object Array]';\n},\n\n/** !#server\n * checks if the given value is an element\n *\n * @param mixed value to check\n * @return boolean check result\n */\nisElement = RightJS.isElement = function(value) {\n  return value != null && value.nodeType === 1;\n},\n\n/** !#server\n * checks if the given value is a DOM-node\n *\n * @param mixed value to check\n * @return boolean check result\n */\nisNode = RightJS.isNode = function(value) {\n  return value != null && value.nodeType != null;\n},\n\n/** !#server\n * searches an element by id and/or extends it with the framework extentions\n *\n * @param String element id or Element to extend\n * @return Element or null\n */\n$ = RightJS.$ = function(object) {\n  if (object instanceof Wrapper) {\n    return object;\n  } else if (typeof object === 'string') {\n    object = document.getElementById(object);\n  }\n\n  return wrap(object);\n},\n\n/** !#server\n * Finds all the elements in the document by the given css_rule\n *\n * @param String element\n * @param Boolean raw search marker\n * @return Array search result\n */\n$$ = RightJS.$$ = function(css_rule, raw) {\n  return current_Document.find(css_rule, raw);\n},\n\n/** !#server\n * shortcut to instance new elements\n *\n * @param String tag name\n * @param object options\n * @return Element instance\n */\n$E = RightJS.$E = function(tag_name, options) {\n  return new Element(tag_name, options);\n},\n\n/**\n * shortcut, generates an array of words from a given string\n *\n * @param String string\n * @return Array of words\n */\n$w = RightJS.$w = function(string) {\n  return string.trim().split(/\\s+/);\n},\n\n/**\n * generates an unique id for an object\n *\n * @param Object object\n * @return Integer uniq id\n */\n$uid = RightJS.$uid = function(item) {\n  return UID_KEY in item ? item[UID_KEY] : (item[UID_KEY] = UID++);\n},\n\n/**\n * converts any iterables into an array\n *\n * @param Object iterable\n * @return Array list\n */\n$A = RightJS.$A = function(it) {\n  return slice.call(it, 0);\n};\n\n/** !#server\n * IE needs a patch for the $A function\n * because it doesn't handle all the cases\n */\nif (!A_proto.map) {\n  $A = RightJS.$A = function(it) {\n    try {\n      return slice.call(it, 0);\n    } catch(e) {\n      for (var a=[], i=0, length = it.length; i < length; i++) {\n        a[i] = it[i];\n      }\n      return a;\n    }\n  };\n}\n\n/** !#server\n * Internet Explorer needs some additional mumbo-jumbo in here\n */\nif (isHash(HTML)) {\n  isHash = RightJS.isHash = function(value) {\n    return to_s.call(value) === '[object Object]' &&\n      value != null && value.hasOwnProperty != null;\n  };\n}\n\n\n/**\n * Generating methods for native units extending\n */\n// adds a standard '.include' method to the native unit\nfunction extend_native(klass) {\n  return $ext(klass, {\n    Methods: {},\n    include: function() {\n      for (var i=0, l = arguments.length; i < l; i++) {\n        if (isHash(arguments[i])) {\n          $ext(klass.prototype, arguments[i]);\n          $ext(klass.Methods,   arguments[i]);\n        }\n      }\n    }\n  });\n}\n\nfor (var i=0, natives = 'Array Function Number String Date RegExp'.split(' '); i < natives.length; i++) {\n  RightJS[natives[i]] = extend_native(new Function('return '+ natives[i])());\n}\n\n// referring those two as well\nRightJS.Object = Object;\nRightJS.Math   = Math;\n\n\n/**\n * Checks if the data is an array and if not,\n * then makes an array out of it\n *\n * @param mixed in data\n * @return Array data\n */\nfunction ensure_array(data) {\n  return isArray(data) ? data : [data];\n}\n\n\n/**\n * The Object class extentions\n *\n * Credits:\n *   Some functionality is inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\n$ext(Object, {\n  /**\n   * extracts the list of the attribute names of the given object\n   *\n   * @param Object object\n   * @return Array keys list\n   */\n  keys: function(object) {\n    var keys = [], key;\n    for (key in object) {\n      keys.push(key);\n    }\n    return keys;\n  },\n\n  /**\n   * extracts the list of the attribute values of the given object\n   *\n   * @param Object object\n   * @return Array values list\n   */\n  values: function(object) {\n    var values = [], key;\n    for (key in object) {\n      values.push(object[key]);\n    }\n    return values;\n  },\n\n  /**\n   * Calls the function with every key/value pair on the hash\n   *\n   * @param in Object the data hash\n   * @param Function the callback\n   * @param scope Object an optional scope\n   * @return Object the original hash\n   */\n  each: function(object, callback, scope) {\n    for (var key in object) {\n      callback.call(scope, key, object[key]);\n    }\n\n    return object;\n  },\n\n  /**\n   * checks if the object-hash has no keys\n   *\n   * @param Object object\n   * @return check result\n   */\n  empty: function(object) {\n    for (var key in object) { return false; }\n    return true;\n  },\n\n  /**\n   * A simple cloning method\n   * NOTE: does not clone the things recoursively!\n   *\n   * @param Object object\n   * @return Object clone\n   */\n  clone: function(object) {\n    return Object.merge(object);\n  },\n\n  /**\n   * returns a copy of the object which contains\n   * all the same keys/values except the key-names\n   * passed the the method arguments\n   *\n   * @param Object object\n   * @param String key-name to exclude\n   * .....\n   * @return Object filtered copy\n   */\n  without: function() {\n    var filter = $A(arguments), object = filter.shift(), copy = {}, key;\n\n    for (key in object) {\n      if (!filter.include(key)) {\n        copy[key] = object[key];\n      }\n    }\n\n    return copy;\n  },\n\n  /**\n   * returns a copy of the object which contains all the\n   * key/value pairs from the specified key-names list\n   *\n   * NOTE: if some key does not exists in the original object, it will be just skipped\n   *\n   * @param Object object\n   * @param String key name to exclude\n   * .....\n   * @return Object filtered copy\n   */\n  only: function() {\n    var filter = $A(arguments), object = filter.shift(), copy = {},\n        i=0, length = filter.length;\n\n    for (; i < length; i++) {\n      if (filter[i] in object) {\n        copy[filter[i]] = object[filter[i]];\n      }\n    }\n\n    return copy;\n  },\n\n  /**\n   * merges the given objects and returns the result\n   *\n   * NOTE this method _DO_NOT_ change the objects, it creates a new object\n   *      which conatins all the given ones.\n   *      if there is some keys introspections, the last object wins.\n   *      all non-object arguments will be omitted\n   *\n   * @param first Object object\n   * @param second Object mixing\n   * ......\n   * @return Object merged object\n   */\n  merge: function() {\n    var object = {}, i=0, args=arguments, l=args.length, key;\n    for (; i < l; i++) {\n      if (isHash(args[i])) {\n        for (key in args[i]) {\n          object[key] = isHash(args[i][key]) && !(args[i][key] instanceof Class) ?\n            Object.merge(key in object ? object[key] : {}, args[i][key]) : args[i][key];\n        }\n      }\n    }\n    return object;\n  },\n\n  /**\n   * converts a hash-object into an equivalent url query string\n   *\n   * @param Object object\n   * @return String query\n   */\n  toQueryString: function(object) {\n    var entries = to_query_string_map(object), i=0, result = [];\n\n    for (; i < entries.length; i++) {\n      result.push(encodeURIComponent(entries[i][0]) + \"=\" + encodeURIComponent(''+entries[i][1]));\n    }\n\n    return result.join('&');\n  }\n}, true);\n\n// private\n\n/**\n * pre-converts nested objects into a flat key-value structure\n *\n * @param {Object} data-hash\n * @param {String} key-prefix\n * @return {Array} key-value pairs\n */\nfunction to_query_string_map(hash, prefix) {\n  var result = [], key, value, i;\n\n  for (key in hash) {\n    value = hash[key];\n    if (prefix) {\n      key = prefix + \"[\"+ key + \"]\";\n    }\n\n    if (typeof(value) === 'object') {\n      if (isArray(value)) {\n        if (!key.endsWith('[]')) {\n          key += \"[]\";\n        }\n        for (i=0; i < value.length; i++) {\n          result.push([key, value[i]]);\n        }\n      } else if (value) { // assuming it's an object\n        value = to_query_string_map(value, key);\n        for (i=0; i < value.length; i++) {\n          result.push(value[i]);\n        }\n      }\n    } else {\n      result.push([key, value]);\n    }\n  }\n\n  return result;\n}\n\n/**\n * here are the starndard Math object extends\n *\n * Credits:\n *   The idea of random mehtod is taken from\n *     - Ruby      (http://www.ruby-lang.org) Copyright (C) Yukihiro Matsumoto\n *\n * Copyright (C) 2008-2010 Nikolay Nemshilov\n */\nvar Math_old_random = Math.random;\n\n/**\n * the standard random method replacement, to make it more useful\n *\n * USE:\n *   Math.random();    // original functionality, returns a float between 0 and 1\n *   Math.random(10);  // returns an integer between 0 and 10\n *   Math.random(1,4); // returns an integer between 1 and 4\n *\n * @param min Integer minimum value if there's two arguments and maximum value if there's only one\n * @param max Integer maximum value\n * @return Float random between 0 and 1 if there's no arguments or an integer in the given range\n */\nMath.random = function(min, max) {\n\n  if (arguments.length === 0) {\n    return Math_old_random();\n  } else if (arguments.length === 1) {\n    max = min;\n    min = 0;\n  }\n\n  return ~~(Math_old_random() * (max-min+1) + ~~min);\n};\n\n\n/**\n * The Array class extentions\n *\n * Credits:\n *   Some of the functionality is inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *     - Ruby      (http://www.ruby-lang.org) Copyright (C) Yukihiro Matsumoto\n *\n * Copyright (C) 2008-2010 Nikolay Nemshilov\n */\nvar original_sort = A_proto.sort,\n\n// JavaScript 1.6 methods recatching up or faking\nfor_each = A_proto.forEach || function(callback, scope) {\n  for (var i=0, l=this.length; i < l; i++) {\n    callback.call(scope, this[i], i, this);\n  }\n},\n\nfilter   = A_proto.filter || function(callback, scope) {\n  for (var result=[], j=0, i=0, l=this.length; i < l; i++) {\n    if (callback.call(scope, this[i], i, this)) {\n      result[j++] = this[i];\n    }\n  }\n  return result;\n},\n\nreject   = function(callback, scope) {\n  for (var result=[], j=0, i=0, l=this.length; i < l; i++) {\n    if (!callback.call(scope, this[i], i, this)) {\n      result[j++] = this[i];\n    }\n  }\n  return result;\n},\n\nmap      = A_proto.map || function(callback, scope) {\n  for (var result=[], i=0, l=this.length; i < l; i++) {\n    result[i] = callback.call(scope, this[i], i, this);\n  }\n  return result;\n},\n\nsome     = A_proto.some || function(callback, scope) {\n  for (var i=0, l=this.length; i < l; i++) {\n    if (callback.call(scope, this[i], i, this)) {\n      return true;\n    }\n  }\n  return false;\n},\n\nevery    = A_proto.every || function(callback, scope) {\n  for (var i=0, l=this.length; i < l; i++) {\n    if (!callback.call(scope, this[i], i, this)) {\n      return false;\n    }\n  }\n  return true;\n},\n\nfirst    = function(callback, scope) {\n  for (var i=0, l=this.length; i < l; i++) {\n    if (callback.call(scope, this[i], i, this)) {\n      return this[i];\n    }\n  }\n  return undefined;\n},\n\nlast     = function(callback, scope) {\n  for (var i=this.length-1; i > -1; i--) {\n    if (callback.call(scope, this[i], i, this)) {\n      return this[i];\n    }\n  }\n  return undefined;\n};\n\n\n//\n// RightJS callbacks magick preprocessing\n//\n\n// prepares a correct callback function\nfunction guess_callback(argsi, array) {\n  var callback = argsi[0], args = slice.call(argsi, 1), scope = array, attr;\n\n  if (typeof(callback) === 'string') {\n    attr = callback;\n    if (array.length !== 0 && typeof(array[0][attr]) === 'function') {\n      callback = function(object) { return object[attr].apply(object, args); };\n    } else {\n      callback = function(object) { return object[attr]; };\n    }\n  } else {\n    scope = args[0];\n  }\n\n  return [callback, scope];\n}\n\n// defining the manual break errors class\nfunction Break() {}\n\n// calls the given method with preprocessing the arguments\nfunction call_method(func, scope, args) {\n  try {\n    return func.apply(scope, guess_callback(args, scope));\n  } catch(e) { if (!(e instanceof Break)) { throw(e); } }\n\n  return undefined;\n}\n\n// checks the value as a boolean\nfunction boolean_check(i) {\n  return !!i;\n}\n\n// default sorting callback\nfunction default_sort(a, b) {\n  return a > b ? 1 : a < b ? -1 : 0;\n}\n\nArray.include({\n  /**\n   * IE fix\n   * returns the index of the value in the array\n   *\n   * @param mixed value\n   * @param Integer optional offset\n   * @return Integer index or -1 if not found\n   */\n  indexOf: A_proto.indexOf || function(value, from) {\n    for (var i=(from<0) ? Math.max(0, this.length+from) : from || 0, l=this.length; i < l; i++) {\n      if (this[i] === value) {\n        return i;\n      }\n    }\n    return -1;\n  },\n\n  /**\n   * IE fix\n   * returns the last index of the value in the array\n   *\n   * @param mixed value\n   * @return Integer index or -1 if not found\n   */\n  lastIndexOf: A_proto.lastIndexOf || function(value) {\n    for (var i=this.length-1; i > -1; i--) {\n      if (this[i] === value) {\n        return i;\n      }\n    }\n    return -1;\n  },\n\n  /**\n   * returns the first element of the array\n   *\n   * @return mixed first element of the array\n   */\n  first: function() {\n    return arguments.length ? call_method(first, this, arguments) : this[0];\n  },\n\n  /**\n   * returns the last element of the array\n   *\n   * @return mixed last element of the array\n   */\n  last: function() {\n    return arguments.length ? call_method(last, this, arguments) : this[this.length-1];\n  },\n\n  /**\n   * returns a random item of the array\n   *\n   * @return mixed a random item\n   */\n  random: function() {\n    return this.length === 0 ? undefined : this[Math.random(this.length-1)];\n  },\n\n  /**\n   * returns the array size\n   *\n   * @return Integer the array size\n   */\n  size: function() {\n    return this.length;\n  },\n\n  /**\n   * cleans the array\n   * @return Array this\n   */\n  clean: function() {\n    this.length = 0;\n    return this;\n  },\n\n  /**\n   * checks if the array has no elements in it\n   *\n   * @return boolean check result\n   */\n  empty: function() {\n    return this.length === 0;\n  },\n\n  /**\n   * creates a copy of the given array\n   *\n   * @return Array copy of the array\n   */\n  clone: function() {\n    return this.slice(0);\n  },\n\n  /**\n   * calls the given callback function in the given scope for each element of the array\n   *\n   * @param Function callback\n   * @param Object scope\n   * @return Array this\n   */\n  each: function() {\n    call_method(for_each, this, arguments);\n    return this;\n  },\n  forEach: for_each,\n\n  /**\n   * creates a list of the array items converted in the given callback function\n   *\n   * @param Function callback\n   * @param Object optional scope\n   * @return Array collected\n   */\n  map: function() {\n    return call_method(map, this, arguments);\n  },\n\n  /**\n   * creates a list of the array items which are matched in the given callback function\n   *\n   * @param Function callback\n   * @param Object optional scope\n   * @return Array filtered copy\n   */\n  filter: function() {\n    return call_method(filter, this, arguments);\n  },\n\n  /**\n   * creates a list of the array items that are not matching the give callback function\n   *\n   * @param Function callback\n   * @param Object optionl scope\n   * @return Array filtered copy\n   */\n  reject: function() {\n    return call_method(reject, this, arguments);\n  },\n\n  /**\n   * checks if any of the array elements is logically true\n   *\n   * @param Function optional callback for checks\n   * @param Object optional scope for the callback\n   * @return boolean check result\n   */\n  some: function(value) {\n    return call_method(some, this, value ? arguments : [boolean_check]);\n  },\n\n  /**\n   * checks if all the array elements are logically true\n   *\n   * @param Function optional callback for checks\n   * @param Object optional scope for the callback\n   * @return Boolean check result\n   */\n  every: function(value) {\n    return call_method(every, this, value ? arguments : [boolean_check]);\n  },\n\n  /**\n   * applies the given lambda to each element in the array\n   *\n   * NOTE: changes the array by itself\n   *\n   * @param Function callback\n   * @param Object optional scope\n   * @return Array this\n   */\n  walk: function() {\n    this.map.apply(this, arguments).forEach(function(value, i) { this[i] = value; }, this);\n    return this;\n  },\n\n  /**\n   * similar to the concat function but it adds only the values which are not on the list yet\n   *\n   * @param Array to merge\n   * ....................\n   * @return Array new merged\n   */\n  merge: function() {\n    for (var copy = this.clone(), arg, i=0; i < arguments.length; i++) {\n      arg = ensure_array(arguments[i]);\n\n      for (var j=0; j < arg.length; j++) {\n        if (copy.indexOf(arg[j]) == -1) {\n          copy.push(arg[j]);\n        }\n      }\n    }\n    return copy;\n  },\n\n  /**\n   * flats out complex array into a single dimension array\n   *\n   * @return Array flatten copy\n   */\n  flatten: function() {\n    var copy = [];\n    this.forEach(function(value) {\n      if (isArray(value)) {\n        copy = copy.concat(value.flatten());\n      } else {\n        copy.push(value);\n      }\n    });\n    return copy;\n  },\n\n  /**\n   * returns a copy of the array whithout any null or undefined values\n   *\n   * @return Array filtered version\n   */\n  compact: function() {\n    return this.without(null, undefined);\n  },\n\n  /**\n   * returns a copy of the array which contains only the unique values\n   *\n   * @return Array filtered copy\n   */\n  uniq: function() {\n    return [].merge(this);\n  },\n\n  /**\n   * checks if all of the given values\n   * exists in the given array\n   *\n   * @param mixed value\n   * ....\n   * @return boolean check result\n   */\n  includes: function() {\n    for (var i=0; i < arguments.length; i++) {\n      if (this.indexOf(arguments[i]) === -1) {\n        return false;\n      }\n    }\n    return true;\n  },\n\n  /**\n   * returns a copy of the array without the items passed as the arguments\n   *\n   * @param mixed value\n   * ......\n   * @return Array filtered copy\n   */\n  without: function() {\n    var filter = slice.call(arguments);\n    return this.filter(function(value) {\n      return filter.indexOf(value) === -1;\n    });\n  },\n\n  /**\n   * Shuffles the array items in a random order\n   *\n   * @return Array shuffled version\n   */\n  shuffle: function() {\n    var shuff = this.clone(), j, x, i = shuff.length;\n\n    for (; i > 0; j = Math.random(i-1), x = shuff[--i], shuff[i] = shuff[j], shuff[j] = x) {}\n\n    return shuff;\n  },\n\n  /**\n   * Default sort fix for numeric values\n   *\n   * @param Function callback\n   * @return Array self\n   */\n  sort: function(callback) {\n    return original_sort.apply(this, (callback || !isNumber(this[0])) ? arguments : [default_sort]);\n  },\n\n  /**\n   * sorts the array by running its items though a lambda or calling their attributes\n   *\n   * @param Function callback or attribute name\n   * @param Object scope or attribute argument\n   * @return Array sorted copy\n   */\n  sortBy: function() {\n    var pair = guess_callback(arguments, this);\n\n    return this.sort(function(a, b) {\n      return default_sort(\n        pair[0].call(pair[1], a),\n        pair[0].call(pair[1], b)\n      );\n    });\n  },\n\n  /**\n   * Returns the minimal value on the list\n   *\n   * @return Number minimal value\n   */\n  min: function() {\n    return Math.min.apply(Math, this);\n  },\n\n  /**\n   * Returns the maximal value\n   *\n   * @return Number maximal value\n   */\n  max: function() {\n    return Math.max.apply(Math, this);\n  },\n\n  /**\n   * Returns a summ of all the items on the list\n   *\n   * @return Number a summ of values on the list\n   */\n  sum: function() {\n    for(var sum=0, i=0, l=this.length; i < l; sum += this[i++]) {}\n    return sum;\n  }\n});\n\nA_proto.include = A_proto.includes;\n\n\n/**\n * The String class extentions\n *\n * Credits:\n *   Some of the functionality inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *   The trim function taken from work of Steven Levithan\n *     - http://blog.stevenlevithan.com/archives/faster-trim-javascript\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nString.include({\n  /**\n   * checks if the string is an empty string\n   *\n   * @return boolean check result\n   */\n  empty: function() {\n    return this == '';\n  },\n\n  /**\n   * checks if the string contains only white-spaces\n   *\n   * @return boolean check result\n   */\n  blank: function() {\n    return this == false;\n  },\n\n  /**\n   * removes trailing whitespaces\n   *\n   * @return String trimmed version\n   */\n  trim: String.prototype.trim || function() {\n    var str = this.replace(/^\\s\\s*/, ''), i = str.length;\n    while ((/\\s/).test(str.charAt(--i))) {}\n    return str.slice(0, i + 1);\n  },\n\n  /**\n   * returns a copy of the string with all the tags removed\n   * @return String without tags\n   */\n  stripTags: function() {\n    return this.replace(/<\\/?[^>]+>/ig, '');\n  },\n\n  /**\n   * removes all the scripts declarations out of the string\n   * @param mixed option. If it equals true the scrips will be executed,\n   *                      if a function the scripts will be passed in it\n   * @return String without scripts\n   */\n  stripScripts: function(option) {\n    var scripts = '', text = this.replace(\n      /<script[^>]*>([\\s\\S]*?)<\\/script>/img,\n      function(match, source) {\n        scripts += source + \"\\n\";\n        return '';\n      }\n    );\n\n    if (option === true) {\n      $eval(scripts);\n    } else if (isFunction(option)) {\n      option(scripts, text);\n    }\n\n    return text;\n  },\n\n  /**\n   * extracts all the scripts out of the string\n   *\n   * @return String the extracted stcripts\n   */\n  extractScripts: function() {\n    var scripts = '';\n    this.stripScripts(function(s) { scripts = s; });\n    return scripts;\n  },\n\n  /**\n   * evals all the scripts in the string\n   *\n   * @return String self (unchanged version with scripts still in their place)\n   */\n  evalScripts: function() {\n    this.stripScripts(true);\n    return this;\n  },\n\n  /**\n   * converts underscored or dasherized string to a camelized one\n   * @returns String camelized version\n   */\n  camelize: function() {\n    return this.replace(/(\\-|_)+(.)?/g, function(match, dash, chr) {\n      return chr ? chr.toUpperCase() : '';\n    });\n  },\n\n  /**\n   * converts a camelized or dasherized string into an underscored one\n   * @return String underscored version\n   */\n  underscored: function() {\n    return this.replace(/([a-z\\d])([A-Z]+)/g, '$1_$2').replace(/\\-/g, '_').toLowerCase();\n  },\n\n  /**\n   * returns a capitalised version of the string\n   *\n   * @return String captialised version\n   */\n  capitalize: function() {\n    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();\n  },\n\n  /**\n   * Makes a dashed version of the string\n   *\n   * @return String dashed version\n   */\n  dasherize: function() {\n    return this.underscored().replace(/_/g, '-');\n  },\n\n  /**\n   * checks if the string contains the given substring\n   *\n   * @param String string\n   * @return boolean check result\n   */\n  includes: function(string) {\n    return this.indexOf(string) != -1;\n  },\n\n  /**\n   * checks if the string starts with the given substring\n   *\n   * @param String string\n   * @param boolean ignore the letters case\n   * @return boolean check result\n   */\n  startsWith: function(string, ignorecase) {\n    return (ignorecase !== true ? this.indexOf(string) :\n      this.toLowerCase().indexOf(string.toLowerCase())\n    ) === 0;\n  },\n\n  /**\n   * checks if the string ends with the given substring\n   *\n   * @param String substring\n   * @param boolean ignore the letters case\n   * @return boolean check result\n   */\n  endsWith: function(string, ignorecase) {\n    return this.length - (\n      ignorecase !== true ? this.lastIndexOf(string) :\n        this.toLowerCase().lastIndexOf(string.toLowerCase())\n    ) === string.length;\n  },\n\n  /**\n   * converts the string to an integer value\n   * @param Integer base\n   * @return Integer or NaN\n   */\n  toInt: function(base) {\n    return parseInt(this, base === undefined ? 10 : base);\n  },\n\n  /**\n   * converts the string to a float value\n   * @param boolean flat if the method should not use a flexible matching\n   * @return Float or NaN\n   */\n  toFloat: function(strict) {\n    return parseFloat(strict === true ? this :\n      this.replace(',', '.').replace(/(\\d)-(\\d)/, '$1.$2'));\n  }\n\n});\n\nString.prototype.include = String.prototype.includes;\n\n\n/**\n * The Function class extentions\n *\n * Credits:\n *   Some of the functionality inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nFunction.include({\n  /**\n   * binds the function to be executed in the given scope\n   *\n   * @param Object scope\n   * @param mixed optional curry (left) argument\n   * ....\n   * @return Function binded function\n   */\n  bind: function() {\n    var args = $A(arguments), scope = args.shift(), func = this;\n    return function() {\n      return func.apply(scope,\n        (args.length !== 0 || arguments.length !== 0) ?\n          args.concat($A(arguments)) : args\n      );\n    };\n  },\n\n  /**\n   * binds the function as an event listener to the given scope object\n   *\n   * @param Object scope\n   * @param mixed optional curry (left) argument\n   * .......\n   * @return Function binded function\n   */\n  bindAsEventListener: function() {\n    var args = $A(arguments), scope = args.shift(), func = this;\n    return function(event) {\n      return func.apply(scope, [event].concat(args).concat($A(arguments)));\n    };\n  },\n\n  /**\n   * allows you to put some curry in your cookery\n   *\n   * @param mixed value to curry\n   * ....\n   * @return Function curried function\n   */\n  curry: function() {\n    return this.bind.apply(this, [this].concat($A(arguments)));\n  },\n\n  /**\n   * The right side curry feature\n   *\n   * @param mixed value to curry\n   * ....\n   * @return Function curried function\n   */\n  rcurry: function() {\n    var curry = $A(arguments), func = this;\n    return function() {\n      return func.apply(func, $A(arguments).concat(curry));\n    };\n  },\n\n  /**\n   * delays the function execution\n   *\n   * @param Integer delay ms\n   * @param mixed value to curry\n   * .....\n   * @return Integer timeout marker\n   */\n  delay: function() {\n    var args  = $A(arguments), timeout = args.shift(),\n        timer = new Number(setTimeout(this.bind.apply(this, [this].concat(args)), timeout));\n\n    timer.cancel = function() { clearTimeout(this); };\n\n    return timer;\n  },\n\n  /**\n   * creates a periodical execution of the function with the given timeout\n   *\n   * @param Integer delay ms\n   * @param mixed value to curry\n   * ...\n   * @return Ineger interval marker\n   */\n  periodical: function() {\n    var args  = $A(arguments), timeout = args.shift(),\n        timer = new Number(setInterval(this.bind.apply(this, [this].concat(args)), timeout));\n\n    timer.stop = function() { clearInterval(this); };\n\n    return timer;\n  },\n\n  /**\n   * Chains the given function after the current one\n   *\n   * @param Function the next function\n   * @param mixed optional value to curry\n   * ......\n   * @return Function chained function\n   */\n  chain: function() {\n    var args = $A(arguments), func = args.shift(), current = this;\n    return function() {\n      var result = current.apply(current, arguments);\n      func.apply(func, args);\n      return result;\n    };\n  }\n});\n\n\n/**\n * The Number class extentions\n *\n * Credits:\n *   Some methods inspired by\n *     - Ruby      (http://www.ruby-lang.org) Copyright (C) Yukihiro Matsumoto\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nNumber.include({\n  /**\n   * executes the given callback the given number of times\n   *\n   * @param Function callback\n   * @param Object optional callback execution scope\n   * @return void\n   */\n  times: function(callback, scope) {\n    for (var i=0; i < this; i++) {\n      callback.call(scope, i);\n    }\n    return this;\n  },\n\n  upto: function(number, callback, scope) {\n    for (var i=this+0; i <= number; i++) {\n      callback.call(scope, i);\n    }\n    return this;\n  },\n\n  downto: function(number, callback, scope) {\n    for (var i=this+0; i >= number; i--) {\n      callback.call(scope, i);\n    }\n    return this;\n  },\n\n  /**\n   * Maps a list of numbers from current to given\n   * or map a result of calls of the callback on those numbers\n   *\n   * @param {Number} end number\n   * @param {Function} optional callback\n   * @param {Object} optional callback scope\n   * @return {Array} the result list\n   */\n  to: function(number, callback, scope) {\n    var start = this + 0, end = number, result = [], i=start;\n\n    callback = callback || function(i) { return i; };\n\n    if (end > start) {\n      for (; i <= end; i++) {\n        result.push(callback.call(scope, i));\n      }\n    } else {\n      for (; i >= end; i--) {\n        result.push(callback.call(scope, i));\n      }\n    }\n\n    return result;\n  },\n\n  abs: function() {\n    return Math.abs(this);\n  },\n\n  round: function(size) {\n    return size ? parseFloat(this.toFixed(size)) : Math.round(this);\n  },\n\n  ceil: function() {\n    return Math.ceil(this);\n  },\n\n  floor: function() {\n    return Math.floor(this);\n  },\n\n  min: function(value) {\n    return this < value ? value : this + 0;\n  },\n\n  max: function(value) {\n    return this > value ? value : this + 0;\n  }\n});\n\n\n/**\n * The Regexp class extentions\n *\n * Credits:\n *   Inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *\n * Copyright (C) 2008-2010 Nikolay V. Nemshilov\n */\n\n\n /**\n  * Escapes the string for safely use as a regular expression\n  *\n  * @param String raw string\n  * @return String escaped string\n  */\nRegExp.escape = function(string) {\n  return (''+string).replace(/([.*+?\\^=!:${}()|\\[\\]\\/\\\\])/g, '\\\\$1');\n};\n\n\nif (!window.JSON) {\n  window.JSON = (function() {\n    var\n    // see the original JSON decoder implementation for descriptions http://www.json.org/json2.js\n    cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n    specials = {'\\b': '\\\\b', '\\t': '\\\\t', '\\n': '\\\\n', '\\f': '\\\\f', '\\r': '\\\\r', '\"' : '\\\\\"', '\\\\': '\\\\\\\\'},\n    quotables = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g;\n\n\n    // quotes the string\n    function quote(string) {\n      return string.replace(quotables, function(chr) {\n        return specials[chr] || '\\\\u' + ('0000' + chr.charCodeAt(0).toString(16)).slice(-4);\n      });\n    }\n\n    // adds the leading zero symbol\n    function zerofy(num) {\n      return (num < 10 ? '0' : '')+num;\n    }\n\n    return {\n      stringify: function(value) {\n        switch(typeof(value)) {\n          case 'boolean': return String(value);\n          case 'number':  return String(value+0);\n          case 'string':  return '\"'+ quote(value) + '\"';\n          case 'object':\n            if (value === null) {\n              return 'null';\n            } else if (isArray(value)) {\n              return '['+$A(value).map(JSON.stringify).join(',')+']';\n\n            } else if (to_s.call(value) === '[object Date]') {\n              return '\"' + value.getUTCFullYear() + '-' +\n                zerofy(value.getUTCMonth() + 1)   + '-' +\n                zerofy(value.getUTCDate())        + 'T' +\n                zerofy(value.getUTCHours())       + ':' +\n                zerofy(value.getUTCMinutes())     + ':' +\n                zerofy(value.getUTCSeconds())     + '.' +\n                zerofy(value.getMilliseconds())   + 'Z' +\n              '\"';\n\n            } else {\n              var result = [], key;\n              for (key in value) {\n                result.push('\"'+key+'\":'+JSON.stringify(value[key]));\n              }\n              return '{'+result.join(',')+'}';\n            }\n        }\n      },\n\n      parse: function(string) {\n        if (isString(string) && string) {\n          // getting back the UTF-8 symbols\n          string = string.replace(cx, function (a) {\n            return '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n          });\n\n          // checking the JSON string consistency\n          if (/^[\\],:{}\\s]*$/.test(string.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n            .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n            .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n              return new Function('return '+string)();\n            }\n        }\n\n        throw \"JSON parse error: \"+string;\n      }\n    };\n  })();\n}\n\n/**\n * The basic Class unit\n *\n * Credits:\n *   The Class unit is inspired by its implementation in\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *     - Ruby      (http://www.ruby-lang.org) Copyright (C) Yukihiro Matsumoto\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nvar Class = RightJS.Class = function() {\n  var args   = $A(arguments).slice(0,2),\n      props  = args.pop() || {},\n      parent = args.pop(),\n      klass  = arguments[2], // you can send your own klass as the third argument\n      SKlass = function() {};\n\n  // if the parent class only was specified\n  if (!args.length && !isHash(props)) {\n    parent = props; props = {};\n  }\n\n// !#server:begin\n  if (!klass && parent && (parent === Wrapper || parent.ancestors.include(Wrapper))) {\n    klass = Wrapper_makeKlass();\n  }\n// !#server:end\n\n  // defining the basic klass function\n  klass = $ext(klass || function() {\n    Class_checkPrebind(this);\n    return 'initialize' in this ?\n      this.initialize.apply(this, arguments) :\n      this;\n  }, Class_Methods);\n\n  // handling the inheritance\n  parent = parent || Class;\n\n  SKlass.prototype = parent.prototype;\n  klass.prototype  = new SKlass();\n  klass.parent     = parent;\n  klass.prototype.constructor = klass;\n\n  // collecting the list of ancestors\n  klass.ancestors = [];\n  while (parent) {\n    klass.ancestors.push(parent);\n    parent = parent.parent;\n  }\n\n  // handling the module injections\n  ['extend', 'include'].each(function(name) {\n    if (name in props) {\n      klass[name].apply(klass, ensure_array(props[name]));\n    }\n  });\n\n  return klass.include(props);\n},\n\n/**\n * Class utility methods\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nClass_Methods = {\n  /**\n   * this method will extend the class-level with the given objects\n   *\n   * NOTE: this method _WILL_OVERWRITE_ the existing itercecting entries\n   *\n   * NOTE: this method _WILL_NOT_OVERWRITE_ the class prototype and\n   *       the class 'name' and 'parent' attributes. If one of those\n   *       exists in one of the received modeuls, the attribute will be\n   *       skipped\n   *\n   * @param Object module to extend\n   * ....\n   * @return Class the klass\n   */\n  extend: function() {\n    $A(arguments).filter(isHash).each(function(module) {\n      $ext(this, Class_clean_module(module, true));\n      Class_handle_module_callbacks(this, module, true);\n    }, this);\n\n    return this;\n  },\n\n  /**\n   * extends the class prototype with the given objects\n   * NOTE: this method _WILL_OVERWRITE_ the existing itercecting entries\n   * NOTE: this method _WILL_NOT_OVERWRITE_ the 'klass' attribute of the klass.prototype\n   *\n   * @param Object module to include\n   * ....\n   * @return Class the klass\n   */\n  include: function() {\n    var klasses = [this].concat(this.ancestors);\n\n    $A(arguments).filter(isHash).each(function(module) {\n      Object.each(Class_clean_module(module, false), function(name, method) {\n        // searching for the super-method\n        for (var super_method, i=0, l = klasses.length; i < l; i++) {\n          if (name in klasses[i].prototype) {\n            super_method = klasses[i].prototype[name];\n            break;\n          }\n        }\n\n        this.prototype[name] = isFunction(method) && isFunction(super_method) ?\n          function() {\n            this.$super = super_method;\n            return method.apply(this, arguments);\n          } : method;\n      }, this);\n\n      Class_handle_module_callbacks(this, module, false);\n    }, this);\n\n    return this;\n  }\n},\n\nClass_module_callback_names = $w(\n  'selfExtended self_extended selfIncluded self_included extend include'\n);\n\n// hooking up the class-methods to the root class\n$ext(Class, Class_Methods);\nClass.prototype.$super = undefined;\n\nfunction Class_clean_module(module, extend) {\n  return Object.without.apply(Object, [module].concat(\n    Class_module_callback_names.concat( extend ?\n      $w('prototype parent ancestors') : ['constructor']\n    )\n  ));\n}\n\nfunction Class_handle_module_callbacks(klass, module, extend) {\n  (module[Class_module_callback_names[extend ? 0 : 2]] ||\n   module[Class_module_callback_names[extend ? 1 : 3]] ||\n   function() {}\n  ).call(module, klass);\n}\n\n/**\n * This method gets through a list of the object its class and all the ancestors\n * and finds a hash named after property, used for configuration purposes with\n * the Observer and Options modules\n *\n * NOTE: this method will look for capitalized and uppercased versions of the\n *       property name\n *\n * @param Object a class instance\n * @param String property name\n * @return Object hash or null if nothing found\n */\nfunction Class_findSet(object, property) {\n  var upcased   = property.toUpperCase(),\n    constructor = object.constructor,\n    candidates  = [object, constructor].concat(constructor.ancestors || []),\n    i = 0;\n\n  for (l = candidates.length; i < l; i++) {\n    if (upcased in candidates[i]) {\n      return candidates[i][upcased];\n    } else if (property in candidates[i]) {\n      return candidates[i][property];\n    }\n  }\n\n  return null;\n}\n\n/**\n * Handles the 'prebind' feature for Class instances\n *\n * @param Class instance\n * @return void\n */\nfunction Class_checkPrebind(object) {\n  if ('prebind' in object && isArray(object.prebind)) {\n    object.prebind.each(function(method) {\n      object[method] = object[method].bind(object);\n    });\n  }\n}\n\n/**\n * This is a simple mix-in module to be included in other classes\n *\n * Basically it privdes the <tt>setOptions</tt> method which processes\n * an instance options assigment and merging with the default options\n *\n * Credits:\n *   The idea of the module is inspired by\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nvar Options = RightJS.Options = {\n  /**\n   * assigns the options by merging them with the default ones\n   *\n   * @param Object options\n   * @return Object current instance\n   */\n  setOptions: function(opts) {\n    var options = this.options = $ext($ext({},\n      Object.clone(Class_findSet(this, 'Options'))), opts\n    ), match, key;\n\n    // hooking up the observer options\n    if (isFunction(this.on)) {\n      for (key in options) {\n        if ((match = key.match(/on([A-Z][A-Za-z]+)/))) {\n          this.on(match[1].toLowerCase(), options[key]);\n          delete(options[key]);\n        }\n      }\n    }\n\n    return this;\n  },\n\n  /**\n   * Cuts of an options hash from the end of the arguments list\n   * assigns them using the #setOptions method and then\n   * returns the list of other arguments as an Array instance\n   *\n   * @param mixed iterable\n   * @return Array of the arguments\n   */\n  cutOptions: function(in_args) {\n    var args = $A(in_args);\n    this.setOptions(isHash(args.last()) ? args.pop() : {});\n    return args;\n  }\n};\n\n\n/**\n * standard Observer class.\n *\n * Might be used as a usual class or as a builder over another objects\n *\n * Credits:\n *   The naming principle is inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nvar Observer = RightJS.Observer = new Class({\n  include: Options,\n\n  /**\n   * general constructor\n   *\n   * @param Object options\n   */\n  initialize: function(options) {\n    this.setOptions(options);\n    Observer_createShortcuts(this, Class_findSet(this, 'Events'));\n    return this;\n  },\n\n  /**\n   * binds an event listener\n   *\n   * USAGE:\n   *  on(String event, Function callback[, arguments, ...]);\n   *  on(String event, String method_name[, arguments, ...]);\n   *  on(Object events_hash);\n   *\n   * @return Observer self\n   */\n  on: function() {\n    Observer_on(this, arguments, function(h) { return h; });\n    return this;\n  },\n\n  /**\n   * checks if the observer observes given event and/or callback\n   *\n   * USAGE:\n   *   observes(String event)\n   *   observes(Function callback)\n   *   observes(String event, Function callback)\n   *\n   * @retun boolean check result\n   */\n  observes: function(event, callback) {\n    if (!isString(event)) { callback = event; event = null; }\n    if (isString(callback)) { callback = callback in this ? this[callback] : null; }\n\n    return (this.$listeners || []).some(function(i) {\n      return (event && callback) ? i.e === event && i.f === callback :\n        event ? i.e === event : i.f === callback;\n    });\n  },\n\n  /**\n   * stops observing an event or/and function\n   *\n   * USAGE:\n   *   stopObserving(String event)\n   *   stopObserving(Function callback)\n   *   stopObserving(String event, Function callback)\n   *\n   * @return Observer self\n   */\n  stopObserving: function(event, callback) {\n    Observer_stopObserving(this, event, callback, function() {});\n    return this;\n  },\n\n  /**\n   * returns the listeners list for the event\n   *\n   * NOTE: if no event was specified the method will return _all_\n   *       event listeners for _all_ the events\n   *\n   * @param String event name\n   * @return Array of listeners\n   */\n  listeners: function(event) {\n    return (this.$listeners || []).filter(function(i) {\n      return !event || i.e === event;\n    }).map(function(i) { return i.f; }).uniq();\n  },\n\n  /**\n   * initiates the event handling\n   *\n   * @param String event name\n   * @param mixed optional argument\n   * ........\n   * @return Observer self\n   */\n  fire: function() {\n    var args = $A(arguments), event = args.shift();\n\n    (this.$listeners || []).each(function(i) {\n      if (i.e === event) {\n        i.f.apply(this, i.a.concat(args));\n      }\n    }, this);\n\n    return this;\n  }\n}),\n\n/**\n * adds an observer functionality to any object\n *\n * @param Object object\n * @param Array optional events list to build shortcuts\n * @return Object extended object\n */\nObserver_create = Observer.create =  function(object, events) {\n  $ext(object, Object.without(Observer.prototype, 'initialize', 'setOptions'), true);\n  return Observer_createShortcuts(object, events || Class_findSet(object, 'Events'));\n},\n\n/**\n * builds shortcut methods to wire/fire events on the object\n *\n * @param Object object to extend\n * @param Array list of event names\n * @return Object extended object\n */\nObserver_createShortcuts = Observer.createShortcuts = function(object, names) {\n  (names || []).each(function(name) {\n    var method_name = 'on'+name.replace(/(^|_|:)([a-z])/g,\n      function(match, pre, chr) { return chr.toUpperCase(); }\n    );\n\n    if (!(method_name in object)) {\n      object[method_name] = function() {\n        return this.on.apply(this, [name].concat($A(arguments)));\n      };\n    }\n  });\n\n  return object;\n};\n\nfunction Observer_on(object, o_args, preprocess) {\n  var args     = slice.call(o_args, 2),\n      event    = o_args[0],\n      callback = o_args[1],\n      name     = false;\n\n  if (isString(event)) {\n    switch (typeof callback) {\n      case \"string\":\n        name     = callback;\n        callback = callback in object ? object[callback] : function() {};\n\n      case \"function\":\n        ('$listeners' in object ? object.$listeners : (\n          object.$listeners = []\n        )).push(preprocess({\n          e: event, f: callback, a: args, r: name || false, t: object\n        }));\n        break;\n\n      default:\n        if (isArray(callback)) {\n          for (var i=0; i < callback.length; i++) {\n            object.on.apply(object, [event].concat(\n              ensure_array(callback[i])\n            ).concat(args));\n          }\n        }\n    }\n\n  } else {\n    // assuming it's a hash of key-value pairs\n    args = slice.call(o_args, 1);\n\n    for (name in event) {\n      object.on.apply(object, [name].concat(\n        ensure_array(event[name])\n      ).concat(args));\n    }\n  }\n}\n\nfunction Observer_stopObserving(object, event, callback, preprocess) {\n  if (isHash(event)) {\n    for (var key in event) {\n      object.stopObserving(key, event[key]);\n    }\n  } else {\n    if (!isString(event)) {  callback = event; event = null; }\n    if (isString(callback)){ callback = object[callback]; }\n\n    object.$listeners = (object.$listeners || []).filter(function(i) {\n      var result = (event && callback) ?\n        (i.e !== event || i.f !== callback) :\n        (event ? i.e !== event : i.f !== callback);\n\n      if (!result) { preprocess(i); }\n\n      return result;\n    });\n  }\n}\n\n\n/**\n * this object will contain info about the current browser\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nvar agent = navigator.userAgent,\n    Browser_Opera = 'opera' in window,\n    Browser_IE    = 'attachEvent' in window && !Browser_Opera,\n\nBrowser = RightJS.Browser = {\n  IE:           Browser_IE,\n  Opera:        Browser_Opera,\n  WebKit:       agent.include('AppleWebKit/'),\n  Gecko:        agent.include('Gecko') && !agent.include('KHTML'),\n  MobileSafari: /Apple.*Mobile.*Safari/.test(agent),\n  Konqueror:    agent.include('Konqueror'),\n\n  // internal marker for the browsers which require the olds module\n  OLD:          !document.querySelector,\n  // internal marker for IE browsers version <= 8\n  IE8L:         false\n},\n\nIE8_OR_LESS = false,\nIE_OPACITY  = !('opacity' in HTML.style) && ('filter' in HTML.style);\n\ntry {\n  // checking if that an IE version <= 8\n  document.createElement('<input/>');\n  Browser.OLD = Browser.IE8L = IE8_OR_LESS = true;\n} catch(e) {}\n\n\n/**\n * The dom-wrapper main unit\n *\n * This unit is basically for the internal use\n * so that we could control the common functionality\n * among all the wrappers\n *\n * Copyright (C) 2010-2011 Nikolay Nemshilov\n */\n\nvar Wrapper = RightJS.Wrapper = new Class({\n  // predefining the property in the prototype\n  _: undefined,\n\n  /**\n   * Default constructor\n   *\n   * @param mixed raw dom unit\n   * @return void\n   */\n  initialize: function(raw_object) {\n    this._ = raw_object;\n  }\n});\n\n// exposing the cache so it could be manupulated externally\nWrapper.Cache = Wrappers_Cache;\n\n// instantiating the actual class object for a wrapper\nfunction Wrapper_makeKlass() {\n  /**\n   * Default wrappers Klass function\n   *\n   * @param mixed the raw object\n   * @param Object options\n   * @return void\n   */\n  return function(object, options) {\n    Class_checkPrebind(this);\n\n    this.initialize.apply(this, arguments); // <- there might be a different number of args in a subclass\n\n    var item = this._, uid = UID_KEY in item ? item[UID_KEY] :\n      // NOTE we use positive indexes for dom-elements and negative for everything else\n      (item[UID_KEY] = (item.nodeType === 1 ? 1 : -1) * UID++);\n\n    Wrappers_Cache[uid] = this;\n  };\n}\n\n/**\n * Element's own Klass function\n * we need that because it does some dynamic typecasting mumbo jumbo\n * plus we would like to optimize some stuff here and there\n *\n * @param raw dom element or the tag name\n * @param Object options\n * @return Element instance\n */\nfunction Element_Klass(element, options) {\n  Element_initialize(this, element, options);\n\n  var inst = this, raw = inst._, cast = Wrapper.Cast(raw),\n      uid = UID_KEY in raw ? raw[UID_KEY] : (raw[UID_KEY] = UID++);\n\n  if (cast !== undefined) {\n    inst = new cast(raw, options);\n    if ('$listeners' in this) {\n      inst.$listeners = this.$listeners;\n    }\n  }\n\n  Wrappers_Cache[uid] = inst;\n\n  return inst;\n}\n\n// searches for a suitable class for dynamic typecasting\nWrapper.Cast = function(unit) {\n  return unit.tagName in Element_wrappers ? Element_wrappers[unit.tagName] : undefined;\n};\n\n/**\n * Event's own Klass function, we don't need to check\n * nothing in here, don't need to hit the wrappers cache and so one\n *\n * @param raw dom-event or a string event-name\n * @param bounding element or an object with options\n * @return void\n */\nfunction Event_Klass(event, bound_element) {\n  if (typeof(event) === 'string') {\n    event = $ext({type: event}, bound_element);\n    this.stopped = event.bubbles === false;\n\n    if (isHash(bound_element)) {\n      $ext(this, bound_element);\n    }\n  }\n\n  this._             = event;\n  this.type          = event.type;\n\n  this.which         = event.which;\n  this.keyCode       = event.keyCode;\n\n  this.target        = wrap(\n    // Webkit throws events on textual nodes as well, gotta fix that\n    event.target != null && 'nodeType' in event.target && event.target.nodeType === 3 ?\n      event.target.parentNode : event.target\n  );\n\n  this.currentTarget = wrap(event.currentTarget);\n  this.relatedTarget = wrap(event.relatedTarget);\n\n  this.pageX         = event.pageX;\n  this.pageY         = event.pageY;\n\n  // making old IE attrs looks like w3c standards\n  if (IE8_OR_LESS && 'srcElement' in event) {\n    this.which         = event.button === 2 ? 3 : event.button === 4 ? 2 : 1;\n\n    this.target        = wrap(event.srcElement) || bound_element;\n    this.relatedTarget = this.target._ === event.fromElement ? wrap(event.toElement) : this.target;\n    this.currentTarget = bound_element;\n\n    var scrolls = this.target.win().scrolls();\n\n    this.pageX = event.clientX + scrolls.x;\n    this.pageY = event.clientY + scrolls.y;\n  }\n}\n\n\n/**\n * Private quick wrapping function, unlike `$`\n * it doesn't search by ID and handle double-wrapps\n * just pure dom-wrapping functionality\n *\n * @param raw dom unit\n * @return Wrapper dom-wrapper\n */\nfunction wrap(object) {\n  if (object != null) {\n    var wrapper = UID_KEY in object ? Wrappers_Cache[object[UID_KEY]] : undefined;\n\n    if (wrapper !== undefined) {\n      return wrapper;\n    } else if (object.nodeType === 1) {\n      return new Element(object);\n    } else if (object.nodeType === 9) {\n      return new Document(object);\n    } else if (object.window == object) {\n      return new Window(object);\n    } else if (isElement(object.target) || isElement(object.srcElement)) {\n      return new Event(object);\n    }\n  }\n\n  return object;\n}\n\n/**\n * A simple document wrapper\n *\n * Copyright (C) 2010-2011 Nikolay Nemshilov\n */\nvar Document = RightJS.Document = new Class(Wrapper, {\n  // returns the window reference\n  win: function() {\n    return wrap(this._.defaultView || this._.parentWindow);\n  }\n}),\n\n// a common local wrapped document reference\ncurrent_Document = wrap(document);\n\n\n/**\n * the window object extensions\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nvar Window = RightJS.Window = new Class(Wrapper, {\n  /**\n   * Selfreference to have a common interface with the rest of the wrappers\n   * in case of events handling\n   *\n   * @return Window\n   */\n  win: function() {\n    return this;\n  },\n\n  /**\n   * returns the inner-size of the window\n   *\n   * @return Object x: d+, y: d+\n   */\n  size: function() {\n    var win = this._, html = win.document.documentElement;\n    return win.innerWidth ? {x: win.innerWidth, y: win.innerHeight} :\n      {x: html.clientWidth, y: html.clientHeight};\n  },\n\n  /**\n   * returns the scrolls for the window\n   *\n   * @return Object x: d+, y: d+\n   */\n  scrolls: function() {\n    var win = this._, doc = win.document, body = doc.body, html = doc.documentElement;\n\n    return (win.pageXOffset || win.pageYOffset) ? {x: win.pageXOffset, y: win.pageYOffset} :\n      (body && (body.scrollLeft || body.scrollTop)) ? {x: body.scrollLeft, y: body.scrollTop} :\n      {x: html.scrollLeft, y: html.scrollTop};\n  },\n\n  /**\n   * overloading the native scrollTo method to support hashes and element references\n   *\n   * @param mixed number left position, a hash position, element or a string element id\n   * @param number top position\n   * @param Object fx options\n   * @return window self\n   */\n  scrollTo: function(left, top, fx_options) {\n    var left_pos = left, top_pos = top,\n        element = isNumber(left) ? null : $(left);\n\n    if(element instanceof Element) {\n      left = element.position();\n    }\n\n    if (isHash(left)) {\n      top_pos  = left.y;\n      left_pos = left.x;\n    }\n\n    // checking if a smooth scroll was requested\n    if (isHash(fx_options = fx_options || top) && RightJS.Fx) {\n      new Fx.Scroll(this, fx_options).start({x: left_pos, y: top_pos});\n    } else {\n      this._.scrollTo(left_pos, top_pos);\n    }\n\n    return this;\n  }\n});\n\n\n/**\n * represents some additional functionality for the Event class\n *\n * NOTE: there more additional functionality for the Event class in the rightjs-goods project\n *\n * Credits:\n *   The additional method names are inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nvar Event = RightJS.Event = new Class(Wrapper, {\n  // predefining the keys to spped up the assignments\n  type:          null,\n\n  which:         null,\n  keyCode:       null,\n\n  target:        null,\n  currentTarget: null,\n  relatedTarget: null,\n\n  pageX:         null,\n  pageY:         null,\n\n  /**\n   * the class constructor\n   *\n   * @param raw dom-event\n   * @param HTMLElement the bound element\n   * @return void\n   */\n  initialize: Event_Klass, // the actual initialization happens in the Klass function\n\n  /**\n   * Stops the event bubbling process\n   *\n   * @return RightJS.Event this\n   */\n  stopPropagation: function() {\n    if (this._.stopPropagation) {\n      this._.stopPropagation();\n    } else {\n      this._.cancelBubble = true;\n    }\n\n    this.stopped = true;\n    return this;\n  },\n\n  /**\n   * Prevents the default browser action on the event\n   *\n   * @return RightJS.Event this\n   */\n  preventDefault: function() {\n    if (this._.preventDefault) {\n      this._.preventDefault();\n    } else {\n      this._.returnValue = false;\n    }\n\n    return this;\n  },\n\n  /**\n   * Fully stops the event\n   *\n   * @return RightJS.Event this\n   */\n  stop: function() {\n    return this.stopPropagation().preventDefault();\n  },\n\n  /**\n   * Returns the event position\n   *\n   * @return Object {x: ..., y: ...}\n   */\n  position: function() {\n    return {x: this.pageX, y: this.pageY};\n  },\n\n  /**\n   * Returns the event's offset relative to the target element\n   *\n   * @return Object {x: ..., y: ...} or null\n   */\n  offset: function() {\n    if(this.target instanceof Element) {\n      var element_position = this.target.position();\n\n      return {\n        x: this.pageX - element_position.x,\n        y: this.pageY - element_position.y\n      };\n    }\n\n    // triggered outside browser window (at toolbar etc.)\n    return null;\n  },\n\n  /**\n   * Finds the element between the event target\n   * and the boundary element that matches the\n   * css-rule\n   *\n   * @param String css-rule\n   * @return Element element or null\n   */\n  find: function(css_rule) {\n    if (this.target instanceof Wrapper && this.currentTarget instanceof Wrapper) {\n      var target = this.target._,\n          search = this.currentTarget.find(css_rule, true);\n\n      while (target) {\n        if (search.indexOf(target) !== -1) {\n          return wrap(target);\n        }\n        target = target.parentNode;\n      }\n    }\n\n    return undefined;\n  }\n}, Event_Klass),\n\nEvent_delegation_shortcuts = [];\n\n\n/**\n * The DOM Element unit handling\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\n\nvar Element = RightJS.Element = new Class(Wrapper, {\n  /**\n   * constructor\n   *\n   * NOTE: this constructor will dynamically typecast\n   *       the wrappers depending on the element tag-name\n   *\n   * @param String element tag name or an HTMLElement instance\n   * @param Object options\n   * @return Element element\n   */\n  initialize: function(element, options) {\n    Element_initialize(this, element, options);\n  }\n\n}, Element_Klass),\n\nElement_wrappers = Element.Wrappers = {},\nelements_cache = {},\n\n/**\n * bulds dom-elements\n *\n * @param String element tag name\n * @param Object options\n * @return HTMLElement\n */\nmake_element = function (tag, options) {\n  return (tag in elements_cache ? elements_cache[tag] : (\n    elements_cache[tag] = document.createElement(tag)\n  )).cloneNode(false);\n};\n\n//\n// IE 6,7,8 (not 9!) browsers have a bug with checkbox and radio input elements\n// it doesn't place the 'checked' property correctly, plus there are some issues\n// with clonned SELECT objects, so we are replaceing the elements maker in here\n//\nif (IE8_OR_LESS) {\n  make_element = function(tag, options) {\n    if (options !== undefined && (tag === 'input' || tag === 'button')) {\n      tag = '<'+ tag +' name=\"'+ options.name +\n        '\" type=\"'+ options.type +'\"'+\n        (options.checked ? ' checked' : '') + ' />';\n\n      delete(options.name);\n      delete(options.type);\n    }\n\n    return document.createElement(tag);\n  };\n}\n\n/**\n * Basic element's constructor\n *\n * @param Element wrapper instance\n * @param mixed raw dom element of a string tag name\n * @param Object options\n * @return void\n */\nfunction Element_initialize(inst, element, options) {\n  if (typeof element === 'string') {\n    inst._ = make_element(element, options);\n\n    if (options !== undefined) {\n      for (var key in options) {\n        switch (key) {\n          case 'id':    inst._.id        = options[key]; break;\n          case 'html':  inst._.innerHTML = options[key]; break;\n          case 'class': inst._.className = options[key]; break;\n          case 'on':    inst.on(options[key]);           break;\n          default:      inst.set(key, options[key]);\n        }\n      }\n    }\n  } else {\n    inst._ = element;\n  }\n}\n\n\n/**\n * The DOM Element unit structures handling module\n *\n * NOTE: all the methods will process and return only the Element nodes\n *       all the textual nodes will be skipped\n *\n * NOTE: if a css-rule was specified then the result of the method\n *       will be filtered/adjusted depends on the rule\n *\n * Credits:\n *   The naming principle and most of the names are taken from\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *   The insertions system implementation is inspired by\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\n\nElement.include({\n  parent: function(css_rule) {\n    var parent = this._.parentNode, parent_type = parent && parent.nodeType;\n\n    return css_rule ? this.parents(css_rule)[0] :\n      (parent_type === 1 || parent_type === 9) ? // <- IE6 sometimes has a fragment node in there\n      wrap(parent) : null;\n  },\n\n  parents: function(css_rule) {\n    return recursively_collect(this, 'parentNode', css_rule);\n  },\n\n  children: function(css_rule) {\n    return this.find(css_rule).filter(function(element) {\n      return element._.parentNode === this._;\n    }, this);\n  },\n\n  siblings: function(css_rule) {\n    return this.prevSiblings(css_rule).reverse().concat(this.nextSiblings(css_rule));\n  },\n\n  nextSiblings: function(css_rule) {\n    return recursively_collect(this, 'nextSibling', css_rule);\n  },\n\n  prevSiblings: function(css_rule) {\n    return recursively_collect(this, 'previousSibling', css_rule);\n  },\n\n  next: function(css_rule) {\n    return !css_rule && this._.nextElementSibling !== undefined ?\n      wrap(this._.nextElementSibling) : this.nextSiblings(css_rule)[0];\n  },\n\n  prev: function(css_rule) {\n    return !css_rule && this._.previousElementSibling !== undefined ?\n      wrap(this._.previousElementSibling) : this.prevSiblings(css_rule)[0];\n  },\n\n  /**\n   * removes the elemnt out of this parent node\n   *\n   * @return Element self\n   */\n  remove: function() {\n    var element = this._, parent = element.parentNode;\n    if (parent) {\n      parent.removeChild(element);\n    }\n    return this;\n  },\n\n  /**\n   * handles the elements insertion functionality\n   *\n   * The content might be one of the following data\n   *\n   *  o) an element instance\n   *  o) a String (all the scripts will be parsed out and executed)\n   *  o) a list of Elements\n   *  o) a hash like {position: content}\n   *\n   * @param mixed data to insert\n   * @param String position to insert  top/bottom/before/after/instead\n   * @return Element self\n   */\n  insert: function(content, position) {\n    var scripts = null, element = this._;\n    position = position === undefined ? 'bottom' : position;\n\n    if (typeof(content) !== 'object') {\n      scripts = content = (''+content);\n    } else if (content instanceof Element) {\n      content = content._;\n    }\n\n    Element_insertions[position](element,\n      content.nodeType === undefined ?\n        Element_createFragment(\n          (position === 'bottom' || position === 'top') ?\n            element : element.parentNode, content\n        ) : content\n    );\n\n    if (scripts !== null) { scripts.evalScripts(); }\n\n    return this;\n  },\n\n  /**\n   * Inserts the element inside the given one at the given position\n   *\n   * @param mixed destination element reference\n   * @param String optional position\n   * @return Element this\n   */\n  insertTo: function(element, position) {\n    $(element).insert(this, position);\n    return this;\n  },\n\n  /**\n   * A shortcut to uppend several units into the element\n   *\n   * @param mixed data\n   * ..................\n   * @return Element this\n   */\n  append: function(first) {\n    return this.insert(isString(first) ? $A(arguments).join('') : arguments);\n  },\n\n  /**\n   * updates the content of the element by the given content\n   *\n   * @param mixed content (a String, an Element or a list of elements)\n   * @return Element self\n   */\n  update: function(content) {\n    if (typeof(content) !== 'object') {\n      content = '' + content;\n\n      try {\n        this._.innerHTML = content;\n      } catch(e) {\n        return this.clean().insert(content);\n      }\n\n      content.evalScripts();\n\n      return this;\n    } else {\n      return this.clean().insert(content);\n    }\n  },\n\n  /**\n   * Works with the Element's innerHTML property\n   * This method works both ways! if a content is provided\n   * then it will be assigned, otherwise will return\n   * the innerHTML property\n   *\n   * @param String html content\n   * @return String html content or Element this\n   */\n  html: function(content) {\n    return content === undefined ? this._.innerHTML : this.update(content);\n  },\n\n  /**\n   * Works with the Element's innerHTML property as a text\n   * when set something, it will appear as is with everything quoted\n   * when get, will return a string without any tags in it\n   *\n   * @param String text content\n   * @return String text content or Element this\n   */\n  text: function(text) {\n    return text === undefined ? (\n      this._.textContent === undefined ? this._.innerText : this._.textContent\n    ) : this.update(this.doc()._.createTextNode(text));\n  },\n\n  /**\n   * replaces the current element by the given content\n   *\n   * @param mixed content (a String, an Element or a list of elements)\n   * @return Element self\n   */\n  replace: function(content) {\n    return this.insert(content, 'instead');\n  },\n\n  /**\n   * wraps the element with the given element\n   *\n   * @param Element wrapper\n   * @return Element self\n   */\n  wrap: function(wrapper) {\n    var element = this._, parent = element.parentNode;\n    if (parent) {\n      wrapper = $(wrapper)._;\n      parent.replaceChild(wrapper, element);\n      wrapper.appendChild(element);\n    }\n    return this;\n  },\n\n  /**\n   * removes all the child nodes out of the element\n   *\n   * @return Element self\n   */\n  clean: function() {\n    while (this._.firstChild) {\n      this._.removeChild(this._.firstChild);\n    }\n\n    return this;\n  },\n\n  /**\n   * checks if the element has no child nodes\n   *\n   * @return boolean check result\n   */\n  empty: function() {\n    return this.html().blank();\n  },\n\n  /**\n   * Creates a clean clone of the element without any events attached to it\n   *\n   * @return Element new clone\n   */\n  clone: function() {\n    return new Element(this._.cloneNode(true));\n  },\n\n  /**\n   * Returns an index of the element among the other child elements\n   *\n   * NOTE: doesn't count the textual nodes!\n   *\n   * @return Integer index\n   */\n  index: function() {\n    var node    = this._,\n        sibling = node.parentNode.firstChild,\n        index   = 0;\n\n    while (sibling !== node) {\n      if (sibling.nodeType === 1) { // counting elements only\n        index ++;\n      }\n      sibling = sibling.nextSibling;\n    }\n\n    return index;\n  }\n});\n\n/**\n * Recursively collects the target element's related nodes\n *\n * @param Element context\n * @param name String pointer attribute name\n * @param rule String optional css-atom rule\n * @return Array found elements\n */\nfunction recursively_collect(where, attr, css_rule) {\n  var node = where._, result = [], i=0, no_rule = !css_rule;\n\n  while ((node = node[attr])) {\n    if (node.nodeType === 1 && (no_rule || wrap(node).match(css_rule))) {\n      result[i++] = wrap(node);\n    }\n  }\n\n  return result;\n}\n\n// list of insertions handling functions\n// NOTE: each of the methods will be called in the contects of the current element\nvar Element_insertions = {\n  bottom: function(target, content) {\n    target.appendChild(content);\n  },\n\n  top: function(target, content) {\n    if (target.firstChild !== null) {\n      target.insertBefore(content, target.firstChild);\n    } else {\n      target.appendChild(content);\n    }\n  },\n\n  after: function(target, content) {\n    var parent = target.parentNode, sibling = target.nextSibling;\n    if (sibling !== null) {\n      parent.insertBefore(content, sibling);\n    } else {\n      parent.appendChild(content);\n    }\n  },\n\n  before: function(target, content) {\n    target.parentNode.insertBefore(content, target);\n  },\n\n  instead: function(target, content) {\n    target.parentNode.replaceChild(content, target);\n  }\n},\n\n// the element insertion wrappers list\nElement_wraps = {\n  TBODY:  ['<TABLE>',            '</TABLE>',                           2],\n  TR:     ['<TABLE><TBODY>',     '</TBODY></TABLE>',                   3],\n  TD:     ['<TABLE><TBODY><TR>', '</TR></TBODY></TABLE>',              4],\n  COL:    ['<TABLE><COLGROUP>',  '</COLGROUP><TBODY></TBODY></TABLE>', 2],\n  LEGEND: ['<FIELDSET>',         '</FIELDSET>',                        2],\n  AREA:   ['<map>',              '</map>',                             2],\n  OPTION: ['<SELECT>',           '</SELECT>',                          2]\n};\n\n$alias(Element_wraps, {\n  OPTGROUP: 'OPTION',\n  THEAD:    'TBODY',\n  TFOOT:    'TBODY',\n  TH:       'TD'\n});\n\n// converts any data into a html fragment unit\nvar fragment = document.createDocumentFragment(),\n    tmp_cont = document.createElement('DIV');\n\nfunction Element_createFragment(context, content) {\n  if (typeof(content) === 'string') {\n    var tag   = context.tagName,\n        tmp   = tmp_cont,\n        wrap  = tag in Element_wraps ? Element_wraps[tag] : ['', '', 1],\n        depth = wrap[2];\n\n    tmp.innerHTML = wrap[0] + '<'+ tag + '>' + content + '</'+ tag + '>' + wrap[1];\n\n    while (depth-- !== 0) {\n      tmp = tmp.firstChild;\n    }\n\n    content = tmp.childNodes;\n\n    while (content.length !== 0) {\n      fragment.appendChild(content[0]);\n    }\n\n  } else {\n    for (var i=0, length = content.length, node; i < length; i++) {\n      node = content[content.length === length ? i : 0];\n      fragment.appendChild(node instanceof Element ? node._ : node);\n    }\n  }\n\n  return fragment;\n}\n\n\n/**\n * this module contains the element unit styles related methods\n *\n * Credits:\n *   Some of the functionality is inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *     - Dojo      (www.dojotoolkit.org)      Copyright (C) The Dojo Foundation\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nElement.include({\n  /**\n   * assigns styles out of the hash to the element\n   *\n   * NOTE: the style keys might be camelized or dasherized, both cases should work\n   *\n   * @param Object styles list or String style name\n   * @param String style value in case of the first param a string style name\n   * @return Element self\n   */\n  setStyle: function(hash, value) {\n    var key, c_key, style = {}, element_style = this._.style;\n\n    if (value !== undefined) { style[hash] = value; hash = style; }\n    else if(isString(hash)) {\n      hash.split(';').each(function(option) {\n        var els = option.split(':').map('trim');\n        if (els[0] && els[1]) {\n          style[els[0]] = els[1];\n        }\n      });\n      hash = style;\n    }\n\n\n    for (key in hash) {\n      c_key = key.indexOf('-') < 0 ? key : key.camelize();\n\n      if (IE_OPACITY && key === 'opacity') {\n        element_style.filter = 'alpha(opacity='+ hash[key] * 100 +')';\n      } else if (key === 'float') {\n        c_key = Browser_IE ? 'styleFloat' : 'cssFloat';\n      }\n\n      element_style[c_key] = hash[key];\n    }\n\n    return this;\n  },\n\n  /**\n   * returns style of the element\n   *\n   * NOTE: will include the CSS level definitions\n   *\n   * @param String style key\n   * @return String style value or null if not set\n   */\n  getStyle: function(key) {\n    return clean_style(this._.style, key) || clean_style(this.computedStyles(), key);\n  },\n\n  /**\n   * returns the hash of computed styles for the element\n   *\n   * @return Object/CSSDefinition computed styles\n   */\n  computedStyles: HTML.currentStyle ? function() {\n    return this._.currentStyle || {};\n  } : HTML.runtimeStyle ? function() {\n    return this._.runtimeStyle || {};\n  } : function() {\n    return this._.ownerDocument.defaultView.getComputedStyle(this._, null);\n  },\n\n  /**\n   * checks if the element has the given class name\n   *\n   * @param String class name\n   * @return boolean check result\n   */\n  hasClass: function(name) {\n    return (' '+this._.className+' ').indexOf(' '+name+' ') != -1;\n  },\n\n  /**\n   * sets the whole class-name string for the element\n   *\n   * @param String class-name\n   * @return Element self\n   */\n  setClass: function(class_name) {\n    this._.className = class_name;\n    return this;\n  },\n\n  /**\n   * Returns the current class-name\n   *\n   * @return String class-name\n   */\n  getClass: function() {\n    return this._.className;\n  },\n\n  /**\n   * adds the given class name to the element\n   *\n   * @param String class name\n   * @return Element self\n   */\n  addClass: function(name) {\n    var testee = ' '+this._.className+' ';\n    if (testee.indexOf(' '+name+' ') == -1) {\n      this._.className += (testee === '  ' ? '' : ' ') + name;\n    }\n    return this;\n  },\n\n  /**\n   * removes the given class name\n   *\n   * @param String class name\n   * @return Element self\n   */\n  removeClass: function(name) {\n    this._.className = (' '+this._.className+' ').replace(' '+name+' ', ' ').trim();\n    return this;\n  },\n\n  /**\n   * toggles the given class name on the element\n   *\n   * @param String class name\n   * @return Element self\n   */\n   toggleClass: function(name) {\n     return this[this.hasClass(name) ? 'removeClass' : 'addClass'](name);\n   },\n\n   /**\n    * adds the given class-name to the element\n    * and removes it from all the element siblings\n    *\n    * @param String class name\n    * @return Element self\n    */\n   radioClass: function(name) {\n     this.siblings().each('removeClass', name);\n     return this.addClass(name);\n   }\n});\n\n/**\n * cleans up a style value\n *\n * @param Object styles hash\n * @param String style-key\n * @return String clean style\n */\nfunction clean_style(style, key) {\n  key = key.camelize();\n\n  if (key === 'opacity') {\n    return IE_OPACITY ? (\n      (/opacity=(\\d+)/i.exec(style.filter || '') ||\n      ['', '100'])[1].toInt() / 100\n    )+'' :style[key].replace(',', '.');\n  }\n\n  if (key === 'float') {\n    key = Browser_IE ? 'styleFloat' : 'cssFloat';\n  }\n\n  var value = style[key];\n\n  // Opera returns named colors with quotes\n  if (Browser_Opera && /color/i.test(key) && value) {\n    value = value.replace(/\"/g, '');\n  }\n\n  return value;\n}\n\n\n/**\n * Common DOM Element unit methods\n *\n * Credits:\n *   Most of the naming system in the module inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nElement.include({\n  /**\n   * sets the element attributes\n   *\n   * @param String attr name or Object attributes hash\n   * @param mixed attribute value\n   * @return Element self\n   */\n  set: function(hash, value) {\n    if (typeof(hash) === 'string') { var val = {}; val[hash] = value; hash = val; }\n\n    var key, element = this._;\n\n    for (key in hash) {\n      if (key === 'style') {\n        this.setStyle(hash[key]);\n      } else {\n        // some attributes are not available as properties\n        if (!(key in element)) {\n          element.setAttribute(key, ''+hash[key]);\n        }\n        if (key.substr(0,5) !== 'data-') {\n          element[key] = hash[key];\n        }\n      }\n    }\n\n    return this;\n  },\n\n  /**\n   * returns the attribute value for the name\n   *\n   * @param String attr name\n   * @return mixed value\n   */\n  get: function(name) {\n    var element = this._, value = element[name] || element.getAttribute(name);\n    return value === '' ? null : value;\n  },\n\n  /**\n   * checks if the element has that attribute\n   *\n   * @param String attr name\n   * @return Boolean check result\n   */\n  has: function(name) {\n    return this.get(name) !== null;\n  },\n\n  /**\n   * erases the given attribute of the element\n   *\n   * @param String attr name\n   * @return Element self\n   */\n  erase: function(name) {\n    this._.removeAttribute(name);\n    return this;\n  },\n\n  /**\n   * checks if the elemnt is hidden\n   *\n   * NOTE: will check css level computed styles too\n   *\n   * @return boolean check result\n   */\n  hidden: function() {\n    return this.getStyle('display') === 'none';\n  },\n\n  /**\n   * checks if the element is visible\n   *\n   * @return boolean check result\n   */\n  visible: function() {\n    return !this.hidden();\n  },\n\n  /**\n   * hides the element\n   *\n   * @param String optional effect name\n   * @param Object the optional effect options\n   * @return Element self\n   */\n  hide: function(effect, options) {\n    if (this.visible()) {\n      this._d = this.getStyle('display');\n      this._.style.display = 'none';\n    }\n\n    return this;\n  },\n\n  /**\n   * shows the element\n   *\n   * @return Element self\n   */\n  show: function() {\n    if (this.hidden()) {\n      var element   = this._, value = this._d, dummy;\n\n      // trying to guess the default 'style.display' for this kind of elements\n      if (!value || value === 'none') {\n        dummy = $E(element.tagName).insertTo(HTML);\n        value = dummy.getStyle('display');\n        dummy.remove();\n      }\n\n      // failsafe in case the user been naughty\n      if (value === 'none') {\n        value = 'block';\n      }\n\n      element.style.display = value;\n    }\n\n    return this;\n  },\n\n  /**\n   * toggles the visibility state of the element\n   *\n   * @return Element self\n   */\n  toggle: function() {\n    return this[this.visible() ? 'hide' : 'show']();\n  },\n\n  /**\n   * shows the element and hides all the sibligns\n   *\n   * @param String optional effect name\n   * @param Object the optional effect options\n   * @return Element self\n   */\n  radio: function(effect, options) {\n    this.siblings().each('hide', effect, options);\n    return this.show();\n  },\n\n  /**\n   * Sets/gets the `data-smth` data attribute and\n   * automatically converts everything in/out JSON\n   *\n   * @param String key name\n   * @param mixed data or `undefined` to erase\n   * @return mixed Element self or extracted data\n   */\n  data: function(key, value) {\n    var name, result, match, attrs, attr, i;\n\n    if (isHash(key)) {\n      for (name in key) {\n        value = this.data(name, key[name]);\n      }\n    } else if (value === undefined) {\n      key = 'data-'+ (''+key).dasherize();\n\n      for (result = {}, match = false, attrs = this._.attributes, i=0; i < attrs.length; i++) {\n        value = attrs[i].value;\n        try { value = JSON.parse(value); } catch (e) {}\n\n        if (attrs[i].name === key) {\n          result = value;\n          match  = true;\n          break;\n        } else if (attrs[i].name.indexOf(key) === 0) {\n          result[attrs[i].name.substring(key.length+1).camelize()] = value;\n          match = true;\n        }\n      }\n\n      value = match ? result : null;\n    } else {\n      key = 'data-'+ (''+key).dasherize();\n\n      if (!isHash(value)) { value = {'': value}; }\n\n      for (name in value) {\n        attr = name.blank() ? key : key+'-'+name.dasherize();\n\n        if (value[name] === null) {\n          this._.removeAttribute(attr);\n        } else {\n          this._.setAttribute(attr, isString(value[name]) ? value[name] : JSON.stringify(value[name]));\n        }\n      }\n\n      value = this;\n    }\n\n    return value;\n  }\n});\n\n\n/**\n * this module contains the Element's part of functionality\n * responsible for the dimensions and positions getting/setting\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nElement.include({\n  /**\n   * Returns the reference to this element document\n   *\n   * @return RightJS.Document\n   */\n  doc: function() {\n    return wrap(this._.ownerDocument);\n  },\n\n  /**\n   * Returns the reference to this elements window\n   *\n   * @return RightJS.Window\n   */\n  win: function() {\n    return this.doc().win();\n  },\n\n  /**\n   * Returns the element size as a hash\n   *\n   * @return Object {x: NNN, y: NNN}\n   */\n  size: function() {\n    return { x: this._.offsetWidth, y: this._.offsetHeight };\n  },\n\n  /**\n   * Returns the element absolute position\n   *\n   * NOTE: see the konq.js file for the manual version of the method\n   *\n   * @return Object {x: NNN, y: NNN}\n   */\n  position: function() {\n    var rect    = this._.getBoundingClientRect(),\n        html    = this.doc()._.documentElement,\n        scrolls = this.win().scrolls();\n\n    return {\n      x: rect.left + scrolls.x - html.clientLeft,\n      y: rect.top  + scrolls.y - html.clientTop\n    };\n  },\n\n  /**\n   * Returns the element scrolls\n   *\n   * @return Object {x: NNN, y: NNN}\n   */\n  scrolls: function() {\n    return { x: this._.scrollLeft, y: this._.scrollTop };\n  },\n\n  /**\n   * returns the element dimensions hash\n   *\n   * @return Object dimensions (top, left, width, height, scrollLeft, scrollTop)\n   */\n  dimensions: function() {\n    var size     = this.size(),\n        scrolls  = this.scrolls(),\n        position = this.position();\n\n    return {\n      top:        position.y,\n      left:       position.x,\n      width:      size.x,\n      height:     size.y,\n      scrollLeft: scrolls.x,\n      scrollTop:  scrolls.y\n    };\n  },\n\n  /**\n   * Checks if the element overlaps the given position\n   *\n   * @param Object position {x: NNN, y: NNN}\n   * @return boolean check result\n   */\n  overlaps: function(target) {\n    var pos = this.position(), size = this.size();\n\n    return target.x > pos.x && target.x < (pos.x + size.x) &&\n           target.y > pos.y && target.y < (pos.y + size.y);\n  },\n\n  /**\n   * sets the width of the element in pixels\n   *\n   * NOTE: will double assign the size of the element, so it match the exact\n   *       size including any possible borders and paddings\n   *\n   * @param Integer width in pixels\n   * @return Element self\n   */\n  setWidth: function(width_px) {\n    var style = this._.style;\n    style.width = width_px + 'px';\n    style.width = (2 * width_px - this._.offsetWidth) + 'px';\n    return this;\n  },\n\n  /**\n   * sets the width of the element in pixels\n   *\n   * NOTE: will double assign the size of the element, so it match the exact\n   *       size including any possible borders and paddings\n   *\n   * @param Integer height in pixels\n   * @return Element self\n   */\n  setHeight: function(height_px) {\n    var style = this._.style;\n    style.height = height_px + 'px';\n    style.height = (2 * height_px - this._.offsetHeight) + 'px';\n    return this;\n  },\n\n  /**\n   * sets the size of the element in pixels\n   *\n   * NOTE: will double assign the size of the element, so it match the exact\n   *       size including any possible borders and paddings\n   *\n   * @param width Integer width in pixels or {x: 10, y: 20} like object\n   * @param height Integer height\n   * @return Element self\n   */\n  resize: function(width, height) {\n    if (isHash(width)) {\n      height = width.y;\n      width  = width.x;\n    }\n    return this.setWidth(width).setHeight(height);\n  },\n\n  /**\n   * sets the element position (against the window corner)\n   *\n   * @param left Number left position in pixels or an object like {x: 10, y: 20}\n   * @param top Number top position in pixels\n   * @return Element self\n   */\n  moveTo: function(left, top) {\n    if (isHash(left)) {\n      top  = left.y;\n      left = left.x;\n    }\n\n    return this.setStyle({\n      left: left + 'px',\n      top:  top  + 'px'\n    });\n  },\n\n  /**\n   * sets the scroll position\n   *\n   * @param left Integer left scroll px or an object like {x: 22, y: 33}\n   * @param top Integer top scroll px\n   * @return Element self\n   */\n  scrollTo: function(left, top) {\n    if (isHash(left)) {\n      top  = left.y;\n      left = left.x;\n    }\n\n    this._.scrollLeft = left;\n    this._.scrollTop  = top;\n\n    return this;\n  },\n\n  /**\n   * makes the window be scrolled to the element\n   *\n   * @param Object fx options\n   * @return Element self\n   */\n  scrollThere: function(options) {\n    this.win().scrollTo(this, options);\n    return this;\n  }\n});\n\n\n/**\n * DOM Element events handling methods\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\n[Element, Document, Window].each('include', $ext(Observer_create({}), {\n  /**\n   * The basic events handling attachment method\n   * SEE Observer#on for more details about supported arguments\n   *\n   * @returnt this\n   */\n  on: function() {\n    Observer_on(this, arguments, function(hash) {\n\n      if (hash.e === 'mouseenter' || hash.e === 'mouseleave') {\n        mouse_io_activate();\n        hash.n = hash.e;\n        hash.w = function() {};\n        // NOTE: we don't attach this listener to the actual element!\n        //       so it didn't screw with IE's native enter/leave handlers\n      } else {\n        if (hash.e === 'contextmenu' && Browser.Konqueror) {\n          hash.n = 'rightclick';\n        } else if (hash.e === 'mousewheel' && Browser.Gecko) {\n          hash.n = 'DOMMouseScroll';\n        } else {\n          hash.n = hash.e;\n        }\n\n        hash.w = function(event) {\n          event = new Event(event, hash.t);\n          if (hash.f.apply(hash.t, (hash.r?[]:[event]).concat(hash.a)) === false) {\n            event.stop();\n          }\n        };\n\n        if (IE8_OR_LESS) {\n          hash.t._.attachEvent('on'+hash.n, hash.w);\n        } else {\n          hash.t._.addEventListener(hash.n, hash.w, false);\n        }\n      }\n\n      return hash;\n    });\n\n    return this;\n  },\n\n  /**\n   * Stops an event handling\n   *\n   * @param String event name or a function callback\n   * @param function callback or nothing\n   * @return this\n   */\n  stopObserving: function(event, callback) {\n    Observer_stopObserving(this, event, callback, function(hash) {\n      if (IE8_OR_LESS) {\n        hash.t._.detachEvent('on'+ hash.n, hash.w);\n      } else {\n        hash.t._.removeEventListener(hash.n, hash.w, false);\n      }\n    });\n\n    return this;\n  },\n\n  /**\n   * Artificially trigers the event on the element\n   *\n   * @param string event name or an Event instance\n   * @param Object options\n   * @return this\n   */\n  fire: function(event, options) {\n    var parent = this.parent && this.parent();\n\n    if (!(event instanceof Event)) {\n      event = new Event(event, $ext({target: this._}, options));\n    }\n\n    // setting up the currentTarget reference\n    event.currentTarget = this;\n\n    (this.$listeners || []).each(function(hash) {\n      if (hash.e === event.type &&\n        hash.f.apply(this, (hash.r?[]:[event]).concat(hash.a)) === false\n      ) {\n        event.stop();\n      }\n    }, this);\n\n    // manually bypassing the event to the parent one if it should bubble\n    if (parent && parent.fire && !event.stopped) {\n      parent.fire(event);\n    }\n\n    return this;\n  },\n\n  /**\n   * a simple events terminator method to be hooked like this.onClick('stopEvent');\n   *\n   * @return false\n   */\n  stopEvent: function() { return false; }\n}));\n\n// couple more shortcuts for the window\nObserver_createShortcuts(Window.prototype, $w('blur focus scroll resize load'));\n\n/**\n * Registers a list of event-binding shortcuts like\n *  $(element).onClick\n *  $(element).onMouseover\n *\n * @param String space separated event names\n * @return void\n */\nfunction Element_add_event_shortcuts(tokens) {\n  tokens = $w(tokens);\n  Event_delegation_shortcuts = Event_delegation_shortcuts.concat(tokens);\n\n  Observer_createShortcuts(Element.prototype, tokens);\n  Observer_createShortcuts(Document.prototype, tokens);\n}\n\nElement_add_event_shortcuts(\n  'click rightclick contextmenu mousedown mouseup '+\n  'mouseover mouseout mousemove keypress keydown keyup'\n);\n\n\n/**\n * The DOM elements selection handling\n *\n * NOTE: this module is just a wrap over the native CSS-selectors feature\n *       see the olds/css.js file for the manual selector code\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\n\n[Element, Document].each('include', {\n  /**\n   * Extracts the first element matching the css-rule,\n   * or just any first element if no css-rule was specified\n   *\n   * @param String css-rule\n   * @return Element matching node or null\n   */\n  first: function(css_rule) {\n    return wrap(\n      css_rule === undefined && this._.firstElementChild !== undefined ?\n      this._.firstElementChild : this._.querySelector(css_rule || '*')\n    );\n  },\n\n  /**\n   * Finds a list of matching nodes, or all the descendant nodes if no css-rule provided\n   *\n   * @param String css-rule\n   * @param boolean raw-search\n   * @return Array of elements\n   */\n  find: function(css_rule, raw) {\n    var query = this._.querySelectorAll(css_rule || '*'), result, i=0, l = query.length;\n\n    if (raw === true) {\n      result = $A(query);\n    } else {\n      for (result = []; i < l; i++) {\n        result[i] = wrap(query[i]);\n      }\n    }\n\n    return result;\n  },\n\n  /**\n   * checks if the element matches this css-rule\n   *\n   * NOTE: the element should be attached to the page\n   *\n   * @param String css-rule\n   * @return Boolean check result\n   */\n  match: function(css_rule) {\n    // finding the top parent element (the element might not be on the document)\n    var element = this._, parent = element, result, faking = false;\n\n    while (parent.parentNode !== null && parent.parentNode.nodeType !== 11) {\n      parent = parent.parentNode;\n    }\n\n    // creating a fake context when needed\n    if (element === parent) {\n      parent = document.createElement('div');\n      parent.appendChild(element);\n      faking = true;\n    }\n\n    result = wrap(parent).find(css_rule, true).indexOf(element) !== -1;\n\n    if (faking) {\n      parent.removeChild(element);\n    }\n\n    return result;\n  }\n});\n\n\n/**\n * The dom-ready event handling code\n *\n * Credits:\n *   The basic principles of the module are originated from\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *\n * Copyright (C) 2009-2011 Nikolay Nemshilov\n */\nDocument.include({\n  on: function(name) {\n    if (name === 'ready' && !this._iR) {\n      var document = this._, ready = this.fire.bind(this, 'ready');\n\n      // IE and Konqueror browsers\n      if ('readyState' in document) {\n        (function() {\n          if (['loaded','complete'].include(document.readyState)) {\n            ready();\n          } else {\n            arguments.callee.delay(50);\n          }\n        })();\n      } else {\n        document.addEventListener('DOMContentLoaded', ready, false);\n      }\n\n      this._iR = true;\n    }\n\n    return this.$super.apply(this, arguments);\n  }\n});\n\nObserver_createShortcuts(Document.prototype, ['ready']);\n\n/**\n * The form unit class and extensions\n *\n * Credits:\n *   The basic principles of the module are inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *\n * Copyright (C) 2009-2011 Nikolay Nemshilov\n */\n\nvar Form = RightJS.Form = Element_wrappers.FORM = new Class(Element, {\n  /**\n   * constructor\n   *\n   * NOTE: this constructor can be called as a normal Element constructor\n   *       or with the options only, which will make a FORM element\n   *\n   *   var form = new Form(raw_form_object_element);\n   *   var form = new Form({method: 'post', action: '/boo/hoo'});\n   *\n   * @param Object options or HTMLFormElement object\n   * @return void\n   */\n  initialize: function(in_options) {\n    var options = in_options || {}, remote = 'remote' in options, element = options;\n\n    if (isHash(options) && !isElement(options)) {\n      element = 'form';\n      options = Object.without(options, 'remote');\n    }\n\n    this.$super(element, options);\n\n    if (remote) {\n      this.remotize();\n    }\n  },\n\n  /**\n   * returns the form elements as an array of extended units\n   *\n   * @return Array of elements\n   */\n  elements: function() {\n    return this.find('input,button,select,textarea');\n  },\n\n  /**\n   * returns the list of all the input elements on the form\n   *\n   * @return Array of elements\n   */\n  inputs: function() {\n    return this.elements().filter(function(input) {\n      return !['submit', 'button', 'reset', 'image', null].include(input._.type);\n    });\n  },\n\n  /**\n   * Accessing an input by name\n   *\n   * @param String name\n   * @return Input field\n   */\n  input: function(name) {\n    var input = this._[name];\n\n    if ('tagName' in input) {\n      input = wrap(input);\n    } else { // a list of radio-buttons (coz they have all the same name)\n      input = $A(input).map(wrap);\n    }\n\n    return input;\n  },\n\n  /**\n   * focuses on the first input element on the form\n   *\n   * @return Form this\n   */\n  focus: function() {\n    var element = this.inputs().first(function(input) {\n      return input._.type !== 'hidden';\n    });\n\n    if (element) { element.focus(); }\n\n    return this;\n  },\n\n  /**\n   * removes focus out of all the form elements\n   *\n   * @return Form this\n   */\n  blur: function() {\n    this.elements().each('blur');\n    return this;\n  },\n\n  /**\n   * disables all the elements on the form\n   *\n   * @return Form this\n   */\n  disable: function() {\n    this.elements().each('disable');\n    return this;\n  },\n\n  /**\n   * enables all the elements on the form\n   *\n   * @return Form this\n   */\n  enable: function() {\n    this.elements().each('enable');\n    return this;\n  },\n\n  /**\n   * returns the list of the form values\n   *\n   * @return Object values\n   */\n  values: function() {\n    var values = {};\n\n    this.inputs().each(function (element) {\n      var input = element._,\n          hash  = values, key,\n          keys  = input.name.match(/[^\\[]+/g);\n\n      if (!input.disabled && input.name && (!(input.type === 'checkbox' || input.type === 'radio') || input.checked)) {\n        // getting throught the smth[smth][smth][] in the name\n        while (keys.length > 1) {\n          key  = keys.shift();\n          if (key.endsWith(']')) {\n            key  = key.substr(0, key.length-1);\n          }\n          if (!hash[key]) {\n            hash[key] = keys[0] === ']' ? [] : {};\n          }\n          hash = hash[key];\n        }\n\n        key  = keys.shift();\n        if (key.endsWith(']')) {\n          key = key.substr(0, key.length-1);\n        }\n\n        if (key === '') { // an array\n          hash.push(element.value());\n        } else {\n          hash[key] = element.value();\n        }\n      }\n    });\n\n    return values;\n  },\n\n  /**\n   * returns the key/values organized ready to be sent via a get request\n   *\n   * @return String serialized values\n   */\n  serialize: function() {\n    return Object.toQueryString(this.values());\n  },\n\n  /**\n   * Delegating the submit method\n   *\n   * @return Form this\n   */\n  submit: function() {\n    this._.submit();\n    return this;\n  },\n\n  /**\n   * Delegating the 'reset' method\n   *\n   * @return Form this\n   */\n  reset: function() {\n    this._.reset();\n    return this;\n  }\n});\n\n// creating the event shortcuts\nElement_add_event_shortcuts('submit reset focus blur disable enable change');\n\n\n/**\n * The form input element class\n *\n * Copyright (C) 2010-2011 Nikolay Nemshilov\n */\nvar Input = RightJS.Input =\n\n// retgistering the typecasted wrappers\nElement_wrappers.INPUT    =\nElement_wrappers.BUTTON   =\nElement_wrappers.SELECT   =\nElement_wrappers.TEXTAREA =\nElement_wrappers.OPTGROUP =\n\nnew Class(Element, {\n  /**\n   * Constructor\n   *\n   * NOTE: this constructor can be called in several ways\n   *\n   *  Like normal Element\n   *   var input = new Input('texarea', {...});\n   *   var input = new Input(document.createElement('select'));\n   *\n   *  Or with options only which will make an INPUT element by default\n   *    var input = new Input({type: 'password', name: 'password'});\n   *\n   * @param HTMLElement or a String tag name or Options for default 'input' tag\n   * @param Object options\n   * @return void\n   */\n  initialize: function(element, options) {\n    // type to tag name conversion\n    if (!element || (isHash(element) && !isElement(element))) {\n      options = element || {};\n\n      if (/textarea|select/.test(options.type || '')) {\n        element = options.type;\n        delete(options.type);\n      } else {\n        element = 'input';\n      }\n    }\n\n    this.$super(element, options);\n  },\n\n  /**\n   * Returns a reference to the input's form\n   *\n   * @return Form wrapped form\n   */\n  form: function() {\n    return wrap(this._.form);\n  },\n\n  /**\n   * Overloading the method to fix some issues with IE and FF\n   *\n   * @param mixed content\n   * @param string optional position\n   * @return Input this\n   */\n  insert: function(content, position) {\n    this.$super(content, position);\n\n    // manually resetting the selected option in here\n    this.find('option').each(function(option) {\n      option._.selected = !!option.get('selected');\n    });\n\n    return this;\n  },\n\n  /**\n   * Overloading the method so it always called the '#insert' method\n   *\n   * @param mixed content\n   * @return Input this\n   */\n  update: function(content) {\n    return this.clean().insert(content);\n  },\n\n  /**\n   * uniform access to the element values\n   *\n   * @return String element value\n   */\n  getValue: function() {\n    if (this._.type == 'select-multiple') {\n      return this.find('option').map(function(option) {\n        return option._.selected ? option._.value : null;\n      }).compact();\n    } else {\n      return this._.value;\n    }\n  },\n\n  /**\n   * uniform accesss to set the element value\n   *\n   * @param String value\n   * @return Element this\n   */\n  setValue: function(value) {\n    if (this._.type == 'select-multiple') {\n      value = ensure_array(value).map(String);\n      this.find('option').each(function(option) {\n        option._.selected = value.include(option._.value);\n      });\n    } else {\n      this._.value = value;\n    }\n    return this;\n  },\n\n  /**\n   * Both ways getter/setter for the value parameter\n   *\n   * @param mixed value\n   * @return mixed this or the value\n   */\n  value: function(value) {\n    return this[value === undefined ? 'getValue' : 'setValue'](value);\n  },\n\n  /**\n   * focuses on the first input element on the form\n   *\n   * @return Form this\n   */\n  focus: function() {\n    this._.focus();\n    this.focused = true;\n    if (Browser_IE) { this.fire('focus', {bubbles: false}); }\n    return this;\n  },\n\n  /**\n   * removes focus out of all the form elements\n   *\n   * @return Form this\n   */\n  blur: function() {\n    this._.blur();\n    this.focused = false;\n    if (Browser_IE) { this.fire('blur', {bubbles: false}); }\n    return this;\n  },\n\n  /**\n   * focuses on the element and selects its content\n   *\n   * @return Element this\n   */\n  select: function() {\n    this._.select();\n    return this.focus();\n  },\n\n  /**\n   * disables all the elements on the form\n   *\n   * @return Form this\n   */\n  disable: function() {\n    this._.disabled = true;\n    return this.fire('disable');\n  },\n\n  /**\n   * enables all the elements on the form\n   *\n   * @return Form this\n   */\n  enable: function() {\n    this._.disabled = false;\n    return this.fire('enable');\n  },\n\n  /**\n   * A bidirectional method to set/get the disabled status of the input field\n   *\n   * @param boolean optional value\n   * @return Input in setter mode boolean in getter\n   */\n  disabled: function(value) {\n    return value === undefined ? this._.disabled : this[value ? 'disable' : 'enable']();\n  },\n\n  /**\n   * A bidirectional method to set/get the checked status of the input field\n   *\n   * @param boolean optional value\n   * @return Input in setter mode boolean in getter\n   */\n  checked: function(value) {\n    if (value === undefined) {\n      value = this._.checked;\n    } else {\n      this._.checked = value;\n      value = this;\n    }\n\n    return value;\n  }\n});\n\n\n/**\n * This module provides correct focus/blur events bubbling\n *\n * Copyright (C) 2010-2011 Nikolay Nemshilov\n */\n\n/**\n * Triggers a manual focus/blur events bubbling\n *\n * @param raw dom-event\n * @return void\n */\nfunction focus_boobler(raw_event) {\n  var event  = new Event(raw_event),\n      target = event.target,\n      parent = target.parent && target.parent();\n\n  event.type = raw_event.type === 'focusin' || raw_event.type === 'focus' ? 'focus' : 'blur';\n\n  if (parent) { parent.fire(event); }\n}\n\n/**\n * Hooking up the 'focus' and 'blur' events\n * at the document level and then rebooble them\n * manually like they were normal events\n *\n */\nif (IE8_OR_LESS) {\n  document.attachEvent('onfocusin',  focus_boobler);\n  document.attachEvent('onfocusout', focus_boobler);\n} else {\n  document.addEventListener('focus', focus_boobler, true);\n  document.addEventListener('blur',  focus_boobler, true);\n}\n\n\n/**\n * Provides the mouse enter/leave events handling emulation\n *\n * Copyright (C) 2010-2011 Nikolay Nemshilov\n */\nvar mouse_io_index = [], mouse_io_inactive = true;\n\n/**\n * Fires the actual mouseenter/mouseleave event\n *\n * @param original event\n * @param raw dom element\n * @param integer uid\n * @param boolean mouseenter or mouseleave\n * @return void\n */\nfunction mouse_io_fire(raw, element, uid, enter) {\n  var event = new Event(raw);\n  event.type    = enter === true ? 'mouseenter' : 'mouseleave';\n  event.bubbles = false;\n  event.stopped = true;\n  event.target  = wrap(element);\n\n  // replacing the #find method so that UJS didn't\n  // get broke with trying to find nested elements\n  event.find = function(css_rule) {\n    return $$(css_rule, true)\n      .indexOf(this.target._) === -1 ?\n        undefined : this.target;\n  };\n\n  event.target.fire(event);\n  current_Document.fire(event);\n}\n\n/**\n * Figures out the enter/leave events by listening the\n * mouseovers in the document\n *\n * @param raw dom event\n * @return void\n */\nfunction mouse_io_handler(e) {\n  var target  = e.target        || e.srcElement,\n      from    = e.relatedTarget || e.fromElement,\n      element = target,\n      passed  = false,\n      parents = [],\n      uid, event;\n\n  while (element.nodeType === 1) {\n    uid = $uid(element);\n\n    if (mouse_io_index[uid] === undefined) {\n      mouse_io_fire(e, element, uid,\n        mouse_io_index[uid] = true\n      );\n    }\n\n    if (element === from) {\n      passed = true;\n    }\n\n    parents.push(element);\n\n    element = element.parentNode;\n  }\n\n  if (from && !passed) {\n    while (from !== null && from.nodeType === 1 && parents.indexOf(from) === -1) {\n      uid = $uid(from);\n      if (mouse_io_index[uid] !== undefined) {\n        mouse_io_fire(e, from, uid,\n          mouse_io_index[uid] = undefined\n        );\n      }\n\n      from = from.parentNode;\n    }\n  }\n}\n\n/**\n * Calling 'mouseleave' for all currently active elements on the page\n *\n * @return void\n */\nfunction mouse_io_reset(e) {\n  mouse_io_index.each(function(value, uid) {\n    if (value && Wrappers_Cache[uid]) {\n      mouse_io_fire(e, Wrappers_Cache[uid]._, uid, false);\n    }\n  });\n}\n\n/**\n * Activating the mouse-io events emulation\n *\n * @return void\n */\nfunction mouse_io_activate() {\n  if (mouse_io_inactive) {\n    mouse_io_inactive = false;\n\n    if (Browser_IE) {\n      document.attachEvent('onmouseover', mouse_io_handler);\n      window.attachEvent('blur', mouse_io_reset);\n    } else {\n      document.addEventListener('mouseover', mouse_io_handler, false);\n      window.addEventListener('blur', mouse_io_reset, false);\n    }\n  }\n}\n\nElement_add_event_shortcuts('mouseenter mouseleave');\n\n/**\n * This module the standard events delegation interface\n *\n * Copyright (C) 2010-2011 Nikolay Nemshilov\n */\n[Element, Document].each('include', {\n  /**\n   * Attaches a delegative event listener to the element/document\n   *\n   * USAGE:\n   *    $(element).delegate('click', '#css.rule', function() {...});\n   *    $(element).delegate('click', '#css.rule', [func1, func2, ...]);\n   *    $(element).delegate('click', '#css.rule', 'addClass', 'boo');\n   *    $(element).delegate('click', '#css.rule', 'hide');\n   *\n   *    $(element).delegate('click', {\n   *      '#css.rule1': function() {},\n   *      '#css.rule2': [func1, func2, ...],\n   *      '#css.rule3': ['addClass', 'boo'],\n   *      '#css.rule4': 'hide'\n   *    });\n   *\n   * @param event name\n   * @param css-rule a hash or rules\n   * @param callback\n   * @return this\n   */\n  delegate: function(event) {\n    var rules = delegation_rules(arguments), css_rule, i, j, list;\n    for (css_rule in rules) {\n      for (i=0, list = rules[css_rule]; i < list.length; i++) {\n        // registering the delegative listener\n        this.on(event, build_delegative_listener(css_rule, list[i], this));\n\n        // adding the css-rule and callback references to the store\n        $ext(this.$listeners.last(), { dr: css_rule, dc: list[i][0] });\n      }\n    }\n\n    return this;\n  },\n\n  /**\n   * Removes a delegative event listener from the element\n   *\n   * USAGE:\n   *    $(element).undelegate('click');\n   *    $(element).undelegate('click', '#css.rule');\n   *    $(element).undelegate('click', '#css.rule', function() {});\n   *    $(element).undelegate('click', '#css.rule', [func1, func2, ...]);\n   *    $(element).undelegate('click', '#css.rule', 'addClass', 'boo');\n   *    $(element).undelegate('click', '#css.rule', 'hide');\n   *\n   *    $(element).undelegate('click', {\n   *      '#css.rule1': function() {},\n   *      '#css.rule2': [func1, func2, ...],\n   *      '#css.rule3': ['addClass', 'boo'],\n   *      '#css.rule4': 'hide'\n   *    });\n   *\n   * @param event name\n   * @param css-rule or a hash or rules\n   * @param callback\n   * @return this\n   */\n  undelegate: function(event) {\n    delegation_listeners(arguments, this).each(function(h) {\n      this.stopObserving(h.n, h.f);\n    }, this);\n\n    return this;\n  },\n\n  /**\n   * Checks if there is sucha delegative event listener\n   *\n   * USAGE:\n   *    $(element).delegates('click');\n   *    $(element).delegates('click', '#css.rule');\n   *    $(element).delegates('click', '#css.rule', function() {});\n   *    $(element).delegates('click', '#css.rule', [func1, func2, ...]);\n   *    $(element).delegates('click', '#css.rule', 'addClass', 'boo');\n   *    $(element).delegates('click', '#css.rule', 'hide');\n   *\n   *    $(element).delegates('click', {\n   *      '#css.rule1': function() {},\n   *      '#css.rule2': [func1, func2, ...],\n   *      '#css.rule3': ['addClass', 'boo'],\n   *      '#css.rule4': 'hide'\n   *    });\n   *\n   * NOTE:\n   *    if several rules are specified then it will check if\n   *    _any_ of them are delegateed\n   *\n   * @param event name\n   * @param css-rule or a hash of rules\n   * @param callback\n   * @return boolean check result\n   */\n  delegates: function() {\n    return !!delegation_listeners(arguments, this).length;\n  }\n});\n\n/**\n * Builds the actual event listener that will delegate stuff\n * to other elements as they reach the element where the listener\n * attached\n *\n * @param String css rule\n * @param Arguments the original arguments list\n * @param Object scope\n * @return Function the actual event listener\n */\nfunction build_delegative_listener(css_rule, entry, scope) {\n  var args = $A(entry), callback = args.shift();\n  return function(event) {\n    var target = event.find(css_rule);\n    return target === undefined ? target :\n      typeof(callback) === 'string' ?\n        target[callback].apply(target, args) :\n        callback.apply(target, [event].concat(args));\n  };\n}\n\n/**\n * Converts the events-delegation api arguments\n * into a systematic hash of rules\n *\n * @param Arguments arguments\n * @return Object hash of rules\n */\nfunction delegation_rules(raw_args) {\n  var args = $A(raw_args), rules = args[1] || {}, hash = {}, css_rule;\n\n  if (isString(rules)) {\n    hash[rules] = args.slice(2);\n    if (isArray(hash[rules][0])) {\n      hash[rules] = hash[rules][0].map(ensure_array);\n    }\n  } else {\n    hash = rules;\n  }\n\n  // converting everything into a hash of lists of callbacks\n  for (css_rule in hash) {\n    hash[css_rule] = ensure_array(hash[css_rule]);\n    hash[css_rule] = isArray(hash[css_rule][0]) ? hash[css_rule] : [hash[css_rule]];\n  }\n\n  return hash;\n}\n\n/**\n * Returns the list of delegative listeners that match the conditions\n *\n * @param Arguments raw-arguments\n * @param Element the element\n * @return Array list of matching listeners\n */\nfunction delegation_listeners(args, object) {\n  var event = args[0], i, list,\n     rules = delegation_rules(args),\n     rules_are_empty = !Object.keys(rules).length;\n\n  return (object.$listeners || []).filter(function(hash) {\n    return hash.dr && hash.n === event && (\n      rules_are_empty || (function() {\n        for (var css_rule in rules) {\n          if (hash.dr === css_rule) {\n            for (i=0, list = rules[css_rule]; i < list.length; i++) {\n              if (!list[i].length || list[i][0] === hash.dc) {\n                return true;\n              }\n            }\n          }\n        }\n\n        return false;\n      })()\n    );\n  });\n}\n\n\n/**\n * Some String level shortcuts to handle collections of elements\n *\n * Copyright (C) 2011 Nikolay Nemshilov\n */\n\n/**\n * Some nice shortcuts for the document-level events delegation handling\n *\n * USAGE:\n *\n *   \"ul#main-menu li\".on(\"click\", function() { alert('clicked'); });\n *   \"ul#main-menu li\".on(\"mouseover\", \"addClass\", \"hovered\");\n *   \"ul#main-menu li\".on(\"mouseout\", \"removeClass\", \"hovered\");\n *\n *   // or like that in a shash\n *   \"ul#main-menu li\".on({\n *     click:     function() { alert('clicked'); },\n *     mouseover: ['addClass',    'hovered'],\n *     mouseout:  ['removeClass', 'hovered'],\n *     dblclick:  'hide'\n *   });\n *\n *\n *   \"#css.rule\".observes('click');\n *   \"#css.rule\".observes('click', function() {});\n *   \"#css.rule\".observes('click', 'method_name');\n *   ....\n *\n *   \"#css.rule\".stopObserving('click');\n *   \"#css.rule\".stopObserving('click', function() {});\n *   \"#css.rule\".stopObserving('click', 'method_name');\n *    ....\n */\nObject.each({\n  on:            'delegate',\n  stopObserving: 'undelegate',\n  observes:      'delegates'\n}, function(name, method) {\n  String.prototype[name] = function() {\n    var args = $A(arguments), result;\n\n    args.splice(1,0,''+this);\n    result = current_Document[method].apply(current_Document, args);\n\n    return result === current_Document ? this : result;\n  };\n});\nvar old_on = String.prototype.on;\nString.prototype.on = function(hash) {\n  if (isHash(hash)) {\n    for (var key in hash) {\n      old_on.apply(this, [key].concat([hash[key]]));\n    }\n  } else {\n    old_on.apply(this, arguments);\n  }\n  return this;\n};\n\n/**\n * building the list of String#onEvent shortucts\n *\n * USAGE:\n *\n *    \"#css.rule\".onClick(function() {...});\n *    \"#css.rule\".onMouseover('method_name');\n */\nEvent_delegation_shortcuts.each(function(name) {\n  String.prototype['on'+name.capitalize()] = function() {\n    return this.on.apply(this, [name].concat($A(arguments)));\n  };\n});\n\n/**\n * The rest of the DOM methods access\n *\n * USAGE:\n *   \"#css.rule\".addClass('boo-hoo');\n *   \"#css.rule\".setStyle({color: 'red'});\n *\n */\n$w('Element Input Form').each(function(klass) {\n  Object.each(klass in RightJS ? RightJS[klass].prototype : {}, function(name, method) {\n    if (isFunction(method) && !(name in String.prototype)) {\n      String.prototype[name] = function() {\n        var nodes = $$(this, true), i=0, l = nodes.length, first=true, element, result;\n        for (; i < l; i++) {\n          element = wrap(nodes[i]);\n          result  = element[name].apply(element, arguments);\n\n          // checking if that's a data-retrieving call\n          if (first) {\n            if (result !== element) {\n              return result;\n            }\n            first = false;\n          }\n        }\n\n        // don't return the string itself in here,\n        // it will screw with data-retrieving calls on empty collections\n        return null;\n      };\n    }\n  });\n});\n\n/**\n * XMLHttpRequest wrapper\n *\n * Credits:\n *   Some of the functionality inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *     - jQuery    (http://jquery.com)        Copyright (C) John Resig\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nvar Xhr = RightJS.Xhr = new Class(Observer, {\n  extend: {\n    // supported events list\n    EVENTS: $w('success failure complete request cancel create'),\n\n    // default options\n    Options: {\n      headers: {\n        'X-Requested-With': 'XMLHttpRequest',\n        'Accept': 'text/javascript,text/html,application/xml,text/xml,*/*'\n      },\n      method:       'post',\n      encoding:     'utf-8',\n      async:        true,\n      evalScripts:  false,\n      evalResponse: false,\n      evalJS:       true,\n      evalJSON:     true,\n      secureJSON:   true,\n      urlEncoded:   true,\n      spinner:      null,\n      spinnerFx:    'fade',\n      params:       null,\n      iframed:      false,\n      jsonp:        false\n    },\n\n    /**\n     * Shortcut to initiate and send an XHR in a single call\n     *\n     * @param String url\n     * @param Object options\n     * @return Xhr request\n     */\n    load: function(url, options) {\n      return new this(url, $ext({method: 'get'}, options)).send();\n    }\n  },\n\n  /**\n   * basic constructor\n   *\n   * @param String url\n   * @param Object options\n   */\n  initialize: function(url, options) {\n    this.initCallbacks(); // system level callbacks should be initialized before the user callbacks\n\n    this.url = url;\n\n    // copying some options to the instance level attributes\n    $ext(this.$super(options), this.options);\n\n    // merging in the global params\n    if (this.params != Xhr.Options.params) {\n      this.params = this.prepareData(Xhr.Options.params, this.params);\n    }\n\n    // removing the local spinner if it's the same as the global one\n    if (Xhr.Options.spinner && $(this.spinner) === $(Xhr.Options.spinner)) {\n      this.spinner = null;\n    }\n  },\n\n  /**\n   * sets a header\n   *\n   * @param name String header name\n   * @param value String header value\n   * @return Xhr self\n   */\n  setHeader: function(name, value) {\n    this.headers[name] = value;\n    return this;\n  },\n\n  /**\n   * tries to get a response header\n   *\n   * @return mixed String header value or undefined\n   */\n  getHeader: function(name) {\n    var value;\n    try {\n      value = this.xhr.getResponseHeader(name);\n    } catch(e) {}\n    return value;\n  },\n\n  /**\n   * checks if the request was successful\n   *\n   * @return boolean check result\n   */\n  successful: function() {\n    return (this.status >= 200) && (this.status < 300);\n  },\n\n  /**\n   * performs the actual request sending\n   *\n   * @param Object options\n   * @return Xhr self\n   */\n  send: function(params) {\n    var add_params = {},\n        url = this.url,\n        method  = this.method.toLowerCase(),\n        headers = this.headers,\n        key, xhr;\n\n    if (method == 'put' || method == 'delete') {\n      add_params._method = method;\n      method = 'post';\n    }\n\n    var data = this.prepareData(this.params, this.prepareParams(params), add_params);\n\n    if (this.urlEncoded && method == 'post' && !headers['Content-type']) {\n      this.setHeader('Content-type', 'application/x-www-form-urlencoded;charset='+this.encoding);\n    }\n\n    if (method == 'get') {\n      if (data) { url += (url.include('?') ? '&' : '?') + data; }\n      data = null;\n    }\n\n    xhr = this.xhr = this.createXhr();\n    this.fire('create');\n\n    xhr.open(method, url, this.async);\n\n    xhr.onreadystatechange = this.stateChanged.bind(this);\n\n    for (key in headers) {\n      xhr.setRequestHeader(key, headers[key]);\n    }\n\n    xhr.send(data);\n    this.fire('request');\n\n    if (!this.async) { this.stateChanged(); }\n\n    return this;\n  },\n\n  /**\n   * elements automaticall update method, creates an Xhr request\n   * and updates the element innerHTML value onSuccess.\n   *\n   * @param Element element\n   * @param Object optional request params\n   * @return Xhr self\n   */\n  update: function(element, params) {\n    return this.onSuccess(function(r) { element.update(r.text); }).send(params);\n  },\n\n  /**\n   * stops the request processing\n   *\n   * @return Xhr self\n   */\n  cancel: function() {\n    var xhr = this.xhr;\n\n    if (!xhr || xhr.canceled) { return this; }\n\n    xhr.abort();\n    xhr.onreadystatechange = function() {};\n    xhr.canceled = true;\n\n    return this.fire('cancel');\n  },\n\n// protected\n  // wrapping the original method to send references to the xhr objects\n  fire: function(name) {\n    return this.$super(name, this, this.xhr);\n  },\n\n  // creates new request instance\n  createXhr: function() {\n    if (this.jsonp) {\n      return new Xhr.JSONP(this);\n    } else if (this.form && this.form.first('input[type=file]')) {\n      return new Xhr.IFramed(this.form);\n    } else if ('ActiveXObject' in window){\n      return new ActiveXObject('MSXML2.XMLHTTP');\n    } else {\n      return new XMLHttpRequest();\n    }\n  },\n\n  // prepares user sending params\n  prepareParams: function(params) {\n    return params;\n  },\n\n  // converts all the params into a url params string\n  prepareData: function() {\n    return $A(arguments).map(function(param) {\n      if (!isString(param)) {\n        param = Object.toQueryString(param);\n      }\n      return param.blank() ? null : param;\n    }).compact().join('&');\n  },\n\n  // handles the state change\n  stateChanged: function() {\n    var xhr = this.xhr;\n\n    if (xhr.readyState != 4 || xhr.canceled) { return; }\n\n    try { this.status = xhr.status;\n    } catch(e) { this.status = 0; }\n\n    this.text = this.responseText = xhr.responseText;\n    this.xml  = this.responseXML  = xhr.responseXML;\n\n    this.fire('complete').fire(this.successful() ? 'success' : 'failure');\n  },\n\n  // called on success\n  tryScripts: function(response) {\n    var content_type = this.getHeader('Content-type');\n    var x_json_data  = this.getHeader('X-JSON');\n\n    if (x_json_data) {\n      this.json = this.responseJSON = this.headerJSON = JSON.parse(x_json_data);\n    }\n\n    if (this.evalResponse || (this.evalJS && /(ecma|java)script/i.test(content_type))) {\n      $eval(this.text);\n    } else if (/json/.test(content_type) && this.evalJSON) {\n      this.json = this.responseJSON = JSON.parse(this.text);\n    } else if (this.evalScripts) {\n      this.text.evalScripts();\n    }\n  },\n\n  // initializes the request callbacks\n  initCallbacks: function() {\n    // connecting basic callbacks\n    this.on({\n      create:   'showSpinner',\n      complete: 'hideSpinner',\n      cancel:   'hideSpinner'\n    });\n\n    this.on('complete', 'tryScripts');\n\n    // wiring the global xhr callbacks\n    Xhr.EVENTS.each(function(name) {\n      this.on(name, function() { Xhr.fire(name, this, this.xhr); });\n    }, this);\n  },\n\n  showSpinner: function() { Xhr.showSpinner.call(this, this); },\n  hideSpinner: function() { Xhr.hideSpinner.call(this, this); }\n});\n\n// attaching the common spinner handling\n$ext(Observer_create(Xhr), {\n  counter: 0,\n\n  // shows the spinner\n  showSpinner: function(context) {\n    Xhr.trySpinner(context, 'show');\n  },\n\n  // hides the spinner\n  hideSpinner: function(context) {\n    Xhr.trySpinner(context, 'hide');\n  },\n\n  trySpinner: function(context, method) {\n    var object = context || Xhr.Options, spinner = $(object.spinner);\n    if (spinner) { spinner[method](object.spinnerFx, {duration: 100}); }\n  },\n\n  // counts a request in\n  countIn: function() {\n    Xhr.counter ++;\n    Xhr.showSpinner();\n  },\n\n  // counts a request out\n  countOut: function() {\n    Xhr.counter --;\n    if (Xhr.counter < 1) {\n      Xhr.hideSpinner();\n    }\n  }\n}).on({\n  create:   'countIn',\n  complete: 'countOut',\n  cancel:   'countOut'\n});\n\n\n/**\n * Here are the Form unit Xhr extensions\n *\n * Credits:\n *   Some of the functionality inspired by\n *     - Prototype (http://prototypejs.org)   Copyright (C) Sam Stephenson\n *     - jQuery    (http://jquery.com)        Copyright (C) John Resig\n *\n * Copyright (C) 2009-2011 Nikolay V. Nemshilov\n */\nForm.include({\n  /**\n   * sends the form via xhr request\n   *\n   * @param Options xhr request options\n   * @return Form this\n   */\n  send: function(options) {\n    options = options || {};\n    options.method = options.method || this._.method || 'post';\n\n    this.xhr = new Xhr(\n      this._.action || document.location.href,\n      $ext({spinner: this.first('.spinner')}, options)\n    )\n    .onComplete(this.enable.bind(this))\n    .onCancel(this.enable.bind(this))\n    .send(this);\n\n    this.disable.bind(this).delay(1); // webkit needs this async call with iframed calls\n    return this;\n  },\n\n  /**\n   * Cancels current Xhr request (if there are any)\n   *\n   * @return Form this\n   */\n  cancelXhr: function() {\n    if (this.xhr instanceof Xhr) {\n      this.xhr.cancel();\n    }\n\n    return this;\n  },\n\n  /**\n   * makes the form be remote by default\n   *\n   * @param Object default options\n   * @return Form this\n   */\n  remotize: function(options) {\n    if (!this.remote) {\n      this.on('submit', Form_remote_send, options);\n      this.remote = true;\n    }\n\n    return this;\n  },\n\n  /**\n   * removes the remote call hook\n   *\n   * @return Form this\n   */\n  unremotize: function() {\n    this.stopObserving('submit', Form_remote_send);\n    this.remote = false;\n    return this;\n  }\n});\n\n/**\n * Catches the form submit events and sends the form remotely\n *\n * @param Event submit\n * @param Object xhr options\n * @return void\n */\nfunction Form_remote_send(event, options) {\n  event.stop();\n  this.send(options);\n}\n\n/**\n * Adds Xhr params handling if a Form element is passed to Xhr#send\n * \n * @param Object params - could be Hash or Form element\n * @return Object\n */\nXhr.include({\n  prepareParams: function(params) {\n    if (params && params instanceof Form) {\n      this.form = params;\n      params = params.values();\n    }\n    return params;\n  }\n});\n\n\n/**\n * this module contains the Element unit XHR related extensions\n *\n * Credits:\n *   - jQuery    (http://jquery.com)        Copyright (C) John Resig\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nElement.include({\n  /**\n   * performs an Xhr request to the given url\n   * and updates the element internals with the responseText\n   *\n   * @param String url address\n   * @param Object xhr options\n   * @return Element this\n   */\n  load: function(url, options) {\n    new Xhr(url, $ext({method: 'get'}, options)).update(this);\n    return this;\n  }\n});\n\n\n/**\n * A dummy XmlHTTPRequest interface to be used in other\n * fake requests\n *\n * Copyright (C) 2010-2011 Nikolay Nemshilov\n */\nXhr.Dummy = {\n  open:               function() {},\n  setRequestHeader:   function() {},\n  onreadystatechange: function() {}\n};\n\n\n/**\n * This unit presents a fake drop in replacement for the XmlHTTPRequest unit\n * but works with an iframe targeting in the background\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\nXhr.IFramed = new Class({\n  include: Xhr.Dummy,\n\n  /**\n   * constructor\n   *\n   * @param Form form which will be submitted via the frame\n   * @return void\n   */\n  initialize: function(form) {\n    this.form = form;\n    this.id   = 'xhr_'+ new Date().getTime();\n\n    this.form.doc().first('body').append('<i><iframe name=\"'+this.id+'\" id=\"'+this.id+\n      '\" width=\"0\" height=\"0\" frameborder=\"0\" src=\"about:blank\"></iframe></i>',\n      'after');\n\n    $(this.id).on('load', this.onLoad.bind(this));\n  },\n\n  send: function() {\n    this.form.set('target', this.id).submit();\n  },\n\n  onLoad: function() {\n    this.status       = 200;\n    this.readyState   = 4;\n\n    this.form.set('target', '');\n\n    try {\n      this.responseText = window[this.id].document.documentElement.innerHTML;\n    } catch(e) { }\n\n    this.onreadystatechange();\n  },\n\n  abort: function() {\n    $(this.id).set('src', 'about:blank');\n  }\n});\n\n\n/**\n * The JSONP Xhr request tonnel\n *\n * Copyright (C) 2010-2011 Nikolay Nemshilov\n */\nXhr.JSONP = new Class({\n  include: Xhr.Dummy,\n\n  prefix: 'jsonp',\n\n  /**\n   * Constructor\n   *\n   * @param Xhr the actual xhr request object\n   * @return void\n   */\n  initialize: function(xhr) {\n    this.xhr   = xhr;\n    this.name  = this.prefix + new Date().getTime();\n    this.param = (isString(xhr.jsonp) ?\n      xhr.jsonp : 'callback') + \"=\" + this.name;\n\n    this.script = $E('script', {\n      charset: xhr.encoding,\n      async:   xhr.async\n    });\n  },\n\n  /**\n   * saving the url and method for the further use\n   *\n   * @param method String request method\n   * @param address String request url address\n   * @param Boolean async request marker\n   * @return void\n   */\n  open: function(method, url, async) {\n    this.url    = url;\n    this.method = method;\n  },\n\n  /**\n   * Sends the actual request by inserting the script into the document body\n   *\n   * @param String data\n   * @return void\n   */\n  send: function(data) {\n    window[this.name] = this.finish.bind(this);\n\n    this.script.set('src', this.url + (this.url.include('?') ? '&' : '?') + this.param + \"&\" + data)\n      .insertTo($$('script').last(), 'after');\n  },\n\n  /**\n   * Receives the actual JSON data from the server\n   *\n   * @param Object JSON data\n   * @return void\n   */\n  finish: function(data) {\n    this.status       = 200;\n    this.readyState   = 4;\n\n    this.xhr.json = this.xhr.responseJSON = data;\n\n    this.onreadystatechange();\n  },\n\n  /**\n   * We can't really cancel a JSONP request\n   * but we can prevent the default handler to ckick in\n   *\n   * @return void\n   */\n  abort: function() {\n    window[this.name] = function() {};\n  }\n});\n\n\n/**\n * Basic visual effects class\n *\n * Credits:\n *   The basic principles, structures and naming system are inspired by\n *     - MooTools  (http://mootools.net) Copyright (C) Valerio Proietti\n *   The cubic bezier emulation is backported from\n *     - Lovely.IO (http://lovely.io) Copytirhgt (C) Nikolay Nemshilov\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nvar Fx = RightJS.Fx = new Class(Observer, {\n  extend: {\n    EVENTS: $w('start finish cancel'),\n\n    // named durations\n    Durations: {\n      'short':  200,\n      'normal': 400,\n      'long':   800\n    },\n\n    // default options\n    Options: {\n      fps:        IE8_OR_LESS ? 40 : 60,\n      duration:   'normal',\n      transition: 'default',\n      queue:      true,\n      engine:     'css'\n    }\n  },\n\n  /**\n   * Basic constructor\n   *\n   * @param Object options\n   */\n  initialize: function(element, options) {\n    this.$super(options);\n    this.element = $(element);\n    fx_register(this);\n  },\n\n  /**\n   * starts the transition\n   *\n   * @return Fx this\n   */\n  start: function() {\n    if (fx_add_to_queue(this, arguments)) { return this; }\n\n    fx_mark_current(this);\n\n    this.prepare.apply(this, arguments);\n\n    fx_start_timer(this);\n\n    return this.fire('start', this);\n  },\n\n  /**\n   * finishes the transition\n   *\n   * @return Fx this\n   */\n  finish: function() {\n    fx_stop_timer(this);\n    fx_remove_from_queue(this);\n    this.fire('finish');\n    fx_run_next(this);\n    return this;\n  },\n\n  /**\n   * interrupts the transition\n   *\n   * NOTE:\n   *   this method cancels all the scheduled effects\n   *   in the element chain\n   *\n   * @return Fx this\n   */\n  cancel: function() {\n    fx_stop_timer(this);\n    fx_remove_from_queue(this);\n    return this.fire('cancel');\n  },\n\n// protected\n  // dummy method, should be implemented in a subclass\n  prepare: function() {},\n\n  // dummy method, processes the element properties\n  render: function() {}\n}),\n\n// global effects registry\nscheduled_fx = [], running_fx = [];\n\n/**\n * Registers the element in the effects queue\n *\n * @param Fx effect\n * @return void\n */\nfunction fx_register(fx) {\n  var uid = $uid((fx.element || {})._ || {});\n  fx.ch = (scheduled_fx[uid] = scheduled_fx[uid] || []);\n  fx.cr = (running_fx[uid]   = running_fx[uid]   || []);\n}\n\n/**\n * Registers the effect in the effects queue\n *\n * @param Fx fx\n * @param Arguments original arguments list\n * @return boolean true if it queued and false if it's ready to go\n */\nfunction fx_add_to_queue(fx, args) {\n  var chain = fx.ch, queue = fx.options.queue;\n\n  if (!chain || fx.$ch) {\n    return (fx.$ch = false);\n  }\n\n  if (queue) {\n    chain.push([args, fx]);\n  }\n\n  return queue && chain[0][1] !== fx;\n}\n\n/**\n * Puts the fx into the list of currently running effects\n *\n * @param Fx fx\n * @return void\n */\nfunction fx_mark_current(fx) {\n  if (fx.cr) {\n    fx.cr.push(fx);\n  }\n}\n\n/**\n * Removes the fx from the queue\n *\n * @param Fx fx\n * @return void\n */\nfunction fx_remove_from_queue(fx) {\n  var currents = fx.cr;\n  if (currents) {\n    currents.splice(currents.indexOf(fx), 1);\n  }\n}\n\n/**\n * Tries to invoke the next effect in the queue\n *\n * @param Fx fx\n * @return void\n */\nfunction fx_run_next(fx) {\n  var chain = fx.ch, next = chain.shift();\n  if ((next = chain[0])) {\n    next[1].$ch = true;\n    next[1].start.apply(next[1], next[0]);\n  }\n}\n\n/**\n * Cancels all currently running and scheduled effects\n * on the element\n *\n * @param Element element\n * @return void\n */\nfunction fx_cancel_all(element) {\n  var uid = $uid(element._);\n\n  (running_fx[uid] || []).each('cancel');\n  (scheduled_fx[uid] || []).splice(0);\n}\n\n/**\n * Initializes the fx rendering timer\n *\n * @param Fx fx\n * @return void\n */\nfunction fx_start_timer(fx) {\n  var options    = fx.options,\n      duration   = Fx.Durations[options.duration] || options.duration,\n      steps      = Math.ceil(duration / 1000 * options.fps),\n      transition = Bezier_sequence(options.transition, steps),\n      interval   = Math.round(1000 / options.fps),\n      number     = 0;\n\n  fx._timer = setInterval(function() {\n    if (number === steps) {\n      fx.finish();\n    } else {\n      fx.render(transition[number]);\n      number++;\n    }\n  }, interval);\n}\n\n/**\n * Cancels the Fx rendering timer (if any)\n *\n * @param Fx fx\n * @return void\n */\nfunction fx_stop_timer(fx) {\n  if (fx._timer) {\n    clearInterval(fx._timer);\n  }\n}\n\n\n///////////////////////////////////////////////////////////////////////////////\n// CSS3 Cubic Bezier sequentions emulator\n// Backport from Lovely.IO (http://lovely.io)\n// See also:\n// http://st-on-it.blogspot.com/2011/05/calculating-cubic-bezier-function.html\n///////////////////////////////////////////////////////////////////////////////\n\n// CSS3 cubic-bezier presets\nvar Bezier_presets = {\n  'default':     '(.25,.1,.25,1)',\n  'linear':      '(0,0,1,1)',\n  'ease-in':     '(.42,0,1,1)',\n  'ease-out':    '(0,0,.58,1)',\n  'ease-in-out': '(.42,0,.58,1)',\n  'ease-out-in': '(0,.42,1,.58)'\n},\n\n// Bezier loockup tables cache\nBezier_cache = {};\n\n// builds a loockup table of parametric values with a given size\nfunction Bezier_sequence(params, size) {\n  params = Bezier_presets[params] || native_fx_functions[params] || params;\n  params = params.match(/([\\d\\.]+)[\\s,]+([\\d\\.]+)[\\s,]+([\\d\\.]+)[\\s,]+([\\d\\.]+)/);\n  params = [0, params[1]-0, params[2]-0, params[3]-0, params[4]-0]; // cleaning up\n\n  var name = params.join(',') + ',' + size, Cx, Bx, Ax, Cy, By, Ay, sequence, step, x;\n\n  function bezier_x(t) { return t * (Cx + t * (Bx + t * Ax)); }\n  function bezier_y(t) { return t * (Cy + t * (By + t * Ay)); }\n\n  // a quick search for a more or less close parametric\n  // value using several iterations by Newton's method\n\n  function bezier_x_der(t) { // bezier_x derivative\n    return Cx + t * (2*Bx + t * 3*Ax) + 1e-3;\n  }\n  function find_parametric(t) {\n    var x=t, i=0, z;\n\n    while (i < 5) {\n      z = bezier_x(x) - t;\n\n      if (Math.abs(z) < 1e-3) { break; }\n\n      x = x - z/bezier_x_der(x);\n      i++;\n    }\n\n    return x;\n  }\n\n  if (!(name in Bezier_cache)) {\n    // defining bezier functions in a polynomial form (coz it's faster)\n    Cx = 3 * params[1];\n    Bx = 3 * (params[3] - params[1]) - Cx;\n    Ax = 1 - Cx - Bx;\n\n    Cy = 3 * params[2];\n    By = 3 * (params[4] - params[2]) - Cy;\n    Ay = 1 - Cy - By;\n\n\n    // building the actual lookup table\n    Bezier_cache[name] = sequence = [];\n    x=0; step=1/size;\n\n    while (x < 1.0001) { // should include 1.0\n      sequence.push(bezier_y(find_parametric(x)));\n      x += step;\n    }\n  }\n\n  return Bezier_cache[name];\n}\n\n/**\n * There are the String unit extensions for the effects library\n *\n * Copyright (C) 2008-2009 Nikolay V. Nemshilov\n */\nString.COLORS = {\n  maroon:  '#800000',\n  red:     '#ff0000',\n  orange:  '#ffA500',\n  yellow:  '#ffff00',\n  olive:   '#808000',\n  purple:  '#800080',\n  fuchsia: '#ff00ff',\n  white:   '#ffffff',\n  lime:    '#00ff00',\n  green:   '#008000',\n  navy:    '#000080',\n  blue:    '#0000ff',\n  aqua:    '#00ffff',\n  teal:    '#008080',\n  black:   '#000000',\n  silver:  '#c0c0c0',\n  gray:    '#808080',\n  brown:   '#a52a2a'\n};\n\nString.include({\n  /**\n   * converts a #XXX or rgb(X, X, X) sring into standard #XXXXXX color string\n   *\n   * @return String hex color\n   */\n  toHex: function() {\n    var match = /^#(\\w)(\\w)(\\w)$/.exec(this);\n\n    if (match) {\n      match = \"#\"+ match[1]+match[1]+match[2]+match[2]+match[3]+match[3];\n    } else if ((match = /^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$/.exec(this))) {\n      match = \"#\"+ match.slice(1).map(function(bit) {\n        bit = (bit-0).toString(16);\n        return bit.length == 1 ? '0'+bit : bit;\n      }).join('');\n    } else {\n      match = String.COLORS[this] || this;\n    }\n\n    return match;\n  },\n\n  /**\n   * converts a hex string into an rgb array\n   *\n   * @param boolean flag if need an array\n   * @return String rgb(R,G,B) or Array [R,G,B]\n   */\n  toRgb: function(array) {\n    var match = /#([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})/i.exec(this.toHex()||'');\n\n    if (match) {\n      match = match.slice(1).map('toInt', 16);\n      match = array ? match : 'rgb('+match+')';\n    }\n\n    return match;\n  }\n});\n\n\n/**\n * This block contains additional Element shortcuts for effects easy handling\n *\n * Credits:\n *   Some ideas are inspired by\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nElement.include({\n  /**\n   * Stops all the visual effects on the element\n   *\n   * @return Element this\n   */\n  stop: function() {\n    fx_cancel_all(this);\n    return this;\n  },\n\n  /**\n   * hides the element with given visual effect\n   *\n   * @param String fx name\n   * @param Object fx options\n   * @return Element this\n   */\n  hide: function(fx, options) {\n    return (fx && this.visible()) ? call_fx(this, fx, ['out', options]) : this.$super();\n  },\n\n  /**\n   * shows the element with the given visual effect\n   *\n   * @param String fx name\n   * @param Object fx options\n   * @return Element this\n   */\n  show: function(fx, options) {\n    return (fx && !this.visible()) ? call_fx(this, fx, ['in', options]) : this.$super();\n  },\n\n  /**\n   * Toggles the element state with visual effect\n   *\n   * @param String fx name\n   * @param Object fx options\n   * @return Element this\n   */\n  toggle: function(fx, options) {\n    return fx ? call_fx(this, fx, ['toggle', options]) : this.$super();\n  },\n\n  /**\n   * Removes the element out of the DOM structure\n   *\n   * @param String fx name\n   * @param Object fx options\n   * @return Element this\n   */\n  remove: function(fx, options) {\n    return (fx && this.visible()) ? call_fx(this, fx, ['out', $ext(options || {}, {\n      onFinish: this.$super.bind(this)\n    })]) : this.$super();\n  },\n\n  /**\n   * runs the Fx.Morth effect to the given style\n   *\n   * @param style Object style\n   * @param options Object optional effect options\n   * @return Element self\n   */\n  morph: function(style, options) {\n    return call_fx(this, 'morph', [style, options || {}]); // <- don't replace with arguments\n  },\n\n  /**\n   * highlights the element\n   *\n   * @param start String start color\n   * @param end String optional end color\n   * @param Object effect options\n   * @return Element self\n   */\n  highlight: function() {\n    return call_fx(this, 'highlight', arguments);\n  },\n\n  /**\n   * runs the Fx.Fade effect on the element\n   *\n   * @param mixed fade direction 'in' 'out' or a float number\n   * @return Element self\n   */\n  fade: function() {\n    return call_fx(this, 'fade', arguments);\n  },\n\n  /**\n   * runs the Fx.Slide effect on the element\n   *\n   * @param String 'in' or 'out'\n   * @param Object effect options\n   * @return Element self\n   */\n  slide: function() {\n    return call_fx(this, 'slide', arguments);\n  },\n\n  /**\n   * Starts the smooth scrolling effect\n   *\n   * @param position Object {x: NNN, y: NNN} where to scroll\n   * @param options Object fx-options\n   * @return Element this\n   */\n  scroll: function(value, options) {\n    return call_fx(this, 'scroll', [value, options||{}]);\n  },\n\n  /**\n   * wraps the old scroll to be able to run it with fxes\n   *\n   * If you send two hashes then will start a smooth scrolling\n   * otherwise will just jump over with the usual method\n   *\n   * @return Element this\n   */\n  scrollTo: function(value, options) {\n    return isHash(options) ? this.scroll(value, options) : this.$super.apply(this, arguments);\n  }\n});\n\n/**\n * Calls the visual effect on the element\n *\n * @param Element context\n * @param String fx-name\n * @param Object fx-options\n * @return Element context\n */\nfunction call_fx(element, name, params) {\n  var args    = $A(params).compact(),\n      options = isHash(args.last()) ? args.pop() : {},\n      fx      = new Fx[name.capitalize()](element, options);\n\n  fx.start.apply(fx, args);\n\n  return element;\n}\n\n\n/**\n * This class provides the basic effect for styles manipulation\n *\n * Copyright (C) 2008-2011 Nikolay Nemshilov\n */\n\n/////////////////////////////////////////////////////////////////////////////\n// Native css-transitions based implementation\n/////////////////////////////////////////////////////////////////////////////\n\nvar native_fx_prefix = ['WebkitT', 'OT', 'MozT', 'MsT', 't'].first(function(name) {\n  return name + 'ransition' in HTML.style;\n}),\nnative_fx_transition = native_fx_prefix     + 'ransition',\nnative_fx_property   = native_fx_transition + 'Property',\nnative_fx_duration   = native_fx_transition + 'Duration',\nnative_fx_function   = native_fx_transition + 'TimingFunction',\n\n// basic transition algorithm replacements\nnative_fx_functions  = {\n  Sin: 'cubic-bezier(.3,0,.6,1)',\n  Cos: 'cubic-bezier(0,.3,.6,0)',\n  Log: 'cubic-bezier(0,.6,.3,.8)',\n  Exp: 'cubic-bezier(.6,0,.8,.3)',\n  Lin: 'cubic-bezier(0,0,1,1)'\n};\n\nfunction native_fx_prepare(style) {\n  var options = this.options,\n      element = this.element,\n      element_style = element._.style,\n      old_style = Object.only(\n        element.computedStyles(),\n        native_fx_property,\n        native_fx_duration,\n        native_fx_function\n      );\n\n  function reset_transitions_style() {\n    for (var key in old_style) {\n      element_style[key] = old_style[key];\n    }\n  }\n\n  this\n    .onFinish(reset_transitions_style)\n    .onCancel(function() {\n      element_style[native_fx_property] = 'none';\n      setTimeout(reset_transitions_style, 1);\n    });\n\n  // setting up the transition\n  element_style[native_fx_property] = 'all';\n  element_style[native_fx_duration] = (Fx.Durations[options.duration] || options.duration) +'ms';\n  element_style[native_fx_function] = native_fx_functions[options.transition] || options.transition;\n\n  setTimeout(function() { element.setStyle(style); }, 0);\n}\n\n// NOTE: OPERA's css-transitions are a bit jerky so we disable them by default\nFx.Options.engine = native_fx_prefix === undefined || Browser_Opera ? 'javascript' : 'native';\n\n////////////////////////////////////////////////////////////////////////////\n// Manual version\n////////////////////////////////////////////////////////////////////////////\n\nFx.Morph = new Class(Fx, {\n// protected\n\n  // parepares the effect\n  prepare: function(style) {\n    if (this.options.engine === 'native' && native_fx_prefix !== undefined) {\n      this.render = this.transition = function() {};\n      native_fx_prepare.call(this, style);\n    } else {\n      var keys   = style_keys(style),\n          before = clone_style(this.element, keys),\n          after  = end_style(this.element, style, keys);\n\n      clean_styles(this.element, before, after);\n\n      this.before = parse_style(before);\n      this.after  = parse_style(after);\n    }\n  },\n\n  render: function(delta) {\n    var before, after, value, style = this.element._.style, key, i, l;\n    for (key in this.after) {\n      before = this.before[key];\n      after  = this.after[key];\n\n      for (i=0, l = after.length; i < l; i++) {\n        value = before[i] + (after[i] - before[i]) * delta;\n        if (after.r) {\n          value = Math.round(value);\n        }\n        after.t[i*2 + 1] = value;\n      }\n\n      style[key] = after.t.join('');\n    }\n  }\n});\n\n// a list of common style names to compact the code a bit\nvar directions = $w('Top Left Right Bottom');\n\n// adds variants to the style names list\nfunction add_variants(keys, key, variants) {\n  for (var i=0; i < variants.length; i++) {\n    keys.push(key + variants[i]);\n  }\n}\n\n// creates an appropriate style-keys list out of the user styles\nfunction style_keys(style) {\n  var keys = [], border_types = ['Style', 'Color', 'Width'], key, i, j;\n\n  for (key in style) {\n    if (key.startsWith('border')) {\n      for (i=0; i < 3; i++) {\n        for (j=0; j < 4; j++) {\n          keys.push('border' + directions[j] + border_types[i]);\n        }\n      }\n    } else if (key === 'margin' || key === 'padding') {\n      add_variants(keys, key, directions);\n    } else if (key.startsWith('background')) {\n      add_variants(keys, 'background', ['Color', 'Position', 'PositionX', 'PositionY']);\n    } else if (key === 'opacity' && IE_OPACITY) {\n      keys.push('filter');\n    } else {\n      keys.push(key);\n    }\n  }\n\n  return keys;\n}\n\n\n// checks if the color is transparent\nfunction is_transparent(color) {\n  return color === 'transparent' || color === 'rgba(0, 0, 0, 0)';\n}\n\n// adjusts the border-styles\nfunction check_border_styles(element, before, after) {\n  for (var i=0; i < 4; i++) {\n    var\n      bd_style = 'border' + directions[i] + 'Style',\n      bd_width = 'border' + directions[i] + 'Width',\n      bd_color = 'border' + directions[i] + 'Color';\n\n    if (bd_style in before && before[bd_style] != after[bd_style]) {\n      var style = element._.style;\n\n      if (before[bd_style] == 'none') {\n        style[bd_width] = '0px';\n      }\n\n      style[bd_style] = after[bd_style];\n      if (is_transparent(before[bd_color])) {\n        style[bd_color] = element.getStyle('Color');\n      }\n    }\n  }\n}\n\n// parses the style hash into a processable format\nfunction parse_style(values) {\n  var result = {}, re = /[\\d\\.\\-]+/g, m, key, value, i;\n\n  for (key in values) {\n    m = values[key].match(re);\n    value = m.map('toFloat');\n    value.t = values[key].split(re);\n    value.r = value.t[0] === 'rgb(';\n\n    if (value.t.length == 1) { value.t.unshift(''); }\n\n    for (i=0; i < value.length; i++) {\n      value.t.splice(i*2 + 1, 0, value[i]);\n    }\n    result[key] = value;\n  }\n\n  return result;\n}\n\n// cleans up and optimizies the styles\nfunction clean_styles(element, before, after) {\n  var key;\n\n  for (key in after) {\n    // checking the height/width options\n    if ((key == 'width' || key == 'height') && before[key] == 'auto') {\n      before[key] = element._['offset'+key.capitalize()] + 'px';\n    }\n  }\n\n  // IE opacity filter fix\n  if (IE_OPACITY && after.filter && !before.filter) {\n    before.filter = 'alpha(opacity=100)';\n  }\n\n  // adjusting the border style\n  check_border_styles(element, before, after);\n\n  // cleaing up the list\n  for (key in after) {\n    // proprocessing colors\n    if (after[key] !== before[key] && /color/i.test(key)) {\n      if (Browser_Opera) {\n        after[key] = after[key].replace(/\"/g, '');\n        before[key] = before[key].replace(/\"/g, '');\n      }\n\n      if (!is_transparent(after[key]))  { after[key]  = after[key].toRgb(); }\n      if (!is_transparent(before[key])) { before[key] = before[key].toRgb(); }\n\n      if (!after[key] || !before[key]) {  after[key] = before[key] = ''; }\n    }\n\n    // filling up the missing size\n    if (/\\d/.test(after[key]) && !/\\d/.test(before[key])) {\n      before[key] = after[key].replace(/[\\d\\.\\-]+/g, '0');\n    }\n\n    // removing unprocessable keys\n    if (after[key] === before[key] || !/\\d/.test(before[key]) || !/\\d/.test(after[key])) {\n      delete(after[key]);\n      delete(before[key]);\n    }\n  }\n}\n\n// cloning the element current styles hash\nfunction clone_style(element, keys) {\n  var i=0, len = keys.length, style = element.computedStyles(), clean = {}, key;\n\n  for (; i < len; i++) {\n    key = keys[i];\n\n    if (key in style) {\n      clean[key] = ''+ style[key];\n\n      // libwebkit bug fix for in case of languages pack applied\n      if (key === 'opacity') {\n        clean[key] = clean[key].replace(',', '.');\n      }\n    }\n  }\n\n  return clean;\n}\n\n// calculating the end styles hash\nfunction end_style(element, style, keys) {\n  var dummy = element.clone()\n      .setStyle('position:absolute;z-index:-1;visibility:hidden')\n      .setWidth(element.size().x)\n      .setStyle(style), after;\n\n  if (element.parent()) {\n    element.insert(dummy, 'before');\n  }\n\n  after = clone_style(dummy, keys);\n  dummy.remove();\n\n  return after;\n}\n\n\n/**\n * the elements hightlighting effect\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nFx.Highlight = new Class(Fx.Morph, {\n  extend: {\n    Options: Object.merge(Fx.Options, {\n      color:      '#FF8',\n      transition: 'Exp'\n    })\n  },\n\n// protected\n\n  /**\n   * starts the transition\n   *\n   * @param high String the hightlight color\n   * @param back String optional fallback color\n   * @return self\n   */\n  prepare: function(start, end) {\n    var element       = this.element,\n        element_style = element._.style,\n        style_name    = 'backgroundColor',\n        end_color     = end || element.getStyle(style_name);\n\n    if (is_transparent(end_color)) {\n      this.onFinish(function() { element_style[style_name] = 'transparent'; });\n\n      // trying to find the end color\n      end_color = [element].concat(element.parents())\n        .map('getStyle', style_name)\n        .reject(is_transparent)\n        .compact().first() || '#FFF';\n    }\n\n    element_style[style_name] = (start || this.options.color);\n\n    return this.$super({backgroundColor: end_color});\n  }\n});\n\n\n/**\n * this is a superclass for the bidirectional effects\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nFx.Twin = new Class(Fx.Morph, {\n\n  /**\n   * hides the element if it meant to be switched off\n   *\n   * @return Fx self\n   */\n  finish: function() {\n    if (this.how === 'out') {\n      // calling 'prototype' to prevent circular calls from subclasses\n      Element.prototype.hide.call(this.element);\n    }\n\n    return this.$super();\n  },\n\n// protected\n\n  /**\n   * assigns the direction of the effect in or out\n   *\n   * @param String 'in', 'out' or 'toggle', 'toggle' by default\n   */\n  setHow: function(how) {\n    this.how = how || 'toggle';\n\n    if (this.how === 'toggle') {\n      this.how = this.element.visible() ? 'out' : 'in';\n    }\n  }\n\n});\n\n\n/**\n * the slide effects wrapper\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nFx.Slide = new Class(Fx.Twin, {\n  extend: {\n    Options: Object.merge(Fx.Options, {\n      direction: 'top'\n    })\n  },\n\n// protected\n  prepare: function(how) {\n    this.setHow(how);\n\n    // calling 'prototype' to prevent circular calls from subclasses\n    var element = Element.prototype.show.call(this.element),\n        element_style = element._.style,\n        old_styles = Object.only(\n          element_style,\n          'overflow', 'width', 'height',\n          'marginTop', 'marginLeft'\n        );\n\n    function restore_styles() {\n      for (var key in old_styles) {\n        element_style[key] = old_styles[key];\n      }\n    }\n\n    this.onFinish(restore_styles).onCancel(restore_styles);\n\n    element_style.overflow = 'hidden';\n\n    return this.$super(fx_slide_prepare_styles(\n      element_style,\n      element.size(),\n      this.options.direction,\n      this.how\n    ));\n  }\n});\n\nfunction fx_slide_prepare_styles(element_style, size, direction, how) {\n  var style = {},\n      margin_left = element_style.marginLeft.toFloat() || 0,\n      margin_top  = element_style.marginTop.toFloat()  || 0,\n      to_right  = direction === 'right',\n      to_bottom = direction === 'bottom',\n      vertical  = direction === 'top' || to_bottom;\n\n  if (how === 'out') {\n    style[vertical ? 'height' : 'width'] = '0px';\n\n    if (to_right) {\n      style.marginLeft = margin_left + size.x+'px';\n    } else if (to_bottom) {\n      style.marginTop = margin_top + size.y +'px';\n    }\n  } else {\n    if (vertical) {\n      style.height = size.y + 'px';\n      element_style.height = '0px';\n    } else {\n      style.width = size.x + 'px';\n      element_style.width = '0px';\n    }\n\n    if (to_right) {\n      style.marginLeft = margin_left + 'px';\n      element_style.marginLeft = margin_left + size.x + 'px';\n    } else if (to_bottom) {\n      style.marginTop = margin_top + 'px';\n      element_style.marginTop = margin_top + size.y + 'px';\n    }\n  }\n\n  return style;\n}\n\n\n/**\n * The opacity effects wrapper\n *\n * Copyright (C) 2008-2011 Nikolay V. Nemshilov\n */\nFx.Fade = new Class(Fx.Twin, {\n  prepare: function(how) {\n    this.setHow(how);\n\n    if (this.how === 'in') {\n      // calling 'prototype' to prevent circular calls from subclasses\n      Element.prototype.show.call(this.element.setStyle({opacity: 0}));\n    }\n\n    return this.$super({opacity: this.how === 'in' ? 1 : 0});\n  }\n});\n\n\n/**\n * An abstract attributes based Fx\n *\n * Copyright (C) 2010 Nikolay Nemshilov\n */\nFx.Attr = new Class(Fx, {\n\n  prepare: function(attrs) {\n    this.before = {};\n    this.after  = attrs;\n    var key, element = this.element._;\n\n    for (key in attrs) {\n      this.before[key] = element[key];\n    }\n  },\n\n  render: function(delta) {\n    var key, element = this.element._, before = this.before;\n    for (key in before) {\n      element[key] = before[key] + (this.after[key] - before[key]) * delta;\n    }\n  }\n\n});\n\n/**\n * A smooth scrolling visual effect\n *\n * Copyright (C) 2009-2011 Nikolay Nemshilov\n */\nFx.Scroll = new Class(Fx.Attr, {\n\n  initialize: function(element, options) {\n    element = $(element);\n    // swapping the actual scrollable when it's the window\n    this.$super(\n      element instanceof Window ?\n        element._.document[\n          Browser.WebKit ? 'body' : 'documentElement'\n        ] : element,\n      options\n    );\n  },\n\n  prepare: function(value) {\n    var attrs = {};\n\n    if ('x' in value) { attrs.scrollLeft = value.x; }\n    if ('y' in value) { attrs.scrollTop  = value.y; }\n\n    this.$super(attrs);\n  }\n\n});\n\n\n/**\n * this module handles the work with cookies\n *\n * Credits:\n *   Most things in the unit are take from\n *     - MooTools  (http://mootools.net)      Copyright (C) Valerio Proietti\n *\n * Copyright (C) 2008-2010 Nikolay V. Nemshilov\n */\nvar Cookie = RightJS.Cookie = new Class({\n  include: Options,\n\n  extend: {\n    // sets the cookie\n    set: function(name, value, options) {\n      return new this(name, options).set(value);\n    },\n    // gets the cookie\n    get: function(name, options) {\n      return new this(name, options).get();\n    },\n    // deletes the cookie\n    remove: function(name, options) {\n      return new this(name, options).remove();\n    },\n\n    // checks if the cookies are enabled\n    enabled: function() {\n      document.cookie = \"__t=1\";\n      return document.cookie.indexOf(\"__t=1\")!=-1;\n    },\n\n    // some basic options\n    Options: {\n      secure:   false,\n      document: document\n    }\n  },\n\n  /**\n   * constructor\n   * @param String cookie name\n   * @param Object options\n   * @return void\n   */\n  initialize: function(name, options) {\n    this.name = name;\n    this.setOptions(options);\n  },\n\n  /**\n   * sets the cookie with the name\n   *\n   * @param mixed value\n   * @return Cookie this\n   */\n  set: function(data) {\n    if (!isString(data)) { data = JSON.stringify(data); }\n\n    var value = encodeURIComponent(data), options = this.options;\n\n    if (options.domain) { value += '; domain=' + options.domain; }\n    if (options.path)   { value += '; path=' + options.path; }\n    if (options.duration) {\n      var date = new Date();\n      date.setTime(date.getTime() + options.duration * 24 * 60 * 60 * 1000);\n      value += '; expires=' + date.toGMTString();\n    }\n    if (options.secure) { value += '; secure'; }\n    options.document.cookie = this.name + '=' + value;\n    return this;\n  },\n\n  /**\n   * searches for a cookie with the name\n   *\n   * @return mixed saved value or null if nothing found\n   */\n  get: function() {\n    var value = this.options.document.cookie.match(\n      '(?:^|;)\\\\s*' + RegExp.escape(this.name) + '=([^;]*)'\n    );\n    if (value) {\n      value = decodeURIComponent(value[1]);\n      try { value = JSON.parse(value); }\n      catch (e) {}\n    }\n    return value || null;\n  },\n\n  /**\n   * removes the cookie\n   *\n   * @return Cookie this\n   */\n  remove: function() {\n    this.options.duration = -1;\n    return this.set('');\n  }\n});\n\n\n// globalizing the top-level variables\n$ext(window, Object.without(RightJS, 'version', 'modules'));\n\nreturn RightJS;\n})(window, document, Object, Array, String, Function, Number, Math);\n/**\n * The old browsers support patch loading script\n * will be included in the core file when it's built\n * with the no-olds option\n *\n * Basically it just checks all the script tags on the page\n * finds the core inclusion tag and uses it's src attribute\n * to dynamically load the olds patch\n *\n * Copyright (C) 2009-2011 Nikolay V. Nemshilov\n */\nif (RightJS.Browser.OLD) {\n  (function(d) {\n    var script  = d.createElement('script'),\n        scripts = d.getElementsByTagName('script'),\n        rjs_spt = scripts[scripts.length - 1];\n\n    script.src = rjs_spt.src.replace(/(^|\\/)(right)([^\\/]+)$/, '$1$2-olds$3');\n\n    rjs_spt.parentNode.appendChild(script);\n  })(document);\n}\n"
  },
  {
    "path": "vendor/zepto.js",
    "content": "/* Zepto v1.0rc1 - polyfill zepto event detect fx ajax form touch - zeptojs.com/license */\n;(function(undefined){\n  if (String.prototype.trim === undefined) // fix for iOS 3.2\n    String.prototype.trim = function(){ return this.replace(/^\\s+/, '').replace(/\\s+$/, '') }\n\n  // For iOS 3.x\n  // from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce\n  if (Array.prototype.reduce === undefined)\n    Array.prototype.reduce = function(fun){\n      if(this === void 0 || this === null) throw new TypeError()\n      var t = Object(this), len = t.length >>> 0, k = 0, accumulator\n      if(typeof fun != 'function') throw new TypeError()\n      if(len == 0 && arguments.length == 1) throw new TypeError()\n\n      if(arguments.length >= 2)\n       accumulator = arguments[1]\n      else\n        do{\n          if(k in t){\n            accumulator = t[k++]\n            break\n          }\n          if(++k >= len) throw new TypeError()\n        } while (true)\n\n      while (k < len){\n        if(k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t)\n        k++\n      }\n      return accumulator\n    }\n\n})()\nvar Zepto = (function() {\n  var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice,\n    document = window.document,\n    elementDisplay = {}, classCache = {},\n    getComputedStyle = document.defaultView.getComputedStyle,\n    cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },\n    fragmentRE = /^\\s*<(\\w+|!)[^>]*>/,\n\n    // Used by `$.zepto.init` to wrap elements, text/comment nodes, document,\n    // and document fragment node types.\n    elementTypes = [1, 3, 8, 9, 11],\n\n    adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ],\n    table = document.createElement('table'),\n    tableRow = document.createElement('tr'),\n    containers = {\n      'tr': document.createElement('tbody'),\n      'tbody': table, 'thead': table, 'tfoot': table,\n      'td': tableRow, 'th': tableRow,\n      '*': document.createElement('div')\n    },\n    readyRE = /complete|loaded|interactive/,\n    classSelectorRE = /^\\.([\\w-]+)$/,\n    idSelectorRE = /^#([\\w-]+)$/,\n    tagSelectorRE = /^[\\w-]+$/,\n    toString = ({}).toString,\n    zepto = {},\n    camelize, uniq,\n    tempParent = document.createElement('div')\n\n  zepto.matches = function(element, selector) {\n    if (!element || element.nodeType !== 1) return false\n    var matchesSelector = element.webkitMatchesSelector || element.mozMatchesSelector ||\n                          element.oMatchesSelector || element.matchesSelector\n    if (matchesSelector) return matchesSelector.call(element, selector)\n    // fall back to performing a selector:\n    var match, parent = element.parentNode, temp = !parent\n    if (temp) (parent = tempParent).appendChild(element)\n    match = ~zepto.qsa(parent, selector).indexOf(element)\n    temp && tempParent.removeChild(element)\n    return match\n  }\n\n  function isFunction(value) { return toString.call(value) == \"[object Function]\" }\n  function isObject(value) { return value instanceof Object }\n  function isPlainObject(value) {\n    var key, ctor\n    if (toString.call(value) !== \"[object Object]\") return false\n    ctor = (isFunction(value.constructor) && value.constructor.prototype)\n    if (!ctor || !hasOwnProperty.call(ctor, 'isPrototypeOf')) return false\n    for (key in value);\n    return key === undefined || hasOwnProperty.call(value, key)\n  }\n  function isArray(value) { return value instanceof Array }\n  function likeArray(obj) { return typeof obj.length == 'number' }\n\n  function compact(array) { return array.filter(function(item){ return item !== undefined && item !== null }) }\n  function flatten(array) { return array.length > 0 ? [].concat.apply([], array) : array }\n  camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }\n  function dasherize(str) {\n    return str.replace(/::/g, '/')\n           .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')\n           .replace(/([a-z\\d])([A-Z])/g, '$1_$2')\n           .replace(/_/g, '-')\n           .toLowerCase()\n  }\n  uniq = function(array){ return array.filter(function(item, idx){ return array.indexOf(item) == idx }) }\n\n  function classRE(name) {\n    return name in classCache ?\n      classCache[name] : (classCache[name] = new RegExp('(^|\\\\s)' + name + '(\\\\s|$)'))\n  }\n\n  function maybeAddPx(name, value) {\n    return (typeof value == \"number\" && !cssNumber[dasherize(name)]) ? value + \"px\" : value\n  }\n\n  function defaultDisplay(nodeName) {\n    var element, display\n    if (!elementDisplay[nodeName]) {\n      element = document.createElement(nodeName)\n      document.body.appendChild(element)\n      display = getComputedStyle(element, '').getPropertyValue(\"display\")\n      element.parentNode.removeChild(element)\n      display == \"none\" && (display = \"block\")\n      elementDisplay[nodeName] = display\n    }\n    return elementDisplay[nodeName]\n  }\n\n  // `$.zepto.fragment` takes a html string and an optional tag name\n  // to generate DOM nodes nodes from the given html string.\n  // The generated DOM nodes are returned as an array.\n  // This function can be overriden in plugins for example to make\n  // it compatible with browsers that don't support the DOM fully.\n  zepto.fragment = function(html, name) {\n    if (name === undefined) name = fragmentRE.test(html) && RegExp.$1\n    if (!(name in containers)) name = '*'\n    var container = containers[name]\n    container.innerHTML = '' + html\n    return $.each(slice.call(container.childNodes), function(){\n      container.removeChild(this)\n    })\n  }\n\n  // `$.zepto.Z` swaps out the prototype of the given `dom` array\n  // of nodes with `$.fn` and thus supplying all the Zepto functions\n  // to the array. Note that `__proto__` is not supported on Internet\n  // Explorer. This method can be overriden in plugins.\n  zepto.Z = function(dom, selector) {\n    dom = dom || []\n    dom.__proto__ = arguments.callee.prototype\n    dom.selector = selector || ''\n    return dom\n  }\n\n  // `$.zepto.isZ` should return `true` if the given object is a Zepto\n  // collection. This method can be overriden in plugins.\n  zepto.isZ = function(object) {\n    return object instanceof zepto.Z\n  }\n\n  // `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and\n  // takes a CSS selector and an optional context (and handles various\n  // special cases).\n  // This method can be overriden in plugins.\n  zepto.init = function(selector, context) {\n    // If nothing given, return an empty Zepto collection\n    if (!selector) return zepto.Z()\n    // If a function is given, call it when the DOM is ready\n    else if (isFunction(selector)) return $(document).ready(selector)\n    // If a Zepto collection is given, juts return it\n    else if (zepto.isZ(selector)) return selector\n    else {\n      var dom\n      // normalize array if an array of nodes is given\n      if (isArray(selector)) dom = compact(selector)\n      // if a JavaScript object is given, return a copy of it\n      // this is a somewhat peculiar option, but supported by\n      // jQuery so we'll do it, too\n      else if (isPlainObject(selector))\n        dom = [$.extend({}, selector)], selector = null\n      // wrap stuff like `document` or `window`\n      else if (elementTypes.indexOf(selector.nodeType) >= 0 || selector === window)\n        dom = [selector], selector = null\n      // If it's a html fragment, create nodes from it\n      else if (fragmentRE.test(selector))\n        dom = zepto.fragment(selector.trim(), RegExp.$1), selector = null\n      // If there's a context, create a collection on that context first, and select\n      // nodes from there\n      else if (context !== undefined) return $(context).find(selector)\n      // And last but no least, if it's a CSS selector, use it to select nodes.\n      else dom = zepto.qsa(document, selector)\n      // create a new Zepto collection from the nodes found\n      return zepto.Z(dom, selector)\n    }\n  }\n\n  // `$` will be the base `Zepto` object. When calling this\n  // function just call `$.zepto.init, whichs makes the implementation\n  // details of selecting nodes and creating Zepto collections\n  // patchable in plugins.\n  $ = function(selector, context){\n    return zepto.init(selector, context)\n  }\n\n  // Copy all but undefined properties from one or more\n  // objects to the `target` object.\n  $.extend = function(target){\n    slice.call(arguments, 1).forEach(function(source) {\n      for (key in source)\n        if (source[key] !== undefined)\n          target[key] = source[key]\n    })\n    return target\n  }\n\n  // `$.zepto.qsa` is Zepto's CSS selector implementation which\n  // uses `document.querySelectorAll` and optimizes for some special cases, like `#id`.\n  // This method can be overriden in plugins.\n  zepto.qsa = function(element, selector){\n    var found\n    return (element === document && idSelectorRE.test(selector)) ?\n      ( (found = element.getElementById(RegExp.$1)) ? [found] : emptyArray ) :\n      (element.nodeType !== 1 && element.nodeType !== 9) ? emptyArray :\n      slice.call(\n        classSelectorRE.test(selector) ? element.getElementsByClassName(RegExp.$1) :\n        tagSelectorRE.test(selector) ? element.getElementsByTagName(selector) :\n        element.querySelectorAll(selector)\n      )\n  }\n\n  function filtered(nodes, selector) {\n    return selector === undefined ? $(nodes) : $(nodes).filter(selector)\n  }\n\n  function funcArg(context, arg, idx, payload) {\n   return isFunction(arg) ? arg.call(context, idx, payload) : arg\n  }\n\n  $.isFunction = isFunction\n  $.isObject = isObject\n  $.isArray = isArray\n  $.isPlainObject = isPlainObject\n\n  $.inArray = function(elem, array, i){\n    return emptyArray.indexOf.call(array, elem, i)\n  }\n\n  $.trim = function(str) { return str.trim() }\n\n  // plugin compatibility\n  $.uuid = 0\n\n  $.map = function(elements, callback){\n    var value, values = [], i, key\n    if (likeArray(elements))\n      for (i = 0; i < elements.length; i++) {\n        value = callback(elements[i], i)\n        if (value != null) values.push(value)\n      }\n    else\n      for (key in elements) {\n        value = callback(elements[key], key)\n        if (value != null) values.push(value)\n      }\n    return flatten(values)\n  }\n\n  $.each = function(elements, callback){\n    var i, key\n    if (likeArray(elements)) {\n      for (i = 0; i < elements.length; i++)\n        if (callback.call(elements[i], i, elements[i]) === false) return elements\n    } else {\n      for (key in elements)\n        if (callback.call(elements[key], key, elements[key]) === false) return elements\n    }\n\n    return elements\n  }\n\n  // Define methods that will be available on all\n  // Zepto collections\n  $.fn = {\n    // Because a collection acts like an array\n    // copy over these useful array functions.\n    forEach: emptyArray.forEach,\n    reduce: emptyArray.reduce,\n    push: emptyArray.push,\n    indexOf: emptyArray.indexOf,\n    concat: emptyArray.concat,\n\n    // `map` and `slice` in the jQuery API work differently\n    // from their array counterparts\n    map: function(fn){\n      return $.map(this, function(el, i){ return fn.call(el, i, el) })\n    },\n    slice: function(){\n      return $(slice.apply(this, arguments))\n    },\n\n    ready: function(callback){\n      if (readyRE.test(document.readyState)) callback($)\n      else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)\n      return this\n    },\n    get: function(idx){\n      return idx === undefined ? slice.call(this) : this[idx]\n    },\n    toArray: function(){ return this.get() },\n    size: function(){\n      return this.length\n    },\n    remove: function(){\n      return this.each(function(){\n        if (this.parentNode != null)\n          this.parentNode.removeChild(this)\n      })\n    },\n    each: function(callback){\n      this.forEach(function(el, idx){ callback.call(el, idx, el) })\n      return this\n    },\n    filter: function(selector){\n      return $([].filter.call(this, function(element){\n        return zepto.matches(element, selector)\n      }))\n    },\n    add: function(selector,context){\n      return $(uniq(this.concat($(selector,context))))\n    },\n    is: function(selector){\n      return this.length > 0 && zepto.matches(this[0], selector)\n    },\n    not: function(selector){\n      var nodes=[]\n      if (isFunction(selector) && selector.call !== undefined)\n        this.each(function(idx){\n          if (!selector.call(this,idx)) nodes.push(this)\n        })\n      else {\n        var excludes = typeof selector == 'string' ? this.filter(selector) :\n          (likeArray(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector)\n        this.forEach(function(el){\n          if (excludes.indexOf(el) < 0) nodes.push(el)\n        })\n      }\n      return $(nodes)\n    },\n    eq: function(idx){\n      return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1)\n    },\n    first: function(){\n      var el = this[0]\n      return el && !isObject(el) ? el : $(el)\n    },\n    last: function(){\n      var el = this[this.length - 1]\n      return el && !isObject(el) ? el : $(el)\n    },\n    find: function(selector){\n      var result\n      if (this.length == 1) result = zepto.qsa(this[0], selector)\n      else result = this.map(function(){ return zepto.qsa(this, selector) })\n      return $(result)\n    },\n    closest: function(selector, context){\n      var node = this[0]\n      while (node && !zepto.matches(node, selector))\n        node = node !== context && node !== document && node.parentNode\n      return $(node)\n    },\n    parents: function(selector){\n      var ancestors = [], nodes = this\n      while (nodes.length > 0)\n        nodes = $.map(nodes, function(node){\n          if ((node = node.parentNode) && node !== document && ancestors.indexOf(node) < 0) {\n            ancestors.push(node)\n            return node\n          }\n        })\n      return filtered(ancestors, selector)\n    },\n    parent: function(selector){\n      return filtered(uniq(this.pluck('parentNode')), selector)\n    },\n    children: function(selector){\n      return filtered(this.map(function(){ return slice.call(this.children) }), selector)\n    },\n    siblings: function(selector){\n      return filtered(this.map(function(i, el){\n        return slice.call(el.parentNode.children).filter(function(child){ return child!==el })\n      }), selector)\n    },\n    empty: function(){\n      return this.each(function(){ this.innerHTML = '' })\n    },\n    // `pluck` is borrowed from Prototype.js\n    pluck: function(property){\n      return this.map(function(){ return this[property] })\n    },\n    show: function(){\n      return this.each(function(){\n        this.style.display == \"none\" && (this.style.display = null)\n        if (getComputedStyle(this, '').getPropertyValue(\"display\") == \"none\")\n          this.style.display = defaultDisplay(this.nodeName)\n      })\n    },\n    replaceWith: function(newContent){\n      return this.before(newContent).remove()\n    },\n    wrap: function(newContent){\n      return this.each(function(){\n        $(this).wrapAll($(newContent)[0].cloneNode(false))\n      })\n    },\n    wrapAll: function(newContent){\n      if (this[0]) {\n        $(this[0]).before(newContent = $(newContent))\n        newContent.append(this)\n      }\n      return this\n    },\n    unwrap: function(){\n      this.parent().each(function(){\n        $(this).replaceWith($(this).children())\n      })\n      return this\n    },\n    clone: function(){\n      return $(this.map(function(){ return this.cloneNode(true) }))\n    },\n    hide: function(){\n      return this.css(\"display\", \"none\")\n    },\n    toggle: function(setting){\n      return (setting === undefined ? this.css(\"display\") == \"none\" : setting) ? this.show() : this.hide()\n    },\n    prev: function(){ return $(this.pluck('previousElementSibling')) },\n    next: function(){ return $(this.pluck('nextElementSibling')) },\n    html: function(html){\n      return html === undefined ?\n        (this.length > 0 ? this[0].innerHTML : null) :\n        this.each(function(idx){\n          var originHtml = this.innerHTML\n          $(this).empty().append( funcArg(this, html, idx, originHtml) )\n        })\n    },\n    text: function(text){\n      return text === undefined ?\n        (this.length > 0 ? this[0].textContent : null) :\n        this.each(function(){ this.textContent = text })\n    },\n    attr: function(name, value){\n      var result\n      return (typeof name == 'string' && value === undefined) ?\n        (this.length == 0 || this[0].nodeType !== 1 ? undefined :\n          (name == 'value' && this[0].nodeName == 'INPUT') ? this.val() :\n          (!(result = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : result\n        ) :\n        this.each(function(idx){\n          if (this.nodeType !== 1) return\n          if (isObject(name)) for (key in name) this.setAttribute(key, name[key])\n          else this.setAttribute(name, funcArg(this, value, idx, this.getAttribute(name)))\n        })\n    },\n    removeAttr: function(name){\n      return this.each(function(){ if (this.nodeType === 1) this.removeAttribute(name) })\n    },\n    prop: function(name, value){\n      return (value === undefined) ?\n        (this[0] ? this[0][name] : undefined) :\n        this.each(function(idx){\n          this[name] = funcArg(this, value, idx, this[name])\n        })\n    },\n    data: function(name, value){\n      var data = this.attr('data-' + dasherize(name), value)\n      return data !== null ? data : undefined\n    },\n    val: function(value){\n      return (value === undefined) ?\n        (this.length > 0 ? this[0].value : undefined) :\n        this.each(function(idx){\n          this.value = funcArg(this, value, idx, this.value)\n        })\n    },\n    offset: function(){\n      if (this.length==0) return null\n      var obj = this[0].getBoundingClientRect()\n      return {\n        left: obj.left + window.pageXOffset,\n        top: obj.top + window.pageYOffset,\n        width: obj.width,\n        height: obj.height\n      }\n    },\n    css: function(property, value){\n      if (value === undefined && typeof property == 'string')\n        return (\n          this.length == 0\n            ? undefined\n            : this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))\n\n      var css = ''\n      for (key in property)\n        if(typeof property[key] == 'string' && property[key] == '')\n          this.each(function(){ this.style.removeProperty(dasherize(key)) })\n        else\n          css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'\n\n      if (typeof property == 'string')\n        if (value == '')\n          this.each(function(){ this.style.removeProperty(dasherize(property)) })\n        else\n          css = dasherize(property) + \":\" + maybeAddPx(property, value)\n\n      return this.each(function(){ this.style.cssText += ';' + css })\n    },\n    index: function(element){\n      return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0])\n    },\n    hasClass: function(name){\n      if (this.length < 1) return false\n      else return classRE(name).test(this[0].className)\n    },\n    addClass: function(name){\n      return this.each(function(idx){\n        classList = []\n        var cls = this.className, newName = funcArg(this, name, idx, cls)\n        newName.split(/\\s+/g).forEach(function(klass){\n          if (!$(this).hasClass(klass)) classList.push(klass)\n        }, this)\n        classList.length && (this.className += (cls ? \" \" : \"\") + classList.join(\" \"))\n      })\n    },\n    removeClass: function(name){\n      return this.each(function(idx){\n        if (name === undefined)\n          return this.className = ''\n        classList = this.className\n        funcArg(this, name, idx, classList).split(/\\s+/g).forEach(function(klass){\n          classList = classList.replace(classRE(klass), \" \")\n        })\n        this.className = classList.trim()\n      })\n    },\n    toggleClass: function(name, when){\n      return this.each(function(idx){\n        var newName = funcArg(this, name, idx, this.className)\n        ;(when === undefined ? !$(this).hasClass(newName) : when) ?\n          $(this).addClass(newName) : $(this).removeClass(newName)\n      })\n    }\n  }\n\n  // Generate the `width` and `height` functions\n  ;['width', 'height'].forEach(function(dimension){\n    $.fn[dimension] = function(value){\n      var offset, Dimension = dimension.replace(/./, function(m){ return m[0].toUpperCase() })\n      if (value === undefined) return this[0] == window ? window['inner' + Dimension] :\n        this[0] == document ? document.documentElement['offset' + Dimension] :\n        (offset = this.offset()) && offset[dimension]\n      else return this.each(function(idx){\n        var el = $(this)\n        el.css(dimension, funcArg(this, value, idx, el[dimension]()))\n      })\n    }\n  })\n\n  function insert(operator, target, node) {\n    var parent = (operator % 2) ? target : target.parentNode\n    parent ? parent.insertBefore(node,\n      !operator ? target.nextSibling :      // after\n      operator == 1 ? parent.firstChild :   // prepend\n      operator == 2 ? target :              // before\n      null) :                               // append\n      $(node).remove()\n  }\n\n  function traverseNode(node, fun) {\n    fun(node)\n    for (var key in node.childNodes) traverseNode(node.childNodes[key], fun)\n  }\n\n  // Generate the `after`, `prepend`, `before`, `append`,\n  // `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods.\n  adjacencyOperators.forEach(function(key, operator) {\n    $.fn[key] = function(){\n      // arguments can be nodes, arrays of nodes, Zepto objects and HTML strings\n      var nodes = $.map(arguments, function(n){ return isObject(n) ? n : zepto.fragment(n) })\n      if (nodes.length < 1) return this\n      var size = this.length, copyByClone = size > 1, inReverse = operator < 2\n\n      return this.each(function(index, target){\n        for (var i = 0; i < nodes.length; i++) {\n          var node = nodes[inReverse ? nodes.length-i-1 : i]\n          traverseNode(node, function(node){\n            if (node.nodeName != null && node.nodeName.toUpperCase() === 'SCRIPT' && (!node.type || node.type === 'text/javascript'))\n              window['eval'].call(window, node.innerHTML)\n          })\n          if (copyByClone && index < size - 1) node = node.cloneNode(true)\n          insert(operator, target, node)\n        }\n      })\n    }\n\n    $.fn[(operator % 2) ? key+'To' : 'insert'+(operator ? 'Before' : 'After')] = function(html){\n      $(html)[key](this)\n      return this\n    }\n  })\n\n  zepto.Z.prototype = $.fn\n\n  // Export internal API functions in the `$.zepto` namespace\n  zepto.camelize = camelize\n  zepto.uniq = uniq\n  $.zepto = zepto\n\n  return $\n})()\n\n// If `$` is not yet defined, point it to `Zepto`\nwindow.Zepto = Zepto\n'$' in window || (window.$ = Zepto)\n;(function($){\n  var $$ = $.zepto.qsa, handlers = {}, _zid = 1, specialEvents={}\n\n  specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents'\n\n  function zid(element) {\n    return element._zid || (element._zid = _zid++)\n  }\n  function findHandlers(element, event, fn, selector) {\n    event = parse(event)\n    if (event.ns) var matcher = matcherFor(event.ns)\n    return (handlers[zid(element)] || []).filter(function(handler) {\n      return handler\n        && (!event.e  || handler.e == event.e)\n        && (!event.ns || matcher.test(handler.ns))\n        && (!fn       || zid(handler.fn) === zid(fn))\n        && (!selector || handler.sel == selector)\n    })\n  }\n  function parse(event) {\n    var parts = ('' + event).split('.')\n    return {e: parts[0], ns: parts.slice(1).sort().join(' ')}\n  }\n  function matcherFor(ns) {\n    return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)')\n  }\n\n  function eachEvent(events, fn, iterator){\n    if ($.isObject(events)) $.each(events, iterator)\n    else events.split(/\\s/).forEach(function(type){ iterator(type, fn) })\n  }\n\n  function add(element, events, fn, selector, getDelegate, capture){\n    capture = !!capture\n    var id = zid(element), set = (handlers[id] || (handlers[id] = []))\n    eachEvent(events, fn, function(event, fn){\n      var delegate = getDelegate && getDelegate(fn, event),\n        callback = delegate || fn\n      var proxyfn = function (event) {\n        var result = callback.apply(element, [event].concat(event.data))\n        if (result === false) event.preventDefault()\n        return result\n      }\n      var handler = $.extend(parse(event), {fn: fn, proxy: proxyfn, sel: selector, del: delegate, i: set.length})\n      set.push(handler)\n      element.addEventListener(handler.e, proxyfn, capture)\n    })\n  }\n  function remove(element, events, fn, selector){\n    var id = zid(element)\n    eachEvent(events || '', fn, function(event, fn){\n      findHandlers(element, event, fn, selector).forEach(function(handler){\n        delete handlers[id][handler.i]\n        element.removeEventListener(handler.e, handler.proxy, false)\n      })\n    })\n  }\n\n  $.event = { add: add, remove: remove }\n\n  $.proxy = function(fn, context) {\n    if ($.isFunction(fn)) {\n      var proxyFn = function(){ return fn.apply(context, arguments) }\n      proxyFn._zid = zid(fn)\n      return proxyFn\n    } else if (typeof context == 'string') {\n      return $.proxy(fn[context], fn)\n    } else {\n      throw new TypeError(\"expected function\")\n    }\n  }\n\n  $.fn.bind = function(event, callback){\n    return this.each(function(){\n      add(this, event, callback)\n    })\n  }\n  $.fn.unbind = function(event, callback){\n    return this.each(function(){\n      remove(this, event, callback)\n    })\n  }\n  $.fn.one = function(event, callback){\n    return this.each(function(i, element){\n      add(this, event, callback, null, function(fn, type){\n        return function(){\n          var result = fn.apply(element, arguments)\n          remove(element, type, fn)\n          return result\n        }\n      })\n    })\n  }\n\n  var returnTrue = function(){return true},\n      returnFalse = function(){return false},\n      eventMethods = {\n        preventDefault: 'isDefaultPrevented',\n        stopImmediatePropagation: 'isImmediatePropagationStopped',\n        stopPropagation: 'isPropagationStopped'\n      }\n  function createProxy(event) {\n    var proxy = $.extend({originalEvent: event}, event)\n    $.each(eventMethods, function(name, predicate) {\n      proxy[name] = function(){\n        this[predicate] = returnTrue\n        return event[name].apply(event, arguments)\n      }\n      proxy[predicate] = returnFalse\n    })\n    return proxy\n  }\n\n  // emulates the 'defaultPrevented' property for browsers that have none\n  function fix(event) {\n    if (!('defaultPrevented' in event)) {\n      event.defaultPrevented = false\n      var prevent = event.preventDefault\n      event.preventDefault = function() {\n        this.defaultPrevented = true\n        prevent.call(this)\n      }\n    }\n  }\n\n  $.fn.delegate = function(selector, event, callback){\n    var capture = false\n    if(event == 'blur' || event == 'focus'){\n      if($.iswebkit)\n        event = event == 'blur' ? 'focusout' : event == 'focus' ? 'focusin' : event\n      else\n        capture = true\n    }\n\n    return this.each(function(i, element){\n      add(element, event, callback, selector, function(fn){\n        return function(e){\n          var evt, match = $(e.target).closest(selector, element).get(0)\n          if (match) {\n            evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element})\n            return fn.apply(match, [evt].concat([].slice.call(arguments, 1)))\n          }\n        }\n      }, capture)\n    })\n  }\n  $.fn.undelegate = function(selector, event, callback){\n    return this.each(function(){\n      remove(this, event, callback, selector)\n    })\n  }\n\n  $.fn.live = function(event, callback){\n    $(document.body).delegate(this.selector, event, callback)\n    return this\n  }\n  $.fn.die = function(event, callback){\n    $(document.body).undelegate(this.selector, event, callback)\n    return this\n  }\n\n  $.fn.on = function(event, selector, callback){\n    return selector == undefined || $.isFunction(selector) ?\n      this.bind(event, selector) : this.delegate(selector, event, callback)\n  }\n  $.fn.off = function(event, selector, callback){\n    return selector == undefined || $.isFunction(selector) ?\n      this.unbind(event, selector) : this.undelegate(selector, event, callback)\n  }\n\n  $.fn.trigger = function(event, data){\n    if (typeof event == 'string') event = $.Event(event)\n    fix(event)\n    event.data = data\n    return this.each(function(){\n      // items in the collection might not be DOM elements\n      // (todo: possibly support events on plain old objects)\n      if('dispatchEvent' in this) this.dispatchEvent(event)\n    })\n  }\n\n  // triggers event handlers on current element just as if an event occurred,\n  // doesn't trigger an actual event, doesn't bubble\n  $.fn.triggerHandler = function(event, data){\n    var e, result\n    this.each(function(i, element){\n      e = createProxy(typeof event == 'string' ? $.Event(event) : event)\n      e.data = data\n      e.target = element\n      $.each(findHandlers(element, event.type || event), function(i, handler){\n        result = handler.proxy(e)\n        if (e.isImmediatePropagationStopped()) return false\n      })\n    })\n    return result\n  }\n\n  // shortcut methods for `.bind(event, fn)` for each event type\n  ;('focusin focusout load resize scroll unload click dblclick '+\n  'mousedown mouseup mousemove mouseover mouseout '+\n  'change select keydown keypress keyup error').split(' ').forEach(function(event) {\n    $.fn[event] = function(callback){ return this.bind(event, callback) }\n  })\n\n  ;['focus', 'blur'].forEach(function(name) {\n    $.fn[name] = function(callback) {\n      if (callback) this.bind(name, callback)\n      else if (this.length) try { this.get(0)[name]() } catch(e){}\n      return this\n    }\n  })\n\n  $.Event = function(type, props) {\n    var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true\n    if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name])\n    event.initEvent(type, bubbles, true, null, null, null, null, null, null, null, null, null, null, null, null)\n    return event\n  }\n\n})(Zepto)\n;(function($){\n  function detect(ua){\n    var os = this.os = {}, browser = this.browser = {},\n      webkit = ua.match(/WebKit\\/([\\d.]+)/),\n      android = ua.match(/(Android)\\s+([\\d.]+)/),\n      ipad = ua.match(/(iPad).*OS\\s([\\d_]+)/),\n      iphone = !ipad && ua.match(/(iPhone\\sOS)\\s([\\d_]+)/),\n      webos = ua.match(/(webOS|hpwOS)[\\s\\/]([\\d.]+)/),\n      touchpad = webos && ua.match(/TouchPad/),\n      kindle = ua.match(/Kindle\\/([\\d.]+)/),\n      silk = ua.match(/Silk\\/([\\d._]+)/),\n      blackberry = ua.match(/(BlackBerry).*Version\\/([\\d.]+)/)\n\n    // todo clean this up with a better OS/browser\n    // separation. we need to discern between multiple\n    // browsers on android, and decide if kindle fire in\n    // silk mode is android or not\n\n    if (browser.webkit = !!webkit) browser.version = webkit[1]\n\n    if (android) os.android = true, os.version = android[2]\n    if (iphone) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.')\n    if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.')\n    if (webos) os.webos = true, os.version = webos[2]\n    if (touchpad) os.touchpad = true\n    if (blackberry) os.blackberry = true, os.version = blackberry[2]\n    if (kindle) os.kindle = true, os.version = kindle[1]\n    if (silk) browser.silk = true, browser.version = silk[1]\n    if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true\n  }\n\n  detect.call($, navigator.userAgent)\n  // make available to unit tests\n  $.__detect = detect\n\n})(Zepto)\n;(function($, undefined){\n  var prefix = '', eventPrefix, endEventName, endAnimationName,\n    vendors = { Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS' },\n    document = window.document, testEl = document.createElement('div'),\n    supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,\n    clearProperties = {}\n\n  function downcase(str) { return str.toLowerCase() }\n  function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) }\n\n  $.each(vendors, function(vendor, event){\n    if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {\n      prefix = '-' + downcase(vendor) + '-'\n      eventPrefix = event\n      return false\n    }\n  })\n\n  clearProperties[prefix + 'transition-property'] =\n  clearProperties[prefix + 'transition-duration'] =\n  clearProperties[prefix + 'transition-timing-function'] =\n  clearProperties[prefix + 'animation-name'] =\n  clearProperties[prefix + 'animation-duration'] = ''\n\n  $.fx = {\n    off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),\n    cssPrefix: prefix,\n    transitionEnd: normalizeEvent('TransitionEnd'),\n    animationEnd: normalizeEvent('AnimationEnd')\n  }\n\n  $.fn.animate = function(properties, duration, ease, callback){\n    if ($.isObject(duration))\n      ease = duration.easing, callback = duration.complete, duration = duration.duration\n    if (duration) duration = duration / 1000\n    return this.anim(properties, duration, ease, callback)\n  }\n\n  $.fn.anim = function(properties, duration, ease, callback){\n    var transforms, cssProperties = {}, key, that = this, wrappedCallback, endEvent = $.fx.transitionEnd\n    if (duration === undefined) duration = 0.4\n    if ($.fx.off) duration = 0\n\n    if (typeof properties == 'string') {\n      // keyframe animation\n      cssProperties[prefix + 'animation-name'] = properties\n      cssProperties[prefix + 'animation-duration'] = duration + 's'\n      endEvent = $.fx.animationEnd\n    } else {\n      // CSS transitions\n      for (key in properties)\n        if (supportedTransforms.test(key)) {\n          transforms || (transforms = [])\n          transforms.push(key + '(' + properties[key] + ')')\n        }\n        else cssProperties[key] = properties[key]\n\n      if (transforms) cssProperties[prefix + 'transform'] = transforms.join(' ')\n      if (!$.fx.off && typeof properties === 'object') {\n        cssProperties[prefix + 'transition-property'] = Object.keys(properties).join(', ')\n        cssProperties[prefix + 'transition-duration'] = duration + 's'\n        cssProperties[prefix + 'transition-timing-function'] = (ease || 'linear')\n      }\n    }\n\n    wrappedCallback = function(event){\n      if (typeof event !== 'undefined') {\n        if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from \"below\"\n        $(event.target).unbind(endEvent, arguments.callee)\n      }\n      $(this).css(clearProperties)\n      callback && callback.call(this)\n    }\n    if (duration > 0) this.bind(endEvent, wrappedCallback)\n\n    setTimeout(function() {\n      that.css(cssProperties)\n      if (duration <= 0) setTimeout(function() {\n        that.each(function(){ wrappedCallback.call(this) })\n      }, 0)\n    }, 0)\n\n    return this\n  }\n\n  testEl = null\n})(Zepto)\n;(function($){\n  var jsonpID = 0,\n      isObject = $.isObject,\n      document = window.document,\n      key,\n      name,\n      rscript = /<script\\b[^<]*(?:(?!<\\/script>)<[^<]*)*<\\/script>/gi,\n      scriptTypeRE = /^(?:text|application)\\/javascript/i,\n      xmlTypeRE = /^(?:text|application)\\/xml/i,\n      jsonType = 'application/json',\n      htmlType = 'text/html',\n      blankRE = /^\\s*$/\n\n  // trigger a custom event and return false if it was cancelled\n  function triggerAndReturn(context, eventName, data) {\n    var event = $.Event(eventName)\n    $(context).trigger(event, data)\n    return !event.defaultPrevented\n  }\n\n  // trigger an Ajax \"global\" event\n  function triggerGlobal(settings, context, eventName, data) {\n    if (settings.global) return triggerAndReturn(context || document, eventName, data)\n  }\n\n  // Number of active Ajax requests\n  $.active = 0\n\n  function ajaxStart(settings) {\n    if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart')\n  }\n  function ajaxStop(settings) {\n    if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop')\n  }\n\n  // triggers an extra global event \"ajaxBeforeSend\" that's like \"ajaxSend\" but cancelable\n  function ajaxBeforeSend(xhr, settings) {\n    var context = settings.context\n    if (settings.beforeSend.call(context, xhr, settings) === false ||\n        triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false)\n      return false\n\n    triggerGlobal(settings, context, 'ajaxSend', [xhr, settings])\n  }\n  function ajaxSuccess(data, xhr, settings) {\n    var context = settings.context, status = 'success'\n    settings.success.call(context, data, status, xhr)\n    triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data])\n    ajaxComplete(status, xhr, settings)\n  }\n  // type: \"timeout\", \"error\", \"abort\", \"parsererror\"\n  function ajaxError(error, type, xhr, settings) {\n    var context = settings.context\n    settings.error.call(context, xhr, type, error)\n    triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error])\n    ajaxComplete(type, xhr, settings)\n  }\n  // status: \"success\", \"notmodified\", \"error\", \"timeout\", \"abort\", \"parsererror\"\n  function ajaxComplete(status, xhr, settings) {\n    var context = settings.context\n    settings.complete.call(context, xhr, status)\n    triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings])\n    ajaxStop(settings)\n  }\n\n  // Empty function, used as default callback\n  function empty() {}\n\n  $.ajaxJSONP = function(options){\n    var callbackName = 'jsonp' + (++jsonpID),\n      script = document.createElement('script'),\n      abort = function(){\n        $(script).remove()\n        if (callbackName in window) window[callbackName] = empty\n        ajaxComplete('abort', xhr, options)\n      },\n      xhr = { abort: abort }, abortTimeout\n\n    if (options.error) script.onerror = function() {\n      xhr.abort()\n      options.error()\n    }\n\n    window[callbackName] = function(data){\n      clearTimeout(abortTimeout)\n      $(script).remove()\n      delete window[callbackName]\n      ajaxSuccess(data, xhr, options)\n    }\n\n    serializeData(options)\n    script.src = options.url.replace(/=\\?/, '=' + callbackName)\n    $('head').append(script)\n\n    if (options.timeout > 0) abortTimeout = setTimeout(function(){\n        xhr.abort()\n        ajaxComplete('timeout', xhr, options)\n      }, options.timeout)\n\n    return xhr\n  }\n\n  $.ajaxSettings = {\n    // Default type of request\n    type: 'GET',\n    // Callback that is executed before request\n    beforeSend: empty,\n    // Callback that is executed if the request succeeds\n    success: empty,\n    // Callback that is executed the the server drops error\n    error: empty,\n    // Callback that is executed on request complete (both: error and success)\n    complete: empty,\n    // The context for the callbacks\n    context: null,\n    // Whether to trigger \"global\" Ajax events\n    global: true,\n    // Transport\n    xhr: function () {\n      return new window.XMLHttpRequest()\n    },\n    // MIME types mapping\n    accepts: {\n      script: 'text/javascript, application/javascript',\n      json:   jsonType,\n      xml:    'application/xml, text/xml',\n      html:   htmlType,\n      text:   'text/plain'\n    },\n    // Whether the request is to another domain\n    crossDomain: false,\n    // Default timeout\n    timeout: 0\n  }\n\n  function mimeToDataType(mime) {\n    return mime && ( mime == htmlType ? 'html' :\n      mime == jsonType ? 'json' :\n      scriptTypeRE.test(mime) ? 'script' :\n      xmlTypeRE.test(mime) && 'xml' ) || 'text'\n  }\n\n  function appendQuery(url, query) {\n    return (url + '&' + query).replace(/[&?]{1,2}/, '?')\n  }\n\n  // serialize payload and append it to the URL for GET requests\n  function serializeData(options) {\n    if (isObject(options.data)) options.data = $.param(options.data)\n    if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))\n      options.url = appendQuery(options.url, options.data)\n  }\n\n  $.ajax = function(options){\n    var settings = $.extend({}, options || {})\n    for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]\n\n    ajaxStart(settings)\n\n    if (!settings.crossDomain) settings.crossDomain = /^([\\w-]+:)?\\/\\/([^\\/]+)/.test(settings.url) &&\n      RegExp.$2 != window.location.host\n\n    var dataType = settings.dataType, hasPlaceholder = /=\\?/.test(settings.url)\n    if (dataType == 'jsonp' || hasPlaceholder) {\n      if (!hasPlaceholder) settings.url = appendQuery(settings.url, 'callback=?')\n      return $.ajaxJSONP(settings)\n    }\n\n    if (!settings.url) settings.url = window.location.toString()\n    serializeData(settings)\n\n    var mime = settings.accepts[dataType],\n        baseHeaders = { },\n        protocol = /^([\\w-]+:)\\/\\//.test(settings.url) ? RegExp.$1 : window.location.protocol,\n        xhr = $.ajaxSettings.xhr(), abortTimeout\n\n    if (!settings.crossDomain) baseHeaders['X-Requested-With'] = 'XMLHttpRequest'\n    if (mime) {\n      baseHeaders['Accept'] = mime\n      if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0]\n      xhr.overrideMimeType && xhr.overrideMimeType(mime)\n    }\n    if (settings.contentType || (settings.data && settings.type.toUpperCase() != 'GET'))\n      baseHeaders['Content-Type'] = (settings.contentType || 'application/x-www-form-urlencoded')\n    settings.headers = $.extend(baseHeaders, settings.headers || {})\n\n    xhr.onreadystatechange = function(){\n      if (xhr.readyState == 4) {\n        clearTimeout(abortTimeout)\n        var result, error = false\n        if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {\n          dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'))\n          result = xhr.responseText\n\n          try {\n            if (dataType == 'script')    (1,eval)(result)\n            else if (dataType == 'xml')  result = xhr.responseXML\n            else if (dataType == 'json') result = blankRE.test(result) ? null : JSON.parse(result)\n          } catch (e) { error = e }\n\n          if (error) ajaxError(error, 'parsererror', xhr, settings)\n          else ajaxSuccess(result, xhr, settings)\n        } else {\n          ajaxError(null, 'error', xhr, settings)\n        }\n      }\n    }\n\n    var async = 'async' in settings ? settings.async : true\n    xhr.open(settings.type, settings.url, async)\n\n    for (name in settings.headers) xhr.setRequestHeader(name, settings.headers[name])\n\n    if (ajaxBeforeSend(xhr, settings) === false) {\n      xhr.abort()\n      return false\n    }\n\n    if (settings.timeout > 0) abortTimeout = setTimeout(function(){\n        xhr.onreadystatechange = empty\n        xhr.abort()\n        ajaxError(null, 'timeout', xhr, settings)\n      }, settings.timeout)\n\n    // avoid sending empty string (#319)\n    xhr.send(settings.data ? settings.data : null)\n    return xhr\n  }\n\n  $.get = function(url, success){ return $.ajax({ url: url, success: success }) }\n\n  $.post = function(url, data, success, dataType){\n    if ($.isFunction(data)) dataType = dataType || success, success = data, data = null\n    return $.ajax({ type: 'POST', url: url, data: data, success: success, dataType: dataType })\n  }\n\n  $.getJSON = function(url, success){\n    return $.ajax({ url: url, success: success, dataType: 'json' })\n  }\n\n  $.fn.load = function(url, success){\n    if (!this.length) return this\n    var self = this, parts = url.split(/\\s/), selector\n    if (parts.length > 1) url = parts[0], selector = parts[1]\n    $.get(url, function(response){\n      self.html(selector ?\n        $(document.createElement('div')).html(response.replace(rscript, \"\")).find(selector).html()\n        : response)\n      success && success.call(self)\n    })\n    return this\n  }\n\n  var escape = encodeURIComponent\n\n  function serialize(params, obj, traditional, scope){\n    var array = $.isArray(obj)\n    $.each(obj, function(key, value) {\n      if (scope) key = traditional ? scope : scope + '[' + (array ? '' : key) + ']'\n      // handle data in serializeArray() format\n      if (!scope && array) params.add(value.name, value.value)\n      // recurse into nested objects\n      else if (traditional ? $.isArray(value) : isObject(value))\n        serialize(params, value, traditional, key)\n      else params.add(key, value)\n    })\n  }\n\n  $.param = function(obj, traditional){\n    var params = []\n    params.add = function(k, v){ this.push(escape(k) + '=' + escape(v)) }\n    serialize(params, obj, traditional)\n    return params.join('&').replace('%20', '+')\n  }\n})(Zepto)\n;(function ($) {\n  $.fn.serializeArray = function () {\n    var result = [], el\n    $( Array.prototype.slice.call(this.get(0).elements) ).each(function () {\n      el = $(this)\n      var type = el.attr('type')\n      if (this.nodeName.toLowerCase() != 'fieldset' &&\n        !this.disabled && type != 'submit' && type != 'reset' && type != 'button' &&\n        ((type != 'radio' && type != 'checkbox') || this.checked))\n        result.push({\n          name: el.attr('name'),\n          value: el.val()\n        })\n    })\n    return result\n  }\n\n  $.fn.serialize = function () {\n    var result = []\n    this.serializeArray().forEach(function (elm) {\n      result.push( encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value) )\n    })\n    return result.join('&')\n  }\n\n  $.fn.submit = function (callback) {\n    if (callback) this.bind('submit', callback)\n    else if (this.length) {\n      var event = $.Event('submit')\n      this.eq(0).trigger(event)\n      if (!event.defaultPrevented) this.get(0).submit()\n    }\n    return this\n  }\n\n})(Zepto)\n;(function($){\n  var touch = {}, touchTimeout\n\n  function parentIfText(node){\n    return 'tagName' in node ? node : node.parentNode\n  }\n\n  function swipeDirection(x1, x2, y1, y2){\n    var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2)\n    return xDelta >= yDelta ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')\n  }\n\n  var longTapDelay = 750, longTapTimeout\n\n  function longTap(){\n    longTapTimeout = null\n    if (touch.last) {\n      touch.el.trigger('longTap')\n      touch = {}\n    }\n  }\n\n  function cancelLongTap(){\n    if (longTapTimeout) clearTimeout(longTapTimeout)\n    longTapTimeout = null\n  }\n\n  $(document).ready(function(){\n    var now, delta\n\n    $(document.body).bind('touchstart', function(e){\n      now = Date.now()\n      delta = now - (touch.last || now)\n      touch.el = $(parentIfText(e.touches[0].target))\n      touchTimeout && clearTimeout(touchTimeout)\n      touch.x1 = e.touches[0].pageX\n      touch.y1 = e.touches[0].pageY\n      if (delta > 0 && delta <= 250) touch.isDoubleTap = true\n      touch.last = now\n      longTapTimeout = setTimeout(longTap, longTapDelay)\n    }).bind('touchmove', function(e){\n      cancelLongTap()\n      touch.x2 = e.touches[0].pageX\n      touch.y2 = e.touches[0].pageY\n    }).bind('touchend', function(e){\n       cancelLongTap()\n\n      // double tap (tapped twice within 250ms)\n      if (touch.isDoubleTap) {\n        touch.el.trigger('doubleTap')\n        touch = {}\n\n      // swipe\n      } else if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) ||\n                 (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)) {\n        touch.el.trigger('swipe') &&\n          touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))\n        touch = {}\n\n      // normal tap\n      } else if ('last' in touch) {\n        touch.el.trigger('tap')\n\n        touchTimeout = setTimeout(function(){\n          touchTimeout = null\n          touch.el.trigger('singleTap')\n          touch = {}\n        }, 250)\n      }\n    }).bind('touchcancel', function(){\n      if (touchTimeout) clearTimeout(touchTimeout)\n      if (longTapTimeout) clearTimeout(longTapTimeout)\n      longTapTimeout = touchTimeout = null\n      touch = {}\n    })\n  })\n\n  ;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(m){\n    $.fn[m] = function(callback){ return this.bind(m, callback) }\n  })\n})(Zepto)"
  }
]